<?php

// ============================================================
// LẤY URL HIỆN TẠI
// ============================================================

$url = $_GET['url'] ?? '';

$url = trim($url, '/');

// Legacy sales code is retained for rollback only. It is deliberately not
// reachable from the active PET SPA runtime, including by direct URLs.
$disabledLegacySalesRoutes = [
    'products', 'product',
    'cart', 'cart/add', 'cart/update', 'cart/remove', 'cart/clear',
    'checkout', 'checkout/place-order', 'order/success',
    'customer/addresses', 'customer/address/create', 'customer/address/update',
    'customer/address/delete', 'customer/address/default',
    'customer/orders', 'customer/order', 'customer/order/cancel',
    'customer/reviews', 'customer/review/store',
    'owner/reports', 'owner/reports/products', 'owner/reports/customers',
    'owner/reports/promotions', 'owner/reports/inventory',
    'owner/reports/export/products', 'owner/reports/export/customers',
    'owner/reports/export/revenue',
    'owner/product-categories', 'owner/product-category/store',
    'owner/product-category/update', 'owner/product-category/toggle',
    'owner/products', 'owner/product/create', 'owner/product/store',
    'owner/product/edit', 'owner/product/update', 'owner/product/hide',
    'owner/product/image/delete',
    'owner/orders', 'owner/order', 'owner/order/status', 'owner/order/paid',
    'owner/promotions', 'owner/promotion/create', 'owner/promotion/store',
    'owner/promotion/edit', 'owner/promotion/update', 'owner/promotion/toggle',
    'owner/reviews', 'owner/review/reply', 'owner/review/toggle',
    'admin/moderation/products', 'admin/moderation/reviews',
    'admin/moderation/product/status', 'admin/moderation/review/status'
];

if (in_array($url, $disabledLegacySalesRoutes, true)) {
    http_response_code(404);
    require BASE_PATH . '/app/views/errors/404.php';
    exit;
}

// ============================================================
// ROUTES
// ============================================================

switch ($url) {

    // --------------------------------------------------------
    // TRANG CHỦ
    // --------------------------------------------------------
    case '':
    case 'home':

    require_once BASE_PATH
        . '/app/controllers/HomeController.php';

    $controller =
        new HomeController();

    $controller->index();

    break;
    // --------------------------------------------------------
    // SẢN PHẨM
    // --------------------------------------------------------
    // ============================================================
// PRODUCTS
// ============================================================

case 'products':

    require_once BASE_PATH
        . '/app/controllers/ProductController.php';

    $controller =
        new ProductController();

    $controller->index();

    break;


// ============================================================
// PRODUCT DETAIL
// ============================================================

case 'product':

    require_once BASE_PATH
        . '/app/controllers/ProductController.php';

    $controller =
        new ProductController();

    $controller->detail();

    break;

    // --------------------------------------------------------
    // LIÊN HỆ
    // --------------------------------------------------------
    case 'contact':

    require_once BASE_PATH
        . '/app/controllers/ContactController.php';

    $controller =
        new ContactController();

    $controller->index();

    break;


case 'contact/submit':

    require_once BASE_PATH
        . '/app/controllers/ContactController.php';

    $controller =
        new ContactController();

    $controller->submit();

    break;


// OWNER

case 'owner/contacts':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerContactController.php';

    $controller =
        new OwnerContactController();

    $controller->index();

    break;


case 'owner/contact':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerContactController.php';

    $controller =
        new OwnerContactController();

    $controller->detail();

    break;


case 'owner/contact/status':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerContactController.php';

    $controller =
        new OwnerContactController();

    $controller->updateStatus();

    break;

case 'owner/notifications':
    require_once BASE_PATH . '/app/controllers/owner/OwnerNotificationController.php';
    (new OwnerNotificationController())->index();
    break;
case 'owner/notifications/poll':
    require_once BASE_PATH . '/app/controllers/owner/OwnerNotificationController.php';
    (new OwnerNotificationController())->poll();
    break;
case 'owner/notification/read':
    require_once BASE_PATH . '/app/controllers/owner/OwnerNotificationController.php';
    (new OwnerNotificationController())->read();
    break;

case 'owner/notifications/read-all':
    require_once BASE_PATH . '/app/controllers/owner/OwnerNotificationController.php';
    (new OwnerNotificationController())->readAll();
    break;

    // ============================================================
// CART
// ============================================================

case 'cart':

    require_once BASE_PATH
        . '/app/controllers/CartController.php';

    $controller =
        new CartController();

    $controller->index();

    break;


// ============================================================
// ADD CART
// ============================================================

case 'cart/add':

    require_once BASE_PATH
        . '/app/controllers/CartController.php';

    $controller =
        new CartController();

    $controller->add();

    break;


// ============================================================
// UPDATE CART
// ============================================================

case 'cart/update':

    require_once BASE_PATH
        . '/app/controllers/CartController.php';

    $controller =
        new CartController();

    $controller->update();

    break;


// ============================================================
// REMOVE CART ITEM
// ============================================================

case 'cart/remove':

    require_once BASE_PATH
        . '/app/controllers/CartController.php';

    $controller =
        new CartController();

    $controller->remove();

    break;


// ============================================================
// CLEAR CART
// ============================================================

case 'cart/clear':

    require_once BASE_PATH
        . '/app/controllers/CartController.php';

    $controller =
        new CartController();

    $controller->clear();

    break;
    // ============================================================
// CHECKOUT
// ============================================================

case 'checkout':

    require_once BASE_PATH
        . '/app/controllers/CheckoutController.php';

    $controller =
        new CheckoutController();

    $controller->index();

    break;


// ============================================================
// PLACE ORDER
// ============================================================

case 'checkout/place-order':

    require_once BASE_PATH
        . '/app/controllers/CheckoutController.php';

    $controller =
        new CheckoutController();

    $controller->placeOrder();

    break;


// ============================================================
// ORDER SUCCESS
// ============================================================

case 'order/success':

    require_once BASE_PATH
        . '/app/controllers/CheckoutController.php';

    $controller =
        new CheckoutController();

    $controller->success();

    break;
    // ============================================================
// LOGIN
// ============================================================

case 'login':

    require_once BASE_PATH
        . '/app/controllers/AuthController.php';

    $controller =
        new AuthController();

    $controller->login();

    break;


// ============================================================
// LOGIN SUBMIT
// ============================================================

case 'login/submit':

    require_once BASE_PATH
        . '/app/controllers/AuthController.php';

    $controller =
        new AuthController();

    $controller->loginSubmit();

    break;


// ============================================================
// FORGOT / RESET PASSWORD
// ============================================================

case 'forgot-password':

    require_once BASE_PATH
        . '/app/controllers/ForgotPasswordController.php';

    (new ForgotPasswordController())->forgot();

    break;


case 'reset-password':

    require_once BASE_PATH
        . '/app/controllers/ForgotPasswordController.php';

    (new ForgotPasswordController())->reset();

    break;


// ============================================================
// REGISTER
// ============================================================

case 'register':

    require_once BASE_PATH
        . '/app/controllers/AuthController.php';

    $controller =
        new AuthController();

    $controller->register();

    break;


// ============================================================
// REGISTER SUBMIT
// ============================================================

case 'register/submit':

    require_once BASE_PATH
        . '/app/controllers/AuthController.php';

    $controller =
        new AuthController();

    $controller->registerSubmit();

    break;


// ============================================================
// LOGOUT
// ============================================================

case 'logout':

    require_once BASE_PATH
        . '/app/controllers/AuthController.php';

    $controller =
        new AuthController();

    $controller->logout();

    break;


// ============================================================
// ADMIN CORE
// ============================================================

case 'admin':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminDashboardController.php';

    (new AdminDashboardController())->index();

    break;


case 'admin/users':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminUserController.php';

    (new AdminUserController())->index();

    break;


case 'admin/permissions':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminPermissionController.php';

    (new AdminPermissionController())->index();

    break;


case 'admin/permissions/update':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminPermissionController.php';

    (new AdminPermissionController())->update();

    break;


case 'admin/user':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminUserController.php';

    (new AdminUserController())->detail();

    break;

case 'admin/user/create':
    require_once BASE_PATH . '/app/controllers/admin/AdminUserController.php';
    (new AdminUserController())->create();
    break;

case 'admin/user/edit':
    require_once BASE_PATH . '/app/controllers/admin/AdminUserController.php';
    (new AdminUserController())->edit();
    break;

case 'admin/user/save':
    require_once BASE_PATH . '/app/controllers/admin/AdminUserController.php';
    (new AdminUserController())->save();
    break;


case 'admin/user/status':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminUserController.php';

    (new AdminUserController())->updateStatus();

    break;


case 'admin/user/role':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminUserController.php';

    (new AdminUserController())->updateRole();

    break;


case 'admin/moderation':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminContentController.php';

    (new AdminContentController())->index();

    break;


case 'admin/moderation/products':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminContentController.php';

    (new AdminContentController())->products();

    break;


case 'admin/moderation/posts':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminContentController.php';

    (new AdminContentController())->posts();

    break;


case 'admin/moderation/gallery':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminContentController.php';

    (new AdminContentController())->gallery();

    break;


case 'admin/moderation/reviews':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminContentController.php';

    (new AdminContentController())->reviews();

    break;


case 'admin/moderation/product/status':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminContentController.php';

    (new AdminContentController())->updateProductStatus();

    break;


case 'admin/moderation/post/status':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminContentController.php';

    (new AdminContentController())->updatePostStatus();

    break;


case 'admin/moderation/gallery/status':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminContentController.php';

    (new AdminContentController())->updateGalleryStatus();

    break;


case 'admin/moderation/review/status':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminContentController.php';

    (new AdminContentController())->updateReviewStatus();

    break;


case 'admin/activity-logs':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminLogController.php';

    (new AdminLogController())->index();

    break;


case 'admin/system-settings':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminSettingController.php';

    (new AdminSettingController())->index();

    break;


case 'admin/system-settings/update':

    require_once BASE_PATH
        . '/app/controllers/admin/AdminSettingController.php';

    (new AdminSettingController())->update();

    break;


    // ============================================================
// CUSTOMER DASHBOARD
// ============================================================

case 'customer':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerDashboardController.php';

    $controller =
        new CustomerDashboardController();

    $controller->index();

    break;


// ============================================================
// CUSTOMER PROFILE
// ============================================================

case 'customer/profile':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerProfileController.php';

    $controller =
        new CustomerProfileController();

    $controller->index();

    break;


case 'customer/profile/update':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerProfileController.php';

    $controller =
        new CustomerProfileController();

    $controller->update();

    break;


case 'customer/avatar/upload':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerAvatarController.php';

    (new CustomerAvatarController())->upload();

    break;


case 'customer/avatar/delete':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerAvatarController.php';

    (new CustomerAvatarController())->delete();

    break;


case 'customer/password/update':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerProfileController.php';

    $controller =
        new CustomerProfileController();

    $controller->changePassword();

    break;


// ============================================================
// CUSTOMER ADDRESSES
// ============================================================

case 'customer/addresses':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerAddressController.php';

    $controller =
        new CustomerAddressController();

    $controller->index();

    break;


case 'customer/address/create':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerAddressController.php';

    $controller =
        new CustomerAddressController();

    $controller->create();

    break;


case 'customer/address/update':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerAddressController.php';

    $controller =
        new CustomerAddressController();

    $controller->update();

    break;


case 'customer/address/delete':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerAddressController.php';

    $controller =
        new CustomerAddressController();

    $controller->delete();

    break;


case 'customer/address/default':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerAddressController.php';

    $controller =
        new CustomerAddressController();

    $controller->setDefault();

    break;


// ============================================================
// CUSTOMER ORDERS
// ============================================================

case 'customer/orders':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerOrderController.php';

    $controller =
        new CustomerOrderController();

    $controller->index();

    break;


case 'customer/order':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerOrderController.php';

    $controller =
        new CustomerOrderController();

    $controller->detail();

    break;


case 'customer/order/cancel':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerOrderController.php';

    $controller =
        new CustomerOrderController();

    $controller->cancel();

    break;
    // ============================================================
// OWNER DASHBOARD
// ============================================================

case 'owner':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerDashboardController.php';

    $controller =
        new OwnerDashboardController();

    $controller->index();

    break;


// ============================================================
// OWNER REPORTS
// ============================================================

case 'owner/reports':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerReportController.php';

    (new OwnerReportController())->index();

    break;


case 'owner/reports/products':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerReportController.php';

    (new OwnerReportController())->products();

    break;


case 'owner/reports/customers':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerReportController.php';

    (new OwnerReportController())->customers();

    break;


case 'owner/reports/promotions':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerReportController.php';

    (new OwnerReportController())->promotions();

    break;


case 'owner/reports/inventory':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerReportController.php';

    (new OwnerReportController())->inventory();

    break;


case 'owner/reports/export/products':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerReportController.php';

    (new OwnerReportController())->exportProducts();

    break;


case 'owner/reports/export/customers':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerReportController.php';

    (new OwnerReportController())->exportCustomers();

    break;


case 'owner/reports/export/revenue':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerReportController.php';

    (new OwnerReportController())->exportRevenue();

    break;


// ============================================================
// OWNER PRODUCT CATEGORIES
// ============================================================

case 'owner/product-categories':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerCategoryController.php';

    $controller =
        new OwnerCategoryController();

    $controller->index();

    break;


case 'owner/product-category/store':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerCategoryController.php';

    $controller =
        new OwnerCategoryController();

    $controller->store();

    break;


case 'owner/product-category/update':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerCategoryController.php';

    $controller =
        new OwnerCategoryController();

    $controller->update();

    break;


case 'owner/product-category/toggle':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerCategoryController.php';

    $controller =
        new OwnerCategoryController();

    $controller->toggle();

    break;


// ============================================================
// OWNER PRODUCTS
// ============================================================

case 'owner/products':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerProductController.php';

    $controller =
        new OwnerProductController();

    $controller->index();

    break;


case 'owner/product/create':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerProductController.php';

    $controller =
        new OwnerProductController();

    $controller->create();

    break;


case 'owner/product/store':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerProductController.php';

    $controller =
        new OwnerProductController();

    $controller->store();

    break;


case 'owner/product/edit':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerProductController.php';

    $controller =
        new OwnerProductController();

    $controller->edit();

    break;


case 'owner/product/update':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerProductController.php';

    $controller =
        new OwnerProductController();

    $controller->update();

    break;


case 'owner/product/hide':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerProductController.php';

    $controller =
        new OwnerProductController();

    $controller->hide();

    break;


case 'owner/product/image/delete':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerProductController.php';

    $controller =
        new OwnerProductController();

    $controller->deleteImage();

    break;
    // ============================================================
// OWNER ORDERS
// ============================================================

case 'owner/orders':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerOrderController.php';

    $controller =
        new OwnerOrderController();

    $controller->index();

    break;


// ============================================================
// OWNER ORDER DETAIL
// ============================================================

case 'owner/order':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerOrderController.php';

    $controller =
        new OwnerOrderController();

    $controller->detail();

    break;


// ============================================================
// OWNER ORDER STATUS
// ============================================================

case 'owner/order/status':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerOrderController.php';

    $controller =
        new OwnerOrderController();

    $controller->updateStatus();

    break;


// ============================================================
// OWNER ORDER PAYMENT
// ============================================================

case 'owner/order/paid':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerOrderController.php';

    $controller =
        new OwnerOrderController();

    $controller->markPaid();

    break;
    // ============================================================
// OWNER CUSTOMERS
// ============================================================

case 'owner/customers':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerCustomerController.php';

    $controller =
        new OwnerCustomerController();

    $controller->index();

    break;


case 'owner/customer':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerCustomerController.php';

    $controller =
        new OwnerCustomerController();

    $controller->detail();

    break;
    // ============================================================
// OWNER PROMOTIONS
// ============================================================

case 'owner/promotions':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPromotionController.php';

    $controller =
        new OwnerPromotionController();

    $controller->index();

    break;


case 'owner/promotion/create':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPromotionController.php';

    $controller =
        new OwnerPromotionController();

    $controller->create();

    break;


case 'owner/promotion/store':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPromotionController.php';

    $controller =
        new OwnerPromotionController();

    $controller->store();

    break;


case 'owner/promotion/edit':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPromotionController.php';

    $controller =
        new OwnerPromotionController();

    $controller->edit();

    break;


case 'owner/promotion/update':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPromotionController.php';

    $controller =
        new OwnerPromotionController();

    $controller->update();

    break;


case 'owner/promotion/toggle':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPromotionController.php';

    $controller =
        new OwnerPromotionController();

    $controller->toggle();

    break;
    // ============================================================
// OWNER POSTS
// ============================================================

case 'owner/posts':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPostController.php';

    $controller =
        new OwnerPostController();

    $controller->index();

    break;


case 'owner/post/create':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPostController.php';

    $controller =
        new OwnerPostController();

    $controller->create();

    break;


case 'owner/post/store':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPostController.php';

    $controller =
        new OwnerPostController();

    $controller->store();

    break;


case 'owner/post/edit':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPostController.php';

    $controller =
        new OwnerPostController();

    $controller->edit();

    break;


case 'owner/post/update':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPostController.php';

    $controller =
        new OwnerPostController();

    $controller->update();

    break;


case 'owner/post/hide':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPostController.php';

    $controller =
        new OwnerPostController();

    $controller->hide();

    break;


case 'owner/post/delete':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPostController.php';

    $controller =
        new OwnerPostController();

    $controller->delete();

    break;


// ============================================================
// POST CATEGORIES
// ============================================================

case 'owner/post-categories':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPostCategoryController.php';

    $controller =
        new OwnerPostCategoryController();

    $controller->index();

    break;


case 'owner/post-category/store':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPostCategoryController.php';

    $controller =
        new OwnerPostCategoryController();

    $controller->store();

    break;


case 'owner/post-category/toggle':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerPostCategoryController.php';

    $controller =
        new OwnerPostCategoryController();

    $controller->toggle();

    break;
    // ============================================================
// OWNER GALLERY
// ============================================================

case 'owner/gallery':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerGalleryController.php';

    $controller =
        new OwnerGalleryController();

    $controller->index();

    break;


case 'owner/gallery/store':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerGalleryController.php';

    $controller =
        new OwnerGalleryController();

    $controller->store();

    break;


case 'owner/gallery/edit':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerGalleryController.php';

    $controller =
        new OwnerGalleryController();

    $controller->edit();

    break;


case 'owner/gallery/update':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerGalleryController.php';

    $controller =
        new OwnerGalleryController();

    $controller->update();

    break;


case 'owner/gallery/toggle':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerGalleryController.php';

    $controller =
        new OwnerGalleryController();

    $controller->toggle();

    break;


case 'owner/gallery/delete':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerGalleryController.php';

    $controller =
        new OwnerGalleryController();

    $controller->delete();

    break;
    // ============================================================
// CUSTOMER REVIEWS
// ============================================================

case 'customer/reviews':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerReviewController.php';

    $controller =
        new CustomerReviewController();

    $controller->index();

    break;


case 'customer/review/store':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerReviewController.php';

    $controller =
        new CustomerReviewController();

    $controller->store();

    break;


// ============================================================
// CUSTOMER NOTIFICATIONS
// ============================================================

case 'customer/notifications':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerNotificationController.php';

    (new CustomerNotificationController())->index();

    break;


case 'customer/notification/read':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerNotificationController.php';

    (new CustomerNotificationController())->markRead();

    break;


case 'customer/notifications/read-all':

    require_once BASE_PATH
        . '/app/controllers/customer/CustomerNotificationController.php';

    (new CustomerNotificationController())->markAllRead();

    break;


// ============================================================
// OWNER REVIEWS
// ============================================================

case 'owner/reviews':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerReviewController.php';

    $controller =
        new OwnerReviewController();

    $controller->index();

    break;


case 'owner/review/reply':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerReviewController.php';

    $controller =
        new OwnerReviewController();

    $controller->reply();

    break;


case 'owner/review/toggle':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerReviewController.php';

    $controller =
        new OwnerReviewController();

    $controller->toggle();

    break;
    // ============================================================
// OWNER SETTINGS
// ============================================================

case 'owner/settings':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerSettingController.php';

    $controller =
        new OwnerSettingController();

    $controller->index();

    break;


case 'owner/settings/update':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerSettingController.php';

    $controller =
        new OwnerSettingController();

    $controller->update();

    break;


// ============================================================
// OWNER SOCIAL LINKS
// ============================================================

case 'owner/social/save':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerSettingController.php';

    $controller =
        new OwnerSettingController();

    $controller->saveSocial();

    break;


case 'owner/social/toggle':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerSettingController.php';

    $controller =
        new OwnerSettingController();

    $controller->toggleSocial();

    break;


case 'owner/social/delete':

    require_once BASE_PATH
        . '/app/controllers/owner/OwnerSettingController.php';

    $controller =
        new OwnerSettingController();

    $controller->deleteSocial();

    break;
    case 'posts':

    require_once BASE_PATH
        . '/app/controllers/PostController.php';

    $controller =
        new PostController();

    $controller->index();

    break;


case 'post':

    require_once BASE_PATH
        . '/app/controllers/PostController.php';

    $controller =
        new PostController();

    $controller->detail();

    break;
case 'gallery':

    require_once BASE_PATH
        . '/app/controllers/GalleryController.php';

    $controller =
        new GalleryController();

    $controller->index();

    break;

// ============================================================
// SPA BOOKING
// ============================================================
case 'services':
    require_once BASE_PATH . '/app/controllers/ServiceController.php';
    (new ServiceController())->index();
    break;
case 'service':
    require_once BASE_PATH . '/app/controllers/ServiceController.php';
    (new ServiceController())->detail();
    break;
case 'customer/bookings':
    require_once BASE_PATH . '/app/controllers/customer/CustomerBookingController.php';
    (new CustomerBookingController())->index();
    break;
case 'customer/booking':
    require_once BASE_PATH . '/app/controllers/customer/CustomerBookingController.php';
    (new CustomerBookingController())->detail();
    break;
case 'customer/booking/create':
    require_once BASE_PATH . '/app/controllers/customer/CustomerBookingController.php';
    (new CustomerBookingController())->create();
    break;
case 'customer/booking/available-slots':
    require_once BASE_PATH . '/app/controllers/customer/CustomerBookingController.php';
    (new CustomerBookingController())->availableSlots();
    break;
case 'customer/booking/store':
    require_once BASE_PATH . '/app/controllers/customer/CustomerBookingController.php';
    (new CustomerBookingController())->store();
    break;
case 'customer/booking/cancel':
    require_once BASE_PATH . '/app/controllers/customer/CustomerBookingController.php';
    (new CustomerBookingController())->cancel();
    break;
case 'owner/service-categories':
    require_once BASE_PATH . '/app/controllers/owner/OwnerServiceCategoryController.php';
    (new OwnerServiceCategoryController())->index();
    break;
case 'owner/service-category/store':
    require_once BASE_PATH . '/app/controllers/owner/OwnerServiceCategoryController.php';
    (new OwnerServiceCategoryController())->store();
    break;
case 'owner/service-category/update':
    require_once BASE_PATH . '/app/controllers/owner/OwnerServiceCategoryController.php';
    (new OwnerServiceCategoryController())->update();
    break;
case 'owner/service-category/toggle':
    require_once BASE_PATH . '/app/controllers/owner/OwnerServiceCategoryController.php';
    (new OwnerServiceCategoryController())->toggle();
    break;
case 'owner/services':
    require_once BASE_PATH . '/app/controllers/owner/OwnerServiceController.php';
    (new OwnerServiceController())->index();
    break;
case 'owner/service/create':
    require_once BASE_PATH . '/app/controllers/owner/OwnerServiceController.php';
    (new OwnerServiceController())->create();
    break;
case 'owner/service/store':
    require_once BASE_PATH . '/app/controllers/owner/OwnerServiceController.php';
    (new OwnerServiceController())->store();
    break;
case 'owner/service/edit':
    require_once BASE_PATH . '/app/controllers/owner/OwnerServiceController.php';
    (new OwnerServiceController())->edit();
    break;
case 'owner/service/update':
    require_once BASE_PATH . '/app/controllers/owner/OwnerServiceController.php';
    (new OwnerServiceController())->update();
    break;
case 'owner/service/toggle':
    require_once BASE_PATH . '/app/controllers/owner/OwnerServiceController.php';
    (new OwnerServiceController())->toggle();
    break;
case 'owner/schedule':
    require_once BASE_PATH . '/app/controllers/owner/OwnerScheduleController.php';
    (new OwnerScheduleController())->index();
    break;
case 'owner/business-hours/update':
    require_once BASE_PATH . '/app/controllers/owner/OwnerScheduleController.php';
    (new OwnerScheduleController())->updateHours();
    break;
case 'owner/blocked-slot/store':
    require_once BASE_PATH . '/app/controllers/owner/OwnerScheduleController.php';
    (new OwnerScheduleController())->storeBlockedSlot();
    break;
case 'owner/blocked-slot/delete':
    require_once BASE_PATH . '/app/controllers/owner/OwnerScheduleController.php';
    (new OwnerScheduleController())->deleteBlockedSlot();
    break;
case 'owner/bookings':
    require_once BASE_PATH . '/app/controllers/owner/OwnerBookingController.php';
    (new OwnerBookingController())->index();
    break;
case 'owner/booking':
    require_once BASE_PATH . '/app/controllers/owner/OwnerBookingController.php';
    (new OwnerBookingController())->detail();
    break;
case 'owner/booking/status':
    require_once BASE_PATH . '/app/controllers/owner/OwnerBookingController.php';
    (new OwnerBookingController())->updateStatus();
    break;
case 'owner/booking/note':
    require_once BASE_PATH . '/app/controllers/owner/OwnerBookingController.php';
    (new OwnerBookingController())->updateNote();
    break;


// --------------------------------------------------------
// KHÔNG TÌM THẤY ROUTE
// --------------------------------------------------------
default:

    http_response_code(404);

    require BASE_PATH
        . '/app/views/errors/404.php';

    break;
}
