import{pV as O}from"./cli-0.5.3-842pf3t4.mjs";import{NY as X,PY as Q}from"./cli-0.5.3-vqmxwet2.mjs";import{QY as b}from"./cli-0.5.3-rch86nhn.mjs";import{Laa as W,Yaa as P}from"./cli-0.5.3-t65dek0m.mjs";import{Tma as U}from"./cli-0.5.3-0df3r78b.mjs";P();Q();var Y=U(O(),1),J=U(b(),1);function L(D,z){let F=z/100*(D.length-1),q=Math.floor(F),k=Math.ceil(F);if(q===k)return D[q];return D[q]+(D[k]-D[q])*(F-q)}var T=1024;function V(){let D=new Map,z=new Map,F=new Map;return{increment(q,k=1){D.set(q,(D.get(q)??0)+k)},set(q,k){D.set(q,k)},observe(q,k){let y=z.get(q);if(!y)y={reservoir:[],count:0,sum:0,min:k,max:k},z.set(q,y);if(y.count++,y.sum+=k,k<y.min)y.min=k;if(k>y.max)y.max=k;if(y.reservoir.length<T)y.reservoir.push(k);else{let B=Math.floor(Math.random()*y.count);if(B<T)y.reservoir[B]=k}},add(q,k){let y=F.get(q);if(!y)y=new Set,F.set(q,y);y.add(k)},getAll(){let q=Object.fromEntries(D);for(let[k,y]of z){if(y.count===0)continue;q[`${k}_count`]=y.count,q[`${k}_min`]=y.min,q[`${k}_max`]=y.max,q[`${k}_avg`]=y.sum/y.count;let B=[...y.reservoir].sort((G,H)=>G-H);q[`${k}_p50`]=L(B,50),q[`${k}_p95`]=L(B,95),q[`${k}_p99`]=L(B,99)}for(let[k,y]of F)q[k]=y.size;return q}}}var Z=J.createContext(null);function C(D){let z=Y.c(7),{store:F,children:q}=D,k;if(z[0]===Symbol.for("react.memo_cache_sentinel"))k=V(),z[0]=k;else k=z[0];let B=F??k,G,H;if(z[1]!==B)G=()=>{let M=()=>{let N=B.getAll();if(Object.keys(N).length>0)W((A)=>({...A,lastSessionMetrics:N}))};return process.on("exit",M),()=>{process.off("exit",M)}},H=[B],z[1]=B,z[2]=G,z[3]=H;else G=z[2],H=z[3];J.useEffect(G,H);let K;if(z[4]!==q||z[5]!==B)K=X(Z.Provider,{value:B,children:q}),z[4]=q,z[5]=B,z[6]=K;else K=z[6];return K}
export{V as ub,C as vb};
