local I=import("\046\046\047\097\115\115\105\103\110")local u=import("\046\046\047\116\121\112\101\075\101\121")local z=import("\046\046\047\102\117\110\099\116\105\111\110\115\047\116\121\112\101\111\102")local s={}setmetatable(s,{__tostring=function()return"\086\101\099\116\111\114\050"end})local C={}local R={}R[u]="\086\101\099\116\111\114\050"function R.__index(u,I)local z=(getmetatable(u)).internal if z[I]~=nil then return z[I]end if C[I]~=nil then return C[I]end error(string.format("\037\115 \105\115 \110\111\116 \097 \118\097\108\105\100 \109\101\109\098\101\114 \111\102 \086\101\099\116\111\114\050",tostring(I)),2)end function R.__add(u,I)return s.new(u.X+I.X,u.Y+I.Y)end function R.__sub(u,I)return s.new(u.X-I.X,u.Y-I.Y)end function R.__mul(u,I)if z(u)=="\086\101\099\116\111\114\050"and z(I)=="\086\101\099\116\111\114\050"then return s.new(u.X*I.X,u.Y*I.Y)elseif z(u)=="\086\101\099\116\111\114\050"and z(I)=="\110\117\109\098\101\114"then return s.new(u.X*I,u.Y*I)elseif z(u)=="\110\117\109\098\101\114"and z(I)=="\086\101\099\116\111\114\050"then return s.new(I.X*u,I.Y*u)else error("\097\116\116\101\109\112\116 \116\111 \109\117\108\116\105\112\108\121 \097 \086\101\099\116\111\114\050 \119\105\116\104 \097\110 \105\110\099\111\109\112\097\116\105\098\108\101 \118\097\108\117\101 \116\121\112\101 \111\114 \110\105\108")end end function R.__div(u,I)if z(u)=="\086\101\099\116\111\114\050"and z(I)=="\086\101\099\116\111\114\050"then return s.new(u.X/I.X,u.Y/I.Y)elseif z(u)=="\086\101\099\116\111\114\050"and z(I)=="\110\117\109\098\101\114"then return s.new(u.X/I,u.Y/I)elseif z(u)=="\110\117\109\098\101\114"and z(I)=="\086\101\099\116\111\114\050"then return s.new(I.X/u,I.Y/u)else error("\097\116\116\101\109\112\116 \116\111 \100\105\118\105\100\101 \097 \086\101\099\116\111\114\050 \119\105\116\104 \097\110 \105\110\099\111\109\112\097\116\105\098\108\101 \118\097\108\117\101 \116\121\112\101 \111\114 \110\105\108")end end function R.__eq(u,I)return u.X==I.X and u.Y==I.Y end function s.new(...)if select("\035",...)==0 then return s.new(0,0)end local u,z=...if type(u)~="\110\117\109\098\101\114"or type(z)~="\110\117\109\098\101\114"then error("\086\101\099\116\111\114\050\046\110\101\119 \116\097\107\101\115 \105\110 \050 \110\117\109\098\101\114\115",2)end local C={X=u,Y=z}local Q=newproxy(true)I(getmetatable(Q),R);(getmetatable(Q)).internal=C return Q end return s
local assign = import("../assign")
local typeKey = import("../typeKey")
local typeof = import("../functions/typeof")

local Vector2 = {}

setmetatable(Vector2, {
	__tostring = function()
		return "Vector2"
	end,
})

local prototype = {}

local metatable = {}
metatable[typeKey] = "Vector2"

function metatable:__index(key)
	local internal = getmetatable(self).internal

	if internal[key] ~= nil then
		return internal[key]
	end

	if prototype[key] ~= nil then
		return prototype[key]
	end

	error(string.format("%s is not a valid member of Vector2", tostring(key)), 2)
end

function metatable:__add(other)
	return Vector2.new(self.X + other.X, self.Y + other.Y)
end

function metatable:__sub(other)
	return Vector2.new(self.X - other.X, self.Y - other.Y)
end

function metatable:__mul(other)
	if typeof(self) == "Vector2" and typeof(other) == "Vector2" then
		return Vector2.new(self.X * other.X, self.Y * other.Y)
	elseif typeof(self) == "Vector2" and typeof(other) == "number" then
		return Vector2.new(self.X * other, self.Y * other)
	elseif typeof(self) == "number" and typeof(other) == "Vector2" then
		return Vector2.new(other.X * self, other.Y * self)
	else
		error("attempt to multiply a Vector2 with an incompatible value type or nil")
	end
end

function metatable:__div(other)
	if typeof(self) == "Vector2" and typeof(other) == "Vector2" then
		return Vector2.new(self.X / other.X, self.Y / other.Y)
	elseif typeof(self) == "Vector2" and typeof(other) == "number" then
		return Vector2.new(self.X / other, self.Y / other)
	elseif typeof(self) == "number" and typeof(other) == "Vector2" then
		return Vector2.new(other.X / self, other.Y / self)
	else
		error("attempt to divide a Vector2 with an incompatible value type or nil")
	end
end

function metatable:__eq(other)
	return self.X == other.X and self.Y == other.Y
end

function Vector2.new(...)
	if select("#", ...) == 0 then
		return Vector2.new(0, 0)
	end

	local X, Y = ...
	if type(X) ~= "number" or type(Y) ~= "number" then
		error("Vector2.new takes in 2 numbers", 2)
	end

	local internalInstance = {
		X = X,
		Y = Y,
	}

	local instance = newproxy(true)

	assign(getmetatable(instance), metatable)
	getmetatable(instance).internal = internalInstance

	return instance
end

return Vector2
