1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="623a153b-9417-4c04-b915-720bc1f0a7e0",e._sentryDebugIdIdentifier="sentry-dbid-623a153b-9417-4c04-b915-720bc1f0a7e0")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5304],{40919:(e,t,n)=>{n.d(t,{F:()=>a,P:()=>c});var r=n(55222),l=n(46627);function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pcmu";return"pcma"===t?r.lF(e):l.lF(e)}function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pcmu";return"pcma"===t?r.D4(e):l.D4(e)}},55304:(e,t,n)=>{n.d(t,{m:()=>U,u:()=>R});var r=n(32233),l=n(30865),a=n(2601),c=n(19775),o=n(78153),u=n(40919),i=n(99512);let s=!1,d={current:null},f={current:null},m={current:""},h={current:0},p={current:1},w="pcmu",y=null,g=null,b=null,_=null,v={current:null},X={current:null},S="/worklets/recorder-processor.js",k={dev:"https://dev.fix-it.ai",staging:"https://staging.fix-it.ai",prod:"https://www.fix-it.ai"},x={},D={},I=[],N=!1,O=new Set,A=new Map;async function C(e,t){let n=[],r=function(){let e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e?window.location.origin:"dev.fix-it.ai"===e||"v1.fix-it.ai"===e||"staging.fix-it.ai"===e?k[(0,a.vv)()]:(0,o.lL)(e)?window.location.origin:k.prod}();r&&n.push(new URL(S,r).toString());let l=function(e){try{let t=new URL(e),n="wss:"===t.protocol?"https:":"ws:"===t.protocol?"http:":t.protocol,r="".concat(n,"//").concat(t.host);return new URL(S,r).toString()}catch(e){return null}}(t);l&&!n.includes(l)&&n.push(l),n.push(S);let c=null;for(let t of n)try{await e.audioWorklet.addModule(t);return}catch(e){c=e}throw c}function T(){return I.reduce((e,t)=>e+t.length,0)+Array.from(A.values()).reduce((e,t)=>e+t,0)}function E(){O.forEach(e=>{try{e.stop(),e.disconnect()}catch(e){}A.delete(e)}),O.clear(),A.clear()}function P(e){if(e.includes("chunk_")&&e.includes("_complete"))try{let t=e.match(/chunk_(\d+)_/);return t?parseInt(t[1]):null}catch(e){}return null}async function M(e,t){Date.now(),await new Promise(e=>setTimeout(e,200));let n=T()/8e3;if(n>0){let e=1.15*n;await new Promise(t=>setTimeout(t,1e3*e))}else await new Promise(e=>setTimeout(e,100));let r=Date.now();for(;Date.now()-r<1500&&0!==T();)await new Promise(e=>setTimeout(e,50));await new Promise(e=>setTimeout(e,100));let l=P(e),a=[e];if(null!==l)for(let[t,n]of Object.entries(x)){if(t===e)continue;let n=P(t);null!==n&&n<l&&a.push(t)}for(let e of a){let n={event:"mark",streamSid:t,mark:{name:e}};try{f.current&&f.current.readyState===WebSocket.OPEN&&(f.current.send(JSON.stringify(n)),Date.now(),x[e]&&delete x[e])}catch(e){}}}async function R(e,t,n,o,S,k,T){if(!s){U(),y=e||null,g=S||null,b=k||null;try{let e=new AudioContext({latencyHint:"interactive"});d.current=e;let S=T||(0,a.TV)();await C(e,S);let k=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!1,autoGainControl:!1},video:!1});X.current=k;let P=new MediaStreamAudioSourceNode(e,{mediaStream:k}),R=new AudioWorkletNode(e,"recorder-processor",{numberOfInputs:1,numberOfOutputs:0,processorOptions:{frameMs:100}});v.current=R,P.connect(R);let F=o||(0,l.qq)(),L=new URLSearchParams({user_id:F});t&&L.set("campaign_id",t),n&&L.set("prompt_id",n);let W=await (0,c.TV)();if(!W)throw Error("Not authenticated");let J="".concat(S,"/voiceagent?").concat(L.toString()),V=new WebSocket(J);f.current=V,V.onopen=()=>{m.current=crypto.randomUUID(),s=!0,h.current=e.currentTime+.05,p.current=1,r.oR.success("Voicebot connected. Speak now."),y&&y(!0),_=setInterval(()=>{if(V.readyState!==WebSocket.OPEN){if(s=!1,y)try{y(!1)}catch(e){y=null}_&&(clearInterval(_),_=null)}},5e3)},V.addEventListener("message",function e(t){try{JSON.parse(t.data)}catch(e){}V.send(JSON.stringify({event:"start",streamSid:m.current,firebase_token:W,start:{accountSid:"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",callSid:crypto.randomUUID(),from:"+10000000000",to:F,mediaFormat:{encoding:"x-mulaw",sampleRate:8e3,channels:1}}})),V.removeEventListener("message",e)}),R.port.onmessage=async e=>{var t;if((null==(t=e.data)?void 0:t.type)!=="f32"||!s||!f.current||f.current.readyState!==WebSocket.OPEN)return;let n=e.data.f32,r=e.data.sr,l=await (0,i.AI)(n,r),a=(0,i.xH)(l),c=(0,u.F)(a,w),o=function(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}(c);try{f.current.send(JSON.stringify({event:"media",streamSid:m.current,sequenceNumber:p.current++,media:{payload:o}}))}catch(e){if(s&&(s=!1,y))try{y(!1)}catch(e){y=null}}},V.onmessage=e=>{if(s&&d.current)try{var t,n,r,l,a,c,o,i,f,p,y,_,v,X,S,k,C,T,P,R,U,F,L;let s=JSON.parse(e.data),W=s.event;if("clear"===W){E(),I=[],N=!0,h.current=d.current.currentTime+.01,setTimeout(()=>{N=!1},100);return}if("mark"===W){let e=(null==(t=s.mark)?void 0:t.name)||"unknown",n=s.streamSid||m.current,r=Date.now();D[e]=r,x[e]=r,M(e,n).catch(e=>{});return}if("transcript_with_latency"===W){let e=null!=(r=s.type)?r:"unknown",t=null!=(l=s.turn_number)?l:0,u={};if("number"==typeof s.stt_latency_ms&&(u.stt=s.stt_latency_ms),"number"==typeof s.llm_first_token_latency_ms&&(u.llm=s.llm_first_token_latency_ms),"number"==typeof s.tts_latency_ms&&(u.tts=s.tts_latency_ms),Object.keys(u).length>0)try{null==b||b(u,e,t)}catch(e){}let d=null!=(_=null!=(y=null!=(p=null!=(f=null!=(i=null!=(o=null!=(c=null!=(a=s.sentence)?a:s.text)?c:s.transcript)?o:s.agent_response)?i:s.response)?f:s.message)?p:s.content)?y:null==(n=s.data)?void 0:n.text)?_:"";if(d){let n=e.includes("first_message")||e.includes("llm")||e.includes("agent")||e.includes("bot")||"ai"===s.role||"ai"===s.speaker,r=null==(X=null!=(v=s.is_final)?v:s.final)||X;try{null==g||g(n?"ai":"user",d,r,t)}catch(e){}}return}if("transcript"===W||"transcription"===W||"text"===W){let e=null!=(R=null!=(P=null!=(T=null!=(C=s.transcript)?C:s.transcription)?T:s.text)?P:null==(S=s.data)?void 0:S.text)?R:"",t="user"===s.role||"user"===s.speaker||(null==(k=s.data)?void 0:k.speaker)==="user"?"user":"ai",n=null==(F=null!=(U=s.is_final)?U:s.final)||F;e&&g&&g(t,e,n);return}if("media"===W){if(N)return;let e=null==(L=s.media)?void 0:L.payload;if(!e)return;let t=function(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}(e),n=(0,u.P)(t,w),r=new Float32Array(n.length);for(let e=0;e<n.length;e++)r[e]=n[e]/32768;N||I.push(r);let l=d.current.createBuffer(1,r.length,8e3);l.getChannelData(0).set(r);let a=new AudioBufferSourceNode(d.current,{buffer:l});a.connect(d.current.destination),O.add(a),a.onended=()=>{O.delete(a),A.delete(a)};let c=Math.max(h.current,d.current.currentTime+.01);a.start(c),h.current=c+l.duration,I.length>0&&I.shift(),A.set(a,r.length)}}catch(e){}},V.onerror=e=>{r.oR.error("Voicebot connection error."),y&&y(!1)}
1,V.onclose=e=>{s&&(_&&(clearInterval(_),_=null),U(),(0,r.oR)("Voicebot disconnected."))}}catch(e){r.oR.error("Failed to start voice session."),y&&y(!1)}}}function U(){try{f.current&&(f.current.close(),f.current=null)}catch(e){}try{v.current&&(v.current.disconnect(),v.current=null)}catch(e){}try{X.current&&(X.current.getTracks().forEach(e=>e.stop()),X.current=null)}catch(e){}try{d.current&&(d.current.close(),d.current=null)}catch(e){}_&&(clearInterval(_),_=null),E(),x={},D={},I=[],N=!1,A.clear(),s=!1,y&&y(!1),y=null,g=null,b=null}},99512:(e,t,n)=>{async function r(e,t){if(8e3===t)return e.slice();let n=new OfflineAudioContext(1,Math.max(1,Math.round(e.length*(8e3/t))),8e3),r=n.createBuffer(1,e.length,t);r.getChannelData(0).set(e);let l=new AudioBufferSourceNode(n,{buffer:r});return l.connect(n.destination),l.start(),(await n.startRendering()).getChannelData(0).slice(0)}function l(e){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++){let r=Math.max(-1,Math.min(1,e[n]));t[n]=r<0?32768*r|0:32767*r|0}return t}n.d(t,{AI:()=>r,xH:()=>l})}}]); 2//# sourceMappingURL=5304-932358193ba07646.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.