local Z=script:FindFirstAncestor("\077\097\122\101\071\101\110\101\114\097\116\111\114\080\108\117\103\105\110")local I=require(Z:WaitForChild("\082\111\097\099\116"))local S=Z.Plugin local C=require(Z.RoactRodux)local f=require(S.Config)local L=require(S.Components.Theme)local n=require(S.Components.Panel)local y=require(S.Components.FitScrollingFrame)local i=require(S.Components.FitText)local s=require(S.Components.FormButton)local U=require(S.Components.FormTextInput)local k=require(S.Components.PluginSettings)local r=require(S.Components.MaterialsDropdown)local V=require(S.Components.Checkbox)local w=require(S.Components.SettingsFormItem)local N=require(S.Components.UIPadding)local Y=require(S.Actions.SetSettings)local Q=game:GetService("\083\101\108\101\099\116\105\111\110")local g=I.createElement local u=I.Component:extend("\083\101\116\116\105\110\103\115\070\111\114\109")function u.init(Z)local I=Z.props.changeSettings local S=Z.props.settings Q.SelectionChanged:Connect(function()if#Q:Get()>0 then I({location=(Q:Get())[1]})else I({location=nil})end end)end function u.render(Z)local I=Z.props.generateMaze local S=Z.props.changeSettings local C=Z.props.settings return L.with(function(Z)return k.with(function()local L=C.location local k="\119\111\114\107\115\112\097\099\101"local Y=tostring(Vector3.new(0,0,0))if L and L:IsA("\066\097\115\101\080\097\114\116")then k=L.Name Y=tostring(L.Position)end return g(n,nil,{Layout=g("\085\073\076\105\115\116\076\097\121\111\117\116",{SortOrder=Enum.SortOrder.LayoutOrder;HorizontalAlignment=Enum.HorizontalAlignment.Left;VerticalAlignment=Enum.VerticalAlignment.Top});Inputs=g(y,{fitAxes="\089";containerProps={BackgroundTransparency=1;LayoutOrder=0,Size=UDim2.new(1,0,1,0)};layoutProps={Padding=UDim.new(0,8)},paddingProps={PaddingTop=UDim.new(0,10),PaddingBottom=UDim.new(0,10),PaddingLeft=UDim.new(0,10),PaddingRight=UDim.new(0,10)}},{UIPadding=g(N,{padding=10});Location=g(w,{LayoutOrder=2,Text="\083\101\108\101\099\116\105\111\110\047\076\111\099\097\116\105\111\110\047\082\111\116\097\116\105\111\110";theme=Z;Input=g(i,{Kind="\084\101\120\116\076\097\098\101\108",LayoutOrder=2;BackgroundTransparency=1;TextXAlignment=Enum.TextXAlignment.Left,Font=Z.TitleFont;TextSize=20;Text=k..(" "..Y);TextColor3=Z.Text1})}),Height=g(w,{LayoutOrder=4,Text="\072\101\105\103\104\116",theme=Z;Input=g(U,{layoutOrder=2,width=UDim.new(0,70);value=C.height,placeholderValue=f.defaultHeight,onValueChange=function(Z)S({height=Z})end})}),Width=g(w,{LayoutOrder=6,Text="\087\105\100\116\104";theme=Z,Input=g(U,{layoutOrder=2;width=UDim.new(0,70);value=C.width,placeholderValue=f.defaultWidth;onValueChange=function(Z)S({width=Z})end})}),partThickness=g(w,{LayoutOrder=8;Text="\084\104\105\099\107\110\101\115\115",theme=Z,Input=g(U,{layoutOrder=2;width=UDim.new(0,70),value=C.partThickness;onValueChange=function(Z)S({partThickness=Z})end})});wallMaterial=g(w,{LayoutOrder=9,Text="\087\097\108\108 \077\097\116\101\114\105\097\108";theme=Z,Input=g(r,{Size=UDim2.new(0,200,1,0),LayoutOrder=2,value=C.wallMaterial;onSelect=function(Z)warn(Z)S({wallMaterial=Z})end})});groundMaterial=g(w,{LayoutOrder=11,Text="\071\114\111\117\110\100 \077\097\116\101\114\105\097\108",theme=Z;Input=g(r,{Size=UDim2.new(0,200,1,0),LayoutOrder=2;value=C.groundMaterial,onSelect=function(Z)S({groundMaterial=Z})end})}),onlyBlocks=g(w,{LayoutOrder=14;Text="\085\115\101 \111\110\108\121 \098\108\111\099\107\115",theme=Z,Input=g(V,{layoutOrder=2,checked=C.onlyBlocks,onChange=function(Z)S({onlyBlocks=Z})end})});addRandomModels=g(w,{LayoutOrder=16,Text="\082\097\110\100\111\109 \109\111\100\101\108\115";theme=Z;Input=g(V,{layoutOrder=2;checked=C.addRandomModels;onChange=function(Z)S({addRandomModels=Z})end})}),addStartAndFinish=g(w,{LayoutOrder=18,Text="\083\116\097\114\116 \097\110\100 \070\105\110\105\115\104";theme=Z;Input=g(V,{layoutOrder=2,checked=C.addStartAndFinish;onChange=function(Z)S({addStartAndFinish=Z})end})});addKillBlocks=g(w,{LayoutOrder=20,Text="\075\105\108\108\098\108\111\099\107\115";theme=Z;Input=g(V,{layoutOrder=2,checked=C.addKillBlocks;onChange=function(Z)S({addKillBlocks=Z})end})}),addCeiling=g(w,{LayoutOrder=22;Text="\067\101\105\108\105\110\103",theme=Z;Input=g(V,{layoutOrder=2;checked=C.addCeiling;onChange=function(Z)S({addCeiling=Z})end})}),Button=g(s,{text="\071\101\110\101\114\097\116\101";LayoutOrder=30,onClick=function()if I~=nil then local Z=C.height if Z:len()==0 then Z=f.defaultHeight end local S=C.width if S:len()==0 then S=f.defaultWidth end local L=C.partThickness if L:len()==0 then L=f.defaultThickness end I({width=S,height=Z,partThickness=L;wallMaterial=C.wallMaterial;groundMaterial=C.groundMaterial;addRandomModels=C.addRandomModels,addStartAndFinish=C.addStartAndFinish;addKillBlocks=C.addKillBlocks,addCeiling=C.addCeiling;onlyBlocks=C.onlyBlocks,location=C.location or workspace})end end})})})end)end)end local o=(C.connect(function(Z)local I=Z.settings return{settings=I}end,function(Z)return{changeSettings=function(I)Z(Y(I))end}end))(u)return o
local Root = script:FindFirstAncestor('MazeGeneratorPlugin')
local Roact = require(Root:WaitForChild('Roact'))
local Plugin = Root.Plugin
local RoactRodux = require(Root.RoactRodux)
local Config = require(Plugin.Config)
local Theme = require(Plugin.Components.Theme)
local Panel = require(Plugin.Components.Panel)
local FitScrollingFrame = require(Plugin.Components.FitScrollingFrame)
local FitText = require(Plugin.Components.FitText)
local FormButton = require(Plugin.Components.FormButton)
local FormTextInput = require(Plugin.Components.FormTextInput)
local PluginSettings = require(Plugin.Components.PluginSettings)
local MaterialsDropdown = require(Plugin.Components.MaterialsDropdown)
local Checkbox = require(Plugin.Components.Checkbox)
local SettingsFormItem = require(Plugin.Components.SettingsFormItem)
local UIPadding = require(Plugin.Components.UIPadding)
local SetSettings = require(Plugin.Actions.SetSettings)

local selection = game:GetService('Selection')
local e = Roact.createElement

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

function SettingsForm:init()
	local changeSettings = self.props.changeSettings
	local settings = self.props.settings
	selection.SelectionChanged:Connect(function()
		if #selection:Get() > 0 then
			changeSettings({ location = selection:Get()[1] })
		else
			changeSettings({ location = nil })
		end
	end)
end

function SettingsForm:render()
	local generateMaze = self.props.generateMaze
	local changeSettings = self.props.changeSettings
	local settings = self.props.settings

	return Theme.with(function(theme)
		return PluginSettings.with(function()
			local location = settings.location
			local locationName = 'workspace'
			local locationPos = tostring(Vector3.new(0, 0, 0))

			if location and location:IsA('BasePart') then
				locationName = location.Name
				locationPos = tostring(location.Position)
			end

			return e(Panel, nil, {
				Layout = e('UIListLayout', {
					SortOrder = Enum.SortOrder.LayoutOrder,
					HorizontalAlignment = Enum.HorizontalAlignment.Left,
					VerticalAlignment = Enum.VerticalAlignment.Top,
				}),
				Inputs = e(
					FitScrollingFrame,
					{
						fitAxes = 'Y',
						containerProps = {
							BackgroundTransparency = 1,
							LayoutOrder = 0,
							Size = UDim2.new(1, 0, 1, 0),
						},
						layoutProps = { Padding = UDim.new(0, 8) },
						paddingProps = {
							PaddingTop = UDim.new(0, 10),
							PaddingBottom = UDim.new(0, 10),
							PaddingLeft = UDim.new(0, 10),
							PaddingRight = UDim.new(0, 10),
						},
					},
					{
						UIPadding = e(UIPadding, { padding = 10 }),
						Location = e(SettingsFormItem, {
							LayoutOrder = 2,
							Text = 'Selection/Location/Rotation',
							theme = theme,
							Input = e(FitText, {
								Kind = 'TextLabel',
								LayoutOrder = 2,
								BackgroundTransparency = 1,
								TextXAlignment = Enum.TextXAlignment.Left,
								Font = theme.TitleFont,
								TextSize = 20,
								Text = locationName .. ' ' .. locationPos,
								TextColor3 = theme.Text1,
							}),
						}),
						Height = e(SettingsFormItem, {
							LayoutOrder = 4,
							Text = 'Height',
							theme = theme,
							Input = e(FormTextInput, {
								layoutOrder = 2,
								width = UDim.new(0, 70),
								value = settings.height,
								placeholderValue = Config.defaultHeight,
								onValueChange = function(newValue)
									changeSettings({ height = newValue })
								end,
							}),
						}),
						Width = e(SettingsFormItem, {
							LayoutOrder = 6,
							Text = 'Width',
							theme = theme,
							Input = e(FormTextInput, {
								layoutOrder = 2,
								width = UDim.new(0, 70),
								value = settings.width,
								placeholderValue = Config.defaultWidth,
								onValueChange = function(newValue)
									changeSettings({ width = newValue })
								end,
							}),
						}),
						partThickness = e(SettingsFormItem, {
							LayoutOrder = 8,
							Text = 'Thickness',
							theme = theme,
							Input = e(FormTextInput, {
								layoutOrder = 2,
								width = UDim.new(0, 70),
								value = settings.partThickness,
								onValueChange = function(newValue)
									changeSettings({ partThickness = newValue })
								end,
							}),
						}),
						wallMaterial = e(SettingsFormItem, {
							LayoutOrder = 9,
							Text = 'Wall Material',
							theme = theme,
							Input = e(MaterialsDropdown, {
								Size = UDim2.new(0, 200, 1, 0),
								LayoutOrder = 2,
								value = settings.wallMaterial,
								onSelect = function(material)
									warn(material)
									changeSettings({ wallMaterial = material })
								end,
							}),
						}),
						groundMaterial = e(SettingsFormItem, {
							LayoutOrder = 11,
							Text = 'Ground Material',
							theme = theme,
							Input = e(MaterialsDropdown, {
								Size = UDim2.new(0, 200, 1, 0),
								LayoutOrder = 2,
								value = settings.groundMaterial,
								onSelect = function(material)
									changeSettings({ groundMaterial = material })
								end,
							}),
						}),
						onlyBlocks = e(SettingsFormItem, {
							LayoutOrder = 14,
							Text = 'Use only blocks',
							theme = theme,
							Input = e(Checkbox, {
								layoutOrder = 2,
								checked = settings.onlyBlocks,
								onChange = function(newValue)
									changeSettings({ onlyBlocks = newValue })
								end,
							}),
						}),
						addRandomModels = e(SettingsFormItem, {
							LayoutOrder = 16,
							Text = 'Random models',
							theme = theme,
							Input = e(Checkbox, {
								layoutOrder = 2,
								checked = settings.addRandomModels,
								onChange = function(newValue)
									changeSettings({ addRandomModels = newValue })
								end,
							}),
						}),
						addStartAndFinish = e(SettingsFormItem, {
							LayoutOrder = 18,
							Text = 'Start and Finish',
							theme = theme,
							Input = e(Checkbox, {
								layoutOrder = 2,
								checked = settings.addStartAndFinish,
								onChange = function(newValue)
									changeSettings({ addStartAndFinish = newValue })
								end,
							}),
						}),
						addKillBlocks = e(SettingsFormItem, {
							LayoutOrder = 20,
							Text = 'Killblocks',
							theme = theme,
							Input = e(Checkbox, {
								layoutOrder = 2,
								checked = settings.addKillBlocks,
								onChange = function(newValue)
									changeSettings({ addKillBlocks = newValue })
								end,
							}),
						}),
						addCeiling = e(SettingsFormItem, {
							LayoutOrder = 22,
							Text = 'Ceiling',
							theme = theme,
							Input = e(Checkbox, {
								layoutOrder = 2,
								checked = settings.addCeiling,
								onChange = function(newValue)
									changeSettings({ addCeiling = newValue })
								end,
							}),
						}),
						Button = e(FormButton, {
							text = 'Generate',
							LayoutOrder = 30,
							onClick = function()
								if generateMaze ~= nil then
									local height = settings.height
									if height:len() == 0 then
										height = Config.defaultHeight
									end

									local width = settings.width
									if width:len() == 0 then
										width = Config.defaultWidth
									end
									local partThickness = settings.partThickness
									if partThickness:len() == 0 then
										partThickness = Config.defaultThickness
									end

									generateMaze({
										width = width,
										height = height,
										partThickness = partThickness,
										wallMaterial = settings.wallMaterial,
										groundMaterial = settings.groundMaterial,
										addRandomModels = settings.addRandomModels,
										addStartAndFinish = settings.addStartAndFinish,
										addKillBlocks = settings.addKillBlocks,
										addCeiling = settings.addCeiling,
										onlyBlocks = settings.onlyBlocks,
										location = settings.location or workspace,
									})
								end
							end,
						}),
					}
				),
			})
		end)
	end)
end

local SettingsFormConnected = RoactRodux.connect(
	function(state)
		local settings = state.settings

		return { settings = settings }
	end,
	function(dispatch)
		return { changeSettings = function(settings)
			dispatch(SetSettings(settings))
		end }
	end
)(SettingsForm)

return SettingsFormConnected