import { PollData_Design_PollDesign_Background_Type } from "./../ricos-schema/next-schema/index.js";
import { resolveCssColor } from "./../_shared/resolve-css-color.js";
import { unreachable } from "./../_shared/uncreachable.js";
import { getScaleImageSrc } from "./../wix-rich-content-common/lib/image-utils.js";
function getRandomValue(pool) {
  return pool[Math.floor(Math.random() * pool.length)];
}
function toBackgroundString(background, backgroundType, width, height) {
  switch (backgroundType) {
    case PollData_Design_PollDesign_Background_Type.GRADIENT:
      try {
        const { gradient } = background;
        return `linear-gradient(${gradient.angle}deg, ${resolveCssColor(
          gradient.startColor
        )}, ${resolveCssColor(gradient.lastColor)})`;
      } catch (error) {
        console.error(error);
        return null;
      }
    case PollData_Design_PollDesign_Background_Type.IMAGE:
      if (!width || !height) {
        return null;
      }
      const URL = background.image?.src?.url;
      const imageSrc = getScaleImageSrc(URL, width, height);
      return `url('${imageSrc}') center / cover`;
    case PollData_Design_PollDesign_Background_Type.COLOR:
      return resolveCssColor(background.color) ?? null;
    default:
      unreachable(backgroundType);
      return resolveCssColor(background.color) ?? null;
  }
}
export {
  getRandomValue,
  toBackgroundString
};
//# sourceMappingURL=helpers.js.map
