local function __TS__CountVarargs(...) return select("#", ...) end local function __TS__SparseArrayNew(...) local sparseArray = {...} sparseArray.sparseLength = __TS__CountVarargs(...) return sparseArray end local function __TS__SparseArrayPush(sparseArray, ...) local args = {...} local argsLen = __TS__CountVarargs(...) local listLen = sparseArray.sparseLength for i = 1, argsLen do sparseArray[listLen + i] = args[i] end sparseArray.sparseLength = listLen + argsLen end local function __TS__SparseArraySpread(sparseArray) local _unpack = unpack or table.unpack return _unpack(sparseArray, 1, sparseArray.sparseLength) end local function __TS__ArraySplice(self, ...) local args = {...} local len = #self local actualArgumentCount = __TS__CountVarargs(...) local start = args[1] local deleteCount = args[2] if start < 0 then start = len + start if start < 0 then start = 0 end elseif start > len then start = len end local itemCount = actualArgumentCount - 2 if itemCount < 0 then itemCount = 0 end local actualDeleteCount if actualArgumentCount == 0 then actualDeleteCount = 0 elseif actualArgumentCount == 1 then actualDeleteCount = len - start else actualDeleteCount = deleteCount or 0 if actualDeleteCount < 0 then actualDeleteCount = 0 end if actualDeleteCount > len - start then actualDeleteCount = len - start end end local out = {} for k = 1, actualDeleteCount do local from = start + k if self[from] ~= nil then out[k] = self[from] end end if itemCount < actualDeleteCount then for k = start + 1, len - actualDeleteCount do local from = k + actualDeleteCount local to = k + itemCount if self[from] then self[to] = self[from] else self[to] = nil end end for k = len - actualDeleteCount + itemCount + 1, len do self[k] = nil end elseif itemCount > actualDeleteCount then for k = len - actualDeleteCount, start + 1, -1 do local from = k + actualDeleteCount local to = k + itemCount if self[from] then self[to] = self[from] else self[to] = nil end end end local j = start + 1 for i = 3, actualArgumentCount do self[j] = args[i] j = j + 1 end for k = #self, len - actualDeleteCount + itemCount + 1, -1 do self[k] = nil end return out end local function __TS__ArraySort(self, compareFn) if compareFn ~= nil then table.sort( self, function(a, b) return compareFn(nil, a, b) < 0 end ) else table.sort(self) end return self end local function __TS__ArrayIndexOf(self, searchElement, fromIndex) if fromIndex == nil then fromIndex = 0 end local len = #self if len == 0 then return -1 end if fromIndex >= len then return -1 end if fromIndex < 0 then fromIndex = len + fromIndex if fromIndex < 0 then fromIndex = 0 end end for i = fromIndex + 1, len do if self[i] == searchElement then return i - 1 end end return -1 end local function __TS__Class(self) local c = {prototype = {}} c.prototype.__index = c.prototype c.prototype.constructor = c return c end local function __TS__ClassExtends(target, base) target.____super = base local staticMetatable = setmetatable({__index = base}, base) setmetatable(target, staticMetatable) local baseMetatable = getmetatable(base) if baseMetatable then if type(baseMetatable.__index) == "function" then staticMetatable.__index = baseMetatable.__index end if type(baseMetatable.__newindex) == "function" then staticMetatable.__newindex = baseMetatable.__newindex end end setmetatable(target.prototype, base.prototype) if type(base.prototype.__index) == "function" then target.prototype.__index = base.prototype.__index end if type(base.prototype.__newindex) == "function" then target.prototype.__newindex = base.prototype.__newindex end if type(base.prototype.__tostring) == "function" then target.prototype.__tostring = base.prototype.__tostring end end local function __TS__New(target, ...) local instance = setmetatable({}, target.prototype) instance:____constructor(...) return instance end local __TS__Symbol, Symbol do local symbolMetatable = {__tostring = function(self) return ("Symbol(" .. (self.description or "")) .. ")" end} function __TS__Symbol(description) return setmetatable({description = description}, symbolMetatable) end Symbol = { asyncDispose = __TS__Symbol("Symbol.asyncDispose"), dispose = __TS__Symbol("Symbol.dispose"), iterator = __TS__Symbol("Symbol.iterator"), hasInstance = __TS__Symbol("Symbol.hasInstance"), species = __TS__Symbol("Symbol.species"), toStringTag = __TS__Symbol("Symbol.toStringTag") } end local function __TS__InstanceOf(obj, classTbl) if type(classTbl) ~= "table" then error("Right-hand side of 'instanceof' is not an object", 0) end if classTbl[Symbol.hasInstance] ~= nil then return not not classTbl[Symbol.hasInstance](classTbl, obj) end if type(obj) == "table" then local luaClass = obj.constructor while luaClass ~= nil do if luaClass == classTbl then return true end luaClass = luaClass.____super end end return false end return { __TS__SparseArrayNew = __TS__SparseArrayNew, __TS__SparseArrayPush = __TS__SparseArrayPush, __TS__SparseArraySpread = __TS__SparseArraySpread, __TS__ArraySplice = __TS__ArraySplice, __TS__ArraySort = __TS__ArraySort, __TS__ArrayIndexOf = __TS__ArrayIndexOf, __TS__Class = __TS__Class, __TS__ClassExtends = __TS__ClassExtends, __TS__New = __TS__New, __TS__InstanceOf = __TS__InstanceOf }