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

local _G = _G

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

	local main =
		"!BCDM_TVrB3jQoZFrDpkQT6hbfvovbFiy7T3pW2unQCwk0hiE76(H(B)MxiqabL2URT7D9SD3fsMmZK51KzOUnDDCbpffUYZhrFeGwegSegTBw4ZOinyeDq9a4d(OLUp4cMcXl2CR3s8gRvQbl2eg5Q5cgggHwhfUnyz)q)WT0fz20Dy7UnA1TvVlBO0rPBhLEURUOthxtLkNPvLZ0MIqSlqdU4BNgk5G(oUWMFyyag49debcfIOAt4ZamC9Au0Gza68tG7c3I5SeOVUPJUnLhsFSLRzdgbAqjG8gG(Jc7FBXjpUa20SCCSMYWMw)bt)AQ6HSaGJ1Se0A2jH7hgbFebWrqmKGjRBDbmLgbbnAiiT2U((W4ykNdEg(KtOaPZcJ9WEHb0zg7Te54T4BmWeRd8eAbBsK36nycjBjE(wp8gcxplY7rIreFgXQC29eIATKIfmethGWUJqbOiOpvEtfYXIhCbx8Y96F)PiuC8ZWD8bh6dx7cSM7mXWuNQhGldFwwvrOH1QvXi8DUMx0u8YFXvlYs9gmPEdjndx2NQDI33NGnI18jcu8fILddlFPTsI6l1gc4OoAerZltnUoUXx60lfoZRsrwNUjiRJaURKGR5LPa2mboby96Mbw7CgvK5UmbO2s8MoaOB2x)R269hRApspJfeCGGrZwdhYbFTV1unRVoZYW0bKjhYVWmsz2lfMEcy6LG8lZGQtkuxDLyZPKaMsljHqg6ueuS7(8Q9CZx1MZSzZQ2kn(s384LUPbZnhBn5UIRrOpuKyLH2waNYbusHOnXYAqbnNsN9rhLvvYKvnZr2Ek7z9r0wtSMBZ45Pwd0TvD0ljQtEwEIXOXvWY5bCSU6n3vlUMaCsybHFKzZ8lmXpetFlpgLqiMcY(UVCvyMJ0vcVsfHXFVEuq6Mbr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)HhyLA6jF4UjHR9cMIIJHRz245GJTNbdqRGB9P5nx6HNgUej1YeBO3sohXoGb93qlcjbu1vuO3c6tt3H3WFAYqBY)H5DI3kWiigddwGg4TAL3ccf2j6ntf)QAFo6BzrFpquPpUqLN2ucLh99HZMhAvPV(Sen9Twa1Fvrt)PKRI)h3)9"

	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
