local _,ns = ...
ns.ADDUIEVENT("PLAYER_LOGIN", function()
if not AddUIDB.raidframebuff then return end

local helpbuff = {
[194384] = true,--救赎
[410089] = true,--先知先觉

}

local BigDotList = {
[440313] = true,--词缀不显示放大
--11.1第二赛季流血dot
[438975] = true,
[257544] = true,
[424414] = true, 
[441413] = true,
[424426] = true, 
[427621] = true, 
[427635] = true, 
[434773] = true, 
[439468] = true, 
[447272] = true, 
[453461] = true,
}

--WeakAuras\Libs\LibDispel
local function IsBleed(id)
	if LibStub and LibStub("LibDispel-1.0",true) and LibStub("LibDispel-1.0"):GetBleedList()[id] then
		return LibStub("LibDispel-1.0"):GetBleedList()[id]
	end
end

hooksecurefunc('CompactUnitFrame_UtilSetBuff', function(buffFrame, aura)
	local buffsize = buffFrame:GetParent():GetHeight()/3
	if helpbuff[aura.spellId] and aura.sourceUnit == "player" then
		buffFrame:SetSize(buffsize*1.3,buffsize*1.3)
		buffFrame.cooldown:GetRegions():SetFont(STANDARD_TEXT_FONT, buffFrame:GetHeight()/1.8, "OUTLINE")
		buffFrame.cooldown:SetHideCountdownNumbers(false)
	elseif aura.duration < 61 or aura.expirationTime - GetTime()<61 then 
		buffFrame:SetSize(buffsize*0.8,buffsize*0.8)
		buffFrame.cooldown:GetRegions():SetFont(STANDARD_TEXT_FONT, buffFrame:GetHeight()/1.8, nil)
		buffFrame.cooldown:SetHideCountdownNumbers(false)
	else
		buffFrame:SetSize(buffsize*0.8,buffsize*0.8)
		buffFrame.cooldown:SetHideCountdownNumbers(true)
		
	end
end)

hooksecurefunc('CompactUnitFrame_UtilSetDebuff', function(debuffFrame, aura)
	local debuffsize = debuffFrame:GetParent():GetHeight()/3
	if aura.dispelName or BigDotList[aura.spellId] or IsBleed(aura.spellId) then
		debuffFrame:SetSize(debuffsize*1.5,debuffsize*1.5)
		debuffFrame.cooldown:GetRegions():SetFont(STANDARD_TEXT_FONT, debuffFrame:GetHeight()/1.8, nil)
		if (aura.duration < 61 or aura.expirationTime - GetTime()<61) and aura.expirationTime - GetTime()>0 then 
			debuffFrame.cooldown:SetHideCountdownNumbers(false)
		else
			debuffFrame.cooldown:SetHideCountdownNumbers(true)
		end
	elseif (aura.duration < 61 or aura.expirationTime - GetTime()<61) and aura.expirationTime - GetTime()>0 then 
		debuffFrame:SetSize(debuffsize,debuffsize)
		debuffFrame.cooldown:SetHideCountdownNumbers(false)
		debuffFrame.cooldown:GetRegions():SetFont(STANDARD_TEXT_FONT, debuffFrame:GetHeight()/1.8, nil)
	else
		debuffFrame:SetSize(debuffsize*.8,debuffsize*.8)
		debuffFrame.cooldown:SetHideCountdownNumbers(true)
	end
end)

hooksecurefunc('CompactUnitFrame_UpdatePrivateAuras', function(frame)
	if frame:IsForbidden() then return end
	if not frame.unit then return end
	if not frame.PrivateAuraAnchors then
		return;
	end

	for _, self in ipairs(frame.PrivateAuraAnchors) do
		--CompactUnitPrivateAuraAnchorMixin:SetUnit(unit)
		if self.anchorID then
			C_UnitAuras.RemovePrivateAuraAnchor(self.anchorID);
			self.anchorID = nil;
		end

		if frame.displayedUnit then
			local iconAnchor =
			{
				point = "BOTTOMLEFT",
				relativeTo = self,
				relativePoint = "BOTTOMRIGHT",
				offsetX = 0,
				offsetY = 0,
			};

			local privateAnchorArgs = {};
			privateAnchorArgs.unitToken = frame.displayedUnit;
			privateAnchorArgs.auraIndex = self.auraIndex;
			privateAnchorArgs.parent = self;
			privateAnchorArgs.showCountdownFrame = true;
			privateAnchorArgs.showCountdownNumbers = true;
			privateAnchorArgs.iconInfo =
			{
				iconAnchor = iconAnchor,
				iconWidth = self:GetWidth()*1.5,
				iconHeight = self:GetHeight()*1.5,
			};
			privateAnchorArgs.durationAnchor = nil;

			self.anchorID = C_UnitAuras.AddPrivateAuraAnchor(privateAnchorArgs);
		end
	end

	local lastShownDebuff;
	for i = 3, 1, -1 do
		local debuff = frame["Debuff"..i];
		if debuff:IsShown() then
			lastShownDebuff = debuff;
			break;
		end
	end
	frame.PrivateAuraAnchor1:ClearAllPoints();
	frame.PrivateAuraAnchor2:ClearAllPoints();
	if lastShownDebuff then
		frame.PrivateAuraAnchor1:SetPoint("BOTTOMLEFT", lastShownDebuff, "BOTTOMRIGHT", -18, 0);
		frame.PrivateAuraAnchor2:SetPoint("BOTTOMLEFT", frame.PrivateAuraAnchor1, "BOTTOMRIGHT", 12, 0);
	else
		frame.PrivateAuraAnchor1:SetPoint("BOTTOMLEFT", frame.Debuff1, "BOTTOMLEFT", -18, 0);
		frame.PrivateAuraAnchor2:SetPoint("BOTTOMLEFT", frame.PrivateAuraAnchor1, "BOTTOMRIGHT", 12, 0);
	end
end)




end)