-- Compiled with roblox-ts v3.0.0 local TS = _G[script] local _core = TS.import(script, TS.getModule(script, "@lattice-ui", "core").out) local createStrictContext = _core.createStrictContext local React = _core.React local defaultLightTheme = TS.import(script, script.Parent, "tokens").defaultLightTheme local _binding = createStrictContext("ThemeProvider") local ThemeContextProvider = _binding[1] local useThemeContext = _binding[2] local function ThemeProvider(props) local internalTheme, setInternalTheme = React.useState(props.defaultTheme or defaultLightTheme) local controlled = props.theme ~= nil local resolvedTheme = props.theme or internalTheme local setTheme = React.useCallback(function(nextTheme) if not controlled then setInternalTheme(nextTheme) end local _result = props.onThemeChange if _result ~= nil then _result(nextTheme) end end, { controlled, props.onThemeChange }) local contextValue = React.useMemo(function() return { theme = resolvedTheme, setTheme = setTheme, } end, { resolvedTheme, setTheme }) return React.createElement(ThemeContextProvider, { value = contextValue, }, props.children) end local function useTheme() return useThemeContext() end local function useThemeValue(selector) local context = useThemeContext() return React.useMemo(function() return selector(context.theme) end, { context.theme, selector }) end return { ThemeProvider = ThemeProvider, useTheme = useTheme, useThemeValue = useThemeValue, }