local N=require(script.Parent.Binding)local function R()local R,s=N.create(nil)local v={}setmetatable(v,{__index=function(N,s)if s=="\099\117\114\114\101\110\116"then return R:getValue()else return R[s]end end,__newindex=function(N,s,v)if s=="\099\117\114\114\101\110\116"then error("\067\097\110\110\111\116 \097\115\115\105\103\110 \116\111 \116\104\101 \'\099\117\114\114\101\110\116\' \112\114\111\112\101\114\116\121 \111\102 \114\101\102\115",2)end R[s]=v end,__tostring=function(N)return("\082\111\097\099\116\082\101\102\040\037\115\041"):format(tostring(R:getValue()))end})return v end return R
--[[
	A ref is nothing more than a binding with a special field 'current'
	that maps to the getValue method of the binding
]]
local Binding = require(script.Parent.Binding)

local function createRef()
	local binding, _ = Binding.create(nil)

	local ref = {}

	--[[
		A ref is just redirected to a binding via its metatable
	]]
	setmetatable(ref, {
		__index = function(self, key)
			if key == "current" then
				return binding:getValue()
			else
				return binding[key]
			end
		end,
		__newindex = function(self, key, value)
			if key == "current" then
				error("Cannot assign to the 'current' property of refs", 2)
			end

			binding[key] = value
		end,
		__tostring = function(self)
			return ("RoactRef(%s)"):format(tostring(binding:getValue()))
		end,
	})

	return ref
end

return createRef
