local C=require(script.Parent.Parent.Shared.Util)local O=C.MakeSequenceType({Prefixes="\035 \104\101\120\067\111\108\111\114\051 \033 \098\114\105\099\107\067\111\108\111\114\051";ValidateEach=function(C,O)if C==nil then return false,("\073\110\118\097\108\105\100 \111\114 \109\105\115\115\105\110\103 \110\117\109\098\101\114 \097\116 \112\111\115\105\116\105\111\110 \037\100 \105\110 \067\111\108\111\114\051 \116\121\112\101\046"):format(O)elseif C<0 or C>255 then return false,("\078\117\109\098\101\114 \111\117\116 \111\102 \097\099\099\101\112\116\097\098\108\101 \114\097\110\103\101 \048-\050\053\053 \097\116 \112\111\115\105\116\105\111\110 \037\100 \105\110 \067\111\108\111\114\051 \116\121\112\101\046"):format(O)elseif C%1~=0 then return false,("\078\117\109\098\101\114 \105\115 \110\111\116 \097\110 \105\110\116\101\103\101\114 \097\116 \112\111\115\105\116\105\111\110 \037\100 \105\110 \067\111\108\111\114\051 \116\121\112\101\046"):format(O)end return true end;TransformEach=tonumber;Constructor=Color3.fromRGB;Length=3})local function V(C)if#C==1 then C=C..C end return tonumber(C,16)end local L={Transform=function(O)local L,j,W=O:match("\094\035\063\040\037\120\037\120\063\041\040\037\120\037\120\063\041\040\037\120\037\120\063\041\036")return C.Each(V,L,j,W)end,Validate=function(C,O,V)return C~=nil and(O~=nil and V~=nil),"\073\110\118\097\108\105\100 \104\101\120 \099\111\108\111\114"end,Parse=function(...)return Color3.fromRGB(...)end}return function(V)V:RegisterType("\099\111\108\111\114\051",O)V:RegisterType("\099\111\108\111\114\051\115",C.MakeListableType(O,{Prefixes="\035 \104\101\120\067\111\108\111\114\051\115 \033 \098\114\105\099\107\067\111\108\111\114\051\115"}))V:RegisterType("\104\101\120\067\111\108\111\114\051",L)V:RegisterType("\104\101\120\067\111\108\111\114\051\115",C.MakeListableType(L))end
local Util = require(script.Parent.Parent.Shared.Util)

local color3Type = Util.MakeSequenceType({
	Prefixes = "# hexColor3 ! brickColor3";
	ValidateEach = function(value, i)
		if value == nil then
			return false, ("Invalid or missing number at position %d in Color3 type."):format(i)
		elseif value < 0 or value > 255 then
			return false, ("Number out of acceptable range 0-255 at position %d in Color3 type."):format(i)
		elseif value % 1 ~= 0 then
			return false, ("Number is not an integer at position %d in Color3 type."):format(i)
		end

		return true
	end;
	TransformEach = tonumber;
	Constructor = Color3.fromRGB;
	Length = 3;
})

local function parseHexDigit(x)
	if #x == 1 then
		x = x .. x
	end

	return tonumber(x, 16)
end

local hexColor3Type = {
	Transform = function(text)
		local r, g, b = text:match("^#?(%x%x?)(%x%x?)(%x%x?)$")
		return Util.Each(parseHexDigit, r, g, b)
	end;

	Validate = function(r, g, b)
		return r ~= nil and g ~= nil and b ~= nil, "Invalid hex color"
	end;

	Parse = function(...)
		return Color3.fromRGB(...)
	end;
}

return function (cmdr)
	cmdr:RegisterType("color3", color3Type)
	cmdr:RegisterType("color3s", Util.MakeListableType(color3Type, {
		Prefixes = "# hexColor3s ! brickColor3s"
	}))

	cmdr:RegisterType("hexColor3", hexColor3Type)
	cmdr:RegisterType("hexColor3s", Util.MakeListableType(hexColor3Type))
end
