local K=game:GetService("\067\111\110\116\101\120\116\065\099\116\105\111\110\083\101\114\118\105\099\101")local L=require(script.Parent.Parent.Packages.Roact)local M=require(script.Parent.Parent.Packages.t)local J=(require(script.Parent.Parent.Libraries.Configuration)).ConfigurationContext local V=L.Component:extend("\071\097\109\101\112\097\100\084\111\103\103\108\101\066\117\116\116\111\110")local U=66 V.defaultProps={actionName="\071\097\109\101\112\097\100\084\111\103\103\108\101\066\117\116\116\111\110";onActivated=function() end}V.validateProps=M.interface({onActivated=M.callback,transparency=M.optional(M.union(M.table,M.number))})function V.init(K)K.onActivated=function(L,M)if M~=Enum.UserInputState.Begin then return end K.props.onActivated()end end function V.render(K)return L.createElement("\073\109\097\103\101\066\117\116\116\111\110",{Size=UDim2.fromOffset(U,U);Image=K.props.configuration.gamepadButtonIcon,ImageTransparency=K.props.transparency;BackgroundTransparency=1,[L.Event.Activated]=K.props.onActivated},{AspectRatio=L.createElement("\085\073\065\115\112\101\099\116\082\097\116\105\111\067\111\110\115\116\114\097\105\110\116",{AspectRatio=1}),GamepadButton=L.createElement("\073\109\097\103\101\076\097\098\101\108",{Image=K.props.configuration.toggleButtonImage,ImageTransparency=K.props.transparency,Size=UDim2.fromScale(.5,.5),Position=UDim2.fromScale(1,1);AnchorPoint=Vector2.new(.85,.85);BackgroundTransparency=1})})end function V.didMount(L)K:BindAction(L.props.actionName,L.onActivated,false,L.props.configuration.toggleButton)end function V.willUnmount(L)K:UnbindAction(L.props.actionName)end return J.withConfiguration(V)
--[[
	Button for opening the EmoteBar on gamepad enabled devices.
]]

local ContextActionService = game:GetService("ContextActionService")

local Roact = require(script.Parent.Parent.Packages.Roact)
local t = require(script.Parent.Parent.Packages.t)
local ConfigurationContext = require(script.Parent.Parent.Libraries.Configuration).ConfigurationContext

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

local MAX_SIZE = 66

GamepadToggleButton.defaultProps = {
	actionName = "GamepadToggleButton",
	onActivated = function() end,
}

GamepadToggleButton.validateProps = t.interface({
	onActivated = t.callback,
	transparency = t.optional(t.union(t.table, t.number)), -- Binding or number
})

function GamepadToggleButton:init()
	self.onActivated = function(_actionName, inputState)
		if inputState ~= Enum.UserInputState.Begin then
			return
		end

		self.props.onActivated()
	end
end

function GamepadToggleButton:render()
	return Roact.createElement("ImageButton", {
		Size = UDim2.fromOffset(MAX_SIZE, MAX_SIZE),
		Image = self.props.configuration.gamepadButtonIcon,
		ImageTransparency = self.props.transparency,
		BackgroundTransparency = 1,

		[Roact.Event.Activated] = self.props.onActivated,
	}, {
		AspectRatio = Roact.createElement("UIAspectRatioConstraint", {
			AspectRatio = 1,
		}),

		GamepadButton = Roact.createElement("ImageLabel", {
			Image = self.props.configuration.toggleButtonImage,
			ImageTransparency = self.props.transparency,
			Size = UDim2.fromScale(0.5, 0.5),
			Position = UDim2.fromScale(1, 1),
			AnchorPoint = Vector2.new(0.85, 0.85),
			BackgroundTransparency = 1,
		}),
	})
end

function GamepadToggleButton:didMount()
	ContextActionService:BindAction(
		self.props.actionName,
		self.onActivated,
		false,
		self.props.configuration.toggleButton
	)
end

function GamepadToggleButton:willUnmount()
	ContextActionService:UnbindAction(self.props.actionName)
end

return ConfigurationContext.withConfiguration(GamepadToggleButton)
