local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__Class = ____lualib.__TS__Class
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
local ____playerDataStructures = require("functions.playerDataStructures")
local defaultMapGetPlayer = ____playerDataStructures.defaultMapGetPlayer
local ____shouldFire = require("shouldFire")
local shouldFireTrinketType = ____shouldFire.shouldFireTrinketType
local ____DefaultMap = require("classes.DefaultMap")
local DefaultMap = ____DefaultMap.DefaultMap
local ____CustomCallback = require("classes.private.CustomCallback")
local CustomCallback = ____CustomCallback.CustomCallback
local TRINKETS_THAT_CAN_BREAK = {TrinketType.WISH_BONE, TrinketType.WALNUT}
local v = {run = {playersTrinketMap = __TS__New(
    DefaultMap,
    function() return __TS__New(Map) end
)}}
____exports.PostTrinketBreak = __TS__Class()
local PostTrinketBreak = ____exports.PostTrinketBreak
PostTrinketBreak.name = "PostTrinketBreak"
__TS__ClassExtends(PostTrinketBreak, CustomCallback)
function PostTrinketBreak.prototype.____constructor(self)
    CustomCallback.prototype.____constructor(self)
    self.v = v
    self.shouldFire = shouldFireTrinketType
    self.entityTakeDmgPlayer = function(____, player, _amount, _damageFlags, _source, _countdownFrames)
        local trinketMap = defaultMapGetPlayer(nil, v.run.playersTrinketMap, player)
        for ____, trinketType in ipairs(TRINKETS_THAT_CAN_BREAK) do
            do
                local numTrinketsHeld = player:GetTrinketMultiplier(trinketType)
                local oldNumTrinketsHeld = trinketMap:get(trinketType)
                if oldNumTrinketsHeld == nil then
                    oldNumTrinketsHeld = 0
                end
                if numTrinketsHeld >= oldNumTrinketsHeld then
                    goto __continue5
                end
                trinketMap:set(trinketType, numTrinketsHeld)
                local numTrinketsOnGround = Isaac.CountEntities(nil, EntityType.PICKUP, PickupVariant.TRINKET, trinketType)
                if numTrinketsOnGround > 0 then
                    goto __continue5
                end
                self:fire(player, trinketType)
            end
            ::__continue5::
        end
        return nil
    end
    self.postPEffectUpdateReordered = function(____, player)
        local trinketMap = defaultMapGetPlayer(nil, v.run.playersTrinketMap, player)
        for ____, trinketType in ipairs(TRINKETS_THAT_CAN_BREAK) do
            local numTrinkets = player:GetTrinketMultiplier(trinketType)
            if numTrinkets == 0 then
                trinketMap:delete(trinketType)
            else
                trinketMap:set(trinketType, numTrinkets)
            end
        end
    end
    self.customCallbacksUsed = {{ModCallbackCustom.ENTITY_TAKE_DMG_PLAYER, self.entityTakeDmgPlayer}, {ModCallbackCustom.POST_PEFFECT_UPDATE_REORDERED, self.postPEffectUpdateReordered}}
end
return ____exports
