@php
  $isAdminRoute = fn (...$patterns) => request()->routeIs(...$patterns);
  $dashboardActive = $isAdminRoute('admin.dashboard');
  $usersOpen = $isAdminRoute(
      'admin.usersdetails',
      'admin.addinstitute',
      'admin.institutedetails',
      'admin.instituteprofile',
      'admin.instituteprofiledetails',
      'admin.loginstatus',
      'admin.unloginstatus',
      'admin.schoolstudents',
      'admin.studentscontest',
      'admin.userprofile',
      'admin.examreaultdetaiils',
      'admin.studentpaymentdetails',
      'admin.userpayments',
      'admin.studentcompetition',
      'admin.competitionstudentsdetails'
  );
  $subjectsOpen = $isAdminRoute(
      'admin.addstudentsgroup',
      'admin.managestudentsgroup',
      'admin.editstudentsgroup',
      'admin.addclasssubject',
      'admin.manageclasssubject',
      'admin.editclasssubject',
      'admin.addmathchapter',
      'admin.managemathchapter',
      'admin.editmathchapter',
      'admin.addstudentspattern',
      'admin.managestudentspattern',
      'admin.editstudentspattern'
  );
  $competitionOpen = $isAdminRoute(
      'admin.addcontest',
      'admin.managecontest',
      'admin.editcontest',
      'admin.applieddetails',
      'admin.assigncompetition',
      'admin.addassigncompetition',
      'admin.editassigncompetition'
  );
  $freeExamOpen = $isAdminRoute(
      'admin.addfreecontest',
      'admin.managefreecontest',
      'admin.editfreecontest',
      'admin.freeassigncompetition',
      'admin.addfreeassigncompetition',
      'admin.editfreeassigncompetition'
  );
  $questionsOpen = $isAdminRoute(
      'admin.addquestions',
      'admin.managequestions',
      'admin.editquestions',
      'admin.addquestionsset',
      'admin.managequestionssets',
      'admin.editquestionsset',
      'admin.loadquestions',
      'admin.loadquestionscince',
      'admin.loadquestionhindi',
      'admin.loadquestionenglish',
      'admin.loadquestionmaths'
  );
  $appOpen = $isAdminRoute(
      'admin.addpage',
      'admin.pagemanagement',
      'admin.editpage',
      'admin.addbanner',
      'admin.bannermanagement',
      'admin.editbanner',
      'admin.appmanagement'
  );
  $walletOpen = $isAdminRoute(
      'admin.amountrequest',
      'admin.amountrequestaccepted',
      'admin.rejectrequest',
      'admin.changestatus',
      'admin.withdrawrequest',
      'admin.withdrawrequestaccepted',
      'admin.rejectwithdraw',
      'admin.changewithdrawstatus'
  );
  $resultOpen = $isAdminRoute(
      'admin.examresult',
      'admin.scholarshipcompetition',
      'admin.resultdetails',
      'admin.paymentdistribute'
  );
  $passwordOpen = $isAdminRoute('admin.changepassword');
  $settingsOpen = $appOpen || $passwordOpen;
@endphp
<aside id="sidebar-wrapper">
  <div class="sidebar-brand">
    <a href="{{ route('admin.dashboard') }}">
      <img alt="image" src="{{ asset('public/frontend/images/logo.png') }}" class="header-logo" style="height: 70px;" />
      <span class="logo-name"></span>
    </a>
  </div>
  <ul class="sidebar-menu">
    <li class="menu-header">Main</li>
    <li class="dropdown {{ $dashboardActive ? 'active' : '' }}">
      <a href="{{ route('admin.dashboard') }}" class="nav-link"><i data-feather="grid"></i><span>Dashboard</span></a>
    </li>
    <li class="menu-header">Users</li>
    <li class="dropdown {{ $usersOpen ? 'active submenu-open' : '' }}">
      <a href="#" class="menu-toggle nav-link has-dropdown {{ $usersOpen ? 'toggled' : '' }}" aria-expanded="{{ $usersOpen ? 'true' : 'false' }}"><i data-feather="users"></i><span>Users</span></a>
      <ul class="dropdown-menu">
        <li class="{{ $isAdminRoute('admin.usersdetails') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.usersdetails') }}">Students</a></li>
        <li class="{{ $isAdminRoute('admin.addinstitute') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.addinstitute') }}">Add Institute</a></li>
        <li class="{{ $isAdminRoute('admin.institutedetails', 'admin.instituteprofiledetails', 'admin.addinstitute') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.institutedetails') }}">Institutes</a></li>
      </ul>
    </li>
    <li class="menu-header">Masters</li>
    <li class="dropdown {{ $subjectsOpen ? 'active submenu-open' : '' }}">
      <a href="#" class="menu-toggle nav-link has-dropdown {{ $subjectsOpen ? 'toggled' : '' }}" aria-expanded="{{ $subjectsOpen ? 'true' : 'false' }}"><i data-feather="layers"></i><span>Academics</span></a>
      <ul class="dropdown-menu">
        <li class="{{ $isAdminRoute('admin.addstudentsgroup', 'admin.editstudentsgroup') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.addstudentsgroup') }}">Add Class</a></li>
        <li class="{{ $isAdminRoute('admin.managestudentsgroup') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.managestudentsgroup') }}">Classes</a></li>
        <li class="{{ $isAdminRoute('admin.addclasssubject', 'admin.editclasssubject') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.addclasssubject') }}">Add Subject</a></li>
        <li class="{{ $isAdminRoute('admin.manageclasssubject') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.manageclasssubject') }}">Subjects</a></li>
        <li class="{{ $isAdminRoute('admin.addmathchapter', 'admin.editmathchapter') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.addmathchapter') }}">Add Chapter</a></li>
        <li class="{{ $isAdminRoute('admin.managemathchapter') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.managemathchapter') }}">Chapters</a></li>
        <li class="{{ $isAdminRoute('admin.addstudentspattern', 'admin.editstudentspattern') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.addstudentspattern') }}">Add Board</a></li>
        <li class="{{ $isAdminRoute('admin.managestudentspattern') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.managestudentspattern') }}">Boards</a></li>
      </ul>
    </li>
    <li class="menu-header">Exams</li>
    <li class="dropdown {{ $competitionOpen ? 'active submenu-open' : '' }}">
      <a href="#" class="menu-toggle nav-link has-dropdown {{ $competitionOpen ? 'toggled' : '' }}" aria-expanded="{{ $competitionOpen ? 'true' : 'false' }}"><i data-feather="award"></i><span>Paid Exams</span></a>
      <ul class="dropdown-menu">
        <li class="{{ $isAdminRoute('admin.addcontest', 'admin.editcontest') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.addcontest') }}">Create</a></li>
        <li class="{{ $isAdminRoute('admin.managecontest', 'admin.applieddetails') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.managecontest') }}">Manage</a></li>
        <li class="{{ $isAdminRoute('admin.assigncompetition', 'admin.addassigncompetition', 'admin.editassigncompetition') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.assigncompetition') }}">Assign</a></li>
      </ul>
    </li>
    <li class="dropdown {{ $freeExamOpen ? 'active submenu-open' : '' }}">
      <a href="#" class="menu-toggle nav-link has-dropdown {{ $freeExamOpen ? 'toggled' : '' }}" aria-expanded="{{ $freeExamOpen ? 'true' : 'false' }}"><i data-feather="gift"></i><span>Free Exams</span></a>
      <ul class="dropdown-menu">
        <li class="{{ $isAdminRoute('admin.addfreecontest', 'admin.editfreecontest') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.addfreecontest') }}">Create</a></li>
        <li class="{{ $isAdminRoute('admin.managefreecontest') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.managefreecontest') }}">Manage</a></li>
        <li class="{{ $isAdminRoute('admin.freeassigncompetition', 'admin.addfreeassigncompetition', 'admin.editfreeassigncompetition') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.freeassigncompetition') }}">Assign</a></li>
      </ul>
    </li>
    <li class="dropdown {{ $questionsOpen ? 'active submenu-open' : '' }}">
      <a href="#" class="menu-toggle nav-link has-dropdown {{ $questionsOpen ? 'toggled' : '' }}" aria-expanded="{{ $questionsOpen ? 'true' : 'false' }}"><i data-feather="help-circle"></i><span>Questions</span></a>
      <ul class="dropdown-menu">
        <li class="{{ $isAdminRoute('admin.addquestions', 'admin.editquestions') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.addquestions') }}">Add Questions</a></li>
        <li class="{{ $isAdminRoute('admin.managequestions') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.managequestions') }}">Questions</a></li>
        <li class="{{ $isAdminRoute('admin.addquestionsset', 'admin.editquestionsset') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.addquestionsset') }}">Add Set</a></li>
        <li class="{{ $isAdminRoute('admin.managequestionssets') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.managequestionssets') }}">Sets</a></li>
      </ul>
    </li>
    <li class="menu-header">Finance</li>
    <li class="dropdown {{ $walletOpen ? 'active submenu-open' : '' }}">
      <a href="#" class="menu-toggle nav-link has-dropdown {{ $walletOpen ? 'toggled' : '' }}" aria-expanded="{{ $walletOpen ? 'true' : 'false' }}"><i data-feather="credit-card"></i><span>Wallet</span></a>
      <ul class="dropdown-menu">
        <li class="{{ $isAdminRoute('admin.amountrequest') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.amountrequest') }}">Recharge</a></li>
        <li class="{{ $isAdminRoute('admin.amountrequestaccepted') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.amountrequestaccepted') }}">Accepted Recharge</a></li>
        <li class="{{ $isAdminRoute('admin.rejectrequest') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.rejectrequest') }}">Declined Recharge</a></li>
        <li class="{{ $isAdminRoute('admin.withdrawrequest') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.withdrawrequest') }}">Withdraw</a></li>
        <li class="{{ $isAdminRoute('admin.withdrawrequestaccepted') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.withdrawrequestaccepted') }}">Accepted Withdraw</a></li>
        <li class="{{ $isAdminRoute('admin.rejectwithdraw') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.rejectwithdraw') }}">Declined Withdraw</a></li>
      </ul>
    </li>
    <li class="dropdown {{ $resultOpen ? 'active submenu-open' : '' }}">
      <a href="#" class="menu-toggle nav-link has-dropdown {{ $resultOpen ? 'toggled' : '' }}" aria-expanded="{{ $resultOpen ? 'true' : 'false' }}"><i data-feather="bar-chart-2"></i><span>Results</span></a>
      <ul class="dropdown-menu">
        <li class="{{ $isAdminRoute('admin.scholarshipcompetition', 'admin.resultdetails', 'admin.paymentdistribute', 'admin.examresult') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.scholarshipcompetition') }}">Scholarship</a></li>
      </ul>
    </li>
    <li class="menu-header">Settings</li>
    <li class="dropdown {{ $settingsOpen ? 'active submenu-open' : '' }}">
      <a href="#" class="menu-toggle nav-link has-dropdown {{ $settingsOpen ? 'toggled' : '' }}" aria-expanded="{{ $settingsOpen ? 'true' : 'false' }}"><i data-feather="settings"></i><span>Settings</span></a>
      <ul class="dropdown-menu">
        <li class="{{ $isAdminRoute('admin.addpage', 'admin.editpage') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.addpage') }}">Add Page</a></li>
        <li class="{{ $isAdminRoute('admin.pagemanagement') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.pagemanagement') }}">Pages</a></li>
        <li class="{{ $isAdminRoute('admin.addbanner', 'admin.editbanner') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.addbanner') }}">Add Banner</a></li>
        <li class="{{ $isAdminRoute('admin.bannermanagement') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.bannermanagement') }}">Banners</a></li>
        <li class="{{ $isAdminRoute('admin.appmanagement') ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.appmanagement') }}">Site Settings</a></li>
        <li class="{{ $passwordOpen ? 'active' : '' }}"><a class="nav-link" href="{{ route('admin.changepassword') }}">Password</a></li>
      </ul>
    </li>
  </ul>
</aside>
