var R=Object.defineProperty;var S=(a,n)=>R(a,"name",{value:n,configurable:!0});import{r as i,g as l,h as p,p as E,i as v,k as U}from"./mermaid-GHXKKRXX-D4c_pudv.js";function y(a,n){const d=typeof n=="function"?{onOrphaned:n}:n??{},{onOrphaned:f,onCreate:u}=d,t=i.useRef(new Map).current,r=new Set(a.map(e=>e.id));for(const e of a){if(t.has(e.id))continue;const o=e.adoptedFrom!==void 0?t.get(e.adoptedFrom):void 0;if(e.adoptedFrom!==void 0&&o)t.delete(e.adoptedFrom),t.set(e.id,o);else{const g=l(e.id);t.set(e.id,g),u?.(e.id,g)}}const s=i.useRef(new Set);i.useEffect(()=>{const e=s.current;s.current=r;for(const o of e)!r.has(o)&&t.has(o)&&(t.delete(o),f?.(o))});const c=new Map;for(const e of r){const o=t.get(e);o&&c.set(e,o)}return c}S(y,"useStoreMap");function M(a,n){const d=i.useRef(a);d.current=a;const f=i.useRef(n);f.current=n;const u=[...a.keys()].sort().join(",");i.useLayoutEffect(()=>{const m=[];for(const[t,r]of d.current)t!==f.current&&m.push(p(t,"onSessionUpdate",s=>{const{update:c}=s;E(r,c),v(c)?.turnEnd&&r.getState().setHasUnseenUpdates(!0)}),p(t,"onPermissionRequest",s=>{U(r,s)}),p(t,"onConfigOptionsUpdate",s=>{r.getState().setConfigOptions(s)}),p(t,"onExperimentsUpdate",s=>{r.getState().setExperiments(s)}));return()=>{for(const t of m)t.dispose()}},[u,n])}S(M,"useBackgroundEventWiring");export{M as a,y as u};
