-- Decompiled with the Synapse X Luau decompiler.


local u1 = nil;
coroutine.wrap(function()
	u1 = require(game.ReplicatedStorage:WaitForChild("Resources"));
end)();
local l__Events__1 = u1.Assets.Events;
local v2 = {};
local u2 = u1.RunService:IsServer();
function v2.Fire(p1, p2, ...)
	local v3 = nil;
	p1 = string.lower(p1);
	v3 = GetRemote(p1);
	if not u2 then
		v3:FireServer((CreatePacket(p2, ...)));
		return;
	end;
	if not p2:FindFirstChild("__LOADED") then
		return;
	end;
	v3:FireClient(p2, (CreatePacket(...)));
end;
function v2.FireAll(p3, ...)
	p3 = string.lower(p3);
	local v4 = GetRemote(p3);
	local v5 = CreatePacket(...);
	local v6 = {};
	local v7 = game.Players:GetPlayers();

	for v8, v9 in ipairs(v7) do
		if not v8 then
			break;
		end;
		if v9:FindFirstChild("__LOADED") then
			table.insert(v6, v9);
		end;	
	end;
	if #v7 <= #v6 then
		v4:FireAllClients(v5);
		return;
	end;

	for v11, v12 in ipairs(v6) do
		if not v11 then
			break;
		end;
		coroutine.wrap(function()
			v4:FireClient(v12, v5);
		end)();	
	end;
end;
function v2.Invoke(p4, p5, ...)
	p4 = string.lower(p4);
	local v14 = GetRemote(p4, true);
	if not u2 then
		u1.Signal.Fire("CORE Network Invoke", p4);
	end;
	if not u2 then
		return DecodePacket(v14:InvokeServer((CreatePacket(p5, ...))));
	end;
	if not p5:FindFirstChild("__LOADED") then
		return;
	end;
	return DecodePacket(v14:InvokeClient(p5, (CreatePacket(...))));
end;
function v2.Fired(p6)
	p6 = string.lower(p6);
	return GetEvent(p6).Event;
end;
function v2.Invoked(p7)
	p7 = string.lower(p7);
	return GetEvent(p7, true);
end;
function v2.Recieve(p8, ...)
	local v15 = { ... };
	if p8 == "a" then
		GetRemote(unpack(v15));
		return;
	end;
	if p8 == "b" then
		GetRemote(unpack(v15), true);
		return;
	end;
	if p8 == "c" then
		local v16, v17 = unpack(v15);
		GetEvent(v16):Fire(DecodePacket(v17));
		return;
	end;
	if p8 == "d" then
		local v18, v19 = unpack(v15);
		return CreatePacket(GetEvent(v18, true):Invoke(DecodePacket(v19)));
	end;
	if p8 == "e" then
		local v20, v21, v22 = unpack(v15);
		GetEvent(v20):Fire(v21, DecodePacket(v22));
		return;
	end;
	if p8 ~= "f" then
		return;
	end;
	local v23, v24, v25 = unpack(v15);
	return CreatePacket(GetEvent(v23, true):Invoke(v24, DecodePacket(v25)));
end;
function CreatePacket(...)
	return { ... };
end;
function DecodePacket(p9)
	return unpack(p9);
end;
local u3 = {};
function GetEvent(p10, p11)
	p10 = string.lower(p10);
	local v26 = u3[p10];
	if not v26 then
		local v27 = "BindableEvent";
		if p11 then
			v27 = "BindableFunction";
		end;
		v26 = Instance.new(v27);
		v26.Name = p10;
		v26.Parent = script;
		u3[p10] = v26;
	end;
	return v26;
end;
local l__MAIN__4 = l__Events__1:WaitForChild("MAIN");
function GetRemote(p12, p13)
	p12 = string.lower(p12);
	local v28 = l__Events__1:FindFirstChild(p12);
	if not v28 then
		if u2 then
			local v29 = "RemoteEvent";
			if p13 then
				v29 = "RemoteFunction";
			end;
			local v30 = Instance.new(v29);
			v30.Name = p12;
			v30.Parent = l__Events__1;
			ListenRemote(p12, p13);
			return v30;
		end;
		local v31 = "a";
		if p13 then
			v31 = "b";
		end;
		l__MAIN__4:FireServer(v31, p12);
		while true do
			if not l__Events__1:FindFirstChild(p12) then

			else
				break;
			end;
			u1.RenderStepped();		
		end;
		v28 = l__Events__1:FindFirstChild(p12);
		ListenRemote(p12, p13);
	end;
	return v28;
end;
local u5 = {};
function ListenRemote(p14, p15)
	local v32 = nil;
	p14 = string.lower(p14);
	v32 = GetRemote(p14, p15);
	if u5[p14] then
		return;
	end;
	u5[p14] = true;
	if u2 then
		if p15 then
			function v32.OnServerInvoke(p16, ...)
				return v2.Recieve("f", p14, p16, ...);
			end;
		else
			v32.OnServerEvent:Connect(function(p17, ...)
				v2.Recieve("e", p14, p17, ...);
			end);
		end;
	elseif p15 then
		function v32.OnClientInvoke(...)
			if not u2 then
				u1.Signal.Fire("CORE Network Invoked", p14);
			end;
			return v2.Recieve("d", p14, ...);
		end;
	else
		v32.OnClientEvent:Connect(function(...)
			v2.Recieve("c", p14, ...);
		end);
	end;
end;
function ClientInit()

	for v33, v34 in ipairs(l__Events__1:GetChildren()) do
		if v33 then

		else
			break;
		end;
		if v34.Name ~= "MAIN" then
			ListenRemote(v34.Name, v34:IsA("RemoteFunction"));
		end;	
	end;
end;
if u2 then
	l__MAIN__4.OnServerEvent:Connect(function(p18, p19, p20, ...)
		v2.Recieve(p19, p20, ...);
	end);
end

