"use strict";

import { createContext, useCallback, useContext, useState } from "react";
import { Appearance } from "react-native";
import { IOThemeDark, IOThemeLight } from "../core/IOColors";
import { jsx as _jsx } from "react/jsx-runtime";
export const IOThemes = {
  light: IOThemeLight,
  dark: IOThemeDark
};
export const IOThemeContext = /*#__PURE__*/createContext({
  themeType: Appearance.getColorScheme() ?? "unspecified",
  theme: Appearance.getColorScheme() === "dark" ? IOThemes.dark : IOThemes.light,
  setTheme: () => void 0
});
export const useIOThemeContext = () => useContext(IOThemeContext);
export const useIOTheme = () => useIOThemeContext().theme;
export const IOThemeContextProvider = ({
  children,
  theme
}) => {
  const [currentTheme, setCurrentTheme] = useState(theme ?? "unspecified");
  const resolvedTheme = currentTheme === "unspecified" ? Appearance.getColorScheme() ?? "light" : currentTheme;
  const handleThemeChange = useCallback(newTheme => {
    setCurrentTheme(newTheme);
  }, []);
  return /*#__PURE__*/_jsx(IOThemeContext.Provider, {
    value: {
      themeType: currentTheme,
      theme: resolvedTheme === "dark" ? IOThemes.dark : IOThemes.light,
      setTheme: handleThemeChange
    },
    children: children
  });
};
//# sourceMappingURL=IOThemeContextProvider.js.map