const t=new Set;function i(e){return t.add(e),()=>{t.delete(e)}}function c(e){const n=[];for(const s of t)try{s(e)}catch(o){n.push(o)}if(n.length>0)throw new AggregateError(n,"Failed to cleanup session resources")}function a(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:String(e)}function r(e){if(!(e instanceof Error))return{name:"ThrownValue",message:a(e)};const n=e.code;return{name:e.name||void 0,message:e.message||e.name,stack:e.stack,code:typeof n=="string"||typeof n=="number"?n:void 0}}function u(e,n,s){return{type:e,timestamp:Date.now(),error:r(n),details:s}}function f(e,n){e.diagnostics=[...e.diagnostics??[],n]}export{f as a,u as b,c,r as e,a as f,i as r};
