local M=script.Parent.Parent local L=require(M:WaitForChild("\067\104\097\116\083\101\116\116\105\110\103\115"))local o=require(M:WaitForChild("\067\104\097\116\067\111\110\115\116\097\110\116\115"))local F=require(script.Parent:WaitForChild("\085\116\105\108"))function CreateMessageLabel(M,o)local d=M.FromSpeaker local R=M.Message local U=M.ExtraData or{}local N=U.Font or L.DefaultFont local C=U.TextSize or L.ChatWindowTextSize local c=U.NameColor or L.DefaultNameColor local j=U.ChatColor or L.DefaultMessageColor local t=U.ChannelColor or j local g=U.Tags or{}local h=U.Icons or{}local S=string.format("\091\037\115\093\058",d)local A=F:GetStringTextBounds(S,N,C)local u=F:GetNumberOfSpaces(S,N,C)+1 local z,w=F:CreateBaseMessage("",N,C,j)local G=F:AddNameButtonToBaseMessage(w,c,S,d)local V=nil local P=UDim2.new(0,0,0,0)if o~=M.OriginalChannel then local L=string.format("\123\037\115\125",M.OriginalChannel)V=F:AddChannelButtonToBaseMessage(w,t,L,M.OriginalChannel)P=UDim2.new(0,V.Size.X.Offset+(F:GetStringTextBounds(" ",N,C)).X,0,0)u=(u+F:GetNumberOfSpaces(L,N,C))+1 end local f={}for M,L in pairs(g)do local o=L.TagColor or Color3.fromRGB(255,0,255)local d=L.TagText or"\063\063\063"local R=string.format("\091\037\115\093 ",d)local U=F:AddTagLabelToBaseMessage(w,o,R)U.Position=P u=u+F:GetNumberOfSpaces(R,N,C)P=P+UDim2.new(0,U.Size.X.Offset,0,0)table.insert(f,U)end local x={}for M,L in pairs(h)do local o=F:AddIconLabelToBaseMessage(w,L)o.Position=P u=u+F:GetNumberOfSpaces(o,N,C)P=P+UDim2.new(0,o.Size.X.Offset,0,0)table.insert(x,o)end G.Position=P local function b(L)if M.IsFiltered then w.Text=string.rep(" ",u)..L.Message else w.Text=string.rep(" ",u)..string.rep("\095",L.MessageLength)end end b(M)local function y(M)return F:GetMessageHeight(w,z,M)end local Y={}Y[G]={TextTransparency={FadedIn=0,FadedOut=1},TextStrokeTransparency={FadedIn=.75,FadedOut=1}}Y[w]={TextTransparency={FadedIn=0,FadedOut=1},TextStrokeTransparency={FadedIn=.75,FadedOut=1}}for M,L in pairs(f)do local o=string.format("\084\097\103\037\100",M)Y[L]={TextTransparency={FadedIn=0,FadedOut=1};TextStrokeTransparency={FadedIn=.75;FadedOut=1}}end for M,L in pairs(x)do Y[L]={ImageTransparency={FadedIn=0,FadedOut=1}}end if V then Y[V]={TextTransparency={FadedIn=0,FadedOut=1};TextStrokeTransparency={FadedIn=.75,FadedOut=1}}end local O,W,i=F:CreateFadeFunctions(Y)return{[F.KEY_BASE_FRAME]=z,[F.KEY_BASE_MESSAGE]=w,[F.KEY_UPDATE_TEXT_FUNC]=b,[F.KEY_GET_HEIGHT]=y;[F.KEY_FADE_IN]=O;[F.KEY_FADE_OUT]=W,[F.KEY_UPDATE_ANIMATION]=i}end return{[F.KEY_MESSAGE_TYPE]=o.MessageTypeDefault,[F.KEY_CREATOR_FUNCTION]=CreateMessageLabel}
-- // Chat Icon Amendment by ChipioIndustries.
-- // Based on latest chat version as of 10/10/2019
-- // Edits on lines 26, 59, 92

local clientChatModules = script.Parent.Parent
local ChatSettings = require(clientChatModules:WaitForChild("ChatSettings"))
local ChatConstants = require(clientChatModules:WaitForChild("ChatConstants"))
local util = require(script.Parent:WaitForChild("Util"))

function CreateMessageLabel(messageData, channelName)
	local fromSpeaker = messageData.FromSpeaker
	local message = messageData.Message

	local extraData = messageData.ExtraData or {}
	local useFont = extraData.Font or ChatSettings.DefaultFont
	local useTextSize = extraData.TextSize or ChatSettings.ChatWindowTextSize
	local useNameColor = extraData.NameColor or ChatSettings.DefaultNameColor
	local useChatColor = extraData.ChatColor or ChatSettings.DefaultMessageColor
	local useChannelColor = extraData.ChannelColor or useChatColor
	local tags = extraData.Tags or {}
	local icons = extraData.Icons or {}

	local formatUseName = string.format("[%s]:", fromSpeaker)
	local speakerNameSize = util:GetStringTextBounds(formatUseName, useFont, useTextSize)
	local numNeededSpaces = util:GetNumberOfSpaces(formatUseName, useFont, useTextSize) + 1

	local BaseFrame, BaseMessage = util:CreateBaseMessage("", useFont, useTextSize, useChatColor)
	local NameButton = util:AddNameButtonToBaseMessage(BaseMessage, useNameColor, formatUseName, fromSpeaker)
	local ChannelButton = nil

	local guiObjectSpacing = UDim2.new(0, 0, 0, 0)

	if channelName ~= messageData.OriginalChannel then
		local formatChannelName = string.format("{%s}", messageData.OriginalChannel)
		ChannelButton = util:AddChannelButtonToBaseMessage(
			BaseMessage,
			useChannelColor,
			formatChannelName,
			messageData.OriginalChannel
		)
		guiObjectSpacing =
			UDim2.new(0, ChannelButton.Size.X.Offset + util:GetStringTextBounds(" ", useFont, useTextSize).X, 0, 0)
		numNeededSpaces = numNeededSpaces + util:GetNumberOfSpaces(formatChannelName, useFont, useTextSize) + 1
	end

	local tagLabels = {}
	for i, tag in pairs(tags) do
		local tagColor = tag.TagColor or Color3.fromRGB(255, 0, 255)
		local tagText = tag.TagText or "???"
		local formatTagText = string.format("[%s] ", tagText)
		local label = util:AddTagLabelToBaseMessage(BaseMessage, tagColor, formatTagText)
		label.Position = guiObjectSpacing

		numNeededSpaces = numNeededSpaces + util:GetNumberOfSpaces(formatTagText, useFont, useTextSize)
		guiObjectSpacing = guiObjectSpacing + UDim2.new(0, label.Size.X.Offset, 0, 0)

		table.insert(tagLabels, label)
	end

	local iconLabels = {}
	for i, icon in pairs(icons) do
		local label = util:AddIconLabelToBaseMessage(BaseMessage, icon)
		label.Position = guiObjectSpacing

		numNeededSpaces = numNeededSpaces + util:GetNumberOfSpaces(label, useFont, useTextSize)
		guiObjectSpacing = guiObjectSpacing + UDim2.new(0, label.Size.X.Offset, 0, 0)

		table.insert(iconLabels, label)
	end

	NameButton.Position = guiObjectSpacing

	local function UpdateTextFunction(messageObject)
		if messageData.IsFiltered then
			BaseMessage.Text = string.rep(" ", numNeededSpaces) .. messageObject.Message
		else
			BaseMessage.Text = string.rep(" ", numNeededSpaces) .. string.rep("_", messageObject.MessageLength)
		end
	end

	UpdateTextFunction(messageData)

	local function GetHeightFunction(xSize)
		return util:GetMessageHeight(BaseMessage, BaseFrame, xSize)
	end

	local FadeParmaters = {}
	FadeParmaters[NameButton] = {
		TextTransparency = { FadedIn = 0, FadedOut = 1 },
		TextStrokeTransparency = { FadedIn = 0.75, FadedOut = 1 },
	}

	FadeParmaters[BaseMessage] = {
		TextTransparency = { FadedIn = 0, FadedOut = 1 },
		TextStrokeTransparency = { FadedIn = 0.75, FadedOut = 1 },
	}

	for i, tagLabel in pairs(tagLabels) do
		local index = string.format("Tag%d", i)
		FadeParmaters[tagLabel] = {
			TextTransparency = { FadedIn = 0, FadedOut = 1 },
			TextStrokeTransparency = { FadedIn = 0.75, FadedOut = 1 },
		}
	end

	for i, icon in pairs(iconLabels) do
		FadeParmaters[icon] = {
			ImageTransparency = { FadedIn = 0, FadedOut = 1 },
		}
	end

	if ChannelButton then
		FadeParmaters[ChannelButton] = {
			TextTransparency = { FadedIn = 0, FadedOut = 1 },
			TextStrokeTransparency = { FadedIn = 0.75, FadedOut = 1 },
		}
	end

	local FadeInFunction, FadeOutFunction, UpdateAnimFunction = util:CreateFadeFunctions(FadeParmaters)

	return {
		[util.KEY_BASE_FRAME] = BaseFrame,
		[util.KEY_BASE_MESSAGE] = BaseMessage,
		[util.KEY_UPDATE_TEXT_FUNC] = UpdateTextFunction,
		[util.KEY_GET_HEIGHT] = GetHeightFunction,
		[util.KEY_FADE_IN] = FadeInFunction,
		[util.KEY_FADE_OUT] = FadeOutFunction,
		[util.KEY_UPDATE_ANIMATION] = UpdateAnimFunction,
	}
end

return {
	[util.KEY_MESSAGE_TYPE] = ChatConstants.MessageTypeDefault,
	[util.KEY_CREATOR_FUNCTION] = CreateMessageLabel,
}
