@cloudflare/realtimekit-react 1.1.0-staging.4 → 1.1.0-staging.5
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/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -20,4 +20,4 @@ ${t}`}const Ks={maxInvocations:5,period:1};function Bt(t,e){return function(r,i,
|
|
|
20
20
|
maxEnergy: ${a(this,gn)}`),n===-1/0||r<1e-6?{energy:0,isVoice:!1}:((!a(this,Pi)||n<a(this,Pi))&&v(this,Pi,n),(!a(this,gn)||n>a(this,gn))&&v(this,gn,n),{energy:(n-a(this,Pi))/(a(this,gn)-a(this,Pi))*10||0,isVoice:i})},Td=new WeakSet,Rh=function(t){return t<5},Mh=new WeakSet,my=function(t=a(this,Vs)){var e;if(!a(this,Wr)||!t){Y.hasFeature(re.ENABLE_AUDIO_ACTIVITY_DEBUG_LOGS)&&l.debug(`AudioActivityReporter: No producerId or energy to report: ${a(this,Wr)}`);return}const r={producerId:a(this,Wr),energy:Math.round(t),silent:F(e=Zd,Td,Rh).call(e,t)};v(this,Uo,r.silent),this.reportRequest(r)},du=new WeakSet,Ig=function(t){const e=Math.log10(t);return Math.round(e)},f(Ah,Td),f(Ah,du);const c1=(t=!1)=>{if("MediaStreamTrackGenerator"in window&&"AudioData"in window)try{const r=new window.MediaStreamTrackGenerator({kind:"audio"}),i=r.writable.getWriter(),n=48e3,s=128,o=1;let c=0,d=null;const h=()=>u(void 0,null,function*(){try{const g=new Float32Array(s*o),y=new window.AudioData({format:"f32",sampleRate:n,numberOfFrames:s,numberOfChannels:o,timestamp:c,data:g});c+=s/n*1e6,yield i.ready,yield i.write(y)}catch{d&&clearInterval(d),i.releaseLock(),r.writable.abort()}});d=window.setInterval(h,100);const p=new MediaStream([r]).getAudioTracks()[0];return p.addEventListener("ended",()=>{d&&clearInterval(d),i.releaseLock(),r.writable.abort()}),Object.assign(p,{fakeTracks:"fakeTracks:fakeAudioTrack"}),p.enabled=t,p}catch{}const e=window.AudioContext||window.webkitAudioContext;if(e)try{const r=new e;if(!r||r.state!=="running"||!r.destination)return;const i=r.createOscillator();i.frequency.value=0,i.type="sine";const n=r.createGain();n.gain.value=0,i.connect(n);const s=r.createMediaStreamDestination();n.connect(s),i.start();const o=s.stream.getAudioTracks()[0];return o?(Object.assign(o,{fakeTracks:"fakeTracks:fakeAudioTrack"}),o.enabled=t,o):void 0}catch{return}},d1=(t=!1)=>{var e,r;const i=new MediaStream().getVideoTracks()[0],n=document.createElement("canvas");n.height=(e=i==null?void 0:i.getSettings().height)!=null?e:720,n.width=(r=i==null?void 0:i.getSettings().width)!=null?r:1280;const s=n.getContext("2d");s.fillStyle="black",s.fillRect(0,0,n.width,n.height),setInterval(()=>{s.fillStyle="black",s.fillRect(0,0,n.width,n.height)},1e3);const o=n.captureStream().getVideoTracks()[0];return Object.assign(o,{fakeTracks:"fakeTracks:fakeVideoTrack"}),o.enabled=t,o};var l1=Object.defineProperty,u1=Object.getOwnPropertyDescriptor,fe=(t,e,r,i)=>{for(var n=i>1?void 0:i?u1(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&l1(e,r,n),n};const Ht=["video/VP9","video/VP8"];var Dc,Oc,yt,z,Ka,$r,Dt,is,ns,ss,Nc,mr,fi,za,as,os,Ot,qt,Xi,cs,lu,Cg,uu,Pg,hu,Rg,Lc,pu,mu,gu,Mg,fu,Ag,vu,Dg,yu,Og,lt,St,ds,Ya,Su,Ng,Eu,Lg,Tu,Vg;const gy=(gu=class{constructor(t,e,r){f(this,Xi),f(this,lu),f(this,uu),f(this,hu),f(this,Lc),f(this,fu),f(this,vu),f(this,yu),f(this,lt),f(this,ds),f(this,Su),f(this,Eu),f(this,Tu),m(this,"context"),m(this,"authToken"),m(this,"e2ee"),f(this,Dc,void 0),f(this,Oc,void 0),f(this,yt,void 0),f(this,z,void 0),f(this,Ka,void 0),f(this,$r,void 0),f(this,Dt,void 0),f(this,is,void 0),f(this,ns,void 0),f(this,ss,void 0),f(this,Nc,void 0),f(this,mr,null),f(this,fi,void 0),f(this,za,void 0),f(this,as,void 0),f(this,os,void 0),f(this,Ot,void 0),f(this,qt,void 0);var i,n;this.context=t;const{socket:s}=r;this.mediaJoined=!1,v(this,as,new Map([["video/VP9",new Set],["video/VP8",new Set]])),v(this,os,new Map([["video/VP9",new Set],["video/VP8",new Set]])),v(this,$r,e),v(this,yt,s),v(this,is,!1),v(this,z,new s1(t,s,e)),v(this,Dt,a(this,z).events),v(this,fi,new Set),v(this,Ot,new Map),v(this,ns,!1),v(this,ss,new ih),e===Le.CF&&!navigator.isReactNative&&v(this,qt,new Ah(a(this,z).socketHandler.audioActivity.bind(a(this,z).socketHandler))),this.e2ee=(n=(i=t.getValue("modules").e2ee)==null?void 0:i.enabled)!=null?n:!1,this.handleSocketEvents(),this.handleCallstatsEvents(),v(this,Nc,rp(()=>u(this,null,function*(){if(!a(this,Xi,cs).mediaJoinAttempted)return;const{roomJoined:o}=yield this.joinRoom(a(this,Oc),a(this,Dc),!0,!0);o&&(this.context.getValue("peerSessionStore").emit(R.RESET_PRODUCER_STATE),this.context.getValue("peerSessionStore").emit(R.ROOM_NODE_RECONNECTED))}),5e3,{leading:!0,maxWait:1e3}))}get peerId(){return this.context.getValue("peerId")}get mediaJoined(){return a(this,Xi,cs).mediaJoined}set mediaJoined(t){a(this,Xi,cs).mediaJoined=t}reset(){a(this,z).closeAllProducers(),a(this,z).closeAllConsumers(),a(this,Ot).clear(),a(this,fi).clear(),v(this,mr,null),a(this,ss).stop(),a(this,z).stopAllTransports(),a(this,z).reset(),v(this,ss,new ih)}joinRoom(t,e){return u(this,arguments,function*(r,i,n=!1,s=!1,o={}){a(this,Xi,cs).mediaJoinAttempted=!0,v(this,is,!0),n&&this.reset();try{return yield a(this,ss).push(()=>F(this,lu,Cg).call(this,r,i,s,o),"joinRoom")}catch(c){return l.error("Error in room joining process",{error:c}),this.context.getValue("peerSessionStore").emit(R.ROOM_NODE_FAILED),{roomJoined:!1}}})}initializeConnection(t,e){return u(this,arguments,function*(r,i,n=!1,s={}){return a(this,mr)?a(this,mr):(v(this,mr,(()=>u(this,null,function*(){try{yield F(this,Lc,pu).call(this,r,i,n,s)}catch(o){throw v(this,mr,null),o}}))()),a(this,mr))})}getConsumers(){return a(this,z).consumers}leaveRoom(){return u(this,null,function*(){var t;a(this,z).stopAllTransports(),v(this,ns,!1),a(this,Xi,cs).mediaJoinAttempted=!1;const e={closeRoom:!1};try{const r=yield a(this,yt).sendMessagePromise(a(this,Dt).leaveRoom,dI.toBinary(e));(t=QI.fromBinary(r.payload))!=null&&t.closed||l.warn("weird state on peer closed and should not happen")}catch(r){l.error("error on sending leave room request",{error:r})}J.callEnded(),S.destruct()})}activatePeers(t){return u(this,null,function*(){return this.createConsumers(t)})}createConsumers(t){return u(this,null,function*(){return t.length===0?Promise.resolve():a(this,z).createConsumers(t)})}closeConsumers(t){return u(this,null,function*(){if(!t.length)return;const e=t.reduce((r,i)=>{const n=a(this,z).producerIdToConsumerIdMap.get(i.producerId);return n?(r.push(n),r):(l.warn(`consumer not found in close consumers: ${i.producerId}`),r)},[]);yield a(this,z).closeConsumers(e)})}_shareWebcam(t,e){return u(this,null,function*(){const r=e==="video/VP9"?ke.WEBCAM:ke.WEBCAM_BACKUP,i=F(this,lt,St).call(this,r);if(i){const p=yield i;if(a(this,z).producers.has(p)){const g=a(this,z).producers.get(p);if(!g.closed)return yield g.replaceTrack({track:t}),yield this.resumeWebcam(r),t;yield this.disableWebcam(e)}return this._shareWebcam(t,e)}const n=[e].concat(Ht.filter(p=>p!==e)),s=F(this,Tu,Vg).call(this,t,n),o=js(this.context,"disableSimulcast"),c=a(this,$r)===Le.CF?re.ENABLE_CF_SIMULCAST:re.ENABLE_HIVE_SIMULCAST;!o&&Y.hasFeature(c)?(l.info(`Simulcast enabled for SFU: ${a(this,$r)}`),s.encodings=KD(t)):l.info(`Simulcast disabled for webcam producer, SFU: ${a(this,$r)}`),Y.hasFeature(re.TRACK_HINT)&&(s.track.contentHint=Y.getValue(re.TRACK_HINT));const d=()=>{l.info("Disabling video due to the producer closure"),a(this,Ot).delete(r)},h=a(this,z).createProducer(s,d);return F(this,ds,Ya).call(this,r,h.then(p=>p.id)),h.then(p=>p.track)})}shareWebcam(t){return u(this,null,function*(){var e;if(t===void 0)return null;const r=(e=Y.getValue(re.FORCE_VIDEO_CODEC))==null?void 0:e.toString();if(r)return l.debug(`Calling _shareWebcam with forced video codec: ${r}`),this._shareWebcam(t,r);const i=Ht.filter(n=>{var s,o;return((o=(s=a(this,Ka).sender)==null?void 0:s.video)==null?void 0:o.codecs.findIndex(c=>c.mimeType===n))>=0&&a(this,os).get(n).size>0});return i.length===0&&i.push(Ht[0]),yield Promise.all(i.map(n=>(l.debug(`Calling _shareWebcam with video codec: ${n}`),this._shareWebcam(t,n)))),t})}shareScreen(t){return u(this,null,function*(){const{video:e,audio:r}=t;if(e===void 0)return;const i={track:e,codecOptions:[{name:"VP8"}],appData:{screenShare:!0,e2ee:this.e2ee,supportsRemoteControl:Re.isElectron()},stopTracks:!1},n=()=>{l.info("Disabling screenShare due to the producer closure"),a(this,Ot).delete(ke.SCREENSHARE_VIDEO),a(this,Ot).delete(ke.SCREENSHARE_AUDIO)},s=a(this,z).createProducer(i,n);F(this,ds,Ya).call(this,ke.SCREENSHARE_VIDEO,s.then(c=>c.id));let o;if(r){const c={track:r,codecOptions:[{name:"opus"}],appData:{screenShare:!0,e2ee:this.e2ee,supportsRemoteControl:Re.isElectron()},stopTracks:!1,zeroRtpOnPause:a(this,$r)!==Le.CF},d=()=>{};o=a(this,z).createProducer(c,d),F(this,ds,Ya).call(this,ke.SCREENSHARE_AUDIO,o.then(h=>h.id))}yield Promise.all([s,o||Promise.resolve()]),J.screenShareStart()})}shareMic(t){return u(this,null,function*(){try{if(t===void 0)throw new Ut("track undefined");const e=F(this,lt,St).call(this,ke.MIC);if(e){const s=yield e;if(a(this,z).producers.has(s)){const o=a(this,z).producers.get(s);if(!o.closed){yield o.replaceTrack({track:t}),yield this.resumeMic(),a(this,qt)&&(a(this,qt).audioTrack=t,a(this,qt).producerId=s,a(this,qt).start());return}yield a(this,z).closeProducer(s,{stopTrack:!1})}yield this.shareMic(t);return}const r=F(this,Eu,Lg).call(this,t),i=()=>{a(this,Ot).delete(ke.MIC)},n=a(this,z).createProducer(r,i);F(this,ds,Ya).call(this,ke.MIC,n.then(s=>s.id)),yield n.then(s=>{a(this,qt)&&(a(this,qt).audioTrack=s.track,a(this,qt).producerId=s.id,a(this,qt).start())})}catch(e){throw new w(e)}})}pauseMic(){return u(this,null,function*(){var t;const e=yield F(this,lt,St).call(this,ke.MIC),r=a(this,z).producers.get(e);if(!r){l.error("pauseMic::could_not_find_mic_producer");return}if(r.paused){l.info("pauseMic::mic_producer_already_paused");return}r.pause(),(t=a(this,qt))==null||t.stop();const i={producerId:r.id,pause:!0};a(this,yt).sendMessage(a(this,Dt).toggleProducer,hc.toBinary(i))})}pauseWebcam(){return u(this,null,function*(){const t=yield F(this,lt,St).call(this,ke.WEBCAM),e=yield F(this,lt,St).call(this,ke.WEBCAM_BACKUP),r=a(this,z).producers.get(t),i=a(this,z).producers.get(e);if(!r&&!i){l.error("pauseWebcam::could_not_find_webcam_producer");return}const n=s=>{const o={producerId:s.id,pause:!0};a(this,yt).sendMessage(a(this,Dt).toggleProducer,hc.toBinary(o))};r&&(r.pause(),n(r)),i&&(i.pause(),n(i))})}resumeMic(){return u(this,null,function*(){const t=yield F(this,lt,St).call(this,ke.MIC),e=a(this,z).producers.get(t);if(!e){l.error("resumeMic::could_not_find_mic_producer");return}if(!e.pause){l.info("resumeMic::mic_producer_already_resumed");return}e.resume(),e.appData.e2ee&&this.context.getValue("peerSessionStore").emit(R.E2EE_ACTIVE_PRODUCER,e);const r={producerId:e.id,pause:!1};a(this,yt).sendMessage(a(this,Dt).toggleProducer,hc.toBinary(r))})}resumeWebcam(){return u(this,arguments,function*(t=ke.WEBCAM){const e=yield F(this,lt,St).call(this,t),r=a(this,z).producers.get(e);if(!r){l.error("resumeWebcam::could_not_find_webcam_producer");return}if(!r.paused){l.info("resumeWebcam::webcam_producer_already_resumed");return}r.resume(),r.appData.e2ee&&this.context.getValue("peerSessionStore").emit(R.E2EE_ACTIVE_PRODUCER,r);const i={producerId:r.id,pause:!1};a(this,yt).sendMessage(a(this,Dt).toggleProducer,hc.toBinary(i))})}disableWebcam(t){return u(this,null,function*(){const e=t==="video/VP9"?ke.WEBCAM:ke.WEBCAM_BACKUP,r=yield F(this,lt,St).call(this,e);F(this,Su,Ng).call(this,e),r&&(yield a(this,z).closeProducer(r))})}disableMic(){return u(this,null,function*(){var t;const e=yield F(this,lt,St).call(this,ke.MIC);e&&(yield a(this,z).closeProducer(e)),(t=a(this,qt))==null||t.stop(),a(this,Ot).delete(ke.MIC)})}disableScreenShare(){return u(this,null,function*(){l.info("screen_sharing_stopped"),J.screenShareStop();const t=yield F(this,lt,St).call(this,ke.SCREENSHARE_VIDEO),e=yield F(this,lt,St).call(this,ke.SCREENSHARE_AUDIO);t&&(yield a(this,z).closeProducer(t)),e&&(yield a(this,z).closeProducer(e)),a(this,fi).clear(),a(this,Ot).delete(ke.SCREENSHARE_VIDEO),a(this,Ot).delete(ke.SCREENSHARE_AUDIO)})}muteSelf(){return u(this,null,function*(){this.pauseMic()})}unmuteSelf(){return u(this,null,function*(){})}resetVideoProducers(t,e){return u(this,null,function*(){if(t){const r=yield F(this,lt,St).call(this,ke.WEBCAM),i=yield F(this,lt,St).call(this,ke.WEBCAM_BACKUP);yield a(this,z).closeProducer(r,{stopTrack:!1}),yield a(this,z).closeProducer(i,{stopTrack:!1}),this.shareWebcam(t)}if(e){const r=yield F(this,lt,St).call(this,ke.SCREENSHARE_VIDEO);yield a(this,z).closeProducer(r,{stopTrack:!1}),this.shareScreen({video:e})}})}changeDisplayName(t,e){return u(this,null,function*(){const r={displayName:t,participantId:e!=null?e:this.peerId};if(!(yield a(this,z).socketHandler.changeDisplayName(r)))throw new Error("failed to change display name!")})}kick(t){const e={peerIds:[t]};a(this,z).socketHandler.kickPeer(e)}kickAll(){a(this,z).socketHandler.kickAll()}muteAll(t){return u(this,null,function*(){if(!(yield a(this,z).socketHandler.hostControlForAll("audio")))throw new Error("failed to mute all participant")})}muteAllVideo(){return u(this,null,function*(){if(!(yield a(this,z).socketHandler.hostControlForAll("video")))throw new Error("failed to mute all video participant")})}disableAudio(t){return u(this,null,function*(){if(!(yield a(this,z).socketHandler.hostControlForPeer(t,"audio")))throw new Error("failed to mute given participant")})}disableVideo(t){return u(this,null,function*(){if(!(yield a(this,z).socketHandler.hostControlForPeer(t,"video")))throw new Error("failed to mute video of given participant")})}pinPeer(t){return u(this,null,function*(){const e={participantId:t!=null?t:""};try{yield a(this,yt).sendMessagePromise(a(this,Dt).globalPinPeer,bI.toBinary(e))}catch(r){l.error("Error in pinning peer:",{error:r})}})}validateScreenShare(t){return this.peerId===t.peerId&&a(this,z).producers.get(t.producerId)&&a(this,fi).add(t.consumerPeerId),a(this,fi).size}switchConsumersToLayer(t,e){return u(this,null,function*(){const r=t.map(i=>this.getConsumers().get(i));a(this,z).switchConsumersToLayer(r,e)})}handleSocketEvents(){return u(this,null,function*(){a(this,yt).on(a(this,Dt).peerProducerCreateBroadcast,({payload:t})=>{var e,r;if(this.mediaJoined)try{const{participantId:i,producerState:n}=CC.fromBinary(t);if(i===this.peerId)return;if(n!=null&&n.mimeType||(n.mimeType=n.kind===jr.AUDIO?"audio/opus":"video/VP8"),n.kind===jr.VIDEO&&!n.screenShare&&((r=(e=a(this,Ka).receiver)==null?void 0:e.video)==null?void 0:r.codecs.findIndex(s=>s.mimeType===Ht[0]))>=0&&a(this,as).get(Ht[0]).has(i)&&n.mimeType!==Ht[0]){l.warn(`Ignoring producer: ${n.producerId}`);return}l.info(`producer created broadcast: ${i}, producer state: ${n}`),this.context.getValue("peerSessionStore").emit(R.NEW_PRODUCER,{peerId:i,producer:G(L({},n),{kind:n.kind===jr.AUDIO?"audio":"video",producingPeerId:i})})}catch(i){l.error("error in peer-producer-create-broadcast",{error:i})}}),a(this,yt).on(a(this,Dt).peerProducerToggleBroadcast,({payload:t})=>{if(this.mediaJoined)try{const{participantId:e,initiatorParticipantId:r,producerState:{kind:i,pause:n,producerId:s}}=Im.fromBinary(t),o=i===jr.AUDIO?"audio":"video";if(l.info(`producer toggle broadcast: ${e}, producerId: ${s}, kind:${o}, paused:${n} payload: ${JSON.stringify(Im.fromBinary(t))}`),e===this.peerId&&r!==this.peerId&&n&&this.context.getValue("peerSessionStore").emit(o==="audio"?R.MUTE_SELF:R.MUTE_SELF_VIDEO),e===this.peerId)return;this.context.getValue("peerSessionStore").emit(R.PRODUCER_TOGGLE,{peerId:e,producerId:s,paused:n,kind:o}),Array.from(this.getConsumers().values()).filter(c=>c.producerId===s).forEach(c=>{c.paused!==n&&(l.debug(`consumer state mismatched for ${c.id}. updating consumer pause state ${c.paused} to ${n}`),n?(c.pause(),this.context.getValue("peerSessionStore").emit(R.CONSUMER_PAUSED,{id:c.id})):(c.resume(),this.context.getValue("peerSessionStore").emit(R.CONSUMER_RESUMED,{id:c.id})))})}catch(e){l.error("error in producer toggle broadcast handler",{error:e})}}),a(this,yt).on(a(this,Dt).peerLeaveBroadcast,({payload:t})=>{if(this.mediaJoined)try{const{participantId:e}=Bu.fromBinary(t);if(e===this.peerId)return;l.info(`peer left broadcast:${e}`),a(this,fi).delete(e),a(this,z).consumers.forEach(r=>{r.peerId===e&&r.close()}),this.context.getValue("peerSessionStore").emit(R.PEER_CLOSED,{id:e})}catch(e){l.error("error in peer left broadcast",{error:e})}}),a(this,yt).on(a(this,Dt).peerProducerCloseBroadcast,({payload:t})=>{if(this.mediaJoined)try{const{participantId:e,producerState:{producerId:r}}=MC.fromBinary(t);if(e===this.peerId)return;l.info(`producer closed broadcast:${e}`),this.context.getValue("peerSessionStore").emit(R.PRODUCER_CLOSED,{peerId:e,producerId:r});const i=a(this,z).producerIdToConsumerIdMap.get(r);if(!i){l.warn(`no consumer found for producer:${r}`);return}l.info(`closing consumer ${i}, producer id: ${r}`),a(this,z).closeConsumer(i).then(()=>{l.info(`closed consumer: ${i}`),a(this,z).producerIdToConsumerIdMap.delete(r),this.context.getValue("peerSessionStore").emit(R.CONSUMER_CLOSED,{id:i})}).catch(n=>{l.error("error closing consumer",{error:n})})}catch(e){l.error("error on producer close broadcast",{error:e})}}),a(this,yt).on(a(this,Dt).mediaRoomTerminationBroadcastResponse,()=>{!this.mediaJoined&&!a(this,is)&&!a(this,ns)||(l.warn("media hub termination broadcast received, rejoining room"),this.context.getValue("peerSessionStore").emit(R.ROOM_NODE_DISCONNECTED),a(this,Nc).call(this))})})}handleCallstatsEvents(){J.onConsumerScore(t=>{t.forEach((e,r)=>{const i=a(this,z).consumers.get(r);i&&this.context.getValue("peerSessionStore").emit(R.CONSUMER_SCORE_UPDATE,{id:r,kind:i.kind,peerId:i.peerId,score:e.score,scoreStats:e})})}),J.onProducerScore(t=>{t.forEach((e,r)=>{const i=Array.from(a(this,z).producers.values()).find(n=>n.id===r);i&&this.context.getValue("peerSessionStore").emit(R.PRODUCER_SCORE_UPDATE,{id:r,kind:i.kind,appData:i.appData,score:e.score,scoreStats:e})})})}handlePeerCapabilities(t,e){var r,i,n,s;for(let o=0;o<=Ht.length;o+=1){const c=Ht[o];if(((i=(r=e==null?void 0:e.receiver)==null?void 0:r.video)==null?void 0:i.codecs.findIndex(d=>d.mimeType===c))>=0||o===Ht.length-1){a(this,os).get(c).add(t);break}}for(let o=0;o<=Ht.length;o+=1){const c=Ht[o];if(((s=(n=e==null?void 0:e.sender)==null?void 0:n.video)==null?void 0:s.codecs.findIndex(d=>d.mimeType===c))>=0||o===Ht.length-1){a(this,as).get(c).add(t);break}}}handlePeerLeaving(t){Y.hasFeature(re.FORCE_VIDEO_CODEC)||(a(this,as).forEach(e=>e.delete(t)),a(this,os).forEach((e,r)=>{e.delete(t),!(e.size!==0||r===Ht[0])&&this.disableWebcam(r)}))}},Dc=new WeakMap,Oc=new WeakMap,yt=new WeakMap,z=new WeakMap,Ka=new WeakMap,$r=new WeakMap,Dt=new WeakMap,is=new WeakMap,ns=new WeakMap,ss=new WeakMap,Nc=new WeakMap,mr=new WeakMap,fi=new WeakMap,za=new WeakMap,as=new WeakMap,os=new WeakMap,Ot=new WeakMap,qt=new WeakMap,Xi=new WeakSet,cs=function(){return this.context.getValue("connectionHandler")},lu=new WeakSet,Cg=function(t,e,r,i){return u(this,null,function*(){v(this,Oc,t);try{return a(this,mr)?yield a(this,mr):yield F(this,Lc,pu).call(this,t,e,r,i),F(this,hu,Rg).call(this,e),{roomJoined:yield F(this,uu,Pg).call(this)}}catch(n){return l.error("Failed to complete room join",{error:n}),{roomJoined:!1}}finally{v(this,mr,null)}})},uu=new WeakSet,Pg=function(){return u(this,null,function*(){try{this.mediaJoined=!0;const{roomState:t}=yield a(this,z).socketHandler.notifySelfJoinComplete();return v(this,Dc,t.roomUuid),v(this,ns,!0),v(this,is,!1),!0}catch(t){return l.error("Error completing room join",{error:t}),this.mediaJoined=!1,!1}})},hu=new WeakSet,Rg=function(t){navigator.product!=="ReactNative"&&setTimeout(()=>{try{const e={userId:this.context.getValue("userId"),peerId:this.peerId,roomUUID:t,roomViewType:"groupCall",deviceInfo:G(L({},Re.getDeviceInfo()),{userAgent:navigator.userAgent,memory:navigator.deviceMemory,cpus:navigator.hardwareConcurrency}),sdkName:this.context.getValue("sdkName"),sdkVersion:this.context.getValue("sdkVersion"),metaData:{},permissions:{}};J.roomJoined(e)}catch(e){l.error("Error reporting room joined analytics",{error:e})}},0)},Lc=new WeakSet,pu=function(t,e,r,i){return u(this,null,function*(){var n,s;try{(s=a(this,za))!=null||v(this,za,F(n=gy,mu,Mg).call(n));const o=F(this,fu,Ag).call(this);yield F(this,vu,Dg).call(this,t,e,r,o),yield a(this,z).setupTransports({send:!0,recv:!0}),yield F(this,yu,Og).call(this,i)}catch(o){throw l.error("Failed to initialize connection",{error:o}),o}})},mu=new WeakSet,Mg=function(){const{ipInfo:t}=ht();if(!(t!=null&&t.loc))return;const[e,r]=t.loc.split(",").map(parseFloat);return{latitude:e,longitude:r}},fu=new WeakSet,Ag=function(){var t;const e=(t=Y.getValue(re.FORCE_VIDEO_CODEC))==null?void 0:t.toString(),r=$O(e);return v(this,Ka,r),r},vu=new WeakSet,Dg=function(t,e,r,i){return u(this,null,function*(){yield ey((n,s)=>u(this,null,function*(){if(!a(this,yt).isConnected){s(new Error("Socket is not connected"));return}n>0&&l.warn("Retry: send joinRoom message",{debuggingHint:`Retry attempt ${n}`});try{yield a(this,z).socketHandler.joinRoom(e,t,i,r,a(this,za))}catch(o){throw l.error("Failed to send joinRoom message after retries",{error:o}),o}}),{delayTime:1e3,strategy:"exponential",maxRetryCount:Y.hasFeature(re.ENABLE_HIVE_INFINITE_RETRIES)?1/0:3})})},yu=new WeakSet,Og=function(t){return u(this,null,function*(){if(!(a(this,$r)===Le.HIVE||!Y.hasFeature(re.PRECREATE_PRODUCERS)||!t))try{const e=[];if(t.canProduceVideo===q.Allowed&&e.push(this.shareWebcam(d1(!0))),t.canProduceAudio===q.Allowed){const r=c1(!0);r&&e.push(this.shareMic(r))}e.length>0&&(yield Promise.all(e))}catch(e){l.warn("Failed to precreate producers",{error:e})}})},lt=new WeakSet,St=function(t){return a(this,Ot).get(t)},ds=new WeakSet,Ya=function(t,e){return a(this,Ot).set(t,e)},Su=new WeakSet,Ng=function(t){return a(this,Ot).delete(t)},Eu=new WeakSet,Lg=function(t){return{track:t,encodings:[{priority:"high"}],codecOptions:[{name:"opus"}],appData:{e2ee:this.e2ee},stopTracks:!1,zeroRtpOnPause:a(this,$r)!==Le.CF}},Tu=new WeakSet,Vg=function(t,e){return{track:t,codecOptions:e?e.map(r=>({name:r.split("/")[1]})):[{name:"VP8"}],appData:{screenShare:!1,e2ee:this.e2ee},stopTracks:!1}},f(gu,mu),gu);let he=gy;fe([S.trace("MediaNodeClient.reset",{country:S.location.country})],he.prototype,"reset",1);fe([S.trace("MediaNodeClient.joinRoom")],he.prototype,"joinRoom",1);fe([S.trace("MediaNodeClient.leaveRoom")],he.prototype,"leaveRoom",1);fe([S.trace("MediaNodeClient.activatePeers")],he.prototype,"activatePeers",1);fe([S.trace("MediaNodeClient.createConsumers")],he.prototype,"createConsumers",1);fe([S.trace("MediaNodeClient.closeConsumers")],he.prototype,"closeConsumers",1);fe([S.trace("MediaNodeClient._shareWebcam")],he.prototype,"_shareWebcam",1);fe([S.trace("MediaNodeClient.shareWebcam")],he.prototype,"shareWebcam",1);fe([S.trace("MediaNodeClient.shareScreen")],he.prototype,"shareScreen",1);fe([S.trace("MediaNodeClient.shareMic")],he.prototype,"shareMic",1);fe([S.trace("MediaNodeClient.pauseMic")],he.prototype,"pauseMic",1);fe([S.trace("MediaNodeClient.pauseWebcam")],he.prototype,"pauseWebcam",1);fe([S.trace("MediaNodeClient.resumeMic")],he.prototype,"resumeMic",1);fe([S.trace("MediaNodeClient.resumeWebcam")],he.prototype,"resumeWebcam",1);fe([S.trace("MediaNodeClient.disableWebcam")],he.prototype,"disableWebcam",1);fe([S.trace("HiveClient.disableMic")],he.prototype,"disableMic",1);fe([S.trace("HiveClient.disableScreenShare")],he.prototype,"disableScreenShare",1);fe([S.trace("MediaNodeClient.muteSelf")],he.prototype,"muteSelf",1);fe([S.trace("MediaNodeClient.resetVideoProducers")],he.prototype,"resetVideoProducers",1);fe([S.trace("MediaNodeClient.changeDisplayName")],he.prototype,"changeDisplayName",1);fe([S.trace("MediaNodeClient.kickPeer")],he.prototype,"kick",1);fe([S.trace("MediaNodeClient.kickAllPeers")],he.prototype,"kickAll",1);fe([S.trace("MediaNodeClient.muteAll")],he.prototype,"muteAll",1);fe([S.trace("MediaNodeClient.muteAllVideo")],he.prototype,"muteAllVideo",1);fe([S.trace("MediaNodeClient.disableAudio")],he.prototype,"disableAudio",1);fe([S.trace("MediaNodeClient.disableVideo")],he.prototype,"disableVideo",1);fe([S.trace("MediaNodeClient.pinPeer")],he.prototype,"pinPeer",1);fe([S.trace("MediaNodeClient.validateScreenShare")],he.prototype,"validateScreenShare",1);function fy(t,e,r){const i=t.getValue("roomNodeClient");if(i){if(i)return i;throw new Error("Room node client already set up.")}const n=new he(t,e,r);return t.setValue("roomNodeClient",n),n}function vy(t){const e=t.getValue("roomNodeClient");try{e==null||e.leaveRoom()}catch{l.error("roomNodeClient::cleanupRoomNodeClient")}t.setValue("roomNodeClient",void 0)}var h1=Object.defineProperty,p1=Object.getOwnPropertyDescriptor,jn=(t,e,r,i)=>{for(var n=i>1?void 0:i?p1(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&h1(e,r,n),n},Zi,Nr,de,Nt,Gt,xg;const yy=(xg=class{constructor(t,e,r,i){f(this,Nt),m(this,"self"),m(this,"authToken"),f(this,Zi,void 0),m(this,"viewType"),f(this,Nr,void 0),f(this,de,void 0);const{socket:n}=r,s=t.getValue("authToken");this.self=e,v(this,de,t),this.viewType=i,this.authToken=s,v(this,Zi,n),v(this,Nr,r),e.config.viewType!==Ft.Chat&&this.setupEvents()}get peerId(){return a(this,de).getValue("peerId")}get mediaJoined(){return a(this,de).getValue("connectionHandler").mediaJoined}static init(t,e,r,i,n){return u(this,null,function*(){const s=ht(),o=t.getValue("peerId"),c=!!t.getValue("cachedUserDetails"),d=yield nt.__init__(t,r,i,n,n.name,c);if(navigator.product!=="ReactNative"){const h=!Y.hasFeature(re.PRECALL_BANDWIDTH_TEST);setTimeout(()=>u(this,null,function*(){const p=yield d.getAllDevices();l.info("populated_full_device_list",{devices:JSON.stringify(p)}),J.devices("AUDIO",p==null?void 0:p.filter(g=>g.kind==="audioinput")),J.devices("VIDEO",p==null?void 0:p.filter(g=>g.kind==="videoinput")),J.devices("SPEAKER",p==null?void 0:p.filter(g=>g.kind==="audiooutput")),l.info("Callstats:: initializing");try{yield J.initialize({peerId:o,engineName:Re.getDeviceInfo().engineName,env:t.getValue("env"),iceServers:yield s.getICEServers(),apiBase:t.getValue("apiBase"),flags:Y.getAllFlags(),logger:l,apiHostnames:fv(t),skipConnectivityChecks:h}),l.info("Callstats:: initialized")}catch(g){l.error("Callstats:: initialization failed",{error:g})}}),0)}else l.info("Callstats:: Skipped initialization due to navigator product being ReactNative.");return new yy(t,d,e,n.viewType)})}shareMediaTracks(){return u(this,null,function*(){var t;const{audioTrack:e,videoTrack:r,permissions:i,audioEnabled:n,videoEnabled:s,screenShareEnabled:o,screenShareTracks:c}=this.self;if(i.canProduceAudio===q.Allowed&&n)try{yield a(this,Nt,Gt).shareMic(e),this.self.audioEnabled||a(this,Nt,Gt).pauseMic()}catch{this.self.disableAudio()}if(i.canProduceVideo===q.Allowed&&s)try{const d=yield a(this,Nt,Gt).shareWebcam(r);d&&d.id!==r.id&&Y.hasFeature(re.EXP_RESHARE)&&(yield a(this,Nt,Gt).shareWebcam(d)),this.self.videoEnabled||a(this,Nt,Gt).pauseWebcam()}catch{this.self.disableVideo()}if(i.canProduceScreenshare===q.Allowed&&o)try{yield(t=a(this,Nt,Gt))==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(){l.info("SelController.waitlisted"),this.self.waitlistStatus="waiting",this.self.roomState="waitlisted",this.self.emit("waitlisted")}waitlistAcceptHandler(){if(l.info("SelController.waitlistAccepted"),this.self.waitlistStatus==="accepted"){l.warn("SelfController.WAITLIST_ACCEPTED.UserAlreadyAccepted");return}this.self.waitlistStatus="accepted",this.joinRoom()}waitlistRejectedHandler(){if(l.info("SelfController.waitlistRejected"),this.self.waitlistStatus==="rejected"){l.warn("SelfController.WAITLIST_REJECTED.UserAlreadyRejected");return}this.self.waitlistStatus="rejected",this.leaveRoom("rejected")}resetSelf(t){return u(this,null,function*(){J.callEnded(),a(this,Nt,Gt).reset(),t&&(yield this.joinRoom(t))})}setupEvents(){a(this,de).getValue("peerSessionStore").on(R.RESET_PRODUCER_STATE,()=>u(this,null,function*(){this.mediaJoined&&this.shareMediaTracks()})),a(this,de).getValue("peerSessionStore").on(R.ROOM_NODE_RECONNECTED,()=>{this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:!0})}),a(this,de).getValue("peerSessionStore").on(R.ROOM_NODE_DISCONNECTED,()=>{this.self.roomState!=="disconnected"&&(this.self.roomState="disconnected",this.self.emit("roomLeft",{state:"disconnected"}))}),a(this,de).getValue("peerSessionStore").on(R.ROOM_NODE_FAILED,()=>{this.self.roomState="failed",this.self.emit("roomLeft",{state:"failed"})}),a(this,de).getValue("peerSessionStore").on(R.SOCKET_SERVICE_RECONNECTED,({wasJoinAttempted:t})=>{t===!1&&(this.self.roomState="init"),this.resetSelf(t)}),a(this,de).getValue("peerSessionStore").on(R.SOCKET_SERVICE_DISCONNECTED,({joinAttempted:t})=>{if(this.self.roomState==="disconnected")return;let{peerId:e}=this;t&&Y.hasFeature(re.REFRESH_ID_ON_DISCONNECTION)&&(e=Gs()),a(this,Zi).updateURL(e),S.resetPeerId(e),ht().setHeader("dyte-tracing-id",e),Rn.remapContext(e,a(this,de)),this.self.roomState="disconnected",this.self.emit("roomLeft",{state:"disconnected"})}),a(this,de).getValue("peerSessionStore").on(R.SOCKET_SERVICE_FAILED,()=>{this.self.roomState="failed",this.self.emit("roomLeft",{state:"failed"})}),a(this,Nr).on(B.waitingRoomRequestAccepted,()=>{this.waitlistAcceptHandler()}),a(this,Nr).on(Gc.updateUserPreset,t=>{t.updatePeersPresets.forEach(e=>{e.userIds===this.self.userId&&a(this,de).getValue("peerSessionStore").emit(R.UPDATE_PERMISSIONS,e.patch)})}),a(this,Nr).on(B.waitingRoomRequestDenied,()=>{this.waitlistRejectedHandler()}),a(this,Nr).on(B.kick,()=>{this.kickHandler({kickType:"kick"})}),a(this,Nr).on(B.kickAll,()=>{this.kickHandler({kickType:"kickAll"})}),a(this,de).getValue("peerSessionStore").onAsync(R.JOIN_MEDIA_ROOM,this.joinMediaRoom.bind(this)),a(this,de).getValue("peerSessionStore").on(R.PRODUCER_SCORE_UPDATE,({score:t,kind:e,appData:r,scoreStats:i})=>{var n;const s=(n=r==null?void 0:r.screenShare)!=null?n:!1;this.self.emit("mediaScoreUpdate",{kind:e,isScreenshare:s,score:t,participantId:this.self.id,scoreStats:i})}),a(this,de).getValue("peerSessionStore").on(R.MUTE_SELF,()=>u(this,null,function*(){this.self.audioEnabled&&(yield this.self.disableAudio(),J.audioOff())})),a(this,de).getValue("peerSessionStore").on(R.MUTE_SELF_VIDEO,()=>u(this,null,function*(){this.self.videoEnabled&&(yield this.self.disableVideo(),J.videoOff())})),a(this,de).getValue("peerSessionStore").onAsync(R.LEAVE_MEDIA_ROOM,this.leaveMediaRoom.bind(this)),a(this,de).getValue("peerSessionStore").on(R.PIP_HANGUP,this.leaveRoom.bind(this))}joinRoom(t=!1){return u(this,null,function*(){try{const{peer:e}=yield a(this,Nr).joinRoom(this.self);a(this,Nr).socket.flush();const r=cp(e.stageType);if(a(this,de).setValue("stageStatus",r,!1),e.waitlisted){this.waitlistedHandler();return}yield this.joinMediaRoom(t),a(this,de).notify("stageStatus")}catch(e){throw l.error("Error in joinRoom",{error:e}),e}})}leaveRoom(t="left"){return u(this,null,function*(){var e,r;if(t==="rejected"){try{(e=a(this,Zi))==null||e.disconnect()}catch{l.error("SelfController::leaveRoom::socketDisconnect")}this.self.roomState=t,this.self.emit("roomLeft",{state:t});return}this.self.setIsPinned(!1),a(this,de).setValue("stageStatus","OFF_STAGE",!1),yield this.leaveMediaRoom(t),a(this,de).notify("stageStatus");try{(r=a(this,Zi))==null||r.disconnect()}catch{l.error("SelfController::leaveRoom::socketDisconnect")}vy(a(this,de)),yield a(this,de).getValue("roomSocketHandler").cleanup(),this.self.roomState=t,this.self.emit("roomLeft",{state:t})})}joinMediaRoom(t=!1){return u(this,null,function*(){var e,r;const{peerId:i,viewType:n,meetingId:s,stageStatus:o,roomNodeOptions:c}=a(this,de).getAllValues(),{sfu:d}=c;try{if(n===Ft.Livestream){if(o!=="ON_STAGE"){this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:t});return}fy(a(this,de),d,{socket:a(this,Zi),peerId:i})}const{canProduceAudio:h,canProduceVideo:p,canProduceScreenshare:g}=this.self.permissions,{roomJoined:y}=(r=yield(e=a(this,Nt,Gt))==null?void 0:e.joinRoom(this.self.name,s,t,t,{canProduceAudio:h,canProduceVideo:p,canProduceScreenshare:g}))!=null?r:{};if(!y)return;o==="ON_STAGE"&&(yield this.shareMediaTracks()),this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:t})}catch(h){throw l.error("Error:SelfController.mediaRoomJoin",{error:h}),new w("Error: could not join media room","0002")}})}leaveMediaRoom(t){return u(this,null,function*(){const e=a(this,de).getValue("viewType");t!=="connected-meeting"&&(yield this.cleanupSelf()),!(t==="stageLeft"&&e===Ft.Webinar)&&a(this,Nt,Gt)&&(a(this,Nt,Gt).mediaJoined&&t!=="disconnected"&&(yield a(this,Nt,Gt).leaveRoom()),!(t==="stageLeft"&&e===Ft.Livestream)&&(a(this,Nt,Gt).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()})}},Zi=new WeakMap,Nr=new WeakMap,de=new WeakMap,Nt=new WeakSet,Gt=function(){return a(this,de).getValue("roomNodeClient")},xg);let $i=yy;jn([S.trace("SelfController.resetSelf")],$i.prototype,"resetSelf",1);jn([S.trace("SelfController.setupEvents")],$i.prototype,"setupEvents",1);jn([S.trace("SelfController.joinRoom")],$i.prototype,"joinRoom",1);jn([S.trace("SelfController.leaveRoom")],$i.prototype,"leaveRoom",1);jn([S.trace("SelfController.joinMediaRoom")],$i.prototype,"joinMediaRoom",1);jn([S.trace("SelfController.leaveMediaRoom")],$i.prototype,"leaveMediaRoom",1);jn([S.trace("SelfController.init")],$i,"init",1);var kd;class m1{constructor(e){f(this,kd,void 0),v(this,kd,e)}on(e,r){let i;e===B.roomPeerCount?i=Rm.fromBinary.bind(Rm):i=Bm.fromBinary.bind(Bm),a(this,kd).on(e,({payload:n})=>{const s=i(n);return r(s)})}}kd=new WeakMap;var bd;class g1{constructor(e){f(this,bd,void 0),v(this,bd,e)}on(e,r){let i,n;switch(e){case B.transcript:{i=Fl.fromBinary.bind(Fl),n=Fl.create();break}default:{l.debug("AISocketHandler switch case hit default, event not accounted for.");break}}a(this,bd).on(e,({payload:s})=>{let o=n;try{o=i(s)}catch(c){l.error("chatSocketHandler::on::binary_decode_error",{error:c})}return r(o)})}}bd=new WeakMap;var f1=Object.defineProperty,v1=Object.getOwnPropertyDescriptor,Ep=(t,e,r,i)=>{for(var n=i>1?void 0:i?v1(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&f1(e,r,n),n},Ri;class bl{constructor(e){f(this,Ri,void 0),v(this,Ri,e)}getPolls(){return a(this,Ri).sendMessagePromise(Qr.getPolls)}createPoll(e,r,i=!1,n=!1){const s={anonymous:i,hideVotes:n,question:e,options:r};return a(this,Ri).sendMessage(Qr.createPoll,yA.toBinary(s))}votePoll(e,r){const i={index:r,pollId:e};return a(this,Ri).sendMessage(Qr.votePoll,EA.toBinary(i))}on(e,r){let i,n;switch(e){case Qr.updatePoll:case Qr.createPoll:case Qr.votePoll:{i=Gl.fromBinary.bind(Gl),n=Gl.create();break}}a(this,Ri).on(e,({payload:s})=>{let o=n;try{o=i(s)}catch(c){l.error("pollSocketHandler::on::binary_decode_error",{error:c})}return r(o)})}removeListeners(e){a(this,Ri).removeListeners(e)}}Ri=new WeakMap;Ep([S.trace("PollSocketHandler.getPolls")],bl.prototype,"getPolls",1);Ep([S.trace("PollSocketHandler.createPoll")],bl.prototype,"createPoll",1);Ep([S.trace("PollSocketHandler.votePoll")],bl.prototype,"votePoll",1);var y1=Object.defineProperty,S1=Object.getOwnPropertyDescriptor,E1=(t,e,r,i)=>{for(var n=i>1?void 0:i?S1(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&y1(e,r,n),n},xr;class Sy{constructor(e,r){m(this,"socket"),f(this,xr,void 0),v(this,xr,e),this.socket=r,this.handleSocketEvents(),a(this,xr).setValue("roomSocketHandler",this)}cleanup(){return u(this,null,function*(){var e;try{(e=this.socket)==null||e.disconnect()}catch{l.error("roomSocketHandler::cleanup")}})}joinRoom(e){return u(this,null,function*(){var r;this.socket.joinAttempted=!0;const i={capabilities:[],peer:{displayName:(r=e.name)!=null?r:"Participant",customParticipantId:e.customParticipantId,peerId:e.id,userId:e.userId,displayPictureUrl:e.picture,waitlisted:!1},roomUuid:""},n=this.socket.sendMessagePromise(B.joinRoom,sP.toBinary(i));try{const{peer:s}=us.fromBinary((yield n).payload);a(this,xr).getValue("connectionHandler").socketJoined=!0,a(this,xr).getValue("peerSessionStore").emit(R.SOCKET_SERVICE_ROOM_JOINED,{peer:s});const o=this.getRoomState(),c=this.getRoomPeersNonPaginated(),[{room:d},{peers:h}]=yield Promise.all([o,c]);return a(this,xr).getValue("peerSessionStore").emit(R.ROOM_STATE,d),a(this,xr).getValue("peerSessionStore").emit(R.SOCKET_PEERS,h),{peer:s}}catch(s){throw l.error("RoomSocketHandler.joinRoom.failed",{error:s}),new w("Error: RoomSocketHandler.joinRoom failed.","0002",s)}})}getAllAddedParticipants(){return u(this,null,function*(){try{return HP.fromBinary((yield this.socket.sendMessagePromise(B.getAllAddedParticipants)).payload).participants.map(e=>{var r=e,{id:i}=r,n=cl(r,["id"]);return G(L({},n),{userId:i})})}catch{return[]}})}getRoomPeers(e,r,i){return u(this,null,function*(){let n;try{const s={seachQuery:e,limit:r,offset:i},o=yield this.socket.sendMessagePromise(B.getRoomPeersInfo,zC.toBinary(s));n=Bl.fromBinary(o.payload)}catch(s){l.error("getRoomPeers::binary_decode_error",{error:s})}return n})}getRoomPeersNonPaginated(){return u(this,null,function*(){let e;try{const r=yield this.socket.sendMessagePromise(B.getRoomPeersInfo);e=Bl.fromBinary(r.payload)}catch(r){l.error("getRoomJoinedPeers::binary_decode_error",{error:r})}return e})}getStagePeers(){return u(this,null,function*(){let e;try{const r=yield this.socket.sendMessagePromise(B.getRoomPeersInfo);e=Bl.fromBinary(r.payload)}catch(r){l.error("getRoomJoinedPeers::binary_decode_error",{error:r})}return e})}getPeerInfo(e){return u(this,null,function*(){let r;try{const i=yield this.socket.sendMessagePromise(B.getPeerInfo,Cv.toBinary({peerId:e}));r=us.fromBinary(i.payload)}catch(i){l.error("getPeerInfo::binary_decode_error",{error:i})}return r})}getRoomState(){return u(this,null,function*(){let e=Mm.create();try{const r=yield this.socket.sendMessagePromise(B.getRoomInfo);e=Mm.fromBinary(r.payload)}catch(r){l.error("getRoomState::binary_decode_error",{error:r})}return e})}getRoomStageState(){return u(this,null,function*(){let e=Nm.create();try{const r=yield this.socket.sendMessagePromise(B.getRoomStageState);e=Nm.fromBinary(r.payload)}catch(r){l.error("getRoomStageState::binary_decode_error",{error:r})}return e})}broadcastMessage(e,r){return u(this,null,function*(){const i={type:e,payload:new TextEncoder().encode(JSON.stringify(r)),timestamp:Date.now(),ids:[]};return this.socket.sendMessagePromise(B.broadcastMessage,fa.toBinary(i))})}broadcastToMeetings(e,r,i){return u(this,null,function*(){const n={type:e,payload:new TextEncoder().encode(JSON.stringify(i)),timestamp:Date.now(),ids:r,broadcastType:1};return this.socket.sendMessagePromise(B.broadcastToEntity,fa.toBinary(n))})}broadcastToPeers(e,r,i){return u(this,null,function*(){const n={type:e,payload:new TextEncoder().encode(JSON.stringify(i)),timestamp:Date.now(),ids:r,broadcastType:0};return this.socket.sendMessage(B.broadcastToEntity,fa.toBinary(n))})}leaveRoom(){return u(this,null,function*(){this.socket.joinAttempted=!1,this.socket.sendMessagePromise(B.leaveRoom,oP.toBinary({}))})}kick(e){return u(this,null,function*(){const r={peerIds:[e]};this.socket.sendMessage(B.kick,Rv.toBinary(r))})}kickAll(e=!1){return u(this,null,function*(){const r={propagateKickAcrossRooms:e};this.socket.sendMessage(B.kickAll,_v.toBinary(r))})}getWaitingRoomRequests(){this.socket.sendMessage(B.getWaitingRoomRequests)}acceptWaitingRoomRequest(e){const r={userIds:e};this.socket.sendMessage(B.acceptWaitingRoomRequests,zP.toBinary(r))}rejectWaitingRoomRequest(e){const r={userIds:e};this.socket.sendMessage(B.denyWaitingRoomRequests,QP.toBinary(r))}updatePermissions(e,r){return u(this,null,function*(){const i={updatePeersPresets:[]};return e.forEach(n=>{i.updatePeersPresets.push({userIds:n,patch:r})}),this.socket.sendMessagePromise(Gc.updateUserPreset,IR.toBinary(i))})}handleSocketEvents(){this.socket.on(B.broadcastMessage,({payload:e})=>{try{const r=fa.fromBinary(e);a(this,xr).getValue("peerSessionStore").emit(R.ROOM_MESSAGE,{payload:JSON.parse(new TextDecoder().decode(r.payload)),type:r.type,timestamp:r.timestamp})}catch(r){l.error("failed to decode broadcast message:",r)}}),this.socket.on(B.broadcastToEntity,({payload:e})=>{try{const r=fa.fromBinary(e);a(this,xr).getValue("peerSessionStore").emit(R.MESSAGE,{payload:JSON.parse(new TextDecoder().decode(r.payload)),type:r.type,timestamp:r.timestamp})}catch(r){l.error("failed to decode peer broadcast message:",r)}})}on(e,r){let i,n;switch(e){case B.joinRoom:case B.leaveRoom:case B.kick:case B.kickAll:{i=us.fromBinary.bind(us),n=us.create();break}case B.getWaitingRoomRequests:{i=(s,o)=>s?Om.fromBinary(s,o):{requests:[]},n=Om.create();break}case B.recordingPaused:case B.recordingStarted:case B.recordingStopped:{i=Hm.fromBinary.bind(Hm);break}case Gc.updateUserPreset:{i=Lm.fromBinary.bind(Lm);break}case _r.peerJoinedBroadcast:case or.peerJoinedBroadcast:{i=_m.fromBinary.bind(_m);break}case _r.selfJoinComplete:case or.selfJoinComplete:{i=Fu.fromBinary.bind(Fu);break}case _r.globalPeerPinBroadcast:case or.globalPeerPinBroadcast:{i=Cm.fromBinary.bind(Cm);break}case _r.selectedPeer:case or.selectedPeer:{i=Uu.fromBinary.bind(Uu);break}case _r.selectedPeerDiff:case or.selectedPeerDiff:{i=bm.fromBinary.bind(bm);break}case _r.leaveRoom:case or.leaveRoom:{i=Bu.fromBinary.bind(Bu);break}}this.socket.on(e,({payload:s})=>{let o=n;if(!i)return r(void 0);try{o=i(s)}catch(c){l.error("roomSocketHandler::on::binary_decode_error",{error:c})}return r(o)})}getUserPermissions(e){return u(this,null,function*(){const r={userIds:[e]};try{const i=yield this.socket.sendMessagePromise(Gc.getUserPresets,SR.toBinary(r)),n=bR.fromBinary(i.payload).peerPresets[0],s=new TextDecoder().decode(n.preset),o=JSON.parse(s).permissions;return{chat:o.chat,polls:o.polls,plugins:o.plugins}}catch(i){throw l.error("Error in getting user preset",{error:i}),i}})}}xr=new WeakMap;E1([S.trace("RoomSocketHandler.joinRoom")],Sy.prototype,"joinRoom",1);var Kt;class T1{constructor(e){f(this,Kt,void 0),v(this,Kt,e)}getStageRequests(){return u(this,null,function*(){const{payload:e}=yield a(this,Kt).sendMessagePromise(B.getStageRequests);return e?ql.fromBinary(e):{stageRequests:[]}})}requestAccess(){a(this,Kt).sendMessage(B.requestStageAccess)}cancelRequestAccess(){a(this,Kt).sendMessage(B.cancelStageRequest)}grantAccess(e){return u(this,null,function*(){const r={userIds:e};a(this,Kt).sendMessage(B.grantStageAccess,cA.toBinary(r))})}denyAccess(e){return u(this,null,function*(){const r={userIds:e};a(this,Kt).sendMessage(B.denyStageAccess,lA.toBinary(r))})}joinStage(){return a(this,Kt).sendMessagePromise(B.joinStage,void 0,void 0,B.peerStageStatusUpdate)}leaveStage(e){const r={userIds:[e]};return a(this,Kt).sendMessagePromise(B.leaveStage,jm.toBinary(r),void 0,B.peerStageStatusUpdate)}kick(e){const r={userIds:e};return a(this,Kt).sendMessagePromise(B.leaveStage,jm.toBinary(r))}on(e,r){let i;switch(e){case B.grantStageAccess:case B.denyStageAccess:{i=void 0;break}case B.getStagePeers:{i=Wm.fromBinary.bind(Wm);break}case B.getStageRequests:case B.requestStageAccess:case B.cancelStageRequest:{i=ql.fromBinary.bind(ql);break}case B.peerStageStatusUpdate:{i=Pm.fromBinary.bind(Pm);break}}a(this,Kt).on(e,({payload:n,id:s})=>{if(!n||!i)return r(void 0,s);const o=i(n);return r(o,s)})}getPeerInfo(e){return u(this,null,function*(){const r=yield a(this,Kt).sendMessagePromise(B.getPeerInfo,Cv.toBinary({peerId:e}));return us.fromBinary(r.payload)})}}Kt=new WeakMap;var tt;class k1{constructor(e){f(this,tt,void 0),v(this,tt,e)}addPlugin(e,r){a(this,tt).sendMessage(K.addPlugin,wM.toBinary({pluginId:e,staggered:r}))}removePlugin(e){a(this,tt).sendMessage(K.removePlugin,CM.toBinary({pluginId:e,staggered:!1}))}getActivePlugins(){return u(this,null,function*(){const{payload:e}=yield a(this,tt).sendMessagePromise(K.getPlugins);return e?YM.fromBinary(e):{plugins:[]}})}customPluginEventToRoom(e,r,i){const n={pluginId:e,pluginData:new TextEncoder().encode(JSON.stringify(r))};a(this,tt).sendMessage(K.customPluginEventToRoom,xM.toBinary(n),i)}customPluginEventToPeers(e,r,i,n){const s={pluginId:e,peerIds:r,pluginData:new TextEncoder().encode(JSON.stringify(i))};a(this,tt).sendMessage(K.customPluginEventToPeers,FM.toBinary(s),n)}enablePluginForRoom(e,r){a(this,tt).sendMessage(K.enablePluginForRoom,RM.toBinary({pluginId:e}),r)}enablePluginForPeers(e,r,i){a(this,tt).sendMessage(K.enablePluginForPeers,OM.toBinary({pluginId:e,peerIds:r}),i)}disablePluginForRoom(e,r){a(this,tt).sendMessage(K.disablePluginForRoom,AM.toBinary({pluginId:e}),r)}disablePluginForPeers(e,r,i){a(this,tt).sendMessage(K.disablePluginForPeers,LM.toBinary({pluginId:e,peerIds:r}),i)}storeInsertKeys(e,r,i,n){const s={pluginId:e,storeName:r,insertKeys:i.map(o=>({storeKey:o.key,payload:new TextEncoder().encode(JSON.stringify(o.payload))}))};a(this,tt).sendMessage(K.storeInsertKeys,Vm.toBinary(s),n)}storeGetKeys(e,r,i,n){const s={pluginId:e,storeName:r,getKeys:i.map(o=>({storeKey:o.key}))};a(this,tt).sendMessage(K.storeGetKeys,HM.toBinary(s),n)}storeDeleteKeys(e,r,i,n){const s={pluginId:e,storeName:r,deleteKeys:i.map(o=>({storeKey:o.key}))};a(this,tt).sendMessage(K.storeDeleteKeys,GM.toBinary(s),n)}storeDelete(e,r,i){a(this,tt).sendMessage(K.storeDelete,JM.toBinary({pluginId:e,storeName:r}),i)}getPluginDataOld(e,r){l.info("getPluginDataOld",{plugin:{id:e,storeName:r}})}storePluginDataOld(e,r,i){const n={pluginId:e,storeName:r,insertKeys:[{storeKey:i.key,payload:new TextEncoder().encode(JSON.stringify(i))}]};a(this,tt).sendMessage(K.storeInsertKeys,Vm.toBinary(n))}on(e,r){let i;switch(e){case K.addPlugin:case K.enablePluginForPeers:case K.enablePluginForRoom:{i=qu.fromBinary.bind(qu);break}case K.removePlugin:case K.disablePluginForPeers:case K.disablePluginForRoom:{i=xm.fromBinary.bind(xm);break}case K.customPluginEventToPeers:case K.customPluginEventToRoom:{i=Fm.fromBinary.bind(Fm);break}case K.storeInsertKeys:case K.storeGetKeys:case K.storeDeleteKeys:case K.storeDelete:{i=Um.fromBinary.bind(Um);break}}a(this,tt).on(e,({payload:n,id:s})=>{const o=i(n);return r(o,s)})}}tt=new WeakMap;var b1=Object.defineProperty,_1=(t,e,r)=>e in t?b1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,w1=(t,e,r)=>(_1(t,typeof e!="symbol"?e+"":e,r),r),Tp=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},N=(t,e,r)=>(Tp(t,e,"read from private field"),r?r.call(t):e.get(t)),Ce=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},ue=(t,e,r,i)=>(Tp(t,e,"write to private field"),i?i.call(t,r):e.set(t,r),r),De=(t,e,r)=>(Tp(t,e,"access private method"),r),el={},I1={get exports(){return el},set exports(t){el=t}},xs=typeof Reflect=="object"?Reflect:null,Ug=xs&&typeof xs.apply=="function"?xs.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)},_d;xs&&typeof xs.ownKeys=="function"?_d=xs.ownKeys:Object.getOwnPropertySymbols?_d=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:_d=function(t){return Object.getOwnPropertyNames(t)};function C1(t){console&&console.warn&&console.warn(t)}var Ey=Number.isNaN||function(t){return t!==t};function ge(){ge.init.call(this)}I1.exports=ge;el.once=A1;ge.EventEmitter=ge;ge.prototype._events=void 0;ge.prototype._eventsCount=0;ge.prototype._maxListeners=void 0;var Fg=10;function _l(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(ge,"defaultMaxListeners",{enumerable:!0,get:function(){return Fg},set:function(t){if(typeof t!="number"||t<0||Ey(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Fg=t}});ge.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};ge.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Ey(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 Ty(t){return t._maxListeners===void 0?ge.defaultMaxListeners:t._maxListeners}ge.prototype.getMaxListeners=function(){return Ty(this)};ge.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i=t==="error",n=this._events;if(n!==void 0)i=i&&n.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 o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var c=n[t];if(c===void 0)return!1;if(typeof c=="function")Ug(c,this,e);else for(var d=c.length,h=Iy(c,d),r=0;r<d;++r)Ug(h[r],this,e);return!0};function ky(t,e,r,i){var n,s,o;if(_l(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),n=Ty(t),n>0&&o.length>n&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=o.length,C1(c)}return t}ge.prototype.addListener=function(t,e){return ky(this,t,e,!1)};ge.prototype.on=ge.prototype.addListener;ge.prototype.prependListener=function(t,e){return ky(this,t,e,!0)};function P1(){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 by(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=P1.bind(i);return n.listener=r,i.wrapFn=n,n}ge.prototype.once=function(t,e){return _l(e),this.on(t,by(this,t,e)),this};ge.prototype.prependOnceListener=function(t,e){return _l(e),this.prependListener(t,by(this,t,e)),this};ge.prototype.removeListener=function(t,e){var r,i,n,s,o;if(_l(e),i=this._events,i===void 0)return this;if(r=i[t],r===void 0)return this;if(r===e||r.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||e));else if(typeof r!="function"){for(n=-1,s=r.length-1;s>=0;s--)if(r[s]===e||r[s].listener===e){o=r[s].listener,n=s;break}if(n<0)return this;n===0?r.shift():R1(r,n),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,o||e)}return this};ge.prototype.off=ge.prototype.removeListener;ge.prototype.removeAllListeners=function(t){var e,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[t]),this;if(arguments.length===0){var n=Object.keys(r),s;for(i=0;i<n.length;++i)s=n[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=r[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 _y(t,e,r){var i=t._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?r?[n.listener||n]:[n]:r?M1(n):Iy(n,n.length)}ge.prototype.listeners=function(t){return _y(this,t,!0)};ge.prototype.rawListeners=function(t){return _y(this,t,!1)};ge.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):wy.call(t,e)};ge.prototype.listenerCount=wy;function wy(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}ge.prototype.eventNames=function(){return this._eventsCount>0?_d(this._events):[]};function Iy(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function R1(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function M1(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function A1(t,e){return new Promise(function(r,i){function n(o){t.removeListener(e,s),i(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",n),r([].slice.call(arguments))}Cy(t,e,s,{once:!0}),e!=="error"&&D1(t,n,{once:!0})})}function D1(t,e,r){typeof t.on=="function"&&Cy(t,"error",e,r)}function Cy(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function n(s){i.once&&t.removeEventListener(e,n),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}class O1 extends E{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 Bg=new O1;class Py{static encode(e){return Bg.toBinary(e)}static decode(e){return Bg.fromBinary(new Uint8Array(e))}}function N1(t,e){return Math.floor(Math.random()*(e-t+1)+t)}var Mi;class L1{constructor(e={}){w1(this,"opts"),Ce(this,Mi,void 0),this.opts={initialTimeout:e.initialTimeout||1e3,maxTimeout:e.maxTimeout||1e4,factor:e.factor||2},ue(this,Mi,0)}wait(){return u(this,null,function*(){ue(this,Mi,N(this,Mi)+1);const e=N1(0,Math.min(this.opts.maxTimeout,this.opts.initialTimeout*GS(2,N(this,Mi))));yield new Promise(r=>{setTimeout(r,e)})})}getAttempts(){return N(this,Mi)}reset(){ue(this,Mi,0)}}Mi=new WeakMap;const vi={debug:0,info:1,warn:2,error:3};var fn,vn;class V1{constructor(e){Ce(this,fn,void 0),Ce(this,vn,void 0),ue(this,fn,console),ue(this,vn,e)}debug(...e){vi[N(this,vn)]>vi.debug||N(this,fn).debug("[Sockrates]:",...e)}info(...e){vi[N(this,vn)]>vi.info||N(this,fn).info("[Sockrates]:",...e)}warn(...e){vi[N(this,vn)]>vi.warn||N(this,fn).warn("[Sockrates]:",...e)}error(...e){vi[N(this,vn)]>vi.error||N(this,fn).error("[Sockrates]:",...e)}}fn=new WeakMap,vn=new WeakMap;var Ry=(t=>(t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSING=2]="CLOSING",t[t.CLOSED=3]="CLOSED",t))(Ry||{});const x1="2",U1="3";var Fe,ks,Ae,Ge,Ai,rt,ri,Ui,br,bs,Yr,Dh,My,wo,wd,Oh,Ay,Nh,Wg,tl,Lh,Vh,Dy,Fo,Id,Bo,rl,il,xh,Us,Wo,jo,nl;class F1{constructor(e,r){var i;Ce(this,Dh),Ce(this,wo),Ce(this,Oh),Ce(this,Nh),Ce(this,tl),Ce(this,Vh),Ce(this,Fo),Ce(this,Bo),Ce(this,il),Ce(this,Us),Ce(this,jo),Ce(this,Fe,void 0),Ce(this,ks,void 0),Ce(this,Ae,void 0),Ce(this,Ge,void 0),Ce(this,Ai,void 0),Ce(this,rt,void 0),Ce(this,ri,void 0),Ce(this,Ui,void 0),Ce(this,br,void 0),Ce(this,bs,void 0),Ce(this,Yr,void 0);var n,s,o,c,d,h,p,g,y;ue(this,ks,e),ue(this,Ai,[]),ue(this,rt,new el),ue(this,ri,!0),ue(this,br,!1),ue(this,Ae,r!=null?r:{}),(n=N(this,Ae)).autoReconnect!=null||(n.autoReconnect=!0),(s=N(this,Ae)).retryConnectionInterval!=null||(s.retryConnectionInterval=1e3),(o=N(this,Ae)).pingTimeout!=null||(o.pingTimeout=3e4),(c=N(this,Ae)).connectionTimeout!=null||(c.connectionTimeout=5e3),(d=N(this,Ae)).debug!=null||(d.debug=!0),(h=N(this,Ae)).maxReconnectionAttempts!=null||(h.maxReconnectionAttempts=10),(p=N(this,Ae)).disconnectOnPingTimeout!=null||(p.disconnectOnPingTimeout=!0),(g=N(this,Ae)).queueOnDisconnect!=null||(g.queueOnDisconnect=!1),(y=N(this,Ae)).flushOnReconnect!=null||(y.flushOnReconnect=!1),ue(this,Ui,{code:void 0,reason:void 0}),ue(this,Ge,(i=N(this,Ae).logger)!=null?i:new V1(N(this,Ae).debug?"debug":"info")),ue(this,Yr,new L1)}get readyState(){var e;return(e=N(this,Fe))==null?void 0:e.readyState}get url(){return N(this,ks)}updateURL(e){ue(this,ks,e),De(this,Vh,Dy).call(this)}get config(){return N(this,Ae)}get sendQueue(){return N(this,Ai)}flush(){if(!N(this,Ae).queueOnDisconnect)return!1;const e=[];return N(this,Ai).forEach(r=>{this.send(r.event,r.id,r.payload,r.metadata)||e.push(r)}),ue(this,Ai,e),N(this,Ai)}connect(e=!1){return u(this,null,function*(){if(!e&&[0,1].includes(this.readyState)){N(this,Ge).debug("Websocket was already connecting or connected.");return}if(N(this,ri)!==!1)return new Promise((r,i)=>{De(this,Us,Wo).call(this),De(this,jo,nl).call(this);try{ue(this,Fe,new WebSocket(De(this,Dh,My).call(this,N(this,ks)))),N(this,Fe).binaryType="arraybuffer",N(this,Ge).debug("Connecting");const n=setTimeout(()=>{N(this,Ge).debug("Connection timeout. Closing socket"),ue(this,ri,!0),De(this,jo,nl).call(this),N(this,Fe).close(3001,"Connection Timeout"),N(this,Ae).autoReconnect&&!N(this,br)&&(N(this,rt).emit("reconnecting"),De(this,Fo,Id).call(this)),i(new Error("Connection timed out!"))},N(this,Ae).connectionTimeout);N(this,Fe).onopen=()=>{N(this,Ge).debug(`Ready State: ${Ry[N(this,Fe).readyState]}`),n&&clearTimeout(n),De(this,il,xh).call(this),ue(this,Ui,{code:void 0,reason:void 0}),N(this,rt).emit("connected"),N(this,Ae).flushOnReconnect&&this.flush(),r()},N(this,Fe).onclose=s=>{try{n&&clearTimeout(n);const{code:o,reason:c}=s;i(c),N(this,Ge).debug("Socket closed. Close event:",{event:s}),N(this,Ge).debug(`Connection closed code: ${o}`),N(this,Ge).debug(`Connection closed reason: ${c}`),N(this,br)||De(this,tl,Lh).call(this,o,c)}catch(o){De(this,wo,wd).call(this,o)}},N(this,Fe).onerror=s=>{De(this,wo,wd).call(this,s)},N(this,Fe).onmessage=s=>De(this,Oh,Ay).call(this,s)}catch(n){De(this,wo,wd).call(this,n,i)}})})}send(e,r,i,n){const s={event:e,id:r,payload:i,metadata:n};if(N(this,Ae).queueOnDisconnect&&(!N(this,Fe)||N(this,Fe).readyState!==1))return N(this,Ge).debug("Queuing message since socket is not connected!",s),N(this,Ai).push(s),!1;const o=Py.encode(s);return De(this,Bo,rl).call(this,o)}emit(e,r,i,n){return this.send(e,r,i,n)}sendRaw(e){return De(this,Bo,rl).call(this,e)}receive(e,r){return N(this,rt).on(e.toString(),r)}on(e,r){if(typeof e=="string"&&(e==="connected"||e==="disconnected"||e==="errored"||e==="reconnected"||e==="reconnecting"||e==="reconnectAttempt"||e==="reconnectFailure"||e==="failed")){N(this,rt).on(e,r);return}this.receive(e,r)}removeAllListeners(){N(this,rt).removeAllListeners()}removeReceiver(e,r){this.removeListener(e,r)}removeListener(e,r){N(this,rt).removeListener(e.toString(),r)}removeReceivers(e){this.removeListeners(e)}removeListeners(e){N(this,rt).listeners(e.toString()).map(r=>this.removeListener(e,r))}disconnect(){ue(this,ri,!1),De(this,Us,Wo).call(this),this.removeAllListeners(),ue(this,Ui,{code:1e3,reason:"Sockrates disconnect method called"}),N(this,Fe).close(1e3,"Sockrates disconnect method called.")}}Fe=new WeakMap,ks=new WeakMap,Ae=new WeakMap,Ge=new WeakMap,Ai=new WeakMap,rt=new WeakMap,ri=new WeakMap,Ui=new WeakMap,br=new WeakMap,bs=new WeakMap,Yr=new WeakMap,Dh=new WeakSet,My=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)://.")},wo=new WeakSet,wd=function(t,e){N(this,Ge).error("Error:",{error:t}),N(this,rt).emit("errored",{error:t}),e==null||e(t)},Oh=new WeakSet,Ay=function(t){if(De(this,il,xh).call(this),t.data===x1){N(this,Ge).debug("Received ping from server"),De(this,Bo,rl).call(this,U1);return}const e=Py.decode(t.data),{id:r,payload:i}=e;N(this,Ge).debug("Received message",{event:e.event,messageID:r}),N(this,rt).emit(e.event.toString(),{id:r,payload:i})},Nh=new WeakSet,Wg=function(){return N(this,Fe).readyState===1},tl=new WeakSet,Lh=function(t,e){ue(this,Ui,{reason:e,code:t}),N(this,rt).emit("disconnected",{code:t,reason:e})},Vh=new WeakSet,Dy=function(){const{reason:t,code:e}=N(this,Ui);e&&e!==1e3&&N(this,ri)&&N(this,Ae).autoReconnect&&!N(this,br)&&(N(this,Ge).debug(`Triggering reconnection due to ${t}.`),N(this,rt).emit("reconnecting"),De(this,Fo,Id).call(this))},Fo=new WeakSet,Id=function(t=!0){return u(this,null,function*(){if(t&&N(this,br)){N(this,Ge).debug("Reconnect called when already in a reconnect loop. Ignoring.");return}if(N(this,br)||N(this,Yr).reset(),N(this,Ae).maxReconnectionAttempts!==null&&N(this,Yr).getAttempts()>=N(this,Ae).maxReconnectionAttempts){N(this,rt).emit("failed"),ue(this,br,!1);return}ue(this,br,!0),De(this,jo,nl).call(this),De(this,Us,Wo).call(this);try{if(yield N(this,Yr).wait(),N(this,ri)===!1)return;if(N(this,Ge).debug(`Reconnection attempt ${N(this,Yr).getAttempts()}`),N(this,rt).emit("reconnectAttempt",{attempt:N(this,Yr).getAttempts()}),yield this.connect(),!De(this,Nh,Wg).call(this))throw Error("Reconnect Failed");ue(this,br,!1),ue(this,Ui,{code:void 0,reason:void 0}),N(this,rt).emit("reconnected")}catch{N(this,Ge).debug("Failed to reconnect."),N(this,rt).emit("reconnectFailure",{attempt:N(this,Yr).getAttempts()}),De(this,Fo,Id).call(this,!1)}})},Bo=new WeakSet,rl=function(t){try{return N(this,Fe).send(t),!0}catch(e){return N(this,Ge).error(e.message),!1}},il=new WeakSet,xh=function(){this.config.disconnectOnPingTimeout&&(N(this,Ge).debug("Resetting ping timeout"),De(this,Us,Wo).call(this),ue(this,bs,setTimeout(()=>{var t;N(this,Ge).debug("Disconnecting the socket due to ping timeout"),ue(this,ri,!0);const e=3002,r="Ping timeout";(t=N(this,Fe))==null||t.close(e,r),De(this,tl,Lh).call(this,e,r)},N(this,Ae).pingTimeout)))},Us=new WeakSet,Wo=function(){N(this,bs)&&(clearTimeout(N(this,bs)),ue(this,bs,void 0))},jo=new WeakSet,nl=function(){N(this,Fe)&&(N(this,Fe).onopen=void 0,N(this,Fe).onerror=void 0,N(this,Fe).onmessage=void 0,N(this,Fe).onclose=void 0)};var B1=Object.defineProperty,W1=Object.getOwnPropertyDescriptor,wl=(t,e,r,i)=>{for(var n=i>1?void 0:i?W1(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&B1(e,r,n),n};const jg=65535,j1=3e3;var en,Ve,xe,We,gr,ir,Vc,ku,xc,bu,Hg;const Oy=(Hg=class{constructor(t,{peerId:e,meetingId:r,authToken:i,capabilities:n}){f(this,xe),f(this,Vc),f(this,xc),f(this,en,void 0),f(this,Ve,void 0),m(this,"roomName"),m(this,"authToken"),m(this,"capabilities"),f(this,gr,void 0),f(this,ir,void 0);var s;if(!e||!r||!i)throw new w("peerId, meetingId, or authToken can not be empty","0404");v(this,gr,void 0),v(this,ir,t),this.capabilities=n,this.roomName=r,this.authToken=i,v(this,en,F(this,Vc,ku).call(this,e)),v(this,Ve,new F1(a(this,en),{autoReconnect:!0,disconnectOnPingTimeout:(s=n.includes("PING"))!=null?s:!1,queueOnDisconnect:!0,flushOnReconnect:!1,logger:l})),this.handleSocketConnectionEvents()}get joinAttempted(){return a(this,xe,We).socketJoinAttempted}set joinAttempted(t){a(this,xe,We).socketJoinAttempted=t}get peerId(){return a(this,ir).getValue("peerId")}updateURL(t){t!==this.peerId&&(v(this,en,F(this,Vc,ku).call(this,t)),l.debug("SocketService:: Connection URL updated.")),a(this,Ve).updateURL(a(this,en))}static getSocketEdgeDomain(t){return Ns({servicePrefix:"socket-edge",baseURI:t})}get url(){return a(this,en)}connect(){return u(this,null,function*(){a(this,xe,We).socketJoinAttempted=!0,yield a(this,Ve).connect(),a(this,xe,We).socketJoinAttempted=!0,a(this,xe,We).socketState={state:"connected",reconnected:!1,reconnectionAttempt:void 0}})}disconnect(){return u(this,null,function*(){a(this,xe,We).socketJoinAttempted=!1,a(this,Ve).disconnect(),a(this,xe,We).socketJoinAttempted=!0,a(this,xe,We).socketState={state:"disconnected",reconnected:!1,reconnectionAttempt:void 0}})}get isConnected(){try{return a(this,Ve).readyState===1}catch{return!1}}sendMessage(t,e,r){const i={};return S.injectContext(i),a(this,Ve).send(t,r!=null?r:F(this,xc,bu).call(this),e,new TextEncoder().encode(JSON.stringify(i)))}sendMessagePromise(t,e,r,i){const n=parseInt({}.SOCKET_SERVICE_MESSAGE_REQUEST_TIMEOUT,10)||2e4;return this.sendMessagePromiseWithTimeout({event:t,timeout:n,protobuf:e,messageId:r,resp:i})}sendMessagePromiseWithTimeout({event:t,timeout:e,protobuf:r,messageId:i,resp:n}){const s=n!=null?n:t;return new Promise((o,c)=>{const d=(T,b)=>{a(this,Ve).removeListener(s,T),a(this,Ve).removeListener(jg,b),a(this,Ve).removeListener(or.errorResponse,b),a(this,Ve).removeListener(_r.errorResponse,b)},h=i!=null?i:F(this,xc,bu).call(this),p={};S.injectContext(p);const g=({id:T,payload:b})=>{if(h===T){let A;try{const P=WI.fromBinary(b);A=new Error(P.errorMessage)}catch(P){A=new Error("failed to parse error message",{cause:P});try{const V=jC.fromBinary(b);A=new Error(V.message)}catch(V){A=new Error("failed to parse error message",{cause:V})}}c(A),d(y,g)}},y=({id:T,payload:b})=>{h===T&&(o({id:T,payload:b}),d(y,g))};a(this,Ve).on(s,y),a(this,Ve).on(jg,g),a(this,Ve).on(or.errorResponse,g),a(this,Ve).on(_r.errorResponse,g),setTimeout(()=>{d(y,g),c(new Error(`request timeout for callback eventId:${t}`))},e),a(this,Ve).send(t,h,r,new TextEncoder().encode(JSON.stringify(p)))})}on(t,e){a(this,Ve).on(t,e)}onStateEvent(t,e){a(this,Ve).on(t,e)}removeListener(t,e){a(this,Ve).removeListener(t,e)}removeListeners(t){a(this,Ve).removeListeners(t)}flush(){return a(this,Ve).flush()}handleSocketConnectionEvents(){this.onStateEvent("connected",()=>u(this,null,function*(){l.info("SocketService::Connected to socket-edge"),a(this,gr)&&(clearTimeout(a(this,gr)),v(this,gr,void 0)),a(this,xe,We).updateSocketConnectionState("connected")})),this.onStateEvent("disconnected",({code:t,reason:e})=>{var r;l.info("SocketService::Disconnected from socket-edge",{error:{code:t,reason:e},country:S.location.country});const{recv:i,send:n}=(r=a(this,xe,We).mediaState)!=null?r:{};i!=null&&i.state&&(i==null?void 0:i.state)!==qs.CONNECTED||n!=null&&n.state&&(n==null?void 0:n.state)!==qs.CONNECTED?a(this,ir).getValue("peerSessionStore").emit(R.SOCKET_SERVICE_DISCONNECTED,{joinAttempted:a(this,xe,We).joinAttempted}):v(this,gr,setTimeout(()=>{a(this,ir).getValue("peerSessionStore").emit(R.SOCKET_SERVICE_DISCONNECTED,{joinAttempted:a(this,xe,We).joinAttempted}),v(this,gr,void 0)},j1)),a(this,xe,We).updateSocketConnectionState("disconnected")}),this.onStateEvent("reconnecting",()=>u(this,null,function*(){l.info("SocketService::Reconnecting to socket-edge",{country:S.location.country}),a(this,xe,We).updateSocketConnectionState("reconnecting")})),this.onStateEvent("reconnectAttempt",t=>u(this,[t],function*({attempt:e}){l.info("SocketService::Attempting to reconnect to socket-edge",{socket:{retryAttempt:e}}),a(this,xe,We).updateSocketConnectionState("reconnectAttempt",e)})),this.onStateEvent("reconnectFailure",({attempt:t})=>{l.info("SocketService::Reconnect attempt to socket-edge failed",{socket:{retryAttempt:t}}),a(this,xe,We).updateSocketConnectionState("reconnectFailure",t)}),this.onStateEvent("reconnected",()=>u(this,null,function*(){l.info("SocketService::Reconnected to socket-edge",{connectionState:{joinAttempted:a(this,xe,We).mediaJoinAttempted}}),a(this,gr)&&(clearTimeout(a(this,gr)),v(this,gr,void 0)),a(this,ir).getValue("peerSessionStore").emit(R.SOCKET_SERVICE_RECONNECTED,{wasJoinAttempted:a(this,xe,We).mediaJoinAttempted}),a(this,xe,We).updateSocketConnectionState("reconnected")})),this.onStateEvent("failed",()=>u(this,null,function*(){l.info("SocketService::Failed to connect to socket-edge",{country:S.location.country}),a(this,ir).getValue("peerSessionStore").emit(R.SOCKET_SERVICE_FAILED),a(this,xe,We).updateSocketConnectionState("failed")}))}},en=new WeakMap,Ve=new WeakMap,xe=new WeakSet,We=function(){return a(this,ir).getValue("connectionHandler")},gr=new WeakMap,ir=new WeakMap,Vc=new WeakSet,ku=function(t){let e=Oy.getSocketEdgeDomain(a(this,ir).getValue("baseURI"));typeof js(a(this,ir),"socket_server_base")=="string"&&(e=js(a(this,ir),"socket_server_base"));const r=`wss://${e}`,i=new URL(`${r}/ws`),n=this.peerId,s=G(L({roomID:this.roomName,peerID:t,authToken:this.authToken,useMediaV2:!0},n!==t&&{oldPeerID:n}),{ping:this.capabilities.includes("PING"),capabilities:this.capabilities.map(o=>jd[o]).join(" "),joinWithDetails:!0,useCfWorker:!0,useStartSession:!0});return Object.entries(s).forEach(([o,c])=>{i.searchParams.append(o,c.toString())}),i.href},xc=new WeakSet,bu=function(){return`${this.peerId}-${(Math.random()+1).toString(36).substring(7)}`},Hg);let rc=Oy;wl([S.trace("SocketService.connect")],rc.prototype,"connect",1);wl([S.trace("SocketService.disconnect")],rc.prototype,"disconnect",1);wl([S.trace("SocketService.sendMessagePromise")],rc.prototype,"sendMessagePromise",1);wl([S.trace("SocketService.sendMessagePromiseWithTimeout")],rc.prototype,"sendMessagePromiseWithTimeout",1);const yn=class{static handleConnectedRoomsDumpRaw({payload:t}){var e;const r=gP.fromBinary(t),i=r.meetings.map(n=>{var s;return{id:n.id,title:n.title,participants:(s=n.participants)!=null?s:[]}});return{parentMeeting:{id:r.parentMeeting.id,title:r.parentMeeting.title,participants:(e=r.parentMeeting.participants)!=null?e:[]},meetings:i}}static handleTransferPeerRaw({payload:t}){const e=WP.fromBinary(t);return{authToken:e.authToken,meetingId:e.meetingId}}static handleMovedPeerRaw({payload:t}){const e=Pv.fromBinary(t);return{meetingId:e.meetingId,customParticipantId:e.customParticipantId}}static handleConnectedRoomsUpdatedRaw({payload:t}){return Dm.fromBinary(t).payloads.map(e=>({id:e.id,title:e.title}))}static handleConnectedRoomsDeletedRaw({payload:t}){return AP.fromBinary(t).payloads}static getConnectedRoomsDump(){return u(this,null,function*(){const t=yield yn.socketService.sendMessagePromise(B.getConnectedRoomsDump);return yn.handleConnectedRoomsDumpRaw(t)})}static createConnectedRooms(t){return u(this,null,function*(){const{payload:e}=yield yn.socketService.sendMessagePromise(B.createConnectedRooms,SP.toBinary({payloads:t}));return Dm.fromBinary(e).payloads.map(r=>({id:r.id,title:r.title}))})}static updateConnectedRooms(t){return u(this,null,function*(){})}static disableConnectedRooms(t){return u(this,null,function*(){const e=t.map(i=>({id:i})),r=yield yn.socketService.sendMessagePromise(B.deleteConnectedRooms,RP.toBinary({payloads:e}));return yn.handleConnectedRoomsDeletedRaw(r)})}static movePeersBetweenRooms(t){return u(this,null,function*(){try{const e=yield yn.socketService.sendMessagePromise(B.movePeers,xP.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=yn;m(Ne,"socketService"),m(Ne,"currentMeetingId");var H1=Object.defineProperty,q1=Object.getOwnPropertyDescriptor,Il=(t,e,r,i)=>{for(var n=i>1?void 0:i?q1(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&H1(e,r,n),n};const _s=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,r;const{peerId:i,apiBase:n,authToken:s,meetingId:o,organizationId:c,cachedUserDetails:d}=t.getAllValues();if(vy(t),Re.isSupported()===!1)throw new w("Browser not supported","0010",!0);const h=ZA(t,{authToken:s,baseURL:n,cachedUserDetails:d});h.setRoomName(o),h.setRoomUUID(o),h.setOrganizationId(c),h.setHeader("dyte-tracing-id",i),t.setValue("apiClient",h);const p=new LD(t);t.setValue("connectionHandler",p);const g=_s.createSocketService(t),y=g.connect(),T=h.getUserDetails(),b=h.getPlugins();let A=Le.HIVE,P,V="";try{yield _s.setupFlagsmith(t)}catch(ie){l.error("Failed to setup flagsmith",{error:ie})}try{yield y}catch(ie){l.error("[Controller]: Failed to connect to socket server:",{error:ie})}try{({sfu:A,meetingTitle:V}=yield h.getRoomNodeData()),P=yield T,l.info(`SFU ${A} is being used.`),t.setValue("presetName",P.preset.name),t.setValue("roomNodeOptions",{sfu:A})}catch(ie){l.error("Failed to get room metadata",{error:ie})}const j=SO.init(P.preset,!t.getValue("modules").theme),$=BO.init(t,j.viewType,P.preset.permissions),I=_s.setupControllers(g,t,P,b,V,j,$);_D(j)&&((e=_s.createRoomNodeClient(t,g).initializeConnection(P.participant.name,o,!1,$))==null||e.catch(ie=>{l.error("[Controller]: Failed to queue partial media room promise:",{error:ie})})),S.location.country=(r=h.ipInfo)==null?void 0:r.country;const{controllers:se}=yield I;return T0(),new _s(n,se)})}static setupFlagsmith(t){return u(this,null,function*(){var e;const{peerId:r,baseURI:i,overrides:n,meetingId:s,organizationId:o}=t.getAllValues(),c=E0(s),d=G(L({entity:xu.PEER,clientId:o,isAnonUser:!o,sdkVersion:t.getValue("sdkVersion"),presetName:t.getValue("presetName"),meetingHash:c,roomName:s},Re.getDeviceInfo()),{isReactNative:navigator.isReactNative});try{const h=(e=n==null?void 0:n.whitelabelled_flags_endpoint)==null||e?Ns({servicePrefix:"flags",baseURI:i}):"edge.api.flagsmith.com";yield Y.identify(`${xu.PEER}_${r}`,JSON.parse(JSON.stringify(d)),!1,5e3,h,l),l.info("flagsmith::allFlags",{flags:JSON.stringify(Y.getAllFlags())},!0)}catch{l.error("Failed to fetch flagsmith flags")}})}static setupControllers(t,e,r,i,n,s,o){return u(this,null,function*(){var c,d,h;const p=e.getValue("modules"),{participant:g}=r,y=e.getValue("defaults"),{sfu:T}=e.getValue("roomNodeOptions"),{viewType:b,mediaConstraints:{audio:A}}=s;e.setValue("viewType",b),e.setValue("defaults",L({mediaConfiguration:{audio:{enableHighBitrate:(c=A.enableHighBitrate)!=null?c:!1,enableStereo:(d=A.enableStereo)!=null?d:!1}}},y)),e.setValue("maxPreferredStreams",Re.isMobile()?s.maxVideoStreams.mobile:s.maxVideoStreams.desktop);let P,V,j,$,I,se,ie,ve;const Qe=new g1(t);Ne.socketService=t;const dt=new bl(t),Mt=new cr(t),M=new T1(t),k=new Sy(e,t),_=new k1(t),W=new m1(t),we=new Dn(t),pe=yield $i.init(e,k,g,o,s),U=yield Bv.init(e,pe.self,k,Qe,n);if(p.participant&&(ve=new di(e,pe.self,k,T)),(h=p.e2ee)!=null&&h.enabled&&p.e2ee.manager.init(l,e.getValue("peerSessionStore")),p.chat&&(V=yield ii.init(e,Mt,we,pe.self,ve.participants)),p.internals&&(I=yield lp.init()),p.livestream&&s.viewType===Ft.Livestream&&Y.hasFeature(re.LIVESTREAM)&&(ie=new zv(e,pe.self,W)),s.viewType!==Ft.Chat){if(p.poll&&(P=yield Vv.init(e,pe.self,dt)),p.recording&&(se=new qv(e,pe.self,k)),p.stage&&(j=new Wv(e,M,k,pe.self,ve.participants)),p.plugin){if(!ve)throw new w("The plugin module cannot be initialized without the `participant` module","0102");const Be=yield i;$=yield Xo.init(e,Be,_,Mt,V==null?void 0:V.chat,pe.self,ve.participants,n)}if(p.pip){const Be=yield _0._init(e,pe.self);e.setValue("pip",Be)}}const C={storesManager:new CO(e,_),pollController:P,selfController:pe,metaController:U,chatController:V,stageController:j,pluginController:$,recordingController:se,internalsController:I,livestreamController:ie,participantController:ve};return{theme:s,permissions:o,controllers:C}})}static createRoomNodeClient(t,e){const{peerId:r,roomNodeOptions:i}=t.getAllValues(),{sfu:n}=i;return fy(t,n,{socket:e,peerId:r})}static createSocketService(t){const{peerId:e,meetingId:r,authToken:i}=t.getAllValues(),n=["PING"];return new rc(t,{peerId:e,meetingId:r,authToken:i,capabilities:n})}};let ic=_s;Il([S.trace("Controller.init")],ic,"init",1);Il([S.trace("setupFlagsmith")],ic,"setupFlagsmith",1);Il([S.trace("Controller.createRoomNodeClient")],ic,"createRoomNodeClient",1);Il([S.trace("Controller.createSocketService")],ic,"createSocketService",1);var G1=Object.defineProperty,$1=Object.getOwnPropertyDescriptor,J1=(t,e,r,i)=>{for(var n=i>1?void 0:i?$1(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&G1(e,r,n),n},Cd,Uh;class Ny extends Xt{constructor(e,r){super(),f(this,Cd,void 0),m(this,"meetings",[]),m(this,"parentMeeting",null),f(this,Uh,void 0),v(this,Uh,e),v(this,Cd,r.self)}get supportsConnectedMeetings(){return a(this,Cd).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(r=>({id:r.id,title:r.title}))})}updateMeetings(e){return u(this,null,function*(){this.validateConnectedMeetingsAction(),yield Ne.updateConnectedRooms(e.map(r=>({meetingId:r.id,title:r.title})))})}deleteMeetings(e){return u(this,null,function*(){this.validateConnectedMeetingsAction();const r=this.meetings.map(i=>e.includes(i.id)&&i.participants.length!==0?this.moveParticipants(i.id,this.parentMeeting.id,i.participants.map(n=>n.id)):Promise.resolve());return yield Promise.all(r),yield Ne.disableConnectedRooms(e)})}moveParticipants(e,r,i){return u(this,null,function*(){this.validateConnectedMeetingsAction();const n=yield Ne.movePeersBetweenRooms({sourceMeetingId:e,destinationMeetingId:r,participants:i.map(s=>({id:s}))});return n.success&&this.moveSuccessHandler(e,r,i),n})}moveParticipantsWithCustomPreset(e,r,i){return u(this,null,function*(){this.validateConnectedMeetingsAction();const n=yield Ne.movePeersBetweenRooms({sourceMeetingId:e,destinationMeetingId:r,participants:i});return n.success&&this.moveSuccessHandler(e,r,i.map(s=>s.id)),n})}moveSuccessHandler(e,r,i){const n=new Map;[...this.parentMeeting.participants,...this.meetings.flatMap(s=>s.participants)].forEach(s=>n.set(s.id,s)),r===this.parentMeeting.id&&(this.parentMeeting.participants=this.parentMeeting.participants.concat(i.map(s=>n.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(r===s.id){const o=s.participants.concat(i.map(c=>n.get(c)));return G(L({},s),{participants:o})}if(e===s.id){const o=s.participants.filter(c=>!i.includes(c.id));return G(L({},s),{participants:o})}return s})}}Cd=new WeakMap,Uh=new WeakMap;J1([Bt({maxInvocations:60,period:60})],Ny.prototype,"getConnectedMeetings",1);var K1=Object.defineProperty,z1=Object.getOwnPropertyDescriptor,kp=(t,e,r,i)=>{for(var n=i>1?void 0:i?z1(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&K1(e,r,n),n},Qa,fr,_u,wu;const Di=(_u=class{constructor(t,e,r){m(this,"connectedMeetings"),f(this,Qa,void 0),f(this,fr,void 0),f(this,wu,void 0),v(this,wu,t),v(this,Qa,r),this.connectedMeetings=new Ny(t,e),this.setCurrentMeeting(e)}static init(t,e,r){return Di.instance||(Di.instance=new Di(t,e,r)),Di.instance.connectedMeetings.supportsConnectedMeetings&&(Di.instance.setupEvents(),e.self.once("roomJoined",()=>Di.instance.getConnectedMeetings())),Di.instance}setCurrentMeeting(t){v(this,fr,t),Ne.currentMeetingId=t.meta.meetingId}getConnectedMeetings(){this.connectedMeetings.getConnectedMeetings()}setupEvents(){Ne.socketService&&(Ne.socketService.on(B.getConnectedRoomsDump,this.handleConnectedRoomsDump.bind(this)),Ne.socketService.on(B.transferPeer,this.handleTransferPeer.bind(this)),Ne.socketService.on(B.movedPeer,this.handleMovedPeer.bind(this)),Ne.socketService.on(B.connectedRoomsUpdated,this.handleConnectedRoomsUpdated.bind(this)),Ne.socketService.on(B.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:r}){var i,n,s,o;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.`);l.info("ConnectedMeetingsController::switchMeeting:: asking ui-kit to show switching breakout UI"),this.connectedMeetings.emit("changingMeeting",r);const c={video:a(this,fr).self.videoEnabled,audio:a(this,fr).self.audioEnabled};try{a(this,fr).self.cleanupEvents(),yield a(this,fr).leave("connected-meeting")}catch(h){l.error(`ConnectedMeetingsController:: switchMeeting:: issues in leaving previous meeting. Meeting Id: ${(n=(i=a(this,fr))==null?void 0:i.meta)==null?void 0:n.meetingId}`,{error:h})}Ne.socketService=void 0,l.info(`ConnectedMeetingsController::switchMeeting:: initializing new meeting. Meeting Id: ${r}`);const d=yield Vy.init(G(L({},a(this,Qa)),{cachedUserDetails:null,defaults:G(L(L({},a(this,Qa).defaults),c),{mediaHandler:a(this,fr).self}),authToken:e}));l.info(`ConnectedMeetingsController::switchMeeting:: initialized new meeting. Meeting Id: ${(s=d==null?void 0:d.meta)==null?void 0:s.meetingId}`);try{const{hidden:h}=a(this,fr).self;d.self.setName(a(this,fr).self.name),yield d.join(),h&&d.self.hide()}catch(h){l.error("ConnectedMeetingsController.joinRoom",{error:h})}return l.info(`ConnectedMeetingsController::switchMeeting:: asking ui-kit to show in-meeting ui of newly joined meeting id: ${(o=d==null?void 0:d.meta)==null?void 0:o.meetingId}`),this.connectedMeetings.emit("meetingChanged",d),this.setCurrentMeeting(d),d})}handleConnectedRoomsDump(t){const e=Ne.handleConnectedRoomsDumpRaw(t);this.connectedMeetings.meetings=e.meetings.map(r=>({id:r.id,title:r.title,participants:r.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),r=new Map;this.connectedMeetings.meetings.forEach(i=>{r.set(i.id,i)}),e.forEach(i=>{r.has(i.id)?r.get(i.id).title=i.title:r.set(i.id,G(L({},i),{participants:[]}))}),this.connectedMeetings.meetings=Array.from(r.values()),this.emitStateUpdate()}handleConnectedRoomsDeleted(t){const e=Ne.handleConnectedRoomsDeletedRaw(t).map(r=>r.id);this.connectedMeetings.meetings=this.connectedMeetings.meetings.filter(r=>!e.includes(r.id)),this.emitStateUpdate()}emitStateUpdate(){this.connectedMeetings.emit("stateUpdate",{meetings:this.connectedMeetings.meetings,parentMeeting:this.connectedMeetings.parentMeeting})}},Qa=new WeakMap,fr=new WeakMap,wu=new WeakMap,m(_u,"instance"),_u);let Cl=Di;kp([S.trace("ConnectedMeetingsController.getConnectedMeetings")],Cl.prototype,"getConnectedMeetings",1);kp([S.trace("ConnectedMeetingsController.setupEvents")],Cl.prototype,"setupEvents",1);kp([S.trace("ConnectedMeetingsController.switchMeeting")],Cl.prototype,"switchMeeting",1);class Y1{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){l.error("Error getting battery",e)}})),m(this,"updateChargeInfo",()=>{var e;l.log(`Battery charging? ${(e=this.battery)!=null&&e.charging?"Yes":"No"}`)}),m(this,"updateLevelInfo",()=>{if(!this.battery){l.log("Battery level: Not known");return}l.log(`Battery level: ${this.battery.level*100}%`)}),m(this,"cleanup",()=>{var e,r;"getBattery"in navigator&&((e=this.battery)==null||e.removeEventListener("chargingchange",this.updateChargeInfo),(r=this.battery)==null||r.removeEventListener("levelchange",this.updateLevelInfo))})}}const qg=new Y1;function Q1(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:r,orgId:i,participantId:n}=JSON.parse(atob(t.split(".")[1]));if(!r)throw Error(`Received V1 auth token ${t}`);let s="dyte.io";e&&(s=e);const o=`https://api.${s}`;return{meetingId:r,orgId:i,participantId:n,baseURI:s,apiBase:o}}catch(r){throw l.error("constants::decodeAuthToken",{error:r,debuggingHint:`Unable to decode auth token: ${t}`},!0),new w("Invalid auth token","0004")}}var Sn,ws,Is,sl,Fh,Ly;class X1{constructor(){f(this,Fh),f(this,Sn,new Audio),f(this,ws,new MediaStream),f(this,Is,new Map),f(this,sl,void 0),a(this,Sn).srcObject=a(this,ws),a(this,Sn).autoplay=!0}playTracks(e){return u(this,null,function*(){return e.forEach(r=>{a(this,Is).has(r.id)||(a(this,ws).addTrack(r),a(this,Is).set(r.id,r))}),this.play()})}setSpeakerDevice(e){typeof HTMLAudioElement.prototype.setSinkId=="function"&&a(this,Sn).setSinkId(e)}removeTrack(e){const r=a(this,Is).get(e);r&&(a(this,ws).removeTrack(r),a(this,Is).delete(e))}play(){return u(this,null,function*(){return a(this,Sn).srcObject=a(this,ws),a(this,Sn).play().catch(e=>{F(this,Fh,Ly).call(this,e)})})}onError(e){v(this,sl,e)}}Sn=new WeakMap,ws=new WeakMap,Is=new WeakMap,sl=new WeakMap,Fh=new WeakSet,Ly=function(t){var e;(e=a(this,sl))==null||e.call(this,t)};var Cs;class Z1 extends X1{constructor(){super(),f(this,Cs,void 0),v(this,Cs,new Map)}addParticipantTrack(e,r){a(this,Cs).set(e,r.id),this.playTracks([r])}removeParticipantTrack(e){const r=a(this,Cs).get(e);r&&this.removeTrack(r),a(this,Cs).delete(e)}}Cs=new WeakMap;var eN=Object.defineProperty,tN=Object.getOwnPropertyDescriptor,Pl=(t,e,r,i)=>{for(var n=i>1?void 0:i?tN(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(n=(i?o(e,r,n):o(n))||n);return i&&n&&eN(e,r,n),n},at,Uc,tn,Iu,Gg,$g;let Hi=($g=class{constructor(t,e){f(this,Iu),f(this,at,void 0),f(this,Uc,void 0),f(this,tn,void 0),v(this,tn,t),v(this,at,e)}static init(t){return u(this,null,function*(){var e,r,i,n,s,o,c;v0(),Re.init();const d=(r=(e=t==null?void 0:t.cachedUserDetails)==null?void 0:e.peerId)!=null?r:Gs();qg.init();const{authToken:h,baseURI:p}=t,g=Q1(h,p),{meetingId:y}=g,T=cl(g,["meetingId"]);window.__zone_symbol__DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION=!0;const b=Hi.setupContext(d,t,y,T);S.meetingMetadata.roomName=y,S.meetingMetadata.userId=T.participantId,S.meetingMetadata.organizationId=T.orgId,S.init(b,(n=(i=t.modules)==null?void 0:i.tracing)!=null?n:!0),l.info("DyteClient::init::options",{dyteClientInitOptions:G(L({},t),{authToken:`${(s=t.authToken)==null?void 0:s.slice(0,10)}...
|
|
23
|
-
${(o=t.authToken)==null?void 0:o.slice(-10)}`})});const A=yield ic.init(b),P=new Hi(b,A);return F(c=P,Iu,Gg).call(c,t),P})}static setupContext(t,e,r,i){var n,s;const o=Rn.createContext(t,e),c=L(L({},l0),e==null?void 0:e.modules);return o.setValue("peerId",t),o.setValue("modules",c),o.setValue("sdkName","web-core"),o.setValue("meetingId",r),o.setValue("apiBase",i.apiBase),o.setValue("baseURI",i.baseURI),o.setValue("userId",i.participantId),o.setValue("organizationId",i.orgId),o.setValue("authToken",e.authToken),o.setValue("overrides",(n=e.overrides)!=null?n:{}),o.setValue("env",u0({baseURI:i.baseURI})),o.setValue("defaults",e.defaults||{audio:!0,video:!0}),o.setValue("onError",e.onError||(()=>{})),o.setValue("cachedUserDetails",Ir(e.cachedUserDetails)),o.setValue("sdkVersion","VERSION_PLACEHOLDER"),(s=e.modules)!=null&&s.
|
|
23
|
+
${(o=t.authToken)==null?void 0:o.slice(-10)}`})});const A=yield ic.init(b),P=new Hi(b,A);return F(c=P,Iu,Gg).call(c,t),P})}static setupContext(t,e,r,i){var n,s;const o=Rn.createContext(t,e),c=L(L({},l0),e==null?void 0:e.modules);return o.setValue("peerId",t),o.setValue("modules",c),o.setValue("sdkName","web-core"),o.setValue("meetingId",r),o.setValue("apiBase",i.apiBase),o.setValue("baseURI",i.baseURI),o.setValue("userId",i.participantId),o.setValue("organizationId",i.orgId),o.setValue("authToken",e.authToken),o.setValue("overrides",(n=e.overrides)!=null?n:{}),o.setValue("env",u0({baseURI:i.baseURI})),o.setValue("defaults",e.defaults||{audio:!0,video:!0}),o.setValue("onError",e.onError||(()=>{})),o.setValue("cachedUserDetails",Ir(e.cachedUserDetails)),o.setValue("sdkVersion","VERSION_PLACEHOLDER"),(s=e.modules)!=null&&s.experimentalAudioPlayback&&o.setValue("audioPlayback",new Z1),o}join(){return u(this,null,function*(){const{selfController:t}=a(this,at);return t.self.roomJoined?null:t.joinRoom()})}leave(t){return u(this,null,function*(){var e;qg.cleanup(),a(this,tn).getValue("peerSessionStore").reset(),(e=a(this,tn).getValue("roomSocketHandler"))==null||e.cleanup();const{selfController:r}=a(this,at);return r.leaveRoom(t)})}get participants(){var t;return(t=a(this,at).participantController)==null?void 0:t.participants}get self(){var t;return(t=a(this,at).selfController)==null?void 0:t.self}get meta(){var t;return(t=a(this,at).metaController)==null?void 0:t.meta}get ai(){var t;return(t=a(this,at).metaController)==null?void 0:t.ai}get plugins(){var t;return(t=a(this,at).pluginController)==null?void 0:t.plugins}get chat(){var t;return(t=a(this,at).chatController)==null?void 0:t.chat}get polls(){var t;return(t=a(this,at).pollController)==null?void 0:t.polls}get connectedMeetings(){var t;return(t=a(this,Uc))==null?void 0:t.connectedMeetings}get recording(){var t;return(t=a(this,at).recordingController)==null?void 0:t.recording}get livestream(){var t;return(t=a(this,at).livestreamController)==null?void 0:t.livestream}get stage(){var t;return(t=a(this,at).stageController)==null?void 0:t.stage}get stores(){return a(this,at).storesManager}get audio(){return a(this,tn).getValue("audioPlayback")}get __internals__(){var t;return(t=a(this,at).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)})}},at=new WeakMap,Uc=new WeakMap,tn=new WeakMap,Iu=new WeakSet,Gg=function(t){v(this,Uc,Cl.init(a(this,tn),this,t))},$g);Pl([gt("0002"),Gi.executeWithLock({methodName:"meeting.join",lockName:"DyteClient.join",timeout:3e3})],Hi.prototype,"join",1);Pl([gt("0003")],Hi.prototype,"leave",1);Pl([gt("0001"),Gi.executeWithLock({methodName:"DyteClient.init",lockName:"DyteClient.init",timeout:3e3})],Hi,"init",1);Hi=Pl([gt("0000")],Hi);const Vy=Hi;class rN{constructor(e){nc(this,"meeting");nc(this,"l");nc(this,"onUpdate",()=>{this.l.forEach(e=>{e()})});var r,i,n,s,o,c,d,h,p,g,y,T,b,A,P,V;this.meeting=e,this.l=new Set,(r=this.meeting.self)==null||r.addListener("*",this.onUpdate),(i=this.meeting.meta)==null||i.addListener("*",this.onUpdate),(n=this.meeting.participants)==null||n.addListener("*",this.onUpdate),(o=(s=this.meeting.participants)==null?void 0:s.joined)==null||o.addListener("*",this.onUpdate),(d=(c=this.meeting.participants)==null?void 0:c.active)==null||d.addListener("*",this.onUpdate),(p=(h=this.meeting.participants)==null?void 0:h.waitlisted)==null||p.addListener("*",this.onUpdate),(g=this.meeting.stage)==null||g.addListener("*",this.onUpdate),(y=this.meeting.livestream)==null||y.addListener("*",this.onUpdate),(T=this.meeting.chat)==null||T.addListener("*",this.onUpdate),(b=this.meeting.plugins)==null||b.all.addListener("*",this.onUpdate),(A=this.meeting.recording)==null||A.addListener("*",this.onUpdate),(P=this.meeting.connectedMeetings)==null||P.addListener("*",this.onUpdate),(V=this.meeting.polls)==null||V.addListener("*",this.onUpdate)}clean(){var e,r,i,n,s,o,c,d,h,p,g,y,T,b,A,P;(e=this.meeting.self)==null||e.removeListener("*",this.onUpdate),(r=this.meeting.meta)==null||r.removeListener("*",this.onUpdate),(i=this.meeting.participants)==null||i.removeListener("*",this.onUpdate),(s=(n=this.meeting.participants)==null?void 0:n.joined)==null||s.removeListener("*",this.onUpdate),(c=(o=this.meeting.participants)==null?void 0:o.active)==null||c.removeListener("*",this.onUpdate),(h=(d=this.meeting.participants)==null?void 0:d.waitlisted)==null||h.removeListener("*",this.onUpdate),(p=this.meeting.stage)==null||p.removeListener("*",this.onUpdate),(g=this.meeting.livestream)==null||g.removeListener("*",this.onUpdate),(y=this.meeting.chat)==null||y.removeListener("*",this.onUpdate),(T=this.meeting.plugins)==null||T.all.removeListener("*",this.onUpdate),(b=this.meeting.recording)==null||b.removeListener("*",this.onUpdate),(A=this.meeting.connectedMeetings)==null||A.removeListener("*",this.onUpdate),(P=this.meeting.polls)==null||P.removeListener("*",this.onUpdate)}addListener(e){this.l.add(e)}removeListener(e){this.l.delete(e)}}const Rl=Ct.createContext({meeting:void 0,updates:void 0});function iN({value:t,children:e,fallback:r}){const[i,n]=Ct.useState(),s=Ct.useRef();return Ct.useEffect(()=>(t&&n(new rN(t)),()=>{var o;(o=s.current)==null||o.clean()}),[t]),By.default.createElement(Rl.Provider,{value:{meeting:t,updates:i}},t?e:r)}const nN=()=>{const{meeting:t}=Ct.useContext(Rl);if(!t)throw new Error("useDyteMeeting must be used within the DyteProvider");return{meeting:t}},sN=t=>{const e=Ct.useRef(!1),[r,i]=Ct.useState(),n=t==null?void 0:t.resetOnLeave,s=Ct.useCallback(async o=>{if(!e.current)return e.current=!0,Vy.init(o).then(c=>(i(c),c)).finally(()=>{e.current=!1})},[]);return Ct.useEffect(()=>{if(!r||!n)return()=>{};const o=({state:c})=>{c!=="connected-meeting"&&c!=="disconnected"&&i(void 0)};return r.self.on("roomLeft",o),()=>{r.self.removeListener("roomLeft",o)}},[r]),Ct.useEffect(()=>{if(!r||!r.connectedMeetings)return()=>{};const o=c=>{i(void 0),setTimeout(()=>{i(c)},100)};return r.connectedMeetings.on("meetingChanged",o),()=>{r.connectedMeetings.removeListener("meetingChanged",o)}},[r]),[r,s]},aN=(t,e)=>!!(t!==e||Array.isArray(t)&&Array.isArray(e)&&t.length!==e.length),oN=t=>{const{meeting:e,updates:r}=Ct.useContext(Rl);if(!e)throw new Error("useDyteSelector must be used within the DyteProvider");const i=Ct.useRef(t(e)),[,n]=Ct.useReducer(s=>s+1,0);return Ct.useEffect(()=>{const s=e&&t(e),o=()=>{const c=e&&t(e);aN(i.current,c)&&(i.current=c,n())};return s&&typeof s=="object"&&"addListener"in s?(s.addListener("*",n),()=>{s.removeListener("*",n)}):(r==null||r.addListener(o),()=>{r==null||r.removeListener(o)})},[e,r]),i.current};exports.RTKSelfMedia=Zv;exports.RealtimeKitContext=Rl;exports.RealtimeKitProvider=iN;exports.useRealtimeKitClient=sN;exports.useRealtimeKitMeeting=nN;exports.useRealtimeKitSelector=oN;
|
package/dist/index.es.js
CHANGED
|
@@ -30037,7 +30037,7 @@ let Xr = (Dm = class {
|
|
|
30037
30037
|
var c, d;
|
|
30038
30038
|
const a = Xi.createContext(t, e), o = D(D({}, sC), e == null ? void 0 : e.modules);
|
|
30039
30039
|
return a.setValue("peerId", t), a.setValue("modules", o), a.setValue("sdkName", "web-core"), a.setValue("meetingId", r), a.setValue("apiBase", i.apiBase), a.setValue("baseURI", i.baseURI), a.setValue("userId", i.participantId), a.setValue("organizationId", i.orgId), a.setValue("authToken", e.authToken), a.setValue("overrides", (c = e.overrides) != null ? c : {}), a.setValue("env", rC({ baseURI: i.baseURI })), a.setValue("defaults", e.defaults || { audio: true, video: true }), a.setValue("onError", e.onError || (() => {
|
|
30040
|
-
})), a.setValue("cachedUserDetails", Cs(e.cachedUserDetails)), a.setValue("sdkVersion", "VERSION_PLACEHOLDER"), (d = e.modules) != null && d.
|
|
30040
|
+
})), a.setValue("cachedUserDetails", Cs(e.cachedUserDetails)), a.setValue("sdkVersion", "VERSION_PLACEHOLDER"), (d = e.modules) != null && d.experimentalAudioPlayback && a.setValue("audioPlayback", new BD()), a;
|
|
30041
30041
|
}
|
|
30042
30042
|
join() {
|
|
30043
30043
|
return l(this, null, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/realtimekit-react",
|
|
3
|
-
"version": "1.1.0-staging.
|
|
3
|
+
"version": "1.1.0-staging.5",
|
|
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",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"private": false,
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@cloudflare/realtimekit": "1.1.0-staging.
|
|
20
|
+
"@cloudflare/realtimekit": "1.1.0-staging.5"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": ">=16.8.6"
|