<?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 InventoryCoverageStateBadge implements BadgeMapper
{
    public function spec(mixed $value): BadgeSpec
    {
        $state = BadgeCatalog::normalizeState($value);

        return match ($state) {
            'succeeded' => new BadgeSpec('Succeeded', 'success', 'heroicon-m-check-circle'),
            'failed' => new BadgeSpec('Failed', 'danger', 'heroicon-m-x-circle'),
            'skipped' => new BadgeSpec('Skipped', 'warning', 'heroicon-m-minus-circle'),
            'unknown' => new BadgeSpec('Unknown', 'gray', 'heroicon-m-question-mark-circle'),
            default => BadgeSpec::unknown(),
        };
    }
}
