<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Terminy\Providers;

use Livewire\Livewire;
use Illuminate\Support\ServiceProvider;
use Seka\Portal\Modul\Terminy\Composers\Udalosti\ZoznamBuducichUdalostiComposer;
use Seka\Portal\Modul\Terminy\Http\Controllers\Backend\Adresar\Livewire\Pages\Nove as AdresarNovePage;
use Seka\Portal\Modul\Terminy\Http\Controllers\Backend\Adresar\Livewire\Pages\Index as AdresarIndexPage;
use Seka\Portal\Modul\Terminy\Http\Controllers\Backend\Udalosti\Livewire\Pages\Nova as UdalostiNovaPage;
use Seka\Portal\Modul\Terminy\Http\Controllers\Backend\Udalosti\Livewire\Pages\Index as UdalostiIndexPage;
use Seka\Portal\Modul\Terminy\Http\Controllers\Livewire\Components\Udalosti\Stav as UdalostiStavComponent;
use Seka\Portal\Modul\Terminy\Http\Controllers\Livewire\Components\Udalosti\Druh as UdalostiDruhComponent;
use Seka\Portal\Modul\Terminy\Http\Controllers\Backend\Adresar\Livewire\Pages\Upravit as AdresarUpravitPage;
use Seka\Portal\Modul\Terminy\Http\Controllers\Backend\Udalosti\Livewire\Pages\Upravit as UdalostiUpravitPage;
use Seka\Portal\Modul\Terminy\Http\Controllers\Backend\Adresar\Livewire\Components\Form as AdresarFormComponent;
use Seka\Portal\Modul\Terminy\Http\Controllers\Backend\Udalosti\Livewire\Components\Form as UdalostiFormComponent;
use Seka\Portal\Modul\Terminy\Http\Controllers\Backend\Adresar\Livewire\Components\Zoznam as AdresarZoznamComponent;
use Seka\Portal\Modul\Terminy\Http\Controllers\Backend\Udalosti\Livewire\Components\Zoznam as UdalostiZoznamComponent;
use Seka\Portal\Modul\Terminy\Http\Controllers\Backend\Registracie\Livewire\Components\Form as RegistracieFormComponent;
use Seka\Portal\Modul\Terminy\Http\Controllers\Frontend\Registracie\Livewire\Components\Form as FrontendRegistracieFormComponent;

/**
 * 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
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function register()
    {
        $this->registerComposers();
    }

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

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

        // COMPONENTS
        Livewire::component('Terminy::components.livewire.udalosti.druh', UdalostiDruhComponent::class);
        Livewire::component('Terminy::components.livewire.udalosti.stav', UdalostiStavComponent::class);
        Livewire::component('Terminy::pages.adresar.backend.livewire.components.form', AdresarFormComponent::class);
        Livewire::component('Terminy::pages.adresar.backend.livewire.components.zoznam', AdresarZoznamComponent::class);
        Livewire::component('Terminy::pages.udalosti.backend.livewire.components.form', UdalostiFormComponent::class);
        Livewire::component('Terminy::pages.udalosti.backend.livewire.components.zoznam', UdalostiZoznamComponent::class);
        Livewire::component('Terminy::pages.udalosti.registracie.backend.livewire.components.form', RegistracieFormComponent::class);
        Livewire::component('Terminy::pages.udalosti.registracie.frontend.livewire.components.form', FrontendRegistracieFormComponent::class);
    }
}
