<?php

namespace App\Providers\Filament;

use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\AuthenticateSession;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;

class SupplierPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->id('supplierPortal')
            ->path('supplier-portal')
            ->login()
            ->brandName(fn () => auth()->check() && auth()->user()->supplier
                ? 'Beszállítói Portál – ' . auth()->user()->supplier->name
                : 'Beszállítói Portál')
            ->colors([
                'primary' => '#b83400',
                'gray' => [
                    50 => '#f6f5f0',
                    100 => '#eceadf',
                    200 => '#d1cfc0',
                    300 => '#b4b19b',
                    400 => '#9e9b81',
                    500 => '#7d775c',
                    600 => '#6d6850',
                    700 => '#453821',
                    800 => '#3a301c',
                    900 => '#2d2516',
                    950 => '#1f1a0f',
                ],
                'danger' => Color::Red,
                'info' => Color::Blue,
                'success' => Color::Emerald,
                'warning' => Color::Orange,
            ])
            ->font('Trebuchet MS')
            ->discoverResources(
                in: app_path('Filament/SupplierPortal/Resources'),
                for: 'App\Filament\SupplierPortal\Resources'
            )
            ->discoverPages(
                in: app_path('Filament/SupplierPortal/Pages'),
                for: 'App\Filament\SupplierPortal\Pages'
            )
            ->pages([])
            ->discoverWidgets(
                in: app_path('Filament/SupplierPortal/Widgets'),
                for: 'App\Filament\SupplierPortal\Widgets'
            )
            ->widgets([])
            ->middleware([
                EncryptCookies::class,
                AddQueuedCookiesToResponse::class,
                StartSession::class,
                AuthenticateSession::class,
                ShareErrorsFromSession::class,
                VerifyCsrfToken::class,
                SubstituteBindings::class,
                DisableBladeIconComponents::class,
                DispatchServingFilamentEvent::class,
            ])
            ->authMiddleware([
                Authenticate::class,
            ])
            ->darkMode(false)
            ->breadcrumbs(false)
            ->navigation(false);
    }
}
