<?php
declare(strict_types=1);

namespace PpPhp\Core\Designer\Visual;

final class DesignerVisualRuntime
{
    public function compose(array $page = [], array $target = [], array $fields = [], array $components = []): array
    {
        return [
            'canvas' => (new DesignerCanvasRuntime())->clean($page, 'normal'),
            'selection' => (new DesignerSelectionOverlayRuntime())->target((string)($target['id'] ?? 'page'), (string)($target['type'] ?? 'page'), (array)($target['parentPath'] ?? [])),
            'inspector' => (new DesignerInspectorVisualRuntime())->inspectorFor($target ?: ['id'=>'page','type'=>'page']),
            'toolbox' => (new DesignerToolboxVisualRuntime())->viewModel($components),
            'fields' => (new DesignerFieldsIntegrationRuntime())->fieldBadges($fields),
            'header' => (new DesignerHeaderVisualRuntime())->viewModel(),
            'health' => (new DesignerRuntimeHealth())->check(),
            'classes' => ['designer-visual-runtime','designer-runtime-integrated'],
        ];
    }
}
