<?php
declare(strict_types=1);

use App\Core\Registries\MenuRegistry;
use App\Core\Registries\PermissionRegistry;

// Add archive as a child under the existing branches_settings menu
// We check if the menu already exists and add our child to it
$existing = MenuRegistry::get('branches_settings');
if ($existing) {
    $children = $existing['children'] ?? [];
    $children[] = ['label_ar' => 'الأرشيف', 'label_en' => 'Archive', 'route' => '/archive', 'permission' => 'report.view_audit', 'order' => 4];
    $existing['children'] = $children;
    MenuRegistry::register('branches_settings', $existing);
}

PermissionRegistry::register('archive', [
    'archive.view'         => ['ar' => 'عرض الأرشيف',        'en' => 'View Archive'],
    'archive.take_snapshot' => ['ar' => 'أخذ لقطة أرشيفية',   'en' => 'Take Archive Snapshot'],
    'archive.compare'      => ['ar' => 'مقارنة اللقطات',     'en' => 'Compare Snapshots'],
    'archive.number_chain' => ['ar' => 'سلسلة أرقام العضوية', 'en' => 'Number Chain'],
]);