"use strict";
const React = require("react");
const styles_entries_css_cjs = require("../../../css.cjs");
const styles_lib_playroom_FrameComponent_cjs = require("./FrameComponent.cjs");
const styles_lib_css_atoms_sprinkles_css_cjs = require("../css/atoms/sprinkles.css.cjs");
const styles_lib_components_Autosuggest_Autosuggest_cjs = require("../components/Autosuggest/Autosuggest.cjs");
const styles_lib_css_breakpoints_cjs = require("../css/breakpoints.cjs");
const styles_lib_components_private_Placeholder_Placeholder_cjs = require("../components/private/Placeholder/Placeholder.cjs");
function useScope() {
  const responsiveValue = styles_lib_components_Autosuggest_Autosuggest_cjs.useResponsiveValue();
  const [colorMode, setColorMode] = React.useState(
    "lightMode"
  );
  React.useEffect(() => {
    const observer = new MutationObserver((mutationsList) => {
      for (const mutation of mutationsList) {
        if (mutation.type === "attributes" && mutation.attributeName === "class") {
          setColorMode(
            document.documentElement.classList.contains(styles_lib_css_atoms_sprinkles_css_cjs.darkMode) ? "darkMode" : "lightMode"
          );
        }
      }
    });
    observer.observe(document.documentElement, { attributes: true });
    return () => {
      observer.disconnect();
    };
  }, [colorMode]);
  function playroomColorModeValue(value) {
    if (typeof value !== "object" || !(value.darkMode || value.lightMode)) {
      return;
    }
    return document.documentElement.classList.contains(styles_lib_css_atoms_sprinkles_css_cjs.darkMode) ? value.darkMode : value.lightMode;
  }
  function playroomResponsiveValue(value) {
    Object.values(value).forEach((v) => {
      if (v === null) {
        throw new Error(
          `You cannot use 'null' as a value when using 'responsiveValue'.`
        );
      }
    });
    const resolvedValue = responsiveValue(value);
    if (resolvedValue === null) {
      return value.mobile;
    }
    return resolvedValue;
  }
  return {
    vars: styles_entries_css_cjs.vars,
    atoms: styles_entries_css_cjs.atoms,
    breakpoints: styles_lib_css_breakpoints_cjs.breakpoints,
    showToast: styles_lib_components_private_Placeholder_Placeholder_cjs.useToast(),
    responsiveValue: playroomResponsiveValue,
    colorModeValue: playroomColorModeValue,
    ...styles_lib_playroom_FrameComponent_cjs.usePlayroomStore()
  };
}
exports.useScope = useScope;
