import { jsx, jsxs } from "react/jsx-runtime";
import { Button } from "../ui/button";
import { ChevronLeft, ChevronRight } from "lucide-react";
import { useTranslations } from "next-intl";
function InvoicesPagination({
  currentPage,
  totalPages,
  totalInvoices,
  limit,
  offset,
  onPageChange,
  isLoading = false
}) {
  const t = useTranslations("settings.billing.invoices.pagination");
  const showingFrom = Math.min(offset + 1, totalInvoices);
  const showingTo = Math.min(offset + limit, totalInvoices);
  const handlePrevious = () => {
    if (currentPage > 1) {
      onPageChange(currentPage - 1);
    }
  };
  const handleNext = () => {
    if (currentPage < totalPages) {
      onPageChange(currentPage + 1);
    }
  };
  if (totalInvoices === 0) {
    return null;
  }
  return /* @__PURE__ */ jsxs(
    "div",
    {
      className: "flex items-center justify-between pt-4 border-t",
      "data-cy": "invoices-pagination",
      "aria-label": t("showing", { from: showingFrom, to: showingTo, total: totalInvoices }),
      children: [
        /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("showing", { from: showingFrom, to: showingTo, total: totalInvoices }) }),
        /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
          /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: t("page", { current: currentPage, total: totalPages }) }),
          /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
            /* @__PURE__ */ jsxs(
              Button,
              {
                variant: "outline",
                size: "sm",
                onClick: handlePrevious,
                disabled: currentPage <= 1 || isLoading,
                "aria-label": t("previous"),
                "data-cy": "pagination-previous",
                children: [
                  /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4", "aria-hidden": "true" }),
                  /* @__PURE__ */ jsx("span", { className: "ml-1", children: t("previous") })
                ]
              }
            ),
            /* @__PURE__ */ jsxs(
              Button,
              {
                variant: "outline",
                size: "sm",
                onClick: handleNext,
                disabled: currentPage >= totalPages || isLoading,
                "aria-label": t("next"),
                "data-cy": "pagination-next",
                children: [
                  /* @__PURE__ */ jsx("span", { className: "mr-1", children: t("next") }),
                  /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4", "aria-hidden": "true" })
                ]
              }
            )
          ] })
        ] })
      ]
    }
  );
}
export {
  InvoicesPagination
};
