"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var shared_with_viewer_exports = {};
__export(shared_with_viewer_exports, {
  CARD_DEFAULTS: () => CARD_DEFAULTS,
  CARD_OVERFLOW_MESSAGE: () => CARD_OVERFLOW_MESSAGE,
  PAGE_FORMAT_TO_MM: () => PAGE_FORMAT_TO_MM,
  PAGE_SIZE_PRESETS: () => PAGE_SIZE_PRESETS,
  getCardBackgroundColorCssVar: () => getCardBackgroundColorCssVar,
  getPageSizeByFormat: () => getPageSizeByFormat,
  isTransparentCardBackgroundColor: () => isTransparentCardBackgroundColor
});
module.exports = __toCommonJS(shared_with_viewer_exports);
var import_theme_color_token = require("./../_shared/theme-color-token.js");
var import_wix_rich_content_common = require("./../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) => (0, import_wix_rich_content_common.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 ? (0, import_theme_color_token.resolveDocumentColorToCss)(effectiveColor) ?? effectiveColor : void 0;
};
//# sourceMappingURL=shared-with-viewer.js.map
