from __future__ import annotations

from typing import Annotated

from fastapi import APIRouter, Depends

from ..strategy import get_engine
from .auth import require_user

router = APIRouter(prefix="/api/plan", tags=["plan"])


@router.get("/state")
async def plan_state(_user: Annotated[str, Depends(require_user)]) -> dict:
    return get_engine().state()


@router.post("/start")
async def plan_start(_user: Annotated[str, Depends(require_user)]) -> dict:
    return await get_engine().start()


@router.post("/pause")
async def plan_pause(_user: Annotated[str, Depends(require_user)]) -> dict:
    return await get_engine().pause()


@router.post("/emergency-close")
async def plan_emergency(_user: Annotated[str, Depends(require_user)]) -> dict:
    return await get_engine().emergency_close()
