function methods.GetMessageModeTextLabel(d)return d:GetMessageModeTextButton()end function methods.IsFocused(d)if d.UserHasChatOff then return false end return(d:GetTextBox()):IsFocused()end function methods.GetVisible(d)return d.GuiObject.Visible end function methods.CaptureFocus(d)if not d.UserHasChatOff then(d:GetTextBox()):CaptureFocus()end end function methods.ReleaseFocus(R,d)(R:GetTextBox()):ReleaseFocus(d)end function methods.ResetText(d)(d:GetTextBox()).Text=""end function methods.SetText(R,d)(R:GetTextBox()).Text=d end function methods.GetEnabled(d)return d.GuiObject.Visible end function methods.SetEnabled(R,d)if R.UserHasChatOff then R.GuiObject.Visible=true else R.GuiObject.Visible=d end end function methods.SetTextLabelText(R,d)if not R.UserHasChatOff then R.TextLabel.Text=d end end function methods.SetTextBoxText(R,d)R.TextBox.Text=d end function methods.GetTextBoxText(d)return d.TextBox.Text end function methods.ResetSize(d)d.TargetYSize=0 d:TweenToTargetYSize()end function methods.CalculateSize(d)if d.CalculatingSizeLock then return end d.CalculatingSizeLock=true local R=d.GuiObject.Size d.GuiObject.Size=UDim2.new(1,0,0,46)local v=nil local b=nil if d:IsFocused()or d.TextBox.Text~=""then v=d.TextBox.textSize b=d.TextBox.TextBounds.Y else v=d.TextLabel.textSize b=d.TextLabel.TextBounds.Y end d.GuiObject.Size=R local x=b-v if d.TargetYSize~=x then d.TargetYSize=x d:TweenToTargetYSize()end d.CalculatingSizeLock=false end function methods.TweenToTargetYSize(d)local R=UDim2.new(1,0,1,d.TargetYSize)local v=d.GuiObject.Size local b=d.GuiObject.AbsoluteSize.Y d.GuiObject.Size=R local x=d.GuiObject.AbsoluteSize.Y d.GuiObject.Size=v local i=math.abs(x-b)local L=math.min(1,i*(1/d.TweenPixelsPerSecond))local f=pcall(function()d.GuiObject:TweenSize(R,Enum.EasingDirection.Out,Enum.EasingStyle.Quad,L,true)end)if not f then d.GuiObject.Size=R end end function methods.SetTextSize(R,d)if not R:IsInCustomState()then if R.TextBox then R.TextBox.TextSize=d end if R.TextLabel then R.TextLabel.TextSize=d end end end function methods.GetDefaultChannelNameColor(d)if ChatSettings.DefaultChannelNameColor then return ChatSettings.DefaultChannelNameColor end return Color3.fromRGB(35,76,142)end function methods.SetChannelTarget(R,d)local v=R.GuiObjects.MessageModeTextButton local b=R.TextBox local x=R.TextLabel R.TargetChannel=d if not R:IsInCustomState()then if d~=ChatSettings.GeneralChannelName then v.Size=UDim2.new(0,1000,1,0)v.Text=string.format("\091\037\115\093 ",d)local i=R:GetChannelNameColor(d)if i then v.TextColor3=i else v.TextColor3=R:GetDefaultChannelNameColor()end local L=v.TextBounds.X v.Size=UDim2.new(0,L,1,0)b.Size=UDim2.new(1,-L,1,0)b.Position=UDim2.new(0,L,0,0)x.Size=UDim2.new(1,-L,1,0)x.Position=UDim2.new(0,L,0,0)else v.Text=""v.Size=UDim2.new(0,0,0,0)b.Size=UDim2.new(1,0,1,0)b.Position=UDim2.new(0,0,0,0)x.Size=UDim2.new(1,0,1,0)x.Position=UDim2.new(0,0,0,0)end end end function methods.IsInCustomState(d)return d.InCustomState end function methods.ResetCustomState(d)if d.InCustomState then d.CustomState:Destroy()d.CustomState=nil d.InCustomState=false d.ChatBarParentFrame:ClearAllChildren()d:CreateGuiObjects(d.ChatBarParentFrame)d:SetTextLabelText(ChatLocalization:Get("\071\097\109\101\067\104\097\116\095\067\104\097\116\077\097\105\110\095\067\104\097\116\066\097\114\084\101\120\116","\084\111 \099\104\097\116 \099\108\105\099\107 \104\101\114\101 \111\114 \112\114\101\115\115 \"\047\" \107\101\121"))end end function methods.GetCustomMessage(d)if d.InCustomState then return d.CustomState:GetMessage()end return nil end function methods.CustomStateProcessCompletedMessage(R,d)if R.InCustomState then return R.CustomState:ProcessCompletedMessage()end return false end function methods.FadeOutBackground(R,d)R.AnimParams.Background_TargetTransparency=1 R.AnimParams.Background_NormalizedExptValue=CurveUtil:NormalizedDefaultExptValueInSeconds(d)R:FadeOutText(d)end function methods.FadeInBackground(R,d)R.AnimParams.Background_TargetTransparency=.6 R.AnimParams.Background_NormalizedExptValue=CurveUtil:NormalizedDefaultExptValueInSeconds(d)R:FadeInText(d)end function methods.FadeOutText(R,d)R.AnimParams.Text_TargetTransparency=1 R.AnimParams.Text_NormalizedExptValue=CurveUtil:NormalizedDefaultExptValueInSeconds(d)end function methods.FadeInText(R,d)R.AnimParams.Text_TargetTransparency=.4 R.AnimParams.Text_NormalizedExptValue=CurveUtil:NormalizedDefaultExptValueInSeconds(d)end function methods.AnimGuiObjects(d)d.GuiObject.BackgroundTransparency=d.AnimParams.Background_CurrentTransparency d.GuiObjects.TextBoxFrame.BackgroundTransparency=d.AnimParams.Background_CurrentTransparency d.GuiObjects.TextLabel.TextTransparency=d.AnimParams.Text_CurrentTransparency d.GuiObjects.TextBox.TextTransparency=d.AnimParams.Text_CurrentTransparency d.GuiObjects.MessageModeTextButton.TextTransparency=d.AnimParams.Text_CurrentTransparency end function methods.InitializeAnimParams(d)d.AnimParams.Text_TargetTransparency=.4 d.AnimParams.Text_CurrentTransparency=.4 d.AnimParams.Text_NormalizedExptValue=1 d.AnimParams.Background_TargetTransparency=.6 d.AnimParams.Background_CurrentTransparency=.6 d.AnimParams.Background_NormalizedExptValue=1 end function methods.Update(R,d)R.AnimParams.Text_CurrentTransparency=CurveUtil:Expt(R.AnimParams.Text_CurrentTransparency,R.AnimParams.Text_TargetTransparency,R.AnimParams.Text_NormalizedExptValue,d)R.AnimParams.Background_CurrentTransparency=CurveUtil:Expt(R.AnimParams.Background_CurrentTransparency,R.AnimParams.Background_TargetTransparency,R.AnimParams.Background_NormalizedExptValue,d)R:AnimGuiObjects()end function methods.SetChannelNameColor(v,d,R)v.ChannelNameColors[d]=R if v.GuiObjects.MessageModeTextButton.Text==d then v.GuiObjects.MessageModeTextButton.TextColor3=R end end function methods.GetChannelNameColor(R,d)return R.ChannelNameColors[d]end
-- Deprecated in favour of GetMessageModeTextButton
-- Retained for compatibility reasons.
function methods:GetMessageModeTextLabel()
	return self:GetMessageModeTextButton()
end

function methods:IsFocused()
	if self.UserHasChatOff then
		return false
	end

	return self:GetTextBox():IsFocused()
end

function methods:GetVisible()
	return self.GuiObject.Visible
end

function methods:CaptureFocus()
	if not self.UserHasChatOff then
		self:GetTextBox():CaptureFocus()
	end
end

function methods:ReleaseFocus(didRelease)
	self:GetTextBox():ReleaseFocus(didRelease)
end

function methods:ResetText()
	self:GetTextBox().Text = ""
end

function methods:SetText(text)
	self:GetTextBox().Text = text
end

function methods:GetEnabled()
	return self.GuiObject.Visible
end

function methods:SetEnabled(enabled)
	if self.UserHasChatOff then
		-- The chat bar can not be removed if a user has chat turned off so that
		-- the chat bar can display a message explaining that chat is turned off.
		self.GuiObject.Visible = true
	else
		self.GuiObject.Visible = enabled
	end
end

function methods:SetTextLabelText(text)
	if not self.UserHasChatOff then
		self.TextLabel.Text = text
	end
end

function methods:SetTextBoxText(text)
	self.TextBox.Text = text
end

function methods:GetTextBoxText()
	return self.TextBox.Text
end

function methods:ResetSize()
	self.TargetYSize = 0
	self:TweenToTargetYSize()
end

function methods:CalculateSize()
	if self.CalculatingSizeLock then
		return
	end
	self.CalculatingSizeLock = true

	local lastPos = self.GuiObject.Size
	self.GuiObject.Size = UDim2.new(1, 0, 0, 46)

	local textSize = nil
	local bounds = nil

	if self:IsFocused() or self.TextBox.Text ~= "" then
		textSize = self.TextBox.textSize
		bounds = self.TextBox.TextBounds.Y
	else
		textSize = self.TextLabel.textSize
		bounds = self.TextLabel.TextBounds.Y
	end

	self.GuiObject.Size = lastPos

	local newTargetYSize = bounds - textSize
	if self.TargetYSize ~= newTargetYSize then
		self.TargetYSize = newTargetYSize
		self:TweenToTargetYSize()
	end

	self.CalculatingSizeLock = false
end

function methods:TweenToTargetYSize()
	local endSize = UDim2.new(1, 0, 1, self.TargetYSize)
	local curSize = self.GuiObject.Size

	local curAbsoluteSizeY = self.GuiObject.AbsoluteSize.Y
	self.GuiObject.Size = endSize
	local endAbsoluteSizeY = self.GuiObject.AbsoluteSize.Y
	self.GuiObject.Size = curSize

	local pixelDistance = math.abs(endAbsoluteSizeY - curAbsoluteSizeY)
	local tweeningTime = math.min(1, (pixelDistance * (1 / self.TweenPixelsPerSecond))) -- pixelDistance * (seconds per pixels)

	local success = pcall(function()
		self.GuiObject:TweenSize(endSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, tweeningTime, true)
	end)
	if not success then
		self.GuiObject.Size = endSize
	end
end

function methods:SetTextSize(textSize)
	if not self:IsInCustomState() then
		if self.TextBox then
			self.TextBox.TextSize = textSize
		end
		if self.TextLabel then
			self.TextLabel.TextSize = textSize
		end
	end
end

function methods:GetDefaultChannelNameColor()
	if ChatSettings.DefaultChannelNameColor then
		return ChatSettings.DefaultChannelNameColor
	end
	return Color3.fromRGB(35, 76, 142)
end

function methods:SetChannelTarget(targetChannel)
	local messageModeTextButton = self.GuiObjects.MessageModeTextButton
	local textBox = self.TextBox
	local textLabel = self.TextLabel

	self.TargetChannel = targetChannel

	if not self:IsInCustomState() then
		if targetChannel ~= ChatSettings.GeneralChannelName then
			messageModeTextButton.Size = UDim2.new(0, 1000, 1, 0)
			messageModeTextButton.Text = string.format("[%s] ", targetChannel)

			local channelNameColor = self:GetChannelNameColor(targetChannel)
			if channelNameColor then
				messageModeTextButton.TextColor3 = channelNameColor
			else
				messageModeTextButton.TextColor3 = self:GetDefaultChannelNameColor()
			end

			local xSize = messageModeTextButton.TextBounds.X
			messageModeTextButton.Size = UDim2.new(0, xSize, 1, 0)
			textBox.Size = UDim2.new(1, -xSize, 1, 0)
			textBox.Position = UDim2.new(0, xSize, 0, 0)
			textLabel.Size = UDim2.new(1, -xSize, 1, 0)
			textLabel.Position = UDim2.new(0, xSize, 0, 0)
		else
			messageModeTextButton.Text = ""
			messageModeTextButton.Size = UDim2.new(0, 0, 0, 0)
			textBox.Size = UDim2.new(1, 0, 1, 0)
			textBox.Position = UDim2.new(0, 0, 0, 0)
			textLabel.Size = UDim2.new(1, 0, 1, 0)
			textLabel.Position = UDim2.new(0, 0, 0, 0)
		end
	end
end

function methods:IsInCustomState()
	return self.InCustomState
end

function methods:ResetCustomState()
	if self.InCustomState then
		self.CustomState:Destroy()
		self.CustomState = nil
		self.InCustomState = false

		self.ChatBarParentFrame:ClearAllChildren()
		self:CreateGuiObjects(self.ChatBarParentFrame)
		self:SetTextLabelText(
			ChatLocalization:Get("GameChat_ChatMain_ChatBarText", 'To chat click here or press "/" key')
		)
	end
end

function methods:GetCustomMessage()
	if self.InCustomState then
		return self.CustomState:GetMessage()
	end
	return nil
end

function methods:CustomStateProcessCompletedMessage(message)
	if self.InCustomState then
		return self.CustomState:ProcessCompletedMessage()
	end
	return false
end

function methods:FadeOutBackground(duration)
	self.AnimParams.Background_TargetTransparency = 1
	self.AnimParams.Background_NormalizedExptValue = CurveUtil:NormalizedDefaultExptValueInSeconds(duration)
	self:FadeOutText(duration)
end

function methods:FadeInBackground(duration)
	self.AnimParams.Background_TargetTransparency = 0.6
	self.AnimParams.Background_NormalizedExptValue = CurveUtil:NormalizedDefaultExptValueInSeconds(duration)
	self:FadeInText(duration)
end

function methods:FadeOutText(duration)
	self.AnimParams.Text_TargetTransparency = 1
	self.AnimParams.Text_NormalizedExptValue = CurveUtil:NormalizedDefaultExptValueInSeconds(duration)
end

function methods:FadeInText(duration)
	self.AnimParams.Text_TargetTransparency = 0.4
	self.AnimParams.Text_NormalizedExptValue = CurveUtil:NormalizedDefaultExptValueInSeconds(duration)
end

function methods:AnimGuiObjects()
	self.GuiObject.BackgroundTransparency = self.AnimParams.Background_CurrentTransparency
	self.GuiObjects.TextBoxFrame.BackgroundTransparency = self.AnimParams.Background_CurrentTransparency

	self.GuiObjects.TextLabel.TextTransparency = self.AnimParams.Text_CurrentTransparency
	self.GuiObjects.TextBox.TextTransparency = self.AnimParams.Text_CurrentTransparency
	self.GuiObjects.MessageModeTextButton.TextTransparency = self.AnimParams.Text_CurrentTransparency
end

function methods:InitializeAnimParams()
	self.AnimParams.Text_TargetTransparency = 0.4
	self.AnimParams.Text_CurrentTransparency = 0.4
	self.AnimParams.Text_NormalizedExptValue = 1

	self.AnimParams.Background_TargetTransparency = 0.6
	self.AnimParams.Background_CurrentTransparency = 0.6
	self.AnimParams.Background_NormalizedExptValue = 1
end

function methods:Update(dtScale)
	self.AnimParams.Text_CurrentTransparency = CurveUtil:Expt(
		self.AnimParams.Text_CurrentTransparency,
		self.AnimParams.Text_TargetTransparency,
		self.AnimParams.Text_NormalizedExptValue,
		dtScale
	)
	self.AnimParams.Background_CurrentTransparency = CurveUtil:Expt(
		self.AnimParams.Background_CurrentTransparency,
		self.AnimParams.Background_TargetTransparency,
		self.AnimParams.Background_NormalizedExptValue,
		dtScale
	)

	self:AnimGuiObjects()
end

function methods:SetChannelNameColor(channelName, channelNameColor)
	self.ChannelNameColors[channelName] = channelNameColor
	if self.GuiObjects.MessageModeTextButton.Text == channelName then
		self.GuiObjects.MessageModeTextButton.TextColor3 = channelNameColor
	end
end

function methods:GetChannelNameColor(channelName)
	return self.ChannelNameColors[channelName]
end
