import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
import { B as Button } from './Button-BNzCI47m.js';

import './MenuFooter.css';const stack = "_stack_o8ro5_1";
const leading = "_leading_o8ro5_26";
const trailing = "_trailing_o8ro5_32";
const styles = {
	stack: stack,
	"stack-row": "_stack-row_o8ro5_8",
	"clear-full": "_clear-full_o8ro5_13",
	"confirmation-row": "_confirmation-row_o8ro5_18",
	leading: leading,
	trailing: trailing
};

const preventBlur = (e) => {
  e.preventDefault();
};
const ClearButton = ({
  onClick,
  label = "Clear",
  disabled,
  fullWidth
}) => /* @__PURE__ */ jsx(
  Button,
  {
    appearance: "secondary",
    size: "small",
    onMouseDown: preventBlur,
    onClick,
    disabled,
    className: fullWidth ? styles["clear-full"] : void 0,
    children: label
  }
);
const ConfirmationRow = ({
  applyLabel = "Apply",
  cancelLabel = "Cancel",
  onApply,
  onCancel,
  applyDisabled,
  leading
}) => /* @__PURE__ */ jsxs("div", { className: styles["confirmation-row"], children: [
  leading ? /* @__PURE__ */ jsx("div", { className: styles["leading"], children: leading }) : null,
  /* @__PURE__ */ jsxs("div", { className: styles["trailing"], children: [
    /* @__PURE__ */ jsx(
      Button,
      {
        appearance: "secondary",
        size: "small",
        onMouseDown: preventBlur,
        onClick: onCancel,
        children: cancelLabel
      }
    ),
    /* @__PURE__ */ jsx(
      Button,
      {
        appearance: "primary",
        size: "small",
        onMouseDown: preventBlur,
        onClick: onApply,
        disabled: applyDisabled,
        children: applyLabel
      }
    )
  ] })
] });
const MenuFooter = ({
  clear,
  confirmation,
  addNew
}) => {
  if (confirmation) {
    if (clear && addNew) {
      return /* @__PURE__ */ jsxs("div", { className: styles["stack"], children: [
        /* @__PURE__ */ jsx("div", { className: styles["stack-row"], children: addNew }),
        /* @__PURE__ */ jsx(
          ConfirmationRow,
          {
            ...confirmation,
            leading: /* @__PURE__ */ jsx(ClearButton, { ...clear })
          }
        )
      ] });
    }
    if (clear) {
      return /* @__PURE__ */ jsx(
        ConfirmationRow,
        {
          ...confirmation,
          leading: /* @__PURE__ */ jsx(ClearButton, { ...clear })
        }
      );
    }
    return /* @__PURE__ */ jsx(ConfirmationRow, { ...confirmation, leading: addNew });
  }
  if (clear && addNew) {
    return /* @__PURE__ */ jsxs("div", { className: styles["stack"], children: [
      /* @__PURE__ */ jsx("div", { className: styles["stack-row"], children: addNew }),
      /* @__PURE__ */ jsx("div", { className: styles["stack-row"], children: /* @__PURE__ */ jsx(ClearButton, { ...clear, fullWidth: true }) })
    ] });
  }
  if (clear) {
    return /* @__PURE__ */ jsx("div", { className: styles["stack-row"], children: /* @__PURE__ */ jsx(ClearButton, { ...clear, fullWidth: true }) });
  }
  if (addNew) {
    return /* @__PURE__ */ jsx(Fragment, { children: addNew });
  }
  return null;
};
MenuFooter.displayName = "MenuFooter";

export { MenuFooter as M };
//# sourceMappingURL=MenuFooter-Ck9L599M.js.map
