local W={}local f={"\110\117\109\098\101\114","\098\111\111\108\101\097\110"}function W.ValueToSourceString(e,W)local R=typeof(W)if R=="\115\116\114\105\110\103"then return("\"\037\115\""):format(W)end if table.find(f,R)then return tostring(W)end if R=="\069\110\117\109\073\116\101\109"then return("\069\110\117\109\046\037\115\046\037\115"):format(tostring(W.EnumType),tostring(W.Name))end if R=="\067\111\108\111\114\051"then return("\067\111\108\111\114\051\046\102\114\111\109\082\071\066\040\037\100\044 \037\100\044 \037\100\041"):format(W.R*255,W.G*255,W.B*255)end error(("\068\111\110\'\116 \107\110\111\119 \104\111\119 \116\111 \099\111\110\118\101\114\116 \037\113 \040\037\115\041 \105\110\116\111 \097 \115\111\117\114\099\101 \115\116\114\105\110\103"):format(tostring(W),R))end function W.ReturnFirstNonNil(W,...)local f=table.pack(...)for W,f in pairs(f)do if f~=nil then return f end end end return W
---
---Utility functions for values
---
---@class ValueUtil
---
local ValueUtil = {}

--------------------------------------------------
-- Types
-- ...

--------------------------------------------------
-- Dependencies
-- ...

--------------------------------------------------
-- Constants
-- ...

--------------------------------------------------
-- Members
local valueToSourceStringToStringTypes = { "number", "boolean" }

---
---Passed a value, will return a string that could represent it in a lua file.
---Example:
---    local value1 = true: boolean
---    print(ValueUtil:ValueToSourceString(value1)) -> "true"
---
---    local value2 = Enum.KeyCode.H
---    print(ValueUtil:ValueToSourceString(value2)) -> "Enum.KeyCode.H"
---
function ValueUtil:ValueToSourceString(value)
    local valueType = typeof(value)

    -- String
    if valueType == "string" then
        return ('"%s"'):format(value)
    end

    -- To String method
    if table.find(valueToSourceStringToStringTypes, valueType) then
        return tostring(value)
    end

    -- Enum Item
    if valueType == "EnumItem" then
        return ("Enum.%s.%s"):format(tostring(value.EnumType), tostring(value.Name))
    end

    -- Color3
    if valueType == "Color3" then
        return ("Color3.fromRGB(%d, %d, %d)"):format(value.R * 255, value.G * 255, value.B * 255)
    end

    error(("Don't know how to convert %q (%s) into a source string"):format(tostring(value), valueType))
end

---
---Passed a list of values, returns the first non-nil value
---@vararg any
---@return any
---
function ValueUtil:ReturnFirstNonNil(...)
    local tbl = table.pack(...)
    for _, value in pairs(tbl) do
        if value ~= nil then
            return value
        end
    end
end

return ValueUtil
