export default class DocumentCache{static#e={Scene:5};#t={Scene:new Map};#c(e){const t=this.#s(e),c=DocumentCache.#e[e];if(t.size<=c)return;const s=Array.from(t.values());for(s.sort(((e,t)=>t.lastAccessed-e.lastAccessed));t.size>c;){const e=s.pop();t.delete(e.value.id)}}#s(e){const t=this.#t[e];if(!t)throw new Error(`The document cache does not support ${e} documents.`);return t}addAll(e){const t=e[0]?.documentName,c=this.#s(t),s=performance.now();e.forEach((e=>c.set(e.id,{lastAccessed:s,value:e}))),this.#c(t)}delete(e){this.#s(e.documentName).delete(e.id)}deleteAll(e){const t=e[0]?.documentName,c=this.#s(t);for(const t of e)c.delete(t.id)}get(e,t){return this.#t[e]?.get(t)?.value}set(e){this.#s(e.documentName).set(e.id,{lastAccessed:performance.now(),value:e}),this.#c(e.documentName)}}