/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import { entries as entries$1 } from "../packages/utils/dist/entries.js";
import { textVariants } from "../packages/fixtures/dist/index.js";
import { FONT_FAMILY_PREFIX, FONT_SIZE_PREFIX, FONT_SLANT_PREFIX, FONT_WEIGHT_PREFIX, FONT_WIDTH_PREFIX, LETTER_SPACING_PREFIX, LINE_HEIGHT_PREFIX, TEXT_RESPONSIVE_BREAKPOINT_CLASSNAMES, TEXT_RESPONSIVE_CLASSNAME, TEXT_TRANSFORM_PREFIX } from "../packages/css-tokens/dist/index.js";
import { assertUnreachable } from "../packages/utils/dist/assertUnreachable.js";
import { isString } from "lodash-es";
//#region ../tailwind-internal/dist/components/getResponsiveTextStyles.js
/*! © 2026 Yahoo, Inc. UDS Tailwind Internal v0.0.0-development */
const textVariantsSafe = (variant) => variant.replace("/", "-");
const BASE_SIZE = 16;
const toRem = (size) => `${size / BASE_SIZE}rem`;
const mapClassNames = (name) => "." + TEXT_RESPONSIVE_BREAKPOINT_CLASSNAMES[name];
const getValue = (config, variant, key, breakpoint) => {
	const data = config.typography[variant]?.[key];
	if (!data) throw new Error(`Missing typography data for variant "${variant}" and key "${key}"`);
	const value = breakpoint === "base" ? data.base : data.breakpoints?.[breakpoint];
	if (!value) throw new Error(`Missing value for variant "${variant}", key "${key}", and breakpoint "${breakpoint}"`);
	if (isString(value)) return value;
	switch (value.type) {
		case "px": return toRem(value.value);
		case "unitless": return String(value.value);
	}
	return assertUnreachable(value);
};
const convertFontAlias = (config, value) => {
	if (value in config.font) return `var(--${FONT_FAMILY_PREFIX}-${value})`;
	return value;
};
const cssVariablesForBreakpoint = (config, breakpoint) => Object.fromEntries(textVariants.flatMap((variant) => {
	const safeVariant = textVariantsSafe(variant);
	return [
		[`--${FONT_FAMILY_PREFIX}-${safeVariant}`, convertFontAlias(config, getValue(config, variant, "fontFamily", breakpoint))],
		[`--${FONT_SIZE_PREFIX}-${safeVariant}`, getValue(config, variant, "fontSize", breakpoint)],
		[`--${FONT_WEIGHT_PREFIX}-${safeVariant}`, getValue(config, variant, "fontWeight", breakpoint)],
		[`--${FONT_SLANT_PREFIX}-${safeVariant}`, getValue(config, variant, "fontSlant", breakpoint)],
		[`--${FONT_WIDTH_PREFIX}-${safeVariant}`, getValue(config, variant, "fontWidth", breakpoint)],
		[`--${LINE_HEIGHT_PREFIX}-${safeVariant}`, getValue(config, variant, "lineHeight", breakpoint)],
		[`--${TEXT_TRANSFORM_PREFIX}-${safeVariant}`, getValue(config, variant, "textTransform", breakpoint)],
		[`--${LETTER_SPACING_PREFIX}-${safeVariant}`, getValue(config, variant, "letterSpacing", breakpoint)]
	];
}));
const tailwindConfigPerVariant = (prefix) => Object.fromEntries(textVariants.map(textVariantsSafe).map((variant) => [variant, `var(--${prefix}-${variant})`]));
const RESPONSIVE_TAILWIND_CONFIG_MAP = {
	fontFamily: tailwindConfigPerVariant(FONT_FAMILY_PREFIX),
	fontWeight: tailwindConfigPerVariant(FONT_WEIGHT_PREFIX),
	fontSlant: tailwindConfigPerVariant(FONT_SLANT_PREFIX),
	fontWidth: tailwindConfigPerVariant(FONT_WIDTH_PREFIX),
	fontSize: tailwindConfigPerVariant(FONT_SIZE_PREFIX),
	lineHeight: tailwindConfigPerVariant(LINE_HEIGHT_PREFIX),
	textTransform: tailwindConfigPerVariant(TEXT_TRANSFORM_PREFIX),
	letterSpacing: tailwindConfigPerVariant(LETTER_SPACING_PREFIX)
};
const getBaseTextVars = (config) => {
	return cssVariablesForBreakpoint(config, "base");
};
const getResponsiveTextStyles = (config) => {
	const breakpoints = entries$1(config.breakpoints).sort(([, { value: minWidthA }], [, { value: minWidthB }]) => minWidthA - minWidthB);
	return {
		[`.${TEXT_RESPONSIVE_CLASSNAME}`]: Object.fromEntries(breakpoints.map(([name, { value: minWidth }]) => [`@media (min-width: ${minWidth}px)`, cssVariablesForBreakpoint(config, name)])),
		[mapClassNames("base")]: cssVariablesForBreakpoint(config, "base"),
		[mapClassNames("defaultBreakpoint")]: cssVariablesForBreakpoint(config, config.globalDefaults.breakpoint),
		...Object.fromEntries(breakpoints.map(([name]) => [mapClassNames(name), cssVariablesForBreakpoint(config, name)]))
	};
};
//#endregion
export { RESPONSIVE_TAILWIND_CONFIG_MAP, getBaseTextVars, getResponsiveTextStyles, textVariantsSafe };
