<?php

namespace Database\Seeders;

use App\Models\User\Permission;
use Illuminate\Database\Seeder;

class PermissionSeeder extends Seeder
{
    public function run(): void
    {
        $permissions = [

            /*
            |--------------------------------------------------------------------------
            | USERS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'users.view',
                'group'       => 'Users',
                'label'       => 'View users',
                'description' => 'View user lists and individual user profiles',
            ],
            [
                'name'        => 'users.create',
                'group'       => 'Users',
                'label'       => 'Create users',
                'description' => 'Create new user accounts',
            ],
            [
                'name'        => 'users.update',
                'group'       => 'Users',
                'label'       => 'Edit users',
                'description' => 'Edit existing user details and status',
            ],
            [
                'name'        => 'users.delete',
                'group'       => 'Users',
                'label'       => 'Delete users',
                'description' => 'Permanently delete user accounts',
            ],
            [
                'name'        => 'users.impersonate',
                'group'       => 'Users',
                'label'       => 'Impersonate users',
                'description' => 'Log in as another user for support or troubleshooting',
            ],
            [
                'name'        => 'users.sessions.manage',
                'group'       => 'Users',
                'label'       => 'Manage user sessions',
                'description' => 'Revoke active sessions and log users out of devices',
            ],
            [
                'name'        => 'users.api-keys.manage',
                'group'       => 'Users',
                'label'       => 'Manage API keys',
                'description' => 'Create and revoke API tokens for users',
            ],

            /*
            |--------------------------------------------------------------------------
            | ROLES
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'roles.view',
                'group'       => 'Roles',
                'label'       => 'View roles',
                'description' => 'View roles and their assigned permissions',
            ],
            [
                'name'        => 'roles.create',
                'group'       => 'Roles',
                'label'       => 'Create roles',
                'description' => 'Create new roles',
            ],
            [
                'name'        => 'roles.update',
                'group'       => 'Roles',
                'label'       => 'Edit roles',
                'description' => 'Edit role names and permissions',
            ],
            [
                'name'        => 'roles.delete',
                'group'       => 'Roles',
                'label'       => 'Delete roles',
                'description' => 'Delete non-system roles',
            ],

            /*
            |--------------------------------------------------------------------------
            | PERMISSIONS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'permissions.view',
                'group'       => 'Permissions',
                'label'       => 'View permissions',
                'description' => 'View system permissions and their usage',
            ],
            [
                'name'        => 'permissions.create',
                'group'       => 'Permissions',
                'label'       => 'Create permissions',
                'description' => 'Create new permissions',
            ],
            [
                'name'        => 'permissions.edit',
                'group'       => 'Permissions',
                'label'       => 'Edit permission descriptions',
                'description' => 'Edit permission descriptions',
            ],
            /*
            |--------------------------------------------------------------------------
            | TRANCHES
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'tranches.view',
                'group'       => 'Tranches',
                'label'       => 'View tranches',
                'description' => 'View tranche lists and details',
            ],
            [
                'name'        => 'tranches.create',
                'group'       => 'Tranches',
                'label'       => 'Create tranches',
                'description' => 'Create new tranches',
            ],
            [
                'name'        => 'tranches.edit',
                'group'       => 'Tranches',
                'label'       => 'Edit tranches',
                'description' => 'Edit existing tranches',
            ],
            [
                'name'        => 'tranches.delete',
                'group'       => 'Tranches',
                'label'       => 'Delete tranches',
                'description' => 'Delete tranches',
            ],

            /*
            |--------------------------------------------------------------------------
            | CLIENTS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'clients.view',
                'group'       => 'Clients',
                'label'       => 'View clients',
                'description' => 'View client lists and profiles',
            ],
            [
                'name'        => 'clients.create',
                'group'       => 'Clients',
                'label'       => 'Create clients',
                'description' => 'Create new clients',
            ],
            [
                'name'        => 'clients.edit',
                'group'       => 'Clients',
                'label'       => 'Edit clients',
                'description' => 'Edit existing client details',
            ],
            [
                'name'        => 'clients.delete',
                'group'       => 'Clients',
                'label'       => 'Delete clients',
                'description' => 'Delete clients from the system',
            ],

            /*
            |--------------------------------------------------------------------------
            | CLAIMS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'claims.view',
                'group'       => 'Claims',
                'label'       => 'View claims',
                'description' => 'View claim lists and details',
            ],
            [
                'name'        => 'claims.create',
                'group'       => 'Claims',
                'label'       => 'Create claims',
                'description' => 'Register new claims',
            ],
            [
                'name'        => 'claims.edit',
                'group'       => 'Claims',
                'label'       => 'Edit claims',
                'description' => 'Update claim information',
            ],
            [
                'name'        => 'claims.delete',
                'group'       => 'Claims',
                'label'       => 'Delete claims',
                'description' => 'Delete claims',
            ],

            /*
            |--------------------------------------------------------------------------
            | INSTITUTIONS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'institutions.view',
                'group'       => 'Institutions',
                'label'       => 'View institutions',
                'description' => 'View institution lists and details',
            ],
            [
                'name'        => 'institutions.create',
                'group'       => 'Institutions',
                'label'       => 'Create institutions',
                'description' => 'Add new institutions',
            ],
            [
                'name'        => 'institutions.edit',
                'group'       => 'Institutions',
                'label'       => 'Edit institutions',
                'description' => 'Edit existing institutions',
            ],
            [
                'name'        => 'institutions.delete',
                'group'       => 'Institutions',
                'label'       => 'Delete institutions',
                'description' => 'Delete institutions',
            ],

            /*
            |--------------------------------------------------------------------------
            | INSTITUTION CONTACTS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'institutions.contacts.create',
                'group'       => 'Institution Contacts',
                'label'       => 'Create contacts',
                'description' => 'Create new institution contacts',
            ],
            [
                'name'        => 'institutions.contacts.edit',
                'group'       => 'Institution Contacts',
                'label'       => 'Edit contacts',
                'description' => 'Edit existing institution contacts',
            ],
            [
                'name'        => 'institutions.contacts.delete',
                'group'       => 'Institution Contacts',
                'label'       => 'Delete contacts',
                'description' => 'Delete institution contacts',
            ],
          
            /*
            |--------------------------------------------------------------------------
            | INSTITUTION LINKS
            |--------------------------------------------------------------------------
            */

            [
                'name'        => 'institutions.links.create',
                'group'       => 'Institution Links',
                'label'       => 'Create links',
                'description' => 'Link institutions together or to other entities',
            ],
            [
                'name'        => 'institutions.links.delete',
                'group'       => 'Institution Links',
                'label'       => 'Delete links',
                'description' => 'Remove links between institutions or entities',
            ],

            /*
            |--------------------------------------------------------------------------
            | CLAIM INSTITUTIONS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'claims.institutions.create',
                'group'       => 'Claim Institutions',
                'label'       => 'Link institution to claim',
                'description' => 'Add an institution to a claim with a record type and dates',
            ],
            [
                'name'        => 'claims.institutions.delete',
                'group'       => 'Claim Institutions',
                'label'       => 'Remove institution from claim',
                'description' => 'Unlink an institution record from a claim',
            ],

            /*
            |--------------------------------------------------------------------------
            | INSTITUTION RECORD TYPES
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'institution-record-types.view',
                'group'       => 'Institution Record Types',
                'label'       => 'View institution record types',
                'description' => 'View the list of institution record types',
            ],
            [
                'name'        => 'institution-record-types.create',
                'group'       => 'Institution Record Types',
                'label'       => 'Create institution record types',
                'description' => 'Add new institution record types',
            ],
            [
                'name'        => 'institution-record-types.edit',
                'group'       => 'Institution Record Types',
                'label'       => 'Edit institution record types',
                'description' => 'Edit existing institution record types',
            ],
            [
                'name'        => 'institution-record-types.delete',
                'group'       => 'Institution Record Types',
                'label'       => 'Delete institution record types',
                'description' => 'Delete institution record types',
            ],

            /*
            |--------------------------------------------------------------------------
            | LEAD SOURCES
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'sources.view',
                'group'       => 'Lead Sources',
                'label'       => 'View lead sources',
                'description' => 'View lead source lists',
            ],
            [
                'name'        => 'sources.create',
                'group'       => 'Lead Sources',
                'label'       => 'Create lead sources',
                'description' => 'Add new lead sources',
            ],
            [
                'name'        => 'sources.edit',
                'group'       => 'Lead Sources',
                'label'       => 'Edit lead sources',
                'description' => 'Edit existing lead sources',
            ],
            [
                'name'        => 'sources.delete',
                'group'       => 'Lead Sources',
                'label'       => 'Delete lead sources',
                'description' => 'Delete lead sources',
            ],

            /*
            |--------------------------------------------------------------------------
            | LEAD SOURCE ENDPOINTS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'sources.endpoints.view',
                'group'       => 'Lead Source Endpoints',
                'label'       => 'View lead source endpoints',
                'description' => 'View lead source endpoint lists',
            ],
            [
                'name'        => 'sources.endpoints.create',
                'group'       => 'Lead Source Endpoints',
                'label'       => 'Create lead source endpoints',
                'description' => 'Add new lead source endpoints',
            ],
            [
                'name'        => 'sources.endpoints.edit',
                'group'       => 'Lead Source Endpoints',
                'label'       => 'Edit lead source endpoints',
                'description' => 'Edit existing lead source endpoints',
            ],
            [
                'name'        => 'sources.endpoints.delete',
                'group'       => 'Lead Source Endpoints',
                'label'       => 'Delete lead source endpoints',
                'description' => 'Delete lead source endpoints',
            ],

            /*
            |--------------------------------------------------------------------------
            | REPORTS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'reports.view',
                'group'       => 'Reports',
                'label'       => 'View reports',
                'description' => 'View any report',
            ],
            [
                'name'        => 'reports.tranches.view',
                'group'       => 'Reports',
                'label'       => 'View tranche report',
                'description' => 'View the summary report for tranches',
            ],
            [
                'name'        => 'reports.tranches.details',
                'group'       => 'Reports',
                'label'       => 'View tranche report details',
                'description' => 'View detailed breakdown within the tranche report',
            ],
            [
                'name'        => 'reports.tranches.export',
                'group'       => 'Reports',
                'label'       => 'Export tranche report',
                'description' => 'Export tranche report data to external formats',
            ],
            [
                'name'        => 'reports.trends',
                'group'       => 'Reports',
                'label'       => 'View the trends report',
                'description' => 'View any trends report',
            ],

            [
                'name'        => 'reports.tranches.export',
                'group'       => 'Reports',
                'label'       => 'Export tranche report',
                'description' => 'Export tranche report data to external formats',
            ],
            
            [
                'name'        => 'reports.wip.view',
                'group'       => 'Reports',
                'label'       => 'View WIP reports',
                'description' => 'View WIP reports by campaign and investment tranche',
            ],
            
            [
                'name'        => 'reports.wip.tracking',
                'group'       => 'Reports',
                'label'       => 'View WIP tracking',
                'description' => 'View daily, weekly and monthly WIP tracking dashboards',
            ],
            
            [
                'name'        => 'reports.trends',
                'group'       => 'Reports',
                'label'       => 'View the trends report',
                'description' => 'View any trends report',
            ],

            [
                'name'        => 'sources.endpoints.toggle',
                'group'       => 'Lead Source Endpoints',
                'label'       => 'Toggle source endpoints',
                'description' => 'Enable or disable specific source endpoints',
            ],
            [
                'name'        => 'sources.toggle',
                'group'       => 'Lead Sources',
                'label'       => 'Toggle sources',
                'description' => 'Enable or disable lead sources',
            ],
            [
                'name'        => 'sources.view.single',
                'group'       => 'Lead Sources',
                'label'       => 'View single source',
                'description' => 'View detailed information for a specific source',
            ],
            [
                'name'        => 'reports.status',
                'group'       => 'Reports',
                'label'       => 'View status report',
                'description' => 'Access the status report',
            ],
            [
                'name'        => 'reports.status.days',
                'group'       => 'Reports',
                'label'       => 'View report daily status',
                'description' => 'View days in status report',
            ],
            [
                'name'        => 'reports.status.claims',
                'group'       => 'Reports',
                'label'       => 'View status report claims',
                'description' => 'View claims in status report',
            ],
            [
                'name'        => 'reports.latest-actions.view',
                'group'       => 'Reports',
                'label'       => 'View latest actions report',
                'description' => 'View the latest actions report across users and records',
            ],
            [
                'name'        => 'reports.system-changes.view',
                'group'       => 'Reports',
                'label'       => 'View system changes report',
                'description' => 'View admin/system change history (users, roles, permissions, tags, statuses, etc.)',
            ],
            [
                'name'        => 'reports.agent-availability.view',
                'group'       => 'Reports',
                'label'       => 'View agent availability report',
                'description' => 'View the day-by-day timeline of agent presence (available/busy/wrap-up/offline)',
            ],
            [
                'name'        => 'reports.estimated-value.tranches',
                'group'       => 'Reports',
                'label'       => 'View estimated value by funding tranche',
                'description' => 'View estimated claim value grouped by client funding tranche',
            ],
            [
                'name'        => 'dashboard.view',
                'group'       => 'Dashboard',
                'label'       => 'View dashboard',
                'description' => 'Access the main dashboard overview',
            ],
            [
                'name'        => 'lead-performance.view',
                'group'       => 'Dashboard',
                'label'       => 'View lead performance dashboard',
                'description' => 'Access lead volume, contact and conversion performance reporting',
            ],
            [
                'name'        => 'users.roles.manage',
                'group'       => 'Users',
                'label'       => 'Manage user roles',
                'description' => 'Assign and remove roles from users',
            ],
            [
                'name'        => 'users.status.toggle',
                'group'       => 'Users',
                'label'       => 'Toggle user status',
                'description' => 'Enable or disable user accounts',
            ],
            [
                'name'        => 'users.view.single',
                'group'       => 'Users',
                'label'       => 'View single user',
                'description' => 'View detailed information for a specific user profile',
            ],
            [
                'name'        => 'users.profile.manage',
                'group'       => 'Users',
                'label'       => 'Manage user profiles',
                'description' => 'Edit and update user profile information',
            ],
            [
                'name'        => 'institutions.view.single',
                'group'       => 'Institutions',
                'label'       => 'View single institution',
                'description' => 'View details for a specific institution',
            ],
            [
                'name'        => 'claims.application.generate',
                'group'       => 'Claims',
                'label'       => 'Generate claim applications',
                'description' => 'Create and generate application documents for claims',
            ],
            [
                'name'        => 'claims.request.send',
                'group'       => 'Claims',
                'label'       => 'Send claim requests',
                'description' => 'Submit an esign request for the claim',
            ],
            [
                'name'        => 'dsars.view',
                'group'       => 'DSARs',
                'label'       => 'View DSARs',
                'description' => 'View Data Subject Access Request lists and details',
            ],
            [
                'name'        => 'dsars.types.view',
                'group'       => 'DSARs',
                'label'       => 'View DSAR types',
                'description' => 'View the different categories and types of DSAR configurations',
            ],
            [
                'name'        => 'dsars.types.create',
                'group'       => 'DSARs',
                'label'       => 'Create DSAR types',
                'description' => 'Create new DSAR type configurations',
            ],
            [
                'name'        => 'dsars.types.edit',
                'group'       => 'DSARs',
                'label'       => 'Edit DSAR types',
                'description' => 'Edit existing DSAR type configurations',
            ],
            [
                'name'        => 'dsars.types.delete',
                'group'       => 'DSARs',
                'label'       => 'Delete DSAR types',
                'description' => 'Delete DSAR type configurations',
            ],
            [
                'name'        => 'dsars.responses.log',
                'group'       => 'DSARs',
                'label'       => 'Log DSAR responses',
                'description' => 'Log a response received against a DSAR',
            ],
            [
                'name'        => 'dsars.tranche.view',
                'group'       => 'DSARs',
                'label'       => 'View DSAR tranche',
                'description' => 'View a DSAR tranche and its associated requests',
            ],
            [
                'name'        => 'dsars.batch.send',
                'group'       => 'DSARs',
                'label'       => 'Send DSAR batch',
                'description' => 'Send an approved batch of DSARs in a tranche',
            ],
            [
                'name'        => 'dsars.report',
                'group'       => 'DSARs',
                'label'       => 'View DSAR report',
                'description' => 'View the DSAR activity report',
            ],

            [
                'name'        => 'notes.view',
                'group'       => 'Notes',
                'label'       => 'View notes',
                'description' => 'View lists and individual content of system notes',
            ],
            [
                'name'        => 'notes.create',
                'group'       => 'Notes',
                'label'       => 'Create notes',
                'description' => 'Create and attach new notes to records',
            ],
            [
                'name'        => 'notes.delete',
                'group'       => 'Notes',
                'label'       => 'Delete notes',
                'description' => 'Remove notes from the system',
            ],

            [
                'name'        => 'notes.primary.delete',
                'group'       => 'Notes',
                'label'       => 'Delete key info',
                'description' => 'Remove key info from a client',
            ],
            [
                'name'        => 'tasks.admin',
                'group'       => 'Task Manager',
                'label'       => 'View task hub',
                'description' => 'Have an admin view over everyones tasks',
            ],
            [
                'name'        => 'tasks.create',
                'group'       => 'Task Manager',
                'label'       => 'Create tasks',
                'description' => 'Create new tasks on client, claim, and other records',
            ],
            [
                'name'        => 'tasks.edit',
                'group'       => 'Task Manager',
                'label'       => 'Edit tasks',
                'description' => 'Edit existing tasks on records',
            ],
            [
                'name'        => 'tasks.delete',
                'group'       => 'Task Manager',
                'label'       => 'Delete tasks',
                'description' => 'Delete tasks from records',
            ],
            [
                'name'        => 'tasks.complete',
                'group'       => 'Task Manager',
                'label'       => 'Complete tasks',
                'description' => 'Mark tasks as completed',
            ],
            [
                'name'        => 'clients.tranche.view',
                'group'       => 'Clients',
                'label'       => 'View Client Tranche',
                'description' => 'View the client tranche on listing pages',
            ],
            [
                'name'        => 'users.history.view',
                'group'       => 'Users',
                'label'       => 'View User Log',
                'description' => 'View history tab on a user profile'
            ], [
                'name'        => 'monitoring.view',
                'group'       => 'Monitoring',
                'label'       => 'View Monitoring',
                'description' => 'View monitoring tab'
            ],

            /*
            |--------------------------------------------------------------------------
            | CLIENT RELATIONS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'clients.relations.view',
                'group'       => 'Clients',
                'label'       => 'View client relations',
                'description' => 'View connections and relations between clients',
            ],
            [
                'name'        => 'clients.relations.create',
                'group'       => 'Clients',
                'label'       => 'Create client relations',
                'description' => 'Create new relations between clients',
            ],
            [
                'name'        => 'clients.relations.edit',
                'group'       => 'Clients',
                'label'       => 'Edit client relations',
                'description' => 'Edit existing client relations',
            ],
            [
                'name'        => 'clients.relations.delete',
                'group'       => 'Clients',
                'label'       => 'Delete client relations',
                'description' => 'Delete client relations',
            ],

            /*
            |--------------------------------------------------------------------------
            | INSTITUTION MERGE
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'institutions.merge',
                'group'       => 'Institutions',
                'label'       => 'Merge institutions',
                'description' => 'Merge two institution records into one',
            ],

            /*
            |--------------------------------------------------------------------------
            | SOLICITORS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'solicitors.view',
                'group'       => 'Solicitors',
                'label'       => 'View solicitors',
                'description' => 'View solicitor lists and profiles',
            ],
            [
                'name'        => 'solicitors.create',
                'group'       => 'Solicitors',
                'label'       => 'Create solicitors',
                'description' => 'Create new solicitor records',
            ],
            [
                'name'        => 'solicitors.edit',
                'group'       => 'Solicitors',
                'label'       => 'Edit solicitors',
                'description' => 'Edit existing solicitor details',
            ],
            [
                'name'        => 'solicitors.delete',
                'group'       => 'Solicitors',
                'label'       => 'Delete solicitors',
                'description' => 'Delete solicitor records',
            ],

            /*
            |--------------------------------------------------------------------------
            | TEMPLATES
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'templates.view',
                'group'       => 'Templates',
                'label'       => 'View templates',
                'description' => 'View template lists',
            ],
            [
                'name'        => 'templates.create',
                'group'       => 'Templates',
                'label'       => 'Create templates',
                'description' => 'Create new templates',
            ],
            [
                'name'        => 'templates.edit',
                'group'       => 'Templates',
                'label'       => 'Edit templates',
                'description' => 'Edit existing templates',
            ],
            [
                'name'        => 'templates.delete',
                'group'       => 'Templates',
                'label'       => 'Delete templates',
                'description' => 'Delete templates',
            ],

            /*
            |--------------------------------------------------------------------------
            | DOCUMENT TYPES
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'doc-types.view',
                'group'       => 'Document Types',
                'label'       => 'View document types',
                'description' => 'View document type definitions',
            ],
            [
                'name'        => 'doc-types.create',
                'group'       => 'Document Types',
                'label'       => 'Create document types',
                'description' => 'Create new document type definitions',
            ],
            [
                'name'        => 'doc-types.edit',
                'group'       => 'Document Types',
                'label'       => 'Edit document types',
                'description' => 'Edit existing document type definitions',
            ],
            [
                'name'        => 'doc-types.delete',
                'group'       => 'Document Types',
                'label'       => 'Delete document types',
                'description' => 'Delete document type definitions',
            ],

            /*
            |--------------------------------------------------------------------------
            | KEY DATES
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'key-dates.view',
                'group'       => 'Key Dates',
                'label'       => 'View key date definitions',
                'description' => 'View key date type definitions',
            ],
            [
                'name'        => 'key-dates.create',
                'group'       => 'Key Dates',
                'label'       => 'Create key date definitions',
                'description' => 'Create new key date type definitions',
            ],
            [
                'name'        => 'key-dates.edit',
                'group'       => 'Key Dates',
                'label'       => 'Edit key date definitions',
                'description' => 'Edit existing key date type definitions',
            ],
            [
                'name'        => 'key-dates.delete',
                'group'       => 'Key Dates',
                'label'       => 'Delete key date definitions',
                'description' => 'Delete key date type definitions',
            ],

            /*
            |--------------------------------------------------------------------------
            | TAGS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'tags.view',
                'group'       => 'Tags',
                'label'       => 'View tags',
                'description' => 'View tag definitions',
            ],
            [
                'name'        => 'tags.create',
                'group'       => 'Tags',
                'label'       => 'Create tags',
                'description' => 'Create new tags',
            ],
            [
                'name'        => 'tags.edit',
                'group'       => 'Tags',
                'label'       => 'Edit tags',
                'description' => 'Edit existing tags',
            ],
            [
                'name'        => 'tags.delete',
                'group'       => 'Tags',
                'label'       => 'Delete tags',
                'description' => 'Delete tags',
            ],

            /*
            |--------------------------------------------------------------------------
            | STATUSES
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'statuses.view',
                'group'       => 'Statuses',
                'label'       => 'View claim statuses',
                'description' => 'View claim status definitions',
            ],
            [
                'name'        => 'statuses.create',
                'group'       => 'Statuses',
                'label'       => 'Create claim statuses',
                'description' => 'Create new claim status definitions',
            ],
            [
                'name'        => 'statuses.edit',
                'group'       => 'Statuses',
                'label'       => 'Edit claim statuses',
                'description' => 'Edit existing claim status definitions',
            ],
            [
                'name'        => 'statuses.delete',
                'group'       => 'Statuses',
                'label'       => 'Delete claim statuses',
                'description' => 'Delete claim status definitions',
            ],

            /*
            |--------------------------------------------------------------------------
            | INSTITUTION TYPES
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'institution-types.view',
                'group'       => 'Institution Types',
                'label'       => 'View institution types',
                'description' => 'View institution type definitions',
            ],
            [
                'name'        => 'institution-types.create',
                'group'       => 'Institution Types',
                'label'       => 'Create institution types',
                'description' => 'Create new institution type definitions',
            ],
            [
                'name'        => 'institution-types.edit',
                'group'       => 'Institution Types',
                'label'       => 'Edit institution types',
                'description' => 'Edit existing institution type definitions',
            ],
            [
                'name'        => 'institution-types.delete',
                'group'       => 'Institution Types',
                'label'       => 'Delete institution types',
                'description' => 'Delete institution type definitions',
            ],

            /*
            |--------------------------------------------------------------------------
            | PRINT QUEUE
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'print-queue.view',
                'group'       => 'Print Queue',
                'label'       => 'View print queue',
                'description' => 'View the print queue and its pending items',
            ],
            [
                'name'        => 'print-queue.manage',
                'group'       => 'Print Queue',
                'label'       => 'Manage print queue',
                'description' => 'Remove items from and print the print queue',
            ],

            /*
            |--------------------------------------------------------------------------
            | COMMUNICATIONS (Contact Hub)
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'communications.send.email',
                'group'       => 'Communications',
                'label'       => 'Send emails',
                'description' => 'Send outbound emails from the Contact Hub',
            ],
            [
                'name'        => 'communications.send.sms',
                'group'       => 'Communications',
                'label'       => 'Send SMS',
                'description' => 'Send outbound SMS messages from the Contact Hub',
            ],
            [
                'name'        => 'communications.send.bulk',
                'group'       => 'Communications',
                'label'       => 'Send bulk emails',
                'description' => 'Send a template email to all clients matching a filter',
            ],
            [
                'name'        => 'communications.send.force',
                'group'       => 'Communications',
                'label'       => 'Override send validation',
                'description' => 'Bypass recipient/suppression validation when sending',
            ],
            [
                'name'        => 'communications.templates.manage',
                'group'       => 'Communications',
                'label'       => 'Manage templates',
                'description' => 'Create, edit, and delete email/SMS templates',
            ],
            [
                'name'        => 'communications.triggers.manage',
                'group'       => 'Communications',
                'label'       => 'Manage automatic triggers',
                'description' => 'Configure automatic sends on status changes, tags, and other events',
            ],
            [
                'name'        => 'communications.logs.view.own',
                'group'       => 'Communications',
                'label'       => 'View own communications log',
                'description' => 'View communications sent by this user',
            ],
            [
                'name'        => 'communications.logs.view.all',
                'group'       => 'Communications',
                'label'       => 'View all communications logs',
                'description' => 'View all communications across the tenant',
            ],
            [
                'name'        => 'communications.recordings.view.all',
                'group'       => 'Communications',
                'label'       => 'View all call recordings',
                'description' => 'Stream and download call recordings for any agent across the tenant',
            ],
            [
                'name'        => 'communications.agents.view.all_workspaces',
                'group'       => 'Communications',
                'label'       => 'View agents across all workspaces',
                'description' => 'See dialler agent availability for every solicitor workspace, including which workspace each agent is in. Without this, the dialler dashboard only shows agents in the current workspace.',
            ],
            [
                'name'        => 'communications.call.institution',
                'group'       => 'Communications',
                'label'       => 'Call DSAR institutions',
                'description' => 'Place outbound calls to a DSAR institution contact from a client record',
            ],
            [
                'name'        => 'communications.call.adhoc',
                'group'       => 'Communications',
                'label'       => 'Use the ad-hoc dialpad',
                'description' => 'Dial an arbitrary number from the softphone keypad, optionally attaching a client',
            ],
            /*
            |--------------------------------------------------------------------------
            | DOCUMENTS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'documents.upload',
                'group'       => 'Documents',
                'label'       => 'Upload documents',
                'description' => 'Upload and attach documents to clients, claims, DSARs, and institutions',
            ],
            [
                'name'        => 'documents.delete',
                'group'       => 'Documents',
                'label'       => 'Delete documents',
                'description' => 'Permanently delete documents from records',
            ],
            [
                'name'        => 'documents.print',
                'group'       => 'Documents',
                'label'       => 'Add documents to print queue',
                'description' => 'Send documents to the print queue for printing',
            ],

            /*
            |--------------------------------------------------------------------------
            | CLAIMS — additional granular permissions
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'claims.status.view',
                'group'       => 'Claims',
                'label'       => 'View claim status history',
                'description' => 'View the status change history log for a claim',
            ],
            [
                'name'        => 'claims.status.edit',
                'group'       => 'Claims',
                'label'       => 'Update claim status',
                'description' => 'Change the status of a claim',
            ],
            [
                'name'        => 'claims.key-dates.edit',
                'group'       => 'Claims',
                'label'       => 'Edit claim key dates',
                'description' => 'Set and clear key dates on a claim',
            ],

            /*
            |--------------------------------------------------------------------------
            | DSARS — additional granular permissions
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'dsars.create',
                'group'       => 'DSARs',
                'label'       => 'Create DSAR batches',
                'description' => 'Create new DSAR tranches and batches for a claim',
            ],
            [
                'name'        => 'dsars.mark-posted',
                'group'       => 'DSARs',
                'label'       => 'Mark DSARs as posted',
                'description' => 'Mark physical DSAR letters as posted/sent',
            ],
            [
                'name'        => 'dsars.delete',
                'group'       => 'DSARs',
                'label'       => 'Delete DSARs',
                'description' => 'Delete individual DSARs and draft DSAR tranches',
            ],

            /*
            |--------------------------------------------------------------------------
            | CLIENTS — additional granular permissions
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'clients.handlers.manage',
                'group'       => 'Clients',
                'label'       => 'Manage case handlers',
                'description' => 'Assign and change case handlers on a client record',
            ],

            /*
            |--------------------------------------------------------------------------
            | WITNESS STATEMENTS
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'clients.witness.view',
                'group'       => 'Witness Statements',
                'label'       => 'View witness statements',
                'description' => 'View the witness statement workspace, questionnaire and exhibits',
            ],
            [
                'name'        => 'clients.witness.edit',
                'group'       => 'Witness Statements',
                'label'       => 'Edit witness statements',
                'description' => 'Answer questions, accept/reject suggestions and manage exhibits',
            ],
            [
                'name'        => 'clients.witness.generate',
                'group'       => 'Witness Statements',
                'label'       => 'Generate witness statements',
                'description' => 'Convert answers into a generated witness statement document',
            ],
            [
                'name'        => 'clients.witness.approve',
                'group'       => 'Witness Statements',
                'label'       => 'Approve witness statements',
                'description' => 'Mark a generated witness statement as approved',
            ],

            /*
            |--------------------------------------------------------------------------
            | WORKBOARD
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'workboard.view',
                'group'       => 'Workboard',
                'label'       => 'View workboard',
                'description' => 'View the workboard and pick up available items',
            ],
            [
                'name'        => 'workboard.manage',
                'group'       => 'Workboard',
                'label'       => 'Manage workboard',
                'description' => 'Create categories, add items to pots, and delete categories',
            ],

            /*
            |--------------------------------------------------------------------------
            | INBOX
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'inbox.view',
                'group'       => 'Inbox',
                'label'       => 'View inbox',
                'description' => 'View inbound emails received across all sender addresses',
            ],
            [
                'name'        => 'inbox.override_handler',
                'group'       => 'Inbox',
                'label'       => 'Override handler view',
                'description' => 'View and work another handler\'s triage queue (useful for cover when a colleague is away)',
            ],

            /*
            |--------------------------------------------------------------------------
            | E-SIGNATURES
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'esign.settings.manage',
                'group'       => 'E-Signatures',
                'label'       => 'Manage contracts & e-signature settings',
                'description' => "Manage the firm's contracts and Fintrixor e-signature credentials",
            ],

            /*
            |--------------------------------------------------------------------------
            | COMMUNICATIONS (settings)
            |--------------------------------------------------------------------------
            */
            [
                'name'        => 'communications.settings.manage',
                'group'       => 'Communications',
                'label'       => 'Manage communications settings',
                'description' => 'Manage scheme contact details and communications configuration',
            ],
        ];

        foreach ($permissions as $permission) {
            Permission::updateOrCreate(
                ['name' => $permission['name']],
                [
                    'group'       => $permission['group'],
                    'label'       => $permission['label'],
                    'description' => $permission['description'],
                    'guard_name'  => 'web',
                ]
            );
        }
    }
}
