/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
//#region src/css/postcss.helpers.ts
const COLOR_MODE_RE = /^(\.(uds-color-mode-(?:dark|light)))(\s+.+)?$/;
const escapeForRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const getScopedColorModeAlternativeSelector = (selector, scopeClass, variant = "descendant") => {
	const scopeMatch = selector.match(new RegExp(`^(${escapeForRegExp(scopeClass)})\\s+(.+)$`));
	if (!scopeMatch) return null;
	const colorModeMatch = scopeMatch[2].match(COLOR_MODE_RE);
	if (!colorModeMatch) return null;
	const colorModeClass = colorModeMatch[1];
	const rest = colorModeMatch[3] ?? "";
	return variant === "same-element" ? `${colorModeClass}${scopeClass}${rest}` : `${colorModeClass} ${scopeClass}${rest}`;
};
const buildScopedColorModeSelectorList = (ruleSelector, scopeClass) => {
	const selectors = ruleSelector.split(",").map((value) => value.trim());
	return selectors.reduce((acc, selector) => {
		const nextAltSelectors = [getScopedColorModeAlternativeSelector(selector, scopeClass), getScopedColorModeAlternativeSelector(selector, scopeClass, "same-element")].filter((value) => Boolean(value)).filter((altSelector) => !selectors.includes(altSelector) && !acc.includes(altSelector));
		return [
			...acc,
			selector,
			...nextAltSelectors
		];
	}, []).join(", ");
};

//#endregion
export { buildScopedColorModeSelectorList };
//# sourceMappingURL=postcss.helpers.js.map