---@type Orbit
local Orbit = Orbit
local L = Orbit.L

local Plugin = Orbit:RegisterPlugin("Target Power", "Orbit_TargetPower", {
    displayName = L.PLG_NAME_TARGET_POWER,
    liveToggle = true,
    canvasMode = true,
    defaults = Orbit.UnitPowerBarMixin.sharedDefaults,
})

Mixin(Plugin, Orbit.UnitPowerBarMixin)

function Plugin:AddSettings(dialog, systemFrame)
    self:AddPowerBarSettings(dialog, systemFrame)
end

function Plugin:OnLoad()
    self:CreatePowerBarPlugin({
        unit = "target",
        frameName = "TargetPower",
        displayName = "Target Power",
        parentPlugin = "Orbit_TargetFrame",
        parentIndex = Enum.EditModeUnitFrameSystemIndices.Target,
        enableKey = "EnableTargetPower",
        changeEvent = "PLAYER_TARGET_CHANGED",
        yOffset = -180,
        textAnchor = { point = "CENTER", relativePoint = "CENTER", x = 0, y = 2 },
    })
    Orbit.EventBus:On("ORBIT_TARGET_SETTINGS_CHANGED", function() self:UpdateVisibility() end, self)
end
