<?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;
use App\Support\EnvironmentReviewStatus;

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

        return match ($state) {
            EnvironmentReviewStatus::Draft->value => new BadgeSpec('Draft', 'gray', 'heroicon-m-pencil-square'),
            EnvironmentReviewStatus::Ready->value => new BadgeSpec('Ready', 'info', 'heroicon-m-check-circle'),
            EnvironmentReviewStatus::Published->value => new BadgeSpec('Published', 'success', 'heroicon-m-check-badge'),
            EnvironmentReviewStatus::Archived->value => new BadgeSpec('Archived', 'gray', 'heroicon-m-archive-box'),
            EnvironmentReviewStatus::Superseded->value => new BadgeSpec('Superseded', 'warning', 'heroicon-m-arrow-path'),
            EnvironmentReviewStatus::Failed->value => new BadgeSpec('Failed', 'danger', 'heroicon-m-x-circle'),
            default => BadgeSpec::unknown(),
        };
    }
}
