if select(2, ...).IS_LEGACY_CLIENT then return end -- HET-LEGACY-1207: no-op once Legacy1207 is deleted
-------------------------------------------------------------------------------
-- SpatialParadox.lua
-- 12.1: tracked as a buff GROUP on the player via the tracker's
-- AuraContainer slot, mirroring Time Spiral. Spatial Paradox can land as one
-- of two auras — the caster's own cast (406732) or the linked-ally buff
-- (406789) — and a Preservation Evoker can briefly have BOTH at once. They
-- share the same name and duration, so they collapse into ONE singular-group
-- entry (one checkbox, both IDs tracked); the single AuraContainer slot shows
-- exactly one matching aura, so when both are present only the first the
-- engine surfaces is displayed (they tie on duration, so it's stable).
--
-- PTR-VERIFY (buff IDs): 406732 is the Evoker cast. 406789 is the suspected
-- ally-side aura — verify OUT OF COMBAT on PTR (aura data is readable OOC)
-- with a friendly Evoker; if the ally buff carries a different spellID, fix it
-- in SPELLS below.
-------------------------------------------------------------------------------
local addonName, ns = ...

local DISPLAY_ICON_SPELL = 406732

-- Singular group like Time Spiral: one entry, both Spatial Paradox buff IDs.
-- key is the first (locale-stable) ID; both ids drive the aura filter and the
-- sound registration.
local SPELLS = {
    {
        key  = 406732,
        name = "Spatial Paradox",
        ids  = { 406732, 406789 }, -- Self cast + linked-ally buff (PTR-VERIFY 406789)
    },
}

local allIDs = {}
local defaultSpells = {}
for _, sp in ipairs(SPELLS) do
    defaultSpells[sp.key] = true
    for _, id in ipairs(sp.ids) do
        allIDs[#allIDs + 1] = id
    end
end

ns.RegisterTracker("spatial", {
    dbPrefix     = "",
    displaySpell = DISPLAY_ICON_SPELL, -- Spatial Paradox icon for previews/tree
    buffSpellIDs = allIDs,
    spellList    = SPELLS,
    -- Only one Spatial Paradox display at a time (both IDs share a name and
    -- duration; a single slot shows one) — singular, so Tracker Type labels
    -- stay Icon/Bar rather than pluralizing to Icons/Bars.
    singleActive = true,
    -- Bundled voice clip (Media\Voice_Spatial.ogg); no per-spell name clips.
    hasVoiceClips = false,

    voiceClip = "Interface\\AddOns\\BuzzardAuras\\Media\\Voice_Spatial.ogg",

    -- Group-level voice callout (Time Spiral pattern): a Sound element in
    -- "Voice" mode plays this fixed clip on every tracked ID. A single option
    -- (no user choice) whose `file` maps to Media\Voice_Spatial.ogg — this is
    -- what makes the spellList sound path resolve to the fixed clip rather than
    -- looking for per-spell name clips (which this tracker has none of).
    voiceOptions = {
        { value = "Spatial", name = "Spatial Paradox", file = "Spatial" },
    },

    frameSuffix  = "SpatialParadox",
    label        = "Spatial Paradox",
    defaultPos   = { "CENTER", "CENTER", 0, 0 },

    -- 12.1 preset (see Innervate for the sparse-table rationale).
    -- Circle #E6BF1A @ 85%.
    preset = {
        { style = "circle", circleRadius = 60, ringTexture = "Ring_20px",
          color = { 0.901961, 0.749020, 0.101961, 0.85 } },
        { style = "sound", soundType = "voice", soundChannel = "Master" },
    },

    defaults = {
        enabled        = true,
        barCircleColor = { 0.9, 0.75, 0.1, 1.0 },
        spells         = defaultSpells,
    },

    -- Applicable on every spec — the aura filter simply never matches if the
    -- buff can't land on you. (The old "Enable for DPS Evoker" opt-out was
    -- removed on 12.1; Conditions → Spec covers that if a user wants it.)
})

ns.DISPLAY_ICON_SPELL = DISPLAY_ICON_SPELL
