const d = "uikit-color-scheme";
const r = ".rio.cloud", E = "Thu, 18 Dec 2030 12:00:00 UTC", n = "data-theme", s = "themechange", l = "default", h = "system", i = "light", a = "dark", t = (e) => {
  e ? document.documentElement.setAttribute(n, e) : document.documentElement.removeAttribute(n);
}, T = () => decodeURIComponent(document.cookie).split(";").find((c) => c.includes(d))?.split("=")[1], u = () => {
  const e = T();
  switch (e) {
    case l:
      t();
      break;
    case h:
      window.matchMedia("(prefers-color-scheme: dark)").matches ? t(a) : t(i);
      break;
    case i:
    case a:
      t(e);
      break;
  }
  return e;
}, A = (e) => {
  const o = window.location.host.startsWith("localhost") || window.location.host.startsWith("127.0.0.1"), c = encodeURIComponent(e), m = o ? "localhost" : r;
  document.cookie = `${d}=${c};domain=${m};expires=${E};path=/`;
}, f = () => {
  window.addEventListener(
    "message",
    ({ data: e }) => {
      if (e === s) {
        u();
        for (const o of document.getElementsByTagName("iframe"))
          o.contentWindow?.postMessage(s, "*");
      }
    },
    !1
  );
};
export {
  s as THEME_CHANGE_EVENT,
  a as THEME_DARK,
  n as THEME_DATA_ATTRIBUTE,
  l as THEME_DEFAULT,
  i as THEME_LIGHT,
  h as THEME_SYSTEM,
  u as getColorScheme,
  f as listenForSchemeChange,
  A as setColorScheme
};
//# sourceMappingURL=colorScheme.js.map
