-- I need to fix preset window to use IDs later instead of index...
-- but for now, just convert the old index to new index

-- Pre-Blackwood index to id
local oldIndexToId = {
    [1] = {
        [ 1] = 68, -- Out of Sight
        [ 2] = 67, -- Fleet Phantom
        [ 3] = 76, -- Friends in Low Places
        [ 4] = 77, -- Infamous
        [ 5] = 80, -- Shadowstrike
        [ 6] = 90, -- Cutpurse's Art
        [ 7] = 84, -- Fade Away
        [ 8] = 78, -- Master Gatherer
        [ 9] = 79, -- Treasure Hunter
        [10] = 75, -- Steadfast Enchantment
        [11] = 85, -- Rationer
        [12] = 86, -- Liquid Efficiency
        [13] = 89, -- Angler's Instincts
        [14] = 88, -- Reel Technique
        [15] = 91, -- Homemaker
        [16] = 70, -- Wanderer
        [17] = 81, -- Plentiful Harvest
        [18] = 82, -- War Mount
        [19] = 92, -- Gifted Rider
        [20] = 83, -- Meticulous Disassembly
        [21] = 72, -- Inspiration Boost
        [22] = 71, -- Fortune's Favor
        [23] = 74, -- Gilded Fingers
        [24] = 69, -- Breakfall
        [25] = 87, -- Soul Reservoir
        [26] = 66, -- Steed's Blessing
        [27] = 65, -- Sustaining Shadows
        [28] = 1, -- Professional Upkeep
    },
    [2] = {
        [ 1] = 11, -- Precision
        [ 2] = 12, -- Fighting Finesse
        [ 3] = 108, -- Blessed
        [ 4] = 24, -- Soothing Tide
        [ 5] = 9, -- Rejuvenator
        [ 6] = 163, -- Foresight
        [ 7] = 29, -- Cleansing Revival
        [ 8] = 26, -- Focused Mending
        [ 9] = 28, -- Swift Renewal
        [10] = 10, -- Piercing
        [11] = 17, -- Flawless Ritual
        [12] = 21, -- War Mage
        [13] = 18, -- Battle Mastery
        [14] = 22, -- Mighty
        [15] = 25, -- Deadly Aim
        [16] = 23, -- Biting Aura
        [17] = 27, -- Thaumaturge
        [18] = 30, -- Reaving Blows
        [19] = 8, -- Wrathful Strikes
        [20] = 32, -- Occult Overload
        [21] = 31, -- Backstabber
        [22] = 6, -- Tireless Discipline
        [23] = 20, -- Quick Recovery
        [24] = 13, -- Resilience
        [25] = 14, -- Preparation
        [26] = 15, -- Elemental Aegis
        [27] = 16, -- Hardy
        [28] = 136, -- Enduring Resolve
        [29] = 160, -- Reinforced
        [30] = 162, -- Riposte
        [31] = 159, -- Bulwark
        [32] = 161, -- Last Stand
        [33] = 33, -- Cutting Defense
        [34] = 134, -- Duelist's Rebuff
        [35] = 133, -- Unassailable
        [36] = 99, -- Eldritch Insight
        [37] = 5, -- Endless Endurance
        [38] = 4, -- Untamed Aggression
        [39] = 3, -- Arcane Supremacy
    },
    [3] = {
        [ 1] = 38, -- Sprinter
        [ 2] = 62, -- Rousing Speed
        [ 3] = 42, -- Hasty
        [ 4] = 113, -- Hero's Vigor
        [ 5] = 45, -- Piercing Gaze
        [ 6] = 58, -- Tempered Soul
        [ 7] = 57, -- Survival Instincts
        [ 8] = 46, -- Bastion
        [ 9] = 61, -- Arcane Alacrity
        [10] = 56, -- Spirit Mastery
        [11] = 49, -- Strategic Reserve
        [12] = 53, -- Mystic Tenacity
        [13] = 63, -- Shield Master
        [14] = 48, -- Bloody Renewal
        [15] = 47, -- Siphoning Spells
        [16] = 39, -- Tireless Guardian
        [17] = 40, -- Savage Defense
        [18] = 50, -- Bashing Brutality
        [19] = 60, -- On Guard
        [20] = 44, -- Nimble Protector
        [21] = 43, -- Fortification
        [22] = 37, -- Tumbling
        [23] = 51, -- Expert Evasion
        [24] = 128, -- Defiance
        [25] = 52, -- Slippery
        [26] = 64, -- Unchained
        [27] = 59, -- Juggernaut
        [28] = 54, -- Peace of Mind
        [29] = 55, -- Hardened
        [30] = 35, -- Rejuvenation
        [31] = 34, -- Ironclad
        [32] = 2, -- Boundless Vitality
    },
}

-- Blackwood id to index
local newIdToIndex = {
    [68] = 1, -- Out of Sight
    [76] = 2, -- Friends in Low Places
    [84] = 3, -- Fade Away
    [90] = 4, -- Cutpurse's Art
    [80] = 5, -- Shadowstrike
    [78] = 6, -- Master Gatherer
    [79] = 7, -- Treasure Hunter
    [75] = 8, -- Steadfast Enchantment
    [85] = 9, -- Rationer
    [86] = 10, -- Liquid Efficiency
    [89] = 11, -- Angler's Instincts
    [88] = 12, -- Reel Technique
    [91] = 13, -- Homemaker
    [70] = 14, -- Wanderer
    [81] = 15, -- Plentiful Harvest
    [82] = 16, -- War Mount
    [92] = 17, -- Gifted Rider
    [83] = 18, -- Meticulous Disassembly
    [72] = 19, -- Inspiration Boost
    [71] = 20, -- Fortune's Favor
    [77] = 21, -- Infamous
    [67] = 22, -- Fleet Phantom
    [74] = 23, -- Gilded Fingers
    [69] = 24, -- Breakfall
    [87] = 25, -- Soul Reservoir
    [66] = 26, -- Steed's Blessing
    [65] = 27, -- Sustaining Shadows
    [1] = 28, -- Professional Upkeep

    [11] = 1, -- Precision
    [12] = 2, -- Fighting Finesse
    [108] = 3, -- Blessed
    [262] = 4, -- From the Brink
    [263] = 5, -- Enlivening Overflow
    [261] = 6, -- Hope Infusion
    [260] = 7, -- Salve of Renewal
    [24] = 8, -- Soothing Tide
    [9] = 9, -- Rejuvenator
    [163] = 10, -- Foresight
    [29] = 11, -- Cleansing Revival
    [26] = 12, -- Focused Mending
    [28] = 13, -- Swift Renewal
    [10] = 14, -- Piercing
    [264] = 15, -- Master-at-Arms
    [259] = 16, -- Weapons Expert
    [17] = 17, -- Flawless Ritual
    [21] = 18, -- War Mage
    [18] = 19, -- Battle Mastery
    [22] = 20, -- Mighty
    [25] = 21, -- Deadly Aim
    [23] = 22, -- Biting Aura
    [27] = 23, -- Thaumaturge
    [30] = 24, -- Reaving Blows
    [8] = 25, -- Wrathful Strikes
    [32] = 26, -- Occult Overload
    [31] = 27, -- Backstabber
    [6] = 28, -- Tireless Discipline
    [20] = 29, -- Quick Recovery
    [13] = 30, -- Resilience
    [14] = 31, -- Preparation
    [15] = 32, -- Elemental Aegis
    [16] = 33, -- Hardy
    [136] = 34, -- Enduring Resolve
    [160] = 35, -- Reinforced
    [162] = 36, -- Riposte
    [159] = 37, -- Bulwark
    [161] = 38, -- Last Stand
    [33] = 39, -- Cutting Defense
    [134] = 40, -- Duelist's Rebuff
    [133] = 41, -- Unassailable
    [99] = 42, -- Eldritch Insight
    [5] = 43, -- Endless Endurance
    [4] = 44, -- Untamed Aggression
    [3] = 45, -- Arcane Supremacy

    [38] = 1, -- Sprinter
    [42] = 2, -- Hasty
    [113] = 3, -- Hero's Vigor
    [63] = 4, -- Shield Master
    [46] = 5, -- Bastion
    [58] = 6, -- Tempered Soul
    [57] = 7, -- Survival Instincts
    [56] = 8, -- Spirit Mastery
    [61] = 9, -- Arcane Alacrity
    [45] = 10, -- Piercing Gaze
    [48] = 11, -- Bloody Renewal
    [49] = 12, -- Strategic Reserve
    [53] = 13, -- Mystic Tenacity
    [47] = 14, -- Siphoning Spells
    [62] = 15, -- Rousing Speed
    [39] = 16, -- Tireless Guardian
    [40] = 17, -- Savage Defense
    [50] = 18, -- Bashing Brutality
    [44] = 19, -- Nimble Protector
    [60] = 20, -- On Guard
    [43] = 21, -- Fortification
    [37] = 22, -- Tumbling
    [51] = 23, -- Expert Evasion
    [128] = 24, -- Defiance
    [52] = 25, -- Slippery
    [64] = 26, -- Unchained
    [59] = 27, -- Juggernaut
    [54] = 28, -- Peace of Mind
    [55] = 29, -- Hardened
    [35] = 30, -- Rejuvenation
    [34] = 31, -- Ironclad
    [2] = 32, -- Boundless Vitality
}

-- Blackwood index to id, should not need further conversions after this
local blackwoodIndexToId = {
    [1] = {
        [1] = 68, -- Out of Sight
        [2] = 76, -- Friends in Low Places
        [3] = 84, -- Fade Away
        [4] = 90, -- Cutpurse's Art
        [5] = 80, -- Shadowstrike
        [6] = 78, -- Master Gatherer
        [7] = 79, -- Treasure Hunter
        [8] = 75, -- Steadfast Enchantment
        [9] = 85, -- Rationer
        [10] = 86, -- Liquid Efficiency
        [11] = 89, -- Angler's Instincts
        [12] = 88, -- Reel Technique
        [13] = 91, -- Homemaker
        [14] = 70, -- Wanderer
        [15] = 81, -- Plentiful Harvest
        [16] = 82, -- War Mount
        [17] = 92, -- Gifted Rider
        [18] = 83, -- Meticulous Disassembly
        [19] = 72, -- Inspiration Boost
        [20] = 71, -- Fortune's Favor
        [21] = 77, -- Infamous
        [22] = 67, -- Fleet Phantom
        [23] = 74, -- Gilded Fingers
        [24] = 69, -- Breakfall
        [25] = 87, -- Soul Reservoir
        [26] = 66, -- Steed's Blessing
        [27] = 65, -- Sustaining Shadows
        [28] = 1, -- Professional Upkeep
    },
    [2] = {
        [1] = 11, -- Precision
        [2] = 12, -- Fighting Finesse
        [3] = 108, -- Blessed
        [4] = 262, -- From the Brink
        [5] = 263, -- Enlivening Overflow
        [6] = 261, -- Hope Infusion
        [7] = 260, -- Salve of Renewal
        [8] = 24, -- Soothing Tide
        [9] = 9, -- Rejuvenator
        [10] = 163, -- Foresight
        [11] = 29, -- Cleansing Revival
        [12] = 26, -- Focused Mending
        [13] = 28, -- Swift Renewal
        [14] = 10, -- Piercing
        [15] = 264, -- Master-at-Arms
        [16] = 259, -- Weapons Expert
        [17] = 17, -- Flawless Ritual
        [18] = 21, -- War Mage
        [19] = 18, -- Battle Mastery
        [20] = 22, -- Mighty
        [21] = 25, -- Deadly Aim
        [22] = 23, -- Biting Aura
        [23] = 27, -- Thaumaturge
        [24] = 30, -- Reaving Blows
        [25] = 8, -- Wrathful Strikes
        [26] = 32, -- Occult Overload
        [27] = 31, -- Backstabber
        [28] = 6, -- Tireless Discipline
        [29] = 20, -- Quick Recovery
        [30] = 13, -- Resilience
        [31] = 14, -- Preparation
        [32] = 15, -- Elemental Aegis
        [33] = 16, -- Hardy
        [34] = 136, -- Enduring Resolve
        [35] = 160, -- Reinforced
        [36] = 162, -- Riposte
        [37] = 159, -- Bulwark
        [38] = 161, -- Last Stand
        [39] = 33, -- Cutting Defense
        [40] = 134, -- Duelist's Rebuff
        [41] = 133, -- Unassailable
        [42] = 99, -- Eldritch Insight
        [43] = 5, -- Endless Endurance
        [44] = 4, -- Untamed Aggression
        [45] = 3, -- Arcane Supremacy
    },
    [3] = {
        [1] = 38, -- Sprinter
        [2] = 42, -- Hasty
        [3] = 113, -- Hero's Vigor
        [4] = 63, -- Shield Master
        [5] = 46, -- Bastion
        [6] = 58, -- Tempered Soul
        [7] = 57, -- Survival Instincts
        [8] = 56, -- Spirit Mastery
        [9] = 61, -- Arcane Alacrity
        [10] = 45, -- Piercing Gaze
        [11] = 48, -- Bloody Renewal
        [12] = 49, -- Strategic Reserve
        [13] = 53, -- Mystic Tenacity
        [14] = 47, -- Siphoning Spells
        [15] = 62, -- Rousing Speed
        [16] = 39, -- Tireless Guardian
        [17] = 40, -- Savage Defense
        [18] = 50, -- Bashing Brutality
        [19] = 44, -- Nimble Protector
        [20] = 60, -- On Guard
        [21] = 43, -- Fortification
        [22] = 37, -- Tumbling
        [23] = 51, -- Expert Evasion
        [24] = 128, -- Defiance
        [25] = 52, -- Slippery
        [26] = 64, -- Unchained
        [27] = 59, -- Juggernaut
        [28] = 54, -- Peace of Mind
        [29] = 55, -- Hardened
        [30] = 35, -- Rejuvenation
        [31] = 34, -- Ironclad
        [32] = 2, -- Boundless Vitality
    },
}

function DynamicCP.convertIndex(oldDisciplineIndex, oldIndex)
    local id = oldIndexToId[oldDisciplineIndex][oldIndex]
    return newIdToIndex[id]
end

function DynamicCP.convertBlackwoodToId(oldDisciplineIndex, oldSkillIndex)
    return blackwoodIndexToId[oldDisciplineIndex][oldSkillIndex]
end
