from fastapi import APIRouter

from app import __version__
from app.core.config import settings

router = APIRouter()


@router.get("/health")
async def health_check():
    return {
        "status": "ok",
        "service": settings.service_name,
        "version": __version__,
    }


@router.get("/capabilities")
async def capabilities():
    return {
        "service": settings.service_name,
        "version": __version__,
        "phase": "14.7",
        "commercial_product": "Torbat Beauty",
        "features": {
            "foundation": True,
            "health": True,
            "capabilities": True,
            "metrics": True,
            "external_providers_ready": True,
            "future_booking_engines_ready": True,
            "schedules": True,
            "appointments": True,
            "appointment_lifecycle": True,
            "waiting_list": True,
            "salon_management": True,
            "treatment_rooms": True,
            "stations": True,
            "branch_policies": True,
            "service_catalog": True,
            "service_categories": True,
            "services": True,
            "customers": True,
            "packages": True,
            "memberships": True,
            "staff": True,
            "commissions": True,
            "marketing": True,
            "loyalty_integrations": True,
            "communication_integrations": True,
            "integration_dispatches": True,
            "booking_engine": False,
            "ai": False,
        },
        "independence": {
            "standalone": True,
            "superapp": True,
            "integrations": [
                "accounting",
                "communication",
                "loyalty",
                "crm",
                "experience",
                "delivery",
                "storage",
                "identity",
            ],
            "integration_mode": "api_and_events_only",
        },
    }


@router.get("/metrics")
async def metrics():
    return {
        "service": settings.service_name,
        "version": __version__,
        "phase": "14.7",
        "metrics": {
            "organizations": "tenant_scoped",
            "branches": "tenant_scoped",
            "external_providers": "tenant_scoped",
            "booking_engines": "tenant_scoped",
            "configurations": "tenant_scoped",
            "appointments": "tenant_scoped",
            "staff_schedules": "tenant_scoped",
            "waiting_list_entries": "tenant_scoped",
            "treatment_rooms": "tenant_scoped",
            "stations": "tenant_scoped",
            "service_categories": "tenant_scoped",
            "beauty_services": "tenant_scoped",
            "customer_profiles": "tenant_scoped",
            "package_definitions": "tenant_scoped",
            "membership_plans": "tenant_scoped",
            "staff_profiles": "tenant_scoped",
            "commission_rules": "tenant_scoped",
            "marketing_campaign_refs": "tenant_scoped",
            "integration_dispatches": "tenant_scoped",
            "outbox_events": "tenant_scoped",
        },
        "note": "Beauty Business aggregates through Phase 14.7",
    }
