BTWQUESTS_CATEGORY_LEGION_ARTIFACT = 701
BTWQUESTS_CATEGORY_LEGION_ORDERHALL = 702
BTWQUESTS_CATEGORY_LEGION_AZSUNA = 703
BTWQUESTS_CATEGORY_LEGION_VALSHARAH = 704
BTWQUESTS_CATEGORY_LEGION_HIGHMOUNTAIN = 705
BTWQUESTS_CATEGORY_LEGION_STORMHEIM = 706
BTWQUESTS_CATEGORY_LEGION_SURAMAR = 707
BTWQUESTS_CATEGORY_LEGION_SURAMAR_NIGHTFALLEN = 708
BTWQUESTS_CATEGORY_LEGION_SURAMAR_GOOD_SURAMARITAN = 709
BTWQUESTS_CATEGORY_LEGION_SURAMAR_INSURRECTION = 710
BTWQUESTS_CATEGORY_LEGION_BROKENSHORE = 711
BTWQUESTS_CATEGORY_LEGION_ARGUS = 712
BTWQUESTS_CATEGORY_LEGION_CLASSES_DEATHKNIGHT = 713
BTWQUESTS_CATEGORY_LEGION_CLASSES_DEMONHUNTER = 714
BTWQUESTS_CATEGORY_LEGION_CLASSES_DRUID = 715
BTWQUESTS_CATEGORY_LEGION_CLASSES_HUNTER = 716
BTWQUESTS_CATEGORY_LEGION_CLASSES_MAGE = 717
BTWQUESTS_CATEGORY_LEGION_CLASSES_MONK = 718
BTWQUESTS_CATEGORY_LEGION_CLASSES_PALADIN = 719
BTWQUESTS_CATEGORY_LEGION_CLASSES_PRIEST = 720
BTWQUESTS_CATEGORY_LEGION_CLASSES_ROGUE = 721
BTWQUESTS_CATEGORY_LEGION_CLASSES_SHAMAN = 722
BTWQUESTS_CATEGORY_LEGION_CLASSES_WARLOCK = 723
BTWQUESTS_CATEGORY_LEGION_CLASSES_WARRIOR = 724
BTWQUESTS_CATEGORY_LEGION_HIDDEN = 725
BTWQUESTS_CATEGORY_LEGION_PROFESSIONS = 726
BTWQUESTS_CATEGORY_LEGION_ALLIED_RACES = 727
BTWQUESTS_CATEGORY_LEGION_CLASS = 728

BTWQUESTS_CHAIN_LEGION_ARTIFACT_BALANCEOFPOWER = 70101
BTWQUESTS_CHAIN_LEGION_ARTIFACT_XYLEM = 70102
BTWQUESTS_CHAIN_LEGION_ARTIFACT_TIDESKORN = 70103
BTWQUESTS_CHAIN_LEGION_ARTIFACT_TANKS = 70104
BTWQUESTS_CHAIN_LEGION_ARTIFACT_HEALERS = 70105
BTWQUESTS_CHAIN_LEGION_ARTIFACT_FELTOTEM = 70106
BTWQUESTS_CHAIN_LEGION_ARTIFACT_IMPMOTHER = 70107
BTWQUESTS_CHAIN_LEGION_ARTIFACT_TWINS = 70108

BTWQUESTS_CHAIN_LEGION_ORDERHALL_LIGHTSHEART = 70201
BTWQUESTS_CHAIN_LEGION_ORDERHALL_MEATBALL = 70202

BTWQUESTS_CHAIN_LEGION_AZSUNA_BEHINDENEMYLINES = 70301
BTWQUESTS_CHAIN_LEGION_AZSUNA_DEFENDINGAZUREWINGREPOSE = 70302
BTWQUESTS_CHAIN_LEGION_AZSUNA_AZSUNAVERSUSAZSHARA = 70303
BTWQUESTS_CHAIN_LEGION_AZSUNA_AGAINSTTHEGIANTS = 70304
BTWQUESTS_CHAIN_LEGION_AZSUNA_MAKRANA = 70305
BTWQUESTS_CHAIN_LEGION_AZSUNA_DAGLOP = 70306
BTWQUESTS_CHAIN_LEGION_AZSUNA_VINEYARD = 70307
BTWQUESTS_CHAIN_LEGION_AZSUNA_FELBLAZE = 70308

BTWQUESTS_CHAIN_LEGION_VALSHARAH_INTRODUCTION = 70401
BTWQUESTS_CHAIN_LEGION_VALSHARAH_ARCHDRUID_OF_THE_VALE = 70402
BTWQUESTS_CHAIN_LEGION_VALSHARAH_ARCHDRUID_OF_THE_CLAW = 70403
BTWQUESTS_CHAIN_LEGION_VALSHARAH_ARCHDRUID_OF_LORE = 70404
BTWQUESTS_CHAIN_LEGION_VALSHARAH_INTO_THE_NIGHTMARE = 70405
BTWQUESTS_CHAIN_LEGION_VALSHARAH_ALL_NIGHTMARE_LONG = 70406
BTWQUESTS_CHAIN_LEGION_VALSHARAH_BRADENSBROOK = 70407
BTWQUESTS_CHAIN_LEGION_VALSHARAH_BLACK_ROOK_HOLD = 70408
BTWQUESTS_CHAIN_LEGION_VALSHARAH_WILDKIN = 70409
BTWQUESTS_CHAIN_LEGION_VALSHARAH_GRIZZLEWEALD = 70410
BTWQUESTS_CHAIN_LEGION_VALSHARAH_LUNARWING = 70411

BTWQUESTS_CHAIN_LEGION_HIGHMOUNTAIN_RIVERMANE_TRIBE = 70501
BTWQUESTS_CHAIN_LEGION_HIGHMOUNTAIN_RIVERBEND = 70502
BTWQUESTS_CHAIN_LEGION_HIGHMOUNTAIN_SKYHORN_TRIBE = 70503
BTWQUESTS_CHAIN_LEGION_HIGHMOUNTAIN_BLOODTOTEM_TRIBE = 70504
BTWQUESTS_CHAIN_LEGION_HIGHMOUNTAIN_HULNS_WAR = 70505
BTWQUESTS_CHAIN_LEGION_HIGHMOUNTAIN_SECRETS_OF_HIGHMOUNTAIN = 70506
BTWQUESTS_CHAIN_LEGION_HIGHMOUNTAIN_SNOWBLIND_MESA = 70507
BTWQUESTS_CHAIN_LEGION_HIGHMOUNTAIN_RAZIK = 70508
BTWQUESTS_CHAIN_LEGION_HIGHMOUNTAIN_HEMET = 70509
BTWQUESTS_CHAIN_LEGION_HIGHMOUNTAIN_STONEDARK = 70510
BTWQUESTS_CHAIN_LEGION_HIGHMOUNTAIN_MURKY = 70511

BTWQUESTS_CHAIN_LEGION_STORMHEIM_GREYMANES_GAMBIT_ALLIANCE = 70601
BTWQUESTS_CHAIN_LEGION_STORMHEIM_THE_AFTERMATH_ALLIANCE = 70602
BTWQUESTS_CHAIN_LEGION_STORMHEIM_GREYMANES_GAMBIT_HORDE = 70603
BTWQUESTS_CHAIN_LEGION_STORMHEIM_THE_AFTERMATH_HORDE = 70604
BTWQUESTS_CHAIN_LEGION_STORMHEIM_THE_TRIAL_OF_MIGHT = 70605
BTWQUESTS_CHAIN_LEGION_STORMHEIM_THE_TRIAL_OF_WILL = 70606
BTWQUESTS_CHAIN_LEGION_STORMHEIM_THE_TRIAL_OF_VALOR = 70607
BTWQUESTS_CHAIN_LEGION_STORMHEIM_TO_HELHEIM_AND_BACK = 70608
BTWQUESTS_CHAIN_LEGION_STORMHEIM_SECRETS_OF_THE_SHIELDMAIDENS = 70609
BTWQUESTS_CHAIN_LEGION_STORMHEIM_THE_CHAMPION_OF_STORMHEIM = 70610
BTWQUESTS_CHAIN_LEGION_STORMHEIM_A_MURKY_FATE = 70611
BTWQUESTS_CHAIN_LEGION_STORMHEIM_DREYRGROT = 70612
BTWQUESTS_CHAIN_LEGION_STORMHEIM_RAVENBEAR = 70613
BTWQUESTS_CHAIN_LEGION_STORMHEIM_GOBLINS = 70614

BTWQUESTS_CHAIN_LEGION_SURAMAR_WITHERED_ARMY_TRAINING = 70701

BTWQUESTS_CHAIN_LEGION_SURAMAR_NIGHTFALL = 70801
BTWQUESTS_CHAIN_LEGION_SURAMAR_ARCANIST_KELDANATH = 70802
BTWQUESTS_CHAIN_LEGION_SURAMAR_CHIEF_TELEMANCER_OCULETH = 70803
BTWQUESTS_CHAIN_LEGION_SURAMAR_FEEDING_SHALARAN = 70804
BTWQUESTS_CHAIN_LEGION_SURAMAR_MASQUERADE = 70805
BTWQUESTS_CHAIN_LEGION_SURAMAR_THE_LIGHT_BELOW = 70806

BTWQUESTS_CHAIN_LEGION_SURAMAR_AN_ANCIENT_GIFT = 70901
BTWQUESTS_CHAIN_LEGION_SURAMAR_THE_WANING_CRESCENT = 70902
BTWQUESTS_CHAIN_LEGION_SURAMAR_BLOOD_AND_WINE = 70903
BTWQUESTS_CHAIN_LEGION_SURAMAR_STATECRAFT = 70904
BTWQUESTS_CHAIN_LEGION_SURAMAR_A_GROWING_CRISIS = 70905
BTWQUESTS_CHAIN_LEGION_SURAMAR_A_CHANGE_OF_SEASONS = 70906
BTWQUESTS_CHAIN_LEGION_SURAMAR_BREAKING_THE_LIGHTBREAKER = 70907
BTWQUESTS_CHAIN_LEGION_SURAMAR_MOON_GUARD_STRONGHOLD = 70908
BTWQUESTS_CHAIN_LEGION_SURAMAR_TIDYING_TELANOR = 70909
BTWQUESTS_CHAIN_LEGION_SURAMAR_EMINENT_GROWMAIN = 70910
BTWQUESTS_CHAIN_LEGION_SURAMAR_JANDVIKS_JARL = 70911

BTWQUESTS_CHAIN_LEGION_SURAMAR_LOCKDOWN = 71001
BTWQUESTS_CHAIN_LEGION_SURAMAR_MISSING_PERSONS = 71002
BTWQUESTS_CHAIN_LEGION_SURAMAR_WAXING_CRESCENT = 71003
BTWQUESTS_CHAIN_LEGION_SURAMAR_AN_ELVEN_PROBLEM = 71004
BTWQUESTS_CHAIN_LEGION_SURAMAR_CRAFTING_WAR = 71005
BTWQUESTS_CHAIN_LEGION_SURAMAR_MARCH_ON_SURAMAR = 71006
BTWQUESTS_CHAIN_LEGION_SURAMAR_ELISANDES_RETORT = 71007
BTWQUESTS_CHAIN_LEGION_SURAMAR_AS_STRONG_AS_OUR_WILL = 71008
BTWQUESTS_CHAIN_LEGION_SURAMAR_BREAKING_THE_NIGHTHOLD = 71009

BTWQUESTS_CHAIN_LEGION_BROKENSHORE_BREACHING_THE_TOMB = 71101
BTWQUESTS_CHAIN_LEGION_BROKENSHORE_TREASURE_MASTER_IKSREEGED = 71102
BTWQUESTS_CHAIN_LEGION_BROKENSHORE_A_FOUND_MEMENTO = 71103

BTWQUESTS_CHAIN_LEGION_ARGUS_THE_ASSAULT_BEGINS = 71201
BTWQUESTS_CHAIN_LEGION_ARGUS_DARK_AWAKENINGS = 71202
BTWQUESTS_CHAIN_LEGION_ARGUS_WAR_OF_LIGHT_AND_SHADOW = 71203
BTWQUESTS_CHAIN_LEGION_ARGUS_WRANGLERS = 71204

BTWQUESTS_CHAIN_LEGION_CLASSES_DEATHKNIGHT_BLOOD = 71301
BTWQUESTS_CHAIN_LEGION_CLASSES_DEATHKNIGHT_FROST = 71302
BTWQUESTS_CHAIN_LEGION_CLASSES_DEATHKNIGHT_UNHOLY = 71303
BTWQUESTS_CHAIN_LEGION_CLASSES_DEATHKNIGHT_CAMPAIGN = 71304
BTWQUESTS_CHAIN_LEGION_CLASSES_DEATHKNIGHT_FOLLOWER = 71305
BTWQUESTS_CHAIN_LEGION_CLASSES_DEATHKNIGHT_MOUNT = 71306

BTWQUESTS_CHAIN_LEGION_CLASSES_DEMONHUNTER_HAVOC = 71401
BTWQUESTS_CHAIN_LEGION_CLASSES_DEMONHUNTER_VENGEANCE = 71402
BTWQUESTS_CHAIN_LEGION_CLASSES_DEMONHUNTER_CAMPAIGN = 71403
BTWQUESTS_CHAIN_LEGION_CLASSES_DEMONHUNTER_FOLLOWER = 71404
BTWQUESTS_CHAIN_LEGION_CLASSES_DEMONHUNTER_MOUNT = 71405
BTWQUESTS_CHAIN_LEGION_CLASSES_DEMONHUNTER_STARTING_ZONE = 71406

BTWQUESTS_CHAIN_LEGION_CLASSES_DRUID_BALANCE = 71501
BTWQUESTS_CHAIN_LEGION_CLASSES_DRUID_FERAL = 71502
BTWQUESTS_CHAIN_LEGION_CLASSES_DRUID_GUARDIAN = 71503
BTWQUESTS_CHAIN_LEGION_CLASSES_DRUID_RESTORATION = 71504
BTWQUESTS_CHAIN_LEGION_CLASSES_DRUID_CAMPAIGN = 71505
BTWQUESTS_CHAIN_LEGION_CLASSES_DRUID_FOLLOWER = 71506
BTWQUESTS_CHAIN_LEGION_CLASSES_DRUID_MOUNT = 71507

BTWQUESTS_CHAIN_LEGION_CLASSES_HUNTER_BEASTMASTERY = 71601
BTWQUESTS_CHAIN_LEGION_CLASSES_HUNTER_MARKSMANSHIP = 71602
BTWQUESTS_CHAIN_LEGION_CLASSES_HUNTER_SURVIVAL = 71603
BTWQUESTS_CHAIN_LEGION_CLASSES_HUNTER_CAMPAIGN = 71604
BTWQUESTS_CHAIN_LEGION_CLASSES_HUNTER_FOLLOWER = 71605
BTWQUESTS_CHAIN_LEGION_CLASSES_HUNTER_MOUNT = 71606

BTWQUESTS_CHAIN_LEGION_CLASSES_MAGE_ARCANE = 71701
BTWQUESTS_CHAIN_LEGION_CLASSES_MAGE_FIRE = 71702
BTWQUESTS_CHAIN_LEGION_CLASSES_MAGE_FROST = 71703
BTWQUESTS_CHAIN_LEGION_CLASSES_MAGE_CAMPAIGN = 71704
BTWQUESTS_CHAIN_LEGION_CLASSES_MAGE_FOLLOWER = 71705
BTWQUESTS_CHAIN_LEGION_CLASSES_MAGE_MOUNT = 71706
BTWQUESTS_CHAIN_LEGION_CLASSES_MAGE_ANNOYING_FOLLOWER = 71707

BTWQUESTS_CHAIN_LEGION_CLASSES_MONK_BREWMASTER = 71801
BTWQUESTS_CHAIN_LEGION_CLASSES_MONK_WINDWALKER = 71802
BTWQUESTS_CHAIN_LEGION_CLASSES_MONK_MISTWEAVER = 71803
BTWQUESTS_CHAIN_LEGION_CLASSES_MONK_CAMPAIGN = 71804
BTWQUESTS_CHAIN_LEGION_CLASSES_MONK_FOLLOWER = 71805
BTWQUESTS_CHAIN_LEGION_CLASSES_MONK_MOUNT = 71806

BTWQUESTS_CHAIN_LEGION_CLASSES_PALADIN_HOLY = 71901
BTWQUESTS_CHAIN_LEGION_CLASSES_PALADIN_PROTECTION = 71902
BTWQUESTS_CHAIN_LEGION_CLASSES_PALADIN_RETRIBUTION = 71903
BTWQUESTS_CHAIN_LEGION_CLASSES_PALADIN_CAMPAIGN = 71904
BTWQUESTS_CHAIN_LEGION_CLASSES_PALADIN_FOLLOWER = 71905
BTWQUESTS_CHAIN_LEGION_CLASSES_PALADIN_OTHER_FOLLOWER = 71906
BTWQUESTS_CHAIN_LEGION_CLASSES_PALADIN_MOUNT = 71907

BTWQUESTS_CHAIN_LEGION_CLASSES_PRIEST_DISCIPLINE = 72001
BTWQUESTS_CHAIN_LEGION_CLASSES_PRIEST_HOLY = 72002
BTWQUESTS_CHAIN_LEGION_CLASSES_PRIEST_SHADOW = 72003
BTWQUESTS_CHAIN_LEGION_CLASSES_PRIEST_CAMPAIGN = 72004
BTWQUESTS_CHAIN_LEGION_CLASSES_PRIEST_FOLLOWER = 72005
BTWQUESTS_CHAIN_LEGION_CLASSES_PRIEST_MOUNT = 72006

BTWQUESTS_CHAIN_LEGION_CLASSES_ROGUE_ASSASSINATION = 72101
BTWQUESTS_CHAIN_LEGION_CLASSES_ROGUE_OUTLAW = 72102
BTWQUESTS_CHAIN_LEGION_CLASSES_ROGUE_SUBTLETY = 72103
BTWQUESTS_CHAIN_LEGION_CLASSES_ROGUE_CAMPAIGN = 72104
BTWQUESTS_CHAIN_LEGION_CLASSES_ROGUE_FOLLOWER_ALLIANCE = 72105
BTWQUESTS_CHAIN_LEGION_CLASSES_ROGUE_FOLLOWER_HORDE = 72107
BTWQUESTS_CHAIN_LEGION_CLASSES_ROGUE_MOUNT = 72106

BTWQUESTS_CHAIN_LEGION_CLASSES_SHAMAN_ELEMENTAL = 72201
BTWQUESTS_CHAIN_LEGION_CLASSES_SHAMAN_ENHANCEMENT = 72202
BTWQUESTS_CHAIN_LEGION_CLASSES_SHAMAN_RESTORATION = 72203
BTWQUESTS_CHAIN_LEGION_CLASSES_SHAMAN_CAMPAIGN = 72204
BTWQUESTS_CHAIN_LEGION_CLASSES_SHAMAN_FOLLOWER = 72205
BTWQUESTS_CHAIN_LEGION_CLASSES_SHAMAN_MOUNT = 72206

BTWQUESTS_CHAIN_LEGION_CLASSES_WARLOCK_AFFLICTION = 72301
BTWQUESTS_CHAIN_LEGION_CLASSES_WARLOCK_DEMONOLOGY = 72302
BTWQUESTS_CHAIN_LEGION_CLASSES_WARLOCK_DESTRUCTION = 72303
BTWQUESTS_CHAIN_LEGION_CLASSES_WARLOCK_CAMPAIGN = 72304
BTWQUESTS_CHAIN_LEGION_CLASSES_WARLOCK_FOLLOWER = 72305
BTWQUESTS_CHAIN_LEGION_CLASSES_WARLOCK_MOUNT = 72306

BTWQUESTS_CHAIN_LEGION_CLASSES_WARRIOR_ARMS = 72401
BTWQUESTS_CHAIN_LEGION_CLASSES_WARRIOR_FURY = 72402
BTWQUESTS_CHAIN_LEGION_CLASSES_WARRIOR_PROTECTION = 72403
BTWQUESTS_CHAIN_LEGION_CLASSES_WARRIOR_CAMPAIGN = 72404
BTWQUESTS_CHAIN_LEGION_CLASSES_WARRIOR_FOLLOWER_ALLIANCE = 72405
BTWQUESTS_CHAIN_LEGION_CLASSES_WARRIOR_FOLLOWER_HORDE = 72407
BTWQUESTS_CHAIN_LEGION_CLASSES_WARRIOR_MOUNT = 72406

BTWQUESTS_CHAIN_LEGION_HIDDEN_KOSUMOTH = 72501
BTWQUESTS_CHAIN_LEGION_HIDDEN_MINDWORM = 72502
BTWQUESTS_CHAIN_LEGION_HIDDEN_SUNDARTER = 72503
BTWQUESTS_CHAIN_LEGION_HIDDEN_LUCIDNIGHTMARE = 72504
BTWQUESTS_CHAIN_LEGION_HIDDEN_UUNA = 72505

BTWQUESTS_CHAIN_LEGION_PROFESSIONS_ALCHEMY = 72601
BTWQUESTS_CHAIN_LEGION_PROFESSIONS_BLACKSMITHING = 72602
BTWQUESTS_CHAIN_LEGION_PROFESSIONS_ENCHANTING = 72603
BTWQUESTS_CHAIN_LEGION_PROFESSIONS_ENGINEERING = 72604
BTWQUESTS_CHAIN_LEGION_PROFESSIONS_INSCRIPTION = 72605
BTWQUESTS_CHAIN_LEGION_PROFESSIONS_JEWELCRAFTING = 72606
BTWQUESTS_CHAIN_LEGION_PROFESSIONS_LEATHERWORKING = 72607
BTWQUESTS_CHAIN_LEGION_PROFESSIONS_TAILORING = 72608
BTWQUESTS_CHAIN_LEGION_PROFESSIONS_UNDERLIGHT_ANGLER = 72609

BTWQUESTS_CHAIN_LEGION_ALLIED_RACES_LIGHTFORGED_DRAENEI = 72701
BTWQUESTS_CHAIN_LEGION_ALLIED_RACES_VOID_ELF = 72702
BTWQUESTS_CHAIN_LEGION_ALLIED_RACES_NIGHTBORNE = 72703
BTWQUESTS_CHAIN_LEGION_ALLIED_RACES_HIGHMOUNTAIN_TAUREN = 72704

BTWQUESTS_CHAIN_LEGION_CLASS_CAMPAIGN = 72801
BTWQUESTS_CHAIN_LEGION_CLASS_MOUNT = 72802
BTWQUESTS_CHAIN_LEGION_CLASS_FOLLOWER = 72803
BTWQUESTS_CHAIN_LEGION_CLASS_FOLLOWER2 = 72804

BTWQUESTS_CHAIN_LEGION_EPILOGUE = 7001
BTWQUESTS_CHAIN_LEGION_LOST_MAIL = 7002

BtWQuestsDatabase:AddExpansion(BTWQUESTS_EXPANSION_LEGION, {
    background = {
        texture = "Interface\\EncounterJournal\\UI-EJ-Legion"
    },
    image = {
        texture = "Interface\\AddOns\\BtWQuestsLegion\\UI-Expansion",
        texCoords = {0, 0.90625, 0, 0.8125}
    }
})

-- Broken Isles
BtWQuestsDatabase:AddMap(619, {
    type = "expansion",
    id = BTWQUESTS_EXPANSION_LEGION,
})

-- Dalaran
BtWQuestsDatabase:AddMapRecursive(627, {
    type = "expansion",
    id = BTWQUESTS_EXPANSION_LEGION,
})

-- Support code for handling artifact quest chains
local artifactQuests = {
    ["DEATHKNIGHT"] = {
        firstQuest = 40714, -- The quest right before selecting your first artifact
        {40722, 43965, 44402, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_DEATHKNIGHT_BLOOD},
        {40723, 43966, 44403, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_DEATHKNIGHT_FROST},
        {40724, 43967, 44404, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_DEATHKNIGHT_UNHOLY},
    },
    ["DEMONHUNTER"] = {
        firstQuest = 39047, -- There are 2 versions of this but they both get marked as completed and have the same name
        {40817, 44381, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_DEMONHUNTER_HAVOC},
        {40818, 44382, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_DEMONHUNTER_VENGEANCE},
    },
    ["DRUID"] = {
        firstQuest = 40645,
        {40781, 43976, 44432, 44444, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_DRUID_BALANCE},
        {40701, 43978, 44433, 44445, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_DRUID_FERAL},
        {40702, 43977, 44434, 44446, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_DRUID_GUARDIAN},
        {40703, 43979, 44436, 44447, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_DRUID_RESTORATION},
    },
    ["HUNTER"] = {
        firstQuest = 41415,
        {40621, 44045, 44367, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_HUNTER_BEASTMASTERY},
        {40620, 44046, 44368, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_HUNTER_MARKSMANSHIP},
        {40619, 44047, 44369, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_HUNTER_SURVIVAL},
    },
    ["MAGE"] = {
        firstQuest = 41036,
        {41079, 43442, 44307, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_MAGE_ARCANE},
        {41080, 43443, 44308, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_MAGE_FIRE},
        {41081, 43444, 44309, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_MAGE_FROST},
    },
    ["MONK"] = {
        firstQuest = 40236,
        {40640, 43970, 44427, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_MONK_BREWMASTER},
        {40638, 43971, 44429, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_MONK_WINDWALKER},
        {40639, 43972, 44428, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_MONK_MISTWEAVER},
    },
    ["PALADIN"] = {
        firstQuest = 38710,
        {40410, 44064, 44371, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_PALADIN_HOLY},
        {40411, 44065, 44372, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_PALADIN_PROTECTION},
        {40409, 44066, 44373, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_PALADIN_RETRIBUTION},
    },
    ["PRIEST"] = {
        firstQuest = 40705,
        {40709, 43941, 44409, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_PRIEST_DISCIPLINE},
        {40708, 43940, 44410, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_PRIEST_HOLY},
        {40707, 43939, 44408, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_PRIEST_SHADOW},
    },
    ["ROGUE"] = {
        firstQuest = 40839,
        {40842, 44036, 44376, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_ROGUE_ASSASSINATION},
        {40843, 44037, 44377, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_ROGUE_OUTLAW},
        {40844, 44038, 44378, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_ROGUE_SUBTLETY},
    },
    -- Shamans were handled differently so cant check the exact order they picked their artifacts in
    ["SHAMAN"] = {
        firstQuest = 39746,
        {41329, 43947, nil, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_SHAMAN_ELEMENTAL},
        {41328, 43946, nil, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_SHAMAN_ENHANCEMENT},
        {41330, 43948, nil, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_SHAMAN_RESTORATION},
    },
    ["WARLOCK"] = {
        firstQuest = 40729,
        {40686, 43981, 44388, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_WARLOCK_AFFLICTION},
        {40688, 43982, 44390, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_WARLOCK_DEMONOLOGY},
        {40687, 43983, 44389, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_WARLOCK_DESTRUCTION},
    },
    ["WARRIOR"] = {
        firstQuest = 39654,
        {40582, 43952, 44419, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_WARRIOR_ARMS},
        {40581, 43950, 44418, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_WARRIOR_FURY},
        {40580, 43953, 44420, chain = BTWQUESTS_CHAIN_LEGION_CLASSES_WARRIOR_PROTECTION},
    },
}
local function OtherSpecIndexes(class, specIndex)
    if class == "DEMONHUNTER" then
        return specIndex == 1 and 2 or 1
    elseif class == "DRUID" then
        if specIndex == 1 then
            return 2, 3, 4
        elseif specIndex == 2 then
            return 1, 3, 4
        elseif specIndex == 3 then
            return 1, 2, 4
        else
            return 1, 2, 3
        end
    else
        if specIndex == 1 then
            return 2, 3
        elseif specIndex == 2 then
            return 1, 3
        else
            return 1, 2
        end
    end
end
function BtWQuests.LegionArtifactPrerequisites(class, specIndex)
    local otherA, otherB, otherC = OtherSpecIndexes(class, specIndex)
    local classArtifactQuests = artifactQuests[class]
    if otherB == nil then
        return {
            {
                variations = {
                    { -- Havent done any yet
                        type = "level",
                        level = 98,
                        restrictions = {
                            type = "quest",
                            ids = {
                                classArtifactQuests[1][1],
                                classArtifactQuests[2][1],
                            },
                            equals = true,
                            count = 0,
                        },
                    },
                    { -- Didnt select specIndex first
                        type = "level",
                        level = 102,
                        restrictions = {
                            type = "quest",
                            id = classArtifactQuests[specIndex][1],
                            equals = true,
                            count = 0,
                        },
                    },
                    {
                        type = "level",
                        level = 98,
                    },
                },
            },
            {
                variations = {
                    { -- Chose otherA First
                        type = "chain",
                        id = classArtifactQuests[otherA].chain,
                        restrictions = {
                            type = "quest",
                            id = classArtifactQuests[otherA][1],
                        },
                    },
                    {
                        type = "quest",
                        id = classArtifactQuests.firstQuest,
                    },
                },
            },
        }
    elseif otherC == nil then
        return {
            {
                variations = {
                    { -- Havent done any yet
                        type = "level",
                        level = 98,
                        restrictions = {
                            type = "quest",
                            ids = {
                                classArtifactQuests[1][1],
                                classArtifactQuests[2][1],
                                classArtifactQuests[3][1],
                            },
                            equals = true,
                            count = 0,
                        },
                    },
                    { -- Didnt select specIndex first
                        type = "level",
                        level = 102,
                        restrictions = {
                            type = "quest",
                            id = classArtifactQuests[specIndex][1],
                            equals = true,
                            count = 0,
                        },
                    },
                    {
                        type = "level",
                        level = 98,
                    },
                },
            },
            {
                variations = {
                    { -- Chose otherA first and otherB second
                        type = "chain",
                        id = classArtifactQuests[otherB].chain,
                        restrictions = {
                            type = "quest",
                            ids = {classArtifactQuests[otherA][1], classArtifactQuests[otherB][2]},
                            count = 2,
                        },
                    },
                    { -- Chose otherB first and otherA second
                        type = "chain",
                        id = classArtifactQuests[otherA].chain,
                        restrictions = {
                            type = "quest",
                            ids = {classArtifactQuests[otherB][1], classArtifactQuests[otherA][2]},
                            count = 2,
                        },
                    },
                    { -- Chose otherA First
                        type = "chain",
                        id = classArtifactQuests[otherA].chain,
                        restrictions = {
                            type = "quest",
                            id = classArtifactQuests[otherA][1],
                        },
                    },
                    { -- Chose otherB First
                        type = "chain",
                        id = classArtifactQuests[otherB].chain,
                        restrictions = {
                            type = "quest",
                            id = classArtifactQuests[otherB][1],
                        },
                    },
                    {
                        type = "quest",
                        id = classArtifactQuests.firstQuest,
                    },
                },
            },
        }
    else
        return {
            {
                variations = {
                    { -- Havent done any yet
                        type = "level",
                        level = 98,
                        restrictions = {
                            type = "quest",
                            ids = {
                                classArtifactQuests[1][1],
                                classArtifactQuests[2][1],
                                classArtifactQuests[3][1],
                                classArtifactQuests[4][1],
                            },
                            equals = true,
                            count = 0,
                        },
                    },
                    { -- Didnt select specIndex first
                        type = "level",
                        level = 102,
                        restrictions = {
                            type = "quest",
                            id = classArtifactQuests[specIndex][1],
                            equals = true,
                            count = 0,
                        },
                    },
                    {
                        type = "level",
                        level = 98,
                    },
                },
            },
            {
                variations = {
                    { -- Chose otherA and otherB first or second, otherC third
                        type = "chain",
                        id = classArtifactQuests[otherC].chain,
                        restrictions = {
                            type = "quest",
                            ids = {
                                classArtifactQuests[otherA][1], classArtifactQuests[otherA][2],
                                classArtifactQuests[otherB][1], classArtifactQuests[otherB][2],
                                classArtifactQuests[otherC][3]
                            },
                            count = 3,
                        },
                    },
                    { -- Chose otherA and otherC first or second, otherB third
                        type = "chain",
                        id = classArtifactQuests[otherB].chain,
                        restrictions = {
                            type = "quest",
                            ids = {
                                classArtifactQuests[otherA][1], classArtifactQuests[otherA][2],
                                classArtifactQuests[otherC][1], classArtifactQuests[otherC][2],
                                classArtifactQuests[otherB][3]
                            },
                            count = 3,
                        },
                    },
                    { -- Chose otherB and otherC first or second, otherA third
                        type = "chain",
                        id = classArtifactQuests[otherA].chain,
                        restrictions = {
                            type = "quest",
                            ids = {
                                classArtifactQuests[otherB][1], classArtifactQuests[otherB][2],
                                classArtifactQuests[otherC][1], classArtifactQuests[otherC][2],
                                classArtifactQuests[otherA][3]
                            },
                            count = 3,
                        },
                    },

                    
                    { -- Chose otherA or otherB first and otherC second
                        type = "chain",
                        id = classArtifactQuests[otherC].chain,
                        restrictions = {
                            type = "quest",
                            ids = {
                                classArtifactQuests[otherA][1],
                                classArtifactQuests[otherB][1],
                                classArtifactQuests[otherC][2]
                            },
                            count = 2,
                        },
                    },
                    { -- Chose otherA or otherC first and otherB second
                        type = "chain",
                        id = classArtifactQuests[otherB].chain,
                        restrictions = {
                            type = "quest",
                            ids = {
                                classArtifactQuests[otherA][1],
                                classArtifactQuests[otherC][1],
                                classArtifactQuests[otherB][2]
                            },
                            count = 2,
                        },
                    },
                    { -- Chose otherB or otherC first and otherA second
                        type = "chain",
                        id = classArtifactQuests[otherA].chain,
                        restrictions = {
                            type = "quest",
                            ids = {
                                classArtifactQuests[otherB][1],
                                classArtifactQuests[otherC][1],
                                classArtifactQuests[otherA][2]
                            },
                            count = 2,
                        },
                    },


                    { -- Chose otherA First
                        type = "chain",
                        id = classArtifactQuests[otherA].chain,
                        restrictions = {
                            type = "quest",
                            id = classArtifactQuests[otherA][1],
                        },
                    },
                    { -- Chose otherB First
                        type = "chain",
                        id = classArtifactQuests[otherB].chain,
                        restrictions = {
                            type = "quest",
                            id = classArtifactQuests[otherB][1],
                        },
                    },
                    { -- Chose otherC First
                        type = "chain",
                        id = classArtifactQuests[otherC].chain,
                        restrictions = {
                            type = "quest",
                            id = classArtifactQuests[otherC][1],
                        },
                    },

                    {
                        type = "quest",
                        id = classArtifactQuests.firstQuest,
                    },
                },
            },
        }
    end
end
function BtWQuests.LegionArtifactActive(class, specIndex)
    return {
        type = "quest",
        ids = artifactQuests[class][specIndex],
    }
end
function BtWQuests.LegionArtifactNonSelected(class)
    local classArtifactQuests = artifactQuests[class]
    return {
        type = "quest",
        ids = {
            classArtifactQuests[1][1],
            classArtifactQuests[2][1],
            classArtifactQuests[3] and classArtifactQuests[3][1],
            classArtifactQuests[4] and classArtifactQuests[4][1],
        },
        equals = true,
        count = 0,
    }
end
