-- FIXME Luau: GetPlayers() is typed as returning an array of Instances so we
-- need to cast it to `{ Player }`

local players = (Players:GetPlayers() :: any) :: { Player }
local controller = ExperienceComponents.HumanoidControllers.new(players, {
	Players.LocalPlayer :: Player,
})

Players.PlayerAdded:Connect(function(player)
	controller:addHumanoidController(player)
end)

Players.PlayerRemoving:Connect(function(player)
	controller:removeHumanoidController(player)
end)

local hideOthers: types.Action = {
	name = "Hide Others",
	description = "Toggle visibility of other players in your photo",
	icon = assets.UsersOutline,
	activeIcon = assets.UsersSolid,
	onActivated = function()
		controller:hideHumanoids()

		return function()
			controller:showHumanoids()
		end
	end,
}

return hideOthers
