local ____exports = {}
local getAllSaveDataToWriteToDisk
local ____SerializationType = require("enums.SerializationType")
local SerializationType = ____SerializationType.SerializationType
local ____deepCopy = require("functions.deepCopy")
local deepCopy = ____deepCopy.deepCopy
local ____jsonHelpers = require("functions.jsonHelpers")
local jsonEncode = ____jsonHelpers.jsonEncode
local ____log = require("functions.log")
local log = ____log.log
local ____table = require("functions.table")
local isTableEmpty = ____table.isTableEmpty
local iterateTableInOrder = ____table.iterateTableInOrder
local ____constants = require("classes.features.other.saveDataManager.constants")
local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
function getAllSaveDataToWriteToDisk(self, saveDataMap, saveDataConditionalFuncMap)
    local allSaveData = {}
    iterateTableInOrder(
        nil,
        saveDataMap,
        function(____, subscriberName, saveData)
            local conditionalFunc = saveDataConditionalFuncMap[subscriberName]
            if conditionalFunc ~= nil then
                local shouldSave = conditionalFunc(nil)
                if not shouldSave then
                    return
                end
            end
            local saveDataWithoutRoom = {persistent = saveData.persistent, run = saveData.run, level = saveData.level}
            if isTableEmpty(nil, saveDataWithoutRoom) then
                return
            end
            local saveDataCopy = deepCopy(nil, saveDataWithoutRoom, SerializationType.SERIALIZE, subscriberName)
            allSaveData[subscriberName] = saveDataCopy
        end,
        SAVE_DATA_MANAGER_DEBUG
    )
    return allSaveData
end
function ____exports.saveToDisk(self, mod, saveDataMap, saveDataConditionalFuncMap)
    local allSaveData = getAllSaveDataToWriteToDisk(nil, saveDataMap, saveDataConditionalFuncMap)
    local jsonString = jsonEncode(nil, allSaveData)
    mod:SaveData(jsonString)
    log("The save data manager wrote data to the \"save#.dat\" file for mod: " .. mod.Name)
end
return ____exports
