function methods.DoLockChatBar(U)if U.TextLabel then if LocalPlayer.UserId>0 then U.TextLabel.Text="\084\111 \099\104\097\116 \105\110 \103\097\109\101\044 \116\117\114\110 \111\110 \099\104\097\116 \105\110 \121\111\117\114 \080\114\105\118\097\099\121 \083\101\116\116\105\110\103\115\046"else U.TextLabel.Text="\083\105\103\110 \117\112 \116\111 \099\104\097\116 \105\110 \103\097\109\101\046"end U:CalculateSize()end if U.TextBox then U.TextBox.Active=false U.TextBox.Focused:connect(function()U.TextBox:ReleaseFocus()end)end end function methods.SetUpTextBoxEvents(G,U,c,I)UserInputService.InputBegan:connect(function(c,I)if c.KeyCode==Enum.KeyCode.Backspace then if G:IsFocused()and U.Text==""then G:SetChannelTarget(ChatSettings.GeneralChannelName)end end end)U.Changed:connect(function(c)if c=="\065\098\115\111\108\117\116\101\083\105\122\101"then G:CalculateSize()return end if c~="\084\101\120\116"then return end G:CalculateSize()if string.len(U.Text)>ChatSettings.MaximumMessageLength then U.Text=string.sub(U.Text,1,ChatSettings.MaximumMessageLength)return end if not G.InCustomState then local c=G.CommandProcessor:ProcessInProgressChatMessage(U.Text,G.ChatWindow,G)if c then G.InCustomState=true G.CustomState=c end else G.CustomState:TextUpdated()end end)local function j(I)if I or U.Text~=""then c.Visible=false else c.Visible=true end end I.MouseButton1Click:connect(function()if I.Text~=""then G:SetChannelTarget(ChatSettings.GeneralChannelName)end end)U.Focused:connect(function()if not G.UserHasChatOff then G:CalculateSize()j(true)end end)U.FocusLost:connect(function(c,I)G:CalculateSize()if I and I.KeyCode==Enum.KeyCode.Escape then U.Text=""end j(false)end)end function methods.GetTextBox(U)return U.TextBox end function methods.GetMessageModeTextButton(U)return U.GuiObjects.MessageModeTextButton end

function methods:DoLockChatBar()
	if self.TextLabel then
		if LocalPlayer.UserId > 0 then
			self.TextLabel.Text = "To chat in game, turn on chat in your Privacy Settings."
		else
			self.TextLabel.Text = "Sign up to chat in game."
		end
		self:CalculateSize()
	end
	if self.TextBox then
		self.TextBox.Active = false
		self.TextBox.Focused:connect(function()
			self.TextBox:ReleaseFocus()
		end)
	end
end

function methods:SetUpTextBoxEvents(TextBox, TextLabel, MessageModeTextButton)
	--// Code for getting back into general channel from other target channel when pressing backspace.
	UserInputService.InputBegan:connect(function(inputObj, gpe)
		if (inputObj.KeyCode == Enum.KeyCode.Backspace) then
			if (self:IsFocused() and TextBox.Text == "") then
				self:SetChannelTarget(ChatSettings.GeneralChannelName)
			end
		end
	end)

	TextBox.Changed:connect(function(prop)
		if prop == "AbsoluteSize" then
			self:CalculateSize()
			return
		end

		if prop ~= "Text" then
			return
		end

		self:CalculateSize()

		if (string.len(TextBox.Text) > ChatSettings.MaximumMessageLength) then
			TextBox.Text = string.sub(TextBox.Text, 1, ChatSettings.MaximumMessageLength)
			return
		end

		if not self.InCustomState then
			local customState = self.CommandProcessor:ProcessInProgressChatMessage(TextBox.Text, self.ChatWindow, self)
			if customState then
				self.InCustomState = true
				self.CustomState = customState
			end
		else
			self.CustomState:TextUpdated()
		end
	end)

	local function UpdateOnFocusStatusChanged(isFocused)
		if isFocused or TextBox.Text ~= "" then
			TextLabel.Visible = false
		else
			TextLabel.Visible = true
		end
	end

	MessageModeTextButton.MouseButton1Click:connect(function()
		if MessageModeTextButton.Text ~= "" then
			self:SetChannelTarget(ChatSettings.GeneralChannelName)
		end
	end)

	TextBox.Focused:connect(function()
		if not self.UserHasChatOff then
			self:CalculateSize()
			UpdateOnFocusStatusChanged(true)
		end
	end)

	TextBox.FocusLost:connect(function(enterPressed, inputObject)
		self:CalculateSize()
		if (inputObject and inputObject.KeyCode == Enum.KeyCode.Escape) then
			TextBox.Text = ""
		end
		UpdateOnFocusStatusChanged(false)
	end)
end

function methods:GetTextBox()
	return self.TextBox
end

function methods:GetMessageModeTextButton()
	return self.GuiObjects.MessageModeTextButton
end
