local _, core     = ...;
WC_Lib            = {};
WC_Lib.structures = {};

WC_Lib.structures.CurrentFilters = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true}; -- Obtenu, Manquant, HF, Mount, Pet, Transmog, Easy, Medium, Hard, Neutral, Ally, Horde, Classic, BC, WOTLK, Cata, MOP, WOD, Legion, BFA, Shadow

WC_Lib.structures.tableAccents      = {};
WC_Lib.structures.tableAccents["À"] = "A";
WC_Lib.structures.tableAccents["Á"] = "A";
WC_Lib.structures.tableAccents["Â"] = "A";
WC_Lib.structures.tableAccents["Ã"] = "A";
WC_Lib.structures.tableAccents["Ä"] = "A";
WC_Lib.structures.tableAccents["Ç"] = "C";
WC_Lib.structures.tableAccents["È"] = "E";
WC_Lib.structures.tableAccents["É"] = "E";
WC_Lib.structures.tableAccents["Ê"] = "E";
WC_Lib.structures.tableAccents["Ë"] = "E";
WC_Lib.structures.tableAccents["Ì"] = "I";
WC_Lib.structures.tableAccents["Í"] = "I";
WC_Lib.structures.tableAccents["Î"] = "I";
WC_Lib.structures.tableAccents["Ï"] = "I";
WC_Lib.structures.tableAccents["Ñ"] = "N";
WC_Lib.structures.tableAccents["Ò"] = "O";
WC_Lib.structures.tableAccents["Ó"] = "O";
WC_Lib.structures.tableAccents["Ô"] = "O";
WC_Lib.structures.tableAccents["Õ"] = "O";
WC_Lib.structures.tableAccents["Ö"] = "O";
WC_Lib.structures.tableAccents["Ù"] = "U";
WC_Lib.structures.tableAccents["Ú"] = "U";
WC_Lib.structures.tableAccents["Û"] = "U";
WC_Lib.structures.tableAccents["Ü"] = "U";
WC_Lib.structures.tableAccents["Ý"] = "Y";



WC_Lib.structures.WCFilterMenu = {
	frameOwner = nil;
	contextMenu = {
		{   text             = core.L["MountCollected"],
			keepShownOnClick = true,
			isCheckbox       = true,
			func = function()
				WC_Lib.structures.CurrentFilters[1]            = not WC_Lib.structures.CurrentFilters[1];
				WC_Lib.structures.WCFilterMenu.info[1].checked = not WC_Lib.structures.WCFilterMenu.info[1].checked;
				WC_Lib.DisplayGuidesByFilter("WC");
			end
		},
		{   text = core.L["MountNotCollected"],
			arg1 = core.L["MountNotCollected"],
			isNotRadio       = true,
			disabled         = false,
			keepShownOnClick = true,
			checked          = true,
			func = function(self, arg1)
				WC_Lib.structures.CurrentFilters[2]            = not WC_Lib.structures.CurrentFilters[2];
				WC_Lib.structures.WCFilterMenu.info[2].checked = not WC_Lib.structures.WCFilterMenu.info[2].checked;
				WC_Lib.DisplayGuidesByFilter("WC");
			end
		},
		{   text = core.L["Catégorie"],
			hasArrow     = true,
			notCheckable = true,
			menuList = {
				{	text = core.L["Hauts-faits"],
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[3]                        = not WC_Lib.structures.CurrentFilters[3];
						WC_Lib.structures.WCFilterMenu.info[3].menuList[1].checked = not WC_Lib.structures.WCFilterMenu.info[3].menuList[1].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = core.L["Mounts"],
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[4]                        = not WC_Lib.structures.CurrentFilters[4];
						WC_Lib.structures.WCFilterMenu.info[3].menuList[2].checked = not WC_Lib.structures.WCFilterMenu.info[3].menuList[2].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = core.L["Pets"],
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[5]                        = not WC_Lib.structures.CurrentFilters[5];
						WC_Lib.structures.WCFilterMenu.info[3].menuList[3].checked = not WC_Lib.structures.WCFilterMenu.info[3].menuList[3].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{   text = core.L["Transmog"],
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[6]                        = not WC_Lib.structures.CurrentFilters[6];
						WC_Lib.structures.WCFilterMenu.info[3].menuList[4].checked = not WC_Lib.structures.WCFilterMenu.info[3].menuList[4].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
			},
			func = function(self, arg1)
			end
		},
		{   text = core.L["Difficulté"],
			hasArrow     = true,
			notCheckable = true,
			menuList = {
				{	text = core.L["Difficult"][1],
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[7]                        = not WC_Lib.structures.CurrentFilters[7];
						WC_Lib.structures.WCFilterMenu.info[4].menuList[1].checked = not WC_Lib.structures.WCFilterMenu.info[4].menuList[1].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = core.L["Difficult"][2],
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[8]                        = not WC_Lib.structures.CurrentFilters[8];
						WC_Lib.structures.WCFilterMenu.info[4].menuList[2].checked = not WC_Lib.structures.WCFilterMenu.info[4].menuList[2].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = core.L["Difficult"][3],
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[9]                        = not WC_Lib.structures.CurrentFilters[9];
						WC_Lib.structures.WCFilterMenu.info[4].menuList[3].checked = not WC_Lib.structures.WCFilterMenu.info[4].menuList[3].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
			},
			func = function(self, arg1)
			end
		},
		{   text = core.L["Faction"],
			hasArrow     = true,
			notCheckable = true,
			menuList = {
				{	text = core.L["FactionList"][1],
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[10]                       = not WC_Lib.structures.CurrentFilters[10];
						WC_Lib.structures.WCFilterMenu.info[5].menuList[1].checked = not WC_Lib.structures.WCFilterMenu.info[5].menuList[1].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = core.L["FactionList"][2],
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[11]                       = not WC_Lib.structures.CurrentFilters[11];
						WC_Lib.structures.WCFilterMenu.info[5].menuList[2].checked = not WC_Lib.structures.WCFilterMenu.info[5].menuList[2].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = core.L["FactionList"][3],
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[12]                       = not WC_Lib.structures.CurrentFilters[12];
						WC_Lib.structures.WCFilterMenu.info[5].menuList[3].checked = not WC_Lib.structures.WCFilterMenu.info[5].menuList[3].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
			},
			func = function(self, arg1)
			end
		},
		{   text = core.L["Expansion"],
			hasArrow     = true,
			notCheckable = true,
			menuList = {
				{	text = core.L["Tout cocher"],
					disabled         = false,
					keepShownOnClick = true,
					notCheckable     = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[13]                        = true;
						WC_Lib.structures.CurrentFilters[14]                        = true;
						WC_Lib.structures.CurrentFilters[15]                        = true;
						WC_Lib.structures.CurrentFilters[16]                        = true;
						WC_Lib.structures.CurrentFilters[17]                        = true;
						WC_Lib.structures.CurrentFilters[18]                        = true;
						WC_Lib.structures.CurrentFilters[19]                        = true;
						WC_Lib.structures.CurrentFilters[20]                        = true;
						WC_Lib.structures.CurrentFilters[21]                        = true;
						WC_Lib.structures.CurrentFilters[22]                        = true;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[3].checked  = true;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[4].checked  = true;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[5].checked  = true;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[6].checked  = true;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[7].checked  = true;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[8].checked  = true;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[9].checked  = true;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[10].checked = true;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[11].checked = true;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[12].checked = true;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = core.L["Tout décocher"],
					disabled         = false,
					keepShownOnClick = true,
					notCheckable     = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[13]                        = false;
						WC_Lib.structures.CurrentFilters[14]                        = false;
						WC_Lib.structures.CurrentFilters[15]                        = false;
						WC_Lib.structures.CurrentFilters[16]                        = false;
						WC_Lib.structures.CurrentFilters[17]                        = false;
						WC_Lib.structures.CurrentFilters[18]                        = false;
						WC_Lib.structures.CurrentFilters[19]                        = false;
						WC_Lib.structures.CurrentFilters[20]                        = false;
						WC_Lib.structures.CurrentFilters[21]                        = false;
						WC_Lib.structures.CurrentFilters[22]                        = false;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[3].checked  = false;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[4].checked  = false;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[5].checked  = false;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[6].checked  = false;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[7].checked  = false;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[8].checked  = false;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[9].checked  = false;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[10].checked = false;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[11].checked = false;
						WC_Lib.structures.WCFilterMenu.info[6].menuList[12].checked = false;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = "Classic",
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[13]                       = not WC_Lib.structures.CurrentFilters[13];
						WC_Lib.structures.WCFilterMenu.info[6].menuList[3].checked = not WC_Lib.structures.WCFilterMenu.info[6].menuList[3].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = "Burning Crusade",
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[14]                       = not WC_Lib.structures.CurrentFilters[14];
						WC_Lib.structures.WCFilterMenu.info[6].menuList[4].checked = not WC_Lib.structures.WCFilterMenu.info[6].menuList[4].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = "Wrath of the Lich King",
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[15]                       = not WC_Lib.structures.CurrentFilters[15];
						WC_Lib.structures.WCFilterMenu.info[6].menuList[5].checked = not WC_Lib.structures.WCFilterMenu.info[6].menuList[5].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = "Cataclysm",
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[16]                       = not WC_Lib.structures.CurrentFilters[16];
						WC_Lib.structures.WCFilterMenu.info[6].menuList[6].checked = not WC_Lib.structures.WCFilterMenu.info[6].menuList[6].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = "Mist of Pandaria",
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[17]                       = not WC_Lib.structures.CurrentFilters[17];
						WC_Lib.structures.WCFilterMenu.info[6].menuList[7].checked = not WC_Lib.structures.WCFilterMenu.info[6].menuList[7].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = "Warlords of Draenor",
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[18]                       = not WC_Lib.structures.CurrentFilters[18];
						WC_Lib.structures.WCFilterMenu.info[6].menuList[8].checked = not WC_Lib.structures.WCFilterMenu.info[6].menuList[8].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = "Legion",
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[19]                       = not WC_Lib.structures.CurrentFilters[19];
						WC_Lib.structures.WCFilterMenu.info[6].menuList[9].checked = not WC_Lib.structures.WCFilterMenu.info[6].menuList[9].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = "Battle for Azeroth",
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[20]                        = not WC_Lib.structures.CurrentFilters[20];
						WC_Lib.structures.WCFilterMenu.info[6].menuList[10].checked = not WC_Lib.structures.WCFilterMenu.info[6].menuList[10].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
				{	text = "Shadowlands",
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[21]                        = not WC_Lib.structures.CurrentFilters[21];
						WC_Lib.structures.WCFilterMenu.info[6].menuList[11].checked = not WC_Lib.structures.WCFilterMenu.info[6].menuList[11].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},				
				{	text = "Dragonflight",
					isNotRadio       = true,
					disabled         = false,
					keepShownOnClick = true,
					checked          = true,
					func = function(self)
						WC_Lib.structures.CurrentFilters[22]                        = not WC_Lib.structures.CurrentFilters[22];
						WC_Lib.structures.WCFilterMenu.info[6].menuList[12].checked = not WC_Lib.structures.WCFilterMenu.info[6].menuList[12].checked;
						WC_Lib.DisplayGuidesByFilter("WC");
					end
				},
			},
			func = function(self, arg1)
			end
		},
	}
};

WC_Lib.structures.WCGuideMenu = {
	frameOwner = nil;
	contextMenu = {
		{	text = core.L["Exporter"],
			func = function()
				WC_Lib.ShowPopupExport(WC_Lib.structures.WCGuideMenu.frameOwner.idGuide, WC_Lib.structures.WCGuideMenu.frameOwner.addon);
				PlaySound("83", "sfx");
			end
		},
		{   text = core.L["Supprimer"],
			func = function()
				local confirmDialog = StaticPopup_Show("WC_ConfirmDialog", core.L["Voulez-vous supprimer"].." |cFFF5CC00"..WC_Lib.structures.WCGuideMenu.frameOwner.nameGuide.."|r ?\nID: |cff00c8ff"..WC_Lib.structures.WCGuideMenu.frameOwner.idGuide.."|r");
				confirmDialog.func  = function() WC_Lib.DeleteCollection(WC_Lib.structures.WCGuideMenu.frameOwner.idGuide, WC_Lib.structures.WCGuideMenu.frameOwner.addon); end;
				PlaySound("882", "sfx");
			end
		},
	}
};

StaticPopupDialogs["DISCORD"] = {
	text = core.L["TextUrl"],
	button1 = core.L["Close"],
	OnShow = function (self)
		local eb = _G[self:GetName() .. "EditBox"];
		if eb then
			eb:SetText("https://discord.gg/cc5TGnd")
			eb:SetWidth(250);
			eb:HighlightText();
		end
	end,
	whileDead = true,
	hasEditBox = true
}

StaticPopupDialogs["PATREON"] = {
	text = core.L["TextUrl"],
	button1 = core.L["Close"],
	OnShow = function (self, data)
		local eb = _G[self:GetName() .. "EditBox"];
		if eb then
			eb:SetText("https://www.patreon.com/WoWChallenger")
			eb:SetWidth(250);
			eb:HighlightText();
		end
	end,
	whileDead = true,
	hasEditBox = true
}

WC_Lib.structures.WCJoinMenu = {
	contextMenu = {
		{	text = "DISCORD",
			func = function()
				StaticPopup_Show("DISCORD");
			end
		},
		{
			isDivider = true,
		},
		{   text = "PATREON",
			func = function()
				StaticPopup_Show("PATREON");
			end
		},
	}
};

-- ===== ADVENTURES ===== --
WC_Lib.structures.CDMenuAdventures = {
	infoAdventure = nil;
	contextMenu = {
		{   text = core.L["Supprimer"],
			arg1 = core.L["Supprimer"],
			notCheckable = true,
			func = function(self, arg1)
				local confirmDialog = StaticPopup_Show("WC_ConfirmDialog", core.L["Voulez-vous supprimer"].." |cFFF5CC00"..WC_Lib.structures.CDMenuAdventures.infoAdventure.title.."|r ?\nID: |cff00c8ff"..WC_Lib.structures.CDMenuAdventures.infoAdventure.id.."|r");
				confirmDialog.func  = function()
					DeleteInAdventure(WC_Lib.structures.CDMenuAdventures.infoAdventure.id, 1, "WC");
					RefreshListAdventures("WC");
				end;
			end
		},
	}
};

WC_Lib.structures.CDMenuImport = {
	addon = nil,
	contextMenu = {
		{   text = core.L["Importation rapide"],
			func = function()
				ShowPopupImportAdventures(1, WC_Lib.structures.CDMenuImport.addon);
			end
		},
		{   text = core.L["Importation complète (contenu volumineux)"],
			func = function()
				FullImport(1, WC_Lib.structures.CDMenuImport.addon);
			end
		},
	}
};