import { useEngagementMedium } from "@saasquatch/component-boilerplate";
export function usePopupContainer(props) {
  const engagementMedium = useEngagementMedium();
  function closePopup() {
    var _a;
    if (useEngagementMedium() === "POPUP") {
      (_a = window.frameElement["squatchJsApi"]) === null || _a === void 0 ? void 0 : _a.close();
    }
  }
  const popupPadding = props.popupPadding
    ? props.popupPadding === "none"
      ? "0"
      : `var(--sl-spacing-${props.popupPadding})`
    : "var(--sl-spacing-medium)";
  const embedPadding = props.embedPadding
    ? props.embedPadding === "none"
      ? "0"
      : `var(--sl-spacing-${props.embedPadding})`
    : "0";
  const padding = useEngagementMedium() === "POPUP" ? popupPadding : embedPadding;
  return {
    states: {
      showCloseButton: props.closeButton && engagementMedium === "POPUP",
      styles: {
        ...props,
        padding,
        closeButtonText: props.closeButtonText ? props.closeButtonText : "X",
        poweredByText: props.poweredByText,
      },
    },
    data: {},
    callbacks: { closePopup },
  };
}
