import { jsx, jsxs } from "react/jsx-runtime";
import { Button } from "../Button/index.js";
/* empty css                  */
import Modal$1 from "../../node_modules/@mui/material/Modal/Modal.js";
import Box from "../../node_modules/@mui/material/Box/Box.js";
function Modal({
  className = "",
  title,
  size = "medium",
  children,
  primaryButtonLabel,
  secondaryButtonLabel,
  open,
  onPrimaryButtonClick,
  onSecondaryButtonClick,
  primaryButtonProps,
  secondaryButtonProps,
  onClose,
  width,
  height,
  footerOptions,
  isBottomSheet = false,
  isExpanded = false,
  onExpand,
  maxHeight,
  zIndex = 1300,
  withExpandIcon = false,
  ...args
}) {
  const modalClasses = [
    "ia_modalPopover",
    `ia_modal_${size}`,
    className,
    isBottomSheet ? "is-bottom-sheet" : "",
    isExpanded ? "expanded" : "",
    withExpandIcon ? "with-expand-icon" : ""
  ].filter(Boolean).join(" ");
  const style = { width, height, maxHeight };
  const handleClose = () => {
    if (typeof onClose === "function") onClose();
  };
  const headerActions = /* @__PURE__ */ jsxs("div", { className: "modal-actions", children: [
    isBottomSheet && withExpandIcon && typeof onExpand === "function" && /* @__PURE__ */ jsx(
      "button",
      {
        "aria-label": isExpanded ? "Collapse" : "Expand",
        className: isExpanded ? "collapse_icon" : "expand_icon",
        type: "button",
        onClick: onExpand
      }
    ),
    /* @__PURE__ */ jsx(
      "button",
      {
        "aria-label": "Close",
        className: "close_icon",
        "data-testid": "modal-close-button",
        type: "button",
        onClick: handleClose
      }
    )
  ] });
  if (!primaryButtonLabel && !secondaryButtonLabel) {
    return /* @__PURE__ */ jsx(
      Modal$1,
      {
        "aria-describedby": "modal-modal-description",
        "aria-labelledby": "modal-modal-title",
        open,
        sx: { "&.MuiModal-root": { zIndex: `${zIndex}` } },
        onClose: handleClose,
        ...args,
        children: /* @__PURE__ */ jsxs(Box, { className: modalClasses, style, children: [
          /* @__PURE__ */ jsxs("div", { className: "ia_modalHeader", children: [
            /* @__PURE__ */ jsx("div", { className: "ia_modalHeading", children: title }),
            headerActions
          ] }),
          /* @__PURE__ */ jsx("div", { className: "ia_modalBody", children }),
          footerOptions != null && /* @__PURE__ */ jsx("div", { className: "ia_modalFooter", children: footerOptions })
        ] })
      }
    );
  }
  return /* @__PURE__ */ jsx(
    Modal$1,
    {
      "aria-describedby": "modal-modal-description",
      "aria-labelledby": "modal-modal-title",
      open,
      sx: { "&.MuiModal-root": { zIndex: `${zIndex}` } },
      onClose: handleClose,
      ...args,
      children: /* @__PURE__ */ jsxs(Box, { className: modalClasses, style, children: [
        /* @__PURE__ */ jsxs("div", { className: "ia_modalHeader", children: [
          /* @__PURE__ */ jsx("div", { className: "ia_modalHeading", children: title }),
          headerActions
        ] }),
        /* @__PURE__ */ jsx("div", { className: "ia_modalBody", children }),
        /* @__PURE__ */ jsxs("div", { className: "ia_modalFooter", children: [
          secondaryButtonLabel != null && /* @__PURE__ */ jsx(Button, { variant: "url", onClick: onSecondaryButtonClick, ...secondaryButtonProps, children: secondaryButtonLabel }),
          primaryButtonLabel != null && // eslint-disable-next-line jsx-a11y/no-autofocus
          /* @__PURE__ */ jsx(Button, { autoFocus: true, onClick: onPrimaryButtonClick, ...primaryButtonProps, children: primaryButtonLabel })
        ] })
      ] })
    }
  );
}
Modal.displayName = "Modal";
export {
  Modal
};
