# retoor <retoor@molodetz.nl>

from __future__ import annotations

import asyncio
import sys

RESET = "\033[0m"
BOLD = "\033[1m"
CYAN = "\033[36m"
GREEN = "\033[32m"
YELLOW = "\033[33m"
GREY = "\033[90m"


def _supports_color() -> bool:
    return sys.stdout.isatty()


def paint(text: str, color: str) -> str:
    if not _supports_color():
        return text
    return f"{color}{text}{RESET}"


def banner(text: str) -> None:
    print(paint(text, BOLD + CYAN))


def assistant(text: str) -> None:
    print(paint("agent> ", GREEN) + text)


def notice(text: str) -> None:
    print(paint(text, GREY))


def warn(text: str) -> None:
    print(paint(text, YELLOW))


async def prompt(label: str) -> str:
    rendered = paint(label, BOLD + CYAN)
    return await asyncio.to_thread(input, rendered)
