<?php

/** @var \App\Core\Router $router */

// Auth
$router->get('/login', 'AuthController', 'loginForm');
$router->post('/login', 'AuthController', 'login');
$router->get('/logout', 'AuthController', 'logout');
$router->get('/change-password', 'AuthController', 'changePasswordForm');
$router->post('/change-password', 'AuthController', 'changePassword');

// Dashboard
$router->get('/', 'DashboardController', 'index');
$router->get('/seo/stats', 'DashboardController', 'seoStats');

// Logs
$router->get('/logs', 'LogController', 'index');

// Global Topics (library)
$router->get('/global-topics', 'GlobalTopicController', 'index');
$router->post('/global-topics/categories', 'GlobalTopicController', 'storeCategory');
$router->post('/global-topics/{id}/subtopics', 'GlobalTopicController', 'storeSubtopic');
$router->post('/global-topics/{id}/update', 'GlobalTopicController', 'update');
$router->post('/global-topics/{id}/delete', 'GlobalTopicController', 'destroy');

// Sites
$router->get('/sites', 'SiteController', 'index');
$router->get('/sites/create', 'SiteController', 'create');
$router->post('/sites', 'SiteController', 'store');
$router->get('/sites/{id}/edit', 'SiteController', 'edit');
$router->post('/sites/{id}', 'SiteController', 'update');
$router->post('/sites/{id}/delete', 'SiteController', 'destroy');
$router->post('/sites/{id}/test', 'SiteController', 'testConnection');
$router->get('/sites/{id}/dashboard', 'SiteController', 'dashboard');
$router->get('/sites/{id}/comments', 'SiteController', 'comments');
$router->post('/sites/{id}/comments/settings', 'SiteController', 'updateCommentsEnabled');
$router->post('/sites/{id}/comments/{commentId}/delete', 'SiteController', 'deleteComment');
$router->post('/sites/{id}/dashboard/permalinks/enable', 'SiteController', 'enablePrettyPermalinks');
$router->post('/sites/{id}/dashboard/remote-service/update', 'SiteController', 'updateRemoteService');
$router->post('/sites/{id}/dashboard/theme/install', 'SiteController', 'installBackproNewsTheme');
$router->post('/sites/{id}/dashboard/reinstall', 'SiteController', 'reinstallWordPress');
$router->post('/sites/{id}/dashboard/seo/sync', 'SiteController', 'syncSeoMetrics');
$router->get('/sites/{id}/seo', 'SiteController', 'seoPanel');
$router->post('/sites/{id}/seo/sync', 'SiteController', 'syncSeoMetrics');
$router->get('/seo/token-sync', 'SiteController', 'syncSeoByToken');
$router->post('/seo/token-sync', 'SiteController', 'syncSeoByToken');

// Topics
$router->get('/sites/{id}/topics', 'TopicController', 'index');
$router->post('/sites/{id}/topics', 'TopicController', 'store');
$router->post('/topics/{id}/update', 'TopicController', 'update');
$router->post('/topics/{id}/delete', 'TopicController', 'destroy');

// Categories (sync from WordPress)
$router->get('/sites/{id}/categories', 'CategoryController', 'index');
$router->post('/sites/{id}/categories/sync', 'CategoryController', 'sync');
$router->post('/sites/{id}/categories/create', 'CategoryController', 'create');
$router->post('/sites/{id}/categories/from-topics', 'CategoryController', 'createFromTopics');

// Articles
$router->get('/articles', 'ArticleController', 'index');
$router->post('/articles/import', 'ArticleController', 'importFromWordPress');
$router->get('/articles/{id}', 'ArticleController', 'show');
$router->post('/articles/{id}/delete', 'ArticleController', 'destroy');
$router->post('/articles/{id}/replace-image', 'ArticleController', 'replaceImage');

// Publish (manual trigger)
$router->post('/publish/run', 'PublishController', 'run');
$router->post('/publish/site/{id}', 'PublishController', 'runForSite');
$router->get('/publish/token-run', 'PublishController', 'runByToken');
$router->post('/publish/token-run', 'PublishController', 'runByToken');

// Installer (Remote WordPress Installation)
$router->get('/installer', 'InstallerController', 'index');
$router->post('/installer', 'InstallerController', 'install');
$router->get('/installer/status/{id}', 'InstallerController', 'status');

// StatLink
$router->get('/statlink', 'StatLinkController', 'index');
$router->get('/statlink/token-run', 'StatLinkController', 'runByToken');
$router->post('/statlink/token-run', 'StatLinkController', 'runByToken');

// Settings
$router->get('/settings', 'SettingsController', 'index');
$router->post('/settings', 'SettingsController', 'update');
$router->get('/settings/database', 'SettingsController', 'database');
$router->post('/settings/database/migrate', 'SettingsController', 'migrate');
