<?php

/**
 * Notifications module manifest.
 *
 * In-app notifications with bell icon, dropdown panel,
 * event-driven creation, and scheduled cleanup.
 */
return [
    'id' => 'notifications',
    'version' => '1.0.0',
    'enabled_by_default' => true,
    'load_order' => 15,
    'requires' => [],

    'routes' => [
        ['path' => 'notifications/list-data', 'target' => 'notifications/list-data'],
        ['path' => 'notifications/mark-read-data', 'target' => 'notifications/mark-read-data'],
        ['path' => 'notifications/delete-data', 'target' => 'notifications/delete-data'],
        ['path' => 'notifications/unread-count-data', 'target' => 'notifications/unread-count-data'],
    ],
    'public_paths' => [],

    'container_registrars' => [
        \MintyPHP\Module\Notifications\NotificationsContainerRegistrar::class,
    ],

    'ui_slots' => [
        'topbar.right_item' => [
            [
                'key' => 'notifications-bell',
                'template' => 'templates/topbar-notification-bell.phtml',
                'permission' => 'notifications.view',
                'order' => 100,
            ],
        ],
        'layout.head_style' => [
            [
                'key' => 'notifications-topbar-style',
                'path' => 'modules/notifications/css/layout/app-topbar-notifications.css',
                'permission' => 'notifications.view',
                'order' => 100,
            ],
            [
                'key' => 'notifications-dropdown-style',
                'path' => 'modules/notifications/css/components/app-notification-dropdown.css',
                'permission' => 'notifications.view',
                'order' => 101,
            ],
        ],
        'runtime.component' => [
            [
                'key' => 'notification-bell',
                'script' => 'modules/notifications/js/components/app-notification-bell.js',
                'export' => 'initNotificationBell',
                'scope' => 'global',
                'config_path' => 'components.notificationBell',
                'default_config' => [],
                'phase' => 'late',
                'permission' => 'notifications.view',
                'order' => 100,
            ],
        ],
    ],

    'authorization_policies' => [
        \MintyPHP\Module\Notifications\NotificationsAuthorizationPolicy::class,
    ],

    'permissions' => [
        [
            'key' => 'notifications.view',
            'description' => 'View and manage own notifications',
        ],
    ],

    'event_listeners' => [
        'user.created' => [
            ['class' => \MintyPHP\Module\Notifications\Listeners\UserCreatedNotificationListener::class, 'method' => 'handle'],
        ],
        'user.deleted' => [
            ['class' => \MintyPHP\Module\Notifications\Listeners\UserDeletedNotificationListener::class, 'method' => 'handle'],
        ],
        'user.activated' => [
            ['class' => \MintyPHP\Module\Notifications\Listeners\UserActivatedNotificationListener::class, 'method' => 'handle'],
        ],
        'user.deactivated' => [
            ['class' => \MintyPHP\Module\Notifications\Listeners\UserDeactivatedNotificationListener::class, 'method' => 'handle'],
        ],
        'user.assignment_changed' => [
            ['class' => \MintyPHP\Module\Notifications\Listeners\UserAssignmentChangedNotificationListener::class, 'method' => 'handle'],
        ],
        'scheduler.job_failed' => [
            ['class' => \MintyPHP\Module\Notifications\Listeners\SchedulerJobFailedNotificationListener::class, 'method' => 'handle'],
        ],
    ],

    'scheduler_jobs' => [
        [
            'job_key' => 'notifications_cleanup',
            'handler' => \MintyPHP\Module\Notifications\Handler\NotificationCleanupJobHandler::class,
            'label' => 'Notification cleanup',
            'description' => 'Purges read notifications older than 90 days',
            'default_enabled' => 1,
            'default_timezone' => 'UTC',
            'default_schedule_type' => 'daily',
            'default_schedule_interval' => 1,
            'default_schedule_time' => '04:00',
            'default_schedule_weekdays_csv' => null,
            'default_catchup_once' => 1,
            'allowed_schedule_types' => ['daily', 'weekly'],
        ],
    ],

    'layout_context_providers' => [
        \MintyPHP\Module\Notifications\Providers\NotificationsLayoutProvider::class,
    ],
    'session_providers' => [
        \MintyPHP\Module\Notifications\Providers\NotificationsSessionProvider::class,
    ],

    'search_resources' => [],
    'asset_groups' => [],
    'migrations_path' => 'db/updates',
    'i18n_path' => 'i18n',
];
