var e=localStorage.getItem(`sidebar_user_role`)||`admin`;function t(e,t){event&&event.stopPropagation();var n=document.getElementById(e),r=t.querySelector(`.chevron-icon`);if(n)if(n.style.display===`none`||n.style.display===``){for(var i=document.querySelectorAll(`.submenu`),a=0;a<i.length;a++){i[a].style.display=`none`;var o=i[a].closest(`.dropdown-container`);if(o){var s=o.querySelector(`.dropdown-toggle-custom`);if(s){var c=s.querySelector(`.chevron-icon`);c&&(c.style.transform=`rotate(0deg)`)}}}n.style.display=`block`,r&&(r.style.transform=`rotate(180deg)`)}else n.style.display=`none`,r&&(r.style.transform=`rotate(0deg)`)}function n(){for(var e=document.querySelectorAll(`.submenu`),t=0;t<e.length;t++){e[t].style.display=`none`;var n=e[t].closest(`.dropdown-container`);if(n){var r=n.querySelector(`.dropdown-toggle-custom`);if(r){var i=r.querySelector(`.chevron-icon`);i&&(i.style.transform=`rotate(0deg)`)}}}}function r(){let t=document.getElementById(`roleToggleTrack`),n=document.getElementById(`roleStatusText`),r=document.getElementById(`roleIcon`),i=document.getElementById(`userRoleDisplay`),o=document.getElementById(`topRoleDisplay`),s=document.getElementById(`toggleRoleText`);e===`admin`?(e=`director`,n.innerHTML=`Director Mode`,r.className=`fas fa-star-of-life`,i&&(i.innerHTML=`<i class="fas fa-star-of-life"></i><span>Director</span>`),o&&(o.innerText=`Director`),s&&(s.innerText=`Admin`),t&&(t.classList.remove(`admin-mode`),t.classList.add(`director-mode`)),document.body.classList.remove(`admin-mode`),document.body.classList.add(`director-mode`)):(e=`admin`,n.innerHTML=`Admin Mode`,r.className=`fas fa-crown`,i&&(i.innerHTML=`<i class="fas fa-shield-alt"></i><span>Admin</span>`),o&&(o.innerText=`Admin`),s&&(s.innerText=`Director`),t&&(t.classList.remove(`director-mode`),t.classList.add(`admin-mode`)),document.body.classList.remove(`director-mode`),document.body.classList.add(`admin-mode`)),localStorage.setItem(`sidebar_user_role`,e),localStorage.setItem(`user_role`,e===`admin`?`Admin`:`Director`),a(e===`admin`?`Administrator`:`Director`),window.dispatchEvent(new CustomEvent(`roleChanged`,{detail:{role:e===`admin`?`Admin`:`Director`}}))}function i(){let e=document.getElementById(`datetimeDisplay`);e&&(e.textContent=new Date().toLocaleDateString(`en-US`,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}))}setInterval(i,6e4),i();function a(e){let t=document.createElement(`div`);t.className=`fixed bottom-4 right-4 px-5 py-3 rounded-xl shadow-lg z-50 animate-slide-in ${e===`Administrator`?`bg-emerald-500`:`bg-amber-500`} text-white`,t.innerHTML=`
        <div class="flex items-center gap-3">
            <i class="fas fa-${e===`Administrator`?`crown`:`star-of-life`} text-lg"></i>
            <div>
                <p class="font-semibold">Role Changed</p>
                <p class="text-sm opacity-90">Switched to ${e} mode</p>
            </div>
        </div>
    `,document.body.appendChild(t),setTimeout(()=>{t.style.opacity=`0`,t.style.transition=`opacity 0.3s`,setTimeout(()=>t.remove(),300)},3e3)}function o(){let e=document.getElementById(`mainSidebar`),t=document.getElementById(`sidebarBackdrop`);e.classList.toggle(`mobile-open`),t.classList.toggle(`active`)}function s(){let e=document.getElementById(`mainSidebar`),t=document.getElementById(`sidebarBackdrop`);e.classList.remove(`mobile-open`),t.classList.remove(`active`)}function c(){let t=localStorage.getItem(`sidebar_user_role`);t&&(t===`admin`||t===`director`)&&(e=t);let r=document.getElementById(`roleToggleTrack`),i=document.getElementById(`roleStatusText`),a=document.getElementById(`roleIcon`),o=document.getElementById(`userRoleDisplay`);e===`admin`?(i&&(i.innerHTML=`Admin Mode`),a&&(a.className=`fas fa-crown`),o&&(o.innerHTML=`<i class="fas fa-shield-alt"></i><span>Admin</span>`),r&&r.classList.add(`admin-mode`)):(i&&(i.innerHTML=`Director Mode`),a&&(a.className=`fas fa-star-of-life`),o&&(o.innerHTML=`<i class="fas fa-star-of-life"></i><span>Director</span>`),r&&r.classList.add(`director-mode`)),n();var c=window.location.pathname;if(c.includes(`/payments`)){var l=document.getElementById(`paymentsSubmenu`);l&&(l.style.display=`block`)}if(c.includes(`/reports`)||c.includes(`/deductions`)||c.includes(`/losses`)){var u=document.getElementById(`reportsSubmenu`);u&&(u.style.display=`block`)}document.querySelectorAll(`.salary-sidebar .nav-link, .salary-sidebar .dropdown-toggle-custom`).forEach(e=>{e.addEventListener(`click`,function(e){window.innerWidth<=768&&!this.classList.contains(`dropdown-toggle-custom`)&&setTimeout(()=>s(),100)})})}document.addEventListener(`DOMContentLoaded`,c),window.toggleDropdown=t,window.toggleUserRole=r,window.toggleMobileSidebar=o,window.closeMobileSidebar=s;