var p=Object.defineProperty;var f=(o,e,r)=>e in o?p(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var h=(o,e,r)=>f(o,typeof e!="symbol"?e+"":e,r);class g{constructor(){h(this,"poolSize",120)}async fetchConversations(e,r,s){return await m(150),this.generateConversations(e,r,s)}generateConversations(e,r,s){const u=Date.now(),i=[];for(let n=0;n<this.poolSize;n++){const c=String(1e5+n);i.push({conversationId:c,medium:n%2===0?"phone":"whatsapp",phoneNumber:`+44 7700 ${String(1e3+n%90).padStart(4,"0")}`,duration:Math.floor(Math.random()*600),createdAt:u-n*36e5})}let a=i;if(r){const n=r.replace(/\s+/g,"");a=i.filter(c=>{var l;return(l=c.phoneNumber)==null?void 0:l.replace(/\s+/g,"").includes(n)})}if(a.sort((n,c)=>c.createdAt-n.createdAt),s){const n=a.findIndex(c=>c.conversationId===s);n>=0&&(a=a.slice(n+1))}const t=a.slice(0,e),d=t.length?t[t.length-1].conversationId:void 0;return{limit:e,items:t,lastConversationId:d}}async fetchTraces(e){return await m(150),{items:this.generateTraces(e)}}generateTraces(e){const r=w($(e)),s=Math.floor(r()*5)+3,u=Date.now(),i=Array.from({length:s},(a,t)=>{const d=u-(s-t)*3e4,n=t%3;return n===0?{traceType:"CONVERSATIONAL",traceId:`conv-${e}-${t}`,conversationId:e,eventName:"received-message",role:"user",medium:"phone",content:`Hello (${t})`,createdAt:d}:n===1?{traceType:"API_CALL",traceId:`api-${e}-${t}`,conversationId:e,operationName:"getBooking",method:"GET",path:`/bookings/${e}`,createdAt:d,durationMs:Math.floor(r()*200)+50,status:200,ok:!0}:{traceType:"STEP",traceId:`step-${e}-${t}`,conversationId:e,scopeId:`scope-${t}`,workflowId:`workflow-${t}`,workflowRunId:`run-${e}-${t}`,name:"main",renderedPrompt:`Rendered prompt for ${e}/${t}`,receivedContext:{foo:"bar"},receivedPrompt:`User says #${t}`,createdAt:d,stringifiedConversation:`user: hi
agent: ok (${t})`,response:`response ${t}`,model:"gpt-4"}});return i.sort((a,t)=>a.createdAt-t.createdAt),i}}function m(o){return new Promise(e=>setTimeout(e,o))}function $(o){let e=1779033703^o.length;for(let r=0;r<o.length;r++)e=Math.imul(e^o.charCodeAt(r),3432918353),e=e<<13|e>>>19;return e>>>0}function w(o){return function(){let e=o+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}const k=new g;export{k as m};
