# retoor <retoor@molodetz.nl>

import logging

from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse

from devplacepy.templating import templates
from devplacepy.seo import list_page_seo
from devplacepy.utils import get_current_user

logger = logging.getLogger(__name__)
router = APIRouter()

TOOLS = [
    {
        "slug": "seo",
        "name": "SEO Diagnostics",
        "icon": "🔍",
        "url": "/tools/seo",
        "description": (
            "Audit any URL or sitemap against a broad battery of technical, on-page, "
            "structured-data, performance, accessibility and AI-readiness checks."
        ),
    },
    {
        "slug": "deepsearch",
        "name": "DeepSearch",
        "icon": "🧠",
        "url": "/tools/deepsearch",
        "description": (
            "Run a multi-agent deep web research job that crawls and indexes sources, "
            "synthesises a cited report with confidence and gap analysis, then lets you "
            "chat over the gathered evidence."
        ),
    },
]


@router.get("", response_class=HTMLResponse)
async def tools_index(request: Request):
    user = get_current_user(request)
    seo_ctx = list_page_seo(
        request,
        title="Tools",
        description="Developer tools on DevPlace, including the SEO Diagnostics auditor.",
        breadcrumbs=[
            {"name": "Home", "url": "/feed"},
            {"name": "Tools", "url": "/tools"},
        ],
    )
    return templates.TemplateResponse(
        request,
        "tools/index.html",
        {**seo_ctx, "request": request, "user": user, "tools": TOOLS},
    )
