1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5353],{27174:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/dev/voice-lab",function(){return n(90601)}])},90601:function(e,t,n){"use strict";n.r(t),n.d(t,{__N_SSP:function(){return i},default:function(){return r}});var l=n(11527),a=n(50959),o=n(21759),i=!0;function r(){let e=function(){let[e,t]=(0,a.useState)(null);return(0,a.useEffect)(()=>{t(new URLSearchParams(window.location.search))},[]),e}(),[t,i]=(0,a.useState)("booting");return(0,a.useEffect)(()=>{var t,l,a;if(!e)return;let r=null!==(t=e.get("role"))&&void 0!==t?t:"publisher",u=null!==(l=e.get("url"))&&void 0!==l?l:"",c=null!==(a=e.get("token"))&&void 0!==a?a:"",s=e=>{i(e),console.log("[voice-lab]",e)},d=[],v={role:r,errors:d,ready:!1};window.__lab=v,(async()=>{var t,l,a;let{listAudioDevices:i}=await Promise.resolve().then(n.bind(n,83597));v.listDevices=()=>i();let d=[],p=e=>{let t=null==e?void 0:e.data;if((null==t?void 0:t.event)==="BUFFER_OVERFLOW"){var n;d.push({t:Date.now(),...null!==(n=t.data)&&void 0!==n?n:{}})}},m=e=>"function"==typeof e?function(t){return p(t),e.call(this,t)}:e,g=e=>{let t=e.addEventListener;e.addEventListener=function(){for(var e=arguments.length,n=Array(e),l=0;l<e;l++)n[l]=arguments[l];return"message"===n[0]&&(n[1]=m(n[1])),t.apply(this,n)};let n=Object.getOwnPropertyDescriptor(e,"onmessage");(null==n?void 0:n.set)&&n.get&&Object.defineProperty(e,"onmessage",{...n,set(e){n.set.call(this,m(e))}})};g(Worker.prototype),g(MessagePort.prototype),v.getKrispBufferEvents=()=>d.slice();let h=0;window.__voiceLabOverrides={...window.__voiceLabOverrides,onKrispDrop:e=>{h=e}},v.getProductionDropCount=()=>h,v.setKrispBufferTuningOverride=e=>{var t;return window.__voiceLabOverrides={...window.__voiceLabOverrides,krispBufferTuning:null!=e?e:void 0},null!==(t=window.__voiceLabOverrides.krispBufferTuning)&&void 0!==t?t:null},v.setKrispDebugLogs=e=>(window.__voiceLabOverrides={...window.__voiceLabOverrides,krispDebugLogs:e||void 0},!0===window.__voiceLabOverrides.krispDebugLogs);let f=null,w=Object.getOwnPropertyDescriptor(MediaStreamTrack.prototype,"label");if(null==w?void 0:w.get){let e=w.get;Object.defineProperty(MediaStreamTrack.prototype,"label",{configurable:!0,get(){let t=e.call(this);return null!==f&&"audio"===this.kind?f:t}})}v.lieAboutMicLabel=e=>f=e;let S=window.fetch.bind(window),b=null,y=null,k=[];window.fetch=async function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let l=await S(...t);try{let e=String(t[0]instanceof Request?t[0].url:t[0]);if(k.push(e),null!==b&&l.ok&&e===b){let e=(await l.clone().text()).split("\n").map(e=>e.trim().toLowerCase()).filter(e=>e.length>=1);e.length>0&&(y=e)}else if(l.ok&&/integrations\.livekit\.io\/enc\/v2\/?$/.test(e.split("?")[0])){let e=await l.clone().json();"string"==typeof(null==e?void 0:e.bvcDevices)&&e.bvcDevices&&(b=e.bvcDevices)}}catch(e){}return l},v.getBvcDeviceList=()=>y,v.getFetchLog=()=>k.slice();let T=[],D=window.AudioContext,A=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let l=new D(...t);return T.push({sampleRate:l.sampleRate,at:Date.now()}),l};A.prototype=D.prototype,window.AudioContext=A,v.getAudioContexts=()=>T.slice(),v.tapSelfCheck=()=>new Promise(e=>{let t=new MessageChannel;t.port1.onmessage=()=>{e(d.some(e=>!0===e.synthetic))},t.port2.postMessage({event:"BUFFER_OVERFLOW",data:{synthetic:!0}})}),v.isCrossOriginIsolated=()=>!0===window.crossOriginIsolated;let M=[];v.cpuPressureStart=e=>{let t=URL.createObjectURL(new Blob(["onmessage = (e) => {\n const end = performance.now() + e.data\n while (performance.now() < end) { /* saturate */ }\n postMessage('done')\n }"],{type:"text/javascript"})),n=(navigator.hardwareConcurrency||8)+2;return M=Array.from({length:n},()=>{let n=new Worker(t);return n.postMessage(e),n}),URL.revokeObjectURL(t),n},v.cpuPressureStop=()=>{M.forEach(e=>e.terminate());let e=M.length;return M=[],e};let C=null;v.toneStart=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:700;await (null==C?void 0:C.stop()),C=null;let n=new AudioContext;e&&await n.setSinkId(e),await n.resume();let l=n.createOscillator();l.frequency.value=t;let a=n.createGain();return a.gain.value=.5,l.connect(a),a.connect(n.destination),l.start(),C={stop:async()=>{l.stop(),await n.close()}},!0},v.toneStop=async()=>(await (null==C?void 0:C.stop()),C=null,!0);let P=null;v.stereoToneStart=async function(e,t,n){let l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:700;await (null==P?void 0:P.stop()),P=null;let a=new AudioContext;e&&await a.setSinkId(e),await a.resume();let o=a.createChannelMerger(2),i=[];
1return[t,n].forEach((e,t)=>{let n=a.createOscillator();n.frequency.value=l;let r=a.createGain();r.gain.value=e,n.connect(r),r.connect(o,0,t),n.start(),i.push(n)}),o.connect(a.destination),P={stop:async()=>{i.forEach(e=>e.stop()),await a.close()}},!0},v.stereoToneStop=async()=>(await (null==P?void 0:P.stop()),P=null,!0),v.captureChannelProbe=async function(e,t){let n,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:600;try{n=await navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:e},...t}})}catch(e){return{rejected:e.name||String(e),channelCount:null,leftDbfs:-120,rightDbfs:-120}}try{var a,o,i;let e=null!==(o=null===(a=n.getAudioTracks()[0])||void 0===a?void 0:a.getSettings())&&void 0!==o?o:{},t=new AudioContext;await t.resume();let r=t.createMediaStreamSource(n),u=t.createChannelSplitter(2);r.channelCountMode="explicit",r.channelInterpretation="discrete",r.connect(u);let c=[0,1].map(e=>{let n=t.createAnalyser();return n.fftSize=2048,u.connect(n,e),n}),s=[0,0],d=performance.now();for(;performance.now()-d<l;)c.forEach((e,t)=>{let n=new Float32Array(e.fftSize);e.getFloatTimeDomainData(n);let l=0;for(let e=0;e<n.length;e+=1)l+=n[e]*n[e];let a=Math.sqrt(l/n.length);s[t]=Math.max(s[t],a)}),await new Promise(e=>setTimeout(e,20));return await t.close(),{rejected:null,channelCount:null!==(i=e.channelCount)&&void 0!==i?i:null,leftDbfs:Math.max(-120,20*Math.log10(s[0]+1e-12)),rightDbfs:Math.max(-120,20*Math.log10(s[1]+1e-12))}}finally{n.getTracks().forEach(e=>e.stop())}};let x=null;v.speechStart=async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.7;await (null==x?void 0:x.stop()),x=null;let l=new AudioContext;e&&await l.setSinkId(e),await l.resume();let a=atob(t),o=new Uint8Array(a.length);for(let e=0;e<a.length;e+=1)o[e]=a.charCodeAt(e);let i=await l.decodeAudioData(o.buffer),r=l.createBufferSource();r.buffer=i,r.loop=!0;let u=l.createGain();return u.gain.value=n,r.connect(u),u.connect(l.destination),r.start(),x={stop:async()=>{r.stop(),await l.close()}},{durationSeconds:i.duration}},v.speechStop=async()=>(await (null==x?void 0:x.stop()),x=null,!0);let O=null;v.speechStartElement=async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.7;await (null==O?void 0:O.stop()),O=null;let l=atob(t),a=new Uint8Array(l.length);for(let e=0;e<l.length;e+=1)a[e]=l.charCodeAt(e);let o=URL.createObjectURL(new Blob([a],{type:"audio/wav"})),i=document.createElement("audio");return i.src=o,i.loop=!0,i.volume=Math.max(0,Math.min(1,n)),e&&await i.setSinkId(e),document.body.appendChild(i),await i.play(),O={stop:async()=>{i.pause(),i.remove(),URL.revokeObjectURL(o)}},!0},v.speechStopElement=async()=>(await (null==O?void 0:O.stop()),O=null,!0),v.speechStartAt=async(e,t,n)=>{await (null==x?void 0:x.stop()),x=null;let l=new AudioContext;e&&await l.setSinkId(e),await l.resume();let a=atob(t),o=new Uint8Array(a.length);for(let e=0;e<a.length;e+=1)o[e]=a.charCodeAt(e);let i=await l.decodeAudioData(o.buffer),r=l.createBufferSource();r.buffer=i,r.loop=!0;let u=l.createGain();return u.gain.value=.7,r.connect(u),u.connect(l.destination),r.start(l.currentTime+n/1e3),x={stop:async()=>{r.stop(),await l.close()}},{durationSeconds:i.duration}};let R=null;v.latencyBurstsStart=async function(e,t){var n;let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:12,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:900;await (null==R?void 0:R.stop()),R=null;let o=new AudioContext;e&&await o.setSinkId(e),await o.resume();let i=atob(t),r=new Uint8Array(i.length);for(let e=0;e<i.length;e+=1)r[e]=i.charCodeAt(e);let u=await o.decodeAudioData(r.buffer);await new Promise(e=>{let t=()=>{var n,l;let a=o.getOutputTimestamp();(null!==(n=a.performanceTime)&&void 0!==n?n:0)>0&&(null!==(l=a.contextTime)&&void 0!==l?l:0)>0&&o.currentTime>0?e():setTimeout(t,10)};t()});let c=u.getChannelData(0),s=0;for(let e=0;e<c.length;e+=1)if(Math.abs(c[e])>.02){s=e;break}let d=s/u.sampleRate*1e3,v=[],p=o.createGain();p.gain.value=.7,p.connect(o.destination);let m=o.currentTime+.5;for(let e=0;e<l;e+=1){let t=o.createBufferSource();t.buffer=u,t.connect(p),t.start(m+e*a/1e3),v.push(t)}let g=o.getOutputTimestamp(),h=(null!==(n=o.outputLatency)&&void 0!==n?n:0)*1e3,f=Array.from({length:l},(e,t)=>{var n,l;return performance.timeOrigin+(null!==(n=g.performanceTime)&&void 0!==n?n:performance.now())+(m+t*a/1e3-(null!==(l=g.contextTime)&&void 0!==l?l:o.currentTime))*1e3+d+h});return R={stop:async()=>{for(let e of v)try{e.stop()}catch(e){}await o.close()}},{emitsEpochMs:f,onsetOffsetMs:d,outputLatencyMs:h,burstDurationMs:1e3*u.duration|0}},v.latencyBurstsStop=async()=>(await (null==R?void 0:R.stop()),R=null,!0);let L=null;v.envelopePlayStart=async(e,t)=>{var n,l,a;await (null==L?void 0:L.stop()),L=null;let o=new AudioContext;e&&await o.setSinkId(e),await o.resume();let i=atob(t),r=new Uint8Array(i.length);for(let e=0;e<i.length;e+=1)r[e]=i.charCodeAt(e);let u=await o.decodeAudioData(r.buffer);await new Promise(e=>{let t=()=>{var n,l;let a=o.getOutputTimestamp();(null!==(n=a.performanceTime)&&void 0!==n?n:0)>0&&(null!==(l=a.contextTime)&&void 0!==l?l:0)>0&&o.currentTime>0?e():setTimeout(t,10)};t()});let c=u.getChannelData(0),s=[];for(let e=0;e+256<=c.length;e+=256){let t=0;for(let n=0;n<256;n+=1)t+=c[e+n]*c[e+n];s.push(20*Math.log10(Math.sqrt(t/256)+1e-9))}let d=o.createGain();d.gain.value=.7,d.connect(o.destination);let v=o.createBufferSource();v.buffer=u,v.connect(d);let p=o.currentTime+.5;v.start(p);let m=o.getOutputTimestamp(),g=(null!==(n=o.outputLatency)&&void 0!==n?n:0)*1e3;return L={stop:async()=>{try{v.stop()}catch(e){}await o.close()}},{t0EpochMs:performance.timeOrigin+(null!==(l=m.performanceTime)&&void 0!==l?l:0)+(p-(null!==(a=m.contextTime)&&void 0!==a?a:0))*1e3+g,dtMs:256/u.sampleRate*1e3,dbs:s,durationMs:1e3*u.duration}},v.envelopePlayStop=async()=>(await (null==L?void 0:L.stop()),L=null,!0);let _=null;v.noiseStart=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.15;await (null==_?void 0:_.stop()),_=null;let n=new AudioContext;e&&await n.setSinkId(e),await n.resume();let l=n.createBuffer(1,4*n.sampleRate,n.sampleRate),a=l.getChannelData(0);for(let e=0;e<a.length;e+=1)a[e]=2*Math.random()-1;let o=n.createBufferSource();o.buffer=l,o.loop=!0;let i=n.createBiquadFilter();i.type="lowpass",i.frequency.value=6e3;let r=n.createGain();return r.gain.value=t,o.connect(i),i.connect(r),r.connect(n.destination),o.start(),_={stop:async()=>{o.stop(),await n.close()}},!0},v.setKrispModelOverride=e=>{var t;return window.__voiceLabOverrides={...window.__voiceLabOverrides,krispModel:null!=e?e:void 0},null!==(t=window.__voiceLabOverrides.krispModel)&&void 0!==t?t:null},v.loopCheck=async(e,t)=>{let n=new AudioContext,l=null,a=null,o=null;try{await n.setSinkId(e),await n.resume();let i=n.createOscillator();i.frequency.value=700;let r=n.createGain();
1r.gain.value=.5,i.connect(r),r.connect(n.destination),i.start(),l=i,a=await navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:t},echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});let u=(o=new AudioContext).createMediaStreamSource(a),c=o.createAnalyser();c.fftSize=4096,c.smoothingTimeConstant=0,u.connect(c),await new Promise(e=>setTimeout(e,2e3));let s=new Float32Array(c.frequencyBinCount);c.getFloatFrequencyData(s);let d=o.sampleRate/c.fftSize,v=Math.round(700/d),p=-1/0;for(let e=v-2;e<=v+2;e+=1)s[e]>p&&(p=s[e]);return p}finally{null==l||l.stop(),null==a||a.getTracks().forEach(e=>e.stop()),await n.close().catch(()=>void 0),await (null==o?void 0:o.close().catch(()=>void 0))}};let G=e=>{let t=new AudioContext,n=t.createMediaStreamSource(new MediaStream([e])),l=new Audio;return l.srcObject=new MediaStream([e]),l.muted=!0,l.play().catch(()=>void 0),{context:t,source:n}},B=e=>{let{context:t,source:n}=G(e),l=t.createScriptProcessor(256,1,1),a=t.createGain();a.gain.value=0;let o=0,i=!1,r={t:Date.now(),blocks:0,gapBlocks:0,transitions:0,maxGapRunMs:0},u=0,c=[];return l.onaudioprocess=e=>{let n=e.inputBuffer.getChannelData(0),l=0;for(let e=0;e<n.length;e+=1)l+=n[e]*n[e];let a=Math.sqrt(l/n.length);o=Math.max(a,.994*o);let s=n.length/t.sampleRate*1e3,d=o>1e-4&&a<.05*o;r.blocks+=1,d?(r.gapBlocks+=1,u+=1,r.maxGapRunMs=Math.max(r.maxGapRunMs,u*s),i||(r.transitions+=1)):u=0,i=d,Date.now()-r.t>=1e3&&(c.push(r),r={t:Date.now(),blocks:0,gapBlocks:0,transitions:0,maxGapRunMs:0})},n.connect(l),l.connect(a),a.connect(t.destination),{read:()=>c.slice(),stop:()=>{l.disconnect(),n.disconnect(),t.close()}}},E=e=>{let{context:t,source:n}=G(e),l=t.createAnalyser();l.fftSize=4096,l.smoothingTimeConstant=0,n.connect(l);let a=new Float32Array(l.frequencyBinCount);return(n,o)=>
1{if("ended"===e.readyState||e.muted)return -200;l.getFloatFrequencyData(a);let i=t.sampleRate/l.fftSize,r=-200,u=Math.max(0,Math.floor(n/i)),c=Math.min(a.length-1,Math.ceil(o/i));for(let e=u;e<=c;e+=1)Number.isFinite(a[e])&&a[e]>r&&(r=a[e]);return r}},I=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-48,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:400,{context:l,source:a}=G(e),o=l.createScriptProcessor(256,1,1),i=l.createGain();i.gain.value=0;let r=10**(t/20),u=[],c=-1/0;return o.onaudioprocess=e=>{let t=e.inputBuffer.getChannelData(0),a=0;for(let e=0;e<t.length;e+=1)a+=t[e]*t[e];let o=Math.sqrt(a/t.length),i=e.playbackTime;if(o>=r&&i-c>=n/1e3){var s,d;c=i;let e=l.getOutputTimestamp(),t=null!==(s=e.contextTime)&&void 0!==s?s:0,n=null!==(d=e.performanceTime)&&void 0!==d?d:0;t>0&&n>0&&u.push({epochMs:performance.timeOrigin+n+(i-t)*1e3,db:20*Math.log10(o+1e-9)})}},a.connect(o),o.connect(i),i.connect(l.destination),{read:()=>u.slice(),stop:()=>{o.disconnect(),a.disconnect(),l.close()}}},j=e=>{let{context:t,source:n}=G(e),l=t.createScriptProcessor(256,1,1),a=t.createGain();a.gain.value=0;let o=[],i=null;return l.onaudioprocess=e=>{var n;if(!((null!==(n=t.getOutputTimestamp().contextTime)&&void 0!==n?n:0)>0))return;let l=e.inputBuffer.getChannelData(0),a=0;for(let e=0;e<l.length;e+=1)a+=l[e]*l[e];null===i&&(i=e.playbackTime),o.push(20*Math.log10(Math.sqrt(a/l.length)+1e-9))},n.connect(l),l.connect(a),a.connect(t.destination),{read:()=>{var e,n;let l=t.getOutputTimestamp(),a=null!==(e=l.contextTime)&&void 0!==e?e:0,r=null!==(n=l.performanceTime)&&void 0!==n?n:0;return{t0EpochMs:null===i||a<=0?null:performance.timeOrigin+r+(i-a)*1e3,dtMs:256/t.sampleRate*1e3,dbs:o.slice()}},stop:()=>{l.disconnect(),n.disconnect(),t.close()}}},F=e=>{let{context:t,source:n}=G(e),l=t.createAnalyser();l.fftSize=4096,l.smoothingTimeConstant=0,n.connect(l);let a=new Float32Array(l.frequencyBinCount);return n=>{if("ended"===e.readyState||e.muted)return-1/0;l.getFloatFrequencyData(a);let o=Math.round(n/(t.sampleRate/l.fftSize)),i=-1/0;for(let e=Math.max(0,o-2);e<=o+2;e+=1)a[e]>i&&(i=a[e]);return i}};if("publisher"===r||"applistener"===r){let{createVoiceRoomManagerForLab:e}=await Promise.resolve().then(n.bind(n,29998)),t=e();v.join=async()=>(await t.connect({serverUrl:u,token:c}),t.getSnapshot().status),v.leave=()=>t.leave(),v.snapshot=()=>t.getSnapshot(),v.setInput=(e,n)=>t.setInputDevice({id:null!=e?e:null,label:null!=n?n:null}).then(()=>({ok:!0}),e=>({ok:!1,error:String(null==e?void 0:e.message)})),v.setOutput=(e,n)=>t.setOutputDevice({id:null!=e?e:null,label:null!=n?n:null}).then(()=>({ok:!0}),e=>({ok:!1,error:String(null==e?void 0:e.message)})),v.setMuted=async e=>{if(t.getSnapshot().muted!==e){let e=await t.toggleMute();if(e.mismatch)throw e.mismatch}return t.getSnapshot().muted},v.audioElementCensus=()=>Array.from(document.querySelectorAll("audio")).map(e=>({volume:e.volume,muted:e.muted,paused:e.paused,sink:e.sinkId,tracks:e.srcObject instanceof MediaStream?e.srcObject.getAudioTracks().length:null})),v.webAudioDiag=()=>{var e,n,l,a,o,i,r,u;let c=null===(e=t.lifecycle)||void 0===e?void 0:e.room,s=[];return null==c||null===(n=c.remoteParticipants)||void 0===n||n.forEach(e=>{var t;return null===(t=e.audioTrackPublications)||void 0===t?void 0:t.forEach(e=>{var t,n,l,a,o,i,r,u,c,d,v;let p=e.track;p&&s.push({hasContext:!!p.audioContext,hasGain:!!p.gainNode,gain:null!==(u=null===(n=p.gainNode)||void 0===n?void 0:null===(t=n.gain)||void 0===t?void 0:t.value)&&void 0!==u?u:null,attached:null!==(c=null===(l=p.attachedElements)||void 0===l?void 0:l.length)&&void 0!==c?c:null,elementMuted:null!==(d=null===(o=p.attachedElements)||void 0===o?void 0:null===(a=o[0])||void 0===a?void 0:a.muted)&&void 0!==d?d:null,elementVolume:null!==(v=null===(r=p.attachedElements)||void 0===r?void 0:null===(i=r[0])||void 0===i?void 0:i.volume)&&void 0!==v?v:null})})}),{webAudioMix:null!==(i=null==c?void 0:null===(l=c.options)||void 0===l?void 0:l.webAudioMix)&&void 0!==i?i:null,contextState:null!==(r=null==c?void 0:null===(a=c.audioContext)||void 0===a?void 0:a.state)&&void 0!==r?r:null,contextSink:null!==(u=null==c?void 0:null===(o=c.audioContext)||void 0===o?void 0:o.sinkId)&&void 0!==u?u:null,tracks:s}},v.contextProbeTone=(e,n)=>{var l,a;let o=null===(a=t.lifecycle)||void 0===a?void 0:null===(l=a.room)||void 0===l?void 0:l.audioContext;if(!o)return!1;let i=o.createOscillator();i.frequency.value=e;let r=o.createGain();return r.gain.value=.05,i.connect(r),r.connect(o.destination),i.start(),setTimeout(()=>{i.stop(),r.disconnect()},n),!0},v.setGain=e=>(t.setMicGain(e),t.getSnapshot().micGain),v.appliedMicGain=()=>t.appliedMicGain,v.setMicAgc=e=>(t.setMicAgc(e),t.getSnapshot().micAgc),v.setMicAec=e=>(t.setMicAec(e),t.getSnapshot().micAec),v.publishedOpusStereo=()=>{var e,n,l,a,o,i;let r=null===(a=t.room)||void 0===a?void 0:null===(l=a.engine)||void 0===l?void 0:null===(n=l.pcManager)||void 0===n?void 0:null===(e=n.publisher)||void 0===e?void 0:e._pc,u=e=>{if(!e)return null;let t=e.split(/^m=/m).find(e=>e.startsWith("audio"));if(!t)return null;let n=t.split(/\r?\n/),l=n.map(e=>{var t;return null===(t=/^a=rtpmap:(\d+)\s+opus\//i.exec(e))||void 0===t?void 0:t[1]}).filter(e=>!!e),a=n.filter(e=>l.some(t=>e.startsWith("a=fmtp:".concat(t," ")))),o=a.join(" ");return{stereo:/(?:^|[;\s])stereo=1/.test(o),spropStereo:/(?:^|[;\s])sprop-stereo=1/.test(o),sawOpusFmtp:a.length>0,opusFmtp:a}};return{local:u(null==r?void 0:null===(o=r.localDescription)||void 0===o?void 0:o.sdp),remote:u(null==r?void 0:null===(i=r.remoteDescription)||void 0===i?void 0:i.sdp)}},v.captureSettings=()=>{var e,n,l,a,o;let i=t.room,r=null==i?void 0:null===(o=i.localParticipant)||void 0===o?void 0:null===(a=o.getTrackPublication)||void 0===a?void 0:null===(l=a.c
1all(o,"microphone"))||void 0===l?void 0:null===(n=l.track)||void 0===n?void 0:null===(e=n.getSourceTrackSettings)||void 0===e?void 0:e.call(n);return r?{autoGainControl:!0===r.autoGainControl,echoCancellation:!0===r.echoCancellation,noiseSuppression:!0===r.noiseSuppression,voiceIsolation:!0===r.voiceIsolation}:null},v.setDeafened=async e=>{if(t.getSnapshot().deafened!==e){let{micSettled:e}=t.toggleDeafen(),n=await e;if(n.mismatch)throw n.mismatch}return t.getSnapshot().deafened},v.setMasterVolume=e=>(t.setMasterVolume(e),t.getSnapshot().masterVolume),v.setPseudoAec=e=>(t.setPseudoAec(e),!0),v.outboundAudioStats=async()=>{var e,n,l,a,o;let i=t.room,r=await (null==i?void 0:null===(o=i.localParticipant)||void 0===o?void 0:null===(a=o.getTrackPublication)||void 0===a?void 0:null===(l=a.call(o,"microphone"))||void 0===l?void 0:null===(n=l.track)||void 0===n?void 0:null===(e=n.getRTCStatsReport)||void 0===e?void 0:e.call(n).catch(()=>null));if(!r)return null;for(let e of Array.from(r.values()))if("outbound-rtp"===e.type&&"audio"===e.kind)return{t:Date.now(),packetsSent:e.packetsSent,bytesSent:e.bytesSent,totalPacketSendDelay:e.totalPacketSendDelay,nackCount:e.nackCount};return null},v.orphanTakeover=async()=>{let t=new URLSearchParams(window.location.search).get("token2");if(!t)return"error: token2 missing â inject it before takeover";let n=e();return await n.connect({serverUrl:u,token:t}).then(()=>n.getSnapshot().status,e=>"error: ".concat(String(null==e?void 0:e.message)))},v.toggleShare=()=>t.toggleScreenShare().then(()=>t.getSnapshot().sharing,e=>"error: ".concat(String(null==e?void 0:e.message))),v.localShareTrackState=()=>{var e,n,l,a,o;try{let o=t.room,i=null==o?void 0:null===(a=o.localParticipant)||void 0===a?void 0:null===(l=a.getTrackPublication)||void 0===l?void 0:null===(n=l.call(a,"screen_share"))||void 0===n?void 0:null===(e=n.track)||void 0===e?void 0:e.mediaStreamTrack;if(!i)return v.__lastShareTrack?{readyState:v.__lastShareTrack.readyState}:null;return v.__lastShareTrack=i,{readyState:i.readyState}}catch(e){return{error:String(null!==(o=null==e?void 0:e.message)&&void 0!==o?o:e)}}},v.pipelineDestroyProbe=async()=>{let{MicPipelineProcessor:e}=await Promise.resolve().then(n.bind(n,23513)),t=(await navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0],l=null;try{var a,o;l=new AudioContext;let n=new e(1),i={track:t,kind:"audio",audioContext:l};await n.init(i);let r=null!==(a=n.processedTrack)&&void 0!==a?a:null,u=!1,c=n.destroy();c.then(()=>{u=!0});let s=n.destroy();await s;let d={firstSettled:u,graphDead:!r||"ended"===r.readyState};await c,await n.init(i);let v=null!==(o=n.processedTrack)&&void 0!==o?o:null;await n.destroy();let p={freshTeardownRan:!v||"ended"===v.readyState};return{atSecondSettle:d,resurrection:p}}finally{t.stop(),null==l||l.close().catch(()=>void 0)}},v.setNcLevel=e=>(t.setNcLevel(e),t.getSnapshot().ncLevel),v.setMicAutoGate=e=>(t.setMicAutoGate(e),t.getSnapshot().micAutoGate),v.setMicGateThresholdDbfs=e=>(t.setMicGateThresholdDbfs(e),t.getSnapshot().micGateThresholdDbfs),v.micGateState=()=>t.micGateState(),v.micLevelDbfs=()=>t.micLevelDbfs(),v.pipelineMode=()=>{var e;return null!==(e=t.micPipelineMode)&&void 0!==e?e:null},v.ncEngaged=()=>t.ncEngaged(),v.ncDebug=()=>{var e,n,l;let a=t.outboundMic,o=t.getSnapshot(),i=t.lifecycle.room;return{status:o.status,endReason:o.endReason,dial:o.ncLevel,mode:null!==(n=t.micPipelineMode)&&void 0!==n?n:null,hasProcessor:null!==a.micProcessor,upstreamEnabled:null!==(l=null===(e=a.micProcessor)||void 0===e?void 0:e.upstreamEnabled())&&void 0!==l?l:null,pipelineUnavailable:o.micPipelineUnavailable,muted:o.muted,micBlocked:o.micBlocked,hasPublication:!!(null==i?void 0:i.localParticipant.getTrackPublication("microphone"))}};let l=null;v.outboundGapStart=()=>{let e=t.outboundProcessedTrack;return!!e&&(null==l||l.stop(),l=B(e),!0)},v.outboundGapStop=()=>{var e;let t=null!==(e=null==l?void 0:l.read())&&void 0!==e?e:[];return null==l||l.stop(),l=null,t};let a=null;v.outboundBandDb=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:200,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3200,l=t.outboundProcessedTrack;return l?(a&&a.track===l||(a={track:l,read:E(l)}),a.read(e,n)):null};let o=()=>{var e,n,l,a,o;let i=t.outboundProcessedTrack;if(i)return i;let r=t.room;return null!==(o=null==r?void 0:null===(a=r.localParticipant)||void 0===a?void 0:null===(l=a.getTrackPublication)||void 0===l?void 0:null===(n=l.call(a,"microphone"))||void 0===n?void 0:null===(e=n.track)||void 0===e?void 0:e.mediaStreamTrack)&&void 0!==o?o:null},i=null;v.latencyOutboundDetectorStart=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-48,t=o();return!!t&&(null==i||i.stop(),i=I(t,e),!0)}
1,v.setPipelineBypass=e=>(t.setPipelineBypassForLab(e),!0),v.latencyOutboundDetectorStop=()=>{var e;let t=null!==(e=null==i?void 0:i.read())&&void 0!==e?e:[];return null==i||i.stop(),i=null,t};let r=null;v.envelopeOutboundStart=()=>{let e=t.outboundProcessedTrack;return!!e&&(null==r||r.stop(),r=j(e),!0)},v.envelopeOutboundStop=()=>{var e;let t=null!==(e=null==r?void 0:r.read())&&void 0!==e?e:null;return null==r||r.stop(),r=null,t};let s=[],d=e=>{s.push({t:Date.now(),status:e.status,muted:e.muted,micBlocked:e.micBlocked,inputDeviceId:e.inputDeviceId})};d(t.getSnapshot()),t.subscribe(e=>d(e)),v.getSnapshotLog=()=>s,v.rawCaptureDeviceId=async()=>{var e,n,l,a;try{let a=t.room,o=null==a?void 0:null===(l=a.localParticipant)||void 0===l?void 0:null===(n=l.getTrackPublication)||void 0===n?void 0:null===(e=n.call(l,"microphone"))||void 0===e?void 0:e.track;if(!(null==o?void 0:o.getDeviceId))return{ok:!1,error:"no microphone track / getDeviceId"};let i=await o.getDeviceId(!1);return{ok:!0,deviceId:null!=i?i:null}}catch(e){return{ok:!1,error:String(null!==(a=null==e?void 0:e.message)&&void 0!==a?a:e)}}},v.micTruth=()=>{var e,n,l,a,o,i,r;try{let r=t.room,u=null==r?void 0:null===(n=r.localParticipant)||void 0===n?void 0:null===(e=n.getTrackPublication)||void 0===e?void 0:e.call(n,"microphone"),c=null==u?void 0:u.track;return{hasPublication:!!u,trackIsMuted:null!==(a=null==c?void 0:c.isMuted)&&void 0!==a?a:null,rawReadyState:null!==(o=null==c?void 0:null===(l=c._mediaStreamTrack)||void 0===l?void 0:l.readyState)&&void 0!==o?o:null,pendingDeviceChange:null!==(i=null==c?void 0:c.pendingDeviceChange)&&void 0!==i?i:null}}catch(e){return{error:String(null!==(r=null==e?void 0:e.message)&&void 0!==r?r:e)}}}}if("publisher"===r||"mictest"===r){let{MicEchoTest:e}=await n.e(8163).then(n.bind(n,78163)),{classifyMicTestStartFailure:t}=await Promise.resolve().then(n.bind(n,86242)),l=[],a=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=async e=>{let t=await a(e);return t.getAudioTracks().forEach(e=>l.push(e)),t},v.liveCaptureCount=()=>l.filter(e=>"live"===e.readyState).length,v.captureCensus=()=>l.map(e=>({state:e.readyState,label:e.label,settings:e.getSettings()}));let i=[],r=window.AudioContext,s=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let l=new r(...t);return i.push(l),l};s.prototype=r.prototype,window.AudioContext=s,v.openAudioContextCount=()=>i.filter(e=>"closed"!==e.state).length;let d=null,p=0;v.mictestStart=async n=>{null!=d||(d=new e);try{var l,a,i,r;await d.start({inputDevice:{id:null!==(l=n.inputDeviceId)&&void 0!==l?l:null},outputDevice:{id:null!==(a=n.outputDeviceId)&&void 0!==a?a:null},micGain:null!==(i=n.micGain)&&void 0!==i?i:1,masterVolume:null!==(r=n.masterVolume)&&void 0!==r?r:1,micAgc:n.micAgc,micAec:n.micAec,ncLevel:n.ncLevel,gateDial:{auto:!1,thresholdDbfs:o.uY},onEnded:()=>{p+=1},acquireRoomCredentials:async()=>{var e;if(n.roomFail)throw Error("lab: forced credential failure");return{...null!==(e=n.credentials)&&void 0!==e?e:{serverUrl:u,token:c},expiresAt:"",identity:"lab-mictest"}}})}catch(e){return{ok:!1,failure:t(e)}}return{ok:d.running,failure:null}},v.mictestStop=async()=>{var e;return await (null==d?void 0:d.stop()),null!==(e=null==d?void 0:d.running)&&void 0!==e&&e},v.mictestRunning=()=>{var e;return null!==(e=null==d?void 0:d.running)&&void 0!==e&&e},v.mictestEndedCount=()=>p,v.mictestTruth=()=>{var e;return null!==(e=null==d?void 0:d.ncTruth())&&void 0!==e?e:null},v.mictestUsingKrisp=()=>{var e;return null!==(e=null==d?void 0:d.usingKrisp())&&void 0!==e&&e},v.mictestCaptureSettings=()=>{var e;return null!==(e=null==d?void 0:d.sourceCaptureSettings())&&void 0!==e?e:null},v.mictestLevelDbfs=()=>{var e;return null!==(e=null==d?void 0:d.levelDbfs())&&void 0!==e?e:null},v.mictestGate=()=>{var e;return null!==(e=null==d?void 0:d.gateState())&&void 0!==e?e:null},v.mictestAutoThresholdDbfs=()=>{var e;return null!==(e=null==d?void 0:d.autoThresholdDbfs())&&void 0!==e?e:null},v.mictestSetNcLevel=e=>!!d&&(d.setNcLevel(e),!0),v.mictestSetMicAgc=e=>!!d&&(d.setMicAgc(e),!0),v.mictestSetMicAec=e=>!!d&&(d.setMicAec(e),!0),v.mictestSetGain=e=>!!d&&(d.setMicGain(e),!0),v.mictestSetMasterVolume=e=>!!d&&(d.setMasterVolume(e),!0),v.mictestSetGateDial=e=>!!d&&(d.setGateDial(e),!0),v.mictestSetInputDevice=e=>d?d.setInputDevice({id:e}).then(()=>({ok:!0}
1),e=>({ok:!1,error:String(null==e?void 0:e.message)})):Promise.resolve({ok:!1,error:"no engine"}),v.mictestSetOutputDevice=e=>{var t;return null!==(t=null==d?void 0:d.setOutputDevice({id:e}))&&void 0!==t?t:Promise.resolve()},v.captureToneDb=async e=>{let t=F((await a({audio:{deviceId:{exact:e},echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}})).getAudioTracks()[0]);return v.localToneDb=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:700;return t(e)},!0}}if("applistener"===r&&(v.captureToneDb=async e=>{let t=F((await navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:e},echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}})).getAudioTracks()[0]);return v.localToneDb=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:700;return t(e)},!0}),"listener"===r||"tonepub"===r){let t=await Promise.resolve().then(n.bind(n,80758)),l=new t.Room;if(await l.connect(u,c,{autoSubscribe:!0}),v.roomState=()=>l.state,v.remoteAttributes=e=>{var t;let n=l.remoteParticipants.get(e);return n?{...null!==(t=n.attributes)&&void 0!==t?t:{}}:null},v.inboundAudioStats=async()=>{for(let n of Array.from(l.remoteParticipants.values()))for(let l of Array.from(n.audioTrackPublications.values())){var e,t;let n=await (null===(t=l.track)||void 0===t?void 0:null===(e=t.getRTCStatsReport)||void 0===e?void 0:e.call(t).catch(()=>null));if(n){for(let e of Array.from(n.values()))if("inbound-rtp"===e.type&&"audio"===e.kind)return{t:Date.now(),packetsReceived:e.packetsReceived,packetsLost:e.packetsLost,jitter:e.jitter,concealedSamples:e.concealedSamples,concealmentEvents:e.concealmentEvents,insertedSamplesForDeceleration:e.insertedSamplesForDeceleration,removedSamplesForAcceleration:e.removedSamplesForAcceleration,jitterBufferDelay:e.jitterBufferDelay,jitterBufferEmittedCount:e.jitterBufferEmittedCount,totalSamplesReceived:e.totalSamplesReceived}}}return null},v.resubscribeAudio=async()=>{for(let e of Array.from(l.remoteParticipants.values()))for(let t of Array.from(e.audioTrackPublications.values()))if(t.setSubscribed)return t.setSubscribed(!1),await new Promise(e=>setTimeout(e,150)),t.setSubscribed(!0),!0;return!1},"listener"===r){let e=null,n=null,a=null,o=t=>{var l;n=t.mediaStreamTrack,a=null!==(l=t.receiver)&&void 0!==l?l:null,e=F(t.mediaStreamTrack),v.remoteToneDb=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:700;return e?e(t):-200},i=null},i=null;v.remoteBandDb=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:200,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3200;return!i&&n&&(i=E(n)),i?i(e,t):-200};let r=null,u=[];v.recordRemoteStart=()=>!!n&&(u=[],(r=new MediaRecorder(new MediaStream([n]),{mimeType:"audio/webm;codecs=opus"})).ondataavailable=e=>{e.data.size&&u.push(e.data)},r.start(1e3),!0),v.recordRemoteStop=async()=>{let e=r;if(r=null,!e)return null;await new Promise(t=>{e.onstop=()=>t(),e.stop()});let t=new Blob(u,{type:"audio/webm"}),n=new Uint8Array(await t.arrayBuffer()),l="";for(let e=0;e<n.length;e+=32768)l+=String.fromCharCode(...Array.from(n.subarray(e,e+32768)));return btoa(l)};let c=null;v.latencyRemoteDetectorStart=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-48;return!!n&&(null==c||c.stop(),c=I(n,e),!0)},v.latencyRemoteDetectorStop=()=>{var e;let t=null!==(e=null==c?void 0:c.read())&&void 0!==e?e:[];return null==c||c.stop(),c=null,t};let s=null;v.envelopeRemoteStart=()=>!!n&&(null==s||s.stop(),s=j(n),!0),v.setJitterBufferTargetMs=e=>{var t;let n=a;return n&&"jitterBufferTarget"in n?(n.jitterBufferTarget=e,null!==(t=n.jitterBufferTarget)&&void 0!==t?t:null):null},v.envelopeRemoteStop=()=>{var e;let t=null!==(e=null==s?void 0:s.read())&&void 0!==e?e:null;return null==s||s.stop(),s=null,t};let d=null;v.remoteGapStart=()=>!!n&&(null==d||d.stop(),d=B(n),!0),v.remoteGapStop=()=>{var e;let t=null!==(e=null==d?void 0:d.read())&&void 0!==e?e:[];return null==d||d.stop(),d=null,t};let p=[],m=null;v.startBandLog=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:200,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3200,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:100;return p=[],m&&clearInterval(m),m=setInterval(()=>{let n=v.remoteBandDb(e,t);p.push({t:Date.now(),db:n})},n),!0},v.stopBandLog=()=>(m&&clearInterval(m),m=null,p.slice()),v.remoteAudioPresence=()=>n?{state:n.readyState,muted:n.muted}:{state:"no-track",muted:!1},l.on(t.RoomEvent.TrackSubscribed,e=>{e.kind===t.Track.Kind.Audio&&o(e)}),l.on(t.RoomEvent.TrackUnsubscribed,l=>{l.kind===t.Track.Kind.Audio&&n===l.mediaStreamTrack&&(n=null,e=null,i=null)}
1),l.remoteParticipants.forEach(e=>{e.audioTrackPublications.forEach(e=>{e.track&&o(e.track)})})}if("tonepub"===r){let n=new AudioContext,o=n.createMediaStreamDestination(),i=n.createOscillator();i.frequency.value=700;let r=n.createGain(),u=Number(null!==(a=e.get("tonegain"))&&void 0!==a?a:"0.5");r.gain.value=Number.isFinite(u)&&u>0&&u<=1?u:.5,i.connect(r),r.connect(o),i.start(),await l.localParticipant.publishTrack(o.stream.getAudioTracks()[0],{source:t.Track.Source.Microphone})}}null===(t=v.setMicAutoGate)||void 0===t||t.call(v,!1),null===(l=v.setMicGateThresholdDbfs)||void 0===l||l.call(v,o.uY),v.ready=!0,s("ready role=".concat(r))})().catch(e=>{var t,n;d.push(String(null!==(t=null==e?void 0:e.message)&&void 0!==t?t:e)),s("boot failed: ".concat(String(null!==(n=null==e?void 0:e.message)&&void 0!==n?n:e)))})},[e]),(0,l.jsxs)("div",{style:{fontFamily:"monospace",padding:24,color:"#ddd",background:"#111",minHeight:"100vh"},children:[(0,l.jsx)("h1",{children:"voice lab"}),(0,l.jsx)("p",{"data-testid":"lab-status",children:t})]})}}},function(e){e.O(0,[2888,9774,179],function(){return e(e.s=27174)}),_N_E=e.O()}]);
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.