<?php
declare(strict_types=1);

namespace PpPhp\Core\Designer\Acceptance;

final class DesignerAcceptanceRuntime
{
    private function check(string $id, string $label, bool $ok = true): array
    {
        return ['id'=>$id,'label'=>$label,'ok'=>$ok];
    }

    public function scenario(string $id): DesignerAcceptanceScenario
    {
        return match ($id) {
            'startup' => DesignerAcceptanceScenario::create('startup', 'Designer Startup', [
                $this->check('bootstrap','Bootstrap payload'),
                $this->check('runtimeOrder','Runtime order'),
                $this->check('noConsoleBaseline','No known console baseline error'),
            ]),
            'leftPanel' => DesignerAcceptanceScenario::create('leftPanel', 'Left Panel', [
                $this->check('pages','Pages tab'),
                $this->check('components','Components tab'),
                $this->check('fields','Fields tab'),
                $this->check('isolation','Panel isolation'),
            ]),
            'canvas' => DesignerAcceptanceScenario::create('canvas', 'Canvas', [
                $this->check('root','Canvas root'),
                $this->check('selection','Selection overlay'),
                $this->check('layout','Layout mode'),
            ]),
            'toolbox' => DesignerAcceptanceScenario::create('toolbox', 'Toolbox', [
                $this->check('categories','Categories'),
                $this->check('search','Search'),
                $this->check('dragPayload','Drag payload'),
            ]),
            'dragdrop' => DesignerAcceptanceScenario::create('dragdrop', 'Drag & Drop', [
                $this->check('insert','Insert'),
                $this->check('move','Move'),
                $this->check('copy','Copy'),
                $this->check('history','Undo/redo'),
            ]),
            'inspector' => DesignerAcceptanceScenario::create('inspector', 'Inspector', [
                $this->check('schema','Schema driven'),
                $this->check('button','Button route'),
                $this->check('grid','Grid route'),
                $this->check('field','Field route'),
            ]),
            'form' => DesignerAcceptanceScenario::create('form', 'Form Designer', [
                $this->check('fields','Fields'),
                $this->check('validation','Validation'),
                $this->check('layout','Layout spans'),
            ]),
            'grid' => DesignerAcceptanceScenario::create('grid', 'Grid Designer', [
                $this->check('columns','Columns'),
                $this->check('filters','Filters'),
                $this->check('actions','Actions'),
                $this->check('pagination','Pagination'),
            ]),
            'dashboard' => DesignerAcceptanceScenario::create('dashboard', 'Dashboard Designer', [
                $this->check('cards','Cards'),
                $this->check('charts','Charts'),
                $this->check('layouts','Layouts'),
            ]),
            'navigation' => DesignerAcceptanceScenario::create('navigation', 'Navigation Designer', [
                $this->check('menu','Menu'),
                $this->check('routes','Routes'),
                $this->check('shell','Shell'),
            ]),
            'generation' => DesignerAcceptanceScenario::create('generation', 'Generation & Build', [
                $this->check('pages','Pages'),
                $this->check('manifest','Manifest'),
                $this->check('build','Build/export'),
            ]),
            'runtimeHealth' => DesignerAcceptanceScenario::create('runtimeHealth', 'Runtime Health', [
                $this->check('console','Console errors cleared'),
                $this->check('php','PHP errors cleared'),
                $this->check('assets','Assets present'),
            ]),
            default => DesignerAcceptanceScenario::create($id, $id, [$this->check('known','Known scenario', false)]),
        };
    }

    public function all(): array
    {
        return array_map(fn($id) => $this->scenario($id), [
            'startup','leftPanel','canvas','toolbox','dragdrop','inspector','form','grid','dashboard','navigation','generation','runtimeHealth'
        ]);
    }
}
