-- REQUIRED Combuctor
local CombuctorSet = Combuctor:GetModule("Sets")

-- Profession Icon Name
local IconPathName="Interface/Icons/Inv_misc_food_15"

-- AucItemClasses
local Class_Recipe					=select(7, GetAuctionItemClasses())

-- AucItemSubClasses
local SubClass_Materials			=select(12, GetAuctionItemSubClasses(6))
local SubClass_Products				=select(1, GetAuctionItemSubClasses(4))
local SubClass_Recipe_Cooking		=select(6, GetAuctionItemSubClasses(7))

-- Tab Names
local TN={}
TN.Cooking=SubClass_Recipe_Cooking
TN.All=ALL 								-- Источник==Кулинария ИЛИ Используется==Кулинария или Рецепт
-- Материалы
TN.Materials=SubClass_Materials 		-- Используется==Кулинария
-- Продукты
TN.Products=SubClass_Products			-- Источник==Кулинария
-- Рецепты
TN.Recipes=Class_Recipe					-- Рецепты для Кулинарии
-----------------------------------------------------------------------------------------------------------------------------------------
local function GetItemIDFromLink(itemLink)
	if not itemLink or itemLink=="" then return nil end

	local itemString = string.match(itemLink, "item[%-?%d:]+")
	local linkType, itemId, enchantId,jewelId1, jewelId2, jewelId3, jewelId4,suffixId, uniqueId = strsplit(":", itemString)
	if (linkType == 'item') then
		return itemId
	end

end
-----------------------------------------------------------------------------------------------------------------------------------------
local function isCooking(player, bagType, name, link, quality, level, ilvl, type, subType, stackCount, equipLoc)
	if not link then return false end
	if not subType then return false end

	local ItemID=GetItemIDFromLink(link)
	if not ItemID then return false end

	return (ReagentsForCooking[tonumber(ItemID)] or CraftedByCooking[tonumber(ItemID)] or subType==SubClass_Recipe_Cooking)
end
-----------------------------------------------------------------------------------------------------------------------------------------
local function isMaterial(player, bagType, name, link, quality, level, ilvl, type, subType, stackCount, equipLoc)
	if not link then return false end

	local ItemID=GetItemIDFromLink(link)
	if not ItemID then return false end

	return (ReagentsForCooking[tonumber(ItemID)])
end
-----------------------------------------------------------------------------------------------------------------------------------------
local function isProduct(player, bagType, name, link, quality, level, ilvl, type, subType, stackCount, equipLoc)
	if not link then return false end
	
	local ItemID=GetItemIDFromLink(link)
	if not ItemID then return false end

	return (CraftedByCooking[tonumber(ItemID)])
end
-----------------------------------------------------------------------------------------------------------------------------------------
local function isRecipe(player, bagType, name, link, quality, level, ilvl, type, subType, stackCount, equipLoc)
	if not type then return false end
	if not subType then return false end
	return (type==Class_Recipe and subType==SubClass_Recipe_Cooking)
end
-----------------------------------------------------------------------------------------------------------------------------------------
CombuctorSet:Register(TN.Cooking, IconPathName, isCooking)

CombuctorSet:RegisterSubSet(TN.All,			TN.Cooking,nil,isCooking)
CombuctorSet:RegisterSubSet(TN.Materials,	TN.Cooking,nil,isMaterial)
CombuctorSet:RegisterSubSet(TN.Products,	TN.Cooking,nil,isProduct)
CombuctorSet:RegisterSubSet(TN.Recipes,		TN.Cooking,nil,isRecipe)
