const C=3e4;function p(c=3e4,r){const e=new Map,n=new Map;async function d(t,o,u){if(u)e.delete(t),n.delete(t);else{const s=e.get(t);if(s&&s.expiresAt>Date.now())return s.snapshot}const i=n.get(t);if(i)return i;const a=(async()=>{const s=await o();if(r)for(;e.size>=r;){const l=e.keys().next().value;if(l===void 0)break;e.delete(l)}return e.set(t,{expiresAt:Date.now()+c,snapshot:s}),n.delete(t),s})();return n.set(t,a),a}function f(...t){for(const o of t)e.delete(o),n.delete(o)}function T(){e.clear(),n.clear()}return{load:d,invalidate:f,clear:T,cache:e,inflight:n}}export{C,p as c};
