local start, duration, enable

local function GetItemID(itemName)
	return select(5, string.find(select(2, GetItemInfo(itemName)), "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?"))
end

WhatsNext:AddConditionalStatement("Item Equipped",{
	category = "Items",
	test = function(checkTable) 
		return IsEquippedItem(checkTable.itemName) == 1
	end,
	text = function(checkTable) 
		return "player is wearing " .. tostring(checkTable.itemName) .. "."
	end,
	arguments = {
		itemName = {type = "text", default = ""},
	}
})

WhatsNext:AddConditionalStatement("Item On Cooldown",{
	category = "Items",
	test = function(checkTable) 
		start, duration, enable = GetItemCooldown(GetItemID(checkTable.itemName))
		return start + duration - GetTime() > tonumber(checkTable.time)
	end,
	text = function(checkTable) 
		return tostring(checkTable.itemName) .. " will be on cooldown for more than " .. tostring(checkTable.time) .. " seconds."
	end,
	arguments = {
		itemName = {type = "text", default = ""},
		time = {type = "integer", default = 3},
	}
})

WhatsNext:AddConditionalStatement("Item Disabled",{
	category = "Items",
	test = function(checkTable) 
		return select(3,GetItemCooldown(GetItemID(checkTable.itemName))) == 0
	end,
	text = function(checkTable) 
		return tostring(checkTable.itemName) .. "'s cooldown timer won't start until out of combat."
	end,
	arguments = {
		itemName = {type = "text", default = ""},
	}
})