import * as React from "react";
import y from "../../../../../../../../../_virtual/index12.js";
import { getMatchingGrayColor as a } from "../helpers/get-matching-gray-color.js";
import { themePropDefs as s } from "./theme.props.js";
import { Provider } from "../../../../../../../@radix-ui_react-tooltip@1.2.8_@types_react-dom@19.1.9_@types_react@19.1.13__@types_reac_62a80c6048854e63529d68dc72b9daca/node_modules/@radix-ui/react-tooltip/dist/index.js";
import { Provider as Provider$1 } from "../../../../../../../@radix-ui_react-direction@1.1.1_@types_react@19.1.13_react@19.1.1/node_modules/@radix-ui/react-direction/dist/index.js";
import { Root as Slot } from "../../../../../../../@radix-ui_react-slot@1.2.3_@types_react@19.1.13_react@19.1.1/node_modules/@radix-ui/react-slot/dist/index.js";
const d = () => {
}, P = React.createContext(void 0);
function H() {
  const a2 = React.useContext(P);
  if (a2 === void 0) throw new Error("`useThemeContext` must be used within a `Theme`");
  return a2;
}
const R = React.forwardRef((a2, s2) => React.useContext(P) === void 0 ? React.createElement(Provider, { delayDuration: 200 }, React.createElement(Provider$1, { dir: "ltr" }, React.createElement(I, { ...a2, ref: s2 }))) : React.createElement(A, { ...a2, ref: s2 }));
R.displayName = "Theme";
const I = React.forwardRef((a2, s$1) => {
  const { appearance: r = s.appearance.default, accentColor: c = s.accentColor.default, grayColor: l = s.grayColor.default, panelBackground: p = s.panelBackground.default, radius: n = s.radius.default, scaling: t = s.scaling.default, hasBackground: i = s.hasBackground.default, ...u } = a2, [h, m] = React.useState(r);
  React.useEffect(() => m(r), [r]);
  const [y2, g] = React.useState(c);
  React.useEffect(() => g(c), [c]);
  const [v, C] = React.useState(l);
  React.useEffect(() => C(l), [l]);
  const [k, f] = React.useState(p);
  React.useEffect(() => f(p), [p]);
  const [B, x] = React.useState(n);
  React.useEffect(() => x(n), [n]);
  const [T, b] = React.useState(t);
  return React.useEffect(() => b(t), [t]), React.createElement(A, { ...u, ref: s$1, isRoot: true, hasBackground: i, appearance: h, accentColor: y2, grayColor: v, panelBackground: k, radius: B, scaling: T, onAppearanceChange: m, onAccentColorChange: g, onGrayColorChange: C, onPanelBackgroundChange: f, onRadiusChange: x, onScalingChange: b });
});
I.displayName = "ThemeRoot";
const A = React.forwardRef((a$1, s$1) => {
  const r = React.useContext(P), { asChild: c, isRoot: l, hasBackground: p, appearance: n = r?.appearance ?? s.appearance.default, accentColor: t = r?.accentColor ?? s.accentColor.default, grayColor: i = r?.resolvedGrayColor ?? s.grayColor.default, panelBackground: u = r?.panelBackground ?? s.panelBackground.default, radius: h = r?.radius ?? s.radius.default, scaling: m = r?.scaling ?? s.scaling.default, onAppearanceChange: y$1 = d, onAccentColorChange: g = d, onGrayColorChange: v = d, onPanelBackgroundChange: C = d, onRadiusChange: k = d, onScalingChange: f = d, ...B } = a$1, x = c ? Slot : "div", T = i === "auto" ? a(t) : i, b = a$1.appearance === "light" || a$1.appearance === "dark", S = p === void 0 ? l || b : p;
  return React.createElement(P.Provider, { value: React.useMemo(() => ({ appearance: n, accentColor: t, grayColor: i, resolvedGrayColor: T, panelBackground: u, radius: h, scaling: m, onAppearanceChange: y$1, onAccentColorChange: g, onGrayColorChange: v, onPanelBackgroundChange: C, onRadiusChange: k, onScalingChange: f }), [n, t, i, T, u, h, m, y$1, g, v, C, k, f]) }, React.createElement(x, { "data-is-root-theme": l ? "true" : "false", "data-accent-color": t, "data-gray-color": T, "data-has-background": S ? "true" : "false", "data-panel-background": u, "data-radius": h, "data-scaling": m, ref: s$1, ...B, className: y("radix-themes", { light: n === "light", dark: n === "dark" }, B.className) }));
});
A.displayName = "ThemeImpl";
export {
  R as Theme,
  P as ThemeContext,
  H as useThemeContext
};
//# sourceMappingURL=theme.js.map
