<?php
declare(strict_types=1);

namespace PpPhp\Core\Designer\Visual;

final class DesignerHeaderVisualRuntime
{
    public function actions(): array
    {
        return [
            ['id'=>'undo','label'=>'Undo','group'=>'history','icon'=>'bi-arrow-counterclockwise'],
            ['id'=>'redo','label'=>'Redo','group'=>'history','icon'=>'bi-arrow-clockwise'],
            ['id'=>'save','label'=>'Save','group'=>'primary','icon'=>'bi-save'],
            ['id'=>'generate','label'=>'Generate','group'=>'build','icon'=>'bi-code-square','runtime'=>'R0100.6R'],
            ['id'=>'build','label'=>'Build','group'=>'build','icon'=>'bi-box-seam','runtime'=>'R0100.6S'],
            ['id'=>'preview','label'=>'Preview','group'=>'preview','icon'=>'bi-eye'],
        ];
    }

    public function viewModel(): array
    {
        $actions = $this->actions();
        return [
            'classes' => ['designer-header-v2'],
            'groups' => [
                'history' => array_values(array_filter($actions, static fn(array $a): bool => $a['group'] === 'history')),
                'primary' => array_values(array_filter($actions, static fn(array $a): bool => $a['group'] === 'primary')),
                'build' => array_values(array_filter($actions, static fn(array $a): bool => $a['group'] === 'build')),
                'preview' => array_values(array_filter($actions, static fn(array $a): bool => $a['group'] === 'preview')),
            ],
        ];
    }
}
