"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
0 && (module.exports = {
    createPrerenderResumeDataCache: null,
    createRenderResumeDataCache: null,
    stringifyResumeDataCache: null
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    createPrerenderResumeDataCache: function() {
        return createPrerenderResumeDataCache;
    },
    createRenderResumeDataCache: function() {
        return createRenderResumeDataCache;
    },
    stringifyResumeDataCache: function() {
        return stringifyResumeDataCache;
    }
});
const _cachestore = require("./cache-store");
async function stringifyResumeDataCache(resumeDataCache) {
    if (resumeDataCache.fetch.size === 0 && resumeDataCache.cache.size === 0) {
        return 'null';
    }
    const json = {
        store: {
            fetch: Object.fromEntries((0, _cachestore.stringifyFetchCacheStore)(resumeDataCache.fetch.entries())),
            cache: Object.fromEntries(await (0, _cachestore.stringifyUseCacheCacheStore)(resumeDataCache.cache.entries()))
        }
    };
    return JSON.stringify(json);
}
function createPrerenderResumeDataCache() {
    return {
        cache: new Map(),
        fetch: new Map()
    };
}
function createRenderResumeDataCache(prerenderResumeDataCacheOrPersistedCache) {
    if (typeof prerenderResumeDataCacheOrPersistedCache !== 'string') {
        // If the cache is already a prerender cache, we can return it directly,
        // we're just performing a type change.
        return prerenderResumeDataCacheOrPersistedCache;
    }
    if (prerenderResumeDataCacheOrPersistedCache === 'null') {
        return {
            cache: new Map(),
            fetch: new Map()
        };
    }
    const json = JSON.parse(prerenderResumeDataCacheOrPersistedCache);
    return {
        cache: (0, _cachestore.parseUseCacheCacheStore)(Object.entries(json.store.cache)),
        fetch: (0, _cachestore.parseFetchCacheStore)(Object.entries(json.store.fetch))
    };
}

//# sourceMappingURL=resume-data-cache.js.map