"""Prompt loader for JavaScript/TypeScript optimizer prompts."""

from __future__ import annotations

from pathlib import Path

PROMPTS_DIR = Path(__file__).parent


def get_system_prompt(is_async: bool = False) -> str:
    """Load the system prompt for JavaScript/TypeScript optimization.

    Args:
        is_async: Whether to load the async variant of the prompt

    Returns:
        The system prompt text

    """
    variant = "async_system_prompt.md" if is_async else "system_prompt.md"
    prompt_file = PROMPTS_DIR / variant

    if not prompt_file.exists():
        msg = f"No system prompt found: {prompt_file}"
        raise ValueError(msg)

    return prompt_file.read_text()


def get_user_prompt(is_async: bool = False) -> str:
    """Load the user prompt for JavaScript/TypeScript optimization.

    Args:
        is_async: Whether to load the async variant of the prompt

    Returns:
        The user prompt text

    """
    variant = "async_user_prompt.md" if is_async else "user_prompt.md"
    prompt_file = PROMPTS_DIR / variant

    if not prompt_file.exists():
        msg = f"No user prompt found: {prompt_file}"
        raise ValueError(msg)

    return prompt_file.read_text()
