<?php

use Modules\AiCore\Http\Controllers\InstallController;
use Modules\AiCore\Http\Controllers\AiSettingsController;
use Modules\AiCore\Http\Controllers\AiUsageController;
use Modules\AiCore\Http\Controllers\AiToolsController;
use Modules\AiCore\Http\Controllers\AiFeedbackController;

// Install / Update routes
Route::middleware(['web', 'auth'])->prefix('ai-core')->group(function () {
    Route::get('/install',   [InstallController::class, 'index']);
    Route::post('/install',  [InstallController::class, 'install']);
    Route::get('/uninstall', [InstallController::class, 'uninstall']);
    Route::get('/update',    [InstallController::class, 'update']);
    Route::get('/repair',    [InstallController::class, 'repair']);
});

// Admin routes
Route::group([
    'middleware' => ['web', 'auth', 'SetSessionData', 'language', 'timezone', 'AdminSidebarMenu'],
    'prefix'     => 'ai-core',
], function () {
    Route::get('/settings',       [AiSettingsController::class, 'index'])->name('aicore.settings.index');
    Route::post('/settings/save',    [AiSettingsController::class, 'save'])->name('aicore.settings.save');
    Route::post('/settings/service/save',   [AiSettingsController::class, 'saveService'])->name('aicore.settings.service.save');
    Route::post('/settings/service/remove', [AiSettingsController::class, 'removeService'])->name('aicore.settings.service.remove');
    Route::post('/settings/service/make-default', [AiSettingsController::class, 'makeDefault'])->name('aicore.settings.service.make_default');
    Route::post('/settings/chain/save',     [AiSettingsController::class, 'saveChain'])->name('aicore.settings.chain.save');
    Route::post('/settings/test',    [AiSettingsController::class, 'test'])->name('aicore.settings.test');
    Route::get('/usage',          [AiUsageController::class, 'index'])->name('aicore.usage');
    Route::post('/interpret-lab', [AiToolsController::class, 'interpretLab'])->name('aicore.interpret-lab');
    Route::post('/feedback',      [AiFeedbackController::class, 'store'])->name('aicore.feedback');
});
