@vanira/sdk 0.0.87 → 0.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/headless/index.cjs +1 -1
- package/dist/headless/index.js +36 -33
- package/dist/index.d.ts +4 -0
- package/dist/platforms/browser.cjs +1 -1
- package/dist/platforms/browser.js +36 -33
- package/dist/platforms/react-native.cjs +2 -2
- package/dist/platforms/react-native.js +301 -298
- package/dist/vanira-sdk.es.js +3885 -3879
- package/dist/vanira-sdk.js +1 -1
- package/dist/vanira-sdk.umd.js +85 -85
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<p style="margin:12px 0 0;font-size:12px;color:#888">
|
|
15
15
|
Tip: Ctrl+Shift+R (Windows) or Cmd+Shift+R (Mac)
|
|
16
16
|
</p>
|
|
17
|
-
`,i.appendChild(e),document.body.appendChild(i),(t=e.querySelector("#vanira-stall-refresh"))==null||t.addEventListener("click",()=>{fs(),window.location.reload()}),(n=e.querySelector("#vanira-stall-dismiss"))==null||n.addEventListener("click",()=>fs())}function xd(i){return null}function Nn(){return typeof window>"u"?"/":`${window.location.pathname}${window.location.search}${window.location.hash}`||"/"}class Ld{constructor(e){D(this,"active",!1);D(this,"initialSent",!1);D(this,"lastRoute","");D(this,"sendContext");D(this,"isReady");D(this,"cleanupFns",[]);D(this,"initialRetryTimer",null);D(this,"routePollTimer",null);D(this,"originalPushState",null);D(this,"originalReplaceState",null);this.sendContext=e.sendContext,this.isReady=e.isReady??(()=>!0)}start(){typeof window>"u"||this.active||(this.active=!0,this.initialSent=!1,this.lastRoute=Nn(),this.attachListeners(),this.scheduleInitialContextSend())}stop(){if(!(!this.active&&this.cleanupFns.length===0)){this.active=!1,this.initialSent=!1,this.initialRetryTimer!==null&&(clearTimeout(this.initialRetryTimer),this.initialRetryTimer=null),this.routePollTimer!==null&&(clearInterval(this.routePollTimer),this.routePollTimer=null);for(const e of this.cleanupFns)try{e()}catch{}this.cleanupFns.length=0,this.originalPushState&&(history.pushState=this.originalPushState,this.originalPushState=null),this.originalReplaceState&&(history.replaceState=this.originalReplaceState,this.originalReplaceState=null)}}onChannelReady(){this.scheduleInitialContextSend()}scheduleInitialContextSend(e=0){if(!(!this.active||this.initialSent)){if(this.isReady()){this.sendRouteContext("call_started"),this.initialSent=!0;return}e>=30||(this.initialRetryTimer=window.setTimeout(()=>this.scheduleInitialContextSend(e+1),100))}}attachListeners(){const e=(r,a=0)=>{const o=()=>{const d=Nn();d!==this.lastRoute&&this.handleRouteChange(d,r)};a>0?window.setTimeout(o,a):queueMicrotask(o)},t=()=>e("popstate"),n=()=>e("hashchange"),s=r=>{const a=r.detail;if((a==null?void 0:a.initiated_by)==="agent"){e("vanira_navigate_agent",120);return}e("vanira_navigate",120)};window.addEventListener("popstate",t),window.addEventListener("hashchange",n),window.addEventListener("vanira:navigate",s),this.cleanupFns.push(()=>window.removeEventListener("popstate",t),()=>window.removeEventListener("hashchange",n),()=>window.removeEventListener("vanira:navigate",s)),this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history),history.pushState=(...r)=>{this.originalPushState(...r),e("pushState")},history.replaceState=(...r)=>{this.originalReplaceState(...r),e("replaceState")},this.routePollTimer=window.setInterval(()=>{if(!this.active)return;const r=Nn();r!==this.lastRoute&&this.handleRouteChange(r,"location_poll")},1e3)}handleRouteChange(e,t){if(!this.active)return;const n=this.lastRoute;if(n===e)return;if(this.lastRoute=e,!this.initialSent){this.scheduleInitialContextSend();return}!this.isReady()||xd()||this.sendRouteContext("route_changed",n,t,"user")}sendRouteContext(e,t,n,s="user"){const r=Nn();this.lastRoute=r;const a={ui_state:"page_navigation",navigation_led_by:s,current_route:r,current_page:r,user_action:e==="call_started"?"call_started_on_page":"user_navigated"};e==="call_started"?a.message=`User started the call while viewing ${r}.`:(a.previous_route=t??"",a.message=`User navigated from ${t||"(unknown)"} to ${r}.`,n&&(a.navigation_source=n));try{this.sendContext(a)}catch{}}}const st=class st{constructor(e){D(this,"serverUrl");D(this,"agentId");D(this,"callId");D(this,"prospectId");D(this,"apiKey");D(this,"backendUrl");D(this,"token");D(this,"prospectName");D(this,"extraDetails");D(this,"onConnected");D(this,"onDisconnected");D(this,"onError");D(this,"onTranscription");D(this,"onLocalStream");D(this,"onRemoteTrack");D(this,"onClientToolCall");D(this,"onSessionStarted");D(this,"sessionStartedEmitted",!1);D(this,"pc",null);D(this,"dataChannel",null);D(this,"mediaBytesChannel",null);D(this,"audioElement",null);D(this,"localStream",null);D(this,"micMuted",!1);D(this,"connected",!1);D(this,"appliedRemoteCandidates",new Set);D(this,"remoteDescSet",!1);D(this,"pendingServerIce",[]);D(this,"icePollStop",!1);D(this,"iceServers");D(this,"callSessionLoaded",!1);D(this,"connectGeneration",0);D(this,"runtime");D(this,"sessionBehavior");D(this,"routeTracker",null);D(this,"_status","idle");D(this,"listeners",new Map);D(this,"liveVision");D(this,"liveVisionAutoStarted",!1);D(this,"connectStallTimeoutMs");if(!e.agentId)throw new Error("agentId is required");const t=!!(e.apiKey||e.token),n=!!(e.serverUrl&&e.callId),s=st.normalizeIceServers(e.iceServers);if(!t&&!n)throw new Error("apiKey or token is required — or pass serverUrl and callId from a prior POST /calls/create");this.agentId=e.agentId,this.sessionBehavior=e.sessionBehavior,this.serverUrl=(e.serverUrl||"").replace(/\/$/,""),this.apiKey=e.apiKey,this.token=e.token,this.prospectName=e.prospectName,this.extraDetails=e.extraDetails,this.backendUrl=(e.backendUrl||Ws).replace(/\/$/,""),s.length&&(this.iceServers=s),n&&(this.callSessionLoaded=!0);const r=typeof window<"u";this.prospectId=e.prospectId;const a=e.sessionBehavior==="continue";if(a&&r&&!e.callId){const d=Pr(this.agentId);d&&(e.callId||(this.callId=d.callId),!this.prospectId&&d.prospectId&&(this.prospectId=d.prospectId))}if(!this.prospectId&&r)try{const d=Pr(this.agentId);this.prospectId=(d==null?void 0:d.prospectId)||window.sessionStorage&&window.sessionStorage.getItem("vanira_prospect_id")||window.localStorage&&window.localStorage.getItem("vanira_prospect_id")||void 0}catch{}e.callId?this.callId=e.callId:a||(this.callId=void 0);const o=e.onSessionStarted;this.onSessionStarted=d=>{o==null||o(d),this.emit("session_started",d)},this.liveVision=e.liveVision,this.connectStallTimeoutMs=e.connectStallTimeoutMs??15e3,this.onConnected=()=>{var d;fn(),this._status="connected",(d=e.onConnected)==null||d.call(e),this.emit("connected"),this.maybeAutoStartLiveCamera()},this.onDisconnected=()=>{var d;fn(),this._status="disconnected",(d=e.onDisconnected)==null||d.call(e),this.emit("disconnected")},this.onError=d=>{var l;fn(),this._status="error";const c=typeof d=="string"?d:(d==null?void 0:d.message)||"Connection error";(l=e.onError)==null||l.call(e,d),this.emit("error",c)},this.onTranscription=(d,c,l)=>{var u;(u=e.onTranscription)==null||u.call(e,d,c),this.emit("transcription",{text:d,isFinal:c,role:l})},this.onLocalStream=e.onLocalStream||(()=>{}),this.onRemoteTrack=(d,c)=>{var l;(l=e.onRemoteTrack)==null||l.call(e,d,c),this.emit("track",{track:d,stream:c})},this.onClientToolCall=d=>{var u;(u=e.onClientToolCall)==null||u.call(e,d);const c=(d==null?void 0:d.data)||d,l={name:String(c.name||c.tool_name||""),arguments:c.arguments||c.args||{},tool_call_id:String(c.tool_call_id||c.call_id||""),execution_mode:c.execution_mode==="blocking"?"blocking":"fire_and_forget",client_fields:c.client_fields||{}};l.name&&l.tool_call_id&&this.emit("tool_call",l)},this.runtime=e.runtime,typeof window<"u"&&e.trackRouteContext!==!1&&(this.routeTracker=new Ld({sendContext:d=>this.sendContextUpdate(d),isReady:()=>{var d;return((d=this.dataChannel)==null?void 0:d.readyState)==="open"}}))}async createCall(){return this.connect()}async connect(){var t;this._status="connecting",this.connectStallTimeoutMs>0&&Ad(this.connectStallTimeoutMs);const e=++this.connectGeneration;if(await this.loadCallSession(),!this.isConnectCancelled(e)){if(!this.serverUrl)throw new Error("[VaniraClient] worker_url missing from /calls/create");if(!this.callId)throw new Error("[VaniraClient] call_id missing — must come from POST /calls/create");if(this.onSessionStarted&&this.prospectId&&this.callId&&!this.sessionStartedEmitted)try{this.onSessionStarted({prospectId:this.prospectId,callId:this.callId,serverUrl:this.serverUrl}),this.sessionStartedEmitted=!0}catch{}try{this.appliedRemoteCandidates.clear(),this.remoteDescSet=!1,this.pendingServerIce=[],this.icePollStop=!1,this.stopRemoteIcePolling();const n=this.getIceServers();this.pc=new RTCPeerConnection({iceServers:n,iceTransportPolicy:"all"});let s;try{s=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:{ideal:16e3},channelCount:1}})}catch(u){if(u.name==="NotAllowedError"||u.name==="PermissionDeniedError"||(t=u.message)!=null&&t.includes("Permission denied")){const h=navigator.userAgent,p=/iPad|iPhone|iPod/.test(h)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;let g="Microphone access denied. Please allow microphone access in your browser settings.";p&&(h.includes("CriOS")?g="Microphone access blocked. Please enable it in iOS Settings > Chrome > Microphone, then reload the page.":h.includes("FxiOS")?g="Microphone access blocked. Please enable it in iOS Settings > Firefox > Microphone, then reload the page.":g="Microphone access blocked. Please enable it in iOS Settings > Safari > Microphone (or tap 'aA' > Website Settings > Allow Microphone).");const m=new Error(g);throw m.name=u.name,m}throw u}if(this.isConnectCancelled(e)){s.getTracks().forEach(u=>u.stop());return}if(this.localStream=s,!this.pc||this.isConnectCancelled(e)){s.getTracks().forEach(u=>u.stop());return}if(this.onLocalStream(s),s.getTracks().forEach(u=>{var h;(h=this.pc)==null||h.addTrack(u,s)}),!this.pc)throw new Error("RTCPeerConnection was closed unexpectedly");this.dataChannel=this.pc.createDataChannel("control"),this.dataChannel.onopen=()=>{var u;(u=this.routeTracker)==null||u.onChannelReady()},this.dataChannel.onmessage=u=>{if(typeof u.data=="string")try{this.handleControlEvent(JSON.parse(u.data))}catch{}else if(u.data instanceof ArrayBuffer)try{const h=new TextDecoder().decode(u.data);try{const p=JSON.parse(h);Xa(p)&&this.handleControlEvent(p)}catch{}}catch{}else u.data instanceof Blob&&u.data.text().then(h=>{try{this.handleControlEvent(JSON.parse(h))}catch{}})},this.dataChannel.onerror=u=>{},this.mediaBytesChannel=this.pc.createDataChannel("media-bytes",{ordered:!0}),this.mediaBytesChannel.binaryType="arraybuffer",this.mediaBytesChannel.onopen=()=>{},this.mediaBytesChannel.onerror=u=>{},this.pc.ontrack=u=>{const h=u.track,p=u.streams[0];h.kind==="audio"?(this.audioElement=new Audio,this.audioElement.srcObject=p,this.audioElement.play().catch(g=>{}),this.audioElement.onended=()=>{this.sendEvent("playedStream"),typeof window<"u"&&window.dispatchEvent(new CustomEvent("vanira:agent-playback-ended"))},this.onRemoteTrack(h,p)):h.kind==="video"&&this.onRemoteTrack(h,p)};const r=()=>{var p,g,m,T,k,S,L,v,y,C,I;const u=((p=this.pc)==null?void 0:p.connectionState)==="connected"||((g=this.pc)==null?void 0:g.iceConnectionState)==="connected"||((m=this.pc)==null?void 0:m.iceConnectionState)==="completed",h=((T=this.pc)==null?void 0:T.connectionState)==="failed"||((k=this.pc)==null?void 0:k.iceConnectionState)==="failed"||((S=this.pc)==null?void 0:S.connectionState)==="closed"||((L=this.pc)==null?void 0:L.iceConnectionState)==="closed"||((v=this.pc)==null?void 0:v.connectionState)==="disconnected"||((y=this.pc)==null?void 0:y.iceConnectionState)==="disconnected";((C=this.pc)==null?void 0:C.connectionState)==="connected"&&this.stopRemoteIcePolling(),u&&!this.connected?(this.connected=!0,(I=this.routeTracker)==null||I.start(),this.onConnected()):h&&this.connected&&(this.connected=!1,this.liveVisionAutoStarted=!1,this.onDisconnected())};this.pc.onconnectionstatechange=r,this.pc.oniceconnectionstatechange=r;const a=this.getIceTrickleUrl();this.pc.onicecandidate=u=>{u.candidate&&this.sendRemoteIceCandidate(u.candidate,a)};const o=await this.pc.createOffer();if(this.isConnectCancelled(e)||(await this.pc.setLocalDescription(o),this.isConnectCancelled(e)))return;const d=this.serverUrl.includes("?")?this.serverUrl:`${this.serverUrl}/webrtc?agent=${this.agentId}_${this.callId}`,c=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({offer:this.pc.localDescription,agentId:this.agentId,callId:this.callId})});if(this.isConnectCancelled(e))return;if(!c.ok){const u=await c.json();throw new Error(u.error||`HTTP ${c.status}`)}const{answer:l}=await c.json();if(this.isConnectCancelled(e)||!this.pc||(await this.pc.setRemoteDescription(l),this.isConnectCancelled(e))||(this.remoteDescSet=!0,await this.flushPendingServerIce(),this.isConnectCancelled(e)))return;this.startRemoteIcePolling(a)}catch(n){if(this.isConnectCancelled(e))return;throw this.disconnect(),this.onError(n.message||n),n}}}createCallCacheKey(e,t){const n=this.apiKey?`key:${this.apiKey.slice(0,16)}`:`token:${(this.token||"").slice(-16)}`;return[this.backendUrl,this.agentId,e,t||"",this.prospectId||"",n].join("|")}async postCreateCall(e,t,n){var o,d,c;const s=await fetch(`${this.backendUrl}/calls/create`,{method:"POST",headers:e,body:JSON.stringify({agent_id:this.agentId,type:((o=this.runtime)==null?void 0:o.callType)||"web",mode:t,...(d=this.runtime)!=null&&d.runtimeName?{runtime:this.runtime.runtimeName}:{},prospect_id:this.prospectId,...this.prospectName?{prospect_name:this.prospectName}:{},...this.extraDetails&&Object.keys(this.extraDetails).length?{extra_details:this.extraDetails}:{},...n?{call_id:n}:{}})});if(!s.ok){const l=await s.json().catch(()=>({}));throw new Error(`[VaniraClient] createCall failed (${s.status}): ${((c=l==null?void 0:l.detail)==null?void 0:c.message)||(l==null?void 0:l.message)||s.statusText}`)}const r=await s.json();if(!r.call_id||!r.worker_url)throw new Error("[VaniraClient] /calls/create response missing call_id or worker_url");const a=st.normalizeIceServers(r.ice_servers);if(!a.length)throw new Error("[VaniraClient] /calls/create response missing ice_servers");return{callId:r.call_id,prospectId:r.prospect_id||this.prospectId,serverUrl:r.worker_url.replace(/\/$/,""),iceServers:a}}applyCreateCallSession(e){if(this.callId=e.callId,this.prospectId=e.prospectId||this.prospectId,this.serverUrl=e.serverUrl,this.iceServers=e.iceServers,this.callSessionLoaded=!0,wd(this.agentId,this.callId||"",this.prospectId),this.onSessionStarted&&this.prospectId&&this.callId&&!this.sessionStartedEmitted)try{this.onSessionStarted({prospectId:this.prospectId,callId:this.callId,serverUrl:this.serverUrl}),this.sessionStartedEmitted=!0}catch{}}async loadCallSession(){if(this.callSessionLoaded)return;if(this.serverUrl&&this.callId){this.callSessionLoaded=!0;return}if(!this.apiKey&&!this.token)throw new Error("[VaniraClient] apiKey or token is required to create a call session");const e={"Content-Type":"application/json"};this.apiKey?e["X-API-Key"]=this.apiKey:this.token&&(e.Authorization=this.token.startsWith("Bearer ")?this.token:`Bearer ${this.token}`);const t=this.sessionBehavior==="continue"?this.callId:void 0,n=this.sessionBehavior==="continue"?"continue":"new",s=this.createCallCacheKey(n,t);let r=st.inflightCreates.get(s);r||(r=this.postCreateCall(e,n,t),st.inflightCreates.set(s,r),r.finally(()=>{st.inflightCreates.get(s)===r&&st.inflightCreates.delete(s)}));const a=await r;this.applyCreateCallSession(a)}getIceServers(){var e;if((e=this.iceServers)!=null&&e.length)return this.iceServers;throw new Error("[VaniraClient] ice_servers missing — pass iceServers from POST /calls/create")}static normalizeIceServers(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const s=n==null?void 0:n.urls,r=Array.isArray(s)?s.filter(Boolean):typeof s=="string"&&s.trim()?[s.trim()]:[];if(!r.length)continue;const a={urls:r.length===1?r[0]:r},o=n.username,d=n.credential;o&&(a.username=o),d&&(a.credential=d),t.push(a)}return t}getWorkerOrigin(){var e;if(!((e=this.serverUrl)!=null&&e.trim()))return"";try{return new URL(this.serverUrl).origin}catch{return this.serverUrl.replace(/\/webrtc.*$/,"").replace(/\/$/,"")}}getIceTrickleUrl(){try{const e=new URL(this.serverUrl);return e.pathname.endsWith("/webrtc")?e.pathname=`${e.pathname}/ice`:e.pathname="/webrtc/ice",e.toString()}catch{return`${this.getWorkerOrigin()}/webrtc/ice?agent_id=${this.agentId}&call_id=${this.callId}`}}async sendRemoteIceCandidate(e,t){try{const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({candidate:e.toJSON()})});if(n.ok){const s=await n.json();await this.applyServerIceCandidates(s.candidates)}}catch{}}async applyServerIceCandidates(e){if(!(!this.pc||!(e!=null&&e.length))){if(!this.remoteDescSet){this.pendingServerIce.push(...e);return}for(const t of e){const n=JSON.stringify(t);if(!this.appliedRemoteCandidates.has(n)){this.appliedRemoteCandidates.add(n);try{await this.pc.addIceCandidate(t)}catch{}}}}}async flushPendingServerIce(){if(!this.pc||!this.remoteDescSet||this.pendingServerIce.length===0)return;const e=this.pendingServerIce;this.pendingServerIce=[];for(const t of e){const n=JSON.stringify(t);if(!this.appliedRemoteCandidates.has(n)){this.appliedRemoteCandidates.add(n);try{await this.pc.addIceCandidate(t)}catch{}}}}startRemoteIcePolling(e){this.icePollStop=!1,this.pollServerIce(e)}async pollServerIce(e){var n;const t=Date.now()+15e3;for(;!this.icePollStop&&Date.now()<t;){const s=(n=this.pc)==null?void 0:n.connectionState;if(s==="connected"||s==="failed"||s==="closed")break;try{const r=await fetch(e,{method:"GET"});if(r.ok){const a=await r.json();if(await this.applyServerIceCandidates(a.candidates),a.done&&(!a.candidates||a.candidates.length===0))break}}catch{}await new Promise(r=>setTimeout(r,150))}}stopRemoteIcePolling(){this.icePollStop=!0}sendEvent(e,t={}){var n;if(((n=this.dataChannel)==null?void 0:n.readyState)==="open"){const s={event:e,...t};this.dataChannel.send(JSON.stringify(s))}}async sendEventWhenReady(e,t={},n=1e4){var r;const s=Date.now()+n;for(;Date.now()<s;){if(((r=this.dataChannel)==null?void 0:r.readyState)==="open")return this.sendEvent(e,t),!0;await new Promise(a=>setTimeout(a,50))}return!1}startLiveCamera(e={}){const t={...this.liveVision,...e};this.emit("tool_call",this.buildOpenLiveCameraToolCall(t))}buildOpenLiveCameraToolCall(e={}){const t=e.scope??"until_call_end";return{name:"open_live_camera",tool_call_id:`lv_${crypto.randomUUID()}`,execution_mode:"fire_and_forget",client_fields:{preset_id:N.LiveVision},arguments:{mode:"live",scope:t,target_fps:e.target_fps??1,max_fps:e.max_fps??3,max_width:e.max_width??640,reason:e.reason??"camera_capture",facing_mode:e.facing_mode??"environment",show_preview:e.show_preview??!0,...t==="timed"&&e.duration_sec?{duration_sec:e.duration_sec}:{}}}}maybeAutoStartLiveCamera(){const e=this.liveVision;!(e!=null&&e.enabled)||e.scope!=="full_call"||this.liveVisionAutoStarted||(this.liveVisionAutoStarted=!0,this.emit("tool_call",this.buildOpenLiveCameraToolCall(e)))}handleControlEvent(e){var t;switch(e.event){case"clearAudio":this.dispatchBoardAbort("User interrupted while LaTeX was writing",void 0,N.WriteLatexText);break;case"transcription":{const n=e.data&&typeof e.data=="object"?e.data:{},s=String(e.text??n.text??"").trim(),r=e.isFinal??e.is_final??n.isFinal??n.is_final,a=r===void 0?!0:r===!0||r==="true",o=String(e.role??e.speaker??n.role??n.speaker??"").trim()||void 0;s&&this.onTranscription(s,a,o)}break;case"mark":break;case"client_tool_cancel":{const s=(e.data||e).tool_call_id||e.tool_call_id;this.dispatchBoardAbort("Tool cancelled by server",s);break}case"client_tool_call":{const n=e.tool_call||e.data||e,s=(n==null?void 0:n.tool_call_id)||(n==null?void 0:n.call_id)||e.tool_call_id||"";s&&((t=this.dataChannel)==null?void 0:t.readyState)==="open"&&this.dataChannel.send(JSON.stringify({event:"client_tool_ack",data:{tool_call_id:s}}));const r=(n==null?void 0:n.arguments)||(n==null?void 0:n.args)||{},a=(n==null?void 0:n.client_fields)||{},o=(n==null?void 0:n.name)||(n==null?void 0:n.tool_name)||"",d=_d(a,r,o);if(o==="end_call"){s&&this.sendToolResult(s,{status:"client_ack_end_call",message:"Ending call."}),window.setTimeout(()=>this.disconnect(),120);break}if(d){window.dispatchEvent(new CustomEvent("vanira:preset",{detail:{toolCall:n,client:this}})),this.onClientToolCall(n);break}this.onClientToolCall(n);break}}}disconnect(){var e;fn(),this.connectGeneration++,this.stopRemoteIcePolling(),this.appliedRemoteCandidates.clear(),this.remoteDescSet=!1,this.pendingServerIce=[],this.audioElement&&(this.audioElement.pause(),this.audioElement.srcObject=null),this.dataChannel&&(this.dataChannel.close(),this.dataChannel=null),this.mediaBytesChannel&&(this.mediaBytesChannel.close(),this.mediaBytesChannel=null),this.pc&&(this.pc.getSenders().forEach(t=>{t.track&&t.track.stop()}),this.pc.close(),this.pc=null),this.localStream&&(this.localStream.getTracks().forEach(t=>{try{t.stop()}catch{}}),this.localStream=null),this.connected=!1,(e=this.routeTracker)==null||e.stop(),this.callSessionLoaded=!1,this.sessionStartedEmitted=!1,this.serverUrl="",this.callId=void 0,this.micMuted=!1,this.iceServers=void 0,this.onDisconnected()}setMicrophoneMuted(e){var t,n;this.micMuted=e,(t=this.localStream)==null||t.getAudioTracks().forEach(s=>{s.enabled=!e}),(n=this.pc)==null||n.getSenders().forEach(s=>{var r;((r=s.track)==null?void 0:r.kind)==="audio"&&(s.track.enabled=!e)})}isMicrophoneMuted(){return this.micMuted}toggleMicrophoneMuted(){return this.setMicrophoneMuted(!this.micMuted),this.micMuted}isConnectCancelled(e){return e!==this.connectGeneration}dispatchBoardAbort(e,t,n){typeof window>"u"||window.dispatchEvent(new CustomEvent("vanira:board_abort",{detail:{reason:e,toolCallId:t,presetId:n}}))}sendToolResult(e,t){this.callId,this.sendEvent("client_tool_result",{call_id:this.callId,data:{tool_call_id:e,result:t},result:t}),this.emit("tool_result",{toolCallId:e,result:t})}sendToolAck(e){var t;((t=this.dataChannel)==null?void 0:t.readyState)==="open"&&this.dataChannel.send(JSON.stringify({event:"client_tool_ack",data:{tool_call_id:e}}))}sendContextUpdate(e){this.sendEvent("client_context_update",{data:{context:e}})}sendActionTrigger(e,t={}){this.sendEvent("client_action_trigger",{data:{action_name:e,data:t}})}triggerActionInterrupt(){this.sendEvent("action_interrupt")}sendMediaUpdate(e){if(!this.dataChannel||this.dataChannel.readyState!=="open")return!1;const t={event:"client_media_update",data:{media_id:e.media_id,media_url:e.media_url,content_type:e.content_type,reason:e.reason,message:e.message??""}};return this.dataChannel.send(JSON.stringify(t)),!0}async uploadMediaForToolResult(e,t="general"){return this._postMediaUpload(e,t)}async uploadMedia(e,t="general",n=""){return await Rd(this.dataChannel,this.mediaBytesChannel)?this._uploadMediaViaDataChannel(e,t,n):(Pd(this.dataChannel,this.mediaBytesChannel),this._uploadMediaViaHTTP(e,t,n))}async uploadMediaFrame(e,t="camera_capture",n){const s=n&&!(e instanceof File)?new File([e],n,{type:e.type||"image/jpeg"}):e,{media_id:r,url:a,contentType:o}=await this._postMediaUpload(s,t,!0);if(!r||!a)throw new Error("Frame upload failed: server response missing media_id or url");return{media_id:r,url:a,content_type:o}}async _uploadBytesViaDataChannel(e,t,n,s,r){if(!this.callId||!this.mediaBytesChannel)throw new Error("Upload failed: call not ready for WebRTC media upload.");const a=r||(e instanceof File?e.name:s==="frame"?"frame.jpg":"upload.bin"),o=e.type||(s==="frame"?"image/jpeg":"application/octet-stream"),d=await Md(e);return Id({bytes:d,filename:a,contentType:o,reason:t,message:n,callId:this.callId,mediaBytesChannel:this.mediaBytesChannel,sendControlEvent:(c,l)=>this.sendEvent(c,l),uploadKind:s})}async _uploadMediaViaDataChannel(e,t,n){const s=await this._uploadBytesViaDataChannel(e,t,n,"media");return{media_id:s.media_id,url:s.url}}async _uploadMediaViaHTTP(e,t="general",n=""){const{media_id:s,url:r,contentType:a}=await this._postMediaUpload(e,t,!0);return this.sendMediaUpdate({media_id:s,media_url:r,content_type:a,reason:t,message:n}),{media_id:s,url:r}}async _postMediaUpload(e,t,n=!1){if(!this.serverUrl)throw new Error("Upload failed: serverUrl is not set. Connect the VaniraClient first.");if(!this.callId)throw new Error("Upload failed: callId is missing.");const s=this.getWorkerOrigin();if(!s)throw new Error("Upload failed: worker_url is not set. Connect the call before uploading media.");const r=`${s}/media/upload`,a=new FormData;a.append("file",e),a.append("call_id",this.callId),a.append("reason",t);const o=await fetch(r,{method:"POST",body:a});if(!o.ok){let h=`HTTP ${o.status}`;try{h=(await o.json()).error||h}catch{}throw new Error(`Upload failed: ${h}`)}const d=await o.json(),c=d.media_id,l=d.url,u=d.content_type||e.type;if(!c||!l)throw new Error("Upload failed: server response missing media_id or url");return n?{media_id:c,url:l,contentType:u}:{media_id:c,url:l,contentType:u}}get status(){return this._status}get isConnected(){return this._status==="connected"}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),this}off(e,t){var n;return(n=this.listeners.get(e))==null||n.delete(t),this}emit(e,t){var n;(n=this.listeners.get(e))==null||n.forEach(s=>s(t))}async start(){return await this.connect(),{callId:this.callId||"",prospectId:this.prospectId||"",serverUrl:this.serverUrl||""}}stop(){this.disconnect(),this._status="disconnected"}sendToolError(e,t){this.sendToolResult(e,{status:"error",error:t})}updateContext(e){this.sendContextUpdate(e)}triggerInterrupt(e,t={}){this.triggerActionInterrupt(),this.sendActionTrigger(e,t)}interruptAudioOnly(){this.triggerActionInterrupt()}};D(st,"inflightCreates",new Map);let Qt=st;var Ja;const no={supportsAudioEndedEvent:!0,supportsScreenShare:typeof navigator<"u"&&typeof((Ja=navigator.mediaDevices)==null?void 0:Ja.getDisplayMedia)=="function",supportsDom:typeof document<"u",supportsHtmlAudio:typeof Audio<"u",supportsCustomElements:typeof customElements<"u",supportsLocalStorage:typeof localStorage<"u",supportsBroadcastChannel:typeof BroadcastChannel<"u"},io={name:"browser",callType:"web",runtimeName:"browser",callIdPrefix:"web_",capabilities:no,audio:new $a,media:new Ya,peer:new Qa,dataChannel:new Za};function so(i){return new Qt({...i,runtime:io})}const Nd=so;function Ud(i,e){return e.forEach(function(t){t&&typeof t!="string"&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if(n!=="default"&&!(n in i)){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(i,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(i)}var Fd=Object.defineProperty,Bd=(i,e,t)=>e in i?Fd(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ir=(i,e,t)=>Bd(i,typeof e!="symbol"?e+"":e,t);class ge{constructor(){Ir(this,"_locking"),Ir(this,"_locks"),this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){this._locks+=1;let e;const t=new Promise(s=>e=()=>{this._locks-=1,s()}),n=this._locking.then(()=>e);return this._locking=this._locking.then(()=>t),n}}function se(i,e){if(!i)throw new Error(e)}const Vd=34028234663852886e22,qd=-34028234663852886e22,jd=4294967295,Wd=2147483647,Hd=-2147483648;function qn(i){if(typeof i!="number")throw new Error("invalid int 32: "+typeof i);if(!Number.isInteger(i)||i>Wd||i<Hd)throw new Error("invalid int 32: "+i)}function ms(i){if(typeof i!="number")throw new Error("invalid uint 32: "+typeof i);if(!Number.isInteger(i)||i>jd||i<0)throw new Error("invalid uint 32: "+i)}function ro(i){if(typeof i!="number")throw new Error("invalid float 32: "+typeof i);if(Number.isFinite(i)&&(i>Vd||i<qd))throw new Error("invalid float 32: "+i)}const ao=Symbol("@bufbuild/protobuf/enum-type");function Kd(i){const e=i[ao];return se(e,"missing enum type on enum object"),e}function oo(i,e,t,n){i[ao]=co(e,t.map(s=>({no:s.no,name:s.name,localName:i[s.no]})))}function co(i,e,t){const n=Object.create(null),s=Object.create(null),r=[];for(const a of e){const o=lo(a);r.push(o),n[a.name]=o,s[a.no]=o}return{typeName:i,values:r,findName(a){return n[a]},findNumber(a){return s[a]}}}function Gd(i,e,t){const n={};for(const s of e){const r=lo(s);n[r.localName]=r.no,n[r.no]=r.localName}return oo(n,i,e),n}function lo(i){return"localName"in i?i:Object.assign(Object.assign({},i),{localName:i.name})}class Hs{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const n=this.getType(),s=n.runtime.bin,r=s.makeReadOptions(t);return s.readMessage(this,r.readerFactory(e),e.byteLength,r),this}fromJson(e,t){const n=this.getType(),s=n.runtime.json,r=s.makeReadOptions(t);return s.readMessage(n,e,r,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(s){throw new Error("cannot decode ".concat(this.getType().typeName," from JSON: ").concat(s instanceof Error?s.message:String(s)))}return this.fromJson(n,t)}toBinary(e){const t=this.getType(),n=t.runtime.bin,s=n.makeWriteOptions(e),r=s.writerFactory();return n.writeMessage(this,r,s),r.finish()}toJson(e){const t=this.getType(),n=t.runtime.json,s=n.makeWriteOptions(e);return n.writeMessage(this,s)}toJsonString(e){var t;const n=this.toJson(e);return JSON.stringify(n,null,(t=e==null?void 0:e.prettySpaces)!==null&&t!==void 0?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function zd(i,e,t,n){var s;const r=(s=n==null?void 0:n.localName)!==null&&s!==void 0?s:e.substring(e.lastIndexOf(".")+1),a={[r]:function(o){i.util.initFields(this),i.util.initPartial(o,this)}}[r];return Object.setPrototypeOf(a.prototype,new Hs),Object.assign(a,{runtime:i,typeName:e,fields:i.util.newFieldList(t),fromBinary(o,d){return new a().fromBinary(o,d)},fromJson(o,d){return new a().fromJson(o,d)},fromJsonString(o,d){return new a().fromJsonString(o,d)},equals(o,d){return i.util.equals(a,o,d)}}),a}function Jd(){let i=0,e=0;for(let n=0;n<28;n+=7){let s=this.buf[this.pos++];if(i|=(s&127)<<n,!(s&128))return this.assertBounds(),[i,e]}let t=this.buf[this.pos++];if(i|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[i,e];for(let n=3;n<=31;n+=7){let s=this.buf[this.pos++];if(e|=(s&127)<<n,!(s&128))return this.assertBounds(),[i,e]}throw new Error("invalid varint")}function Ki(i,e,t){for(let r=0;r<28;r=r+7){const a=i>>>r,o=!(!(a>>>7)&&e==0),d=(o?a|128:a)&255;if(t.push(d),!o)return}const n=i>>>28&15|(e&7)<<4,s=!!(e>>3);if(t.push((s?n|128:n)&255),!!s){for(let r=3;r<31;r=r+7){const a=e>>>r,o=!!(a>>>7),d=(o?a|128:a)&255;if(t.push(d),!o)return}t.push(e>>>31&1)}}const jn=4294967296;function Mr(i){const e=i[0]==="-";e&&(i=i.slice(1));const t=1e6;let n=0,s=0;function r(a,o){const d=Number(i.slice(a,o));s*=t,n=n*t+d,n>=jn&&(s=s+(n/jn|0),n=n%jn)}return r(-24,-18),r(-18,-12),r(-12,-6),r(-6),e?ho(n,s):Ks(n,s)}function $d(i,e){let t=Ks(i,e);const n=t.hi&2147483648;n&&(t=ho(t.lo,t.hi));const s=uo(t.lo,t.hi);return n?"-"+s:s}function uo(i,e){var t=Yd(i,e);if(i=t.lo,e=t.hi,e<=2097151)return String(jn*e+i);const n=i&16777215,s=(i>>>24|e<<8)&16777215,r=e>>16&65535;let a=n+s*6777216+r*6710656,o=s+r*8147497,d=r*2;const c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(d+=Math.floor(o/c),o%=c),d.toString()+Dr(o)+Dr(a)}function Yd(i,e){return{lo:i>>>0,hi:e>>>0}}function Ks(i,e){return{lo:i|0,hi:e|0}}function ho(i,e){return e=~e,i?i=~i+1:e+=1,Ks(i,e)}const Dr=i=>{const e=String(i);return"0000000".slice(e.length)+e};function Ar(i,e){if(i>=0){for(;i>127;)e.push(i&127|128),i=i>>>7;e.push(i)}else{for(let t=0;t<9;t++)e.push(i&127|128),i=i>>7;e.push(1)}}function Qd(){let i=this.buf[this.pos++],e=i&127;if(!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<7,!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<14,!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<21,!(i&128))return this.assertBounds(),e;i=this.buf[this.pos++],e|=(i&15)<<28;for(let t=5;i&128&&t<10;t++)i=this.buf[this.pos++];if(i&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function Xd(){const i=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof i.getBigInt64=="function"&&typeof i.getBigUint64=="function"&&typeof i.setBigInt64=="function"&&typeof i.setBigUint64=="function"&&(typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){const s=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),a=BigInt("0"),o=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(d){const c=typeof d=="bigint"?d:BigInt(d);if(c>r||c<s)throw new Error("int64 invalid: ".concat(d));return c},uParse(d){const c=typeof d=="bigint"?d:BigInt(d);if(c>o||c<a)throw new Error("uint64 invalid: ".concat(d));return c},enc(d){return i.setBigInt64(0,this.parse(d),!0),{lo:i.getInt32(0,!0),hi:i.getInt32(4,!0)}},uEnc(d){return i.setBigInt64(0,this.uParse(d),!0),{lo:i.getInt32(0,!0),hi:i.getInt32(4,!0)}},dec(d,c){return i.setInt32(0,d,!0),i.setInt32(4,c,!0),i.getBigInt64(0,!0)},uDec(d,c){return i.setInt32(0,d,!0),i.setInt32(4,c,!0),i.getBigUint64(0,!0)}}}const t=s=>se(/^-?[0-9]+$/.test(s),"int64 invalid: ".concat(s)),n=s=>se(/^[0-9]+$/.test(s),"uint64 invalid: ".concat(s));return{zero:"0",supported:!1,parse(s){return typeof s!="string"&&(s=s.toString()),t(s),s},uParse(s){return typeof s!="string"&&(s=s.toString()),n(s),s},enc(s){return typeof s!="string"&&(s=s.toString()),t(s),Mr(s)},uEnc(s){return typeof s!="string"&&(s=s.toString()),n(s),Mr(s)},dec(s,r){return $d(s,r)},uDec(s,r){return uo(s,r)}}}const te=Xd();var w;(function(i){i[i.DOUBLE=1]="DOUBLE",i[i.FLOAT=2]="FLOAT",i[i.INT64=3]="INT64",i[i.UINT64=4]="UINT64",i[i.INT32=5]="INT32",i[i.FIXED64=6]="FIXED64",i[i.FIXED32=7]="FIXED32",i[i.BOOL=8]="BOOL",i[i.STRING=9]="STRING",i[i.BYTES=12]="BYTES",i[i.UINT32=13]="UINT32",i[i.SFIXED32=15]="SFIXED32",i[i.SFIXED64=16]="SFIXED64",i[i.SINT32=17]="SINT32",i[i.SINT64=18]="SINT64"})(w||(w={}));var Tt;(function(i){i[i.BIGINT=0]="BIGINT",i[i.STRING=1]="STRING"})(Tt||(Tt={}));function pt(i,e,t){if(e===t)return!0;if(i==w.BYTES){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}switch(i){case w.UINT64:case w.FIXED64:case w.INT64:case w.SFIXED64:case w.SINT64:return e==t}return!1}function Xt(i,e){switch(i){case w.BOOL:return!1;case w.UINT64:case w.FIXED64:case w.INT64:case w.SFIXED64:case w.SINT64:return e==0?te.zero:"0";case w.DOUBLE:case w.FLOAT:return 0;case w.BYTES:return new Uint8Array(0);case w.STRING:return"";default:return 0}}function po(i,e){switch(i){case w.BOOL:return e===!1;case w.STRING:return e==="";case w.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}function Or(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function Zd(i){if(Array.isArray(i))return i}function K(i,e,t){return(e=il(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function el(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,s,r,a,o=[],d=!0,c=!1;try{if(r=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;d=!1}else for(;!(d=(n=r.call(t)).done)&&(o.push(n.value),o.length!==e);d=!0);}catch(l){c=!0,s=l}finally{try{if(!d&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw s}}return o}}function tl(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
17
|
+
`,i.appendChild(e),document.body.appendChild(i),(t=e.querySelector("#vanira-stall-refresh"))==null||t.addEventListener("click",()=>{fs(),window.location.reload()}),(n=e.querySelector("#vanira-stall-dismiss"))==null||n.addEventListener("click",()=>fs())}function xd(i){return null}function Nn(){return typeof window>"u"?"/":`${window.location.pathname}${window.location.search}${window.location.hash}`||"/"}class Ld{constructor(e){D(this,"active",!1);D(this,"initialSent",!1);D(this,"lastRoute","");D(this,"sendContext");D(this,"isReady");D(this,"cleanupFns",[]);D(this,"initialRetryTimer",null);D(this,"routePollTimer",null);D(this,"originalPushState",null);D(this,"originalReplaceState",null);this.sendContext=e.sendContext,this.isReady=e.isReady??(()=>!0)}start(){typeof window>"u"||this.active||(this.active=!0,this.initialSent=!1,this.lastRoute=Nn(),this.attachListeners(),this.scheduleInitialContextSend())}stop(){if(!(!this.active&&this.cleanupFns.length===0)){this.active=!1,this.initialSent=!1,this.initialRetryTimer!==null&&(clearTimeout(this.initialRetryTimer),this.initialRetryTimer=null),this.routePollTimer!==null&&(clearInterval(this.routePollTimer),this.routePollTimer=null);for(const e of this.cleanupFns)try{e()}catch{}this.cleanupFns.length=0,this.originalPushState&&(history.pushState=this.originalPushState,this.originalPushState=null),this.originalReplaceState&&(history.replaceState=this.originalReplaceState,this.originalReplaceState=null)}}onChannelReady(){this.scheduleInitialContextSend()}scheduleInitialContextSend(e=0){if(!(!this.active||this.initialSent)){if(this.isReady()){this.sendRouteContext("call_started"),this.initialSent=!0;return}e>=30||(this.initialRetryTimer=window.setTimeout(()=>this.scheduleInitialContextSend(e+1),100))}}attachListeners(){const e=(r,a=0)=>{const o=()=>{const d=Nn();d!==this.lastRoute&&this.handleRouteChange(d,r)};a>0?window.setTimeout(o,a):queueMicrotask(o)},t=()=>e("popstate"),n=()=>e("hashchange"),s=r=>{const a=r.detail;if((a==null?void 0:a.initiated_by)==="agent"){e("vanira_navigate_agent",120);return}e("vanira_navigate",120)};window.addEventListener("popstate",t),window.addEventListener("hashchange",n),window.addEventListener("vanira:navigate",s),this.cleanupFns.push(()=>window.removeEventListener("popstate",t),()=>window.removeEventListener("hashchange",n),()=>window.removeEventListener("vanira:navigate",s)),this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history),history.pushState=(...r)=>{this.originalPushState(...r),e("pushState")},history.replaceState=(...r)=>{this.originalReplaceState(...r),e("replaceState")},this.routePollTimer=window.setInterval(()=>{if(!this.active)return;const r=Nn();r!==this.lastRoute&&this.handleRouteChange(r,"location_poll")},1e3)}handleRouteChange(e,t){if(!this.active)return;const n=this.lastRoute;if(n===e)return;if(this.lastRoute=e,!this.initialSent){this.scheduleInitialContextSend();return}!this.isReady()||xd()||this.sendRouteContext("route_changed",n,t,"user")}sendRouteContext(e,t,n,s="user"){const r=Nn();this.lastRoute=r;const a={ui_state:"page_navigation",navigation_led_by:s,current_route:r,current_page:r,user_action:e==="call_started"?"call_started_on_page":"user_navigated"};e==="call_started"?a.message=`User started the call while viewing ${r}.`:(a.previous_route=t??"",a.message=`User navigated from ${t||"(unknown)"} to ${r}.`,n&&(a.navigation_source=n));try{this.sendContext(a)}catch{}}}const st=class st{constructor(e){D(this,"serverUrl");D(this,"agentId");D(this,"callId");D(this,"prospectId");D(this,"apiKey");D(this,"backendUrl");D(this,"token");D(this,"prospectName");D(this,"welcomeMessage");D(this,"extraDetails");D(this,"onConnected");D(this,"onDisconnected");D(this,"onError");D(this,"onTranscription");D(this,"onLocalStream");D(this,"onRemoteTrack");D(this,"onClientToolCall");D(this,"onSessionStarted");D(this,"sessionStartedEmitted",!1);D(this,"pc",null);D(this,"dataChannel",null);D(this,"mediaBytesChannel",null);D(this,"audioElement",null);D(this,"localStream",null);D(this,"micMuted",!1);D(this,"connected",!1);D(this,"appliedRemoteCandidates",new Set);D(this,"remoteDescSet",!1);D(this,"pendingServerIce",[]);D(this,"icePollStop",!1);D(this,"iceServers");D(this,"callSessionLoaded",!1);D(this,"connectGeneration",0);D(this,"runtime");D(this,"sessionBehavior");D(this,"routeTracker",null);D(this,"_status","idle");D(this,"listeners",new Map);D(this,"liveVision");D(this,"liveVisionAutoStarted",!1);D(this,"connectStallTimeoutMs");var d;if(!e.agentId)throw new Error("agentId is required");const t=!!(e.apiKey||e.token),n=!!(e.serverUrl&&e.callId),s=st.normalizeIceServers(e.iceServers);if(!t&&!n)throw new Error("apiKey or token is required — or pass serverUrl and callId from a prior POST /calls/create");this.agentId=e.agentId,this.sessionBehavior=e.sessionBehavior,this.serverUrl=(e.serverUrl||"").replace(/\/$/,""),this.apiKey=e.apiKey,this.token=e.token,this.prospectName=e.prospectName,this.welcomeMessage=((d=e.welcomeMessage)==null?void 0:d.trim())||void 0,this.extraDetails=e.extraDetails,this.backendUrl=(e.backendUrl||Ws).replace(/\/$/,""),s.length&&(this.iceServers=s),n&&(this.callSessionLoaded=!0);const r=typeof window<"u";this.prospectId=e.prospectId;const a=e.sessionBehavior==="continue";if(a&&r&&!e.callId){const c=Pr(this.agentId);c&&(e.callId||(this.callId=c.callId),!this.prospectId&&c.prospectId&&(this.prospectId=c.prospectId))}if(!this.prospectId&&r)try{const c=Pr(this.agentId);this.prospectId=(c==null?void 0:c.prospectId)||window.sessionStorage&&window.sessionStorage.getItem("vanira_prospect_id")||window.localStorage&&window.localStorage.getItem("vanira_prospect_id")||void 0}catch{}e.callId?this.callId=e.callId:a||(this.callId=void 0);const o=e.onSessionStarted;this.onSessionStarted=c=>{o==null||o(c),this.emit("session_started",c)},this.liveVision=e.liveVision,this.connectStallTimeoutMs=e.connectStallTimeoutMs??15e3,this.onConnected=()=>{var c;fn(),this._status="connected",(c=e.onConnected)==null||c.call(e),this.emit("connected"),this.maybeAutoStartLiveCamera()},this.onDisconnected=()=>{var c;fn(),this._status="disconnected",(c=e.onDisconnected)==null||c.call(e),this.emit("disconnected")},this.onError=c=>{var u;fn(),this._status="error";const l=typeof c=="string"?c:(c==null?void 0:c.message)||"Connection error";(u=e.onError)==null||u.call(e,c),this.emit("error",l)},this.onTranscription=(c,l,u)=>{var h;(h=e.onTranscription)==null||h.call(e,c,l),this.emit("transcription",{text:c,isFinal:l,role:u})},this.onLocalStream=e.onLocalStream||(()=>{}),this.onRemoteTrack=(c,l)=>{var u;(u=e.onRemoteTrack)==null||u.call(e,c,l),this.emit("track",{track:c,stream:l})},this.onClientToolCall=c=>{var h;(h=e.onClientToolCall)==null||h.call(e,c);const l=(c==null?void 0:c.data)||c,u={name:String(l.name||l.tool_name||""),arguments:l.arguments||l.args||{},tool_call_id:String(l.tool_call_id||l.call_id||""),execution_mode:l.execution_mode==="blocking"?"blocking":"fire_and_forget",client_fields:l.client_fields||{}};u.name&&u.tool_call_id&&this.emit("tool_call",u)},this.runtime=e.runtime,typeof window<"u"&&e.trackRouteContext!==!1&&(this.routeTracker=new Ld({sendContext:c=>this.sendContextUpdate(c),isReady:()=>{var c;return((c=this.dataChannel)==null?void 0:c.readyState)==="open"}}))}async createCall(){return this.connect()}async connect(){var t;this._status="connecting",this.connectStallTimeoutMs>0&&Ad(this.connectStallTimeoutMs);const e=++this.connectGeneration;if(await this.loadCallSession(),!this.isConnectCancelled(e)){if(!this.serverUrl)throw new Error("[VaniraClient] worker_url missing from /calls/create");if(!this.callId)throw new Error("[VaniraClient] call_id missing — must come from POST /calls/create");if(this.onSessionStarted&&this.prospectId&&this.callId&&!this.sessionStartedEmitted)try{this.onSessionStarted({prospectId:this.prospectId,callId:this.callId,serverUrl:this.serverUrl}),this.sessionStartedEmitted=!0}catch{}try{this.appliedRemoteCandidates.clear(),this.remoteDescSet=!1,this.pendingServerIce=[],this.icePollStop=!1,this.stopRemoteIcePolling();const n=this.getIceServers();this.pc=new RTCPeerConnection({iceServers:n,iceTransportPolicy:"all"});let s;try{s=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:{ideal:16e3},channelCount:1}})}catch(u){if(u.name==="NotAllowedError"||u.name==="PermissionDeniedError"||(t=u.message)!=null&&t.includes("Permission denied")){const h=navigator.userAgent,p=/iPad|iPhone|iPod/.test(h)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;let g="Microphone access denied. Please allow microphone access in your browser settings.";p&&(h.includes("CriOS")?g="Microphone access blocked. Please enable it in iOS Settings > Chrome > Microphone, then reload the page.":h.includes("FxiOS")?g="Microphone access blocked. Please enable it in iOS Settings > Firefox > Microphone, then reload the page.":g="Microphone access blocked. Please enable it in iOS Settings > Safari > Microphone (or tap 'aA' > Website Settings > Allow Microphone).");const m=new Error(g);throw m.name=u.name,m}throw u}if(this.isConnectCancelled(e)){s.getTracks().forEach(u=>u.stop());return}if(this.localStream=s,!this.pc||this.isConnectCancelled(e)){s.getTracks().forEach(u=>u.stop());return}if(this.onLocalStream(s),s.getTracks().forEach(u=>{var h;(h=this.pc)==null||h.addTrack(u,s)}),!this.pc)throw new Error("RTCPeerConnection was closed unexpectedly");this.dataChannel=this.pc.createDataChannel("control"),this.dataChannel.onopen=()=>{var u;(u=this.routeTracker)==null||u.onChannelReady()},this.dataChannel.onmessage=u=>{if(typeof u.data=="string")try{this.handleControlEvent(JSON.parse(u.data))}catch{}else if(u.data instanceof ArrayBuffer)try{const h=new TextDecoder().decode(u.data);try{const p=JSON.parse(h);Xa(p)&&this.handleControlEvent(p)}catch{}}catch{}else u.data instanceof Blob&&u.data.text().then(h=>{try{this.handleControlEvent(JSON.parse(h))}catch{}})},this.dataChannel.onerror=u=>{},this.mediaBytesChannel=this.pc.createDataChannel("media-bytes",{ordered:!0}),this.mediaBytesChannel.binaryType="arraybuffer",this.mediaBytesChannel.onopen=()=>{},this.mediaBytesChannel.onerror=u=>{},this.pc.ontrack=u=>{const h=u.track,p=u.streams[0];h.kind==="audio"?(this.audioElement=new Audio,this.audioElement.srcObject=p,this.audioElement.play().catch(g=>{}),this.audioElement.onended=()=>{this.sendEvent("playedStream"),typeof window<"u"&&window.dispatchEvent(new CustomEvent("vanira:agent-playback-ended"))},this.onRemoteTrack(h,p)):h.kind==="video"&&this.onRemoteTrack(h,p)};const r=()=>{var p,g,m,T,k,S,L,v,y,C,I;const u=((p=this.pc)==null?void 0:p.connectionState)==="connected"||((g=this.pc)==null?void 0:g.iceConnectionState)==="connected"||((m=this.pc)==null?void 0:m.iceConnectionState)==="completed",h=((T=this.pc)==null?void 0:T.connectionState)==="failed"||((k=this.pc)==null?void 0:k.iceConnectionState)==="failed"||((S=this.pc)==null?void 0:S.connectionState)==="closed"||((L=this.pc)==null?void 0:L.iceConnectionState)==="closed"||((v=this.pc)==null?void 0:v.connectionState)==="disconnected"||((y=this.pc)==null?void 0:y.iceConnectionState)==="disconnected";((C=this.pc)==null?void 0:C.connectionState)==="connected"&&this.stopRemoteIcePolling(),u&&!this.connected?(this.connected=!0,(I=this.routeTracker)==null||I.start(),this.onConnected()):h&&this.connected&&(this.connected=!1,this.liveVisionAutoStarted=!1,this.onDisconnected())};this.pc.onconnectionstatechange=r,this.pc.oniceconnectionstatechange=r;const a=this.getIceTrickleUrl();this.pc.onicecandidate=u=>{u.candidate&&this.sendRemoteIceCandidate(u.candidate,a)};const o=await this.pc.createOffer();if(this.isConnectCancelled(e)||(await this.pc.setLocalDescription(o),this.isConnectCancelled(e)))return;const d=this.serverUrl.includes("?")?this.serverUrl:`${this.serverUrl}/webrtc?agent=${this.agentId}_${this.callId}`,c=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({offer:this.pc.localDescription,agentId:this.agentId,callId:this.callId})});if(this.isConnectCancelled(e))return;if(!c.ok){const u=await c.json();throw new Error(u.error||`HTTP ${c.status}`)}const{answer:l}=await c.json();if(this.isConnectCancelled(e)||!this.pc||(await this.pc.setRemoteDescription(l),this.isConnectCancelled(e))||(this.remoteDescSet=!0,await this.flushPendingServerIce(),this.isConnectCancelled(e)))return;this.startRemoteIcePolling(a)}catch(n){if(this.isConnectCancelled(e))return;throw this.disconnect(),this.onError(n.message||n),n}}}createCallCacheKey(e,t){const n=this.apiKey?`key:${this.apiKey.slice(0,16)}`:`token:${(this.token||"").slice(-16)}`;return[this.backendUrl,this.agentId,e,t||"",this.prospectId||"",n].join("|")}async postCreateCall(e,t,n){var o,d,c;const s=await fetch(`${this.backendUrl}/calls/create`,{method:"POST",headers:e,body:JSON.stringify({agent_id:this.agentId,type:((o=this.runtime)==null?void 0:o.callType)||"web",mode:t,...(d=this.runtime)!=null&&d.runtimeName?{runtime:this.runtime.runtimeName}:{},prospect_id:this.prospectId,...this.prospectName?{prospect_name:this.prospectName}:{},...this.welcomeMessage?{welcome_message:this.welcomeMessage}:{},...this.extraDetails&&Object.keys(this.extraDetails).length?{extra_details:this.extraDetails}:{},...n?{call_id:n}:{}})});if(!s.ok){const l=await s.json().catch(()=>({}));throw new Error(`[VaniraClient] createCall failed (${s.status}): ${((c=l==null?void 0:l.detail)==null?void 0:c.message)||(l==null?void 0:l.message)||s.statusText}`)}const r=await s.json();if(!r.call_id||!r.worker_url)throw new Error("[VaniraClient] /calls/create response missing call_id or worker_url");const a=st.normalizeIceServers(r.ice_servers);if(!a.length)throw new Error("[VaniraClient] /calls/create response missing ice_servers");return{callId:r.call_id,prospectId:r.prospect_id||this.prospectId,serverUrl:r.worker_url.replace(/\/$/,""),iceServers:a}}applyCreateCallSession(e){if(this.callId=e.callId,this.prospectId=e.prospectId||this.prospectId,this.serverUrl=e.serverUrl,this.iceServers=e.iceServers,this.callSessionLoaded=!0,wd(this.agentId,this.callId||"",this.prospectId),this.onSessionStarted&&this.prospectId&&this.callId&&!this.sessionStartedEmitted)try{this.onSessionStarted({prospectId:this.prospectId,callId:this.callId,serverUrl:this.serverUrl}),this.sessionStartedEmitted=!0}catch{}}async loadCallSession(){if(this.callSessionLoaded)return;if(this.serverUrl&&this.callId){this.callSessionLoaded=!0;return}if(!this.apiKey&&!this.token)throw new Error("[VaniraClient] apiKey or token is required to create a call session");const e={"Content-Type":"application/json"};this.apiKey?e["X-API-Key"]=this.apiKey:this.token&&(e.Authorization=this.token.startsWith("Bearer ")?this.token:`Bearer ${this.token}`);const t=this.sessionBehavior==="continue"?this.callId:void 0,n=this.sessionBehavior==="continue"?"continue":"new",s=this.createCallCacheKey(n,t);let r=st.inflightCreates.get(s);r||(r=this.postCreateCall(e,n,t),st.inflightCreates.set(s,r),r.finally(()=>{st.inflightCreates.get(s)===r&&st.inflightCreates.delete(s)}));const a=await r;this.applyCreateCallSession(a)}getIceServers(){var e;if((e=this.iceServers)!=null&&e.length)return this.iceServers;throw new Error("[VaniraClient] ice_servers missing — pass iceServers from POST /calls/create")}static normalizeIceServers(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const s=n==null?void 0:n.urls,r=Array.isArray(s)?s.filter(Boolean):typeof s=="string"&&s.trim()?[s.trim()]:[];if(!r.length)continue;const a={urls:r.length===1?r[0]:r},o=n.username,d=n.credential;o&&(a.username=o),d&&(a.credential=d),t.push(a)}return t}getWorkerOrigin(){var e;if(!((e=this.serverUrl)!=null&&e.trim()))return"";try{return new URL(this.serverUrl).origin}catch{return this.serverUrl.replace(/\/webrtc.*$/,"").replace(/\/$/,"")}}getIceTrickleUrl(){try{const e=new URL(this.serverUrl);return e.pathname.endsWith("/webrtc")?e.pathname=`${e.pathname}/ice`:e.pathname="/webrtc/ice",e.toString()}catch{return`${this.getWorkerOrigin()}/webrtc/ice?agent_id=${this.agentId}&call_id=${this.callId}`}}async sendRemoteIceCandidate(e,t){try{const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({candidate:e.toJSON()})});if(n.ok){const s=await n.json();await this.applyServerIceCandidates(s.candidates)}}catch{}}async applyServerIceCandidates(e){if(!(!this.pc||!(e!=null&&e.length))){if(!this.remoteDescSet){this.pendingServerIce.push(...e);return}for(const t of e){const n=JSON.stringify(t);if(!this.appliedRemoteCandidates.has(n)){this.appliedRemoteCandidates.add(n);try{await this.pc.addIceCandidate(t)}catch{}}}}}async flushPendingServerIce(){if(!this.pc||!this.remoteDescSet||this.pendingServerIce.length===0)return;const e=this.pendingServerIce;this.pendingServerIce=[];for(const t of e){const n=JSON.stringify(t);if(!this.appliedRemoteCandidates.has(n)){this.appliedRemoteCandidates.add(n);try{await this.pc.addIceCandidate(t)}catch{}}}}startRemoteIcePolling(e){this.icePollStop=!1,this.pollServerIce(e)}async pollServerIce(e){var n;const t=Date.now()+15e3;for(;!this.icePollStop&&Date.now()<t;){const s=(n=this.pc)==null?void 0:n.connectionState;if(s==="connected"||s==="failed"||s==="closed")break;try{const r=await fetch(e,{method:"GET"});if(r.ok){const a=await r.json();if(await this.applyServerIceCandidates(a.candidates),a.done&&(!a.candidates||a.candidates.length===0))break}}catch{}await new Promise(r=>setTimeout(r,150))}}stopRemoteIcePolling(){this.icePollStop=!0}sendEvent(e,t={}){var n;if(((n=this.dataChannel)==null?void 0:n.readyState)==="open"){const s={event:e,...t};this.dataChannel.send(JSON.stringify(s))}}async sendEventWhenReady(e,t={},n=1e4){var r;const s=Date.now()+n;for(;Date.now()<s;){if(((r=this.dataChannel)==null?void 0:r.readyState)==="open")return this.sendEvent(e,t),!0;await new Promise(a=>setTimeout(a,50))}return!1}startLiveCamera(e={}){const t={...this.liveVision,...e};this.emit("tool_call",this.buildOpenLiveCameraToolCall(t))}buildOpenLiveCameraToolCall(e={}){const t=e.scope??"until_call_end";return{name:"open_live_camera",tool_call_id:`lv_${crypto.randomUUID()}`,execution_mode:"fire_and_forget",client_fields:{preset_id:N.LiveVision},arguments:{mode:"live",scope:t,target_fps:e.target_fps??1,max_fps:e.max_fps??3,max_width:e.max_width??640,reason:e.reason??"camera_capture",facing_mode:e.facing_mode??"environment",show_preview:e.show_preview??!0,...t==="timed"&&e.duration_sec?{duration_sec:e.duration_sec}:{}}}}maybeAutoStartLiveCamera(){const e=this.liveVision;!(e!=null&&e.enabled)||e.scope!=="full_call"||this.liveVisionAutoStarted||(this.liveVisionAutoStarted=!0,this.emit("tool_call",this.buildOpenLiveCameraToolCall(e)))}handleControlEvent(e){var t;switch(e.event){case"clearAudio":this.dispatchBoardAbort("User interrupted while LaTeX was writing",void 0,N.WriteLatexText);break;case"transcription":{const n=e.data&&typeof e.data=="object"?e.data:{},s=String(e.text??n.text??"").trim(),r=e.isFinal??e.is_final??n.isFinal??n.is_final,a=r===void 0?!0:r===!0||r==="true",o=String(e.role??e.speaker??n.role??n.speaker??"").trim()||void 0;s&&this.onTranscription(s,a,o)}break;case"mark":break;case"client_tool_cancel":{const s=(e.data||e).tool_call_id||e.tool_call_id;this.dispatchBoardAbort("Tool cancelled by server",s);break}case"client_tool_call":{const n=e.tool_call||e.data||e,s=(n==null?void 0:n.tool_call_id)||(n==null?void 0:n.call_id)||e.tool_call_id||"";s&&((t=this.dataChannel)==null?void 0:t.readyState)==="open"&&this.dataChannel.send(JSON.stringify({event:"client_tool_ack",data:{tool_call_id:s}}));const r=(n==null?void 0:n.arguments)||(n==null?void 0:n.args)||{},a=(n==null?void 0:n.client_fields)||{},o=(n==null?void 0:n.name)||(n==null?void 0:n.tool_name)||"",d=_d(a,r,o);if(o==="end_call"){s&&this.sendToolResult(s,{status:"client_ack_end_call",message:"Ending call."}),window.setTimeout(()=>this.disconnect(),120);break}if(d){window.dispatchEvent(new CustomEvent("vanira:preset",{detail:{toolCall:n,client:this}})),this.onClientToolCall(n);break}this.onClientToolCall(n);break}}}disconnect(){var e;fn(),this.connectGeneration++,this.stopRemoteIcePolling(),this.appliedRemoteCandidates.clear(),this.remoteDescSet=!1,this.pendingServerIce=[],this.audioElement&&(this.audioElement.pause(),this.audioElement.srcObject=null),this.dataChannel&&(this.dataChannel.close(),this.dataChannel=null),this.mediaBytesChannel&&(this.mediaBytesChannel.close(),this.mediaBytesChannel=null),this.pc&&(this.pc.getSenders().forEach(t=>{t.track&&t.track.stop()}),this.pc.close(),this.pc=null),this.localStream&&(this.localStream.getTracks().forEach(t=>{try{t.stop()}catch{}}),this.localStream=null),this.connected=!1,(e=this.routeTracker)==null||e.stop(),this.callSessionLoaded=!1,this.sessionStartedEmitted=!1,this.serverUrl="",this.callId=void 0,this.micMuted=!1,this.iceServers=void 0,this.onDisconnected()}setMicrophoneMuted(e){var t,n;this.micMuted=e,(t=this.localStream)==null||t.getAudioTracks().forEach(s=>{s.enabled=!e}),(n=this.pc)==null||n.getSenders().forEach(s=>{var r;((r=s.track)==null?void 0:r.kind)==="audio"&&(s.track.enabled=!e)})}isMicrophoneMuted(){return this.micMuted}toggleMicrophoneMuted(){return this.setMicrophoneMuted(!this.micMuted),this.micMuted}isConnectCancelled(e){return e!==this.connectGeneration}dispatchBoardAbort(e,t,n){typeof window>"u"||window.dispatchEvent(new CustomEvent("vanira:board_abort",{detail:{reason:e,toolCallId:t,presetId:n}}))}sendToolResult(e,t){this.callId,this.sendEvent("client_tool_result",{call_id:this.callId,data:{tool_call_id:e,result:t},result:t}),this.emit("tool_result",{toolCallId:e,result:t})}sendToolAck(e){var t;((t=this.dataChannel)==null?void 0:t.readyState)==="open"&&this.dataChannel.send(JSON.stringify({event:"client_tool_ack",data:{tool_call_id:e}}))}sendContextUpdate(e){this.sendEvent("client_context_update",{data:{context:e}})}sendActionTrigger(e,t={}){this.sendEvent("client_action_trigger",{data:{action_name:e,data:t}})}triggerActionInterrupt(){this.sendEvent("action_interrupt")}sendMediaUpdate(e){if(!this.dataChannel||this.dataChannel.readyState!=="open")return!1;const t={event:"client_media_update",data:{media_id:e.media_id,media_url:e.media_url,content_type:e.content_type,reason:e.reason,message:e.message??""}};return this.dataChannel.send(JSON.stringify(t)),!0}async uploadMediaForToolResult(e,t="general"){return this._postMediaUpload(e,t)}async uploadMedia(e,t="general",n=""){return await Rd(this.dataChannel,this.mediaBytesChannel)?this._uploadMediaViaDataChannel(e,t,n):(Pd(this.dataChannel,this.mediaBytesChannel),this._uploadMediaViaHTTP(e,t,n))}async uploadMediaFrame(e,t="camera_capture",n){const s=n&&!(e instanceof File)?new File([e],n,{type:e.type||"image/jpeg"}):e,{media_id:r,url:a,contentType:o}=await this._postMediaUpload(s,t,!0);if(!r||!a)throw new Error("Frame upload failed: server response missing media_id or url");return{media_id:r,url:a,content_type:o}}async _uploadBytesViaDataChannel(e,t,n,s,r){if(!this.callId||!this.mediaBytesChannel)throw new Error("Upload failed: call not ready for WebRTC media upload.");const a=r||(e instanceof File?e.name:s==="frame"?"frame.jpg":"upload.bin"),o=e.type||(s==="frame"?"image/jpeg":"application/octet-stream"),d=await Md(e);return Id({bytes:d,filename:a,contentType:o,reason:t,message:n,callId:this.callId,mediaBytesChannel:this.mediaBytesChannel,sendControlEvent:(c,l)=>this.sendEvent(c,l),uploadKind:s})}async _uploadMediaViaDataChannel(e,t,n){const s=await this._uploadBytesViaDataChannel(e,t,n,"media");return{media_id:s.media_id,url:s.url}}async _uploadMediaViaHTTP(e,t="general",n=""){const{media_id:s,url:r,contentType:a}=await this._postMediaUpload(e,t,!0);return this.sendMediaUpdate({media_id:s,media_url:r,content_type:a,reason:t,message:n}),{media_id:s,url:r}}async _postMediaUpload(e,t,n=!1){if(!this.serverUrl)throw new Error("Upload failed: serverUrl is not set. Connect the VaniraClient first.");if(!this.callId)throw new Error("Upload failed: callId is missing.");const s=this.getWorkerOrigin();if(!s)throw new Error("Upload failed: worker_url is not set. Connect the call before uploading media.");const r=`${s}/media/upload`,a=new FormData;a.append("file",e),a.append("call_id",this.callId),a.append("reason",t);const o=await fetch(r,{method:"POST",body:a});if(!o.ok){let h=`HTTP ${o.status}`;try{h=(await o.json()).error||h}catch{}throw new Error(`Upload failed: ${h}`)}const d=await o.json(),c=d.media_id,l=d.url,u=d.content_type||e.type;if(!c||!l)throw new Error("Upload failed: server response missing media_id or url");return n?{media_id:c,url:l,contentType:u}:{media_id:c,url:l,contentType:u}}get status(){return this._status}get isConnected(){return this._status==="connected"}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),this}off(e,t){var n;return(n=this.listeners.get(e))==null||n.delete(t),this}emit(e,t){var n;(n=this.listeners.get(e))==null||n.forEach(s=>s(t))}async start(){return await this.connect(),{callId:this.callId||"",prospectId:this.prospectId||"",serverUrl:this.serverUrl||""}}stop(){this.disconnect(),this._status="disconnected"}sendToolError(e,t){this.sendToolResult(e,{status:"error",error:t})}updateContext(e){this.sendContextUpdate(e)}triggerInterrupt(e,t={}){this.triggerActionInterrupt(),this.sendActionTrigger(e,t)}interruptAudioOnly(){this.triggerActionInterrupt()}};D(st,"inflightCreates",new Map);let Qt=st;var Ja;const no={supportsAudioEndedEvent:!0,supportsScreenShare:typeof navigator<"u"&&typeof((Ja=navigator.mediaDevices)==null?void 0:Ja.getDisplayMedia)=="function",supportsDom:typeof document<"u",supportsHtmlAudio:typeof Audio<"u",supportsCustomElements:typeof customElements<"u",supportsLocalStorage:typeof localStorage<"u",supportsBroadcastChannel:typeof BroadcastChannel<"u"},io={name:"browser",callType:"web",runtimeName:"browser",callIdPrefix:"web_",capabilities:no,audio:new $a,media:new Ya,peer:new Qa,dataChannel:new Za};function so(i){return new Qt({...i,runtime:io})}const Nd=so;function Ud(i,e){return e.forEach(function(t){t&&typeof t!="string"&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if(n!=="default"&&!(n in i)){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(i,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(i)}var Fd=Object.defineProperty,Bd=(i,e,t)=>e in i?Fd(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ir=(i,e,t)=>Bd(i,typeof e!="symbol"?e+"":e,t);class ge{constructor(){Ir(this,"_locking"),Ir(this,"_locks"),this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){this._locks+=1;let e;const t=new Promise(s=>e=()=>{this._locks-=1,s()}),n=this._locking.then(()=>e);return this._locking=this._locking.then(()=>t),n}}function se(i,e){if(!i)throw new Error(e)}const Vd=34028234663852886e22,qd=-34028234663852886e22,jd=4294967295,Wd=2147483647,Hd=-2147483648;function qn(i){if(typeof i!="number")throw new Error("invalid int 32: "+typeof i);if(!Number.isInteger(i)||i>Wd||i<Hd)throw new Error("invalid int 32: "+i)}function ms(i){if(typeof i!="number")throw new Error("invalid uint 32: "+typeof i);if(!Number.isInteger(i)||i>jd||i<0)throw new Error("invalid uint 32: "+i)}function ro(i){if(typeof i!="number")throw new Error("invalid float 32: "+typeof i);if(Number.isFinite(i)&&(i>Vd||i<qd))throw new Error("invalid float 32: "+i)}const ao=Symbol("@bufbuild/protobuf/enum-type");function Kd(i){const e=i[ao];return se(e,"missing enum type on enum object"),e}function oo(i,e,t,n){i[ao]=co(e,t.map(s=>({no:s.no,name:s.name,localName:i[s.no]})))}function co(i,e,t){const n=Object.create(null),s=Object.create(null),r=[];for(const a of e){const o=lo(a);r.push(o),n[a.name]=o,s[a.no]=o}return{typeName:i,values:r,findName(a){return n[a]},findNumber(a){return s[a]}}}function Gd(i,e,t){const n={};for(const s of e){const r=lo(s);n[r.localName]=r.no,n[r.no]=r.localName}return oo(n,i,e),n}function lo(i){return"localName"in i?i:Object.assign(Object.assign({},i),{localName:i.name})}class Hs{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const n=this.getType(),s=n.runtime.bin,r=s.makeReadOptions(t);return s.readMessage(this,r.readerFactory(e),e.byteLength,r),this}fromJson(e,t){const n=this.getType(),s=n.runtime.json,r=s.makeReadOptions(t);return s.readMessage(n,e,r,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(s){throw new Error("cannot decode ".concat(this.getType().typeName," from JSON: ").concat(s instanceof Error?s.message:String(s)))}return this.fromJson(n,t)}toBinary(e){const t=this.getType(),n=t.runtime.bin,s=n.makeWriteOptions(e),r=s.writerFactory();return n.writeMessage(this,r,s),r.finish()}toJson(e){const t=this.getType(),n=t.runtime.json,s=n.makeWriteOptions(e);return n.writeMessage(this,s)}toJsonString(e){var t;const n=this.toJson(e);return JSON.stringify(n,null,(t=e==null?void 0:e.prettySpaces)!==null&&t!==void 0?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function zd(i,e,t,n){var s;const r=(s=n==null?void 0:n.localName)!==null&&s!==void 0?s:e.substring(e.lastIndexOf(".")+1),a={[r]:function(o){i.util.initFields(this),i.util.initPartial(o,this)}}[r];return Object.setPrototypeOf(a.prototype,new Hs),Object.assign(a,{runtime:i,typeName:e,fields:i.util.newFieldList(t),fromBinary(o,d){return new a().fromBinary(o,d)},fromJson(o,d){return new a().fromJson(o,d)},fromJsonString(o,d){return new a().fromJsonString(o,d)},equals(o,d){return i.util.equals(a,o,d)}}),a}function Jd(){let i=0,e=0;for(let n=0;n<28;n+=7){let s=this.buf[this.pos++];if(i|=(s&127)<<n,!(s&128))return this.assertBounds(),[i,e]}let t=this.buf[this.pos++];if(i|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[i,e];for(let n=3;n<=31;n+=7){let s=this.buf[this.pos++];if(e|=(s&127)<<n,!(s&128))return this.assertBounds(),[i,e]}throw new Error("invalid varint")}function Ki(i,e,t){for(let r=0;r<28;r=r+7){const a=i>>>r,o=!(!(a>>>7)&&e==0),d=(o?a|128:a)&255;if(t.push(d),!o)return}const n=i>>>28&15|(e&7)<<4,s=!!(e>>3);if(t.push((s?n|128:n)&255),!!s){for(let r=3;r<31;r=r+7){const a=e>>>r,o=!!(a>>>7),d=(o?a|128:a)&255;if(t.push(d),!o)return}t.push(e>>>31&1)}}const jn=4294967296;function Mr(i){const e=i[0]==="-";e&&(i=i.slice(1));const t=1e6;let n=0,s=0;function r(a,o){const d=Number(i.slice(a,o));s*=t,n=n*t+d,n>=jn&&(s=s+(n/jn|0),n=n%jn)}return r(-24,-18),r(-18,-12),r(-12,-6),r(-6),e?ho(n,s):Ks(n,s)}function $d(i,e){let t=Ks(i,e);const n=t.hi&2147483648;n&&(t=ho(t.lo,t.hi));const s=uo(t.lo,t.hi);return n?"-"+s:s}function uo(i,e){var t=Yd(i,e);if(i=t.lo,e=t.hi,e<=2097151)return String(jn*e+i);const n=i&16777215,s=(i>>>24|e<<8)&16777215,r=e>>16&65535;let a=n+s*6777216+r*6710656,o=s+r*8147497,d=r*2;const c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(d+=Math.floor(o/c),o%=c),d.toString()+Dr(o)+Dr(a)}function Yd(i,e){return{lo:i>>>0,hi:e>>>0}}function Ks(i,e){return{lo:i|0,hi:e|0}}function ho(i,e){return e=~e,i?i=~i+1:e+=1,Ks(i,e)}const Dr=i=>{const e=String(i);return"0000000".slice(e.length)+e};function Ar(i,e){if(i>=0){for(;i>127;)e.push(i&127|128),i=i>>>7;e.push(i)}else{for(let t=0;t<9;t++)e.push(i&127|128),i=i>>7;e.push(1)}}function Qd(){let i=this.buf[this.pos++],e=i&127;if(!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<7,!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<14,!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<21,!(i&128))return this.assertBounds(),e;i=this.buf[this.pos++],e|=(i&15)<<28;for(let t=5;i&128&&t<10;t++)i=this.buf[this.pos++];if(i&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function Xd(){const i=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof i.getBigInt64=="function"&&typeof i.getBigUint64=="function"&&typeof i.setBigInt64=="function"&&typeof i.setBigUint64=="function"&&(typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){const s=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),a=BigInt("0"),o=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(d){const c=typeof d=="bigint"?d:BigInt(d);if(c>r||c<s)throw new Error("int64 invalid: ".concat(d));return c},uParse(d){const c=typeof d=="bigint"?d:BigInt(d);if(c>o||c<a)throw new Error("uint64 invalid: ".concat(d));return c},enc(d){return i.setBigInt64(0,this.parse(d),!0),{lo:i.getInt32(0,!0),hi:i.getInt32(4,!0)}},uEnc(d){return i.setBigInt64(0,this.uParse(d),!0),{lo:i.getInt32(0,!0),hi:i.getInt32(4,!0)}},dec(d,c){return i.setInt32(0,d,!0),i.setInt32(4,c,!0),i.getBigInt64(0,!0)},uDec(d,c){return i.setInt32(0,d,!0),i.setInt32(4,c,!0),i.getBigUint64(0,!0)}}}const t=s=>se(/^-?[0-9]+$/.test(s),"int64 invalid: ".concat(s)),n=s=>se(/^[0-9]+$/.test(s),"uint64 invalid: ".concat(s));return{zero:"0",supported:!1,parse(s){return typeof s!="string"&&(s=s.toString()),t(s),s},uParse(s){return typeof s!="string"&&(s=s.toString()),n(s),s},enc(s){return typeof s!="string"&&(s=s.toString()),t(s),Mr(s)},uEnc(s){return typeof s!="string"&&(s=s.toString()),n(s),Mr(s)},dec(s,r){return $d(s,r)},uDec(s,r){return uo(s,r)}}}const te=Xd();var w;(function(i){i[i.DOUBLE=1]="DOUBLE",i[i.FLOAT=2]="FLOAT",i[i.INT64=3]="INT64",i[i.UINT64=4]="UINT64",i[i.INT32=5]="INT32",i[i.FIXED64=6]="FIXED64",i[i.FIXED32=7]="FIXED32",i[i.BOOL=8]="BOOL",i[i.STRING=9]="STRING",i[i.BYTES=12]="BYTES",i[i.UINT32=13]="UINT32",i[i.SFIXED32=15]="SFIXED32",i[i.SFIXED64=16]="SFIXED64",i[i.SINT32=17]="SINT32",i[i.SINT64=18]="SINT64"})(w||(w={}));var Tt;(function(i){i[i.BIGINT=0]="BIGINT",i[i.STRING=1]="STRING"})(Tt||(Tt={}));function pt(i,e,t){if(e===t)return!0;if(i==w.BYTES){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}switch(i){case w.UINT64:case w.FIXED64:case w.INT64:case w.SFIXED64:case w.SINT64:return e==t}return!1}function Xt(i,e){switch(i){case w.BOOL:return!1;case w.UINT64:case w.FIXED64:case w.INT64:case w.SFIXED64:case w.SINT64:return e==0?te.zero:"0";case w.DOUBLE:case w.FLOAT:return 0;case w.BYTES:return new Uint8Array(0);case w.STRING:return"";default:return 0}}function po(i,e){switch(i){case w.BOOL:return e===!1;case w.STRING:return e==="";case w.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}function Or(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function Zd(i){if(Array.isArray(i))return i}function K(i,e,t){return(e=il(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function el(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,s,r,a,o=[],d=!0,c=!1;try{if(r=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;d=!1}else for(;!(d=(n=r.call(t)).done)&&(o.push(n.value),o.length!==e);d=!0);}catch(l){c=!0,s=l}finally{try{if(!d&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw s}}return o}}function tl(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
18
18
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function U(i,e){return Zd(i)||el(i,e)||sl(i,e)||tl()}function nl(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function il(i){var e=nl(i,"string");return typeof e=="symbol"?e:e+""}function sl(i,e){if(i){if(typeof i=="string")return Or(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Or(i,e):void 0}}var ae;(function(i){i[i.Varint=0]="Varint",i[i.Bit64=1]="Bit64",i[i.LengthDelimited=2]="LengthDelimited",i[i.StartGroup=3]="StartGroup",i[i.EndGroup=4]="EndGroup",i[i.Bit32=5]="Bit32"})(ae||(ae={}));class rl{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let s=0;s<this.chunks.length;s++)e+=this.chunks[s].length;let t=new Uint8Array(e),n=0;for(let s=0;s<this.chunks.length;s++)t.set(this.chunks[s],n),n+=this.chunks[s].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(ms(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return qn(e),Ar(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){ro(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){ms(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){qn(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return qn(e),e=(e<<1^e>>31)>>>0,Ar(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),s=te.enc(e);return n.setInt32(0,s.lo,!0),n.setInt32(4,s.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),s=te.uEnc(e);return n.setInt32(0,s.lo,!0),n.setInt32(4,s.hi,!0),this.raw(t)}int64(e){let t=te.enc(e);return Ki(t.lo,t.hi,this.buf),this}sint64(e){let t=te.enc(e),n=t.hi>>31,s=t.lo<<1^n,r=(t.hi<<1|t.lo>>>31)^n;return Ki(s,r,this.buf),this}uint64(e){let t=te.uEnc(e);return Ki(t.lo,t.hi,this.buf),this}}class al{constructor(e,t){this.varint64=Jd,this.uint32=Qd,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case ae.Varint:for(;this.buf[this.pos++]&128;);break;case ae.Bit64:this.pos+=4;case ae.Bit32:this.pos+=4;break;case ae.LengthDelimited:let s=this.uint32();this.pos+=s;break;case ae.StartGroup:for(;;){const r=this.tag(),a=U(r,2),o=a[0],d=a[1];if(d===ae.EndGroup){if(t!==void 0&&o!==t)throw new Error("invalid end group tag");break}this.skip(d,o)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return te.dec(...this.varint64())}uint64(){return te.uDec(...this.varint64())}sint64(){let e=this.varint64(),t=U(e,2),n=t[0],s=t[1],r=-(n&1);return n=(n>>>1|(s&1)<<31)^r,s=s>>>1^r,te.dec(n,s)}bool(){let e=this.varint64(),t=U(e,2),n=t[0],s=t[1];return n!==0||s!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return te.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return te.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function ol(i,e,t,n){let s;return{typeName:e,extendee:t,get field(){if(!s){const r=typeof n=="function"?n():n;r.name=e.split(".").pop(),r.jsonName="[".concat(e,"]"),s=i.util.newFieldList([r]).list()[0]}return s},runtime:i}}function fo(i){const e=i.field.localName,t=Object.create(null);return t[e]=cl(i),[t,()=>t[e]]}function cl(i){const e=i.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return Xt(e.T,e.L);case"message":const t=e.T,n=new t;return t.fieldWrapper?t.fieldWrapper.unwrapField(n):n;case"map":throw"map fields are not allowed to be extensions"}}function dl(i,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let t=i.length-1;t>=0;--t)if(i[t].no==e.no)return[i[t]];return[]}return i.filter(t=>t.no===e.no)}let at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),yi=[];for(let i=0;i<at.length;i++)yi[at[i].charCodeAt(0)]=i;yi[45]=at.indexOf("+");yi[95]=at.indexOf("/");const mo={dec(i){let e=i.length*3/4;i[i.length-2]=="="?e-=2:i[i.length-1]=="="&&(e-=1);let t=new Uint8Array(e),n=0,s=0,r,a=0;for(let o=0;o<i.length;o++){if(r=yi[i.charCodeAt(o)],r===void 0)switch(i[o]){case"=":s=0;case`
|
|
19
19
|
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(s){case 0:a=r,s=1;break;case 1:t[n++]=a<<2|(r&48)>>4,a=r,s=2;break;case 2:t[n++]=(a&15)<<4|(r&60)>>2,a=r,s=3;break;case 3:t[n++]=(a&3)<<6|r,s=0;break}}if(s==1)throw Error("invalid base64 string.");return t.subarray(0,n)},enc(i){let e="",t=0,n,s=0;for(let r=0;r<i.length;r++)switch(n=i[r],t){case 0:e+=at[n>>2],s=(n&3)<<4,t=1;break;case 1:e+=at[s|n>>4],s=(n&15)<<2,t=2;break;case 2:e+=at[s|n>>6],e+=at[n&63],t=0;break}return t&&(e+=at[s],e+="=",t==1&&(e+="=")),e}};function ll(i,e,t){vo(e,i);const n=e.runtime.bin.makeReadOptions(t),s=dl(i.getType().runtime.bin.listUnknownFields(i),e.field),r=fo(e),a=U(r,2),o=a[0],d=a[1];for(const c of s)e.runtime.bin.readField(o,n.readerFactory(c.data),e.field,c.wireType,n);return d()}function ul(i,e,t,n){vo(e,i);const s=e.runtime.bin.makeReadOptions(n),r=e.runtime.bin.makeWriteOptions(n);if(go(i,e)){const c=i.getType().runtime.bin.listUnknownFields(i).filter(l=>l.no!=e.field.no);i.getType().runtime.bin.discardUnknownFields(i);for(const l of c)i.getType().runtime.bin.onUnknownField(i,l.no,l.wireType,l.data)}const a=r.writerFactory();let o=e.field;!o.opt&&!o.repeated&&(o.kind=="enum"||o.kind=="scalar")&&(o=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(o,t,a,r);const d=s.readerFactory(a.finish());for(;d.pos<d.len;){const c=d.tag(),l=U(c,2),u=l[0],h=l[1],p=d.skip(h,u);i.getType().runtime.bin.onUnknownField(i,u,h,p)}}function go(i,e){const t=i.getType();return e.extendee.typeName===t.typeName&&!!t.runtime.bin.listUnknownFields(i).find(n=>n.no==e.field.no)}function vo(i,e){se(i.extendee.typeName==e.getType().typeName,"extension ".concat(i.typeName," can only be applied to message ").concat(i.extendee.typeName))}function bo(i,e){const t=i.localName;if(i.repeated)return e[t].length>0;if(i.oneof)return e[i.oneof.localName].case===t;switch(i.kind){case"enum":case"scalar":return i.opt||i.req?e[t]!==void 0:i.kind=="enum"?e[t]!==i.T.values[0].no:!po(i.T,e[t]);case"message":return e[t]!==void 0;case"map":return Object.keys(e[t]).length>0}}function xr(i,e){const t=i.localName,n=!i.opt&&!i.req;if(i.repeated)e[t]=[];else if(i.oneof)e[i.oneof.localName]={case:void 0};else switch(i.kind){case"map":e[t]={};break;case"enum":e[t]=n?i.T.values[0].no:void 0;break;case"scalar":e[t]=n?Xt(i.T,i.L):void 0;break;case"message":e[t]=void 0;break}}function ot(i,e){if(i===null||typeof i!="object"||!Object.getOwnPropertyNames(Hs.prototype).every(n=>n in i&&typeof i[n]=="function"))return!1;const t=i.getType();return t===null||typeof t!="function"||!("typeName"in t)||typeof t.typeName!="string"?!1:e===void 0?!0:t.typeName==e.typeName}function yo(i,e){return ot(e)||!i.fieldWrapper?e:i.fieldWrapper.wrapField(e)}w.DOUBLE,w.FLOAT,w.INT64,w.UINT64,w.INT32,w.UINT32,w.BOOL,w.STRING,w.BYTES;const Lr={ignoreUnknownFields:!1},Nr={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function hl(i){return i?Object.assign(Object.assign({},Lr),i):Lr}function pl(i){return i?Object.assign(Object.assign({},Nr),i):Nr}const ii=Symbol(),Wn=Symbol();function fl(){return{makeReadOptions:hl,makeWriteOptions:pl,readMessage(i,e,t,n){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error("cannot decode message ".concat(i.typeName," from JSON: ").concat(Qe(e)));n=n??new i;const s=new Map,r=t.typeRegistry;for(const o of Object.entries(e)){var a=U(o,2);const d=a[0],c=a[1],l=i.fields.findJsonName(d);if(l){if(l.oneof){if(c===null&&l.kind=="scalar")continue;const u=s.get(l.oneof);if(u!==void 0)throw new Error("cannot decode message ".concat(i.typeName,' from JSON: multiple keys for oneof "').concat(l.oneof.name,'" present: "').concat(u,'", "').concat(d,'"'));s.set(l.oneof,d)}Ur(n,c,l,t,i)}else{let u=!1;if(r!=null&&r.findExtension&&d.startsWith("[")&&d.endsWith("]")){const h=r.findExtension(d.substring(1,d.length-1));if(h&&h.extendee.typeName==i.typeName){u=!0;const p=fo(h),g=U(p,2),m=g[0],T=g[1];Ur(m,c,h.field,t,h),ul(n,h,T(),t)}}if(!u&&!t.ignoreUnknownFields)throw new Error("cannot decode message ".concat(i.typeName,' from JSON: key "').concat(d,'" is unknown'))}}return n},writeMessage(i,e){const t=i.getType(),n={};let s;try{for(s of t.fields.byNumber()){if(!bo(s,i)){if(s.req)throw"required field not set";if(!e.emitDefaultValues||!gl(s))continue}const a=s.oneof?i[s.oneof.localName].value:i[s.localName],o=Fr(s,a,e);o!==void 0&&(n[e.useProtoFieldName?s.name:s.jsonName]=o)}const r=e.typeRegistry;if(r!=null&&r.findExtensionFor)for(const a of t.runtime.bin.listUnknownFields(i)){const o=r.findExtensionFor(t.typeName,a.no);if(o&&go(i,o)){const d=ll(i,o,e),c=Fr(o.field,d,e);c!==void 0&&(n[o.field.jsonName]=c)}}}catch(r){const a=s?"cannot encode field ".concat(t.typeName,".").concat(s.name," to JSON"):"cannot encode message ".concat(t.typeName," to JSON"),o=r instanceof Error?r.message:String(r);throw new Error(a+(o.length>0?": ".concat(o):""))}return n},readScalar(i,e,t){return bn(i,e,t??Tt.BIGINT,!0)},writeScalar(i,e,t){if(e!==void 0&&(t||po(i,e)))return Hn(i,e)},debug:Qe}}function Qe(i){if(i===null)return"null";switch(typeof i){case"object":return Array.isArray(i)?"array":"object";case"string":return i.length>100?"string":'"'.concat(i.split('"').join('\\"'),'"');default:return String(i)}}function Ur(i,e,t,n,s){let r=t.localName;if(t.repeated){if(se(t.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error("cannot decode field ".concat(s.typeName,".").concat(t.name," from JSON: ").concat(Qe(e)));const o=i[r];for(const d of e){if(d===null)throw new Error("cannot decode field ".concat(s.typeName,".").concat(t.name," from JSON: ").concat(Qe(d)));switch(t.kind){case"message":o.push(t.T.fromJson(d,n));break;case"enum":const c=Gi(t.T,d,n.ignoreUnknownFields,!0);c!==Wn&&o.push(c);break;case"scalar":try{o.push(bn(t.T,d,t.L,!0))}catch(l){let u="cannot decode field ".concat(s.typeName,".").concat(t.name," from JSON: ").concat(Qe(d));throw l instanceof Error&&l.message.length>0&&(u+=": ".concat(l.message)),new Error(u)}break}}}else if(t.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error("cannot decode field ".concat(s.typeName,".").concat(t.name," from JSON: ").concat(Qe(e)));const o=i[r];for(const d of Object.entries(e)){var a=U(d,2);const c=a[0],l=a[1];if(l===null)throw new Error("cannot decode field ".concat(s.typeName,".").concat(t.name," from JSON: map value null"));let u;try{u=ml(t.K,c)}catch(h){let p="cannot decode map key for field ".concat(s.typeName,".").concat(t.name," from JSON: ").concat(Qe(e));throw h instanceof Error&&h.message.length>0&&(p+=": ".concat(h.message)),new Error(p)}switch(t.V.kind){case"message":o[u]=t.V.T.fromJson(l,n);break;case"enum":const h=Gi(t.V.T,l,n.ignoreUnknownFields,!0);h!==Wn&&(o[u]=h);break;case"scalar":try{o[u]=bn(t.V.T,l,Tt.BIGINT,!0)}catch(p){let g="cannot decode map value for field ".concat(s.typeName,".").concat(t.name," from JSON: ").concat(Qe(e));throw p instanceof Error&&p.message.length>0&&(g+=": ".concat(p.message)),new Error(g)}break}}}else switch(t.oneof&&(i=i[t.oneof.localName]={case:r},r="value"),t.kind){case"message":const o=t.T;if(e===null&&o.typeName!="google.protobuf.Value")return;let d=i[r];ot(d)?d.fromJson(e,n):(i[r]=d=o.fromJson(e,n),o.fieldWrapper&&!t.oneof&&(i[r]=o.fieldWrapper.unwrapField(d)));break;case"enum":const c=Gi(t.T,e,n.ignoreUnknownFields,!1);switch(c){case ii:xr(t,i);break;case Wn:break;default:i[r]=c;break}break;case"scalar":try{const l=bn(t.T,e,t.L,!1);switch(l){case ii:xr(t,i);break;default:i[r]=l;break}}catch(l){let u="cannot decode field ".concat(s.typeName,".").concat(t.name," from JSON: ").concat(Qe(e));throw l instanceof Error&&l.message.length>0&&(u+=": ".concat(l.message)),new Error(u)}break}}function ml(i,e){if(i===w.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return bn(i,e,Tt.BIGINT,!0).toString()}function bn(i,e,t,n){if(e===null)return n?Xt(i,t):ii;switch(i){case w.DOUBLE:case w.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const s=Number(e);if(Number.isNaN(s)||!Number.isFinite(s))break;return i==w.FLOAT&&ro(s),s;case w.INT32:case w.FIXED32:case w.SFIXED32:case w.SINT32:case w.UINT32:let r;if(typeof e=="number"?r=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(r=Number(e)),r===void 0)break;return i==w.UINT32||i==w.FIXED32?ms(r):qn(r),r;case w.INT64:case w.SFIXED64:case w.SINT64:if(typeof e!="number"&&typeof e!="string")break;const a=te.parse(e);return t?a.toString():a;case w.FIXED64:case w.UINT64:if(typeof e!="number"&&typeof e!="string")break;const o=te.uParse(e);return t?o.toString():o;case w.BOOL:if(typeof e!="boolean")break;return e;case w.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case w.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return mo.dec(e)}throw new Error}function Gi(i,e,t,n){if(e===null)return i.typeName=="google.protobuf.NullValue"?0:n?i.values[0].no:ii;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const s=i.findName(e);if(s!==void 0)return s.no;if(t)return Wn;break}throw new Error("cannot decode enum ".concat(i.typeName," from JSON: ").concat(Qe(e)))}function gl(i){return i.repeated||i.kind=="map"?!0:!(i.oneof||i.kind=="message"||i.opt||i.req)}function Fr(i,e,t){if(i.kind=="map"){se(typeof e=="object"&&e!=null);const a={},o=Object.entries(e);switch(i.V.kind){case"scalar":for(const c of o){var n=U(c,2);const l=n[0],u=n[1];a[l.toString()]=Hn(i.V.T,u)}break;case"message":for(const c of o){var s=U(c,2);const l=s[0],u=s[1];a[l.toString()]=u.toJson(t)}break;case"enum":const d=i.V.T;for(const c of o){var r=U(c,2);const l=r[0],u=r[1];a[l.toString()]=zi(d,u,t.enumAsInteger)}break}return t.emitDefaultValues||o.length>0?a:void 0}if(i.repeated){se(Array.isArray(e));const a=[];switch(i.kind){case"scalar":for(let o=0;o<e.length;o++)a.push(Hn(i.T,e[o]));break;case"enum":for(let o=0;o<e.length;o++)a.push(zi(i.T,e[o],t.enumAsInteger));break;case"message":for(let o=0;o<e.length;o++)a.push(e[o].toJson(t));break}return t.emitDefaultValues||a.length>0?a:void 0}switch(i.kind){case"scalar":return Hn(i.T,e);case"enum":return zi(i.T,e,t.enumAsInteger);case"message":return yo(i.T,e).toJson(t)}}function zi(i,e,t){var n;if(se(typeof e=="number"),i.typeName=="google.protobuf.NullValue")return null;if(t)return e;const s=i.findNumber(e);return(n=s==null?void 0:s.name)!==null&&n!==void 0?n:e}function Hn(i,e){switch(i){case w.INT32:case w.SFIXED32:case w.SINT32:case w.FIXED32:case w.UINT32:return se(typeof e=="number"),e;case w.FLOAT:case w.DOUBLE:return se(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case w.STRING:return se(typeof e=="string"),e;case w.BOOL:return se(typeof e=="boolean"),e;case w.UINT64:case w.FIXED64:case w.INT64:case w.SFIXED64:case w.SINT64:return se(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case w.BYTES:return se(e instanceof Uint8Array),mo.enc(e)}}const Ft=Symbol("@bufbuild/protobuf/unknown-fields"),Br={readUnknownFields:!0,readerFactory:i=>new al(i)},Vr={writeUnknownFields:!0,writerFactory:()=>new rl};function vl(i){return i?Object.assign(Object.assign({},Br),i):Br}function bl(i){return i?Object.assign(Object.assign({},Vr),i):Vr}function yl(){return{makeReadOptions:vl,makeWriteOptions:bl,listUnknownFields(i){var e;return(e=i[Ft])!==null&&e!==void 0?e:[]},discardUnknownFields(i){delete i[Ft]},writeUnknownFields(i,e){const n=i[Ft];if(n)for(const s of n)e.tag(s.no,s.wireType).raw(s.data)},onUnknownField(i,e,t,n){const s=i;Array.isArray(s[Ft])||(s[Ft]=[]),s[Ft].push({no:e,wireType:t,data:n})},readMessage(i,e,t,n,s){const r=i.getType(),a=s?e.len:e.pos+t;let o,d;for(;e.pos<a;){var c=e.tag(),l=U(c,2);if(o=l[0],d=l[1],s===!0&&d==ae.EndGroup)break;const u=r.fields.find(o);if(!u){const h=e.skip(d,o);n.readUnknownFields&&this.onUnknownField(i,o,d,h);continue}qr(i,e,u,d,n)}if(s&&(d!=ae.EndGroup||o!==t))throw new Error("invalid end group tag")},readField:qr,writeMessage(i,e,t){const n=i.getType();for(const s of n.fields.byNumber()){if(!bo(s,i)){if(s.req)throw new Error("cannot encode field ".concat(n.typeName,".").concat(s.name," to binary: required field not set"));continue}const r=s.oneof?i[s.oneof.localName].value:i[s.localName];jr(s,r,e,t)}return t.writeUnknownFields&&this.writeUnknownFields(i,e),e},writeField(i,e,t,n){e!==void 0&&jr(i,e,t,n)}}}function qr(i,e,t,n,s){let r=t.repeated,a=t.localName;switch(t.oneof&&(i=i[t.oneof.localName],i.case!=a&&delete i.value,i.case=a,a="value"),t.kind){case"scalar":case"enum":const o=t.kind=="enum"?w.INT32:t.T;let d=si;if(t.kind=="scalar"&&t.L>0&&(d=Tl),r){let g=i[a];if(n==ae.LengthDelimited&&o!=w.STRING&&o!=w.BYTES){let T=e.uint32()+e.pos;for(;e.pos<T;)g.push(d(e,o))}else g.push(d(e,o))}else i[a]=d(e,o);break;case"message":const c=t.T;r?i[a].push(Kn(e,new c,s,t)):ot(i[a])?Kn(e,i[a],s,t):(i[a]=Kn(e,new c,s,t),c.fieldWrapper&&!t.oneof&&!t.repeated&&(i[a]=c.fieldWrapper.unwrapField(i[a])));break;case"map":let l=kl(t,e,s),u=U(l,2),h=u[0],p=u[1];i[a][h]=p;break}}function Kn(i,e,t,n){const s=e.getType().runtime.bin,r=n==null?void 0:n.delimited;return s.readMessage(e,i,r?n.no:i.uint32(),t,r),e}function kl(i,e,t){const n=e.uint32(),s=e.pos+n;let r,a;for(;e.pos<s;){const o=e.tag();switch(U(o,1)[0]){case 1:r=si(e,i.K);break;case 2:switch(i.V.kind){case"scalar":a=si(e,i.V.T);break;case"enum":a=e.int32();break;case"message":a=Kn(e,new i.V.T,t,void 0);break}break}}if(r===void 0&&(r=Xt(i.K,Tt.BIGINT)),typeof r!="string"&&typeof r!="number"&&(r=r.toString()),a===void 0)switch(i.V.kind){case"scalar":a=Xt(i.V.T,Tt.BIGINT);break;case"enum":a=i.V.T.values[0].no;break;case"message":a=new i.V.T;break}return[r,a]}function Tl(i,e){const t=si(i,e);return typeof t=="bigint"?t.toString():t}function si(i,e){switch(e){case w.STRING:return i.string();case w.BOOL:return i.bool();case w.DOUBLE:return i.double();case w.FLOAT:return i.float();case w.INT32:return i.int32();case w.INT64:return i.int64();case w.UINT64:return i.uint64();case w.FIXED64:return i.fixed64();case w.BYTES:return i.bytes();case w.FIXED32:return i.fixed32();case w.SFIXED32:return i.sfixed32();case w.SFIXED64:return i.sfixed64();case w.SINT64:return i.sint64();case w.UINT32:return i.uint32();case w.SINT32:return i.sint32()}}function jr(i,e,t,n){se(e!==void 0);const s=i.repeated;switch(i.kind){case"scalar":case"enum":let a=i.kind=="enum"?w.INT32:i.T;if(s)if(se(Array.isArray(e)),i.packed)Cl(t,a,i.no,e);else for(const o of e)yn(t,a,i.no,o);else yn(t,a,i.no,e);break;case"message":if(s){se(Array.isArray(e));for(const o of e)Wr(t,n,i,o)}else Wr(t,n,i,e);break;case"map":se(typeof e=="object"&&e!=null);for(const o of Object.entries(e)){var r=U(o,2);const d=r[0],c=r[1];Sl(t,n,i,d,c)}break}}function Sl(i,e,t,n,s){i.tag(t.no,ae.LengthDelimited),i.fork();let r=n;switch(t.K){case w.INT32:case w.FIXED32:case w.UINT32:case w.SFIXED32:case w.SINT32:r=Number.parseInt(n);break;case w.BOOL:se(n=="true"||n=="false"),r=n=="true";break}switch(yn(i,t.K,1,r),t.V.kind){case"scalar":yn(i,t.V.T,2,s);break;case"enum":yn(i,w.INT32,2,s);break;case"message":se(s!==void 0),i.tag(2,ae.LengthDelimited).bytes(s.toBinary(e));break}i.join()}function Wr(i,e,t,n){const s=yo(t.T,n);t.delimited?i.tag(t.no,ae.StartGroup).raw(s.toBinary(e)).tag(t.no,ae.EndGroup):i.tag(t.no,ae.LengthDelimited).bytes(s.toBinary(e))}function yn(i,e,t,n){se(n!==void 0);let s=ko(e),r=U(s,2),a=r[0],o=r[1];i.tag(t,a)[o](n)}function Cl(i,e,t,n){if(!n.length)return;i.tag(t,ae.LengthDelimited).fork();let s=ko(e),r=U(s,2),a=r[1];for(let o=0;o<n.length;o++)i[a](n[o]);i.join()}function ko(i){let e=ae.Varint;switch(i){case w.BYTES:case w.STRING:e=ae.LengthDelimited;break;case w.DOUBLE:case w.FIXED64:case w.SFIXED64:e=ae.Bit64;break;case w.FIXED32:case w.SFIXED32:case w.FLOAT:e=ae.Bit32;break}const t=w[i].toLowerCase();return[e,t]}function _l(){return{setEnumType:oo,initPartial(i,e){if(i===void 0)return;const t=e.getType();for(const s of t.fields.byMember()){const r=s.localName,a=e,o=i;if(o[r]!=null)switch(s.kind){case"oneof":const d=o[r].case;if(d===void 0)continue;const c=s.findField(d);let l=o[r].value;c&&c.kind=="message"&&!ot(l,c.T)?l=new c.T(l):c&&c.kind==="scalar"&&c.T===w.BYTES&&(l=on(l)),a[r]={case:d,value:l};break;case"scalar":case"enum":let u=o[r];s.T===w.BYTES&&(u=s.repeated?u.map(on):on(u)),a[r]=u;break;case"map":switch(s.V.kind){case"scalar":case"enum":if(s.V.T===w.BYTES)for(const g of Object.entries(o[r])){var n=U(g,2);const m=n[0],T=n[1];a[r][m]=on(T)}else Object.assign(a[r],o[r]);break;case"message":const p=s.V.T;for(const g of Object.keys(o[r])){let m=o[r][g];p.fieldWrapper||(m=new p(m)),a[r][g]=m}break}break;case"message":const h=s.T;if(s.repeated)a[r]=o[r].map(p=>ot(p,h)?p:new h(p));else{const p=o[r];h.fieldWrapper?h.typeName==="google.protobuf.BytesValue"?a[r]=on(p):a[r]=p:a[r]=ot(p,h)?p:new h(p)}break}}},equals(i,e,t){return e===t?!0:!e||!t?!1:i.fields.byMember().every(n=>{const s=e[n.localName],r=t[n.localName];if(n.repeated){if(s.length!==r.length)return!1;switch(n.kind){case"message":return s.every((a,o)=>n.T.equals(a,r[o]));case"scalar":return s.every((a,o)=>pt(n.T,a,r[o]));case"enum":return s.every((a,o)=>pt(w.INT32,a,r[o]))}throw new Error("repeated cannot contain ".concat(n.kind))}switch(n.kind){case"message":let a=s,o=r;return n.T.fieldWrapper&&(a!==void 0&&!ot(a)&&(a=n.T.fieldWrapper.wrapField(a)),o!==void 0&&!ot(o)&&(o=n.T.fieldWrapper.wrapField(o))),n.T.equals(a,o);case"enum":return pt(w.INT32,s,r);case"scalar":return pt(n.T,s,r);case"oneof":if(s.case!==r.case)return!1;const d=n.findField(s.case);if(d===void 0)return!0;switch(d.kind){case"message":return d.T.equals(s.value,r.value);case"enum":return pt(w.INT32,s.value,r.value);case"scalar":return pt(d.T,s.value,r.value)}throw new Error("oneof cannot contain ".concat(d.kind));case"map":const c=Object.keys(s).concat(Object.keys(r));switch(n.V.kind){case"message":const l=n.V.T;return c.every(h=>l.equals(s[h],r[h]));case"enum":return c.every(h=>pt(w.INT32,s[h],r[h]));case"scalar":const u=n.V.T;return c.every(h=>pt(u,s[h],r[h]))}break}})},clone(i){const e=i.getType(),t=new e,n=t;for(const r of e.fields.byMember()){const a=i[r.localName];let o;if(r.repeated)o=a.map(Un);else if(r.kind=="map"){o=n[r.localName];for(const d of Object.entries(a)){var s=U(d,2);const c=s[0],l=s[1];o[c]=Un(l)}}else r.kind=="oneof"?o=r.findField(a.case)?{case:a.case,value:Un(a.value)}:{case:void 0}:o=Un(a);n[r.localName]=o}for(const r of e.runtime.bin.listUnknownFields(i))e.runtime.bin.onUnknownField(n,r.no,r.wireType,r.data);return t}}}function Un(i){if(i===void 0)return i;if(ot(i))return i.clone();if(i instanceof Uint8Array){const e=new Uint8Array(i.byteLength);return e.set(i),e}return i}function on(i){return i instanceof Uint8Array?i:new Uint8Array(i)}function wl(i,e,t){return{syntax:i,json:fl(),bin:yl(),util:Object.assign(Object.assign({},_l()),{newFieldList:e,initFields:t}),makeMessageType(n,s,r){return zd(this,n,s,r)},makeEnum:Gd,makeEnumType:co,getEnumType:Kd,makeExtension(n,s,r){return ol(this,n,s,r)}}}class El{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const t={};for(const n of this.list())t[n.jsonName]=t[n.name]=n;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){const t={};for(const n of this.list())t[n.no]=n;this.numbers=t}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,t)=>e.no-t.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}}function To(i,e){const t=So(i);return e?t:Al(Dl(t))}function Pl(i){return To(i,!1)}const Rl=So;function So(i){let e=!1;const t=[];for(let n=0;n<i.length;n++){let s=i.charAt(n);switch(s){case"_":e=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":t.push(s),e=!1;break;default:e&&(e=!1,s=s.toUpperCase()),t.push(s);break}}return t.join("")}const Il=new Set(["constructor","toString","toJSON","valueOf"]),Ml=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Co=i=>"".concat(i,"$"),Dl=i=>Ml.has(i)?Co(i):i,Al=i=>Il.has(i)?Co(i):i;class Ol{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=Pl(e)}addField(e){se(e.oneof===this,"field ".concat(e.name," not one of ").concat(this.name)),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let t=0;t<this.fields.length;t++)this._lookup[this.fields[t].localName]=this.fields[t]}return this._lookup[e]}}function xl(i,e){var t,n,s,r,a,o;const d=[];let c;for(const l of typeof i=="function"?i():i){const u=l;if(u.localName=To(l.name,l.oneof!==void 0),u.jsonName=(t=l.jsonName)!==null&&t!==void 0?t:Rl(l.name),u.repeated=(n=l.repeated)!==null&&n!==void 0?n:!1,l.kind=="scalar"&&(u.L=(s=l.L)!==null&&s!==void 0?s:Tt.BIGINT),u.delimited=(r=l.delimited)!==null&&r!==void 0?r:!1,u.req=(a=l.req)!==null&&a!==void 0?a:!1,u.opt=(o=l.opt)!==null&&o!==void 0?o:!1,l.packed===void 0&&(u.packed=l.kind=="enum"||l.kind=="scalar"&&l.T!=w.BYTES&&l.T!=w.STRING),l.oneof!==void 0){const h=typeof l.oneof=="string"?l.oneof:l.oneof.name;(!c||c.name!=h)&&(c=new Ol(h)),u.oneof=c,c.addField(u)}d.push(u)}return d}const b=wl("proto3",i=>new El(i,e=>xl(e)),i=>{for(const e of i.getType().fields.byMember()){if(e.opt)continue;const t=e.localName,n=i;if(e.repeated){n[t]=[];continue}switch(e.kind){case"oneof":n[t]={case:void 0};break;case"enum":n[t]=0;break;case"map":n[t]={};break;case"scalar":n[t]=Xt(e.T,e.L);break}}});class Ee extends Hs{constructor(e){super(),this.seconds=te.zero,this.nanos=0,b.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error("cannot decode google.protobuf.Timestamp from JSON: ".concat(b.json.debug(e)));const n=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const s=Date.parse(n[1]+"-"+n[2]+"-"+n[3]+"T"+n[4]+":"+n[5]+":"+n[6]+(n[8]?n[8]:"Z"));if(Number.isNaN(s))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(s<Date.parse("0001-01-01T00:00:00Z")||s>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");return this.seconds=te.parse(s/1e3),this.nanos=0,n[7]&&(this.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),this}toJson(e){const t=Number(this.seconds)*1e3;if(t<Date.parse("0001-01-01T00:00:00Z")||t>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let n="Z";if(this.nanos>0){const s=(this.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?n="."+s.substring(0,3)+"Z":s.substring(6)==="000"?n="."+s.substring(0,6)+"Z":n="."+s+"Z"}return new Date(t).toISOString().replace(".000Z",n)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Ee.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Ee({seconds:te.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return new Ee().fromBinary(e,t)}static fromJson(e,t){return new Ee().fromJson(e,t)}static fromJsonString(e,t){return new Ee().fromJsonString(e,t)}static equals(e,t){return b.util.equals(Ee,e,t)}}Ee.runtime=b;Ee.typeName="google.protobuf.Timestamp";Ee.fields=b.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);const Ll=b.makeMessageType("livekit.MetricsBatch",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Ee},{no:3,name:"str_data",kind:"scalar",T:9,repeated:!0},{no:4,name:"time_series",kind:"message",T:Nl,repeated:!0},{no:5,name:"events",kind:"message",T:Fl,repeated:!0}]),Nl=b.makeMessageType("livekit.TimeSeriesMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"samples",kind:"message",T:Ul,repeated:!0},{no:5,name:"rid",kind:"scalar",T:13}]),Ul=b.makeMessageType("livekit.MetricSample",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Ee},{no:3,name:"value",kind:"scalar",T:2}]),Fl=b.makeMessageType("livekit.EventMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"start_timestamp_ms",kind:"scalar",T:3},{no:5,name:"end_timestamp_ms",kind:"scalar",T:3,opt:!0},{no:6,name:"normalized_start_timestamp",kind:"message",T:Ee},{no:7,name:"normalized_end_timestamp",kind:"message",T:Ee,opt:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"rid",kind:"scalar",T:13}]),_o=b.makeEnum("livekit.BackupCodecPolicy",[{no:0,name:"PREFER_REGRESSION"},{no:1,name:"SIMULCAST"},{no:2,name:"REGRESSION"}]),Fe=b.makeEnum("livekit.TrackType",[{no:0,name:"AUDIO"},{no:1,name:"VIDEO"},{no:2,name:"DATA"}]),oe=b.makeEnum("livekit.TrackSource",[{no:0,name:"UNKNOWN"},{no:1,name:"CAMERA"},{no:2,name:"MICROPHONE"},{no:3,name:"SCREEN_SHARE"},{no:4,name:"SCREEN_SHARE_AUDIO"}]),Gs=b.makeEnum("livekit.VideoQuality",[{no:0,name:"LOW"},{no:1,name:"MEDIUM"},{no:2,name:"HIGH"},{no:3,name:"OFF"}]),mn=b.makeEnum("livekit.ConnectionQuality",[{no:0,name:"POOR"},{no:1,name:"GOOD"},{no:2,name:"EXCELLENT"},{no:3,name:"LOST"}]),wn=b.makeEnum("livekit.ClientConfigSetting",[{no:0,name:"UNSET"},{no:1,name:"DISABLED"},{no:2,name:"ENABLED"}]),He=b.makeEnum("livekit.DisconnectReason",[{no:0,name:"UNKNOWN_REASON"},{no:1,name:"CLIENT_INITIATED"},{no:2,name:"DUPLICATE_IDENTITY"},{no:3,name:"SERVER_SHUTDOWN"},{no:4,name:"PARTICIPANT_REMOVED"},{no:5,name:"ROOM_DELETED"},{no:6,name:"STATE_MISMATCH"},{no:7,name:"JOIN_FAILURE"},{no:8,name:"MIGRATION"},{no:9,name:"SIGNAL_CLOSE"},{no:10,name:"ROOM_CLOSED"},{no:11,name:"USER_UNAVAILABLE"},{no:12,name:"USER_REJECTED"},{no:13,name:"SIP_TRUNK_FAILURE"},{no:14,name:"CONNECTION_TIMEOUT"},{no:15,name:"MEDIA_FAILURE"},{no:16,name:"AGENT_ERROR"}]),_t=b.makeEnum("livekit.ReconnectReason",[{no:0,name:"RR_UNKNOWN"},{no:1,name:"RR_SIGNAL_DISCONNECTED"},{no:2,name:"RR_PUBLISHER_FAILED"},{no:3,name:"RR_SUBSCRIBER_FAILED"},{no:4,name:"RR_SWITCH_CANDIDATE"}]),Bl=b.makeEnum("livekit.SubscriptionError",[{no:0,name:"SE_UNKNOWN"},{no:1,name:"SE_CODEC_UNSUPPORTED"},{no:2,name:"SE_TRACK_NOTFOUND"}]),le=b.makeEnum("livekit.AudioTrackFeature",[{no:0,name:"TF_STEREO"},{no:1,name:"TF_NO_DTX"},{no:2,name:"TF_AUTO_GAIN_CONTROL"},{no:3,name:"TF_ECHO_CANCELLATION"},{no:4,name:"TF_NOISE_SUPPRESSION"},{no:5,name:"TF_ENHANCED_NOISE_CANCELLATION"},{no:6,name:"TF_PRECONNECT_BUFFER"}]),Zt=b.makeEnum("livekit.PacketTrailerFeature",[{no:0,name:"PTF_USER_TIMESTAMP"},{no:1,name:"PTF_FRAME_ID"}]),ki=b.makeMessageType("livekit.Room",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"empty_timeout",kind:"scalar",T:13},{no:14,name:"departure_timeout",kind:"scalar",T:13},{no:4,name:"max_participants",kind:"scalar",T:13},{no:5,name:"creation_time",kind:"scalar",T:3},{no:15,name:"creation_time_ms",kind:"scalar",T:3},{no:6,name:"turn_password",kind:"scalar",T:9},{no:7,name:"enabled_codecs",kind:"message",T:ri,repeated:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"num_participants",kind:"scalar",T:13},{no:11,name:"num_publishers",kind:"scalar",T:13},{no:10,name:"active_recording",kind:"scalar",T:8},{no:13,name:"version",kind:"message",T:Fo}]),ri=b.makeMessageType("livekit.Codec",()=>[{no:1,name:"mime",kind:"scalar",T:9},{no:2,name:"fmtp_line",kind:"scalar",T:9}]),Vl=b.makeMessageType("livekit.ParticipantPermission",()=>[{no:1,name:"can_subscribe",kind:"scalar",T:8},{no:2,name:"can_publish",kind:"scalar",T:8},{no:3,name:"can_publish_data",kind:"scalar",T:8},{no:9,name:"can_publish_sources",kind:"enum",T:b.getEnumType(oe),repeated:!0},{no:7,name:"hidden",kind:"scalar",T:8},{no:8,name:"recorder",kind:"scalar",T:8},{no:10,name:"can_update_metadata",kind:"scalar",T:8},{no:11,name:"agent",kind:"scalar",T:8},{no:12,name:"can_subscribe_metrics",kind:"scalar",T:8},{no:13,name:"can_manage_agent_session",kind:"scalar",T:8}]),xt=b.makeMessageType("livekit.ParticipantInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"identity",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:b.getEnumType(Wt)},{no:4,name:"tracks",kind:"message",T:Vt,repeated:!0},{no:5,name:"metadata",kind:"scalar",T:9},{no:6,name:"joined_at",kind:"scalar",T:3},{no:17,name:"joined_at_ms",kind:"scalar",T:3},{no:9,name:"name",kind:"scalar",T:9},{no:10,name:"version",kind:"scalar",T:13},{no:11,name:"permission",kind:"message",T:Vl},{no:12,name:"region",kind:"scalar",T:9},{no:13,name:"is_publisher",kind:"scalar",T:8},{no:14,name:"kind",kind:"enum",T:b.getEnumType(En)},{no:15,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:16,name:"disconnect_reason",kind:"enum",T:b.getEnumType(He)},{no:18,name:"kind_details",kind:"enum",T:b.getEnumType(ql),repeated:!0},{no:19,name:"data_tracks",kind:"message",T:Ti,repeated:!0},{no:20,name:"client_protocol",kind:"scalar",T:5}]),Wt=b.makeEnum("livekit.ParticipantInfo.State",[{no:0,name:"JOINING"},{no:1,name:"JOINED"},{no:2,name:"ACTIVE"},{no:3,name:"DISCONNECTED"}]),En=b.makeEnum("livekit.ParticipantInfo.Kind",[{no:0,name:"STANDARD"},{no:1,name:"INGRESS"},{no:2,name:"EGRESS"},{no:3,name:"SIP"},{no:4,name:"AGENT"},{no:7,name:"CONNECTOR"},{no:8,name:"BRIDGE"}]),ql=b.makeEnum("livekit.ParticipantInfo.KindDetail",[{no:0,name:"CLOUD_AGENT"},{no:1,name:"FORWARDED"},{no:2,name:"CONNECTOR_WHATSAPP"},{no:3,name:"CONNECTOR_TWILIO"},{no:4,name:"BRIDGE_RTSP"}]),X=b.makeEnum("livekit.Encryption.Type",[{no:0,name:"NONE"},{no:1,name:"GCM"},{no:2,name:"CUSTOM"}]),jl=b.makeMessageType("livekit.SimulcastCodecInfo",()=>[{no:1,name:"mime_type",kind:"scalar",T:9},{no:2,name:"mid",kind:"scalar",T:9},{no:3,name:"cid",kind:"scalar",T:9},{no:4,name:"layers",kind:"message",T:bt,repeated:!0},{no:5,name:"video_layer_mode",kind:"enum",T:b.getEnumType(wo)},{no:6,name:"sdp_cid",kind:"scalar",T:9}]),Vt=b.makeMessageType("livekit.TrackInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"type",kind:"enum",T:b.getEnumType(Fe)},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"muted",kind:"scalar",T:8},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"simulcast",kind:"scalar",T:8},{no:8,name:"disable_dtx",kind:"scalar",T:8},{no:9,name:"source",kind:"enum",T:b.getEnumType(oe)},{no:10,name:"layers",kind:"message",T:bt,repeated:!0},{no:11,name:"mime_type",kind:"scalar",T:9},{no:12,name:"mid",kind:"scalar",T:9},{no:13,name:"codecs",kind:"message",T:jl,repeated:!0},{no:14,name:"stereo",kind:"scalar",T:8},{no:15,name:"disable_red",kind:"scalar",T:8},{no:16,name:"encryption",kind:"enum",T:b.getEnumType(X)},{no:17,name:"stream",kind:"scalar",T:9},{no:18,name:"version",kind:"message",T:Fo},{no:19,name:"audio_features",kind:"enum",T:b.getEnumType(le),repeated:!0},{no:20,name:"backup_codec_policy",kind:"enum",T:b.getEnumType(_o)},{no:21,name:"packet_trailer_features",kind:"enum",T:b.getEnumType(Zt),repeated:!0}]),Ti=b.makeMessageType("livekit.DataTrackInfo",()=>[{no:1,name:"pub_handle",kind:"scalar",T:13},{no:2,name:"sid",kind:"scalar",T:9},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"encryption",kind:"enum",T:b.getEnumType(X)}]),Wl=b.makeMessageType("livekit.DataTrackSubscriptionOptions",()=>[{no:1,name:"target_fps",kind:"scalar",T:13,opt:!0}]),bt=b.makeMessageType("livekit.VideoLayer",()=>[{no:1,name:"quality",kind:"enum",T:b.getEnumType(Gs)},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13},{no:4,name:"bitrate",kind:"scalar",T:13},{no:5,name:"ssrc",kind:"scalar",T:13},{no:6,name:"spatial_layer",kind:"scalar",T:5},{no:7,name:"rid",kind:"scalar",T:9},{no:8,name:"repair_ssrc",kind:"scalar",T:13}]),wo=b.makeEnum("livekit.VideoLayer.Mode",[{no:0,name:"MODE_UNUSED"},{no:1,name:"ONE_SPATIAL_LAYER_PER_STREAM"},{no:2,name:"MULTIPLE_SPATIAL_LAYERS_PER_STREAM"},{no:3,name:"ONE_SPATIAL_LAYER_PER_STREAM_INCOMPLETE_RTCP_SR"}]),ve=b.makeMessageType("livekit.DataPacket",()=>[{no:1,name:"kind",kind:"enum",T:b.getEnumType(yt)},{no:4,name:"participant_identity",kind:"scalar",T:9},{no:5,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:2,name:"user",kind:"message",T:zs,oneof:"value"},{no:3,name:"speaker",kind:"message",T:Hl,oneof:"value"},{no:6,name:"sip_dtmf",kind:"message",T:Io,oneof:"value"},{no:7,name:"transcription",kind:"message",T:Kl,oneof:"value"},{no:8,name:"metrics",kind:"message",T:Ll,oneof:"value"},{no:9,name:"chat_message",kind:"message",T:ai,oneof:"value"},{no:10,name:"rpc_request",kind:"message",T:Js,oneof:"value"},{no:11,name:"rpc_ack",kind:"message",T:Si,oneof:"value"},{no:12,name:"rpc_response",kind:"message",T:$s,oneof:"value"},{no:13,name:"stream_header",kind:"message",T:oi,oneof:"value"},{no:14,name:"stream_chunk",kind:"message",T:ci,oneof:"value"},{no:15,name:"stream_trailer",kind:"message",T:di,oneof:"value"},{no:18,name:"encrypted_packet",kind:"message",T:Eo,oneof:"value"},{no:16,name:"sequence",kind:"scalar",T:13},{no:17,name:"participant_sid",kind:"scalar",T:9}]),yt=b.makeEnum("livekit.DataPacket.Kind",[{no:0,name:"RELIABLE"},{no:1,name:"LOSSY"}]),Eo=b.makeMessageType("livekit.EncryptedPacket",()=>[{no:1,name:"encryption_type",kind:"enum",T:b.getEnumType(X)},{no:2,name:"iv",kind:"scalar",T:12},{no:3,name:"key_index",kind:"scalar",T:13},{no:4,name:"encrypted_value",kind:"scalar",T:12}]),Po=b.makeMessageType("livekit.EncryptedPacketPayload",()=>[{no:1,name:"user",kind:"message",T:zs,oneof:"value"},{no:3,name:"chat_message",kind:"message",T:ai,oneof:"value"},{no:4,name:"rpc_request",kind:"message",T:Js,oneof:"value"},{no:5,name:"rpc_ack",kind:"message",T:Si,oneof:"value"},{no:6,name:"rpc_response",kind:"message",T:$s,oneof:"value"},{no:7,name:"stream_header",kind:"message",T:oi,oneof:"value"},{no:8,name:"stream_chunk",kind:"message",T:ci,oneof:"value"},{no:9,name:"stream_trailer",kind:"message",T:di,oneof:"value"}]),Hl=b.makeMessageType("livekit.ActiveSpeakerUpdate",()=>[{no:1,name:"speakers",kind:"message",T:Ro,repeated:!0}]),Ro=b.makeMessageType("livekit.SpeakerInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"level",kind:"scalar",T:2},{no:3,name:"active",kind:"scalar",T:8}]),zs=b.makeMessageType("livekit.UserPacket",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:5,name:"participant_identity",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12},{no:3,name:"destination_sids",kind:"scalar",T:9,repeated:!0},{no:6,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:4,name:"topic",kind:"scalar",T:9,opt:!0},{no:8,name:"id",kind:"scalar",T:9,opt:!0},{no:9,name:"start_time",kind:"scalar",T:4,opt:!0},{no:10,name:"end_time",kind:"scalar",T:4,opt:!0},{no:11,name:"nonce",kind:"scalar",T:12}]),Io=b.makeMessageType("livekit.SipDTMF",()=>[{no:3,name:"code",kind:"scalar",T:13},{no:4,name:"digit",kind:"scalar",T:9}]),Kl=b.makeMessageType("livekit.Transcription",()=>[{no:2,name:"transcribed_participant_identity",kind:"scalar",T:9},{no:3,name:"track_id",kind:"scalar",T:9},{no:4,name:"segments",kind:"message",T:Gl,repeated:!0}]),Gl=b.makeMessageType("livekit.TranscriptionSegment",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"start_time",kind:"scalar",T:4},{no:4,name:"end_time",kind:"scalar",T:4},{no:5,name:"final",kind:"scalar",T:8},{no:6,name:"language",kind:"scalar",T:9}]),ai=b.makeMessageType("livekit.ChatMessage",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"edit_timestamp",kind:"scalar",T:3,opt:!0},{no:4,name:"message",kind:"scalar",T:9},{no:5,name:"deleted",kind:"scalar",T:8},{no:6,name:"generated",kind:"scalar",T:8}]),Js=b.makeMessageType("livekit.RpcRequest",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"method",kind:"scalar",T:9},{no:3,name:"payload",kind:"scalar",T:9},{no:4,name:"response_timeout_ms",kind:"scalar",T:13},{no:5,name:"version",kind:"scalar",T:13},{no:6,name:"compressed_payload",kind:"scalar",T:12}]),Si=b.makeMessageType("livekit.RpcAck",()=>[{no:1,name:"request_id",kind:"scalar",T:9}]),$s=b.makeMessageType("livekit.RpcResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:9,oneof:"value"},{no:3,name:"error",kind:"message",T:Mo,oneof:"value"},{no:4,name:"compressed_payload",kind:"scalar",T:12,oneof:"value"}]),Mo=b.makeMessageType("livekit.RpcError",()=>[{no:1,name:"code",kind:"scalar",T:13},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"data",kind:"scalar",T:9}]),Do=b.makeMessageType("livekit.ParticipantTracks",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sids",kind:"scalar",T:9,repeated:!0}]),Ao=b.makeMessageType("livekit.ServerInfo",()=>[{no:1,name:"edition",kind:"enum",T:b.getEnumType(Oo)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"region",kind:"scalar",T:9},{no:5,name:"node_id",kind:"scalar",T:9},{no:6,name:"debug_info",kind:"scalar",T:9},{no:7,name:"agent_protocol",kind:"scalar",T:5}]),Oo=b.makeEnum("livekit.ServerInfo.Edition",[{no:0,name:"Standard"},{no:1,name:"Cloud"}]),xo=b.makeMessageType("livekit.ClientInfo",()=>[{no:1,name:"sdk",kind:"enum",T:b.getEnumType(Lo)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"os",kind:"scalar",T:9},{no:5,name:"os_version",kind:"scalar",T:9},{no:6,name:"device_model",kind:"scalar",T:9},{no:7,name:"browser",kind:"scalar",T:9},{no:8,name:"browser_version",kind:"scalar",T:9},{no:9,name:"address",kind:"scalar",T:9},{no:10,name:"network",kind:"scalar",T:9},{no:11,name:"other_sdks",kind:"scalar",T:9},{no:12,name:"client_protocol",kind:"scalar",T:5},{no:13,name:"capabilities",kind:"enum",T:b.getEnumType(No),repeated:!0}]),Lo=b.makeEnum("livekit.ClientInfo.SDK",[{no:0,name:"UNKNOWN"},{no:1,name:"JS"},{no:2,name:"SWIFT"},{no:3,name:"ANDROID"},{no:4,name:"FLUTTER"},{no:5,name:"GO"},{no:6,name:"UNITY"},{no:7,name:"REACT_NATIVE"},{no:8,name:"RUST"},{no:9,name:"PYTHON"},{no:10,name:"CPP"},{no:11,name:"UNITY_WEB"},{no:12,name:"NODE"},{no:13,name:"UNREAL"},{no:14,name:"ESP32"}]),No=b.makeEnum("livekit.ClientInfo.Capability",[{no:0,name:"CAP_UNUSED"},{no:1,name:"CAP_PACKET_TRAILER"}]),Uo=b.makeMessageType("livekit.ClientConfiguration",()=>[{no:1,name:"video",kind:"message",T:Hr},{no:2,name:"screen",kind:"message",T:Hr},{no:3,name:"resume_connection",kind:"enum",T:b.getEnumType(wn)},{no:4,name:"disabled_codecs",kind:"message",T:zl},{no:5,name:"force_relay",kind:"enum",T:b.getEnumType(wn)}]),Hr=b.makeMessageType("livekit.VideoConfiguration",()=>[{no:1,name:"hardware_encoder",kind:"enum",T:b.getEnumType(wn)}]),zl=b.makeMessageType("livekit.DisabledCodecs",()=>[{no:1,name:"codecs",kind:"message",T:ri,repeated:!0},{no:2,name:"publish",kind:"message",T:ri,repeated:!0}]),Fo=b.makeMessageType("livekit.TimedVersion",()=>[{no:1,name:"unix_micro",kind:"scalar",T:3},{no:2,name:"ticks",kind:"scalar",T:5}]),gs=b.makeEnum("livekit.DataStream.OperationType",[{no:0,name:"CREATE"},{no:1,name:"UPDATE"},{no:2,name:"DELETE"},{no:3,name:"REACTION"}]),Bo=b.makeMessageType("livekit.DataStream.TextHeader",()=>[{no:1,name:"operation_type",kind:"enum",T:b.getEnumType(gs)},{no:2,name:"version",kind:"scalar",T:5},{no:3,name:"reply_to_stream_id",kind:"scalar",T:9},{no:4,name:"attached_stream_ids",kind:"scalar",T:9,repeated:!0},{no:5,name:"generated",kind:"scalar",T:8}],{localName:"DataStream_TextHeader"}),Vo=b.makeMessageType("livekit.DataStream.ByteHeader",()=>[{no:1,name:"name",kind:"scalar",T:9}],{localName:"DataStream_ByteHeader"}),oi=b.makeMessageType("livekit.DataStream.Header",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"mime_type",kind:"scalar",T:9},{no:5,name:"total_length",kind:"scalar",T:4,opt:!0},{no:7,name:"encryption_type",kind:"enum",T:b.getEnumType(X)},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:9,name:"text_header",kind:"message",T:Bo,oneof:"content_header"},{no:10,name:"byte_header",kind:"message",T:Vo,oneof:"content_header"}],{localName:"DataStream_Header"}),ci=b.makeMessageType("livekit.DataStream.Chunk",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"chunk_index",kind:"scalar",T:4},{no:3,name:"content",kind:"scalar",T:12},{no:4,name:"version",kind:"scalar",T:5},{no:5,name:"iv",kind:"scalar",T:12,opt:!0}],{localName:"DataStream_Chunk"}),di=b.makeMessageType("livekit.DataStream.Trailer",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"reason",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}],{localName:"DataStream_Trailer"}),Jl=b.makeMessageType("livekit.SubscribedAudioCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"enabled",kind:"scalar",T:8}]),Be=b.makeEnum("livekit.SignalTarget",[{no:0,name:"PUBLISHER"},{no:1,name:"SUBSCRIBER"}]),vs=b.makeEnum("livekit.StreamState",[{no:0,name:"ACTIVE"},{no:1,name:"PAUSED"}]),$l=b.makeEnum("livekit.CandidateProtocol",[{no:0,name:"UDP"},{no:1,name:"TCP"},{no:2,name:"TLS"}]),Yl=b.makeMessageType("livekit.SignalRequest",()=>[{no:1,name:"offer",kind:"message",T:St,oneof:"message"},{no:2,name:"answer",kind:"message",T:St,oneof:"message"},{no:3,name:"trickle",kind:"message",T:Ci,oneof:"message"},{no:4,name:"add_track",kind:"message",T:Pn,oneof:"message"},{no:5,name:"mute",kind:"message",T:_i,oneof:"message"},{no:6,name:"subscription",kind:"message",T:wi,oneof:"message"},{no:7,name:"track_setting",kind:"message",T:Wo,oneof:"message"},{no:8,name:"leave",kind:"message",T:Ei,oneof:"message"},{no:10,name:"update_layers",kind:"message",T:Ko,oneof:"message"},{no:11,name:"subscription_permission",kind:"message",T:Jo,oneof:"message"},{no:12,name:"sync_state",kind:"message",T:ir,oneof:"message"},{no:13,name:"simulate",kind:"message",T:Ye,oneof:"message"},{no:14,name:"ping",kind:"scalar",T:3,oneof:"message"},{no:15,name:"update_metadata",kind:"message",T:tr,oneof:"message"},{no:16,name:"ping_req",kind:"message",T:Qo,oneof:"message"},{no:17,name:"update_audio_track",kind:"message",T:er,oneof:"message"},{no:18,name:"update_video_track",kind:"message",T:Ho,oneof:"message"},{no:19,name:"publish_data_track_request",kind:"message",T:Ys,oneof:"message"},{no:20,name:"unpublish_data_track_request",kind:"message",T:Xs,oneof:"message"},{no:21,name:"update_data_subscription",kind:"message",T:qo,oneof:"message"}]),Kr=b.makeMessageType("livekit.SignalResponse",()=>[{no:1,name:"join",kind:"message",T:eu,oneof:"message"},{no:2,name:"answer",kind:"message",T:St,oneof:"message"},{no:3,name:"offer",kind:"message",T:St,oneof:"message"},{no:4,name:"trickle",kind:"message",T:Ci,oneof:"message"},{no:5,name:"update",kind:"message",T:iu,oneof:"message"},{no:6,name:"track_published",kind:"message",T:Zs,oneof:"message"},{no:8,name:"leave",kind:"message",T:Ei,oneof:"message"},{no:9,name:"mute",kind:"message",T:_i,oneof:"message"},{no:10,name:"speakers_changed",kind:"message",T:su,oneof:"message"},{no:11,name:"room_update",kind:"message",T:ru,oneof:"message"},{no:12,name:"connection_quality",kind:"message",T:ou,oneof:"message"},{no:13,name:"stream_state_update",kind:"message",T:du,oneof:"message"},{no:14,name:"subscribed_quality_update",kind:"message",T:uu,oneof:"message"},{no:15,name:"subscription_permission_update",kind:"message",T:pu,oneof:"message"},{no:16,name:"refresh_token",kind:"scalar",T:9,oneof:"message"},{no:17,name:"track_unpublished",kind:"message",T:nu,oneof:"message"},{no:18,name:"pong",kind:"scalar",T:3,oneof:"message"},{no:19,name:"reconnect",kind:"message",T:tu,oneof:"message"},{no:20,name:"pong_resp",kind:"message",T:mu,oneof:"message"},{no:21,name:"subscription_response",kind:"message",T:bu,oneof:"message"},{no:22,name:"request_response",kind:"message",T:yu,oneof:"message"},{no:23,name:"track_subscribed",kind:"message",T:ku,oneof:"message"},{no:24,name:"room_moved",kind:"message",T:fu,oneof:"message"},{no:25,name:"media_sections_requirement",kind:"message",T:Cu,oneof:"message"},{no:26,name:"subscribed_audio_codec_update",kind:"message",T:hu,oneof:"message"},{no:27,name:"publish_data_track_response",kind:"message",T:Qs,oneof:"message"},{no:28,name:"unpublish_data_track_response",kind:"message",T:Ql,oneof:"message"},{no:29,name:"data_track_subscriber_handles",kind:"message",T:Xl,oneof:"message"}]),bs=b.makeMessageType("livekit.SimulcastCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"cid",kind:"scalar",T:9},{no:4,name:"layers",kind:"message",T:bt,repeated:!0},{no:5,name:"video_layer_mode",kind:"enum",T:b.getEnumType(wo)}]),Pn=b.makeMessageType("livekit.AddTrackRequest",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"type",kind:"enum",T:b.getEnumType(Fe)},{no:4,name:"width",kind:"scalar",T:13},{no:5,name:"height",kind:"scalar",T:13},{no:6,name:"muted",kind:"scalar",T:8},{no:7,name:"disable_dtx",kind:"scalar",T:8},{no:8,name:"source",kind:"enum",T:b.getEnumType(oe)},{no:9,name:"layers",kind:"message",T:bt,repeated:!0},{no:10,name:"simulcast_codecs",kind:"message",T:bs,repeated:!0},{no:11,name:"sid",kind:"scalar",T:9},{no:12,name:"stereo",kind:"scalar",T:8},{no:13,name:"disable_red",kind:"scalar",T:8},{no:14,name:"encryption",kind:"enum",T:b.getEnumType(X)},{no:15,name:"stream",kind:"scalar",T:9},{no:16,name:"backup_codec_policy",kind:"enum",T:b.getEnumType(_o)},{no:17,name:"audio_features",kind:"enum",T:b.getEnumType(le),repeated:!0},{no:18,name:"packet_trailer_features",kind:"enum",T:b.getEnumType(Zt),repeated:!0}]),Ys=b.makeMessageType("livekit.PublishDataTrackRequest",()=>[{no:1,name:"pub_handle",kind:"scalar",T:13},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"encryption",kind:"enum",T:b.getEnumType(X)}]),Qs=b.makeMessageType("livekit.PublishDataTrackResponse",()=>[{no:1,name:"info",kind:"message",T:Ti}]),Xs=b.makeMessageType("livekit.UnpublishDataTrackRequest",()=>[{no:1,name:"pub_handle",kind:"scalar",T:13}]),Ql=b.makeMessageType("livekit.UnpublishDataTrackResponse",()=>[{no:1,name:"info",kind:"message",T:Ti}]),Xl=b.makeMessageType("livekit.DataTrackSubscriberHandles",()=>[{no:1,name:"sub_handles",kind:"map",K:13,V:{kind:"message",T:Zl}}]),Zl=b.makeMessageType("livekit.DataTrackSubscriberHandles.PublishedDataTrack",()=>[{no:1,name:"publisher_identity",kind:"scalar",T:9},{no:2,name:"publisher_sid",kind:"scalar",T:9},{no:3,name:"track_sid",kind:"scalar",T:9}],{localName:"DataTrackSubscriberHandles_PublishedDataTrack"}),Ci=b.makeMessageType("livekit.TrickleRequest",()=>[{no:1,name:"candidateInit",kind:"scalar",T:9},{no:2,name:"target",kind:"enum",T:b.getEnumType(Be)},{no:3,name:"final",kind:"scalar",T:8}]),_i=b.makeMessageType("livekit.MuteTrackRequest",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"muted",kind:"scalar",T:8}]),eu=b.makeMessageType("livekit.JoinResponse",()=>[{no:1,name:"room",kind:"message",T:ki},{no:2,name:"participant",kind:"message",T:xt},{no:3,name:"other_participants",kind:"message",T:xt,repeated:!0},{no:4,name:"server_version",kind:"scalar",T:9},{no:5,name:"ice_servers",kind:"message",T:Go,repeated:!0},{no:6,name:"subscriber_primary",kind:"scalar",T:8},{no:7,name:"alternative_url",kind:"scalar",T:9},{no:8,name:"client_configuration",kind:"message",T:Uo},{no:9,name:"server_region",kind:"scalar",T:9},{no:10,name:"ping_timeout",kind:"scalar",T:5},{no:11,name:"ping_interval",kind:"scalar",T:5},{no:12,name:"server_info",kind:"message",T:Ao},{no:13,name:"sif_trailer",kind:"scalar",T:12},{no:14,name:"enabled_publish_codecs",kind:"message",T:ri,repeated:!0},{no:15,name:"fast_publish",kind:"scalar",T:8}]),tu=b.makeMessageType("livekit.ReconnectResponse",()=>[{no:1,name:"ice_servers",kind:"message",T:Go,repeated:!0},{no:2,name:"client_configuration",kind:"message",T:Uo},{no:3,name:"server_info",kind:"message",T:Ao},{no:4,name:"last_message_seq",kind:"scalar",T:13}]),Zs=b.makeMessageType("livekit.TrackPublishedResponse",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"track",kind:"message",T:Vt}]),nu=b.makeMessageType("livekit.TrackUnpublishedResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),St=b.makeMessageType("livekit.SessionDescription",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"sdp",kind:"scalar",T:9},{no:3,name:"id",kind:"scalar",T:13},{no:4,name:"mid_to_track_id",kind:"map",K:9,V:{kind:"scalar",T:9}}]),iu=b.makeMessageType("livekit.ParticipantUpdate",()=>[{no:1,name:"participants",kind:"message",T:xt,repeated:!0}]),wi=b.makeMessageType("livekit.UpdateSubscription",()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:2,name:"subscribe",kind:"scalar",T:8},{no:3,name:"participant_tracks",kind:"message",T:Do,repeated:!0}]),qo=b.makeMessageType("livekit.UpdateDataSubscription",()=>[{no:1,name:"updates",kind:"message",T:jo,repeated:!0}]),jo=b.makeMessageType("livekit.UpdateDataSubscription.Update",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribe",kind:"scalar",T:8},{no:3,name:"options",kind:"message",T:Wl}],{localName:"UpdateDataSubscription_Update"}),Wo=b.makeMessageType("livekit.UpdateTrackSettings",()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:3,name:"disabled",kind:"scalar",T:8},{no:4,name:"quality",kind:"enum",T:b.getEnumType(Gs)},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"fps",kind:"scalar",T:13},{no:8,name:"priority",kind:"scalar",T:13}]),er=b.makeMessageType("livekit.UpdateLocalAudioTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"features",kind:"enum",T:b.getEnumType(le),repeated:!0}]),Ho=b.makeMessageType("livekit.UpdateLocalVideoTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13}]),Ei=b.makeMessageType("livekit.LeaveRequest",()=>[{no:1,name:"can_reconnect",kind:"scalar",T:8},{no:2,name:"reason",kind:"enum",T:b.getEnumType(He)},{no:3,name:"action",kind:"enum",T:b.getEnumType(Ht)},{no:4,name:"regions",kind:"message",T:gu}]),Ht=b.makeEnum("livekit.LeaveRequest.Action",[{no:0,name:"DISCONNECT"},{no:1,name:"RESUME"},{no:2,name:"RECONNECT"}]),Ko=b.makeMessageType("livekit.UpdateVideoLayers",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"layers",kind:"message",T:bt,repeated:!0}]),tr=b.makeMessageType("livekit.UpdateParticipantMetadata",()=>[{no:1,name:"metadata",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:4,name:"request_id",kind:"scalar",T:13}]),Go=b.makeMessageType("livekit.ICEServer",()=>[{no:1,name:"urls",kind:"scalar",T:9,repeated:!0},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"credential",kind:"scalar",T:9}]),su=b.makeMessageType("livekit.SpeakersChanged",()=>[{no:1,name:"speakers",kind:"message",T:Ro,repeated:!0}]),ru=b.makeMessageType("livekit.RoomUpdate",()=>[{no:1,name:"room",kind:"message",T:ki}]),au=b.makeMessageType("livekit.ConnectionQualityInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"quality",kind:"enum",T:b.getEnumType(mn)},{no:3,name:"score",kind:"scalar",T:2}]),ou=b.makeMessageType("livekit.ConnectionQualityUpdate",()=>[{no:1,name:"updates",kind:"message",T:au,repeated:!0}]),cu=b.makeMessageType("livekit.StreamStateInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:b.getEnumType(vs)}]),du=b.makeMessageType("livekit.StreamStateUpdate",()=>[{no:1,name:"stream_states",kind:"message",T:cu,repeated:!0}]),nr=b.makeMessageType("livekit.SubscribedQuality",()=>[{no:1,name:"quality",kind:"enum",T:b.getEnumType(Gs)},{no:2,name:"enabled",kind:"scalar",T:8}]),lu=b.makeMessageType("livekit.SubscribedCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"qualities",kind:"message",T:nr,repeated:!0}]),uu=b.makeMessageType("livekit.SubscribedQualityUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_qualities",kind:"message",T:nr,repeated:!0},{no:3,name:"subscribed_codecs",kind:"message",T:lu,repeated:!0}]),hu=b.makeMessageType("livekit.SubscribedAudioCodecUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_audio_codecs",kind:"message",T:Jl,repeated:!0}]),zo=b.makeMessageType("livekit.TrackPermission",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"all_tracks",kind:"scalar",T:8},{no:3,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:4,name:"participant_identity",kind:"scalar",T:9}]),Jo=b.makeMessageType("livekit.SubscriptionPermission",()=>[{no:1,name:"all_participants",kind:"scalar",T:8},{no:2,name:"track_permissions",kind:"message",T:zo,repeated:!0}]),pu=b.makeMessageType("livekit.SubscriptionPermissionUpdate",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"allowed",kind:"scalar",T:8}]),fu=b.makeMessageType("livekit.RoomMovedResponse",()=>[{no:1,name:"room",kind:"message",T:ki},{no:2,name:"token",kind:"scalar",T:9},{no:3,name:"participant",kind:"message",T:xt},{no:4,name:"other_participants",kind:"message",T:xt,repeated:!0}]),ir=b.makeMessageType("livekit.SyncState",()=>[{no:1,name:"answer",kind:"message",T:St},{no:2,name:"subscription",kind:"message",T:wi},{no:3,name:"publish_tracks",kind:"message",T:Zs,repeated:!0},{no:4,name:"data_channels",kind:"message",T:Yo,repeated:!0},{no:5,name:"offer",kind:"message",T:St},{no:6,name:"track_sids_disabled",kind:"scalar",T:9,repeated:!0},{no:7,name:"datachannel_receive_states",kind:"message",T:$o,repeated:!0},{no:8,name:"publish_data_tracks",kind:"message",T:Qs,repeated:!0}]),$o=b.makeMessageType("livekit.DataChannelReceiveState",()=>[{no:1,name:"publisher_sid",kind:"scalar",T:9},{no:2,name:"last_seq",kind:"scalar",T:13}]),Yo=b.makeMessageType("livekit.DataChannelInfo",()=>[{no:1,name:"label",kind:"scalar",T:9},{no:2,name:"id",kind:"scalar",T:13},{no:3,name:"target",kind:"enum",T:b.getEnumType(Be)}]),Ye=b.makeMessageType("livekit.SimulateScenario",()=>[{no:1,name:"speaker_update",kind:"scalar",T:5,oneof:"scenario"},{no:2,name:"node_failure",kind:"scalar",T:8,oneof:"scenario"},{no:3,name:"migration",kind:"scalar",T:8,oneof:"scenario"},{no:4,name:"server_leave",kind:"scalar",T:8,oneof:"scenario"},{no:5,name:"switch_candidate_protocol",kind:"enum",T:b.getEnumType($l),oneof:"scenario"},{no:6,name:"subscriber_bandwidth",kind:"scalar",T:3,oneof:"scenario"},{no:7,name:"disconnect_signal_on_resume",kind:"scalar",T:8,oneof:"scenario"},{no:8,name:"disconnect_signal_on_resume_no_messages",kind:"scalar",T:8,oneof:"scenario"},{no:9,name:"leave_request_full_reconnect",kind:"scalar",T:8,oneof:"scenario"}]),Qo=b.makeMessageType("livekit.Ping",()=>[{no:1,name:"timestamp",kind:"scalar",T:3},{no:2,name:"rtt",kind:"scalar",T:3}]),mu=b.makeMessageType("livekit.Pong",()=>[{no:1,name:"last_ping_timestamp",kind:"scalar",T:3},{no:2,name:"timestamp",kind:"scalar",T:3}]),gu=b.makeMessageType("livekit.RegionSettings",()=>[{no:1,name:"regions",kind:"message",T:vu,repeated:!0}]),vu=b.makeMessageType("livekit.RegionInfo",()=>[{no:1,name:"region",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9},{no:3,name:"distance",kind:"scalar",T:3}]),bu=b.makeMessageType("livekit.SubscriptionResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"err",kind:"enum",T:b.getEnumType(Bl)}]),yu=b.makeMessageType("livekit.RequestResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:13},{no:2,name:"reason",kind:"enum",T:b.getEnumType(Et)},{no:3,name:"message",kind:"scalar",T:9},{no:4,name:"trickle",kind:"message",T:Ci,oneof:"request"},{no:5,name:"add_track",kind:"message",T:Pn,oneof:"request"},{no:6,name:"mute",kind:"message",T:_i,oneof:"request"},{no:7,name:"update_metadata",kind:"message",T:tr,oneof:"request"},{no:8,name:"update_audio_track",kind:"message",T:er,oneof:"request"},{no:9,name:"update_video_track",kind:"message",T:Ho,oneof:"request"},{no:10,name:"publish_data_track",kind:"message",T:Ys,oneof:"request"},{no:11,name:"unpublish_data_track",kind:"message",T:Xs,oneof:"request"}]),Et=b.makeEnum("livekit.RequestResponse.Reason",[{no:0,name:"OK"},{no:1,name:"NOT_FOUND"},{no:2,name:"NOT_ALLOWED"},{no:3,name:"LIMIT_EXCEEDED"},{no:4,name:"QUEUED"},{no:5,name:"UNSUPPORTED_TYPE"},{no:6,name:"UNCLASSIFIED_ERROR"},{no:7,name:"INVALID_HANDLE"},{no:8,name:"INVALID_NAME"},{no:9,name:"DUPLICATE_HANDLE"},{no:10,name:"DUPLICATE_NAME"}]),ku=b.makeMessageType("livekit.TrackSubscribed",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),Xo=b.makeMessageType("livekit.ConnectionSettings",()=>[{no:1,name:"auto_subscribe",kind:"scalar",T:8},{no:2,name:"adaptive_stream",kind:"scalar",T:8},{no:3,name:"subscriber_allow_pause",kind:"scalar",T:8,opt:!0},{no:4,name:"disable_ice_lite",kind:"scalar",T:8},{no:5,name:"auto_subscribe_data_track",kind:"scalar",T:8,opt:!0}]),Tu=b.makeMessageType("livekit.JoinRequest",()=>[{no:1,name:"client_info",kind:"message",T:xo},{no:2,name:"connection_settings",kind:"message",T:Xo},{no:3,name:"metadata",kind:"scalar",T:9},{no:4,name:"participant_attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"add_track_requests",kind:"message",T:Pn,repeated:!0},{no:6,name:"publisher_offer",kind:"message",T:St},{no:7,name:"reconnect",kind:"scalar",T:8},{no:8,name:"reconnect_reason",kind:"enum",T:b.getEnumType(_t)},{no:9,name:"participant_sid",kind:"scalar",T:9},{no:10,name:"sync_state",kind:"message",T:ir}]),Su=b.makeMessageType("livekit.WrappedJoinRequest",()=>[{no:1,name:"compression",kind:"enum",T:b.getEnumType(ys)},{no:2,name:"join_request",kind:"scalar",T:12}]),ys=b.makeEnum("livekit.WrappedJoinRequest.Compression",[{no:0,name:"NONE"},{no:1,name:"GZIP"}]),Cu=b.makeMessageType("livekit.MediaSectionsRequirement",()=>[{no:1,name:"num_audios",kind:"scalar",T:13},{no:2,name:"num_videos",kind:"scalar",T:13}]);function _u(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Gn={exports:{}},wu=Gn.exports,Gr;function Eu(){return Gr||(Gr=1,function(i){(function(e,t){i.exports?i.exports=t():e.log=t()})(wu,function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"],r={},a=null;function o(m,T){var k=m[T];if(typeof k.bind=="function")return k.bind(m);try{return Function.prototype.bind.call(k,m)}catch{return function(){return Function.prototype.apply.apply(k,[m,arguments])}}}function d(){console.log&&(console.log.apply||Function.prototype.apply.apply(console.log,[console,arguments]))}function c(m){return m==="debug"&&(m="log"),typeof console===t?!1:m==="trace"&&n?d:console[m]!==void 0?o(console,m):console.log!==void 0?o(console,"log"):e}function l(){for(var m=this.getLevel(),T=0;T<s.length;T++){var k=s[T];this[k]=T<m?e:this.methodFactory(k,m,this.name)}if(this.log=this.debug,typeof console===t&&m<this.levels.SILENT)return"No console available for logging"}function u(m){return function(){typeof console!==t&&(l.call(this),this[m].apply(this,arguments))}}function h(m,T,k){return c(m)||u.apply(this,arguments)}function p(m,T){var k=this,S,L,v,y="loglevel";typeof m=="string"?y+=":"+m:typeof m=="symbol"&&(y=void 0);function C(O){var B=(s[O]||"silent").toUpperCase();if(!(typeof window===t||!y)){try{window.localStorage[y]=B;return}catch{}try{window.document.cookie=encodeURIComponent(y)+"="+B+";"}catch{}}}function I(){var O;if(!(typeof window===t||!y)){try{O=window.localStorage[y]}catch{}if(typeof O===t)try{var B=window.document.cookie,W=encodeURIComponent(y),Z=B.indexOf(W+"=");Z!==-1&&(O=/^([^;]+)/.exec(B.slice(Z+W.length+1))[1])}catch{}return k.levels[O]===void 0&&(O=void 0),O}}function x(){if(!(typeof window===t||!y)){try{window.localStorage.removeItem(y)}catch{}try{window.document.cookie=encodeURIComponent(y)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function V(O){var B=O;if(typeof B=="string"&&k.levels[B.toUpperCase()]!==void 0&&(B=k.levels[B.toUpperCase()]),typeof B=="number"&&B>=0&&B<=k.levels.SILENT)return B;throw new TypeError("log.setLevel() called with invalid level: "+O)}k.name=m,k.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},k.methodFactory=T||h,k.getLevel=function(){return v??L??S},k.setLevel=function(O,B){return v=V(O),B!==!1&&C(v),l.call(k)},k.setDefaultLevel=function(O){L=V(O),I()||k.setLevel(O,!1)},k.resetLevel=function(){v=null,x(),l.call(k)},k.enableAll=function(O){k.setLevel(k.levels.TRACE,O)},k.disableAll=function(O){k.setLevel(k.levels.SILENT,O)},k.rebuild=function(){if(a!==k&&(S=V(a.getLevel())),l.call(k),a===k)for(var O in r)r[O].rebuild()},S=V(a?a.getLevel():"WARN");var A=I();A!=null&&(v=V(A)),l.call(k)}a=new p,a.getLogger=function(T){if(typeof T!="symbol"&&typeof T!="string"||T==="")throw new TypeError("You must supply a name when creating a logger.");var k=r[T];return k||(k=r[T]=new p(T,a.methodFactory)),k};var g=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=g),a},a.getLoggers=function(){return r},a.default=a,a})}(Gn)),Gn.exports}var Pi=Eu(),ks;(function(i){i[i.trace=0]="trace",i[i.debug=1]="debug",i[i.info=2]="info",i[i.warn=3]="warn",i[i.error=4]="error",i[i.silent=5]="silent"})(ks||(ks={}));var pe;(function(i){i.Default="livekit",i.Room="livekit-room",i.TokenSource="livekit-token-source",i.Participant="livekit-participant",i.Track="livekit-track",i.Publication="livekit-track-publication",i.Engine="livekit-engine",i.Signal="livekit-signal",i.PCManager="livekit-pc-manager",i.PCTransport="livekit-pc-transport",i.E2EE="lk-e2ee",i.DataTracks="livekit-data-tracks"})(pe||(pe={}));let q=Pi.getLogger(pe.Default);Object.values(pe).map(i=>Pi.getLogger(i));q.setDefaultLevel(ks.info);function Re(i,e){const t=Pi.getLogger(i);return t.setDefaultLevel(q.getLevel()),e?Pu(t,e):t}function Pu(i,e){const t=s=>(r,a)=>{const o=e(),d=o||a?Object.assign(Object.assign({},o),a):void 0;i[s](r,d)},n=Object.create(i);return n.trace=t("trace"),n.debug=t("debug"),n.info=t("info"),n.warn=t("warn"),n.error=t("error"),n}const Ru=Pi.getLogger(pe.E2EE),cn=7e3,Iu=[0,300,2*2*300,3*3*300,4*4*300,cn,cn,cn,cn,cn];class Mu{constructor(e){this._retryDelays=e!==void 0?[...e]:Iu}nextRetryDelayInMs(e){if(e.retryCount>=this._retryDelays.length)return null;const t=this._retryDelays[e.retryCount];return e.retryCount<=1?t:t+Math.random()*1e3}}function Du(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(t[n[s]]=i[n[s]]);return t}function f(i,e,t,n){function s(r){return r instanceof t?r:new t(function(a){a(r)})}return new(t||(t=Promise))(function(r,a){function o(l){try{c(n.next(l))}catch(u){a(u)}}function d(l){try{c(n.throw(l))}catch(u){a(u)}}function c(l){l.done?r(l.value):s(l.value).then(o,d)}c((n=n.apply(i,e||[])).next())})}function zr(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],n=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&n>=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function en(i){return this instanceof en?(this.v=i,this):new en(i)}function Au(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(i,e||[]),s,r=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(p){return function(g){return Promise.resolve(g).then(p,u)}}function o(p,g){n[p]&&(s[p]=function(m){return new Promise(function(T,k){r.push([p,m,T,k])>1||d(p,m)})},g&&(s[p]=g(s[p])))}function d(p,g){try{c(n[p](g))}catch(m){h(r[0][3],m)}}function c(p){p.value instanceof en?Promise.resolve(p.value.v).then(l,u):h(r[0][2],p)}function l(p){d("next",p)}function u(p){d("throw",p)}function h(p,g){p(g),r.shift(),r.length&&d(r[0][0],r[0][1])}}function Ou(i){var e,t;return e={},n("next"),n("throw",function(s){throw s}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(s,r){e[s]=i[s]?function(a){return(t=!t)?{value:en(i[s](a)),done:!1}:r?r(a):a}:r}}function Ve(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=i[Symbol.asyncIterator],t;return e?e.call(i):(i=typeof zr=="function"?zr(i):i[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=i[r]&&function(a){return new Promise(function(o,d){a=i[r](a),s(o,d,a.done,a.value)})}}function s(r,a,o,d){Promise.resolve(d).then(function(c){r({value:c,done:o})},a)}}var Fn={exports:{}},Jr;function xu(){if(Jr)return Fn.exports;Jr=1;var i=typeof Reflect=="object"?Reflect:null,e=i&&typeof i.apply=="function"?i.apply:function(y,C,I){return Function.prototype.apply.call(y,C,I)},t;i&&typeof i.ownKeys=="function"?t=i.ownKeys:Object.getOwnPropertySymbols?t=function(y){return Object.getOwnPropertyNames(y).concat(Object.getOwnPropertySymbols(y))}:t=function(y){return Object.getOwnPropertyNames(y)};function n(v){}var s=Number.isNaN||function(y){return y!==y};function r(){r.init.call(this)}Fn.exports=r,Fn.exports.once=k,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var a=10;function o(v){if(typeof v!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof v)}Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(v){if(typeof v!="number"||v<0||s(v))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+v+".");a=v}}),r.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(y){if(typeof y!="number"||y<0||s(y))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+y+".");return this._maxListeners=y,this};function d(v){return v._maxListeners===void 0?r.defaultMaxListeners:v._maxListeners}r.prototype.getMaxListeners=function(){return d(this)},r.prototype.emit=function(y){for(var C=[],I=1;I<arguments.length;I++)C.push(arguments[I]);var x=y==="error",V=this._events;if(V!==void 0)x=x&&V.error===void 0;else if(!x)return!1;if(x){var A;if(C.length>0&&(A=C[0]),A instanceof Error)throw A;var O=new Error("Unhandled error."+(A?" ("+A.message+")":""));throw O.context=A,O}var B=V[y];if(B===void 0)return!1;if(typeof B=="function")e(B,this,C);else for(var W=B.length,Z=g(B,W),I=0;I<W;++I)e(Z[I],this,C);return!0};function c(v,y,C,I){var x,V,A;if(o(C),V=v._events,V===void 0?(V=v._events=Object.create(null),v._eventsCount=0):(V.newListener!==void 0&&(v.emit("newListener",y,C.listener?C.listener:C),V=v._events),A=V[y]),A===void 0)A=V[y]=C,++v._eventsCount;else if(typeof A=="function"?A=V[y]=I?[C,A]:[A,C]:I?A.unshift(C):A.push(C),x=d(v),x>0&&A.length>x&&!A.warned){A.warned=!0;var O=new Error("Possible EventEmitter memory leak detected. "+A.length+" "+String(y)+" listeners added. Use emitter.setMaxListeners() to increase limit");O.name="MaxListenersExceededWarning",O.emitter=v,O.type=y,O.count=A.length}return v}r.prototype.addListener=function(y,C){return c(this,y,C,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(y,C){return c(this,y,C,!0)};function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(v,y,C){var I={fired:!1,wrapFn:void 0,target:v,type:y,listener:C},x=l.bind(I);return x.listener=C,I.wrapFn=x,x}r.prototype.once=function(y,C){return o(C),this.on(y,u(this,y,C)),this},r.prototype.prependOnceListener=function(y,C){return o(C),this.prependListener(y,u(this,y,C)),this},r.prototype.removeListener=function(y,C){var I,x,V,A,O;if(o(C),x=this._events,x===void 0)return this;if(I=x[y],I===void 0)return this;if(I===C||I.listener===C)--this._eventsCount===0?this._events=Object.create(null):(delete x[y],x.removeListener&&this.emit("removeListener",y,I.listener||C));else if(typeof I!="function"){for(V=-1,A=I.length-1;A>=0;A--)if(I[A]===C||I[A].listener===C){O=I[A].listener,V=A;break}if(V<0)return this;V===0?I.shift():m(I,V),I.length===1&&(x[y]=I[0]),x.removeListener!==void 0&&this.emit("removeListener",y,O||C)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(y){var C,I,x;if(I=this._events,I===void 0)return this;if(I.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):I[y]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete I[y]),this;if(arguments.length===0){var V=Object.keys(I),A;for(x=0;x<V.length;++x)A=V[x],A!=="removeListener"&&this.removeAllListeners(A);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(C=I[y],typeof C=="function")this.removeListener(y,C);else if(C!==void 0)for(x=C.length-1;x>=0;x--)this.removeListener(y,C[x]);return this};function h(v,y,C){var I=v._events;if(I===void 0)return[];var x=I[y];return x===void 0?[]:typeof x=="function"?C?[x.listener||x]:[x]:C?T(x):g(x,x.length)}r.prototype.listeners=function(y){return h(this,y,!0)},r.prototype.rawListeners=function(y){return h(this,y,!1)},r.listenerCount=function(v,y){return typeof v.listenerCount=="function"?v.listenerCount(y):p.call(v,y)},r.prototype.listenerCount=p;function p(v){var y=this._events;if(y!==void 0){var C=y[v];if(typeof C=="function")return 1;if(C!==void 0)return C.length}return 0}r.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function g(v,y){for(var C=new Array(y),I=0;I<y;++I)C[I]=v[I];return C}function m(v,y){for(;y+1<v.length;y++)v[y]=v[y+1];v.pop()}function T(v){for(var y=new Array(v.length),C=0;C<y.length;++C)y[C]=v[C].listener||v[C];return y}function k(v,y){return new Promise(function(C,I){function x(A){v.removeListener(y,V),I(A)}function V(){typeof v.removeListener=="function"&&v.removeListener("error",x),C([].slice.call(arguments))}L(v,y,V,{once:!0}),y!=="error"&&S(v,x,{once:!0})})}function S(v,y,C){typeof v.on=="function"&&L(v,"error",y,C)}function L(v,y,C,I){if(typeof v.on=="function")I.once?v.once(y,C):v.on(y,C);else if(typeof v.addEventListener=="function")v.addEventListener(y,function x(V){I.once&&v.removeEventListener(y,x),C(V)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof v)}return Fn.exports}var Ie=xu();let Zo=!0,Lu=!0;function gn(i,e,t){const n=i.match(e);return n&&n.length>=t&&parseFloat(n[t],10)}function Ut(i,e,t){if(!i.RTCPeerConnection)return;if(!Object.getOwnPropertyDescriptor(EventTarget.prototype,"addEventListener").writable){return}const s=i.RTCPeerConnection.prototype,r=s.addEventListener;s.addEventListener=function(o,d){if(o!==e)return r.apply(this,arguments);const c=l=>{const u=t(l);u&&(d.handleEvent?d.handleEvent(u):d(u))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(d,c),r.apply(this,[o,c])};const a=s.removeEventListener;s.removeEventListener=function(o,d){if(o!==e||!this._eventMap||!this._eventMap[e])return a.apply(this,arguments);if(!this._eventMap[e].has(d))return a.apply(this,arguments);const c=this._eventMap[e].get(d);return this._eventMap[e].delete(d),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,a.apply(this,[o,c])},Object.defineProperty(s,"on"+e,{get(){return this["_on"+e]},set(o){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),o&&this.addEventListener(e,this["_on"+e]=o)},enumerable:!0,configurable:!0})}function Nu(i){return typeof i!="boolean"?new Error("Argument type: "+typeof i+". Please use a boolean."):(Zo=i,i?"adapter.js logging disabled":"adapter.js logging enabled")}function Uu(i){return typeof i!="boolean"?new Error("Argument type: "+typeof i+". Please use a boolean."):(Lu=!i,"adapter.js deprecation warnings "+(i?"disabled":"enabled"))}function ec(){}function Fu(i){const e={browser:null,version:null};if(typeof i>"u"||!i.navigator||!i.navigator.userAgent)return e.browser="Not a browser.",e;const t=i.navigator;if(t.userAgentData&&t.userAgentData.brands){const n=t.userAgentData.brands.find(s=>s.brand==="Chromium");if(n)return{browser:"chrome",version:parseInt(n.version,10)}}if(t.mozGetUserMedia)e.browser="firefox",e.version=parseInt(gn(t.userAgent,/Firefox\/(\d+)\./,1));else if(t.webkitGetUserMedia||i.isSecureContext===!1&&i.webkitRTCPeerConnection)e.browser="chrome",e.version=parseInt(gn(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2))||null;else if(i.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=parseInt(gn(t.userAgent,/AppleWebKit\/(\d+)\./,1)),e.supportsUnifiedPlan=i.RTCRtpTransceiver&&"currentDirection"in i.RTCRtpTransceiver.prototype,e._safariVersion=gn(t.userAgent,/Version\/(\d+(\.?\d+))/,1);else return e.browser="Not a supported browser.",e;return e}function $r(i){return Object.prototype.toString.call(i)==="[object Object]"}function tc(i){return $r(i)?Object.keys(i).reduce(function(e,t){const n=$r(i[t]),s=n?tc(i[t]):i[t],r=n&&!Object.keys(s).length;return s===void 0||r?e:Object.assign(e,{[t]:s})},{}):i}function Ts(i,e,t){!e||t.has(e.id)||(t.set(e.id,e),Object.keys(e).forEach(n=>{n.endsWith("Id")?Ts(i,i.get(e[n]),t):n.endsWith("Ids")&&e[n].forEach(s=>{Ts(i,i.get(s),t)})}))}function Yr(i,e,t){const n=t?"outbound-rtp":"inbound-rtp",s=new Map;if(e===null)return s;const r=[];return i.forEach(a=>{a.type==="track"&&a.trackIdentifier===e.id&&r.push(a)}),r.forEach(a=>{i.forEach(o=>{o.type===n&&o.trackId===a.id&&Ts(i,o,s)})}),s}const Qr=ec;function nc(i,e){const t=i&&i.navigator;if(!t.mediaDevices)return;const n=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const d={};return Object.keys(o).forEach(c=>{if(c==="require"||c==="advanced"||c==="mediaSource")return;const l=typeof o[c]=="object"?o[c]:{ideal:o[c]};l.exact!==void 0&&typeof l.exact=="number"&&(l.min=l.max=l.exact);const u=function(h,p){return h?h+p.charAt(0).toUpperCase()+p.slice(1):p==="deviceId"?"sourceId":p};if(l.ideal!==void 0){d.optional=d.optional||[];let h={};typeof l.ideal=="number"?(h[u("min",c)]=l.ideal,d.optional.push(h),h={},h[u("max",c)]=l.ideal,d.optional.push(h)):(h[u("",c)]=l.ideal,d.optional.push(h))}l.exact!==void 0&&typeof l.exact!="number"?(d.mandatory=d.mandatory||{},d.mandatory[u("",c)]=l.exact):["min","max"].forEach(h=>{l[h]!==void 0&&(d.mandatory=d.mandatory||{},d.mandatory[u(h,c)]=l[h])})}),o.advanced&&(d.optional=(d.optional||[]).concat(o.advanced)),d},s=function(o,d){if(e.version>=61)return d(o);if(o=JSON.parse(JSON.stringify(o)),o&&typeof o.audio=="object"){const c=function(l,u,h){u in l&&!(h in l)&&(l[h]=l[u],delete l[u])};o=JSON.parse(JSON.stringify(o)),c(o.audio,"autoGainControl","googAutoGainControl"),c(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=n(o.audio)}if(o&&typeof o.video=="object"){let c=o.video.facingMode;c=c&&(typeof c=="object"?c:{ideal:c});const l=e.version<66;if(c&&(c.exact==="user"||c.exact==="environment"||c.ideal==="user"||c.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!l)){delete o.video.facingMode;let u;if(c.exact==="environment"||c.ideal==="environment"?u=["back","rear"]:(c.exact==="user"||c.ideal==="user")&&(u=["front"]),u)return t.mediaDevices.enumerateDevices().then(h=>{h=h.filter(g=>g.kind==="videoinput");let p=h.find(g=>u.some(m=>g.label.toLowerCase().includes(m)));return!p&&h.length&&u.includes("back")&&(p=h[h.length-1]),p&&(o.video.deviceId=c.exact?{exact:p.deviceId}:{ideal:p.deviceId}),o.video=n(o.video),Qr("chrome: "+JSON.stringify(o)),d(o)})}o.video=n(o.video)}return Qr("chrome: "+JSON.stringify(o)),d(o)},r=function(o){return e.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},a=function(o,d,c){s(o,l=>{t.webkitGetUserMedia(l,d,u=>{c&&c(r(u))})})};if(t.getUserMedia=a.bind(t),t.mediaDevices.getUserMedia){const o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(d){return s(d,c=>o(c).then(l=>{if(c.audio&&!l.getAudioTracks().length||c.video&&!l.getVideoTracks().length)throw l.getTracks().forEach(u=>{u.stop()}),new DOMException("","NotFoundError");return l},l=>Promise.reject(r(l))))}}}function ic(i){i.MediaStream=i.MediaStream||i.webkitMediaStream}function sc(i,e){if(!(e.version>102))if(typeof i=="object"&&i.RTCPeerConnection&&!("ontrack"in i.RTCPeerConnection.prototype)){Object.defineProperty(i.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(n){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=n)},enumerable:!0,configurable:!0});const t=i.RTCPeerConnection.prototype.setRemoteDescription;i.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=s=>{s.stream.addEventListener("addtrack",r=>{let a;i.RTCPeerConnection.prototype.getReceivers?a=this.getReceivers().find(d=>d.track&&d.track.id===r.track.id):a={track:r.track};const o=new Event("track");o.track=r.track,o.receiver=a,o.transceiver={receiver:a},o.streams=[s.stream],this.dispatchEvent(o)}),s.stream.getTracks().forEach(r=>{let a;i.RTCPeerConnection.prototype.getReceivers?a=this.getReceivers().find(d=>d.track&&d.track.id===r.id):a={track:r};const o=new Event("track");o.track=r,o.receiver=a,o.transceiver={receiver:a},o.streams=[s.stream],this.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else Ut(i,"track",t=>(t.transceiver||Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}}),t))}function rc(i){if(typeof i=="object"&&i.RTCPeerConnection&&!("getSenders"in i.RTCPeerConnection.prototype)&&"createDTMFSender"in i.RTCPeerConnection.prototype){const e=function(s,r){return{track:r,get dtmf(){return this._dtmf===void 0&&(r.kind==="audio"?this._dtmf=s.createDTMFSender(r):this._dtmf=null),this._dtmf},_pc:s}};if(!i.RTCPeerConnection.prototype.getSenders){i.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const s=i.RTCPeerConnection.prototype.addTrack;i.RTCPeerConnection.prototype.addTrack=function(o,d){let c=s.apply(this,arguments);return c||(c=e(this,o),this._senders.push(c)),c};const r=i.RTCPeerConnection.prototype.removeTrack;i.RTCPeerConnection.prototype.removeTrack=function(o){r.apply(this,arguments);const d=this._senders.indexOf(o);d!==-1&&this._senders.splice(d,1)}}const t=i.RTCPeerConnection.prototype.addStream;i.RTCPeerConnection.prototype.addStream=function(r){this._senders=this._senders||[],t.apply(this,[r]),r.getTracks().forEach(a=>{this._senders.push(e(this,a))})};const n=i.RTCPeerConnection.prototype.removeStream;i.RTCPeerConnection.prototype.removeStream=function(r){this._senders=this._senders||[],n.apply(this,[r]),r.getTracks().forEach(a=>{const o=this._senders.find(d=>d.track===a);o&&this._senders.splice(this._senders.indexOf(o),1)})}}else if(typeof i=="object"&&i.RTCPeerConnection&&"getSenders"in i.RTCPeerConnection.prototype&&"createDTMFSender"in i.RTCPeerConnection.prototype&&i.RTCRtpSender&&!("dtmf"in i.RTCRtpSender.prototype)){const e=i.RTCPeerConnection.prototype.getSenders;i.RTCPeerConnection.prototype.getSenders=function(){const n=e.apply(this,[]);return n.forEach(s=>s._pc=this),n},Object.defineProperty(i.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function ac(i,e){if(e.version>=67||!(typeof i=="object"&&i.RTCPeerConnection&&i.RTCRtpSender&&i.RTCRtpReceiver))return;if(!("getStats"in i.RTCRtpSender.prototype)){const n=i.RTCPeerConnection.prototype.getSenders;n&&(i.RTCPeerConnection.prototype.getSenders=function(){const a=n.apply(this,[]);return a.forEach(o=>o._pc=this),a});const s=i.RTCPeerConnection.prototype.addTrack;s&&(i.RTCPeerConnection.prototype.addTrack=function(){const a=s.apply(this,arguments);return a._pc=this,a}),i.RTCRtpSender.prototype.getStats=function(){const a=this;return this._pc.getStats().then(o=>Yr(o,a.track,!0))}}if(!("getStats"in i.RTCRtpReceiver.prototype)){const n=i.RTCPeerConnection.prototype.getReceivers;n&&(i.RTCPeerConnection.prototype.getReceivers=function(){const r=n.apply(this,[]);return r.forEach(a=>a._pc=this),r}),Ut(i,"track",s=>(s.receiver._pc=s.srcElement,s)),i.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(a=>Yr(a,r.track,!1))}}if(!("getStats"in i.RTCRtpSender.prototype&&"getStats"in i.RTCRtpReceiver.prototype))return;const t=i.RTCPeerConnection.prototype.getStats;i.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof i.MediaStreamTrack){const s=arguments[0];let r,a,o;return this.getSenders().forEach(d=>{d.track===s&&(r?o=!0:r=d)}),this.getReceivers().forEach(d=>(d.track===s&&(a?o=!0:a=d),d.track===s)),o||r&&a?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():a?a.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function oc(i){i.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(a=>this._shimmedLocalStreams[a][0])};const e=i.RTCPeerConnection.prototype.addTrack;i.RTCPeerConnection.prototype.addTrack=function(a,o){if(!o)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const d=e.apply(this,arguments);return this._shimmedLocalStreams[o.id]?this._shimmedLocalStreams[o.id].indexOf(d)===-1&&this._shimmedLocalStreams[o.id].push(d):this._shimmedLocalStreams[o.id]=[o,d],d};const t=i.RTCPeerConnection.prototype.addStream;i.RTCPeerConnection.prototype.addStream=function(a){this._shimmedLocalStreams=this._shimmedLocalStreams||{},a.getTracks().forEach(c=>{if(this.getSenders().find(u=>u.track===c))throw new DOMException("Track already exists.","InvalidAccessError")});const o=this.getSenders();t.apply(this,arguments);const d=this.getSenders().filter(c=>o.indexOf(c)===-1);this._shimmedLocalStreams[a.id]=[a].concat(d)};const n=i.RTCPeerConnection.prototype.removeStream;i.RTCPeerConnection.prototype.removeStream=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[a.id],n.apply(this,arguments)};const s=i.RTCPeerConnection.prototype.removeTrack;i.RTCPeerConnection.prototype.removeTrack=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},a&&Object.keys(this._shimmedLocalStreams).forEach(o=>{const d=this._shimmedLocalStreams[o].indexOf(a);d!==-1&&this._shimmedLocalStreams[o].splice(d,1),this._shimmedLocalStreams[o].length===1&&delete this._shimmedLocalStreams[o]}),s.apply(this,arguments)}}function cc(i,e){if(!i.RTCPeerConnection)return;if(i.RTCPeerConnection.prototype.addTrack&&e.version>=65)return oc(i);const t=i.RTCPeerConnection.prototype.getLocalStreams;i.RTCPeerConnection.prototype.getLocalStreams=function(){const l=t.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(u=>this._reverseStreams[u.id])};const n=i.RTCPeerConnection.prototype.addStream;i.RTCPeerConnection.prototype.addStream=function(l){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},l.getTracks().forEach(u=>{if(this.getSenders().find(p=>p.track===u))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[l.id]){const u=new i.MediaStream(l.getTracks());this._streams[l.id]=u,this._reverseStreams[u.id]=l,l=u}n.apply(this,[l])};const s=i.RTCPeerConnection.prototype.removeStream;i.RTCPeerConnection.prototype.removeStream=function(l){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},s.apply(this,[this._streams[l.id]||l]),delete this._reverseStreams[this._streams[l.id]?this._streams[l.id].id:l.id],delete this._streams[l.id]},i.RTCPeerConnection.prototype.addTrack=function(l,u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const h=[].slice.call(arguments,1);if(h.length!==1||!h[0].getTracks().find(m=>m===l))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(m=>m.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const g=this._streams[u.id];if(g)g.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const m=new i.MediaStream([l]);this._streams[u.id]=m,this._reverseStreams[m.id]=u,this.addStream(m)}return this.getSenders().find(m=>m.track===l)};function r(c,l){let u=l.sdp;return Object.keys(c._reverseStreams||[]).forEach(h=>{const p=c._reverseStreams[h],g=c._streams[p.id];u=u.replace(new RegExp(g.id,"g"),p.id)}),new RTCSessionDescription({type:l.type,sdp:u})}function a(c,l){let u=l.sdp;return Object.keys(c._reverseStreams||[]).forEach(h=>{const p=c._reverseStreams[h],g=c._streams[p.id];u=u.replace(new RegExp(p.id,"g"),g.id)}),new RTCSessionDescription({type:l.type,sdp:u})}["createOffer","createAnswer"].forEach(function(c){const l=i.RTCPeerConnection.prototype[c],u={[c](){const h=arguments;return arguments.length&&typeof arguments[0]=="function"?l.apply(this,[g=>{const m=r(this,g);h[0].apply(null,[m])},g=>{h[1]&&h[1].apply(null,g)},arguments[2]]):l.apply(this,arguments).then(g=>r(this,g))}};i.RTCPeerConnection.prototype[c]=u[c]});const o=i.RTCPeerConnection.prototype.setLocalDescription;i.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?o.apply(this,arguments):(arguments[0]=a(this,arguments[0]),o.apply(this,arguments))};const d=Object.getOwnPropertyDescriptor(i.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(i.RTCPeerConnection.prototype,"localDescription",{get(){const c=d.get.apply(this);return c.type===""?c:r(this,c)}}),i.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(l._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let h;Object.keys(this._streams).forEach(p=>{this._streams[p].getTracks().find(m=>l.track===m)&&(h=this._streams[p])}),h&&(h.getTracks().length===1?this.removeStream(this._reverseStreams[h.id]):h.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Ss(i,e){!i.RTCPeerConnection&&i.webkitRTCPeerConnection&&(i.RTCPeerConnection=i.webkitRTCPeerConnection),i.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=i.RTCPeerConnection.prototype[t],s={[t](){return arguments[0]=new(t==="addIceCandidate"?i.RTCIceCandidate:i.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};i.RTCPeerConnection.prototype[t]=s[t]})}function dc(i,e){e.version>102||Ut(i,"negotiationneeded",t=>{const n=t.target;if(!((e.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics==="plan-b")&&n.signalingState!=="stable"))return t})}var Xr=Object.freeze({__proto__:null,fixNegotiationNeeded:dc,shimAddTrackRemoveTrack:cc,shimAddTrackRemoveTrackWithNative:oc,shimGetSendersWithDtmf:rc,shimGetUserMedia:nc,shimMediaStream:ic,shimOnTrack:sc,shimPeerConnection:Ss,shimSenderReceiverGetStats:ac});function lc(i,e){const t=i&&i.navigator,n=i&&i.MediaStreamTrack;if(t.getUserMedia=function(s,r,a){t.mediaDevices.getUserMedia(s).then(r,a)},!(e.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const s=function(a,o,d){o in a&&!(d in a)&&(a[d]=a[o],delete a[o])},r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(t.mediaDevices.getUserMedia=function(a){return typeof a=="object"&&typeof a.audio=="object"&&(a=JSON.parse(JSON.stringify(a)),s(a.audio,"autoGainControl","mozAutoGainControl"),s(a.audio,"noiseSuppression","mozNoiseSuppression")),r(a)},n&&n.prototype.getSettings){const a=n.prototype.getSettings;n.prototype.getSettings=function(){const o=a.apply(this,arguments);return s(o,"mozAutoGainControl","autoGainControl"),s(o,"mozNoiseSuppression","noiseSuppression"),o}}if(n&&n.prototype.applyConstraints){const a=n.prototype.applyConstraints;n.prototype.applyConstraints=function(o){return this.kind==="audio"&&typeof o=="object"&&(o=JSON.parse(JSON.stringify(o)),s(o,"autoGainControl","mozAutoGainControl"),s(o,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[o])}}}}function Bu(i,e){i.navigator.mediaDevices&&"getDisplayMedia"in i.navigator.mediaDevices||i.navigator.mediaDevices&&(i.navigator.mediaDevices.getDisplayMedia=function(n){if(!(n&&n.video)){const s=new DOMException("getDisplayMedia without video constraints is undefined");return s.name="NotFoundError",s.code=8,Promise.reject(s)}return n.video===!0?n.video={mediaSource:e}:n.video.mediaSource=e,i.navigator.mediaDevices.getUserMedia(n)})}function uc(i){typeof i=="object"&&i.RTCTrackEvent&&"receiver"in i.RTCTrackEvent.prototype&&!("transceiver"in i.RTCTrackEvent.prototype)&&Object.defineProperty(i.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Cs(i,e){typeof i!="object"||!(i.RTCPeerConnection||i.mozRTCPeerConnection)||(!i.RTCPeerConnection&&i.mozRTCPeerConnection&&(i.RTCPeerConnection=i.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=i.RTCPeerConnection.prototype[t],s={[t](){return arguments[0]=new(t==="addIceCandidate"?i.RTCIceCandidate:i.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};i.RTCPeerConnection.prototype[t]=s[t]}))}function hc(i,e){if(typeof i!="object"||!(i.RTCPeerConnection||i.mozRTCPeerConnection)||e.version>=151)return;const t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=i.RTCPeerConnection.prototype.getStats;i.RTCPeerConnection.prototype.getStats=function(){const r=Array.prototype.slice.call(arguments),a=r[0],o=r[1],d=r[2];return this.signalingState==="closed"?Promise.resolve(new Map):n.apply(this,[a||null]).then(c=>{if(e.version<53&&!o)try{c.forEach(l=>{l.type=t[l.type]||l.type})}catch(l){if(l.name!=="TypeError")throw l;c.forEach((u,h)=>{c.set(h,Object.assign({},u,{type:t[u.type]||u.type}))})}return c}).then(o,d)}}function pc(i){if(!(typeof i=="object"&&i.RTCPeerConnection&&i.RTCRtpSender)||i.RTCRtpSender&&"getStats"in i.RTCRtpSender.prototype)return;const e=i.RTCPeerConnection.prototype.getSenders;e&&(i.RTCPeerConnection.prototype.getSenders=function(){const s=e.apply(this,[]);return s.forEach(r=>r._pc=this),s});const t=i.RTCPeerConnection.prototype.addTrack;t&&(i.RTCPeerConnection.prototype.addTrack=function(){const s=t.apply(this,arguments);return s._pc=this,s}),i.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function fc(i){if(!(typeof i=="object"&&i.RTCPeerConnection&&i.RTCRtpSender)||i.RTCRtpSender&&"getStats"in i.RTCRtpReceiver.prototype)return;const e=i.RTCPeerConnection.prototype.getReceivers;e&&(i.RTCPeerConnection.prototype.getReceivers=function(){const n=e.apply(this,[]);return n.forEach(s=>s._pc=this),n}),Ut(i,"track",t=>(t.receiver._pc=t.srcElement,t)),i.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function mc(i){!i.RTCPeerConnection||"removeStream"in i.RTCPeerConnection.prototype||(i.RTCPeerConnection.prototype.removeStream=function(t){this.getSenders().forEach(n=>{n.track&&t.getTracks().includes(n.track)&&this.removeTrack(n)})})}function gc(i){i.DataChannel&&!i.RTCDataChannel&&(i.RTCDataChannel=i.DataChannel)}function vc(i){if(!(typeof i=="object"&&i.RTCPeerConnection))return;const e=i.RTCPeerConnection.prototype.addTransceiver;e&&(i.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let n=arguments[1]&&arguments[1].sendEncodings;n===void 0&&(n=[]),n=[...n];const s=n.length>0;s&&n.forEach(a=>{if("rid"in a&&!/^[a-z0-9]{0,16}$/i.test(a.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in a&&!(parseFloat(a.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in a&&!(parseFloat(a.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const r=e.apply(this,arguments);if(s){const a=r.sender,o=a.getParameters();(!("encodings"in o)||o.encodings.length===1&&Object.keys(o.encodings[0]).length===0)&&(o.encodings=n,a.sendEncodings=n,this.setParametersPromises.push(a.setParameters(o).then(()=>{delete a.sendEncodings}).catch(()=>{delete a.sendEncodings})))}return r})}function bc(i){if(!(typeof i=="object"&&i.RTCRtpSender))return;const e=i.RTCRtpSender.prototype.getParameters;e&&(i.RTCRtpSender.prototype.getParameters=function(){const n=e.apply(this,arguments);return"encodings"in n||(n.encodings=[].concat(this.sendEncodings||[{}])),n})}function yc(i){if(!(typeof i=="object"&&i.RTCPeerConnection))return;const e=i.RTCPeerConnection.prototype.createOffer;i.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function kc(i){if(!(typeof i=="object"&&i.RTCPeerConnection))return;const e=i.RTCPeerConnection.prototype.createAnswer;i.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}var Zr=Object.freeze({__proto__:null,shimAddTransceiver:vc,shimCreateAnswer:kc,shimCreateOffer:yc,shimGetDisplayMedia:Bu,shimGetParameters:bc,shimGetStats:hc,shimGetUserMedia:lc,shimOnTrack:uc,shimPeerConnection:Cs,shimRTCDataChannel:gc,shimReceiverGetStats:fc,shimRemoveStream:mc,shimSenderGetStats:pc});function Tc(i){if(!(typeof i!="object"||!i.RTCPeerConnection)){if("getLocalStreams"in i.RTCPeerConnection.prototype||(i.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in i.RTCPeerConnection.prototype)){const e=i.RTCPeerConnection.prototype.addTrack;i.RTCPeerConnection.prototype.addStream=function(n){this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(s=>e.call(this,s,n)),n.getVideoTracks().forEach(s=>e.call(this,s,n))},i.RTCPeerConnection.prototype.addTrack=function(n){for(var s=arguments.length,r=new Array(s>1?s-1:0),a=1;a<s;a++)r[a-1]=arguments[a];return r&&r.forEach(o=>{this._localStreams?this._localStreams.includes(o)||this._localStreams.push(o):this._localStreams=[o]}),e.apply(this,arguments)}}"removeStream"in i.RTCPeerConnection.prototype||(i.RTCPeerConnection.prototype.removeStream=function(t){this._localStreams||(this._localStreams=[]);const n=this._localStreams.indexOf(t);if(n===-1)return;this._localStreams.splice(n,1);const s=t.getTracks();this.getSenders().forEach(r=>{s.includes(r.track)&&this.removeTrack(r)})})}}function Sc(i){if(!(typeof i!="object"||!i.RTCPeerConnection)&&("getRemoteStreams"in i.RTCPeerConnection.prototype||(i.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in i.RTCPeerConnection.prototype))){Object.defineProperty(i.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(t){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=t),this.addEventListener("track",this._onaddstreampoly=n=>{n.streams.forEach(s=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(s))return;this._remoteStreams.push(s);const r=new Event("addstream");r.stream=s,this.dispatchEvent(r)})})}});const e=i.RTCPeerConnection.prototype.setRemoteDescription;i.RTCPeerConnection.prototype.setRemoteDescription=function(){const n=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(s){s.streams.forEach(r=>{if(n._remoteStreams||(n._remoteStreams=[]),n._remoteStreams.indexOf(r)>=0)return;n._remoteStreams.push(r);const a=new Event("addstream");a.stream=r,n.dispatchEvent(a)})}),e.apply(n,arguments)}}}function Cc(i){if(typeof i!="object"||!i.RTCPeerConnection)return;const e=i.RTCPeerConnection.prototype,t=e.createOffer,n=e.createAnswer,s=e.setLocalDescription,r=e.setRemoteDescription,a=e.addIceCandidate;e.createOffer=function(c,l){const u=arguments.length>=2?arguments[2]:arguments[0],h=t.apply(this,[u]);return l?(h.then(c,l),Promise.resolve()):h},e.createAnswer=function(c,l){const u=arguments.length>=2?arguments[2]:arguments[0],h=n.apply(this,[u]);return l?(h.then(c,l),Promise.resolve()):h};let o=function(d,c,l){const u=s.apply(this,[d]);return l?(u.then(c,l),Promise.resolve()):u};e.setLocalDescription=o,o=function(d,c,l){const u=r.apply(this,[d]);return l?(u.then(c,l),Promise.resolve()):u},e.setRemoteDescription=o,o=function(d,c,l){const u=a.apply(this,[d]);return l?(u.then(c,l),Promise.resolve()):u},e.addIceCandidate=o}function _c(i){const e=i&&i.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const t=e.mediaDevices,n=t.getUserMedia.bind(t);e.mediaDevices.getUserMedia=s=>n(wc(s))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=(function(n,s,r){e.mediaDevices.getUserMedia(n).then(s,r)}).bind(e))}function wc(i){return i&&i.video!==void 0?Object.assign({},i,{video:tc(i.video)}):i}function Ec(i){if(!i.RTCPeerConnection)return;const e=i.RTCPeerConnection;i.RTCPeerConnection=function(n,s){if(n&&n.iceServers){const r=[];for(let a=0;a<n.iceServers.length;a++){let o=n.iceServers[a];o.urls===void 0&&o.url?(o=JSON.parse(JSON.stringify(o)),o.urls=o.url,delete o.url,r.push(o)):r.push(n.iceServers[a])}n.iceServers=r}return new e(n,s)},i.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(i.RTCPeerConnection,"generateCertificate",{get(){return e.generateCertificate}})}function Pc(i){typeof i=="object"&&i.RTCTrackEvent&&"receiver"in i.RTCTrackEvent.prototype&&!("transceiver"in i.RTCTrackEvent.prototype)&&Object.defineProperty(i.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Rc(i){const e=i.RTCPeerConnection.prototype.createOffer;i.RTCPeerConnection.prototype.createOffer=function(n){if(n){typeof n.offerToReceiveAudio<"u"&&(n.offerToReceiveAudio=!!n.offerToReceiveAudio);const s=this.getTransceivers().find(a=>a.receiver.track.kind==="audio");n.offerToReceiveAudio===!1&&s?s.direction==="sendrecv"?s.setDirection?s.setDirection("sendonly"):s.direction="sendonly":s.direction==="recvonly"&&(s.setDirection?s.setDirection("inactive"):s.direction="inactive"):n.offerToReceiveAudio===!0&&!s&&this.addTransceiver("audio",{direction:"recvonly"}),typeof n.offerToReceiveVideo<"u"&&(n.offerToReceiveVideo=!!n.offerToReceiveVideo);const r=this.getTransceivers().find(a=>a.receiver.track.kind==="video");n.offerToReceiveVideo===!1&&r?r.direction==="sendrecv"?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":r.direction==="recvonly"&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):n.offerToReceiveVideo===!0&&!r&&this.addTransceiver("video",{direction:"recvonly"})}return e.apply(this,arguments)}}function Ic(i){typeof i!="object"||i.AudioContext||(i.AudioContext=i.webkitAudioContext)}var ea=Object.freeze({__proto__:null,shimAudioContext:Ic,shimCallbacksAPI:Cc,shimConstraints:wc,shimCreateOfferLegacy:Rc,shimGetUserMedia:_c,shimLocalStreamsAPI:Tc,shimRTCIceServerUrls:Ec,shimRemoteStreamsAPI:Sc,shimTrackEventTransceiver:Pc}),Ji={exports:{}},ta;function Vu(){return ta||(ta=1,function(i){const e={};e.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)},e.localCName=e.generateIdentifier(),e.splitLines=function(t){return t.trim().split(`
|
|
20
20
|
`).map(n=>n.trim())},e.splitSections=function(t){return t.split(`
|