export function calculateTotalPages(totalItems, pageSize) {
    return Math.ceil(totalItems / pageSize);
}
export function getPaginationItems(totalPages, currentPage) {
    if (totalPages <= 7) {
        return Array.from({ length: totalPages }, (_, i) => i + 1);
    }
    const pages = [1];
    if (currentPage <= 4) {
        pages.push(2, 3, 4, 5, '…');
    }
    else if (currentPage >= totalPages - 3) {
        pages.push('…', totalPages - 4, totalPages - 3, totalPages - 2, totalPages - 1);
    }
    else {
        pages.push('…', currentPage - 1, currentPage, currentPage + 1, '…');
    }
    pages.push(totalPages);
    return pages;
}
export function getHiddenPages(totalPages, items, currentPage, position) {
    if (totalPages <= 7)
        return [];
    const all = Array.from({ length: totalPages }, (_, i) => i + 1);
    const visible = items.filter(x => typeof x === 'number');
    const hidden = all.filter(p => !visible.includes(p));
    if (position === 'left') {
        const firstAfterEllipsis = visible[1];
        return hidden.filter(p => p < firstAfterEllipsis);
    }
    else {
        const lastBeforeEllipsis = visible[visible.length - 2];
        return hidden.filter(p => p > lastBeforeEllipsis);
    }
}
export function getRangeText(totalItems, pageSize, currentPage) {
    const start = (currentPage - 1) * pageSize + 1;
    const end = Math.min(currentPage * pageSize, totalItems);
    return `Showing ${start}–${end} of ${totalItems}`;
}
//# sourceMappingURL=nile-pagination-utils.js.map