local D=game:GetService("\083\116\097\114\116\101\114\071\117\105")local E=script.Parent local s=E.Parent local d=s.Parent local V=require(d.Roact)local B=require(E.StyleContext)local v=V.Component:extend("\083\116\121\108\101\080\114\111\118\105\100\101\114")function v.init(s)s.UpdateConnection=(D:GetAttributeChangedSignal("\084\104\101\109\101")):Connect(function()if s.props.Theme then return end s.ThemeObject:Update((require(E)).Themes[D:GetAttribute("\084\104\101\109\101")])end)s:setState({Theme=s.props.Theme or(require(E)).Themes[D:GetAttribute("\084\104\101\109\101")]})end function v.render(D)local E={Theme=D.state.Theme,Update=function(E,s)if D.mounted then E.Theme=s D:setState({Theme=s})end end}D.ThemeObject=E return V.createElement(B.Provider,{value=E},V.createFragment(D.props[V.Children]))end function v.didMount(D)D.mounted=true end function v.willUnmount(D)D.UpdateConnection:Disconnect()D.mounted=false end return v
local StarterGui = game:GetService("StarterGui")
local Theme = script.Parent
local Winro = Theme.Parent
local Packages = Winro.Parent

local Roact = require(Packages.Roact)
local StyleContext = require(Theme.StyleContext)

local StyleProvider = Roact.Component:extend("StyleProvider")

-- // UIBlox theme provider //

function StyleProvider:init()
	-- This is typically considered an anti-pattern, but it's the simplest
	-- way to preserve the behavior that these context solutions employed

	self.UpdateConnection = StarterGui:GetAttributeChangedSignal('Theme'):Connect(function()

		-- If provided as a prop, ignore override
		if self.props.Theme then
			return
		end

		self.ThemeObject:Update(require(Theme).Themes[StarterGui:GetAttribute('Theme')])
	end)

	self:setState({
		Theme = self.props.Theme or require(Theme).Themes[StarterGui:GetAttribute('Theme')],
	})
end

function StyleProvider:render()

	local ThemeObject = {
		Theme = self.state.Theme,
		Update = function(_self, NewTheme)
			if self.mounted then
				_self.Theme = NewTheme
				self:setState({ Theme = NewTheme })
			end
		end,
	}

	self.ThemeObject = ThemeObject

	return Roact.createElement(StyleContext.Provider, {
		value = ThemeObject,
	}, Roact.createFragment(self.props[Roact.Children]))
end

function StyleProvider:didMount()
	self.mounted = true
end

function StyleProvider:willUnmount()
	self.UpdateConnection:Disconnect()
	self.mounted = false
end

return StyleProvider
