<?php

namespace App\Support\Badges;

use Closure;

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

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

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

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

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

    public static function spec(BadgeDomain $domain, mixed $state): BadgeSpec
    {
        return BadgeCatalog::spec($domain, $state);
    }
}
