export const THEME_BOOTSTRAP_SCRIPT = `(() => {
  try {
    const read = (key) => {
      const value = window.localStorage.getItem(key);
      return value === "light" || value === "dark" || value === "system" ? value : null;
    };
    const userKey = window.localStorage.getItem("authUserKey") || "anon";
    const legacyPreference = read("themeMode:" + userKey) || (userKey !== "anon" ? read("themeMode:anon") : null);
    const preference = read("jobtracker.themeMode") || legacyPreference || "system";
    if (!read("jobtracker.themeMode") && legacyPreference) window.localStorage.setItem("jobtracker.themeMode", legacyPreference);
    const mode = preference === "dark" || (preference === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches) ? "dark" : "light";
    document.documentElement.setAttribute("data-color-scheme", mode);
    document.documentElement.style.colorScheme = mode;
  } catch {
    const mode = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
    document.documentElement.setAttribute("data-color-scheme", mode);
    document.documentElement.style.colorScheme = mode;
  }
})();`;
