<?php

namespace App\Support;

final class Permission
{
    const GROUPS = [
        'Ponds' => [
            'ponds.view' => 'View Ponds',
            'ponds.create' => 'Create Ponds',
            'ponds.edit' => 'Edit Ponds',
            'ponds.delete' => 'Delete Ponds',
        ],
        'Cycles' => [
            'cycles.view' => 'View Cycles',
            'cycles.create' => 'Create Cycles',
            'cycles.close' => 'Close Cycles',
        ],
        'Feeding' => [
            'feeding.view' => 'View Feeding Logs',
            'feeding.create' => 'Log Feeding',
            'feeding.delete' => 'Delete Feeding Logs',
        ],
        'Water Quality' => [
            'water_quality.view' => 'View Water Quality',
            'water_quality.create' => 'Log Water Quality',
        ],
        'Health & Mortality' => [
            'health.view' => 'View Health Records',
            'health.create' => 'Log Mortality / Treatment',
        ],
        'Sampling' => [
            'sampling.view' => 'View Sampling Records',
            'sampling.create' => 'Log Sampling',
        ],
        'Harvest' => [
            'harvest.view' => 'View Harvests',
            'harvest.create' => 'Record Harvest',
        ],
        'Sales' => [
            'sales.view' => 'View Sales',
            'sales.create' => 'Create Sales',
            'sales.update_payment' => 'Update Payment Status',
        ],
        'Inventory' => [
            'inventory.view' => 'View Inventory',
            'inventory.create' => 'Add Inventory Items',
            'inventory.edit' => 'Edit Inventory Items',
            'inventory.adjust' => 'Adjust Stock',
        ],
        'Finance' => [
            'finance.view' => 'View Finance',
            'finance.create' => 'Record Expenses',
            'finance.delete' => 'Delete Expenses',
        ],
        'Reports' => [
            'reports.view' => 'View Reports',
        ],
        'Settings' => [
            'settings.view' => 'View Settings',
            'settings.manage' => 'Manage Settings',
        ],
        'Users' => [
            'users.view' => 'View Users',
            'users.create' => 'Create Users',
            'users.edit' => 'Edit Users',
            'users.delete' => 'Delete Users',
            'users.impersonate' => 'Impersonate Users',
        ],
    ];

    public static function all(): array
    {
        return collect(self::GROUPS)
            ->flatMap(fn ($perms) => array_keys($perms))
            ->values()
            ->all();
    }
}
