aura_env.keybind = ""
aura_env.scanned = false
aura_env.bars = {
	"ElvUI_Bar1",
	"ElvUI_Bar2",
	"ElvUI_Bar3",
	"ElvUI_Bar4",
	"ElvUI_Bar5",
	"ElvUI_Bar6",
	"ElvUI_Bar7",
	"ElvUI_Bar8",
	"ElvUI_Bar9",
	"ElvUI_Bar10",
}

aura_env.lookup = function()
	local spellid = 0
	if not aura_env.states or aura_env.states == nil then
		print("No states")
		return
	end

	local triggerInfo = aura_env.states[2]
	if not triggerInfo then triggerInfo = aura_env.states[1] end
	if triggerInfo then spellid = triggerInfo.trigger.spellName end
	if spellid == 0 then return end

	for _, bar in pairs(aura_env.bars) do
		for i = 1, 12 do
			local button = _G[bar .. "Button" .. i]
			local slot = button:GetAttribute("action")
			if slot then
				local type, _, _, id = GetActionInfo(slot)
				if type == "spell" then
					if id == spellid then
						local bindid = button.keyBoundTarget
						local keybind = GetBindingKey(bindid)
						aura_env.keybind = keybind
						break
					end
				end
			end
		end
	end

	if aura_env.keybind then
		aura_env.keybind = string.gsub(aura_env.keybind, "BUTTON", "B")
		aura_env.keybind = string.gsub(aura_env.keybind, "SHIFT%-", "S")
		aura_env.keybind = string.gsub(aura_env.keybind, "CTRL%-", "C")
		aura_env.keybind = string.gsub(aura_env.keybind, "ALT%-", "A")
		aura_env.keybind = string.gsub(aura_env.keybind, "SPACE", "Spb")
	end

	aura_env.scanned = true
end
