import { resolveDocumentColorToCss } from "./../_shared/theme-color-token.js";
import { getOpacityFromHex } from "./../wix-rich-content-common/index.js";
const WIDTH = 900;
const PAGE_SIZE_PRESETS = {
  FLUID: { width: WIDTH },
  A4: { width: WIDTH, height: Math.round(WIDTH * (297 / 210)) },
  LETTER: { width: WIDTH, height: Math.round(WIDTH * 1.294) },
  LEGAL: { width: WIDTH, height: Math.round(WIDTH * (14 / 8.5)) },
  SQUARE: { width: WIDTH, height: WIDTH }
};
const PAGE_FORMAT_TO_MM = {
  A4: { widthMm: 210, heightMm: 297 },
  LETTER: { widthMm: 216, heightMm: 279 },
  LEGAL: { widthMm: 216, heightMm: 356 },
  SQUARE: { widthMm: 210, heightMm: 210 },
  FLUID: { widthMm: 210 }
};
const getPageSizeByFormat = (format) => {
  const key = format?.toUpperCase() ?? "A4";
  return PAGE_SIZE_PRESETS[key] ?? PAGE_SIZE_PRESETS.A4;
};
const CARD_DEFAULTS = {
  width: PAGE_SIZE_PRESETS.A4.width,
  height: PAGE_SIZE_PRESETS.A4.height,
  padding: [40, 40, 40, 40]
};
const CARD_OVERFLOW_MESSAGE = "Content exceeds page boundary";
const isTransparentCardBackgroundColor = (color) => getOpacityFromHex(color) === 0;
const getCardBackgroundColorCssVar = (background, hasExplicitBackground) => {
  const backgroundColor = background?.type === "COLOR" && !isTransparentCardBackgroundColor(background.color) ? background.color : void 0;
  const effectiveColor = backgroundColor ?? (hasExplicitBackground ? "transparent" : void 0);
  return effectiveColor ? resolveDocumentColorToCss(effectiveColor) ?? effectiveColor : void 0;
};
export {
  CARD_DEFAULTS,
  CARD_OVERFLOW_MESSAGE,
  PAGE_FORMAT_TO_MM,
  PAGE_SIZE_PRESETS,
  getCardBackgroundColorCssVar,
  getPageSizeByFormat,
  isTransparentCardBackgroundColor
};
//# sourceMappingURL=shared-with-viewer.js.map
