<?php

declare(strict_types=1);

namespace App\Framework\Console\Layout;

enum TerminalBreakpoint: string
{
    case EXTRA_SMALL = 'xs';  // < 60 chars
    case SMALL = 'sm';        // 60-79 chars
    case MEDIUM = 'md';       // 80-119 chars
    case LARGE = 'lg';        // 120-159 chars
    case EXTRA_LARGE = 'xl';  // >= 160 chars

    public function getMinWidth(): int
    {
        return match ($this) {
            self::EXTRA_SMALL => 0,
            self::SMALL => 60,
            self::MEDIUM => 80,
            self::LARGE => 120,
            self::EXTRA_LARGE => 160,
        };
    }

    public function getMaxWidth(): ?int
    {
        return match ($this) {
            self::EXTRA_SMALL => 59,
            self::SMALL => 79,
            self::MEDIUM => 119,
            self::LARGE => 159,
            self::EXTRA_LARGE => null, // No maximum
        };
    }

    public function getDescription(): string
    {
        return match ($this) {
            self::EXTRA_SMALL => 'Extra Small (< 60 chars)',
            self::SMALL => 'Small (60-79 chars)',
            self::MEDIUM => 'Medium (80-119 chars)',
            self::LARGE => 'Large (120-159 chars)',
            self::EXTRA_LARGE => 'Extra Large (160+ chars)',
        };
    }

    public function getColumnCount(): int
    {
        return match ($this) {
            self::EXTRA_SMALL => 1,
            self::SMALL => 1,
            self::MEDIUM => 2,
            self::LARGE => 3,
            self::EXTRA_LARGE => 4,
        };
    }

    public function getTableWidth(): int
    {
        return match ($this) {
            self::EXTRA_SMALL => 50,
            self::SMALL => 70,
            self::MEDIUM => 80,
            self::LARGE => 110,
            self::EXTRA_LARGE => 140,
        };
    }

    public function shouldTruncateText(): bool
    {
        return $this === self::EXTRA_SMALL || $this === self::SMALL;
    }

    public function getMaxTextLength(): int
    {
        return match ($this) {
            self::EXTRA_SMALL => 30,
            self::SMALL => 50,
            self::MEDIUM => 70,
            self::LARGE => 100,
            self::EXTRA_LARGE => 120,
        };
    }
}
