local n=require(script.Parent.Parent.Parent.Roact)local H=require(script.Parent.Parent)local w=require(script.Parent.Parent.Parent.Promise)local q={1,2;3,4;6,8,9;12;16}local b=n.Component:extend("\080\097\114\101\110\116\067\111\109\112\111\110\101\110\116")function b.init(n)n:setState({Elevation=1})end function b.render(w)return n.createElement("\070\114\097\109\101",{BackgroundTransparency=1},{TextLabel=n.createElement("\084\101\120\116\076\097\098\101\108",{BackgroundColor3=Color3.new(1,1,1);BorderSizePixel=0;Text=w.state.Elevation,ZIndex=2;Size=UDim2.fromScale(1,1),LayoutOrder=math.huge}),Shadow=n.createElement(H.Shadow,{Elevation=w.state.Elevation})})end function b.didMount(n)n.Promise=w.Try(function()while true do(w.Delay(1)):Await()n:setState({Elevation=q[math.random(#q)]})end end)end function b.willUnmount(n)n.Promise:Cancel()n.Promise=nil end return function(w)local r=table.create(#q+2)for w,q in ipairs(q)do r[w]=n.createElement("\070\114\097\109\101",{AnchorPoint=Vector2.new(.5,.5);BackgroundColor3=Color3.new(1,1,1),BorderSizePixel=0;Position=UDim2.fromScale(.5,.5);Size=UDim2.fromOffset(75,75),ZIndex=1},{Shadow=n.createElement(H.Shadow,{Elevation=q,ZIndex=1});TextLabel=n.createElement("\084\101\120\116\076\097\098\101\108",{BackgroundColor3=Color3.new(1,1,1);BorderSizePixel=0;Text=tostring(q);Font=Enum.Font.SourceSans,TextSize=24;Size=UDim2.fromScale(1,1),ZIndex=2})})end table.insert(r,n.createElement("\085\073\071\114\105\100\076\097\121\111\117\116",{CellSize=UDim2.fromOffset(150,150);CellPadding=UDim2.fromOffset(25,25);HorizontalAlignment=Enum.HorizontalAlignment.Center,VerticalAlignment=Enum.VerticalAlignment.Center;SortOrder=Enum.SortOrder.LayoutOrder}))table.insert(r,n.createElement(b))local G=n.mount(n.createElement("\070\114\097\109\101",{Size=UDim2.fromScale(1,1);BackgroundColor3=Color3.new(1,1,1),BorderSizePixel=0},r),w)return function()n.unmount(G)end end
local Roact = require(script.Parent.Parent.Parent.Roact)
local RoactMaterial = require(script.Parent.Parent)
local Promise = require(script.Parent.Parent.Parent.Promise)

local ELEVATIONS = {1, 2, 3, 4, 6, 8, 9, 12, 16}

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

function ParentComponent:init()
	self:setState({
		Elevation = 1,
	})
end

function ParentComponent:render()
	return Roact.createElement("Frame", {
		BackgroundTransparency = 1,
	}, {
		TextLabel = Roact.createElement("TextLabel", {
			BackgroundColor3 = Color3.new(1, 1, 1),
			BorderSizePixel = 0,
			Text = self.state.Elevation,
			ZIndex = 2,
			Size = UDim2.fromScale(1, 1),
			LayoutOrder = math.huge,
		}),

		Shadow = Roact.createElement(RoactMaterial.Shadow, {
			Elevation = self.state.Elevation,
		}),
	})
end

function ParentComponent:didMount()
	self.Promise = Promise.Try(function()
		while true do
			Promise.Delay(1):Await()
			self:setState({
				Elevation = ELEVATIONS[math.random(#ELEVATIONS)],
			})
		end
	end)
end

function ParentComponent:willUnmount()
	self.Promise:Cancel()
	self.Promise = nil
end

return function(Target)
	local ElevationFrames = table.create(#ELEVATIONS + 2)
	for Index, Elevation in ipairs(ELEVATIONS) do
		ElevationFrames[Index] = Roact.createElement("Frame", {
			AnchorPoint = Vector2.new(0.5, 0.5),
			BackgroundColor3 = Color3.new(1, 1, 1),
			BorderSizePixel = 0,
			Position = UDim2.fromScale(0.5, 0.5),
			Size = UDim2.fromOffset(75, 75),
			ZIndex = 1,
		}, {
			Shadow = Roact.createElement(RoactMaterial.Shadow, {
				Elevation = Elevation,
				ZIndex = 1,
			}),

			TextLabel = Roact.createElement("TextLabel", {
				BackgroundColor3 = Color3.new(1, 1, 1),
				BorderSizePixel = 0,
				Text = tostring(Elevation),
				Font = Enum.Font.SourceSans,
				TextSize = 24,
				Size = UDim2.fromScale(1, 1),
				ZIndex = 2,
			}),
		})
	end

	table.insert(ElevationFrames, Roact.createElement("UIGridLayout", {
		CellSize = UDim2.fromOffset(150, 150),
		CellPadding = UDim2.fromOffset(25, 25),
		HorizontalAlignment = Enum.HorizontalAlignment.Center,
		VerticalAlignment = Enum.VerticalAlignment.Center,
		SortOrder = Enum.SortOrder.LayoutOrder,
	}))

	table.insert(ElevationFrames, Roact.createElement(ParentComponent))

	local Tree = Roact.mount(Roact.createElement("Frame", {
		Size = UDim2.fromScale(1, 1),
		BackgroundColor3 = Color3.new(1, 1, 1),
		BorderSizePixel = 0,
	}, ElevationFrames), Target)

	return function()
		Roact.unmount(Tree)
	end
end
