import lodash from "lodash";
import { Node_Type } from "./../../../../ricos-schema/legacy/wix/rich_content/v1/index.js";
import { NO_WRAP, WRAP } from "../../../consts.js";
const convertContainerData = (data, nodeType) => {
  if (!data.containerData) {
    return;
  }
  const { width, alignment, spoiler, height, textWrap = true } = data.containerData;
  const { enabled = false, description, buttonText } = spoiler ?? {};
  const config = {
    ...data.config,
    size: getSize(nodeType, width?.size, width?.custom),
    width: getWidth(nodeType, width?.custom),
    height: height?.custom && parseInt(height.custom),
    alignment: alignment?.toLowerCase(),
    spoiler: spoiler && {
      enabled,
      description,
      buttonContent: buttonText
    },
    textWrap: textWrap ? WRAP : NO_WRAP
  };
  return config;
};
const getSize = (nodeType, size, customWidth) => {
  const hasCustomWidth = customWidth !== void 0;
  if ((nodeType === Node_Type.IMAGE || nodeType === Node_Type.BUTTON) && hasCustomWidth) {
    return "inline";
  }
  if (nodeType === Node_Type.BUTTON) {
    return "small";
  }
  if (size) {
    return lodash.camelCase(size);
  }
};
const getWidth = (nodeType, width) => {
  if (width) {
    return parseInt(width);
  }
  if (!width && nodeType === Node_Type.BUTTON) {
    return "fit-content";
  }
};
export {
  convertContainerData
};
//# sourceMappingURL=convert-container-data.js.map
