local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local __TS__DecorateLegacy = ____lualib.__TS__DecorateLegacy
local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
local ____cachedClasses = require("core.cachedClasses")
local itemConfig = ____cachedClasses.itemConfig
local ____constantsFirstLast = require("core.constantsFirstLast")
local LAST_VANILLA_CARD_TYPE = ____constantsFirstLast.LAST_VANILLA_CARD_TYPE
local LAST_VANILLA_COLLECTIBLE_TYPE = ____constantsFirstLast.LAST_VANILLA_COLLECTIBLE_TYPE
local LAST_VANILLA_PILL_EFFECT = ____constantsFirstLast.LAST_VANILLA_PILL_EFFECT
local LAST_VANILLA_TRINKET_TYPE = ____constantsFirstLast.LAST_VANILLA_TRINKET_TYPE
local NUM_VANILLA_CARD_TYPES = ____constantsFirstLast.NUM_VANILLA_CARD_TYPES
local NUM_VANILLA_COLLECTIBLE_TYPES = ____constantsFirstLast.NUM_VANILLA_COLLECTIBLE_TYPES
local NUM_VANILLA_PILL_EFFECTS = ____constantsFirstLast.NUM_VANILLA_PILL_EFFECTS
local NUM_VANILLA_TRINKET_TYPES = ____constantsFirstLast.NUM_VANILLA_TRINKET_TYPES
local ____decorators = require("decorators")
local Exported = ____decorators.Exported
local ____types = require("functions.types")
local asCardType = ____types.asCardType
local asCollectibleType = ____types.asCollectibleType
local asNumber = ____types.asNumber
local asPillEffect = ____types.asPillEffect
local asTrinketType = ____types.asTrinketType
local ____Feature = require("classes.private.Feature")
local Feature = ____Feature.Feature
--- Mods can add extra things to the game (e.g. collectibles, trinkets, and so on). Since mods load
-- in alphabetical order, the total number of things can't be properly be known until at least one
-- callback fires (which indicates that all mods have been loaded).
-- 
-- This feature gates all such functions behind a callback check. Subsequently, these functions will
-- throw a runtime error if they are called in the menu, before any callbacks have occurred. This
-- ensures that the proper values are always returned and allows you to get immediate feedback if
-- you accidentally access them from the menu.
____exports.ModdedElementDetection = __TS__Class()
local ModdedElementDetection = ____exports.ModdedElementDetection
ModdedElementDetection.name = "ModdedElementDetection"
__TS__ClassExtends(ModdedElementDetection, Feature)
function ModdedElementDetection.prototype.____constructor(self)
    Feature.prototype.____constructor(self)
    self.atLeastOneCallbackFired = false
    self.postPlayerInit = function()
        self.atLeastOneCallbackFired = true
    end
    self.callbacksUsed = {{ModCallback.POST_PLAYER_INIT, self.postPlayerInit}}
end
function ModdedElementDetection.prototype.errorIfNoCallbacksFired(self, constantType)
    if not self.atLeastOneCallbackFired then
        error(("Failed to retrieve a " .. constantType) .. " constant. Since not all mods have been loaded yet, any constants of this type will be inaccurate. Thus, you must wait until at least one callback fires before retrieving these types of constants.")
    end
end
function ModdedElementDetection.prototype.getFirstModdedCollectibleType(self)
    self:errorIfNoCallbacksFired("collectible")
    local firstModdedCollectibleType = asCollectibleType(
        nil,
        asNumber(nil, LAST_VANILLA_COLLECTIBLE_TYPE) + 1
    )
    local itemConfigItem = itemConfig:GetCollectible(firstModdedCollectibleType)
    local ____temp_0
    if itemConfigItem == nil then
        ____temp_0 = nil
    else
        ____temp_0 = firstModdedCollectibleType
    end
    return ____temp_0
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getFirstModdedCollectibleType", true)
function ModdedElementDetection.prototype.getLastCollectibleType(self)
    self:errorIfNoCallbacksFired("collectible")
    return itemConfig:GetCollectibles().Size - 1
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getLastCollectibleType", true)
function ModdedElementDetection.prototype.getNumCollectibleTypes(self)
    self:errorIfNoCallbacksFired("collectible")
    local numModdedCollectibleTypes = self:getNumModdedCollectibleTypes()
    return NUM_VANILLA_COLLECTIBLE_TYPES + numModdedCollectibleTypes
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getNumCollectibleTypes", true)
function ModdedElementDetection.prototype.getNumModdedCollectibleTypes(self)
    self:errorIfNoCallbacksFired("collectible")
    local lastCollectibleType = self:getLastCollectibleType()
    return lastCollectibleType - LAST_VANILLA_COLLECTIBLE_TYPE
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getNumModdedCollectibleTypes", true)
function ModdedElementDetection.prototype.getFirstModdedTrinketType(self)
    self:errorIfNoCallbacksFired("trinket")
    local firstModdedTrinketType = asTrinketType(
        nil,
        asNumber(nil, LAST_VANILLA_TRINKET_TYPE) + 1
    )
    local itemConfigItem = itemConfig:GetTrinket(firstModdedTrinketType)
    local ____temp_1
    if itemConfigItem == nil then
        ____temp_1 = nil
    else
        ____temp_1 = firstModdedTrinketType
    end
    return ____temp_1
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getFirstModdedTrinketType", true)
function ModdedElementDetection.prototype.getLastTrinketType(self)
    self:errorIfNoCallbacksFired("trinket")
    return itemConfig:GetTrinkets().Size - 1
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getLastTrinketType", true)
function ModdedElementDetection.prototype.getNumTrinketTypes(self)
    self:errorIfNoCallbacksFired("trinket")
    local numModdedTrinketTypes = self:getNumModdedTrinketTypes()
    return NUM_VANILLA_TRINKET_TYPES + numModdedTrinketTypes
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getNumTrinketTypes", true)
function ModdedElementDetection.prototype.getNumModdedTrinketTypes(self)
    self:errorIfNoCallbacksFired("trinket")
    local lastTrinketType = self:getLastTrinketType()
    return lastTrinketType - LAST_VANILLA_TRINKET_TYPE
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getNumModdedTrinketTypes", true)
function ModdedElementDetection.prototype.getFirstModdedCardType(self)
    self:errorIfNoCallbacksFired("card")
    local firstModdedCardType = asCardType(
        nil,
        asNumber(nil, LAST_VANILLA_CARD_TYPE) + 1
    )
    local itemConfigCard = itemConfig:GetCard(firstModdedCardType)
    local ____temp_2
    if itemConfigCard == nil then
        ____temp_2 = nil
    else
        ____temp_2 = firstModdedCardType
    end
    return ____temp_2
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getFirstModdedCardType", true)
function ModdedElementDetection.prototype.getLastCardType(self)
    self:errorIfNoCallbacksFired("card")
    local numCards = self:getNumCardTypes()
    return asCardType(nil, numCards)
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getLastCardType", true)
function ModdedElementDetection.prototype.getNumCardTypes(self)
    self:errorIfNoCallbacksFired("card")
    return itemConfig:GetCards().Size - 1
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getNumCardTypes", true)
function ModdedElementDetection.prototype.getNumModdedCardTypes(self)
    self:errorIfNoCallbacksFired("card")
    local numCardTypes = self:getNumCardTypes()
    return numCardTypes - NUM_VANILLA_CARD_TYPES
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getNumModdedCardTypes", true)
function ModdedElementDetection.prototype.getFirstModdedPillEffect(self)
    self:errorIfNoCallbacksFired("pill")
    local firstModdedPillEffect = asPillEffect(
        nil,
        asNumber(nil, LAST_VANILLA_PILL_EFFECT) + 1
    )
    local itemConfigPillEffect = itemConfig:GetPillEffect(firstModdedPillEffect)
    local ____temp_3
    if itemConfigPillEffect == nil then
        ____temp_3 = nil
    else
        ____temp_3 = firstModdedPillEffect
    end
    return ____temp_3
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getFirstModdedPillEffect", true)
function ModdedElementDetection.prototype.getLastPillEffect(self)
    self:errorIfNoCallbacksFired("pill")
    local numPillEffects = self:getNumPillEffects() - 1
    return asPillEffect(nil, numPillEffects)
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getLastPillEffect", true)
function ModdedElementDetection.prototype.getNumPillEffects(self)
    self:errorIfNoCallbacksFired("pill")
    return itemConfig:GetPillEffects().Size
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getNumPillEffects", true)
function ModdedElementDetection.prototype.getNumModdedPillEffects(self)
    self:errorIfNoCallbacksFired("pill")
    local numPillEffects = self:getNumPillEffects()
    return numPillEffects - NUM_VANILLA_PILL_EFFECTS
end
__TS__DecorateLegacy({Exported}, ModdedElementDetection.prototype, "getNumModdedPillEffects", true)
return ____exports
