import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import { useFormikContext } from 'formik';
import { c as cn } from '../utils-BJnb9o5c.js';
import { FormikButton } from './Button.js';
import { B as Button } from '../Button-BCWJgHDy.js';
import 'ramda';
import 'react-router-dom';
import '../renderIcon-C6twJSqH.js';
import '../primitives/Button.js';
import '../button-CrEMzWKw.js';
import '../index-Bo3AAQJp.js';
import '../index-CfriMyrd.js';
import '../index-BtkPdosV.js';
import '../primitives/Spinner.js';
import 'react-i18next';
import '../loader-circle-DycHUAWN.js';
import '../createLucideIcon-C8ycilSN.js';
import '../primitives/Tooltip.js';
import '../tooltip-ChQ9xD1j.js';
import '../index-DNzunGHb.js';
import '../index-CiyxEyB0.js';
import '../index-BNPynZWM.js';
import '../index-DhnfW8wQ.js';
import 'react-dom';
import '../index-CSUSJzOJ.js';
import '../index-zW4GjM5L.js';
import '../index-DOzu5J1s.js';
import '../index-C3hByjk3.js';
import '../floating-ui.react-dom-D8_f_WWh.js';
import '../index-BYZaLNq1.js';
import '../index-fV_U4ZJM.js';
import '../index-yFgkK_AM.js';
import '../index-Cor698lu.js';
import '../index-CSggBaQF.js';

const FormikActionBlock = forwardRef(
  ({
    className,
    submitButtonProps,
    cancelButtonProps,
    isSubmitting: isSubmittingProp,
    position = "left"
  }, ref) => {
    const { handleReset, isSubmitting: isFormikSubmitting } = useFormikContext();
    const isSubmitting = isSubmittingProp ?? isFormikSubmitting;
    const cancelButton = /* @__PURE__ */ jsx(
      Button,
      {
        "data-testid": "cancel-button",
        disabled: isSubmitting,
        label: "Cancel",
        variant: "ghost",
        onClick: handleReset,
        onMouseDown: (e) => e.preventDefault(),
        ...cancelButtonProps
      }
    );
    const submitButton = /* @__PURE__ */ jsx(
      FormikButton,
      {
        "data-testid": "save-changes-button",
        label: "Save changes",
        type: "submit",
        ...submitButtonProps
      }
    );
    return /* @__PURE__ */ jsx(
      "div",
      {
        ref,
        className: cn(
          "flex items-center gap-2",
          position === "right" && "justify-end",
          className
        ),
        children: position === "right" ? /* @__PURE__ */ jsxs(Fragment, { children: [
          cancelButton,
          submitButton
        ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
          submitButton,
          cancelButton
        ] })
      }
    );
  }
);
FormikActionBlock.displayName = "FormikActionBlock";

export { FormikActionBlock };
//# sourceMappingURL=ActionBlock.js.map
