---@class addonTablePlatynator
local addonTable = select(2, ...)

local function GetColor(rgb)
  local color = CreateColorFromRGBHexString(rgb)
  return {r = color.r, g = color.g, b = color.b}
end

function addonTable.CustomiseDialog.AddAlphaToColors(details)
  for _, c in pairs(details.colors) do
    c.a = 1
  end

  return details
end

addonTable.CustomiseDialog.ColorsConfig = {
  ["tapped"] = {
    label = addonTable.Locales.TAPPED,
    default = {
      kind = "tapped",
      colors = {
        tapped = GetColor("6E6E6E"),
      }
    },
    entries = {
      {
        label = addonTable.Locales.TAPPED,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.tapped = value
        end,
        getter = function(details)
          return details.colors.tapped
        end,
      },
    },
  },
  ["target"] = {
    label = addonTable.Locales.TARGET,
    default = {
      kind = "target",
      colors = {
        target = GetColor("34edd1"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.TARGET,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.target = value
        end,
        getter = function(details)
          return details.colors.target
        end,
      },
    },
  },
  ["notTarget"] = {
    label = addonTable.Locales.NOT_TARGET,
    default = {
      kind = "notTarget",
      colors = {
        notTarget = GetColor("34edd1"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.NOT_TARGET,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.notTarget = value
        end,
        getter = function(details)
          return details.colors.notTarget
        end,
      },
    },
  },
  ["softTarget"] = {
    label = addonTable.Locales.SOFT_TARGET,
    default = {
      kind = "softTarget",
      colors = {
        softTarget = GetColor("34edd1"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.SOFT_TARGET_SENTENCE_CASE,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.softTarget = value
        end,
        getter = function(details)
          return details.colors.softTarget
        end,
      },
    },
  },
  ["focus"] = {
    label = addonTable.Locales.FOCUS,
    default = {
      kind = "focus",
      colors = {
        focus = GetColor("46ad32"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.FOCUS,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.focus = value
        end,
        getter = function(details)
          return details.colors.focus
        end,
      },
    },
  },
  ["threat"] = {
    label = addonTable.Locales.THREAT,
    default = {
      kind = "threat",
      colors = {
        safe = GetColor("0F96E6"),
        transition = GetColor("FFA000"),
        warning = GetColor("CC0000"),
        offtank = GetColor("0FAAC8"),
      },
      instancesOnly = false,
      combatOnly = true,
      tanksOnly = false,
      useSafeColor = false,
      useOffTankColor = false,
    },
    entries = {
      {
        label = addonTable.Locales.SAFE,
        kind = "colorPickerWithCheckbox",
        setter = function(details, value)
          details.colors.safe = value.color
          details.useSafeColor = value.enabled
        end,
        getter = function(details)
          return {color = details.colors.safe, enabled = details.useSafeColor}
        end,
      },
      {
        label = addonTable.Locales.OFFTANK,
        kind = "colorPickerWithCheckbox",
        setter = function(details, value)
          details.colors.offtank = value.color
          details.useOffTankColor = value.enabled
        end,
        getter = function(details)
          return {color = details.colors.offtank, enabled = details.useOffTankColor}
        end,
      },
      {
        label = addonTable.Locales.TRANSITION,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.transition = value
        end,
        getter = function(details)
          return details.colors.transition
        end,
      },
      {
        label = addonTable.Locales.WARNING,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.warning = value
        end,
        getter = function(details)
          return details.colors.warning
        end,
      },
      { kind = "spacer" },
      {
        label = addonTable.Locales.ONLY_APPLY_IN_COMBAT,
        kind = "checkbox",
        setter = function(details, value)
          details.combatOnly = value
        end,
        getter = function(details)
          return details.combatOnly
        end,
      },
      {
        label = addonTable.Locales.ONLY_APPLY_IN_INSTANCES,
        kind = "checkbox",
        setter = function(details, value)
          details.instancesOnly = value
        end,
        getter = function(details)
          return details.instancesOnly
        end,
      },
      {
        label = addonTable.Locales.ONLY_APPLY_WHEN_TANK,
        kind = "checkbox",
        setter = function(details, value)
          details.tanksOnly = value
        end,
        getter = function(details)
          return details.tanksOnly
        end,
      },
    },
  },
  ["rarity"] = {
    label = addonTable.Locales.RARITY,
    default = {
      kind = "rarity",
      colors = {
        rare = GetColor("d5d5d5"),
        rareElite = GetColor("f8de7e"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.RARE,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.rare = value
        end,
        getter = function(details)
          return details.colors.rare
        end,
      },
      {
        label = addonTable.Locales.RARE_ELITE,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.rareElite = value
        end,
        getter = function(details)
          return details.colors.rareElite
        end,
      },
    },
  },
  ["eliteType"] = {
    label = addonTable.Locales.ELITE_TYPE,
    default = {
      kind = "eliteType",
      colors = {
        boss = GetColor("bc1c00"),
        miniboss = GetColor("9000bc"),
        caster = GetColor("0074bc"),
        melee = GetColor("fcfcfc"),
        trivial = GetColor("b28e55"),
      },
      enabled = {
        boss = true,
        miniboss = true,
        caster = true,
        melee = true,
        trivial = true,
      },
      instancesOnly = true,
      applyCasterAlways = false,
    },
    entries = {
      {
        label = addonTable.Locales.BOSS,
        kind = "colorPickerWithCheckbox",
        setter = function(details, value)
          details.colors.boss = value.color
          details.enabled.boss = value.enabled
        end,
        getter = function(details)
          return {color = details.colors.boss, enabled = details.enabled.boss}
        end,
      },
      {
        label = addonTable.Locales.MINIBOSS,
        kind = "colorPickerWithCheckbox",
        setter = function(details, value)
          details.colors.miniboss = value.color
          details.enabled.miniboss = value.enabled
        end,
        getter = function(details)
          return {color = details.colors.miniboss, enabled = details.enabled.miniboss}
        end,
      },
      {
        label = addonTable.Locales.CASTER,
        kind = "colorPickerWithCheckbox",
        setter = function(details, value)
          details.colors.caster = value.color
          details.enabled.caster = value.enabled
        end,
        getter = function(details)
          return {color = details.colors.caster, enabled = details.enabled.caster}
        end,
      },
      {
        label = addonTable.Locales.MELEE,
        kind = "colorPickerWithCheckbox",
        setter = function(details, value)
          details.colors.melee = value.color
          details.enabled.melee = value.enabled
        end,
        getter = function(details)
          return {color = details.colors.melee, enabled = details.enabled.melee}
        end,
      },
      {
        label = addonTable.Locales.TRIVIAL,
        kind = "colorPickerWithCheckbox",
        setter = function(details, value)
          details.colors.trivial = value.color
          details.enabled.trivial = value.enabled
        end,
        getter = function(details)
          return {color = details.colors.trivial, enabled = details.enabled.trivial}
        end,
      },
      { kind = "spacer" },
      {
        label = addonTable.Locales.ONLY_APPLY_IN_INSTANCES,
        kind = "checkbox",
        setter = function(details, value)
          details.instancesOnly = value
        end,
        getter = function(details)
          return details.instancesOnly
        end,
      },
      {
        label = addonTable.Locales.USE_CASTER_COLOR_ON_NON_ELITES,
        kind = "checkbox",
        setter = function(details, value)
          details.applyCasterAlways = value
        end,
        getter = function(details)
          return details.applyCasterAlways
        end,
      },
    },
  },
  ["delveType"] = {
    label = addonTable.Locales.DELVE_TYPE,
    default = {
      kind = "delveType",
      colors = {
        boss = GetColor("bc1c00"),
        elite = GetColor("9000bc"),
        rare = GetColor("bc5389"),
        caster = GetColor("0074bc"),
        melee = GetColor("fcfcfc"),
        trivial = GetColor("b28e55"),
      },
      enabled = {
        boss = true,
        elite = true,
        rare = true,
        caster = true,
        melee = true,
        trivial = true,
      },
      delves = true,
      outsideInstances = false,
    },
    entries = {
      {
        label = addonTable.Locales.BOSS,
        kind = "colorPickerWithCheckbox",
        setter = function(details, value)
          details.colors.boss = value.color
          details.enabled.boss = value.enabled
        end,
        getter = function(details)
          return {color = details.colors.boss, enabled = details.enabled.boss}
        end,
      },
      {
        label = addonTable.Locales.ELITE,
        kind = "colorPickerWithCheckbox",
        setter = function(details, value)
          details.colors.elite = value.color
          details.enabled.elite = value.enabled
        end,
        getter = function(details)
          return {color = details.colors.elite, enabled = details.enabled.elite}
        end,
      },
      {
        label = addonTable.Locales.RARE,
        kind = "colorPickerWithCheckbox",
        setter = function(details, value)
          details.colors.rare = value.color
          details.enabled.rare = value.enabled
        end,
        getter = function(details)
          return {color = details.colors.rare, enabled = details.enabled.rare}
        end,
      },
      {
        label = addonTable.Locales.CASTER,
        kind = "colorPickerWithCheckbox",
        setter = function(details, value)
          details.colors.caster = value.color
          details.enabled.caster = value.enabled
        end,
        getter = function(details)
          return {color = details.colors.caster, enabled = details.enabled.caster}
        end,
      },
      {
        label = addonTable.Locales.MELEE,
        kind = "colorPickerWithCheckbox",
        setter = function(details, value)
          details.colors.melee = value.color
          details.enabled.melee = value.enabled
        end,
        getter = function(details)
          return {color = details.colors.melee, enabled = details.enabled.melee}
        end,
      },
      {
        label = addonTable.Locales.TRIVIAL,
        kind = "colorPickerWithCheckbox",
        setter = function(details, value)
          details.colors.trivial = value.color
          details.enabled.trivial = value.enabled
        end,
        getter = function(details)
          return {color = details.colors.trivial, enabled = details.enabled.trivial}
        end,
      },
      {
        label = addonTable.Locales.USE_IN_DELVES,
        kind = "checkbox",
        setter = function(details, value)
          details.delves = value
        end,
        getter = function(details)
          return details.delves
        end,
      },
      {
        label = addonTable.Locales.USE_OUTSIDE_INSTANCES,
        kind = "checkbox",
        setter = function(details, value)
          details.outsideInstances = value
        end,
        getter = function(details)
          return details.outsideInstances
        end,
      },
    },
  },
  ["quest"] = {
    label = addonTable.Locales.QUEST,
    default = {
      kind = "quest",
      colors = {
        friendly = GetColor("E0FF00"),
        neutral = GetColor("FFEC4A"),
        hostile = GetColor("FFB963"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.FRIENDLY,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.friendly = value
        end,
        getter = function(details)
          return details.colors.friendly
        end,
      },
      {
        label = addonTable.Locales.NEUTRAL,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.neutral = value
        end,
        getter = function(details)
          return details.colors.neutral
        end,
      },
      {
        label = addonTable.Locales.HOSTILE,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.hostile = value
        end,
        getter = function(details)
          return details.colors.hostile
        end,
      },
    },
  },
  ["guild"] = {
    label = addonTable.Locales.GUILD,
    default = {
      kind = "guild",
      colors = {
        guild = GetColor("3bbc14")
      },
    },
    entries = {
      {
        label = addonTable.Locales.GUILD,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.guild = value
        end,
        getter = function(details)
          return details.colors.guild
        end,
      },
    },
  },
  ["classColors"] = {
    label = addonTable.Locales.CLASS_COLORS,
    default = {
      kind = "classColors",
      colors = {},
    },
    entries = {},
  },
  ["reaction"] = {
    label = addonTable.Locales.REACTION,
    default = {
      kind = "reaction",
      colors = {
        friendly = GetColor("00FF00"),
        neutral = GetColor("FFFF00"),
        unfriendly = GetColor("ff8100"),
        hostile = GetColor("FF0000"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.FRIENDLY,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.friendly = value
        end,
        getter = function(details)
          return details.colors.friendly
        end,
      },
      {
        label = addonTable.Locales.NEUTRAL,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.neutral = value
        end,
        getter = function(details)
          return details.colors.neutral
        end,
      },
      {
        label = addonTable.Locales.UNFRIENDLY,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.unfriendly = value
        end,
        getter = function(details)
          return details.colors.unfriendly
        end,
      },
      {
        label = addonTable.Locales.HOSTILE,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.hostile = value
        end,
        getter = function(details)
          return details.colors.hostile
        end,
      },
    },
  },
  ["difficulty"] = {
    label = addonTable.Locales.DIFFICULTY,
    default = {
      kind = "difficulty",
      colors = {
        impossible = {r = 1.00, g = 0.10, b = 0.10},
        verydifficult = {r = 1.00, g = 0.50, b = 0.25},
        difficult = {r = 1.00, g = 0.82, b = 0.00},
        standard = {r = 0.25, g = 0.75, b = 0.25},
        trivial = {r = 0.50, g = 0.50, b = 0.50},
      },
    },
    entries = {
      {
        label = addonTable.Locales.TRIVIAL,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.trivial = value
        end,
        getter = function(details)
          return details.colors.trivial
        end,
      },
      {
        label = addonTable.Locales.STANDARD,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.standard = value
        end,
        getter = function(details)
          return details.colors.standard
        end,
      },
      {
        label = addonTable.Locales.DIFFICULT,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.difficult = value
        end,
        getter = function(details)
          return details.colors.difficult
        end,
      },
      {
        label = addonTable.Locales.VERY_DIFFICULT,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.verydifficult = value
        end,
        getter = function(details)
          return details.colors.verydifficult
        end,
      },
      {
        label = addonTable.Locales.IMPOSSIBLE,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.impossible = value
        end,
        getter = function(details)
          return details.colors.impossible
        end,
      },
    },
  },
  ["fixed"] = {
    label = addonTable.Locales.FIXED,
    default = {
      kind = "fixed",
      colors = {
        fixed = GetColor("FFFFFF"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.FIXED,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.fixed = value
        end,
        getter = function(details)
          return details.colors.fixed
        end,
      },
    },
  },
  ["interruptReady"] = {
    label = addonTable.Locales.INTERRUPT_READY,
    default = {
      kind = "interruptReady",
      colors = {
        ready = GetColor("00FF00"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.READY,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.ready = value
        end,
        getter = function(details)
          return details.colors.ready
        end,
      },
    },
  },
  ["interruptNotReady"] = {
    label = addonTable.Locales.INTERRUPT_NOT_READY,
    default = {
      kind = "interruptNotReady",
      colors = {
        notReady = GetColor("FFFFFF"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.NOT_READY,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.notReady = value
        end,
        getter = function(details)
          return details.colors.notReady
        end,
      },
    },
  },
  ["castTargetsYou"] = {
    label = addonTable.Locales.CAST_TARGETS_YOU,
    default = {
      kind = "castTargetsYou",
      colors = {
        targeted = GetColor("FF0000"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.TARGETED,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.targeted = value
        end,
        getter = function(details)
          return details.colors.targeted
        end,
      },
    },
  },
  ["importantCast"] = {
    label = addonTable.Locales.IMPORTANT_CAST,
    default = {
      kind = "importantCast",
      colors = {
        cast = GetColor("FF1827"),
        channel = GetColor("0A43FF"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.CAST,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.cast = value
        end,
        getter = function(details)
          return details.colors.cast
        end,
      },
      {
        label = addonTable.Locales.CHANNEL,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.channel = value
        end,
        getter = function(details)
          return details.colors.channel
        end,
      },
    }
  },
  ["cast"] = {
    label = addonTable.Locales.CASTING,
    default = {
      kind = "cast",
      colors = {
        cast = GetColor("FC8C00"),
        channel = GetColor("3EC637"),
        interrupted = GetColor("FC36E0"),
        empowered = GetColor("05c666"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.CAST,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.cast = value
        end,
        getter = function(details)
          return details.colors.cast
        end,
      },
      {
        label = addonTable.Locales.CHANNEL,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.channel = value
        end,
        getter = function(details)
          return details.colors.channel
        end,
      },
      {
        label = addonTable.Locales.EMPOWERED,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.empowered = value
        end,
        getter = function(details)
          return details.colors.empowered
        end,
      },
      {
        label = addonTable.Locales.INTERRUPTED_CAST,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.interrupted = value
        end,
        getter = function(details)
          return details.colors.interrupted
        end,
      },
    }
  },
  ["uninterruptableCast"] = {
    label = addonTable.Locales.UNINTERRUPTABLE_CAST,
    default = {
      kind = "uninterruptableCast",
      colors = {
        uninterruptable = GetColor("83C0C3"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.UNINTERRUPTABLE,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.uninterruptable = value
        end,
        getter = function(details)
          return details.colors.uninterruptable
        end,
      },
    }
  },
  ["execute"] = {
    label = addonTable.Locales.EXECUTE_CLASSIC,
    default = {
      kind = "execute",
      colors = {
        execute = GetColor("D1D1D1"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.EXECUTE,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.execute = value
        end,
        getter = function(details)
          return details.colors.execute
        end,
      },
    }
  },
  ["mouseover"] = {
    label = addonTable.Locales.MOUSEOVER,
    default = {
      kind = "mouseover",
      colors = {
        mouseover = GetColor("B15FEB"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.MOUSEOVER,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.mouseover = value
        end,
        getter = function(details)
          return details.colors.mouseover
        end,
      },
      { kind = "spacer" },
      {
        label = addonTable.Locales.INCLUDE_TARGET,
        kind = "checkbox",
        setter = function(details, value)
          details.includeTarget = value
        end,
        getter = function(details)
          return details.includeTarget
        end,
      },
    }
  },
  ["inCombat"] = {
    label = addonTable.Locales.IN_COMBAT_WITH,
    default = {
      kind = "inCombat",
      colors = {
        inCombat = GetColor("7c1eff"),
      },
    },
    entries = {
      {
        label = addonTable.Locales.IN_COMBAT_WITH,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.inCombat = value
        end,
        getter = function(details)
          return details.colors.inCombat
        end,
      },
    }
  },
  ["energy"] = {
    label = addonTable.Locales.ENERGY,
    default = {
      kind = "energy",
      colors = {
        energy = GetColor("fff700"),
        mana = GetColor("00aaff"),
        rage = GetColor("ff5500"),
      }
    },
    entries = {
      {
        label = addonTable.Locales.ENERGY,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.energy = value
        end,
        getter = function(details)
          return details.colors.energy
        end,
      },
      {
        label = addonTable.Locales.RAGE,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.rage = value
        end,
        getter = function(details)
          return details.colors.rage
        end,
      },
      {
        label = addonTable.Locales.MANA,
        kind = "colorPicker",
        setter = function(details, value)
          details.colors.mana = value
        end,
        getter = function(details)
          return details.colors.mana
        end,
      },
    },
  },
}

addonTable.CustomiseDialog.ColorsConfigOrder = {
  "tapped",
  "target",
  "notTarget",
  "softTarget",
  "focus",
  "mouseover",
  "threat",
  "inCombat",
  "delveType",
  "eliteType",
  "rarity",
  "quest",
  "guild",
  "classColors",
  "difficulty",
  "execute",
  "reaction",
  "interruptReady",
  "interruptNotReady",
  "castTargetsYou",
  "importantCast",
  "uninterruptableCast",
  "cast",
  "fixed",
}
