<?php

/**
 * Address Book module manifest.
 *
 * Contributes routes, sidebar slots, search entry, user-edit aside action,
 * layout context data, and session lifecycle.
 */
return [
    'id' => 'addressbook',
    'version' => '1.0.0',
    'enabled_by_default' => false,
    'load_order' => 10,
    'requires' => [],

    'routes' => [
        // Keep canonical route stable without forcing a /index target to avoid Router redirect loops.
        ['path' => 'address-book', 'target' => 'address-book'],
        ['path' => 'address-book/data', 'target' => 'address-book/data'],
        // Legacy aliases for existing bookmarks/links.
        ['path' => 'addressbook', 'target' => 'address-book'],
        ['path' => 'adressbook', 'target' => 'address-book'],
    ],
    'public_paths' => [],
    'container_registrars' => [
        \MintyPHP\Module\AddressBook\AddressBookContainerRegistrar::class,
    ],

    'ui_slots' => [
        'aside.tab_panel' => [
            [
                'key' => 'people',
                'label' => 'Address book',
                'icon' => 'bi-people',
                'href' => 'address-book',
                'permission' => 'addressbook.view',
                'panel_template' => 'templates/aside-people-panel.phtml',
                'details_storage' => 'aside-people-tenant',
                'details_open_active' => true,
                'order' => 110,
            ],
        ],
        'search.resource_item' => [
            [
                'key' => 'address-book',
                'label' => 'Address book',
                'base_url' => 'address-book',
                'permission' => 'addressbook.view',
                'order' => 110,
            ],
        ],
        'user.edit.aside_action' => [
            [
                'key' => 'address-book-view-user',
                'type' => 'link',
                'label' => 'View in address book',
                'href' => 'address-book/view/{user_uuid}',
                'permission' => 'addressbook.view',
                'order' => 110,
            ],
        ],
    ],

    'authorization_policies' => [
        \MintyPHP\Module\AddressBook\AddressBookAuthorizationPolicy::class,
    ],

    'search_resources' => [
        \MintyPHP\Module\AddressBook\Providers\AddressBookSearchProvider::class,
    ],

    'asset_groups' => [
        'address-book' => [
            'modules/addressbook/css/pages/address-book-view.css',
        ],
    ],
    'scheduler_jobs' => [],

    'layout_context_providers' => [
        \MintyPHP\Module\AddressBook\Providers\AddressBookLayoutProvider::class,
    ],

    'session_providers' => [
        \MintyPHP\Module\AddressBook\Providers\AddressBookSessionProvider::class,
    ],

    'permissions' => [
        [
            'key' => 'address_book.view',
            'description' => 'Can view address book',
            'active' => true,
            'is_system' => true,
        ],
    ],

    'migrations_path' => 'db/updates',
];
