<?php

declare(strict_types=1);

namespace App\Support\Badges\Domains;

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

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

        return match ($state) {
            'ok' => new BadgeSpec('OK', 'success', 'heroicon-m-check-circle'),
            'warn' => new BadgeSpec('Warn', 'warning', 'heroicon-m-exclamation-triangle'),
            'critical' => new BadgeSpec('Critical', 'danger', 'heroicon-m-x-circle'),
            'unknown' => BadgeSpec::unknown(),
            default => BadgeSpec::unknown(),
        };
    }
}
