local n=script:FindFirstAncestor("\077\097\122\101\071\101\110\101\114\097\116\111\114\080\108\117\103\105\110")local Z=n.Plugin local w=game:GetService("\067\104\097\110\103\101\072\105\115\116\111\114\121\083\101\114\118\105\099\101")local i=require(n:WaitForChild("\082\111\097\099\116"))local X=require(n.Log)local G=require(Z.Config)local K=require(Z.Version)local V=require(Z.preloadAssets)local F=require(Z.Maze.MazeGenerator)local y=require(Z.Components.SettingsForm)local J=i.createElement local v=i.Component:extend("\065\112\112")function v.init(n)n.displayedVersion=K.display(G.version)end function v.generateMaze(Z,n)F:generate(n)w:SetWaypoint("\071\101\110\101\114\097\116\101\100 \077\097\122\101")end function v.render(n)local Z Z={SettingsForm=J(y,{generateMaze=function(Z)n:generateMaze(Z)end})}return J(i.Portal,{target=n.props.root},Z)end function v.didMount(n)X.trace("\082\111\111\116 \123\125 \105\110\105\116\105\097\108\105\122\105\110\103",n.displayedVersion)V()end function v.willUnmount(n)if n.serveSession~=nil then n.serveSession:stop()n.serveSession=nil end end return v
local Root = script:FindFirstAncestor('MazeGeneratorPlugin')
local Plugin = Root.Plugin
local ChangeHistoryService = game:GetService('ChangeHistoryService')
local Roact = require(Root:WaitForChild('Roact'))
local Log = require(Root.Log)

local Config = require(Plugin.Config)
local Version = require(Plugin.Version)
local preloadAssets = require(Plugin.preloadAssets)
local MazeGenerator = require(Plugin.Maze.MazeGenerator)
local SettingsForm = require(Plugin.Components.SettingsForm)

local e = Roact.createElement

local App = Roact.Component:extend('App')

function App:init()
	self.displayedVersion = Version.display(Config.version)
end

function App:generateMaze(settings)
	MazeGenerator:generate(settings)
	ChangeHistoryService:SetWaypoint('Generated Maze')
end

function App:render()
	local children

	children = { SettingsForm = e(SettingsForm, { generateMaze = function(settings)
		self:generateMaze(settings)
	end }) }

	return e(Roact.Portal, { target = self.props.root }, children)
end

function App:didMount()
	Log.trace('Root {} initializing', self.displayedVersion)

	preloadAssets()
end

function App:willUnmount()
	if self.serveSession ~= nil then
		self.serveSession:stop()
		self.serveSession = nil
	end
end

return App