export const DEFAULT_VISIBLE_CONVERSATION_TURNS = 80;

export function conversationWindow(turns = [], visibleTurnCount = DEFAULT_VISIBLE_CONVERSATION_TURNS) {
  const count = Math.max(1, Math.floor(Number(visibleTurnCount) || DEFAULT_VISIBLE_CONVERSATION_TURNS));
  const hiddenTurnCount = Math.max(0, turns.length - count);
  return {
    hiddenTurnCount,
    visibleTurns: hiddenTurnCount > 0 ? turns.slice(hiddenTurnCount) : turns
  };
}
