/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
"use client";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
//#region src/components/client/Pagination/ellipsisDefault.ts
function range(start, end) {
	const result = [];
	for (let i = start; i <= end; i++) result.push(i);
	return result;
}
/**
* Pin first and last page when truncated; ellipses only where there is a gap.
*/
function ellipsisDefault(activePage, totalPages, maxVisiblePageNumbers) {
	if (totalPages <= maxVisiblePageNumbers) return range(1, totalPages);
	const middleBudget = Math.max(1, maxVisiblePageNumbers - 2);
	const half = Math.floor((middleBudget - 1) / 2);
	let windowStart = Math.max(2, activePage - half);
	const windowEnd = Math.min(totalPages - 1, windowStart + middleBudget - 1);
	windowStart = Math.max(2, windowEnd - middleBudget + 1);
	const pageSet = new Set([1, totalPages]);
	for (let i = windowStart; i <= windowEnd; i++) pageSet.add(i);
	const sorted = [...pageSet].sort((a, b) => a - b);
	const result = [];
	for (let i = 0; i < sorted.length; i++) {
		const page = sorted[i];
		const prev = sorted[i - 1];
		if (i > 0 && page - prev > 1) result.push("ellipsis");
		result.push(page);
	}
	return result;
}
//#endregion
exports.ellipsisDefault = ellipsisDefault;
