"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import Link from "next/link";
import { Trash2, Save, Loader2 } from "lucide-react";
import { Button } from "../../primitives/button.js";
import { useT } from "@open-mercato/shared/lib/i18n/context";
function FormActionButtons({
  extraActions,
  showDelete,
  onDelete,
  deleteLabel,
  isDeleting,
  cancelHref,
  cancelLabel,
  submit,
  hidden
}) {
  const t = useT();
  if (hidden) return null;
  const resolvedDeleteLabel = deleteLabel ?? t("ui.forms.actions.delete");
  const resolvedCancelLabel = cancelLabel ?? t("ui.forms.actions.cancel");
  const resolvedSubmitLabel = submit?.label ?? t("ui.forms.actions.save");
  const resolvedPendingLabel = submit?.pendingLabel ?? t("ui.forms.status.saving");
  const SubmitIcon = submit?.icon ?? Save;
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
    extraActions,
    showDelete ? /* @__PURE__ */ jsxs(
      Button,
      {
        type: "button",
        variant: "destructive-outline",
        onClick: onDelete,
        disabled: isDeleting,
        children: [
          isDeleting ? /* @__PURE__ */ jsx(Loader2, { className: "size-4 mr-2 animate-spin" }) : /* @__PURE__ */ jsx(Trash2, { className: "size-4 mr-2" }),
          resolvedDeleteLabel
        ]
      }
    ) : null,
    cancelHref ? /* @__PURE__ */ jsx(Button, { asChild: true, variant: "outline", children: /* @__PURE__ */ jsx(Link, { href: cancelHref, children: resolvedCancelLabel }) }) : null,
    submit ? /* @__PURE__ */ jsxs(
      Button,
      {
        type: "submit",
        form: submit.formId,
        disabled: submit.pending,
        children: [
          submit.pending ? /* @__PURE__ */ jsx(Loader2, { className: "size-4 mr-2 animate-spin" }) : /* @__PURE__ */ jsx(SubmitIcon, { className: "size-4 mr-2" }),
          submit.pending ? resolvedPendingLabel : resolvedSubmitLabel
        ]
      }
    ) : null
  ] });
}
export {
  FormActionButtons
};
//# sourceMappingURL=FormActionButtons.js.map
