/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
const require_safelist = require("../packages/icons/src/safelist.cjs");
const require_utils = require("../css/utils.cjs");
const require_postcssPreserveVars = require("../../../tailwind-internal/dist/utils/postcssPreserveVars.cjs");
let postcss_prune_var = require("postcss-prune-var");
postcss_prune_var = require_runtime.__toESM(postcss_prune_var, 1);
//#region ../css/dist/postcss/pruneVars.mjs
/*! © 2026 Yahoo, Inc. UDS CSS v0.0.0-development */
/**
* Build the preserve → prune → cleanup PostCSS plugin sequence used to remove
* unused CSS variables. Used internally by the `uds css` command; consumers
* should use {@link udsPruneVars} instead.
*/
const getPruneVarPlugins = (safeVarPrefixes) => {
	if (safeVarPrefixes.length === 0) return [(0, postcss_prune_var.default)()];
	return [
		require_postcssPreserveVars.preserveVars({ preserve: safeVarPrefixes }),
		(0, postcss_prune_var.default)(),
		require_postcssPreserveVars.preserveVarsCleanup()
	];
};
/**
* Ready-to-use PostCSS plugin that removes unused UDS token CSS variables
* (and any other unused CSS variables) from generated CSS.
*
* Runtime-configurable UDS variables and icon color variables are always
* preserved. Additional variables can be preserved via the `safelist` option
* using string prefixes or regular expressions.
*
* Must run after all CSS has been generated (e.g. after Tailwind).
*
* @example
* ```js
* // postcss.config.js
* const { udsPruneVars } = require('@yahoo/uds/postcss');
*
* module.exports = {
*   plugins: [udsPruneVars({ safelist: ['--app-theme-'] })],
* };
* ```
*/
const udsPruneVars = (options = {}) => ({
	postcssPlugin: "uds-prune-vars",
	plugins: getPruneVarPlugins([
		...require_utils.getConfigurableCssVariables(),
		...require_safelist.iconPruneVarsSafelist,
		...options.safelist ?? []
	])
});
//#endregion
exports.getPruneVarPlugins = getPruneVarPlugins;
exports.udsPruneVars = udsPruneVars;
