local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local Set = ____lualib.Set
local __TS__Class = ____lualib.__TS__Class
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
local ____entitiesSpecific = require("functions.entitiesSpecific")
local getSlots = ____entitiesSpecific.getSlots
local ____DefaultMap = require("classes.DefaultMap")
local DefaultMap = ____DefaultMap.DefaultMap
local ____Feature = require("classes.private.Feature")
local Feature = ____Feature.Feature
local v = {room = {
    slotAnimations = __TS__New(
        DefaultMap,
        function(____, slot)
            local sprite = slot:GetSprite()
            return sprite:GetAnimation()
        end
    ),
    brokenSlots = __TS__New(Set)
}}
____exports.SlotRenderDetection = __TS__Class()
local SlotRenderDetection = ____exports.SlotRenderDetection
SlotRenderDetection.name = "SlotRenderDetection"
__TS__ClassExtends(SlotRenderDetection, Feature)
function SlotRenderDetection.prototype.____constructor(self, postSlotRender, postSlotAnimationChanged)
    Feature.prototype.____constructor(self)
    self.v = v
    self.postRender = function()
        for ____, slot in ipairs(getSlots(nil)) do
            self.postSlotRender:fire(slot)
            self:checkSlotAnimationChanged(slot)
        end
    end
    self.callbacksUsed = {{ModCallback.POST_RENDER, self.postRender}}
    self.postSlotRender = postSlotRender
    self.postSlotAnimationChanged = postSlotAnimationChanged
end
function SlotRenderDetection.prototype.checkSlotAnimationChanged(self, slot)
    local sprite = slot:GetSprite()
    local currentAnimation = sprite:GetAnimation()
    local ptrHash = GetPtrHash(slot)
    local previousAnimation = v.room.slotAnimations:getAndSetDefault(ptrHash, slot)
    v.room.slotAnimations:set(ptrHash, currentAnimation)
    if currentAnimation ~= previousAnimation then
        self.postSlotAnimationChanged:fire(slot, previousAnimation, currentAnimation)
    end
end
return ____exports
