/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
const require_properties = require("../packages/automated-config/dist/properties.cjs");
const require_hookMetadata = require("../runtimeConfig/hookMetadata.cjs");
//#region ../css/dist/css/utils.mjs
/*! © 2026 Yahoo, Inc. UDS CSS v0.0.0-development */
/**
* Extract variant defaults from a UniversalTokensConfig.
* Converts from config structure to a simpler lookup format.
* e.g., { button: { defaults: { size: 'md' } } } -> { Button: { size: 'md' } }
*/
const extractVariantDefaults = (config) => {
	const componentNameMap = {
		avatar: "Avatar",
		badge: "Badge",
		button: "Button",
		checkbox: "Checkbox",
		chip: "Chip",
		divider: "Divider",
		iconButton: "IconButton",
		input: "Input",
		link: "Link",
		menu: "Menu",
		radio: "Radio",
		switch: "Switch",
		tab: "Tab",
		tabs: "Tabs"
	};
	return Object.entries(config).reduce((acc, [configKey, componentConfig]) => {
		const pascalName = componentNameMap[configKey];
		if (!pascalName || !componentConfig || typeof componentConfig !== "object") return acc;
		const configWithDefaults = componentConfig;
		return configWithDefaults.defaults ? {
			...acc,
			[pascalName]: configWithDefaults.defaults
		} : acc;
	}, {});
};
const extractRuntimeConfigValues = (config) => {
	const values = {};
	const setRuntimeValue = (selector, value) => {
		if (!selector || value === void 0) return;
		values[selector] = value;
	};
	const bottomSheetBackgroundColor = require_hookMetadata.getRuntimeFieldTokenValue(config, "useBottomSheetConfig", "backgroundColor", { variant: "default" });
	if (bottomSheetBackgroundColor !== void 0) setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useBottomSheetConfig", "backgroundColor", { variant: "default" }), bottomSheetBackgroundColor);
	if (config.toast?.variables && config.toast?.defaults) {
		setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useToastConfig", "autoClose"), require_hookMetadata.getRuntimeFieldStaticValue("useToastConfig", "autoClose") ?? void 0);
		setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useToastConfig", "position"), require_hookMetadata.getRuntimeFieldStaticValue("useToastConfig", "position") ?? void 0);
		setRuntimeValue(require_hookMetadata.getRuntimeDefaultPropSelector("useToastConfig", "size"), require_hookMetadata.getRuntimeDefaultPropValue(config, "useToastConfig", "size"));
		setRuntimeValue(require_hookMetadata.getRuntimeDefaultPropSelector("useToastConfig", "variant"), require_hookMetadata.getRuntimeDefaultPropValue(config, "useToastConfig", "variant"));
		require_hookMetadata.getRuntimeSelectorParamValues("useToastConfig", "size").forEach((size) => {
			const textVariant = require_hookMetadata.getRuntimeFieldTokenValue(config, "useToastConfig", "textVariant", { size });
			const iconSize = require_hookMetadata.getRuntimeFieldTokenValue(config, "useToastConfig", "iconSize", { size });
			const buttonSize = require_hookMetadata.getRuntimeFieldTokenValue(config, "useToastConfig", "buttonSize", { size });
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useToastConfig", "textVariant", { size }), textVariant);
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useToastConfig", "iconSize", { size }), iconSize);
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useToastConfig", "buttonSize", { size }), buttonSize);
		});
		require_hookMetadata.getRuntimeSelectorParamValues("useToastConfig", "variant").forEach((variant) => {
			const textColor = require_hookMetadata.getRuntimeFieldTokenValue(config, "useToastConfig", "textColor", { variant });
			const buttonVariant = require_hookMetadata.getRuntimeFieldTokenValue(config, "useToastConfig", "buttonVariant", { variant });
			const iconVariant = require_hookMetadata.getRuntimeFieldTokenValue(config, "useToastConfig", "iconVariant", { variant });
			const backgroundColor = require_hookMetadata.getRuntimeFieldTokenValue(config, "useToastConfig", "backgroundColor", { variant });
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useToastConfig", "textColor", { variant }), textColor);
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useToastConfig", "buttonVariant", { variant }), buttonVariant);
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useToastConfig", "iconVariant", { variant }), iconVariant);
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useToastConfig", "backgroundColor", { variant }), backgroundColor);
		});
	}
	const tooltipBorderRadius = require_hookMetadata.getRuntimeFieldTokenValue(config, "useTooltipConfig", "borderRadius", { size: "default" });
	if (tooltipBorderRadius !== void 0) {
		setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useTooltipConfig", "animationDuration"), require_hookMetadata.getRuntimeFieldStaticValue("useTooltipConfig", "animationDuration") ?? void 0);
		setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useTooltipConfig", "placement"), require_hookMetadata.getRuntimeFieldStaticValue("useTooltipConfig", "placement") ?? void 0);
		setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useTooltipConfig", "borderRadius", { size: "default" }), tooltipBorderRadius);
	}
	if (config.popover?.variables && config.scaleMode?.medium) {
		setRuntimeValue(require_hookMetadata.getRuntimeDefaultPropSelector("usePopoverConfig", "size"), require_hookMetadata.getRuntimeDefaultPropValue(config, "usePopoverConfig", "size") ?? void 0);
		setRuntimeValue(require_hookMetadata.getRuntimeDefaultPropSelector("usePopoverConfig", "variant"), require_hookMetadata.getRuntimeDefaultPropValue(config, "usePopoverConfig", "variant") ?? void 0);
		setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("usePopoverConfig", "animationDuration"), require_hookMetadata.getRuntimeFieldStaticValue("usePopoverConfig", "animationDuration") ?? void 0);
		setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("usePopoverConfig", "placement"), require_hookMetadata.getRuntimeFieldStaticValue("usePopoverConfig", "placement") ?? void 0);
		require_hookMetadata.getRuntimeSelectorParamValues("usePopoverConfig", "size").forEach((size) => {
			const borderRadius = require_hookMetadata.getRuntimeFieldTokenValue(config, "usePopoverConfig", "borderRadius", { size });
			const gap = require_hookMetadata.getRuntimeFieldTokenValue(config, "usePopoverConfig", "gap", { size });
			const spacingHorizontal = require_hookMetadata.getRuntimeFieldTokenValue(config, "usePopoverConfig", "spacingHorizontal", { size });
			const spacingVertical = require_hookMetadata.getRuntimeFieldTokenValue(config, "usePopoverConfig", "spacingVertical", { size });
			const dismissButtonSpacing = require_hookMetadata.getRuntimeFieldTokenValue(config, "usePopoverConfig", "dismissButtonSpacing", { size });
			const dismissIconSize = require_hookMetadata.getRuntimeFieldTokenValue(config, "usePopoverConfig", "dismissIconSize", { size });
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("usePopoverConfig", "borderRadius", { size }), borderRadius);
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("usePopoverConfig", "gap", { size }), gap);
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("usePopoverConfig", "spacingHorizontal", { size }), spacingHorizontal);
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("usePopoverConfig", "spacingVertical", { size }), spacingVertical);
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("usePopoverConfig", "dismissButtonSpacing", { size }), dismissButtonSpacing);
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("usePopoverConfig", "dismissIconSize", { size }), dismissIconSize);
		});
	}
	if (config.modal?.variables) {
		setRuntimeValue(require_hookMetadata.getRuntimeDefaultPropSelector("useModalConfig", "size"), require_hookMetadata.getRuntimeDefaultPropValue(config, "useModalConfig", "size") ?? void 0);
		setRuntimeValue(require_hookMetadata.getRuntimeDefaultPropSelector("useModalConfig", "variant"), require_hookMetadata.getRuntimeDefaultPropValue(config, "useModalConfig", "variant") ?? void 0);
		require_hookMetadata.getRuntimeSelectorParamValues("useModalConfig", "size").forEach((size) => {
			const gutter = require_hookMetadata.getRuntimeFieldTokenValue(config, "useModalConfig", "gutter", { size });
			setRuntimeValue(require_hookMetadata.getRuntimeFieldSelector("useModalConfig", "gutter", { size }), gutter);
		});
	}
	return values;
};
/**
* Format bytes to human readable string
*/
const formatBytes = (bytes) => {
	if (bytes < 1024) return `${bytes} B`;
	const kb = bytes / 1024;
	if (kb < 1024) return `${kb.toFixed(1)} KB`;
	return `${(kb / 1024).toFixed(2)} MB`;
};
/**
* Get motion CSS variable prefixes needed by a set of components.
* Looks up motionVarPrefixes from componentData.json for each component.
*/
const getMotionVarPrefixes = (componentData, components) => {
	const prefixes = components.flatMap((componentName) => {
		return componentData[componentName]?.motionVarPrefixes ?? [];
	});
	return [...new Set(prefixes)];
};
/**
* Collect css variable names exposed by configurable properties.
*/
const getConfigurableCssVariables = () => {
	const udsVarPrefix = "--uds";
	const cssVars = Object.values(require_properties.configurableProperties).flatMap(({ cssProperties }) => {
		if (typeof cssProperties === "string") return cssProperties.startsWith(udsVarPrefix) ? [cssProperties] : [];
		if (Array.isArray(cssProperties)) return cssProperties.filter((cssProperty) => typeof cssProperty === "string" && cssProperty.startsWith(udsVarPrefix));
		return [];
	});
	return [...new Set(["--uds-button-gap", ...cssVars])];
};
//#endregion
exports.extractRuntimeConfigValues = extractRuntimeConfigValues;
exports.extractVariantDefaults = extractVariantDefaults;
exports.formatBytes = formatBytes;
exports.getConfigurableCssVariables = getConfigurableCssVariables;
exports.getMotionVarPrefixes = getMotionVarPrefixes;
