/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import { shadowOffsetMap, shadowSpreadRadiusMap, spacingMap } from "../../fixtures/dist/index.js";
import { newAlwaysPalette } from "../../palette/dist/index.js";
//#region ../css/dist/packages/css-tokens/dist/index.mjs
/*! © 2026 Yahoo, Inc. UDS CSS v0.0.0-development */
/*! © 2026 Yahoo, Inc. UDS Motion Tokens v0.0.0-development */
const BORDER_RADIUS_PREFIX = `uds-border-radius`;
const DROP_SHADOW_PREFIX = `uds-drop-shadow`;
const BACKGROUND_BLUR_COLOR_PREFIX = `uds-background-blur-color`;
const BACKGROUND_BLUR_FALLBACK_COLOR_PREFIX = `uds-background-blur-fallback-color`;
const DARK_COLOR_MODE_CLASSNAME = `uds-color-mode-dark`;
const LIGHT_COLOR_MODE_CLASSNAME = `uds-color-mode-light`;
const BUTTON_SCALE_EFFECT = `--uds-button-scale-effect`;
`${BUTTON_SCALE_EFFECT}`;
`${BUTTON_SCALE_EFFECT}`;
`${BUTTON_SCALE_EFFECT}`;
/**
* These CSS utilities are temporarily housed here because they are shared
* dependencies between:
* - @yahoo/uds-automated-config (component automation/styling generation)
* - @yahoo/uds (tailwind plugin for shadow generation)
*
* Placing them in css-tokens avoids circular dependencies between these packages.
* TODO: Consider creating a dedicated shared utilities package if this grows.
*/
const textVariantsSafe = (variant) => variant.replace("/", "-");
function hexToRgb(hex) {
	hex = hex.replace("#", "");
	if (hex.length === 3) hex = hex.split("").map((char) => char + char).join("");
	return `${parseInt(hex.substring(0, 2), 16)} ${parseInt(hex.substring(2, 4), 16)} ${parseInt(hex.substring(4, 6), 16)}`;
}
const RGB = {
	white: hexToRgb(newAlwaysPalette["always/white"]),
	black: hexToRgb(newAlwaysPalette["always/black"]),
	brand: hexToRgb(newAlwaysPalette["always/brand"]),
	accent: hexToRgb(newAlwaysPalette["always/accent"])
};
const ALWAYS_AS_RGB = {
	black: RGB.black,
	white: RGB.white,
	"always/black": RGB.black,
	"always/white": RGB.white,
	"always/brand": RGB.brand,
	"always/accent": RGB.accent
};
/**
* Generate a single shadow value from a shadow preset configuration
*
* @param preset - The shadow preset configuration
* @param index - Optional index for numbered shadows (2-5)
* @param shadowType - The type of shadow (drop or inset)
* @returns A CSS box-shadow value string
*/
function getShadowLayerValue({ preset, prefix, shadowType, cssVarPrefix }) {
	const varPrefix = cssVarPrefix ?? `--uds-${shadowType}-shadow-`;
	const isPaletteColor = preset.color?.type === "palette";
	const isAlwaysColor = preset.color?.type === "always";
	let shadowColor = `var(--uds-${isPaletteColor ? "shadow" : "spectrum"}-color-${preset?.color?.value})`;
	if (isAlwaysColor) shadowColor = ALWAYS_AS_RGB[preset.color.value];
	const defaultColor = `var(${varPrefix}${prefix ? `${prefix}-` : ""}color, ${shadowColor})`;
	const cssValues = [
		`${shadowOffsetMap[preset.offsetX]}px`,
		`${shadowOffsetMap[preset.offsetY]}px`,
		`${spacingMap[preset.blur]}px`,
		`${shadowSpreadRadiusMap[preset.spread]}px`
	].map((value) => value).join(" ");
	const colorValue = `rgb(${defaultColor} / var(${varPrefix}${prefix ? `${prefix}-` : ""}opacity, ${Number(preset.opacity) / 100}))`;
	return `${shadowType === "inset" ? "inset " : ""}${cssValues} ${colorValue}`;
}
//#endregion
export { BACKGROUND_BLUR_COLOR_PREFIX, BACKGROUND_BLUR_FALLBACK_COLOR_PREFIX, BORDER_RADIUS_PREFIX, BUTTON_SCALE_EFFECT, DARK_COLOR_MODE_CLASSNAME, DROP_SHADOW_PREFIX, LIGHT_COLOR_MODE_CLASSNAME, getShadowLayerValue, textVariantsSafe };
