<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Terminy\Providers;

use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;
use Seka\Portal\Modul\Terminy\Composers\Udalosti\ZoznamBuducichUdalostiComposer;
use Seka\Portal\Modul\Terminy\Livewire\Backend\Adresar\Components\Form as AdresarFormComponent;
use Seka\Portal\Modul\Terminy\Livewire\Backend\Adresar\Components\Zoznam as AdresarZoznamComponent;
use Seka\Portal\Modul\Terminy\Livewire\Backend\Adresar\Pages\Index as AdresarIndexPage;
use Seka\Portal\Modul\Terminy\Livewire\Backend\Adresar\Pages\Nove as AdresarNovePage;
use Seka\Portal\Modul\Terminy\Livewire\Backend\Adresar\Pages\Upravit as AdresarUpravitPage;
use Seka\Portal\Modul\Terminy\Livewire\Backend\MoznostiUdalosti\Components\Form as MoznostiUdalostiFormComponent;
use Seka\Portal\Modul\Terminy\Livewire\Backend\MoznostiUdalosti\Components\Zoznam as MoznostiUdalostiZoznamComponent;
use Seka\Portal\Modul\Terminy\Livewire\Backend\MoznostiUdalosti\Pages\Index as MoznostiUdalostiIndexPage;
use Seka\Portal\Modul\Terminy\Livewire\Backend\MoznostiUdalosti\Pages\Nove as MoznostiUdalostiNovePage;
use Seka\Portal\Modul\Terminy\Livewire\Backend\MoznostiUdalosti\Pages\Upravit as MoznostiUdalostiUpravitPage;
use Seka\Portal\Modul\Terminy\Livewire\Backend\Udalosti\Components\Form as UdalostiFormComponent;
use Seka\Portal\Modul\Terminy\Livewire\Backend\Udalosti\Components\MoznostiUdalosti\Components\Form as BackendMoznostiUdalostiForm;
use Seka\Portal\Modul\Terminy\Livewire\Backend\Udalosti\Components\Registracie\Components\Form as RegistracieFormComponent;
use Seka\Portal\Modul\Terminy\Livewire\Backend\Udalosti\Components\Registracie\Components\Zoznam as RegistracieZoznamComponent;
use Seka\Portal\Modul\Terminy\Livewire\Backend\Udalosti\Components\Zoznam as UdalostiZoznamComponent;
use Seka\Portal\Modul\Terminy\Livewire\Backend\Udalosti\Pages\Index as UdalostiIndexPage;
use Seka\Portal\Modul\Terminy\Livewire\Backend\Udalosti\Pages\Nova as UdalostiNovaPage;
use Seka\Portal\Modul\Terminy\Livewire\Backend\Udalosti\Pages\Upravit as UdalostiUpravitPage;
use Seka\Portal\Modul\Terminy\Livewire\Components\Filtre\Pracoviska as FilterPracoviskaComponent;
use Seka\Portal\Modul\Terminy\Livewire\Components\Filtre\Stav as FilterStavComponent;
use Seka\Portal\Modul\Terminy\Livewire\Components\Udalosti\Druh as UdalostiDruhComponent;
use Seka\Portal\Modul\Terminy\Livewire\Components\Udalosti\Stav as UdalostiStavComponent;
use Seka\Portal\Modul\Terminy\Livewire\Frontend\Registracie\Components\Form as FrontendRegistracieFormComponent;
use Seka\Portal\Modul\Terminy\Livewire\Frontend\Registracie\Components\MoznostiUdalosti\Components\Form as BackendMoznostiFormComponent;

/**
 * Class ViewServiceProvider
 *
 * @package Seka\Portal\Modul\Terminy\Providers
 */
final class ViewServiceProvider extends ServiceProvider
{
    /**
     * @return void
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function boot(): void
    {
        $this->loadViewsFrom(__DIR__ . '/../Resources/views', 'Terminy');
        $this->loadLivewireComponents();
    }

    /**
     * @return void
     */
    private function loadLivewireComponents(): void
    {
        // PAGES
        Livewire::component('Terminy::backend.adresar.pages.nove', AdresarNovePage::class);
        Livewire::component('Terminy::backend.adresar.pages.index', AdresarIndexPage::class);
        Livewire::component('Terminy::backend.adresar.pages.upravit', AdresarUpravitPage::class);
        Livewire::component('Terminy::backend.moznosti-udalosti.pages.nove', MoznostiUdalostiNovePage::class);
        Livewire::component(
            'Terminy::backend.moznosti-udalosti.pages.index',
            MoznostiUdalostiIndexPage::class,
        );
        Livewire::component(
            'Terminy::backend.moznosti-udalosti.pages.upravit',
            MoznostiUdalostiUpravitPage::class,
        );
        Livewire::component('Terminy::backend.udalosti.pages.nova', UdalostiNovaPage::class);
        Livewire::component('Terminy::backend.udalosti.pages.index', UdalostiIndexPage::class);
        Livewire::component('Terminy::backend.udalosti.pages.upravit', UdalostiUpravitPage::class);

        // COMPONENTS
        Livewire::component('Terminy::components.udalosti.druh', UdalostiDruhComponent::class);
        Livewire::component('Terminy::components.udalosti.stav', UdalostiStavComponent::class);
        Livewire::component('Terminy::components.filtre.stav', FilterStavComponent::class);
        Livewire::component('Terminy::components.filtre.pracoviska', FilterPracoviskaComponent::class);
        Livewire::component('Terminy::backend.adresar.components.form', AdresarFormComponent::class);
        Livewire::component('Terminy::backend.adresar.components.zoznam', AdresarZoznamComponent::class);
        Livewire::component('Terminy::backend.moznosti-udalosti.components.form', MoznostiUdalostiFormComponent::class);
        Livewire::component(
            'Terminy::backend.moznosti-udalosti.components.zoznam',
            MoznostiUdalostiZoznamComponent::class,
        );
        Livewire::component('Terminy::backend.udalosti.components.form', UdalostiFormComponent::class);
        Livewire::component('Terminy::backend.udalosti.components.zoznam', UdalostiZoznamComponent::class);
        Livewire::component(
            'Terminy::backend.udalosti.components.registracie.components.form',
            RegistracieFormComponent::class,
        );
        Livewire::component(
            'Terminy::backend.udalosti.components.registracie.components.zoznam',
            RegistracieZoznamComponent::class,
        );
        Livewire::component('Terminy::frontend.registracie.components.form', FrontendRegistracieFormComponent::class);
        Livewire::component(
            'Terminy::backend.udalosti.components.moznosti-udalosti.components.form',
            BackendMoznostiUdalostiForm::class,
        );
        Livewire::component(
            'Terminy::frontend.registracie.components.moznosti-udalosti.components.form',
            BackendMoznostiFormComponent::class,
        );
    }

    /**
     * @return void
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function register()
    {
        $this->registerComposers();
    }

    /**
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function registerComposers(): void
    {
        view()->composer(
            ['Terminy::pages.frontend.udalosti.show'],
            ZoznamBuducichUdalostiComposer::class,
        );
    }
}
