import { w as writable, d as derived } from "./index3.js"; const THEME_KEY = "dw_theme"; function getInitialMode() { if (typeof localStorage !== "undefined") { const stored = localStorage.getItem(THEME_KEY); if (stored === "light" || stored === "dark" || stored === "system") return stored; } return "system"; } const themeMode = writable(getInitialMode()); themeMode.subscribe((value) => { if (typeof localStorage !== "undefined") { localStorage.setItem(THEME_KEY, value); } }); derived(themeMode, ($mode) => { if ($mode === "system") { if (typeof window !== "undefined") { return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; } return "light"; } return $mode; }); export { themeMode as t };