local X=game:GetService("\080\108\097\121\101\114\115")local x=require("\115\101\114\118\101\114\047\110\101\116\119\111\114\107")local U=require("\115\104\097\114\101\100\047\111\117\116\112\117\116\047\109\101\115\115\097\103\101\084\121\112\101\115")local g=require("\115\104\097\114\101\100\047\102\117\110\099\116\105\111\110\115")local y={}y.MessageType=U function y.appendTo(T,X,g,y,A)assert(g,"\078\111 \109\101\115\115\097\103\101\084\121\112\101 \103\105\118\101\110\046")assert(U[g],"\073\110\118\097\108\105\100 \109\101\115\115\097\103\101 \116\121\112\101\046")assert(y,"\078\111 \109\101\115\115\097\103\101 \103\105\118\101\110\046")x:FireClient(X,"\111\117\116\112\117\116\058\058\097\112\112\101\110\100",g,y,A)end function y.appendToAll(A,X,g,y)assert(X,"\078\111 \109\101\115\115\097\103\101\084\121\112\101 \103\105\118\101\110\046")assert(U[X],"\073\110\118\097\108\105\100 \109\101\115\115\097\103\101 \116\121\112\101\046")assert(g,"\078\111 \109\101\115\115\097\103\101 \103\105\118\101\110\046")x:FireAllClients("\111\117\116\112\117\116\058\058\097\112\112\101\110\100",X,g,y)end function y.appendToOthers(G,g,y,A,T)assert(y,"\078\111 \109\101\115\115\097\103\101\084\121\112\101 \103\105\118\101\110\046")assert(U[y],"\073\110\118\097\108\105\100 \109\101\115\115\097\103\101 \116\121\112\101\046")assert(A,"\078\111 \109\101\115\115\097\103\101 \103\105\118\101\110\046")local N=X:GetPlayers()local u=table.find(N,g)if u then table.remove(N,u)end for X,U in N do x:FireClient(U,"\111\117\116\112\117\116\058\058\097\112\112\101\110\100",y,A,T)end end function y.appendWithIdTo(G,X,y,A,T)assert(y,"\078\111 \109\101\115\115\097\103\101\084\121\112\101 \103\105\118\101\110\046")assert(U[y],"\073\110\118\097\108\105\100 \109\101\115\115\097\103\101 \116\121\112\101\046")assert(A,"\078\111 \109\101\115\115\097\103\101 \103\105\118\101\110\046")local N=g.randomString()x:FireClient(X,"\111\117\116\112\117\116\058\058\097\112\112\101\110\100\087\105\116\104\073\100",y,A,T,N)return N end function y.editFrom(G,X,g,y,A,T)assert(y,"\078\111 \109\101\115\115\097\103\101\084\121\112\101 \103\105\118\101\110\046")assert(U[y],"\073\110\118\097\108\105\100 \109\101\115\115\097\103\101 \116\121\112\101\046")assert(A,"\078\111 \109\101\115\115\097\103\101 \103\105\118\101\110\046")x:FireClient(X,"\111\117\116\112\117\116\058\058\101\100\105\116",g,y,A,T)end function y.dropIdFrom(g,X,U)x:FireClient(X,"\111\117\116\112\117\116\058\058\100\114\111\112\073\100",U)end return y
local Players = game:GetService("Players")

local Network = require("server/network")
local MessageTypes = require("shared/output/messageTypes")
local Functions = require("shared/functions")

local Output = {}
Output.MessageType = MessageTypes

function Output:appendTo(player, messageType, message, dateTime)
	assert(messageType, "No messageType given.")
	assert(MessageTypes[messageType], "Invalid message type.")
	assert(message, "No message given.")

	Network:FireClient(player, "output::append", messageType, message, dateTime)
end

function Output:appendToAll(messageType, message, dateTime)
	assert(messageType, "No messageType given.")
	assert(MessageTypes[messageType], "Invalid message type.")
	assert(message, "No message given.")

	Network:FireAllClients("output::append", messageType, message, dateTime)
end

function Output:appendToOthers(excludedPlayer, messageType, message, dateTime)
	assert(messageType, "No messageType given.")
	assert(MessageTypes[messageType], "Invalid message type.")
	assert(message, "No message given.")

	local players = Players:GetPlayers()
	local index = table.find(players, excludedPlayer)
	if index then
		table.remove(players, index)
	end

	for _, player in players do
		Network:FireClient(player, "output::append", messageType, message, dateTime)
	end
end

function Output:appendWithIdTo(player, messageType, message, dateTime)
	assert(messageType, "No messageType given.")
	assert(MessageTypes[messageType], "Invalid message type.")
	assert(message, "No message given.")

	local id = Functions.randomString()
	Network:FireClient(player, "output::appendWithId", messageType, message, dateTime, id)

	return id
end

function Output:editFrom(player, id, messageType, message, dateTime)
	assert(messageType, "No messageType given.")
	assert(MessageTypes[messageType], "Invalid message type.")
	assert(message, "No message given.")

	Network:FireClient(player, "output::edit", id, messageType, message, dateTime)
end

function Output:dropIdFrom(player, id)
	Network:FireClient(player, "output::dropId", id)
end

return Output
