// The visible counter under the testimonials, e.g. "2 / 3": the current // review (counted from 1) out of the total. index is zero-based. Odd input // is made safe instead of thrown at: a total below 1 or not a finite number // counts as 1, and an index outside the range moves to the nearest end, so // the result always reads X / Y with 1 <= X <= Y (FR-TR-12). export function slideCounter(index: number, count: number): string { const total = Number.isFinite(count) ? Math.min(Math.max(1, Math.trunc(count)), Number.MAX_SAFE_INTEGER) : 1; const current = Number.isFinite(index) ? Math.trunc(index) : 0; const position = Math.min(Math.max(current, 0), total - 1); return `${position + 1} / ${total}`; }