/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
"use client";
import { cx } from "../../../styles/styler.js";
import { usePaginationContext, useVisiblePages } from "./paginationContext.js";
import { usePaginationGapClassName } from "./paginationStyles.js";
import { PaginationEllipsis } from "./PaginationEllipsis.js";
import { PaginationItem } from "./PaginationItem.js";
import { PaginationLink } from "./PaginationLink.js";
import { forwardRef } from "react";
import { jsx } from "react/jsx-runtime";
//#region src/components/client/Pagination/PaginationNumbers.tsx
const PaginationNumbers = forwardRef(function PaginationNumbers({ renderItem, className }, ref) {
	const { activePage, getPageHref, size } = usePaginationContext();
	const visiblePages = useVisiblePages();
	return /* @__PURE__ */ jsx("ul", {
		ref,
		className: cx("m-0 inline-flex list-none items-center self-center p-0", usePaginationGapClassName(size), className),
		children: visiblePages.map((item, index) => {
			const key = item === "ellipsis" ? `ellipsis-${index}` : `page-${item}`;
			if (item === "ellipsis") return /* @__PURE__ */ jsx("li", {
				className: "inline-flex items-center",
				children: /* @__PURE__ */ jsx(PaginationEllipsis, {})
			}, key);
			const isActive = item === activePage;
			const href = getPageHref?.(item);
			if (renderItem) return /* @__PURE__ */ jsx("li", {
				className: "inline-flex items-center",
				children: renderItem(item, { isActive })
			}, key);
			if (href && !isActive) return /* @__PURE__ */ jsx("li", {
				className: "inline-flex items-center",
				children: /* @__PURE__ */ jsx(PaginationLink, {
					page: item,
					href,
					children: item
				})
			}, key);
			return /* @__PURE__ */ jsx("li", {
				className: "inline-flex items-center",
				children: /* @__PURE__ */ jsx(PaginationItem, {
					page: item,
					children: item
				})
			}, key);
		})
	});
});
PaginationNumbers.displayName = "PaginationNumbers";
//#endregion
export { PaginationNumbers };
