from __future__ import annotations

import html


def nav(active: str) -> str:
    links = [
        ("login", "/ui/login", "Login"),
        ("tasks", "/ui/tasks", "Tasks"),
        ("serving", "/ui/serving", "Serving"),
        ("new", "/ui/tasks/new", "New Task"),
        ("data", "/ui/data", "Data"),
        ("admin", "/ui/admin", "Admin"),
        ("ray", "#", "Ray Dashboard"),
    ]
    items: list[str] = []
    for key, href, label in links:
        cls = "active" if key == active else ""
        extra = ""
        if key == "ray":
            extra = ' id="nav-ray-dashboard" target="_blank" rel="noopener"'
        items.append(f'<a class="{cls}" href="{href}"{extra}>{html.escape(label)}</a>')
    return "\n".join(items)

