/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-1fc5ad1 | Cube Dev Team */
import { parseStyle } from "../utils/styles.js";

//#region src/tasty/styles/fill.ts
function fillStyle({ fill, backgroundColor, image, backgroundImage, backgroundPosition, backgroundSize, backgroundRepeat, backgroundAttachment, backgroundOrigin, backgroundClip, background }) {
	if (background) return { background: parseStyle(background).output || background };
	const result = {};
	const colorValue = backgroundColor ?? fill;
	if (colorValue) {
		const parsed = parseStyle(colorValue);
		const firstColor = parsed.groups[0]?.colors[0];
		const secondColor = parsed.groups[0]?.colors[1];
		result["background-color"] = firstColor || colorValue;
		if (secondColor && !backgroundImage && !image) {
			result["--tasty-second-fill-color"] = secondColor;
			result["background-image"] = "linear-gradient(var(--tasty-second-fill-color), var(--tasty-second-fill-color))";
		}
	}
	const imageValue = backgroundImage ?? image;
	if (imageValue) result["background-image"] = parseStyle(imageValue).output || imageValue;
	if (backgroundPosition) result["background-position"] = parseStyle(backgroundPosition).output || backgroundPosition;
	if (backgroundSize) result["background-size"] = parseStyle(backgroundSize).output || backgroundSize;
	if (backgroundRepeat) result["background-repeat"] = backgroundRepeat;
	if (backgroundAttachment) result["background-attachment"] = backgroundAttachment;
	if (backgroundOrigin) result["background-origin"] = backgroundOrigin;
	if (backgroundClip) result["background-clip"] = backgroundClip;
	if (Object.keys(result).length === 0) return;
	return result;
}
fillStyle.__lookupStyles = [
	"fill",
	"backgroundColor",
	"image",
	"backgroundImage",
	"backgroundPosition",
	"backgroundSize",
	"backgroundRepeat",
	"backgroundAttachment",
	"backgroundOrigin",
	"backgroundClip",
	"background"
];
function svgFillStyle({ svgFill }) {
	if (!svgFill) return;
	svgFill = parseStyle(svgFill).groups[0]?.colors[0] || svgFill;
	return { fill: svgFill };
}
svgFillStyle.__lookupStyles = ["svgFill"];

//#endregion
export { fillStyle, svgFillStyle };
//# sourceMappingURL=fill.js.map