local AddName, Ns = ...

local defaultLocale, newLocale
function Ns.RegisterLocale(locale, default)
	if default then
		if locale == "enUS" and not defaultLocale then
			defaultLocale, newLocale = {}, {}
			Ns.L = setmetatable(newLocale, { __index = function(t, k)
				local v = defaultLocale[k] or tostring(k)
				return v
			end})
			return defaultLocale
		end
	end
	return newLocale
end

-- icons
local path = "Interface\\AddOns\\"..AddName.."\\Textures\\"
Ns.MiscIcon = "\124T" .. path .."Misc:13\124t "
Ns.SettingsIcon = "\124T" .. path .."Settings:13\124t "
Ns.DisplayIcon = "\124T" .. path .."Display:13\124t "
Ns.SpacingIcon = "\124T" .. path .."Spacing:13\124t "
Ns.LayoutIcon = "\124T" .. path .."Layout:13\124t "
Ns.ColumnIcon = "\124T" .. path .."CheckColumn:13\124t "
Ns.EventsIcon = "\124T" .. path .."Events:13\124t "
Ns.LockIcon = "\124T" .. path .."Lock:12\124t "
Ns.HideIcon = "\124T" .. path .."Hide:12\124t "
Ns.AttachIcon = "\124T" .. path .."Attach:12\124t "
Ns.StrataIcon = "\124T" .. path .."Strata:12\124t "
Ns.OutlineIcon = "\124T" .. path .."Outline:12\124t "
Ns.BackgroundIcon = "\124T" .. path .."Background:12\124t "
Ns.FontsIcon = "\124T" .. path .."Fonts:12\124t "
Ns.FontSizeIcon = "\124T" .. path .."FontSize:12\124t "
Ns.AlignIcon = "\124T" .. path .."Align:12\124t "
Ns.WidthIcon = "\124T" .. path .."Width:12\124t "
Ns.WidthStringIcon = "\124T" .. path .."WidthString:12\124t "
Ns.HeightIcon = "\124T" .. path .."Height:12\124t "
Ns.CapsIcon = "\124T" .. path .."Caps:12\124t "
Ns.TextColorIcon = "\124T" .. path .."TextColor:12\124t "
Ns.ValueColorIcon = "\124T" .. path .."ValueColor:12\124t "
Ns.AbbreviateIcon = "\124T" .. path .."Abbreviate:12\124t "
Ns.ToggleIconsIcon = "\124T" .. path .."ToggleIcons:12\124t "
Ns.SeparatorIcon = "\124T" .. path .."TextSeparator:12\124t "
Ns.MiniMenuIcon = "\124T" .. path .."MinimapMenu:12\124t "
Ns.CompIcon = "\124T" .. path .."Compartment:12\124t "
Ns.HUDIcon = "\124T" .. path .."HUD:12\124t "
Ns.ValueIcon = "\124T" .. path .."ValueColor:12\124t "
Ns.ToggleText = "\124T" .. path .."ToggleText:12\124t "
Ns.HUDBorder = "\124T" .. path .."HUDBorder:12\124t "

-- icon textures

local function getItem(itemId)
	local _,_,_,_,icon = C_Item.GetItemInfoInstant(itemId)
	return icon
end

local function getCurrencyIcon(currencyId)
	local info = C_CurrencyInfo.GetCurrencyInfo(currencyId)
	return info and info.iconFileID
end

local function getCurrency(varName, currencyId)
	local icon = getCurrencyIcon(currencyId) and ("|T" .. getCurrencyIcon(currencyId) .. ":0|t") or ""
	Ns[varName] = icon
	local ok, link = pcall(C_CurrencyInfo.GetCurrencyLink, currencyId)
	if ok and link then
		Ns[varName] = icon .. link
	end
end

local function getSpell(varName, spellId)
	local name, _, icon = C_Spell.GetSpellInfo(spellId)
	local iconStr = icon and ("|T" .. icon .. ":0|t") or ""
	Ns[varName] = iconStr
	local ok, link = pcall(C_Spell.GetSpellLink, spellId)
	if ok and link then
		Ns[varName] = iconStr .. link
	elseif name then
		Ns[varName] = iconStr .. "["..name.."]"
	end
end

-- spell links
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then

	getCurrency("AdventurerLink", 3383)
	getCurrency("VeteranLink", 3341)
	getCurrency("ChampLink", 3343)
	getCurrency("HeroLink", 3345)
	getCurrency("MythLink", 3347)
	getCurrency("CrystalLink", 2815)
	getCurrency("DonorLink", 2897)
	getCurrency("ValorPvPLink", 1191)
	getCurrency("BloodyLink", 2123)
	getCurrency("HonorLink", 1792)
	getCurrency("ConqLink", 1602)
	getCurrency("TimeLink", 1166)
	getCurrency("TenderLink", 2032)
	getCurrency("CartelLink", 3120)
	getCurrency("HalloLink", 2899)
	getCurrency("AssemLink", 2902)
	getCurrency("SevereLink", 2903)
	getCurrency("CofferLink", 3310)
	getCurrency("CoinLink", 2803)
	getCurrency("CatalystLink", 3378)
	getCurrency("CelebLink", 3100)
	getCurrency("DarkfuseLink", 3177)
	getCurrency("GallaLink", 3136)
	getCurrency("RadianceLink", 3283)
	getCurrency("KareshLink", 3129)
	getCurrency("UntethLink", 3303)
	getCurrency("EtherealLink", 3278)
	getCurrency("BronzeLink", 3252)
	getCurrency("TwilightLink", 3319)
	getCurrency("VoidlightLink", 3316)
	getCurrency("CouponsLink", 3363)
	getCurrency("ArcanaLink", 3379)
	getCurrency("SilverLink", 3365)
	getCurrency("AmaniLink", 3354)
	getCurrency("AratiLink", 3370)
	getCurrency("SingLink", 3389)
	getCurrency("AbundLink", 3377)
	getCurrency("AnguishLink", 3392)
	getCurrency("DarkmoonLink", 515)
	getCurrency("LuminousLink", 3385)
	getCurrency("DundunLink", 3376)
	getCurrency("RestoredKeyLink", 3028)
	getCurrency("ManaLink", 3356)
	getCurrency("VoidSampleLink", 3400)
	getCurrency("SlayerLink", 3410)
	getCurrency("PreyLink", 3386)

	Ns.SparkLink = "|T".. getItem(232875)..":0|t"
	Ns.PuzzlingLink = "|T".. getItem(237502)..":0|t"
	Ns.SkyshardsLink = "|T".. getItem(255826)..":0|t"
	Ns.VileEssenceLink = "|T".. getItem(259361)..":0|t"
	getSpell("DelverLink", 471521)
	getSpell("CompanionLink", 220172)
	getSpell("StashLink", 1216211)

elseif WOW_PROJECT_ID == 14 then
	-- Ns.DeathEmbLink = ""--"|T"..select(3, GetSpellInfo(47198))..":0|t"..GetSpellLink(47198).."   "
	-- Ns.FaeFireLink = ""--"|T"..select(3, GetSpellInfo(91565))..":0|t"..GetSpellLink(91565).."   "
	-- Ns.EarMoonLink = ""--"|T"..select(3, GetSpellInfo(60433))..":0|t"..GetSpellLink(60433).."   "
	-- Ns.HuntMarkLink = ""--"|T"..select(3, GetSpellInfo(1130))..":0|t"..GetSpellLink(1130).."   "
	-- Ns.ScarFeverLink = ""--"|T"..select(3, GetSpellInfo(81130))..":0|t"..GetSpellLink(81130).."   "
	-- Ns.ExpArmLink = ""--"|T"..select(3, GetSpellInfo(8647))..":0|t"..GetSpellLink(8647).."   "
	-- Ns.SunArmLink = ""--"|T"..select(3, GetSpellInfo(58567))..":0|t"..GetSpellLink(58567).."   "
	-- Ns.CursEleLink = ""--"|T"..select(3, GetSpellInfo(1490))..":0|t"..GetSpellLink(1490).."   "
	-- Ns.BeaSlayLink = ""--"|T"..select(3, GetSpellInfo(20557))..":0|t"..GetSpellLink(20557).."   "
	-- Ns.MolFuryLink = ""--"|T"..select(3, GetSpellInfo(31679))..":0|t"
	-- Ns.BrittleLink = ""--"|T"..select(3, GetSpellInfo(81326))..":0|t"..GetSpellLink(81326).."   "
	-- Ns.SavCombLink = ""--"|T"..select(3, GetSpellInfo(58413))..":0|t"
	-- Ns.MasPoisLink = ""--"|T"..select(3, GetSpellInfo(93068))..":0|t"..GetSpellLink(93068).."   "
	-- Ns.BloFrenLink = ""--"|T"..select(3, GetSpellInfo(30070))..":0|t"..GetSpellLink(30070).."   "
	-- Ns.NoEscapeLink = ""--"|T"..select(3, GetSpellInfo(53298))..":0|t"
	-- Ns.ShadFlameLink = ""--"|T"..select(3, GetSpellInfo(76768))..":0|t"..GetSpellLink(17800).."   "
	-- Ns.VindiLink = ""--"|T"..select(3, GetSpellInfo(26017))..":0|t"..GetSpellLink(26017).."   "
	-- Ns.LightBreathLink = ""--"|T"..select(3, GetSpellInfo(24844))..":0|t"..GetSpellLink(24844).."   "

elseif WOW_PROJECT_ID == 19 then -- mists
	Ns.DeathEmbLink = ""--"|T"..select(3, GetSpellInfo(47198))..":0|t"..GetSpellLink(47198).."   "
	Ns.FaeFireLink = ""--"|T"..select(3, GetSpellInfo(91565))..":0|t"..GetSpellLink(91565).."   "
	Ns.EarMoonLink = ""--"|T"..select(3, GetSpellInfo(60433))..":0|t"..GetSpellLink(60433).."   "
	Ns.HuntMarkLink = ""--"|T"..select(3, GetSpellInfo(1130))..":0|t"..GetSpellLink(1130).."   "
	Ns.ScarFeverLink = ""--"|T"..select(3, GetSpellInfo(81130))..":0|t"..GetSpellLink(81130).."   "
	Ns.ExpArmLink = ""--"|T"..select(3, GetSpellInfo(8647))..":0|t"..GetSpellLink(8647).."   "
	Ns.SunArmLink = ""--"|T"..select(3, GetSpellInfo(58567))..":0|t"..GetSpellLink(58567).."   "
	Ns.CursEleLink = ""--"|T"..select(3, GetSpellInfo(1490))..":0|t"..GetSpellLink(1490).."   "
	Ns.BeaSlayLink = ""--"|T"..select(3, GetSpellInfo(20557))..":0|t"..GetSpellLink(20557).."   "
	Ns.MolFuryLink = ""--"|T"..select(3, GetSpellInfo(31679))..":0|t"
	Ns.BrittleLink = ""--"|T"..select(3, GetSpellInfo(81326))..":0|t"..GetSpellLink(81326).."   "
	Ns.SavCombLink = ""--"|T"..select(3, GetSpellInfo(58413))..":0|t"
	Ns.MasPoisLink = ""--"|T"..select(3, GetSpellInfo(93068))..":0|t"..GetSpellLink(93068).."   "
	Ns.BloFrenLink = ""--"|T"..select(3, GetSpellInfo(30070))..":0|t"..GetSpellLink(30070).."   "
	Ns.NoEscapeLink = ""--"|T"..select(3, GetSpellInfo(53298))..":0|t"
	Ns.ShadFlameLink = ""--"|T"..select(3, GetSpellInfo(76768))..":0|t"..GetSpellLink(17800).."   "
	Ns.VindiLink = ""--"|T"..select(3, GetSpellInfo(26017))..":0|t"..GetSpellLink(26017).."   "
	Ns.LightBreathLink = ""--"|T"..select(3, GetSpellInfo(24844))..":0|t"..GetSpellLink(24844).."   "

elseif WOW_PROJECT_ID == 5 then -- tbc
	getSpell("BloodFrenzyLink", 29859)
	getSpell("CurseofElementsLink", 1490)
	getSpell("FireVulnerabilityLink", 22959)
	getSpell("HemorrhageLink", 16511)
	getSpell("HuntersMarkLink", 1130)
	getSpell("InsectSwarmLink", 5570)
	getSpell("MiseryLink", 33191)
	getSpell("SealofCrusaderLink", 21082)
	getSpell("ScorpidStingLink", 3043)
	getSpell("SurvivalofFittestLink", 33853)
	getSpell("ShadowWeavingLink", 15257)
	getSpell("ShadowVulnerabilityLink", 17794)
	getSpell("StormstrikeLink", 17364)
	getSpell("WintersChillLink", 12579)
	getSpell("SunderArmorLink", 7386)
	getSpell("ExposeArmorLink", 8647)
	getSpell("FaerieFireLink", 770)
	getSpell("CurseOfReckLink", 704)
	getSpell("ArmorShatterLink", 16928)
end

-- class colors
Ns.Colors = {
	Green = "|cff71ffc9",
	Red = "|cffC41E3A"	,
	Warrior = "|cffC69B6D",
	Rogue = "|cffFFF468",
	Warlock = "|cff8788EE",
	Paladin = "|cffF48CBA",
	DeathKnight = "|cffC41E3A",
	Druid = "|cffFF7C0A",
	Hunter = "|cffAAD372",
	Mage = "|cff3FC7EB",
	Shaman = "|cff0070DD",
	Evoker = "|cff33937F",
	Monk = "|cff00FF98",
	DemonHunter = "|cffA330C9",
}