<?php

namespace App\Enums;

enum StatusEnum: int
{
    case INACTIVE = 0;
    case ACTIVE   = 1;

    public static function labels(): array
    {
        return [
            self::INACTIVE->value => __('dashboard.inactive'),
            self::ACTIVE->value   => __('dashboard.active'),
        ];
    }

    public static function colors(): array
    {
        return [
            self::INACTIVE->value => 'danger',
            self::ACTIVE->value   => 'success',
        ];
    }

    public static function label(self|int|null $value): string
    {
        $key = $value instanceof self ? $value->value : $value;
        return self::labels()[$key] ?? '';
    }

    public static function color(self|int|null $value): string
    {
        $key = $value instanceof self ? $value->value : $value;
        return self::colors()[$key] ?? 'secondary';
    }

    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }

    public static function badge(self|int|null $value): string
    {
        $color = self::color($value);
        $label = self::label($value);
        return '<span class="badge bg-' . $color . '-subtle text-' . $color . '">' . $label . '</span>';
    }

    public static function options(): array
    {
        return collect(self::cases())->map(fn($case) => [
            'value' => $case->value,
            'label' => self::label($case),
        ])->toArray();
    }
}
