
  local parent, ns = ...
  local oUF = ns.oUF or oUF
   
  local function Update(self, event, unit)
    if(self.unit ~= unit) then return end
    
    local ta = self.TotalAbsorb
    if(ta.PreUpdate) then ta:PreUpdate(unit) end

    -- SECRET-SAFE: UnitGetTotalAbsorbs and UnitHealthMax return secret values.
    -- Pass them directly to C-side SetMinMaxValues/SetValue only.
    -- Use a scratch FontString to read back a plain string for the > 0 check.
    local absorbs = UnitGetTotalAbsorbs(unit)
    local maxHP = UnitHealthMax(unit)

    if absorbs == nil or maxHP == nil then
      ta:SetValue(0)
      ta:Hide()
      return
    end

    ta:SetMinMaxValues(0, maxHP)
    ta:SetValue(absorbs)

    -- Check if absorbs > 0 without Lua arithmetic on secret value:
    -- Render to a hidden scratch FontString, read back as plain text.
    local scratch = ta._absorbScratch
    if not scratch then
      local sf = CreateFrame("Frame", nil, UIParent)
      sf:SetSize(1, 1); sf:Hide()
      scratch = sf:CreateFontString(nil, "ARTWORK")
      scratch:SetFont("Fonts\\FRIZQT__.TTF", 10)
      ta._absorbScratch = scratch
    end
    scratch:SetFormattedText("%.0f", absorbs)
    local absorbStr = scratch:GetText()
    local absorbNum = absorbStr and tonumber(absorbStr) or 0

    if absorbNum > 0 then
      ta:Show()
    else
      ta:Hide()
    end
   
    if(ta.PostUpdate) then
      return ta:PostUpdate(unit, absorbs, maxHP)
    end
  end
   
  local function Path(self, ...)
    return (self.TotalAbsorb.Override or Update) (self, ...)
  end
   
  local ForceUpdate = function(element)
    return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
  end
   
  local function Enable(self)
    if rOrbs:CheckClientVersion(WOW_PROJECT_CLASSIC) then return end
    local ta = self.TotalAbsorb
    if(ta) then
      ta.__owner = self
      ta.ForceUpdate = ForceUpdate
   
      self:RegisterEvent('UNIT_ABSORB_AMOUNT_CHANGED', Path)
      self:RegisterEvent('UNIT_MAXHEALTH', Path)
   
      return true
    end
  end
   
  local function Disable(self)
    if rOrbs:CheckClientVersion(WOW_PROJECT_CLASSIC) then return end
    local ta = self.TotalAbsorb
    if(ta) then
      self:UnregisterEvent('UNIT_ABSORB_AMOUNT_CHANGED', Path)
      self:UnregisterEvent('UNIT_MAXHEALTH', Path)
    end
  end
   
  oUF:AddElement('TotalAbsorb', Path, Enable, Disable)
