<?php

namespace App\Filament\Support;

use App\Filament\Forms\Components\PermissionOverridePicker;
use App\Filament\Forms\Components\PermissionPicker;
use App\Services\PermissionCatalog;

/**
 * The section → module → action permission picker for editors of a FLAT grant
 * set: RoleResource (a role's own permissions) and TenantResource's Entitlements
 * action (a tenant's ceiling). Built from {@see PermissionCatalog::matrix()} so
 * every permission editor in the app renders from one catalog.
 *
 * The per-user editor is deliberately NOT this component — a user's permissions
 * are an exception layer over their roles rather than a set of their own, so it
 * uses {@see PermissionOverridePicker}, which
 * stores inherit/grant/revoke instead of a flat list.
 */
class PermissionMatrix
{
    public static function checkboxList(string $name = 'permissions'): PermissionPicker
    {
        return PermissionPicker::make($name)
            ->label('Permissions')
            ->columnSpanFull();
    }
}
