local W={}local h={Disconnect=function(W)local h=W._listener if h~=nil then local U=W._listener_table local B=table.find(U,h)if B~=nil then table.remove(U,B)end W._listener=nil end if W._disconnect_listener~=nil then W._disconnect_listener(W._disconnect_param)W._disconnect_listener=nil end end}function W.NewArrayScriptConnection(W,U,B,g)return{_listener=U,_listener_table=W;_disconnect_listener=B,_disconnect_param=g,Disconnect=h.Disconnect}end local U={}local B={Disconnect=function(W)local h=W._listener if h~=nil then local U=W._script_signal local B=U._fire_pointer_stack local g=U._listeners_next local T=U._listeners_back for W=1,U._stack_count,1 do if B[W]==h then B[W]=g[h]end end if U._tail_listener==h then local W=T[h]if W~=nil then g[W]=nil T[h]=nil else U._head_listener=nil end U._tail_listener=W elseif U._head_listener==h then local W=g[h]T[W]=nil g[h]=nil U._head_listener=W else local W=g[h]local U=T[h]if W~=nil or U~=nil then g[U]=W T[W]=U g[h]=nil T[h]=nil end end W._listener=nil U._listener_count=U._listener_count-1 end if W._disconnect_listener~=nil then W._disconnect_listener(W._disconnect_param)W._disconnect_listener=nil end end}function U.Connect(W,h,U,g)if type(h)~="\102\117\110\099\116\105\111\110"then error("\091\077\097\100\119\111\114\107\083\099\114\105\112\116\083\105\103\110\097\108\093\058 \079\110\108\121 \102\117\110\099\116\105\111\110\115 \099\097\110 \098\101 \112\097\115\115\101\100 \116\111 \083\099\114\105\112\116\083\105\103\110\097\108\058\067\111\110\110\101\099\116\040\041")end local T=W._tail_listener if T==nil then W._head_listener=h W._tail_listener=h W._listener_count=W._listener_count+1 elseif T~=h and W._listeners_next[h]==nil then W._listeners_next[T]=h W._listeners_back[h]=T W._tail_listener=h W._listener_count=W._listener_count+1 end return{_listener=h;_script_signal=W;_disconnect_listener=U,_disconnect_param=g,Disconnect=B.Disconnect}end function U.GetListenerCount(W)return W._listener_count end function U.Fire(W,...)local h=W._fire_pointer_stack local U=W._stack_count+1 W._stack_count=U local B=W._listeners_next h[U]=W._head_listener while true do local W=h[U]h[U]=B[W]if W==nil then break end W(...)end W._stack_count=W._stack_count-1 end function W.NewScriptSignal()return{_fire_pointer_stack={};_stack_count=0;_listener_count=0,_listeners_next={},_listeners_back={},_head_listener=nil;_tail_listener=nil;Connect=U.Connect,GetListenerCount=U.GetListenerCount;Fire=U.Fire}end return W


local v1 = {};
local u1 = {
	Disconnect = function(p1)
		local l___listener__2 = p1._listener;
		if l___listener__2 ~= nil then
			local l___listener_table__3 = p1._listener_table;
			local v4 = table.find(l___listener_table__3, l___listener__2);
			if v4 ~= nil then
				table.remove(l___listener_table__3, v4);
			end;
			p1._listener = nil;
		end;
		if p1._disconnect_listener ~= nil then
			p1._disconnect_listener(p1._disconnect_param);
			p1._disconnect_listener = nil;
		end;
	end
};
function v1.NewArrayScriptConnection(p2, p3, p4, p5)
	return {
		_listener = p3, 
		_listener_table = p2, 
		_disconnect_listener = p4, 
		_disconnect_param = p5, 
		Disconnect = u1.Disconnect
	};
end;
local v5 = {};
local u2 = {
	Disconnect = function(p6)
		local l___listener__6 = p6._listener;
		if l___listener__6 ~= nil then
			local l___script_signal__7 = p6._script_signal;
			local l___fire_pointer_stack__8 = l___script_signal__7._fire_pointer_stack;
			local l___listeners_next__9 = l___script_signal__7._listeners_next;
			local l___listeners_back__10 = l___script_signal__7._listeners_back;
			for v11 = 1, l___script_signal__7._stack_count do
				if l___fire_pointer_stack__8[v11] == l___listener__6 then
					l___fire_pointer_stack__8[v11] = l___listeners_next__9[l___listener__6];
				end;
			end;
			if l___script_signal__7._tail_listener == l___listener__6 then
				local v12 = l___listeners_back__10[l___listener__6];
				if v12 ~= nil then
					l___listeners_next__9[v12] = nil;
					l___listeners_back__10[l___listener__6] = nil;
				else
					l___script_signal__7._head_listener = nil;
				end;
				l___script_signal__7._tail_listener = v12;
			elseif l___script_signal__7._head_listener == l___listener__6 then
				local v13 = l___listeners_next__9[l___listener__6];
				l___listeners_back__10[v13] = nil;
				l___listeners_next__9[l___listener__6] = nil;
				l___script_signal__7._head_listener = v13;
			else
				local v14 = l___listeners_next__9[l___listener__6];
				local v15 = l___listeners_back__10[l___listener__6];
				if v14 ~= nil or v15 ~= nil then
					l___listeners_next__9[v15] = v14;
					l___listeners_back__10[v14] = v15;
					l___listeners_next__9[l___listener__6] = nil;
					l___listeners_back__10[l___listener__6] = nil;
				end;
			end;
			p6._listener = nil;
			l___script_signal__7._listener_count = l___script_signal__7._listener_count - 1;
		end;
		if p6._disconnect_listener ~= nil then
			p6._disconnect_listener(p6._disconnect_param);
			p6._disconnect_listener = nil;
		end;
	end
};
function v5.Connect(p7, p8, p9, p10)
	if type(p8) ~= "function" then
		error("[MadworkScriptSignal]: Only functions can be passed to ScriptSignal:Connect()");
	end;
	local l___tail_listener__16 = p7._tail_listener;
	if l___tail_listener__16 == nil then
		p7._head_listener = p8;
		p7._tail_listener = p8;
		p7._listener_count = p7._listener_count + 1;
	elseif l___tail_listener__16 ~= p8 and p7._listeners_next[p8] == nil then
		p7._listeners_next[l___tail_listener__16] = p8;
		p7._listeners_back[p8] = l___tail_listener__16;
		p7._tail_listener = p8;
		p7._listener_count = p7._listener_count + 1;
	end;
	return {
		_listener = p8, 
		_script_signal = p7, 
		_disconnect_listener = p9, 
		_disconnect_param = p10, 
		Disconnect = u2.Disconnect
	};
end;
function v5.GetListenerCount(p11)
	return p11._listener_count;
end;
function v5.Fire(p12, ...)
	local l___fire_pointer_stack__17 = p12._fire_pointer_stack;
	local v18 = p12._stack_count + 1;
	p12._stack_count = v18;
	local l___listeners_next__19 = p12._listeners_next;
	l___fire_pointer_stack__17[v18] = p12._head_listener;
	while true do
		local v20 = l___fire_pointer_stack__17[v18];
		l___fire_pointer_stack__17[v18] = l___listeners_next__19[v20];
		if v20 == nil then
			break;
		end;
		v20(...);	
	end;
	p12._stack_count = p12._stack_count - 1;
end;
function v1.NewScriptSignal()
	return {
		_fire_pointer_stack = {}, 
		_stack_count = 0, 
		_listener_count = 0, 
		_listeners_next = {}, 
		_listeners_back = {}, 
		_head_listener = nil, 
		_tail_listener = nil, 
		Connect = v5.Connect, 
		GetListenerCount = v5.GetListenerCount, 
		Fire = v5.Fire
	};
end;
return v1;
