"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lz-string"),t=require("lodash/debounce"),r=require("../cache-utils/formatBytes.js"),n=require("../cache-utils/idle-callback.js"),s=require("./constants.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=i(e),u=i(t);exports.createStorageFlusher=function(e){return u.default((function(){var t=e.pendingWriteRef.current;if(t){var i=n.scheduleIdleWork((function(){e.idleHandlesRef.current.delete(i);try{var n=JSON.stringify(t.wellIds),u={version:s.CACHE_VERSION,timestamp:t.timestamp,schema:s.CACHE_SCHEMA,compression:"lz-utf16",count:t.wellIds.length,sizeKB:r.formatBytesToKB(n.length),state:l.default.compressToUTF16(n)};sessionStorage.setItem(s.STORAGE_KEY,JSON.stringify(u))}finally{e.pendingWriteRef.current===t&&(e.pendingWriteRef.current=null)}}),{timeout:5e3});e.idleHandlesRef.current.add(i)}}),s.DEBOUNCE_DELAY)};
//# sourceMappingURL=createStorageFlusher.js.map
