"""Fixed-size token chunks with overlap — py-02's arithmetic, over a string."""

from __future__ import annotations


def chunk(text: str, size: int, overlap: int) -> list[list[str]]:
    """Split ``text`` on whitespace, then into chunks of ``size`` tokens.

    Consecutive chunks share ``overlap`` tokens, so the stride is ``size - overlap`` and
    ``out[1][0] is out[0][size - overlap]``. The final chunk is returned even when it is
    short. Empty (or whitespace-only) text returns ``[]``.

    Raises ValueError when ``size < 1``, when ``overlap < 0``, or when
    ``overlap >= size`` (which would make the stride zero or negative — an infinite loop).
    """
    ...
