local _, data = ... ---@cast data HeimdallData if not Heimdall_Data then Heimdall_Data = {} end ---@class HeimdallData ---@field config HeimdallConfig ---@field raceMap table ---@field stinkies table ---@field messenger HeimdallMessengerData ---@field who HeimdallWhoData ---@field dumpTable fun(table: any, depth?: number): nil ---@field utf8len fun(input: string): number ---@field padString fun(input: string, targetLength: number, left?: boolean): string --- Config --- ---@class HeimdallConfig ---@field spotter HeimdallSpotterConfig ---@field who HeimdallWhoConfig ---@field messenger HeimdallMessengerConfig ---@class HeimdallSpotterConfig ---@field enabled boolean ---@field everyone boolean ---@field hostile boolean ---@field alliance boolean ---@field stinky boolean ---@field notifyChannel string ---@field zoneOverride string? ---@field throttleTime number ---@class HeimdallWhoConfig ---@field enabled boolean ---@class HeimdallMessengerConfig ---@field enabled boolean --- Data --- ---@class HeimdallMessengerData ---@field queue table ---@field ticker number? ---@class HeimdallWhoData ---@field ticker number? data.messenger = { queue = {} } data.config = { spotter = { enabled = true, everyone = false, hostile = true, alliance = false, stinky = false, notifyChannel = "Foobar", zoneOverride = nil, throttleTime = 1 }, who = { enabled = true }, messenger = { enabled = true } } data.raceMap = { ["Orc"] = "Horde", ["Undead"] = "Horde", ["Tauren"] = "Horde", ["Troll"] = "Horde", ["Blood Elf"] = "Horde", ["Goblin"] = "Horde", ["Human"] = "Alliance", ["Dwarf"] = "Alliance", ["Night Elf"] = "Alliance", ["Gnome"] = "Alliance", ["Draenei"] = "Alliance", ["Worgen"] = "Alliance", ["Vulpera"] = "Horde", ["Nightborne"] = "Horde", ["Zandalari Troll"] = "Horde", ["Kul Tiran"] = "Alliance", ["Dark Iron Dwarf"] = "Alliance", ["Void Elf"] = "Alliance", ["Lightforged Draenei"] = "Alliance", ["Mechagnome"] = "Alliance", ["Mag'har Orc"] = "Horde" } data.stinkies = {} ---@param input string ---@return number data.utf8len = function(input) if not input then return 0 end local len = 0 local i = 1 local n = #input while i <= n do local c = input:byte(i) if c >= 0 and c <= 127 then i = i + 1 elseif c >= 194 and c <= 223 then i = i + 2 elseif c >= 224 and c <= 239 then i = i + 3 elseif c >= 240 and c <= 244 then i = i + 4 else i = i + 1 end len = len + 1 end return len end ---@param input string ---@param targetLength number ---@param left boolean ---@return string data.padString = function(input, targetLength, left) left = left or false local len = data.utf8len(input) if len < targetLength then if left then input = input .. string.rep(" ", targetLength - len) else input = string.rep(" ", targetLength - len) .. input end end return input end