// Share the existing non-sensitive device theme across application and workspace windows. (() => { const choices=[...document.querySelectorAll('[data-app-theme-choice]')],valid=new Set(choices.map(node=>node.dataset.appThemeChoice)); window.addEventListener('storage',event=>{ if(event.key!=='plotdirector.applicationTheme'||!valid.has(event.newValue))return; if(window.PlotDirectorApplyApplicationTheme){window.PlotDirectorApplyApplicationTheme(event.newValue);return;} const root=document.documentElement;root.dataset.appTheme=event.newValue;root.dataset.theme=event.newValue.endsWith('-dark')?'dark':'light';root.dataset.bsTheme=root.dataset.theme; choices.forEach(node=>node.setAttribute('aria-pressed',String(node.dataset.appThemeChoice===event.newValue))); window.dispatchEvent(new CustomEvent('plotdirector:theme-changed',{detail:{theme:event.newValue}})); }); })();