<?php

use adrienpayet\notifications\NotificationCollector;
use adrienpayet\notifications\providers\CommentProvider;
use adrienpayet\notifications\providers\ReplyProvider;
use adrienpayet\notifications\providers\ProjectRequestProvider;
use adrienpayet\notifications\providers\AppointmentRequestProvider;
use adrienpayet\notifications\providers\ContentProvider;

// Charger les classes
F::loadClasses([
    // Nouvelles classes - Système de providers
    "adrienpayet\\notifications\\NotificationProvider" => __DIR__ . "/src/NotificationProvider.php",
    "adrienpayet\\notifications\\NotificationCollector" => __DIR__ . "/src/NotificationCollector.php",
    "adrienpayet\\notifications\\providers\\CommentProvider" => __DIR__ . "/src/providers/CommentProvider.php",
    "adrienpayet\\notifications\\providers\\ReplyProvider" => __DIR__ . "/src/providers/ReplyProvider.php",
    "adrienpayet\\notifications\\providers\\ProjectRequestProvider" => __DIR__ . "/src/providers/ProjectRequestProvider.php",
    "adrienpayet\\notifications\\providers\\AppointmentRequestProvider" => __DIR__ . "/src/providers/AppointmentRequestProvider.php",
    "adrienpayet\\notifications\\providers\\ContentProvider" => __DIR__ . "/src/providers/ContentProvider.php",

    // Anciennes classes - Gardées pour rétro-compatibilité pendant migration
    "adrienpayet\\notifications\\Notification" => __DIR__ . "/src/Notification.php",
    "adrienpayet\\notifications\\NotificationsPage" => __DIR__ . "/src/NotificationsPage.php",

    // Classes partagées
    "adrienpayet\\D2P\\data\\Position" => __DIR__ . "/../classes/Position.php",
    "adrienpayet\\D2P\\data\\Author" => __DIR__ . "/../classes/Author.php",
    "adrienpayet\\D2P\\data\\location\\Location" => __DIR__ . "/../classes/location/Location.php",
    "adrienpayet\\D2P\\data\\location\\PageDetails" => __DIR__ . "/../classes/location/PageDetails.php",
    "adrienpayet\\D2P\\data\\location\\ProjectDetails" => __DIR__ . "/../classes/location/ProjectDetails.php",
    "adrienpayet\\D2P\\data\\location\\FileDetails" => __DIR__ . "/../classes/location/FileDetails.php",
]);

// Créer et configurer le collector
$collector = new NotificationCollector();
$collector->register(new CommentProvider());
$collector->register(new ReplyProvider());
$collector->register(new ProjectRequestProvider());
$collector->register(new AppointmentRequestProvider());
$collector->register(new ContentProvider());

Kirby::plugin("adrienpayet/pdc-notifications", [
    "options" => [
        "collector" => $collector
    ],
    "routes" => [
        // Nouvelles routes
        require(__DIR__ . "/routes/mark-as-read.php"),
        require(__DIR__ . "/routes/mark-all-read.php"),
        // Anciennes routes - Gardées pour rétro-compatibilité
        require(__DIR__ . "/routes/readAll.php"),
        require(__DIR__ . "/routes/read.php"),
    ],
]);
