<?php
/**
 * AI Routes
 *
 * REST API routes for AI functionality.
 *
 * @package FleekDash\Routes\Groups
 * @since 2.3.0
 */

namespace FleekDash\Routes\Groups;

use FleekDash\Controllers\AI\AIChatController;
use FleekDash\Libs\API\Route;
use FleekDash\Libs\API\RouteAuthMiddleware;

defined('ABSPATH') || exit;

/**
 * Class AIRoutes
 *
 * Registers AI-related routes.
 */
class AIRoutes
{
    /**
     * Register all AI-related routes
     *
     * @return void
     */
    public static function register(): void
    {
        // Chat endpoint
        Route::post(
            'ai/chat',
            [AIChatController::class, 'chat'],
            RouteAuthMiddleware::authenticated()
        );

        // Get all providers
        Route::get(
            'ai/providers',
            [AIChatController::class, 'getProviders'],
            RouteAuthMiddleware::authenticated()
        );

        // Get active provider
        Route::get(
            'ai/provider',
            [AIChatController::class, 'getActiveProvider'],
            RouteAuthMiddleware::authenticated()
        );

        // Get provider settings
        Route::get(
            'ai/providers/(?P<id>[a-zA-Z0-9_-]+)/settings',
            [AIChatController::class, 'getProviderSettings'],
            RouteAuthMiddleware::authenticated()
        );

        // Update provider settings
        Route::post(
            'ai/providers/(?P<id>[a-zA-Z0-9_-]+)/settings',
            [AIChatController::class, 'updateProviderSettings'],
            RouteAuthMiddleware::authenticated()
        );

        // Activate provider
        Route::post(
            'ai/providers/(?P<id>[a-zA-Z0-9_-]+)/activate',
            [AIChatController::class, 'activateProvider'],
            RouteAuthMiddleware::authenticated()
        );

        // Deactivate provider
        Route::post(
            'ai/providers/(?P<id>[a-zA-Z0-9_-]+)/deactivate',
            [AIChatController::class, 'deactivateProvider'],
            RouteAuthMiddleware::authenticated()
        );
    }
}
