local MER, W, WF, F, E, I, V, P, G, L = unpack(ElvUI_MerathilisUI)
local module = MER:GetModule("MER_Profiles") ---@class Profiles
local Splash = MER:GetModule("MER_SplashScreen") ---@class SplashScreen

local _G = _G

function module:LoadBetterCooldownManagerProfile()
	local BCDMG = _G.BCDMG

	local main =
		[[!BCDM_TV1A3jQox4FrTlfV)rqrLvvWdbQtpFGwQMQSouOVq80X(H53(BUWLeeS0P9OZSgxhpDGqY(w2zVt2pGtthlhWlrHp55dlCjaUkmyTB0(fHVcJuCJinQg4(OpCTJIdyM7(WDiCJ6nDakgwwgZD0LWxoC087ZgJElhGLXch92o6nC07q6nYbmm0pCxKYEaYfbjutXD1)SjkCxWA2Jy0DC7(nA1V1GUnK6i1h)Z5PR60HWMQEsRkFs7ewp1Bn0YB1)e78iw0GFhXRx4MghgGaEVbXDhRnGTHVIfYnBGrJwaipxqVhQQBPAs170lBrvuQ6MPOSEt(jr)BlMSGF(4i3NHauKlYftAJLoGLERrBXDSrJCZ0qF3yQ8cE19fRWuR7IWypKxya5jtHEB2IW0TfN19f4kYZM7IwTLsxJNKdwTnmIyYzJyPhAlwFwe59mEUwC8w7FHo5momcEsMCWgKjWayKRpzsHXS4dDgPTyyplXS24APbulBJRBlLyCZMUbwYtMGNxs6k3mqJR7miRF69YiwN(jeRtA)6L3pGkaOQpu9Et1HtLnNOMpS0rLs8CA3wy(VX1d6M0N2CckJCJUFOXCfJ7xyOPBbYvqrQNpm9MDZ6uk5tf7b9Z72GSEniLuds6w38E1jRx96LsmPKUj1IJP5KtkvW6FGEdmT1)ygQMnRsJBCDFr6sSnaB9PgZUR4ys1FjorzSPbWQ8oYnhOmZWyuHjlPohsoIOkLBRAkW2bsh49HNuNzyBsL55gJunLTuljMGOiptBY0kezXoovv(27QLuJ7CYc901r6nfhys8le5orkYrqe5YseFYd6kSsdpTjLfUd3MWZYFqZ8vF9sxklLUizWasx6N3JmpJuxtAhA2VGa3LtQA2kB4T5vuSxLGBxHvzj2mskbAyiYfKy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84IlId9H9)GOiLaU6rIquca2DBK6IWbh(j1SGeqfxef63ZcivllWph81DlyyiYZj2WGkcztbOoR8ZW8KTE(mKi5S9z1E0yoV3hN8hb(2J)n5Y)PgNoU0pkxE41R)NIBgvs(WPXI7g)WhzHKSJHtO3Si5Z4(rAfVEX3D)SWnEbZHXXUBO0rOF0u9GrWNC35tcZT2dnpCnKRw7MUERz2u2bGWB)XBLdaNolm6zmZXxnFpAlRTzJnX)dIzzmc0cIrUbRGJ8E6jVvyoSp9tmRI1j)0VejFfUUNULJFq3SJ8YvC(EJpoTVzlKEC4lrYJxCpuo(34VZz)Lc5N9Kd)x9sH8L8k3W(pN)p]]

	BCDMG:ImportBCDM(main, I.ProfileNames.Default)
end

function module:ApplyCooldownManagerProfile()
	if not E:IsAddOnEnabled("BetterCooldownManager") then
		WF.Developer.LogWarning("BetterCooldownManager is not enabled. Will not apply profile.")
		return
	end

	Splash:Wrap("Applying BetterCooldownManager Profile ...", function()
		local profileName = I.ProfileNames.Default

		self:LoadBetterCooldownManagerProfile()

		E:UpdateMedia()
		E:UpdateFontTemplates()

		-- execute elvui update, callback later
		self:ExecuteElvUIUpdate(function()
			Splash:Hide()

			F.Event.TriggerEvent("MER.DatabaseUpdate")
		end, true)
	end, true, "BetterCooldownManager")
end
