import { computed, type MaybeRefOrGetter, toValue } from 'vue';
import { buildPaginationSummary } from '@/lib/grouped-table';
import type { DataTablePagination } from '@/types/data-table';

export function usePaginationSummary(
    pagination: MaybeRefOrGetter<DataTablePagination | undefined>,
    showingCount: MaybeRefOrGetter<number>,
    itemLabel: string,
) {
    return computed(() =>
        buildPaginationSummary(toValue(pagination), toValue(showingCount), itemLabel),
    );
}
