"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("../cache-utils/idle-callback.js"),t=require("./constants.js"),l=require("./useHydrateFromStorage.js"),c=require("./createStorageFlusher.js");exports.useAllWellsCache=function(){var u=e.useRef(null),n=e.useRef(null),a=e.useRef(new Set);l.useHydrateFromStorage(u,a);var s=e.useRef(c.createStorageFlusher({pendingWriteRef:n,idleHandlesRef:a}));return e.useEffect((function(){var e=s.current,t=a.current;return function(){e.cancel(),t.forEach(r.cancelIdleWork),t.clear()}}),[]),{getCachedWellIds:e.useCallback((function(){var e=Date.now(),r=u.current,l=n.current;return r&&e-r.timestamp<t.CACHE_TTL?r.wellIds:l&&e-l.timestamp<t.CACHE_TTL?l.wellIds:(r&&(u.current=null),null)}),[]),setCachedWellIds:e.useCallback((function(e){var r={wellIds:e,timestamp:Date.now()};u.current=r,n.current=r,s.current()}),[]),clearCache:e.useCallback((function(){u.current=null,n.current=null,s.current.cancel(),a.current.forEach(r.cancelIdleWork),a.current.clear(),sessionStorage.removeItem(t.STORAGE_KEY)}),[])}};
//# sourceMappingURL=useAllWellsCache.js.map
