"""Link behavior configuration — project-level control for target attribute."""

from dataclasses import dataclass


@dataclass
class LinkConfig:
    """Configuration for link rendering behavior.

    Controls the ``target`` attribute on ``<a>`` tags generated by StreamTeX.

    Usage in ``book.py``::

        import streamtex as stx
        stx.set_link_config(LinkConfig(external_target="_blank"))

    Attributes:
        external_target: Target for external links (http/https). Default ``"_blank"``.
        internal_target: Target for internal anchor links (``#``). Default ``"_self"``.
    """

    external_target: str = "_blank"
    internal_target: str = "_self"


_link_config: LinkConfig = LinkConfig()


def set_link_config(config: LinkConfig) -> None:
    """Set the global link configuration for the current project."""
    global _link_config
    _link_config = config


def get_link_config() -> LinkConfig:
    """Return the current global link configuration."""
    return _link_config
