<?php

namespace Apexl\Io\Display\Pages;

use Apexl\Config\ConfigurationInterface;
use Apexl\Io\Component\Factories\GenericComponentFactory;
use Apexl\Io\Display\Page;
use Apexl\Io\Display\Regions\NoUIContentRegion;
use Apexl\Io\Display\Regions\PageContentRegion;
use Apexl\Io\HookManager;
use Apexl\Io\Menu\Services\MenuManager;
use Apexl\Io\Services\HttpPaths;
use Apexl\Io\Services\VariableManager;

/**
 * Class blankPage
 * A blank page with no UI, only a content region.
 * @package apexl\Io\modules\display\pages
 */
class BlankPage extends Page
{

    public function __construct(
        readonly private VariableManager $variableManager,
        ConfigurationInterface $config,
        MenuManager $menuManager,
        HttpPaths $path,
        GenericComponentFactory $componentFactory,
        HookManager $hookManager,
    ) {
        parent::__construct(
            $config,
            $menuManager,
            $path,
            $componentFactory,
            $hookManager,
        );
    }

    public function addToContent(array $components, ?int $weight = null): static
    {
        $this->addToRegion($components, NoUIContentRegion::class, $weight);

        return $this;
    }

    protected function buildRegions(): void
    {
        $this->globalRegion = new PageContentRegion()
            ->addWrapperClass($this->variableManager->get('noui_page_global_classes') ?? 'h-100');

        $this->globalRegion->addRegions([
            new NoUIContentRegion(),
        ]);
    }
}
