"""Path filters for web UI CI gating (#436)."""

from __future__ import annotations

import re
from collections.abc import Iterable

_WEBUI_TOUCH_RE = re.compile(
    r"^(?:webui/|tests/test_webui_|docs/webui|scripts/(?:run-webui|test-webui|ci-webui-check)$)"
)


def touches_webui_surface(path: str) -> bool:
    """Return True when *path* is a web UI surface file."""
    return bool(_WEBUI_TOUCH_RE.match(path.strip()))


def should_run_webui_ci(changed_paths: Iterable[str]) -> bool:
    """Return True when any changed path should trigger the web UI test suite."""
    return any(touches_webui_surface(path) for path in changed_paths)