<?php

namespace App\Filament\Pages;

use App\Filament\Traits\HasUserRole;
use App\Livewire\StudentKnowledgeGraph;
use BackedEnum;
use UnitEnum;
use Filament\Pages\Page;
use Illuminate\Support\Arr;

class StudentKnowledgeGraphPage extends Page
{
    use HasUserRole;

    protected static BackedEnum | string | null $navigationIcon = 'heroicon-o-chart-bar';

    protected static ?string $navigationLabel = '学生知识图谱';

    protected static UnitEnum | string | null $navigationGroup = null;

    protected static ?int $navigationSort = 25;

    protected static bool $shouldRegisterNavigation = false;

    protected string $view = 'filament.pages.student-knowledge-graph-page';

    public bool $showNodeDetails = true;
    public string $detailLayout = 'inline';

    public function mount(): void
    {
        // 初始化用户角色检查
        $this->initializeUserRole();

        // Page 类不需要 authorizeResourceAccess
        $this->showNodeDetails = filter_var(
            request()->query('show_details', true),
            FILTER_VALIDATE_BOOLEAN
        );

        $layout = request()->query('detail_layout', 'inline');
        $this->detailLayout = in_array($layout, ['inline', 'drawer'], true)
            ? $layout
            : 'inline';
    }

    public function getBreadcrumbs(): array
    {
        return [
            '学生知识图谱',
        ];
    }

    protected function getHeaderWidgets(): array
    {
        return [
            // 可以在这里添加额外的header widgets
        ];
    }

    protected function getFooterWidgets(): array
    {
        return [
            // 可以在这里添加额外的footer widgets
        ];
    }
}
