local ____exports = {}
local getNewDoorPNGPath
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
local ____gridEntities = require("functions.gridEntities")
local removeGridEntity = ____gridEntities.removeGridEntity
local ____stage = require("functions.stage")
local calculateStageType = ____stage.calculateStageType
local ____string = require("functions.string")
local removeCharactersBefore = ____string.removeCharactersBefore
local ____constants = require("classes.features.other.customStages.constants")
local DEFAULT_BASE_STAGE = ____constants.DEFAULT_BASE_STAGE
function getNewDoorPNGPath(self, customStage, fileName)
    repeat
        local ____switch26 = fileName
        local ____cond26 = ____switch26 == "gfx/grid/door_01_normaldoor.anm2"
        if ____cond26 then
            do
                local ____opt_0 = customStage.doorPNGPaths
                return ____opt_0 and ____opt_0.normal
            end
        end
        ____cond26 = ____cond26 or ____switch26 == "gfx/grid/door_02_treasureroomdoor.anm2"
        if ____cond26 then
            do
                local ____opt_2 = customStage.doorPNGPaths
                return ____opt_2 and ____opt_2.treasureRoom
            end
        end
        ____cond26 = ____cond26 or ____switch26 == "gfx/grid/door_03_ambushroomdoor.anm2"
        if ____cond26 then
            do
                local ____opt_4 = customStage.doorPNGPaths
                return ____opt_4 and ____opt_4.normalChallengeRoom
            end
        end
        ____cond26 = ____cond26 or ____switch26 == "gfx/grid/door_04_selfsacrificeroomdoor.anm2"
        if ____cond26 then
            do
                local ____opt_6 = customStage.doorPNGPaths
                return ____opt_6 and ____opt_6.curseRoom
            end
        end
        ____cond26 = ____cond26 or ____switch26 == "gfx/grid/door_05_arcaderoomdoor.anm2"
        if ____cond26 then
            do
                local ____opt_8 = customStage.doorPNGPaths
                return ____opt_8 and ____opt_8.arcade
            end
        end
        ____cond26 = ____cond26 or ____switch26 == "gfx/grid/door_07_devilroomdoor.anm2"
        if ____cond26 then
            do
                local ____opt_10 = customStage.doorPNGPaths
                return ____opt_10 and ____opt_10.devilRoom
            end
        end
        ____cond26 = ____cond26 or ____switch26 == "gfx/grid/door_07_holyroomdoor.anm2"
        if ____cond26 then
            do
                local ____opt_12 = customStage.doorPNGPaths
                return ____opt_12 and ____opt_12.angelRoom
            end
        end
        ____cond26 = ____cond26 or ____switch26 == "gfx/grid/door_08_holeinwall.anm2"
        if ____cond26 then
            do
                local ____opt_14 = customStage.doorPNGPaths
                return ____opt_14 and ____opt_14.secretRoom
            end
        end
        ____cond26 = ____cond26 or ____switch26 == "gfx/grid/door_09_bossambushroomdoor.anm2"
        if ____cond26 then
            do
                local ____opt_16 = customStage.doorPNGPaths
                return ____opt_16 and ____opt_16.bossChallengeRoom
            end
        end
        ____cond26 = ____cond26 or ____switch26 == "gfx/grid/door_10_bossroomdoor.anm2"
        if ____cond26 then
            do
                local ____opt_18 = customStage.doorPNGPaths
                return ____opt_18 and ____opt_18.bossRoom
            end
        end
        ____cond26 = ____cond26 or ____switch26 == "gfx/grid/door_15_bossrushdoor.anm2"
        if ____cond26 then
            do
                local ____opt_20 = customStage.doorPNGPaths
                return ____opt_20 and ____opt_20.bossRush
            end
        end
    until true
    return nil
end
--- For `GridEntityType.DECORATION` (1).
function ____exports.setCustomDecorationGraphics(self, customStage, gridEntity)
    if customStage.decorationsPNGPath == nil and customStage.decorationsANM2Path == nil then
        return
    end
    local gridEntityType = gridEntity:GetType()
    if gridEntityType ~= GridEntityType.DECORATION then
        return
    end
    local sprite = gridEntity:GetSprite()
    local fileName = sprite:GetFilename()
    if string.lower(fileName) ~= "gfx/grid/props_01_basement.anm2" then
        return
    end
    if customStage.decorationsANM2Path ~= nil then
        local anm2Path = removeCharactersBefore(nil, customStage.decorationsANM2Path, "gfx/")
        sprite:Load(anm2Path, true)
    elseif customStage.decorationsPNGPath ~= nil then
        local pngPath = removeCharactersBefore(nil, customStage.decorationsPNGPath, "gfx/")
        sprite:ReplaceSpritesheet(0, pngPath)
        sprite:LoadGraphics()
    end
end
--- For `GridEntityType.ROCK` (2).
function ____exports.setCustomRockGraphics(self, customStage, gridEntity)
    if customStage.rocksPNGPath == nil and customStage.rocksANM2Path == nil then
        return
    end
    local gridEntityRock = gridEntity:ToRock()
    if gridEntityRock == nil then
        return
    end
    local sprite = gridEntity:GetSprite()
    local fileName = sprite:GetFilename()
    repeat
        local ____switch11 = fileName
        local ____cond11 = ____switch11 == "gfx/grid/grid_rock.anm2"
        if ____cond11 then
            do
                if customStage.rocksANM2Path ~= nil then
                    local anm2Path = removeCharactersBefore(nil, customStage.rocksANM2Path, "gfx/")
                    sprite:Load(anm2Path, true)
                elseif customStage.rocksPNGPath ~= nil then
                    local pngPath = removeCharactersBefore(nil, customStage.rocksPNGPath, "gfx/")
                    sprite:ReplaceSpritesheet(0, pngPath)
                    sprite:LoadGraphics()
                end
                break
            end
        end
        ____cond11 = ____cond11 or ____switch11 == "gfx/grid/grid_pit.anm2"
        if ____cond11 then
            do
                if customStage.rocksPNGPath ~= nil then
                    local pngPath = removeCharactersBefore(nil, customStage.rocksPNGPath, "gfx/")
                    sprite:ReplaceSpritesheet(1, pngPath)
                    sprite:LoadGraphics()
                end
                break
            end
        end
    until true
end
--- For `GridEntityType.PIT` (7).
function ____exports.setCustomPitGraphics(self, customStage, gridEntity)
    if customStage.pitsPNGPath == nil then
        return
    end
    local pngPath = removeCharactersBefore(nil, customStage.pitsPNGPath, "gfx/")
    local gridEntityPit = gridEntity:ToPit()
    if gridEntityPit == nil then
        return
    end
    local sprite = gridEntity:GetSprite()
    local fileName = sprite:GetFilename()
    if fileName == "gfx/grid/grid_pit.anm2" then
        sprite:ReplaceSpritesheet(0, pngPath)
        sprite:LoadGraphics()
    end
end
--- For `GridEntityType.DOOR` (16).
function ____exports.setCustomDoorGraphics(self, customStage, gridEntity)
    if customStage.doorPNGPaths == nil then
        return
    end
    local gridEntityDoor = gridEntity:ToDoor()
    if gridEntityDoor == nil then
        return
    end
    local sprite = gridEntity:GetSprite()
    local fileName = sprite:GetFilename()
    local doorPNGPath = getNewDoorPNGPath(nil, customStage, fileName)
    if doorPNGPath ~= nil then
        local fixedPath = removeCharactersBefore(nil, doorPNGPath, "gfx/")
        sprite:ReplaceSpritesheet(0, fixedPath)
        sprite:LoadGraphics()
    end
end
function ____exports.convertVanillaTrapdoors(self, customStage, gridEntity, isFirstFloor, customTrapdoors)
    local gridEntityType = gridEntity:GetType()
    if gridEntityType ~= GridEntityType.TRAPDOOR then
        return
    end
    removeGridEntity(nil, gridEntity, true)
    if isFirstFloor then
        customTrapdoors:spawnCustomTrapdoor(gridEntity.Position, customStage.name, LevelStage.BASEMENT_2)
    else
        local baseStage = customStage.baseStage or DEFAULT_BASE_STAGE
        local destinationStage = baseStage + 2
        local destinationStageType = calculateStageType(nil, destinationStage)
        customTrapdoors:spawnCustomTrapdoor(gridEntity.Position, nil, destinationStage, destinationStageType)
    end
end
return ____exports
