local i=Roact.createElement local M=require(script:WaitForChild("\084\111\111\108\116\105\112"))local Y=Roact.PureComponent:extend("\077\111\100\101\084\111\103\103\108\101")function Y.init(i)i.Maid=Maid.new()function i.OnInputBegin(M,Y,U)if U then return end if Y.UserInputType.Name=="\077\111\117\115\101\077\111\118\101\109\101\110\116"then i:setState({IsHovering=true})end end function i.OnInputEnd(M,Y,U)if Y.UserInputType.Name=="\077\111\117\115\101\077\111\118\101\109\101\110\116"then i:setState({IsHovering=false})end end function i.OnActivated()i.props.Core.Targeting:ToggleTargetingMode()end i:setState({TargetingMode=i.props.Core.Targeting.TargetingMode,IsHovering=false})end function Y.didMount(i)local M=i.props.Core.Targeting i.Maid.ModeListener=M.TargetingModeChanged:Connect(function(M)i:setState({TargetingMode=M})end)end function Y.willUnmount(i)i.Maid:Destroy()end function Y.render(Y)local U=Y.state.TargetingMode=="\083\099\111\112\101\100"and 0 or Y.state.TargetingMode=="\068\105\114\101\099\116"and 14 return Roact.createFragment({ModeToggle=i("\073\109\097\103\101\066\117\116\116\111\110",{BackgroundTransparency=1,Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\052\052\052\053\057\053\057\053\050\051";ImageTransparency=1-(Y.state.IsHovering and.5 or.2),ScaleType=Enum.ScaleType.Slice;SliceCenter=Rect.new(4,4,12,12);ImageColor3=Color3.fromRGB(131,131,131);Size=UDim2.new(0,18.0,0,18.0),LayoutOrder=0;[Roact.Event.Activated]=Y.OnActivated,[Roact.Event.InputBegan]=Y.OnInputBegin;[Roact.Event.InputEnded]=Y.OnInputEnd},{Icon=i("\073\109\097\103\101\076\097\098\101\108",{BackgroundTransparency=1;Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\052\052\054\051\048\050\048\056\053\051";ImageTransparency=1-(Y.state.IsHovering and 1 or.5),AnchorPoint=Vector2.new(.5,.5),Position=UDim2.new(.5,0,.5,0),Size=UDim2.new(0,14.0,0,14.0),ImageRectOffset=Vector2.new(U,0),ImageRectSize=Vector2.new(14,14)}),Tooltip=i(M,{Visible=Y.state.IsHovering;IsToolModeEnabled=Y.props.IsToolModeEnabled})}),ModeToggleSpacer=i("\070\114\097\109\101",{BackgroundTransparency=1;Size=UDim2.new(0,0,1,0);LayoutOrder=1})})end return Y
-- Roact
local new = Roact.createElement
local Tooltip = require(script:WaitForChild("Tooltip"))

local ModeToggle = Roact.PureComponent:extend("ModeToggle")

function ModeToggle:init()
	self.Maid = Maid.new()

	--- Processes input, listens for hover start
	function self.OnInputBegin(rbx, Input, WasProcessed)
		if WasProcessed then
			return
		end

		-- Set hovering state
		if Input.UserInputType.Name == "MouseMovement" then
			self:setState({
				IsHovering = true,
			})
		end
	end

	--- Processes input, listens for hover end
	function self.OnInputEnd(rbx, Input, WasProcessed)
		if Input.UserInputType.Name == "MouseMovement" then
			self:setState({
				IsHovering = false,
			})
		end
	end

	--- Processes input, and toggles between targeting modes.
	function self.OnActivated()
		self.props.Core.Targeting:ToggleTargetingMode()
	end

	-- Set initial targeting mode
	self:setState({
		TargetingMode = self.props.Core.Targeting.TargetingMode,
		IsHovering = false,
	})
end

function ModeToggle:didMount()
	local Targeting = self.props.Core.Targeting
	self.Maid.ModeListener = Targeting.TargetingModeChanged:Connect(function(NewTargetingMode)
		self:setState({
			TargetingMode = NewTargetingMode,
		})
	end)
end

function ModeToggle:willUnmount()
	self.Maid:Destroy()
end

function ModeToggle:render()
	local IconSpritesheetPosition = (self.state.TargetingMode == "Scoped" and 0)
		or (self.state.TargetingMode == "Direct" and 14)
	return Roact.createFragment({
		ModeToggle = new("ImageButton", {
			BackgroundTransparency = 1,
			Image = "rbxassetid://4445959523",
			ImageTransparency = 1 - (self.state.IsHovering and 0.5 or 0.2),
			ScaleType = Enum.ScaleType.Slice,
			SliceCenter = Rect.new(4, 4, 12, 12),
			ImageColor3 = Color3.fromRGB(131, 131, 131),
			Size = UDim2.new(0, 36 / 2, 0, 36 / 2),
			LayoutOrder = 0,
			[Roact.Event.Activated] = self.OnActivated,
			[Roact.Event.InputBegan] = self.OnInputBegin,
			[Roact.Event.InputEnded] = self.OnInputEnd,
		}, {
			Icon = new("ImageLabel", {
				BackgroundTransparency = 1,
				Image = "rbxassetid://4463020853",
				ImageTransparency = 1 - (self.state.IsHovering and 1 or 0.5),
				AnchorPoint = Vector2.new(0.5, 0.5),
				Position = UDim2.new(0.5, 0, 0.5, 0),
				Size = UDim2.new(0, 28 / 2, 0, 28 / 2),
				ImageRectOffset = Vector2.new(IconSpritesheetPosition, 0),
				ImageRectSize = Vector2.new(14, 14),
			}),
			Tooltip = new(Tooltip, {
				Visible = self.state.IsHovering,
				IsToolModeEnabled = self.props.IsToolModeEnabled,
			}),
		}),
		ModeToggleSpacer = new("Frame", {
			BackgroundTransparency = 1,
			Size = UDim2.new(0, 0, 1, 0),
			LayoutOrder = 1,
		}),
	})
end

return ModeToggle
