@cloudflare/realtimekit 0.5.0-staging.66 → 0.5.0-staging.68
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/browser.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/mock.cjs.js +2 -2
- package/dist/mock.es.js +57 -56
- package/dist/react.cjs.js +1 -1
- package/dist/react.es.js +1 -1
- package/package.json +1 -1
package/dist/react.cjs.js
CHANGED
|
@@ -20,4 +20,4 @@ ${t}`}const Ws={maxInvocations:5,period:1};function Bt(t,e){return function(n,i,
|
|
|
20
20
|
`}this.midTransceiverMap.set(a.mid,a);const d=l=>u(this,null,function*(){return p.debug(`send() | calling pc.setRemoteDescription() [answer:${JSON.stringify(l)}]`),yield this.pc.setRemoteDescription(l),a.mid});return p.debug(`send() | calling pc.setLocalDescription() [offer: ${JSON.stringify(c,void 0,2)}]`),{offerSdp:c,callback:d,sender:a.sender,mid:a.mid}})}addCustomEventListeners(){this.pc.addEventListener("datachannel",e=>{const{channel:n}=e;n.onmessage=i=>{this.safeEmit("datachannel",e.channel,String.fromCharCode(...new Uint8Array(i.data)))}})}}class Ld extends Sp{constructor(e){super(),m(this,"supportsSendEncodings",!1),this.supportsSendEncodings=e.supportsSendEncodings}static createFactory(e){return()=>new Ld(e)}get name(){return"Firefox60"}send(e){return u(this,arguments,function*({track:n,encodings:i,codecOptions:r,screenShare:s}){this._assertSendDirection();const a=this.supportsSendEncodings&&i!==void 0?{sendEncodings:i}:{},c=this.pc.addTransceiver(n,V({direction:"sendonly",streams:[s?this._sendScreenShareStream:this._sendWebStream]},a));if(!this.supportsSendEncodings&&i){i.reverse();const h=c.sender.getParameters();h.encodings=i,yield c.sender.setParameters(h)}const d=(h,g)=>{var y;const S=qh(h),b=S.media[S.media.length-1],w=b.rtp.filter(q=>g.some(I=>I.name===q.codec)),C=b.fmtp.filter(q=>w.some(I=>I.payload===q.payload)),F=(y=b.rtcpFb)==null?void 0:y.filter(q=>w.some(I=>I.payload===q.payload)),O=w.map(q=>q.payload);return S.media[S.media.length-1].rtp=w,S.media[S.media.length-1].fmtp=C,S.media[S.media.length-1].rtcpFb=F,S.media[S.media.length-1].payloads=O.join(" "),vf(S)},l=yield this.pc.createOffer();if(l.sdp=d(l.sdp,r),p.debug(`send() | calling pc.setLocalDescription() [offer:${JSON.stringify(l)}]`),yield this.pc.setLocalDescription(l),n==="audio"||n.kind==="audio"){const{enableDtx:h,enableStereo:g}=this,y=this.enableHighBitrate?g?128e3:64e3:g?64e3:32e3;l.sdp=l.sdp.replace("minptime=10;useinbandfec=1",`minptime=10;useinbandfec=1;${h?"usedtx=1;":""}${g?"stereo=1;sprop-stereo=1;":""}maxaveragebitrate=${y}`)}return this.midTransceiverMap.set(c.mid,c),{offerSdp:l,callback:h=>u(this,null,function*(){return p.debug(`send() | calling pc.setRemoteDescription() [answer:${JSON.stringify(h)}]`),yield this.pc.setRemoteDescription(h),c.mid}),sender:c.sender,mid:c.mid}})}setMaxSpatialLayer(e,n){return u(this,null,function*(){this._assertSendDirection(),p.debug(`setMaxSpatialLayer() [localId:${e}, spatialLayer:${n}]`);const i=this.midTransceiverMap.get(e);if(!i)throw new Error("associated RTCRtpTransceiver not found");const r=i.sender.getParameters(),s=r.encodings.length-1-n;r.encodings.forEach((a,c)=>{c>=s?a.active=!0:a.active=!1}),yield i.sender.setParameters(r)})}addCustomEventListeners(){this.pc.addEventListener("datachannel",e=>{const{channel:n}=e;n.onmessage=i=>u(this,null,function*(){const r=yield i.data.arrayBuffer();this.safeEmit("datachannel",e.channel,String.fromCharCode(...new Uint8Array(r)))})})}}class Tp extends Sp{static createFactory(){return()=>new Tp}get name(){return"Chrome74"}send(e){return u(this,arguments,function*({track:n,encodings:i,codecOptions:r,screenShare:s}){this._assertSendDirection(),p.debug("Safari12::creating new transceiver");const a=this.pc.addTransceiver(n,{direction:"sendonly",streams:[s?this._sendScreenShareStream:this._sendWebStream],sendEncodings:i}),c=RTCRtpSender.getCapabilities(typeof n=="string"?n:n.kind);p.info(`Safari12::senders available params: ${JSON.stringify(c)}`);const d=[];r&&r.length>0&&r.forEach(h=>{var g;const y=c.codecs.find(S=>S.mimeType.includes(h.name));if(h.parameters){p.info(`Safari12::codecOption.parameters:, ${JSON.stringify(h.parameters)}`);const S=((g=y.sdpFmtpLine)==null?void 0:g.split(";"))||[];S.push(...h.parameters);const b=[...new Set(S).values()];y.sdpFmtpLine=b.join(";")}d.push(y)}),p.info(`Safari12::selected codecs: ${JSON.stringify(d)}`),a.setCodecPreferences(d);const l=yield this.pc.createOffer();if(yield this.pc.setLocalDescription(l),n==="audio"||n.kind==="audio"){const{enableStereo:h,enableDtx:g}=this,y=this.enableHighBitrate?h?128e3:64e3:h?64e3:32e3;l.sdp=l.sdp.replace("minptime=10;useinbandfec=1",`minptime=10;useinbandfec=1;${g?"usedtx=1;":""}${h?"stereo=1;sprop-stereo=1;":""}maxaveragebitrate=${y}`)}return this.midTransceiverMap.set(a.mid,a),{offerSdp:l,callback:h=>u(this,null,function*(){return p.debug(`Safari12::send() | calling pc.setRemoteDescription() [answer:${JSON.stringify(h)}]`),yield this.pc.setRemoteDescription(h),a.mid}),sender:a.sender,mid:a.mid}})}addCustomEventListeners(){this.pc.ondatachannel=e=>{const{channel:n}=e;n.onmessage=i=>u(this,null,function*(){const r=String.fromCharCode(...new Uint8Array(i.data));this.safeEmit("datachannel",e.channel,r)})}}}function RN(t,e){return typeof t=="undefined"?e:typeof window!="undefined"&&Object.getOwnPropertyDescriptor(window,"structuredClone")?structuredClone(t):JSON.parse(JSON.stringify(t))}var jc,cs,Kn,Qn,Di,Hc,lu,rh,My,sh,Ay;class MN extends No{constructor(e){var n,i;super(),f(this,Qn),f(this,Hc),f(this,rh),f(this,sh),m(this,"rtpReceiver"),m(this,"id"),m(this,"localId"),m(this,"producerId"),m(this,"producingTransportId"),m(this,"mimeType"),m(this,"track"),m(this,"peerId"),m(this,"appData"),m(this,"transceiver"),m(this,"closeTranscieverOnClose"),f(this,jc,void 0),f(this,cs,void 0),f(this,Kn,void 0),this.id=e.id,this.localId=e.localId,v(this,jc,e.handler),this.appData=e.appData,this.peerId=e.producingPeerId,this.producingTransportId=e.producingTransportId,v(this,Kn,!1),this.producerId=e.producerId,this.track=e.track,v(this,cs,(n=e.paused)!=null?n:!1),this.mimeType=e.mimeType,this.transceiver=e.transceiver,this.closeTranscieverOnClose=(i=e.closeTranscieverOnClose)!=null?i:!1,this.rtpReceiver=e.rtpReceiver,H(this,rh,My).call(this)}get closed(){return o(this,Kn)}get kind(){return this.track.kind}get paused(){return o(this,cs)}close(e){o(this,Kn)||(p.debug(`Consumer::close() ${e?`with reason ${e}`:""}`,o(this,Qn,Di)),v(this,Kn,!0),this.closeTranscieverOnClose&&(H(this,sh,Ay).call(this),this.transceiver.stop()),this.safeEmit("close",e))}getStats(){return u(this,null,function*(){if(o(this,Kn))throw new Ct("closed");return o(this,jc).getReceiverStats(this.localId)})}pause(){if(p.debug("consumer::pause()",o(this,Qn,Di)),o(this,Kn)){p.error("consumer::pause() | Consumer closed",o(this,Qn,Di));return}v(this,cs,!0),this.track.enabled=!1,this.safeEmit("pause")}resume(){if(p.debug("consumer::resume()",o(this,Qn,Di)),o(this,Kn)){p.error("Consumer::resume() | Consumer closed",o(this,Qn,Di));return}v(this,cs,!1),this.track.enabled=!0,this.safeEmit("resume")}}jc=new WeakMap,cs=new WeakMap,Kn=new WeakMap,Qn=new WeakSet,Di=function(){return{consumer:{id:this.id,appData:this.appData,peerId:this.peerId,kind:this.kind}}},Hc=new WeakSet,lu=function(){p.debug('Consumer::track "ended" event',o(this,Qn,Di)),this.safeEmit("trackended")},rh=new WeakSet,My=function(){this.track.addEventListener("ended",H(this,Hc,lu).bind(this))},sh=new WeakSet,Ay=function(){try{this.track.removeEventListener("ended",H(this,Hc,lu)),this.track.stop()}catch(t){p.error("Consumer::destroyTrack()",K(V({},o(this,Qn,Di)),{error:t}))}};var An,Ka,za,ds,vn,ut,or,Ya,tn,yn;class AN extends No{constructor(e){var n,i;super(),f(this,tn),m(this,"id"),m(this,"localId"),f(this,An,void 0),m(this,"kind"),m(this,"appData"),m(this,"rtpSender"),f(this,Ka,void 0),f(this,za,void 0),f(this,ds,void 0),f(this,vn,!1),f(this,ut,void 0),f(this,or,void 0),f(this,Ya,void 0),this.id=e.id,this.localId=e.localId,v(this,ut,e.track),this.kind=(n=e.track)==null?void 0:n.kind,v(this,or,e.disableTrackOnPause?!((i=e.track)!=null&&i.enabled):!1),v(this,Ya,void 0),v(this,Ka,e.stopTracks),v(this,za,e.disableTrackOnPause),v(this,ds,e.zeroRtpOnPause),this.appData=e.appData||{},this._onTrackEnded=this._onTrackEnded.bind(this),v(this,An,e.handler),this.rtpSender=e.rtpSender,this._handleTrack()}get closed(){return o(this,vn)}get track(){return o(this,ut)}get paused(){return o(this,or)}get maxSpatialLayer(){return o(this,Ya)}close(e){return u(this,null,function*(){if(o(this,vn))return;if(p.debug(`Producer::close() ${e?`with reason ${e}`:""}`,o(this,tn,yn)),v(this,vn,!0),this._destroyTrack(),e===oh){this.safeEmit("close");return}const{offerSdp:n,callback:i}=yield o(this,An).stopSending(this.localId),{answer:r}=yield this.safeEmitAsPromise("close",{offer:n,reason:e});i(r)})}getStats(){return u(this,null,function*(){if(o(this,vn))throw new Ct("closed");return o(this,An).getSenderStats(this.localId)})}pause(){p.debug("Producer::pause()",o(this,tn,yn)),o(this,vn)&&p.error("Producer::pause() | Producer closed",o(this,tn,yn)),v(this,or,!0),o(this,ut)&&o(this,za)&&(o(this,ut).enabled=!1),o(this,ds)&&o(this,An).replaceTrack(this.localId,null),this.emit("pause")}resume(){if(p.debug("Producer::resume()",o(this,tn,yn)),o(this,vn)){p.error("Producer::resume() | Producer closed",o(this,tn,yn));return}v(this,or,!1),o(this,ut)&&o(this,za)&&(o(this,ut).enabled=!0),o(this,ds)&&o(this,An).replaceTrack(this.localId,o(this,ut)),this.emit("resume")}replaceTrack(e){return u(this,arguments,function*({track:n}){if(p.debug(`Producer::replaceTrack() trackId: ${n==null?void 0:n.id}`,o(this,tn,yn)),o(this,vn)){if(n&&o(this,Ka))try{n.stop()}catch(i){p.error("Producer::replaceTrack",K(V({},o(this,tn,yn)),{error:i}))}throw new Ct("closed")}else if(n&&n.readyState==="ended")throw new Ct("track ended");if(n===o(this,ut)){p.debug(`replaceTrack() | same track, ignored trackId: ${n.id}`,o(this,tn,yn));return}(!o(this,ds)||!o(this,or))&&(yield o(this,An).replaceTrack(this.localId,n)),this._destroyTrack(),v(this,ut,n),this._handleTrack()})}setMaxSpatialLayer(e){return u(this,null,function*(){if(o(this,vn))throw new Ct("closed");if(this.kind!=="video")throw new Oo("not a video Producer");if(typeof e!="number")throw new TypeError("invalid spatialLayer");yield o(this,An).setMaxSpatialLayer(this.localId,e),v(this,Ya,e)})}setRtpEncodingParameters(e){return u(this,null,function*(){if(o(this,vn))throw new Ct("closed");if(typeof e!="object")throw new TypeError("invalid params");yield o(this,An).setRtpEncodingParameters(this.localId,e)})}_onTrackEnded(){p.debug(`Producer::track "ended" event trackId: ${this.track.id}`,o(this,tn,yn)),this.safeEmit("trackended",this.track.id)}_handleTrack(){o(this,ut)&&o(this,ut).addEventListener("ended",this._onTrackEnded)}_destroyTrack(){var e;if(o(this,ut))try{o(this,ut).removeEventListener("ended",this._onTrackEnded),o(this,Ka)&&o(this,ut).stop()}catch(n){p.error(`Producer::_destroyTrack trackId: ${(e=this.track)==null?void 0:e.id}`,K(V({},o(this,tn,yn)),{error:n}))}}}An=new WeakMap,Ka=new WeakMap,za=new WeakMap,ds=new WeakMap,vn=new WeakMap,ut=new WeakMap,or=new WeakMap,Ya=new WeakMap,tn=new WeakSet,yn=function(){return{producer:{id:this.id,appData:this.appData,kind:this.kind}}};function Dy(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function ah(t){return Math.random().toString(36).substring(2,2+t)}const Sc=1;function qg(t){const e=t;return delete e.payload._bolt,e}function DN(t){return t.payload&&Dy(t.payload)}function Oy(t){var e,n;return DN(t)&&(n=(e=t.payload._bolt)==null?void 0:e.id)!=null?n:""}var cr;const Qa=class extends mt.EventEmitter{constructor(t,e,n){super(),m(this,"channel"),m(this,"queue"),m(this,"serverProtocolVersion"),f(this,cr,new Map),m(this,"respond",(i,r,s=!1)=>{let a;s?a=Qa.createErrorResponse(i,r):a=Qa.createResponse(i,r),this.channel.send(JSON.stringify(a))}),m(this,"notify",i=>{const r=Qa.createNotification(i);this.channel.send(JSON.stringify(r))}),m(this,"request",i=>u(this,null,function*(){const r=Qa.createRequest(i),s=new Promise((a,c)=>{const d=1e3*(5+.1*this.queue.size),{id:l}=r.payload._bolt,h={id:l,method:r.type,resolve:g=>{this.queue.delete(l)&&(clearTimeout(h.timer),a(g))},timer:setTimeout(()=>{this.queue.delete(l)&&c(new Error(`request timeout for message id: ${l}`))},d),cancel:g=>{this.queue.delete(l)&&(clearTimeout(h.timer),c(g))}};this.queue.set(l,h)});return this.channel.send(JSON.stringify(r)),s})),m(this,"send",i=>{const r=JSON.stringify(i),s=16384;if(r.length>s){const a=s-200,c=Math.ceil(r.length/a),d=[];for(let h=0;h<c;h+=1){const g=h*a,y=(h+1)*a;d.push(r.slice(g,y))}const l=Us();for(let h=0;h<c;h+=1){const g=d[h],y=JSON.stringify({id:l,count:c,chunkIndex:h,chunk:g});p.debug(`Sending message chunk over dc: ${y}`),this.channel.send(y)}}else p.debug(`Sending message over dc: ${r}`),this.channel.send(r)}),m(this,"processMessage",i=>{var r;o(this,cr).has(i.id)||o(this,cr).set(i.id,[]);const s=o(this,cr).get(i.id);if(s[i.chunkIndex]=i,(s==null?void 0:s.length)===i.count&&!s.some(a=>a===void 0)){const a=o(this,cr).get(i.id),c=a==null?void 0:a.reduce((l,h)=>l+h.chunk,"");o(this,cr).delete(i.id);const d=JSON.parse(c);if(!d.payload||!Dy(d.payload))throw new Error("corrupted incoming message over dc",{cause:{code:"CORRUPT_DC_MESSAGE",values:d}});if(this.processBoltHandshake(d))return;if(this.serverProtocolVersion=(r=d.payload._bolt)==null?void 0:r.version,!this.processResponseMsg(d))return d}}),m(this,"processResponseMsg",i=>{const{id:r}=i.payload._bolt,s=this.queue.get(r);return s?(p.debug(`resolving pending request with id: ${r}, complete response: ${JSON.stringify(i)}`),i.type==="error"?s.cancel(qg(i)):s.resolve(qg(i)),!0):!1}),m(this,"processBoltHandshake",i=>{var r,s;return i.type==="_bolt"||i.type==="handshake"?(this.respond((s=(r=i.payload._bolt)==null?void 0:r.id)!=null?s:ah(8),{type:"_bolt",payload:{message:"pong"}}),!0):!1}),this.label=e,this.transportId=n,this.channel=t,this.queue=new Map}};let Xa=Qa;cr=new WeakMap,m(Xa,"createRequest",t=>{var e;if((e=t.payload)!=null&&e._bolt)throw new Error("rpc fields are internal values");return{type:t.type,payload:K(V({},t.payload),{_bolt:{id:ah(8),type:"REQUEST",version:Sc}})}}),m(Xa,"createResponse",(t,e)=>{var n;if((n=e.payload)!=null&&n._bolt)throw new Error("rpc fields are internal values");return{type:e.type,payload:K(V({},e.payload),{_bolt:{id:t,type:"RESPONSE",version:Sc}})}}),m(Xa,"createNotification",t=>{var e;if((e=t.payload)!=null&&e._bolt)throw new Error("rpc fields are internal values");return{type:t.type,payload:K(V({},t.payload),{bolt:{id:ah(8),type:"NOTIFY",version:Sc}})}}),m(Xa,"createErrorResponse",(t,e)=>({type:"error",payload:{error:e.message,_bolt:{id:t,type:"RESPONSE",version:Sc}}}));function Gg(t){if(Promise.allSettled)return Promise.allSettled(t);const e=t.map(n=>n.then(i=>({status:"fulfilled",value:i})).catch(i=>({status:"rejected",reason:i})));return Promise.all(e)}const oh="transport closed";var Za;class ON extends No{constructor(e,{id:n,direction:i,handlerFactory:r,iceServers:s,iceTransportPolicy:a,proprietaryConstraints:c,additionalSettings:d,appData:l,config:h}){var g,y,S;super(),m(this,"awaitQueue"),m(this,"observer"),f(this,Za,void 0),m(this,"id"),m(this,"serverId"),m(this,"closed",!1),m(this,"direction"),m(this,"maxSctpMessageSize"),m(this,"handler"),m(this,"connectionState","new"),m(this,"producers"),m(this,"consumers"),m(this,"datachannels"),m(this,"connected",!1),m(this,"eventsDCReadyPromise"),m(this,"eventsDCReadyPromiseResolver"),m(this,"eventsDCFailureTimer"),m(this,"transportConnectionPromise"),m(this,"consumerTrackEvents"),m(this,"unknownTracksMap"),m(this,"appData"),p.debug(`constructor() [id: ${n}, direction: ${i}]`),v(this,Za,e),this.id=n,this.direction=i;const b=RN(d,{});delete b.iceServers,delete b.iceTransportPolicy,delete b.bundlePolicy,delete b.rtcpMuxPolicy,delete b.sdpSemantics,this.producers=new Map,this.consumers=new Map,this.datachannels=new Map,this.consumerTrackEvents=new Map,this.unknownTracksMap=new Map,this.awaitQueue=new Nd,this.observer=new No,this.handler=r(),this.handler.enableHighBitrate=(g=h==null?void 0:h.enableHighBitrate)!=null?g:!1,this.handler.enableStereo=(y=h==null?void 0:h.enableStereo)!=null?y:!1,this.handler.enableDtx=(S=h==null?void 0:h.enableDtx)!=null?S:!0,this.handler.init({onTrackHandler:this._ontrack.bind(this),direction:i,iceServers:s,iceTransportPolicy:a,additionalSettings:d,proprietaryConstraints:c}),this.appData=l||{},this.transportConnectionPromise=new Promise(w=>{this.observer.once("connected",()=>{w(!0)}),this.observer.once("disconnect",()=>{w(!1)}),this.observer.once("close",()=>{w(!1)})}),this.eventsDCReadyPromise=new Promise(w=>{this.eventsDCReadyPromiseResolver=w}),this.handler.on("@connectionstatechange",w=>{w!==this.connectionState&&(p.debug(`connection state changed to ${w}`),this.connectionState=w,w==="connected"&&(this.connected=!0,this.observer.emit("connected")),w==="disconnected"&&(this.connected=!1,this.observer.emit("disconnect")),(w==="failed"||w==="closed")&&(this.connected=!1,this.observer.emit("close")),this.closed||this.safeEmit("connectionstatechange",w))}),this.handler.on("@icecandidate",({candidate:w})=>{this.closed||this.safeEmit("icecandidate",w)}),this.handler.on("dc_open",w=>{let C=this.datachannels.get(w.label);C||(C||(C=new Xa(w,w.label,this.serverId),this.datachannels.set(w.label,C)),this.eventsDCFailureTimer=setTimeout(()=>{w.label==="events"&&(this.eventsDCReadyPromiseResolver(!1),this.safeEmit("dc_error",w.label))},5e3))}),this.handler.on("datachannel",(w,C)=>{w.label==="events"&&(this.eventsDCReadyPromiseResolver(!0),this.eventsDCFailureTimer&&clearTimeout(this.eventsDCFailureTimer));const F=this.datachannels.get(w.label);if(!F){p.error("unregistered datachannel for message",{rtcChannel:{label:w.label,message:C}});return}try{const O=JSON.parse(C);p.debug("datachannel message chunk recieved",{dataChannelMessageChunk:{id:O.id,count:O.count,chunkIndex:O.chunkIndex,chunk:O.chunk,transprtId:this.serverId}});const q=F.processMessage(O);if(!q)return;p.debug(`datachannel message with id:${O.id} on transport:${this.serverId}complete - ${JSON.stringify(q)}`),this.emit(`datachannel:${w.label}`,F.label,q)}catch(O){p.error("error parsing message",{error:O})}})}setServerId(e){this.serverId=e}getDatachannel(e){return this.datachannels.get(e)}get isEventsDCReady(){return this.eventsDCReadyPromise}close(){this.closed||(p.debug("Transport close called"),this.connected=!1,this.closed=!0,this.handler.close(),Array.from(this.producers.values()).forEach(e=>{e.close(oh).catch(()=>{})}),this.producers.clear(),Array.from(this.consumers.values()).forEach(e=>{e.close(oh)}),this.consumers.clear(),this.consumerTrackEvents.clear(),this.emit("close"),this.observer.emit("close"))}getStats(){return u(this,null,function*(){if(this.closed)throw new Ct("closed");return this.handler.getTransportStats()})}connect(e,n){return u(this,null,function*(){try{const{producerIds:i}=yield this.awaitQueue.push(()=>u(this,null,function*(){const{offerSdp:r,callback:s}=yield this.handler.connect(),{transportId:a,answer:c,producerIds:d}=yield e(r);return this.setServerId(a),yield s(c),{producerIds:d}}));if(i.forEach((r,s)=>{this.createProducerObject({id:r,localId:n[s].mid,track:n[s].track,stopTracks:!0,disableTrackOnPause:!0,zeroRtpOnPause:!1,appData:JSON.parse(n[s].appData||"{}"),handler:this.handler}).catch(a=>{p.error("error creating producer:",a)})}),!(yield this.transportConnectionPromise))throw new Error("ice connection failed");if(o(this,Za)===it.HIVE&&!(yield this.isEventsDCReady))throw new Error("events datachannel not open")}catch(i){throw p.error("transport failed to connect:",i),i}})}restartIce(){return u(this,null,function*(){if(p.debug("restartIce()"),this.closed)throw new Ct("closed");return this.handler.restartIce()})}canProduce(e){return u(this,null,function*(){const{track:n,appData:i}=e;if(n){if(this.direction!=="send")throw new Oo("not a sending Transport");if(n.readyState==="ended")throw new Ct("track ended");if(this.listenerCount("connect")===0&&this.connectionState==="new")throw new TypeError('no "connect" listener set into this transport');if(i&&typeof i!="object")throw new TypeError("if given, appData must be an object")}else throw new TypeError("missing track");if(!(yield this.transportConnectionPromise))throw new Rs("transport not connected");return!0})}produce(e,n){return u(this,null,function*(){if(!(yield this.canProduce(e)))throw new Error("Cannot produce");const{track:i,encodings:r,codecOptions:s,stopTracks:a=!0,disableTrackOnPause:c=!0,zeroRtpOnPause:d=!1,appData:l={}}=e;p.debug(`produce() [track:${i.id}]`);const{producerId:h,localId:g,rtpSender:y}=yield this.awaitQueue.push(()=>u(this,null,function*(){const{offerSdp:S,callback:b,sender:w,mid:C}=yield this.handler.send({track:i,encodings:r,codecOptions:s,screenShare:l==null?void 0:l.screenShare}),{answer:F,producerId:O}=yield n({offer:S,kind:i.kind,paused:c?!i.enabled:!1,appData:K(V({},l||{}),{mid:C}),codecOptions:s,producingTransportId:this.serverId}),q=yield b(F);return{producerId:O,localId:q,rtpSender:w}}),"producer");return this.createProducerObject({id:h,localId:g,track:i,stopTracks:a,disableTrackOnPause:c,zeroRtpOnPause:d,appData:l,handler:this.handler,rtpSender:y})})}precreateProducers(e){return u(this,null,function*(){const n=[];for(const{kind:i,options:{encodings:r,codecOptions:s,track:a}}of e){const c=yield this.handler.send({track:a,encodings:r,codecOptions:s});n.push({kind:i,result:c})}return n})}createProducerObject(e){return u(this,null,function*(){const n=new AN(e);return this.producers.set(n.id,n),n.once("close",()=>{this.producers.delete(n.id)}),n})}closeProducer(e){return u(this,null,function*(){yield this.awaitQueue.push(e.close.bind(e),"producer")})}canConsume(){return u(this,null,function*(){if(this.closed)throw new Ct("closed");if(this.direction!=="recv")throw new Oo("not a receiving transport");if(this.listenerCount("connect")===0&&this.connectionState==="new")throw new TypeError('no "connect" listener set into this transport');if(!(yield this.transportConnectionPromise))throw new Rs("transport not connected");return!0})}consume(e,n,i){return u(this,null,function*(){const r=[];return this.awaitQueue.push(()=>u(this,null,function*(){const{consumerStates:s,sessionDescription:a}=yield n(e);return s.forEach((c,d)=>{r.push(this.createConsumerObjectAndWaitForTrack(K(V({},c),{producerId:d})))}),a&&(yield i(a)),Gg(r)}),"consumer")})}setRemoteOffer(e){return u(this,null,function*(){yield this.setRemoteDescription(e);const n=yield this.handler.pc.createAnswer(),i=qh(n.sdp);return i.media=i.media.map(r=>{if(r.type==="audio"){const s=V({},r),a=s.fmtp.find(c=>c.payload===111);return a&&(a.config+=";stereo=1;sprop-stereo=1"),s.rtcpFb||(s.rtcpFb=[]),s.rtcpFb.some(c=>c.type==="nack")||s.rtcpFb.push({payload:parseInt(s.payloads,10),type:"nack"}),s}return r}),n.sdp=vf(i),yield this.setLocalDescription(n),n})}_ontrack(e){const{track:n,transceiver:i,streams:r}=e;p.info(`track event received [trackId: ${n.id}]`);let s;o(this,Za)===it.HIVE?s=`${r[0].id}:${n.kind}`:s=`${i.mid}:${n.kind}`,n.addEventListener("ended",()=>{p.info(`rtc consumer track ended [trackId: ${n.id}]`),this.unknownTracksMap.delete(s)});const a=this.consumerTrackEvents.get(s);a?(a(n,i),this.consumerTrackEvents.delete(s)):(p.warn(`track event handler not found ${s}`),this.unknownTracksMap.set(s,e))}sendErrorOverDC(e,n,i){const r=this.getDatachannel(e);if(!r)throw new Error("datachannel not found",{cause:{code:"DC_NOT_FOUND",values:{label:e}}});r.respond(n,i,!0)}sendResponseOverDC(e,n,i){const r=this.getDatachannel(e);if(!r)throw new Error("datachannel not found",{cause:{code:"DC_NOT_FOUND",values:{label:e}}});r.respond(n,i)}createConsumerObjectAndWaitForTrack(e){return u(this,null,function*(){const{consumerId:n,producerId:i,producingPeerId:r,producingTransportId:s,streamId:a,paused:c,screenShare:d,appData:l,kind:h,mimeType:g}=e,y=`${a}:${h}`,S=K(V({},e),{name:"consumer creation task error",message:"consumer creation failed"});return new Promise((b,w)=>u(this,null,function*(){const C=setTimeout(()=>{this.consumerTrackEvents.delete(y),S.isTimedout=!0,w(S)},5e3),F=(q,I)=>{try{if(q.readyState==="ended")clearTimeout(C),w(S);else{const Z=q;Z.enabled=!0,this.handler.midTransceiverMap.set(I.mid,I);const se=new MN({id:n,localId:I.mid,transceiver:I,track:Z,paused:c,producerId:i,producingPeerId:r,producingTransportId:s,handler:this.handler,appData:K(V({},l),{screenShare:d,peerId:r}),rtpReceiver:I.receiver,mimeType:g});this.consumers.set(n,se),se.once("close",()=>{this.consumers.delete(se.id),this.handler.midTransceiverMap.delete(I.mid)}),p.info("consumer created for ",{consumer:{id:n,kind:h,appData:{screenShare:d},peerId:r,producerId:i}}),this.observer.emit("newconsumer",se),clearTimeout(C),b(se)}}catch(Z){p.warn("error while creating consumer:",Z),clearTimeout(C),w(S)}},O=this.unknownTracksMap.get(y);O?(this.unknownTracksMap.delete(y),F(O.track,O.transceiver)):this.consumerTrackEvents.set(y,F)}))})}setRemoteDescription(e){return u(this,null,function*(){yield this.handler.pc.setRemoteDescription(e)})}setLocalDescription(e){return u(this,null,function*(){p.debug(`${this.direction}() {transportId: ${this.serverId}} | calling pc.setLocalDescription() [offer:${JSON.stringify(e)}]`),yield this.handler.pc.setLocalDescription(e)})}retryFailedConsumerCreationTasks(e){return u(this,null,function*(){return Gg(e.map(n=>u(this,null,function*(){return yp(i=>u(this,null,function*(){return i>0&&p.warn(`retrying failed consumer creation task: ${JSON.stringify(n)}`),this.createConsumerObjectAndWaitForTrack(V({},n))}))})))})}sendDataChannelMessage(e,n){return u(this,null,function*(){const i=this.getDatachannel(e);if(!i)throw bN("DC_NOT_READY",`${e} datachannel not ready`);const r=(yield i.request(n)).payload;return p.info(`sendDataChannelMessage::response ${JSON.stringify(r)}`),r})}}Za=new WeakMap;function NN(){if(typeof navigator=="object"&&navigator.product==="ReactNative"){if(typeof RTCPeerConnection=="undefined"){p.warn("Device::this._detectDevice() | unsupported ReactNative without RTCPeerConnection");return}return p.debug("Device::this._detectDevice() | ReactNative handler chosen"),"Chrome74"}if(typeof navigator=="object"&&typeof navigator.userAgent=="string"){const t=navigator.userAgent,e=of.getParser(t),n=e.getEngine();if(e.satisfies({chrome:">=74",chromium:">=74","microsoft edge":">=88"}))return"Chrome74";if(e.satisfies({chrome:">=55",chromium:">=55"}))return;if(e.satisfies({firefox:">=110"}))return"Firefox110";if(e.satisfies({firefox:">=60"}))return"Firefox60";if(e.satisfies({ios:{OS:">=14.3",firefox:">=30.0"}})||e.satisfies({safari:">=12.0"})&&typeof RTCRtpTransceiver!="undefined"&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(e.satisfies({safari:">=11"})||e.satisfies({"microsoft edge":">=11"})&&e.satisfies({"microsoft edge":"<=18"}))return;if(n.name&&n.name.toLowerCase()==="blink"){const i=t.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);return i?Number(i[1])>=74?"Chrome74":void 0:"Chrome74"}if(n.name.toLowerCase()==="webkit"&&e.getOS().name.toLowerCase()==="ios")return typeof RTCRtpTransceiver!="undefined"&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection")?"Safari12":void 0;p.warn("Device::this._detectDevice() | browser not supported");return}p.warn("Device::this._detectDevice() | unknown device")}var qc;class LN{constructor(e,{handlerName:n,handlerFactory:i}={}){if(m(this,"handlerFactory"),f(this,qc,void 0),p.debug("constructor()"),v(this,qc,e),n&&i)throw new TypeError("just one of handlerName or handlerInterface can be given");if(i)this.handlerFactory=i;else{if(n)p.debug(`Device::constructor() | handler given: ${n}`);else if(n=NN(),n)p.debug(`Device::constructor() | detected handler: ${n}`);else throw new Error("device not supported");switch(n){case"Chrome74":this.handlerFactory=Ep.createFactory();break;case"Safari12":this.handlerFactory=Tp.createFactory();break;case"Firefox60":this.handlerFactory=Ld.createFactory({supportsSendEncodings:!1});break;case"Firefox110":this.handlerFactory=Ld.createFactory({supportsSendEncodings:!0});break;default:throw new TypeError(`unknown handlerName "${n}"`)}}}createTransport(e){const n=Us();return new ON(o(this,qc),K(V({id:n},e),{handlerFactory:this.handlerFactory}))}}qc=new WeakMap;const xN=2e3;var Mi,fo,Vt,Ut,Ms,vo,eo,to,ls,br,no,yo,Gc,Jc,ch,dh,Ny,lh,Ly,uh,xy,hh,Vy,ph,Jg,$c,uu,Kc,hu;class VN extends mt.EventEmitter{constructor(e,n,i){switch(super(),f(this,yo),f(this,Jc),f(this,dh),f(this,lh),f(this,uh),f(this,hh),f(this,ph),f(this,$c),f(this,Kc),f(this,Mi,void 0),f(this,fo,void 0),f(this,Vt,void 0),f(this,Ut,void 0),f(this,Ms,void 0),f(this,vo,void 0),f(this,eo,void 0),f(this,to,{transportFailureCount:{send:0,recv:0},lastConnectionTime:0}),f(this,ls,void 0),f(this,br,"all"),f(this,no,void 0),v(this,Mi,e),v(this,Ms,n),v(this,no,i),v(this,fo,new LN(i)),v(this,vo,new CN(n,i)),i){case it.CF:{v(this,eo,En);break}case it.HIVE:default:{v(this,eo,sn);break}}o(this,yo,Gc).mediaState={send:{state:Bi.NEW,reconnected:!1},recv:{state:Bi.NEW,reconnected:!1}},X.hasFeature(re.FORCE_RELAY)&&v(this,br,"relay"),H(this,Jc,ch).call(this)}get socket(){return o(this,Ms)}get socketHandler(){return o(this,vo)}get sendTransport(){return o(this,Vt)}get recvTransport(){return o(this,Ut)}get events(){return o(this,eo)}get nodeType(){return o(this,no)}createTransports(e){return u(this,null,function*(){var n,i,r,s,a,c,d,l;X.hasFeature(re.FORCE_RELAY)&&(p.info("ICE Transport Policy set to relay"),v(this,br,"relay"));const h=yield dt().getICEServers().catch(y=>(p.warn(`failed to get iceservers from server: ${y.message}`),[])),g=[];if(e.send){const y=X.hasFeature(re.DISABLE_OPUS_DTX_CF),S=H(this,lh,Ly).call(this,{iceServers:h,additionalSettings:{encodedInsertableStreams:(n=o(this,Mi).getValue("modules").e2ee)==null?void 0:n.enabled},config:{enableHighBitrate:(s=(r=(i=o(this,Mi).getValue("defaults").mediaConfiguration)==null?void 0:i.audio)==null?void 0:r.enableHighBitrate)!=null?s:!1,enableStereo:(d=(c=(a=o(this,Mi).getValue("defaults").mediaConfiguration)==null?void 0:a.audio)==null?void 0:c.enableStereo)!=null?d:!1,enableDtx:o(this,no)===it.HIVE?!0:!!y},iceTransportPolicy:o(this,br)});g.push(S)}if(e.recv){const y=H(this,uh,xy).call(this,{iceServers:h,additionalSettings:{encodedInsertableStreams:(l=o(this,Mi).getValue("modules").e2ee)==null?void 0:l.enabled},iceTransportPolicy:o(this,br)});g.push(y)}yield Promise.all(g)})}stopTransports(e){var n,i,r,s;e.send&&((n=o(this,Vt))==null||n.close(),(i=o(this,Vt))==null||i.removeAllListeners(),v(this,Vt,void 0)),e.recv&&((r=o(this,Ut))==null||r.close(),(s=o(this,Ut))==null||s.removeAllListeners(),v(this,Ut,void 0)),H(this,Jc,ch).call(this)}stopAllTransports(){p.info("Closing all transports"),this.stopTransports({send:!0,recv:!0})}connectTransportWithRetry(e,n){return u(this,null,function*(){const{id:i,serverId:r,direction:s}=e;H(this,hh,Vy).call(this,e);try{const a=X.hasFeature(re.ENABLE_HIVE_INFINITE_RETRIES)?1/0:3;return yield yp((c,d)=>u(this,null,function*(){c>0&&p.debug(`Retrying transport connect, count: ${c}`,{transport:{id:i,serverId:r,type:s}});try{yield H(this,dh,Ny).call(this,e,n)}catch(l){if(l instanceof Rs){d(l);return}throw l}}),{delayTime:100,strategy:"exponential",maxRetryCount:a}),e}catch(a){throw p.error(`Failed to connect send transport after retry: ${e.id}`,{error:a,transport:{id:i,serverId:r,type:s}}),e.close(),e.removeAllListeners(),this.handleErrors("rejoin"),a}})}handleErrors(e){throw new Error("Method not implemented.")}}Mi=new WeakMap,fo=new WeakMap,Vt=new WeakMap,Ut=new WeakMap,Ms=new WeakMap,vo=new WeakMap,eo=new WeakMap,to=new WeakMap,ls=new WeakMap,br=new WeakMap,no=new WeakMap,yo=new WeakSet,Gc=function(){return o(this,Mi).getValue("connectionHandler")},Jc=new WeakSet,ch=function(){v(this,ls,{send:void 0,recv:void 0})},dh=new WeakSet,Ny=function(t,e){return u(this,null,function*(){const{id:n,serverId:i,direction:r}=t;if(p.info(`Connecting ${r} transport`,{transport:{id:n,serverId:i,type:r}}),!o(this,Ms).isConnected)throw new Rs("Socket is not connected");if(t.connectionState==="closed")throw new Rs("Transport is closed");try{yield t.connect(s=>H(this,ph,Jg).call(this,r,s,e),e),p.info(`Connected ${r} transport`,{transport:{id:n,serverId:i,type:r}})}catch(s){throw o(this,to).transportFailureCount[r]+=1,s.message==="ice connection failed"?new Rs(s.message):s}})},lh=new WeakSet,Ly=function(t){return u(this,null,function*(){var e,n;if(o(this,Vt)&&o(this,Vt).connected){p.info("Transport send is already connected",{transport:{id:(e=o(this,Vt))==null?void 0:e.id,serverId:(n=o(this,Vt))==null?void 0:n.serverId,type:"send"}});return}v(this,Vt,yield o(this,fo).createTransport(K(V({},t),{direction:"send"}))),$.configureSendTransport(o(this,Vt))})},uh=new WeakSet,xy=function(t){return u(this,null,function*(){var e,n;if(o(this,Ut)&&o(this,Ut).connected){p.info("Transport recv is already connected",{transport:{id:(e=o(this,Ut))==null?void 0:e.id,serverId:(n=o(this,Ut))==null?void 0:n.serverId,type:"recv"}});return}v(this,Ut,yield o(this,fo).createTransport(K(V({},t),{direction:"recv"}))),$.configureRecvTransport(o(this,Ut))})},hh=new WeakSet,Vy=function(t){const{direction:e,id:n}=t;t.on("connectionstatechange",i=>u(this,null,function*(){H(this,Kc,hu).call(this,{state:i,direction:e}),p.info(`Transport connection state changed for ${e} transport`,{transport:{id:n,serverId:t.serverId,type:e,status:i}});const r=()=>{const s=o(this,ls)[e];s!==void 0&&(clearTimeout(s),o(this,ls)[e]=void 0)};switch(i){case"connected":r(),o(this,to).lastConnectionTime=performance.now();break;case"disconnected":o(this,ls)[e]=setTimeout(()=>u(this,null,function*(){yield H(this,$c,uu).call(this,t)}),xN);break;case"failed":if(t.closed)return;r(),yield H(this,$c,uu).call(this,t);break}})),t.on("icecandidate",i=>u(this,null,function*(){p.debug("Sending iceCandidate:",{iceCandidate:i})})),t.on("datachannel:events",(i,r)=>u(this,null,function*(){var s,a;p.debug("Got data channel message on event:",{rtcChannel:{label:i,message:r}});try{switch(r.type){case"handshake":{const c={type:"handshake",payload:{message:"pong"}};t.sendResponseOverDC(i,Oy(r),c);break}case"hub-disconnect":{p.debug(`media hub disconnected, full_reconnect: ${(s=r.payload)==null?void 0:s.full_reconnect}`),((a=r.payload)==null?void 0:a.full_reconnect)===!0&&this.handleErrors("rejoin");break}case"error":break;default:break}}catch{p.error(`Unable to handle the incoming datachannel message on channel ${i}`)}})),t.on("dc_error",()=>{t.direction==="recv"&&(p.warn("Events datachannel did not open in 5s",{country:E.location.country}),this.handleErrors("reconnectRecvTransport"))})},ph=new WeakSet,Jg=function(t,e,n){return u(this,null,function*(){const i=t==="recv";try{const{sdp:r,type:s}=e,a={consuming:i,description:{sdp:r,type:s,target:i?Fi.SUBSCRIBER:Fi.PUBLISHER},producers:[]};return!i&&n&&(a.producers=n),o(this,vo).connectTransport(a)}catch(r){throw p.error(`Error in ${t} transport connection:`,{error:r,country:E.location.country}),r}})},$c=new WeakSet,uu=function(t){return u(this,null,function*(){t.close(),t.removeAllListeners();const{direction:e}=t;switch(X.hasFeature(re.HIVE_TRANSPORT_FORCE_RELAY_ON_ICE_FAILED)&&o(this,Ms).isConnected&&o(this,to).transportFailureCount[e]>2&&(p.warn(`Multiple disconnections in ${e} transport, forcing relay`),v(this,br,"relay")),yield this.createTransports({[e]:!0}),e){case"send":{yield this.connectTransportWithRetry(o(this,Vt)),p.info("Transport reconnected",{transport:o(this,Vt)}),M.emit(A.RESET_PRODUCER_STATE);break}case"recv":{yield this.connectTransportWithRetry(o(this,Ut)),p.info("Transport reconnected",{transport:o(this,Ut)}),M.emit(A.UPDATE_ACTIVE,{createAllConsumers:!0});break}default:p.warn("Unknown transport direction",{transport:t})}H(this,Kc,hu).call(this,{state:Bi.CONNECTED,direction:e})})},Kc=new WeakSet,hu=function(t){const{state:e,direction:n}=t;o(this,yo,Gc).mediaState[n]={state:e,reconnected:!0},M.emit(A.TRANSPORT_STATE_UPDATE,V({transport:n},o(this,yo,Gc).mediaState[n]))};var mh,Uy;class UN{constructor(e){f(this,mh),this.recvTransport=e,H(this,mh,Uy).call(this)}create(e){return u(this,null,function*(){if(!e||e&&e.length===0)throw new Error("List of producers is required");const n={type:"create_consumer",payload:{producers:e.map(({producerId:a,producingTransportId:c,kind:d,mimeType:l})=>({producerId:a,producingTransportId:c,preferredCodec:V(V({},d==="video"&&l?{video:l}:{}),d==="audio"&&l?{audio:l}:{})}))}},i=yield this.recvTransport.sendDataChannelMessage("events",n),r=new Map;e.forEach(a=>r.set(a.producerId,a));const s=new Map;return Object.entries(i).forEach(([a,c])=>{const d=r.get(c.producerId);d&&s.set(c.producerId,{consumerId:a,producingTransportId:d.producingTransportId,producingPeerId:d.producingPeerId,kind:d.kind,paused:d.pause,streamId:c.streamId,trackId:c.trackId,screenShare:d.screenShare,mimeType:d.mimeType,appData:{}})}),{consumerStates:s}})}negotiate(e,n,i){return u(this,null,function*(){try{p.debug(`Received offer over dc: ${e.sdp} for transport`);const r=yield this.recvTransport.setRemoteOffer(e),s={type:"answer",payload:{type:r.type,sdp:r.sdp}};return p.debug(`datachannel answer: ${JSON.stringify(s)}`),this.recvTransport.sendResponseOverDC(i,n,s),r}catch(r){throw p.error("datachannel:events::Error:",r),r.code!=="DC_NOT_FOUND"&&this.recvTransport.sendErrorOverDC(i,n,r),r}})}close(e){return u(this,null,function*(){if(!e.length)return{};const n=e.map(a=>a.id);p.info(`Closing consumers: ${JSON.stringify(n)}`);const i={type:"close_consumers",payload:{consumers:n}},r=yield this.recvTransport.sendDataChannelMessage("events",i),{failedConsumers:s}=r;return{failedConsumers:s}})}}mh=new WeakSet,Uy=function(){this.recvTransport.on("datachannel:events",(t,e)=>u(this,null,function*(){try{switch(e.type){case"negotiation":{const{sdp:n}=e.payload,i={sdp:n,type:"offer"};this.negotiate(i,Oy(e),t);break}default:break}}catch{p.error(`Unable to handle the incoming datachannel message on channel ${t}`)}}))};class FN{constructor(e,n,i,r){this.events=e,this.recvTransport=n,this.socket=i,this.socketHandler=r}create(e){return u(this,null,function*(){if(!e||e&&e.length===0)throw new Error("List of producers is required");const n=new Map,i=[];e.forEach(c=>{const{producingPeerId:d,producerId:l,producingTransportId:h}=c;n.set(l,d),i.push({producingPeerId:d,producerId:l,producingTransportId:h})});const r=yield this.socketHandler.consume({requests:i,consumingTransportId:this.recvTransport.serverId}),s=new Map;e.forEach(c=>s.set(c.producerId,c));const a=new Map;return Object.entries(r.consumerStateMap).forEach(([c,d])=>{const l=s.get(c);if(!l)return;let h={};try{h=JSON.parse(d.producerState.appData)}catch{}a.set(c,{consumerId:d.consumerId,producingTransportId:l.producingTransportId,producingPeerId:l.producingPeerId,kind:l.kind,paused:l.pause,streamId:d.producerTrack.streamId,trackId:d.producerTrack.trackId,screenShare:l.screenShare,mimeType:l.mimeType,appData:h})}),{consumerStates:a,sessionDescription:r.sessionDescription}})}negotiate(e){return u(this,null,function*(){p.debug(`setting remote offer: ${JSON.stringify(e)} on recvTransport`,{transport:this.recvTransport});const n=yield this.recvTransport.setRemoteOffer(e),i={transportId:this.recvTransport.serverId,description:{sdp:n.sdp,type:n.type,target:Fi.SUBSCRIBER}};return p.debug(`sending renegotiate request: ${JSON.stringify(i)} on recvTransport`,{transport:this.recvTransport}),yield this.socket.sendMessagePromise(this.events.renegotiateSessionDescription,pP.toBinary(i)),p.info("renegotiation done",{transport:this.recvTransport}),n})}close(e){return u(this,null,function*(){if(!e.length)return{};const n=e.map(r=>r.localId);p.info(`Closing consumers: ${JSON.stringify(n)}`);const i={consumerIds:n};return yield(()=>u(this,null,function*(){var r;return(r=this.recvTransport)==null?void 0:r.awaitQueue.push(()=>u(this,null,function*(){yield this.socketHandler.closeConsumer(i)}),"close_consumer").catch(s=>{p.warn("error on closing consumer:",{error:s})})}))(),{}})}}class xd{constructor(e){this.socketHandler=e}static getMSIDFromSDP(e,n){return qh(e).media.filter(i=>n==="video"?i.type==="video":i.type==="audio").at(-1).msid}create(e){return u(this,arguments,function*({offer:n,kind:i,paused:r,appData:s,codecOptions:a,producingTransportId:c}){var d,l;const h=xd.getMSIDFromSDP(n.sdp,i),g={description:{sdp:n.sdp,type:n.type,target:Fi.PUBLISHER},paused:r,kind:i,msid:h,appData:JSON.stringify(s),screenShare:(d=s.screenShare)!=null?d:!1,mimeType:`${i}/${(l=a[0])==null?void 0:l.name}`,producingTransportId:c},{answer:y,producerId:S}=yield this.socketHandler.produce(g);return{answer:y,producerId:S}})}}const BN=3;var So,_s,Ir,Eo,zc,ei,Vd,gh,Fy,fh,By,vh,Wy,yh,jy,Ud,Sh,Fd,Eh,Th,Hy;class WN extends VN{constructor(e,n,i){super(e,n,i),f(this,gh),f(this,fh),f(this,vh),f(this,yh),f(this,Ud),f(this,Fd),f(this,Th),f(this,So,void 0),f(this,_s,void 0),f(this,Ir,void 0),f(this,Eo,void 0),f(this,zc,void 0),f(this,ei,void 0),f(this,Vd,{producerCreationFailureCount:0,consumerCreationFailureCount:0,producerNotReadyFailureCount:0}),v(this,So,e),o(this,gh,Fy).mediaState={send:{state:Bi.NEW,reconnected:!1},recv:{state:Bi.NEW,reconnected:!1}},this.reset()}get socketHandler(){return super.socketHandler}get producers(){return o(this,_s)}get consumers(){return o(this,Ir)}get producerIdToConsumerIdMap(){return o(this,Eo)}reset(){v(this,_s,new Map),v(this,Ir,new Map),v(this,Eo,new Map)}setupTransports(e,n){return u(this,null,function*(){yield this.createTransports(e);let i,r;e.send&&(i=H(this,fh,By).call(this,n)),e.recv&&(r=H(this,vh,Wy).call(this));const[s]=yield Promise.all([i,r]);return s})}createProducer(e,n){return u(this,null,function*(){var i;if(!this.sendTransport||this.sendTransport.closed)throw new Error("Send transport is closed");try{const r=yield this.sendTransport.produce(e,H(this,yh,jy).bind(this));return(i=e.appData)!=null&&i.e2ee&&M.emit(A.E2EE_ACTIVE_PRODUCER,r),H(this,Ud,Sh).call(this,r,n),r}catch(r){throw p.error("Failed to create producer",{error:r}),o(this,Vd).producerCreationFailureCount+=1,r}})}closeProducer(e,n){return u(this,null,function*(){var i;const r=this.producers.get(e);if(!r){p.warn(`Producer with ID ${e} was not found`);return}n!=null&&n.stopTrack&&r.track.stop();try{yield this.sendTransport.closeProducer(r),(i=o(this,So).getValue("modules").e2ee)!=null&&i.enabled&&M.emit(A.E2EE_INACTIVE_PRODUCER,r)}catch(s){p.error("Failed to close producer on server",{error:s,producer:r})}})}closeAllProducers(){return Promise.all(Array.from(o(this,_s).entries()).map(([,e])=>e.close()))}createConsumer(e){return this.createConsumers([e])}createConsumers(e){return u(this,null,function*(){if(!this.recvTransport||this.recvTransport.closed)throw new Error("Recv transport is closed");try{const n=e.filter(({producerId:i})=>!this.producers.get(i));(yield this.recvTransport.consume(n,H(this,Fd,Eh).bind(this),o(this,ei).negotiate.bind(o(this,ei)))).forEach(i=>{i.status!=="rejected"&&H(this,Th,Hy).call(this,i.value)})}catch{}})}closeConsumer(e){return this.closeConsumers([e])}closeConsumers(e){return u(this,null,function*(){if(!o(this,ei))return;const n=e.map(r=>this.consumers.get(r)).filter(r=>r!==void 0);if(n.length===0)return;const{failedConsumers:i}=yield o(this,ei).close(n);i!=null&&i.length&&p.warn("Failed to close some consumers",{consumerIds:i})})}closeAllConsumers(){return this.closeConsumers(Array.from(o(this,Ir).keys()))}switchConsumersToLayer(e,n){return u(this,null,function*(){const i=this.recvTransport.getDatachannel("events");if(!i){p.warn("events datachannel not found");return}const r={type:"switch_consumer_layer",payload:{consumerIds:e,layer:n}};yield i.request(r),p.info(`Consumers switched layers to ${n}`,{consumerIds:e})})}}So=new WeakMap,_s=new WeakMap,Ir=new WeakMap,Eo=new WeakMap,zc=new WeakMap,ei=new WeakMap,Vd=new WeakMap,gh=new WeakSet,Fy=function(){return o(this,So).getValue("connectionHandler")},fh=new WeakSet,By=function(t){return u(this,null,function*(){v(this,zc,new xd(this.socketHandler));const e=[];return t&&(yield this.sendTransport.precreateProducers(t)).forEach((n,i)=>u(this,[n,i],function*({kind:r,result:s},a){var c;const{codecOptions:d}=t[a].options,l=d[0]?`${r}/${(c=d[0])==null?void 0:c.name}`:void 0;e.push({kind:r,msid:xd.getMSIDFromSDP(s.offerSdp.sdp,r),mid:s.mid,paused:!0,mimeType:l,appData:JSON.stringify({mid:s.mid}),screenShare:!1,track:t[a].options.track})})),yield this.connectTransportWithRetry(this.sendTransport,e),this.sendTransport.producers.size?e.map(({mid:n},i)=>{const[,r]=Array.from(this.sendTransport.producers.entries()).find(([,s])=>s.localId===n);return H(this,Ud,Sh).call(this,r,t[i].onClose),r}):[]})},vh=new WeakSet,Wy=function(){return u(this,null,function*(){switch(this.recvTransport.on("connect",()=>{o(this,Eo).clear()}),yield this.connectTransportWithRetry(this.recvTransport),this.nodeType){case it.CF:{v(this,ei,new FN(this.events,this.recvTransport,this.socket,this.socketHandler));break}case it.HIVE:default:v(this,ei,new UN(this.recvTransport))}})},yh=new WeakSet,jy=function(t){return o(this,zc).create(t)},Ud=new WeakSet,Sh=function(t,e){t.on("close",(n,i)=>u(this,[n,i],function*({offer:r,reason:s},a){p.info("producer::closing",{debuggingHint:s,producer:K(V({},t),{status:"closing"})});const c={producerId:t.id,description:{sdp:r.sdp,type:r.type,target:Fi.PUBLISHER}};try{const d=yield this.socketHandler.closeProducer(c),l={sdp:d==null?void 0:d.sdp,type:d==null?void 0:d.type};p.info("producer::closed",{producer:K(V({},t),{status:"closed"})}),a({answer:l})}catch(d){p.error("producer close error",d)}this.producers.delete(t.id),e()})),t.on("trackended",()=>{p.info("producer::trackended",{producer:K(V({},t),{status:"UNKNOWN"})})}),o(this,_s).set(t.id,t)},Fd=new WeakSet,Eh=function(t,e=0){return u(this,null,function*(){try{return yield this.recvTransport.canConsume(),yield o(this,ei).create(t)}catch(n){if(n instanceof _N&&(o(this,Vd).consumerCreationFailureCount+=1),e<=BN)return p.error(`Error in consume request attempt:${e}`,{error:n}),H(this,Fd,Eh).call(this,t,e+1);throw p.error("Error in consume request",{error:n}),n}})},Th=new WeakSet,Hy=function(t){t.on("close",e=>u(this,null,function*(){p.debug("consumer closed",{consumer:{closureReason:e,id:t.id,kind:t.kind,appData:t.appData}}),o(this,Ir).delete(t.id),M.emit(A.CONSUMER_CLOSED,{id:t.id})})),o(this,Ir).set(t.id,t),this.producerIdToConsumerIdMap.set(t.producerId,t.id),M.emit(A.NEW_CONSUMER,{id:t.id,appData:t.appData,peerId:t.peerId})};var Yc,Qc,Xc,io,To,ko,Bd,Wd,ws,$t,xn,Dn,dr,lr,Ai,jd,kh,qy,bh,Gy,_h,Jy,wh,$y;const Ih=class{constructor({initialEnergyThreshold:t=.015,zeroCrossingThreshold:e=20,minVoiceDuration:n=3,hangoverFrames:i=5,noiseAdaptationRate:r=.95,voiceAdaptationRate:s=.99,minEnergyThreshold:a=.005,maxEnergyThreshold:c=.2,energyRatioThreshold:d=1.5,noiseHistorySize:l=50}={}){f(this,kh),f(this,bh),f(this,Yc,void 0),f(this,Qc,void 0),f(this,Xc,void 0),f(this,io,void 0),f(this,To,void 0),f(this,ko,void 0),f(this,Bd,void 0),f(this,Wd,void 0),f(this,ws,void 0),f(this,$t,void 0),f(this,xn,void 0),f(this,Dn,!1),f(this,dr,0),f(this,lr,0),f(this,Ai,[]),f(this,jd,void 0),v(this,io,t),v(this,$t,t),v(this,Yc,e),v(this,Qc,n),v(this,Xc,i),v(this,To,r),v(this,ko,s),v(this,Bd,a),v(this,Wd,c),v(this,ws,d),v(this,jd,l),v(this,xn,t/2)}get voiceDetected(){return o(this,Dn)}processAudioChunk(t){var e,n;const i=H(e=Ih,_h,Jy).call(e,t),r=H(n=Ih,wh,$y).call(n,t);return H(this,kh,qy).call(this,i),i/o(this,xn)>o(this,ws)&&i>o(this,$t)&&r>o(this,Yc)?(v(this,dr,o(this,dr)+1),v(this,lr,o(this,Xc)),o(this,dr)>=o(this,Qc)&&v(this,Dn,!0)):(v(this,dr,0),o(this,lr)>0?v(this,lr,o(this,lr)-1):o(this,Dn)&&v(this,Dn,!1),o(this,Dn)||H(this,bh,Gy).call(this,i)),o(this,Dn)}reset(){v(this,Dn,!1),v(this,dr,0),v(this,lr,0),v(this,$t,o(this,io)),v(this,xn,o(this,io)/2),v(this,Ai,[])}getThresholdInfo(){return{currentEnergyThreshold:o(this,$t),backgroundNoiseEnergy:o(this,xn),energyRatioThreshold:o(this,ws)}}};let Ph=Ih;Yc=new WeakMap,Qc=new WeakMap,Xc=new WeakMap,io=new WeakMap,To=new WeakMap,ko=new WeakMap,Bd=new WeakMap,Wd=new WeakMap,ws=new WeakMap,$t=new WeakMap,xn=new WeakMap,Dn=new WeakMap,dr=new WeakMap,lr=new WeakMap,Ai=new WeakMap,jd=new WeakMap,kh=new WeakSet,qy=function(t){o(this,Dn)?v(this,$t,o(this,ko)*o(this,$t)+(1-o(this,ko))*t):v(this,$t,o(this,To)*o(this,$t)+(1-o(this,To))*(o(this,xn)*o(this,ws))),v(this,$t,Math.max(o(this,Bd),Math.min(o(this,Wd),o(this,$t))))},bh=new WeakSet,Gy=function(t){if(t<o(this,$t)*1.2)if(o(this,Ai).push(t),o(this,Ai).length>o(this,jd)&&o(this,Ai).shift(),o(this,Ai).length>=10){const e=[...o(this,Ai)].sort((i,r)=>i-r),n=Math.floor(e.length/2);v(this,xn,e[n])}else v(this,xn,.95*o(this,xn)+.05*t)},_h=new WeakSet,Jy=function(t){return Math.sqrt(t.map(e=>e*e).reduce((e,n)=>e+n)/t.length)},wh=new WeakSet,$y=function(t){let e=0;for(let n=1;n<t.length;n+=1)(t[n]>=0&&t[n-1]<0||t[n]<0&&t[n-1]>=0)&&(e+=1);return e},f(Ph,_h),f(Ph,wh);const jN=60,HN=400;var ur,hr,As,ro,Pr,so,bo,Hd,pr,us,_o,Ch,Ky,Zc,Rh,Mh,zy,pu,$g,mu,Kg;const wo=class{constructor(t){f(this,Ch),f(this,Mh),f(this,ur,void 0),f(this,hr,void 0),f(this,As,void 0),f(this,ro,void 0),f(this,Pr,void 0),f(this,so,void 0),f(this,bo,void 0),f(this,Hd,void 0),f(this,pr,void 0),f(this,us,void 0),f(this,_o,void 0),this.reportRequest=t,v(this,ro,new AudioContext),v(this,Pr,o(this,ro).createAnalyser()),o(this,Pr).fftSize=2048,v(this,Hd,new Ph)}set producerId(t){v(this,As,t)}set audioTrack(t){v(this,so,t);const e=new MediaStream;e.addTrack(o(this,so)),o(this,ro).createMediaStreamSource(e).connect(o(this,Pr))}start(){o(this,ur)&&Ts(o(this,ur)),v(this,ur,fd(()=>u(this,null,function*(){var t;if(!o(this,so)||!o(this,As))return;const{energy:e}=H(this,Ch,Ky).call(this),n=H(t=wo,Zc,Rh).call(t,e);let i=.9;o(this,_o)!==n&&o(this,_o)?i=.9:n?i=.3:i=.5,v(this,bo,(o(this,bo)||0)*(1-i)+e*i)}),jN)),o(this,hr)&&Ts(o(this,hr)),v(this,hr,fd(H(this,Mh,zy).bind(this),HN))}stop(){o(this,ur)&&Ts(o(this,ur)),o(this,hr)&&Ts(o(this,hr))}};let ed=wo;ur=new WeakMap,hr=new WeakMap,As=new WeakMap,ro=new WeakMap,Pr=new WeakMap,so=new WeakMap,bo=new WeakMap,Hd=new WeakMap,pr=new WeakMap,us=new WeakMap,_o=new WeakMap,Ch=new WeakSet,Ky=function(){var t,e;const n=new Float32Array(o(this,Pr).frequencyBinCount);o(this,Pr).getFloatTimeDomainData(n);const i=o(this,Hd).processAudioChunk(n),r=H(t=wo,pu,$g).call(t,n),s=H(e=wo,mu,Kg).call(e,r);return(!o(this,pr)||s<o(this,pr))&&v(this,pr,s),(!o(this,us)||s>o(this,us))&&v(this,us,s),{energy:(s-o(this,pr))/(o(this,us)-o(this,pr))*10||0,isVoice:i}},Zc=new WeakSet,Rh=function(t){return t<5},Mh=new WeakSet,zy=function(t=o(this,bo)){var e;if(!o(this,As)||!t)return;const n={producerId:o(this,As),energy:Math.round(t),silent:H(e=wo,Zc,Rh).call(e,t)};v(this,_o,n.silent),this.reportRequest(n)},pu=new WeakSet,$g=function(t){return Math.sqrt(t.reduce((e,n)=>e+n*n,0)/t.length)},mu=new WeakSet,Kg=function(t){const e=Math.log10(t);return Math.round(e)},f(ed,Zc),f(ed,pu),f(ed,mu);const qN=()=>{const t=new window.AudioContext,e=t.createOscillator();e.type="triangle",e.frequency.setValueAtTime(20,t.currentTime);const n=t.createGain();n.gain.setValueAtTime(0,t.currentTime),e.connect(n);const i=t.createMediaStreamDestination();return n.connect(i),e.start(),i.stream.getAudioTracks()[0]},GN=()=>{var t,e;const n=new MediaStream().getVideoTracks()[0],i=document.createElement("canvas");i.height=(t=n==null?void 0:n.getSettings().height)!=null?t:720,i.width=(e=n==null?void 0:n.getSettings().width)!=null?e:1280;const r=i.getContext("2d");return r.fillStyle="black",r.fillRect(0,0,i.width,i.height),setInterval(()=>{r.fillStyle="black",r.fillRect(0,0,i.width,i.height)},1e3),i.captureStream().getVideoTracks()[0]};var JN=Object.defineProperty,$N=Object.getOwnPropertyDescriptor,he=(t,e,n,i)=>{for(var r=i>1?void 0:i?$N(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&JN(e,n,r),r};const Cn=["video/VP9","video/VP8"];var td,nd,bt,J,ao,mr,Lt,hs,ps,gr,id,wi,oo,ms,gs,xt,nn,fr,fs,ht,_t,vs,co,rd,Ah,sd,Dh;class ue{constructor(e,n,i){f(this,fr),f(this,ht),f(this,vs),f(this,rd),f(this,sd),m(this,"context"),m(this,"authToken"),m(this,"e2ee"),f(this,td,void 0),f(this,nd,void 0),f(this,bt,void 0),f(this,J,void 0),f(this,ao,void 0),f(this,mr,void 0),f(this,Lt,void 0),f(this,hs,void 0),f(this,ps,void 0),f(this,gr,void 0),f(this,id,void 0),f(this,wi,void 0),m(this,"maxPreferredStreams"),f(this,oo,void 0),f(this,ms,void 0),f(this,gs,void 0),f(this,xt,void 0),f(this,nn,void 0),m(this,"partialJoinRoomPromise");var r,s;this.context=e;const{socket:a}=i;this.mediaJoined=!1,v(this,ms,new Map([["video/VP9",new Set],["video/VP8",new Set]])),v(this,gs,new Map([["video/VP9",new Set],["video/VP8",new Set]])),v(this,mr,n),v(this,bt,a),v(this,hs,!1),v(this,J,new WN(e,a,n)),v(this,Lt,o(this,J).events),this.maxPreferredStreams=6,v(this,wi,new Set),v(this,xt,new Map),v(this,ps,!1),v(this,gr,new Nd),n===it.CF&&v(this,nn,new ed(o(this,J).socketHandler.audioActivity.bind(o(this,J).socketHandler))),this.e2ee=(s=(r=e.getValue("modules").e2ee)==null?void 0:r.enabled)!=null?s:!1,this.handleSocketEvents(),this.handleCallstatsEvents(),v(this,id,Id(()=>u(this,null,function*(){if(!o(this,fr,fs).mediaJoinAttempted)return;const{roomJoined:c}=yield this.joinRoom(o(this,nd),o(this,td),{},!0,!0);c&&(M.emit(A.RESET_PRODUCER_STATE),M.emit(A.ROOM_NODE_RECONNECTED))}),5e3,{leading:!0,maxWait:1e3}))}get peerId(){return this.context.getValue("peerId")}get mediaJoined(){return o(this,fr,fs).mediaJoined}set mediaJoined(e){o(this,fr,fs).mediaJoined=e}reset(e=!0){o(this,J).closeAllProducers(),o(this,J).closeAllConsumers(),o(this,wi).clear(),e&&(this.partialJoinRoomPromise=void 0,o(this,gr).stop(),o(this,J).stopAllTransports(),o(this,J).reset(),v(this,gr,new Nd))}joinRoom(e,n){return u(this,arguments,function*(i,r,s={},a=!1,c=!1){o(this,fr,fs).mediaJoinAttempted=!0,v(this,hs,!0),this.reset(a);const d=dt().ipInfo;if(d!=null&&d.loc&&!o(this,oo)){const h=d.loc.split(",");v(this,oo,{latitude:parseFloat(h[0]),longitude:parseFloat(h[1])})}let l;try{return l=yield o(this,gr).push(()=>this._joinRoom(i,r,s,c,o(this,oo)),"joinRoom"),l}catch{l={roomJoined:!1}}return l.roomJoined||M.emit(A.ROOM_NODE_FAILED),l})}_partialJoinRoom(e,n,i=!1,r=void 0){return u(this,null,function*(){var s;const{ipInfo:a}=dt();let c=r;if(a!=null&&a.loc&&!r){const[S,b]=a.loc.split(",").map(parseFloat);c={latitude:S,longitude:b}}const d=(s=X.getValue(re.FORCE_VIDEO_CODEC))==null?void 0:s.toString(),l=PN(d);v(this,ao,l),this.maxPreferredStreams=this.context.getValue("maxPreferredStreams"),yield yp((S,b)=>u(this,null,function*(){if(!o(this,bt).isConnected){b(new Error("socket is not connected"));return}S>0&&p.warn(`retrying sending join room request, count: ${S}`);try{yield o(this,J).socketHandler.joinRoom(n,e,l,i,c)}catch(w){throw p.error("failed to send join room request, error:",{error:w}),w}}),{delayTime:1e3,strategy:"exponential",maxRetryCount:X.hasFeature(re.ENABLE_HIVE_INFINITE_RETRIES)?1/0:3});const h="video/VP8",g=o(this,mr)!==it.HIVE&&X.hasFeature(re.PRECREATE_PRODUCERS)?[{type:ge.MIC,kind:"audio",options:H(this,rd,Ah).call(this,qN()),onClose:()=>this.disableMic()},{type:ge.WEBCAM,kind:"video",options:H(this,sd,Dh).call(this,GN(),h),onClose:()=>{this.disableWebcam(h)}}]:[],y=yield o(this,J).setupTransports({send:!0,recv:!0},g);y!=null&&y.length&&g.forEach((S,b)=>{o(this,xt).set(S.type,Promise.resolve(y[b].id))})})}partialJoinRoom(e,n,i=!1,r=void 0){return u(this,null,function*(){return this.partialJoinRoomPromise=o(this,gr).push(()=>this._partialJoinRoom(e,n,i,r)),this.partialJoinRoomPromise})}_joinRoom(e,n){return u(this,arguments,function*(i,r,s={},a=!1,c=null){v(this,nd,i);try{this.partialJoinRoomPromise?yield this.partialJoinRoomPromise:yield this._partialJoinRoom(i,r,a,c)}catch(d){p.error("error in partial join room",{error:d})}finally{this.partialJoinRoomPromise=void 0}try{return navigator.product!=="ReactNative"&&setTimeout(()=>u(this,null,function*(){const d={userId:this.context.getValue("userId"),peerId:this.peerId,roomUUID:r,roomViewType:"groupCall",deviceInfo:K(V({},Ce.getDeviceInfo()),{userAgent:navigator.userAgent,memory:navigator.deviceMemory,cpus:navigator.hardwareConcurrency}),sdkName:this.context.getValue("sdkName"),sdkVersion:this.context.getValue("sdkVersion"),metaData:{},permissions:{}};$.roomJoined(d)})),{roomJoined:yield this.completeJoinRoom()}}catch(d){return p.error("error on sending join room request",{error:d}),{roomJoined:!1}}})}completeJoinRoom(){return u(this,null,function*(){try{this.mediaJoined=!0;const{maxPreferredStreams:e,roomState:n}=yield o(this,J).socketHandler.notifySelfJoinComplete();return v(this,td,n.roomUuid),v(this,ps,!0),v(this,hs,!1),this.maxPreferredStreams=e!=null?e:6,!0}catch(e){return p.error("error on completing join room:",{error:e}),this.mediaJoined=!1,!1}})}leaveRoom(){return u(this,null,function*(){o(this,J).stopAllTransports(),v(this,ps,!1),o(this,fr,fs).mediaJoinAttempted=!1;const e={closeRoom:!1};o(this,bt).sendMessagePromise(o(this,Lt).leaveRoom,VP.toBinary(e)).then(n=>{var i;(i=kC.fromBinary(n.payload))!=null&&i.closed||p.warn("weird state on peer closed and should not happen")}).catch(n=>{p.error("error on sending leave room request",{error:n})}),$.callEnded(),E.destruct()})}getConsumers(){return o(this,J).consumers}activatePeers(e){return u(this,null,function*(){return this.createConsumers(e)})}deactivatePeers(e,n="default"){return u(this,null,function*(){const i=new Set;e.forEach(s=>{s.screenShare&&s.kind==="video"&&i.add(s.producingPeerId)});const r=n==="default"?e.filter(s=>!i.has(s.producingPeerId)).filter(s=>s.kind!=="audio"):e;yield Promise.all(r.map(s=>{const a=o(this,J).producerIdToConsumerIdMap.get(s.producerId);if(!a){p.warn(`consumer not found in deactivate producers: ${s.producerId}`);return}return o(this,J).closeConsumer(a)}))})}createConsumers(e){return u(this,null,function*(){return e.length===0?Promise.resolve():o(this,J).createConsumers(e)})}closeConsumers(e){return u(this,null,function*(){if(!e.length)return;const n=e.reduce((i,r)=>{const s=o(this,J).producerIdToConsumerIdMap.get(r.producerId);return s?(i.push(s),i):(p.warn(`consumer not found in deactivate producers: ${r.producerId}`),i)},[]);yield o(this,J).closeConsumers(n)})}_shareWebcam(e,n){return u(this,null,function*(){const i=n==="video/VP9"?ge.WEBCAM:ge.WEBCAM_BACKUP,r=H(this,ht,_t).call(this,i);if(r){const h=yield r;if(o(this,J).producers.has(h)){const g=o(this,J).producers.get(h);if(!g.closed&&!navigator.isReactNative)return yield g.replaceTrack({track:e}),yield this.resumeWebcam(i),e;yield this.disableWebcam(n)}return this._shareWebcam(e,n)}const s=H(this,sd,Dh).call(this,e,n),a=Cd(this.context,"disableSimulcast"),c=o(this,mr)===it.CF?re.ENABLE_CF_SIMULCAST:re.ENABLE_HIVE_SIMULCAST;!a&&X.hasFeature(c)?(p.info(`Simulcast enabled for SFU: ${o(this,mr)}`),s.encodings=TO(e)):p.info(`Simulcast disabled for webcam producer, SFU: ${o(this,mr)}`),X.hasFeature(re.TRACK_HINT)&&(s.track.contentHint=X.getValue(re.TRACK_HINT));const d=()=>{p.info("Disabling video due to the producer closure"),o(this,xt).delete(i)},l=o(this,J).createProducer(s,d);return H(this,vs,co).call(this,i,l.then(h=>h.id)),l.then(h=>h.track)})}shareWebcam(e){return u(this,null,function*(){if(e===void 0)return null;if(X.hasFeature(re.FORCE_VIDEO_CODEC)){const n=X.getValue(re.FORCE_VIDEO_CODEC).toString();if(n)return p.debug(`Calling _shareWebcam with forced video codec: ${n}`),this._shareWebcam(e,n)}return yield Promise.all(Cn.map(n=>{var i,r;return((r=(i=o(this,ao).sender)==null?void 0:i.video)==null?void 0:r.codecs.findIndex(s=>s.mimeType===n))>=0&&o(this,gs).get(n).size>0?(p.debug(`Calling _shareWebcam with video codec: ${n}`),this._shareWebcam(e,n)):e})),e})}shareScreen(e){return u(this,null,function*(){const{video:n,audio:i}=e;if(n===void 0)return;const r={track:n,codecOptions:[{name:"VP8"}],appData:{screenShare:!0,e2ee:this.e2ee,supportsRemoteControl:Ce.isElectron()},stopTracks:!1},s=()=>{p.info("Disabling screenShare due to the producer closure"),o(this,xt).delete(ge.SCREENSHARE_VIDEO),o(this,xt).delete(ge.SCREENSHARE_AUDIO)},a=o(this,J).createProducer(r,s);H(this,vs,co).call(this,ge.SCREENSHARE_VIDEO,a.then(d=>d.id));let c;if(i){const d={track:i,codecOptions:[{name:"opus"}],appData:{screenShare:!0,e2ee:this.e2ee,supportsRemoteControl:Ce.isElectron()},stopTracks:!1,zeroRtpOnPause:!0},l=()=>{};c=o(this,J).createProducer(d,l),H(this,vs,co).call(this,ge.SCREENSHARE_AUDIO,c.then(h=>h.id))}yield Promise.all([a,c||Promise.resolve()]),$.screenShareStart()})}shareMic(e){return u(this,null,function*(){try{if(e===void 0)throw new Ct("track undefined");const n=H(this,ht,_t).call(this,ge.MIC);if(n){const a=yield n;if(o(this,J).producers.has(a)){const c=o(this,J).producers.get(a);if(!c.closed&&!navigator.isReactNative){yield c.replaceTrack({track:e}),yield this.resumeMic(),o(this,nn)&&(o(this,nn).audioTrack=e,o(this,nn).producerId=a,o(this,nn).start());return}yield o(this,J).closeProducer(a,{stopTrack:!1})}yield this.shareMic(e);return}const i=H(this,rd,Ah).call(this,e),r=()=>{o(this,xt).delete(ge.MIC)},s=o(this,J).createProducer(i,r);H(this,vs,co).call(this,ge.MIC,s.then(a=>a.id)),yield s.then(a=>{o(this,nn)&&(o(this,nn).audioTrack=a.track,o(this,nn).producerId=a.id,o(this,nn).start())})}catch(n){throw new P(n)}})}pauseMic(){return u(this,null,function*(){const e=yield H(this,ht,_t).call(this,ge.MIC),n=o(this,J).producers.get(e);if(!n){p.error("pauseMic::could_not_find_mic_producer");return}if(n.paused){p.info("pauseMic::mic_producer_already_paused");return}n.pause();const i={producerId:n.id,pause:!0};o(this,bt).sendMessage(o(this,Lt).toggleProducer,tc.toBinary(i))})}pauseWebcam(){return u(this,null,function*(){const e=yield H(this,ht,_t).call(this,ge.WEBCAM),n=yield H(this,ht,_t).call(this,ge.WEBCAM_BACKUP),i=o(this,J).producers.get(e),r=o(this,J).producers.get(n);if(!i&&!r){p.error("pauseWebcam::could_not_find_webcam_producer");return}const s=a=>{const c={producerId:a.id,pause:!0};o(this,bt).sendMessage(o(this,Lt).toggleProducer,tc.toBinary(c))};i&&(i.pause(),s(i)),r&&(r.pause(),s(r))})}resumeMic(){return u(this,null,function*(){const e=yield H(this,ht,_t).call(this,ge.MIC),n=o(this,J).producers.get(e);if(!n){p.error("resumeMic::could_not_find_mic_producer");return}if(!n.pause){p.info("resumeMic::mic_producer_already_resumed");return}n.resume(),n.appData.e2ee&&M.emit(A.E2EE_ACTIVE_PRODUCER,n);const i={producerId:n.id,pause:!1};o(this,bt).sendMessage(o(this,Lt).toggleProducer,tc.toBinary(i))})}resumeWebcam(){return u(this,arguments,function*(e=ge.WEBCAM){const n=yield H(this,ht,_t).call(this,e),i=o(this,J).producers.get(n);if(!i){p.error("resumeWebcam::could_not_find_webcam_producer");return}if(!i.paused){p.info("resumeWebcam::webcam_producer_already_resumed");return}i.resume(),i.appData.e2ee&&M.emit(A.E2EE_ACTIVE_PRODUCER,i);const r={producerId:i.id,pause:!1};o(this,bt).sendMessage(o(this,Lt).toggleProducer,tc.toBinary(r))})}disableWebcam(e){return u(this,null,function*(){const n=e==="video/VP9"?ge.WEBCAM:ge.WEBCAM_BACKUP,i=yield H(this,ht,_t).call(this,n);i&&(yield o(this,J).closeProducer(i)),o(this,xt).delete(n)})}disableMic(){return u(this,null,function*(){var e;const n=yield H(this,ht,_t).call(this,ge.MIC);n&&(yield o(this,J).closeProducer(n)),(e=o(this,nn))==null||e.stop(),o(this,xt).delete(ge.MIC)})}disableScreenShare(){return u(this,null,function*(){p.info("screen_sharing_stopped"),$.screenShareStop();const e=yield H(this,ht,_t).call(this,ge.SCREENSHARE_VIDEO),n=yield H(this,ht,_t).call(this,ge.SCREENSHARE_AUDIO);e&&(yield o(this,J).closeProducer(e)),n&&(yield o(this,J).closeProducer(n)),o(this,wi).clear(),o(this,xt).delete(ge.SCREENSHARE_VIDEO),o(this,xt).delete(ge.SCREENSHARE_AUDIO)})}muteSelf(){return u(this,null,function*(){this.pauseMic()})}unmuteSelf(){return u(this,null,function*(){})}resetVideoProducers(e,n){return u(this,null,function*(){if(e){const i=yield H(this,ht,_t).call(this,ge.WEBCAM),r=yield H(this,ht,_t).call(this,ge.WEBCAM_BACKUP);yield o(this,J).closeProducer(i,{stopTrack:!1}),yield o(this,J).closeProducer(r,{stopTrack:!1}),this.shareWebcam(e)}if(n){const i=yield H(this,ht,_t).call(this,ge.SCREENSHARE_VIDEO);yield o(this,J).closeProducer(i,{stopTrack:!1}),this.shareScreen({video:n})}})}changeDisplayName(e,n){return u(this,null,function*(){const i={displayName:e,participantId:n!=null?n:this.peerId};if(!(yield o(this,J).socketHandler.changeDisplayName(i)))throw new Error("failed to change display name!")})}kick(e){return u(this,null,function*(){const n={participantId:e};if(!(yield o(this,J).socketHandler.kickPeer(n)))throw new Error("failed to kickout the participant!")})}kickAll(){return u(this,null,function*(){if(!(yield o(this,J).socketHandler.kickAll()))throw new Error("failed to kickout all participant!")})}muteAll(e){return u(this,null,function*(){if(!(yield o(this,J).socketHandler.hostControlForAll("audio")))throw new Error("failed to mute all participant")})}muteAllVideo(){return u(this,null,function*(){if(!(yield o(this,J).socketHandler.hostControlForAll("video")))throw new Error("failed to mute all video participant")})}disableAudio(e){return u(this,null,function*(){if(!(yield o(this,J).socketHandler.hostControlForPeer(e,"audio")))throw new Error("failed to mute given participant")})}disableVideo(e){return u(this,null,function*(){if(!(yield o(this,J).socketHandler.hostControlForPeer(e,"video")))throw new Error("failed to mute video of given participant")})}pinPeer(e){return u(this,null,function*(){const n={participantId:e!=null?e:""};try{yield o(this,bt).sendMessagePromise(o(this,Lt).globalPinPeer,$P.toBinary(n))}catch(i){p.error("Error in pinning peer:",{error:i})}})}validateScreenShare(e){return this.peerId===e.peerId&&o(this,J).producers.get(e.producerId)&&o(this,wi).add(e.consumerPeerId),o(this,wi).size}switchConsumersToLayer(e,n){return u(this,null,function*(){o(this,J).switchConsumersToLayer(e,n)})}handleSocketEvents(){return u(this,null,function*(){o(this,bt).on(o(this,Lt).peerProducerCreateBroadcast,({payload:e})=>{var n,i;if(this.mediaJoined)try{const{participantId:r,producerState:s}=ZC.fromBinary(e);if(r===this.peerId)return;if(s!=null&&s.mimeType||(s.mimeType=s.kind===Vn.AUDIO?"audio/opus":"video/VP8"),s.kind===Vn.VIDEO&&!s.screenShare&&((i=(n=o(this,ao).receiver)==null?void 0:n.video)==null?void 0:i.codecs.findIndex(a=>a.mimeType===Cn[0]))>=0&&o(this,ms).get(Cn[0]).has(r)&&s.mimeType!==Cn[0]){p.warn(`Ignoring producer: ${s.producerId}`);return}p.info(`producer created broadcast: ${r}, producer state: ${s}`),M.emit(A.NEW_PRODUCER,{peerId:r,producer:K(V({},s),{kind:s.kind===Vn.AUDIO?"audio":"video",producingPeerId:r})})}catch(r){p.error("error in peer-producer-create-broadcast",{error:r})}}),o(this,bt).on(o(this,Lt).peerProducerToggleBroadcast,({payload:e})=>{if(this.mediaJoined)try{const{participantId:n,initiatorParticipantId:i,producerState:{kind:r,pause:s,producerId:a}}=ng.fromBinary(e),c=r===Vn.AUDIO?"audio":"video";if(p.info(`producer toggle broadcast: ${n}, producerId: ${a}, kind:${c}, paused:${s} payload: ${JSON.stringify(ng.fromBinary(e))}`),n===this.peerId&&i!==this.peerId&&s&&M.emit(c==="audio"?A.MUTE_SELF:A.MUTE_SELF_VIDEO),n===this.peerId)return;M.emit(A.PRODUCER_TOGGLE,{peerId:n,producerId:a,paused:s,kind:c}),Array.from(this.getConsumers().values()).filter(d=>d.producerId===a).forEach(d=>{d.paused!==s&&(p.debug(`consumer state mismatched for ${d.id}. updating consumer pause state ${d.paused} to ${s}`),s?(d.pause(),M.emit(A.CONSUMER_PAUSED,{id:d.id})):(d.resume(),M.emit(A.CONSUMER_RESUMED,{id:d.id})))})}catch(n){p.error("error in producer toggle broadcast handler",{error:n})}}),o(this,bt).on(o(this,Lt).peerLeaveBroadcast,({payload:e})=>{if(this.mediaJoined)try{const{participantId:n}=Fu.fromBinary(e);if(n===this.peerId)return;p.info(`peer left broadcast:${n}`),o(this,wi).delete(n),o(this,J).consumers.forEach(i=>{i.peerId===n&&i.close()}),M.emit(A.PEER_CLOSED,{id:n})}catch(n){p.error("error in peer left broadcast",{error:n})}}),o(this,bt).on(o(this,Lt).peerProducerCloseBroadcast,({payload:e})=>{if(this.mediaJoined)try{const{participantId:n,producerState:{producerId:i}}=nR.fromBinary(e);if(n===this.peerId)return;p.info(`producer closed broadcast:${n}`),M.emit(A.PRODUCER_CLOSED,{peerId:n,producerId:i});const r=o(this,J).producerIdToConsumerIdMap.get(i);if(!r){p.warn(`no consumer found for producer:${i}`);return}p.info(`closing consumer ${r}, producer id: ${i}`),o(this,J).closeConsumer(r).then(()=>{p.info(`closed consumer: ${r}`),o(this,J).producerIdToConsumerIdMap.delete(i),M.emit(A.CONSUMER_CLOSED,{id:r})}).catch(s=>{p.error("error closing consumer",{error:s})})}catch(n){p.error("error on producer close broadcast",{error:n})}}),o(this,bt).on(o(this,Lt).mediaRoomTerminationBroadcastResponse,()=>{!this.mediaJoined&&!o(this,hs)&&!o(this,ps)||(p.warn("media hub termination broadcast received, rejoining room"),M.emit(A.ROOM_NODE_DISCONNECTED),o(this,id).call(this))})})}handleCallstatsEvents(){$.onConsumerScore(e=>{e.forEach((n,i)=>{const r=o(this,J).consumers.get(i);r&&M.emit(A.CONSUMER_SCORE_UPDATE,{id:i,kind:r.kind,peerId:r.peerId,score:n.score,scoreStats:n})})}),$.onProducerScore(e=>{e.forEach((n,i)=>{const r=Array.from(o(this,J).producers.values()).find(s=>s.id===i);r&&M.emit(A.PRODUCER_SCORE_UPDATE,{id:i,kind:r.kind,appData:r.appData,score:n.score,scoreStats:n})})})}handlePeerCapabilities(e,n){var i,r,s,a;for(let c=0;c<=Cn.length;c+=1){const d=Cn[c];if(((r=(i=n==null?void 0:n.receiver)==null?void 0:i.video)==null?void 0:r.codecs.findIndex(l=>l.mimeType===d))>=0||c===Cn.length-1){o(this,gs).get(d).add(e);break}}for(let c=0;c<=Cn.length;c+=1){const d=Cn[c];if(((a=(s=n==null?void 0:n.sender)==null?void 0:s.video)==null?void 0:a.codecs.findIndex(l=>l.mimeType===d))>=0||c===Cn.length-1){o(this,ms).get(d).add(e);break}}}handlePeerLeaving(e){X.hasFeature(re.FORCE_VIDEO_CODEC)||(o(this,ms).forEach(n=>n.delete(e)),o(this,gs).forEach((n,i)=>{n.delete(e),n.size===0&&this.disableWebcam(i)}))}}td=new WeakMap,nd=new WeakMap,bt=new WeakMap,J=new WeakMap,ao=new WeakMap,mr=new WeakMap,Lt=new WeakMap,hs=new WeakMap,ps=new WeakMap,gr=new WeakMap,id=new WeakMap,wi=new WeakMap,oo=new WeakMap,ms=new WeakMap,gs=new WeakMap,xt=new WeakMap,nn=new WeakMap,fr=new WeakSet,fs=function(){return this.context.getValue("connectionHandler")},ht=new WeakSet,_t=function(t){return o(this,xt).get(t)},vs=new WeakSet,co=function(t,e){return o(this,xt).set(t,e)},rd=new WeakSet,Ah=function(t){return{track:t,encodings:[{priority:"high"}],codecOptions:[{name:"opus"}],appData:{e2ee:this.e2ee},stopTracks:!1,zeroRtpOnPause:!0}},sd=new WeakSet,Dh=function(t,e){return{track:t,codecOptions:[{name:e?e.split("/")[1]:"VP8"}],appData:{screenShare:!1,e2ee:this.e2ee},stopTracks:!1}};he([E.trace("MediaNodeClient.reset",{country:E.location.country})],ue.prototype,"reset",1);he([E.trace("MediaNodeClient.joinRoom")],ue.prototype,"joinRoom",1);he([E.trace("MediaNodeClient.completeJoinRoom")],ue.prototype,"completeJoinRoom",1);he([E.trace("MediaNodeClient.leaveRoom")],ue.prototype,"leaveRoom",1);he([E.trace("MediaNodeClient.activatePeers")],ue.prototype,"activatePeers",1);he([E.trace("MediaNodeClient.deactivatePeers")],ue.prototype,"deactivatePeers",1);he([E.trace("MediaNodeClient.createConsumers")],ue.prototype,"createConsumers",1);he([E.trace("MediaNodeClient.closeConsumers")],ue.prototype,"closeConsumers",1);he([E.trace("MediaNodeClient._shareWebcam")],ue.prototype,"_shareWebcam",1);he([E.trace("MediaNodeClient.shareWebcam")],ue.prototype,"shareWebcam",1);he([E.trace("MediaNodeClient.shareScreen")],ue.prototype,"shareScreen",1);he([E.trace("MediaNodeClient.shareMic")],ue.prototype,"shareMic",1);he([E.trace("MediaNodeClient.pauseMic")],ue.prototype,"pauseMic",1);he([E.trace("MediaNodeClient.pauseWebcam")],ue.prototype,"pauseWebcam",1);he([E.trace("MediaNodeClient.resumeMic")],ue.prototype,"resumeMic",1);he([E.trace("MediaNodeClient.resumeWebcam")],ue.prototype,"resumeWebcam",1);he([E.trace("MediaNodeClient.disableWebcam")],ue.prototype,"disableWebcam",1);he([E.trace("HiveClient.disableMic")],ue.prototype,"disableMic",1);he([E.trace("HiveClient.disableScreenShare")],ue.prototype,"disableScreenShare",1);he([E.trace("MediaNodeClient.muteSelf")],ue.prototype,"muteSelf",1);he([E.trace("MediaNodeClient.resetVideoProducers")],ue.prototype,"resetVideoProducers",1);he([E.trace("MediaNodeClient.changeDisplayName")],ue.prototype,"changeDisplayName",1);he([E.trace("MediaNodeClient.kickPeer")],ue.prototype,"kick",1);he([E.trace("MediaNodeClient.kickAllPeers")],ue.prototype,"kickAll",1);he([E.trace("MediaNodeClient.muteAll")],ue.prototype,"muteAll",1);he([E.trace("MediaNodeClient.muteAllVideo")],ue.prototype,"muteAllVideo",1);he([E.trace("MediaNodeClient.disableAudio")],ue.prototype,"disableAudio",1);he([E.trace("MediaNodeClient.disableVideo")],ue.prototype,"disableVideo",1);he([E.trace("MediaNodeClient.pinPeer")],ue.prototype,"pinPeer",1);he([E.trace("MediaNodeClient.validateScreenShare")],ue.prototype,"validateScreenShare",1);function Yy(t,e,n){const i=t.getValue("roomNodeClient");if(i){if(i)return i;throw new Error("Room node client already set up.")}const r=new ue(t,e,n);return t.setValue("roomNodeClient",r),r}function Qy(t){const e=t.getValue("roomNodeClient");try{e==null||e.leaveRoom()}catch{p.error("roomNodeClient::cleanupRoomNodeClient")}t.setValue("roomNodeClient",void 0)}var KN=Object.defineProperty,zN=Object.getOwnPropertyDescriptor,jr=(t,e,n,i)=>{for(var r=i>1?void 0:i?zN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&KN(e,n,r),r},Xi,Rn,St,en,ln,zg;const Xy=(zg=class{constructor(t,e,n,i){f(this,en),m(this,"self"),m(this,"authToken"),f(this,Xi,void 0),m(this,"viewType"),f(this,Rn,void 0),f(this,St,void 0);const{socket:r}=n,s=t.getValue("authToken");this.self=e,v(this,St,t),this.viewType=i,this.authToken=s,v(this,Xi,r),v(this,Rn,n),e.config.viewType!==Rt.Chat&&this.setupEvents()}get peerId(){return o(this,St).getValue("peerId")}get mediaJoined(){return o(this,St).getValue("connectionHandler").mediaJoined}static init(t,e,n,i,r){return u(this,null,function*(){const s=dt(),a=t.getValue("peerId"),c=!!t.getValue("cachedUserDetails"),d=yield st.__init__(t,n,i,r,r.name,c);if(navigator.product!=="ReactNative"){const l=!X.hasFeature(re.PRECALL_BANDWIDTH_TEST);setTimeout(()=>u(this,null,function*(){const h=yield d.getAllDevices();p.info("populated_full_device_list",{devices:JSON.stringify(h)}),$.devices("AUDIO",h==null?void 0:h.filter(g=>g.kind==="audioinput")),$.devices("VIDEO",h==null?void 0:h.filter(g=>g.kind==="videoinput")),$.devices("SPEAKER",h==null?void 0:h.filter(g=>g.kind==="audiooutput")),p.info("Callstats:: initializing");try{yield $.initialize({peerId:a,engineName:Ce.getDeviceInfo().engineName,env:t.getValue("env"),iceServers:yield s.getICEServers(),apiBase:t.getValue("apiBase"),flags:X.getAllFlags(),logger:p,apiHostnames:$v(t),skipConnectivityChecks:l}),p.info("Callstats:: initialized")}catch(g){p.error("Callstats:: initialization failed",{error:g})}}),0)}else p.info("Callstats:: Skipped initialization due to navigator product being ReactNative.");return new Xy(t,d,e,r.viewType)})}shareMediaTracks(){return u(this,null,function*(){var t;const{audioTrack:e,videoTrack:n,permissions:i,audioEnabled:r,videoEnabled:s,screenShareEnabled:a,screenShareTracks:c}=this.self;if(i.canProduceAudio&&r)try{yield o(this,en,ln).shareMic(e)}catch{this.self.disableAudio()}if(i.canProduceVideo&&s)try{const d=yield o(this,en,ln).shareWebcam(n);d&&d.id!==n.id&&X.hasFeature(re.EXP_RESHARE)&&(yield o(this,en,ln).shareWebcam(d))}catch{this.self.disableVideo()}if(i.canProduceScreenshare&&a)try{yield(t=o(this,en,ln))==null?void 0:t.shareScreen({video:c.video,audio:c.audio})}catch{this.self.disableScreenShare()}})}kickHandler(t){return u(this,null,function*(){let e="kicked";(t==null?void 0:t.kickType)==="kickAll"&&(e="ended"),this.leaveRoom(e)})}waitlistedHandler(){p.info("SelController.waitlisted"),this.self.waitlistStatus="waiting",this.self.roomState="waitlisted",this.self.emit("waitlisted")}waitlistAcceptHandler(){if(p.info("SelController.waitlistAccepted"),this.self.waitlistStatus==="accepted"){p.warn("SelfController.WAITLIST_ACCEPTED.UserAlreadyAccepted");return}this.self.waitlistStatus="accepted",this.joinRoom()}waitlistRejectedHandler(){if(p.info("SelfController.waitlistRejected"),this.self.waitlistStatus==="rejected"){p.warn("SelfController.WAITLIST_REJECTED.UserAlreadyRejected");return}this.self.waitlistStatus="rejected",this.leaveRoom("rejected")}resetSelf(t){return u(this,null,function*(){$.callEnded(),o(this,en,ln).reset(),t&&(yield this.joinRoom(t))})}setupEvents(){M.on(A.RESET_PRODUCER_STATE,()=>u(this,null,function*(){this.mediaJoined&&this.shareMediaTracks()})),M.on(A.ROOM_NODE_RECONNECTED,()=>{this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:!0})}),M.on(A.ROOM_NODE_DISCONNECTED,()=>{this.self.roomState!=="disconnected"&&(this.self.roomState="disconnected",this.self.emit("roomLeft",{state:"disconnected"}))}),M.on(A.ROOM_NODE_FAILED,()=>{this.self.roomState="failed",this.self.emit("roomLeft",{state:"failed"})}),M.on(A.SOCKET_SERVICE_RECONNECTED,({wasJoinAttempted:t})=>{t===!1&&(this.self.roomState="init"),this.resetSelf(t)}),M.on(A.SOCKET_SERVICE_DISCONNECTED,({joinAttempted:t})=>{if(this.self.roomState==="disconnected")return;let{peerId:e}=this;t&&X.hasFeature(re.REFRESH_ID_ON_DISCONNECTION)&&(e=Us()),o(this,Xi).updateURL(e),E.resetPeerId(e),dt().setHeader("dyte-tracing-id",e),Cr.remapContext(e,o(this,St)),this.self.roomState="disconnected",this.self.emit("roomLeft",{state:"disconnected"})}),M.on(A.SOCKET_SERVICE_FAILED,()=>{this.self.roomState="failed",this.self.emit("roomLeft",{state:"failed"})}),o(this,Rn).on(W.waitingRoomRequestAccepted,()=>{this.waitlistAcceptHandler()}),o(this,Rn).on(Dc.updateUserPreset,t=>{t.updatePeersPresets.forEach(e=>{e.userIds===this.self.userId&&M.emit(A.UPDATE_PERMISSIONS,e.patch)})}),o(this,Rn).on(W.waitingRoomRequestDenied,()=>{this.waitlistRejectedHandler()}),o(this,Rn).on(W.kick,()=>{this.kickHandler({kickType:"kick"})}),o(this,Rn).on(W.kickAll,()=>{this.kickHandler({kickType:"kickAll"})}),M.onAsync(A.JOIN_MEDIA_ROOM,this.joinMediaRoom.bind(this)),M.on(A.PRODUCER_SCORE_UPDATE,({score:t,kind:e,appData:n,scoreStats:i})=>{var r;const s=(r=n==null?void 0:n.screenShare)!=null?r:!1;this.self.emit("mediaScoreUpdate",{kind:e,isScreenshare:s,score:t,participantId:this.self.id,scoreStats:i})}),M.on(A.MUTE_SELF,()=>u(this,null,function*(){this.self.audioEnabled&&(yield this.self.disableAudio(),$.audioOff())})),M.on(A.MUTE_SELF_VIDEO,()=>u(this,null,function*(){this.self.videoEnabled&&(yield this.self.disableVideo(),$.videoOff())})),M.onAsync(A.LEAVE_MEDIA_ROOM,this.leaveMediaRoom.bind(this)),M.on(A.PIP_HANGUP,this.leaveRoom.bind(this))}joinRoom(t=!1){return u(this,null,function*(){try{const{peer:e}=yield o(this,Rn).joinRoom(this.self);o(this,Rn).socket.flush();const n=up(e.stageType);if(o(this,St).setValue("stageStatus",n,!1),e.waitlisted){this.waitlistedHandler();return}yield this.joinMediaRoom(t),o(this,St).notify("stageStatus")}catch(e){throw p.error("Error in joinRoom",{error:e}),e}})}leaveRoom(t="left"){return u(this,null,function*(){var e,n;if(t==="rejected"){try{(e=o(this,Xi))==null||e.disconnect()}catch{p.error("SelfController::leaveRoom::socketDisconnect")}this.self.roomState=t,this.self.emit("roomLeft",{state:t});return}this.self.setIsPinned(!1),o(this,St).setValue("stageStatus","OFF_STAGE",!1),yield this.leaveMediaRoom(t),o(this,St).notify("stageStatus");try{(n=o(this,Xi))==null||n.disconnect()}catch{p.error("SelfController::leaveRoom::socketDisconnect")}Qy(o(this,St)),Od.cleanup(),this.self.roomState=t,this.self.emit("roomLeft",{state:t})})}joinMediaRoom(t=!1){return u(this,null,function*(){var e,n;const{peerId:i,viewType:r,meetingId:s,stageStatus:a,roomNodeOptions:c}=o(this,St).getAllValues(),{sfu:d}=c;try{if(r===Rt.Livestream){if(a!=="ON_STAGE"){this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:t});return}Yy(o(this,St),d,{socket:o(this,Xi),peerId:i})}const{roomJoined:l}=(n=yield(e=o(this,en,ln))==null?void 0:e.joinRoom(this.self.name,s,{audio:this.self.audioEnabled,video:this.self.videoEnabled,screen:this.self.screenShareEnabled},t,t))!=null?n:{};if(!l)return;a==="ON_STAGE"&&(yield this.shareMediaTracks()),this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:t})}catch(l){throw p.error("Error:SelfController.mediaRoomJoin",l),new P("Error: could not join media room","0002")}})}leaveMediaRoom(t){return u(this,null,function*(){const e=o(this,St).getValue("viewType");t!=="connected-meeting"&&(yield this.cleanupSelf()),!(t==="stageLeft"&&e===Rt.Webinar)&&o(this,en,ln)&&(o(this,en,ln).mediaJoined&&t!=="disconnected"&&(yield o(this,en,ln).leaveRoom()),!(t==="stageLeft"&&e===Rt.Livestream)&&(o(this,en,ln).mediaJoined=!1))})}cleanupSelf(){return u(this,null,function*(){yield this.self.disableAudio(),yield this.self.disableVideo(),yield this.self.disableScreenShare(),this.self.cleanUpTracks(),this.self.destructMediaHandler(),navigator.isReactNative||this.self.removeDocumentEventListeners()})}},Xi=new WeakMap,Rn=new WeakMap,St=new WeakMap,en=new WeakSet,ln=function(){return o(this,St).getValue("roomNodeClient")},zg);let Gi=Xy;jr([E.trace("SelfController.resetSelf")],Gi.prototype,"resetSelf",1);jr([E.trace("SelfController.setupEvents")],Gi.prototype,"setupEvents",1);jr([E.trace("SelfController.joinRoom")],Gi.prototype,"joinRoom",1);jr([E.trace("SelfController.leaveRoom")],Gi.prototype,"leaveRoom",1);jr([E.trace("SelfController.joinMediaRoom")],Gi.prototype,"joinMediaRoom",1);jr([E.trace("SelfController.leaveMediaRoom")],Gi.prototype,"leaveMediaRoom",1);jr([E.trace("SelfController.init")],Gi,"init",1);var ad;class YN{constructor(e){f(this,ad,void 0),v(this,ad,e)}on(e,n){let i;e===W.roomPeerCount?i=sg.fromBinary.bind(sg):i=fg.fromBinary.bind(fg),o(this,ad).on(e,({payload:r})=>{const s=i(r);return n(s)})}}ad=new WeakMap;var od;class QN{constructor(e){f(this,od,void 0),v(this,od,e)}on(e,n){let i,r;switch(e){case W.transcript:{i=Gl.fromBinary.bind(Gl),r=Gl.create();break}default:{p.debug("AISocketHandler switch case hit default, event not accounted for.");break}}o(this,od).on(e,({payload:s})=>{let a=r;try{a=i(s)}catch(c){p.error("chatSocketHandler::on::binary_decode_error",{error:c})}return n(a)})}}od=new WeakMap;var XN=Object.defineProperty,ZN=Object.getOwnPropertyDescriptor,kp=(t,e,n,i)=>{for(var r=i>1?void 0:i?ZN(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&XN(e,n,r),r},Ii;class vl{constructor(e){f(this,Ii,void 0),v(this,Ii,e)}getPolls(){return o(this,Ii).sendMessagePromise(Yn.getPolls)}createPoll(e,n,i=!1,r=!1){const s={anonymous:i,hideVotes:r,question:e,options:n};return o(this,Ii).sendMessage(Yn.createPoll,G1.toBinary(s))}votePoll(e,n){const i={index:n,pollId:e};return o(this,Ii).sendMessage(Yn.votePoll,$1.toBinary(i))}on(e,n){let i,r;switch(e){case Yn.updatePoll:case Yn.createPoll:case Yn.votePoll:{i=Ql.fromBinary.bind(Ql),r=Ql.create();break}}o(this,Ii).on(e,({payload:s})=>{let a=r;try{a=i(s)}catch(c){p.error("pollSocketHandler::on::binary_decode_error",{error:c})}return n(a)})}removeListeners(e){o(this,Ii).removeListeners(e)}}Ii=new WeakMap;kp([E.trace("PollSocketHandler.getPolls")],vl.prototype,"getPolls",1);kp([E.trace("PollSocketHandler.createPoll")],vl.prototype,"createPoll",1);kp([E.trace("PollSocketHandler.votePoll")],vl.prototype,"votePoll",1);var Jt;class eL{constructor(e){f(this,Jt,void 0),v(this,Jt,e)}getStageRequests(){return u(this,null,function*(){const{payload:e}=yield o(this,Jt).sendMessagePromise(W.getStageRequests);return e?Yl.fromBinary(e):{stageRequests:[]}})}requestAccess(){o(this,Jt).sendMessage(W.requestStageAccess)}cancelRequestAccess(){o(this,Jt).sendMessage(W.cancelStageRequest)}grantAccess(e){return u(this,null,function*(){const n={userIds:e};o(this,Jt).sendMessage(W.grantStageAccess,L1.toBinary(n))})}denyAccess(e){return u(this,null,function*(){const n={userIds:e};o(this,Jt).sendMessage(W.denyStageAccess,V1.toBinary(n))})}joinStage(){return o(this,Jt).sendMessagePromise(W.joinStage,void 0,void 0,W.peerStageStatusUpdate)}leaveStage(e){const n={userIds:[e]};return o(this,Jt).sendMessagePromise(W.leaveStage,yg.toBinary(n),void 0,W.peerStageStatusUpdate)}kick(e){const n={userIds:e};return o(this,Jt).sendMessagePromise(W.leaveStage,yg.toBinary(n))}on(e,n){let i;switch(e){case W.grantStageAccess:case W.denyStageAccess:{i=void 0;break}case W.getStagePeers:{i=vg.fromBinary.bind(vg);break}case W.getStageRequests:case W.requestStageAccess:case W.cancelStageRequest:{i=Yl.fromBinary.bind(Yl);break}case W.peerStageStatusUpdate:{i=rg.fromBinary.bind(rg);break}}o(this,Jt).on(e,({payload:r,id:s})=>{if(!r||!i)return n(void 0,s);const a=i(r);return n(a,s)})}getPeerInfo(e){return u(this,null,function*(){const n=yield o(this,Jt).sendMessagePromise(W.getPeerInfo,ny.toBinary({peerId:e}));return ts.fromBinary(n.payload)})}}Jt=new WeakMap;var tt;class tL{constructor(e){f(this,tt,void 0),v(this,tt,e)}addPlugin(e,n){o(this,tt).sendMessage(z.addPlugin,XA.toBinary({pluginId:e,staggered:n}))}removePlugin(e){o(this,tt).sendMessage(z.removePlugin,e1.toBinary({pluginId:e,staggered:!1}))}getActivePlugins(){return u(this,null,function*(){const{payload:e}=yield o(this,tt).sendMessagePromise(z.getPlugins);return e?b1.fromBinary(e):{plugins:[]}})}customPluginEventToRoom(e,n,i){const r={pluginId:e,pluginData:new TextEncoder().encode(JSON.stringify(n))};o(this,tt).sendMessage(z.customPluginEventToRoom,l1.toBinary(r),i)}customPluginEventToPeers(e,n,i,r){const s={pluginId:e,peerIds:n,pluginData:new TextEncoder().encode(JSON.stringify(i))};o(this,tt).sendMessage(z.customPluginEventToPeers,h1.toBinary(s),r)}enablePluginForRoom(e,n){o(this,tt).sendMessage(z.enablePluginForRoom,n1.toBinary({pluginId:e}),n)}enablePluginForPeers(e,n,i){o(this,tt).sendMessage(z.enablePluginForPeers,a1.toBinary({pluginId:e,peerIds:n}),i)}disablePluginForRoom(e,n){o(this,tt).sendMessage(z.disablePluginForRoom,r1.toBinary({pluginId:e}),n)}disablePluginForPeers(e,n,i){o(this,tt).sendMessage(z.disablePluginForPeers,c1.toBinary({pluginId:e,peerIds:n}),i)}storeInsertKeys(e,n,i,r){const s={pluginId:e,storeName:n,insertKeys:i.map(a=>({storeKey:a.key,payload:new TextEncoder().encode(JSON.stringify(a.payload))}))};o(this,tt).sendMessage(z.storeInsertKeys,hg.toBinary(s),r)}storeGetKeys(e,n,i,r){const s={pluginId:e,storeName:n,getKeys:i.map(a=>({storeKey:a.key}))};o(this,tt).sendMessage(z.storeGetKeys,f1.toBinary(s),r)}storeDeleteKeys(e,n,i,r){const s={pluginId:e,storeName:n,deleteKeys:i.map(a=>({storeKey:a.key}))};o(this,tt).sendMessage(z.storeDeleteKeys,y1.toBinary(s),r)}storeDelete(e,n,i){o(this,tt).sendMessage(z.storeDelete,E1.toBinary({pluginId:e,storeName:n}),i)}getPluginDataOld(e,n){p.info("getPluginDataOld",{plugin:{id:e,storeName:n}})}storePluginDataOld(e,n,i){const r={pluginId:e,storeName:n,insertKeys:[{storeKey:i.key,payload:new TextEncoder().encode(JSON.stringify(i))}]};o(this,tt).sendMessage(z.storeInsertKeys,hg.toBinary(r))}on(e,n){let i;switch(e){case z.addPlugin:case z.enablePluginForPeers:case z.enablePluginForRoom:{i=Hu.fromBinary.bind(Hu);break}case z.removePlugin:case z.disablePluginForPeers:case z.disablePluginForRoom:{i=pg.fromBinary.bind(pg);break}case z.customPluginEventToPeers:case z.customPluginEventToRoom:{i=gg.fromBinary.bind(gg);break}case z.storeInsertKeys:case z.storeGetKeys:case z.storeDeleteKeys:case z.storeDelete:{i=mg.fromBinary.bind(mg);break}}o(this,tt).on(e,({payload:r,id:s})=>{const a=i(r);return n(a,s)})}}tt=new WeakMap;var nL=Object.defineProperty,iL=(t,e,n)=>e in t?nL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,rL=(t,e,n)=>(iL(t,typeof e!="symbol"?e+"":e,n),n),bp=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},x=(t,e,n)=>(bp(t,e,"read from private field"),n?n.call(t):e.get(t)),Ie=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},me=(t,e,n,i)=>(bp(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),De=(t,e,n)=>(bp(t,e,"access private method"),n),qd={},sL={get exports(){return qd},set exports(t){qd=t}},Ds=typeof Reflect=="object"?Reflect:null,Yg=Ds&&typeof Ds.apply=="function"?Ds.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)},cd;Ds&&typeof Ds.ownKeys=="function"?cd=Ds.ownKeys:Object.getOwnPropertySymbols?cd=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:cd=function(t){return Object.getOwnPropertyNames(t)};function aL(t){console&&console.warn&&console.warn(t)}var Zy=Number.isNaN||function(t){return t!==t};function ve(){ve.init.call(this)}sL.exports=ve;qd.once=lL;ve.EventEmitter=ve;ve.prototype._events=void 0;ve.prototype._eventsCount=0;ve.prototype._maxListeners=void 0;var Qg=10;function yl(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(ve,"defaultMaxListeners",{enumerable:!0,get:function(){return Qg},set:function(t){if(typeof t!="number"||t<0||Zy(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Qg=t}});ve.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};ve.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Zy(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function eS(t){return t._maxListeners===void 0?ve.defaultMaxListeners:t._maxListeners}ve.prototype.getMaxListeners=function(){return eS(this)};ve.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var i=t==="error",r=this._events;if(r!==void 0)i=i&&r.error===void 0;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=r[t];if(c===void 0)return!1;if(typeof c=="function")Yg(c,this,e);else for(var d=c.length,l=sS(c,d),n=0;n<d;++n)Yg(l[n],this,e);return!0};function tS(t,e,n,i){var r,s,a;if(yl(n),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),a=s[e]),a===void 0)a=s[e]=n,++t._eventsCount;else if(typeof a=="function"?a=s[e]=i?[n,a]:[a,n]:i?a.unshift(n):a.push(n),r=eS(t),r>0&&a.length>r&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=a.length,aL(c)}return t}ve.prototype.addListener=function(t,e){return tS(this,t,e,!1)};ve.prototype.on=ve.prototype.addListener;ve.prototype.prependListener=function(t,e){return tS(this,t,e,!0)};function oL(){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 nS(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},r=oL.bind(i);return r.listener=n,i.wrapFn=r,r}ve.prototype.once=function(t,e){return yl(e),this.on(t,nS(this,t,e)),this};ve.prototype.prependOnceListener=function(t,e){return yl(e),this.prependListener(t,nS(this,t,e)),this};ve.prototype.removeListener=function(t,e){var n,i,r,s,a;if(yl(e),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===e||n.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||e));else if(typeof n!="function"){for(r=-1,s=n.length-1;s>=0;s--)if(n[s]===e||n[s].listener===e){a=n[s].listener,r=s;break}if(r<0)return this;r===0?n.shift():cL(n,r),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||e)}return this};ve.prototype.off=ve.prototype.removeListener;ve.prototype.removeAllListeners=function(t){var e,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var r=Object.keys(n),s;for(i=0;i<r.length;++i)s=r[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=n[t],typeof e=="function")this.removeListener(t,e);else if(e!==void 0)for(i=e.length-1;i>=0;i--)this.removeListener(t,e[i]);return this};function iS(t,e,n){var i=t._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?n?[r.listener||r]:[r]:n?dL(r):sS(r,r.length)}ve.prototype.listeners=function(t){return iS(this,t,!0)};ve.prototype.rawListeners=function(t){return iS(this,t,!1)};ve.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):rS.call(t,e)};ve.prototype.listenerCount=rS;function rS(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}ve.prototype.eventNames=function(){return this._eventsCount>0?cd(this._events):[]};function sS(t,e){for(var n=new Array(e),i=0;i<e;++i)n[i]=t[i];return n}function cL(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function dL(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function lL(t,e){return new Promise(function(n,i){function r(a){t.removeListener(e,s),i(a)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",r),n([].slice.call(arguments))}aS(t,e,s,{once:!0}),e!=="error"&&uL(t,r,{once:!0})})}function uL(t,e,n){typeof t.on=="function"&&aS(t,"error",e,n)}function aS(t,e,n,i){if(typeof t.on=="function")i.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function r(s){i.once&&t.removeEventListener(e,r),n(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}class hL extends T{constructor(){super("message.v1.SocketMessage",[{no:1,name:"event",kind:"scalar",T:13},{no:2,name:"id",kind:"scalar",opt:!0,T:9},{no:3,name:"payload",kind:"scalar",opt:!0,T:12},{no:4,name:"metadata",kind:"scalar",opt:!0,T:12}])}}const Xg=new hL;class oS{static encode(e){return Xg.toBinary(e)}static decode(e){return Xg.fromBinary(new Uint8Array(e))}}function pL(t,e){return Math.floor(Math.random()*(e-t+1)+t)}var Pi;class mL{constructor(e={}){rL(this,"opts"),Ie(this,Pi,void 0),this.opts={initialTimeout:e.initialTimeout||1e3,maxTimeout:e.maxTimeout||1e4,factor:e.factor||2},me(this,Pi,0)}wait(){return u(this,null,function*(){me(this,Pi,x(this,Pi)+1);const e=pL(0,Math.min(this.opts.maxTimeout,this.opts.initialTimeout*TE(2,x(this,Pi))));yield new Promise(n=>{setTimeout(n,e)})})}getAttempts(){return x(this,Pi)}reset(){me(this,Pi,0)}}Pi=new WeakMap;const gi={debug:0,info:1,warn:2,error:3};var vr,yr;class gL{constructor(e){Ie(this,vr,void 0),Ie(this,yr,void 0),me(this,vr,console),me(this,yr,e)}debug(...e){gi[x(this,yr)]>gi.debug||x(this,vr).debug("[Sockrates]:",...e)}info(...e){gi[x(this,yr)]>gi.info||x(this,vr).info("[Sockrates]:",...e)}warn(...e){gi[x(this,yr)]>gi.warn||x(this,vr).warn("[Sockrates]:",...e)}error(...e){gi[x(this,yr)]>gi.error||x(this,vr).error("[Sockrates]:",...e)}}vr=new WeakMap,yr=new WeakMap;var cS=(t=>(t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSING=2]="CLOSING",t[t.CLOSED=3]="CLOSED",t))(cS||{});const fL="2",vL="3";var Ue,ys,Ae,He,Ci,nt,ti,Ni,Sn,Ss,zn,Oh,dS,lo,dd,Nh,lS,Lh,Zg,Gd,xh,Vh,uS,Io,ld,Po,Jd,$d,Uh,Os,Co,Ro,Kd;class yL{constructor(e,n){var i;Ie(this,Oh),Ie(this,lo),Ie(this,Nh),Ie(this,Lh),Ie(this,Gd),Ie(this,Vh),Ie(this,Io),Ie(this,Po),Ie(this,$d),Ie(this,Os),Ie(this,Ro),Ie(this,Ue,void 0),Ie(this,ys,void 0),Ie(this,Ae,void 0),Ie(this,He,void 0),Ie(this,Ci,void 0),Ie(this,nt,void 0),Ie(this,ti,void 0),Ie(this,Ni,void 0),Ie(this,Sn,void 0),Ie(this,Ss,void 0),Ie(this,zn,void 0);var r,s,a,c,d,l,h,g,y;me(this,ys,e),me(this,Ci,[]),me(this,nt,new qd),me(this,ti,!0),me(this,Sn,!1),me(this,Ae,n!=null?n:{}),(r=x(this,Ae)).autoReconnect!=null||(r.autoReconnect=!0),(s=x(this,Ae)).retryConnectionInterval!=null||(s.retryConnectionInterval=1e3),(a=x(this,Ae)).pingTimeout!=null||(a.pingTimeout=3e4),(c=x(this,Ae)).connectionTimeout!=null||(c.connectionTimeout=5e3),(d=x(this,Ae)).debug!=null||(d.debug=!0),(l=x(this,Ae)).maxReconnectionAttempts!=null||(l.maxReconnectionAttempts=10),(h=x(this,Ae)).disconnectOnPingTimeout!=null||(h.disconnectOnPingTimeout=!0),(g=x(this,Ae)).queueOnDisconnect!=null||(g.queueOnDisconnect=!1),(y=x(this,Ae)).flushOnReconnect!=null||(y.flushOnReconnect=!1),me(this,Ni,{code:void 0,reason:void 0}),me(this,He,(i=x(this,Ae).logger)!=null?i:new gL(x(this,Ae).debug?"debug":"info")),me(this,zn,new mL)}get readyState(){var e;return(e=x(this,Ue))==null?void 0:e.readyState}get url(){return x(this,ys)}updateURL(e){me(this,ys,e),De(this,Vh,uS).call(this)}get config(){return x(this,Ae)}get sendQueue(){return x(this,Ci)}flush(){if(!x(this,Ae).queueOnDisconnect)return!1;const e=[];return x(this,Ci).forEach(n=>{this.send(n.event,n.id,n.payload,n.metadata)||e.push(n)}),me(this,Ci,e),x(this,Ci)}connect(e=!1){return u(this,null,function*(){if(!e&&[0,1].includes(this.readyState)){x(this,He).debug("Websocket was already connecting or connected.");return}if(x(this,ti)!==!1)return new Promise((n,i)=>{De(this,Os,Co).call(this),De(this,Ro,Kd).call(this);try{me(this,Ue,new WebSocket(De(this,Oh,dS).call(this,x(this,ys)))),x(this,Ue).binaryType="arraybuffer",x(this,He).debug("Connecting");const r=setTimeout(()=>{x(this,He).debug("Connection timeout. Closing socket"),me(this,ti,!0),De(this,Ro,Kd).call(this),x(this,Ue).close(3001,"Connection Timeout"),x(this,Ae).autoReconnect&&!x(this,Sn)&&(x(this,nt).emit("reconnecting"),De(this,Io,ld).call(this)),i(new Error("Connection timed out!"))},x(this,Ae).connectionTimeout);x(this,Ue).onopen=()=>{x(this,He).debug(`Ready State: ${cS[x(this,Ue).readyState]}`),r&&clearTimeout(r),De(this,$d,Uh).call(this),me(this,Ni,{code:void 0,reason:void 0}),x(this,nt).emit("connected"),x(this,Ae).flushOnReconnect&&this.flush(),n()},x(this,Ue).onclose=s=>{try{r&&clearTimeout(r);const{code:a,reason:c}=s;i(c),x(this,He).debug("Socket closed. Close event:",{event:s}),x(this,He).debug(`Connection closed code: ${a}`),x(this,He).debug(`Connection closed reason: ${c}`),x(this,Sn)||De(this,Gd,xh).call(this,a,c)}catch(a){De(this,lo,dd).call(this,a)}},x(this,Ue).onerror=s=>{De(this,lo,dd).call(this,s)},x(this,Ue).onmessage=s=>De(this,Nh,lS).call(this,s)}catch(r){De(this,lo,dd).call(this,r,i)}})})}send(e,n,i,r){const s={event:e,id:n,payload:i,metadata:r};if(x(this,Ae).queueOnDisconnect&&(!x(this,Ue)||x(this,Ue).readyState!==1))return x(this,He).debug("Queuing message since socket is not connected!",s),x(this,Ci).push(s),!1;const a=oS.encode(s);return De(this,Po,Jd).call(this,a)}emit(e,n,i,r){return this.send(e,n,i,r)}sendRaw(e){return De(this,Po,Jd).call(this,e)}receive(e,n){return x(this,nt).on(e.toString(),n)}on(e,n){if(typeof e=="string"&&(e==="connected"||e==="disconnected"||e==="errored"||e==="reconnected"||e==="reconnecting"||e==="reconnectAttempt"||e==="reconnectFailure"||e==="failed")){x(this,nt).on(e,n);return}this.receive(e,n)}removeAllListeners(){x(this,nt).removeAllListeners()}removeReceiver(e,n){this.removeListener(e,n)}removeListener(e,n){x(this,nt).removeListener(e.toString(),n)}removeReceivers(e){this.removeListeners(e)}removeListeners(e){x(this,nt).listeners(e.toString()).map(n=>this.removeListener(e,n))}disconnect(){me(this,ti,!1),De(this,Os,Co).call(this),this.removeAllListeners(),me(this,Ni,{code:1e3,reason:"Sockrates disconnect method called"}),x(this,Ue).close(1e3,"Sockrates disconnect method called.")}}Ue=new WeakMap,ys=new WeakMap,Ae=new WeakMap,He=new WeakMap,Ci=new WeakMap,nt=new WeakMap,ti=new WeakMap,Ni=new WeakMap,Sn=new WeakMap,Ss=new WeakMap,zn=new WeakMap,Oh=new WeakSet,dS=function(t){if(t.startsWith("ws://")||t.startsWith("wss://"))return t;if(t.startsWith("https://"))return`wss://${t.substring(8)}`;if(t.startsWith("http://"))return`ws://${t.substring(7)}`;throw new Error("Invalid URL. URL must start with http(s):// or ws(s)://.")},lo=new WeakSet,dd=function(t,e){x(this,He).error("Error:",{error:t}),x(this,nt).emit("errored",{error:t}),e==null||e(t)},Nh=new WeakSet,lS=function(t){if(De(this,$d,Uh).call(this),t.data===fL){x(this,He).debug("Received ping from server"),De(this,Po,Jd).call(this,vL);return}const e=oS.decode(t.data),{id:n,payload:i}=e;x(this,He).debug("Received message",{event:e.event,messageID:n}),x(this,nt).emit(e.event.toString(),{id:n,payload:i})},Lh=new WeakSet,Zg=function(){return x(this,Ue).readyState===1},Gd=new WeakSet,xh=function(t,e){me(this,Ni,{reason:e,code:t}),x(this,nt).emit("disconnected",{code:t,reason:e})},Vh=new WeakSet,uS=function(){const{reason:t,code:e}=x(this,Ni);e&&e!==1e3&&x(this,ti)&&x(this,Ae).autoReconnect&&!x(this,Sn)&&(x(this,He).debug(`Triggering reconnection due to ${t}.`),x(this,nt).emit("reconnecting"),De(this,Io,ld).call(this))},Io=new WeakSet,ld=function(t=!0){return u(this,null,function*(){if(t&&x(this,Sn)){x(this,He).debug("Reconnect called when already in a reconnect loop. Ignoring.");return}if(x(this,Sn)||x(this,zn).reset(),x(this,Ae).maxReconnectionAttempts!==null&&x(this,zn).getAttempts()>=x(this,Ae).maxReconnectionAttempts){x(this,nt).emit("failed"),me(this,Sn,!1);return}me(this,Sn,!0),De(this,Ro,Kd).call(this),De(this,Os,Co).call(this);try{if(yield x(this,zn).wait(),x(this,ti)===!1)return;if(x(this,He).debug(`Reconnection attempt ${x(this,zn).getAttempts()}`),x(this,nt).emit("reconnectAttempt",{attempt:x(this,zn).getAttempts()}),yield this.connect(),!De(this,Lh,Zg).call(this))throw Error("Reconnect Failed");me(this,Sn,!1),me(this,Ni,{code:void 0,reason:void 0}),x(this,nt).emit("reconnected")}catch{x(this,He).debug("Failed to reconnect."),x(this,nt).emit("reconnectFailure",{attempt:x(this,zn).getAttempts()}),De(this,Io,ld).call(this,!1)}})},Po=new WeakSet,Jd=function(t){try{return x(this,Ue).send(t),!0}catch(e){return x(this,He).error(e.message),!1}},$d=new WeakSet,Uh=function(){this.config.disconnectOnPingTimeout&&(x(this,He).debug("Resetting ping timeout"),De(this,Os,Co).call(this),me(this,Ss,setTimeout(()=>{var t;x(this,He).debug("Disconnecting the socket due to ping timeout"),me(this,ti,!0);const e=3002,n="Ping timeout";(t=x(this,Ue))==null||t.close(e,n),De(this,Gd,xh).call(this,e,n)},x(this,Ae).pingTimeout)))},Os=new WeakSet,Co=function(){x(this,Ss)&&(clearTimeout(x(this,Ss)),me(this,Ss,void 0))},Ro=new WeakSet,Kd=function(){x(this,Ue)&&(x(this,Ue).onopen=void 0,x(this,Ue).onerror=void 0,x(this,Ue).onmessage=void 0,x(this,Ue).onclose=void 0)};var SL=Object.defineProperty,EL=Object.getOwnPropertyDescriptor,Sl=(t,e,n,i)=>{for(var r=i>1?void 0:i?EL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&SL(e,n,r),r};const ef=65535,TL=3e3;var Zi,Le,xe,Fe,un,fi,Ec,gu,Tc,fu,tf;const hS=(tf=class{constructor(t,{peerId:e,meetingId:n,authToken:i,capabilities:r}){f(this,xe),f(this,Ec),f(this,Tc),f(this,Zi,void 0),f(this,Le,void 0),m(this,"roomName"),m(this,"authToken"),m(this,"capabilities"),f(this,un,void 0),f(this,fi,void 0);var s;if(!e||!n||!i)throw new P("peerId, meetingId, or authToken can not be empty","0404");v(this,un,void 0),v(this,fi,t),this.capabilities=r,this.roomName=n,this.authToken=i,v(this,Zi,H(this,Ec,gu).call(this,e)),v(this,Le,new yL(o(this,Zi),{autoReconnect:!0,disconnectOnPingTimeout:(s=r.includes("PING"))!=null?s:!1,queueOnDisconnect:!0,flushOnReconnect:!1,logger:p})),this.handleSocketConnectionEvents()}get joinAttempted(){return o(this,xe,Fe).socketJoinAttempted}set joinAttempted(t){o(this,xe,Fe).socketJoinAttempted=t}get peerId(){return o(this,fi).getValue("peerId")}updateURL(t){t!==this.peerId&&(v(this,Zi,H(this,Ec,gu).call(this,t)),p.debug("SocketService:: Connection URL updated.")),o(this,Le).updateURL(o(this,Zi))}static getSocketEdgeDomain(t){return Cs({servicePrefix:"socket-edge",baseURI:t})}get url(){return o(this,Zi)}connect(){return u(this,null,function*(){o(this,xe,Fe).socketJoinAttempted=!0,yield o(this,Le).connect(),o(this,xe,Fe).socketJoinAttempted=!0,o(this,xe,Fe).socketState={state:"connected",reconnected:!1,reconnectionAttempt:void 0}})}disconnect(){return u(this,null,function*(){o(this,xe,Fe).socketJoinAttempted=!1,o(this,Le).disconnect(),o(this,xe,Fe).socketJoinAttempted=!0,o(this,xe,Fe).socketState={state:"disconnected",reconnected:!1,reconnectionAttempt:void 0}})}get isConnected(){try{return o(this,Le).readyState===1}catch{return!1}}sendMessage(t,e,n){const i={};return E.injectContext(i),o(this,Le).send(t,n!=null?n:H(this,Tc,fu).call(this),e,new TextEncoder().encode(JSON.stringify(i)))}sendMessagePromise(t,e,n,i){const r=parseInt({}.SOCKET_SERVICE_MESSAGE_REQUEST_TIMEOUT,10)||2e4;return this.sendMessagePromiseWithTimeout({event:t,timeout:r,protobuf:e,messageId:n,resp:i})}sendMessagePromiseWithTimeout({event:t,timeout:e,protobuf:n,messageId:i,resp:r}){const s=r!=null?r:t;return new Promise((a,c)=>{const d=(S,b)=>{o(this,Le).removeListener(s,S),o(this,Le).removeListener(ef,b),o(this,Le).removeListener(sn.errorResponse,b),o(this,Le).removeListener(En.errorResponse,b)},l=i!=null?i:H(this,Tc,fu).call(this),h={};E.injectContext(h);const g=({id:S,payload:b})=>{if(l===S){let w;try{const C=hC.fromBinary(b);w=new Error(C.errorMessage)}catch(C){w=new Error("failed to parse error message",{cause:C});try{const F=mR.fromBinary(b);w=new Error(F.message)}catch(F){w=new Error("failed to parse error message",{cause:F})}}c(w),d(y,g)}},y=({id:S,payload:b})=>{l===S&&(a({id:S,payload:b}),d(y,g))};o(this,Le).on(s,y),o(this,Le).on(ef,g),o(this,Le).on(sn.errorResponse,g),o(this,Le).on(En.errorResponse,g),setTimeout(()=>{d(y,g),c(new Error(`request timeout for callback eventId:${t}`))},e),o(this,Le).send(t,l,n,new TextEncoder().encode(JSON.stringify(h)))})}on(t,e){o(this,Le).on(t,e)}onStateEvent(t,e){o(this,Le).on(t,e)}removeListener(t,e){o(this,Le).removeListener(t,e)}removeListeners(t){o(this,Le).removeListeners(t)}flush(){return o(this,Le).flush()}handleSocketConnectionEvents(){this.onStateEvent("connected",()=>u(this,null,function*(){p.info("SocketService::Connected to socket-edge"),o(this,un)&&(clearTimeout(o(this,un)),v(this,un,void 0)),o(this,xe,Fe).updateSocketConnectionState("connected")})),this.onStateEvent("disconnected",({code:t,reason:e})=>{var n;p.info("SocketService::Disconnected from socket-edge",{error:{code:t,reason:e},country:E.location.country});const{recv:i,send:r}=(n=o(this,xe,Fe).mediaState)!=null?n:{};i!=null&&i.state&&(i==null?void 0:i.state)!==Bi.CONNECTED||r!=null&&r.state&&(r==null?void 0:r.state)!==Bi.CONNECTED?M.emit(A.SOCKET_SERVICE_DISCONNECTED,{joinAttempted:o(this,xe,Fe).joinAttempted}):v(this,un,setTimeout(()=>{M.emit(A.SOCKET_SERVICE_DISCONNECTED,{joinAttempted:o(this,xe,Fe).joinAttempted}),v(this,un,void 0)},TL)),o(this,xe,Fe).updateSocketConnectionState("disconnected")}),this.onStateEvent("reconnecting",()=>u(this,null,function*(){p.info("SocketService::Reconnecting to socket-edge",{country:E.location.country}),o(this,xe,Fe).updateSocketConnectionState("reconnecting")})),this.onStateEvent("reconnectAttempt",t=>u(this,[t],function*({attempt:e}){p.info("SocketService::Attempting to reconnect to socket-edge",{socket:{retryAttempt:e}}),o(this,xe,Fe).updateSocketConnectionState("reconnectAttempt",e)})),this.onStateEvent("reconnectFailure",({attempt:t})=>{p.info("SocketService::Reconnect attempt to socket-edge failed",{socket:{retryAttempt:t}}),o(this,xe,Fe).updateSocketConnectionState("reconnectFailure",t)}),this.onStateEvent("reconnected",()=>u(this,null,function*(){p.info("SocketService::Reconnected to socket-edge",{connectionState:{joinAttempted:o(this,xe,Fe).mediaJoinAttempted}}),o(this,un)&&(clearTimeout(o(this,un)),v(this,un,void 0)),M.emit(A.SOCKET_SERVICE_RECONNECTED,{wasJoinAttempted:o(this,xe,Fe).mediaJoinAttempted}),o(this,xe,Fe).updateSocketConnectionState("reconnected")})),this.onStateEvent("failed",()=>u(this,null,function*(){p.info("SocketService::Failed to connect to socket-edge",{country:E.location.country}),M.emit(A.SOCKET_SERVICE_FAILED),o(this,xe,Fe).updateSocketConnectionState("failed")}))}},Zi=new WeakMap,Le=new WeakMap,xe=new WeakSet,Fe=function(){return o(this,fi).getValue("connectionHandler")},un=new WeakMap,fi=new WeakMap,Ec=new WeakSet,gu=function(t){let e=hS.getSocketEdgeDomain(o(this,fi).getValue("baseURI"));typeof Cd(o(this,fi),"socket_server_base")=="string"&&(e=Cd(o(this,fi),"socket_server_base"));const n=`wss://${e}`,i=new URL(`${n}/ws`),r=this.peerId,s=K(V({roomID:this.roomName,peerID:t,authToken:this.authToken,useMediaV2:!0},r!==t&&{oldPeerID:r}),{ping:this.capabilities.includes("PING"),capabilities:this.capabilities.map(a=>Rd[a]).join(" "),joinWithDetails:!0,useCfWorker:!0});return Object.entries(s).forEach(([a,c])=>{i.searchParams.append(a,c.toString())}),i.href},Tc=new WeakSet,fu=function(){return`${this.peerId}-${(Math.random()+1).toString(36).substring(7)}`},tf);let Go=hS;Sl([E.trace("SocketService.connect")],Go.prototype,"connect",1);Sl([E.trace("SocketService.disconnect")],Go.prototype,"disconnect",1);Sl([E.trace("SocketService.sendMessagePromise")],Go.prototype,"sendMessagePromise",1);Sl([E.trace("SocketService.sendMessagePromiseWithTimeout")],Go.prototype,"sendMessagePromiseWithTimeout",1);const Sr=class{static handleConnectedRoomsDumpRaw({payload:t}){var e;const n=WR.fromBinary(t),i=n.meetings.map(r=>{var s;return{id:r.id,title:r.title,participants:(s=r.participants)!=null?s:[]}});return{parentMeeting:{id:n.parentMeeting.id,title:n.parentMeeting.title,participants:(e=n.parentMeeting.participants)!=null?e:[]},meetings:i}}static handleTransferPeerRaw({payload:t}){const e=pM.fromBinary(t);return{authToken:e.authToken,meetingId:e.meetingId}}static handleMovedPeerRaw({payload:t}){const e=iy.fromBinary(t);return{meetingId:e.meetingId,customParticipantId:e.customParticipantId}}static handleConnectedRoomsUpdatedRaw({payload:t}){return cg.fromBinary(t).payloads.map(e=>({id:e.id,title:e.title}))}static handleConnectedRoomsDeletedRaw({payload:t}){return iM.fromBinary(t).payloads}static getConnectedRoomsDump(){return u(this,null,function*(){const t=yield Sr.socketService.sendMessagePromise(W.getConnectedRoomsDump);return Sr.handleConnectedRoomsDumpRaw(t)})}static createConnectedRooms(t){return u(this,null,function*(){const{payload:e}=yield Sr.socketService.sendMessagePromise(W.createConnectedRooms,GR.toBinary({payloads:t}));return cg.fromBinary(e).payloads.map(n=>({id:n.id,title:n.title}))})}static updateConnectedRooms(t){return u(this,null,function*(){})}static disableConnectedRooms(t){return u(this,null,function*(){const e=t.map(i=>({id:i})),n=yield Sr.socketService.sendMessagePromise(W.deleteConnectedRooms,tM.toBinary({payloads:e}));return Sr.handleConnectedRoomsDeletedRaw(n)})}static movePeersBetweenRooms(t){return u(this,null,function*(){try{const e=yield Sr.socketService.sendMessagePromise(W.movePeers,dM.toBinary({sourceMeetingId:t.sourceMeetingId,destinationMeetingId:t.destinationMeetingId,participants:t.participants}));return new TextDecoder().decode(e.payload).includes("error")?{success:!1,error:"failed to move participants"}:{success:!0}}catch(e){return{success:!1,error:e}}})}};let Ne=Sr;m(Ne,"socketService"),m(Ne,"currentMeetingId");var kL=Object.defineProperty,bL=Object.getOwnPropertyDescriptor,El=(t,e,n,i)=>{for(var r=i>1?void 0:i?bL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&kL(e,n,r),r};const Es=class{constructor(t,e){m(this,"apiBase"),m(this,"selfController"),m(this,"pollController"),m(this,"chatController"),m(this,"metaController"),m(this,"storesManager"),m(this,"stageController"),m(this,"pluginController"),m(this,"internalsController"),m(this,"recordingController"),m(this,"livestreamController"),m(this,"participantController"),this.apiBase=t,this.storesManager=e.storesManager,this.metaController=e.metaController,this.selfController=e.selfController,this.chatController=e.chatController,this.pollController=e.pollController,this.stageController=e.stageController,this.pluginController=e.pluginController,this.recordingController=e.recordingController,this.internalsController=e.internalsController,this.participantController=e.participantController,this.livestreamController=e.livestreamController}static init(t){return u(this,null,function*(){var e,n;const{peerId:i,apiBase:r,authToken:s,meetingId:a,organizationId:c,cachedUserDetails:d}=t.getAllValues();if(M.reset(),Od.cleanup(),Qy(t),Ce.isSupported()===!1)throw new P("Browser not supported","0010",!0);const l=ID(t,{authToken:s,baseURL:r,cachedUserDetails:d});l.setRoomName(a),l.setRoomUUID(a),l.setOrganizationId(c),l.setHeader("dyte-tracing-id",i),t.setValue("apiClient",l);const h=new cO;t.setValue("connectionHandler",h);const g=Es.createSocketService(t),y=g.connect(),S=l.getUserDetails(),b=l.getPlugins();let w=it.HIVE,C,F="";try{yield Es.setupFlagsmith(t)}catch(Z){p.error("Failed to setup flagsmith",{error:Z})}try{yield y}catch(Z){p.error("[Controller]: Failed to connect to socket server:",{error:Z})}try{({sfu:w,meetingTitle:F}=yield l.getRoomNodeData()),C=yield S,p.info(`SFU ${w} is being used.`),t.setValue("presetName",C.preset.name),t.setValue("roomNodeOptions",{sfu:w})}catch(Z){p.error("Failed to get room metadata",{error:Z})}const O=JO.init(C.preset,!t.getValue("modules").theme),q=Es.setupControllers(g,t,C,b,F,O);QD(O)&&((e=Es.createRoomNodeClient(t,g).partialJoinRoom(C.participant.name,a,void 0))==null||e.catch(Z=>{p.error("[Controller]: Failed to queue partial media room promise:",{error:Z})})),E.location.country=(n=l.ipInfo)==null?void 0:n.country;const{controllers:I}=yield q;return zI(),new Es(r,I)})}static setupFlagsmith(t){return u(this,null,function*(){var e;const{peerId:n,baseURI:i,overrides:r,meetingId:s,organizationId:a}=t.getAllValues(),c=$I(s),d=K(V({entity:xu.PEER,clientId:a,isAnonUser:!a,sdkVersion:t.getValue("sdkVersion"),presetName:t.getValue("presetName"),meetingHash:c,roomName:s},Ce.getDeviceInfo()),{isReactNative:navigator.isReactNative});try{const l=(e=r==null?void 0:r.whitelabelled_flags_endpoint)==null||e?Cs({servicePrefix:"flags",baseURI:i}):"edge.api.flagsmith.com";yield X.identify(`${xu.PEER}_${n}`,JSON.parse(JSON.stringify(d)),!1,5e3,l,p),p.info("flagsmith::allFlags",{flags:JSON.stringify(X.getAllFlags())},!0)}catch{p.error("Failed to fetch flagsmith flags")}})}static setupControllers(t,e,n,i,r,s){return u(this,null,function*(){var a,c,d;const l=e.getValue("modules"),{preset:h,participant:g}=n,y=e.getValue("defaults"),{sfu:S}=e.getValue("roomNodeOptions"),{viewType:b,mediaConstraints:{audio:w}}=s;e.setValue("viewType",b),e.setValue("defaults",V({mediaConfiguration:{audio:{enableHighBitrate:(a=w.enableHighBitrate)!=null?a:!1,enableStereo:(c=w.enableStereo)!=null?c:!1}}},y));const C=pN.init(e,b,h.permissions);e.setValue("maxPreferredStreams",Ce.isMobile()?s.maxVideoStreams.mobile:s.maxVideoStreams.desktop);let F,O,q,I,Z,se,Te,ce;const Re=new QN(t);Ne.socketService=t;const vt=new vl(t),D=new an(t),k=new eL(t),_=Od.create(t,e),j=new tL(t),we=new YN(t),ze=new Dr(t),B=yield Gi.init(e,_,g,C,s),R=yield my.init(e,B.self,_,Re,r);if(l.participant&&(ce=new di(e,B.self,_,S)),(d=l.e2ee)!=null&&d.enabled&&l.e2ee.manager.init(p,M),l.chat&&(O=yield ii.init(e,D,ze,B.self,ce.participants)),l.internals&&(Z=yield pp.init()),l.livestream&&s.viewType===Rt.Livestream&&X.hasFeature(re.LIVESTREAM)&&(Te=new by(B.self,we)),s.viewType!==Rt.Chat){if(l.poll&&(F=yield ly.init(e,B.self,vt)),l.recording&&(se=new yy(e,B.self,_)),l.stage&&(q=new gy(e,k,_,B.self,ce.participants)),l.plugin){if(!ce)throw new P("The plugin module cannot be initialized without the `participant` module","0102");const jn=yield i;I=yield Wo.init(e,jn,j,D,O==null?void 0:O.chat,B.self,ce.participants,r)}if(l.pip){const jn=yield XI._init(e,B.self);e.setValue("pip",jn)}}const Ye={storesManager:new eN(e,j),pollController:F,selfController:B,metaController:R,chatController:O,stageController:q,pluginController:I,recordingController:se,internalsController:Z,livestreamController:Te,participantController:ce};return{theme:s,permissions:C,controllers:Ye}})}static createRoomNodeClient(t,e){const{peerId:n,roomNodeOptions:i}=t.getAllValues(),{sfu:r}=i;return Yy(t,r,{socket:e,peerId:n})}static createSocketService(t){const{peerId:e,meetingId:n,authToken:i}=t.getAllValues(),r=["PING"];return new Go(t,{peerId:e,meetingId:n,authToken:i,capabilities:r})}};let Jo=Es;El([E.trace("Controller.init")],Jo,"init",1);El([E.trace("setupFlagsmith")],Jo,"setupFlagsmith",1);El([E.trace("Controller.createRoomNodeClient")],Jo,"createRoomNodeClient",1);El([E.trace("Controller.createSocketService")],Jo,"createSocketService",1);var _L=Object.defineProperty,wL=Object.getOwnPropertyDescriptor,IL=(t,e,n,i)=>{for(var r=i>1?void 0:i?wL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&_L(e,n,r),r},ud,Fh;class pS extends zt{constructor(e,n){super(),f(this,ud,void 0),m(this,"meetings",[]),m(this,"parentMeeting",null),f(this,Fh,void 0),v(this,Fh,e),v(this,ud,n.self)}get supportsConnectedMeetings(){return o(this,ud).id!==""}get isActive(){return this.meetings.length!==0}get currentMeetingId(){return Ne.currentMeetingId}validateConnectedMeetingsAction(){if(!this.supportsConnectedMeetings)throw new Error(`You are not allowed to perform this action.
|
|
21
21
|
Please connect with Dyte team to move you to V2 APIs & to enable connected meetings.`)}getConnectedMeetings(){return u(this,null,function*(){return this.validateConnectedMeetingsAction(),yield Ne.getConnectedRoomsDump()})}createMeetings(e){return u(this,null,function*(){return this.validateConnectedMeetingsAction(),(yield Ne.createConnectedRooms(e)).map(n=>({id:n.id,title:n.title}))})}updateMeetings(e){return u(this,null,function*(){this.validateConnectedMeetingsAction(),yield Ne.updateConnectedRooms(e.map(n=>({meetingId:n.id,title:n.title})))})}deleteMeetings(e){return u(this,null,function*(){this.validateConnectedMeetingsAction();const n=this.meetings.map(i=>e.includes(i.id)&&i.participants.length!==0?this.moveParticipants(i.id,this.parentMeeting.id,i.participants.map(r=>r.id)):Promise.resolve());return yield Promise.all(n),yield Ne.disableConnectedRooms(e)})}moveParticipants(e,n,i){return u(this,null,function*(){this.validateConnectedMeetingsAction();const r=yield Ne.movePeersBetweenRooms({sourceMeetingId:e,destinationMeetingId:n,participants:i.map(s=>({id:s}))});return r.success&&this.moveSuccessHandler(e,n,i),r})}moveParticipantsWithCustomPreset(e,n,i){return u(this,null,function*(){this.validateConnectedMeetingsAction();const r=yield Ne.movePeersBetweenRooms({sourceMeetingId:e,destinationMeetingId:n,participants:i});return r.success&&this.moveSuccessHandler(e,n,i.map(s=>s.id)),r})}moveSuccessHandler(e,n,i){const r=new Map;[...this.parentMeeting.participants,...this.meetings.flatMap(s=>s.participants)].forEach(s=>r.set(s.id,s)),n===this.parentMeeting.id&&(this.parentMeeting.participants=this.parentMeeting.participants.concat(i.map(s=>r.get(s)))),e===this.parentMeeting.id&&(this.parentMeeting.participants=this.parentMeeting.participants.filter(s=>!i.includes(s.id))),this.meetings=this.meetings.map(s=>{if(n===s.id){const a=s.participants.concat(i.map(c=>r.get(c)));return K(V({},s),{participants:a})}if(e===s.id){const a=s.participants.filter(c=>!i.includes(c.id));return K(V({},s),{participants:a})}return s})}}ud=new WeakMap,Fh=new WeakMap;IL([Bt({maxInvocations:60,period:60})],pS.prototype,"getConnectedMeetings",1);var PL=Object.defineProperty,CL=Object.getOwnPropertyDescriptor,_p=(t,e,n,i)=>{for(var r=i>1?void 0:i?CL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&PL(e,n,r),r},Da,hn,vu,yu;const Ri=(vu=class{constructor(t,e,n){m(this,"connectedMeetings"),f(this,Da,void 0),f(this,hn,void 0),f(this,yu,void 0),v(this,yu,t),v(this,Da,n),this.connectedMeetings=new pS(t,e),this.setCurrentMeeting(e)}static init(t,e,n){return Ri.instance||(Ri.instance=new Ri(t,e,n)),Ri.instance.connectedMeetings.supportsConnectedMeetings&&(Ri.instance.setupEvents(),e.self.once("roomJoined",()=>Ri.instance.getConnectedMeetings())),Ri.instance}setCurrentMeeting(t){v(this,hn,t),Ne.currentMeetingId=t.meta.meetingId}getConnectedMeetings(){this.connectedMeetings.getConnectedMeetings()}setupEvents(){Ne.socketService&&(Ne.socketService.on(W.getConnectedRoomsDump,this.handleConnectedRoomsDump.bind(this)),Ne.socketService.on(W.transferPeer,this.handleTransferPeer.bind(this)),Ne.socketService.on(W.movedPeer,this.handleMovedPeer.bind(this)),Ne.socketService.on(W.connectedRoomsUpdated,this.handleConnectedRoomsUpdated.bind(this)),Ne.socketService.on(W.connectedRoomsDeleted,this.handleConnectedRoomsDeleted.bind(this)))}handleTransferPeer(t){const e=Ne.handleTransferPeerRaw(t);return this.switchMeeting(e)}switchMeeting(t){return u(this,arguments,function*({authToken:e,meetingId:n}){var i,r,s,a;if(!this.connectedMeetings.supportsConnectedMeetings)throw new Error(`You are not allowed to perform this action.
|
|
22
22
|
Please connect with Dyte team to move you to V2 APIs & to enable connected meetings.`);p.info("ConnectedMeetingsController::switchMeeting:: asking ui-kit to show switching breakout UI"),this.connectedMeetings.emit("changingMeeting",n);const c={video:o(this,hn).self.videoEnabled,audio:o(this,hn).self.audioEnabled};try{o(this,hn).self.cleanupEvents(),yield o(this,hn).leave("connected-meeting")}catch(l){p.error(`ConnectedMeetingsController:: switchMeeting:: issues in leaving previous meeting. Meeting Id: ${(r=(i=o(this,hn))==null?void 0:i.meta)==null?void 0:r.meetingId}`,{error:l})}Ne.socketService=void 0,p.info(`ConnectedMeetingsController::switchMeeting:: initializing new meeting. Meeting Id: ${n}`);const d=yield mS.init(K(V({},o(this,Da)),{cachedUserDetails:null,defaults:K(V(V({},o(this,Da).defaults),c),{mediaHandler:o(this,hn).self}),authToken:e}));p.info(`ConnectedMeetingsController::switchMeeting:: initialized new meeting. Meeting Id: ${(s=d==null?void 0:d.meta)==null?void 0:s.meetingId}`);try{const{hidden:l}=o(this,hn).self;d.self.setName(o(this,hn).self.name),yield d.join(),l&&d.self.hide()}catch(l){p.error("ConnectedMeetingsController.joinRoom",{error:l})}return p.info(`ConnectedMeetingsController::switchMeeting:: asking ui-kit to show in-meeting ui of newly joined meeting id: ${(a=d==null?void 0:d.meta)==null?void 0:a.meetingId}`),this.connectedMeetings.emit("meetingChanged",d),this.setCurrentMeeting(d),d})}handleConnectedRoomsDump(t){const e=Ne.handleConnectedRoomsDumpRaw(t);this.connectedMeetings.meetings=e.meetings.map(n=>({id:n.id,title:n.title,participants:n.participants||[]})),this.connectedMeetings.parentMeeting={id:e.parentMeeting.id,title:e.parentMeeting.title,participants:e.parentMeeting.participants},this.emitStateUpdate()}handleMovedPeer(t){return Ne.handleMovedPeerRaw(t)}handleConnectedRoomsUpdated(t){const e=Ne.handleConnectedRoomsUpdatedRaw(t),n=new Map;this.connectedMeetings.meetings.forEach(i=>{n.set(i.id,i)}),e.forEach(i=>{n.has(i.id)?n.get(i.id).title=i.title:n.set(i.id,K(V({},i),{participants:[]}))}),this.connectedMeetings.meetings=Array.from(n.values()),this.emitStateUpdate()}handleConnectedRoomsDeleted(t){const e=Ne.handleConnectedRoomsDeletedRaw(t).map(n=>n.id);this.connectedMeetings.meetings=this.connectedMeetings.meetings.filter(n=>!e.includes(n.id)),this.emitStateUpdate()}emitStateUpdate(){this.connectedMeetings.emit("stateUpdate",{meetings:this.connectedMeetings.meetings,parentMeeting:this.connectedMeetings.parentMeeting})}},Da=new WeakMap,hn=new WeakMap,yu=new WeakMap,m(vu,"instance"),vu);let Tl=Ri;_p([E.trace("ConnectedMeetingsController.getConnectedMeetings")],Tl.prototype,"getConnectedMeetings",1);_p([E.trace("ConnectedMeetingsController.setupEvents")],Tl.prototype,"setupEvents",1);_p([E.trace("ConnectedMeetingsController.switchMeeting")],Tl.prototype,"switchMeeting",1);class RL{constructor(){m(this,"battery"),m(this,"init",()=>u(this,null,function*(){try{"getBattery"in navigator&&(this.battery=yield navigator.getBattery(),this.battery.addEventListener("chargingchange",this.updateChargeInfo),this.battery.addEventListener("levelchange",this.updateLevelInfo),this.updateLevelInfo(),this.updateChargeInfo())}catch(e){p.error("Error getting battery",e)}})),m(this,"updateChargeInfo",()=>{var e;p.log(`Battery charging? ${(e=this.battery)!=null&&e.charging?"Yes":"No"}`)}),m(this,"updateLevelInfo",()=>{if(!this.battery){p.log("Battery level: Not known");return}p.log(`Battery level: ${this.battery.level*100}%`)}),m(this,"cleanup",()=>{var e,n;"getBattery"in navigator&&((e=this.battery)==null||e.removeEventListener("chargingchange",this.updateChargeInfo),(n=this.battery)==null||n.removeEventListener("levelchange",this.updateLevelInfo))})}}const nf=new RL;function ML(t,e){t.startsWith("eyJ")||console.error("Invalid auth token provided. Ensure you are passing a %cparticipant `authToken`%c \u2014 not an Org API Key or an incorrectly formatted token.\nYou get the participant token from the Add Participant API: https://docs.dyte.io/api#/operations/add_participant","font-weight: bold","font-weight: normal");try{const{meetingId:n,orgId:i,participantId:r}=JSON.parse(atob(t.split(".")[1]));if(!n)throw Error(`Received V1 auth token ${t}`);let s="dyte.io";e&&(s=e);const a=`https://api.${s}`;return{meetingId:n,orgId:i,participantId:r,baseURI:s,apiBase:a}}catch(n){throw p.error("constants::decodeAuthToken",{error:n,debuggingHint:`Unable to decode auth token: ${t}`},!0),new P("Invalid auth token","0004")}}var AL=Object.defineProperty,DL=Object.getOwnPropertyDescriptor,kl=(t,e,n,i)=>{for(var r=i>1?void 0:i?DL(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&AL(e,n,r),r},ot,kc,bc,Su,rf,sf;let Wi=(sf=class{constructor(t,e){f(this,Su),f(this,ot,void 0),f(this,kc,void 0),f(this,bc,void 0),v(this,bc,t),v(this,ot,e)}static init(t){return u(this,null,function*(){var e,n,i,r,s;qI(),Ce.init();const a=Us();nf.init();const{authToken:c,baseURI:d}=t,l=ML(c,d),{meetingId:h}=l,g=Qd(l,["meetingId"]);window.__zone_symbol__DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION=!0;const y=Wi.setupContext(a,t,h,g);E.meetingMetadata.roomName=h,E.meetingMetadata.userId=g.participantId,E.meetingMetadata.organizationId=g.orgId,E.init(y,(n=(e=t.modules)==null?void 0:e.tracing)!=null?n:!0),p.info("DyteClient::init::options",{dyteClientInitOptions:K(V({},t),{authToken:`${(i=t.authToken)==null?void 0:i.slice(0,10)}...
|
|
23
|
-
${(r=t.authToken)==null?void 0:r.slice(-10)}`})});const S=yield Jo.init(y),b=new Wi(y,S);return H(s=b,Su,rf).call(s,t),b})}static setupContext(t,e,n,i){var r;const s=Cr.createContext(t,e),a=V(V({},UI),e==null?void 0:e.modules);return s.setValue("peerId",t),s.setValue("modules",a),s.setValue("sdkName","web-core"),s.setValue("meetingId",n),s.setValue("apiBase",i.apiBase),s.setValue("baseURI",i.baseURI),s.setValue("userId",i.participantId),s.setValue("organizationId",i.orgId),s.setValue("authToken",e.authToken),s.setValue("overrides",(r=e.overrides)!=null?r:{}),s.setValue("env",FI({baseURI:i.baseURI})),s.setValue("defaults",e.defaults||{audio:!0,video:!0}),s.setValue("onError",e.onError||(()=>{})),s.setValue("cachedUserDetails",kn(e.cachedUserDetails)),s.setValue("sdkVersion","2.5.0-staging.
|
|
23
|
+
${(r=t.authToken)==null?void 0:r.slice(-10)}`})});const S=yield Jo.init(y),b=new Wi(y,S);return H(s=b,Su,rf).call(s,t),b})}static setupContext(t,e,n,i){var r;const s=Cr.createContext(t,e),a=V(V({},UI),e==null?void 0:e.modules);return s.setValue("peerId",t),s.setValue("modules",a),s.setValue("sdkName","web-core"),s.setValue("meetingId",n),s.setValue("apiBase",i.apiBase),s.setValue("baseURI",i.baseURI),s.setValue("userId",i.participantId),s.setValue("organizationId",i.orgId),s.setValue("authToken",e.authToken),s.setValue("overrides",(r=e.overrides)!=null?r:{}),s.setValue("env",FI({baseURI:i.baseURI})),s.setValue("defaults",e.defaults||{audio:!0,video:!0}),s.setValue("onError",e.onError||(()=>{})),s.setValue("cachedUserDetails",kn(e.cachedUserDetails)),s.setValue("sdkVersion","2.5.0-staging.66"),s}join(){return u(this,null,function*(){const{selfController:t}=o(this,ot);return t.self.roomJoined?null:t.joinRoom()})}leave(t){return u(this,null,function*(){nf.cleanup();const{selfController:e}=o(this,ot);return e.leaveRoom(t)})}get participants(){var t;return(t=o(this,ot).participantController)==null?void 0:t.participants}get self(){var t;return(t=o(this,ot).selfController)==null?void 0:t.self}get meta(){var t;return(t=o(this,ot).metaController)==null?void 0:t.meta}get ai(){var t;return(t=o(this,ot).metaController)==null?void 0:t.ai}get plugins(){var t;return(t=o(this,ot).pluginController)==null?void 0:t.plugins}get chat(){var t;return(t=o(this,ot).chatController)==null?void 0:t.chat}get polls(){var t;return(t=o(this,ot).pollController)==null?void 0:t.polls}get connectedMeetings(){var t;return(t=o(this,kc))==null?void 0:t.connectedMeetings}get recording(){var t;return(t=o(this,ot).recordingController)==null?void 0:t.recording}get livestream(){var t;return(t=o(this,ot).livestreamController)==null?void 0:t.livestream}get stage(){var t;return(t=o(this,ot).stageController)==null?void 0:t.stage}get stores(){return o(this,ot).storesManager}get __internals__(){var t;return(t=o(this,ot).internalsController)==null?void 0:t.internals}joinRoom(){return u(this,null,function*(){return this.join()})}leaveRoom(t){return u(this,null,function*(){return this.leave(t)})}},ot=new WeakMap,kc=new WeakMap,bc=new WeakMap,Su=new WeakSet,rf=function(t){v(this,kc,Tl.init(o(this,bc),this,t))},sf);kl([gt("0002"),qi.executeWithLock({methodName:"meeting.join",lockName:"DyteClient.join",timeout:3e3})],Wi.prototype,"join",1);kl([gt("0003")],Wi.prototype,"leave",1);kl([gt("0001"),qi.executeWithLock({methodName:"DyteClient.init",lockName:"DyteClient.init",timeout:3e3})],Wi,"init",1);Wi=kl([gt("0000")],Wi);const mS=Wi;var OL=Object.defineProperty,NL=(t,e,n)=>e in t?OL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Eu=(t,e,n)=>(NL(t,typeof e!="symbol"?e+"":e,n),n);class LL{constructor(e){Eu(this,"meeting"),Eu(this,"l"),Eu(this,"onUpdate",()=>{this.l.forEach(I=>{I()})});var n,i,r,s,a,c,d,l,h,g,y,S,b,w,C,F,O,q;this.meeting=e,this.l=new Set,(n=this.meeting.self)==null||n.addListener("*",this.onUpdate),(i=this.meeting.meta)==null||i.addListener("*",this.onUpdate),(r=this.meeting.participants)==null||r.addListener("*",this.onUpdate),(a=(s=this.meeting.participants)==null?void 0:s.joined)==null||a.addListener("*",this.onUpdate),(d=(c=this.meeting.participants)==null?void 0:c.active)==null||d.addListener("*",this.onUpdate),(h=(l=this.meeting.participants)==null?void 0:l.waitlisted)==null||h.addListener("*",this.onUpdate),(g=this.meeting.stage)==null||g.addListener("*",this.onUpdate),(y=this.meeting.livestream)==null||y.addListener("*",this.onUpdate),(S=this.meeting.chat)==null||S.addListener("*",this.onUpdate),(b=this.meeting.plugins)==null||b.all.addListener("*",this.onUpdate),(w=this.meeting.recording)==null||w.addListener("*",this.onUpdate),(C=this.meeting.connectedMeetings)==null||C.addListener("*",this.onUpdate),(F=this.meeting.spotlight)==null||F.addListener("*",this.onUpdate),(O=this.meeting.remote)==null||O.addListener("*",this.onUpdate),(q=this.meeting.polls)==null||q.addListener("*",this.onUpdate)}clean(){var e,n,i,r,s,a,c,d,l,h,g,y,S,b,w,C,F,O;(e=this.meeting.self)==null||e.removeListener("*",this.onUpdate),(n=this.meeting.meta)==null||n.removeListener("*",this.onUpdate),(i=this.meeting.participants)==null||i.removeListener("*",this.onUpdate),(s=(r=this.meeting.participants)==null?void 0:r.joined)==null||s.removeListener("*",this.onUpdate),(c=(a=this.meeting.participants)==null?void 0:a.active)==null||c.removeListener("*",this.onUpdate),(l=(d=this.meeting.participants)==null?void 0:d.waitlisted)==null||l.removeListener("*",this.onUpdate),(h=this.meeting.stage)==null||h.removeListener("*",this.onUpdate),(g=this.meeting.livestream)==null||g.removeListener("*",this.onUpdate),(y=this.meeting.chat)==null||y.removeListener("*",this.onUpdate),(S=this.meeting.plugins)==null||S.all.removeListener("*",this.onUpdate),(b=this.meeting.recording)==null||b.removeListener("*",this.onUpdate),(w=this.meeting.connectedMeetings)==null||w.removeListener("*",this.onUpdate),(C=this.meeting.spotlight)==null||C.removeListener("*",this.onUpdate),(F=this.meeting.remote)==null||F.removeListener("*",this.onUpdate),(O=this.meeting.polls)==null||O.removeListener("*",this.onUpdate)}addListener(e){this.l.add(e)}removeListener(e){this.l.delete(e)}}const wp=Pt.createContext({meeting:void 0,updates:void 0});function xL({value:t,children:e,fallback:n}){const[i,r]=Pt.useState(),s=Pt.useRef();return Pt.useEffect(()=>(t&&r(new LL(t)),()=>{var a;(a=s.current)==null||a.clean()}),[t]),fS.default.createElement(wp.Provider,{value:{meeting:t,updates:i}},t?e:n)}const VL=()=>{const{meeting:t}=Pt.useContext(wp);if(!t)throw new Error("useDyteMeeting must be used within the DyteProvider");return{meeting:t}},UL=t=>{const e=Pt.useRef(!1),[n,i]=Pt.useState(),r=t==null?void 0:t.resetOnLeave,s=Pt.useCallback(async a=>{if(!e.current)return e.current=!0,mS.init(a).then(c=>(i(c),c)).finally(()=>{e.current=!1})},[]);return Pt.useEffect(()=>{if(!n||!r)return()=>{};const a=({state:c})=>{c!=="connected-meeting"&&c!=="disconnected"&&i(void 0)};return n.self.on("roomLeft",a),()=>{n.self.removeListener("roomLeft",a)}},[n]),Pt.useEffect(()=>{if(!n||!n.connectedMeetings)return()=>{};const a=c=>{i(void 0),setTimeout(()=>{i(c)},100)};return n.connectedMeetings.on("meetingChanged",a),()=>{n.connectedMeetings.removeListener("meetingChanged",a)}},[n]),[n,s]},FL=(t,e)=>!!(t!==e||Array.isArray(t)&&Array.isArray(e)&&t.length!==e.length),BL=t=>{const{meeting:e,updates:n}=Pt.useContext(wp);if(!e)throw new Error("useDyteSelector must be used within the DyteProvider");const i=Pt.useRef(t(e)),[,r]=Pt.useReducer(s=>s+1,0);return Pt.useEffect(()=>{const s=e&&t(e),a=()=>{const c=e&&t(e);FL(i.current,c)&&(i.current=c,r())};return s&&typeof s=="object"&&"addListener"in s?(s.addListener("*",r),()=>{s.removeListener("*",r)}):(n==null||n.addListener(a),()=>{n==null||n.removeListener(a)})},[e,n]),i.current},WL=t=>UL(t),jL=xL,HL=VL,qL=BL,GL=()=>HL(),JL=t=>qL(t);exports.RealtimeKitProvider=jL;exports.useRTKSelector=JL;exports.useRealtimeKitClient=WL;exports.useRealtimeKitMeeting=GL;
|
package/dist/react.es.js
CHANGED
|
@@ -30644,7 +30644,7 @@ let Xr = (hf = class {
|
|
|
30644
30644
|
var c;
|
|
30645
30645
|
const n = Hi.createContext(t, e), a = N(N({}, DR), e == null ? void 0 : e.modules);
|
|
30646
30646
|
return n.setValue("peerId", t), n.setValue("modules", a), n.setValue("sdkName", "web-core"), n.setValue("meetingId", r), n.setValue("apiBase", i.apiBase), n.setValue("baseURI", i.baseURI), n.setValue("userId", i.participantId), n.setValue("organizationId", i.orgId), n.setValue("authToken", e.authToken), n.setValue("overrides", (c = e.overrides) != null ? c : {}), n.setValue("env", OR({ baseURI: i.baseURI })), n.setValue("defaults", e.defaults || { audio: true, video: true }), n.setValue("onError", e.onError || (() => {
|
|
30647
|
-
})), n.setValue("cachedUserDetails", gs(e.cachedUserDetails)), n.setValue("sdkVersion", "2.5.0-staging.
|
|
30647
|
+
})), n.setValue("cachedUserDetails", gs(e.cachedUserDetails)), n.setValue("sdkVersion", "2.5.0-staging.66"), n;
|
|
30648
30648
|
}
|
|
30649
30649
|
join() {
|
|
30650
30650
|
return u(this, null, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/realtimekit",
|
|
3
|
-
"version": "0.5.0-staging.
|
|
3
|
+
"version": "0.5.0-staging.68",
|
|
4
4
|
"description": "A real-time video and audio SDK for building custom, collaborative communication experiences.",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|