<?php

namespace App\Support\Badges\Domains;

use App\Support\Badges\BadgeCatalog;
use App\Support\Badges\BadgeMapper;
use App\Support\Badges\BadgeSpec;

final class TenantRbacStatusBadge implements BadgeMapper
{
    public function spec(mixed $value): BadgeSpec
    {
        $state = BadgeCatalog::normalizeState($value);

        return match ($state) {
            'ok' => new BadgeSpec('OK', 'success', 'heroicon-m-check-circle'),
            'configured' => new BadgeSpec('Configured', 'success', 'heroicon-m-check-circle'),
            'manual_assignment_required' => new BadgeSpec('Manual assignment required', 'warning', 'heroicon-m-exclamation-triangle'),
            'not_configured' => new BadgeSpec('Not configured', 'gray', 'heroicon-m-minus-circle'),
            'degraded' => new BadgeSpec('Degraded', 'warning', 'heroicon-m-exclamation-triangle'),
            'stale' => new BadgeSpec('Stale', 'warning', 'heroicon-m-clock'),
            'error' => new BadgeSpec('Error', 'danger', 'heroicon-m-x-circle'),
            'failed' => new BadgeSpec('Failed', 'danger', 'heroicon-m-x-circle'),
            default => BadgeSpec::unknown(),
        };
    }
}
