import {
  Button
} from "/build/_shared/chunk-UWBTKPLD.js";
import {
  ChevronLeftIcon,
  ChevronRightIcon,
  DoubleArrowLeftIcon,
  DoubleArrowRightIcon
} from "/build/_shared/chunk-LGQ4GCFK.js";
import {
  Link,
  init_esm2 as init_esm
} from "/build/_shared/chunk-ZC2TL3GZ.js";
import {
  require_jsx_dev_runtime
} from "/build/_shared/chunk-ED7KKCRB.js";
import {
  createHotContext,
  init_remix_hmr
} from "/build/_shared/chunk-G7KTOMTD.js";
import {
  __toESM
} from "/build/_shared/chunk-PNG5AS42.js";

// app/components/Pagination.tsx
init_remix_hmr();
init_esm();
var import_jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
if (!window.$RefreshReg$ || !window.$RefreshSig$ || !window.$RefreshRuntime$) {
  console.warn("remix:hmr: React Fast Refresh only works when the Remix compiler is running in development mode.");
} else {
  prevRefreshReg = window.$RefreshReg$;
  prevRefreshSig = window.$RefreshSig$;
  window.$RefreshReg$ = (type, id) => {
    window.$RefreshRuntime$.register(type, '"app/components/Pagination.tsx"' + id);
  };
  window.$RefreshSig$ = window.$RefreshRuntime$.createSignatureFunctionForTransform;
}
var prevRefreshReg;
var prevRefreshSig;
if (import.meta) {
  import.meta.hot = createHotContext(
    //@ts-expect-error
    "app/components/Pagination.tsx"
  );
  import.meta.hot.lastModified = "1711663831012.5999";
}
var PageLink = ({
  page,
  pageText,
  variant = "ghost",
  disabled = false,
  isActive = false
}) => {
  const pageLinkComponent = /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(Button, { variant, size: "sm", className: isActive ? "bg-muted" : "", disabled, children: pageText || page }, void 0, false, {
    fileName: "app/components/Pagination.tsx",
    lineNumber: 31,
    columnNumber: 29
  }, this);
  return disabled ? pageLinkComponent : /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(Link, { to: `?page=${page}`, prefetch: "intent", children: pageLinkComponent }, void 0, false, {
    fileName: "app/components/Pagination.tsx",
    lineNumber: 34,
    columnNumber: 41
  }, this);
};
_c = PageLink;
function Pagination({
  currentPage,
  totalPages
}) {
  const pageNumbers = Array.from({
    length: totalPages
  }, (_, i) => i + 1);
  const showStartingEllipsis = currentPage >= 3;
  const showEndingEllipsis = currentPage <= totalPages - 2;
  const lowerBound = Math.max(0, currentPage === totalPages ? totalPages - 3 : currentPage - 2);
  const upperBound = Math.min(totalPages, currentPage === 1 ? 3 : currentPage + 1);
  const visiblePageNumbers = pageNumbers.slice(lowerBound, upperBound);
  const firstPage = pageNumbers[0];
  const lastPage = pageNumbers[pageNumbers.length - 1];
  const hasPreviousPages = currentPage > 1;
  const hasNextPages = currentPage < totalPages;
  return /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("div", { className: "flex items-center gap-1", children: [
    /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(PageLink, { variant: "outline", page: firstPage, pageText: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(DoubleArrowLeftIcon, {}, void 0, false, {
      fileName: "app/components/Pagination.tsx",
      lineNumber: 56,
      columnNumber: 62
    }, this), disabled: !hasPreviousPages }, void 0, false, {
      fileName: "app/components/Pagination.tsx",
      lineNumber: 56,
      columnNumber: 7
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(PageLink, { variant: "outline", page: currentPage - 1, pageText: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(ChevronLeftIcon, {}, void 0, false, {
      fileName: "app/components/Pagination.tsx",
      lineNumber: 58,
      columnNumber: 68
    }, this), disabled: !hasPreviousPages }, void 0, false, {
      fileName: "app/components/Pagination.tsx",
      lineNumber: 58,
      columnNumber: 7
    }, this),
    showStartingEllipsis && /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("span", { className: "-mr-1 ml-1 text-gray-500", children: "..." }, void 0, false, {
      fileName: "app/components/Pagination.tsx",
      lineNumber: 60,
      columnNumber: 32
    }, this),
    visiblePageNumbers.map((page) => /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(PageLink, { page, pageText: page, isActive: currentPage === page }, page, false, {
      fileName: "app/components/Pagination.tsx",
      lineNumber: 61,
      columnNumber: 39
    }, this)),
    showEndingEllipsis && /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("span", { className: "-ml-1 mr-1 text-gray-500", children: "..." }, void 0, false, {
      fileName: "app/components/Pagination.tsx",
      lineNumber: 62,
      columnNumber: 30
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(PageLink, { variant: "outline", page: currentPage + 1, pageText: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(ChevronRightIcon, {}, void 0, false, {
      fileName: "app/components/Pagination.tsx",
      lineNumber: 64,
      columnNumber: 68
    }, this), disabled: !hasNextPages }, void 0, false, {
      fileName: "app/components/Pagination.tsx",
      lineNumber: 64,
      columnNumber: 7
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(PageLink, { variant: "outline", page: lastPage, pageText: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(DoubleArrowRightIcon, {}, void 0, false, {
      fileName: "app/components/Pagination.tsx",
      lineNumber: 66,
      columnNumber: 61
    }, this), disabled: !hasNextPages }, void 0, false, {
      fileName: "app/components/Pagination.tsx",
      lineNumber: 66,
      columnNumber: 7
    }, this)
  ] }, void 0, true, {
    fileName: "app/components/Pagination.tsx",
    lineNumber: 55,
    columnNumber: 10
  }, this);
}
_c2 = Pagination;
var _c;
var _c2;
$RefreshReg$(_c, "PageLink");
$RefreshReg$(_c2, "Pagination");
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;

export {
  Pagination
};
//# sourceMappingURL=/build/_shared/chunk-66K6NTQO.js.map
