local s=require(((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\080\097\099\107\097\103\101")).MWorks)local I={}function I.setupUpdate(I)I.Updated=s.newBindable()end function I.newClass(s)local c={}if s then for s,I in pairs(s)do c[s]=I end end setmetatable(c,{__index=I})c:setupUpdate()return c end function I.newSubClass(c,s,I)local M={}c[s]=M if I then for s,I in pairs(I)do c[s]=I end end setmetatable(M,{__index=c})M:setupUpdate()return M end function I.Update(s,...)local I=table.pack(...)if type(I[1])=="\116\097\098\108\101"then local c=I[1]for I,c in pairs(c)do if s[I]then s[I]=c s.Updated:Fire(I,c)end end elseif I[1]~=nil then local c=I[1]local M=I[2]s[c]=M s.Updated:Fire(c,M)else s.Updated:Fire()end end function I.newValue(s,...)local I=table.pack(...)local c local M if#I<1 then return end if#I>1 then c=I[1]M=I[2]else c=#s+1 M=I[1]end s[c]=M s:Update(c,M)return c end function I.removeValue(I,s)if I[s]==nil then return end I[s]=nil I:Update()end return I

local MWorks = require(game:GetService("ReplicatedStorage"):WaitForChild("Package").MWorks)
local module = {}

function module:setupUpdate() --Not used externally. Used for setting up classes of all types
	self.Updated = MWorks.newBindable()
end

function module.newClass(attributes)
	local self = {}
	if attributes then 
		for i,v in pairs(attributes) do
			self[i] = v
		end
	end
	setmetatable(self,{
		__index = module;
	})
	self:setupUpdate()
	return self
end

function module:newSubClass(Name,attributes)
	local subClass = {}
	self[Name] = subClass
	if attributes then 
		for i,v in pairs(attributes) do
			self[i] = v
		end
	end
	setmetatable(subClass,{__index = self})
	subClass:setupUpdate()
	return subClass
end

function module:Update(...)
	local args = table.pack(...)
	if type(args[1]) == "table" then 
		local Table = args[1]
		for i,v in pairs(Table) do
			if self[i] then 
				self[i] = v
				self.Updated:Fire(i,v)
			end
		end
	elseif args[1] ~= nil then  
		local Name = args[1]
		local Value = args[2]
		self[Name] = Value
		self.Updated:Fire(Name,Value)
	else 
		self.Updated:Fire()
	end
end

function module:newValue(...)
	local args = table.pack(...)
	local index; 
	local Value;
	if #args < 1 then return end 
	if #args > 1 then 
		index = args[1]
		Value = args[2]
	else 
		index = #self+1
		Value = args[1]
	end
	self[index] = Value 
	self:Update(index,Value)
	return index 
end

function module:removeValue(index)
	if self[index] == nil then return end 
	self[index] = nil 
	self:Update()
end

return module
