'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var jsxRuntime = require('react/jsx-runtime');
var react = require('@chakra-ui/react');
var icons = require('@chakra-ui/icons');
var usePagination = require('../../hooks/usePagination.cjs');

const Pagination = ({
  currentPage,
  totalCount,
  pageSize = 10,
  siblingCount = 1,
  onPageChange
}) => {
  const { pages, totalPageCount } = usePagination.usePagination({
    totalCount,
    pageSize,
    siblingCount,
    currentPage
  });
  return /* @__PURE__ */ jsxRuntime.jsxs(react.HStack, { spacing: 2, children: [
    /* @__PURE__ */ jsxRuntime.jsx(
      react.IconButton,
      {
        variant: "ghost",
        onClick: () => onPageChange(Math.max(1, currentPage - 1)),
        isDisabled: currentPage === 1,
        icon: /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronLeftIcon, {}),
        "aria-label": "Previous Page"
      }
    ),
    pages.map((page, idx) => /* @__PURE__ */ jsxRuntime.jsx(
      react.Button,
      {
        variant: currentPage === page ? "outline" : "ghost",
        isDisabled: page === null,
        onClick: () => page !== null && onPageChange(page),
        children: page != null ? page : "..."
      },
      page != null ? page : `${idx}-dots`
    )),
    /* @__PURE__ */ jsxRuntime.jsx(
      react.IconButton,
      {
        variant: "ghost",
        onClick: () => onPageChange(Math.min(currentPage + 1, totalPageCount)),
        isDisabled: currentPage === totalPageCount,
        icon: /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightIcon, {}),
        "aria-label": "Next Page"
      }
    )
  ] });
};

exports.Pagination = Pagination;
//# sourceMappingURL=Pagination.cjs.map
