import { jsx, jsxs } from "react/jsx-runtime";
import default_1 from "../../node_modules/@mui/icons-material/Close.js";
import { Button } from "../Button/index.js";
/* empty css                    */
import Popover$1 from "../../node_modules/@mui/material/Popover/Popover.js";
function Popover({
  children,
  title,
  onClose,
  primaryButtonLabel,
  secondaryButtonLabel,
  onPrimaryButtonClick,
  onSecondaryButtonClick,
  primaryButtonProps,
  secondaryButtonProps,
  slotProps,
  "data-testid": dataTestId,
  ...props
}) {
  var _a;
  const mergedSlotProps = {
    ...slotProps,
    paper: {
      ...slotProps == null ? void 0 : slotProps.paper,
      // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
      className: ["popover-container", (_a = slotProps == null ? void 0 : slotProps.paper) == null ? void 0 : _a.className].filter(Boolean).join(" ")
    }
  };
  const handleCloseIconClick = (e) => {
    onClose == null ? void 0 : onClose(e, "backdropClick");
  };
  return /* @__PURE__ */ jsx(Popover$1, { ...props, slotProps: mergedSlotProps, onClose, children: /* @__PURE__ */ jsxs("div", { className: "popover-content", "data-testid": dataTestId, children: [
    /* @__PURE__ */ jsxs("div", { className: "popover-header", children: [
      /* @__PURE__ */ jsx("span", { className: "popover-header-title", children: title }),
      onClose != null && /* @__PURE__ */ jsx(
        default_1,
        {
          "aria-label": "Close",
          "data-testid": "popover-close-icon",
          fontSize: "small",
          role: "button",
          sx: { color: "#60697D", cursor: "pointer" },
          onClick: handleCloseIconClick
        }
      )
    ] }),
    /* @__PURE__ */ jsx("div", { className: "popover-body", children }),
    /* @__PURE__ */ jsx("div", { className: "popover-footer", children: /* @__PURE__ */ jsxs("div", { className: "popover-footer-content", children: [
      primaryButtonLabel != null || secondaryButtonLabel != null ? /* @__PURE__ */ jsx("div", { className: "divider-line" }) : null,
      /* @__PURE__ */ jsxs("div", { className: "popover-footer-buttons", children: [
        secondaryButtonLabel != null && /* @__PURE__ */ jsx(
          Button,
          {
            variant: "tertiary",
            onClick: onSecondaryButtonClick,
            ...secondaryButtonProps,
            children: secondaryButtonLabel
          }
        ),
        primaryButtonLabel != null && /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: onPrimaryButtonClick, ...primaryButtonProps, children: primaryButtonLabel })
      ] })
    ] }) })
  ] }) });
}
Popover.displayName = "Popover";
export {
  Popover
};
