-- LOOT_READY LOOT_OPENED

function(e, ...)
    local slot = 1
    local lootinfo = GetLootInfo()
    for k, v in pairs(lootinfo) do
        if v.locked == false then
            local link = GetLootSlotLink(slot)
            if not link then link = GetLootSlotLink(slot) end
            if aura_env.filter[1] == true and (v.item:match("%d+ Gold") or v.item:match("%d+ Silver") or v.item:match("%d+ Copper")) then
                LootSlot(slot)
            elseif aura_env.filter[2] == true and link:match("Azerite") then
                LootSlot(slot)
            elseif aura_env.filter[3] == true and v.item:match("War Resources") then
                LootSlot(slot)
            elseif aura_env.filter[4] == true and v.item:match("Residuum") then
                LootSlot(slot)
            elseif aura_env.filter[5] == true and v.item:match("Manapearl") then
                LootSlot(slot)
            end
            if link then
                local type = select(6, GetItemInfo(link)) or ""
                local subtype = select(7, GetItemInfo(link)) or ""
                local ilvl = select(4, GetItemInfo(link)) or 0
                local equip = select(9, GetItemInfo(link))
                if aura_env.filter[6] == true and (select(7, GetItemInfo(link)) or 0) == "Mount" then
                    LootSlot(slot)
                elseif aura_env.filter[7] == true and ilvl > aura_env.ilvlFilter then
                    LootSlot(slot)
                elseif aura_env.filter[8] == true and (select(7, GetItemInfo(link)) or 0) == "Herb" then
                    LootSlot(slot)
                elseif aura_env.filter[9] == true and (select(7, GetItemInfo(link)) or 0) == "Cooking" then
                    LootSlot(slot)
                elseif aura_env.filter[10] == true and (select(7, GetItemInfo(link)) or 0) == "Cloth" and type == "Tradeskill" then
                    LootSlot(slot)
                elseif aura_env.filter[11] == true and (select(7, GetItemInfo(link)) or 0) == "Metal & Stone" then
                    LootSlot(slot)
                elseif aura_env.filter[12] == true and (select(11, GetItemInfo(link)) or 0) > aura_env.goldFilter and v.quality == 0 then
                    LootSlot(slot)
                elseif aura_env.filter[13] == true and v.quality > 1 and v.quality < 4 and type ~= "Weapon" and type ~= "Armor" then
                    LootSlot(slot)
                elseif aura_env.filter[14] == true and v.isQuestItem == true then
                    LootSlot(slot)
                elseif aura_env.filter[15] == true and v.quality == 0 then
                    LootSlot(slot)
                elseif aura_env.filter[16] == true and aura_env.whitelist[v.item] then
                    LootSlot(slot)
                elseif aura_env.filter[17] == true and type == "Quest" and subtype == "Quest" then
                    LootSlot(slot)
                elseif aura_env.filter[21] == true and type == "Tradeskill" and subtype == "Elemental" then
                    LootSlot(slot)
                else
                    if type == "Weapon" or type == "Armor" then
                        if aura_env.filter[18] == true and aura_env.skills[select(3, UnitClass("player"))][subtype] == 1 and v.quality > 2 then
                            LootSlot(slot)
                        elseif aura_env.filter[19] == true and (equip == "INVTYPE_FINGER" or equip == "INVTYPE_TRINKET" or equip == "INVTYPE_CLOAK" or equip == "INVTYPE_NECK") and v.quality > 2 then
                            LootSlot(slot)
                        end
                    elseif aura_env.filter[20] == true and type == "Miscellaneous" then
                        if subtype == "Mount" then
                            LootSlot(slot)
                        end
                    end
                end
            end
            slot = slot + 1
        end
    end
end