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

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

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

-- AucItemSubClasses
local SubClass_Materials					= select(2, GetAuctionItemSubClasses(6))
local SubClass_Other						= select(13, GetAuctionItemSubClasses(6))
local SubClass_Products					= select(5, GetAuctionItemSubClasses(4))
local SubClass_Recipe_FirstAid		= select(8, GetAuctionItemSubClasses(7))

-- Tab Names
local TN = {}
TN.FirstAid = SubClass_Recipe_FirstAid
TN.All = ALL 
TN.Materials = SubClass_Materials
TN.Other = SubClass_Other
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
-----------------------------------------------------------------------------------------------------------------------------------------
function TN.isFirstAid(player, bagType, name, link, quality, level, ilvl, type, subType, stackCount, equipLoc)
	return TN.isMaterial(player, bagType, name, link, quality, level, ilvl, type, subType, stackCount, equipLoc)
	or TN.isProduct(player, bagType, name, link, quality, level, ilvl, type, subType, stackCount, equipLoc)
	or TN.isRecipe(player, bagType, name, link, quality, level, ilvl, type, subType, stackCount, equipLoc);
end
-----------------------------------------------------------------------------------------------------------------------------------------
function TN.isMaterial(player, bagType, name, link, quality, level, ilvl, type, subType, stackCount, equipLoc)
	if not subType then return false end
	if not link then return false end

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

	return Cloth[tonumber(ItemID)] or AntiVenomMaterials[tonumber(ItemID)]
end
-----------------------------------------------------------------------------------------------------------------------------------------
function TN.isProduct(player, bagType, name, link, quality, level, ilvl, type, subType, stackCount, equipLoc)
	if not subType then return false end
	if not link then return false end

	local ItemID=GetItemIDFromLink(link)
	if not ItemID then return false end
	return subType==SubClass_Products or AntiVenomProducts[tonumber(ItemID)]
end
-----------------------------------------------------------------------------------------------------------------------------------------
function TN.isRecipe(player, bagType, name, link, quality, level, ilvl, type, subType, stackCount, equipLoc)
	if not subType then return false end
	return (type==Class_Recipe and subType==SubClass_Recipe_FirstAid)
end
-----------------------------------------------------------------------------------------------------------------------------------------
CombuctorSet:Register(TN.FirstAid, IconPathName, TN.isFirstAid)

CombuctorSet:RegisterSubSet(TN.All,			TN.FirstAid,nil,TN.isFirstAid)
CombuctorSet:RegisterSubSet(TN.Materials.." | "..TN.Other,	TN.FirstAid,nil,TN.isMaterial)
CombuctorSet:RegisterSubSet(TN.Products.." | "..TN.Other,	TN.FirstAid,nil,TN.isProduct)
CombuctorSet:RegisterSubSet(TN.Recipes,		TN.FirstAid,nil,TN.isRecipe)
