window.taxbaikAdminSession = { syncRouteClass: function () { document.documentElement.classList.toggle( 'admin-login-route', window.location.pathname.toLowerCase().endsWith('/admin/login')); }, clearAuthToken: function () { try { localStorage.removeItem('auth_token'); } catch { // Ignore storage errors; redirect still recovers the session. } }, watchReconnect: function () { window.taxbaikAdminSession.syncRouteClass(); window.addEventListener('popstate', window.taxbaikAdminSession.syncRouteClass); // Show loading indicator on page load, hide when content renders const loadingOverlay = document.getElementById('blazor-loading'); if (loadingOverlay) { // Hide loading when page is fully interactive // Watch for Blazor components to render const hideLoading = () => { loadingOverlay.classList.remove('show'); document.removeEventListener('blazor:ready', hideLoading); observer.disconnect(); }; // Hide on Blazor ready event document.addEventListener('blazor:ready', hideLoading); // Also hide after DOM content loaded + small delay if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { setTimeout(() => { if (loadingOverlay.classList.contains('show')) { hideLoading(); } }, 500); }); } else { setTimeout(() => { if (loadingOverlay.classList.contains('show')) { hideLoading(); } }, 500); } // Watch for interactive elements to appear const observer = new MutationObserver(() => { const mudElements = document.querySelectorAll('[class*="mud-"]').length; if (mudElements > 20 && loadingOverlay.classList.contains('show')) { hideLoading(); } }); observer.observe(document.body, { childList: true, subtree: true }); } const modal = document.getElementById('components-reconnect-modal'); if (!modal) { return; } const reloadOnRejectedCircuit = () => { const className = modal.className || ''; if (className.includes('components-reconnect-failed') || className.includes('components-reconnect-rejected')) { window.setTimeout(() => window.location.reload(), 1500); } }; new MutationObserver(reloadOnRejectedCircuit) .observe(modal, { attributes: true, attributeFilter: ['class'] }); } };