import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { ChevronButton } from "./chevronButton";
import { CurrentButton } from "./currentButton";
import { PageButton } from "./pageButton";
import { PaginationService } from "./paginationService";
import { Spread } from "./spread";
import "./styles.css";
/**
 * Pagination component for navigating through paginated data.
 *
 * @component
 * @example
 * ```tsx
 * <Pagination
 *   totalCountRegisters={100}
 *   currentPage={1}
 *   registerPerPage={10}
 *   siblingsCount={1}
 *   onChange={(page) => console.log('Page changed to:', page)}
 * />
 * ```
 *
 * @param props - The component props
 * @returns A pagination navigation component with page numbers and navigation buttons
 */
function Pagination(props) {
    const { totalCountRegisters: baseTotalCountRegisters, siblingsCount: baseSiblingsCount, currentPage: baseCurrentPage, registerPerPage: baseRegisterPerPage, onChange: baseOnChange, ...rest } = props;
    const { currentPage, siblingsCount, previousPages, nextPages, lastPage, handlePageChange, handleMinusChange, handlePlusChange, } = new PaginationService({
        totalCountRegisters: baseTotalCountRegisters,
        currentPage: baseCurrentPage,
        registerPerPage: baseRegisterPerPage,
        siblingsCount: baseSiblingsCount,
        onChange: baseOnChange,
    });
    return (_jsxs("div", { className: "arkynPagination", ...rest, children: [_jsx(ChevronButton, { orientation: "left", handlePageChange: handleMinusChange, disabled: currentPage <= 1 }), currentPage > 1 + siblingsCount && (_jsxs(_Fragment, { children: [_jsx(PageButton, { page: 1, handlePageChange: () => handlePageChange(1) }), currentPage > 2 + siblingsCount && _jsx(Spread, {})] })), previousPages.map((page, index) => (_jsx(PageButton, { page: page, handlePageChange: handleMinusChange }, index))), _jsx(CurrentButton, { currentPage: currentPage }), nextPages.map((page, index) => (_jsx(PageButton, { page: page, handlePageChange: handlePlusChange }, index))), currentPage + siblingsCount < lastPage && (_jsxs(_Fragment, { children: [currentPage + 1 + siblingsCount < lastPage && _jsx(Spread, {}), _jsx(PageButton, { page: lastPage, handlePageChange: () => handlePageChange(lastPage) })] })), _jsx(ChevronButton, { orientation: "right", handlePageChange: handlePlusChange, disabled: currentPage >= lastPage })] }));
}
export { Pagination };
