"""Renderer registry for display modes."""

from .base import ModeRenderer
from .reference import ReferenceRenderer
from .code import CodeRenderer


_RENDERERS: dict[str, ModeRenderer] = {}


def register_renderer(renderer: ModeRenderer) -> None:
    """Register a mode renderer.

    Args:
        renderer: Renderer instance to register
    """
    _RENDERERS[renderer.mode] = renderer


def get_renderer(mode: str) -> ModeRenderer | None:
    """Get renderer for mode.

    Args:
        mode: Mode name to get renderer for

    Returns:
        Renderer instance or None if not found
    """
    return _RENDERERS.get(mode)


def list_modes() -> list[str]:
    """List available modes.

    Returns:
        List of registered mode names
    """
    return list(_RENDERERS.keys())


register_renderer(ReferenceRenderer())
register_renderer(CodeRenderer())


__all__ = [
    "ModeRenderer",
    "ReferenceRenderer",
    "CodeRenderer",
    "register_renderer",
    "get_renderer",
    "list_modes",
]
