(function(){"use strict";const n="adminTheme",o="theme";function c(e){if(!e)return;console.log("applyTheme",e);let t=e;if(t&&t[0]==='"')try{t=JSON.parse(t)}catch(m){}if(!["light","dark","auto"].includes(t))return;const r=document.documentElement;r.setAttribute("data-theme",t),r.classList.remove("dark");const a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;(t==="dark"||t==="auto"&&a)&&r.classList.add("dark")}let s=!1;c(localStorage.getItem(n));const l=e=>{if(e==null)return null;if(e[0]==='"')try{return JSON.parse(e)}catch(t){}return e},u=e=>e==="light"||e==="dark"||e==="auto";window.addEventListener("storage",e=>{if(e.key!==n&&e.key!==o||s)return;const t=typeof e.newValue=="string"?e.newValue:null,r=l(t);if(u(r)){try{if(s=!0,e.key===n)localStorage.getItem(o)!==r&&localStorage.setItem(o,r);else{const a=localStorage.getItem(n),i=JSON.stringify(r);a!==i&&localStorage.setItem(n,i)}}finally{s=!1}c(r)}})})();
