/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
require("../../../../../../_virtual/_rolldown/runtime.cjs");
const require_index = require("../../../css-tokens/dist/index.cjs");
const require_mapTextVariantFixtureToValue = require("../mapTextVariantFixtureToValue.cjs");
const require_properties = require("../properties.cjs");
const require_StateAxis = require("../types/StateAxis.cjs");
const require_componentStatePseudoStates = require("./componentStatePseudoStates.cjs");
const require_generateSchemaKey = require("./generateSchemaKey.cjs");
const require_resolvePropertyStates = require("./resolvePropertyStates.cjs");
const require_variantConfigGuards = require("./variantConfigGuards.cjs");
const require_buildConfigSchema = require("./buildConfigSchema.cjs");
const require_generateDefaultClassName = require("./generateDefaultClassName.cjs");
const require_getButtonControlHeight = require("./getButtonControlHeight.cjs");
const require_pseudoStateSelectors = require("./pseudoStateSelectors.cjs");
const require_resolveSlotByCascade = require("./resolveSlotByCascade.cjs");
let lodash_es = require("lodash-es");
//#region ../tailwind-internal/dist/packages/automated-config/dist/utils/index.js
/*! © 2026 Yahoo, Inc. UDS Tailwind Internal v0.0.0-development */
/*! © 2026 Yahoo, Inc. UDS Default Config v0.0.0-development */
const CSS_PADDING = "padding";
const PAGINATION_CONTROL_SIZE_VAR = "--uds-pagination-control-size";
const CSS_GAP = "gap";
const CSS_LINE_HEIGHT = "line-height";
const CSS_BORDER_WIDTH = "border-width";
const CSS_BORDER_RADIUS = "border-radius";
const CSS_BORDER_COLOR = "border-color";
const NESTED_BORDER_RADIUS_SIZE_VAR = "--uds-nested-border-radius-size";
const NESTED_BORDER_RADIUS_WIDTH_VAR = "--uds-nested-border-radius-width";
const CSS_BOX_SHADOW = "box-shadow";
const CSS_BORDER_TOP_WIDTH = "border-top-width";
const CSS_BORDER_RIGHT_WIDTH = "border-right-width";
const CSS_BORDER_BOTTOM_WIDTH = "border-bottom-width";
const CSS_BORDER_LEFT_WIDTH = "border-left-width";
const CSS_BORDER_TOP_COLOR = "border-top-color";
const CSS_BORDER_RIGHT_COLOR = "border-right-color";
const CSS_BORDER_BOTTOM_COLOR = "border-bottom-color";
const CSS_BORDER_LEFT_COLOR = "border-left-color";
const CSS_TAB_UNDERLINE_WIDTH = "--uds-tab-underline-width";
const CSS_TAB_UNDERLINE_COLOR = "--uds-tab-underline-color";
function deepMerge(target, source) {
	return (0, lodash_es.mergeWith)({}, target, source);
}
const COMPONENTS_WITH_SHADOW_BORDERS = [
	{
		componentName: "button",
		layer: "root"
	},
	{
		componentName: "iconbutton",
		layer: "root"
	},
	{
		componentName: "chip",
		layer: "root"
	},
	{
		componentName: "tab",
		layer: "root"
	},
	{
		componentName: "tabs",
		layer: "root"
	},
	{
		componentName: "pagination",
		layer: "root"
	}
];
/**
* Legacy state keys still used by unmigrated component configs via per-property
* `pseudoStates` arrays. They aren't in the new `StateAxis` taxonomy (so the
* resolver/StateBuilder don't auto-compose them) but they must remain in
* `KNOWN_STATE_KEYS` so the docs-mode map / configurator safelist still cover
* configs that emit them. Drop entries from this list as components migrate.
*/
const LEGACY_STATE_KEYS = [
	"disabled",
	"focused",
	"focused-keyboard",
	"selected"
];
/**
* Enumerates every canonical state key the system supports: rest, every atom,
* every modifier-subset (up to {@link MAX_MODIFIERS_PER_COMPOUND}) on its own
* and combined with each interactive, plus any legacy keys still in use.
*
* Mirrors `resolvePropertyStates` exactly so what the resolver pre-emits in
* the schema, what the StateBuilder lets users compose, and what the docs
* map / configurator safelist preserve are all the same set.
*/
function enumerateAllStateKeys() {
	const states = ["rest"];
	const atoms = [...require_StateAxis.INTERACTIVE_ATOMICS, ...require_StateAxis.MODIFIER_ATOMICS].sort(require_StateAxis.comparePriority);
	for (const stateKey of require_resolvePropertyStates.atomicAndCompoundStateKeys(atoms)) states.push(stateKey);
	for (const legacy of LEGACY_STATE_KEYS) states.push(legacy);
	return states;
}
const KNOWN_STATE_KEYS = enumerateAllStateKeys();
/**
* Lookup of every known state key to its index in `KNOWN_STATE_KEYS` — i.e. the
* resolver's emission order. The CSS generator iterates property-state maps
* in this order (instead of the alphabetical insertion order produced by
* `syncYosConfig`'s `normalizeConfig`), so cascade tie-breaking under the
* uniform per-atom specificity actually follows the priority chain. Unknown
* keys sort to the end.
*/
const KNOWN_STATE_RANK = new Map(KNOWN_STATE_KEYS.map((key, index) => [key, index]));
function compareStateKeys(a, b) {
	const ra = KNOWN_STATE_RANK.get(a) ?? Number.POSITIVE_INFINITY;
	const rb = KNOWN_STATE_RANK.get(b) ?? Number.POSITIVE_INFINITY;
	if (ra === rb) return a < b ? -1 : a > b ? 1 : 0;
	return ra - rb;
}
function buildStateRecord(transform) {
	const record = {};
	for (const key of KNOWN_STATE_KEYS) record[key] = transform(key);
	return record;
}
buildStateRecord(require_pseudoStateSelectors.getStateDocsClass);
/**
* Layout line-height for button root: icon size only (not textVariant line-height).
* @see getButtonContentLineHeight
*/
/**
* Shared pagination control content size: max(icon size, text line-height).
* Keeps page numbers and prev/next icons vertically centered when typography exceeds icon height.
*/
function getPaginationControlContentSize({ schema, iconLayerKey, textLayerKey, state, theme }) {
	const iconSizeValue = schema.variables?.[iconLayerKey]?.size?.[state]?.value;
	const textVariantValue = schema.variables?.[textLayerKey]?.textVariant?.[state]?.value;
	if (iconSizeValue && textVariantValue) return `max(${theme(require_properties.configurableProperties.iconSize.twThemePath("iconSizes", iconSizeValue))}, ${theme(require_mapTextVariantFixtureToValue.mapTextVariantFixtureToValue("lineHeight")("textVariants", textVariantValue))})`;
	if (iconSizeValue) return theme(require_properties.configurableProperties.iconSize.twThemePath("iconSizes", iconSizeValue));
	return "1em";
}
/**
* Shared pagination control size: padding on all sides plus max(icon size, line-height).
* Used for both width and height so page circles stay square for single-digit labels.
*/
function getPaginationControlSize({ padding, schema, iconLayerKey, textLayerKey, state, theme }) {
	return `calc(2 * ${padding} + ${getPaginationControlContentSize({
		schema,
		iconLayerKey,
		textLayerKey,
		state,
		theme
	})})`;
}
/**
* Forces button borders to use box-shadow instead of border properties.
* Converts border-width and border-color into an inset box-shadow layer.
*
* Why box-shadow for borders?
* - Respects border-radius (unlike outline which stays rectangular)
* - Allows layering multiple shadows in a single property
* - GPU-accelerated and performant
* - Works perfectly with rounded/circular buttons
*
* @param classStyles - The CSS declarations for a button class
* @returns Modified styles with box-shadow layers, or original if no border
*
* @example
* Input:  { border-width: '2px', border-color: 'red', box-shadow: '0 2px 4px rgba(0,0,0,0.1)' }
* Output: { box-shadow: 'inset 0 0 0 2px red, 0 2px 4px rgba(0,0,0,0.1)' }
* Renders borders using inset box-shadows instead of CSS border widths.
* This preserves visual borders without affecting layout dimensions.
*/
function applyBoxShadowBorder(classStyles) {
	const stripImportant = (value) => value.replace(/\s*!important\s*$/, "");
	const hasImportant = (value) => value?.includes("!important") ?? false;
	const isZeroWidth = (value) => !value || /^(0|0px|0rem|0em|0%)$/i.test(stripImportant(value).trim());
	const negateLength = (value) => {
		const normalized = stripImportant(value).trim();
		if (/^(0|0px|0rem|0em|0%)$/i.test(normalized)) return "0";
		return `calc(${normalized} * -1)`;
	};
	const borderWidth = classStyles[CSS_BORDER_WIDTH];
	const borderColor = classStyles[CSS_BORDER_COLOR];
	const topWidth = classStyles[CSS_BORDER_TOP_WIDTH] ?? borderWidth;
	const rightWidth = classStyles[CSS_BORDER_RIGHT_WIDTH] ?? borderWidth;
	const bottomWidth = classStyles[CSS_BORDER_BOTTOM_WIDTH] ?? borderWidth;
	const leftWidth = classStyles[CSS_BORDER_LEFT_WIDTH] ?? borderWidth;
	const topColor = classStyles[CSS_BORDER_TOP_COLOR] ?? borderColor;
	const rightColor = classStyles[CSS_BORDER_RIGHT_COLOR] ?? borderColor;
	const bottomColor = classStyles[CSS_BORDER_BOTTOM_COLOR] ?? borderColor;
	const leftColor = classStyles[CSS_BORDER_LEFT_COLOR] ?? borderColor;
	const borderLayers = [];
	const sidesWithBorder = [
		topWidth,
		rightWidth,
		bottomWidth,
		leftWidth
	].map((width, index) => {
		const color = [
			topColor,
			rightColor,
			bottomColor,
			leftColor
		][index];
		return {
			width: stripImportant(width ?? "").trim(),
			color: stripImportant(color ?? "").trim()
		};
	}).filter(({ width }) => !isZeroWidth(width));
	if (sidesWithBorder.length === 0) return classStyles;
	const uniformWidth = sidesWithBorder.every(({ width }) => width === sidesWithBorder[0].width);
	const uniformColor = sidesWithBorder.every(({ color }) => color && color === sidesWithBorder[0].color);
	const hasBorderWidthShorthand = borderWidth !== void 0 && !isZeroWidth(borderWidth);
	const allSidesBordered = sidesWithBorder.length === 4;
	if ((hasBorderWidthShorthand || allSidesBordered) && uniformWidth && uniformColor) {
		const { width, color } = sidesWithBorder[0];
		borderLayers.push(`inset 0 0 0 ${width} ${color}`);
	} else {
		if (!isZeroWidth(topWidth) && topColor) borderLayers.push(`inset 0 ${stripImportant(topWidth)} 0 0 ${stripImportant(topColor)}`);
		if (!isZeroWidth(rightWidth) && rightColor) borderLayers.push(`inset ${negateLength(rightWidth)} 0 0 0 ${stripImportant(rightColor)}`);
		if (!isZeroWidth(bottomWidth) && bottomColor) borderLayers.push(`inset 0 ${negateLength(bottomWidth)} 0 0 ${stripImportant(bottomColor)}`);
		if (!isZeroWidth(leftWidth) && leftColor) borderLayers.push(`inset ${stripImportant(leftWidth)} 0 0 0 ${stripImportant(leftColor)}`);
	}
	const layers = [...borderLayers, classStyles[CSS_BOX_SHADOW] && stripImportant(classStyles[CSS_BOX_SHADOW])].filter(Boolean);
	const needsImportant = hasImportant(topWidth) || hasImportant(rightWidth) || hasImportant(bottomWidth) || hasImportant(leftWidth) || hasImportant(topColor) || hasImportant(rightColor) || hasImportant(bottomColor) || hasImportant(leftColor) || hasImportant(borderWidth) || hasImportant(borderColor) || hasImportant(classStyles[CSS_BOX_SHADOW]);
	const newStyles = { ...classStyles };
	newStyles[CSS_BOX_SHADOW] = layers.join(", ") + (needsImportant ? " !important" : "");
	delete newStyles[CSS_BORDER_WIDTH];
	delete newStyles[CSS_BORDER_COLOR];
	delete newStyles[CSS_BORDER_TOP_WIDTH];
	delete newStyles[CSS_BORDER_RIGHT_WIDTH];
	delete newStyles[CSS_BORDER_BOTTOM_WIDTH];
	delete newStyles[CSS_BORDER_LEFT_WIDTH];
	delete newStyles[CSS_BORDER_TOP_COLOR];
	delete newStyles[CSS_BORDER_RIGHT_COLOR];
	delete newStyles[CSS_BORDER_BOTTOM_COLOR];
	delete newStyles[CSS_BORDER_LEFT_COLOR];
	return newStyles;
}
function generateClassName({ componentName, subComponentName, variantKey, variantValue, componentStateKey, componentStateValue, layer, layerOptionalPseudoSelector }) {
	let className = "";
	if (subComponentName) className = `uds-${componentName}-${subComponentName}-${variantKey}`.toLowerCase();
	else className = `uds-${componentName}-${variantKey}`.toLowerCase();
	if (variantValue) className = `${className}-${variantValue}`.toLowerCase();
	if (componentStateKey && componentStateValue) className = `${className}-${componentStateKey}-${componentStateValue}`.toLowerCase();
	className = `${className}-${layer}`.toLowerCase();
	if (layerOptionalPseudoSelector) className = `${className}${layerOptionalPseudoSelector}`;
	return className.replaceAll(/\s+/g, "-");
}
/**
* Select triggers carry `uds-ring-shadow` and draw focus via the focus-ring tokens.
* Input wrappers still use `focus-within` border styling, so exclude `.uds-ring` and
* `.uds-select-field-trigger` descendants from those rules.
*/
function getLayerClassSelector(layer, className, componentName, propertyStateSelector) {
	return componentName === "input" && (layer === "inputWrapperDynamic" || layer === "inputWrapper") && propertyStateSelector.includes("focus-within") ? `.${className}:not(.uds-ring):not(.uds-select-field-trigger)` : `.${className}`;
}
const getTheCssPropertyValue = (schema, theme, propertyName, schemaStateValue, existingValue, originalPropertyDefinition) => {
	const { value, type } = schemaStateValue;
	const propertyConfig = require_properties.configurableProperties[propertyName];
	let newValue;
	if (propertyConfig.customValueRenderer) newValue = propertyConfig.customValueRenderer(schemaStateValue, schema, theme, originalPropertyDefinition);
	else {
		const safeTwThemePath = propertyConfig.twThemePath;
		newValue = theme(safeTwThemePath(originalPropertyDefinition ? require_buildConfigSchema.findFixtureTypeForValue(originalPropertyDefinition, value) : type, String(value)));
	}
	if (propertyConfig.concatenate && existingValue) return `${existingValue}${propertyConfig.concatenationDelimiter || ", "}${newValue}`;
	return newValue;
};
/**
* Builds the per-state resolution map for a per-componentState OVERRIDE in
* exhaustive mode: the universal layer's state map with the override's ENABLED
* (and `rest`) slots layered on top. An unset or disabled override slot defers
* to the universal layer's value, so `resolveSlotByCascade` picks the
* most-specific *enabled* slot across both layers (override winning ties) rather
* than collapsing every unset state to the override's own `rest`.
*/
function mergeUniversalUnderOverride(universal, override) {
	const merged = { ...universal };
	const overrideRecord = override;
	for (const state of Object.keys(overrideRecord)) {
		const slot = overrideRecord[state];
		if (state === "rest" && slot?.isEnabled !== false || slot?.isEnabled === true) merged[state] = slot;
	}
	return merged;
}
/**
* Replays SELECTIVE emission for a STANDALONE atomicStates layer (no universal
* fallback) and returns the sparse set of slots it would emit: `rest`, every
* explicitly-enabled state, and every cascade-correction. Mirrors the inline
* selective decision in `generateDeclaration` — keep the two in lock-step.
*
* The override path seeds its own correction accumulator with this for the
* UNIVERSAL layer. Universal layers are emitted in a separate pass at the SAME
* specificity tier as their per-option overrides (see `bumpRootSpecificity`), so
* at runtime a universal rule wins wherever the override emits nothing. Without
* this seed, an override that flattens a state to `rest` (e.g. a `filled` help
* text that's `muted` everywhere) silently inherits the universal's brighter
* rule for that state in selective mode — a divergence from exhaustive, where
* the override emits every state explicitly. Seeding makes the override emit a
* correction whenever the universal would otherwise render a different value.
*/
function selectiveEmittedStates(stateMap, orderedStateKeys, emittableStates) {
	const emitted = { rest: stateMap.rest };
	for (const stateKey of orderedStateKeys) {
		if (stateKey === "rest" || !emittableStates.has(stateKey)) continue;
		const value = require_resolveSlotByCascade.resolveSlotByCascade(stateKey, stateMap);
		if (!value) continue;
		if (!(stateMap[stateKey]?.isEnabled === true)) {
			if (require_resolveSlotByCascade.resolveSlotByCascade(stateKey, emitted)?.value === value.value) continue;
		}
		emitted[stateKey] = {
			...value,
			isEnabled: true
		};
	}
	return emitted;
}
function generateDeclaration({ componentName, subComponentName, variantKey, variantValue, layer, layerOptionalPseudoSelector, componentStateKey, componentStateValue, schema, propertyKey, originalPropertyDefinition, declaredStates, layerUsesAtomicStates, theme, currentStyles, previewOptions, excludedPseudoStates = [], emit, fallbackStateMap, bumpRootSpecificity, buttonHeightReferenceSchema }) {
	const shouldUseExhaustive = (emit ?? "exhaustive") === "exhaustive" && layerUsesAtomicStates;
	const { cssProperties: configuredCssProperties, extendedProperties: configuredExtendedGetter } = require_properties.configurableProperties[originalPropertyDefinition.name];
	const configuredExtendedProperties = (0, lodash_es.isFunction)(configuredExtendedGetter) ? configuredExtendedGetter({
		componentName,
		subComponentName,
		layer,
		propertyKey
	}) : configuredExtendedGetter;
	if (!(typeof configuredCssProperties === "string" && configuredCssProperties.length > 0 || Array.isArray(configuredCssProperties) && configuredCssProperties.length > 0 || Array.isArray(configuredExtendedProperties) && configuredExtendedProperties.length > 0)) return {};
	const schemaKey = require_generateSchemaKey.generateSchemaKey({
		variantKey,
		variantValue,
		layer,
		subComponentName,
		componentStateKey,
		componentStateValue
	});
	let className = generateClassName({
		componentName,
		variantKey,
		variantValue,
		layer,
		subComponentName,
		componentStateKey,
		componentStateValue
	});
	const propertyStateMap = schema.variables?.[schemaKey]?.[propertyKey];
	if (!propertyStateMap) throw new Error(`Prop definition (${componentName} - ${schemaKey} - ${propertyKey}) not found, this is not expected, please report the bug to the UDS team`);
	const styles = {};
	const excludedStateSet = new Set(excludedPseudoStates);
	const emittableStates = new Set([...declaredStates].filter((state) => !excludedStateSet.has(state)));
	const orderedStateKeys = (shouldUseExhaustive || layerUsesAtomicStates ? [...emittableStates] : Object.keys(propertyStateMap)).sort(compareStateKeys);
	const resolutionStates = fallbackStateMap ? mergeUniversalUnderOverride(fallbackStateMap, propertyStateMap) : propertyStateMap;
	const emittedForSelective = layerUsesAtomicStates && !shouldUseExhaustive ? fallbackStateMap ? selectiveEmittedStates(fallbackStateMap, orderedStateKeys, emittableStates) : { rest: resolutionStates.rest } : {};
	for (const propStateStr of orderedStateKeys) {
		if (!emittableStates.has(propStateStr)) continue;
		const propertyState = propStateStr;
		let propertyStateSelector = require_pseudoStateSelectors.getStateSelector(propertyState);
		if (componentName === "selectitem" && propertyState === "focused") propertyStateSelector = ":is(:focus, [data-active-item])";
		const schemaValueForState = shouldUseExhaustive || layerUsesAtomicStates ? require_resolveSlotByCascade.resolveSlotByCascade(propStateStr, resolutionStates) : propertyStateMap[propertyState];
		if (!schemaValueForState) continue;
		if (!shouldUseExhaustive) {
			if (layerUsesAtomicStates) {
				const isExplicitlyEnabled = propertyStateMap[propertyState]?.isEnabled === true;
				if (propStateStr !== "rest" && !isExplicitlyEnabled) {
					if (require_resolveSlotByCascade.resolveSlotByCascade(propStateStr, emittedForSelective)?.value === schemaValueForState.value) continue;
				}
				emittedForSelective[propStateStr] = {
					...schemaValueForState,
					isEnabled: true
				};
			} else if (schemaValueForState.isEnabled === false) continue;
		}
		let fullClassName = ``;
		if (layer === "root") if (componentStateKey && componentStateValue) {
			const rootVariantClass = generateClassName({
				componentName,
				variantKey,
				variantValue,
				layer,
				subComponentName
			});
			className = generateClassName({
				componentName,
				variantKey,
				layer,
				subComponentName,
				componentStateKey,
				componentStateValue
			});
			fullClassName = `.${rootVariantClass}${propertyStateSelector}.${className}`;
		} else fullClassName = bumpRootSpecificity ? `.${className}.${className}${propertyStateSelector}` : `.${className}${propertyStateSelector}`;
		else {
			const rootVariantClassName = generateClassName({
				componentName,
				variantKey,
				variantValue,
				layer: "root",
				subComponentName
			});
			if (componentStateKey && componentStateValue) {
				const rootVariantClassNameWithComponentState = generateClassName({
					componentName,
					variantKey,
					layer: "root",
					subComponentName,
					componentStateKey,
					componentStateValue
				});
				className = generateClassName({
					componentName,
					variantKey,
					variantValue,
					layer,
					layerOptionalPseudoSelector,
					subComponentName
				});
				const layerClassSelector = getLayerClassSelector(layer, className, componentName, propertyStateSelector);
				fullClassName = `.${rootVariantClassName}${propertyStateSelector}.${rootVariantClassNameWithComponentState} ${layerClassSelector}`;
			} else {
				className = generateClassName({
					componentName,
					variantKey,
					variantValue,
					layer,
					layerOptionalPseudoSelector,
					subComponentName
				});
				const layerClassSelector = getLayerClassSelector(layer, className, componentName, propertyStateSelector);
				fullClassName = bumpRootSpecificity ? `.${rootVariantClassName}.${rootVariantClassName}${propertyStateSelector} ${layerClassSelector}` : `.${rootVariantClassName}${propertyStateSelector} ${layerClassSelector}`;
			}
		}
		const { cssProperties, extendedProperties: extendedPropertiesGetter } = require_properties.configurableProperties[originalPropertyDefinition.name];
		const cssDeclarations = {};
		const isExtendedPropertiesFunction = (0, lodash_es.isFunction)(extendedPropertiesGetter);
		const extendedProperties = isExtendedPropertiesFunction ? extendedPropertiesGetter({
			componentName,
			subComponentName,
			layer,
			propertyKey
		}) : extendedPropertiesGetter;
		if (extendedProperties && extendedProperties.length) {
			if (!isExtendedPropertiesFunction && (typeof cssProperties === "string" || Array.isArray(cssProperties) && cssProperties.length > 0)) throw new Error("Invalid configuration: cssProperties should not be configured when extendedProperties are defined. Please update your property configuration accordingly.");
			for (const extendedProp of extendedProperties) {
				const cssPropertiesRef = require_properties.configurableProperties[extendedProp].cssProperties;
				if (typeof cssPropertiesRef === "string") {
					const existingValue = currentStyles?.[fullClassName]?.[cssPropertiesRef];
					cssDeclarations[cssPropertiesRef] = getTheCssPropertyValue(schema, theme, extendedProp, schemaValueForState, existingValue);
				} else if (Array.isArray(cssPropertiesRef)) for (const cssProp of cssPropertiesRef) {
					const existingValue = currentStyles?.[fullClassName]?.[cssProp];
					cssDeclarations[cssProp] = getTheCssPropertyValue(schema, theme, extendedProp, schemaValueForState, existingValue);
				}
			}
		} else if (typeof cssProperties === "string") {
			const existingValue = currentStyles?.[fullClassName]?.[cssProperties];
			cssDeclarations[cssProperties] = getTheCssPropertyValue(schema, theme, originalPropertyDefinition.name, schemaValueForState, existingValue, originalPropertyDefinition);
		} else if (Array.isArray(cssProperties)) for (const cssProp of cssProperties) {
			const existingValue = currentStyles?.[fullClassName]?.[cssProp];
			cssDeclarations[cssProp] = getTheCssPropertyValue(schema, theme, originalPropertyDefinition.name, schemaValueForState, existingValue, originalPropertyDefinition);
		}
		/**
		* Button root layer workarounds & enhancements.
		* These handle Motion animation bridges and visual fixes until better config-to-component solutions exist.
		*/
		if (componentName === "button" && layer === "root") {
			if (propertyKey === CSS_GAP) cssDeclarations[require_index.BUTTON_GAP_VAR] = cssDeclarations[CSS_GAP];
			if (propertyKey === "spacingVertical") {
				const paddingVertical = cssDeclarations["padding-top"];
				if (paddingVertical) require_getButtonControlHeight.applyButtonControlHeightDeclarations({
					cssDeclarations,
					paddingVertical,
					schema,
					rootLayerKey: require_generateSchemaKey.generateSchemaKey({
						variantKey,
						variantValue,
						layer: "root",
						subComponentName
					}),
					iconLayerKey: require_generateSchemaKey.generateSchemaKey({
						variantKey,
						variantValue,
						layer: "icon",
						subComponentName
					}),
					state: propertyState,
					theme
				});
			}
			if (propertyKey === "scaleEffect" && propertyState === "hover") {
				const rootClassName = `.${className}`;
				const renderValue = (schemaValue) => require_properties.configurableProperties.scaleEffect.customValueRenderer?.(schemaValue, schema, () => "") ?? "1";
				if (!styles[rootClassName]) styles[rootClassName] = {};
				styles[rootClassName][require_index.BUTTON_SCALE_EFFECT_REST] = "1";
				if (propertyStateMap.hover) styles[rootClassName][require_index.BUTTON_SCALE_EFFECT_HOVER] = renderValue(propertyStateMap.hover);
				if (propertyStateMap.pressed) styles[rootClassName][require_index.BUTTON_SCALE_EFFECT_PRESSED] = renderValue(propertyStateMap.pressed);
			}
			if (cssDeclarations[CSS_LINE_HEIGHT]) cssDeclarations[CSS_LINE_HEIGHT] = require_getButtonControlHeight.getButtonContentLineHeight({
				schema,
				rootLayerKey: require_generateSchemaKey.generateSchemaKey({
					variantKey,
					variantValue,
					layer: "root",
					subComponentName
				}),
				iconLayerKey: require_generateSchemaKey.generateSchemaKey({
					variantKey,
					variantValue,
					layer: "icon",
					subComponentName
				}),
				state: propertyState,
				theme
			});
		}
		if (componentName === "iconbutton" && layer === "root") {
			if (propertyKey === "spacing") {
				const paddingVertical = cssDeclarations[CSS_PADDING];
				if (paddingVertical) require_getButtonControlHeight.applyIconButtonControlHeightDeclarations({
					cssDeclarations,
					paddingVertical,
					iconButtonSchema: schema,
					buttonHeightReferenceSchema,
					variantValue,
					iconLayerKey: require_generateSchemaKey.generateSchemaKey({
						variantKey,
						variantValue,
						layer: "icon",
						subComponentName
					}),
					state: propertyState,
					theme
				});
			}
		}
		if (componentName === "pagination" && layer === "item") {
			let padding;
			if (propertyKey === "spacing") padding = cssDeclarations[CSS_PADDING];
			else if (propertyKey === "paginationWidthVar") {
				const itemSchemaKey = require_generateSchemaKey.generateSchemaKey({
					variantKey,
					variantValue,
					layer: "item",
					subComponentName
				});
				const paddingValue = schema.variables?.[itemSchemaKey]?.spacing?.[propertyState]?.value;
				if (paddingValue) padding = theme(require_properties.configurableProperties.spacing.twThemePath("spacingAliases", paddingValue));
			}
			if (padding) {
				const iconLayerKey = require_generateSchemaKey.generateSchemaKey({
					variantKey,
					variantValue,
					layer: "icon",
					subComponentName
				});
				const textLayerKey = require_generateSchemaKey.generateSchemaKey({
					variantKey,
					variantValue,
					layer: "text",
					subComponentName
				});
				cssDeclarations[PAGINATION_CONTROL_SIZE_VAR] = getPaginationControlSize({
					padding,
					schema,
					iconLayerKey,
					textLayerKey,
					state: propertyState,
					theme
				});
			}
		}
		if (propertyKey === "borderRadius" && cssDeclarations[CSS_BORDER_RADIUS] && (componentName === "paddlenav" && layer === "root" || componentName === "input" && layer === "inputWrapperDynamic")) cssDeclarations[NESTED_BORDER_RADIUS_SIZE_VAR] = cssDeclarations[CSS_BORDER_RADIUS];
		if (componentName === "paddlenav" && layer === "root") {
			if (propertyKey === "borderWidth" && cssDeclarations[CSS_BORDER_WIDTH]) cssDeclarations[NESTED_BORDER_RADIUS_WIDTH_VAR] = cssDeclarations[CSS_BORDER_WIDTH];
		}
		if ((componentName === "tabs" || componentName === "tab") && layer === "root") {
			const schemaVariablesForKey = schema?.variables?.[schemaKey];
			if (propertyKey === "borderWidth" && schemaVariablesForKey?.underlineWidth) {
				const borderWidth = cssDeclarations[CSS_BORDER_WIDTH];
				if (borderWidth) {
					cssDeclarations[CSS_BORDER_TOP_WIDTH] = borderWidth;
					cssDeclarations[CSS_BORDER_RIGHT_WIDTH] = borderWidth;
					cssDeclarations[CSS_BORDER_BOTTOM_WIDTH] = borderWidth;
					cssDeclarations[CSS_BORDER_LEFT_WIDTH] = borderWidth;
					delete cssDeclarations[CSS_BORDER_WIDTH];
				}
			}
			if (propertyKey === "borderColor" && schemaVariablesForKey?.underlineColor) {
				const borderColor = cssDeclarations[CSS_BORDER_COLOR];
				if (borderColor) {
					cssDeclarations[CSS_BORDER_TOP_COLOR] = borderColor;
					cssDeclarations[CSS_BORDER_RIGHT_COLOR] = borderColor;
					cssDeclarations[CSS_BORDER_BOTTOM_COLOR] = borderColor;
					cssDeclarations[CSS_BORDER_LEFT_COLOR] = borderColor;
					delete cssDeclarations[CSS_BORDER_COLOR];
				}
			}
			if (propertyKey === "underlineWidth") {
				const underlineWidth = cssDeclarations[CSS_BORDER_BOTTOM_WIDTH];
				if (underlineWidth) {
					cssDeclarations[CSS_TAB_UNDERLINE_WIDTH] = underlineWidth;
					delete cssDeclarations[CSS_BORDER_BOTTOM_WIDTH];
				}
			}
			if (propertyKey === "underlineColor") {
				const underlineColor = cssDeclarations[CSS_BORDER_BOTTOM_COLOR];
				if (underlineColor) {
					cssDeclarations[CSS_TAB_UNDERLINE_COLOR] = underlineColor;
					delete cssDeclarations[CSS_BORDER_BOTTOM_COLOR];
				}
			}
		}
		if (!styles[fullClassName]) styles[fullClassName] = {
			...cssDeclarations,
			...styles[fullClassName]
		};
		if (previewOptions?.generatePseudoStateClassModifier) {
			const pseudoPrefixClass = require_pseudoStateSelectors.getStateDocsClass(propertyState);
			if (pseudoPrefixClass.length) {
				const importantCssDeclarations = Object.fromEntries(Object.entries(cssDeclarations).map(([prop, value]) => {
					const strValue = String(value).trimEnd().replace(/;$/, "");
					if (strValue.includes("!important")) return [prop, strValue];
					return [prop, `${strValue} !important`];
				}));
				styles[`.${pseudoPrefixClass}${fullClassName}`.replace(propertyStateSelector, "")] = {
					...importantCssDeclarations,
					...styles[`.${pseudoPrefixClass}${fullClassName}`.replace(propertyStateSelector, "")]
				};
			}
		}
	}
	return styles;
}
/**
* Emit CSS for per-state schema entries that target a variant's universal
* layers — the "override" path. Per-state schema entries can be authored by
* the Configurator (via `setConfigPseudoStateVariable`) or written by data
* migrations; they aren't declared in source configs.
*
* Iterates the cartesian product of `componentStates.X.options × universal
* layers × universal properties`. For each combination, calls
* `generateDeclaration` with the universal property's metadata plus the
* componentState key/value — the existing schema lookup inside
* `generateDeclaration` picks up the override slot if one exists and skips
* the property otherwise.
*/
function emitSchemaOverrideStyles({ componentName, subComponentName, variantKey, variantOption, variantConfig, schema, theme, previewOptions, emit, currentStyles }) {
	let styles = currentStyles;
	const universalLayers = variantConfig.layers;
	const componentStates = variantConfig.componentStates;
	if (!universalLayers || !componentStates) return styles;
	const variables = schema.variables;
	if (!variables) return styles;
	for (const componentStateKey in componentStates) {
		const componentState = componentStates[componentStateKey];
		for (const componentStateOption of componentState.options) for (const layerKey in universalLayers) {
			const universalLayer = universalLayers[layerKey];
			const schemaEntry = variables[require_generateSchemaKey.generateSchemaKey({
				variantKey,
				variantValue: variantOption,
				componentStateKey,
				componentStateValue: componentStateOption,
				layer: layerKey,
				subComponentName
			})];
			if (!schemaEntry) continue;
			for (const propertyKey in universalLayer.properties) {
				if (!schemaEntry[propertyKey]) continue;
				const originalPropertyDefinition = universalLayer.properties[propertyKey];
				const fallbackStateMap = variables[require_generateSchemaKey.generateSchemaKey({
					variantKey,
					variantValue: variantOption,
					layer: layerKey,
					subComponentName
				})]?.[propertyKey];
				const declarations = generateDeclaration({
					componentName,
					subComponentName,
					variantKey,
					variantValue: variantOption,
					componentStateKey,
					componentStateValue: componentStateOption,
					layer: layerKey,
					layerOptionalPseudoSelector: universalLayer.pseudoSelector,
					propertyKey,
					originalPropertyDefinition,
					declaredStates: new Set(require_resolvePropertyStates.resolvePropertyStates(universalLayer, originalPropertyDefinition)),
					layerUsesAtomicStates: (universalLayer.atomicStates?.length ?? 0) > 0,
					theme,
					schema,
					currentStyles: styles,
					previewOptions,
					emit,
					fallbackStateMap
				});
				styles = deepMerge(styles, declarations);
			}
		}
	}
	return styles;
}
/**
* Emit CSS for a set of layers without a component-state segment in the
* selector. Used by both `VariantConfigWithProperties` (where layers are the
* only source of styles) and `VariantConfigWithComponentStates` (where these
* layers express the variant's universal baseline, with per-state overrides
* winning via class-compound specificity).
*/
function emitUniversalLayers({ componentName, subComponentName, variantKey, variantOption, layers, schema, theme, previewOptions, emit, currentStyles, bumpRootSpecificity, buttonHeightReferenceSchema }) {
	let styles = currentStyles;
	const variables = schema.variables;
	for (const layerKey in layers) {
		const layer = layers[layerKey];
		const schemaKey = require_generateSchemaKey.generateSchemaKey({
			variantKey,
			variantValue: variantOption,
			layer: layerKey,
			subComponentName
		});
		const schemaEntry = variables?.[schemaKey];
		for (const propertyKey in layer.properties) {
			if (!schemaEntry || !schemaEntry[propertyKey]) continue;
			const originalPropertyDefinition = layer.properties[propertyKey];
			const declarations = generateDeclaration({
				componentName,
				subComponentName,
				variantKey,
				variantValue: variantOption,
				layer: layerKey,
				layerOptionalPseudoSelector: layer.pseudoSelector,
				propertyKey,
				originalPropertyDefinition,
				declaredStates: new Set(require_resolvePropertyStates.resolvePropertyStates(layer, originalPropertyDefinition)),
				layerUsesAtomicStates: (layer.atomicStates?.length ?? 0) > 0,
				theme,
				schema,
				currentStyles: styles,
				previewOptions,
				emit,
				bumpRootSpecificity,
				buttonHeightReferenceSchema
			});
			styles = deepMerge(styles, declarations);
		}
	}
	return styles;
}
function generateConfigStyles(config, schema, theme, previewOptions, emit, generateStylesContext) {
	const componentName = config.label.toLowerCase();
	let styles = {};
	for (const variantKey in config.variants) {
		const variantConfig = config.variants[variantKey];
		for (const variantOption of variantConfig.options) if (require_variantConfigGuards.isVariantConfigWithComponentStates(variantConfig)) {
			if (variantConfig.layers) styles = emitUniversalLayers({
				componentName,
				variantKey,
				variantOption,
				layers: variantConfig.layers,
				schema,
				theme,
				previewOptions,
				emit,
				currentStyles: styles,
				bumpRootSpecificity: true,
				buttonHeightReferenceSchema: generateStylesContext?.buttonHeightReferenceSchema
			});
			const componentStates = variantConfig.componentStates;
			for (const componentStateKey in componentStates) {
				const componentState = componentStates[componentStateKey];
				for (const componentStateOption of componentState.options) {
					const excludedPseudoStates = require_componentStatePseudoStates.getExcludedPseudoStatesForComponentStateOption(componentState, componentStateOption);
					const excludedLayers = new Set(require_componentStatePseudoStates.getExcludedLayersForComponentStateOption(componentState, componentStateOption));
					for (const layerKey in componentState.layers) {
						if (excludedLayers.has(layerKey)) continue;
						const layer = componentState.layers[layerKey];
						for (const propertyKey in layer.properties) {
							const originalPropertyDefinition = layer.properties[propertyKey];
							const declarations = generateDeclaration({
								componentName,
								variantKey,
								variantValue: variantOption,
								componentStateKey,
								componentStateValue: componentStateOption,
								layer: layerKey,
								layerOptionalPseudoSelector: layer.pseudoSelector,
								propertyKey,
								originalPropertyDefinition,
								declaredStates: new Set(require_resolvePropertyStates.resolvePropertyStates(layer, originalPropertyDefinition)),
								layerUsesAtomicStates: (layer.atomicStates?.length ?? 0) > 0,
								theme,
								schema,
								currentStyles: styles,
								previewOptions,
								excludedPseudoStates,
								emit,
								buttonHeightReferenceSchema: generateStylesContext?.buttonHeightReferenceSchema
							});
							styles = deepMerge(styles, declarations);
						}
					}
				}
			}
			styles = emitSchemaOverrideStyles({
				componentName,
				variantKey,
				variantOption,
				variantConfig,
				schema,
				theme,
				previewOptions,
				emit,
				currentStyles: styles
			});
		} else if (require_variantConfigGuards.isVariantConfigWithProperties(variantConfig)) styles = emitUniversalLayers({
			componentName,
			variantKey,
			variantOption,
			layers: variantConfig.layers,
			schema,
			theme,
			previewOptions,
			emit,
			currentStyles: styles,
			buttonHeightReferenceSchema: generateStylesContext?.buttonHeightReferenceSchema
		});
	}
	if (config.subComponents) {
		const { subComponents } = config;
		for (const subComponentKey in subComponents) for (const variantKey in subComponents[subComponentKey].variants) {
			const variantConfig = subComponents[subComponentKey].variants[variantKey];
			for (const variantOption of variantConfig.options) if (require_variantConfigGuards.isVariantConfigWithComponentStates(variantConfig)) {
				if (variantConfig.layers) styles = emitUniversalLayers({
					componentName,
					subComponentName: subComponentKey,
					variantKey,
					variantOption,
					layers: variantConfig.layers,
					schema,
					theme,
					previewOptions,
					emit,
					currentStyles: styles,
					bumpRootSpecificity: true,
					buttonHeightReferenceSchema: generateStylesContext?.buttonHeightReferenceSchema
				});
				const componentStates = variantConfig.componentStates;
				for (const componentStateKey in componentStates) {
					const componentState = componentStates[componentStateKey];
					for (const componentStateOption of componentState.options) {
						const excludedPseudoStates = require_componentStatePseudoStates.getExcludedPseudoStatesForComponentStateOption(componentState, componentStateOption);
						const excludedLayers = new Set(require_componentStatePseudoStates.getExcludedLayersForComponentStateOption(componentState, componentStateOption));
						for (const layerKey in componentState.layers) {
							if (excludedLayers.has(layerKey)) continue;
							const layer = componentState.layers[layerKey];
							for (const propertyKey in layer.properties) {
								const originalPropertyDefinition = layer.properties[propertyKey];
								const declarations = generateDeclaration({
									componentName,
									variantKey,
									variantValue: variantOption,
									componentStateKey,
									componentStateValue: componentStateOption,
									subComponentName: subComponentKey,
									layer: layerKey,
									layerOptionalPseudoSelector: layer.pseudoSelector,
									propertyKey,
									originalPropertyDefinition,
									declaredStates: new Set(require_resolvePropertyStates.resolvePropertyStates(layer, originalPropertyDefinition)),
									layerUsesAtomicStates: (layer.atomicStates?.length ?? 0) > 0,
									theme,
									schema,
									currentStyles: styles,
									previewOptions,
									excludedPseudoStates,
									emit,
									buttonHeightReferenceSchema: generateStylesContext?.buttonHeightReferenceSchema
								});
								styles = deepMerge(styles, declarations);
							}
						}
					}
				}
				styles = emitSchemaOverrideStyles({
					componentName,
					subComponentName: subComponentKey,
					variantKey,
					variantOption,
					variantConfig,
					schema,
					theme,
					previewOptions,
					emit,
					currentStyles: styles
				});
			} else if (require_variantConfigGuards.isVariantConfigWithProperties(variantConfig)) styles = emitUniversalLayers({
				componentName,
				subComponentName: subComponentKey,
				variantKey,
				variantOption,
				layers: variantConfig.layers,
				schema,
				theme,
				previewOptions,
				emit,
				currentStyles: styles,
				buttonHeightReferenceSchema: generateStylesContext?.buttonHeightReferenceSchema
			});
		}
	}
	/**
	* Post-process button/iconbutton styles to force box-shadow for borders.
	* This runs AFTER all properties have been processed and merged.
	*/
	const toApply = COMPONENTS_WITH_SHADOW_BORDERS.find((c) => c.componentName === componentName);
	if (toApply) {
		for (const className in styles) if (className.includes(`-${toApply.layer}`.toLowerCase())) {
			const raw = styles[className];
			if (toApply.componentName === "tab") {
				const tabUnderlineWidth = raw[CSS_TAB_UNDERLINE_WIDTH];
				const tabUnderlineColor = raw[CSS_TAB_UNDERLINE_COLOR];
				const withoutTabUnderline = { ...raw };
				delete withoutTabUnderline[CSS_TAB_UNDERLINE_WIDTH];
				delete withoutTabUnderline[CSS_TAB_UNDERLINE_COLOR];
				const merged = applyBoxShadowBorder(withoutTabUnderline);
				if (tabUnderlineWidth !== void 0) merged[CSS_TAB_UNDERLINE_WIDTH] = tabUnderlineWidth;
				if (tabUnderlineColor !== void 0) merged[CSS_TAB_UNDERLINE_COLOR] = tabUnderlineColor;
				styles[className] = merged;
			} else styles[className] = applyBoxShadowBorder(raw);
		}
	}
	return styles;
}
/**
* @param config - Component configuration (Button, IconButton, etc.)
* @param schema - Production schema with defaults and variables
* @param theme - Tailwind theme function to resolve design tokens
* @param previewOptions - Options for generating preview mode class modifiers
* @returns CSS styles object with grouped selectors for default aliases
*/
const generateStylesInner = (config, schema, theme, previewOptions, generateStylesContext) => {
	const styles = generateConfigStyles(config, schema, theme, previewOptions, previewOptions.emit ?? "exhaustive", generateStylesContext);
	if (!config.variants && !config.subComponents) return styles;
	const componentName = config.label.toLowerCase();
	if (componentName !== "button" && componentName !== "iconbutton") return styles;
	const replacementMap = /* @__PURE__ */ new Map();
	/**
	* Helper: Extract all layer keys from a variant configuration
	* Handles both simple variants (with direct layers) and variants with component states
	* (which may additionally declare top-level universal layers).
	*/
	const getLayerKeys = (variantConfig) => {
		if (require_variantConfigGuards.isVariantConfigWithComponentStates(variantConfig)) {
			const layerKeysSet = /* @__PURE__ */ new Set();
			for (const componentStateConfig of Object.values(variantConfig.componentStates)) Object.keys(componentStateConfig.layers ?? {}).forEach((key) => layerKeysSet.add(key));
			if (variantConfig.layers) Object.keys(variantConfig.layers).forEach((key) => layerKeysSet.add(key));
			return Array.from(layerKeysSet);
		} else if (require_variantConfigGuards.isVariantConfigWithProperties(variantConfig)) return Object.keys(variantConfig.layers);
		return [];
	};
	/**
	* Helper: Build replacement map for default variant values
	* For each default variant + layer combination, creates an entry like:
	*   "uds-button-size-sm-root" → ".uds-button-size-sm-root, .uds-button-size-default-root"
	*/
	const buildReplacements = (variants, subComponentName) => {
		for (const [variantType, variantConfig] of Object.entries(variants)) {
			if (!require_variantConfigGuards.isVariantConfigWithProperties(variantConfig) && !require_variantConfigGuards.isVariantConfigWithComponentStates(variantConfig)) continue;
			const layerKeys = getLayerKeys(variantConfig);
			if (layerKeys.length) {
				const defaultValue = schema.defaults?.[variantType];
				if (defaultValue) for (const layerKey of layerKeys) {
					const baseClass = generateClassName({
						componentName,
						variantKey: variantType,
						variantValue: defaultValue,
						layer: layerKey,
						subComponentName
					});
					const defaultClass = require_generateDefaultClassName.generateDefaultClassName(componentName, variantType, layerKey, subComponentName);
					replacementMap.set(baseClass, `.${baseClass}, .${defaultClass}`);
				}
			}
		}
	};
	if (config.variants) buildReplacements(config.variants);
	if (config.subComponents) for (const [subComponentName, subComponentConfig] of Object.entries(config.subComponents)) buildReplacements(subComponentConfig.variants, subComponentName);
	const finalStyles = {};
	for (const [selector, declarations] of Object.entries(styles)) {
		let defaultsSelector = selector;
		let hasMatch = false;
		for (const [defaultVariantClass, replacement] of replacementMap.entries()) if (selector.includes(defaultVariantClass)) {
			hasMatch = true;
			const defaultMatch = replacement.match(/,\s*\.([a-z0-9-]+)/);
			if (defaultMatch) {
				const defaultClass = defaultMatch[1];
				defaultsSelector = defaultsSelector.replaceAll(defaultVariantClass, defaultClass);
			}
		}
		if (!hasMatch) {
			finalStyles[selector] = declarations;
			continue;
		}
		finalStyles[`${selector}, ${defaultsSelector}`] = declarations;
	}
	return finalStyles;
};
/**
* Public entry point. Generates a component's CSS, emitting each declared state
* as its own rule (one selector per rule) so the cascade is carried entirely by
* per-rule specificity — which CSS minifiers preserve.
*
* An earlier optimization merged rules sharing a declaration block into a single
* comma-separated selector list (to avoid repeating invariant declarations per
* state). It was removed: a minifier's forgiving-`:is()` rewrite — applied to a
* comma-separated list that contains `:has()` when targeting browsers without
* native `:has()` support — collapses the list to its single highest
* specificity, inflating the weakest selector (`rest`) above genuinely
* customized states and corrupting the cascade. Separate rules never form such a
* list, so minifiers leave their specificity intact. (gzip already collapses the
* repeated declaration blocks, so the shipped-size cost is minimal.)
*/
const generateStyles = (config, schema, theme, previewOptions, generateStylesContext) => generateStylesInner(config, schema, theme, previewOptions, generateStylesContext);
//#endregion
exports.generateStyles = generateStyles;
