local z=require(script.Parent.Parent.Shared.Util)local s=z.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(z,s)if z==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(s)elseif z<0 or z>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(s)elseif z%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(s)end return true end,TransformEach=tonumber,Constructor=Color3.fromRGB,Length=3})local function B(z)if#z==1 then z=z..z end return tonumber(z,16)end local o={Transform=function(s)local o,X,G=s: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 z.Each(B,o,X,G)end,Validate=function(z,s,B)return z~=nil and(s~=nil and B~=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(B)B:RegisterType("\099\111\108\111\114\051",s)B:RegisterType("\099\111\108\111\114\051\115",z.MakeListableType(s,{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"}))B:RegisterType("\104\101\120\067\111\108\111\114\051",o)B:RegisterType("\104\101\120\067\111\108\111\114\051\115",z.MakeListableType(o))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
