local r=(require(script.Parent.loader)).load(script)local Q=r("\066\097\115\105\099\080\097\110\101")local t=r("\077\097\116\101\114\105\097\108\076\105\115\116")local x=r("\083\105\103\110\097\108")local w=r("\067\111\110\118\101\114\116\080\097\110\101")local E=r("\067\104\101\099\107\098\111\120")local k=setmetatable({},Q)k.ClassName="\080\108\117\103\105\110\085\073"k.__index=k function k.new(r,I,Y,v)local s=setmetatable(Q.new(I),k)s._serviceBag=assert(r,"\078\111 \115\101\114\118\105\099\101\066\097\103")s._terrainConverter=v or error("\078\111 \116\101\114\114\097\105\110\067\111\110\118\101\114\116\101\114")s._selectionService=Y or error("\078\111 \115\101\108\101\099\116\111\110\083\101\114\118\105\099\101")s.RequestClose=s._maid:Add(x.new())s.RequestConvert=s._maid:Add(x.new())s._materialList=t.new(s._serviceBag,s.Gui.Content.MaterialList)s._maid:GiveTask(s._materialList)s._convertPane=w.new(s._serviceBag,s.Gui.Content.ConvertPane,Y,v)s._maid:GiveTask(s._convertPane)s._maid:GiveTask(s._convertPane.RequestConvert:Connect(function(r)s.RequestConvert:Fire(r,s._materialList.SelectedMaterial.Value)end))s.Gui.Header.CloseButton.MouseButton1Click:Connect(function()s.RequestClose:Fire()end)s._optionsFrame=s.Gui.Content.Options s._removePartCheckBox=E.new(s._serviceBag,{Name="\075\101\101\112 \099\111\110\118\101\114\116\101\100 \112\097\114\116";BoolValue=s._terrainConverter.KeepConvertedPart})s:_addOptionGui(s._removePartCheckBox)s._replaceExistingTerrain=E.new(s._serviceBag,{Name="\079\118\101\114\119\114\105\116\101 \116\101\114\114\097\105\110",BoolValue=s._terrainConverter.OverwriteTerrain})s:_addOptionGui(s._replaceExistingTerrain)s._ignoreWater=E.new(s._serviceBag,{Name="\079\118\101\114\119\114\105\116\101 \119\097\116\101\114";BoolValue=s._terrainConverter.OverwriteWater})s:_addOptionGui(s._ignoreWater)return s end function k._addOptionGui(Q,r)r.Gui.LayoutOrder=#Q._optionsFrame:GetChildren()+1 r.Gui.Parent=Q._optionsFrame Q._maid:GiveTask(r)end function k.SetMaterialInput(Q,r)Q._materialInput=r or error("\078\111 \109\097\116\101\114\105\097\108\073\110\112\117\116")Q._maid:GiveTask(r)Q._maid:GiveTask(r.MaterialSelected:Connect(function(r)Q._materialList.SelectedMaterial.Value=r end))Q._maid:GiveTask(r.ConvertRequest:Connect(function()local r=Q._selectionService:Get()if#r>0 then Q.RequestConvert:Fire(r,Q._materialList.SelectedMaterial.Value)end end))end return k
--[=[
	@class PluginUI
]=]

local require = require(script.Parent.loader).load(script)

local BasicPane = require("BasicPane")
local MaterialList = require("MaterialList")
local Signal = require("Signal")
local ConvertPane = require("ConvertPane")
local Checkbox = require("Checkbox")

local PluginUI = setmetatable({}, BasicPane)
PluginUI.ClassName = "PluginUI"
PluginUI.__index = PluginUI

function PluginUI.new(serviceBag, gui, selectonService, terrainConverter)
	local self = setmetatable(BasicPane.new(gui), PluginUI)

	self._serviceBag = assert(serviceBag, "No serviceBag")

	self._terrainConverter = terrainConverter or error("No terrainConverter")
	self._selectionService = selectonService or error("No selectonService")

	self.RequestClose = self._maid:Add(Signal.new())
	self.RequestConvert = self._maid:Add(Signal.new()) -- :Fire(selection, material)

	self._materialList = MaterialList.new(self._serviceBag, self.Gui.Content.MaterialList)
	self._maid:GiveTask(self._materialList)

	self._convertPane = ConvertPane.new(self._serviceBag, self.Gui.Content.ConvertPane, selectonService, terrainConverter)
	self._maid:GiveTask(self._convertPane)
	self._maid:GiveTask(self._convertPane.RequestConvert:Connect(function(selection)
		self.RequestConvert:Fire(selection, self._materialList.SelectedMaterial.Value)
	end))

	self.Gui.Header.CloseButton.MouseButton1Click:Connect(function()
		self.RequestClose:Fire()
	end)

	self._optionsFrame = self.Gui.Content.Options

	self._removePartCheckBox = Checkbox.new(self._serviceBag, {
		Name = "Keep converted part";
		BoolValue = self._terrainConverter.KeepConvertedPart
	})
	self:_addOptionGui(self._removePartCheckBox)

	self._replaceExistingTerrain = Checkbox.new(self._serviceBag, {
		Name = "Overwrite terrain";
		BoolValue = self._terrainConverter.OverwriteTerrain;
	})
	self:_addOptionGui(self._replaceExistingTerrain)

	self._ignoreWater = Checkbox.new(self._serviceBag, {
		Name = "Overwrite water";
		BoolValue = self._terrainConverter.OverwriteWater;
	})
	self:_addOptionGui(self._ignoreWater)

	return self
end

function PluginUI:_addOptionGui(option)
	option.Gui.LayoutOrder = #self._optionsFrame:GetChildren() + 1
	option.Gui.Parent = self._optionsFrame
	self._maid:GiveTask(option)
end

function PluginUI:SetMaterialInput(materialInput)
	self._materialInput = materialInput or error("No materialInput")
	self._maid:GiveTask(materialInput)

	self._maid:GiveTask(materialInput.MaterialSelected:Connect(function(material)
		self._materialList.SelectedMaterial.Value = material
	end))

	self._maid:GiveTask(materialInput.ConvertRequest:Connect(function()
		local selection = self._selectionService:Get()
		if #selection > 0 then
			self.RequestConvert:Fire(selection, self._materialList.SelectedMaterial.Value)
		end
	end))
end

return PluginUI