"""
Page controller for serving HTML templates.

This module provides endpoints for serving HTML pages using Jinja2 templates.
"""
from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse

from src.server.utils.template_helpers import render_template

router = APIRouter(tags=["pages"])


@router.get("/", response_class=HTMLResponse)
async def root(request: Request):
    """Serve the main application page."""
    return render_template(
        "index.html",
        request,
        title="Aniworld Download Manager"
    )


@router.get("/setup", response_class=HTMLResponse)
async def setup_page(request: Request):
    """Serve the setup page."""
    return render_template(
        "setup.html",
        request,
        title="Setup - Aniworld"
    )


@router.get("/login", response_class=HTMLResponse)
async def login_page(request: Request):
    """Serve the login page."""
    return render_template(
        "login.html",
        request,
        title="Login - Aniworld"
    )


@router.get("/queue", response_class=HTMLResponse)
async def queue_page(request: Request):
    """Serve the download queue page."""
    return render_template(
        "queue.html",
        request,
        title="Download Queue - Aniworld"
    )


@router.get("/loading", response_class=HTMLResponse)
async def loading_page(request: Request):
    """Serve the initialization loading page."""
    return render_template(
        "loading.html",
        request,
        title="Initializing - Aniworld"
    )
