-- Decompiled with the Synapse X Luau decompiler.

local l__Parent__1 = script.Parent;
local v2 = {};
v2.__index = v2;
local u1 = require(game:GetService("Chat"):WaitForChild("ClientChatModules"):WaitForChild("ChatSettings"));
local u2 = {
	ScrollBarThickness = 4
};
function v2.Destroy(p1)
	p1.GuiObject:Destroy();
	p1.Destroyed = true;
end;
function v2.SetActive(p2, p3)
	p2.GuiObject.Visible = p3;
end;
function v2.UpdateMessageFiltered(p4, p5)
	local v3 = nil;
	local v4 = 1;
	local l__MessageObjectLog__5 = p4.MessageObjectLog;
	while v4 <= #l__MessageObjectLog__5 do
		local v6 = l__MessageObjectLog__5[v4];
		if v6.ID == p5.ID then
			v3 = v6;
			break;
		end;
		v4 = v4 + 1;	
	end;
	if v3 then
		v3.UpdateTextFunction(p5);
		p4:PositionMessageLabelInWindow(v3, v4);
	end;
end;
local u3 = require(l__Parent__1:WaitForChild("MessageLabelCreator")).new();
function v2.AddMessage(p6, p7)
	p6:WaitUntilParentedCorrectly();
	local v7 = u3:CreateMessageLabel(p7, p6.CurrentChannelName);
	if v7 == nil then
		return;
	end;
	table.insert(p6.MessageObjectLog, v7);
	p6:PositionMessageLabelInWindow(v7, #p6.MessageObjectLog);
end;
function v2.AddMessageAtIndex(p8, p9, p10)
	local v8 = u3:CreateMessageLabel(p9, p8.CurrentChannelName);
	if v8 == nil then
		return;
	end;
	table.insert(p8.MessageObjectLog, p10, v8);
	p8:PositionMessageLabelInWindow(v8, p10);
end;
function v2.RemoveLastMessage(p11)
	p11:WaitUntilParentedCorrectly();
	p11.MessageObjectLog[1]:Destroy();
	table.remove(p11.MessageObjectLog, 1);
end;
function v2.IsScrolledDown(p12)
	local l__Offset__9 = p12.Scroller.CanvasSize.Y.Offset;
	local l__Y__10 = p12.Scroller.AbsoluteWindowSize.Y;
	local v11 = true;
	if not (l__Offset__9 < l__Y__10) then
		v11 = l__Offset__9 - p12.Scroller.CanvasPosition.Y <= l__Y__10 + 5;
	end;
	return v11;
end;
function v2.UpdateMessageTextHeight(p13, p14)
	local l__BaseFrame__12 = p14.BaseFrame;
	for v13 = 1, 10 do
		if p14.BaseMessage.TextFits then
			break;
		end;
		l__BaseFrame__12.Size = UDim2.new(1, 0, 0, p14.GetHeightFunction(p13.Scroller.AbsoluteSize.X - v13));
	end;
end;
function v2.PositionMessageLabelInWindow(p15, p16, p17)
	p15:WaitUntilParentedCorrectly();
	local l__BaseFrame__14 = p16.BaseFrame;
	local v15 = 1;
	if p15.MessageObjectLog[p17 - 1] then
		if p17 == #p15.MessageObjectLog then
			v15 = p15.MessageObjectLog[p17 - 1].BaseFrame.LayoutOrder + 1;
		else
			v15 = p15.MessageObjectLog[p17 - 1].BaseFrame.LayoutOrder;
		end;
	end;
	l__BaseFrame__14.LayoutOrder = v15;
	l__BaseFrame__14.Size = UDim2.new(1, 0, 0, p16.GetHeightFunction(p15.Scroller.AbsoluteSize.X));
	l__BaseFrame__14.Parent = p15.Scroller;
	if p16.BaseMessage then
		p15:UpdateMessageTextHeight(p16);
	end;
	if p15:IsScrolledDown() then
		p15.Scroller.CanvasPosition = Vector2.new(0, math.max(0, p15.Scroller.CanvasSize.Y.Offset - p15.Scroller.AbsoluteSize.Y));
	end;
end;
function v2.ReorderAllMessages(p18)
	p18:WaitUntilParentedCorrectly();
	if p18.GuiObject.AbsoluteSize.Y < 1 then
		return;
	end;
	for v16, v17 in pairs(p18.MessageObjectLog) do
		p18:UpdateMessageTextHeight(v17);
	end;
	if not p18:IsScrolledDown() then
		p18.Scroller.CanvasPosition = p18.Scroller.CanvasPosition;
		return;
	end;
	p18.Scroller.CanvasPosition = Vector2.new(0, math.max(0, p18.Scroller.CanvasSize.Y.Offset - p18.Scroller.AbsoluteSize.Y));
end;
function v2.Clear(p19)
	for v18, v19 in pairs(p19.MessageObjectLog) do
		v19:Destroy();
	end;
	p19.MessageObjectLog = {};
end;
function v2.SetCurrentChannelName(p20, p21)
	p20.CurrentChannelName = p21;
end;
function v2.FadeOutBackground(p22, p23)

end;
function v2.FadeInBackground(p24, p25)

end;
local u4 = require(l__Parent__1:WaitForChild("CurveUtil"));
function v2.FadeOutText(p26, p27)
	for v20 = 1, #p26.MessageObjectLog do
		if p26.MessageObjectLog[v20].FadeOutFunction then
			p26.MessageObjectLog[v20].FadeOutFunction(p27, u4);
		end;
	end;
end;
function v2.FadeInText(p28, p29)
	for v21 = 1, #p28.MessageObjectLog do
		if p28.MessageObjectLog[v21].FadeInFunction then
			p28.MessageObjectLog[v21].FadeInFunction(p29, u4);
		end;
	end;
end;
function v2.Update(p30, p31)
	for v22 = 1, #p30.MessageObjectLog do
		if p30.MessageObjectLog[v22].UpdateAnimFunction then
			p30.MessageObjectLog[v22].UpdateAnimFunction(p31, u4);
		end;
	end;
end;
function v2.WaitUntilParentedCorrectly(p32)
	while not p32.GuiObject:IsDescendantOf(game:GetService("Players").LocalPlayer) do
		p32.GuiObject.AncestryChanged:wait();	
	end;
end;
local function u5()
	local v23 = Instance.new("Frame");
	v23.Selectable = false;
	v23.Size = UDim2.new(1, 0, 1, 0);
	v23.BackgroundTransparency = 1;
	local v24 = Instance.new("ScrollingFrame");
	v24.Selectable = u1.GamepadNavigationEnabled;
	v24.Name = "Scroller";
	v24.BackgroundTransparency = 1;
	v24.BorderSizePixel = 0;
	v24.Position = UDim2.new(0, 0, 0, 3);
	v24.Size = UDim2.new(1, -4, 1, -6);
	v24.CanvasSize = UDim2.new(0, 0, 0, 0);
	v24.ScrollBarThickness = u2.ScrollBarThickness;
	v24.Active = true;
	v24.Parent = v23;
	local v25 = Instance.new("UIListLayout");
	v25.SortOrder = Enum.SortOrder.LayoutOrder;
	v25.Parent = v24;
	return v23, v24, v25;
end;
function u2.new()
	local v26 = setmetatable({}, v2);
	v26.Destroyed = false;
	local v27, v28, v29 = u5();
	v26.GuiObject = v27;
	v26.Scroller = v28;
	v26.Layout = v29;
	v26.MessageObjectLog = {};
	v26.Name = "MessageLogDisplay";
	v26.GuiObject.Name = "Frame_" .. v26.Name;
	v26.CurrentChannelName = "";
	v26.GuiObject:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
		spawn(function()
			v26:ReorderAllMessages();
		end);
	end);
	local u6 = true;
	v26.Layout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
		local l__AbsoluteContentSize__30 = v26.Layout.AbsoluteContentSize;
		v26.Scroller.CanvasSize = UDim2.new(0, 0, 0, l__AbsoluteContentSize__30.Y);
		if u6 then
			v26.Scroller.CanvasPosition = Vector2.new(0, l__AbsoluteContentSize__30.Y - v26.Scroller.AbsoluteWindowSize.Y);
		end;
	end);
	v26.Scroller:GetPropertyChangedSignal("CanvasPosition"):Connect(function()
		u6 = v26:IsScrolledDown();
	end);
	return v26;
end;
return u2;