local X={}X.__index=X local function G()local X=Instance.new("\070\114\097\109\101")X.Selectable=false X.Size=UDim2.new(1,0,1,0)X.BackgroundTransparency=1 local G=1 local E=1 local m=Instance.new("\070\114\097\109\101")m.Selectable=false m.Name="\066\097\099\107\103\114\111\117\110\100\070\114\097\109\101"m.Size=UDim2.new(1,-G*2,1,-E*2)m.Position=UDim2.new(0,G,0,E)m.BackgroundTransparency=1 m.Parent=X local C=Instance.new("\070\114\097\109\101")C.Selectable=false C.Name="\085\110\115\101\108\101\099\116\101\100\070\114\097\109\101"C.Size=UDim2.new(1,0,1,0)C.Position=UDim2.new(0,0,0,0)C.BorderSizePixel=0 C.BackgroundColor3=ChatSettings.ChannelsTabUnselectedColor C.BackgroundTransparency=.6 C.Parent=m local a=Instance.new("\070\114\097\109\101")a.Selectable=false a.Name="\083\101\108\101\099\116\101\100\070\114\097\109\101"a.Size=UDim2.new(1,0,1,0)a.Position=UDim2.new(0,0,0,0)a.BorderSizePixel=0 a.BackgroundColor3=ChatSettings.ChannelsTabSelectedColor a.BackgroundTransparency=1 a.Parent=m local h=Instance.new("\073\109\097\103\101\076\097\098\101\108")h.Selectable=false h.Name="\066\097\099\107\103\114\111\117\110\100\073\109\097\103\101"h.BackgroundTransparency=1 h.BorderSizePixel=0 h.Size=UDim2.new(1,0,1,0)h.Position=UDim2.new(0,0,0,0)h.ScaleType=Enum.ScaleType.Slice h.Parent=a h.BackgroundTransparency=-0.4 local B=1.2 h.BackgroundColor3=Color3.fromRGB(78*B,84*B,96*B)local l=2 local K=4 local I=Instance.new("\073\109\097\103\101\076\097\098\101\108")I.Selectable=false I.Size=UDim2.new(.5,-l,0,K)I.BackgroundTransparency=1 I.ScaleType=Enum.ScaleType.Slice I.SliceCenter=Rect.new(3,3,32,21)I.Parent=a local Q=I:Clone()Q.Parent=a I.Position=UDim2.new(0,l,1,-K)Q.Position=UDim2.new(.5,0,1,-K)I.Image="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\117\105\047\083\101\116\116\105\110\103\115\047\083\108\105\100\101\114\047\083\101\108\101\099\116\101\100\066\097\114\076\101\102\116\046\112\110\103"Q.Image="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\117\105\047\083\101\116\116\105\110\103\115\047\083\108\105\100\101\114\047\083\101\108\101\099\116\101\100\066\097\114\082\105\103\104\116\046\112\110\103"I.Name="\066\108\117\101\066\097\114\076\101\102\116"Q.Name="\066\108\117\101\066\097\114\082\105\103\104\116"local g=Instance.new("\084\101\120\116\066\117\116\116\111\110")g.Selectable=ChatSettings.GamepadNavigationEnabled g.Size=UDim2.new(1,0,1,0)g.Position=UDim2.new(0,0,0,0)g.BackgroundTransparency=1 g.Font=ChatSettings.DefaultFont g.TextSize=ChatSettings.ChatChannelsTabTextSize g.TextColor3=Color3.new(1,1,1)g.TextStrokeTransparency=.75 g.Parent=m local y=g:Clone()local u=g:Clone()y.Parent=C u.Parent=a y.Font=Enum.Font.SourceSans y.Active=false u.Active=false local q=Instance.new("\070\114\097\109\101")q.Selectable=false q.Size=UDim2.new(0,18,0,18)q.Position=UDim2.new(.8,-9,.5,-9)q.BackgroundTransparency=1 q.Parent=m local b=Instance.new("\073\109\097\103\101\076\097\098\101\108")b.Selectable=false b.Size=UDim2.new(1,0,1,0)b.BackgroundTransparency=1 b.Image="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\117\105\047\067\104\097\116\047\077\101\115\115\097\103\101\067\111\117\110\116\101\114\046\112\110\103"b.Visible=false b.Parent=q local i=Instance.new("\084\101\120\116\076\097\098\101\108")i.Selectable=false i.BackgroundTransparency=1 i.Size=UDim2.new(0,13,0,9)i.Position=UDim2.new(.5,-7,.5,-7)i.Font=ChatSettings.DefaultFont i.TextSize=14 i.TextColor3=Color3.new(1,1,1)i.Text=""i.Parent=b return X,g,y,u,b,C,a end function X.Destroy(X)X.GuiObject:Destroy()end function X.UpdateMessagePostedInChannel(G,X)if G.Active and X~=true then return end local E=G.UnreadMessageCount+1 G.UnreadMessageCount=E local m=G.NewMessageIcon m.Visible=true m.TextLabel.Text=E<100 and tostring(E)or"\033"local C=.15 local a=UDim2.new(0,0,-0.1,0)local h=m.Position local B=h+a local l=Enum.EasingDirection.Out local K=Enum.EasingStyle.Quad m.Position=UDim2.new(0,0,-0.15,0)m:TweenPosition(UDim2.new(0,0,0,0),l,K,C,true)end function X.SetActive(G,X)G.Active=X G.UnselectedFrame.Visible=not X G.SelectedFrame.Visible=X if X then G.UnreadMessageCount=0 G.NewMessageIcon.Visible=false G.NameTag.Font=Enum.Font.SourceSansBold else G.NameTag.Font=Enum.Font.SourceSans end end function X.SetTextSize(G,X)G.NameTag.TextSize=X end function X.FadeOutBackground(G,X)G.AnimParams.Background_TargetTransparency=1 G.AnimParams.Background_NormalizedExptValue=CurveUtil:NormalizedDefaultExptValueInSeconds(X)end function X.FadeInBackground(G,X)G.AnimParams.Background_TargetTransparency=.6 G.AnimParams.Background_NormalizedExptValue=CurveUtil:NormalizedDefaultExptValueInSeconds(X)end function X.FadeOutText(G,X)G.AnimParams.Text_TargetTransparency=1 G.AnimParams.Text_NormalizedExptValue=CurveUtil:NormalizedDefaultExptValueInSeconds(X)G.AnimParams.TextStroke_TargetTransparency=1 G.AnimParams.TextStroke_NormalizedExptValue=CurveUtil:NormalizedDefaultExptValueInSeconds(X)end function X.FadeInText(G,X)G.AnimParams.Text_TargetTransparency=0 G.AnimParams.Text_NormalizedExptValue=CurveUtil:NormalizedDefaultExptValueInSeconds(X)G.AnimParams.TextStroke_TargetTransparency=.75 G.AnimParams.TextStroke_NormalizedExptValue=CurveUtil:NormalizedDefaultExptValueInSeconds(X)end function X.AnimGuiObjects(X)X.UnselectedFrame.BackgroundTransparency=X.AnimParams.Background_CurrentTransparency X.SelectedFrame.BackgroundImage.BackgroundTransparency=X.AnimParams.Background_CurrentTransparency X.SelectedFrame.BlueBarLeft.ImageTransparency=X.AnimParams.Background_CurrentTransparency X.SelectedFrame.BlueBarRight.ImageTransparency=X.AnimParams.Background_CurrentTransparency X.NameTagNonSelect.TextTransparency=X.AnimParams.Background_CurrentTransparency X.NameTagNonSelect.TextStrokeTransparency=X.AnimParams.Background_CurrentTransparency X.NameTag.TextTransparency=X.AnimParams.Text_CurrentTransparency X.NewMessageIcon.ImageTransparency=X.AnimParams.Text_CurrentTransparency X.WhiteTextNewMessageNotification.TextTransparency=X.AnimParams.Text_CurrentTransparency X.NameTagSelect.TextTransparency=X.AnimParams.Text_CurrentTransparency X.NameTag.TextStrokeTransparency=X.AnimParams.TextStroke_CurrentTransparency X.WhiteTextNewMessageNotification.TextStrokeTransparency=X.AnimParams.TextStroke_CurrentTransparency X.NameTagSelect.TextStrokeTransparency=X.AnimParams.TextStroke_CurrentTransparency end function X.InitializeAnimParams(X)X.AnimParams.Text_TargetTransparency=0 X.AnimParams.Text_CurrentTransparency=0 X.AnimParams.Text_NormalizedExptValue=CurveUtil:NormalizedDefaultExptValueInSeconds(0)X.AnimParams.TextStroke_TargetTransparency=.75 X.AnimParams.TextStroke_CurrentTransparency=.75 X.AnimParams.TextStroke_NormalizedExptValue=CurveUtil:NormalizedDefaultExptValueInSeconds(0)X.AnimParams.Background_TargetTransparency=.6 X.AnimParams.Background_CurrentTransparency=.6 X.AnimParams.Background_NormalizedExptValue=CurveUtil:NormalizedDefaultExptValueInSeconds(0)end function X.Update(G,X)G.AnimParams.Background_CurrentTransparency=CurveUtil:Expt(G.AnimParams.Background_CurrentTransparency,G.AnimParams.Background_TargetTransparency,G.AnimParams.Background_NormalizedExptValue,X)G.AnimParams.Text_CurrentTransparency=CurveUtil:Expt(G.AnimParams.Text_CurrentTransparency,G.AnimParams.Text_TargetTransparency,G.AnimParams.Text_NormalizedExptValue,X)G.AnimParams.TextStroke_CurrentTransparency=CurveUtil:Expt(G.AnimParams.TextStroke_CurrentTransparency,G.AnimParams.TextStroke_TargetTransparency,G.AnimParams.TextStroke_NormalizedExptValue,X)G:AnimGuiObjects()end

local methods = {}
methods.__index = methods

local function CreateGuiObjects()
	local BaseFrame = Instance.new("Frame")
	BaseFrame.Selectable = false
	BaseFrame.Size = UDim2.new(1, 0, 1, 0)
	BaseFrame.BackgroundTransparency = 1

	local gapOffsetX = 1
	local gapOffsetY = 1

	local BackgroundFrame = Instance.new("Frame")
	BackgroundFrame.Selectable = false
	BackgroundFrame.Name = "BackgroundFrame"
	BackgroundFrame.Size = UDim2.new(1, -gapOffsetX * 2, 1, -gapOffsetY * 2)
	BackgroundFrame.Position = UDim2.new(0, gapOffsetX, 0, gapOffsetY)
	BackgroundFrame.BackgroundTransparency = 1
	BackgroundFrame.Parent = BaseFrame

	local UnselectedFrame = Instance.new("Frame")
	UnselectedFrame.Selectable = false
	UnselectedFrame.Name = "UnselectedFrame"
	UnselectedFrame.Size = UDim2.new(1, 0, 1, 0)
	UnselectedFrame.Position = UDim2.new(0, 0, 0, 0)
	UnselectedFrame.BorderSizePixel = 0
	UnselectedFrame.BackgroundColor3 = ChatSettings.ChannelsTabUnselectedColor
	UnselectedFrame.BackgroundTransparency = 0.6
	UnselectedFrame.Parent = BackgroundFrame

	local SelectedFrame = Instance.new("Frame")
	SelectedFrame.Selectable = false
	SelectedFrame.Name = "SelectedFrame"
	SelectedFrame.Size = UDim2.new(1, 0, 1, 0)
	SelectedFrame.Position = UDim2.new(0, 0, 0, 0)
	SelectedFrame.BorderSizePixel = 0
	SelectedFrame.BackgroundColor3 = ChatSettings.ChannelsTabSelectedColor
	SelectedFrame.BackgroundTransparency = 1
	SelectedFrame.Parent = BackgroundFrame

	local SelectedFrameBackgroundImage = Instance.new("ImageLabel")
	SelectedFrameBackgroundImage.Selectable = false
	SelectedFrameBackgroundImage.Name = "BackgroundImage"
	SelectedFrameBackgroundImage.BackgroundTransparency = 1
	SelectedFrameBackgroundImage.BorderSizePixel = 0
	SelectedFrameBackgroundImage.Size = UDim2.new(1, 0, 1, 0)
	SelectedFrameBackgroundImage.Position = UDim2.new(0, 0, 0, 0)
	SelectedFrameBackgroundImage.ScaleType = Enum.ScaleType.Slice
	SelectedFrameBackgroundImage.Parent = SelectedFrame

	SelectedFrameBackgroundImage.BackgroundTransparency = 0.6 - 1
	local rate = 1.2 * 1
	SelectedFrameBackgroundImage.BackgroundColor3 = Color3.fromRGB(78 * rate, 84 * rate, 96 * rate)

	local borderXOffset = 2
	local blueBarYSize = 4
	local BlueBarLeft = Instance.new("ImageLabel")
	BlueBarLeft.Selectable = false
	BlueBarLeft.Size = UDim2.new(0.5, -borderXOffset, 0, blueBarYSize)
	BlueBarLeft.BackgroundTransparency = 1
	BlueBarLeft.ScaleType = Enum.ScaleType.Slice
	BlueBarLeft.SliceCenter = Rect.new(3,3,32,21)
	BlueBarLeft.Parent = SelectedFrame

	local BlueBarRight = BlueBarLeft:Clone()
	BlueBarRight.Parent = SelectedFrame

	BlueBarLeft.Position = UDim2.new(0, borderXOffset, 1, -blueBarYSize)
	BlueBarRight.Position = UDim2.new(0.5, 0, 1, -blueBarYSize)
	BlueBarLeft.Image = "rbxasset://textures/ui/Settings/Slider/SelectedBarLeft.png"
	BlueBarRight.Image = "rbxasset://textures/ui/Settings/Slider/SelectedBarRight.png"

	BlueBarLeft.Name = "BlueBarLeft"
	BlueBarRight.Name = "BlueBarRight"

	local NameTag = Instance.new("TextButton")
	NameTag.Selectable = ChatSettings.GamepadNavigationEnabled
	NameTag.Size = UDim2.new(1, 0, 1, 0)
	NameTag.Position = UDim2.new(0, 0, 0, 0)
	NameTag.BackgroundTransparency = 1
	NameTag.Font = ChatSettings.DefaultFont
	NameTag.TextSize = ChatSettings.ChatChannelsTabTextSize
	NameTag.TextColor3 = Color3.new(1, 1, 1)
	NameTag.TextStrokeTransparency = 0.75
	NameTag.Parent = BackgroundFrame

	local NameTagNonSelect = NameTag:Clone()
	local NameTagSelect = NameTag:Clone()
	NameTagNonSelect.Parent = UnselectedFrame
	NameTagSelect.Parent = SelectedFrame
	NameTagNonSelect.Font = Enum.Font.SourceSans
	NameTagNonSelect.Active = false
	NameTagSelect.Active = false

	local NewMessageIconFrame = Instance.new("Frame")
	NewMessageIconFrame.Selectable = false
	NewMessageIconFrame.Size = UDim2.new(0, 18, 0, 18)
	NewMessageIconFrame.Position = UDim2.new(0.8, -9, 0.5, -9)
	NewMessageIconFrame.BackgroundTransparency = 1
	NewMessageIconFrame.Parent = BackgroundFrame

	local NewMessageIcon = Instance.new("ImageLabel")
	NewMessageIcon.Selectable = false
	NewMessageIcon.Size = UDim2.new(1, 0, 1, 0)
	NewMessageIcon.BackgroundTransparency = 1
	NewMessageIcon.Image = "rbxasset://textures/ui/Chat/MessageCounter.png"
	NewMessageIcon.Visible = false
	NewMessageIcon.Parent = NewMessageIconFrame

	local NewMessageIconText = Instance.new("TextLabel")
	NewMessageIconText.Selectable = false
	NewMessageIconText.BackgroundTransparency = 1
	NewMessageIconText.Size = UDim2.new(0, 13, 0, 9)
	NewMessageIconText.Position = UDim2.new(0.5, -7, 0.5, -7)
	NewMessageIconText.Font = ChatSettings.DefaultFont
	NewMessageIconText.TextSize = 14
	NewMessageIconText.TextColor3 = Color3.new(1, 1, 1)
	NewMessageIconText.Text = ""
	NewMessageIconText.Parent = NewMessageIcon

	return BaseFrame, NameTag, NameTagNonSelect, NameTagSelect, NewMessageIcon, UnselectedFrame, SelectedFrame
end

function methods:Destroy()
	self.GuiObject:Destroy()
end

function methods:UpdateMessagePostedInChannel(ignoreActive)
	if (self.Active and (ignoreActive ~= true)) then return end

	local count = self.UnreadMessageCount + 1
	self.UnreadMessageCount = count

	local label = self.NewMessageIcon
	label.Visible = true
	label.TextLabel.Text = (count < 100) and tostring(count) or "!"

	local tweenTime = 0.15
	local tweenPosOffset = UDim2.new(0, 0, -0.1, 0)

	local curPos = label.Position
	local outPos = curPos + tweenPosOffset
	local easingDirection = Enum.EasingDirection.Out
	local easingStyle = Enum.EasingStyle.Quad

	label.Position = UDim2.new(0, 0, -0.15, 0)
	label:TweenPosition(UDim2.new(0, 0, 0, 0), easingDirection, easingStyle, tweenTime, true)

end

function methods:SetActive(active)
	self.Active = active
	self.UnselectedFrame.Visible = not active
	self.SelectedFrame.Visible = active

	if (active) then
		self.UnreadMessageCount = 0
		self.NewMessageIcon.Visible = false

		self.NameTag.Font = Enum.Font.SourceSansBold
	else
		self.NameTag.Font = Enum.Font.SourceSans

	end
end

function methods:SetTextSize(textSize)
	self.NameTag.TextSize = textSize
end

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

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

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

function methods:FadeInText(duration)
	self.AnimParams.Text_TargetTransparency = 0
	self.AnimParams.Text_NormalizedExptValue = CurveUtil:NormalizedDefaultExptValueInSeconds(duration)
	self.AnimParams.TextStroke_TargetTransparency = 0.75
	self.AnimParams.TextStroke_NormalizedExptValue = CurveUtil:NormalizedDefaultExptValueInSeconds(duration)
end

function methods:AnimGuiObjects()
	self.UnselectedFrame.BackgroundTransparency = self.AnimParams.Background_CurrentTransparency
	self.SelectedFrame.BackgroundImage.BackgroundTransparency = self.AnimParams.Background_CurrentTransparency
	self.SelectedFrame.BlueBarLeft.ImageTransparency = self.AnimParams.Background_CurrentTransparency
	self.SelectedFrame.BlueBarRight.ImageTransparency = self.AnimParams.Background_CurrentTransparency
	self.NameTagNonSelect.TextTransparency = self.AnimParams.Background_CurrentTransparency
	self.NameTagNonSelect.TextStrokeTransparency = self.AnimParams.Background_CurrentTransparency

	self.NameTag.TextTransparency = self.AnimParams.Text_CurrentTransparency
	self.NewMessageIcon.ImageTransparency = self.AnimParams.Text_CurrentTransparency
	self.WhiteTextNewMessageNotification.TextTransparency = self.AnimParams.Text_CurrentTransparency
	self.NameTagSelect.TextTransparency = self.AnimParams.Text_CurrentTransparency

	self.NameTag.TextStrokeTransparency = self.AnimParams.TextStroke_CurrentTransparency
	self.WhiteTextNewMessageNotification.TextStrokeTransparency = self.AnimParams.TextStroke_CurrentTransparency
	self.NameTagSelect.TextStrokeTransparency = self.AnimParams.TextStroke_CurrentTransparency
end

function methods:InitializeAnimParams()
	self.AnimParams.Text_TargetTransparency = 0
	self.AnimParams.Text_CurrentTransparency = 0
	self.AnimParams.Text_NormalizedExptValue = CurveUtil:NormalizedDefaultExptValueInSeconds(0)

	self.AnimParams.TextStroke_TargetTransparency = 0.75
	self.AnimParams.TextStroke_CurrentTransparency = 0.75
	self.AnimParams.TextStroke_NormalizedExptValue = CurveUtil:NormalizedDefaultExptValueInSeconds(0)

	self.AnimParams.Background_TargetTransparency = 0.6
	self.AnimParams.Background_CurrentTransparency = 0.6
	self.AnimParams.Background_NormalizedExptValue = CurveUtil:NormalizedDefaultExptValueInSeconds(0)
end

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

	self:AnimGuiObjects()
end
