local T=(require(script.Parent.EnumItem)).new local O={}function O.new(O,a)local D=newproxy(true)local w=getmetatable(D)local v={}local H={}function v.GetEnumItems(T)local O={}for T,a in pairs(H)do table.insert(O,a)end return O end w.__metatable="\084\104\101 \109\101\116\097\116\097\098\108\101 \105\115 \108\111\099\107\101\100"w.__tostring=function()return O end function w.__index(T,a)local D=v[a]or H[a]if D then return D else error(("\037\115 \105\115 \110\111\116 \097 \118\097\108\105\100 \109\101\109\098\101\114 \111\102 \"\037\115\""):format(a,"\069\110\117\109\046"..O),2)end end function w.__newindex(T,O)error(O.." \099\097\110\110\111\116 \098\101 \097\115\115\105\103\110\101\100 \116\111",2)end for O,a in pairs(a)do local w,v local t=type(O)if t=="\110\117\109\098\101\114"then w=a v=O if type(a)~="\115\116\114\105\110\103"then error("\069\120\112\101\099\116\101\100 \115\116\114\105\110\103 \097\115 \118\097\108\117\101 \119\104\101\110 \107\101\121 \105\115 \097 \110\117\109\098\101\114",4)end elseif t=="\115\116\114\105\110\103"then w=O v=a else error("\069\120\112\101\099\116\101\100 \110\117\109\098\101\114 \111\114 \115\116\114\105\110\103 \097\115 \107\101\121",4)end H[w]=T(w,v,D)end return D end return O
local newEnumItem = require(script.Parent.EnumItem).new

--[=[
    @class Enum
    Mirror of Roblox's
    [Enum](https://developer.roblox.com/en-us/api-reference/datatype/Enum)
    DataType.
]=]
local Enum = {}

--[=[
    @within Enum
    @private
    @return Enum
    Creates a new Enum.
]=]
--[=[
    @within Enum
    @function GetEnumItems
    @return EnumItem[]
    Returns an array containing all of the EnumItem options available for
    this enum.
]=]
function Enum.new(enumName, enumItemsList)
    local enum = newproxy(true)
    local meta = getmetatable(enum)

    local methods = {}
    local enumItems = {}

    function methods:GetEnumItems()
        local list = {}

        for _,enumItem in pairs(enumItems) do
            table.insert(list, enumItem)
        end

        return list
    end

    --[[
    Not compatible with Roblox Enums

    function methods:FromValue(enumValue)
        for _,enumItem in pairs(enumItems) do
            if enumItem.Value == enumValue then
                return enumItem
            end
        end
    end
    ]]

    meta.__metatable = "The metatable is locked"
    meta.__tostring = function()
        return enumName
    end

    function meta.__index(_, i)
        local v = methods[i] or enumItems[i]

        if v then
            return v
        else
            error(("%s is not a valid member of \"%s\""):format(i, "Enum.".. enumName), 2)
        end
    end

    function meta.__newindex(_, i)
        error(i.. " cannot be assigned to", 2)
    end

    for i, v in pairs(enumItemsList) do
        local enumItemName, enumItemValue

        local t = type(i)
        if t == "number" then
            enumItemName = v
            enumItemValue = i

            if type(v) ~= "string" then
                error("Expected string as value when key is a number", 4)
            end
        elseif t == "string" then
            enumItemName = i
            enumItemValue = v
        else
            error("Expected number or string as key", 4)
        end

        enumItems[enumItemName] = newEnumItem(enumItemName, enumItemValue, enum)
    end

    return enum
end

return Enum