<?php

namespace App\Support\Badges;

use Closure;

final class TagBadgeRenderer
{
    public static function label(TagBadgeDomain $domain): Closure
    {
        return static function (mixed $state, mixed ...$args) use ($domain): string {
            return TagBadgeCatalog::spec($domain, $state)->label;
        };
    }

    public static function color(TagBadgeDomain $domain): Closure
    {
        return static function (mixed $state, mixed ...$args) use ($domain): string {
            return TagBadgeCatalog::spec($domain, $state)->color;
        };
    }

    public static function icon(TagBadgeDomain $domain): Closure
    {
        return static function (mixed $state, mixed ...$args) use ($domain): ?string {
            return TagBadgeCatalog::spec($domain, $state)->icon;
        };
    }

    public static function iconColor(TagBadgeDomain $domain): Closure
    {
        return static function (mixed $state, mixed ...$args) use ($domain): ?string {
            $spec = TagBadgeCatalog::spec($domain, $state);

            return $spec->iconColor ?? $spec->color;
        };
    }

    public static function spec(TagBadgeDomain $domain, mixed $state): TagBadgeSpec
    {
        return TagBadgeCatalog::spec($domain, $state);
    }
}
