import e from"/admin-ui/js/core/theme.js";import"/admin-ui/js/components/ds-button.js";import"/admin-ui/js/components/ds-card.js";import"/admin-ui/js/components/ds-input.js";import"/admin-ui/js/components/ds-badge.js";import"/admin-ui/js/components/ds-action-bar.js";import"/admin-ui/js/components/ds-toast.js";import"/admin-ui/js/components/ds-toast-provider.js";import"/admin-ui/js/components/ds-notification-center.js";import"/admin-ui/js/components/ds-workflow.js";import"/admin-ui/js/core/ai.js";import t from"/admin-ui/js/stores/context-store.js";import o from"/admin-ui/js/services/notification-service.js";import"/admin-ui/js/core/browser-logger.js";import n from"/admin-ui/js/core/navigation.js";import i from"/admin-ui/js/core/app.js";!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver(e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&t(e)}).observe(document,{childList:!0,subtree:!0})}function t(e){if(e.ep)return;e.ep=!0;const t=function(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?t.credentials="include":"anonymous"===e.crossOrigin?t.credentials="omit":t.credentials="same-origin",t}(e);fetch(e.href,t)}}(),function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver(e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&t(e)}).observe(document,{childList:!0,subtree:!0})}function t(e){if(e.ep)return;e.ep=!0;const t=function(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?t.credentials="include":"anonymous"===e.crossOrigin?t.credentials="omit":t.credentials="same-origin",t}(e);fetch(e.href,t)}}(),document.addEventListener("DOMContentLoaded",()=>{i.init(),new n(document.querySelector(".sidebar__nav"));const s=document.getElementById("theme-toggle");s&&s.addEventListener("click",()=>{e.toggle()});const r=document.getElementById("team-context-select"),a=e=>{document.querySelectorAll(".help-section").forEach(t=>{const o=t.dataset.team;t.style.display="all"===e||o===e||"all"===o?"":"none"})};if(r){const e=localStorage.getItem("dss_team_context")||"all";r.value=e,a(e),t.setContext({team:e}),r.addEventListener("change",e=>{const o=e.target.value;localStorage.setItem("dss_team_context",o),a(o),t.setContext({team:o}),window.dispatchEvent(new CustomEvent("team-context-changed",{detail:{team:o}}))})}const c=document.getElementById("sidebar-toggle"),d=document.getElementById("ai-sidebar");c&&d&&("true"===localStorage.getItem("dss_ai_sidebar_collapsed")&&(d.classList.add("collapsed"),c.setAttribute("aria-expanded","false")),c.addEventListener("click",()=>{const e=d.classList.toggle("collapsed");c.setAttribute("aria-expanded",!e),localStorage.setItem("dss_ai_sidebar_collapsed",e)}));const l=document.getElementById("notification-toggle"),m=document.querySelector("ds-notification-center"),u=document.getElementById("notification-indicator");l&&m&&(l.addEventListener("click",e=>{e.stopPropagation(),m.hasAttribute("open")?m.removeAttribute("open"):m.setAttribute("open","")}),document.addEventListener("click",e=>{m.contains(e.target)||l.contains(e.target)||m.removeAttribute("open")}),o.addEventListener("unread-count-changed",e=>{const{count:t}=e.detail;u&&(u.style.display=t>0?"block":"none")}),m.addEventListener("notification-action",e=>{const{event:t,payload:o}=e.detail;if(console.log("Notification action:",t,o),t.startsWith("navigate:")){const e=t.replace("navigate:","");window.location.hash=e}})),window.addEventListener("dss-ask-ai",e=>{const{prompt:t,openSidebar:o}=e.detail;o&&d&&d.classList.contains("collapsed")&&(d.classList.remove("collapsed"),null==c||c.setAttribute("aria-expanded","true"),localStorage.setItem("dss_ai_sidebar_collapsed","false"));const n=document.querySelector("ds-ai-chat");n&&"function"==typeof n.setInput&&n.setInput(t)}),window.addEventListener("hashchange",()=>{const e=window.location.hash.substring(1)||"dashboard";t.setContext({page:e})}),t.setContext({page:window.location.hash.substring(1)||"dashboard"})});
