import{f as b}from"./chunk-JCNRQYRP.js";import{g as m}from"./chunk-VKWPEFWQ.js";m();import{performance as u}from"node:perf_hooks";function w(){return b()?"bubble":"mute-and-report"}function h(g={}){let i={sensitive:{},public:{...g}},p=t=>{Object.assign(i.public,t)},M=t=>{Object.assign(i.sensitive,t)},l=async(t,e,n)=>{let r=n==="auto"?w():n,s=async()=>{let c=await e();t(c)};if(r==="bubble")await s();else try{await s()}catch(c){let{sendErrorToBugsnag:o}=await import("./error-handler-MCUV4RZV.js");await o(c,"unexpected_error")}},a=[];return{getAllPublicMetadata:()=>({...i.public}),getAllSensitiveMetadata:()=>({...i.sensitive}),addPublicMetadata:async(t,e="auto")=>l(p,t,e),addSensitiveMetadata:async(t,e="auto")=>l(M,t,e),runWithTimer:t=>async e=>{a.push(0);let n=u.now();try{return await e()}finally{let r=u.now();r=Math.max(n,r);let s=Math.max(r-n,0),c=a.pop(),o=Math.max(s-c,0);a.length>0&&(a[a.length-1]=(a[a.length-1]??0)+s),u.measure(`${t}#measurable`,{start:n,duration:o}),u.measure(`${t}#wall`,{start:n,end:r});let d=i.public[t]||0;d+=o,i.public[t]=d}}}}var y=h({cmd_all_timing_network_ms:0,cmd_all_timing_prompts_ms:0}),{getAllPublicMetadata:S,getAllSensitiveMetadata:f,addPublicMetadata:x,addSensitiveMetadata:A,runWithTimer:P}=y;export{h as a,S as b,f as c,x as d,A as e,P as f};
