<?php

declare(strict_types=1);

namespace App\Support\Badges\Domains;

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

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

        return match ($state) {
            AuditOutcome::Success => new BadgeSpec('Success', 'success', 'heroicon-m-check-circle'),
            AuditOutcome::Failed => new BadgeSpec('Failed', 'danger', 'heroicon-m-x-circle'),
            AuditOutcome::Partial => new BadgeSpec('Partial', 'warning', 'heroicon-m-exclamation-triangle'),
            AuditOutcome::Info => new BadgeSpec('Info', 'gray', 'heroicon-m-information-circle'),
            AuditOutcome::Blocked => new BadgeSpec('Blocked', 'warning', 'heroicon-m-no-symbol'),
        };
    }
}
