<?php

namespace FleekDash\Routes\Groups;

use FleekDash\Libs\API\Route;
use FleekDash\Libs\API\RouteAuthMiddleware;
use FleekDash\Controllers\Analytics\CommentsStatsController;
use FleekDash\Controllers\Analytics\UsersStatsController;
use FleekDash\Controllers\Analytics\ContentStatsController;
use FleekDash\Controllers\Analytics\GrowthStatsController;

/**
 * Analytics Stats Routes (V2.2)
 * 
 * Registers analytics endpoints for:
 * - Comments Stats (/stats/comments)
 * - Users Stats (/stats/users)
 * - Content Stats (/content/published)
 * - Growth Stats (/growth/site)
 * 
 * Each category provides: index, chart, summary, comparison
 * 
 * Migrated from includes/API/real/ auto-registration system
 * 
 * @package FleekDash\Routes\Groups
 * @since 2.2.0
 */
class AnalyticsStatsRoutes
{
    public static function register($route)
    {
        // ═══════════════════════════════════════════════════════════
        // COMMENTS STATS ENDPOINTS
        // ═══════════════════════════════════════════════════════════

        // GET /stats/comments - Full data with pagination
        $route->get('/stats/comments', [CommentsStatsController::class, 'index'], 
            RouteAuthMiddleware::public(), [
                'limit' => ['required' => false, 'type' => 'integer'],
                'page' => ['required' => false, 'type' => 'integer'],
                'per_page' => ['required' => false, 'type' => 'integer'],
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
            ]
        );

        // GET /stats/comments/chart - Chart data (time series)
        $route->get('/stats/comments/chart', [CommentsStatsController::class, 'chart'], 
            RouteAuthMiddleware::public(), [
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
            ]
        );

        // GET /stats/comments/summary - Summary KPIs
        $route->get('/stats/comments/summary', [CommentsStatsController::class, 'summary'], 
            RouteAuthMiddleware::public(), [
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
            ]
        );

        // GET /stats/comments/comparison - Period comparison
        $route->get('/stats/comments/comparison', [CommentsStatsController::class, 'comparison'], 
            RouteAuthMiddleware::public(), [
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
                'comparison_type' => ['required' => false, 'type' => 'string'],
            ]
        );

        // ═══════════════════════════════════════════════════════════
        // USERS STATS ENDPOINTS
        // ═══════════════════════════════════════════════════════════

        // GET /stats/users - Full data with pagination
        $route->get('/stats/users', [UsersStatsController::class, 'index'], 
            RouteAuthMiddleware::public(), [
                'limit' => ['required' => false, 'type' => 'integer'],
                'page' => ['required' => false, 'type' => 'integer'],
                'per_page' => ['required' => false, 'type' => 'integer'],
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
            ]
        );

        // GET /stats/users/chart - Chart data (time series)
        $route->get('/stats/users/chart', [UsersStatsController::class, 'chart'], 
            RouteAuthMiddleware::public(), [
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
            ]
        );

        // GET /stats/users/summary - Summary KPIs
        $route->get('/stats/users/summary', [UsersStatsController::class, 'summary'], 
            RouteAuthMiddleware::public(), [
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
            ]
        );

        // GET /stats/users/comparison - Period comparison
        $route->get('/stats/users/comparison', [UsersStatsController::class, 'comparison'], 
            RouteAuthMiddleware::public(), [
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
                'comparison_type' => ['required' => false, 'type' => 'string'],
            ]
        );

        // ═══════════════════════════════════════════════════════════
        // CONTENT STATS ENDPOINTS
        // ═══════════════════════════════════════════════════════════

        // GET /content/published - Full data with pagination
        $route->get('/content/published', [ContentStatsController::class, 'index'], 
            RouteAuthMiddleware::public(), [
                'limit' => ['required' => false, 'type' => 'integer'],
                'page' => ['required' => false, 'type' => 'integer'],
                'per_page' => ['required' => false, 'type' => 'integer'],
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
            ]
        );

        // GET /content/published/chart - Chart data (time series)
        $route->get('/content/published/chart', [ContentStatsController::class, 'chart'], 
            RouteAuthMiddleware::public(), [
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
            ]
        );

        // GET /content/published/summary - Summary KPIs
        $route->get('/content/published/summary', [ContentStatsController::class, 'summary'], 
            RouteAuthMiddleware::public(), [
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
            ]
        );

        // GET /content/published/comparison - Period comparison
        $route->get('/content/published/comparison', [ContentStatsController::class, 'comparison'], 
            RouteAuthMiddleware::public(), [
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
                'comparison_type' => ['required' => false, 'type' => 'string'],
            ]
        );

        // ═══════════════════════════════════════════════════════════
        // GROWTH STATS ENDPOINTS
        // ═══════════════════════════════════════════════════════════

        // GET /growth/site - Full growth data
        $route->get('/growth/site', [GrowthStatsController::class, 'index'], 
            RouteAuthMiddleware::public(), [
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
            ]
        );

        // GET /growth/site/chart - Chart data (time series)
        $route->get('/growth/site/chart', [GrowthStatsController::class, 'chart'], 
            RouteAuthMiddleware::public(), [
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
            ]
        );

        // GET /growth/site/summary - Summary KPIs
        $route->get('/growth/site/summary', [GrowthStatsController::class, 'summary'], 
            RouteAuthMiddleware::public(), [
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
            ]
        );

        // GET /growth/site/comparison - Period comparison
        $route->get('/growth/site/comparison', [GrowthStatsController::class, 'comparison'], 
            RouteAuthMiddleware::public(), [
                'time_range' => ['required' => false, 'type' => 'string'],
                'start_date' => ['required' => false, 'type' => 'string'],
                'end_date' => ['required' => false, 'type' => 'string'],
                'comparison_type' => ['required' => false, 'type' => 'string'],
            ]
        );
    }
}

