local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local __TS__Iterator = ____lualib.__TS__Iterator
local ____exports = {}
local clearAndCopyAllElements, RESETTABLE_SAVE_DATA_KEYS
local ____SaveDataKey = require("enums.SaveDataKey")
local SaveDataKey = ____SaveDataKey.SaveDataKey
local ____SerializationType = require("enums.SerializationType")
local SerializationType = ____SerializationType.SerializationType
local ____deepCopy = require("functions.deepCopy")
local deepCopy = ____deepCopy.deepCopy
local ____log = require("functions.log")
local logError = ____log.logError
local ____table = require("functions.table")
local clearTable = ____table.clearTable
local iterateTableInOrder = ____table.iterateTableInOrder
local ____ReadonlySet = require("types.ReadonlySet")
local ReadonlySet = ____ReadonlySet.ReadonlySet
local ____constants = require("classes.features.other.saveDataManager.constants")
local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
function ____exports.restoreDefaultsForAllFeaturesKey(self, saveDataMap, saveDataDefaultsMap, saveDataKey)
    iterateTableInOrder(
        nil,
        saveDataMap,
        function(____, subscriberName, saveData)
            ____exports.restoreDefaultForFeatureKey(
                nil,
                saveDataDefaultsMap,
                subscriberName,
                saveData,
                saveDataKey
            )
        end,
        SAVE_DATA_MANAGER_DEBUG
    )
end
function ____exports.restoreDefaultForFeatureKey(self, saveDataDefaultsMap, subscriberName, saveData, saveDataKey)
    if not RESETTABLE_SAVE_DATA_KEYS:has(saveDataKey) then
        error(("Failed to restore default values for a save data key of \"" .. saveDataKey) .. "\", since it is not on the allowed list of resettable save data keys.")
    end
    local childTable = saveData[saveDataKey]
    if childTable == nil then
        return
    end
    local saveDataDefaults = saveDataDefaultsMap[subscriberName]
    if saveDataDefaults == nil then
        logError("Failed to find the default copy of the save data for subscriber: " .. subscriberName)
        return
    end
    local childTableDefaults = saveDataDefaults[saveDataKey]
    if childTableDefaults == nil then
        logError(((("Failed to find the default copy of the child table \"" .. saveDataKey) .. "\" for subscriber \"") .. subscriberName) .. "\". This error usually means that your mod-specific save data is out of date. You can try purging all of your mod-specific save data by deleting the following directory: C:\\Program Files (x86)\\Steam\\steamapps\\common\\The Binding of Isaac Rebirth\\data")
        return
    end
    local childTableDefaultsCopy = deepCopy(nil, childTableDefaults, SerializationType.NONE, (subscriberName .. " --> ") .. saveDataKey)
    clearAndCopyAllElements(nil, childTable, childTableDefaultsCopy)
end
function clearAndCopyAllElements(self, oldTable, newTable)
    clearTable(nil, oldTable)
    for key, value in pairs(newTable) do
        oldTable[key] = value
    end
end
RESETTABLE_SAVE_DATA_KEYS = __TS__New(ReadonlySet, {SaveDataKey.RUN, SaveDataKey.LEVEL, SaveDataKey.ROOM})
function ____exports.restoreDefaultsForAllFeaturesAndKeys(self, saveDataMap, saveDataDefaultsMap)
    for ____, saveDataKey in __TS__Iterator(RESETTABLE_SAVE_DATA_KEYS) do
        ____exports.restoreDefaultsForAllFeaturesKey(nil, saveDataMap, saveDataDefaultsMap, saveDataKey)
    end
end
return ____exports
