local SSA, Auras = unpack(select(2,...))

-- Cache Global Addon Variables
local AncestralProtectionTotemBar = SSA.AncestralProtectionTotemBar

-- Initialize Data Variables
AncestralProtectionTotemBar.spellID = 207399
AncestralProtectionTotemBar.icon = 136080
AncestralProtectionTotemBar.start = 0
AncestralProtectionTotemBar.duration = 30
AncestralProtectionTotemBar.elapsed = 0
AncestralProtectionTotemBar.condition = function() 
	local _,_,_,selected = GetTalentInfo(4,3,1)
	
	return selected
end

AncestralProtectionTotemBar:SetScript('OnUpdate',function(self,elapsed)
	if (not Auras.db.char.isFirstEverLoad) then
		if (Auras:RefreshRateHandler(0.1,self.elapsed)) then
			self.elapsed = 0
			
			if ((Auras:CharacterCheck(self,3) and self.condition()) or Auras:IsPreviewingTimerbar(self)) then
				Auras:RunTimerBarCode(self,spec,db)
			end
		else
			self.elapsed = self.elapsed + elapsed
		end
	end
end)

AncestralProtectionTotemBar:SetScript("OnEvent",function(self,event)
	if (event ~= "COMBAT_LOG_EVENT_UNFILTERED") then
		return
	end
	
	if ((Auras:CharacterCheck(self,3) and self.condition()) or Auras:IsPreviewingTimerbar(self)) then
		Auras:RunTimerEvent_Totem(self,CombatLogGetCurrentEventInfo())
	end
end)