"""Text utilities.""" ELLIPSIS = "\u2026" def truncate(text: str, n: int) -> str: """Return text unchanged if len(text) <= n, else its first n-1 chars followed by '…'. Raises ValueError if n < 1. """ if n < 1: raise ValueError(f"n must be >= 1, got {n}") if len(text) <= n: return text return text[: n - 1] + ELLIPSIS