"use client";
import * as l from "react";
var v = (t, i, m, n, o, r, u, d) => {
  let s = document.documentElement, h = ["light", "dark"];
  function c(e) {
    (Array.isArray(t) ? t : [t]).forEach((a) => {
      let p = a === "class", S = p && r ? o.map((f) => r[f] || f) : o;
      p ? (s.classList.remove(...S), s.classList.add(r && r[e] ? r[e] : e)) : s.setAttribute(a, e);
    }), y(e);
  }
  function y(e) {
    d && h.includes(e) && (s.style.colorScheme = e);
  }
  function g() {
    return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
  }
  if (n) c(n);
  else try {
    let e = localStorage.getItem(i) || m, a = u && e === "system" ? g() : e;
    c(a);
  } catch {
  }
}, w = l.createContext(void 0), T = { setTheme: (t) => {
}, themes: [] }, b = () => {
  var t;
  return (t = l.useContext(w)) != null ? t : T;
};
l.memo(({ forcedTheme: t, storageKey: i, attribute: m, enableSystem: n, enableColorScheme: o, defaultTheme: r, value: u, themes: d, nonce: s, scriptProps: h }) => {
  let c = JSON.stringify([m, i, r, t, d, u, n, o]).slice(1, -1);
  return l.createElement("script", { ...h, suppressHydrationWarning: !0, nonce: typeof window > "u" ? s : "", dangerouslySetInnerHTML: { __html: `(${v.toString()})(${c})` } });
});
export {
  b as useTheme
};
