@cloudflare/realtimekit-react 1.2.0-staging.3 → 1.2.0-staging.4

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 CHANGED
@@ -9,7 +9,7 @@
9
9
  `},xs=vf,rT=tT,jc=rT,ws=xs.parse;xs.parseParams;xs.parseFmtpConfig;xs.parsePayloads;xs.parseRemoteCandidates;xs.parseImageAttributes;xs.parseSimulcastStreamList;var iT=Object.defineProperty,sT=Object.defineProperties,nT=Object.getOwnPropertyDescriptors,Wd=Object.getOwnPropertySymbols,aT=Object.getPrototypeOf,yf=Object.prototype.hasOwnProperty,Sf=Object.prototype.propertyIsEnumerable,oT=Reflect.get,cT=Math.pow,Nu=(t,e,r)=>e in t?iT(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,V=(t,e)=>{for(var r in e||(e={}))yf.call(e,r)&&Nu(t,r,e[r]);if(Wd)for(var r of Wd(e))Sf.call(e,r)&&Nu(t,r,e[r]);return t},G=(t,e)=>sT(t,nT(e)),fl=(t,e)=>{var r={};for(var i in t)yf.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&Wd)for(var i of Wd(t))e.indexOf(i)<0&&Sf.call(t,i)&&(r[i]=t[i]);return r},m=(t,e,r)=>(Nu(t,typeof e!="symbol"?e+"":e,r),r),Qh=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},a=(t,e,r)=>(Qh(t,e,"read from private field"),r?r.call(t):e.get(t)),g=(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)},f=(t,e,r,i)=>(Qh(t,e,"write to private field"),i?i.call(t,r):e.set(t,r),r),U=(t,e,r)=>(Qh(t,e,"access private method"),r),dT=(t,e,r)=>oT(aT(t),r,e),u=(t,e,r)=>new Promise((i,s)=>{var n=d=>{try{c(r.next(d))}catch(l){s(l)}},o=d=>{try{c(r.throw(d))}catch(l){s(l)}},c=d=>d.done?i(d.value):Promise.resolve(d.value).then(n,o);c((r=r.apply(t,e)).next())});function lT(t){const{length:e}=this,r=t>=0?t:e+t;return r<0||r>=e?void 0:this[r]}Array.prototype.at||Object.assign(Array.prototype,{at:lT});function uT(t){const{length:e}=this,r=t>=0?t:e+t;return r<0||r>=e?void 0:this[r]}String.prototype.at||Object.assign(String.prototype,{at:uT});const hT=t=>{!navigator.isReactNative&&typeof window!="undefined"&&(window.addEventListener("error",e=>{var r;!((r=e.filename)!=null&&r.includes("localhost"))&&e.lineno!==0&&t.error("window::error",{error:e.error},!0)}),window.addEventListener("unhandledrejection",e=>{var r,i,s,n,o,c,d,l;t.error("window::unhandledrejection",{error:e==null?void 0:e.reason,networkCall:{url:(i=(r=e==null?void 0:e.reason)==null?void 0:r.config)==null?void 0:i.url,baseURL:(n=(s=e==null?void 0:e.reason)==null?void 0:s.config)==null?void 0:n.baseURL,method:(c=(o=e==null?void 0:e.reason)==null?void 0:o.config)==null?void 0:c.method,status:(d=e==null?void 0:e.reason)==null?void 0:d.status,statusText:(l=e==null?void 0:e.reason)==null?void 0:l.statusText}},!0)}),window.addEventListener("offline",()=>{t.info("window::offline")}),window.addEventListener("online",()=>{t.info("window::online")}))},Ko="chrome",Tf="opera",kf="firefox",Ef="iexplorer",bf="safari",wf="nwjs",_f="electron",If="react-native",Xh="unknown",jd={Chrome:Ko,Chromium:Ko,Opera:Tf,Firefox:kf,"Internet Explorer":Ef,Safari:bf};function pT(){const{userAgent:t}=navigator,e={name:Xh,version:void 0};if(t.match(/Chrome/)&&!t.match(/Edge/))if(t.match(/Edg(A?)/)){const r=t.match(/Chrome\/([\d.]+)/)[1];Number.parseInt(r,10)>72&&(e.name=Ko,e.version=r)}else e.name=Ko,e.version=t.match(/Chrome\/([\d.]+)/)[1];return e}function mT(){const{userAgent:t}=navigator;if(t.match(/Electron/)){const e=t.match(/Electron\/([\d.]+)/)[1];return{name:_f,version:e}}return null}function gT(){const{userAgent:t}=navigator;if(t.match(/JitsiMeetNW/)){const e=t.match(/JitsiMeetNW\/([\d.]+)/)[1];return{name:wf,version:e}}}function fT(){const t=navigator.userAgent.match(/\b(react[ \t_-]*native)(?:\/(\S+))?/i);let e;if(t||navigator.product==="ReactNative")return t&&t.length>2&&(t[1],e=t[2]),e||(e="unknown"),{name:If,version:e}}function vT(t){let e;const r=[fT,mT,gT];for(let s=0;s<r.length;s+=1)if(e=r[s](),e)return e;const i=t.getBrowserName();return i in jd?{name:jd[i],version:t.getBrowserVersion()}:(e=pT(),e||{name:Xh,version:void 0})}class yT{constructor(){m(this,"_bowser"),m(this,"_name"),m(this,"_version"),m(this,"getDeviceInfo",()=>({isMobile:this.isMobile(),browserName:this._bowser.getBrowserName(),osName:this._bowser.getOSName(),browserVersion:this._bowser.getBrowserVersion(),osVersionName:this._bowser.getOSVersion(),engineName:this._bowser.getEngineName()}))}init(e){let r,i;if(this._bowser=nf.getParser(navigator.userAgent),typeof e=="undefined"){const s=vT(this._bowser);r=s.name,i=s.version}else e.name in jd?(r=jd[e.name],i=e.version):(r=Xh,i=void 0);this._name=r,this._version=i}getName(){return this._name}isChrome(){return this._name===Ko}isOpera(){return this._name===Tf}isFirefox(){return this._name===kf}isIExplorer(){return this._name===Ef}isSafari(){return this._name===bf}isNWJS(){return this._name===wf}isElectron(){return this._name===_f}isReactNative(){return this._name===If||navigator.isReactNative===!0}getVersion(){return this._version}isMobile(){return this._bowser.getPlatformType()==="mobile"}_checkCondition(e){if(this._version)return this._bowser.satisfies(e)}isVersionGreaterThan(e){return this._checkCondition({[this._name]:`>${e}`})}isVersionLessThan(e){return this._checkCondition({[this._name]:`<${e}`})}isVersionEqualTo(e){return this._checkCondition({[this._name]:`~${e}`})}}class ST extends yT{doesVideoMuteByStreamRemove(){return this.isChromiumBased()||this.isWebKitBased()}supportsP2P(){return!this.usesUnifiedPlan()}isChromiumBased(){return this.isChrome()||this.isElectron()||this.isNWJS()||this.isOpera()}isWebKitBased(){return this._bowser.isEngine("webkit")&&typeof navigator.mediaDevices!="undefined"&&typeof navigator.mediaDevices.getUserMedia!="undefined"&&typeof window.RTCRtpTransceiver!="undefined"&&Object.keys(RTCRtpTransceiver.prototype).indexOf("currentDirection")>-1}isSupported(){return typeof RTCPeerConnection!="undefined"}isUserInteractionRequiredForUnmute(){return this.isFirefox()&&this.isVersionLessThan("68")}supportsVideoMuteOnConnInterrupted(){return this.isChromiumBased()||this.isReactNative()||this.isWebKitBased()}supportsBandwidthStatistics(){return!this.isFirefox()&&!this.isWebKitBased()}supportsCodecPreferences(){return this.usesUnifiedPlan()&&typeof window.RTCRtpTransceiver!="undefined"&&Object.keys(window.RTCRtpTransceiver.prototype).indexOf("setCodecPreferences")>-1&&Object.keys(RTCRtpSender.prototype).indexOf("getCapabilities")>-1&&!this.isWebKitBased()}supportsDeviceChangeEvent(){return navigator.mediaDevices&&typeof navigator.mediaDevices.ondevicechange!="undefined"&&typeof navigator.mediaDevices.addEventListener!="undefined"}supportsLocalCandidateRttStatistics(){return this.isChromiumBased()||this.isReactNative()||this.isWebKitBased()}supportsPerformanceObserver(){return typeof window.PerformanceObserver!="undefined"&&PerformanceObserver.supportedEntryTypes.indexOf("longtask")>-1}supportsReceiverStats(){return typeof window.RTCRtpReceiver!="undefined"&&Object.keys(RTCRtpReceiver.prototype).indexOf("getSynchronizationSources")>-1}supportsRTTStatistics(){return!this.isFirefox()}usesPlanB(){return!this.usesUnifiedPlan()}usesSdpMungingForSimulcast(){return this.isChromiumBased()||this.isReactNative()||this.isWebKitBased()}usesUnifiedPlan(){return!!(this.isFirefox()||this.isWebKitBased())}usesNewGumFlow(){return!!(this.isChromiumBased()||this.isFirefox()||this.isWebKitBased())}usesAdapter(){return this.usesNewGumFlow()}usesRidsForSimulcast(){return!1}supportsGetDisplayMedia(){return typeof navigator.getDisplayMedia!="undefined"||typeof navigator.mediaDevices!="undefined"&&typeof navigator.mediaDevices.getDisplayMedia!="undefined"}supportsInsertableStreams(){if(!(typeof window.RTCRtpSender!="undefined"&&(window.RTCRtpSender.prototype.createEncodedStreams||window.RTCRtpSender.prototype.createEncodedVideoStreams)))return!1;const e=new ReadableStream;try{return window.postMessage(e,"*",[e]),!0}catch{return!1}}supportsAudioRed(){return Boolean(window.RTCRtpSender&&window.RTCRtpSender.getCapabilities&&window.RTCRtpSender.getCapabilities("audio").codecs.some(e=>e.mimeType==="audio/red")&&window.RTCRtpReceiver&&window.RTCRtpReceiver.getCapabilities&&window.RTCRtpReceiver.getCapabilities("audio").codecs.some(e=>e.mimeType==="audio/red"))}supportsSdpSemantics(){return this.isChromiumBased()}_getChromiumBasedVersion(){if(this.isChromiumBased()){if(this.isNWJS())return Number.parseInt(process.versions.chromium,10);const e=navigator.userAgent;if(e.match(/Chrome/))return Number.parseInt(e.match(/Chrome\/([\d.]+)/)[1],10)}return-1}isIOSMobile(){return this.isMobile&&this._bowser.getOSName()==="iOS"}}const Ie=new ST;var gt={},TT={get exports(){return gt},set exports(t){gt=t}},Gn=typeof Reflect=="object"?Reflect:null,jp=Gn&&typeof Gn.apply=="function"?Gn.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)},Hc;Gn&&typeof Gn.ownKeys=="function"?Hc=Gn.ownKeys:Object.getOwnPropertySymbols?Hc=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Hc=function(t){return Object.getOwnPropertyNames(t)};function kT(t){console&&console.warn&&console.warn(t)}var Cf=Number.isNaN||function(t){return t!==t};function he(){he.init.call(this)}TT.exports=he;gt.once=_T;he.EventEmitter=he;he.prototype._events=void 0;he.prototype._eventsCount=0;he.prototype._maxListeners=void 0;var Hp=10;function vl(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(he,"defaultMaxListeners",{enumerable:!0,get:function(){return Hp},set:function(t){if(typeof t!="number"||t<0||Cf(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Hp=t}});he.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};he.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Cf(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 Pf(t){return t._maxListeners===void 0?he.defaultMaxListeners:t._maxListeners}he.prototype.getMaxListeners=function(){return Pf(this)};he.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i=t==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var n;if(e.length>0&&(n=e[0]),n instanceof Error)throw n;var o=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw o.context=n,o}var c=s[t];if(c===void 0)return!1;if(typeof c=="function")jp(c,this,e);else for(var d=c.length,l=Of(c,d),r=0;r<d;++r)jp(l[r],this,e);return!0};function Rf(t,e,r,i){var s,n,o;if(vl(r),n=t._events,n===void 0?(n=t._events=Object.create(null),t._eventsCount=0):(n.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),n=t._events),o=n[e]),o===void 0)o=n[e]=r,++t._eventsCount;else if(typeof o=="function"?o=n[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),s=Pf(t),s>0&&o.length>s&&!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,kT(c)}return t}he.prototype.addListener=function(t,e){return Rf(this,t,e,!1)};he.prototype.on=he.prototype.addListener;he.prototype.prependListener=function(t,e){return Rf(this,t,e,!0)};function ET(){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 Mf(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},s=ET.bind(i);return s.listener=r,i.wrapFn=s,s}he.prototype.once=function(t,e){return vl(e),this.on(t,Mf(this,t,e)),this};he.prototype.prependOnceListener=function(t,e){return vl(e),this.prependListener(t,Mf(this,t,e)),this};he.prototype.removeListener=function(t,e){var r,i,s,n,o;if(vl(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(s=-1,n=r.length-1;n>=0;n--)if(r[n]===e||r[n].listener===e){o=r[n].listener,s=n;break}if(s<0)return this;s===0?r.shift():bT(r,s),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,o||e)}return this};he.prototype.off=he.prototype.removeListener;he.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 s=Object.keys(r),n;for(i=0;i<s.length;++i)n=s[i],n!=="removeListener"&&this.removeAllListeners(n);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 Af(t,e,r){var i=t._events;if(i===void 0)return[];var s=i[e];return s===void 0?[]:typeof s=="function"?r?[s.listener||s]:[s]:r?wT(s):Of(s,s.length)}he.prototype.listeners=function(t){return Af(this,t,!0)};he.prototype.rawListeners=function(t){return Af(this,t,!1)};he.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Df.call(t,e)};he.prototype.listenerCount=Df;function Df(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}he.prototype.eventNames=function(){return this._eventsCount>0?Hc(this._events):[]};function Of(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function bT(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function wT(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function _T(t,e){return new Promise(function(r,i){function s(o){t.removeListener(e,n),i(o)}function n(){typeof t.removeListener=="function"&&t.removeListener("error",s),r([].slice.call(arguments))}Nf(t,e,n,{once:!0}),e!=="error"&&IT(t,s,{once:!0})})}function IT(t,e,r){typeof t.on=="function"&&Nf(t,"error",e,r)}function Nf(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 s(n){i.once&&t.removeEventListener(e,s),r(n)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var z;(function(t){t[t.MAJOR_EVENT=0]="MAJOR_EVENT",t[t.MINOR_EVENT=1]="MINOR_EVENT"})(z||(z={}));var L;(function(t){t.PRECALL_TEST_BEGIN="precall_begin",t.PRECALL_TEST_COMPLETE="precall_end",t.CALL_JOIN_BEGIN="call_join",t.NET_QUALITY_TEST_BEGIN="net_quality_test_begin",t.NET_QUALITY_TEST_END="net_quality_test_end",t.WEBSOCKET_CONNECTED="websocket_connected",t.TRANSPORT_CONNECTED="transport_connected",t.AUDIO_ON="audio_on",t.AUDIO_OFF="audio_off",t.VIDEO_ON="video_on",t.VIDEO_OFF="video_off",t.PARTICIPANT_ROLE="participant_role",t.PING_STAT="ping_stat",t.DISCONNECT="disconnect",t.RECONNECT_ATTEMPT="reconnect_attempt",t.SCREENSHARE_START_REQUESTED="screenshare_start_requested",t.SCREENSHARE_STARTED="screenshare_started",t.SCREENSHARE_STOPPED="screenshare_stopped",t.TAB_CHANGE="tab_change",t.BROWSER_BACKGROUNDED="browser_backgrounded",t.BROWSER_FOREGROUNDED="browser_foregrounded",t.DOMINANT_SPEAKER="dominant_speaker",t.AUDIO_DEVICES_UPDATES="audio_devices_updates",t.VIDEO_DEVICES_UPDATES="video_devices_updates",t.SPEAKER_DEVICES_UPDATES="speaker_devices_updates",t.SELECTED_MICROHPONE_UPDATE="selected_microphone_update",t.SELECTED_CAMERA_UPDATE="selected_camera_update",t.SELECTED_SPEAKER_UPDATE="selected_speaker_update",t.EXPECTED_VIDEO_RESOLUTION="expected_video_resolution",t.EXPECTED_SCREENSHARE_RESOLUTION="expected_screenshare_resolution",t.MEDIA_PERMISSION="media_permission",t.LEGACY_SWITCH="legacy_switch",t.AUDIO_PLAY_FAILED="audio_play_failed",t.VIDEO_PLAY_FAILED="video_play_failed",t.AUDIO_TRACK_MUTED="audio_track_muted",t.VIDEO_TRACK_MUTED="video_track_muted",t.IVS_PLAYER_REBUFFERING="ivs_player_rebuffering",t.IVS_PLAYER_AUDIO_BLOCKED="ivs_player_audio_blocked",t.IVS_PLAYER_PLAYBACK_BLOCKED="ivs_player_playback_blocked",t.IVS_PLAYER_ERROR="ivs_player_error",t.IVS_PLAYER_RECOVERABLE_ERROR="ivs_player_recoverable_error",t.IVS_PLAYER_WORKER_ERROR="ivs_player_worker_error",t.IVS_PLAYER_NETWORK_UNAVAILABLE="ivs_player_network_unavailable",t.LIVESTREAM_LATENCY="livestream_latency",t.IVS_PLAYER_ANALYTICS_EVENT="ivs_player_analytics_event",t.IVS_PLAYER_PLAYBACK_RATE_CHANGED="ivs_player_playback_rate_changed",t.IVS_PLAYER_QUALITY_CHANGED="ivs_player_quality_changed",t.IVS_PLAYER_INITIALIZED="ivs_player_initialized"})(L||(L={}));const CT=new Map([[L.PRECALL_TEST_BEGIN,z.MINOR_EVENT],[L.PRECALL_TEST_COMPLETE,z.MINOR_EVENT],[L.CALL_JOIN_BEGIN,z.MAJOR_EVENT],[L.NET_QUALITY_TEST_BEGIN,z.MINOR_EVENT],[L.NET_QUALITY_TEST_END,z.MINOR_EVENT],[L.WEBSOCKET_CONNECTED,z.MINOR_EVENT],[L.TRANSPORT_CONNECTED,z.MAJOR_EVENT],[L.AUDIO_ON,z.MINOR_EVENT],[L.AUDIO_OFF,z.MINOR_EVENT],[L.VIDEO_ON,z.MINOR_EVENT],[L.VIDEO_OFF,z.MINOR_EVENT],[L.PARTICIPANT_ROLE,z.MINOR_EVENT],[L.PING_STAT,z.MAJOR_EVENT],[L.DISCONNECT,z.MAJOR_EVENT],[L.RECONNECT_ATTEMPT,z.MAJOR_EVENT],[L.SCREENSHARE_START_REQUESTED,z.MINOR_EVENT],[L.SCREENSHARE_STARTED,z.MINOR_EVENT],[L.SCREENSHARE_STOPPED,z.MINOR_EVENT],[L.TAB_CHANGE,z.MINOR_EVENT],[L.BROWSER_BACKGROUNDED,z.MINOR_EVENT],[L.BROWSER_FOREGROUNDED,z.MINOR_EVENT],[L.DOMINANT_SPEAKER,z.MINOR_EVENT],[L.AUDIO_DEVICES_UPDATES,z.MINOR_EVENT],[L.VIDEO_DEVICES_UPDATES,z.MINOR_EVENT],[L.SPEAKER_DEVICES_UPDATES,z.MINOR_EVENT],[L.SELECTED_MICROHPONE_UPDATE,z.MINOR_EVENT],[L.SELECTED_CAMERA_UPDATE,z.MINOR_EVENT],[L.SELECTED_SPEAKER_UPDATE,z.MINOR_EVENT],[L.MEDIA_PERMISSION,z.MINOR_EVENT],[L.LEGACY_SWITCH,z.MINOR_EVENT],[L.AUDIO_PLAY_FAILED,z.MINOR_EVENT],[L.VIDEO_PLAY_FAILED,z.MINOR_EVENT],[L.AUDIO_TRACK_MUTED,z.MINOR_EVENT],[L.VIDEO_TRACK_MUTED,z.MINOR_EVENT],[L.IVS_PLAYER_REBUFFERING,z.MAJOR_EVENT],[L.IVS_PLAYER_AUDIO_BLOCKED,z.MAJOR_EVENT],[L.IVS_PLAYER_PLAYBACK_BLOCKED,z.MAJOR_EVENT],[L.IVS_PLAYER_ERROR,z.MAJOR_EVENT],[L.IVS_PLAYER_RECOVERABLE_ERROR,z.MAJOR_EVENT],[L.IVS_PLAYER_WORKER_ERROR,z.MAJOR_EVENT],[L.IVS_PLAYER_NETWORK_UNAVAILABLE,z.MAJOR_EVENT],[L.LIVESTREAM_LATENCY,z.MAJOR_EVENT],[L.IVS_PLAYER_ANALYTICS_EVENT,z.MINOR_EVENT],[L.IVS_PLAYER_PLAYBACK_RATE_CHANGED,z.MINOR_EVENT],[L.IVS_PLAYER_QUALITY_CHANGED,z.MINOR_EVENT],[L.IVS_PLAYER_INITIALIZED,z.MINOR_EVENT],[L.EXPECTED_VIDEO_RESOLUTION,z.MINOR_EVENT],[L.EXPECTED_SCREENSHARE_RESOLUTION,z.MINOR_EVENT]]);class PT{constructor(){m(this,"events"),this.events=[]}add(e){this.events.push(e)}flush(){return{entries:this.events.splice(0,25)}}}class RT extends gt{constructor({logger:e,peerId:r,apiHostnames:i}){super(),m(this,"logger"),m(this,"peerId"),m(this,"eventStore"),m(this,"apiEndpoint"),this.logger=e,this.peerId=r,this.apiEndpoint=`https://${i.daCollector}/api/v1/message`,this.eventStore=new PT}sendEventsChunkToServer(e){return u(this,null,function*(){var r;const i={payload:e,peerId:this.peerId};try{return yield fetch(this.apiEndpoint,{method:"POST",body:JSON.stringify(i)}),!0}catch(s){return this.logger.error("callStats::sendEventsChunkToServer::catch",{error:s}),(r=e.entries)==null||r.forEach(n=>{this.eventStore.add(n)}),!1}})}callEvent(e){e.timestamp=new Date,this.eventStore.add(e),this.emit(e.event,e.metaData),CT.get(e.event)===z.MAJOR_EVENT&&this.flush()}flush(){return u(this,null,function*(){var e;const r=this.eventStore.flush();return(e=r==null?void 0:r.entries)!=null&&e.length?(yield this.sendEventsChunkToServer(r),!0):!1})}}var qp;(function(t){t.CHROMIUM="chromum",t.FIREFOX="firefox",t.SAFARI="safari"})(qp||(qp={}));const Do={DEVEL:"devel",PREPROD:"preprod",PROD:"prod"};var or;(function(t){t.AUDIO="AUDIO",t.VIDEO="VIDEO",t.SPEAKER="SPEAKER",t.SCREENSHARE="SCREENSHARE"})(or||(or={}));var Gp;(function(t){t[t.INIT=0]="INIT",t[t.ACCEPTED=1]="ACCEPTED",t[t.DENIED=2]="DENIED",t[t.SYS_DENIED=3]="SYS_DENIED",t[t.FAILED=4]="FAILED",t[t.NOTFOUND=5]="NOTFOUND",t[t.NOT_APPLICABLE=6]="NOT_APPLICABLE"})(Gp||(Gp={}));function qi(t){return t?t.split(".").slice(0,2).concat(["0","0"]).join("."):""}function Hd({packetsLost:t,packetsSent:e}){return e>0?t*100/e:0}function qd({packetsLost:t,packetsReceived:e}){return e+t>0?t*100/(e+t):0}const Vf=240,Lf=720,xf=8,Uf=3,yl=10,Sl=.02,Tl=.03;function ci({stat:t,weight:e,rangeMin:r,rangeMax:i,rangeRankingDirection:s}){return t==null?e:r===i?s==="UP"?t<=r?e:0:t>=i?e:0:s==="UP"?(1-Math.max(Math.min(i,Math.abs(t))-r,0)/(i-r))*e:s==="DOWN"?Math.max(Math.min(i,Math.abs(t))-r,0)/(i-r)*e:e}function Ff({isLowQualityVideo:t,isVideoStuck:e,isVideoLagging:r,jitterQuality:i,packetsLostQuality:s}){const n=.8*((t?.85:1)*(r?.7:1)*(e?.5:1))+.2*(i*s);return Math.round((n+Number.EPSILON)*100)/100}function Bf({packetsLost:t,packetsSent:e}){return e>0?t*100/e:0}function Wf({packetsLost:t,packetsSent:e,jitter:r}){const i=ci({stat:Bf({packetsLost:t,packetsSent:e}),weight:.7,rangeMin:0,rangeMax:yl,rangeRankingDirection:"UP"}),s=ci({stat:r,weight:.3,rangeMin:Sl,rangeMax:Tl,rangeRankingDirection:"UP"});return i+s}function MT({frameWidth:t,isScreenShare:e}){return t<(e?Lf:Vf)}function AT({framesPerSecond:t,isScreenShare:e}){return t<(e?Uf:xf)}function DT({framesEncoded:t}){return t===0}function jf({frameWidth:t,framesPerSecond:e,packetsLost:r,packetsSent:i,jitter:s,isScreenShare:n,framesEncoded:o}){const c=ci({stat:Bf({packetsLost:r,packetsSent:i}),weight:1,rangeMin:0,rangeMax:yl,rangeRankingDirection:"UP"}),d=ci({stat:s,weight:1,rangeMin:Sl,rangeMax:Tl,rangeRankingDirection:"UP"}),l=MT({frameWidth:t,isScreenShare:n}),h=AT({framesPerSecond:e,isScreenShare:n}),p=DT({framesEncoded:o,isScreenShare:n});return Ff({isLowQualityVideo:l,isVideoLagging:h,isVideoStuck:p,jitterQuality:d,packetsLostQuality:c})}function Hf({packetsLost:t,packetsReceived:e}){return e+t>0?t*100/(e+t):0}function qf({concealmentEvents:t,packetsLost:e,packetsReceived:r,jitter:i}){const s=ci({stat:t,weight:.2,rangeMin:0,rangeMax:3,rangeRankingDirection:"UP"}),n=.5,o=ci({stat:Hf({packetsLost:e,packetsReceived:r}),weight:n,rangeMin:0,rangeMax:yl,rangeRankingDirection:"UP"}),c=ci({stat:i,weight:.3,rangeMin:Sl,rangeMax:Tl,rangeRankingDirection:"UP"});return s+o+c}function OT({framesDecoded:t}){return t===0}function NT({framesPerSecond:t,isScreenShare:e}){return t<(e?Uf:xf)}function VT({frameWidth:t,isScreenShare:e}){return t<(e?Lf:Vf)}function Gf({frameWidth:t,framesPerSecond:e,packetsLost:r,packetsReceived:i,jitter:s,isScreenShare:n,framesDecoded:o}){const c=ci({stat:Hf({packetsLost:r,packetsReceived:i}),weight:1,rangeMin:0,rangeMax:yl,rangeRankingDirection:"UP"}),d=ci({stat:s,weight:1,rangeMin:Sl,rangeMax:Tl,rangeRankingDirection:"UP"}),l=VT({frameWidth:t,isScreenShare:n}),h=NT({framesPerSecond:e,isScreenShare:n}),p=OT({framesDecoded:o,isScreenShare:n});return Ff({isLowQualityVideo:l,isVideoLagging:h,isVideoStuck:p,jitterQuality:d,packetsLostQuality:c})}class di{constructor(e){m(this,"pc1"),m(this,"pc2"),m(this,"constrainVideoBitrateKbps"),m(this,"constrainOfferToRemoveVideoFec",!1),m(this,"iceCandidateFilter");const r=new RTCPeerConnection(e),i=new RTCPeerConnection(e);this.pc1=r,this.pc2=i,this.iceCandidateFilter=di.noFilter,this.pc1.addEventListener("icecandidate",this.onIceCandidate.bind(this,this.pc2)),this.pc2.addEventListener("icecandidate",this.onIceCandidate.bind(this,this.pc1))}static parseCandidate(e){const r="candidate:",i=e.indexOf(r)+r.length,s=e.substr(i).split(" ");return{type:s[7],protocol:s[2],address:s[4]}}static isNotHostCandidate(e){return e.type!=="host"}static isHost(e){return e.type==="host"}static isRelay(e){return e.type==="relay"}static isReflexive(e){return e.type==="srflx"}static noFilter(e){return!0}onIceCandidate(e,r){if(r.candidate){const i=di.parseCandidate(r.candidate.candidate);this.iceCandidateFilter(i)&&e.addIceCandidate(r.candidate)}}setIceCandidateFilter(e){this.iceCandidateFilter=e}constrainVideoBitrate(e){this.constrainVideoBitrateKbps=e}disableVideoFec(){this.constrainOfferToRemoveVideoFec=!0}gotOffer(e){this.constrainOfferToRemoveVideoFec&&(e.sdp=e.sdp.replace(/(m=video 1 [^\r]+)(116 117)(\r\n)/g,`$1\r
10
10
  `),e.sdp=e.sdp.replace(/a=rtpmap:116 red\/90000\r\n/g,""),e.sdp=e.sdp.replace(/a=rtpmap:117 ulpfec\/90000\r\n/g,""),e.sdp=e.sdp.replace(/a=rtpmap:98 rtx\/90000\r\n/g,""),e.sdp=e.sdp.replace(/a=fmtp:98 apt=116\r\n/g,"")),this.pc1.setLocalDescription(e),this.pc2.setRemoteDescription(e),this.pc2.createAnswer().then(this.gotAnswer.bind(this),this.reportFatal.bind(this))}gotAnswer(e){this.constrainVideoBitrateKbps&&(e.sdp=e.sdp.replace(/a=mid:video\r\n/g,`a=mid:video\r
11
11
  b=AS:${this.constrainVideoBitrateKbps}\r
12
- `)),this.pc2.setLocalDescription(e),this.pc1.setRemoteDescription(e)}establishConnection(){this.pc1.createOffer().then(this.gotOffer.bind(this),this.reportFatal.bind(this))}reportFatal(e){console.error("Error:",e)}getRoundTripTime(){return u(this,null,function*(){const[e,r]=yield Promise.all([this.pc1.getStats(),this.pc2.getStats()]);let i,s;if(e.forEach(n=>{n.type==="candidate-pair"&&n.nominated===!0&&n.bytesSent>0&&(i=n)}),r.forEach(n=>{n.type==="candidate-pair"&&n.nominated===!0&&n.bytesReceived>0&&(s=n)}),i&&s)try{if(i.currentRoundTripTime&&s.currentRoundTripTime)return{rtt:i.currentRoundTripTime,backendRTT:s.currentRoundTripTime};const n=(s.lastPacketReceivedTimestamp-i.lastPacketSentTimestamp)/1e3;return{rtt:n,backendRTT:n}}catch{return}})}close(){this.pc1.close(),this.pc2.close()}}class $f extends gt{constructor(e){super(),m(this,"call"),m(this,"timeOut"),this.call=new di(e)}start(e=1e4){this.call.establishConnection(),this.timeOut=setTimeout(this.testFailed.bind(this),e)}testComplete(e){clearTimeout(this.timeOut),this.call.close(),this.emit("done",e)}testFailed(e){this.call.close(),this.emit("failed",e)}}const LT=8,xT=1/1e3;class UT extends $f{constructor(e){super(e),m(this,"senderChannel"),m(this,"recieveChannel"),m(this,"startTime"),m(this,"lastBitrateMeasureTime"),m(this,"sentPayloadBytes",0),m(this,"recievedPayloadBytes",0),m(this,"lastReceivedPayloadBytes",0),m(this,"stopSending",!1),m(this,"testProgress",0),m(this,"samplePacket",""),m(this,"finalBitrateSum",0),m(this,"bitRateSampels",0),m(this,"maxNumberOfPacketsToSend",0),m(this,"bytesToKeepBuffered",0),m(this,"testDurationSeconds",5),this.call.setIceCandidateFilter(di.isNotHostCandidate),this.senderChannel=this.call.pc1.createDataChannel(null);for(let r=0;r<1024*256;r+=1)this.samplePacket+="h";this.maxNumberOfPacketsToSend=1,this.bytesToKeepBuffered=1024*this.maxNumberOfPacketsToSend,this.testDurationSeconds=4,this.senderChannel.addEventListener("open",this.sendingStep.bind(this)),this.call.pc2.addEventListener("datachannel",this.onRecieverChannel.bind(this))}sendingStep(){const e=new Date;this.startTime||(this.startTime=e,this.lastBitrateMeasureTime=e);for(let i=0;i!==this.maxNumberOfPacketsToSend&&!(this.senderChannel.bufferedAmount>=this.bytesToKeepBuffered);i+=1){this.sentPayloadBytes+=this.samplePacket.length;try{this.senderChannel.send(this.samplePacket)}catch{}}const r=e.getTime()-this.startTime.getTime();r>=1e3*this.testDurationSeconds?(this.stopSending=!0,this.testProgress=100):(this.testProgress=r/(10*this.testDurationSeconds),setTimeout(this.sendingStep.bind(this),1))}onMessageRecieved(e){this.recievedPayloadBytes+=e.data.length;const r=new Date,i=r.getTime()-this.lastBitrateMeasureTime.getTime();if(i>=1e3){const s=(this.recievedPayloadBytes-this.lastReceivedPayloadBytes)*LT/(i/1e3);this.finalBitrateSum+=s,this.bitRateSampels+=1,this.lastReceivedPayloadBytes=this.recievedPayloadBytes,this.lastBitrateMeasureTime=r}if(this.stopSending&&this.sentPayloadBytes===this.recievedPayloadBytes){const s=this.finalBitrateSum/this.bitRateSampels;this.testComplete({throughput:Math.round(s*xT)})}}testComplete(e){this.call.getRoundTripTime().then(({rtt:r,backendRTT:i})=>super.testComplete({RTT:r,backendRTT:i,throughput:e.throughput}))}onRecieverChannel(e){this.recieveChannel=e.channel,this.recieveChannel.addEventListener("message",this.onMessageRecieved.bind(this))}}class Zh extends $f{constructor(e,r=di.noFilter){super(e),m(this,"ch1"),m(this,"ch2"),this.call.setIceCandidateFilter(r);const i=this.call.pc1.createDataChannel(null);this.ch1=i,i.addEventListener("open",()=>{i.send("hello")}),i.addEventListener("message",this.onCh1Recieve.bind(this)),this.call.pc2.addEventListener("datachannel",this.dataChannelHandler.bind(this))}onCh1Recieve(e){e.data!=="world"?this.hangup("Invalid data transmitted."):this.testComplete({connectivity:!0})}onCh2Recieve(e){if(e.data!=="hello")this.hangup("Invalid data transmitted.");else try{this.ch2.send("world")}catch{}}dataChannelHandler(e){const r=e.channel;this.ch2=r,r.addEventListener("message",this.onCh2Recieve.bind(this))}hangup(e){this.testFailed(e)}}class FT extends Zh{constructor(e){super(e,di.isHost)}}class BT extends Zh{constructor(e){super(e,di.isRelay)}}class WT extends Zh{constructor(e){super(e,di.isReflexive)}}class jT{constructor(){m(this,"ipInformation",null)}getIPDetails(e){return u(this,arguments,function*({peerId:r,apiHostnames:i,logger:s}){var n,o,c;if(!this.ipInformation){try{const d=`https://${i.location}`,l=yield(yield fetch(d)).json();if(((n=l.loc)==null?void 0:n.length)>5)return this.ipInformation=l,(o=this.ipInformation)!=null&&o.ip&&(this.ipInformation.ip=qi(this.ipInformation.ip)),l;throw Error("Insufficient data")}catch(d){s.error("callstats::ipDetails:: failed to fetch ip using location service",{error:d})}try{const d=yield fetch(`https://${i.locationLegacy}/?token=3c493932b0624c&peerId=${r}`,{method:"POST"});this.ipInformation=yield d.json(),(c=this.ipInformation)!=null&&c.ip&&(this.ipInformation.ip=qi(this.ipInformation.ip))}catch(d){s.error("callstats::ipDetails:: failed to fetch ip using legacy location service",{error:d})}}return this.ipInformation})}resetCache(){this.ipInformation=null}}const ep=new jT,$p=[{urls:"turn:turn.dyte.in:443?transport=tcp",username:"dyte",credential:"dytein",credentialType:"password"},{urls:"turn:turn.dyte.in:3478?transport=udp",username:"dyte",credential:"dytein",credentialType:"password"}];function Jp(t){const[e,r]=t.split(",");return{coords:{latitude:Number(e),longitude:Number(r)}}}class Jf{constructor(){m(this,"transport"),m(this,"candidatePair"),m(this,"outboundVideoRtp",new Map),m(this,"inboundVideoRtp",new Map),m(this,"outboundAudioRtp",new Map),m(this,"inboundAudioRtp",new Map),m(this,"remoteInboundRtp",new Map),m(this,"producerStreamMap",new Map),m(this,"consumerStreamMap",new Map),m(this,"staleProducerStreamMap",!1),m(this,"staleConsumerStreamMap",!1)}}class Kf extends gt{constructor(){super(),m(this,"observer"),m(this,"outboundProducerMap",new Map),m(this,"inboundConsumerMap",new Map),m(this,"consumerPeerIdMap",new Map),m(this,"pausedConsumerMap",new Map),m(this,"pausedProducerMap",new Map),m(this,"overallProducingTransportsStatsMap",{}),m(this,"overallConsumingTransportsStatsMap",{}),m(this,"overallConsumersStatsMap",{}),m(this,"overallProducersStatsMap",{}),m(this,"videoProducerToStatsMap",new Map),m(this,"audioProducerToStatsMap",new Map),m(this,"videoConsumerToStatsMap",new Map),m(this,"audioConsumerToStatsMap",new Map),m(this,"consumerIdsWithFreezedVideo",new Set),m(this,"consumerIdsWithFreezedAudio",new Set),m(this,"producerIdsWithFreezedVideo",new Set),m(this,"producerIdsWithFreezedAudio",new Set),m(this,"freezedProducingTransportIds",new Set),m(this,"freezedConsumingTransportIds",new Set),m(this,"screenShareProducers",new Set),m(this,"screenShareConsumers",new Set),m(this,"ipDetails"),m(this,"callStatsInstance"),this.observer=new gt}registerProducer(e){return u(this,null,function*(){yield this.generateProducerStreamMap(e),e.on("close",this.deregisterProducer.bind(this,e)),e.on("pause",this.pauseProducer.bind(this,e.id)),e.on("resume",this.resumeProducer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareProducers.add(e.id)})}pauseProducer(e){this.pausedProducerMap.set(e,{lastReportCalculated:!1})}resumeProducer(e){this.pausedProducerMap.delete(e)}processInboundConsumerVideoStats(e,r,i){var s,n;const o=((n=(s=this==null?void 0:this.callStatsInstance)==null?void 0:s.consumerSharedMediaStatesMap)==null?void 0:n.get(e))||{};r.totalVideoPacketsReceived===i.packetsReceived?(this.consumerIdsWithFreezedVideo.add(e),this.callStatsInstance&&o.video&&(this.callStatsInstance.logger.debug("callstats::measurements::consumerVideoFreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_video_status","pause",e))):(r.totalVideoPacketsReceived=i.packetsReceived,this.consumerIdsWithFreezedVideo.has(e)&&(this.consumerIdsWithFreezedVideo.delete(e),this.callStatsInstance&&o.video&&(this.callStatsInstance.logger.debug("callstats::measurements::consumerVideoDefreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_video_status","resume",e))))}processInboundConsumerAudioStats(e,r,i){var s,n;const o=((n=(s=this==null?void 0:this.callStatsInstance)==null?void 0:s.consumerSharedMediaStatesMap)==null?void 0:n.get(e))||{};r.totalAudioPacketsReceived===i.packetsReceived?(this.consumerIdsWithFreezedAudio.add(e),this.callStatsInstance&&o.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::consumerAudioFreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_audio_status","pause",e))):(r.totalAudioPacketsReceived=i.packetsReceived,this.consumerIdsWithFreezedAudio.has(e)&&(this.consumerIdsWithFreezedAudio.delete(e),this.callStatsInstance&&o.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::consumerAudioDefreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_audio_status","resume",e))))}processOutboundProducerVideoStats(e,r,i){var s;const n=((s=this==null?void 0:this.callStatsInstance)==null?void 0:s.currentUserMediaStates)||{};r.totalVideoPacketsSent===i.packetsSent?(this.producerIdsWithFreezedVideo.add(e),this.callStatsInstance&&n.video&&(this.callStatsInstance.logger.debug("callStats::measurements::producerVideoFreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_video_status","pause",e))):(r.totalVideoPacketsSent=i.packetsSent,this.producerIdsWithFreezedVideo.has(e)&&(this.producerIdsWithFreezedVideo.delete(e),this.callStatsInstance&&n.video&&(this.callStatsInstance.logger.debug("callStats::measurements::producerVideoDefreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_video_status","resume",e))))}processOutboundProducerAudioStats(e,r,i){var s;const n=((s=this==null?void 0:this.callStatsInstance)==null?void 0:s.currentUserMediaStates)||{};r.totalAudioPacketsSent===i.packetsSent?(this.producerIdsWithFreezedAudio.add(e),this.callStatsInstance&&n.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::producerAudioFreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_audio_status","pause",e))):(r.totalAudioPacketsSent=i.packetsSent,this.producerIdsWithFreezedAudio.has(e)&&(this.producerIdsWithFreezedAudio.delete(e),this.callStatsInstance&&n.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::producerAudioDefreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_audio_status","resume",e))))}processProducingTransportStats(e,r,i){var s;const n=((s=this==null?void 0:this.callStatsInstance)==null?void 0:s.currentUserMediaStates)||{},{audio:o,video:c,screen:d}=n,l=o||c||d;r.totalPacketsSent===i.packetsSent?(this.freezedProducingTransportIds.add(e),this.callStatsInstance&&l&&(this.callStatsInstance.logger.debug("callStats::measurements::producingTransportFreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("producing_transport_status","pause",e))):(r.totalPacketsSent=i.packetsSent,this.freezedProducingTransportIds.has(e)&&(this.freezedProducingTransportIds.delete(e),this.callStatsInstance&&l&&(this.callStatsInstance.logger.debug("callStats::measurements::producingTransportDefreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("producing_transport_status","resume",e))))}processConsumingTransportStats(e,r,i){var s,n;const o=!!Array.from(((n=(s=this==null?void 0:this.callStatsInstance)==null?void 0:s.consumerSharedMediaStatesMap)==null?void 0:n.values())||[]).reduce((c,d)=>c||d.audio||d.video||d.screen,!1);r.totalPacketsReceived===i.packetsSent?(this.freezedConsumingTransportIds.add(e),this.callStatsInstance&&o&&(this.callStatsInstance.logger.debug("callStats::measurements::consumingTransportFreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("consuming_transport_status","pause",e))):(r.totalPacketsReceived=i.packetsSent,this.freezedConsumingTransportIds.has(e)&&(this.freezedConsumingTransportIds.delete(e),this.callStatsInstance&&o&&(this.callStatsInstance.logger.debug("callStats::measurements::consumingTransportDefreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("consuming_transport_status","resume",e))))}registerConsumer(e){return u(this,null,function*(){yield this.generateConsumerStreamMap(e),this.consumerPeerIdMap.set(e.id,{producerId:e.producerId,peerId:e.appData.peerId,appData:e.appData}),e.on("close",this.deregisterConsumer.bind(this,e)),e.on("pause",this.pauseConsumer.bind(this,e.id)),e.on("resume",this.resumeConsumer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareConsumers.add(e.id)})}pauseConsumer(e){this.pausedConsumerMap.set(e,{lastReportCalculated:!1})}resumeConsumer(e){this.pausedConsumerMap.delete(e)}generateProducerStreamMap(e,r=!1){return u(this,null,function*(){const i=yield e.getStats(),s=r?this.getProducerStatsFromReport(this.parseRTCReport(i,["outbound-rtp","remote-inbound-rtp"],!1,e.id))[0]:void 0;for(const n of i.values())switch(n.type){case"outbound-rtp":{this.outboundProducerMap.set(n.id,e.id);break}}return s})}generateConsumerStreamMap(e,r=!1){return u(this,null,function*(){const i=yield e.getStats(),s=r?this.getConsumerStatsFromReport(this.parseRTCReport(i,["inbound-rtp"],!1,e.id))[0]:void 0;for(const n of i.values())switch(n.type){case"inbound-rtp":{this.inboundConsumerMap.set(n.id,e.id);break}}return s})}deregisterProducer(e){this.outboundProducerMap.forEach((r,i)=>{r===e.id&&this.outboundProducerMap.delete(i)}),this.pausedProducerMap.delete(e.id),this.screenShareProducers.delete(e.id)}deregisterConsumer(e){this.inboundConsumerMap.forEach((r,i)=>{r===e.id&&this.inboundConsumerMap.delete(i)}),this.consumerPeerIdMap.delete(e.id),this.pausedConsumerMap.delete(e.id),this.screenShareConsumers.delete(e.id)}getIceCandidateStats(e){var r;return{id:e.id,type:e.candidateType||e.type,address:e.address,port:e.port,url:e.url,protocol:(r=e.relayProtocol)!=null?r:e.protocol,networkType:e.networkType,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort}}getWorkingSimulcastVideoStats(e){return e.find(r=>{const i=r.framesEncoded>0,s=r.packetsSent>0,n=r.frameWidth&&r.frameHeight;return i&&s&&!!n})||e[e.length-1]}parseRTCReport(e,r=[],i=!1,s=void 0,n=void 0){var o,c,d,l,h,p,v,T,E,C,b,P,j;const W=e,w=new Jf,te=r.length?new Set(r):void 0,re=[],ae=[],Me=[],Xe=new Map,jt=new Map;for(const A of W.values()){if(te){if(te.size===0)break;if(te.has(A.type))i&&te.delete(A.type);else continue}switch(A.type){case"local-candidate":{re.push(this.getIceCandidateStats(A));break}case"remote-candidate":{ae.push(this.getIceCandidateStats(A));break}case"candidate-pair":{const{nominated:S}=A,{selected:_}=A,B=A,oe={nominated:S!=null?S:_,currentRoundTripTime:B.currentRoundTripTime,totalRoundTripTime:B.totalRoundTripTime,bytesReceived:B.bytesReceived,bytesSent:B.bytesSent,availableOutgoingBitrate:B.availableOutgoingBitrate,availableIncomingBitrate:B.availableIncomingBitrate,lastPacketReceivedTimestamp:B.lastPacketReceivedTimestamp,lastPacketSentTimestamp:B.lastPacketSentTimestamp,localCandidateId:B.localCandidateId,remoteCandidateId:B.remoteCandidateId,bytesDiscardedOnSend:B.bytesDiscardedOnSend,packetsSent:B.packetsSent,packetsReceived:B.packetsReceived,packetsDiscardedOnSend:B.packetsDiscardedOnSend};Me.push(oe),(A.nominated===!0||A.selected===!0)&&(w.candidatePair=oe);break}case"transport":{const S=A;n&&(n.producing&&(this.overallProducingTransportsStatsMap[n.id]||(this.overallProducingTransportsStatsMap[n.id]={totalPacketsSent:0})),n.consuming&&(this.overallConsumingTransportsStatsMap[n.id]||(this.overallConsumingTransportsStatsMap[n.id]={totalPacketsReceived:0})));const _={bytesReceived:S.bytesReceived,bytesSent:S.bytesSent,packetsSent:S.packetsSent,packetsReceived:S.packetsReceived,dtlsCipher:S.dtlsCipher,dtlsState:S.dtlsState,iceRole:S.iceRole};if(w.transport=_,n){if(n.producing){const B=this.overallProducingTransportsStatsMap[n.id];this.processProducingTransportStats(n.id,B,_)}if(n.consuming){const B=this.overallConsumingTransportsStatsMap[n.id];this.processConsumingTransportStats(n.id,B,_)}}break}case"remote-inbound-rtp":{const S=A,_={jitter:S.jitter,fractionLost:S.fractionLost,roundTripTime:S.roundTripTime,roundTripTimeMeasurements:S.roundTripTimeMeasurements,totalRoundTripTime:S.totalRoundTripTime,packetsLost:S.packetsLost};w.remoteInboundRtp.set(S.localId,_);break}case"outbound-rtp":{const S=A,_=s||this.outboundProducerMap.get(A.id),B=this.pausedProducerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedProducerMap.set(_,{lastReportCalculated:!0})}this.overallProducersStatsMap[_]||(this.overallProducersStatsMap[_]={totalVideoPacketsSent:0,totalAudioPacketsSent:0});const oe=this.overallProducersStatsMap[_];if(["video","audio"].includes(S.mediaType)||["video","audio"].includes(S.kind)){if(!this.outboundProducerMap.has(A.id)){w.staleProducerStreamMap=!0;break}const He=this.callStatsInstance.producers.get(_);if(((o=He==null?void 0:He.track)==null?void 0:o.readyState)==="ended")break;w.producerStreamMap.has(_)||w.producerStreamMap.set(_,{outboundVideoRtpId:[],outboundAudioRtpId:[]});const x={bytesSent:S.bytesSent,packetsSent:S.packetsSent,nackCount:S.nackCount,ssrc:S.ssrc,mid:S.mid,active:S.active,codecId:S.codecId,headerBytesSent:S.headerBytesSent||0,totalPacketSendDelay:S.totalPacketSendDelay||0};if(S.mediaType==="video"||S.kind==="video"){const R=S,ce=V({frameHeight:R.frameHeight,frameWidth:R.frameWidth,framesEncoded:R.framesEncoded,framesDropped:R.framesDropped,framesPerSecond:R.framesPerSecond,framesSent:R.framesSent,keyFramesEncoded:R.keyFramesEncoded,firCount:R.firCount,encoderImplementation:R.encoderImplementation,hugeFramesSent:R.hugeFramesSent,pliCount:R.pliCount,qpSum:R.qpSum,qualityLimitationDurations:R.qualityLimitationDurations,qualityLimitationReason:R.qualityLimitationReason,qualityLimitationResolutionChanges:R.qualityLimitationResolutionChanges,totalEncodeTime:R.targetBitrate,totalPacketSendDelay:R.totalPacketSendDelay,retransmittedBytesSent:R.retransmittedBytesSent,retransmittedPacketsSent:R.retransmittedPacketsSent,scalabilityMode:R.scalabilityMode,powerEfficientEncoder:R.powerEfficientEncoder},x);w.outboundVideoRtp.set(A.id,ce),w.producerStreamMap.get(_).outboundVideoRtpId.push(A.id),this.processOutboundProducerVideoStats(_,oe,ce)}else if(S.mediaType==="audio"||S.kind==="audio"){const R=S,ce=V({retransmittedBytesSent:R.retransmittedBytesSent,retransmittedPacketsSent:R.retransmittedPacketsSent},x);w.outboundAudioRtp.set(A.id,ce),w.producerStreamMap.get(_).outboundAudioRtpId.push(A.id),this.processOutboundProducerAudioStats(_,oe,ce)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Outbound-rtp. mediatype: ${S.mediaType} kind: ${S.kind}`);break}case"inbound-rtp":{const S=A,_=s||this.inboundConsumerMap.get(A.id),B=this.pausedConsumerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedConsumerMap.set(_,{lastReportCalculated:!0})}if(S.ssrc===1234)break;this.overallConsumersStatsMap[_]||(this.overallConsumersStatsMap[_]={totalVideoPacketsReceived:0,totalAudioPacketsReceived:0});const oe=this.overallConsumersStatsMap[_];if(["video","audio"].includes(S.mediaType)||["video","audio"].includes(S.kind)){if(!this.inboundConsumerMap.has(A.id)){w.staleConsumerStreamMap=!0;break}w.consumerStreamMap.has(_)||w.consumerStreamMap.set(_,{inboundVideoRtpId:[],inboundAudioRtpId:[]});const He={bytesReceived:S.bytesReceived,packetsReceived:S.packetsReceived,packetsLost:S.packetsLost>=0?S.packetsLost:0,jitter:S.jitter,nackCount:S.nackCount,jitterBufferDelay:S.jitterBufferDelay,jitterBufferEmittedCount:S.jitterBufferEmittedCount,lastPacketReceivedTimestamp:S.lastPacketReceivedTimestamp,ssrc:S.ssrc,mid:S.mid,codecId:S.codecId,headerBytesReceived:S.headerBytesReceived||0,packetsDiscarded:S.packetsDiscarded||0,jitterBufferMinimumDelay:S.jitterBufferMinimumDelay||0,jitterBufferTargetDelay:S.jitterBufferTargetDelay||0};if(S.mediaType==="video"||S.kind==="video"){const x=S,R=V({frameHeight:x.frameHeight,frameWidth:x.frameWidth,framesDecoded:x.framesDecoded,framesDropped:x.framesDropped,framesPerSecond:x.framesPerSecond,framesReceived:x.framesReceived,keyFramesDecoded:x.keyFramesDecoded,firCount:x.firCount,decoderImplementation:x.decoderImplementation,pliCount:x.pliCount,totalProcessingDelay:x.totalProcessingDelay,qpSum:x.qpSum||0,totalAssemblyTime:x.totalAssemblyTime||0,totalDecodeTime:x.totalDecodeTime||0,totalFreezesDuration:x.totalFreezesDuration||0,totalInterFrameDelay:x.totalInterFrameDelay||0,totalPausesDuration:x.totalPausesDuration||0,totalSquaredInterFrameDelay:x.totalSquaredInterFrameDelay||0,freezeCount:x.freezeCount||0,pauseCount:x.pauseCount||0,powerEfficientDecoder:x.powerEfficientDecoder},He);R.score=Gf({frameWidth:R.frameWidth||0,framesDecoded:(R.framesDecoded||0)-(((c=this.videoConsumerToStatsMap.get(_))==null?void 0:c.framesDecoded)||0),framesPerSecond:R.framesPerSecond||0,packetsLost:(R.packetsLost||0)-(((d=this.videoConsumerToStatsMap.get(_))==null?void 0:d.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((l=this.videoConsumerToStatsMap.get(_))==null?void 0:l.packetsReceived)||0),jitter:R.jitter||0,isScreenShare:this.screenShareConsumers.has(_)}),jt.set(_,{score:+(R.score*10).toFixed(),frameWidth:R.frameWidth||0,frameHeight:R.frameHeight||0,framesPerSecond:R.framesPerSecond||0,packetsLostPercentage:qd({packetsLost:(R.packetsLost||0)-(((h=this.videoConsumerToStatsMap.get(_))==null?void 0:h.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((p=this.videoConsumerToStatsMap.get(_))==null?void 0:p.packetsReceived)||0)}),jitter:R.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((R.bytesReceived||0)-(((v=this.videoConsumerToStatsMap.get(_))==null?void 0:v.bytesReceived)||0))*8/7}),this.videoConsumerToStatsMap.set(_,R),w.inboundVideoRtp.set(A.id,R),w.consumerStreamMap.get(_).inboundVideoRtpId.push(A.id),this.processInboundConsumerVideoStats(_,oe,R)}else if(S.mediaType==="audio"||S.kind==="audio"){const x=S,R=V({audioLevel:x.audioLevel,concealedSamples:x.concealedSamples,concealmentEvents:x.concealmentEvents,totalAudioEnergy:x.totalAudioEnergy,totalSamplesDuration:x.totalSamplesDuration,totalSamplesReceived:x.totalSamplesReceived,fecPacketsDiscarded:x.fecPacketsDiscarded||0,fecPacketsReceived:x.fecPacketsReceived||0,insertedSamplesForDeceleration:x.insertedSamplesForDeceleration||0,removedSamplesForAcceleration:x.removedSamplesForAcceleration||0,silentConcealedSamples:x.silentConcealedSamples||0,playoutId:x.playoutId},He);R.score=qf({concealmentEvents:(R.concealmentEvents||0)-(((T=this.audioConsumerToStatsMap.get(_))==null?void 0:T.concealmentEvents)||0),packetsLost:(R.packetsLost||0)-(((E=this.audioConsumerToStatsMap.get(_))==null?void 0:E.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((C=this.audioConsumerToStatsMap.get(_))==null?void 0:C.packetsReceived)||0),jitter:R.jitter||0}),jt.set(_,{score:+(R.score*10).toFixed(),packetsLostPercentage:qd({packetsLost:(R.packetsLost||0)-(((b=this.audioConsumerToStatsMap.get(_))==null?void 0:b.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((P=this.audioConsumerToStatsMap.get(_))==null?void 0:P.packetsReceived)||0)}),jitter:R.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((R.bytesReceived||0)-(((j=this.audioConsumerToStatsMap.get(_))==null?void 0:j.bytesReceived)||0))*8/7}),this.audioConsumerToStatsMap.set(_,R),w.inboundAudioRtp.set(A.id,R),w.consumerStreamMap.get(_).inboundAudioRtpId.push(A.id),this.processInboundConsumerAudioStats(_,oe,R)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Inbound-rtp. mediatype: ${S.mediaType} kind: ${S.kind}`);break}}}if(w.producerStreamMap.forEach((A,S)=>{var _,B,oe,He,x,R,ce,Qi,Xi,Gr,oa,ca,da,la,ua,ha,pa,ma,ga,fa,va,ya,Sa;if(A.outboundVideoRtpId.length>0){const ge=[];A.outboundVideoRtpId.forEach(Ul=>{ge.push(w.outboundVideoRtp.get(Ul))});const se=this.getWorkingSimulcastVideoStats(ge);se.score=jf({frameWidth:se.frameWidth||0,framesPerSecond:se.framesPerSecond||0,jitter:((_=se.remoteData)==null?void 0:_.jitter)||0,isScreenShare:this.screenShareProducers.has(S),packetsSent:(se.packetsSent||0)-(((B=this.videoProducerToStatsMap.get(S))==null?void 0:B.packetsSent)||0),packetsLost:(((oe=se.remoteData)==null?void 0:oe.packetsLost)||0)-(((x=(He=this.videoProducerToStatsMap.get(S))==null?void 0:He.remoteData)==null?void 0:x.packetsLost)||0),framesEncoded:(se.framesEncoded||0)-(((R=this.videoProducerToStatsMap.get(S))==null?void 0:R.framesEncoded)||0)}),Xe.set(S,{score:+(se.score*10).toFixed(),frameWidth:se.frameWidth||0,frameHeight:se.frameHeight||0,framesPerSecond:se.framesPerSecond||0,jitter:((ce=se.remoteData)==null?void 0:ce.jitter)||0,isScreenShare:this.screenShareProducers.has(S),packetsLostPercentage:Hd({packetsSent:(se.packetsSent||0)-(((Qi=this.videoProducerToStatsMap.get(S))==null?void 0:Qi.packetsSent)||0),packetsLost:(((Xi=se.remoteData)==null?void 0:Xi.packetsLost)||0)-(((oa=(Gr=this.videoProducerToStatsMap.get(S))==null?void 0:Gr.remoteData)==null?void 0:oa.packetsLost)||0)}),bitrate:((se.bytesSent||0)-(((ca=this.videoProducerToStatsMap.get(S))==null?void 0:ca.bytesSent)||0))*8/7,cpuLimitations:se.qualityLimitationReason==="cpu",bandwidthLimitations:se.qualityLimitationReason==="bandwidth"}),this.videoProducerToStatsMap.set(S,se)}else if(A.outboundAudioRtpId.length>0){const ge=w.outboundAudioRtp.get(A.outboundAudioRtpId[0]);ge.score=Wf({packetsSent:(ge.packetsSent||0)-(((da=this.audioProducerToStatsMap.get(S))==null?void 0:da.packetsSent)||0),packetsLost:(((la=ge.remoteData)==null?void 0:la.packetsLost)||0)-(((ha=(ua=this.audioProducerToStatsMap.get(S))==null?void 0:ua.remoteData)==null?void 0:ha.packetsLost)||0),jitter:((pa=ge.remoteData)==null?void 0:pa.jitter)||0}),Xe.set(S,{score:+(ge.score*10).toFixed(),bitrate:((ge.bytesSent||0)-(((ma=this.audioProducerToStatsMap.get(S))==null?void 0:ma.bytesSent)||0))*8/7,packetsLostPercentage:Hd({packetsSent:(ge.packetsSent||0)-(((ga=this.audioProducerToStatsMap.get(S))==null?void 0:ga.packetsSent)||0),packetsLost:(((fa=ge.remoteData)==null?void 0:fa.packetsLost)||0)-(((ya=(va=this.audioProducerToStatsMap.get(S))==null?void 0:va.remoteData)==null?void 0:ya.packetsLost)||0)}),jitter:((Sa=ge.remoteData)==null?void 0:Sa.jitter)||0,isScreenShare:this.screenShareProducers.has(S)}),this.audioProducerToStatsMap.set(S,ge)}}),Me.forEach(A=>{const S=re.find(B=>B.id===A.localCandidateId?(A.localCandidateId=B.id,B):null),_=ae.find(B=>B.id===A.remoteCandidateId?(A.remoteCandidateId=B.id,B):null);S&&(A.localCandidateType=S.type,A.localCandidateAddress=qi(S.address),A.localCandidatePort=S.port,A.localCandidateProtocol=S.protocol,A.localCandidateUrl=S.url,A.localCandidateNetworkType=S.networkType,A.localCandidateRelatedAddress=qi(S.relatedAddress),A.localCandidateRelatedPort=S.relatedPort),_&&(A.remoteCandidateType=_.type,A.remoteCandidateAddress=qi(_.address),A.remoteCandidatePort=_.port,A.remoteCandidateProtocol=_.protocol,A.remoteCandidateUrl=_.url)}),w.candidatePair&&(w.transport?(w.transport.totalRoundTripTime=w.candidatePair.totalRoundTripTime,w.transport.availableOutgoingBitrate=w.candidatePair.availableOutgoingBitrate,w.transport.availableIncomingBitrate=w.candidatePair.availableIncomingBitrate,w.transport.roundTripTime=w.candidatePair.currentRoundTripTime):w.transport={bytesReceived:w.candidatePair.bytesReceived,bytesSent:w.candidatePair.bytesSent,totalRoundTripTime:w.candidatePair.totalRoundTripTime,availableOutgoingBitrate:w.candidatePair.availableOutgoingBitrate,availableIncomingBitrate:w.candidatePair.availableIncomingBitrate,roundTripTime:w.candidatePair.currentRoundTripTime}),w.transport&&(w.transport.candidatePairs=Me),w.transport&&!w.transport.roundTripTime){let A=0,S=0;w.remoteInboundRtp.forEach((_,B)=>{_.roundTripTime&&_.roundTripTime>A&&(A=_.roundTripTime,S=_.totalRoundTripTime)}),w.transport.roundTripTime=A,w.transport.totalRoundTripTime=S}if(jt.size>0)try{this.observer.emit("consumer_score",jt)}catch{}if(Xe.size>0)try{this.observer.emit("producer_score",Xe)}catch{}return w}getProducersReport(e){return u(this,null,function*(){const r=e.map(i=>this.generateProducerStreamMap(i,!0));return r.length>0?Promise.all(r):void 0})}getConsumersReport(e){return u(this,null,function*(){const r=e.map(i=>this.generateConsumerStreamMap(i,!0));return r.length>0?Promise.all(r):void 0})}getTransportReport(e){return u(this,null,function*(){return e.getStats()})}getProcessedStats(e,r,i){return u(this,null,function*(){const s=yield this.getTransportReport(e),n={producing:i,consuming:r,id:e.id},o=s,c=this.parseRTCReport(o,["transport","candidate-pair","inbound-rtp","outbound-rtp","remote-inbound-rtp","local-candidate","remote-candidate"],!1,void 0,n);if(!c)return;const d={stats:c.transport,transportId:e.id,consuming:r,producing:i},l=c.staleProducerStreamMap?void 0:this.getProducerStatsFromReport(c),h=c.staleConsumerStreamMap?void 0:this.getConsumerStatsFromReport(c);return{transportReport:d,producerReport:l,consumerReport:h}})}getProducerStatsFromReport(e){const r=[];try{e.producerStreamMap.forEach((i,s)=>{var n,o;r.push({producerId:s,videoStats:i.outboundVideoRtpId.map(c=>e.outboundVideoRtp.get(c)),audioStats:i.outboundAudioRtpId.map(c=>e.outboundAudioRtp.get(c)),appData:((o=(n=this.callStatsInstance.producers)==null?void 0:n.get(s))==null?void 0:o.appData)||null})})}catch(i){this.callStatsInstance.logger.error("callStats::measurements::getProducerStatsFromReport",{error:{reason:i.reason,message:i.message}})}return r}getConsumerStatsFromReport(e){const r=[];try{e.consumerStreamMap.forEach((i,s)=>{const{peerId:n,producerId:o,appData:c}=this.consumerPeerIdMap.get(s);r.push({consumerId:s,peerId:n,producerId:o,appData:c,videoStats:i.inboundVideoRtpId.map(d=>e.inboundVideoRtp.get(d)),audioStats:i.inboundAudioRtpId.map(d=>e.inboundAudioRtp.get(d))})})}catch(i){console.error("getConsumersReport: ",i,e)}return r}getUserLocation(){return u(this,null,function*(){return new Promise((e,r)=>{try{navigator.geolocation?navigator.geolocation.getCurrentPosition(i=>{e(i)}):r()}catch(i){r(i)}})})}getConnectivity(e){return u(this,null,function*(){try{const r={iceServers:e||$p},i=new Promise((l,h)=>{try{const p=new FT(r);p.addListener("done",l),p.addListener("failed",()=>{l({connectivity:!1})}),p.start(2e3)}catch(p){h(p)}}),s=new Promise((l,h)=>{try{const p=new BT(r);p.addListener("done",l),p.addListener("failed",()=>{l({connectivity:!1})}),p.start(2e3)}catch(p){h(p)}}),n=new Promise((l,h)=>{try{const p=new WT(r);p.addListener("done",l),p.addListener("failed",()=>{l({connectivity:!1})}),p.start(2e3)}catch(p){h(p)}}),[o,c,d]=yield Promise.all([i,s,n]);return{host:o==null?void 0:o.connectivity,relay:c==null?void 0:c.connectivity,reflexive:d==null?void 0:d.connectivity}}catch{return{host:!1,relay:!1,reflexive:!1}}})}getThroughput(e){return u(this,null,function*(){try{const r=yield new Promise((i,s)=>{try{const n={iceServers:e||$p},o=new UT(n);o.addListener("done",i),o.addListener("failed",s),o.start(1e4)}catch(n){s(n)}});return{throughput:r.throughput,fractionalLoss:0,RTT:r.RTT,jitter:0,backendRTT:r.backendRTT}}catch{return}})}getIPDetails(){return u(this,null,function*(){var e,r;try{return this.ipDetails||(this.ipDetails=yield ep.getIPDetails({peerId:(e=this.callStatsInstance)==null?void 0:e.peerId,apiHostnames:(r=this.callStatsInstance)==null?void 0:r.apiHostnames,logger:this.callStatsInstance.logger})),this.ipDetails}catch{return}})}getNetworkQuality(e){return u(this,null,function*(){const[r,i]=yield Promise.all([this.getConnectivity(e),this.getThroughput(e)]);return{connectivity:r,throughput:i==null?void 0:i.throughput,fractionalLoss:i==null?void 0:i.fractionalLoss,RTT:i==null?void 0:i.RTT,jitter:i==null?void 0:i.jitter,backendRTT:i==null?void 0:i.backendRTT}})}getNetworkInfo(e,r=!1){return u(this,null,function*(){var i,s;if(r){const d=yield this.getIPDetails();return{ipDetails:d,effectiveNetworkType:(i=navigator.connection)==null?void 0:i.effectiveType,location:d!=null&&d.loc?Jp(d==null?void 0:d.loc):void 0}}const[n,o,c]=yield Promise.all([this.getConnectivity(e),this.getThroughput(e),this.getIPDetails()]);return{ipDetails:c,effectiveNetworkType:(s=navigator.connection)==null?void 0:s.effectiveType,location:c!=null&&c.loc?Jp(c==null?void 0:c.loc):void 0,turnConnectivity:n?n.host||n.relay||n.reflexive:!1,connectivity:n,throughput:o==null?void 0:o.throughput,fractionalLoss:o==null?void 0:o.fractionalLoss,RTT:o==null?void 0:o.RTT,jitter:o==null?void 0:o.jitter,backendRTT:o==null?void 0:o.backendRTT}})}}class HT extends Kf{}class zf extends Kf{constructor(){super(...arguments),m(this,"producerMap",new Map),m(this,"consumerMap",new Map)}registerProducer(e){return u(this,null,function*(){this.producerMap.set(e.id,e),yield this.generateProducerStreamMap(e),e.on("close",this.deregisterProducer.bind(this,e)),e.on("pause",this.pauseProducer.bind(this,e.id)),e.on("resume",this.resumeProducer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareProducers.add(e.id)})}registerConsumer(e){return u(this,null,function*(){this.consumerMap.set(e.id,e),yield this.generateConsumerStreamMap(e),this.consumerPeerIdMap.set(e.id,{producerId:e.producerId,peerId:e.appData.peerId,appData:e.appData}),e.on("close",this.deregisterConsumer.bind(this,e)),e.on("pause",this.pauseConsumer.bind(this,e.id)),e.on("resume",this.resumeConsumer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareConsumers.add(e.id)})}generateConsumerStreamMap(e,r=!1){return u(this,null,function*(){const i=yield e.getStats(),s=this.parseRTCReport(i,["inbound-rtp"],!1,e.id),n=[...s.consumerStreamMap.values()][0],o=r?this.getConsumerStatsFromParsedConsumerStats(s,n,e.id):void 0;for(const c of i.values())switch(c.type){case"inbound-rtp":{this.inboundConsumerMap.set(c.id,e.id);break}}return o})}deregisterProducer(e){this.producerMap.delete(e.id),this.outboundProducerMap.forEach((r,i)=>{r===e.id&&this.outboundProducerMap.delete(i)}),this.pausedProducerMap.delete(e.id),this.screenShareProducers.delete(e.id)}deregisterConsumer(e){this.consumerMap.delete(e.id),this.inboundConsumerMap.forEach((r,i)=>{r===e.id&&this.inboundConsumerMap.delete(i)}),this.consumerPeerIdMap.delete(e.id),this.pausedConsumerMap.delete(e.id),this.screenShareConsumers.delete(e.id)}getIceCandidateStats(e){var r;return{id:e.id,type:e.candidateType||e.type,address:e.address,port:e.port,url:e.url,protocol:(r=e.relayProtocol)!=null?r:e.protocol,networkType:e.networkType,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort}}parseRTCReport(e,r=[],i=!1,s=void 0,n=void 0){var o,c,d,l,h,p,v,T,E,C,b,P,j;const W=e,w=new Jf,te=r.length?new Set(r):void 0,re=[],ae=[],Me=[],Xe=new Map,jt=new Map;for(const A of W.values()){if(te){if(te.size===0)break;if(te.has(A.type))i&&te.delete(A.type);else continue}switch(A.type){case"local-candidate":{re.push(this.getIceCandidateStats(A));break}case"remote-candidate":{ae.push(this.getIceCandidateStats(A));break}case"candidate-pair":{const{nominated:S}=A,{selected:_}=A,B=A,oe={nominated:S!=null?S:_,currentRoundTripTime:B.currentRoundTripTime,totalRoundTripTime:B.totalRoundTripTime,bytesReceived:B.bytesReceived,bytesSent:B.bytesSent,availableOutgoingBitrate:B.availableOutgoingBitrate,availableIncomingBitrate:B.availableIncomingBitrate,lastPacketReceivedTimestamp:B.lastPacketReceivedTimestamp,lastPacketSentTimestamp:B.lastPacketSentTimestamp,localCandidateId:B.localCandidateId,remoteCandidateId:B.remoteCandidateId,bytesDiscardedOnSend:B.bytesDiscardedOnSend,packetsSent:B.packetsSent,packetsReceived:B.packetsReceived,packetsDiscardedOnSend:B.packetsDiscardedOnSend};Me.push(oe),(A.nominated===!0||A.selected===!0)&&(w.candidatePair=oe);break}case"transport":{const S=A;n&&(n.producing&&(this.overallProducingTransportsStatsMap[n.id]||(this.overallProducingTransportsStatsMap[n.id]={totalPacketsSent:0})),n.consuming&&(this.overallConsumingTransportsStatsMap[n.id]||(this.overallConsumingTransportsStatsMap[n.id]={totalPacketsReceived:0})));const _={bytesReceived:S.bytesReceived,bytesSent:S.bytesSent,packetsSent:S.packetsSent,packetsReceived:S.packetsReceived,dtlsCipher:S.dtlsCipher,dtlsState:S.dtlsState,iceRole:S.iceRole};if(w.transport=_,n){if(n.producing){const B=this.overallProducingTransportsStatsMap[n.id];this.processProducingTransportStats(n.id,B,_)}if(n.consuming){const B=this.overallConsumingTransportsStatsMap[n.id];this.processConsumingTransportStats(n.id,B,_)}}break}case"remote-inbound-rtp":{const S=A,_={jitter:S.jitter,fractionLost:S.fractionLost,roundTripTime:S.roundTripTime,roundTripTimeMeasurements:S.roundTripTimeMeasurements,totalRoundTripTime:S.totalRoundTripTime,packetsLost:S.packetsLost};w.remoteInboundRtp.set(S.localId,_);break}case"outbound-rtp":{const S=A,_=s||this.outboundProducerMap.get(A.id),B=this.pausedProducerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedProducerMap.set(_,{lastReportCalculated:!0})}this.overallProducersStatsMap[_]||(this.overallProducersStatsMap[_]={totalVideoPacketsSent:0,totalAudioPacketsSent:0});const oe=this.overallProducersStatsMap[_];if(["video","audio"].includes(S.mediaType)||["video","audio"].includes(S.kind)){if(!this.outboundProducerMap.has(A.id)){w.staleProducerStreamMap=!0;break}const He=this.callStatsInstance.producers.get(_);if(((o=He==null?void 0:He.track)==null?void 0:o.readyState)==="ended")break;w.producerStreamMap.has(_)||w.producerStreamMap.set(_,{outboundVideoRtpId:[],outboundAudioRtpId:[]});const x={bytesSent:S.bytesSent,packetsSent:S.packetsSent,nackCount:S.nackCount,ssrc:S.ssrc,mid:S.mid,active:S.active,codecId:S.codecId,headerBytesSent:S.headerBytesSent||0,totalPacketSendDelay:S.totalPacketSendDelay||0};if(S.mediaType==="video"||S.kind==="video"){const R=S,ce=V({frameHeight:R.frameHeight,frameWidth:R.frameWidth,framesEncoded:R.framesEncoded,framesDropped:R.framesDropped?R.framesDropped:R.droppedFrames,framesPerSecond:R.framesPerSecond?R.framesPerSecond:R.framerateMean,framesSent:R.framesSent,keyFramesEncoded:R.keyFramesEncoded,firCount:R.firCount,encoderImplementation:R.encoderImplementation,hugeFramesSent:R.hugeFramesSent,pliCount:R.pliCount,qpSum:R.qpSum,qualityLimitationReason:R.qualityLimitationReason,qualityLimitationDurations:R.qualityLimitationDurations,qualityLimitationResolutionChanges:R.qualityLimitationResolutionChanges,totalEncodeTime:R.totalEncodeTime,totalPacketSendDelay:R.totalEncodeTime,retransmittedBytesSent:R.retransmittedBytesSent,retransmittedPacketsSent:R.retransmittedPacketsSent,scalabilityMode:R.scalabilityMode,powerEfficientEncoder:R.powerEfficientEncoder},x);w.outboundVideoRtp.set(A.id,ce),w.producerStreamMap.get(_).outboundVideoRtpId.push(A.id),this.processOutboundProducerVideoStats(_,oe,ce)}else if(S.mediaType==="audio"||S.kind==="audio"){const R=S,ce=V({retransmittedBytesSent:R.retransmittedBytesSent,retransmittedPacketsSent:R.retransmittedPacketsSent},x);w.outboundAudioRtp.set(A.id,ce),w.producerStreamMap.get(_).outboundAudioRtpId.push(A.id),this.processOutboundProducerAudioStats(_,oe,ce)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Outbound-rtp. mediatype: ${S.mediaType} kind: ${S.kind}`);break}case"inbound-rtp":{const S=A,_=s||this.inboundConsumerMap.get(A.id),B=this.pausedConsumerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedConsumerMap.set(_,{lastReportCalculated:!0})}if(S.ssrc===1234)break;this.overallConsumersStatsMap[_]||(this.overallConsumersStatsMap[_]={totalVideoPacketsReceived:0,totalAudioPacketsReceived:0});const oe=this.overallConsumersStatsMap[_];if(["video","audio"].includes(S.mediaType)||["video","audio"].includes(S.kind)){if(!this.inboundConsumerMap.has(A.id)){w.staleConsumerStreamMap=!0;break}w.consumerStreamMap.has(_)||w.consumerStreamMap.set(_,{inboundVideoRtpId:[],inboundAudioRtpId:[]});const He={bytesReceived:S.bytesReceived,packetsReceived:S.packetsReceived,packetsLost:S.packetsLost>=0?S.packetsLost:0,jitter:S.jitter,nackCount:S.nackCount,jitterBufferDelay:S.jitterBufferDelay,jitterBufferEmittedCount:S.jitterBufferEmittedCount,lastPacketReceivedTimestamp:S.lastPacketReceivedTimestamp,ssrc:S.ssrc,mid:S.mid,codecId:S.codecId,headerBytesReceived:S.headerBytesReceived||0,packetsDiscarded:S.packetsDiscarded||0,jitterBufferMinimumDelay:S.jitterBufferMinimumDelay||0,jitterBufferTargetDelay:S.jitterBufferTargetDelay||0};if(S.mediaType==="video"||S.kind==="video"){const x=S,R=V({frameHeight:x.frameHeight,frameWidth:x.frameWidth,framesDecoded:x.framesDecoded,framesDropped:x.framesDropped?x.framesDropped:x.droppedFrames,framesPerSecond:x.framesPerSecond?x.framesPerSecond:x.framerateMean,framesReceived:x.framesReceived,keyFramesDecoded:x.keyFramesDecoded,firCount:x.firCount,decoderImplementation:x.decoderImplementation,pliCount:x.pliCount,totalProcessingDelay:x.totalProcessingDelay,qpSum:x.qpSum||0,totalAssemblyTime:x.totalAssemblyTime||0,totalDecodeTime:x.totalDecodeTime||0,totalFreezesDuration:x.totalFreezesDuration||0,totalInterFrameDelay:x.totalInterFrameDelay||0,totalPausesDuration:x.totalPausesDuration||0,totalSquaredInterFrameDelay:x.totalSquaredInterFrameDelay||0,freezeCount:x.freezeCount||0,pauseCount:x.pauseCount||0,powerEfficientDecoder:x.powerEfficientDecoder},He);R.score=Gf({frameWidth:R.frameWidth||0,framesDecoded:(R.framesDecoded||0)-(((c=this.videoConsumerToStatsMap.get(_))==null?void 0:c.framesDecoded)||0),framesPerSecond:R.framesPerSecond||0,packetsLost:(R.packetsLost||0)-(((d=this.videoConsumerToStatsMap.get(_))==null?void 0:d.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((l=this.videoConsumerToStatsMap.get(_))==null?void 0:l.packetsReceived)||0),jitter:R.jitter||0,isScreenShare:this.screenShareConsumers.has(_)}),jt.set(_,{score:+(R.score*10).toFixed(),frameWidth:R.frameWidth||0,frameHeight:R.frameHeight||0,framesPerSecond:R.framesPerSecond||0,packetsLostPercentage:qd({packetsLost:(R.packetsLost||0)-(((h=this.videoConsumerToStatsMap.get(_))==null?void 0:h.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((p=this.videoConsumerToStatsMap.get(_))==null?void 0:p.packetsReceived)||0)}),jitter:R.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((R.bytesReceived||0)-(((v=this.videoConsumerToStatsMap.get(_))==null?void 0:v.bytesReceived)||0))*8/7}),this.videoConsumerToStatsMap.set(_,R),w.inboundVideoRtp.set(A.id,R),w.consumerStreamMap.get(_).inboundVideoRtpId.push(A.id),this.processInboundConsumerVideoStats(_,oe,R)}else if(S.mediaType==="audio"||S.kind==="audio"){const x=S,R=V({audioLevel:x.audioLevel,concealedSamples:x.concealedSamples,concealmentEvents:x.concealmentEvents,totalAudioEnergy:x.totalAudioEnergy,totalSamplesDuration:x.totalSamplesDuration,totalSamplesReceived:x.totalSamplesReceived,fecPacketsDiscarded:x.fecPacketsDiscarded||0,fecPacketsReceived:x.fecPacketsReceived||0,insertedSamplesForDeceleration:x.insertedSamplesForDeceleration||0,removedSamplesForAcceleration:x.removedSamplesForAcceleration||0,silentConcealedSamples:x.silentConcealedSamples||0,playoutId:x.playoutId},He);R.score=qf({concealmentEvents:(R.concealmentEvents||0)-(((T=this.audioConsumerToStatsMap.get(_))==null?void 0:T.concealmentEvents)||0),packetsLost:(R.packetsLost||0)-(((E=this.audioConsumerToStatsMap.get(_))==null?void 0:E.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((C=this.audioConsumerToStatsMap.get(_))==null?void 0:C.packetsReceived)||0),jitter:R.jitter||0}),jt.set(_,{score:+(R.score*10).toFixed(),packetsLostPercentage:qd({packetsLost:(R.packetsLost||0)-(((b=this.audioConsumerToStatsMap.get(_))==null?void 0:b.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((P=this.audioConsumerToStatsMap.get(_))==null?void 0:P.packetsReceived)||0)}),jitter:R.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((R.bytesReceived||0)-(((j=this.audioConsumerToStatsMap.get(_))==null?void 0:j.bytesReceived)||0))*8/7}),this.audioConsumerToStatsMap.set(_,R),w.inboundAudioRtp.set(A.id,R),w.consumerStreamMap.get(_).inboundAudioRtpId.push(A.id),this.processInboundConsumerAudioStats(_,oe,R)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Inbound-rtp. mediatype: ${S.mediaType} kind: ${S.kind}`);break}}}if(w.producerStreamMap.forEach((A,S)=>{var _,B,oe,He,x,R,ce,Qi,Xi,Gr,oa,ca,da,la,ua,ha,pa,ma,ga,fa,va,ya,Sa;if(A.outboundVideoRtpId.length>0){const ge=[];A.outboundVideoRtpId.forEach(Ul=>{ge.push(w.outboundVideoRtp.get(Ul))});const se=this.getWorkingSimulcastVideoStats(ge);se.score=jf({frameWidth:se.frameWidth||0,framesPerSecond:se.framesPerSecond||0,jitter:((_=se.remoteData)==null?void 0:_.jitter)||0,isScreenShare:this.screenShareProducers.has(S),packetsSent:(se.packetsSent||0)-(((B=this.videoProducerToStatsMap.get(S))==null?void 0:B.packetsSent)||0),packetsLost:(((oe=se.remoteData)==null?void 0:oe.packetsLost)||0)-(((x=(He=this.videoProducerToStatsMap.get(S))==null?void 0:He.remoteData)==null?void 0:x.packetsLost)||0),framesEncoded:(se.framesEncoded||0)-(((R=this.videoProducerToStatsMap.get(S))==null?void 0:R.framesEncoded)||0)}),Xe.set(S,{score:+(se.score*10).toFixed(),frameWidth:se.frameWidth||0,frameHeight:se.frameHeight||0,framesPerSecond:se.framesPerSecond||0,jitter:((ce=se.remoteData)==null?void 0:ce.jitter)||0,isScreenShare:this.screenShareProducers.has(S),packetsLostPercentage:Hd({packetsSent:(se.packetsSent||0)-(((Qi=this.videoProducerToStatsMap.get(S))==null?void 0:Qi.packetsSent)||0),packetsLost:(((Xi=se.remoteData)==null?void 0:Xi.packetsLost)||0)-(((oa=(Gr=this.videoProducerToStatsMap.get(S))==null?void 0:Gr.remoteData)==null?void 0:oa.packetsLost)||0)}),bitrate:((se.bytesSent||0)-(((ca=this.videoProducerToStatsMap.get(S))==null?void 0:ca.bytesSent)||0))*8/7,cpuLimitations:se.qualityLimitationReason==="cpu",bandwidthLimitations:se.qualityLimitationReason==="bandwidth"}),this.videoProducerToStatsMap.set(S,se)}else if(A.outboundAudioRtpId.length>0){const ge=w.outboundAudioRtp.get(A.outboundAudioRtpId[0]);ge.score=Wf({packetsSent:(ge.packetsSent||0)-(((da=this.audioProducerToStatsMap.get(S))==null?void 0:da.packetsSent)||0),packetsLost:(((la=ge.remoteData)==null?void 0:la.packetsLost)||0)-(((ha=(ua=this.audioProducerToStatsMap.get(S))==null?void 0:ua.remoteData)==null?void 0:ha.packetsLost)||0),jitter:((pa=ge.remoteData)==null?void 0:pa.jitter)||0}),Xe.set(S,{score:+(ge.score*10).toFixed(),bitrate:((ge.bytesSent||0)-(((ma=this.audioProducerToStatsMap.get(S))==null?void 0:ma.bytesSent)||0))*8/7,packetsLostPercentage:Hd({packetsSent:(ge.packetsSent||0)-(((ga=this.audioProducerToStatsMap.get(S))==null?void 0:ga.packetsSent)||0),packetsLost:(((fa=ge.remoteData)==null?void 0:fa.packetsLost)||0)-(((ya=(va=this.audioProducerToStatsMap.get(S))==null?void 0:va.remoteData)==null?void 0:ya.packetsLost)||0)}),jitter:((Sa=ge.remoteData)==null?void 0:Sa.jitter)||0,isScreenShare:this.screenShareProducers.has(S)}),this.audioProducerToStatsMap.set(S,ge)}}),Me.forEach(A=>{const S=re.find(B=>B.id===A.localCandidateId?(A.localCandidateId=B.id,B):null),_=ae.find(B=>B.id===A.remoteCandidateId?(A.remoteCandidateId=B.id,B):null);S&&(A.localCandidateType=S.type,A.localCandidateAddress=qi(S.address),A.localCandidatePort=S.port,A.localCandidateProtocol=S.protocol,A.localCandidateUrl=S.url,A.localCandidateNetworkType=S.networkType,A.localCandidateRelatedAddress=qi(S.relatedAddress),A.localCandidateRelatedPort=S.relatedPort),_&&(A.remoteCandidateType=_.type,A.remoteCandidateAddress=qi(_.address),A.remoteCandidatePort=_.port,A.remoteCandidateProtocol=_.protocol,A.remoteCandidateUrl=_.url)}),w.candidatePair&&(w.transport?(w.transport.bytesReceived=w.candidatePair.bytesReceived,w.transport.bytesSent=w.candidatePair.bytesSent,w.transport.totalRoundTripTime=w.candidatePair.totalRoundTripTime,w.transport.availableOutgoingBitrate=w.candidatePair.availableOutgoingBitrate,w.transport.availableIncomingBitrate=w.candidatePair.availableIncomingBitrate,w.transport.roundTripTime=w.candidatePair.currentRoundTripTime):w.transport={bytesReceived:w.candidatePair.bytesReceived,bytesSent:w.candidatePair.bytesSent,totalRoundTripTime:w.candidatePair.totalRoundTripTime,availableOutgoingBitrate:w.candidatePair.availableOutgoingBitrate,availableIncomingBitrate:w.candidatePair.availableIncomingBitrate,roundTripTime:w.candidatePair.currentRoundTripTime}),w.transport&&(w.transport.candidatePairs=Me),w.transport&&!w.transport.roundTripTime){let A=0,S=0;w.remoteInboundRtp.forEach((_,B)=>{_.roundTripTime&&_.roundTripTime>A&&(A=_.roundTripTime,S=_.totalRoundTripTime)}),w.transport.roundTripTime=A,w.transport.totalRoundTripTime=S}if(jt.size>0)try{this.observer.emit("consumer_score",jt)}catch{}if(Xe.size>0)try{this.observer.emit("producer_score",Xe)}catch{}return w}getProducerStatsFromReport(e){const r=[];try{e.producerStreamMap.forEach((i,s)=>{const n=this.producerMap.get(s),o=n.track.getSettings(),c=i.outboundVideoRtpId.map(l=>{const h=e.outboundVideoRtp.get(l);return h.frameHeight||(h.frameHeight=o.height,h.frameWidth=o.width,h.framesPerSecond=o.frameRate),h}),d={producerId:s,appData:n.appData,videoStats:c,audioStats:i.outboundAudioRtpId.map(l=>e.outboundAudioRtp.get(l))};r.push(d)})}catch(i){console.error("getProducersReport: ",i,e)}return r}getConsumerStatsFromParsedConsumerStats(e,r,i){let s;try{const{peerId:n,producerId:o,appData:c}=this.consumerPeerIdMap.get(i),d=r==null?void 0:r.inboundVideoRtpId.map(l=>{const h=this.consumerMap.get(i).track.getSettings(),p=e.inboundVideoRtp.get(l);return p.frameHeight||(p.frameHeight=h.height,p.frameWidth=h.width,p.framesPerSecond=h.frameRate),p});s={consumerId:i,peerId:n,producerId:o,appData:c,videoStats:d,audioStats:r==null?void 0:r.inboundAudioRtpId.map(l=>e.inboundAudioRtp.get(l))}}catch(n){console.error("getConsumerStatsFromParsedConsumerStats: ",n,e)}return s}getConsumerStatsFromReport(e){const r=[];try{e.consumerStreamMap.forEach((i,s)=>{r.push(this.getConsumerStatsFromParsedConsumerStats(e,i,s))})}catch(i){console.error("getConsumerStatsFromReport: ",i,e)}return r}}class qT extends zf{}function Gd(t,e,r,i){if(t!=null&&t.logger&&t.logger.error("Callstats::handleError",{error:i}),typeof r=="function"&&i instanceof e)r.call(null,i,t);else throw i}function Kp(t,e,r){const i=t.value;return t.value=function(...s){try{const n=i.apply(this,s);return n&&n instanceof Promise?n.catch(o=>{Gd(this,e,r,o)}):n}catch(n){Gd(this,e,r,n)}return null},t}const Z=(t,e)=>(r,i,s)=>{const n=s.value;return s.value=function(...o){try{const c=n.apply(this,o);return c&&c instanceof Promise?c.catch(d=>{Gd(this,t,e,d)}):c}catch(c){Gd(this,t,e,c)}return null},s},GT=(t,e)=>(r,i,s)=>{if(s)return Kp(s,t,e);for(const n of Reflect.ownKeys(r.prototype).filter(o=>o!=="constructor")){const o=Object.getOwnPropertyDescriptor(r.prototype,n);o.value instanceof Function&&Object.defineProperty(r.prototype,n,Kp(o,t,e))}};var Y=globalThis&&globalThis.__decorate||function(t,e,r,i){var s=arguments.length,n=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,r,i);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(n=(s<3?o(n):s>3?o(e,r,n):o(e,r))||n);return s>3&&n&&Object.defineProperty(e,r,n),n};const Q=console;let K=class extends gt{constructor(t="https://api.testingv3.dyte.in",e="Blink",r=Do.PROD,i,s,n,o){switch(super(),m(this,"observer"),m(this,"eventHandler"),m(this,"measurements"),m(this,"producingTransport"),m(this,"consumingTransport"),m(this,"producers",new Map),m(this,"consumers",new Map),m(this,"iceServers"),m(this,"connectionInfoPromise"),m(this,"pingStatsTimeout"),m(this,"logger"),m(this,"env"),m(this,"apiHostnames"),m(this,"peerId"),m(this,"consumerSharedMediaStatesMap",new Map),m(this,"currentUserMediaStates",{}),this.env=r,this.apiHostnames=o,this.logger=s,this.peerId=n,this.eventHandler=new RT({logger:s,peerId:n,apiHostnames:o}),this.logger.debug("callStats::engineName: ",{engineName:e}),e){case"Blink":this.measurements=new HT;break;case"Gecko":this.measurements=new zf;break;case"WebKit":this.measurements=new qT;break;default:throw Error(`Unknown engineName! ${e}`)}this.measurements.callStatsInstance=this,this.registerProducer=this.registerProducer.bind(this),this.registerConsumer=this.registerConsumer.bind(this),this.observer=new gt,this.measurements.observer.on("consumer_score",c=>{s.debug(`callStats::consumer_score ${[...c.entries()]}`),this.eventHandler.emit("consumer_score",c)}),this.measurements.observer.on("producer_score",c=>{s.debug(`callStats::producer_score ${[...c.entries()]}`),this.eventHandler.emit("producer_score",c)})}registerIceServers(t){this.iceServers=t}registerConsumer(t){var e;this.consumerSharedMediaStatesMap.has(t.id)||this.consumerSharedMediaStatesMap.set(t.id,{}),this.consumers.set(t.id,t),this.measurements.registerConsumer(t),this.logger.debug("callStats::registerConsumer",{consumerId:t.id,consumerkind:t.kind,isScreenShare:!!((e=t.appData)!=null&&e.screenShare)}),t.on("close",this.deRegisterConsumer.bind(this,t))}registerProducer(t){var e;this.producers.set(t.id,t),this.measurements.registerProducer(t),this.logger.debug("callStats::registerProducer",{producerId:t.id,producerKind:t.kind,isScreenShare:!!((e=t.appData)!=null&&e.screenShare)}),t.on("close",this.deRegisterProducer.bind(this,t))}sendConsumerSharedMediaStateEvent(t,e){this.consumerSharedMediaStatesMap.has(t)||this.consumerSharedMediaStatesMap.set(t,{});const r=this.consumerSharedMediaStatesMap.get(t);this.consumerSharedMediaStatesMap.set(t,Object.assign(r,e))}registerProducingTransport(t){var e;this.producingTransport=t,t.on("close",this.disconnectProducingTransport.bind(this,t)),t.on("disconnect",this.disconnectProducingTransport.bind(this,t)),Array.from(((e=t._producers)==null?void 0:e.values())||[]).forEach(r=>{this.registerProducer(r)}),t.on("newproducer",this.registerProducer)}registerConsumingTransport(t){var e;this.consumingTransport=t,t.on("close",this.disconnectConsumingTransport.bind(this,t)),t.on("disconnect",this.disconnectConsumingTransport.bind(this,t)),Array.from(((e=t._consumers)==null?void 0:e.values())||[]).forEach(r=>{this.registerConsumer(r)}),t.on("newconsumer",this.registerConsumer)}deRegisterConsumer(t){this.consumers.delete(t.id)}deRegisterProducer(t){var e;this.producers.delete(t.id),this.logger.debug("callStats::deRegisterProducer",{producerId:t.id,producerKind:t.kind,isScreenShare:!!((e=t.appData)!=null&&e.screenShare)})}disconnectConsumingTransport(){this.consumingTransport=void 0}disconnectProducingTransport(){this.producingTransport=void 0}callEvent(t){this.eventHandler.callEvent(t)}sendPreCallTestBeginEvent(t=!1,e){this.connectionInfoPromise=this.measurements.getNetworkInfo(this.iceServers,t),this.eventHandler.callEvent({event:L.PRECALL_TEST_BEGIN,timestamp:e}),this.connectionInfoPromise&&this.connectionInfoPromise.then(r=>{this.eventHandler.callEvent({event:L.PRECALL_TEST_COMPLETE,metaData:{connectionInfo:r},timestamp:e})})}sendScreenShareToggleEvent(t,e=null,r){this.currentUserMediaStates.screen=t,this.eventHandler.callEvent({event:t?L.SCREENSHARE_STARTED:L.SCREENSHARE_STOPPED,metaData:{ssrc:e},timestamp:r})}sendScreenShareRequestedEvent(t){this.eventHandler.callEvent({event:L.SCREENSHARE_START_REQUESTED,timestamp:t})}sendActiveSpeakerEvent(t,e){this.eventHandler.callEvent({event:L.DOMINANT_SPEAKER,metaData:{peerId:t},timestamp:e})}devices(t,e,r){this.eventHandler.callEvent({event:t===or.AUDIO&&L.AUDIO_DEVICES_UPDATES||t===or.VIDEO&&L.VIDEO_DEVICES_UPDATES||t===or.SPEAKER&&L.SPEAKER_DEVICES_UPDATES,metaData:{deviceList:e},timestamp:r})}selectedDevice(t,e,r){this.eventHandler.callEvent({event:t===or.AUDIO&&L.SELECTED_MICROHPONE_UPDATE||t===or.VIDEO&&L.SELECTED_CAMERA_UPDATE||t===or.SPEAKER&&L.SELECTED_SPEAKER_UPDATE,metaData:{device:e},timestamp:r})}mediaPermission(t,e,r){this.eventHandler.callEvent({event:L.MEDIA_PERMISSION,metaData:{deviceType:t,permission:e},timestamp:r})}mediaPlaybackFailed(t,e){this.eventHandler.callEvent({event:t===or.AUDIO&&L.AUDIO_PLAY_FAILED||t===or.VIDEO&&L.VIDEO_PLAY_FAILED,metaData:{deviceType:t},timestamp:e})}mediaTrackMuted(t,e){this.eventHandler.callEvent({event:t===or.AUDIO&&L.AUDIO_TRACK_MUTED||t===or.VIDEO&&L.VIDEO_TRACK_MUTED,metaData:{deviceType:t},timestamp:e})}tabChanged(t,e){this.eventHandler.callEvent({event:L.TAB_CHANGE,metaData:{isMeetingsTabActive:t},timestamp:e})}browserBackgrounded(t){this.eventHandler.callEvent({event:L.BROWSER_BACKGROUNDED,timestamp:t})}browserForegrounded(t){this.eventHandler.callEvent({event:L.BROWSER_FOREGROUNDED,timestamp:t})}legacySwitch(t,e){this.eventHandler.callEvent({event:L.LEGACY_SWITCH,metadata:{on:t},timestamp:e})}getPreCallTestResults(){return u(this,null,function*(){return this.connectionInfoPromise})}sendCallJoinBeginEvent(t,e){t=G(V({},t),{meetingEnv:this.env}),t.deviceInfo=G(V({},t.deviceInfo),{userAgent:navigator.userAgent,cpus:navigator.hardwareConcurrency,memory:navigator.deviceMemory}),this.eventHandler.callEvent({event:L.CALL_JOIN_BEGIN,metaData:{peerMetaData:t},timestamp:e})}sendNetworkQualityTestBeginEvent(t,e){this.eventHandler.callEvent({event:L.NET_QUALITY_TEST_BEGIN,timestamp:e}),new Promise((r,i)=>u(this,null,function*(){const s=[];try{for(const n of t)try{if(n.iceServers&&n.iceServers.length>0){const o=yield this.measurements.getNetworkQuality(n.iceServers);s.push(G(V({},n),{networkResults:o}))}}catch(o){console.warn("Error handling ",o)}r({regionData:s})}catch(n){console.warn("Error in callstats, ",n),i(n)}})).then(r=>{this.eventHandler.callEvent({event:L.NET_QUALITY_TEST_END,timestamp:e,metaData:r})})}sendWebSocketConnectedEvent(t){this.eventHandler.callEvent({event:L.WEBSOCKET_CONNECTED,timestamp:t})}sendTransportConnectedEvent(t){this.eventHandler.callEvent({event:L.TRANSPORT_CONNECTED,timestamp:t})}sendAudioToggleEvent(t,e){this.currentUserMediaStates.audio=t;let r;t?r=L.AUDIO_ON:r=L.AUDIO_OFF,this.eventHandler.callEvent({event:r,timestamp:e})}sendVideoToggleEvent(t,e){this.currentUserMediaStates.video=t;let r;t?r=L.VIDEO_ON:r=L.VIDEO_OFF,this.eventHandler.callEvent({event:r,timestamp:e})}sendParticipantRoleToggleEvent(t,e){this.eventHandler.callEvent({event:L.PARTICIPANT_ROLE,timestamp:e,metaData:t})}startPingStats(t=7e3){this.sendPingStatsEvent(!1,new Date),this.pingStatsTimeout=setInterval(this.sendPingStatsEvent.bind(this),t)}stopPingStats(){clearInterval(this.pingStatsTimeout)}sendPingStatsEvent(t=!0,e){return u(this,null,function*(){let r,i;if(this.producingTransport&&(r=yield this.measurements.getProcessedStats(this.producingTransport,!1,!0),!r||!(r!=null&&r.producerReport))){this.logger.debug("callStats::sendPingStatsEvent::staleProducingTransport",{disclaimer:"Stale producer? Regenerating Stream Maps!"});const n=yield this.measurements.getProducersReport([...this.producers.values()]);r&&n?r.producerReport=n:(r=yield this.measurements.getProcessedStats(this.producingTransport,!1,!0),(!r||!(r!=null&&r.producerReport))&&this.logger.debug("callStats::sendPingStatsEvent::noProducingTransportReport",{disclaimer:"Stream maps invalid despite regenerating!"}))}if(this.consumingTransport&&(i=yield this.measurements.getProcessedStats(this.consumingTransport,!0,!1),!i||!i.consumerReport)){this.logger.debug("callStats::sendPingStatsEvent::staleConsumingTransport",{disclaimer:"Stale consumer? Regenerating Stream Maps!"});const n=yield this.measurements.getConsumersReport([...this.consumers.values()]);i&&n?i.consumerReport=n:(i=yield this.measurements.getProcessedStats(this.consumingTransport,!0,!1),(!i||!i.consumerReport)&&this.logger.debug("callStats::sendPingStatsEvent::noConsumingTransportReport",{disclaimer:"Stream maps invalid despite regenerating!"}))}const s={producingTransportStats:r?r==null?void 0:r.transportReport:void 0,consumingTransportStats:i?i==null?void 0:i.transportReport:void 0,producerStats:[].concat((r==null?void 0:r.producerReport)||[]).concat((i==null?void 0:i.producerReport)||[]),consumerStats:[].concat((i==null?void 0:i.consumerReport)||[]).concat((r==null?void 0:r.consumerReport)||[])};if(t&&s.producerStats.length===0&&s.consumerStats.length===0){yield this.eventHandler.flush();return}this.eventHandler.callEvent({event:L.PING_STAT,metaData:s,timestamp:e})})}sendIVSPlayerRebufferEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_REBUFFERING,timestamp:t})}sendIVSPlayerAudioBlockEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_AUDIO_BLOCKED,timestamp:t})}sendIVSPlayerPlaybackBlockedEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_PLAYBACK_BLOCKED,timestamp:t})}sendIVSPlayerNetworkUnavailableEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_NETWORK_UNAVAILABLE,timestamp:t})}sendIVSPlayerInitializedEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_INITIALIZED,timestamp:t})}sendIVSPlayerWorkerErrorEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_WORKER_ERROR,timestamp:t})}sendIVSPlayerErrorEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_ERROR,timestamp:e,metaData:t})}sendIVSPlayerRecoverableErrorEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_RECOVERABLE_ERROR,timestamp:e,metaData:t})}sendIVSPlayerAnalyticsEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_ANALYTICS_EVENT,timestamp:e,metaData:t})}sendIVSPlayerPlaybackRateChangedEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_PLAYBACK_RATE_CHANGED,timestamp:e,metaData:{updatedPlaybackRate:t}})}sendIVSPlayerQualityChanged(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_QUALITY_CHANGED,timestamp:e,metaData:t})}sendPlayerLiveLatency(t,e){this.eventHandler.callEvent({event:L.LIVESTREAM_LATENCY,timestamp:e,metaData:{latency:t}})}sendDisconnectEvent(t){this.eventHandler.callEvent({event:L.DISCONNECT,timestamp:t})}sendReconnectEvent(t){this.eventHandler.callEvent({event:L.RECONNECT_ATTEMPT,timestamp:t})}expectedVideoResolution(t,e,r){this.eventHandler.callEvent({event:L.EXPECTED_VIDEO_RESOLUTION,timestamp:r,metaData:{frameWidth:t,frameHeight:e}})}expectedScreenshareResolution(t,e,r){this.eventHandler.callEvent({event:L.EXPECTED_SCREENSHARE_RESOLUTION,timestamp:r,metaData:{frameWidth:t,frameHeight:e}})}};Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerIceServers",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerConsumer",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerProducer",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendConsumerSharedMediaStateEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerProducingTransport",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerConsumingTransport",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"deRegisterConsumer",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"deRegisterProducer",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"disconnectConsumingTransport",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"disconnectProducingTransport",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendPreCallTestBeginEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendScreenShareToggleEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendScreenShareRequestedEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendActiveSpeakerEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"devices",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"selectedDevice",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"mediaPermission",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"mediaPlaybackFailed",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"mediaTrackMuted",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"tabChanged",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"browserBackgrounded",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"browserForegrounded",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"legacySwitch",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"getPreCallTestResults",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendCallJoinBeginEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendNetworkQualityTestBeginEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendWebSocketConnectedEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendTransportConnectedEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendAudioToggleEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendVideoToggleEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendParticipantRoleToggleEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"startPingStats",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"stopPingStats",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendPingStatsEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerRebufferEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerAudioBlockEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerPlaybackBlockedEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerNetworkUnavailableEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerInitializedEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerWorkerErrorEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerErrorEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerRecoverableErrorEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerAnalyticsEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerPlaybackRateChangedEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerQualityChanged",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendPlayerLiveLatency",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendDisconnectEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendReconnectEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"expectedVideoResolution",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"expectedScreenshareResolution",null);K=Y([GT(TypeError,(t,e)=>Q.error(e,t))],K);const $T=K;class Yf extends gt{constructor(){super(...arguments),m(this,"stats"),m(this,"peerId"),m(this,"backend"),m(this,"iceServers"),m(this,"initialized",!1),m(this,"stalled",!1),m(this,"ipInformation"),m(this,"logger")}initialize(e){return u(this,arguments,function*({peerId:r,engineName:i,env:s=Do.PROD,iceServers:n,apiBase:o="https://api.cluster.dyte.in",flags:c,logger:d=console,apiHostnames:l,skipConnectivityChecks:h=!1}){var p,v,T;try{this.peerId=r,this.logger=d,this.ipInformation=yield ep.getIPDetails({peerId:r,apiHostnames:l,logger:d}),this.backend=new $T(o,i,s,c,d,r,l),this.iceServers=n,(p=this.backend)==null||p.registerIceServers(this.iceServers),this.initialized=!0,(T=(v=this.backend)==null?void 0:v.eventHandler)==null||T.emit("initialized",this.ipInformation),this.emit("initialized",this.ipInformation),this.startPreCallTest(h)}catch(E){this.logger.error("callStats::CallStatsIntegration: ",{error:E}),this.stallCallStats()}})}configureSendTransport(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.registerProducingTransport(e)})}configureRecvTransport(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.registerConsumingTransport(e)})}candidateRegionalNetworkQualityTest(e){return u(this,null,function*(){const r=new Date;this.onSafeInitialization(()=>{var i;try{(i=this.backend)==null||i.sendNetworkQualityTestBeginEvent(e,r)}catch(s){this.logger.error("callStats::sendNetworkQualityTestBeginEvent",{error:{reason:s.reason}})}})})}roomJoined(e){return u(this,null,function*(){const r=new Date;this.onSafeInitialization(()=>{var i,s;(i=this.backend)==null||i.sendCallJoinBeginEvent(e,r),this.backend,(s=this.backend)==null||s.startPingStats()})})}audioOff(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendAudioToggleEvent(!1,e)})}audioOn(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendAudioToggleEvent(!0,e)})}videoOff(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendVideoToggleEvent(!1,e)})}videoOn(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendVideoToggleEvent(!0,e)})}callEnded(){const e=new Date;this.onSafeInitialization(()=>{var r,i;(r=this.backend)==null||r.stopPingStats(),(i=this.backend)==null||i.sendDisconnectEvent(e)})}screenShareStart(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendScreenShareToggleEvent(!0,e,r)})}consumerSharedMediaState(e,r){this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendConsumerSharedMediaStateEvent(e,r)})}screenShareStop(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendScreenShareToggleEvent(!1,e,r)})}screenShareRequested(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendScreenShareRequestedEvent(e)})}activeSpeaker(e){if(e!==this.peerId)return;const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendActiveSpeakerEvent(e,r)})}devices(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.devices(e,r,i)})}selectedDevice(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.selectedDevice(e,r,i)})}mediaPermission(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.mediaPermission(e,r,i)})}mediaPlaybackFailed(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.mediaPlaybackFailed(e,r)})}mediaTrackMuted(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.mediaTrackMuted(e,r)})}tabChanged(e=!1){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.tabChanged(e,r)})}browserBackgrounded(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.browserBackgrounded(e)})}browserForegrounded(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.browserForegrounded(e)})}legacySwitch(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.legacySwitch(e,r)})}startPreCallTest(e=!1){return u(this,null,function*(){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendPreCallTestBeginEvent(e,r)})})}onPreCallTestResults(e){return this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.once("precall_end",e)}),e}onReceivingConsumerAudioStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consumer_audio_status",e)})}onReceivingConsumerVideoStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consumer_video_status",e)})}onReceivingProducerAudioStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producer_audio_status",e)})}onReceivingProducerVideoStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producer_video_status",e)})}onReceivingProducingTransportStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producing_transport_status",e)})}onReceivingConsumingTransportStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consuming_transport_status",e)})}onProducerScore(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producer_score",e)})}onConsumerScore(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consumer_score",e)})}onSafeInitialization(e){if(this.initialized)e(this.ipInformation,!1);else if(!this.stalled){const r=i=>{e(i,!0)};return this.once("initialized",r),r}return()=>{}}removeInitializationListener(e){this.removeListener("initialized",e)}stallCallStats(){this.stalled=!0,this.removeAllListeners("initialized")}ivsPlayerEvent(e,r){const i=new Date;this.onSafeInitialization(()=>{var s,n,o,c,d,l,h,p,v,T,E;switch(e){case"PlayerRebuffering":(s=this.backend)==null||s.sendIVSPlayerRebufferEvent(i);break;case"PlayerAudioBlocked":(n=this.backend)==null||n.sendIVSPlayerAudioBlockEvent(i);break;case"PlayerPlaybackBlocked":(o=this.backend)==null||o.sendIVSPlayerPlaybackBlockedEvent(i);break;case"PlayerNetworkUnavailable":(c=this.backend)==null||c.sendIVSPlayerNetworkUnavailableEvent(i);break;case"PlayerInitialized":(d=this.backend)==null||d.sendIVSPlayerInitializedEvent(i);break;case"PlayerWorkerError":(l=this.backend)==null||l.sendIVSPlayerWorkerErrorEvent(i);break;case"PlayerError":(h=this.backend)==null||h.sendIVSPlayerErrorEvent(r,i);break;case"PlayerRecoverableError":(p=this.backend)==null||p.sendIVSPlayerRecoverableErrorEvent(r,i);break;case"PlayerAnalyticsEvent":(v=this.backend)==null||v.sendIVSPlayerAnalyticsEvent(r,i);break;case"PlayerPlaybackRateChanged":(T=this.backend)==null||T.sendIVSPlayerPlaybackRateChangedEvent(r,i);break;case"PlayerQualityChanged":(E=this.backend)==null||E.sendIVSPlayerQualityChanged(r,i);break}})}livestreamLatency(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendPlayerLiveLatency(e,r)})}expectedVideoResolution(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.expectedVideoResolution(e,r,i)})}expectedScreenshareResolution(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.expectedScreenshareResolution(e,r,i)})}}const JT=new Yf;JT.setMaxListeners(30);function KT(){this.__data__=[],this.size=0}function Xo(t,e){return t===e||t!==t&&e!==e}function kl(t,e){for(var r=t.length;r--;)if(Xo(t[r][0],e))return r;return-1}var zT=Array.prototype,YT=zT.splice;function QT(t){var e=this.__data__,r=kl(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():YT.call(e,r,1),--this.size,!0}function XT(t){var e=this.__data__,r=kl(e,t);return r<0?void 0:e[r][1]}function ZT(t){return kl(this.__data__,t)>-1}function ek(t,e){var r=this.__data__,i=kl(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}function hi(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}hi.prototype.clear=KT;hi.prototype.delete=QT;hi.prototype.get=XT;hi.prototype.has=ZT;hi.prototype.set=ek;function tk(){this.__data__=new hi,this.size=0}function rk(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}function ik(t){return this.__data__.get(t)}function sk(t){return this.__data__.has(t)}var nk=typeof global=="object"&&global&&global.Object===Object&&global;const Qf=nk;var ak=typeof self=="object"&&self&&self.Object===Object&&self,ok=Qf||ak||Function("return this")();const Cr=ok;var ck=Cr.Symbol;const $i=ck;var Xf=Object.prototype,dk=Xf.hasOwnProperty,lk=Xf.toString,ka=$i?$i.toStringTag:void 0;function uk(t){var e=dk.call(t,ka),r=t[ka];try{t[ka]=void 0;var i=!0}catch{}var s=lk.call(t);return i&&(e?t[ka]=r:delete t[ka]),s}var hk=Object.prototype,pk=hk.toString;function mk(t){return pk.call(t)}var gk="[object Null]",fk="[object Undefined]",zp=$i?$i.toStringTag:void 0;function Us(t){return t==null?t===void 0?fk:gk:zp&&zp in Object(t)?uk(t):mk(t)}function Ir(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var vk="[object AsyncFunction]",yk="[object Function]",Sk="[object GeneratorFunction]",Tk="[object Proxy]";function tp(t){if(!Ir(t))return!1;var e=Us(t);return e==yk||e==Sk||e==vk||e==Tk}var kk=Cr["__core-js_shared__"];const Hl=kk;var Yp=function(){var t=/[^.]+$/.exec(Hl&&Hl.keys&&Hl.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Ek(t){return!!Yp&&Yp in t}var bk=Function.prototype,wk=bk.toString;function Fs(t){if(t!=null){try{return wk.call(t)}catch{}try{return t+""}catch{}}return""}var _k=/[\\^$.*+?()[\]{}|]/g,Ik=/^\[object .+?Constructor\]$/,Ck=Function.prototype,Pk=Object.prototype,Rk=Ck.toString,Mk=Pk.hasOwnProperty,Ak=RegExp("^"+Rk.call(Mk).replace(_k,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Dk(t){if(!Ir(t)||Ek(t))return!1;var e=tp(t)?Ak:Ik;return e.test(Fs(t))}function Ok(t,e){return t==null?void 0:t[e]}function Bs(t,e){var r=Ok(t,e);return Dk(r)?r:void 0}var Nk=Bs(Cr,"Map");const zo=Nk;var Vk=Bs(Object,"create");const Yo=Vk;function Lk(){this.__data__=Yo?Yo(null):{},this.size=0}function xk(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Uk="__lodash_hash_undefined__",Fk=Object.prototype,Bk=Fk.hasOwnProperty;function Wk(t){var e=this.__data__;if(Yo){var r=e[t];return r===Uk?void 0:r}return Bk.call(e,t)?e[t]:void 0}var jk=Object.prototype,Hk=jk.hasOwnProperty;function qk(t){var e=this.__data__;return Yo?e[t]!==void 0:Hk.call(e,t)}var Gk="__lodash_hash_undefined__";function $k(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Yo&&e===void 0?Gk:e,this}function Ns(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}Ns.prototype.clear=Lk;Ns.prototype.delete=xk;Ns.prototype.get=Wk;Ns.prototype.has=qk;Ns.prototype.set=$k;function Jk(){this.size=0,this.__data__={hash:new Ns,map:new(zo||hi),string:new Ns}}function Kk(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function El(t,e){var r=t.__data__;return Kk(e)?r[typeof e=="string"?"string":"hash"]:r.map}function zk(t){var e=El(this,t).delete(t);return this.size-=e?1:0,e}function Yk(t){return El(this,t).get(t)}function Qk(t){return El(this,t).has(t)}function Xk(t,e){var r=El(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}function Ws(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}Ws.prototype.clear=Jk;Ws.prototype.delete=zk;Ws.prototype.get=Yk;Ws.prototype.has=Qk;Ws.prototype.set=Xk;var Zk=200;function eE(t,e){var r=this.__data__;if(r instanceof hi){var i=r.__data__;if(!zo||i.length<Zk-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new Ws(i)}return r.set(t,e),this.size=r.size,this}function Hr(t){var e=this.__data__=new hi(t);this.size=e.size}Hr.prototype.clear=tk;Hr.prototype.delete=rk;Hr.prototype.get=ik;Hr.prototype.has=sk;Hr.prototype.set=eE;function tE(t,e){for(var r=-1,i=t==null?0:t.length;++r<i&&e(t[r],r,t)!==!1;);return t}var rE=function(){try{var t=Bs(Object,"defineProperty");return t({},"",{}),t}catch{}}();const $d=rE;function rp(t,e,r){e=="__proto__"&&$d?$d(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var iE=Object.prototype,sE=iE.hasOwnProperty;function Zf(t,e,r){var i=t[e];(!(sE.call(t,e)&&Xo(i,r))||r===void 0&&!(e in t))&&rp(t,e,r)}function Zo(t,e,r,i){var s=!r;r||(r={});for(var n=-1,o=e.length;++n<o;){var c=e[n],d=i?i(r[c],t[c],c,r,t):void 0;d===void 0&&(d=t[c]),s?rp(r,c,d):Zf(r,c,d)}return r}function nE(t,e){for(var r=-1,i=Array(t);++r<t;)i[r]=e(r);return i}function qr(t){return t!=null&&typeof t=="object"}var aE="[object Arguments]";function Qp(t){return qr(t)&&Us(t)==aE}var ev=Object.prototype,oE=ev.hasOwnProperty,cE=ev.propertyIsEnumerable,dE=Qp(function(){return arguments}())?Qp:function(t){return qr(t)&&oE.call(t,"callee")&&!cE.call(t,"callee")};const Jd=dE;var lE=Array.isArray;const Ji=lE;function uE(){return!1}var tv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Xp=tv&&typeof module=="object"&&module&&!module.nodeType&&module,hE=Xp&&Xp.exports===tv,Zp=hE?Cr.Buffer:void 0,pE=Zp?Zp.isBuffer:void 0,mE=pE||uE;const Yn=mE;var gE=9007199254740991,fE=/^(?:0|[1-9]\d*)$/;function rv(t,e){var r=typeof t;return e=e==null?gE:e,!!e&&(r=="number"||r!="symbol"&&fE.test(t))&&t>-1&&t%1==0&&t<e}var vE=9007199254740991;function iv(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=vE}var yE="[object Arguments]",SE="[object Array]",TE="[object Boolean]",kE="[object Date]",EE="[object Error]",bE="[object Function]",wE="[object Map]",_E="[object Number]",IE="[object Object]",CE="[object RegExp]",PE="[object Set]",RE="[object String]",ME="[object WeakMap]",AE="[object ArrayBuffer]",DE="[object DataView]",OE="[object Float32Array]",NE="[object Float64Array]",VE="[object Int8Array]",LE="[object Int16Array]",xE="[object Int32Array]",UE="[object Uint8Array]",FE="[object Uint8ClampedArray]",BE="[object Uint16Array]",WE="[object Uint32Array]",_e={};_e[OE]=_e[NE]=_e[VE]=_e[LE]=_e[xE]=_e[UE]=_e[FE]=_e[BE]=_e[WE]=!0;_e[yE]=_e[SE]=_e[AE]=_e[TE]=_e[DE]=_e[kE]=_e[EE]=_e[bE]=_e[wE]=_e[_E]=_e[IE]=_e[CE]=_e[PE]=_e[RE]=_e[ME]=!1;function jE(t){return qr(t)&&iv(t.length)&&!!_e[Us(t)]}function ip(t){return function(e){return t(e)}}var sv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oo=sv&&typeof module=="object"&&module&&!module.nodeType&&module,HE=Oo&&Oo.exports===sv,ql=HE&&Qf.process,qE=function(){try{var t=Oo&&Oo.require&&Oo.require("util").types;return t||ql&&ql.binding&&ql.binding("util")}catch{}}();const Qn=qE;var em=Qn&&Qn.isTypedArray,GE=em?ip(em):jE;const bl=GE;var $E=Object.prototype,JE=$E.hasOwnProperty;function nv(t,e){var r=Ji(t),i=!r&&Jd(t),s=!r&&!i&&Yn(t),n=!r&&!i&&!s&&bl(t),o=r||i||s||n,c=o?nE(t.length,String):[],d=c.length;for(var l in t)(e||JE.call(t,l))&&!(o&&(l=="length"||s&&(l=="offset"||l=="parent")||n&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||rv(l,d)))&&c.push(l);return c}var KE=Object.prototype;function wl(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||KE;return t===r}function av(t,e){return function(r){return t(e(r))}}var zE=av(Object.keys,Object);const YE=zE;var QE=Object.prototype,XE=QE.hasOwnProperty;function ov(t){if(!wl(t))return YE(t);var e=[];for(var r in Object(t))XE.call(t,r)&&r!="constructor"&&e.push(r);return e}function ec(t){return t!=null&&iv(t.length)&&!tp(t)}function sp(t){return ec(t)?nv(t):ov(t)}function ZE(t,e){return t&&Zo(e,sp(e),t)}function eb(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var tb=Object.prototype,rb=tb.hasOwnProperty;function ib(t){if(!Ir(t))return eb(t);var e=wl(t),r=[];for(var i in t)i=="constructor"&&(e||!rb.call(t,i))||r.push(i);return r}function tc(t){return ec(t)?nv(t,!0):ib(t)}function sb(t,e){return t&&Zo(e,tc(e),t)}var cv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tm=cv&&typeof module=="object"&&module&&!module.nodeType&&module,nb=tm&&tm.exports===cv,rm=nb?Cr.Buffer:void 0,im=rm?rm.allocUnsafe:void 0;function dv(t,e){if(e)return t.slice();var r=t.length,i=im?im(r):new t.constructor(r);return t.copy(i),i}function lv(t,e){var r=-1,i=t.length;for(e||(e=Array(i));++r<i;)e[r]=t[r];return e}function ab(t,e){for(var r=-1,i=t==null?0:t.length,s=0,n=[];++r<i;){var o=t[r];e(o,r,t)&&(n[s++]=o)}return n}function uv(){return[]}var ob=Object.prototype,cb=ob.propertyIsEnumerable,sm=Object.getOwnPropertySymbols,db=sm?function(t){return t==null?[]:(t=Object(t),ab(sm(t),function(e){return cb.call(t,e)}))}:uv;const np=db;function lb(t,e){return Zo(t,np(t),e)}function hv(t,e){for(var r=-1,i=e.length,s=t.length;++r<i;)t[s+r]=e[r];return t}var ub=av(Object.getPrototypeOf,Object);const ap=ub;var hb=Object.getOwnPropertySymbols,pb=hb?function(t){for(var e=[];t;)hv(e,np(t)),t=ap(t);return e}:uv;const pv=pb;function mb(t,e){return Zo(t,pv(t),e)}function mv(t,e,r){var i=e(t);return Ji(t)?i:hv(i,r(t))}function Vu(t){return mv(t,sp,np)}function gb(t){return mv(t,tc,pv)}var fb=Bs(Cr,"DataView");const Lu=fb;var vb=Bs(Cr,"Promise");const xu=vb;var yb=Bs(Cr,"Set");const Uu=yb;var Sb=Bs(Cr,"WeakMap");const Fu=Sb;var nm="[object Map]",Tb="[object Object]",am="[object Promise]",om="[object Set]",cm="[object WeakMap]",dm="[object DataView]",kb=Fs(Lu),Eb=Fs(zo),bb=Fs(xu),wb=Fs(Uu),_b=Fs(Fu),ds=Us;(Lu&&ds(new Lu(new ArrayBuffer(1)))!=dm||zo&&ds(new zo)!=nm||xu&&ds(xu.resolve())!=am||Uu&&ds(new Uu)!=om||Fu&&ds(new Fu)!=cm)&&(ds=function(t){var e=Us(t),r=e==Tb?t.constructor:void 0,i=r?Fs(r):"";if(i)switch(i){case kb:return dm;case Eb:return nm;case bb:return am;case wb:return om;case _b:return cm}return e});const Xn=ds;var Ib=Object.prototype,Cb=Ib.hasOwnProperty;function Pb(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Cb.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Rb=Cr.Uint8Array;const Kd=Rb;function op(t){var e=new t.constructor(t.byteLength);return new Kd(e).set(new Kd(t)),e}function Mb(t,e){var r=e?op(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Ab=/\w*$/;function Db(t){var e=new t.constructor(t.source,Ab.exec(t));return e.lastIndex=t.lastIndex,e}var lm=$i?$i.prototype:void 0,um=lm?lm.valueOf:void 0;function Ob(t){return um?Object(um.call(t)):{}}function gv(t,e){var r=e?op(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Nb="[object Boolean]",Vb="[object Date]",Lb="[object Map]",xb="[object Number]",Ub="[object RegExp]",Fb="[object Set]",Bb="[object String]",Wb="[object Symbol]",jb="[object ArrayBuffer]",Hb="[object DataView]",qb="[object Float32Array]",Gb="[object Float64Array]",$b="[object Int8Array]",Jb="[object Int16Array]",Kb="[object Int32Array]",zb="[object Uint8Array]",Yb="[object Uint8ClampedArray]",Qb="[object Uint16Array]",Xb="[object Uint32Array]";function Zb(t,e,r){var i=t.constructor;switch(e){case jb:return op(t);case Nb:case Vb:return new i(+t);case Hb:return Mb(t,r);case qb:case Gb:case $b:case Jb:case Kb:case zb:case Yb:case Qb:case Xb:return gv(t,r);case Lb:return new i;case xb:case Bb:return new i(t);case Ub:return Db(t);case Fb:return new i;case Wb:return Ob(t)}}var hm=Object.create,ew=function(){function t(){}return function(e){if(!Ir(e))return{};if(hm)return hm(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();const tw=ew;function fv(t){return typeof t.constructor=="function"&&!wl(t)?tw(ap(t)):{}}var rw="[object Map]";function iw(t){return qr(t)&&Xn(t)==rw}var pm=Qn&&Qn.isMap,sw=pm?ip(pm):iw;const nw=sw;var aw="[object Set]";function ow(t){return qr(t)&&Xn(t)==aw}var mm=Qn&&Qn.isSet,cw=mm?ip(mm):ow;const dw=cw;var lw=1,uw=2,hw=4,vv="[object Arguments]",pw="[object Array]",mw="[object Boolean]",gw="[object Date]",fw="[object Error]",yv="[object Function]",vw="[object GeneratorFunction]",yw="[object Map]",Sw="[object Number]",Sv="[object Object]",Tw="[object RegExp]",kw="[object Set]",Ew="[object String]",bw="[object Symbol]",ww="[object WeakMap]",_w="[object ArrayBuffer]",Iw="[object DataView]",Cw="[object Float32Array]",Pw="[object Float64Array]",Rw="[object Int8Array]",Mw="[object Int16Array]",Aw="[object Int32Array]",Dw="[object Uint8Array]",Ow="[object Uint8ClampedArray]",Nw="[object Uint16Array]",Vw="[object Uint32Array]",Te={};Te[vv]=Te[pw]=Te[_w]=Te[Iw]=Te[mw]=Te[gw]=Te[Cw]=Te[Pw]=Te[Rw]=Te[Mw]=Te[Aw]=Te[yw]=Te[Sw]=Te[Sv]=Te[Tw]=Te[kw]=Te[Ew]=Te[bw]=Te[Dw]=Te[Ow]=Te[Nw]=Te[Vw]=!0;Te[fw]=Te[yv]=Te[ww]=!1;function qc(t,e,r,i,s,n){var o,c=e&lw,d=e&uw,l=e&hw;if(r&&(o=s?r(t,i,s,n):r(t)),o!==void 0)return o;if(!Ir(t))return t;var h=Ji(t);if(h){if(o=Pb(t),!c)return lv(t,o)}else{var p=Xn(t),v=p==yv||p==vw;if(Yn(t))return dv(t,c);if(p==Sv||p==vv||v&&!s){if(o=d||v?{}:fv(t),!c)return d?mb(t,sb(o,t)):lb(t,ZE(o,t))}else{if(!Te[p])return s?t:{};o=Zb(t,p,c)}}n||(n=new Hr);var T=n.get(t);if(T)return T;n.set(t,o),dw(t)?t.forEach(function(b){o.add(qc(b,e,r,b,t,n))}):nw(t)&&t.forEach(function(b,P){o.set(P,qc(b,e,r,P,t,n))});var E=l?d?gb:Vu:d?tc:sp,C=h?void 0:E(t);return tE(C||t,function(b,P){C&&(P=b,b=t[P]),Zf(o,P,qc(b,e,r,P,t,n))}),o}var Lw=1,xw=4;function cp(t){return qc(t,Lw|xw)}var Uw="[object Symbol]";function Fw(t){return typeof t=="symbol"||qr(t)&&Us(t)==Uw}var Bw=Object.defineProperty,Ww=(t,e)=>{for(var r in e)Bw(t,r,{get:e[r],enumerable:!0})},jw={};Ww(jw,{permissions:()=>Hw,theme:()=>qw});var Ft=(t=>(t.GroupCall="GROUP_CALL",t.Webinar="WEBINAR",t.AudioRoom="AUDIO_ROOM",t.Livestream="LIVESTREAM",t.Chat="CHAT",t))(Ft||{}),q=(t=>(t.Allowed="ALLOWED",t.NotAllowed="NOT_ALLOWED",t.CanRequest="CAN_REQUEST",t))(q||{}),Hw={view_type:"GROUP_CALL",accept_waiting_requests:!1,accept_present_requests:!1,request_produce:!1,can_allow_participant_audio:!1,can_allow_participant_screensharing:!1,can_allow_participant_video:!1,can_spotlight:!1,request_kick_participant:!1,kick_participant:!1,pin_participant:!1,can_edit_display_name:!1,can_record:!1,can_livestream:!1,can_present:!0,waiting_room_type:"SKIP_ON_ACCEPT",recorder_type:"NONE",plugins:{can_close:!0,can_start:!0},polls:{can_create:!0,can_vote:!0,can_view:!0},produce:{video:{allow:!0,quality:"vga",frame_rate:24},audio:!0,screenshare:{allow:!0,quality:"hd",frame_rate:5}},chat:{public:{can_send:!0,text:!0,files:!0},private:{can_send:!1,can_receive:!1,text:!1,files:!1}},connected_meetings:{can_alter_connected_meetings:!1,can_switch_connected_meetings:!1,can_switch_to_parent_meeting:!1},reactions:!1,hidden_participant:!1,is_recorder:!1,show_participant_list:!0,can_change_participant_role:!1,can_change_theme:!1,max_screenshare_count:1},qw={setup_screen:{is_enabled:!0},alone_here:{is_enabled:!0},waiting_room:{is_enabled:!1,enable_preview:!0},control_bar:{is_enabled:!0,elements:{plugins:!0,screenshare:!0,invite:!0,participants:!0,chat:!0,reactions:!1,polls:!0,fullscreen:!0,layout:!0}},header:{is_enabled:!0,elements:{timer:!0,title:!0,participant_count:!0,change_layout:!0}},pip_mode:!0,auto_tune:!0,grid:{multi:{maxVideoCount:6,videoFit:"cover"},single:{maxVideoCount:6,videoFit:"cover"},defaultView:"multi"},controls:{pip_toggle:!1}},Tv="hXgU8Wc8pwuGNq9ms5q9Hh",gm;typeof process!="undefined"&&(gm=process==null?void 0:process.env)!=null&&gm.FLAGSMITH_ENVIRONMENT_KEY&&(Tv={}.FLAGSMITH_ENVIRONMENT_KEY);function Gw(t=[]){const e={};return t.forEach(r=>{e[r.feature.name]={enabled:r.enabled,value:r.feature_state_value}}),e}var kv=class{constructor(t=Tv){m(this,"flags",{}),m(this,"environmentKey",null),this.environmentKey=t}identifyAndFetchFlagsWithRetry(t){return u(this,arguments,function*({primaryEndpoint:e,secondaryEndpoint:r,forceEvaluate:i,timeout:s,uniqueIdentifier:n,traitsObj:o,logger:c}){const d=JSON.parse(JSON.stringify(o)),l=Object.entries(d).map(p=>({trait_key:p[0],trait_value:p[1]})),h=[e,r,r];for(const p of h)try{const v=new AbortController,T=setTimeout(()=>v.abort(),s),E="_"+(Math.random()+1).toString(36).substring(2),C=yield fetch(`https://${p}/api/v1/identities/`,{method:"POST",headers:{"Content-Type":"application/json","X-Environment-Key":this.environmentKey},body:JSON.stringify({identifier:n+(i?E:""),traits:l}),signal:v.signal});if(clearTimeout(T),!C.ok)throw new Error(`Request failed with status ${C.status}`);const b=yield C.json();return Gw(b.flags||[])}catch(v){c.error("Flagsmith identify failed!!",{error:v,url:p})}return{}})}identify(t){return u(this,arguments,function*(e,r={},i=!1,s=5e3,n="edge.api.flagsmith.com",o=console){return this.flags=yield this.identifyAndFetchFlagsWithRetry({traitsObj:r,uniqueIdentifier:e,forceEvaluate:i,timeout:s,primaryEndpoint:n,secondaryEndpoint:"edge.api.flagsmith.com",logger:o}),this.flags})}getValue(t){return this.flags&&this.flags[t]&&this.flags[t].value}hasFeature(t){return this.flags&&this.flags[t]&&this.flags[t].enabled}getAllFlags(){return this.flags}},$w=new kv;function Jw(t){return new kv(t)}var Ev=[-2,-1,0,1,2],Kw=[0,1,2,3,4];function zw(t){t=t.trim();let e="0",r="0",i="0";return t.length==4?(e="0x"+t[1]+t[1],r="0x"+t[2]+t[2],i="0x"+t[3]+t[3]):t.length>6&&(e="0x"+t[1]+t[2],r="0x"+t[3]+t[4],i="0x"+t[5]+t[6]),[+e,+r,+i]}var Yw=(t,e,r)=>{let i,s,n;if(e==0)i=s=n=r;else{const o=(l,h,p)=>(p<0&&(p+=1),p>1&&(p-=1),p<.16666666666666666?l+(h-l)*6*p:p<.5?h:p<.6666666666666666?l+(h-l)*(.6666666666666666-p)*6:l),c=r<.5?r*(1+e):r+e-r*e,d=2*r-c;i=o(d,c,t+1/3),s=o(d,c,t),n=o(d,c,t-1/3)}return[Math.round(i*255),Math.round(s*255),Math.round(n*255)]},Qw=(t,e,r)=>{t/=255,e/=255,r/=255;const i=Math.max(t,e,r),s=Math.min(t,e,r);let n,o;const c=(i+s)/2;if(i==s)n=o=0;else{const d=i-s;switch(o=c>.5?d/(2-i-s):d/(i+s),i){case t:n=(e-r)/d+(e<r?6:0);break;case e:n=(r-t)/d+2;break;case r:n=(t-e)/d+4;break}n/=6}return[n,o,c]},Xw=(t,e,r)=>{const i=s=>s.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(r)}`},bv=(t,e=Ev,r=.4)=>{const i=[],[s,n,o]=zw(t),[c,d,l]=Qw(s,n,o),h=Math.round(l*100);h>70?r=.8:h>60?r=.9:h<10?r=.075:h<42&&(r=.3);const p=e.findIndex(b=>b===0);if(p===-1)throw new Error("Invalid reducer provided, it must contain atleast one zero");const v=5-p,T=p+1,E=(100-h)/v,C=h/T;for(const b of e){let P;b<0?P=h+b*C*r:b>0?P=h+b*E*r:P=h;const[j,W,w]=Yw(c,d,P/100);i.push(Xw(j,W,w))}return i},fm={dark:{background:{1e3:"#252525",900:"#2F2F2F",800:"#323232",700:"#3E3E3E",600:"#4A4A4A"},text:"#F5F5F5","video-bg":"#1C1C1C"},light:{background:{1e3:"#FFFFFF",900:"#F5F5F5",800:"#EBEBEB",700:"#E0E0E0",600:"#D6D6D6"},text:"#111111","text-on-brand":"#ffffff","video-bg":"#DADADA"}},Zw=t=>{const[e,r,i,s,n]=bv(t,Ev);return{300:e,400:r,500:i,600:s,700:n}},e_=t=>{if(t==="#FFFFFF")return fm.light.background;if(t==="#000000")return fm.dark.background;const[e,r,i,s,n]=bv(t,Kw);return{1e3:e,900:r,800:i,700:s,600:n}},t_={border_radius:"rounded",border_width:"thin",spacing_base:4,theme:"dark",colors:{brand:Zw("#2160FD"),background:e_("#141414"),danger:"#FF2D2D",text:"#EEEEEE",text_on_brand:"#EEEEEE",success:"#62A504",video_bg:"#191919",warning:"#FFCD07"}};function wv(){return cp(t_)}var r_={permissions:{can_accept_production_requests:!1,can_edit_display_name:!0,accept_waiting_requests:!1,disable_participant_audio:!1,disable_participant_screensharing:!1,disable_participant_video:!1,can_spotlight:!1,kick_participant:!1,pin_participant:!1,can_record:!1,can_livestream:!1,waiting_room_type:"SKIP",plugins:{can_close:!0,can_start:!0,can_edit_config:!1,config:{}},polls:{can_create:!0,can_vote:!0,can_view:!0},media:{video:{can_produce:"ALLOWED",can_consume:"ALLOWED"},audio:{can_produce:"ALLOWED"},screenshare:{can_produce:"ALLOWED",can_consume:"ALLOWED"}},chat:{public:{can_send:!0,text:!0,files:!0},private:{can_send:!1,can_receive:!1,text:!1,files:!1},channel:{can_create:"ALL",can_delete:"ALL",can_update:"ALL",can_read_all:!1},message:{can_delete:"ALL",can_edit:"ALL",delete_cutoff_time_seconds:0,edit_cutoff_time_seconds:0}},hidden_participant:!1,is_recorder:!1,recorder_type:"NONE",show_participant_list:!0,transcription_enabled:!1,can_change_participant_permissions:!1,connected_meetings:{can_alter_connected_meetings:!1,can_switch_connected_meetings:!1,can_switch_to_parent_meeting:!1},stage_enabled:!1,stage_access:void 0,accept_stage_requests:!1},ui:{oldTheme:{setup_screen:{is_enabled:!1},alone_here:{is_enabled:!1},waiting_room:{is_enabled:!1,enable_preview:!0},control_bar:{is_enabled:!0,elements:{plugins:!0,screenshare:!0,invite:!1,participants:!0,chat:!0,reactions:!1,polls:!0,fullscreen:!0,layout:!0}},header:{is_enabled:!0,elements:{timer:!0,title:!0,participant_count:!0,change_layout:!0}},pip_mode:!0,auto_tune:!0,colors:{primary:"#2160FD",secondary:"#1A1A1A",text:"#EEEEEE",background:"#1A1A1A",textPrimary:"#EEEEEE",videoBackground:"#1A1A1A"},dimensions:{mode:"fillParent"},grid:{multi:{maxVideoCount:6,videoFit:"cover"},single:{maxVideoCount:6,videoFit:"cover"},defaultView:"MULTI"},controls:{pip_toggle:!1},plugins:[]},design_tokens:wv(),config_diff:{}},config:{view_type:"GROUP_CALL",media:{audio:{enable_stereo:!1,enable_high_bitrate:!1},video:{quality:"vga",frame_rate:24},screenshare:{quality:"hd",frame_rate:5}},max_video_streams:{mobile:6,desktop:6},max_screenshare_count:1,track_recording:{subscriptions:[]}},version:"hybrid"};function i_(){return cp(r_)}var s_={permissions:{can_accept_production_requests:!1,can_edit_display_name:!0,accept_waiting_requests:!1,disable_participant_audio:!1,disable_participant_screensharing:!1,disable_participant_video:!1,can_spotlight:!1,kick_participant:!1,pin_participant:!1,can_record:!1,can_livestream:!1,waiting_room_type:"SKIP",plugins:{can_close:!0,can_start:!0,can_edit_config:!1,config:{}},polls:{can_create:!0,can_vote:!0,can_view:!0},media:{video:{can_produce:"ALLOWED"},audio:{can_produce:"ALLOWED"},screenshare:{can_produce:"ALLOWED"}},chat:{public:{can_send:!0,text:!0,files:!0},private:{can_send:!1,can_receive:!1,text:!1,files:!1}},hidden_participant:!1,is_recorder:!1,recorder_type:"NONE",show_participant_list:!0,transcription_enabled:!1,can_change_participant_permissions:!1,connected_meetings:{can_alter_connected_meetings:!1,can_switch_connected_meetings:!1,can_switch_to_parent_meeting:!1},stage_enabled:!1,stage_access:void 0,accept_stage_requests:!1},ui:{design_tokens:wv(),config_diff:{}},config:{view_type:"GROUP_CALL",media:{audio:{enable_stereo:!1,enable_high_bitrate:!1},video:{quality:"vga",frame_rate:24},screenshare:{quality:"hd",frame_rate:5}},max_video_streams:{mobile:6,desktop:6},max_screenshare_count:1,track_recording:{subscriptions:[]}},version:"2.0.0"};function dp(){return cp(s_)}var Gc;class _v{constructor(){g(this,Gc,void 0)}get telemetry(){var e;return(e=a(this,Gc))==null?void 0:e.getValue("telemetry")}init(e){f(this,Gc,e)}info(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("info",e,r,i)}error(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("error",e,r,i)}debug(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("debug",e,r,i)}log(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("log",e,r,i)}warn(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("warn",e,r,i)}}Gc=new WeakMap;var bi,wi;const Iv=class extends gt.EventEmitter{constructor(t){super(),g(this,bi,void 0),g(this,wi,void 0),m(this,"asyncPromiseTimeout"),m(this,"logger"),this.logger=t,f(this,bi,new Map),f(this,wi,new Map),this.asyncPromiseTimeout=8e3}emitAsync(t,...e){return u(this,null,function*(){a(this,bi).set(t,[]);const r=a(this,wi).get(t).map(()=>new Promise(i=>{a(this,bi).get(t).push(i)}));dT(Iv.prototype,this,"emit").call(this,t,...e),yield Promise.race([Promise.all(r),new Promise((i,s)=>setTimeout(()=>s(new Error(`emitAsync failed to resolve for event ${t}.`)),this.asyncPromiseTimeout))]),a(this,bi).delete(t)})}onAsync(t,e){const r=a(this,bi),i=(...s)=>u(this,null,function*(){var n;try{yield e(...s)}catch(c){this.logger.error("[onAsync]",{error:c})}const o=(n=r.get(t))==null?void 0:n.shift();o==null||o()});return a(this,wi).get(t)||a(this,wi).set(t,[]),a(this,wi).get(t).push(i),super.on(t,i)}reset(){f(this,bi,new Map),f(this,wi,new Map),super.removeAllListeners()}};let n_=Iv;bi=new WeakMap,wi=new WeakMap;var a_=/\s/;function o_(t){for(var e=t.length;e--&&a_.test(t.charAt(e)););return e}var c_=/^\s+/;function d_(t){return t&&t.slice(0,o_(t)+1).replace(c_,"")}var vm=0/0,l_=/^[-+]0x[0-9a-f]+$/i,u_=/^0b[01]+$/i,h_=/^0o[0-7]+$/i,p_=parseInt;function ym(t){if(typeof t=="number")return t;if(Fw(t))return vm;if(Ir(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=Ir(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=d_(t);var r=u_.test(t);return r||h_.test(t)?p_(t.slice(2),r?2:8):l_.test(t)?vm:+t}function Cv(t){return t}function m_(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var g_=800,f_=16,v_=Date.now;function y_(t){var e=0,r=0;return function(){var i=v_(),s=f_-(i-r);if(r=i,s>0){if(++e>=g_)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}function S_(t){return function(){return t}}var T_=$d?function(t,e){return $d(t,"toString",{configurable:!0,enumerable:!1,value:S_(e),writable:!0})}:Cv;const k_=T_;var E_=y_(k_);const b_=E_;var Sm=Math.max;function w_(t,e,r){return e=Sm(e===void 0?t.length-1:e,0),function(){for(var i=arguments,s=-1,n=Sm(i.length-e,0),o=Array(n);++s<n;)o[s]=i[e+s];s=-1;for(var c=Array(e+1);++s<e;)c[s]=i[s];return c[e]=r(o),m_(t,this,c)}}function __(t,e){return b_(w_(t,e,Cv),t+"")}function I_(t,e,r){if(!Ir(r))return!1;var i=typeof e;return(i=="number"?ec(r)&&rv(e,r.length):i=="string"&&e in r)?Xo(r[e],t):!1}function C_(t){return __(function(e,r){var i=-1,s=r.length,n=s>1?r[s-1]:void 0,o=s>2?r[2]:void 0;for(n=t.length>3&&typeof n=="function"?(s--,n):void 0,o&&I_(r[0],r[1],o)&&(n=s<3?void 0:n,s=1),e=Object(e);++i<s;){var c=r[i];c&&t(e,c,i,n)}return e})}var P_="[object Object]",R_=Function.prototype,M_=Object.prototype,Pv=R_.toString,A_=M_.hasOwnProperty,D_=Pv.call(Object);function O_(t){if(!qr(t)||Us(t)!=P_)return!1;var e=ap(t);if(e===null)return!0;var r=A_.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Pv.call(r)==D_}var N_="__lodash_hash_undefined__";function V_(t){return this.__data__.set(t,N_),this}function L_(t){return this.__data__.has(t)}function zd(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Ws;++e<r;)this.add(t[e])}zd.prototype.add=zd.prototype.push=V_;zd.prototype.has=L_;function x_(t,e){for(var r=-1,i=t==null?0:t.length;++r<i;)if(e(t[r],r,t))return!0;return!1}function U_(t,e){return t.has(e)}var F_=1,B_=2;function Rv(t,e,r,i,s,n){var o=r&F_,c=t.length,d=e.length;if(c!=d&&!(o&&d>c))return!1;var l=n.get(t),h=n.get(e);if(l&&h)return l==e&&h==t;var p=-1,v=!0,T=r&B_?new zd:void 0;for(n.set(t,e),n.set(e,t);++p<c;){var E=t[p],C=e[p];if(i)var b=o?i(C,E,p,e,t,n):i(E,C,p,t,e,n);if(b!==void 0){if(b)continue;v=!1;break}if(T){if(!x_(e,function(P,j){if(!U_(T,j)&&(E===P||s(E,P,r,i,n)))return T.push(j)})){v=!1;break}}else if(!(E===C||s(E,C,r,i,n))){v=!1;break}}return n.delete(t),n.delete(e),v}function W_(t){var e=-1,r=Array(t.size);return t.forEach(function(i,s){r[++e]=[s,i]}),r}function j_(t){var e=-1,r=Array(t.size);return t.forEach(function(i){r[++e]=i}),r}var H_=1,q_=2,G_="[object Boolean]",$_="[object Date]",J_="[object Error]",K_="[object Map]",z_="[object Number]",Y_="[object RegExp]",Q_="[object Set]",X_="[object String]",Z_="[object Symbol]",e0="[object ArrayBuffer]",t0="[object DataView]",Tm=$i?$i.prototype:void 0,Gl=Tm?Tm.valueOf:void 0;function r0(t,e,r,i,s,n,o){switch(r){case t0:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case e0:return!(t.byteLength!=e.byteLength||!n(new Kd(t),new Kd(e)));case G_:case $_:case z_:return Xo(+t,+e);case J_:return t.name==e.name&&t.message==e.message;case Y_:case X_:return t==e+"";case K_:var c=W_;case Q_:var d=i&H_;if(c||(c=j_),t.size!=e.size&&!d)return!1;var l=o.get(t);if(l)return l==e;i|=q_,o.set(t,e);var h=Rv(c(t),c(e),i,s,n,o);return o.delete(t),h;case Z_:if(Gl)return Gl.call(t)==Gl.call(e)}return!1}var i0=1,s0=Object.prototype,n0=s0.hasOwnProperty;function a0(t,e,r,i,s,n){var o=r&i0,c=Vu(t),d=c.length,l=Vu(e),h=l.length;if(d!=h&&!o)return!1;for(var p=d;p--;){var v=c[p];if(!(o?v in e:n0.call(e,v)))return!1}var T=n.get(t),E=n.get(e);if(T&&E)return T==e&&E==t;var C=!0;n.set(t,e),n.set(e,t);for(var b=o;++p<d;){v=c[p];var P=t[v],j=e[v];if(i)var W=o?i(j,P,v,e,t,n):i(P,j,v,t,e,n);if(!(W===void 0?P===j||s(P,j,r,i,n):W)){C=!1;break}b||(b=v=="constructor")}if(C&&!b){var w=t.constructor,te=e.constructor;w!=te&&"constructor"in t&&"constructor"in e&&!(typeof w=="function"&&w instanceof w&&typeof te=="function"&&te instanceof te)&&(C=!1)}return n.delete(t),n.delete(e),C}var o0=1,km="[object Arguments]",Em="[object Array]",mc="[object Object]",c0=Object.prototype,bm=c0.hasOwnProperty;function d0(t,e,r,i,s,n){var o=Ji(t),c=Ji(e),d=o?Em:Xn(t),l=c?Em:Xn(e);d=d==km?mc:d,l=l==km?mc:l;var h=d==mc,p=l==mc,v=d==l;if(v&&Yn(t)){if(!Yn(e))return!1;o=!0,h=!1}if(v&&!h)return n||(n=new Hr),o||bl(t)?Rv(t,e,r,i,s,n):r0(t,e,d,r,i,s,n);if(!(r&o0)){var T=h&&bm.call(t,"__wrapped__"),E=p&&bm.call(e,"__wrapped__");if(T||E){var C=T?t.value():t,b=E?e.value():e;return n||(n=new Hr),s(C,b,r,i,n)}}return v?(n||(n=new Hr),a0(t,e,r,i,s,n)):!1}function Mv(t,e,r,i,s){return t===e?!0:t==null||e==null||!qr(t)&&!qr(e)?t!==t&&e!==e:d0(t,e,r,i,Mv,s)}function l0(t){return function(e,r,i){for(var s=-1,n=Object(e),o=i(e),c=o.length;c--;){var d=o[t?c:++s];if(r(n[d],d,n)===!1)break}return e}}var u0=l0();const h0=u0;var p0=function(){return Cr.Date.now()};const $l=p0;var m0="Expected a function",g0=Math.max,f0=Math.min;function lp(t,e,r){var i,s,n,o,c,d,l=0,h=!1,p=!1,v=!0;if(typeof t!="function")throw new TypeError(m0);e=ym(e)||0,Ir(r)&&(h=!!r.leading,p="maxWait"in r,n=p?g0(ym(r.maxWait)||0,e):n,v="trailing"in r?!!r.trailing:v);function T(re){var ae=i,Me=s;return i=s=void 0,l=re,o=t.apply(Me,ae),o}function E(re){return l=re,c=setTimeout(P,e),h?T(re):o}function C(re){var ae=re-d,Me=re-l,Xe=e-ae;return p?f0(Xe,n-Me):Xe}function b(re){var ae=re-d,Me=re-l;return d===void 0||ae>=e||ae<0||p&&Me>=n}function P(){var re=$l();if(b(re))return j(re);c=setTimeout(P,C(re))}function j(re){return c=void 0,v&&i?T(re):(i=s=void 0,o)}function W(){c!==void 0&&clearTimeout(c),l=0,i=d=s=c=void 0}function w(){return c===void 0?o:j($l())}function te(){var re=$l(),ae=b(re);if(i=arguments,s=this,d=re,ae){if(c===void 0)return E(d);if(p)return clearTimeout(c),c=setTimeout(P,e),T(d)}return c===void 0&&(c=setTimeout(P,e)),o}return te.cancel=W,te.flush=w,te}function Bu(t,e,r){(r!==void 0&&!Xo(t[e],r)||r===void 0&&!(e in t))&&rp(t,e,r)}function v0(t){return qr(t)&&ec(t)}function Wu(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}function y0(t){return Zo(t,tc(t))}function S0(t,e,r,i,s,n,o){var c=Wu(t,r),d=Wu(e,r),l=o.get(d);if(l){Bu(t,r,l);return}var h=n?n(c,d,r+"",t,e,o):void 0,p=h===void 0;if(p){var v=Ji(d),T=!v&&Yn(d),E=!v&&!T&&bl(d);h=d,v||T||E?Ji(c)?h=c:v0(c)?h=lv(c):T?(p=!1,h=dv(d,!0)):E?(p=!1,h=gv(d,!0)):h=[]:O_(d)||Jd(d)?(h=c,Jd(c)?h=y0(c):(!Ir(c)||tp(c))&&(h=fv(d))):p=!1}p&&(o.set(d,h),s(h,d,i,n,o),o.delete(d)),Bu(t,r,h)}function Av(t,e,r,i,s){t!==e&&h0(e,function(n,o){if(s||(s=new Hr),Ir(n))S0(t,e,o,r,Av,i,s);else{var c=i?i(Wu(t,o),n,o+"",t,e,s):void 0;c===void 0&&(c=n),Bu(t,o,c)}},tc)}var T0="[object Map]",k0="[object Set]",E0=Object.prototype,b0=E0.hasOwnProperty;function w0(t){if(t==null)return!0;if(ec(t)&&(Ji(t)||typeof t=="string"||typeof t.splice=="function"||Yn(t)||bl(t)||Jd(t)))return!t.length;var e=Xn(t);if(e==T0||e==k0)return!t.size;if(wl(t))return!ov(t).length;for(var r in t)if(b0.call(t,r))return!1;return!0}function _0(t,e){return Mv(t,e)}var I0=C_(function(t,e,r){Av(t,e,r)});const _i=I0;var ju=(t=>(t.PARTICIPANT="PARTICIPANT",t.PEER="PEER",t.CLIENT="CLIENT",t))(ju||{});const X={PROPAGATE_KICK_ALL:"propagate_kick_across_rooms",REFRESH_ID_ON_DISCONNECTION:"refresh_id_on_disconnection",SIMULCAST:"simulcast",CHAT_SOCKET_SERVER:"chat_socket_server",POLL_SOCKET_SERVER:"poll_socket_server",PLUGIN_SOCKET_SERVER:"plugin_socket_server",NR_OTEL_WEB:"nr_otel_web",ICE_RESTART_ON_FAILED_STATE:"ice_restart_on_failed_state",ICE_RESTART_ON_DISCONNECTED_STATE:"ice_restart_on_disconnected_state",ENABLE_ICE_STATE_LOGGING:"enable_ice_state_logging",SUPPRESS_PEER_MUTE_UNMUTE_EMITS:"web_core_suppress_peer_mute_unmute_emits",SKIP_OTEL_TRACES:"skip_otel_traces",USE_USERIDS_IN_CHAT:"use_userids_in_chat",CUSTOM_PING_PONG:"custom_ping_pong",ENABLE_HIVE_SIMULCAST:"enable_hive_simulcast",ENABLE_HIVE_TRANSPORT_RECONNECTION_ON_ICE_FAILED:"enable_hive_transport_reconnection_on_ice_failed",ENABLE_HIVE_EXPERIMENTAL_FAIL_RECOVERY:"enable_hive_fail_recovery",ENABLE_HIVE_INFINITE_RETRIES:"enable_hive_infinite_retries",HIVE_TRANSPORT_FORCE_RELAY_ON_ICE_FAILED:"hive_transport_force_relay_on_ice_failed",ENABLE_HIVE_CONSUME_OVER_DC:"enable_hive_consume_over_dc",ENABLE_CF_SIMULCAST:"enable_cf_simulcast",ENABLE_CF_TRANSPORT_RECONNECTION_ON_ICE_FAILED:"enable_cf_transport_reconnection_on_ice_failed",ENABLE_CF_EXPERIMENTAL_FAIL_RECOVERY:"enable_cf_fail_recovery",ENABLE_CF_INFINITE_RETRIES:"enable_cf_infinite_retries",CF_TRANSPORT_FORCE_RELAY_ON_ICE_FAILED:"cf_transport_force_relay_on_ice_failed",BYPASS_LOG_EXCLUSION_LIST:"bypass_log_exclusion_list",LOG_LEVEL:"log_level",V1_PLUGINS:"v1_plugins",SCREENSHARE_DTX:"screenshare_dtx",SCREENSHARE_PRIORITY:"screenshare_priority",SCREENSHARE_MIN_BITRATE:"screenshare_minbitrate",SCREENSHARE_SIMULCAST:"screenshare_simulcast",DISABLE_WEBCAM_LAYERS_ON_SCREENSHARE:"disable_webcam_layers_on_screenshare",SCREENSHARE_FORCE_GOOG_CONFERENCE:"screenshare_force_goog_conference",LIVESTREAM:"feat_livestream",FETCH_RETRY:"fetch_retry",DISABLE_WEBCAM_SIMULCAST:"webcore_disable_webcam_simulcast",OVERRIDE_WEBCAM_SIMULCAST:"override_webcam_simulcast",SOCKET_POLLING:"socket_polling",FEAT_PAGINATED_CHAT:"feat_paginated_chat",VAL_MIN_FRAMERATE:"val_min_framerate",SCREEENSHARE_ERR_HACK:"screenshare_err_hack",SCREEENSHARE_CONSTRAINTS_RETRY:"screenshare_constraints_retry",TROUBLESHOOTING:"feat_troubleshooting",VIDEO_CONSTRAINTS:"video_constraints",SCREENSHARE_CONSTRAINTS:"screenshare_constraints",FEAT_CHAT_SDK:"feat_chat_sdk",FEAT_CHAT_SDK_SEARCH:"chat_search",OBS_QUALITY:"obs_quality",ALLOW_SAFARI_MEDIA_MIDDLEWARES:"allow_safari_media_middlewares",DYNAMIC_VIDEO_QUALITY:"dynamic_video_quality",EXP_RESHARE:"exp_reshare",LEAVE_STAGE_ON_END:"leave_stage_on_end",SKIP_SETTING_IN_USE_DEVICE:"skip_setting_in_use_device",PRECALL_BANDWIDTH_TEST:"precall_bandwidth_test",CONSUMER_BIND_NO_RETRY:"consumer_bind_no_retry",DEBUG_SOCKET_JOIN:"debug_socket_join",FORCE_RELAY:"force_relay",FORCE_VIDEO_CODEC:"force_video_codec",USE_EXPERIMENTAL_SFU_HANDLER:"use_experimental_sfu_handler",TRACK_HINT:"track_hint",OVERRIDE_HIVE_SIMULCAST_DYNAMIC:"override_hive_simulcast_dynamic",PRECREATE_PRODUCERS:"precreate_producers",DISABLE_OPUS_DTX_CF:"disable_opus_dtx_cf",ENABLE_AUDIO_ACTIVITY_DEBUG_LOGS:"enable_audio_activity_debug_logs",NEW_SYNC_CONSUMERS:"new_sync_consumers",DISABLE_LAYER_SWITCH:"disable_layer_switch"};function $c(t){const e={};return typeof(t==null?void 0:t.code)=="number"&&(e.code=t.code),typeof(t==null?void 0:t.code)=="string"&&(e.code=t.code.substring(0,100)),typeof(t==null?void 0:t.name)=="string"&&(e.name=t.name.substring(0,500)),typeof(t==null?void 0:t.message)=="string"&&(e.message=t.message.substring(0,500)),typeof(t==null?void 0:t.reason)=="string"&&(e.reason=t.reason.substring(0,500)),typeof(t==null?void 0:t.stack)=="string"&&(e.stack=t.stack.substring(0,500)),e}function C0(t){var e,r,i,s;const n=typeof navigator!="undefined"&&!navigator.isReactNative&&typeof window!="undefined"&&((e=window.location.host)==null?void 0:e.includes("devel"))&&((r=window.location.host)==null?void 0:r.includes("dyte.io")),o=!!((s=(i=t==null?void 0:t.getValue("modules"))==null?void 0:i.devTools)!=null&&s.logs);return n||o}function P0(t,e){var r;if(t!=null&&t.getValue("flagsmith").hasFeature(X.LOG_LEVEL)){let i=((r=t.getValue("flagsmith").getValue(X.LOG_LEVEL))==null?void 0:r.toString())||"all";if(i=i.toLowerCase().trim(),i==="off")return!1;if(i!=="all"){const s=["debug","log","info","warn","error"],n=s.indexOf(e),o=s.indexOf(i);if(n<o)return!1}}return!0}function Dv(t,e,r={}){return Object.getOwnPropertyNames(t).forEach(i=>{var s;if([null,void 0,NaN].includes(t[i])||e&&(((s=e.match(/\./g))==null?void 0:s.length)||0)>=10)return;const n=e?`${e}.${i}`:i;typeof t[i]=="object"?Dv(t[i],n,r):["number","string","boolean"].includes(typeof t[i])&&(r[n]=t[i])}),r}function wm(t,e,r={},i=""){const s={};try{const n=JSON.stringify(r),o=JSON.parse(n),c=Dv(o,i),d=JSON.stringify(c);return JSON.parse(d)}catch(n){const o=$c(n);s[`${i}.error.message`]=o.message||"",s[`${i}.error.stack`]=o.stack||"",s[`${i}.error.reason`]=o.reason||"",s[`${i}.error.source`]="safelyFlattenObjForOpenTelemetry"}return s}const R0={audio:!0,video:!0,screenshareAudio:!0,screenshareVideo:!0},Ea={baseURL:"http://localhost:5000",createdAt:"2021-08-05T10:49:56.602Z",description:"Develop plugins locally",id:"09259e3b-7be8-46f6-9801-106bf1866e1c",name:"Localhost Dev",organizationId:"4ad15a19-80e2-4105-bf43-48039fd2963e",picture:"https://dyte-uploads.s3.ap-south-1.amazonaws.com/dyte.png",private:!1,published:!0,staggered:!1,tags:["#localhost","#dev"],type:"self_hosted",updatedAt:"2021-08-05T10:50:07.681Z"},M0={pip:!0,poll:!0,chat:!0,stage:!0,theme:!0,plugin:!0,tracing:!0,internals:!0,recording:!0,livestream:!0,participant:!0,connectedMeetings:!0,devTools:{logs:!1}};function Zn(t,e){const r=t.getValue("overrides");return r&&r[e]?r[e]:!1}function A0({baseURI:t}){return t.includes("preprod.dyte")||t.includes("preprod.realtime")?Do.PREPROD:t.includes("devel.dyte")||t.includes("devel.realtime")?Do.DEVEL:Do.PROD}function As({servicePrefix:t,baseURI:e}){return`${t}.${e}`}function Ov(t){const e=t.getValue("baseURI");return{location:As({servicePrefix:"location",baseURI:e}),locationLegacy:As({servicePrefix:"location-legacy",baseURI:e}),daCollector:As({servicePrefix:"da-collector",baseURI:e.replace("realtime.cloudflare.com","dyte.io")})}}const D0='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m16.242 2.932 4.826 4.826a2.75 2.75 0 0 1-.715 4.404l-4.87 2.435a.75.75 0 0 0-.374.426l-1.44 4.166a1.25 1.25 0 0 1-2.065.476L8.5 16.561 4.06 21H3v-1.06l4.44-4.44-3.105-3.104a1.25 1.25 0 0 1 .476-2.066l4.166-1.44a.75.75 0 0 0 .426-.373l2.435-4.87a2.75 2.75 0 0 1 4.405-.715Zm3.766 5.886-4.826-4.826a1.25 1.25 0 0 0-2.002.325l-2.435 4.871a2.25 2.25 0 0 1-1.278 1.12l-3.789 1.31 6.705 6.704 1.308-3.789a2.25 2.25 0 0 1 1.12-1.277l4.872-2.436a1.25 1.25 0 0 0 .325-2.002Z" fill="currentColor"/></svg>',O0='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M4 12.02c0 1.06.2 2.1.6 3.08l.6 1.42c.22.55.64 1.01 1.17 1.29.27.14.56.21.86.21h2.55c.77 0 1.49-.41 1.87-1.08.5-.87 1.02-1.7 1.72-2.43l1.32-1.39c.44-.46.97-.84 1.49-1.23l.59-.45a.6.6 0 0 0 .23-.47c0-.75-.54-1.57-1.22-1.79a3.34 3.34 0 0 0-2.78.29V4.5a1.5 1.5 0 0 0-2.05-1.4 1.5 1.5 0 0 0-2.9 0A1.5 1.5 0 0 0 6 4.5v.09A1.5 1.5 0 0 0 4 6v6.02ZM8 4.5v4a.5.5 0 0 0 1 0v-5a.5.5 0 0 1 1 0v5a.5.5 0 0 0 1 0v-4a.5.5 0 0 1 1 0v6a.5.5 0 0 0 .85.37h.01c.22-.22.44-.44.72-.58.7-.35 2.22-.57 2.4.5l-.53.4c-.52.4-1.04.78-1.48 1.24l-1.33 1.38c-.75.79-1.31 1.7-1.85 2.63-.21.36-.6.58-1.01.58H7.23a.87.87 0 0 1-.4-.1 1.55 1.55 0 0 1-.71-.78l-.59-1.42a7.09 7.09 0 0 1-.53-2.7V6a.5.5 0 0 1 1 0v3.5a.5.5 0 0 0 1 0v-5a.5.5 0 0 1 1 0Z" fill="currentColor"></path></svg>',gc=t=>{if(!t)return;if(!t.startsWith("<svg"))return new Promise(s=>{s(t)});const e=new Blob([t],{type:"image/svg+xml"}),r=new Image,i=window.URL.createObjectURL(e);return new Promise((s,n)=>{r.onload=()=>{s(r),window.URL.revokeObjectURL(i)},r.onerror=()=>{n(),window.URL.revokeObjectURL(i)},r.src=i})},Nv=class{constructor(){m(this,"logsCache",[]),m(this,"logsProcessorTimer"),m(this,"tracingEnabled",!0),m(this,"initialized",!1),m(this,"logsProcessingInterval",7e3),m(this,"logExclusionList",["message","websocket/message","roomMessage","websocket/room-message","websocket/room-legacy-mode","chatMessage","websocket/new-chat-message","websocket/no-active-speaker","websocket/selected-peers","websocket/active-speaker","ping","websocket/new-consumer","websocket/producer-score","websocket/consumer-score","websocket/plugin-event","websocket/plugin-data","websocket/plugin-internal-data"]),m(this,"meetingMetadata",{})}get logsEndpoint(){const t=ai.getContext(this.meetingMetadata.peerId);return`https://${As({servicePrefix:"api-silos",baseURI:t.getValue("baseURI")})}/otel/logs`}resetPeerId(t){this.meetingMetadata.peerId=t}init(t,e,r){this.tracingEnabled=!0,this.initialized=!1,this.logsCache=[];const i=t.getValue("peerId");this.meetingMetadata=e,this.tracingEnabled=r,this.meetingMetadata.peerId=i,this.meetingMetadata.sdkVersion=t.getValue("sdkVersion");const{RNDeviceInfoImpl:s}=navigator;this.meetingMetadata.deviceInfo=navigator.isReactNative?s==null?void 0:s.getDeviceInfo():Ie.getDeviceInfo(),this.meetingMetadata.visitedUrl=!navigator.isReactNative&&typeof window!="undefined"&&window.location.href,this.logsProcessorTimer=setInterval(this.processCachedLogs.bind(this),this.logsProcessingInterval),r&&(this.initialized=!0)}static trace(t,e=void 0){return(r,i,s)=>{const n=s.value;return s.value=function(...o){var c;const d=this==null?void 0:this.telemetry;if(!d||!d.initialized||navigator.isReactNative||!d.tracingEnabled||(c=ai.getContext(d.meetingMetadata.peerId))!=null&&c.getValue("flagsmith").hasFeature(X.SKIP_OTEL_TRACES))return n.apply(this,o);d.addLogInCurrentSpan("info",t,e);const l=performance.now(),h=n.apply(this,o);return Promise.resolve(h).then(()=>{const p=performance.now();p-l>10&&d.addLogInCurrentSpan("info",`${t}_timing`,{execTime:p-l,country:Nv.location.country})}).catch(()=>{const p=performance.now();d.addLogInCurrentSpan("info",`${t}_timing`,{execTime:p-l})}),h},s}}injectContext(t){var e;const r=Os().replace(/-/g,"").substring(0,16),i=(e=this.meetingMetadata.peerId)==null?void 0:e.replace(/-/g,"");t.TRACEPARENT=`00-${i}-${r}-01`}addLogInCurrentSpan(t,e,r={},i=!1){r!=null&&r.error&&Object.assign(r,{error:$c(r.error)});const s=ai.getContext(this.meetingMetadata.peerId);if(C0(s)&&(w0(r)?console[t]("DyteInternalLogs:: ",t,e):console[t]("DyteInternalLogs:: ",t,e,r)),!!P0(s,t))try{const n=wm(s,e,r,"metadata"),o=new Date,c=G(V({message:e,level:t},n),{loggedAt:o.toISOString(),loggedAtTzOffset:o.getTimezoneOffset()});i?this.sendOtelLogsToNewRelic([c]):this.logsCache.push(c)}catch(n){this.addLogInCurrentSpan("error","opentelemetry::addLogInCurrentSpan_failed",{error:$c(n)})}}sendOtelLogsToNewRelic(t){const e=ai.getContext(this.meetingMetadata.peerId);fetch(this.logsEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({meetingMetadata:wm(e,"sendOtelLogsToNewRelic",this.meetingMetadata,"meetingMetadata"),serviceName:e.getValue("sdkName"),logs:t})}).catch(r=>{this.addLogInCurrentSpan("error","opentelemetry::sendOtelLogToNewRelic_failed",{error:$c(r)}),this.logsCache.push(...t)})}processCachedLogs(){const t=this.logsCache.splice(0,25);t!=null&&t.length&&this.sendOtelLogsToNewRelic(t)}destruct(){clearInterval(this.logsProcessorTimer),this.processCachedLogs()}};let k=Nv;m(k,"location",{country:void 0});function N0(t){const e=V({},t),r=new Map,i=(o,c)=>(r.has(o)||r.set(o,new Set),r.get(o).add(c),()=>{var d;return(d=r.get(o))==null?void 0:d.delete(c)}),s=(o,c)=>{var d;(d=r.get(o))==null||d.delete(c)},n=o=>{var c;(c=r.get(o))==null||c.forEach(d=>{try{d(e[o])}catch{}})};return{subscribe:i,unsubscribe:s,notify:n,setValue:(o,c,d=!0)=>{e[o]=c,d&&n(o)},getValue:o=>e[o],getAllValues:()=>e}}class V0{constructor(){m(this,"contexts",new Map),m(this,"mostRecentPeerId",null)}createContext(e,r){if(this.contexts.has(e))return this.contexts.get(e);const i=new k,s=new _v;this.contexts.set(e,N0(r)),this.contexts.get(e).setValue("peerSessionStore",new n_(s));const n=new Yf;return n.setMaxListeners(50),this.contexts.get(e).setValue("logger",s),this.contexts.get(e).setValue("telemetry",i),this.contexts.get(e).setValue("callstats",n),this.contexts.get(e).setValue("flagsmith",Jw()),this.mostRecentPeerId=e,this.contexts.get(e)}remapContext(e,r){const i=r.getValue("peerId");i!==e&&(r.setValue("peerId",e),this.mostRecentPeerId=e,this.contexts.set(e,r),this.contexts.delete(i))}getContext(e){return this.contexts.get(e)}getMostRecentPeerId(){return this.mostRecentPeerId}}const ai=new V0,L0={"00":"DyteClient","01":"Controller","02":"RoomNodeClient","03":"HiveNodeClient","04":"SocketService","05":"Chat","06":"Plugin","07":"Polls","08":"Meta","09":"Preset",10:"Recording",11:"Self",12:"Participant",13:"Spotlight",14:"Remote Request",15:"Webinar",16:"LocalMediaHandler",17:"End-End Encryption",18:"AI",19:"Livestream",20:"Stage"},Jc={"0000":"Internal exception.","0001":"Failed to initialize.","0002":"Failed to join room.","0003":"Failed to leave room.","0004":"Invalid auth token","0010":"Browser not supported","0011":"HTTP Network Error","0012":"Websocket Network Error","0013":"Rate Limited","0100":"Internal exception","0101":"Permission denied","0102":"Prerequisite module missing","0200":"Internal exception.","0300":"Internal exception","0400":"Internal exception","0404":"Missing prerequisites to establish a websocket connection","0500":"Internal exception","0501":"Permission denied.","0502":"Invalid message body.","0503":"Text Message is too large","0504":"Message not found by the given id","0505":"Action not permitted without joining room","0506":"Message search is disabled","0510":"Invalid channel name.","0600":"Internal exception","0601":"Permission denied.","0602":"Auth token not set for plugin","0603":"Iframe was not provided","0700":"Internal exception","0705":"Action not permitted without joining room","0800":"Internal exception","0801":"Permission denied","0900":"Internal exception","0904":"Could not load preset",1e3:"Internal exception",1001:"Permission denied",1004:"Could not find specified recording",1005:"Action not permitted in given recording state",1100:"Internal exception",1101:"Permission denied",1102:"Unsupported",1103:"Name cannot be empty",1104:"No device selected while calling meeting.self.setDevice",1105:"Action not permitted without joining room",1106:"Can't set currently used device",1200:"Internal exception",1201:"Permission denied",1202:"Invalid page number was requested",1203:"Invalid participant count per page was requested",1204:"No participants exists with the given UserIds",1205:"Action not permitted without joining room",1206:"Manual Subscription Mode was not ACTIVATED",1207:"Invalid view mode",1208:"Manual Subscription not enabled for organization",1209:"Broadcast message type must be a non-empty string",1300:"Internal exception",1400:"Internal exception",1402:"No existing remote requests",1403:"No peer exists with given id",1500:"Internal exception",1600:"Internal exception",1601:"Failed to get audio track",1602:"Failed to get video track",1603:"Incorrect device",1604:"Failed to change device",1605:"Failed to get audio & video track",1606:"No audio input devices are available",1607:"No video input devices are available",1608:"No audio output devices (speakers) are available",1609:"Failed to fetch list of media devices",1610:"No media track exists",1611:"Failed to unmute track",1612:"Failed to get screenshare tracks",1701:"Crypto error",1800:"Internal exception",1801:"Can't fetch transcript file",1900:"Internal exception",1901:"Permission denied.",1902:"Livestream that has not yet started, can't be stopped",2e3:"Internal exception",2001:"Permission denied",2002:"Unsupported",2003:"Stage is disabled",2004:"Method not implemented",2005:"Action not permitted without joining room",2006:"Action not permitted in current stage status",9900:"Internal exception"};Object.keys(Jc).forEach(t=>{Jc[t]=`{${L0[t.slice(0,2)]}} ${Jc[t]}`});class I extends Error{constructor(e,r,i=void 0,s=!1){super(e),m(this,"code"),this.code=r,this.name="DyteError",this.message=`[ERR${this.code}]: ${Jc[this.code]}
12
+ `)),this.pc2.setLocalDescription(e),this.pc1.setRemoteDescription(e)}establishConnection(){this.pc1.createOffer().then(this.gotOffer.bind(this),this.reportFatal.bind(this))}reportFatal(e){console.error("Error:",e)}getRoundTripTime(){return u(this,null,function*(){const[e,r]=yield Promise.all([this.pc1.getStats(),this.pc2.getStats()]);let i,s;if(e.forEach(n=>{n.type==="candidate-pair"&&n.nominated===!0&&n.bytesSent>0&&(i=n)}),r.forEach(n=>{n.type==="candidate-pair"&&n.nominated===!0&&n.bytesReceived>0&&(s=n)}),i&&s)try{if(i.currentRoundTripTime&&s.currentRoundTripTime)return{rtt:i.currentRoundTripTime,backendRTT:s.currentRoundTripTime};const n=(s.lastPacketReceivedTimestamp-i.lastPacketSentTimestamp)/1e3;return{rtt:n,backendRTT:n}}catch{return}})}close(){this.pc1.close(),this.pc2.close()}}class $f extends gt{constructor(e){super(),m(this,"call"),m(this,"timeOut"),this.call=new di(e)}start(e=1e4){this.call.establishConnection(),this.timeOut=setTimeout(this.testFailed.bind(this),e)}testComplete(e){clearTimeout(this.timeOut),this.call.close(),this.emit("done",e)}testFailed(e){this.call.close(),this.emit("failed",e)}}const LT=8,xT=1/1e3;class UT extends $f{constructor(e){super(e),m(this,"senderChannel"),m(this,"recieveChannel"),m(this,"startTime"),m(this,"lastBitrateMeasureTime"),m(this,"sentPayloadBytes",0),m(this,"recievedPayloadBytes",0),m(this,"lastReceivedPayloadBytes",0),m(this,"stopSending",!1),m(this,"testProgress",0),m(this,"samplePacket",""),m(this,"finalBitrateSum",0),m(this,"bitRateSampels",0),m(this,"maxNumberOfPacketsToSend",0),m(this,"bytesToKeepBuffered",0),m(this,"testDurationSeconds",5),this.call.setIceCandidateFilter(di.isNotHostCandidate),this.senderChannel=this.call.pc1.createDataChannel(null);for(let r=0;r<1024*256;r+=1)this.samplePacket+="h";this.maxNumberOfPacketsToSend=1,this.bytesToKeepBuffered=1024*this.maxNumberOfPacketsToSend,this.testDurationSeconds=4,this.senderChannel.addEventListener("open",this.sendingStep.bind(this)),this.call.pc2.addEventListener("datachannel",this.onRecieverChannel.bind(this))}sendingStep(){const e=new Date;this.startTime||(this.startTime=e,this.lastBitrateMeasureTime=e);for(let i=0;i!==this.maxNumberOfPacketsToSend&&!(this.senderChannel.bufferedAmount>=this.bytesToKeepBuffered);i+=1){this.sentPayloadBytes+=this.samplePacket.length;try{this.senderChannel.send(this.samplePacket)}catch{}}const r=e.getTime()-this.startTime.getTime();r>=1e3*this.testDurationSeconds?(this.stopSending=!0,this.testProgress=100):(this.testProgress=r/(10*this.testDurationSeconds),setTimeout(this.sendingStep.bind(this),1))}onMessageRecieved(e){this.recievedPayloadBytes+=e.data.length;const r=new Date,i=r.getTime()-this.lastBitrateMeasureTime.getTime();if(i>=1e3){const s=(this.recievedPayloadBytes-this.lastReceivedPayloadBytes)*LT/(i/1e3);this.finalBitrateSum+=s,this.bitRateSampels+=1,this.lastReceivedPayloadBytes=this.recievedPayloadBytes,this.lastBitrateMeasureTime=r}if(this.stopSending&&this.sentPayloadBytes===this.recievedPayloadBytes){const s=this.finalBitrateSum/this.bitRateSampels;this.testComplete({throughput:Math.round(s*xT)})}}testComplete(e){this.call.getRoundTripTime().then(({rtt:r,backendRTT:i})=>super.testComplete({RTT:r,backendRTT:i,throughput:e.throughput}))}onRecieverChannel(e){this.recieveChannel=e.channel,this.recieveChannel.addEventListener("message",this.onMessageRecieved.bind(this))}}class Zh extends $f{constructor(e,r=di.noFilter){super(e),m(this,"ch1"),m(this,"ch2"),this.call.setIceCandidateFilter(r);const i=this.call.pc1.createDataChannel(null);this.ch1=i,i.addEventListener("open",()=>{i.send("hello")}),i.addEventListener("message",this.onCh1Recieve.bind(this)),this.call.pc2.addEventListener("datachannel",this.dataChannelHandler.bind(this))}onCh1Recieve(e){e.data!=="world"?this.hangup("Invalid data transmitted."):this.testComplete({connectivity:!0})}onCh2Recieve(e){if(e.data!=="hello")this.hangup("Invalid data transmitted.");else try{this.ch2.send("world")}catch{}}dataChannelHandler(e){const r=e.channel;this.ch2=r,r.addEventListener("message",this.onCh2Recieve.bind(this))}hangup(e){this.testFailed(e)}}class FT extends Zh{constructor(e){super(e,di.isHost)}}class BT extends Zh{constructor(e){super(e,di.isRelay)}}class WT extends Zh{constructor(e){super(e,di.isReflexive)}}class jT{constructor(){m(this,"ipInformation",null)}getIPDetails(e){return u(this,arguments,function*({peerId:r,apiHostnames:i,logger:s}){var n,o,c;if(!this.ipInformation){try{const d=`https://${i.location}`,l=yield(yield fetch(d)).json();if(((n=l.loc)==null?void 0:n.length)>5)return this.ipInformation=l,(o=this.ipInformation)!=null&&o.ip&&(this.ipInformation.ip=qi(this.ipInformation.ip)),l;throw Error("Insufficient data")}catch(d){s.error("callstats::ipDetails:: failed to fetch ip using location service",{error:d})}try{const d=yield fetch(`https://${i.locationLegacy}/?token=3c493932b0624c&peerId=${r}`,{method:"POST"});this.ipInformation=yield d.json(),(c=this.ipInformation)!=null&&c.ip&&(this.ipInformation.ip=qi(this.ipInformation.ip))}catch(d){s.error("callstats::ipDetails:: failed to fetch ip using legacy location service",{error:d})}}return this.ipInformation})}resetCache(){this.ipInformation=null}}const ep=new jT,$p=[{urls:"turn:turn.dyte.in:443?transport=tcp",username:"dyte",credential:"dytein",credentialType:"password"},{urls:"turn:turn.dyte.in:3478?transport=udp",username:"dyte",credential:"dytein",credentialType:"password"}];function Jp(t){const[e,r]=t.split(",");return{coords:{latitude:Number(e),longitude:Number(r)}}}class Jf{constructor(){m(this,"transport"),m(this,"candidatePair"),m(this,"outboundVideoRtp",new Map),m(this,"inboundVideoRtp",new Map),m(this,"outboundAudioRtp",new Map),m(this,"inboundAudioRtp",new Map),m(this,"remoteInboundRtp",new Map),m(this,"producerStreamMap",new Map),m(this,"consumerStreamMap",new Map),m(this,"staleProducerStreamMap",!1),m(this,"staleConsumerStreamMap",!1)}}class Kf extends gt{constructor(){super(),m(this,"observer"),m(this,"outboundProducerMap",new Map),m(this,"inboundConsumerMap",new Map),m(this,"consumerPeerIdMap",new Map),m(this,"pausedConsumerMap",new Map),m(this,"pausedProducerMap",new Map),m(this,"overallProducingTransportsStatsMap",{}),m(this,"overallConsumingTransportsStatsMap",{}),m(this,"overallConsumersStatsMap",{}),m(this,"overallProducersStatsMap",{}),m(this,"videoProducerToStatsMap",new Map),m(this,"audioProducerToStatsMap",new Map),m(this,"videoConsumerToStatsMap",new Map),m(this,"audioConsumerToStatsMap",new Map),m(this,"consumerIdsWithFreezedVideo",new Set),m(this,"consumerIdsWithFreezedAudio",new Set),m(this,"producerIdsWithFreezedVideo",new Set),m(this,"producerIdsWithFreezedAudio",new Set),m(this,"freezedProducingTransportIds",new Set),m(this,"freezedConsumingTransportIds",new Set),m(this,"screenShareProducers",new Set),m(this,"screenShareConsumers",new Set),m(this,"ipDetails"),m(this,"callStatsInstance"),this.observer=new gt}registerProducer(e){return u(this,null,function*(){yield this.generateProducerStreamMap(e),e.on("close",this.deregisterProducer.bind(this,e)),e.on("pause",this.pauseProducer.bind(this,e.id)),e.on("resume",this.resumeProducer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareProducers.add(e.id)})}pauseProducer(e){this.pausedProducerMap.set(e,{lastReportCalculated:!1})}resumeProducer(e){this.pausedProducerMap.delete(e)}processInboundConsumerVideoStats(e,r,i){var s,n;const o=((n=(s=this==null?void 0:this.callStatsInstance)==null?void 0:s.consumerSharedMediaStatesMap)==null?void 0:n.get(e))||{};r.totalVideoPacketsReceived===i.packetsReceived?(this.consumerIdsWithFreezedVideo.add(e),this.callStatsInstance&&o.video&&(this.callStatsInstance.logger.debug("callstats::measurements::consumerVideoFreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_video_status","pause",e))):(r.totalVideoPacketsReceived=i.packetsReceived,this.consumerIdsWithFreezedVideo.has(e)&&(this.consumerIdsWithFreezedVideo.delete(e),this.callStatsInstance&&o.video&&(this.callStatsInstance.logger.debug("callstats::measurements::consumerVideoDefreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_video_status","resume",e))))}processInboundConsumerAudioStats(e,r,i){var s,n;const o=((n=(s=this==null?void 0:this.callStatsInstance)==null?void 0:s.consumerSharedMediaStatesMap)==null?void 0:n.get(e))||{};r.totalAudioPacketsReceived===i.packetsReceived?(this.consumerIdsWithFreezedAudio.add(e),this.callStatsInstance&&o.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::consumerAudioFreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_audio_status","pause",e))):(r.totalAudioPacketsReceived=i.packetsReceived,this.consumerIdsWithFreezedAudio.has(e)&&(this.consumerIdsWithFreezedAudio.delete(e),this.callStatsInstance&&o.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::consumerAudioDefreezed",{consumerId:e}),this.callStatsInstance.eventHandler.emit("consumer_audio_status","resume",e))))}processOutboundProducerVideoStats(e,r,i){var s;const n=((s=this==null?void 0:this.callStatsInstance)==null?void 0:s.currentUserMediaStates)||{};r.totalVideoPacketsSent===i.packetsSent?(this.producerIdsWithFreezedVideo.add(e),this.callStatsInstance&&n.video&&(this.callStatsInstance.logger.debug("callStats::measurements::producerVideoFreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_video_status","pause",e))):(r.totalVideoPacketsSent=i.packetsSent,this.producerIdsWithFreezedVideo.has(e)&&(this.producerIdsWithFreezedVideo.delete(e),this.callStatsInstance&&n.video&&(this.callStatsInstance.logger.debug("callStats::measurements::producerVideoDefreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_video_status","resume",e))))}processOutboundProducerAudioStats(e,r,i){var s;const n=((s=this==null?void 0:this.callStatsInstance)==null?void 0:s.currentUserMediaStates)||{};r.totalAudioPacketsSent===i.packetsSent?(this.producerIdsWithFreezedAudio.add(e),this.callStatsInstance&&n.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::producerAudioFreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_audio_status","pause",e))):(r.totalAudioPacketsSent=i.packetsSent,this.producerIdsWithFreezedAudio.has(e)&&(this.producerIdsWithFreezedAudio.delete(e),this.callStatsInstance&&n.audio&&(this.callStatsInstance.logger.debug("callStats::measurements::producerAudioDefreezed",{producerId:e}),this.callStatsInstance.eventHandler.emit("producer_audio_status","resume",e))))}processProducingTransportStats(e,r,i){var s;const n=((s=this==null?void 0:this.callStatsInstance)==null?void 0:s.currentUserMediaStates)||{},{audio:o,video:c,screen:d}=n,l=o||c||d;r.totalPacketsSent===i.packetsSent?(this.freezedProducingTransportIds.add(e),this.callStatsInstance&&l&&(this.callStatsInstance.logger.debug("callStats::measurements::producingTransportFreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("producing_transport_status","pause",e))):(r.totalPacketsSent=i.packetsSent,this.freezedProducingTransportIds.has(e)&&(this.freezedProducingTransportIds.delete(e),this.callStatsInstance&&l&&(this.callStatsInstance.logger.debug("callStats::measurements::producingTransportDefreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("producing_transport_status","resume",e))))}processConsumingTransportStats(e,r,i){var s,n;const o=!!Array.from(((n=(s=this==null?void 0:this.callStatsInstance)==null?void 0:s.consumerSharedMediaStatesMap)==null?void 0:n.values())||[]).reduce((c,d)=>c||d.audio||d.video||d.screen,!1);r.totalPacketsReceived===i.packetsSent?(this.freezedConsumingTransportIds.add(e),this.callStatsInstance&&o&&(this.callStatsInstance.logger.debug("callStats::measurements::consumingTransportFreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("consuming_transport_status","pause",e))):(r.totalPacketsReceived=i.packetsSent,this.freezedConsumingTransportIds.has(e)&&(this.freezedConsumingTransportIds.delete(e),this.callStatsInstance&&o&&(this.callStatsInstance.logger.debug("callStats::measurements::consumingTransportDefreezed",{transportId:e}),this.callStatsInstance.eventHandler.emit("consuming_transport_status","resume",e))))}registerConsumer(e){return u(this,null,function*(){yield this.generateConsumerStreamMap(e),this.consumerPeerIdMap.set(e.id,{producerId:e.producerId,peerId:e.appData.peerId,appData:e.appData}),e.on("close",this.deregisterConsumer.bind(this,e)),e.on("pause",this.pauseConsumer.bind(this,e.id)),e.on("resume",this.resumeConsumer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareConsumers.add(e.id)})}pauseConsumer(e){this.pausedConsumerMap.set(e,{lastReportCalculated:!1})}resumeConsumer(e){this.pausedConsumerMap.delete(e)}generateProducerStreamMap(e,r=!1){return u(this,null,function*(){const i=yield e.getStats(),s=r?this.getProducerStatsFromReport(this.parseRTCReport(i,["outbound-rtp","remote-inbound-rtp"],!1,e.id))[0]:void 0;for(const n of i.values())switch(n.type){case"outbound-rtp":{this.outboundProducerMap.set(n.id,e.id);break}}return s})}generateConsumerStreamMap(e,r=!1){return u(this,null,function*(){const i=yield e.getStats(),s=r?this.getConsumerStatsFromReport(this.parseRTCReport(i,["inbound-rtp"],!1,e.id))[0]:void 0;for(const n of i.values())switch(n.type){case"inbound-rtp":{this.inboundConsumerMap.set(n.id,e.id);break}}return s})}deregisterProducer(e){this.outboundProducerMap.forEach((r,i)=>{r===e.id&&this.outboundProducerMap.delete(i)}),this.pausedProducerMap.delete(e.id),this.screenShareProducers.delete(e.id)}deregisterConsumer(e){this.inboundConsumerMap.forEach((r,i)=>{r===e.id&&this.inboundConsumerMap.delete(i)}),this.consumerPeerIdMap.delete(e.id),this.pausedConsumerMap.delete(e.id),this.screenShareConsumers.delete(e.id)}getIceCandidateStats(e){var r;return{id:e.id,type:e.candidateType||e.type,address:e.address,port:e.port,url:e.url,protocol:(r=e.relayProtocol)!=null?r:e.protocol,networkType:e.networkType,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort}}getWorkingSimulcastVideoStats(e){return e.find(r=>{const i=r.framesEncoded>0,s=r.packetsSent>0,n=r.frameWidth&&r.frameHeight;return i&&s&&!!n})||e[e.length-1]}parseRTCReport(e,r=[],i=!1,s=void 0,n=void 0){var o,c,d,l,h,p,v,T,E,C,b,P,j;const W=e,w=new Jf,te=r.length?new Set(r):void 0,re=[],ae=[],Me=[],Xe=new Map,jt=new Map;for(const A of W.values()){if(te){if(te.size===0)break;if(te.has(A.type))i&&te.delete(A.type);else continue}switch(A.type){case"local-candidate":{re.push(this.getIceCandidateStats(A));break}case"remote-candidate":{ae.push(this.getIceCandidateStats(A));break}case"candidate-pair":{const{nominated:S}=A,{selected:_}=A,B=A,oe={nominated:S!=null?S:_,currentRoundTripTime:B.currentRoundTripTime,totalRoundTripTime:B.totalRoundTripTime,bytesReceived:B.bytesReceived,bytesSent:B.bytesSent,availableOutgoingBitrate:B.availableOutgoingBitrate,availableIncomingBitrate:B.availableIncomingBitrate,lastPacketReceivedTimestamp:B.lastPacketReceivedTimestamp,lastPacketSentTimestamp:B.lastPacketSentTimestamp,localCandidateId:B.localCandidateId,remoteCandidateId:B.remoteCandidateId,bytesDiscardedOnSend:B.bytesDiscardedOnSend,packetsSent:B.packetsSent,packetsReceived:B.packetsReceived,packetsDiscardedOnSend:B.packetsDiscardedOnSend};Me.push(oe),(A.nominated===!0||A.selected===!0)&&(w.candidatePair=oe);break}case"transport":{const S=A;n&&(n.producing&&(this.overallProducingTransportsStatsMap[n.id]||(this.overallProducingTransportsStatsMap[n.id]={totalPacketsSent:0})),n.consuming&&(this.overallConsumingTransportsStatsMap[n.id]||(this.overallConsumingTransportsStatsMap[n.id]={totalPacketsReceived:0})));const _={bytesReceived:S.bytesReceived,bytesSent:S.bytesSent,packetsSent:S.packetsSent,packetsReceived:S.packetsReceived,dtlsCipher:S.dtlsCipher,dtlsState:S.dtlsState,iceRole:S.iceRole};if(w.transport=_,n){if(n.producing){const B=this.overallProducingTransportsStatsMap[n.id];this.processProducingTransportStats(n.id,B,_)}if(n.consuming){const B=this.overallConsumingTransportsStatsMap[n.id];this.processConsumingTransportStats(n.id,B,_)}}break}case"remote-inbound-rtp":{const S=A,_={jitter:S.jitter,fractionLost:S.fractionLost,roundTripTime:S.roundTripTime,roundTripTimeMeasurements:S.roundTripTimeMeasurements,totalRoundTripTime:S.totalRoundTripTime,packetsLost:S.packetsLost};w.remoteInboundRtp.set(S.localId,_);break}case"outbound-rtp":{if(!this.outboundProducerMap.has(A.id))break;const S=A,_=s||this.outboundProducerMap.get(A.id),B=this.pausedProducerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedProducerMap.set(_,{lastReportCalculated:!0})}this.overallProducersStatsMap[_]||(this.overallProducersStatsMap[_]={totalVideoPacketsSent:0,totalAudioPacketsSent:0});const oe=this.overallProducersStatsMap[_];if(["video","audio"].includes(S.mediaType)||["video","audio"].includes(S.kind)){if(!this.outboundProducerMap.has(A.id)){w.staleProducerStreamMap=!0;break}const He=this.callStatsInstance.producers.get(_);if(((o=He==null?void 0:He.track)==null?void 0:o.readyState)==="ended")break;w.producerStreamMap.has(_)||w.producerStreamMap.set(_,{outboundVideoRtpId:[],outboundAudioRtpId:[]});const x={bytesSent:S.bytesSent,packetsSent:S.packetsSent,nackCount:S.nackCount,ssrc:S.ssrc,mid:S.mid,active:S.active,codecId:S.codecId,headerBytesSent:S.headerBytesSent||0,totalPacketSendDelay:S.totalPacketSendDelay||0};if(S.mediaType==="video"||S.kind==="video"){const R=S,ce=V({frameHeight:R.frameHeight,frameWidth:R.frameWidth,framesEncoded:R.framesEncoded,framesDropped:R.framesDropped,framesPerSecond:R.framesPerSecond,framesSent:R.framesSent,keyFramesEncoded:R.keyFramesEncoded,firCount:R.firCount,encoderImplementation:R.encoderImplementation,hugeFramesSent:R.hugeFramesSent,pliCount:R.pliCount,qpSum:R.qpSum,qualityLimitationDurations:R.qualityLimitationDurations,qualityLimitationReason:R.qualityLimitationReason,qualityLimitationResolutionChanges:R.qualityLimitationResolutionChanges,totalEncodeTime:R.targetBitrate,totalPacketSendDelay:R.totalPacketSendDelay,retransmittedBytesSent:R.retransmittedBytesSent,retransmittedPacketsSent:R.retransmittedPacketsSent,scalabilityMode:R.scalabilityMode,powerEfficientEncoder:R.powerEfficientEncoder},x);w.outboundVideoRtp.set(A.id,ce),w.producerStreamMap.get(_).outboundVideoRtpId.push(A.id),this.processOutboundProducerVideoStats(_,oe,ce)}else if(S.mediaType==="audio"||S.kind==="audio"){const R=S,ce=V({retransmittedBytesSent:R.retransmittedBytesSent,retransmittedPacketsSent:R.retransmittedPacketsSent},x);w.outboundAudioRtp.set(A.id,ce),w.producerStreamMap.get(_).outboundAudioRtpId.push(A.id),this.processOutboundProducerAudioStats(_,oe,ce)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Outbound-rtp. mediatype: ${S.mediaType} kind: ${S.kind}`);break}case"inbound-rtp":{if(!this.inboundConsumerMap.has(A.id))break;const S=A,_=s||this.inboundConsumerMap.get(A.id),B=this.pausedConsumerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedConsumerMap.set(_,{lastReportCalculated:!0})}if(S.ssrc===1234)break;this.overallConsumersStatsMap[_]||(this.overallConsumersStatsMap[_]={totalVideoPacketsReceived:0,totalAudioPacketsReceived:0});const oe=this.overallConsumersStatsMap[_];if(["video","audio"].includes(S.mediaType)||["video","audio"].includes(S.kind)){if(!this.inboundConsumerMap.has(A.id)){w.staleConsumerStreamMap=!0;break}w.consumerStreamMap.has(_)||w.consumerStreamMap.set(_,{inboundVideoRtpId:[],inboundAudioRtpId:[]});const He={bytesReceived:S.bytesReceived,packetsReceived:S.packetsReceived,packetsLost:S.packetsLost>=0?S.packetsLost:0,jitter:S.jitter,nackCount:S.nackCount,jitterBufferDelay:S.jitterBufferDelay,jitterBufferEmittedCount:S.jitterBufferEmittedCount,lastPacketReceivedTimestamp:S.lastPacketReceivedTimestamp,ssrc:S.ssrc,mid:S.mid,codecId:S.codecId,headerBytesReceived:S.headerBytesReceived||0,packetsDiscarded:S.packetsDiscarded||0,jitterBufferMinimumDelay:S.jitterBufferMinimumDelay||0,jitterBufferTargetDelay:S.jitterBufferTargetDelay||0};if(S.mediaType==="video"||S.kind==="video"){const x=S,R=V({frameHeight:x.frameHeight,frameWidth:x.frameWidth,framesDecoded:x.framesDecoded,framesDropped:x.framesDropped,framesPerSecond:x.framesPerSecond,framesReceived:x.framesReceived,keyFramesDecoded:x.keyFramesDecoded,firCount:x.firCount,decoderImplementation:x.decoderImplementation,pliCount:x.pliCount,totalProcessingDelay:x.totalProcessingDelay,qpSum:x.qpSum||0,totalAssemblyTime:x.totalAssemblyTime||0,totalDecodeTime:x.totalDecodeTime||0,totalFreezesDuration:x.totalFreezesDuration||0,totalInterFrameDelay:x.totalInterFrameDelay||0,totalPausesDuration:x.totalPausesDuration||0,totalSquaredInterFrameDelay:x.totalSquaredInterFrameDelay||0,freezeCount:x.freezeCount||0,pauseCount:x.pauseCount||0,powerEfficientDecoder:x.powerEfficientDecoder},He);R.score=Gf({frameWidth:R.frameWidth||0,framesDecoded:(R.framesDecoded||0)-(((c=this.videoConsumerToStatsMap.get(_))==null?void 0:c.framesDecoded)||0),framesPerSecond:R.framesPerSecond||0,packetsLost:(R.packetsLost||0)-(((d=this.videoConsumerToStatsMap.get(_))==null?void 0:d.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((l=this.videoConsumerToStatsMap.get(_))==null?void 0:l.packetsReceived)||0),jitter:R.jitter||0,isScreenShare:this.screenShareConsumers.has(_)}),jt.set(_,{score:+(R.score*10).toFixed(),frameWidth:R.frameWidth||0,frameHeight:R.frameHeight||0,framesPerSecond:R.framesPerSecond||0,packetsLostPercentage:qd({packetsLost:(R.packetsLost||0)-(((h=this.videoConsumerToStatsMap.get(_))==null?void 0:h.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((p=this.videoConsumerToStatsMap.get(_))==null?void 0:p.packetsReceived)||0)}),jitter:R.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((R.bytesReceived||0)-(((v=this.videoConsumerToStatsMap.get(_))==null?void 0:v.bytesReceived)||0))*8/7}),this.videoConsumerToStatsMap.set(_,R),w.inboundVideoRtp.set(A.id,R),w.consumerStreamMap.get(_).inboundVideoRtpId.push(A.id),this.processInboundConsumerVideoStats(_,oe,R)}else if(S.mediaType==="audio"||S.kind==="audio"){const x=S,R=V({audioLevel:x.audioLevel,concealedSamples:x.concealedSamples,concealmentEvents:x.concealmentEvents,totalAudioEnergy:x.totalAudioEnergy,totalSamplesDuration:x.totalSamplesDuration,totalSamplesReceived:x.totalSamplesReceived,fecPacketsDiscarded:x.fecPacketsDiscarded||0,fecPacketsReceived:x.fecPacketsReceived||0,insertedSamplesForDeceleration:x.insertedSamplesForDeceleration||0,removedSamplesForAcceleration:x.removedSamplesForAcceleration||0,silentConcealedSamples:x.silentConcealedSamples||0,playoutId:x.playoutId},He);R.score=qf({concealmentEvents:(R.concealmentEvents||0)-(((T=this.audioConsumerToStatsMap.get(_))==null?void 0:T.concealmentEvents)||0),packetsLost:(R.packetsLost||0)-(((E=this.audioConsumerToStatsMap.get(_))==null?void 0:E.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((C=this.audioConsumerToStatsMap.get(_))==null?void 0:C.packetsReceived)||0),jitter:R.jitter||0}),jt.set(_,{score:+(R.score*10).toFixed(),packetsLostPercentage:qd({packetsLost:(R.packetsLost||0)-(((b=this.audioConsumerToStatsMap.get(_))==null?void 0:b.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((P=this.audioConsumerToStatsMap.get(_))==null?void 0:P.packetsReceived)||0)}),jitter:R.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((R.bytesReceived||0)-(((j=this.audioConsumerToStatsMap.get(_))==null?void 0:j.bytesReceived)||0))*8/7}),this.audioConsumerToStatsMap.set(_,R),w.inboundAudioRtp.set(A.id,R),w.consumerStreamMap.get(_).inboundAudioRtpId.push(A.id),this.processInboundConsumerAudioStats(_,oe,R)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Inbound-rtp. mediatype: ${S.mediaType} kind: ${S.kind}`);break}}}if(w.producerStreamMap.forEach((A,S)=>{var _,B,oe,He,x,R,ce,Qi,Xi,Gr,oa,ca,da,la,ua,ha,pa,ma,ga,fa,va,ya,Sa;if(A.outboundVideoRtpId.length>0){const ge=[];A.outboundVideoRtpId.forEach(Ul=>{ge.push(w.outboundVideoRtp.get(Ul))});const se=this.getWorkingSimulcastVideoStats(ge);se.score=jf({frameWidth:se.frameWidth||0,framesPerSecond:se.framesPerSecond||0,jitter:((_=se.remoteData)==null?void 0:_.jitter)||0,isScreenShare:this.screenShareProducers.has(S),packetsSent:(se.packetsSent||0)-(((B=this.videoProducerToStatsMap.get(S))==null?void 0:B.packetsSent)||0),packetsLost:(((oe=se.remoteData)==null?void 0:oe.packetsLost)||0)-(((x=(He=this.videoProducerToStatsMap.get(S))==null?void 0:He.remoteData)==null?void 0:x.packetsLost)||0),framesEncoded:(se.framesEncoded||0)-(((R=this.videoProducerToStatsMap.get(S))==null?void 0:R.framesEncoded)||0)}),Xe.set(S,{score:+(se.score*10).toFixed(),frameWidth:se.frameWidth||0,frameHeight:se.frameHeight||0,framesPerSecond:se.framesPerSecond||0,jitter:((ce=se.remoteData)==null?void 0:ce.jitter)||0,isScreenShare:this.screenShareProducers.has(S),packetsLostPercentage:Hd({packetsSent:(se.packetsSent||0)-(((Qi=this.videoProducerToStatsMap.get(S))==null?void 0:Qi.packetsSent)||0),packetsLost:(((Xi=se.remoteData)==null?void 0:Xi.packetsLost)||0)-(((oa=(Gr=this.videoProducerToStatsMap.get(S))==null?void 0:Gr.remoteData)==null?void 0:oa.packetsLost)||0)}),bitrate:((se.bytesSent||0)-(((ca=this.videoProducerToStatsMap.get(S))==null?void 0:ca.bytesSent)||0))*8/7,cpuLimitations:se.qualityLimitationReason==="cpu",bandwidthLimitations:se.qualityLimitationReason==="bandwidth"}),this.videoProducerToStatsMap.set(S,se)}else if(A.outboundAudioRtpId.length>0){const ge=w.outboundAudioRtp.get(A.outboundAudioRtpId[0]);ge.score=Wf({packetsSent:(ge.packetsSent||0)-(((da=this.audioProducerToStatsMap.get(S))==null?void 0:da.packetsSent)||0),packetsLost:(((la=ge.remoteData)==null?void 0:la.packetsLost)||0)-(((ha=(ua=this.audioProducerToStatsMap.get(S))==null?void 0:ua.remoteData)==null?void 0:ha.packetsLost)||0),jitter:((pa=ge.remoteData)==null?void 0:pa.jitter)||0}),Xe.set(S,{score:+(ge.score*10).toFixed(),bitrate:((ge.bytesSent||0)-(((ma=this.audioProducerToStatsMap.get(S))==null?void 0:ma.bytesSent)||0))*8/7,packetsLostPercentage:Hd({packetsSent:(ge.packetsSent||0)-(((ga=this.audioProducerToStatsMap.get(S))==null?void 0:ga.packetsSent)||0),packetsLost:(((fa=ge.remoteData)==null?void 0:fa.packetsLost)||0)-(((ya=(va=this.audioProducerToStatsMap.get(S))==null?void 0:va.remoteData)==null?void 0:ya.packetsLost)||0)}),jitter:((Sa=ge.remoteData)==null?void 0:Sa.jitter)||0,isScreenShare:this.screenShareProducers.has(S)}),this.audioProducerToStatsMap.set(S,ge)}}),Me.forEach(A=>{const S=re.find(B=>B.id===A.localCandidateId?(A.localCandidateId=B.id,B):null),_=ae.find(B=>B.id===A.remoteCandidateId?(A.remoteCandidateId=B.id,B):null);S&&(A.localCandidateType=S.type,A.localCandidateAddress=qi(S.address),A.localCandidatePort=S.port,A.localCandidateProtocol=S.protocol,A.localCandidateUrl=S.url,A.localCandidateNetworkType=S.networkType,A.localCandidateRelatedAddress=qi(S.relatedAddress),A.localCandidateRelatedPort=S.relatedPort),_&&(A.remoteCandidateType=_.type,A.remoteCandidateAddress=qi(_.address),A.remoteCandidatePort=_.port,A.remoteCandidateProtocol=_.protocol,A.remoteCandidateUrl=_.url)}),w.candidatePair&&(w.transport?(w.transport.totalRoundTripTime=w.candidatePair.totalRoundTripTime,w.transport.availableOutgoingBitrate=w.candidatePair.availableOutgoingBitrate,w.transport.availableIncomingBitrate=w.candidatePair.availableIncomingBitrate,w.transport.roundTripTime=w.candidatePair.currentRoundTripTime):w.transport={bytesReceived:w.candidatePair.bytesReceived,bytesSent:w.candidatePair.bytesSent,totalRoundTripTime:w.candidatePair.totalRoundTripTime,availableOutgoingBitrate:w.candidatePair.availableOutgoingBitrate,availableIncomingBitrate:w.candidatePair.availableIncomingBitrate,roundTripTime:w.candidatePair.currentRoundTripTime}),w.transport&&(w.transport.candidatePairs=Me),w.transport&&!w.transport.roundTripTime){let A=0,S=0;w.remoteInboundRtp.forEach((_,B)=>{_.roundTripTime&&_.roundTripTime>A&&(A=_.roundTripTime,S=_.totalRoundTripTime)}),w.transport.roundTripTime=A,w.transport.totalRoundTripTime=S}if(jt.size>0)try{this.observer.emit("consumer_score",jt)}catch{}if(Xe.size>0)try{this.observer.emit("producer_score",Xe)}catch{}return w}getProducersReport(e){return u(this,null,function*(){const r=e.map(i=>this.generateProducerStreamMap(i,!0));return r.length>0?Promise.all(r):void 0})}getConsumersReport(e){return u(this,null,function*(){const r=e.map(i=>this.generateConsumerStreamMap(i,!0));return r.length>0?Promise.all(r):void 0})}getTransportReport(e){return u(this,null,function*(){return e.getStats()})}getProcessedStats(e,r,i){return u(this,null,function*(){const s=yield this.getTransportReport(e),n={producing:i,consuming:r,id:e.id},o=s,c=this.parseRTCReport(o,["transport","candidate-pair","inbound-rtp","outbound-rtp","remote-inbound-rtp","local-candidate","remote-candidate"],!1,void 0,n);if(!c)return;const d={stats:c.transport,transportId:e.id,consuming:r,producing:i},l=c.staleProducerStreamMap?void 0:this.getProducerStatsFromReport(c),h=c.staleConsumerStreamMap?void 0:this.getConsumerStatsFromReport(c);return{transportReport:d,producerReport:l,consumerReport:h}})}getProducerStatsFromReport(e){const r=[];try{e.producerStreamMap.forEach((i,s)=>{var n,o;r.push({producerId:s,videoStats:i.outboundVideoRtpId.map(c=>e.outboundVideoRtp.get(c)),audioStats:i.outboundAudioRtpId.map(c=>e.outboundAudioRtp.get(c)),appData:((o=(n=this.callStatsInstance.producers)==null?void 0:n.get(s))==null?void 0:o.appData)||null})})}catch(i){this.callStatsInstance.logger.error("callStats::measurements::getProducerStatsFromReport",{error:{reason:i.reason,message:i.message}})}return r}getConsumerStatsFromReport(e){const r=[];try{e.consumerStreamMap.forEach((i,s)=>{const{peerId:n,producerId:o,appData:c}=this.consumerPeerIdMap.get(s);r.push({consumerId:s,peerId:n,producerId:o,appData:c,videoStats:i.inboundVideoRtpId.map(d=>e.inboundVideoRtp.get(d)),audioStats:i.inboundAudioRtpId.map(d=>e.inboundAudioRtp.get(d))})})}catch(i){console.error("getConsumersReport: ",i,e)}return r}getUserLocation(){return u(this,null,function*(){return new Promise((e,r)=>{try{navigator.geolocation?navigator.geolocation.getCurrentPosition(i=>{e(i)}):r()}catch(i){r(i)}})})}getConnectivity(e){return u(this,null,function*(){try{const r={iceServers:e||$p},i=new Promise((l,h)=>{try{const p=new FT(r);p.addListener("done",l),p.addListener("failed",()=>{l({connectivity:!1})}),p.start(2e3)}catch(p){h(p)}}),s=new Promise((l,h)=>{try{const p=new BT(r);p.addListener("done",l),p.addListener("failed",()=>{l({connectivity:!1})}),p.start(2e3)}catch(p){h(p)}}),n=new Promise((l,h)=>{try{const p=new WT(r);p.addListener("done",l),p.addListener("failed",()=>{l({connectivity:!1})}),p.start(2e3)}catch(p){h(p)}}),[o,c,d]=yield Promise.all([i,s,n]);return{host:o==null?void 0:o.connectivity,relay:c==null?void 0:c.connectivity,reflexive:d==null?void 0:d.connectivity}}catch{return{host:!1,relay:!1,reflexive:!1}}})}getThroughput(e){return u(this,null,function*(){try{const r=yield new Promise((i,s)=>{try{const n={iceServers:e||$p},o=new UT(n);o.addListener("done",i),o.addListener("failed",s),o.start(1e4)}catch(n){s(n)}});return{throughput:r.throughput,fractionalLoss:0,RTT:r.RTT,jitter:0,backendRTT:r.backendRTT}}catch{return}})}getIPDetails(){return u(this,null,function*(){var e,r;try{return this.ipDetails||(this.ipDetails=yield ep.getIPDetails({peerId:(e=this.callStatsInstance)==null?void 0:e.peerId,apiHostnames:(r=this.callStatsInstance)==null?void 0:r.apiHostnames,logger:this.callStatsInstance.logger})),this.ipDetails}catch{return}})}getNetworkQuality(e){return u(this,null,function*(){const[r,i]=yield Promise.all([this.getConnectivity(e),this.getThroughput(e)]);return{connectivity:r,throughput:i==null?void 0:i.throughput,fractionalLoss:i==null?void 0:i.fractionalLoss,RTT:i==null?void 0:i.RTT,jitter:i==null?void 0:i.jitter,backendRTT:i==null?void 0:i.backendRTT}})}getNetworkInfo(e,r=!1){return u(this,null,function*(){var i,s;if(r){const d=yield this.getIPDetails();return{ipDetails:d,effectiveNetworkType:(i=navigator.connection)==null?void 0:i.effectiveType,location:d!=null&&d.loc?Jp(d==null?void 0:d.loc):void 0}}const[n,o,c]=yield Promise.all([this.getConnectivity(e),this.getThroughput(e),this.getIPDetails()]);return{ipDetails:c,effectiveNetworkType:(s=navigator.connection)==null?void 0:s.effectiveType,location:c!=null&&c.loc?Jp(c==null?void 0:c.loc):void 0,turnConnectivity:n?n.host||n.relay||n.reflexive:!1,connectivity:n,throughput:o==null?void 0:o.throughput,fractionalLoss:o==null?void 0:o.fractionalLoss,RTT:o==null?void 0:o.RTT,jitter:o==null?void 0:o.jitter,backendRTT:o==null?void 0:o.backendRTT}})}}class HT extends Kf{}class zf extends Kf{constructor(){super(...arguments),m(this,"producerMap",new Map),m(this,"consumerMap",new Map)}registerProducer(e){return u(this,null,function*(){this.producerMap.set(e.id,e),yield this.generateProducerStreamMap(e),e.on("close",this.deregisterProducer.bind(this,e)),e.on("pause",this.pauseProducer.bind(this,e.id)),e.on("resume",this.resumeProducer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareProducers.add(e.id)})}registerConsumer(e){return u(this,null,function*(){this.consumerMap.set(e.id,e),yield this.generateConsumerStreamMap(e),this.consumerPeerIdMap.set(e.id,{producerId:e.producerId,peerId:e.appData.peerId,appData:e.appData}),e.on("close",this.deregisterConsumer.bind(this,e)),e.on("pause",this.pauseConsumer.bind(this,e.id)),e.on("resume",this.resumeConsumer.bind(this,e.id)),e.appData.screenShare===!0&&this.screenShareConsumers.add(e.id)})}generateConsumerStreamMap(e,r=!1){return u(this,null,function*(){const i=yield e.getStats(),s=this.parseRTCReport(i,["inbound-rtp"],!1,e.id),n=[...s.consumerStreamMap.values()][0],o=r?this.getConsumerStatsFromParsedConsumerStats(s,n,e.id):void 0;for(const c of i.values())switch(c.type){case"inbound-rtp":{this.inboundConsumerMap.set(c.id,e.id);break}}return o})}deregisterProducer(e){this.producerMap.delete(e.id),this.outboundProducerMap.forEach((r,i)=>{r===e.id&&this.outboundProducerMap.delete(i)}),this.pausedProducerMap.delete(e.id),this.screenShareProducers.delete(e.id)}deregisterConsumer(e){this.consumerMap.delete(e.id),this.inboundConsumerMap.forEach((r,i)=>{r===e.id&&this.inboundConsumerMap.delete(i)}),this.consumerPeerIdMap.delete(e.id),this.pausedConsumerMap.delete(e.id),this.screenShareConsumers.delete(e.id)}getIceCandidateStats(e){var r;return{id:e.id,type:e.candidateType||e.type,address:e.address,port:e.port,url:e.url,protocol:(r=e.relayProtocol)!=null?r:e.protocol,networkType:e.networkType,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort}}parseRTCReport(e,r=[],i=!1,s=void 0,n=void 0){var o,c,d,l,h,p,v,T,E,C,b,P,j;const W=e,w=new Jf,te=r.length?new Set(r):void 0,re=[],ae=[],Me=[],Xe=new Map,jt=new Map;for(const A of W.values()){if(te){if(te.size===0)break;if(te.has(A.type))i&&te.delete(A.type);else continue}switch(A.type){case"local-candidate":{re.push(this.getIceCandidateStats(A));break}case"remote-candidate":{ae.push(this.getIceCandidateStats(A));break}case"candidate-pair":{const{nominated:S}=A,{selected:_}=A,B=A,oe={nominated:S!=null?S:_,currentRoundTripTime:B.currentRoundTripTime,totalRoundTripTime:B.totalRoundTripTime,bytesReceived:B.bytesReceived,bytesSent:B.bytesSent,availableOutgoingBitrate:B.availableOutgoingBitrate,availableIncomingBitrate:B.availableIncomingBitrate,lastPacketReceivedTimestamp:B.lastPacketReceivedTimestamp,lastPacketSentTimestamp:B.lastPacketSentTimestamp,localCandidateId:B.localCandidateId,remoteCandidateId:B.remoteCandidateId,bytesDiscardedOnSend:B.bytesDiscardedOnSend,packetsSent:B.packetsSent,packetsReceived:B.packetsReceived,packetsDiscardedOnSend:B.packetsDiscardedOnSend};Me.push(oe),(A.nominated===!0||A.selected===!0)&&(w.candidatePair=oe);break}case"transport":{const S=A;n&&(n.producing&&(this.overallProducingTransportsStatsMap[n.id]||(this.overallProducingTransportsStatsMap[n.id]={totalPacketsSent:0})),n.consuming&&(this.overallConsumingTransportsStatsMap[n.id]||(this.overallConsumingTransportsStatsMap[n.id]={totalPacketsReceived:0})));const _={bytesReceived:S.bytesReceived,bytesSent:S.bytesSent,packetsSent:S.packetsSent,packetsReceived:S.packetsReceived,dtlsCipher:S.dtlsCipher,dtlsState:S.dtlsState,iceRole:S.iceRole};if(w.transport=_,n){if(n.producing){const B=this.overallProducingTransportsStatsMap[n.id];this.processProducingTransportStats(n.id,B,_)}if(n.consuming){const B=this.overallConsumingTransportsStatsMap[n.id];this.processConsumingTransportStats(n.id,B,_)}}break}case"remote-inbound-rtp":{const S=A,_={jitter:S.jitter,fractionLost:S.fractionLost,roundTripTime:S.roundTripTime,roundTripTimeMeasurements:S.roundTripTimeMeasurements,totalRoundTripTime:S.totalRoundTripTime,packetsLost:S.packetsLost};w.remoteInboundRtp.set(S.localId,_);break}case"outbound-rtp":{if(!this.outboundProducerMap.has(A.id))break;const S=A,_=s||this.outboundProducerMap.get(A.id),B=this.pausedProducerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedProducerMap.set(_,{lastReportCalculated:!0})}this.overallProducersStatsMap[_]||(this.overallProducersStatsMap[_]={totalVideoPacketsSent:0,totalAudioPacketsSent:0});const oe=this.overallProducersStatsMap[_];if(["video","audio"].includes(S.mediaType)||["video","audio"].includes(S.kind)){if(!this.outboundProducerMap.has(A.id)){w.staleProducerStreamMap=!0;break}const He=this.callStatsInstance.producers.get(_);if(((o=He==null?void 0:He.track)==null?void 0:o.readyState)==="ended")break;w.producerStreamMap.has(_)||w.producerStreamMap.set(_,{outboundVideoRtpId:[],outboundAudioRtpId:[]});const x={bytesSent:S.bytesSent,packetsSent:S.packetsSent,nackCount:S.nackCount,ssrc:S.ssrc,mid:S.mid,active:S.active,codecId:S.codecId,headerBytesSent:S.headerBytesSent||0,totalPacketSendDelay:S.totalPacketSendDelay||0};if(S.mediaType==="video"||S.kind==="video"){const R=S,ce=V({frameHeight:R.frameHeight,frameWidth:R.frameWidth,framesEncoded:R.framesEncoded,framesDropped:R.framesDropped?R.framesDropped:R.droppedFrames,framesPerSecond:R.framesPerSecond?R.framesPerSecond:R.framerateMean,framesSent:R.framesSent,keyFramesEncoded:R.keyFramesEncoded,firCount:R.firCount,encoderImplementation:R.encoderImplementation,hugeFramesSent:R.hugeFramesSent,pliCount:R.pliCount,qpSum:R.qpSum,qualityLimitationReason:R.qualityLimitationReason,qualityLimitationDurations:R.qualityLimitationDurations,qualityLimitationResolutionChanges:R.qualityLimitationResolutionChanges,totalEncodeTime:R.totalEncodeTime,totalPacketSendDelay:R.totalEncodeTime,retransmittedBytesSent:R.retransmittedBytesSent,retransmittedPacketsSent:R.retransmittedPacketsSent,scalabilityMode:R.scalabilityMode,powerEfficientEncoder:R.powerEfficientEncoder},x);w.outboundVideoRtp.set(A.id,ce),w.producerStreamMap.get(_).outboundVideoRtpId.push(A.id),this.processOutboundProducerVideoStats(_,oe,ce)}else if(S.mediaType==="audio"||S.kind==="audio"){const R=S,ce=V({retransmittedBytesSent:R.retransmittedBytesSent,retransmittedPacketsSent:R.retransmittedPacketsSent},x);w.outboundAudioRtp.set(A.id,ce),w.producerStreamMap.get(_).outboundAudioRtpId.push(A.id),this.processOutboundProducerAudioStats(_,oe,ce)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Outbound-rtp. mediatype: ${S.mediaType} kind: ${S.kind}`);break}case"inbound-rtp":{if(!this.inboundConsumerMap.has(A.id))break;const S=A,_=s||this.inboundConsumerMap.get(A.id),B=this.pausedConsumerMap.get(_);if(B){if(B.lastReportCalculated===!0)break;this.pausedConsumerMap.set(_,{lastReportCalculated:!0})}if(S.ssrc===1234)break;this.overallConsumersStatsMap[_]||(this.overallConsumersStatsMap[_]={totalVideoPacketsReceived:0,totalAudioPacketsReceived:0});const oe=this.overallConsumersStatsMap[_];if(["video","audio"].includes(S.mediaType)||["video","audio"].includes(S.kind)){if(!this.inboundConsumerMap.has(A.id)){w.staleConsumerStreamMap=!0;break}w.consumerStreamMap.has(_)||w.consumerStreamMap.set(_,{inboundVideoRtpId:[],inboundAudioRtpId:[]});const He={bytesReceived:S.bytesReceived,packetsReceived:S.packetsReceived,packetsLost:S.packetsLost>=0?S.packetsLost:0,jitter:S.jitter,nackCount:S.nackCount,jitterBufferDelay:S.jitterBufferDelay,jitterBufferEmittedCount:S.jitterBufferEmittedCount,lastPacketReceivedTimestamp:S.lastPacketReceivedTimestamp,ssrc:S.ssrc,mid:S.mid,codecId:S.codecId,headerBytesReceived:S.headerBytesReceived||0,packetsDiscarded:S.packetsDiscarded||0,jitterBufferMinimumDelay:S.jitterBufferMinimumDelay||0,jitterBufferTargetDelay:S.jitterBufferTargetDelay||0};if(S.mediaType==="video"||S.kind==="video"){const x=S,R=V({frameHeight:x.frameHeight,frameWidth:x.frameWidth,framesDecoded:x.framesDecoded,framesDropped:x.framesDropped?x.framesDropped:x.droppedFrames,framesPerSecond:x.framesPerSecond?x.framesPerSecond:x.framerateMean,framesReceived:x.framesReceived,keyFramesDecoded:x.keyFramesDecoded,firCount:x.firCount,decoderImplementation:x.decoderImplementation,pliCount:x.pliCount,totalProcessingDelay:x.totalProcessingDelay,qpSum:x.qpSum||0,totalAssemblyTime:x.totalAssemblyTime||0,totalDecodeTime:x.totalDecodeTime||0,totalFreezesDuration:x.totalFreezesDuration||0,totalInterFrameDelay:x.totalInterFrameDelay||0,totalPausesDuration:x.totalPausesDuration||0,totalSquaredInterFrameDelay:x.totalSquaredInterFrameDelay||0,freezeCount:x.freezeCount||0,pauseCount:x.pauseCount||0,powerEfficientDecoder:x.powerEfficientDecoder},He);R.score=Gf({frameWidth:R.frameWidth||0,framesDecoded:(R.framesDecoded||0)-(((c=this.videoConsumerToStatsMap.get(_))==null?void 0:c.framesDecoded)||0),framesPerSecond:R.framesPerSecond||0,packetsLost:(R.packetsLost||0)-(((d=this.videoConsumerToStatsMap.get(_))==null?void 0:d.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((l=this.videoConsumerToStatsMap.get(_))==null?void 0:l.packetsReceived)||0),jitter:R.jitter||0,isScreenShare:this.screenShareConsumers.has(_)}),jt.set(_,{score:+(R.score*10).toFixed(),frameWidth:R.frameWidth||0,frameHeight:R.frameHeight||0,framesPerSecond:R.framesPerSecond||0,packetsLostPercentage:qd({packetsLost:(R.packetsLost||0)-(((h=this.videoConsumerToStatsMap.get(_))==null?void 0:h.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((p=this.videoConsumerToStatsMap.get(_))==null?void 0:p.packetsReceived)||0)}),jitter:R.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((R.bytesReceived||0)-(((v=this.videoConsumerToStatsMap.get(_))==null?void 0:v.bytesReceived)||0))*8/7}),this.videoConsumerToStatsMap.set(_,R),w.inboundVideoRtp.set(A.id,R),w.consumerStreamMap.get(_).inboundVideoRtpId.push(A.id),this.processInboundConsumerVideoStats(_,oe,R)}else if(S.mediaType==="audio"||S.kind==="audio"){const x=S,R=V({audioLevel:x.audioLevel,concealedSamples:x.concealedSamples,concealmentEvents:x.concealmentEvents,totalAudioEnergy:x.totalAudioEnergy,totalSamplesDuration:x.totalSamplesDuration,totalSamplesReceived:x.totalSamplesReceived,fecPacketsDiscarded:x.fecPacketsDiscarded||0,fecPacketsReceived:x.fecPacketsReceived||0,insertedSamplesForDeceleration:x.insertedSamplesForDeceleration||0,removedSamplesForAcceleration:x.removedSamplesForAcceleration||0,silentConcealedSamples:x.silentConcealedSamples||0,playoutId:x.playoutId},He);R.score=qf({concealmentEvents:(R.concealmentEvents||0)-(((T=this.audioConsumerToStatsMap.get(_))==null?void 0:T.concealmentEvents)||0),packetsLost:(R.packetsLost||0)-(((E=this.audioConsumerToStatsMap.get(_))==null?void 0:E.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((C=this.audioConsumerToStatsMap.get(_))==null?void 0:C.packetsReceived)||0),jitter:R.jitter||0}),jt.set(_,{score:+(R.score*10).toFixed(),packetsLostPercentage:qd({packetsLost:(R.packetsLost||0)-(((b=this.audioConsumerToStatsMap.get(_))==null?void 0:b.packetsLost)||0),packetsReceived:(R.packetsReceived||0)-(((P=this.audioConsumerToStatsMap.get(_))==null?void 0:P.packetsReceived)||0)}),jitter:R.jitter||0,isScreenShare:this.screenShareConsumers.has(_),bitrate:((R.bytesReceived||0)-(((j=this.audioConsumerToStatsMap.get(_))==null?void 0:j.bytesReceived)||0))*8/7}),this.audioConsumerToStatsMap.set(_,R),w.inboundAudioRtp.set(A.id,R),w.consumerStreamMap.get(_).inboundAudioRtpId.push(A.id),this.processInboundConsumerAudioStats(_,oe,R)}}else this.callStatsInstance.logger.error(`Callstats: Unknown Inbound-rtp. mediatype: ${S.mediaType} kind: ${S.kind}`);break}}}if(w.producerStreamMap.forEach((A,S)=>{var _,B,oe,He,x,R,ce,Qi,Xi,Gr,oa,ca,da,la,ua,ha,pa,ma,ga,fa,va,ya,Sa;if(A.outboundVideoRtpId.length>0){const ge=[];A.outboundVideoRtpId.forEach(Ul=>{ge.push(w.outboundVideoRtp.get(Ul))});const se=this.getWorkingSimulcastVideoStats(ge);se.score=jf({frameWidth:se.frameWidth||0,framesPerSecond:se.framesPerSecond||0,jitter:((_=se.remoteData)==null?void 0:_.jitter)||0,isScreenShare:this.screenShareProducers.has(S),packetsSent:(se.packetsSent||0)-(((B=this.videoProducerToStatsMap.get(S))==null?void 0:B.packetsSent)||0),packetsLost:(((oe=se.remoteData)==null?void 0:oe.packetsLost)||0)-(((x=(He=this.videoProducerToStatsMap.get(S))==null?void 0:He.remoteData)==null?void 0:x.packetsLost)||0),framesEncoded:(se.framesEncoded||0)-(((R=this.videoProducerToStatsMap.get(S))==null?void 0:R.framesEncoded)||0)}),Xe.set(S,{score:+(se.score*10).toFixed(),frameWidth:se.frameWidth||0,frameHeight:se.frameHeight||0,framesPerSecond:se.framesPerSecond||0,jitter:((ce=se.remoteData)==null?void 0:ce.jitter)||0,isScreenShare:this.screenShareProducers.has(S),packetsLostPercentage:Hd({packetsSent:(se.packetsSent||0)-(((Qi=this.videoProducerToStatsMap.get(S))==null?void 0:Qi.packetsSent)||0),packetsLost:(((Xi=se.remoteData)==null?void 0:Xi.packetsLost)||0)-(((oa=(Gr=this.videoProducerToStatsMap.get(S))==null?void 0:Gr.remoteData)==null?void 0:oa.packetsLost)||0)}),bitrate:((se.bytesSent||0)-(((ca=this.videoProducerToStatsMap.get(S))==null?void 0:ca.bytesSent)||0))*8/7,cpuLimitations:se.qualityLimitationReason==="cpu",bandwidthLimitations:se.qualityLimitationReason==="bandwidth"}),this.videoProducerToStatsMap.set(S,se)}else if(A.outboundAudioRtpId.length>0){const ge=w.outboundAudioRtp.get(A.outboundAudioRtpId[0]);ge.score=Wf({packetsSent:(ge.packetsSent||0)-(((da=this.audioProducerToStatsMap.get(S))==null?void 0:da.packetsSent)||0),packetsLost:(((la=ge.remoteData)==null?void 0:la.packetsLost)||0)-(((ha=(ua=this.audioProducerToStatsMap.get(S))==null?void 0:ua.remoteData)==null?void 0:ha.packetsLost)||0),jitter:((pa=ge.remoteData)==null?void 0:pa.jitter)||0}),Xe.set(S,{score:+(ge.score*10).toFixed(),bitrate:((ge.bytesSent||0)-(((ma=this.audioProducerToStatsMap.get(S))==null?void 0:ma.bytesSent)||0))*8/7,packetsLostPercentage:Hd({packetsSent:(ge.packetsSent||0)-(((ga=this.audioProducerToStatsMap.get(S))==null?void 0:ga.packetsSent)||0),packetsLost:(((fa=ge.remoteData)==null?void 0:fa.packetsLost)||0)-(((ya=(va=this.audioProducerToStatsMap.get(S))==null?void 0:va.remoteData)==null?void 0:ya.packetsLost)||0)}),jitter:((Sa=ge.remoteData)==null?void 0:Sa.jitter)||0,isScreenShare:this.screenShareProducers.has(S)}),this.audioProducerToStatsMap.set(S,ge)}}),Me.forEach(A=>{const S=re.find(B=>B.id===A.localCandidateId?(A.localCandidateId=B.id,B):null),_=ae.find(B=>B.id===A.remoteCandidateId?(A.remoteCandidateId=B.id,B):null);S&&(A.localCandidateType=S.type,A.localCandidateAddress=qi(S.address),A.localCandidatePort=S.port,A.localCandidateProtocol=S.protocol,A.localCandidateUrl=S.url,A.localCandidateNetworkType=S.networkType,A.localCandidateRelatedAddress=qi(S.relatedAddress),A.localCandidateRelatedPort=S.relatedPort),_&&(A.remoteCandidateType=_.type,A.remoteCandidateAddress=qi(_.address),A.remoteCandidatePort=_.port,A.remoteCandidateProtocol=_.protocol,A.remoteCandidateUrl=_.url)}),w.candidatePair&&(w.transport?(w.transport.bytesReceived=w.candidatePair.bytesReceived,w.transport.bytesSent=w.candidatePair.bytesSent,w.transport.totalRoundTripTime=w.candidatePair.totalRoundTripTime,w.transport.availableOutgoingBitrate=w.candidatePair.availableOutgoingBitrate,w.transport.availableIncomingBitrate=w.candidatePair.availableIncomingBitrate,w.transport.roundTripTime=w.candidatePair.currentRoundTripTime):w.transport={bytesReceived:w.candidatePair.bytesReceived,bytesSent:w.candidatePair.bytesSent,totalRoundTripTime:w.candidatePair.totalRoundTripTime,availableOutgoingBitrate:w.candidatePair.availableOutgoingBitrate,availableIncomingBitrate:w.candidatePair.availableIncomingBitrate,roundTripTime:w.candidatePair.currentRoundTripTime}),w.transport&&(w.transport.candidatePairs=Me),w.transport&&!w.transport.roundTripTime){let A=0,S=0;w.remoteInboundRtp.forEach((_,B)=>{_.roundTripTime&&_.roundTripTime>A&&(A=_.roundTripTime,S=_.totalRoundTripTime)}),w.transport.roundTripTime=A,w.transport.totalRoundTripTime=S}if(jt.size>0)try{this.observer.emit("consumer_score",jt)}catch{}if(Xe.size>0)try{this.observer.emit("producer_score",Xe)}catch{}return w}getProducerStatsFromReport(e){const r=[];try{e.producerStreamMap.forEach((i,s)=>{const n=this.producerMap.get(s),o=n.track.getSettings(),c=i.outboundVideoRtpId.map(l=>{const h=e.outboundVideoRtp.get(l);return h.frameHeight||(h.frameHeight=o.height,h.frameWidth=o.width,h.framesPerSecond=o.frameRate),h}),d={producerId:s,appData:n.appData,videoStats:c,audioStats:i.outboundAudioRtpId.map(l=>e.outboundAudioRtp.get(l))};r.push(d)})}catch(i){console.error("getProducersReport: ",i,e)}return r}getConsumerStatsFromParsedConsumerStats(e,r,i){let s;try{const{peerId:n,producerId:o,appData:c}=this.consumerPeerIdMap.get(i),d=r==null?void 0:r.inboundVideoRtpId.map(l=>{const h=this.consumerMap.get(i).track.getSettings(),p=e.inboundVideoRtp.get(l);return p.frameHeight||(p.frameHeight=h.height,p.frameWidth=h.width,p.framesPerSecond=h.frameRate),p});s={consumerId:i,peerId:n,producerId:o,appData:c,videoStats:d,audioStats:r==null?void 0:r.inboundAudioRtpId.map(l=>e.inboundAudioRtp.get(l))}}catch(n){console.error("getConsumerStatsFromParsedConsumerStats: ",n,e)}return s}getConsumerStatsFromReport(e){const r=[];try{e.consumerStreamMap.forEach((i,s)=>{r.push(this.getConsumerStatsFromParsedConsumerStats(e,i,s))})}catch(i){console.error("getConsumerStatsFromReport: ",i,e)}return r}}class qT extends zf{}function Gd(t,e,r,i){if(t!=null&&t.logger&&t.logger.error("Callstats::handleError",{error:i}),typeof r=="function"&&i instanceof e)r.call(null,i,t);else throw i}function Kp(t,e,r){const i=t.value;return t.value=function(...s){try{const n=i.apply(this,s);return n&&n instanceof Promise?n.catch(o=>{Gd(this,e,r,o)}):n}catch(n){Gd(this,e,r,n)}return null},t}const Z=(t,e)=>(r,i,s)=>{const n=s.value;return s.value=function(...o){try{const c=n.apply(this,o);return c&&c instanceof Promise?c.catch(d=>{Gd(this,t,e,d)}):c}catch(c){Gd(this,t,e,c)}return null},s},GT=(t,e)=>(r,i,s)=>{if(s)return Kp(s,t,e);for(const n of Reflect.ownKeys(r.prototype).filter(o=>o!=="constructor")){const o=Object.getOwnPropertyDescriptor(r.prototype,n);o.value instanceof Function&&Object.defineProperty(r.prototype,n,Kp(o,t,e))}};var Y=globalThis&&globalThis.__decorate||function(t,e,r,i){var s=arguments.length,n=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,r,i);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(n=(s<3?o(n):s>3?o(e,r,n):o(e,r))||n);return s>3&&n&&Object.defineProperty(e,r,n),n};const Q=console;let K=class extends gt{constructor(t="https://api.testingv3.dyte.in",e="Blink",r=Do.PROD,i,s,n,o){switch(super(),m(this,"observer"),m(this,"eventHandler"),m(this,"measurements"),m(this,"producingTransport"),m(this,"consumingTransport"),m(this,"producers",new Map),m(this,"consumers",new Map),m(this,"iceServers"),m(this,"connectionInfoPromise"),m(this,"pingStatsTimeout"),m(this,"logger"),m(this,"env"),m(this,"apiHostnames"),m(this,"peerId"),m(this,"consumerSharedMediaStatesMap",new Map),m(this,"currentUserMediaStates",{}),this.env=r,this.apiHostnames=o,this.logger=s,this.peerId=n,this.eventHandler=new RT({logger:s,peerId:n,apiHostnames:o}),this.logger.debug("callStats::engineName: ",{engineName:e}),e){case"Blink":this.measurements=new HT;break;case"Gecko":this.measurements=new zf;break;case"WebKit":this.measurements=new qT;break;default:throw Error(`Unknown engineName! ${e}`)}this.measurements.callStatsInstance=this,this.registerProducer=this.registerProducer.bind(this),this.registerConsumer=this.registerConsumer.bind(this),this.observer=new gt,this.measurements.observer.on("consumer_score",c=>{s.debug(`callStats::consumer_score ${[...c.entries()]}`),this.eventHandler.emit("consumer_score",c)}),this.measurements.observer.on("producer_score",c=>{s.debug(`callStats::producer_score ${[...c.entries()]}`),this.eventHandler.emit("producer_score",c)})}registerIceServers(t){this.iceServers=t}registerConsumer(t){var e;this.consumerSharedMediaStatesMap.has(t.id)||this.consumerSharedMediaStatesMap.set(t.id,{}),this.consumers.set(t.id,t),this.measurements.registerConsumer(t),this.logger.debug("callStats::registerConsumer",{consumerId:t.id,consumerkind:t.kind,isScreenShare:!!((e=t.appData)!=null&&e.screenShare)}),t.on("close",this.deRegisterConsumer.bind(this,t))}registerProducer(t){var e;this.producers.set(t.id,t),this.measurements.registerProducer(t),this.logger.debug("callStats::registerProducer",{producerId:t.id,producerKind:t.kind,isScreenShare:!!((e=t.appData)!=null&&e.screenShare)}),t.on("close",this.deRegisterProducer.bind(this,t))}sendConsumerSharedMediaStateEvent(t,e){this.consumerSharedMediaStatesMap.has(t)||this.consumerSharedMediaStatesMap.set(t,{});const r=this.consumerSharedMediaStatesMap.get(t);this.consumerSharedMediaStatesMap.set(t,Object.assign(r,e))}registerProducingTransport(t){var e;this.producingTransport=t,t.on("close",this.disconnectProducingTransport.bind(this,t)),t.on("disconnect",this.disconnectProducingTransport.bind(this,t)),Array.from(((e=t._producers)==null?void 0:e.values())||[]).forEach(r=>{this.registerProducer(r)}),t.on("newproducer",this.registerProducer)}registerConsumingTransport(t){var e;this.consumingTransport=t,t.on("close",this.disconnectConsumingTransport.bind(this,t)),t.on("disconnect",this.disconnectConsumingTransport.bind(this,t)),Array.from(((e=t._consumers)==null?void 0:e.values())||[]).forEach(r=>{this.registerConsumer(r)}),t.on("newconsumer",this.registerConsumer)}deRegisterConsumer(t){this.consumers.delete(t.id)}deRegisterProducer(t){var e;this.producers.delete(t.id),this.logger.debug("callStats::deRegisterProducer",{producerId:t.id,producerKind:t.kind,isScreenShare:!!((e=t.appData)!=null&&e.screenShare)})}disconnectConsumingTransport(){this.consumingTransport=void 0}disconnectProducingTransport(){this.producingTransport=void 0}callEvent(t){this.eventHandler.callEvent(t)}sendPreCallTestBeginEvent(t=!1,e){this.connectionInfoPromise=this.measurements.getNetworkInfo(this.iceServers,t),this.eventHandler.callEvent({event:L.PRECALL_TEST_BEGIN,timestamp:e}),this.connectionInfoPromise&&this.connectionInfoPromise.then(r=>{this.eventHandler.callEvent({event:L.PRECALL_TEST_COMPLETE,metaData:{connectionInfo:r},timestamp:e})})}sendScreenShareToggleEvent(t,e=null,r){this.currentUserMediaStates.screen=t,this.eventHandler.callEvent({event:t?L.SCREENSHARE_STARTED:L.SCREENSHARE_STOPPED,metaData:{ssrc:e},timestamp:r})}sendScreenShareRequestedEvent(t){this.eventHandler.callEvent({event:L.SCREENSHARE_START_REQUESTED,timestamp:t})}sendActiveSpeakerEvent(t,e){this.eventHandler.callEvent({event:L.DOMINANT_SPEAKER,metaData:{peerId:t},timestamp:e})}devices(t,e,r){this.eventHandler.callEvent({event:t===or.AUDIO&&L.AUDIO_DEVICES_UPDATES||t===or.VIDEO&&L.VIDEO_DEVICES_UPDATES||t===or.SPEAKER&&L.SPEAKER_DEVICES_UPDATES,metaData:{deviceList:e},timestamp:r})}selectedDevice(t,e,r){this.eventHandler.callEvent({event:t===or.AUDIO&&L.SELECTED_MICROHPONE_UPDATE||t===or.VIDEO&&L.SELECTED_CAMERA_UPDATE||t===or.SPEAKER&&L.SELECTED_SPEAKER_UPDATE,metaData:{device:e},timestamp:r})}mediaPermission(t,e,r){this.eventHandler.callEvent({event:L.MEDIA_PERMISSION,metaData:{deviceType:t,permission:e},timestamp:r})}mediaPlaybackFailed(t,e){this.eventHandler.callEvent({event:t===or.AUDIO&&L.AUDIO_PLAY_FAILED||t===or.VIDEO&&L.VIDEO_PLAY_FAILED,metaData:{deviceType:t},timestamp:e})}mediaTrackMuted(t,e){this.eventHandler.callEvent({event:t===or.AUDIO&&L.AUDIO_TRACK_MUTED||t===or.VIDEO&&L.VIDEO_TRACK_MUTED,metaData:{deviceType:t},timestamp:e})}tabChanged(t,e){this.eventHandler.callEvent({event:L.TAB_CHANGE,metaData:{isMeetingsTabActive:t},timestamp:e})}browserBackgrounded(t){this.eventHandler.callEvent({event:L.BROWSER_BACKGROUNDED,timestamp:t})}browserForegrounded(t){this.eventHandler.callEvent({event:L.BROWSER_FOREGROUNDED,timestamp:t})}legacySwitch(t,e){this.eventHandler.callEvent({event:L.LEGACY_SWITCH,metadata:{on:t},timestamp:e})}getPreCallTestResults(){return u(this,null,function*(){return this.connectionInfoPromise})}sendCallJoinBeginEvent(t,e){t=G(V({},t),{meetingEnv:this.env}),t.deviceInfo=G(V({},t.deviceInfo),{userAgent:navigator.userAgent,cpus:navigator.hardwareConcurrency,memory:navigator.deviceMemory}),this.eventHandler.callEvent({event:L.CALL_JOIN_BEGIN,metaData:{peerMetaData:t},timestamp:e})}sendNetworkQualityTestBeginEvent(t,e){this.eventHandler.callEvent({event:L.NET_QUALITY_TEST_BEGIN,timestamp:e}),new Promise((r,i)=>u(this,null,function*(){const s=[];try{for(const n of t)try{if(n.iceServers&&n.iceServers.length>0){const o=yield this.measurements.getNetworkQuality(n.iceServers);s.push(G(V({},n),{networkResults:o}))}}catch(o){console.warn("Error handling ",o)}r({regionData:s})}catch(n){console.warn("Error in callstats, ",n),i(n)}})).then(r=>{this.eventHandler.callEvent({event:L.NET_QUALITY_TEST_END,timestamp:e,metaData:r})})}sendWebSocketConnectedEvent(t){this.eventHandler.callEvent({event:L.WEBSOCKET_CONNECTED,timestamp:t})}sendTransportConnectedEvent(t){this.eventHandler.callEvent({event:L.TRANSPORT_CONNECTED,timestamp:t})}sendAudioToggleEvent(t,e){this.currentUserMediaStates.audio=t;let r;t?r=L.AUDIO_ON:r=L.AUDIO_OFF,this.eventHandler.callEvent({event:r,timestamp:e})}sendVideoToggleEvent(t,e){this.currentUserMediaStates.video=t;let r;t?r=L.VIDEO_ON:r=L.VIDEO_OFF,this.eventHandler.callEvent({event:r,timestamp:e})}sendParticipantRoleToggleEvent(t,e){this.eventHandler.callEvent({event:L.PARTICIPANT_ROLE,timestamp:e,metaData:t})}startPingStats(t=7e3){this.sendPingStatsEvent(!1,new Date),this.pingStatsTimeout=setInterval(this.sendPingStatsEvent.bind(this),t)}stopPingStats(){clearInterval(this.pingStatsTimeout)}sendPingStatsEvent(t=!0,e){return u(this,null,function*(){let r,i;if(this.producingTransport&&(r=yield this.measurements.getProcessedStats(this.producingTransport,!1,!0),!r||!(r!=null&&r.producerReport))){this.logger.debug("callStats::sendPingStatsEvent::staleProducingTransport",{disclaimer:"Stale producer? Regenerating Stream Maps!"});const n=yield this.measurements.getProducersReport([...this.producers.values()]);r&&n?r.producerReport=n:(r=yield this.measurements.getProcessedStats(this.producingTransport,!1,!0),(!r||!(r!=null&&r.producerReport))&&this.logger.debug("callStats::sendPingStatsEvent::noProducingTransportReport",{disclaimer:"Stream maps invalid despite regenerating!"}))}if(this.consumingTransport&&(i=yield this.measurements.getProcessedStats(this.consumingTransport,!0,!1),!i||!i.consumerReport)){this.logger.debug("callStats::sendPingStatsEvent::staleConsumingTransport",{disclaimer:"Stale consumer? Regenerating Stream Maps!"});const n=yield this.measurements.getConsumersReport([...this.consumers.values()]);i&&n?i.consumerReport=n:(i=yield this.measurements.getProcessedStats(this.consumingTransport,!0,!1),(!i||!i.consumerReport)&&this.logger.debug("callStats::sendPingStatsEvent::noConsumingTransportReport",{disclaimer:"Stream maps invalid despite regenerating!"}))}const s={producingTransportStats:r?r==null?void 0:r.transportReport:void 0,consumingTransportStats:i?i==null?void 0:i.transportReport:void 0,producerStats:[].concat((r==null?void 0:r.producerReport)||[]).concat((i==null?void 0:i.producerReport)||[]),consumerStats:[].concat((i==null?void 0:i.consumerReport)||[]).concat((r==null?void 0:r.consumerReport)||[])};if(t&&s.producerStats.length===0&&s.consumerStats.length===0){yield this.eventHandler.flush();return}this.eventHandler.callEvent({event:L.PING_STAT,metaData:s,timestamp:e})})}sendIVSPlayerRebufferEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_REBUFFERING,timestamp:t})}sendIVSPlayerAudioBlockEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_AUDIO_BLOCKED,timestamp:t})}sendIVSPlayerPlaybackBlockedEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_PLAYBACK_BLOCKED,timestamp:t})}sendIVSPlayerNetworkUnavailableEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_NETWORK_UNAVAILABLE,timestamp:t})}sendIVSPlayerInitializedEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_INITIALIZED,timestamp:t})}sendIVSPlayerWorkerErrorEvent(t){this.eventHandler.callEvent({event:L.IVS_PLAYER_WORKER_ERROR,timestamp:t})}sendIVSPlayerErrorEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_ERROR,timestamp:e,metaData:t})}sendIVSPlayerRecoverableErrorEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_RECOVERABLE_ERROR,timestamp:e,metaData:t})}sendIVSPlayerAnalyticsEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_ANALYTICS_EVENT,timestamp:e,metaData:t})}sendIVSPlayerPlaybackRateChangedEvent(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_PLAYBACK_RATE_CHANGED,timestamp:e,metaData:{updatedPlaybackRate:t}})}sendIVSPlayerQualityChanged(t,e){this.eventHandler.callEvent({event:L.IVS_PLAYER_QUALITY_CHANGED,timestamp:e,metaData:t})}sendPlayerLiveLatency(t,e){this.eventHandler.callEvent({event:L.LIVESTREAM_LATENCY,timestamp:e,metaData:{latency:t}})}sendDisconnectEvent(t){this.eventHandler.callEvent({event:L.DISCONNECT,timestamp:t})}sendReconnectEvent(t){this.eventHandler.callEvent({event:L.RECONNECT_ATTEMPT,timestamp:t})}expectedVideoResolution(t,e,r){this.eventHandler.callEvent({event:L.EXPECTED_VIDEO_RESOLUTION,timestamp:r,metaData:{frameWidth:t,frameHeight:e}})}expectedScreenshareResolution(t,e,r){this.eventHandler.callEvent({event:L.EXPECTED_SCREENSHARE_RESOLUTION,timestamp:r,metaData:{frameWidth:t,frameHeight:e}})}};Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerIceServers",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerConsumer",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerProducer",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendConsumerSharedMediaStateEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerProducingTransport",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"registerConsumingTransport",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"deRegisterConsumer",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"deRegisterProducer",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"disconnectConsumingTransport",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"disconnectProducingTransport",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendPreCallTestBeginEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendScreenShareToggleEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendScreenShareRequestedEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendActiveSpeakerEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"devices",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"selectedDevice",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"mediaPermission",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"mediaPlaybackFailed",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"mediaTrackMuted",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"tabChanged",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"browserBackgrounded",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"browserForegrounded",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"legacySwitch",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"getPreCallTestResults",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendCallJoinBeginEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendNetworkQualityTestBeginEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendWebSocketConnectedEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendTransportConnectedEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendAudioToggleEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendVideoToggleEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendParticipantRoleToggleEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"startPingStats",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"stopPingStats",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendPingStatsEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerRebufferEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerAudioBlockEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerPlaybackBlockedEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerNetworkUnavailableEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerInitializedEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerWorkerErrorEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerErrorEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerRecoverableErrorEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerAnalyticsEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerPlaybackRateChangedEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendIVSPlayerQualityChanged",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendPlayerLiveLatency",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendDisconnectEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"sendReconnectEvent",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"expectedVideoResolution",null);Y([Z(TypeError,(t,e)=>Q.error(e,t))],K.prototype,"expectedScreenshareResolution",null);K=Y([GT(TypeError,(t,e)=>Q.error(e,t))],K);const $T=K;class Yf extends gt{constructor(){super(...arguments),m(this,"stats"),m(this,"peerId"),m(this,"backend"),m(this,"iceServers"),m(this,"initialized",!1),m(this,"stalled",!1),m(this,"ipInformation"),m(this,"logger")}initialize(e){return u(this,arguments,function*({peerId:r,engineName:i,env:s=Do.PROD,iceServers:n,apiBase:o="https://api.cluster.dyte.in",flags:c,logger:d=console,apiHostnames:l,skipConnectivityChecks:h=!1}){var p,v,T;try{this.peerId=r,this.logger=d,this.ipInformation=yield ep.getIPDetails({peerId:r,apiHostnames:l,logger:d}),this.backend=new $T(o,i,s,c,d,r,l),this.iceServers=n,(p=this.backend)==null||p.registerIceServers(this.iceServers),this.initialized=!0,(T=(v=this.backend)==null?void 0:v.eventHandler)==null||T.emit("initialized",this.ipInformation),this.emit("initialized",this.ipInformation),this.startPreCallTest(h)}catch(E){this.logger.error("callStats::CallStatsIntegration: ",{error:E}),this.stallCallStats()}})}configureSendTransport(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.registerProducingTransport(e)})}configureRecvTransport(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.registerConsumingTransport(e)})}candidateRegionalNetworkQualityTest(e){return u(this,null,function*(){const r=new Date;this.onSafeInitialization(()=>{var i;try{(i=this.backend)==null||i.sendNetworkQualityTestBeginEvent(e,r)}catch(s){this.logger.error("callStats::sendNetworkQualityTestBeginEvent",{error:{reason:s.reason}})}})})}roomJoined(e){return u(this,null,function*(){const r=new Date;this.onSafeInitialization(()=>{var i,s;(i=this.backend)==null||i.sendCallJoinBeginEvent(e,r),this.backend,(s=this.backend)==null||s.startPingStats()})})}audioOff(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendAudioToggleEvent(!1,e)})}audioOn(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendAudioToggleEvent(!0,e)})}videoOff(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendVideoToggleEvent(!1,e)})}videoOn(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendVideoToggleEvent(!0,e)})}callEnded(){const e=new Date;this.onSafeInitialization(()=>{var r,i;(r=this.backend)==null||r.stopPingStats(),(i=this.backend)==null||i.sendDisconnectEvent(e)})}screenShareStart(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendScreenShareToggleEvent(!0,e,r)})}consumerSharedMediaState(e,r){this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendConsumerSharedMediaStateEvent(e,r)})}screenShareStop(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendScreenShareToggleEvent(!1,e,r)})}screenShareRequested(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.sendScreenShareRequestedEvent(e)})}activeSpeaker(e){if(e!==this.peerId)return;const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendActiveSpeakerEvent(e,r)})}devices(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.devices(e,r,i)})}selectedDevice(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.selectedDevice(e,r,i)})}mediaPermission(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.mediaPermission(e,r,i)})}mediaPlaybackFailed(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.mediaPlaybackFailed(e,r)})}mediaTrackMuted(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.mediaTrackMuted(e,r)})}tabChanged(e=!1){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.tabChanged(e,r)})}browserBackgrounded(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.browserBackgrounded(e)})}browserForegrounded(){const e=new Date;this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.browserForegrounded(e)})}legacySwitch(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.legacySwitch(e,r)})}startPreCallTest(e=!1){return u(this,null,function*(){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendPreCallTestBeginEvent(e,r)})})}onPreCallTestResults(e){return this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.once("precall_end",e)}),e}onReceivingConsumerAudioStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consumer_audio_status",e)})}onReceivingConsumerVideoStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consumer_video_status",e)})}onReceivingProducerAudioStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producer_audio_status",e)})}onReceivingProducerVideoStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producer_video_status",e)})}onReceivingProducingTransportStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producing_transport_status",e)})}onReceivingConsumingTransportStatus(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consuming_transport_status",e)})}onProducerScore(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("producer_score",e)})}onConsumerScore(e){this.onSafeInitialization(()=>{var r;(r=this.backend)==null||r.eventHandler.on("consumer_score",e)})}onSafeInitialization(e){if(this.initialized)e(this.ipInformation,!1);else if(!this.stalled){const r=i=>{e(i,!0)};return this.once("initialized",r),r}return()=>{}}removeInitializationListener(e){this.removeListener("initialized",e)}stallCallStats(){this.stalled=!0,this.removeAllListeners("initialized")}ivsPlayerEvent(e,r){const i=new Date;this.onSafeInitialization(()=>{var s,n,o,c,d,l,h,p,v,T,E;switch(e){case"PlayerRebuffering":(s=this.backend)==null||s.sendIVSPlayerRebufferEvent(i);break;case"PlayerAudioBlocked":(n=this.backend)==null||n.sendIVSPlayerAudioBlockEvent(i);break;case"PlayerPlaybackBlocked":(o=this.backend)==null||o.sendIVSPlayerPlaybackBlockedEvent(i);break;case"PlayerNetworkUnavailable":(c=this.backend)==null||c.sendIVSPlayerNetworkUnavailableEvent(i);break;case"PlayerInitialized":(d=this.backend)==null||d.sendIVSPlayerInitializedEvent(i);break;case"PlayerWorkerError":(l=this.backend)==null||l.sendIVSPlayerWorkerErrorEvent(i);break;case"PlayerError":(h=this.backend)==null||h.sendIVSPlayerErrorEvent(r,i);break;case"PlayerRecoverableError":(p=this.backend)==null||p.sendIVSPlayerRecoverableErrorEvent(r,i);break;case"PlayerAnalyticsEvent":(v=this.backend)==null||v.sendIVSPlayerAnalyticsEvent(r,i);break;case"PlayerPlaybackRateChanged":(T=this.backend)==null||T.sendIVSPlayerPlaybackRateChangedEvent(r,i);break;case"PlayerQualityChanged":(E=this.backend)==null||E.sendIVSPlayerQualityChanged(r,i);break}})}livestreamLatency(e){const r=new Date;this.onSafeInitialization(()=>{var i;(i=this.backend)==null||i.sendPlayerLiveLatency(e,r)})}expectedVideoResolution(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.expectedVideoResolution(e,r,i)})}expectedScreenshareResolution(e,r){const i=new Date;this.onSafeInitialization(()=>{var s;(s=this.backend)==null||s.expectedScreenshareResolution(e,r,i)})}}const JT=new Yf;JT.setMaxListeners(30);function KT(){this.__data__=[],this.size=0}function Xo(t,e){return t===e||t!==t&&e!==e}function kl(t,e){for(var r=t.length;r--;)if(Xo(t[r][0],e))return r;return-1}var zT=Array.prototype,YT=zT.splice;function QT(t){var e=this.__data__,r=kl(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():YT.call(e,r,1),--this.size,!0}function XT(t){var e=this.__data__,r=kl(e,t);return r<0?void 0:e[r][1]}function ZT(t){return kl(this.__data__,t)>-1}function ek(t,e){var r=this.__data__,i=kl(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}function hi(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}hi.prototype.clear=KT;hi.prototype.delete=QT;hi.prototype.get=XT;hi.prototype.has=ZT;hi.prototype.set=ek;function tk(){this.__data__=new hi,this.size=0}function rk(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}function ik(t){return this.__data__.get(t)}function sk(t){return this.__data__.has(t)}var nk=typeof global=="object"&&global&&global.Object===Object&&global;const Qf=nk;var ak=typeof self=="object"&&self&&self.Object===Object&&self,ok=Qf||ak||Function("return this")();const Cr=ok;var ck=Cr.Symbol;const $i=ck;var Xf=Object.prototype,dk=Xf.hasOwnProperty,lk=Xf.toString,ka=$i?$i.toStringTag:void 0;function uk(t){var e=dk.call(t,ka),r=t[ka];try{t[ka]=void 0;var i=!0}catch{}var s=lk.call(t);return i&&(e?t[ka]=r:delete t[ka]),s}var hk=Object.prototype,pk=hk.toString;function mk(t){return pk.call(t)}var gk="[object Null]",fk="[object Undefined]",zp=$i?$i.toStringTag:void 0;function Us(t){return t==null?t===void 0?fk:gk:zp&&zp in Object(t)?uk(t):mk(t)}function Ir(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var vk="[object AsyncFunction]",yk="[object Function]",Sk="[object GeneratorFunction]",Tk="[object Proxy]";function tp(t){if(!Ir(t))return!1;var e=Us(t);return e==yk||e==Sk||e==vk||e==Tk}var kk=Cr["__core-js_shared__"];const Hl=kk;var Yp=function(){var t=/[^.]+$/.exec(Hl&&Hl.keys&&Hl.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Ek(t){return!!Yp&&Yp in t}var bk=Function.prototype,wk=bk.toString;function Fs(t){if(t!=null){try{return wk.call(t)}catch{}try{return t+""}catch{}}return""}var _k=/[\\^$.*+?()[\]{}|]/g,Ik=/^\[object .+?Constructor\]$/,Ck=Function.prototype,Pk=Object.prototype,Rk=Ck.toString,Mk=Pk.hasOwnProperty,Ak=RegExp("^"+Rk.call(Mk).replace(_k,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Dk(t){if(!Ir(t)||Ek(t))return!1;var e=tp(t)?Ak:Ik;return e.test(Fs(t))}function Ok(t,e){return t==null?void 0:t[e]}function Bs(t,e){var r=Ok(t,e);return Dk(r)?r:void 0}var Nk=Bs(Cr,"Map");const zo=Nk;var Vk=Bs(Object,"create");const Yo=Vk;function Lk(){this.__data__=Yo?Yo(null):{},this.size=0}function xk(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Uk="__lodash_hash_undefined__",Fk=Object.prototype,Bk=Fk.hasOwnProperty;function Wk(t){var e=this.__data__;if(Yo){var r=e[t];return r===Uk?void 0:r}return Bk.call(e,t)?e[t]:void 0}var jk=Object.prototype,Hk=jk.hasOwnProperty;function qk(t){var e=this.__data__;return Yo?e[t]!==void 0:Hk.call(e,t)}var Gk="__lodash_hash_undefined__";function $k(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Yo&&e===void 0?Gk:e,this}function Ns(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}Ns.prototype.clear=Lk;Ns.prototype.delete=xk;Ns.prototype.get=Wk;Ns.prototype.has=qk;Ns.prototype.set=$k;function Jk(){this.size=0,this.__data__={hash:new Ns,map:new(zo||hi),string:new Ns}}function Kk(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function El(t,e){var r=t.__data__;return Kk(e)?r[typeof e=="string"?"string":"hash"]:r.map}function zk(t){var e=El(this,t).delete(t);return this.size-=e?1:0,e}function Yk(t){return El(this,t).get(t)}function Qk(t){return El(this,t).has(t)}function Xk(t,e){var r=El(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}function Ws(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}Ws.prototype.clear=Jk;Ws.prototype.delete=zk;Ws.prototype.get=Yk;Ws.prototype.has=Qk;Ws.prototype.set=Xk;var Zk=200;function eE(t,e){var r=this.__data__;if(r instanceof hi){var i=r.__data__;if(!zo||i.length<Zk-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new Ws(i)}return r.set(t,e),this.size=r.size,this}function Hr(t){var e=this.__data__=new hi(t);this.size=e.size}Hr.prototype.clear=tk;Hr.prototype.delete=rk;Hr.prototype.get=ik;Hr.prototype.has=sk;Hr.prototype.set=eE;function tE(t,e){for(var r=-1,i=t==null?0:t.length;++r<i&&e(t[r],r,t)!==!1;);return t}var rE=function(){try{var t=Bs(Object,"defineProperty");return t({},"",{}),t}catch{}}();const $d=rE;function rp(t,e,r){e=="__proto__"&&$d?$d(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var iE=Object.prototype,sE=iE.hasOwnProperty;function Zf(t,e,r){var i=t[e];(!(sE.call(t,e)&&Xo(i,r))||r===void 0&&!(e in t))&&rp(t,e,r)}function Zo(t,e,r,i){var s=!r;r||(r={});for(var n=-1,o=e.length;++n<o;){var c=e[n],d=i?i(r[c],t[c],c,r,t):void 0;d===void 0&&(d=t[c]),s?rp(r,c,d):Zf(r,c,d)}return r}function nE(t,e){for(var r=-1,i=Array(t);++r<t;)i[r]=e(r);return i}function qr(t){return t!=null&&typeof t=="object"}var aE="[object Arguments]";function Qp(t){return qr(t)&&Us(t)==aE}var ev=Object.prototype,oE=ev.hasOwnProperty,cE=ev.propertyIsEnumerable,dE=Qp(function(){return arguments}())?Qp:function(t){return qr(t)&&oE.call(t,"callee")&&!cE.call(t,"callee")};const Jd=dE;var lE=Array.isArray;const Ji=lE;function uE(){return!1}var tv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Xp=tv&&typeof module=="object"&&module&&!module.nodeType&&module,hE=Xp&&Xp.exports===tv,Zp=hE?Cr.Buffer:void 0,pE=Zp?Zp.isBuffer:void 0,mE=pE||uE;const Yn=mE;var gE=9007199254740991,fE=/^(?:0|[1-9]\d*)$/;function rv(t,e){var r=typeof t;return e=e==null?gE:e,!!e&&(r=="number"||r!="symbol"&&fE.test(t))&&t>-1&&t%1==0&&t<e}var vE=9007199254740991;function iv(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=vE}var yE="[object Arguments]",SE="[object Array]",TE="[object Boolean]",kE="[object Date]",EE="[object Error]",bE="[object Function]",wE="[object Map]",_E="[object Number]",IE="[object Object]",CE="[object RegExp]",PE="[object Set]",RE="[object String]",ME="[object WeakMap]",AE="[object ArrayBuffer]",DE="[object DataView]",OE="[object Float32Array]",NE="[object Float64Array]",VE="[object Int8Array]",LE="[object Int16Array]",xE="[object Int32Array]",UE="[object Uint8Array]",FE="[object Uint8ClampedArray]",BE="[object Uint16Array]",WE="[object Uint32Array]",_e={};_e[OE]=_e[NE]=_e[VE]=_e[LE]=_e[xE]=_e[UE]=_e[FE]=_e[BE]=_e[WE]=!0;_e[yE]=_e[SE]=_e[AE]=_e[TE]=_e[DE]=_e[kE]=_e[EE]=_e[bE]=_e[wE]=_e[_E]=_e[IE]=_e[CE]=_e[PE]=_e[RE]=_e[ME]=!1;function jE(t){return qr(t)&&iv(t.length)&&!!_e[Us(t)]}function ip(t){return function(e){return t(e)}}var sv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oo=sv&&typeof module=="object"&&module&&!module.nodeType&&module,HE=Oo&&Oo.exports===sv,ql=HE&&Qf.process,qE=function(){try{var t=Oo&&Oo.require&&Oo.require("util").types;return t||ql&&ql.binding&&ql.binding("util")}catch{}}();const Qn=qE;var em=Qn&&Qn.isTypedArray,GE=em?ip(em):jE;const bl=GE;var $E=Object.prototype,JE=$E.hasOwnProperty;function nv(t,e){var r=Ji(t),i=!r&&Jd(t),s=!r&&!i&&Yn(t),n=!r&&!i&&!s&&bl(t),o=r||i||s||n,c=o?nE(t.length,String):[],d=c.length;for(var l in t)(e||JE.call(t,l))&&!(o&&(l=="length"||s&&(l=="offset"||l=="parent")||n&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||rv(l,d)))&&c.push(l);return c}var KE=Object.prototype;function wl(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||KE;return t===r}function av(t,e){return function(r){return t(e(r))}}var zE=av(Object.keys,Object);const YE=zE;var QE=Object.prototype,XE=QE.hasOwnProperty;function ov(t){if(!wl(t))return YE(t);var e=[];for(var r in Object(t))XE.call(t,r)&&r!="constructor"&&e.push(r);return e}function ec(t){return t!=null&&iv(t.length)&&!tp(t)}function sp(t){return ec(t)?nv(t):ov(t)}function ZE(t,e){return t&&Zo(e,sp(e),t)}function eb(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var tb=Object.prototype,rb=tb.hasOwnProperty;function ib(t){if(!Ir(t))return eb(t);var e=wl(t),r=[];for(var i in t)i=="constructor"&&(e||!rb.call(t,i))||r.push(i);return r}function tc(t){return ec(t)?nv(t,!0):ib(t)}function sb(t,e){return t&&Zo(e,tc(e),t)}var cv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tm=cv&&typeof module=="object"&&module&&!module.nodeType&&module,nb=tm&&tm.exports===cv,rm=nb?Cr.Buffer:void 0,im=rm?rm.allocUnsafe:void 0;function dv(t,e){if(e)return t.slice();var r=t.length,i=im?im(r):new t.constructor(r);return t.copy(i),i}function lv(t,e){var r=-1,i=t.length;for(e||(e=Array(i));++r<i;)e[r]=t[r];return e}function ab(t,e){for(var r=-1,i=t==null?0:t.length,s=0,n=[];++r<i;){var o=t[r];e(o,r,t)&&(n[s++]=o)}return n}function uv(){return[]}var ob=Object.prototype,cb=ob.propertyIsEnumerable,sm=Object.getOwnPropertySymbols,db=sm?function(t){return t==null?[]:(t=Object(t),ab(sm(t),function(e){return cb.call(t,e)}))}:uv;const np=db;function lb(t,e){return Zo(t,np(t),e)}function hv(t,e){for(var r=-1,i=e.length,s=t.length;++r<i;)t[s+r]=e[r];return t}var ub=av(Object.getPrototypeOf,Object);const ap=ub;var hb=Object.getOwnPropertySymbols,pb=hb?function(t){for(var e=[];t;)hv(e,np(t)),t=ap(t);return e}:uv;const pv=pb;function mb(t,e){return Zo(t,pv(t),e)}function mv(t,e,r){var i=e(t);return Ji(t)?i:hv(i,r(t))}function Vu(t){return mv(t,sp,np)}function gb(t){return mv(t,tc,pv)}var fb=Bs(Cr,"DataView");const Lu=fb;var vb=Bs(Cr,"Promise");const xu=vb;var yb=Bs(Cr,"Set");const Uu=yb;var Sb=Bs(Cr,"WeakMap");const Fu=Sb;var nm="[object Map]",Tb="[object Object]",am="[object Promise]",om="[object Set]",cm="[object WeakMap]",dm="[object DataView]",kb=Fs(Lu),Eb=Fs(zo),bb=Fs(xu),wb=Fs(Uu),_b=Fs(Fu),ds=Us;(Lu&&ds(new Lu(new ArrayBuffer(1)))!=dm||zo&&ds(new zo)!=nm||xu&&ds(xu.resolve())!=am||Uu&&ds(new Uu)!=om||Fu&&ds(new Fu)!=cm)&&(ds=function(t){var e=Us(t),r=e==Tb?t.constructor:void 0,i=r?Fs(r):"";if(i)switch(i){case kb:return dm;case Eb:return nm;case bb:return am;case wb:return om;case _b:return cm}return e});const Xn=ds;var Ib=Object.prototype,Cb=Ib.hasOwnProperty;function Pb(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Cb.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Rb=Cr.Uint8Array;const Kd=Rb;function op(t){var e=new t.constructor(t.byteLength);return new Kd(e).set(new Kd(t)),e}function Mb(t,e){var r=e?op(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Ab=/\w*$/;function Db(t){var e=new t.constructor(t.source,Ab.exec(t));return e.lastIndex=t.lastIndex,e}var lm=$i?$i.prototype:void 0,um=lm?lm.valueOf:void 0;function Ob(t){return um?Object(um.call(t)):{}}function gv(t,e){var r=e?op(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Nb="[object Boolean]",Vb="[object Date]",Lb="[object Map]",xb="[object Number]",Ub="[object RegExp]",Fb="[object Set]",Bb="[object String]",Wb="[object Symbol]",jb="[object ArrayBuffer]",Hb="[object DataView]",qb="[object Float32Array]",Gb="[object Float64Array]",$b="[object Int8Array]",Jb="[object Int16Array]",Kb="[object Int32Array]",zb="[object Uint8Array]",Yb="[object Uint8ClampedArray]",Qb="[object Uint16Array]",Xb="[object Uint32Array]";function Zb(t,e,r){var i=t.constructor;switch(e){case jb:return op(t);case Nb:case Vb:return new i(+t);case Hb:return Mb(t,r);case qb:case Gb:case $b:case Jb:case Kb:case zb:case Yb:case Qb:case Xb:return gv(t,r);case Lb:return new i;case xb:case Bb:return new i(t);case Ub:return Db(t);case Fb:return new i;case Wb:return Ob(t)}}var hm=Object.create,ew=function(){function t(){}return function(e){if(!Ir(e))return{};if(hm)return hm(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();const tw=ew;function fv(t){return typeof t.constructor=="function"&&!wl(t)?tw(ap(t)):{}}var rw="[object Map]";function iw(t){return qr(t)&&Xn(t)==rw}var pm=Qn&&Qn.isMap,sw=pm?ip(pm):iw;const nw=sw;var aw="[object Set]";function ow(t){return qr(t)&&Xn(t)==aw}var mm=Qn&&Qn.isSet,cw=mm?ip(mm):ow;const dw=cw;var lw=1,uw=2,hw=4,vv="[object Arguments]",pw="[object Array]",mw="[object Boolean]",gw="[object Date]",fw="[object Error]",yv="[object Function]",vw="[object GeneratorFunction]",yw="[object Map]",Sw="[object Number]",Sv="[object Object]",Tw="[object RegExp]",kw="[object Set]",Ew="[object String]",bw="[object Symbol]",ww="[object WeakMap]",_w="[object ArrayBuffer]",Iw="[object DataView]",Cw="[object Float32Array]",Pw="[object Float64Array]",Rw="[object Int8Array]",Mw="[object Int16Array]",Aw="[object Int32Array]",Dw="[object Uint8Array]",Ow="[object Uint8ClampedArray]",Nw="[object Uint16Array]",Vw="[object Uint32Array]",Te={};Te[vv]=Te[pw]=Te[_w]=Te[Iw]=Te[mw]=Te[gw]=Te[Cw]=Te[Pw]=Te[Rw]=Te[Mw]=Te[Aw]=Te[yw]=Te[Sw]=Te[Sv]=Te[Tw]=Te[kw]=Te[Ew]=Te[bw]=Te[Dw]=Te[Ow]=Te[Nw]=Te[Vw]=!0;Te[fw]=Te[yv]=Te[ww]=!1;function qc(t,e,r,i,s,n){var o,c=e&lw,d=e&uw,l=e&hw;if(r&&(o=s?r(t,i,s,n):r(t)),o!==void 0)return o;if(!Ir(t))return t;var h=Ji(t);if(h){if(o=Pb(t),!c)return lv(t,o)}else{var p=Xn(t),v=p==yv||p==vw;if(Yn(t))return dv(t,c);if(p==Sv||p==vv||v&&!s){if(o=d||v?{}:fv(t),!c)return d?mb(t,sb(o,t)):lb(t,ZE(o,t))}else{if(!Te[p])return s?t:{};o=Zb(t,p,c)}}n||(n=new Hr);var T=n.get(t);if(T)return T;n.set(t,o),dw(t)?t.forEach(function(b){o.add(qc(b,e,r,b,t,n))}):nw(t)&&t.forEach(function(b,P){o.set(P,qc(b,e,r,P,t,n))});var E=l?d?gb:Vu:d?tc:sp,C=h?void 0:E(t);return tE(C||t,function(b,P){C&&(P=b,b=t[P]),Zf(o,P,qc(b,e,r,P,t,n))}),o}var Lw=1,xw=4;function cp(t){return qc(t,Lw|xw)}var Uw="[object Symbol]";function Fw(t){return typeof t=="symbol"||qr(t)&&Us(t)==Uw}var Bw=Object.defineProperty,Ww=(t,e)=>{for(var r in e)Bw(t,r,{get:e[r],enumerable:!0})},jw={};Ww(jw,{permissions:()=>Hw,theme:()=>qw});var Ft=(t=>(t.GroupCall="GROUP_CALL",t.Webinar="WEBINAR",t.AudioRoom="AUDIO_ROOM",t.Livestream="LIVESTREAM",t.Chat="CHAT",t))(Ft||{}),q=(t=>(t.Allowed="ALLOWED",t.NotAllowed="NOT_ALLOWED",t.CanRequest="CAN_REQUEST",t))(q||{}),Hw={view_type:"GROUP_CALL",accept_waiting_requests:!1,accept_present_requests:!1,request_produce:!1,can_allow_participant_audio:!1,can_allow_participant_screensharing:!1,can_allow_participant_video:!1,can_spotlight:!1,request_kick_participant:!1,kick_participant:!1,pin_participant:!1,can_edit_display_name:!1,can_record:!1,can_livestream:!1,can_present:!0,waiting_room_type:"SKIP_ON_ACCEPT",recorder_type:"NONE",plugins:{can_close:!0,can_start:!0},polls:{can_create:!0,can_vote:!0,can_view:!0},produce:{video:{allow:!0,quality:"vga",frame_rate:24},audio:!0,screenshare:{allow:!0,quality:"hd",frame_rate:5}},chat:{public:{can_send:!0,text:!0,files:!0},private:{can_send:!1,can_receive:!1,text:!1,files:!1}},connected_meetings:{can_alter_connected_meetings:!1,can_switch_connected_meetings:!1,can_switch_to_parent_meeting:!1},reactions:!1,hidden_participant:!1,is_recorder:!1,show_participant_list:!0,can_change_participant_role:!1,can_change_theme:!1,max_screenshare_count:1},qw={setup_screen:{is_enabled:!0},alone_here:{is_enabled:!0},waiting_room:{is_enabled:!1,enable_preview:!0},control_bar:{is_enabled:!0,elements:{plugins:!0,screenshare:!0,invite:!0,participants:!0,chat:!0,reactions:!1,polls:!0,fullscreen:!0,layout:!0}},header:{is_enabled:!0,elements:{timer:!0,title:!0,participant_count:!0,change_layout:!0}},pip_mode:!0,auto_tune:!0,grid:{multi:{maxVideoCount:6,videoFit:"cover"},single:{maxVideoCount:6,videoFit:"cover"},defaultView:"multi"},controls:{pip_toggle:!1}},Tv="hXgU8Wc8pwuGNq9ms5q9Hh",gm;typeof process!="undefined"&&(gm=process==null?void 0:process.env)!=null&&gm.FLAGSMITH_ENVIRONMENT_KEY&&(Tv={}.FLAGSMITH_ENVIRONMENT_KEY);function Gw(t=[]){const e={};return t.forEach(r=>{e[r.feature.name]={enabled:r.enabled,value:r.feature_state_value}}),e}var kv=class{constructor(t=Tv){m(this,"flags",{}),m(this,"environmentKey",null),this.environmentKey=t}identifyAndFetchFlagsWithRetry(t){return u(this,arguments,function*({primaryEndpoint:e,secondaryEndpoint:r,forceEvaluate:i,timeout:s,uniqueIdentifier:n,traitsObj:o,logger:c}){const d=JSON.parse(JSON.stringify(o)),l=Object.entries(d).map(p=>({trait_key:p[0],trait_value:p[1]})),h=[e,r,r];for(const p of h)try{const v=new AbortController,T=setTimeout(()=>v.abort(),s),E="_"+(Math.random()+1).toString(36).substring(2),C=yield fetch(`https://${p}/api/v1/identities/`,{method:"POST",headers:{"Content-Type":"application/json","X-Environment-Key":this.environmentKey},body:JSON.stringify({identifier:n+(i?E:""),traits:l}),signal:v.signal});if(clearTimeout(T),!C.ok)throw new Error(`Request failed with status ${C.status}`);const b=yield C.json();return Gw(b.flags||[])}catch(v){c.error("Flagsmith identify failed!!",{error:v,url:p})}return{}})}identify(t){return u(this,arguments,function*(e,r={},i=!1,s=5e3,n="edge.api.flagsmith.com",o=console){return this.flags=yield this.identifyAndFetchFlagsWithRetry({traitsObj:r,uniqueIdentifier:e,forceEvaluate:i,timeout:s,primaryEndpoint:n,secondaryEndpoint:"edge.api.flagsmith.com",logger:o}),this.flags})}getValue(t){return this.flags&&this.flags[t]&&this.flags[t].value}hasFeature(t){return this.flags&&this.flags[t]&&this.flags[t].enabled}getAllFlags(){return this.flags}},$w=new kv;function Jw(t){return new kv(t)}var Ev=[-2,-1,0,1,2],Kw=[0,1,2,3,4];function zw(t){t=t.trim();let e="0",r="0",i="0";return t.length==4?(e="0x"+t[1]+t[1],r="0x"+t[2]+t[2],i="0x"+t[3]+t[3]):t.length>6&&(e="0x"+t[1]+t[2],r="0x"+t[3]+t[4],i="0x"+t[5]+t[6]),[+e,+r,+i]}var Yw=(t,e,r)=>{let i,s,n;if(e==0)i=s=n=r;else{const o=(l,h,p)=>(p<0&&(p+=1),p>1&&(p-=1),p<.16666666666666666?l+(h-l)*6*p:p<.5?h:p<.6666666666666666?l+(h-l)*(.6666666666666666-p)*6:l),c=r<.5?r*(1+e):r+e-r*e,d=2*r-c;i=o(d,c,t+1/3),s=o(d,c,t),n=o(d,c,t-1/3)}return[Math.round(i*255),Math.round(s*255),Math.round(n*255)]},Qw=(t,e,r)=>{t/=255,e/=255,r/=255;const i=Math.max(t,e,r),s=Math.min(t,e,r);let n,o;const c=(i+s)/2;if(i==s)n=o=0;else{const d=i-s;switch(o=c>.5?d/(2-i-s):d/(i+s),i){case t:n=(e-r)/d+(e<r?6:0);break;case e:n=(r-t)/d+2;break;case r:n=(t-e)/d+4;break}n/=6}return[n,o,c]},Xw=(t,e,r)=>{const i=s=>s.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(r)}`},bv=(t,e=Ev,r=.4)=>{const i=[],[s,n,o]=zw(t),[c,d,l]=Qw(s,n,o),h=Math.round(l*100);h>70?r=.8:h>60?r=.9:h<10?r=.075:h<42&&(r=.3);const p=e.findIndex(b=>b===0);if(p===-1)throw new Error("Invalid reducer provided, it must contain atleast one zero");const v=5-p,T=p+1,E=(100-h)/v,C=h/T;for(const b of e){let P;b<0?P=h+b*C*r:b>0?P=h+b*E*r:P=h;const[j,W,w]=Yw(c,d,P/100);i.push(Xw(j,W,w))}return i},fm={dark:{background:{1e3:"#252525",900:"#2F2F2F",800:"#323232",700:"#3E3E3E",600:"#4A4A4A"},text:"#F5F5F5","video-bg":"#1C1C1C"},light:{background:{1e3:"#FFFFFF",900:"#F5F5F5",800:"#EBEBEB",700:"#E0E0E0",600:"#D6D6D6"},text:"#111111","text-on-brand":"#ffffff","video-bg":"#DADADA"}},Zw=t=>{const[e,r,i,s,n]=bv(t,Ev);return{300:e,400:r,500:i,600:s,700:n}},e_=t=>{if(t==="#FFFFFF")return fm.light.background;if(t==="#000000")return fm.dark.background;const[e,r,i,s,n]=bv(t,Kw);return{1e3:e,900:r,800:i,700:s,600:n}},t_={border_radius:"rounded",border_width:"thin",spacing_base:4,theme:"dark",colors:{brand:Zw("#2160FD"),background:e_("#141414"),danger:"#FF2D2D",text:"#EEEEEE",text_on_brand:"#EEEEEE",success:"#62A504",video_bg:"#191919",warning:"#FFCD07"}};function wv(){return cp(t_)}var r_={permissions:{can_accept_production_requests:!1,can_edit_display_name:!0,accept_waiting_requests:!1,disable_participant_audio:!1,disable_participant_screensharing:!1,disable_participant_video:!1,can_spotlight:!1,kick_participant:!1,pin_participant:!1,can_record:!1,can_livestream:!1,waiting_room_type:"SKIP",plugins:{can_close:!0,can_start:!0,can_edit_config:!1,config:{}},polls:{can_create:!0,can_vote:!0,can_view:!0},media:{video:{can_produce:"ALLOWED",can_consume:"ALLOWED"},audio:{can_produce:"ALLOWED"},screenshare:{can_produce:"ALLOWED",can_consume:"ALLOWED"}},chat:{public:{can_send:!0,text:!0,files:!0},private:{can_send:!1,can_receive:!1,text:!1,files:!1},channel:{can_create:"ALL",can_delete:"ALL",can_update:"ALL",can_read_all:!1},message:{can_delete:"ALL",can_edit:"ALL",delete_cutoff_time_seconds:0,edit_cutoff_time_seconds:0}},hidden_participant:!1,is_recorder:!1,recorder_type:"NONE",show_participant_list:!0,transcription_enabled:!1,can_change_participant_permissions:!1,connected_meetings:{can_alter_connected_meetings:!1,can_switch_connected_meetings:!1,can_switch_to_parent_meeting:!1},stage_enabled:!1,stage_access:void 0,accept_stage_requests:!1},ui:{oldTheme:{setup_screen:{is_enabled:!1},alone_here:{is_enabled:!1},waiting_room:{is_enabled:!1,enable_preview:!0},control_bar:{is_enabled:!0,elements:{plugins:!0,screenshare:!0,invite:!1,participants:!0,chat:!0,reactions:!1,polls:!0,fullscreen:!0,layout:!0}},header:{is_enabled:!0,elements:{timer:!0,title:!0,participant_count:!0,change_layout:!0}},pip_mode:!0,auto_tune:!0,colors:{primary:"#2160FD",secondary:"#1A1A1A",text:"#EEEEEE",background:"#1A1A1A",textPrimary:"#EEEEEE",videoBackground:"#1A1A1A"},dimensions:{mode:"fillParent"},grid:{multi:{maxVideoCount:6,videoFit:"cover"},single:{maxVideoCount:6,videoFit:"cover"},defaultView:"MULTI"},controls:{pip_toggle:!1},plugins:[]},design_tokens:wv(),config_diff:{}},config:{view_type:"GROUP_CALL",media:{audio:{enable_stereo:!1,enable_high_bitrate:!1},video:{quality:"vga",frame_rate:24},screenshare:{quality:"hd",frame_rate:5}},max_video_streams:{mobile:6,desktop:6},max_screenshare_count:1,track_recording:{subscriptions:[]}},version:"hybrid"};function i_(){return cp(r_)}var s_={permissions:{can_accept_production_requests:!1,can_edit_display_name:!0,accept_waiting_requests:!1,disable_participant_audio:!1,disable_participant_screensharing:!1,disable_participant_video:!1,can_spotlight:!1,kick_participant:!1,pin_participant:!1,can_record:!1,can_livestream:!1,waiting_room_type:"SKIP",plugins:{can_close:!0,can_start:!0,can_edit_config:!1,config:{}},polls:{can_create:!0,can_vote:!0,can_view:!0},media:{video:{can_produce:"ALLOWED"},audio:{can_produce:"ALLOWED"},screenshare:{can_produce:"ALLOWED"}},chat:{public:{can_send:!0,text:!0,files:!0},private:{can_send:!1,can_receive:!1,text:!1,files:!1}},hidden_participant:!1,is_recorder:!1,recorder_type:"NONE",show_participant_list:!0,transcription_enabled:!1,can_change_participant_permissions:!1,connected_meetings:{can_alter_connected_meetings:!1,can_switch_connected_meetings:!1,can_switch_to_parent_meeting:!1},stage_enabled:!1,stage_access:void 0,accept_stage_requests:!1},ui:{design_tokens:wv(),config_diff:{}},config:{view_type:"GROUP_CALL",media:{audio:{enable_stereo:!1,enable_high_bitrate:!1},video:{quality:"vga",frame_rate:24},screenshare:{quality:"hd",frame_rate:5}},max_video_streams:{mobile:6,desktop:6},max_screenshare_count:1,track_recording:{subscriptions:[]}},version:"2.0.0"};function dp(){return cp(s_)}var Gc;class _v{constructor(){g(this,Gc,void 0)}get telemetry(){var e;return(e=a(this,Gc))==null?void 0:e.getValue("telemetry")}init(e){f(this,Gc,e)}info(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("info",e,r,i)}error(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("error",e,r,i)}debug(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("debug",e,r,i)}log(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("log",e,r,i)}warn(e,r,i){var s;(s=this.telemetry)==null||s.addLogInCurrentSpan("warn",e,r,i)}}Gc=new WeakMap;var bi,wi;const Iv=class extends gt.EventEmitter{constructor(t){super(),g(this,bi,void 0),g(this,wi,void 0),m(this,"asyncPromiseTimeout"),m(this,"logger"),this.logger=t,f(this,bi,new Map),f(this,wi,new Map),this.asyncPromiseTimeout=8e3}emitAsync(t,...e){return u(this,null,function*(){a(this,bi).set(t,[]);const r=a(this,wi).get(t).map(()=>new Promise(i=>{a(this,bi).get(t).push(i)}));dT(Iv.prototype,this,"emit").call(this,t,...e),yield Promise.race([Promise.all(r),new Promise((i,s)=>setTimeout(()=>s(new Error(`emitAsync failed to resolve for event ${t}.`)),this.asyncPromiseTimeout))]),a(this,bi).delete(t)})}onAsync(t,e){const r=a(this,bi),i=(...s)=>u(this,null,function*(){var n;try{yield e(...s)}catch(c){this.logger.error("[onAsync]",{error:c})}const o=(n=r.get(t))==null?void 0:n.shift();o==null||o()});return a(this,wi).get(t)||a(this,wi).set(t,[]),a(this,wi).get(t).push(i),super.on(t,i)}reset(){f(this,bi,new Map),f(this,wi,new Map),super.removeAllListeners()}};let n_=Iv;bi=new WeakMap,wi=new WeakMap;var a_=/\s/;function o_(t){for(var e=t.length;e--&&a_.test(t.charAt(e)););return e}var c_=/^\s+/;function d_(t){return t&&t.slice(0,o_(t)+1).replace(c_,"")}var vm=0/0,l_=/^[-+]0x[0-9a-f]+$/i,u_=/^0b[01]+$/i,h_=/^0o[0-7]+$/i,p_=parseInt;function ym(t){if(typeof t=="number")return t;if(Fw(t))return vm;if(Ir(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=Ir(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=d_(t);var r=u_.test(t);return r||h_.test(t)?p_(t.slice(2),r?2:8):l_.test(t)?vm:+t}function Cv(t){return t}function m_(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var g_=800,f_=16,v_=Date.now;function y_(t){var e=0,r=0;return function(){var i=v_(),s=f_-(i-r);if(r=i,s>0){if(++e>=g_)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}function S_(t){return function(){return t}}var T_=$d?function(t,e){return $d(t,"toString",{configurable:!0,enumerable:!1,value:S_(e),writable:!0})}:Cv;const k_=T_;var E_=y_(k_);const b_=E_;var Sm=Math.max;function w_(t,e,r){return e=Sm(e===void 0?t.length-1:e,0),function(){for(var i=arguments,s=-1,n=Sm(i.length-e,0),o=Array(n);++s<n;)o[s]=i[e+s];s=-1;for(var c=Array(e+1);++s<e;)c[s]=i[s];return c[e]=r(o),m_(t,this,c)}}function __(t,e){return b_(w_(t,e,Cv),t+"")}function I_(t,e,r){if(!Ir(r))return!1;var i=typeof e;return(i=="number"?ec(r)&&rv(e,r.length):i=="string"&&e in r)?Xo(r[e],t):!1}function C_(t){return __(function(e,r){var i=-1,s=r.length,n=s>1?r[s-1]:void 0,o=s>2?r[2]:void 0;for(n=t.length>3&&typeof n=="function"?(s--,n):void 0,o&&I_(r[0],r[1],o)&&(n=s<3?void 0:n,s=1),e=Object(e);++i<s;){var c=r[i];c&&t(e,c,i,n)}return e})}var P_="[object Object]",R_=Function.prototype,M_=Object.prototype,Pv=R_.toString,A_=M_.hasOwnProperty,D_=Pv.call(Object);function O_(t){if(!qr(t)||Us(t)!=P_)return!1;var e=ap(t);if(e===null)return!0;var r=A_.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Pv.call(r)==D_}var N_="__lodash_hash_undefined__";function V_(t){return this.__data__.set(t,N_),this}function L_(t){return this.__data__.has(t)}function zd(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Ws;++e<r;)this.add(t[e])}zd.prototype.add=zd.prototype.push=V_;zd.prototype.has=L_;function x_(t,e){for(var r=-1,i=t==null?0:t.length;++r<i;)if(e(t[r],r,t))return!0;return!1}function U_(t,e){return t.has(e)}var F_=1,B_=2;function Rv(t,e,r,i,s,n){var o=r&F_,c=t.length,d=e.length;if(c!=d&&!(o&&d>c))return!1;var l=n.get(t),h=n.get(e);if(l&&h)return l==e&&h==t;var p=-1,v=!0,T=r&B_?new zd:void 0;for(n.set(t,e),n.set(e,t);++p<c;){var E=t[p],C=e[p];if(i)var b=o?i(C,E,p,e,t,n):i(E,C,p,t,e,n);if(b!==void 0){if(b)continue;v=!1;break}if(T){if(!x_(e,function(P,j){if(!U_(T,j)&&(E===P||s(E,P,r,i,n)))return T.push(j)})){v=!1;break}}else if(!(E===C||s(E,C,r,i,n))){v=!1;break}}return n.delete(t),n.delete(e),v}function W_(t){var e=-1,r=Array(t.size);return t.forEach(function(i,s){r[++e]=[s,i]}),r}function j_(t){var e=-1,r=Array(t.size);return t.forEach(function(i){r[++e]=i}),r}var H_=1,q_=2,G_="[object Boolean]",$_="[object Date]",J_="[object Error]",K_="[object Map]",z_="[object Number]",Y_="[object RegExp]",Q_="[object Set]",X_="[object String]",Z_="[object Symbol]",e0="[object ArrayBuffer]",t0="[object DataView]",Tm=$i?$i.prototype:void 0,Gl=Tm?Tm.valueOf:void 0;function r0(t,e,r,i,s,n,o){switch(r){case t0:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case e0:return!(t.byteLength!=e.byteLength||!n(new Kd(t),new Kd(e)));case G_:case $_:case z_:return Xo(+t,+e);case J_:return t.name==e.name&&t.message==e.message;case Y_:case X_:return t==e+"";case K_:var c=W_;case Q_:var d=i&H_;if(c||(c=j_),t.size!=e.size&&!d)return!1;var l=o.get(t);if(l)return l==e;i|=q_,o.set(t,e);var h=Rv(c(t),c(e),i,s,n,o);return o.delete(t),h;case Z_:if(Gl)return Gl.call(t)==Gl.call(e)}return!1}var i0=1,s0=Object.prototype,n0=s0.hasOwnProperty;function a0(t,e,r,i,s,n){var o=r&i0,c=Vu(t),d=c.length,l=Vu(e),h=l.length;if(d!=h&&!o)return!1;for(var p=d;p--;){var v=c[p];if(!(o?v in e:n0.call(e,v)))return!1}var T=n.get(t),E=n.get(e);if(T&&E)return T==e&&E==t;var C=!0;n.set(t,e),n.set(e,t);for(var b=o;++p<d;){v=c[p];var P=t[v],j=e[v];if(i)var W=o?i(j,P,v,e,t,n):i(P,j,v,t,e,n);if(!(W===void 0?P===j||s(P,j,r,i,n):W)){C=!1;break}b||(b=v=="constructor")}if(C&&!b){var w=t.constructor,te=e.constructor;w!=te&&"constructor"in t&&"constructor"in e&&!(typeof w=="function"&&w instanceof w&&typeof te=="function"&&te instanceof te)&&(C=!1)}return n.delete(t),n.delete(e),C}var o0=1,km="[object Arguments]",Em="[object Array]",mc="[object Object]",c0=Object.prototype,bm=c0.hasOwnProperty;function d0(t,e,r,i,s,n){var o=Ji(t),c=Ji(e),d=o?Em:Xn(t),l=c?Em:Xn(e);d=d==km?mc:d,l=l==km?mc:l;var h=d==mc,p=l==mc,v=d==l;if(v&&Yn(t)){if(!Yn(e))return!1;o=!0,h=!1}if(v&&!h)return n||(n=new Hr),o||bl(t)?Rv(t,e,r,i,s,n):r0(t,e,d,r,i,s,n);if(!(r&o0)){var T=h&&bm.call(t,"__wrapped__"),E=p&&bm.call(e,"__wrapped__");if(T||E){var C=T?t.value():t,b=E?e.value():e;return n||(n=new Hr),s(C,b,r,i,n)}}return v?(n||(n=new Hr),a0(t,e,r,i,s,n)):!1}function Mv(t,e,r,i,s){return t===e?!0:t==null||e==null||!qr(t)&&!qr(e)?t!==t&&e!==e:d0(t,e,r,i,Mv,s)}function l0(t){return function(e,r,i){for(var s=-1,n=Object(e),o=i(e),c=o.length;c--;){var d=o[t?c:++s];if(r(n[d],d,n)===!1)break}return e}}var u0=l0();const h0=u0;var p0=function(){return Cr.Date.now()};const $l=p0;var m0="Expected a function",g0=Math.max,f0=Math.min;function lp(t,e,r){var i,s,n,o,c,d,l=0,h=!1,p=!1,v=!0;if(typeof t!="function")throw new TypeError(m0);e=ym(e)||0,Ir(r)&&(h=!!r.leading,p="maxWait"in r,n=p?g0(ym(r.maxWait)||0,e):n,v="trailing"in r?!!r.trailing:v);function T(re){var ae=i,Me=s;return i=s=void 0,l=re,o=t.apply(Me,ae),o}function E(re){return l=re,c=setTimeout(P,e),h?T(re):o}function C(re){var ae=re-d,Me=re-l,Xe=e-ae;return p?f0(Xe,n-Me):Xe}function b(re){var ae=re-d,Me=re-l;return d===void 0||ae>=e||ae<0||p&&Me>=n}function P(){var re=$l();if(b(re))return j(re);c=setTimeout(P,C(re))}function j(re){return c=void 0,v&&i?T(re):(i=s=void 0,o)}function W(){c!==void 0&&clearTimeout(c),l=0,i=d=s=c=void 0}function w(){return c===void 0?o:j($l())}function te(){var re=$l(),ae=b(re);if(i=arguments,s=this,d=re,ae){if(c===void 0)return E(d);if(p)return clearTimeout(c),c=setTimeout(P,e),T(d)}return c===void 0&&(c=setTimeout(P,e)),o}return te.cancel=W,te.flush=w,te}function Bu(t,e,r){(r!==void 0&&!Xo(t[e],r)||r===void 0&&!(e in t))&&rp(t,e,r)}function v0(t){return qr(t)&&ec(t)}function Wu(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}function y0(t){return Zo(t,tc(t))}function S0(t,e,r,i,s,n,o){var c=Wu(t,r),d=Wu(e,r),l=o.get(d);if(l){Bu(t,r,l);return}var h=n?n(c,d,r+"",t,e,o):void 0,p=h===void 0;if(p){var v=Ji(d),T=!v&&Yn(d),E=!v&&!T&&bl(d);h=d,v||T||E?Ji(c)?h=c:v0(c)?h=lv(c):T?(p=!1,h=dv(d,!0)):E?(p=!1,h=gv(d,!0)):h=[]:O_(d)||Jd(d)?(h=c,Jd(c)?h=y0(c):(!Ir(c)||tp(c))&&(h=fv(d))):p=!1}p&&(o.set(d,h),s(h,d,i,n,o),o.delete(d)),Bu(t,r,h)}function Av(t,e,r,i,s){t!==e&&h0(e,function(n,o){if(s||(s=new Hr),Ir(n))S0(t,e,o,r,Av,i,s);else{var c=i?i(Wu(t,o),n,o+"",t,e,s):void 0;c===void 0&&(c=n),Bu(t,o,c)}},tc)}var T0="[object Map]",k0="[object Set]",E0=Object.prototype,b0=E0.hasOwnProperty;function w0(t){if(t==null)return!0;if(ec(t)&&(Ji(t)||typeof t=="string"||typeof t.splice=="function"||Yn(t)||bl(t)||Jd(t)))return!t.length;var e=Xn(t);if(e==T0||e==k0)return!t.size;if(wl(t))return!ov(t).length;for(var r in t)if(b0.call(t,r))return!1;return!0}function _0(t,e){return Mv(t,e)}var I0=C_(function(t,e,r){Av(t,e,r)});const _i=I0;var ju=(t=>(t.PARTICIPANT="PARTICIPANT",t.PEER="PEER",t.CLIENT="CLIENT",t))(ju||{});const X={PROPAGATE_KICK_ALL:"propagate_kick_across_rooms",REFRESH_ID_ON_DISCONNECTION:"refresh_id_on_disconnection",SIMULCAST:"simulcast",CHAT_SOCKET_SERVER:"chat_socket_server",POLL_SOCKET_SERVER:"poll_socket_server",PLUGIN_SOCKET_SERVER:"plugin_socket_server",NR_OTEL_WEB:"nr_otel_web",ICE_RESTART_ON_FAILED_STATE:"ice_restart_on_failed_state",ICE_RESTART_ON_DISCONNECTED_STATE:"ice_restart_on_disconnected_state",ENABLE_ICE_STATE_LOGGING:"enable_ice_state_logging",SUPPRESS_PEER_MUTE_UNMUTE_EMITS:"web_core_suppress_peer_mute_unmute_emits",SKIP_OTEL_TRACES:"skip_otel_traces",USE_USERIDS_IN_CHAT:"use_userids_in_chat",CUSTOM_PING_PONG:"custom_ping_pong",ENABLE_HIVE_SIMULCAST:"enable_hive_simulcast",ENABLE_HIVE_TRANSPORT_RECONNECTION_ON_ICE_FAILED:"enable_hive_transport_reconnection_on_ice_failed",ENABLE_HIVE_EXPERIMENTAL_FAIL_RECOVERY:"enable_hive_fail_recovery",ENABLE_HIVE_INFINITE_RETRIES:"enable_hive_infinite_retries",HIVE_TRANSPORT_FORCE_RELAY_ON_ICE_FAILED:"hive_transport_force_relay_on_ice_failed",ENABLE_HIVE_CONSUME_OVER_DC:"enable_hive_consume_over_dc",ENABLE_CF_SIMULCAST:"enable_cf_simulcast",ENABLE_CF_TRANSPORT_RECONNECTION_ON_ICE_FAILED:"enable_cf_transport_reconnection_on_ice_failed",ENABLE_CF_EXPERIMENTAL_FAIL_RECOVERY:"enable_cf_fail_recovery",ENABLE_CF_INFINITE_RETRIES:"enable_cf_infinite_retries",CF_TRANSPORT_FORCE_RELAY_ON_ICE_FAILED:"cf_transport_force_relay_on_ice_failed",BYPASS_LOG_EXCLUSION_LIST:"bypass_log_exclusion_list",LOG_LEVEL:"log_level",V1_PLUGINS:"v1_plugins",SCREENSHARE_DTX:"screenshare_dtx",SCREENSHARE_PRIORITY:"screenshare_priority",SCREENSHARE_MIN_BITRATE:"screenshare_minbitrate",SCREENSHARE_SIMULCAST:"screenshare_simulcast",DISABLE_WEBCAM_LAYERS_ON_SCREENSHARE:"disable_webcam_layers_on_screenshare",SCREENSHARE_FORCE_GOOG_CONFERENCE:"screenshare_force_goog_conference",LIVESTREAM:"feat_livestream",FETCH_RETRY:"fetch_retry",DISABLE_WEBCAM_SIMULCAST:"webcore_disable_webcam_simulcast",OVERRIDE_WEBCAM_SIMULCAST:"override_webcam_simulcast",SOCKET_POLLING:"socket_polling",FEAT_PAGINATED_CHAT:"feat_paginated_chat",VAL_MIN_FRAMERATE:"val_min_framerate",SCREEENSHARE_ERR_HACK:"screenshare_err_hack",SCREEENSHARE_CONSTRAINTS_RETRY:"screenshare_constraints_retry",TROUBLESHOOTING:"feat_troubleshooting",VIDEO_CONSTRAINTS:"video_constraints",SCREENSHARE_CONSTRAINTS:"screenshare_constraints",FEAT_CHAT_SDK:"feat_chat_sdk",FEAT_CHAT_SDK_SEARCH:"chat_search",OBS_QUALITY:"obs_quality",ALLOW_SAFARI_MEDIA_MIDDLEWARES:"allow_safari_media_middlewares",DYNAMIC_VIDEO_QUALITY:"dynamic_video_quality",EXP_RESHARE:"exp_reshare",LEAVE_STAGE_ON_END:"leave_stage_on_end",SKIP_SETTING_IN_USE_DEVICE:"skip_setting_in_use_device",PRECALL_BANDWIDTH_TEST:"precall_bandwidth_test",CONSUMER_BIND_NO_RETRY:"consumer_bind_no_retry",DEBUG_SOCKET_JOIN:"debug_socket_join",FORCE_RELAY:"force_relay",FORCE_VIDEO_CODEC:"force_video_codec",USE_EXPERIMENTAL_SFU_HANDLER:"use_experimental_sfu_handler",TRACK_HINT:"track_hint",OVERRIDE_HIVE_SIMULCAST_DYNAMIC:"override_hive_simulcast_dynamic",PRECREATE_PRODUCERS:"precreate_producers",DISABLE_OPUS_DTX_CF:"disable_opus_dtx_cf",ENABLE_AUDIO_ACTIVITY_DEBUG_LOGS:"enable_audio_activity_debug_logs",NEW_SYNC_CONSUMERS:"new_sync_consumers",DISABLE_LAYER_SWITCH:"disable_layer_switch"};function $c(t){const e={};return typeof(t==null?void 0:t.code)=="number"&&(e.code=t.code),typeof(t==null?void 0:t.code)=="string"&&(e.code=t.code.substring(0,100)),typeof(t==null?void 0:t.name)=="string"&&(e.name=t.name.substring(0,500)),typeof(t==null?void 0:t.message)=="string"&&(e.message=t.message.substring(0,500)),typeof(t==null?void 0:t.reason)=="string"&&(e.reason=t.reason.substring(0,500)),typeof(t==null?void 0:t.stack)=="string"&&(e.stack=t.stack.substring(0,500)),e}function C0(t){var e,r,i,s;const n=typeof navigator!="undefined"&&!navigator.isReactNative&&typeof window!="undefined"&&((e=window.location.host)==null?void 0:e.includes("devel"))&&((r=window.location.host)==null?void 0:r.includes("dyte.io")),o=!!((s=(i=t==null?void 0:t.getValue("modules"))==null?void 0:i.devTools)!=null&&s.logs);return n||o}function P0(t,e){var r;if(t!=null&&t.getValue("flagsmith").hasFeature(X.LOG_LEVEL)){let i=((r=t.getValue("flagsmith").getValue(X.LOG_LEVEL))==null?void 0:r.toString())||"all";if(i=i.toLowerCase().trim(),i==="off")return!1;if(i!=="all"){const s=["debug","log","info","warn","error"],n=s.indexOf(e),o=s.indexOf(i);if(n<o)return!1}}return!0}function Dv(t,e,r={}){return Object.getOwnPropertyNames(t).forEach(i=>{var s;if([null,void 0,NaN].includes(t[i])||e&&(((s=e.match(/\./g))==null?void 0:s.length)||0)>=10)return;const n=e?`${e}.${i}`:i;typeof t[i]=="object"?Dv(t[i],n,r):["number","string","boolean"].includes(typeof t[i])&&(r[n]=t[i])}),r}function wm(t,e,r={},i=""){const s={};try{const n=JSON.stringify(r),o=JSON.parse(n),c=Dv(o,i),d=JSON.stringify(c);return JSON.parse(d)}catch(n){const o=$c(n);s[`${i}.error.message`]=o.message||"",s[`${i}.error.stack`]=o.stack||"",s[`${i}.error.reason`]=o.reason||"",s[`${i}.error.source`]="safelyFlattenObjForOpenTelemetry"}return s}const R0={audio:!0,video:!0,screenshareAudio:!0,screenshareVideo:!0},Ea={baseURL:"http://localhost:5000",createdAt:"2021-08-05T10:49:56.602Z",description:"Develop plugins locally",id:"09259e3b-7be8-46f6-9801-106bf1866e1c",name:"Localhost Dev",organizationId:"4ad15a19-80e2-4105-bf43-48039fd2963e",picture:"https://dyte-uploads.s3.ap-south-1.amazonaws.com/dyte.png",private:!1,published:!0,staggered:!1,tags:["#localhost","#dev"],type:"self_hosted",updatedAt:"2021-08-05T10:50:07.681Z"},M0={pip:!0,poll:!0,chat:!0,stage:!0,theme:!0,plugin:!0,tracing:!0,internals:!0,recording:!0,livestream:!0,participant:!0,connectedMeetings:!0,devTools:{logs:!1}};function Zn(t,e){const r=t.getValue("overrides");return r&&r[e]?r[e]:!1}function A0({baseURI:t}){return t.includes("preprod.dyte")||t.includes("preprod.realtime")?Do.PREPROD:t.includes("devel.dyte")||t.includes("devel.realtime")?Do.DEVEL:Do.PROD}function As({servicePrefix:t,baseURI:e}){return`${t}.${e}`}function Ov(t){const e=t.getValue("baseURI");return{location:As({servicePrefix:"location",baseURI:e}),locationLegacy:As({servicePrefix:"location-legacy",baseURI:e}),daCollector:As({servicePrefix:"da-collector",baseURI:e.replace("realtime.cloudflare.com","dyte.io")})}}const D0='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m16.242 2.932 4.826 4.826a2.75 2.75 0 0 1-.715 4.404l-4.87 2.435a.75.75 0 0 0-.374.426l-1.44 4.166a1.25 1.25 0 0 1-2.065.476L8.5 16.561 4.06 21H3v-1.06l4.44-4.44-3.105-3.104a1.25 1.25 0 0 1 .476-2.066l4.166-1.44a.75.75 0 0 0 .426-.373l2.435-4.87a2.75 2.75 0 0 1 4.405-.715Zm3.766 5.886-4.826-4.826a1.25 1.25 0 0 0-2.002.325l-2.435 4.871a2.25 2.25 0 0 1-1.278 1.12l-3.789 1.31 6.705 6.704 1.308-3.789a2.25 2.25 0 0 1 1.12-1.277l4.872-2.436a1.25 1.25 0 0 0 .325-2.002Z" fill="currentColor"/></svg>',O0='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M4 12.02c0 1.06.2 2.1.6 3.08l.6 1.42c.22.55.64 1.01 1.17 1.29.27.14.56.21.86.21h2.55c.77 0 1.49-.41 1.87-1.08.5-.87 1.02-1.7 1.72-2.43l1.32-1.39c.44-.46.97-.84 1.49-1.23l.59-.45a.6.6 0 0 0 .23-.47c0-.75-.54-1.57-1.22-1.79a3.34 3.34 0 0 0-2.78.29V4.5a1.5 1.5 0 0 0-2.05-1.4 1.5 1.5 0 0 0-2.9 0A1.5 1.5 0 0 0 6 4.5v.09A1.5 1.5 0 0 0 4 6v6.02ZM8 4.5v4a.5.5 0 0 0 1 0v-5a.5.5 0 0 1 1 0v5a.5.5 0 0 0 1 0v-4a.5.5 0 0 1 1 0v6a.5.5 0 0 0 .85.37h.01c.22-.22.44-.44.72-.58.7-.35 2.22-.57 2.4.5l-.53.4c-.52.4-1.04.78-1.48 1.24l-1.33 1.38c-.75.79-1.31 1.7-1.85 2.63-.21.36-.6.58-1.01.58H7.23a.87.87 0 0 1-.4-.1 1.55 1.55 0 0 1-.71-.78l-.59-1.42a7.09 7.09 0 0 1-.53-2.7V6a.5.5 0 0 1 1 0v3.5a.5.5 0 0 0 1 0v-5a.5.5 0 0 1 1 0Z" fill="currentColor"></path></svg>',gc=t=>{if(!t)return;if(!t.startsWith("<svg"))return new Promise(s=>{s(t)});const e=new Blob([t],{type:"image/svg+xml"}),r=new Image,i=window.URL.createObjectURL(e);return new Promise((s,n)=>{r.onload=()=>{s(r),window.URL.revokeObjectURL(i)},r.onerror=()=>{n(),window.URL.revokeObjectURL(i)},r.src=i})},Nv=class{constructor(){m(this,"logsCache",[]),m(this,"logsProcessorTimer"),m(this,"tracingEnabled",!0),m(this,"initialized",!1),m(this,"logsProcessingInterval",7e3),m(this,"logExclusionList",["message","websocket/message","roomMessage","websocket/room-message","websocket/room-legacy-mode","chatMessage","websocket/new-chat-message","websocket/no-active-speaker","websocket/selected-peers","websocket/active-speaker","ping","websocket/new-consumer","websocket/producer-score","websocket/consumer-score","websocket/plugin-event","websocket/plugin-data","websocket/plugin-internal-data"]),m(this,"meetingMetadata",{})}get logsEndpoint(){const t=ai.getContext(this.meetingMetadata.peerId);return`https://${As({servicePrefix:"api-silos",baseURI:t.getValue("baseURI")})}/otel/logs`}resetPeerId(t){this.meetingMetadata.peerId=t}init(t,e,r){this.tracingEnabled=!0,this.initialized=!1,this.logsCache=[];const i=t.getValue("peerId");this.meetingMetadata=e,this.tracingEnabled=r,this.meetingMetadata.peerId=i,this.meetingMetadata.sdkVersion=t.getValue("sdkVersion");const{RNDeviceInfoImpl:s}=navigator;this.meetingMetadata.deviceInfo=navigator.isReactNative?s==null?void 0:s.getDeviceInfo():Ie.getDeviceInfo(),this.meetingMetadata.visitedUrl=!navigator.isReactNative&&typeof window!="undefined"&&window.location.href,this.logsProcessorTimer=setInterval(this.processCachedLogs.bind(this),this.logsProcessingInterval),r&&(this.initialized=!0)}static trace(t,e=void 0){return(r,i,s)=>{const n=s.value;return s.value=function(...o){var c;const d=this==null?void 0:this.telemetry;if(!d||!d.initialized||navigator.isReactNative||!d.tracingEnabled||(c=ai.getContext(d.meetingMetadata.peerId))!=null&&c.getValue("flagsmith").hasFeature(X.SKIP_OTEL_TRACES))return n.apply(this,o);d.addLogInCurrentSpan("info",t,e);const l=performance.now(),h=n.apply(this,o);return Promise.resolve(h).then(()=>{const p=performance.now();p-l>10&&d.addLogInCurrentSpan("info",`${t}_timing`,{execTime:p-l,country:Nv.location.country})}).catch(()=>{const p=performance.now();d.addLogInCurrentSpan("info",`${t}_timing`,{execTime:p-l})}),h},s}}injectContext(t){var e;const r=Os().replace(/-/g,"").substring(0,16),i=(e=this.meetingMetadata.peerId)==null?void 0:e.replace(/-/g,"");t.TRACEPARENT=`00-${i}-${r}-01`}addLogInCurrentSpan(t,e,r={},i=!1){r!=null&&r.error&&Object.assign(r,{error:$c(r.error)});const s=ai.getContext(this.meetingMetadata.peerId);if(C0(s)&&(w0(r)?console[t]("DyteInternalLogs:: ",t,e):console[t]("DyteInternalLogs:: ",t,e,r)),!!P0(s,t))try{const n=wm(s,e,r,"metadata"),o=new Date,c=G(V({message:e,level:t},n),{loggedAt:o.toISOString(),loggedAtTzOffset:o.getTimezoneOffset()});i?this.sendOtelLogsToNewRelic([c]):this.logsCache.push(c)}catch(n){this.addLogInCurrentSpan("error","opentelemetry::addLogInCurrentSpan_failed",{error:$c(n)})}}sendOtelLogsToNewRelic(t){const e=ai.getContext(this.meetingMetadata.peerId);fetch(this.logsEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({meetingMetadata:wm(e,"sendOtelLogsToNewRelic",this.meetingMetadata,"meetingMetadata"),serviceName:e.getValue("sdkName"),logs:t})}).catch(r=>{this.addLogInCurrentSpan("error","opentelemetry::sendOtelLogToNewRelic_failed",{error:$c(r)}),this.logsCache.push(...t)})}processCachedLogs(){const t=this.logsCache.splice(0,25);t!=null&&t.length&&this.sendOtelLogsToNewRelic(t)}destruct(){clearInterval(this.logsProcessorTimer),this.processCachedLogs()}};let k=Nv;m(k,"location",{country:void 0});function N0(t){const e=V({},t),r=new Map,i=(o,c)=>(r.has(o)||r.set(o,new Set),r.get(o).add(c),()=>{var d;return(d=r.get(o))==null?void 0:d.delete(c)}),s=(o,c)=>{var d;(d=r.get(o))==null||d.delete(c)},n=o=>{var c;(c=r.get(o))==null||c.forEach(d=>{try{d(e[o])}catch{}})};return{subscribe:i,unsubscribe:s,notify:n,setValue:(o,c,d=!0)=>{e[o]=c,d&&n(o)},getValue:o=>e[o],getAllValues:()=>e}}class V0{constructor(){m(this,"contexts",new Map),m(this,"mostRecentPeerId",null)}createContext(e,r){if(this.contexts.has(e))return this.contexts.get(e);const i=new k,s=new _v;this.contexts.set(e,N0(r)),this.contexts.get(e).setValue("peerSessionStore",new n_(s));const n=new Yf;return n.setMaxListeners(50),this.contexts.get(e).setValue("logger",s),this.contexts.get(e).setValue("telemetry",i),this.contexts.get(e).setValue("callstats",n),this.contexts.get(e).setValue("flagsmith",Jw()),this.mostRecentPeerId=e,this.contexts.get(e)}remapContext(e,r){const i=r.getValue("peerId");i!==e&&(r.setValue("peerId",e),this.mostRecentPeerId=e,this.contexts.set(e,r),this.contexts.delete(i))}getContext(e){return this.contexts.get(e)}getMostRecentPeerId(){return this.mostRecentPeerId}}const ai=new V0,L0={"00":"DyteClient","01":"Controller","02":"RoomNodeClient","03":"HiveNodeClient","04":"SocketService","05":"Chat","06":"Plugin","07":"Polls","08":"Meta","09":"Preset",10:"Recording",11:"Self",12:"Participant",13:"Spotlight",14:"Remote Request",15:"Webinar",16:"LocalMediaHandler",17:"End-End Encryption",18:"AI",19:"Livestream",20:"Stage"},Jc={"0000":"Internal exception.","0001":"Failed to initialize.","0002":"Failed to join room.","0003":"Failed to leave room.","0004":"Invalid auth token","0010":"Browser not supported","0011":"HTTP Network Error","0012":"Websocket Network Error","0013":"Rate Limited","0100":"Internal exception","0101":"Permission denied","0102":"Prerequisite module missing","0200":"Internal exception.","0300":"Internal exception","0400":"Internal exception","0404":"Missing prerequisites to establish a websocket connection","0500":"Internal exception","0501":"Permission denied.","0502":"Invalid message body.","0503":"Text Message is too large","0504":"Message not found by the given id","0505":"Action not permitted without joining room","0506":"Message search is disabled","0510":"Invalid channel name.","0600":"Internal exception","0601":"Permission denied.","0602":"Auth token not set for plugin","0603":"Iframe was not provided","0700":"Internal exception","0705":"Action not permitted without joining room","0800":"Internal exception","0801":"Permission denied","0900":"Internal exception","0904":"Could not load preset",1e3:"Internal exception",1001:"Permission denied",1004:"Could not find specified recording",1005:"Action not permitted in given recording state",1100:"Internal exception",1101:"Permission denied",1102:"Unsupported",1103:"Name cannot be empty",1104:"No device selected while calling meeting.self.setDevice",1105:"Action not permitted without joining room",1106:"Can't set currently used device",1200:"Internal exception",1201:"Permission denied",1202:"Invalid page number was requested",1203:"Invalid participant count per page was requested",1204:"No participants exists with the given UserIds",1205:"Action not permitted without joining room",1206:"Manual Subscription Mode was not ACTIVATED",1207:"Invalid view mode",1208:"Manual Subscription not enabled for organization",1209:"Broadcast message type must be a non-empty string",1300:"Internal exception",1400:"Internal exception",1402:"No existing remote requests",1403:"No peer exists with given id",1500:"Internal exception",1600:"Internal exception",1601:"Failed to get audio track",1602:"Failed to get video track",1603:"Incorrect device",1604:"Failed to change device",1605:"Failed to get audio & video track",1606:"No audio input devices are available",1607:"No video input devices are available",1608:"No audio output devices (speakers) are available",1609:"Failed to fetch list of media devices",1610:"No media track exists",1611:"Failed to unmute track",1612:"Failed to get screenshare tracks",1701:"Crypto error",1800:"Internal exception",1801:"Can't fetch transcript file",1900:"Internal exception",1901:"Permission denied.",1902:"Livestream that has not yet started, can't be stopped",2e3:"Internal exception",2001:"Permission denied",2002:"Unsupported",2003:"Stage is disabled",2004:"Method not implemented",2005:"Action not permitted without joining room",2006:"Action not permitted in current stage status",9900:"Internal exception"};Object.keys(Jc).forEach(t=>{Jc[t]=`{${L0[t.slice(0,2)]}} ${Jc[t]}`});class I extends Error{constructor(e,r,i=void 0,s=!1){super(e),m(this,"code"),this.code=r,this.name="DyteError",this.message=`[ERR${this.code}]: ${Jc[this.code]}
13
13
  ${this.message}`;try{let n=s&&!!i;r&&r.endsWith("00")&&i&&(n=!0),n&&i.error("DyteError",{error:{message:this.message,name:this.name,code:r}});const o=ai.getContext(ai.getMostRecentPeerId());if(o){const c=o.getValue("onError");try{c(this)}catch{}}typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("dyteError",{detail:this}))}catch{}}}function fc(t,e,r,i){if(i instanceof I)throw i;if(i instanceof e){const s=new I(i.message,r);throw s.stack=i.stack,s}else throw i}function _m(t,e,r){if(!t.value){const s=t.get,n=t.set;return s&&(t.get=function(){try{return s.apply(this)}catch(o){fc(this,e,r,o)}}),n&&(t.set=function(o){try{return n.apply(this,[o])}catch(c){fc(this,e,r,c)}}),t}const i=t.value;return t.value=function(...s){try{const n=i.apply(this,s);return n&&n instanceof Promise?n.catch(o=>{fc(this,e,r,o)}):n}catch(n){fc(this,e,r,n)}},t}function x0(t,e){return(r,i,s)=>{if(s)return _m(s,t,e);for(const n of Reflect.ownKeys(r.prototype).filter(o=>o!=="constructor")){const o=Object.getOwnPropertyDescriptor(r.prototype,n);(o.value instanceof Function||o.get instanceof Function||o.set instanceof Function)&&Object.defineProperty(r.prototype,n,_m(o,t,e))}}}const ft=t=>x0(Error,t);function U0(t){let e=0,r,i;if(!t)return e;for(r=0;r<t.length;r+=1)i=t.charCodeAt(r),e=(e<<5)-e+i,e|=0;return Math.abs(e)%100+1}function F0(){Ie.isElectron()&&window.dyteElectronGetDisplayMediaSource&&(navigator.mediaDevices.getDisplayMedia=()=>u(this,null,function*(){const t=yield window.dyteElectronGetDisplayMediaSource({types:["window","screen"]});let e=[];if(t&&(Array.isArray(t)?e=t:e=[t]),!(e!=null&&e.length))throw new Error("Couldn't find any media source for screen share.");let r=e.find(s=>{var n;return(n=s.id)==null?void 0:n.includes("screen")});r=r!=null?r:e[0];const i={audio:!1,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r.id}}};return yield navigator.mediaDevices.getUserMedia(i)}))}var M=(t=>(t.NEW_PRODUCER="NEW_PRODUCER",t.PRODUCER_TRACK_ENDED="PRODUCER_TRACK_ENDED",t.ROOM_NODE_CONNECTION_ERROR="ROOM_NODE_CONNECTION_ERROR",t.SOCKET_SERVICE_ROOM_JOINED="SOCKET_SERVICE_ROOM_JOINED",t.SOCKET_SERVICE_RECONNECTED="SOCKET_SERVICE_RECONNECTED",t.SOCKET_SERVICE_DISCONNECTED="SOCKET_SERVICE_DISCONNECTED",t.SOCKET_SERVICE_FAILED="SOCKET_SERVICE_FAILED",t.SOCKET_STATE_UPDATE="SOCKET_STATE_UPDATE",t.ROOM_NODE_RECONNECTED="ROOM_NODE_RECONNECTED",t.ROOM_NODE_DISCONNECTED="ROOM_NODE_DISCONNECTED",t.ROOM_NODE_FAILED="ROOM_NODE_FAILED",t.TRANSPORT_STATE_UPDATE="TRANSPORT_STATE_UPDATE",t.PRODUCER_SCORE_UPDATE="PRODUCER_SCORE_UPDATE",t.CONSUMER_SCORE_UPDATE="CONSUMER_SCORE_UPDATE",t.PRODUCER_STATUS_UPDATE="PRODUCER_STATUS_UPDATE",t.CONSUMER_STATUS_UPDATE="CONSUMER_STATUS_UPDATE",t.LOW_PRODUCER_SCORE="LOW_PRODUCER_SCORE",t.LOW_CONSUMER_SCORE="LOW_CONSUMER_SCORE",t.MEDIA_PERMISSION_ERROR="MEDIA_PERMISSION_ERROR",t.MEDIA_PERMISSION_UPDATE="MEDIA_PERMISSION_UPDATE",t.WAITLISTED="WAIT_LISTED",t.MESSAGE="websocket/message",t.ROOM_MESSAGE="websocket/room-message",t.PEER_JOINED_INTERNAL="peer/joined-internal",t.PEER_CLOSED="websocket/peer-closed",t.CONSUMER_CLOSED="websocket/consumer-closed",t.CONSUMER_PAUSED="websocket/consumer-paused",t.CONSUMER_RESUMED="websocket/consumer-resumed",t.PRODUCER_CLOSED="websocket/producer-closed",t.NEW_CONSUMER="websocket/new-consumer",t.PRODUCER_SCORE="websocket/producer-score",t.CONSUMER_SCORE="websocket/consumer-score",t.PRODUCER_TOGGLE="hive/producer-toggle",t.CONSUMER_TOGGLE="hive/consumer-toggle",t.SELECTED_PEERS_DIFF="hive/selected-peers-diff",t.UPDATE_ACTIVE="media/update-active",t.RESET_PRODUCER_STATE="hive/reset-producer-state",t.CF_TRANSPORT_STATE_CHANGED="cf/transport-state-changed",t.CF_ROOM_REJOINING="cf/room-rejoining",t.CF_ROOM_REJOIN_FAILED="cf/room-rejoining-failed",t.CF_ROOM_REJOINED="cf/room-rejoined",t.CF_TRANPSORT_RECONNECTING="cf/transport-reconnecting",t.ROOM_STATE="sockethub/room-state",t.PEER_DISPLAY_NAME_CHANGED="hive/display-name-changed",t.GET_STAGE_REQUESTS="GET_STAGE_REQUESTS",t.UPDATE_STAGE_REQUESTS="UPDATE_STAGE_REQUESTS",t.KICK_PEER="KICK_PEER",t.UPDATE_PEER_STAGE_STATUS="UPDATE_PEER_STAGE_STATUS",t.JOIN_MEDIA_ROOM="JOIN_MEDIA_ROOM",t.LEAVE_MEDIA_ROOM="LEAVE_MEDIA_ROOM",t.PIP_HANGUP="PIP_HANGUP",t.E2EE_ACTIVE_PRODUCER="E2EE_ACTIVE_PRODUCER",t.E2EE_INACTIVE_PRODUCER="E2EE_INACTIVE_PRODUCER",t.E2EE_ACTIVE_CONSUMER="E2EE_ACTIVE_CONSUMER",t.E2EE_INACTIVE_CONSUMER="E2EE_INACTIVE_CONSUMER",t.SOCKET_PEERS="SOCKET_PEERS",t.UPDATE_PERMISSIONS="UPDATE_PERMISSIONS",t.MAX_SPATIAL_LAYER_CHANGE="MAX_SPATIAL_LAYER_CHANGE",t.MUTE_SELF="MUTE_SELF",t.MUTE_SELF_VIDEO="MUTE_SELF_VIDEO",t))(M||{});class ra extends gt.EventEmitter{constructor(e){super(),m(this,"logger"),this.logger=e,super.setMaxListeners(25)}emit(e,...r){return super.emit("*",e,...r),super.emit(e,...r)}on(e,r){var i;try{const s=this.listenerCount(e);s>25&&s%25===0&&((i=this.logger)==null||i.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}}))}catch{}return super.on(e,r)}addListener(e,r){var i;try{const s=this.listenerCount(e);s>25&&s%25===0&&((i=this.logger)==null||i.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}}))}catch{}return super.addListener(e,r)}off(e,r){return super.off(e,r)}once(e,r){return super.once(e,r)}prependListener(e,r){return super.prependListener(e,r)}prependOnceListener(e,r){return super.prependOnceListener(e,r)}removeListener(e,r){return super.removeListener(e,r)}removeAllListeners(e){return super.removeAllListeners(e)}listeners(e){return super.listeners(e)}listenerCount(e){return super.listenerCount(e)}}class Xt extends gt.EventEmitter{constructor(e){super(),m(this,"logger"),this.logger=e,super.setMaxListeners(25)}emit(e,...r){return super.emit("*",e,...r),super.emit(e,...r)}on(e,r){var i;try{const s=this.listenerCount(e);s>25&&s%25===0&&((i=this.logger)==null||i.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}}))}catch{}return super.on(e,r)}addListener(e,r){var i;try{const s=this.listenerCount(e);s>25&&s%25===0&&((i=this.logger)==null||i.warn("DyteEventEmitter::maxListenersExceeded",{eventListener:{eventName:e.toString(),listenerCount:this.listenerCount(e)}}))}catch{}return super.addListener(e,r)}off(e,r){return super.off(e,r)}once(e,r){return super.once(e,r)}prependListener(e,r){return super.prependListener(e,r)}prependOnceListener(e,r){return super.prependOnceListener(e,r)}removeListener(e,r){return super.removeListener(e,r)}removeAllListeners(e){return super.removeAllListeners(e)}listeners(e){return super.listeners(e)}listenerCount(e){return super.listenerCount(e)}}function B0(t,e=2){return t.replace(/[^\u00BF-\u1FFF\u2C00-\uD7FF\w\s]/g,"").trim().split(/\s+/).slice(0,e).map(r=>r.charAt(0)).join("").toUpperCase()}const Im=1080,Cm=1920,W0=(t,e,r,i,s,n)=>{let o=.5,c=.5;const d=s,l=n,h=Math.min(r/d,i/l);let p=d*h,v=l*h,T,E,C,b,P=1;return p<r&&(P=r/p),Math.abs(P-1)<1e-14&&v<i&&(P=i/v),p*=P,v*=P,C=d/(p/r),b=l/(v/i),T=(d-C)*o,E=(l-b)*c,T<0&&(T=0),E<0&&(E=0),C>d&&(C=d),b>l&&(b=l),[T,E,C,b,t,e,r,i]};var gr,yn,Et,fr,Fe,Or,Ii,Vt,Je,io,so,Ci,no;const Vv=class extends Xt{constructor(t,e,r,i){const s=t.getValue("logger");super(s),g(this,gr,void 0),g(this,yn,void 0),g(this,Et,void 0),g(this,fr,void 0),g(this,Fe,{height:Im,width:Cm}),g(this,Or,{brand:"#2160FD",background:"#141414",text:"#000000",videoBackground:"#191919",textOnBrand:"#EEEEEE"}),g(this,Ii,void 0),g(this,Vt,{}),g(this,Je,void 0),g(this,io,void 0),g(this,so,void 0),g(this,Ci,void 0),g(this,no,!1),m(this,"cleanupEventListeners",()=>{a(this,yn).unsubscribe("stageStatus",this.handlePipMediaControls),a(this,Je).removeListener("videoUpdate",this.onSelfVideoUpdateListener),a(this,Je).removeListener("audioUpdate",this.onSelfAudioUpdateListener),a(this,Je).removeListener("roomLeft",()=>this.disable())}),m(this,"enablePipMediaControls",()=>{this.mountAudioEvents(),this.mountVideoEvents()}),m(this,"onSelfVideoUpdateListener",({videoEnabled:n})=>{this.updateMediaSession("CAMERA",n)}),m(this,"onSelfAudioUpdateListener",({audioEnabled:n})=>{this.updateMediaSession("MIC",n)}),m(this,"handlePipMediaControls",n=>{n==="ON_STAGE"?this.enablePipMediaControls():this.unmountEvents()}),m(this,"eventCallback",n=>{n==="CAMERA"&&(a(this,Je).videoEnabled?a(this,Je).disableVideo():a(this,Je).enableVideo(),this.emit("cameraToggled")),n==="MIC"&&(a(this,Je).audioEnabled?a(this,Je).disableAudio():a(this,Je).enableAudio(),this.emit("micToggled")),n==="END"&&(a(this,yn).getValue("peerSessionStore").emit(M.PIP_HANGUP),this.cleanupEventListeners(),this.emit("hangup"),this.cleanup())}),m(this,"unmountEvents",()=>{navigator.mediaSession===void 0||navigator.mediaSession.setCameraActive===void 0||(navigator.mediaSession.setActionHandler("togglemicrophone",void 0),navigator.mediaSession.setActionHandler("togglecamera",void 0))}),m(this,"animate",()=>{if(!this.isActive&&a(this,Ci)==="active"){this.disable(!0);return}a(this,Vt)!==void 0&&this.paintCanvas(),a(this,Ii)!==void 0&&f(this,Ii,requestAnimationFrame(()=>this.animate()))}),m(this,"disable",(n=!1)=>{f(this,Ci,"idle"),this.cleanupEventListeners(),cancelAnimationFrame(a(this,Ii)),n!==!0&&document.body.removeChild(a(this,Et)),f(this,Ii,void 0),document.pictureInPictureElement&&document.exitPictureInPicture()}),f(this,yn,t),f(this,Ci,"idle"),f(this,Je,e),f(this,Or,{brand:e.config.designTokens.colors.brand[500],background:e.config.designTokens.colors.background[1e3],text:e.config.designTokens.colors.text,videoBackground:e.config.designTokens.colors.videoBg,textOnBrand:e.config.designTokens.colors.textOnBrand}),r&&this.setupIcon("pin",r),i&&this.setupIcon("handRaise",i)}static _init(t,e){return u(this,null,function*(){let r,i;try{r=yield gc(D0),i=yield gc(O0)}catch{}return new Vv(t,e,r,i)})}setupIcon(t,e){return u(this,null,function*(){switch(t){case"handRaise":f(this,so,e);break;case"pin":f(this,io,e);break}})}overrideIcon(t,e){return u(this,null,function*(){switch(t){case"handRaise":f(this,so,yield gc(e));break;case"pin":f(this,io,yield gc(e));break}})}constructImage(t){const e=new Image,r=new Blob([t],{type:"image/svg+xml"}),i=window.URL.createObjectURL(r);return new Promise(s=>{e.onload=()=>{s(e),window.URL.revokeObjectURL(i)},e.src=i})}createVideoContainer(){f(this,Et,document.createElement("div")),a(this,Et).style.width="0.1px",a(this,Et).style.height="0.1px",a(this,Et).style.overflow="hidden",a(this,Et).style.position="absolute",a(this,Et).style.bottom="0",a(this,Et).style.right="0",a(this,Et).style.opacity="0",a(this,Et).appendChild(a(this,fr))}setupEventListeners(){a(this,yn).subscribe("stageStatus",this.handlePipMediaControls),a(this,Je).addListener("videoUpdate",this.onSelfVideoUpdateListener),a(this,Je).addListener("audioUpdate",this.onSelfAudioUpdateListener),a(this,Je).addListener("roomLeft",()=>this.disable())}createCanvas(){const t=document.createElement("canvas");t.height=a(this,Fe).height,t.width=a(this,Fe).width,f(this,gr,t)}setupMediaSessionEvents(){navigator.mediaSession===void 0||navigator.mediaSession.setCameraActive===void 0||(navigator.mediaSession.setActionHandler("hangup",()=>{this.eventCallback("END")}),this.mountAudioEvents(),this.mountVideoEvents())}mountAudioEvents(){navigator.mediaSession===void 0||navigator.mediaSession.setMicrophoneActive===void 0||a(this,Je).permissions.canProduceAudio&&navigator.mediaSession.setActionHandler("togglemicrophone",()=>{this.eventCallback("MIC")})}mountVideoEvents(){navigator.mediaSession===void 0||navigator.mediaSession.setCameraActive===void 0||a(this,Je).permissions.canProduceVideo&&navigator.mediaSession.setActionHandler("togglecamera",()=>{this.eventCallback("CAMERA")})}getSources(){const t=Object.values(a(this,Vt)).reduce((e,r)=>(e[r.pinned?"pinned":"regular"].push(r),e),{pinned:[],regular:[]});return[...t.pinned,...t.regular]}drawEmptyTile(t,e,r,i){if(a(this,gr)===void 0)return;const s=a(this,gr).getContext("2d"),n=a(this,gr).width,o=0,c=0,d=e-o*2,l=r-o*2,h=Math.floor(n/d),p=Math.floor(t/h),v=t%h*(d+o)+o,T=p*(l+o)+o,{displayText:E,image:C}=i!=null?i:{};s.fillStyle=E||C?a(this,Or).videoBackground:a(this,Or).background,s.strokeStyle=a(this,Or).brand,s.beginPath(),s.moveTo(v+c,T),s.arcTo(v+d,T,v+d,T+c,c),s.arcTo(v+d,T+l,v+d-c,T+l,c),s.arcTo(v,T+l,v,T+l-c,c),s.arcTo(v,T,v+c,T,c),s.closePath(),s.fill(),s.stroke();const b=d/6,P=d/2+v,j=l/2+T;s.save(),(E||C)&&(s.beginPath(),s.arc(P,j,b,0,Math.PI*2),s.fillStyle=a(this,Or).brand,s.fill(),C?(s.clip(),s.drawImage(C,P-b,j-b,b*2,b*2),s.restore()):E&&(s.fillStyle=a(this,Or).textOnBrand,s.font=`${b/2}px sans-serif`,s.textAlign="center",s.textBaseline="middle",s.fillText(E,P,j)),this.drawIcons(i,v,T,Math.max(d,l)))}drawIcons(t,e,r,i){const s=Math.min(Math.max(i*.15,100),200),n=s*.2,o=s*.2;let c=e+n;const d=r+n,l=h=>{const p=a(this,gr).getContext("2d");p.save(),p.fillStyle=a(this,Or).background,p.beginPath(),p.moveTo(c+o,d),p.arcTo(c+s,d,c+s,d+o,o),p.arcTo(c+s,d+s,c+s-o,d+s,o),p.arcTo(c,d+s,c,d+s-o,o),p.arcTo(c,d,c+o,d,o),p.closePath(),p.fill(),typeof h=="string"?(p.font=`${s/1.5}px sans-serif`,p.fillStyle=a(this,Or).text,p.textAlign="center",p.textBaseline="top",p.fillText(h,s/2+c,d+n)):p.drawImage(h,c+n,d+n,s-n*2,s-n*2),c+=s+n,p.restore()};t.pinned&&l(a(this,io)),t.handRaised&&l(a(this,so))}drawTile(t,e,r){var i,s;if(a(this,gr)===void 0)return;const n=a(this,gr).getContext("2d"),o=this.getSources();let c=0,d=0;for(;c<a(this,Fe).height-5;){let l=0;for(;l<a(this,Fe).width-5&&d<r;){if((i=o[d])!=null&&i.enabled){const h=o[d].element,[p,v,T,E,C,b,P,j]=W0(l,c,t,e,h.videoWidth,h.videoHeight);(s=h==null?void 0:h.classList)!=null&&s.contains("mirror")?(n.save(),n.scale(-1,1),n.drawImage(h,p,v,T,E,-1*C,b,-1*P,j),n.restore()):n.drawImage(h,p,v,T,E,C,b,P,j),this.drawIcons(o[d],C,b,Math.max(P,j))}else this.drawEmptyTile(d,t,e,o[d]);d+=1,l+=t}c+=e}}calcGridElemSize(t){switch(t){case 0:case 1:return[a(this,Fe).width,a(this,Fe).height];case 2:return[Math.floor(a(this,Fe).width/2),a(this,Fe).height];case 3:case 4:return[Math.floor(a(this,Fe).width/2),Math.floor(a(this,Fe).height/2)];case 5:case 6:return[Math.floor(a(this,Fe).width/3),Math.floor(a(this,Fe).height/2)];case 7:case 8:case 9:return[Math.floor(a(this,Fe).width/3),Math.floor(a(this,Fe).height/3)];default:return[Math.floor(a(this,Fe).width/3),Math.floor(a(this,Fe).height/2)]}}paintCanvas(){let t=this.getSources().length;t!==1&&(t=t%2>0?t+1:t);const[e,r]=this.calcGridElemSize(t);this.drawTile(e,r,t)}isSupported(){var t;return!!window.chrome&&document.pictureInPictureEnabled&&((t=a(this,Je).config)==null?void 0:t.viewType)!=="LIVESTREAM"}get isActive(){return document.pictureInPictureElement!==null}cleanup(){if(f(this,no,!1),this.isSupported()&&document.exitPictureInPicture!==void 0&&document.pictureInPictureElement!==null&&document.exitPictureInPicture(),a(this,Et))try{document.body.removeChild(a(this,Et))}catch{}this.removeAllSources(),f(this,gr,void 0),f(this,fr,void 0),f(this,Ii,void 0)}init({height:t,width:e}={}){if(!this.isSupported())throw this.logger.error("DytePip.unsupported"),new Error("Picture-in-picture is not available in this environment");if(a(this,no))return;f(this,no,!0),this.createCanvas(),this.setupMediaSessionEvents();const r=document.createElement("video");f(this,Fe,{height:t!=null?t:Im,width:e!=null?e:Cm}),r.height=a(this,Fe).height,r.width=a(this,Fe).width,r.autoplay=!0,r.muted=!0,r.srcObject=a(this,gr).captureStream(24),f(this,fr,r),a(this,fr).onloadedmetadata=()=>{try{this.emit("pipStarted"),a(this,fr).onleavepictureinpicture=()=>{this.emit("pipEnded")}}catch{this.emit("pipEnded")}},this.createVideoContainer(),this.paintCanvas()}updateMediaSession(t,e){navigator.mediaSession!==void 0&&(t==="CAMERA"&&navigator.mediaSession.setCameraActive!==void 0&&navigator.mediaSession.setCameraActive(e),t==="MIC"&&navigator.mediaSession.setMicrophoneActive!==void 0&&navigator.mediaSession.setMicrophoneActive(e))}enableSource(t){a(this,Vt)[t]!==void 0&&(a(this,Vt)[t].enabled=!0)}disableSource(t){a(this,Vt)[t]!==void 0&&(a(this,Vt)[t].enabled=!1)}generateAvatar(t,e){return u(this,null,function*(){if(!e)return;const r=new Image;try{const i=yield(yield fetch(e)).blob(),s=window.URL.createObjectURL(i);r.onload=()=>{this.updateSource(t,{image:r}),window.URL.revokeObjectURL(s)},r.src=s}catch(i){this.logger.error("DytePip::GenerateAvatar",{error:i})}})}addSource(t,e,r,i=!1,s=void 0,n=void 0,o=!1){this.logger.debug("DytePIP::AddSource",{pip:{id:t,handRaised:o}}),a(this,Vt)[t]={id:t,element:e,enabled:r,pinned:i,displayText:s?B0(s):void 0,imageUrl:n,handRaised:o},n&&this.generateAvatar(t,n)}updateSource(t,e){this.logger.info("DytePIP::UpdateSource",{pip:{id:t,handRaised:e.handRaised}});const r=a(this,Vt)[t];r&&(a(this,Vt)[t]=V(V({},r),e))}removeSource(t){delete a(this,Vt)[t]}removePinnedSource(){Object.values(a(this,Vt)).forEach(t=>{t.pinned&&this.removeSource(t.id)})}removeAllSources(){f(this,Vt,{})}enable(){f(this,Ci,"activating"),this.setupEventListeners(),this.updateMediaSession("CAMERA",a(this,Je).videoEnabled),this.updateMediaSession("MIC",a(this,Je).audioEnabled),document.body.appendChild(a(this,Et)),f(this,Ii,requestAnimationFrame(()=>this.animate())),a(this,fr).onloadedmetadata=()=>{a(this,fr).requestPictureInPicture().then(()=>{f(this,Ci,"active")})},a(this,fr).readyState===4&&a(this,fr).requestPictureInPicture().then(()=>{f(this,Ci,"active")})}};let j0=Vv;gr=new WeakMap,yn=new WeakMap,Et=new WeakMap,fr=new WeakMap,Fe=new WeakMap,Or=new WeakMap,Ii=new WeakMap,Vt=new WeakMap,Je=new WeakMap,io=new WeakMap,so=new WeakMap,Ci=new WeakMap,no=new WeakMap;var li;(function(t){t[t.PUBLISHER=0]="PUBLISHER",t[t.SUBSCRIBER=1]="SUBSCRIBER"})(li||(li={}));var Wr;(function(t){t[t.AUDIO=0]="AUDIO",t[t.VIDEO=1]="VIDEO"})(Wr||(Wr={}));class H0 extends y{constructor(){super("media.Codec",[{no:1,name:"channels",kind:"scalar",opt:!0,T:5},{no:2,name:"clock_rate",kind:"scalar",T:5},{no:3,name:"mime_type",kind:"scalar",T:9},{no:4,name:"sdp_fmtp_line",kind:"scalar",opt:!0,T:9},{no:5,name:"payload_type",kind:"scalar",opt:!0,T:13}])}}const Lv=new H0;class q0 extends y{constructor(){super("media.HeaderExtension",[{no:1,name:"direction",kind:"scalar",opt:!0,T:9},{no:2,name:"uri",kind:"scalar",T:9}])}}const G0=new q0;class $0 extends y{constructor(){super("media.Fingerprint",[{no:1,name:"algorithm",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:9}])}}new $0;class J0 extends y{constructor(){super("media.SessionDescription",[{no:1,name:"target",kind:"enum",T:()=>["media.Target",li]},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"sdp",kind:"scalar",T:9}])}}const Pr=new J0;class K0 extends y{constructor(){super("media.ProducerPayload",[{no:1,name:"kind",kind:"scalar",T:9},{no:2,name:"paused",kind:"scalar",T:8},{no:3,name:"screen_share",kind:"scalar",T:8},{no:4,name:"msid",kind:"scalar",T:9},{no:5,name:"app_data",kind:"scalar",opt:!0,T:9},{no:6,name:"mime_type",kind:"scalar",opt:!0,T:9}])}}const z0=new K0;class Y0 extends y{constructor(){super("media.CreateTransportRequest",[{no:1,name:"consuming",kind:"scalar",T:8},{no:2,name:"force_tcp",kind:"scalar",opt:!0,T:8},{no:3,name:"description",kind:"message",T:()=>Pr},{no:4,name:"private_ice",kind:"scalar",opt:!0,T:8},{no:5,name:"producers",kind:"message",repeat:1,T:()=>z0}])}}const Q0=new Y0;class X0 extends y{constructor(){super("media.AudioActivityRequest",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"energy",kind:"scalar",T:5},{no:3,name:"silent",kind:"scalar",T:8}])}}const Z0=new X0;class eI extends y{constructor(){super("media.CreateTransportResponse",[{no:1,name:"transport_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Pr},{no:3,name:"transcription_enabled",kind:"scalar",opt:!0,T:8},{no:4,name:"producer_ids",kind:"scalar",repeat:2,T:9}])}}const xv=new eI;class tI extends y{constructor(){super("media.RenegotiateRequest",[{no:1,name:"transport_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Pr}])}}const rI=new tI;class iI extends y{constructor(){super("media.RenegotiateResponse",[{no:1,name:"transport_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Pr}])}}new iI;class sI extends y{constructor(){super("media.NestedScore",[{no:1,name:"encoding_idx",kind:"scalar",T:5},{no:2,name:"rid",kind:"scalar",T:9},{no:3,name:"score",kind:"scalar",T:5},{no:4,name:"ssrc",kind:"scalar",T:3,L:0}])}}const nI=new sI;class aI extends y{constructor(){super("media.ProducerTrack",[{no:1,name:"track_id",kind:"scalar",T:9},{no:2,name:"producer_id",kind:"scalar",T:9},{no:3,name:"stream_id",kind:"scalar",T:9}])}}const oI=new aI;class cI extends y{constructor(){super("media.ProducerEntry",[{no:1,name:"producing_transport_id",kind:"scalar",T:9},{no:2,name:"producer_id",kind:"scalar",T:9}])}}new cI;class dI extends y{constructor(){super("media.ConsumerEntry",[{no:1,name:"consuming_transport_id",kind:"scalar",T:9},{no:2,name:"consumer_id",kind:"scalar",T:9}])}}new dI;class lI extends y{constructor(){super("media.ProducerState",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"kind",kind:"enum",T:()=>["media.ProducerKind",Wr]},{no:3,name:"pause",kind:"scalar",T:8},{no:4,name:"screen_share",kind:"scalar",T:8},{no:5,name:"app_data",kind:"scalar",opt:!0,T:9},{no:6,name:"producing_transport_id",kind:"scalar",opt:!0,T:9},{no:7,name:"mime_type",kind:"scalar",opt:!0,T:9},{no:8,name:"codec",kind:"message",T:()=>Lv}])}}const rc=new lI;class uI extends y{constructor(){super("media.ConsumerState",[{no:1,name:"consumer_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>rc},{no:3,name:"producer_track",kind:"message",T:()=>oI},{no:4,name:"error_code",kind:"scalar",opt:!0,T:9}])}}const hI=new uI;class pI extends y{constructor(){super("media.ProducerIdToConsumerMap",[{no:1,name:"map",kind:"map",K:9,V:{kind:"message",T:()=>hI}}])}}const Uv=new pI;class mI extends y{constructor(){super("media.PeerRtpCapabilitites",[{no:1,name:"sender",kind:"message",T:()=>Rm},{no:2,name:"receiver",kind:"message",T:()=>Rm}])}}const Fv=new mI;class gI extends y{constructor(){super("media.RtpCapability",[{no:1,name:"codecs",kind:"message",repeat:1,T:()=>Lv},{no:2,name:"header_extensions",kind:"message",repeat:1,T:()=>G0}])}}const Pm=new gI;class fI extends y{constructor(){super("media.RtpCapabilitites",[{no:1,name:"audio",kind:"message",T:()=>Pm},{no:2,name:"video",kind:"message",T:()=>Pm}])}}const Rm=new fI;class vI extends y{constructor(){super("media.PreferredCodec",[{no:1,name:"audio",kind:"scalar",opt:!0,T:9},{no:2,name:"video",kind:"scalar",opt:!0,T:9}])}}const yI=new vI;class SI extends y{constructor(){super("media.Simulcast",[{no:1,name:"preferred_rid",kind:"scalar",opt:!0,T:9},{no:2,name:"priority_ordering",kind:"scalar",opt:!0,T:9},{no:3,name:"rid_not_available",kind:"scalar",opt:!0,T:9}])}}const Bv=new SI;class TI extends y{constructor(){super("media.edge.GeoLocation",[{no:1,name:"latitude",kind:"scalar",T:2},{no:2,name:"longitude",kind:"scalar",T:2},{no:3,name:"region",kind:"scalar",opt:!0,T:9}])}}const kI=new TI;class EI extends y{constructor(){super("media.edge.PeerJoinRequest",[{no:1,name:"display_name",kind:"scalar",opt:!0,T:9},{no:2,name:"prejoined",kind:"scalar",T:8},{no:3,name:"room_uuid",kind:"scalar",T:9},{no:4,name:"meeting_id",kind:"scalar",opt:!0,T:9},{no:5,name:"preset",kind:"scalar",opt:!0,T:12},{no:6,name:"user_id",kind:"scalar",opt:!0,T:9},{no:7,name:"organization_id",kind:"scalar",opt:!0,T:9},{no:8,name:"location",kind:"message",T:()=>kI},{no:9,name:"capabilities",kind:"message",T:()=>Fv}])}}const bI=new EI;class wI extends y{constructor(){super("media.edge.PeerJoinCompleteRequest",[])}}const _I=new wI;class II extends y{constructor(){super("media.edge.PeerLeaveRequest",[{no:1,name:"close_room",kind:"scalar",T:8}])}}const CI=new II;class PI extends y{constructor(){super("media.edge.ConsumeMultipleProducerRequest",[{no:1,name:"producer_ids",kind:"scalar",repeat:2,T:9},{no:2,name:"paused",kind:"scalar",opt:!0,T:8}])}}new PI;class RI extends y{constructor(){super("media.edge.ConsumePeerRequest",[{no:1,name:"producing_peer_id",kind:"scalar",T:9},{no:2,name:"paused",kind:"scalar",opt:!0,T:8},{no:3,name:"producer_id",kind:"scalar",opt:!0,T:9},{no:4,name:"preferred_codec",kind:"message",T:()=>yI},{no:5,name:"producing_transport_id",kind:"scalar",opt:!0,T:9},{no:6,name:"simulcast",kind:"message",T:()=>Bv}])}}const MI=new RI;class AI extends y{constructor(){super("media.edge.ConsumePeersRequest",[{no:1,name:"requests",kind:"message",repeat:1,T:()=>MI},{no:2,name:"consuming_transport_id",kind:"scalar",opt:!0,T:9}])}}const DI=new AI;class OI extends y{constructor(){super("media.edge.UpdateConsumerSimulcastConfigRequest",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"simulcast",kind:"message",T:()=>Bv},{no:3,name:"producing_transport_id",kind:"scalar",T:9},{no:4,name:"mid",kind:"scalar",T:9}])}}const NI=new OI;class VI extends y{constructor(){super("media.edge.UpdateConsumersSimulcastConfigRequest",[{no:1,name:"requests",kind:"message",repeat:1,T:()=>NI},{no:2,name:"consuming_transport_id",kind:"scalar",opt:!0,T:9}])}}const LI=new VI;class xI extends y{constructor(){super("media.edge.ProducerCreateRequest",[{no:1,name:"kind",kind:"scalar",T:9},{no:2,name:"paused",kind:"scalar",T:8},{no:3,name:"screen_share",kind:"scalar",T:8},{no:4,name:"description",kind:"message",T:()=>Pr},{no:5,name:"msid",kind:"scalar",T:9},{no:6,name:"app_data",kind:"scalar",opt:!0,T:9},{no:7,name:"mime_type",kind:"scalar",opt:!0,T:9},{no:8,name:"producing_transport_id",kind:"scalar",opt:!0,T:9}])}}const UI=new xI;class FI extends y{constructor(){super("media.edge.SelectedPeersRequest",[])}}new FI;class BI extends y{constructor(){super("media.edge.GlobalPeerPinningRequest",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}const WI=new BI;class jI extends y{constructor(){super("media.edge.ProducerToggleRequest",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"pause",kind:"scalar",T:8}])}}const vc=new jI;class HI extends y{constructor(){super("media.edge.ConsumerToggleRequest",[{no:1,name:"consumer_id",kind:"scalar",T:9},{no:2,name:"pause",kind:"scalar",T:8}])}}new HI;class qI extends y{constructor(){super("media.edge.ProducerCloseRequest",[{no:1,name:"producer_id",kind:"scalar",T:9},{no:2,name:"description",kind:"message",T:()=>Pr},{no:3,name:"producing_transport_id",kind:"scalar",opt:!0,T:9}])}}const GI=new qI;class $I extends y{constructor(){super("media.edge.ConsumerCloseRequest",[{no:1,name:"consumer_ids",kind:"scalar",repeat:2,T:9},{no:2,name:"description",kind:"message",T:()=>Pr},{no:3,name:"consuming_transport_id",kind:"scalar",opt:!0,T:9}])}}const JI=new $I;class KI extends y{constructor(){super("media.edge.KickPeerRequest",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new KI;class zI extends y{constructor(){super("media.edge.KickAllPeersRequest",[{no:1,name:"propagate_kick_across_rooms",kind:"scalar",T:8}])}}const Wv=new zI;class YI extends y{constructor(){super("media.edge.PeerDisplayNameEditRequest",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",T:9}])}}const QI=new YI;class XI extends y{constructor(){super("media.edge.HostMediaControlForPeerRequest",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"audio",kind:"scalar",T:8},{no:3,name:"video",kind:"scalar",T:8},{no:4,name:"scree_share",kind:"scalar",T:8}])}}const ZI=new XI;class eC extends y{constructor(){super("media.edge.HostMediaControlForAllPeerRequest",[{no:1,name:"audio",kind:"scalar",T:8},{no:2,name:"video",kind:"scalar",T:8},{no:3,name:"screen_share",kind:"scalar",T:8}])}}const tC=new eC;class rC extends y{constructor(){super("media.edge.GetRoomStateResponse",[{no:1,name:"display_title",kind:"scalar",T:9},{no:2,name:"locked_mode",kind:"scalar",T:8},{no:3,name:"room_uuid",kind:"scalar",T:9},{no:4,name:"room_name",kind:"scalar",T:9},{no:5,name:"current_peer_id",kind:"scalar",T:9},{no:6,name:"is_recording",kind:"scalar",opt:!0,T:8},{no:7,name:"recorder_participant_id",kind:"scalar",opt:!0,T:9},{no:8,name:"pinned_peer_ids",kind:"scalar",repeat:2,T:9}])}}const iC=new rC;class sC extends y{constructor(){super("media.edge.ErrorResponse",[{no:1,name:"error_message",kind:"scalar",T:9},{no:2,name:"event_id",kind:"scalar",T:5}])}}const nC=new sC;class aC extends y{constructor(){super("media.edge.EmptyResponse",[])}}new aC;class oC extends y{constructor(){super("media.edge.RoomParticipants",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"producer_states",kind:"message",repeat:1,T:()=>rc},{no:3,name:"display_name",kind:"scalar",T:9},{no:4,name:"user_id",kind:"scalar",opt:!0,T:9},{no:5,name:"capabilities",kind:"message",T:()=>Fv}])}}const jv=new oC;class cC extends y{constructor(){super("media.edge.SelectedPeersResponse",[{no:1,name:"audio_peers",kind:"scalar",repeat:2,T:9},{no:2,name:"compulsory_peers",kind:"scalar",repeat:2,T:9}])}}const Hu=new cC;class dC extends y{constructor(){super("media.edge.SelectedPeersDiffEntry",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"priority",kind:"scalar",T:5}])}}const lC=new dC;class uC extends y{constructor(){super("media.edge.SelectedPeersDiffResponse",[{no:1,name:"entries",kind:"message",repeat:1,T:()=>lC}])}}const Mm=new uC;class hC extends y{constructor(){super("media.edge.PeerJoinResponse",[])}}new hC;class pC extends y{constructor(){super("media.edge.PeerJoinCompleteResponse",[{no:1,name:"room_state",kind:"message",T:()=>iC},{no:2,name:"participants",kind:"message",repeat:1,T:()=>jv},{no:3,name:"selected_peers",kind:"message",T:()=>Hu},{no:4,name:"max_preferred_streams",kind:"scalar",T:5}])}}const qu=new pC;class mC extends y{constructor(){super("media.edge.PeerLeaveResponse",[{no:1,name:"closed",kind:"scalar",T:8}])}}const gC=new mC;class fC extends y{constructor(){super("media.edge.ConsumeMultipleProducerResponse",[{no:1,name:"status",kind:"scalar",T:8},{no:2,name:"consumer_ids_map",kind:"message",T:()=>Uv}])}}new fC;class vC extends y{constructor(){super("media.edge.ConsumePeerResponse",[{no:1,name:"status",kind:"scalar",T:8},{no:2,name:"consumer_ids_map",kind:"message",T:()=>Uv},{no:3,name:"description",kind:"message",T:()=>Pr}])}}const yC=new vC;class SC extends y{constructor(){super("media.edge.ProducerCreateResponse",[{no:1,name:"status",kind:"scalar",T:8},{no:2,name:"producer_id",kind:"scalar",T:9},{no:4,name:"description",kind:"message",T:()=>Pr}])}}const TC=new SC;class kC extends y{constructor(){super("media.edge.ProducerScoreResponse",[{no:1,name:"responseid",kind:"scalar",T:9},{no:2,name:"score",kind:"message",T:()=>nI}])}}new kC;class EC extends y{constructor(){super("media.edge.ActiveSpeakerResponse",[{no:1,name:"responsepeer_id",kind:"scalar",T:9},{no:2,name:"volume",kind:"scalar",T:5}])}}new EC;class bC extends y{constructor(){super("media.edge.NoActiveSpeakerResponse",[])}}new bC;class wC extends y{constructor(){super("media.edge.ProducerToggleResponse",[])}}new wC;class _C extends y{constructor(){super("media.edge.ConsumerToggleResponse",[])}}new _C;class IC extends y{constructor(){super("media.edge.ProducerClosingResponse",[{no:1,name:"description",kind:"message",T:()=>Pr}])}}const CC=new IC;class PC extends y{constructor(){super("media.edge.ConsumerClosingResponse",[{no:1,name:"description",kind:"message",T:()=>Pr}])}}const RC=new PC;class MC extends y{constructor(){super("media.edge.GlobalPeerPinningResponse",[])}}new MC;class AC extends y{constructor(){super("media.edge.KickPeerResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}new AC;class DC extends y{constructor(){super("media.edge.KickAllPeersResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}new DC;class OC extends y{constructor(){super("media.edge.HostMediaControlForPeerResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}const NC=new OC;class VC extends y{constructor(){super("media.edge.HostMediaControlForAllPeerResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}const LC=new VC;class xC extends y{constructor(){super("media.edge.PeerDisplayNameEditResponse",[{no:1,name:"status",kind:"scalar",T:9}])}}const UC=new xC;class FC extends y{constructor(){super("media.edge.PeerJoinBroadcastResponse",[{no:1,name:"participant",kind:"message",T:()=>jv}])}}const Am=new FC;class BC extends y{constructor(){super("media.edge.TrackSubscriptionKind",[{no:1,name:"audio",kind:"scalar",T:8},{no:2,name:"video",kind:"scalar",T:8}])}}const Dm=new BC;class WC extends y{constructor(){super("media.edge.TrackSubscription",[{no:1,name:"label",kind:"scalar",T:9},{no:2,name:"webcam",kind:"message",T:()=>Dm},{no:3,name:"screenshare",kind:"message",T:()=>Dm}])}}const jC=new WC;class HC extends y{constructor(){super("media.edge.PeerProducingTransportCreateBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"transport_details",kind:"message",T:()=>xv},{no:3,name:"track_subscriptions",kind:"message",repeat:1,T:()=>jC}])}}new HC;class qC extends y{constructor(){super("media.edge.PeerProducerCreateBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>rc}])}}const GC=new qC;class $C extends y{constructor(){super("media.edge.PeerProducerToggleBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>rc},{no:3,name:"initiator_participant_id",kind:"scalar",opt:!0,T:9}])}}const Om=new $C;class JC extends y{constructor(){super("media.edge.PeerProducerCloseBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"producer_state",kind:"message",T:()=>rc}])}}const KC=new JC;class zC extends y{constructor(){super("media.edge.PeerLeaveBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}const Gu=new zC;class YC extends y{constructor(){super("media.edge.GlobalPeerPinningBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}const Nm=new YC;class QC extends y{constructor(){super("media.edge.GlobalPeerUnPinningBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new QC;class XC extends y{constructor(){super("media.edge.RecordingStartedBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new XC;class ZC extends y{constructor(){super("media.edge.RecordingStoppedBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9}])}}new ZC;class eP extends y{constructor(){super("media.edge.PeerDisplayNameEditBroadcastResponse",[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",T:9}])}}new eP;class tP extends y{constructor(){super("media.edge.PeerPingRequestBroadcastResponse",[{no:1,name:"password",kind:"scalar",T:9}])}}new tP;class rP extends y{constructor(){super("media.edge.MediaRoomTerminationBroadcastResponse",[{no:1,name:"reason",kind:"scalar",T:9}])}}new rP;class iP extends y{constructor(){super("socket.ai.MeetingTranscript",[{no:1,name:"meeting_id",kind:"scalar",T:9},{no:2,name:"transcript",kind:"scalar",T:9},{no:3,name:"is_partial",kind:"scalar",T:8}])}}const Jl=new iP;class sP extends y{constructor(){super("socket.api.BaseSocketHubMessage",[{no:1,name:"event",kind:"scalar",T:5},{no:2,name:"id",kind:"scalar",T:9},{no:3,name:"peer_id",kind:"scalar",T:9},{no:4,name:"room_id",kind:"scalar",T:9},{no:5,name:"user_id",kind:"scalar",T:9},{no:6,name:"payload",kind:"scalar",T:12},{no:7,name:"error",kind:"scalar",opt:!0,T:8},{no:8,name:"sid",kind:"scalar",opt:!0,T:9}])}}new sP;class nP extends y{constructor(){super("socket.api.ErrorMessage",[{no:1,name:"code",kind:"scalar",opt:!0,T:5},{no:2,name:"message",kind:"scalar",T:9}])}}const aP=new nP;var Ds;(function(t){t[t.BROWSER=0]="BROWSER",t[t.TRACK=1]="TRACK",t[t.COMPOSITE=2]="COMPOSITE"})(Ds||(Ds={}));var si;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ON_STAGE=1]="ON_STAGE",t[t.APPROVED_STAGE=2]="APPROVED_STAGE",t[t.REQUESTED_STAGE=3]="REQUESTED_STAGE",t[t.OFF_STAGE=4]="OFF_STAGE"})(si||(si={}));var $u;(function(t){t[t.NONE=0]="NONE",t[t.RECORDER=1]="RECORDER",t[t.LIVESTREAMER=2]="LIVESTREAMER"})($u||($u={}));var Ju;(function(t){t[t.PEERS=0]="PEERS",t[t.ROOMS=1]="ROOMS"})(Ju||(Ju={}));var Yd;(function(t){t[t.HIVE=0]="HIVE",t[t.CHAT=1]="CHAT",t[t.PING=2]="PING"})(Yd||(Yd={}));class oP extends y{constructor(){super("socket.room.PeerFlags",[{no:1,name:"preset_name",kind:"scalar",T:9},{no:2,name:"recorder_type",kind:"scalar",T:9},{no:3,name:"hidden_participant",kind:"scalar",T:8}])}}const cP=new oP;class dP extends y{constructor(){super("socket.room.Peer",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9},{no:3,name:"display_name",kind:"scalar",T:9},{no:4,name:"stage_type",kind:"enum",opt:!0,T:()=>["socket.room.StageType",si,"STAGE_TYPE_"]},{no:5,name:"custom_participant_id",kind:"scalar",opt:!0,T:9},{no:6,name:"preset_id",kind:"scalar",opt:!0,T:9},{no:7,name:"display_picture_url",kind:"scalar",opt:!0,T:9},{no:8,name:"waitlisted",kind:"scalar",T:8},{no:9,name:"flags",kind:"message",T:()=>cP}])}}const _l=new dP;class lP extends y{constructor(){super("socket.room.PeerInfoResponse",[{no:1,name:"peer",kind:"message",T:()=>_l}])}}const Sn=new lP;class uP extends y{constructor(){super("socket.room.PeerStatusUpdate",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9},{no:3,name:"stage_type",kind:"enum",opt:!0,T:()=>["socket.room.StageType",si,"STAGE_TYPE_"]}])}}const Vm=new uP;class hP extends y{constructor(){super("socket.room.RoomPeersInfoRequest",[{no:1,name:"seach_query",kind:"scalar",T:9},{no:2,name:"limit",kind:"scalar",T:5},{no:3,name:"offset",kind:"scalar",T:5}])}}const pP=new hP;class mP extends y{constructor(){super("socket.room.RoomPeersInfoResponse",[{no:1,name:"peers",kind:"message",repeat:1,T:()=>_l}])}}const Kl=new mP;class gP extends y{constructor(){super("socket.room.RoomPeerCountResponse",[{no:1,name:"count",kind:"scalar",T:4,L:2}])}}const Lm=new gP;class fP extends y{constructor(){super("socket.room.Room",[{no:1,name:"room_id",kind:"scalar",T:9},{no:2,name:"title",kind:"scalar",T:9},{no:4,name:"created_at",kind:"scalar",T:4,L:2},{no:5,name:"active_recordings",kind:"message",repeat:1,T:()=>yP},{no:6,name:"room_uuid",kind:"scalar",opt:!0,T:9}])}}const Hv=new fP;class vP extends y{constructor(){super("socket.room.ActiveRecording",[{no:1,name:"recording_id",kind:"scalar",T:9},{no:2,name:"recording_type",kind:"enum",T:()=>["common.RecordingType",Ds]},{no:3,name:"recording_status",kind:"scalar",T:9}])}}const yP=new vP;class SP extends y{constructor(){super("socket.room.RoomInfoResponse",[{no:1,name:"room",kind:"message",T:()=>Hv}])}}const xm=new SP;class TP extends y{constructor(){super("socket.room.GetPeerInfoRequest",[{no:1,name:"peer_id",kind:"scalar",T:9}])}}const qv=new TP;class kP extends y{constructor(){super("socket.room.UpdatePeerInfoRequest",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",opt:!0,T:9}])}}new kP;class EP extends y{constructor(){super("socket.room.JoinRoomRequest",[{no:1,name:"peer",kind:"message",T:()=>_l},{no:3,name:"room_uuid",kind:"scalar",T:9},{no:4,name:"organization_id",kind:"scalar",opt:!0,T:9},{no:5,name:"use_hive",kind:"scalar",opt:!0,T:8},{no:6,name:"preset",kind:"scalar",opt:!0,T:12},{no:7,name:"capabilities",kind:"enum",repeat:1,T:()=>["socket.room.Capabilities",Yd,"CAPABILITIES_"]},{no:8,name:"timestamp",kind:"scalar",opt:!0,T:4,L:2}])}}const bP=new EP;class wP extends y{constructor(){super("socket.room.LeaveRoomRequest",[{no:1,name:"peer",kind:"message",T:()=>_l},{no:2,name:"timestamp",kind:"scalar",opt:!0,T:4,L:2}])}}const _P=new wP;class IP extends y{constructor(){super("socket.room.UpdateRoomInfoRequest",[{no:1,name:"room",kind:"message",T:()=>Hv}])}}new IP;class CP extends y{constructor(){super("socket.room.GetConnectedRoomsDumpRequest",[])}}new CP;class PP extends y{constructor(){super("socket.room.ServiceError",[{no:1,name:"message",kind:"scalar",opt:!0,T:9},{no:2,name:"code",kind:"scalar",opt:!0,T:9}])}}const up=new PP;class RP extends y{constructor(){super("socket.room.ConnectedMeetingPeer",[{no:1,name:"id",kind:"scalar",opt:!0,T:9},{no:2,name:"display_name",kind:"scalar",opt:!0,T:9},{no:3,name:"custom_participant_id",kind:"scalar",opt:!0,T:9},{no:4,name:"preset_id",kind:"scalar",opt:!0,T:9},{no:5,name:"display_picture_url",kind:"scalar",opt:!0,T:9}])}}const MP=new RP;class AP extends y{constructor(){super("socket.room.ConnectedMeetingDump",[{no:1,name:"id",kind:"scalar",opt:!0,T:9},{no:2,name:"title",kind:"scalar",opt:!0,T:9},{no:3,name:"participants",kind:"message",repeat:1,T:()=>MP}])}}const Um=new AP;class DP extends y{constructor(){super("socket.room.GetConnectedRoomsDumpResponse",[{no:1,name:"parent_meeting",kind:"message",T:()=>Um},{no:2,name:"meetings",kind:"message",repeat:1,T:()=>Um}])}}const OP=new DP;class NP extends y{constructor(){super("socket.room.CreateRoomRequestPayload",[{no:1,name:"title",kind:"scalar",opt:!0,T:9}])}}const VP=new NP;class LP extends y{constructor(){super("socket.room.CreateConnectedRoomsRequest",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>VP}])}}const xP=new LP;class UP extends y{constructor(){super("socket.room.CreateRoomResponsePayload",[{no:1,name:"id",kind:"scalar",opt:!0,T:9},{no:2,name:"title",kind:"scalar",opt:!0,T:9},{no:3,name:"error",kind:"message",T:()=>up}])}}const FP=new UP;class BP extends y{constructor(){super("socket.room.CreateConnectedRoomsResponse",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>FP}])}}const Fm=new BP;class WP extends y{constructor(){super("socket.room.UpdateRoomRequestPayload",[{no:1,name:"meeting_id",kind:"scalar",opt:!0,T:9},{no:2,name:"title",kind:"scalar",opt:!0,T:9}])}}const jP=new WP;class HP extends y{constructor(){super("socket.room.UpdateConnectedRoomsRequest",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>jP}])}}new HP;class qP extends y{constructor(){super("socket.room.DisableRoomPayload",[{no:1,name:"id",kind:"scalar",opt:!0,T:9}])}}const GP=new qP;class $P extends y{constructor(){super("socket.room.DisableConnectedRoomsRequest",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>GP}])}}const JP=new $P;class KP extends y{constructor(){super("socket.room.DisableConnectedRoomsResponse",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>QP}])}}const zP=new KP;class YP extends y{constructor(){super("socket.room.DisableConnectedRoomPayload",[{no:1,name:"id",kind:"scalar",opt:!0,T:9},{no:2,name:"status",kind:"scalar",opt:!0,T:9},{no:3,name:"title",kind:"scalar",opt:!0,T:9},{no:4,name:"error",kind:"message",T:()=>up}])}}const QP=new YP;class XP extends y{constructor(){super("socket.room.MovePeerPayload",[{no:1,name:"id",kind:"scalar",opt:!0,T:9},{no:2,name:"preset_id",kind:"scalar",opt:!0,T:9}])}}const ZP=new XP;class eR extends y{constructor(){super("socket.room.MovePeersBetweenRoomsRequest",[{no:1,name:"source_meeting_id",kind:"scalar",opt:!0,T:9},{no:2,name:"destination_meeting_id",kind:"scalar",opt:!0,T:9},{no:3,name:"participants",kind:"message",repeat:1,T:()=>ZP}])}}const tR=new eR;class rR extends y{constructor(){super("socket.room.MovedPeer",[{no:1,name:"meeting_id",kind:"scalar",opt:!0,T:9},{no:2,name:"custom_participant_id",kind:"scalar",opt:!0,T:9},{no:3,name:"error",kind:"message",T:()=>up}])}}const Gv=new rR;class iR extends y{constructor(){super("socket.room.MovePeersBetweenRoomsResponse",[{no:1,name:"payloads",kind:"message",repeat:1,T:()=>Gv}])}}new iR;class sR extends y{constructor(){super("socket.room.TransferPeer",[{no:1,name:"meeting_id",kind:"scalar",opt:!0,T:9},{no:2,name:"auth_token",kind:"scalar",opt:!0,T:9}])}}const nR=new sR;class aR extends y{constructor(){super("socket.room.GetAllAddedParticipantsResponse",[{no:1,name:"participants",kind:"message",repeat:1,T:()=>dR}])}}const oR=new aR;class cR extends y{constructor(){super("socket.room.AddedParticipant",[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",opt:!0,T:9},{no:3,name:"picture",kind:"scalar",opt:!0,T:9},{no:4,name:"custom_participant_id",kind:"scalar",T:9}])}}const dR=new cR;class lR extends y{constructor(){super("socket.room.RemoveParticipantsRequest",[{no:1,name:"peer_ids",kind:"scalar",repeat:2,T:9}])}}const $v=new lR;class uR extends y{constructor(){super("socket.room.BroadcastMessage",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12},{no:3,name:"timestamp",kind:"scalar",T:4,L:2},{no:4,name:"ids",kind:"scalar",repeat:2,T:9},{no:5,name:"broadcast_type",kind:"enum",opt:!0,T:()=>["socket.room.BroadcastType",Ju,"BROADCAST_TYPE_"]}])}}const ba=new uR;class hR extends y{constructor(){super("socket.room.AcceptWaitingRoomRequests",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const pR=new hR;class mR extends y{constructor(){super("socket.room.DenyWaitingRoomRequests",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const gR=new mR;class fR extends y{constructor(){super("socket.room.WaitingRoomRequest",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9},{no:3,name:"display_name",kind:"scalar",T:9},{no:4,name:"picture",kind:"scalar",opt:!0,T:9},{no:5,name:"custom_participant_id",kind:"scalar",opt:!0,T:9},{no:6,name:"preset_name",kind:"scalar",opt:!0,T:9}])}}const vR=new fR;class yR extends y{constructor(){super("socket.room.GetWaitingRoomRequests",[{no:1,name:"requests",kind:"message",repeat:1,T:()=>vR}])}}const Bm=new yR;class SR extends y{constructor(){super("socket.room.GetRoomStageStateResponse",[{no:1,name:"on_stage_peers",kind:"scalar",repeat:2,T:9},{no:2,name:"approved_stage_peers",kind:"scalar",repeat:2,T:9},{no:3,name:"requested_stage_peers",kind:"scalar",repeat:2,T:9}])}}const Wm=new SR;var Ku;(function(t){t[t.NONE=0]="NONE",t[t.SKIP=1]="SKIP",t[t.ON_PRIVILEGED_USER_ENTRY=2]="ON_PRIVILEGED_USER_ENTRY",t[t.SKIP_ON_ACCEPT=3]="SKIP_ON_ACCEPT"})(Ku||(Ku={}));var ji;(function(t){t[t.NONE=0]="NONE",t[t.ALLOWED=1]="ALLOWED",t[t.NOT_ALLOWED=2]="NOT_ALLOWED",t[t.CAN_REQUEST=3]="CAN_REQUEST"})(ji||(ji={}));class TR extends y{constructor(){super("socket.preset.PollsPermissionUpdate",[{no:1,name:"can_create",kind:"scalar",opt:!0,T:8},{no:2,name:"can_vote",kind:"scalar",opt:!0,T:8},{no:3,name:"can_view",kind:"scalar",opt:!0,T:8}])}}const kR=new TR;class ER extends y{constructor(){super("socket.preset.PluginsPermissionsUpdate",[{no:1,name:"can_close",kind:"scalar",opt:!0,T:8},{no:2,name:"can_start",kind:"scalar",opt:!0,T:8}])}}const bR=new ER;class wR extends y{constructor(){super("socket.preset.PublicChatPermission",[{no:1,name:"can_send",kind:"scalar",opt:!0,T:8},{no:2,name:"text",kind:"scalar",opt:!0,T:8},{no:3,name:"files",kind:"scalar",opt:!0,T:8}])}}const _R=new wR;class IR extends y{constructor(){super("socket.preset.PrivateChatPermission",[{no:1,name:"can_send",kind:"scalar",opt:!0,T:8},{no:2,name:"can_receive",kind:"scalar",opt:!0,T:8},{no:3,name:"text",kind:"scalar",opt:!0,T:8},{no:4,name:"files",kind:"scalar",opt:!0,T:8}])}}const CR=new IR;class PR extends y{constructor(){super("socket.preset.ChatPermissionUpdate",[{no:1,name:"public",kind:"message",T:()=>_R},{no:2,name:"private",kind:"message",T:()=>CR}])}}const RR=new PR;class MR extends y{constructor(){super("socket.preset.ConnectedMeetingPermissionUpdate",[{no:1,name:"can_alter_connected_meetings",kind:"scalar",opt:!0,T:8},{no:2,name:"can_switch_to_parent_meeting",kind:"scalar",opt:!0,T:8},{no:3,name:"can_switch_connected_meetings",kind:"scalar",opt:!0,T:8}])}}const AR=new MR;class DR extends y{constructor(){super("socket.preset.StreamPermission",[{no:1,name:"can_produce",kind:"enum",opt:!0,T:()=>["socket.preset.StreamPermissionType",ji,"STREAM_PERMISSION_TYPE_"]},{no:2,name:"can_consume",kind:"enum",opt:!0,T:()=>["socket.preset.StreamPermissionType",ji,"STREAM_PERMISSION_TYPE_"]}])}}const zl=new DR;class OR extends y{constructor(){super("socket.preset.MediaPermissionUpdate",[{no:1,name:"video",kind:"message",T:()=>zl},{no:2,name:"audio",kind:"message",T:()=>zl},{no:3,name:"screenshare",kind:"message",T:()=>zl}])}}const NR=new OR;class VR extends y{constructor(){super("socket.preset.PresetUpdates",[{no:1,name:"polls",kind:"message",T:()=>kR},{no:2,name:"plugins",kind:"message",T:()=>bR},{no:3,name:"chat",kind:"message",T:()=>RR},{no:4,name:"accept_waiting_requests",kind:"scalar",opt:!0,T:8},{no:5,name:"can_accept_production_requests",kind:"scalar",opt:!0,T:8},{no:6,name:"can_edit_display_name",kind:"scalar",opt:!0,T:8},{no:7,name:"can_record",kind:"scalar",opt:!0,T:8},{no:8,name:"can_livestream",kind:"scalar",opt:!0,T:8},{no:9,name:"can_spotlight",kind:"scalar",opt:!0,T:8},{no:10,name:"disable_participant_audio",kind:"scalar",opt:!0,T:8},{no:11,name:"disable_participant_screensharing",kind:"scalar",opt:!0,T:8},{no:12,name:"disable_participant_video",kind:"scalar",opt:!0,T:8},{no:13,name:"kick_participant",kind:"scalar",opt:!0,T:8},{no:14,name:"pin_participant",kind:"scalar",opt:!0,T:8},{no:15,name:"transcription_enabled",kind:"scalar",opt:!0,T:8},{no:16,name:"waiting_room_type",kind:"enum",opt:!0,T:()=>["socket.preset.WaitingRoomType",Ku,"WAITING_ROOM_TYPE_"]},{no:17,name:"is_recorder",kind:"scalar",opt:!0,T:8},{no:18,name:"recorder_type",kind:"enum",opt:!0,T:()=>["socket.room.RecorderType",$u,"RECORDER_TYPE_"]},{no:19,name:"hidden_participant",kind:"scalar",opt:!0,T:8},{no:20,name:"show_participant_list",kind:"scalar",opt:!0,T:8},{no:21,name:"can_change_participant_permissions",kind:"scalar",opt:!0,T:8},{no:22,name:"connected_meetings",kind:"message",T:()=>AR},{no:23,name:"media",kind:"message",T:()=>NR}])}}const hp=new VR;class LR extends y{constructor(){super("socket.preset.ReadPeersPresetRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const xR=new LR;class UR extends y{constructor(){super("socket.preset.PeerPreset",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"peer_id",kind:"scalar",T:9},{no:3,name:"preset",kind:"scalar",T:12}])}}const FR=new UR;class BR extends y{constructor(){super("socket.preset.ReadPeersPresetResponse",[{no:1,name:"peer_presets",kind:"message",repeat:1,T:()=>FR}])}}const WR=new BR;class jR extends y{constructor(){super("socket.preset.UpdatePeerPreset",[{no:1,name:"user_ids",kind:"scalar",T:9},{no:2,name:"patch",kind:"message",T:()=>hp}])}}const Jv=new jR;class HR extends y{constructor(){super("socket.preset.UpdatePeersPresetRequest",[{no:1,name:"update_peers_presets",kind:"message",repeat:1,T:()=>Jv}])}}const qR=new HR;class GR extends y{constructor(){super("socket.preset.UpdatePeersPresetResponse",[{no:1,name:"update_peers_presets",kind:"message",repeat:1,T:()=>Jv}])}}const jm=new GR;class $R extends y{constructor(){super("socket.preset.PeerUserIDMap",[{no:1,name:"peer_id",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9}])}}const JR=new $R;class KR extends y{constructor(){super("socket.preset.BulkUpdatePeerPresetRequest",[{no:1,name:"peers",kind:"message",repeat:1,T:()=>JR},{no:2,name:"patch",kind:"message",T:()=>hp}])}}new KR;class zR extends y{constructor(){super("socket.preset.BulkUpdatePeerPresetResponse",[{no:2,name:"patch",kind:"message",T:()=>hp}])}}new zR;class YR extends y{constructor(){super("socket.chat.ChatMessage",[{no:1,name:"chat_id",kind:"scalar",T:9},{no:2,name:"peer_id",kind:"scalar",T:9},{no:3,name:"user_id",kind:"scalar",T:9},{no:4,name:"display_name",kind:"scalar",T:9},{no:5,name:"pinned",kind:"scalar",T:8},{no:6,name:"is_edited",kind:"scalar",T:8},{no:7,name:"payload_type",kind:"scalar",T:5},{no:8,name:"payload",kind:"scalar",T:9},{no:10,name:"target_user_ids",kind:"scalar",repeat:2,T:9},{no:11,name:"created_at",kind:"scalar",T:4,L:2},{no:12,name:"created_at_ms",kind:"scalar",opt:!0,T:4,L:2},{no:13,name:"channel_id",kind:"scalar",opt:!0,T:9},{no:14,name:"channel_index",kind:"scalar",opt:!0,T:9}])}}const js=new YR;class QR extends y{constructor(){super("socket.chat.GetPaginatedChatMessageRoomRequest",[{no:1,name:"time_stamp",kind:"scalar",T:4,L:2},{no:2,name:"size",kind:"scalar",T:5},{no:3,name:"from",kind:"scalar",T:5},{no:4,name:"reversed",kind:"scalar",T:8},{no:5,name:"channel_id",kind:"scalar",opt:!0,T:9}])}}const XR=new QR;class ZR extends y{constructor(){super("socket.chat.GetPaginatedChatMessageRoomResponse",[{no:1,name:"messages",kind:"message",repeat:1,T:()=>js},{no:2,name:"next",kind:"scalar",T:8}])}}const eM=new ZR;class tM extends y{constructor(){super("socket.chat.GetChatMessagesResponse",[{no:1,name:"messages",kind:"message",repeat:1,T:()=>js}])}}const Kv=new tM;class rM extends y{constructor(){super("socket.chat.SendChatMessageToRoomRequest",[{no:1,name:"payload_type",kind:"scalar",T:5},{no:2,name:"payload",kind:"scalar",T:9}])}}const iM=new rM;class sM extends y{constructor(){super("socket.chat.SendChatMessageToRoomResponse",[{no:1,name:"message",kind:"message",T:()=>js}])}}const Yl=new sM;class nM extends y{constructor(){super("socket.chat.SendChatMessageToPeersRequest",[{no:1,name:"peer_ids",kind:"scalar",repeat:2,T:9},{no:2,name:"payload_type",kind:"scalar",T:5},{no:3,name:"payload",kind:"scalar",T:9}])}}const aM=new nM;class oM extends y{constructor(){super("socket.chat.SendChatMessageToPeersResponse",[{no:1,name:"message",kind:"message",T:()=>js}])}}const Ql=new oM;class cM extends y{constructor(){super("socket.chat.SendChatMessageToChannelRequest",[{no:1,name:"channel_id",kind:"scalar",T:9},{no:2,name:"payload_type",kind:"scalar",T:5},{no:3,name:"payload",kind:"scalar",T:9}])}}const dM=new cM;class lM extends y{constructor(){super("socket.chat.SendChatMessageToChannelResponse",[{no:1,name:"message",kind:"message",T:()=>js}])}}new lM;class uM extends y{constructor(){super("socket.chat.EditChatMessageRequest",[{no:1,name:"chat_id",kind:"scalar",T:9},{no:2,name:"payload_type",kind:"scalar",opt:!0,T:5},{no:3,name:"payload",kind:"scalar",opt:!0,T:9},{no:4,name:"pinned",kind:"scalar",opt:!0,T:8},{no:5,name:"channel_id",kind:"scalar",opt:!0,T:9}])}}const hM=new uM;class pM extends y{constructor(){super("socket.chat.PinChatMessageRequest",[{no:1,name:"chat_id",kind:"scalar",T:9},{no:2,name:"pinned",kind:"scalar",T:8},{no:3,name:"channel_id",kind:"scalar",opt:!0,T:9}])}}const mM=new pM;class gM extends y{constructor(){super("socket.chat.PinChatMessageResponse",[{no:1,name:"chat_id",kind:"scalar",T:9},{no:2,name:"pinned",kind:"scalar",T:8},{no:3,name:"channel_id",kind:"scalar",opt:!0,T:9}])}}const yc=new gM;class fM extends y{constructor(){super("socket.chat.EditChatMessageResponse",[{no:1,name:"message",kind:"message",T:()=>js}])}}const Sc=new fM;class vM extends y{constructor(){super("socket.chat.DeleteChatMessageRequest",[{no:1,name:"chat_id",kind:"scalar",T:9},{no:2,name:"channel_id",kind:"scalar",opt:!0,T:9}])}}const yM=new vM;class SM extends y{constructor(){super("socket.chat.DeleteChatMessageResponse",[{no:1,name:"chat_id",kind:"scalar",T:9},{no:2,name:"channel_id",kind:"scalar",opt:!0,T:9}])}}const Tc=new SM;class TM extends y{constructor(){super("socket.chat.SearchChatMessagesRequest",[{no:1,name:"time_stamp",kind:"scalar",T:4,L:2},{no:2,name:"size",kind:"scalar",T:5},{no:3,name:"from",kind:"scalar",T:5},{no:4,name:"reversed",kind:"scalar",T:8},{no:5,name:"channel_id",kind:"scalar",opt:!0,T:9},{no:6,name:"search_term",kind:"scalar",T:9}])}}const kM=new TM;class EM extends y{constructor(){super("socket.chat.MarkChannelIndexAsReadRequest",[{no:1,name:"channel_id",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9},{no:3,name:"channel_index",kind:"scalar",T:9}])}}const bM=new EM;class wM extends y{constructor(){super("socket.chat.MarkChannelIndexAsReadResponse",[{no:1,name:"channel_index",kind:"scalar",T:9}])}}const _M=new wM;class IM extends y{constructor(){super("socket.chat.CreateChatChannelRequest",[{no:1,name:"display_name",kind:"scalar",T:9},{no:2,name:"target_user_ids",kind:"scalar",repeat:2,T:9},{no:3,name:"display_picture_url",kind:"scalar",opt:!0,T:9},{no:4,name:"visibility",kind:"scalar",T:9},{no:5,name:"is_direct_message",kind:"scalar",T:8}])}}const CM=new IM;class PM extends y{constructor(){super("socket.chat.UpdateChatChannelRequest",[{no:1,name:"chat_channel_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",opt:!0,T:9},{no:3,name:"target_user_ids",kind:"scalar",repeat:2,T:9},{no:4,name:"display_picture_url",kind:"scalar",opt:!0,T:9},{no:5,name:"visibility",kind:"scalar",opt:!0,T:9},{no:6,name:"is_direct_message",kind:"scalar",opt:!0,T:8}])}}const RM=new PM;class MM extends y{constructor(){super("socket.chat.CreateChatChannelResponse",[{no:1,name:"chat_channel_id",kind:"scalar",T:9}])}}new MM;class AM extends y{constructor(){super("socket.chat.GetChatChannelRequest",[{no:1,name:"chat_channel_id",kind:"scalar",T:9}])}}const DM=new AM;class OM extends y{constructor(){super("socket.chat.LatestMessageAndUnreadCount",[{no:1,name:"message",kind:"message",T:()=>js},{no:2,name:"unread_count",kind:"scalar",T:4,L:2}])}}const NM=new OM;class VM extends y{constructor(){super("socket.chat.ChatChannel",[{no:1,name:"chat_channel_id",kind:"scalar",T:9},{no:2,name:"display_name",kind:"scalar",T:9},{no:3,name:"display_picture_url",kind:"scalar",opt:!0,T:9},{no:4,name:"visibility",kind:"scalar",T:9},{no:5,name:"is_direct_message",kind:"scalar",T:8},{no:6,name:"latest_message_and_unread_count",kind:"message",T:()=>NM},{no:7,name:"target_user_ids",kind:"scalar",repeat:2,T:9}])}}const LM=new VM;class xM extends y{constructor(){super("socket.chat.GetChatChannelResponse",[{no:1,name:"chat_channels",kind:"message",repeat:1,T:()=>LM}])}}const Jr=new xM;class UM extends y{constructor(){super("socket.chat.ChannelMember",[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",opt:!0,T:9},{no:3,name:"picture",kind:"scalar",opt:!0,T:9},{no:4,name:"custom_participant_id",kind:"scalar",T:9}])}}const FM=new UM;class BM extends y{constructor(){super("socket.chat.GetChatChannelMembersResponse",[{no:1,name:"channel_members",kind:"message",repeat:1,T:()=>FM}])}}const WM=new BM;class jM extends y{constructor(){super("socket.plugin.AddPluginRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"staggered",kind:"scalar",T:8}])}}const HM=new jM;class qM extends y{constructor(){super("socket.plugin.RemovePluginRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"staggered",kind:"scalar",T:8}])}}const GM=new qM;class $M extends y{constructor(){super("socket.plugin.EnablePluginForRoomRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9}])}}const JM=new $M;class KM extends y{constructor(){super("socket.plugin.DisablePluginForRoomRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9}])}}const zM=new KM;class YM extends y{constructor(){super("socket.plugin.EnablePluginForPeersRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"peer_ids",kind:"scalar",repeat:2,T:9}])}}const QM=new YM;class XM extends y{constructor(){super("socket.plugin.DisablePluginForPeersRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"peer_ids",kind:"scalar",repeat:2,T:9}])}}const ZM=new XM;class eA extends y{constructor(){super("socket.plugin.PluginEventToRoomRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"plugin_data",kind:"scalar",T:12}])}}const tA=new eA;class rA extends y{constructor(){super("socket.plugin.PluginEventToPeersRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"peer_ids",kind:"scalar",repeat:2,T:9},{no:3,name:"plugin_data",kind:"scalar",T:12}])}}const iA=new rA;class sA extends y{constructor(){super("socket.plugin.StoreKeys",[{no:1,name:"store_key",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",opt:!0,T:12}])}}const pp=new sA;class nA extends y{constructor(){super("socket.plugin.PluginStoreInsertKeysRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"store_name",kind:"scalar",T:9},{no:3,name:"insert_keys",kind:"message",repeat:1,T:()=>pp}])}}const Hm=new nA;class aA extends y{constructor(){super("socket.plugin.PluginStoreGetKeysRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"store_name",kind:"scalar",T:9},{no:3,name:"get_keys",kind:"message",repeat:1,T:()=>pp}])}}const oA=new aA;class cA extends y{constructor(){super("socket.plugin.PluginStoreDeleteKeysRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"store_name",kind:"scalar",T:9},{no:3,name:"delete_keys",kind:"message",repeat:1,T:()=>pp}])}}const dA=new cA;class lA extends y{constructor(){super("socket.plugin.PluginStoreDeleteRequest",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"store_name",kind:"scalar",T:9}])}}const uA=new lA;class hA extends y{constructor(){super("socket.plugin.EnablePluginResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"enabled_by",kind:"scalar",T:9}])}}const zu=new hA;class pA extends y{constructor(){super("socket.plugin.EnablePluginsResponse",[{no:1,name:"plugins",kind:"message",repeat:1,T:()=>zu}])}}const mA=new pA;class gA extends y{constructor(){super("socket.plugin.DisablePluginResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"disabled_by",kind:"scalar",T:9}])}}const qm=new gA;class fA extends y{constructor(){super("socket.plugin.PluginStoreItem",[{no:1,name:"timestamp",kind:"scalar",T:9},{no:2,name:"peer_id",kind:"scalar",T:9},{no:3,name:"store_key",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}])}}const vA=new fA;class yA extends y{constructor(){super("socket.plugin.PluginStoreResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"store_name",kind:"scalar",T:9},{no:3,name:"store_items",kind:"message",repeat:1,T:()=>vA}])}}const Gm=new yA;class SA extends y{constructor(){super("socket.plugin.PluginEventResponse",[{no:1,name:"plugin_id",kind:"scalar",T:9},{no:2,name:"plugin_data",kind:"scalar",T:12}])}}const $m=new SA;class TA extends y{constructor(){super("socket.livestreaming.LiveStreamingEvent",[{no:1,name:"livestream_id",kind:"scalar",T:9},{no:2,name:"err_message",kind:"scalar",T:9},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"meeting_id",kind:"scalar",T:9},{no:5,name:"playback_url",kind:"scalar",T:9},{no:6,name:"org_id",kind:"scalar",T:9},{no:7,name:"room_name",kind:"scalar",T:9},{no:8,name:"room_uuid",kind:"scalar",T:9},{no:9,name:"status",kind:"scalar",T:9},{no:10,name:"manual_ingest",kind:"scalar",opt:!0,T:8}])}}const Jm=new TA;class kA extends y{constructor(){super("socket.livestreaming.GetStagePeersResponse",[{no:1,name:"stage_peers",kind:"scalar",repeat:2,T:9}])}}const Km=new kA;class EA extends y{constructor(){super("socket.livestreaming.StageRequest",[{no:1,name:"display_name",kind:"scalar",T:9},{no:2,name:"user_id",kind:"scalar",T:9},{no:3,name:"peer_id",kind:"scalar",T:9}])}}const bA=new EA;class wA extends y{constructor(){super("socket.livestreaming.GetStageRequestsResponse",[{no:1,name:"stage_requests",kind:"message",repeat:1,T:()=>bA}])}}const Xl=new wA;class _A extends y{constructor(){super("socket.livestreaming.GrantStageAccessRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const IA=new _A;class CA extends y{constructor(){super("socket.livestreaming.DenyStageAccessRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const PA=new CA;class RA extends y{constructor(){super("socket.livestreaming.LeaveStageRequest",[{no:1,name:"user_ids",kind:"scalar",repeat:2,T:9}])}}const zm=new RA;class MA extends y{constructor(){super("socket.polls.Poll",[{no:1,name:"poll_id",kind:"scalar",T:9},{no:2,name:"created_by",kind:"scalar",T:9},{no:3,name:"created_by_user_id",kind:"scalar",T:9},{no:4,name:"question",kind:"scalar",T:9},{no:5,name:"options",kind:"message",repeat:1,T:()=>DA},{no:6,name:"hide_votes",kind:"scalar",T:8},{no:7,name:"anonymous",kind:"scalar",T:8},{no:8,name:"votes",kind:"scalar",repeat:2,T:9}])}}const zv=new MA;class AA extends y{constructor(){super("socket.polls.PollOption",[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"count",kind:"scalar",opt:!0,T:4,L:2},{no:3,name:"votes",kind:"message",repeat:1,T:()=>NA}])}}const DA=new AA;class OA extends y{constructor(){super("socket.polls.PollVote",[{no:1,name:"user_id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9}])}}const NA=new OA;class VA extends y{constructor(){super("socket.polls.NewPollRequest",[{no:1,name:"question",kind:"scalar",T:9},{no:2,name:"options",kind:"scalar",repeat:2,T:9},{no:3,name:"anonymous",kind:"scalar",T:8},{no:4,name:"hide_votes",kind:"scalar",T:8},{no:5,name:"created_by",kind:"scalar",opt:!0,T:9},{no:6,name:"created_by_user_id",kind:"scalar",opt:!0,T:9}])}}const LA=new VA;class xA extends y{constructor(){super("socket.polls.VotePollRequest",[{no:1,name:"poll_id",kind:"scalar",T:9},{no:2,name:"index",kind:"scalar",T:4,L:2}])}}const UA=new xA;class FA extends y{constructor(){super("socket.polls.UpdatePollResponse",[{no:1,name:"poll",kind:"message",T:()=>zv}])}}const Zl=new FA;class BA extends y{constructor(){super("socket.polls.GetPollsResponse",[{no:1,name:"polls",kind:"message",repeat:1,T:()=>zv}])}}const WA=new BA;class jA extends y{constructor(){super("socket.recording.RecordingEvent",[{no:1,name:"recording_id",kind:"scalar",T:9},{no:2,name:"err_message",kind:"scalar",T:9},{no:3,name:"recording_type",kind:"enum",T:()=>["common.RecordingType",Ds]}])}}const Ym=new jA;class HA extends y{constructor(){super("google.protobuf.Timestamp",[{no:1,name:"seconds",kind:"scalar",T:3,L:0},{no:2,name:"nanos",kind:"scalar",T:5}])}now(){const e=this.create(),r=Date.now();return e.seconds=ke.from(Math.floor(r/1e3)).toBigInt(),e.nanos=r%1e3*1e6,e}toDate(e){return new Date(ke.from(e.seconds).toNumber()*1e3+Math.ceil(e.nanos/1e6))}fromDate(e){const r=this.create(),i=e.getTime();return r.seconds=ke.from(Math.floor(i/1e3)).toBigInt(),r.nanos=i%1e3*1e6,r}internalJsonWrite(e,r){let i=ke.from(e.seconds).toNumber()*1e3;if(i<Date.parse("0001-01-01T00:00:00Z")||i>Date.parse("9999-12-31T23:59:59Z"))throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");if(e.nanos<0)throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");let s="Z";if(e.nanos>0){let n=(e.nanos+1e9).toString().substring(1);n.substring(3)==="000000"?s="."+n.substring(0,3)+"Z":n.substring(6)==="000"?s="."+n.substring(0,6)+"Z":s="."+n+"Z"}return new Date(i).toISOString().replace(".000Z",s)}internalJsonRead(e,r,i){if(typeof e!="string")throw new Error("Unable to parse Timestamp from JSON "+Kh(e)+".");let s=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!s)throw new Error("Unable to parse Timestamp from JSON. Invalid format.");let n=Date.parse(s[1]+"-"+s[2]+"-"+s[3]+"T"+s[4]+":"+s[5]+":"+s[6]+(s[8]?s[8]:"Z"));if(Number.isNaN(n))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(n<Date.parse("0001-01-01T00:00:00Z")||n>Date.parse("9999-12-31T23:59:59Z"))throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");return i||(i=this.create()),i.seconds=ke.from(n/1e3).toBigInt(),i.nanos=0,s[7]&&(i.nanos=parseInt("1"+s[7]+"0".repeat(9-s[7].length))-1e9),i}}new HA;class qA extends y{constructor(){super("common.BaseHubMessage",[{no:1,name:"event",kind:"scalar",T:5},{no:2,name:"id",kind:"scalar",T:9},{no:3,name:"peer_id",kind:"scalar",T:9},{no:4,name:"room_id",kind:"scalar",T:9},{no:5,name:"user_id",kind:"scalar",T:9},{no:6,name:"payload",kind:"scalar",T:12},{no:7,name:"error",kind:"scalar",opt:!0,T:8},{no:8,name:"sid",kind:"scalar",opt:!0,T:9},{no:9,name:"room_object_id",kind:"scalar",opt:!0,T:9},{no:10,name:"preset",kind:"scalar",opt:!0,T:9},{no:11,name:"use_start_session",kind:"scalar",opt:!0,T:8}])}}const Yu=new qA;class GA extends y{constructor(){super("common.BulkedHubMessage",[{no:1,name:"messages",kind:"message",repeat:1,T:()=>Yu}])}}new GA;class $A extends y{constructor(){super("common.CFWorkersResponse",[{no:1,name:"responses",kind:"message",repeat:1,T:()=>Yu},{no:2,name:"broadcast_responses",kind:"message",repeat:1,T:()=>Yu}])}}new $A;const JA=0,KA=1,zA=2,YA=3,QA=4,XA=5,ZA={getPeerInfo:0,updatePeerInfo:1,getRoomPeersInfo:2,joinRoom:3,leaveRoom:4,getRoomInfo:5,updateRoomInfo:6,closeRoom:7,startedLivestream:8,stoppedLivestream:9,erroredLivestream:10,getStagePeers:11,getStageRequests:12,requestStageAccess:13,cancelStageRequest:14,grantStageAccess:15,denyStageAccess:16,roomPeerCount:17,joinStage:18,leaveStage:19,getConnectedRoomsDump:20,createConnectedRooms:21,deleteConnectedRooms:22,movePeers:23,transferPeer:24,movedPeer:25,connectedRoomsUpdated:26,connectedRoomsDeleted:27,getAllAddedParticipants:28,broadcastMessage:29,kick:30,kickAll:31,transcript:32,getWaitingRoomRequests:33,acceptWaitingRoomRequests:34,waitingRoomRequestAccepted:35,denyWaitingRoomRequests:36,waitingRoomRequestDenied:37,peerStageStatusUpdate:38,broadcastToEntity:39,recordingStarted:40,recordingStopped:41,recordingPaused:42,getRoomStageState:43,livestreamingInvoked:44},eD={getMessages:0,sendMessageToRoom:1,sendMessageToPeers:2,editMessage:3,deleteMessage:4,getPaginatedMessages:5,sendMessageToChannel:6,searchChannelMessages:7,getAllChatChannels:8,markChannelIndexAsRead:9,pinMessage:10},tD={getPlugins:0,addPlugin:1,enablePluginForRoom:2,disablePluginForPeers:3,enablePluginForPeers:4,disablePluginForRoom:5,removePlugin:6,customPluginEventToRoom:7,customPluginEventToPeers:8,storeInsertKeys:9,storeGetKeys:10,storeDeleteKeys:11,storeDelete:12},rD={createPoll:0,getPolls:1,votePoll:2,updatePoll:3},Yv={unknown:0,createWebRTCTransport:1,produce:2,consume:3,toggleProducer:4,toggleConsumer:5,closeProducer:6,closeConsumer:7,updateConsumersSimulcastConfig:8,joinRoom:16,leaveRoom:17,selectedPeer:18,globalPinPeer:19,selfJoinComplete:20,peerJoinedBroadcast:25,peerLeaveBroadcast:26,peerProducerCreateBroadcast:27,peerProducerToggleBroadcast:28,peerProducerCloseBroadcast:29,globalPeerPinBroadcast:30,recordingStartedBroadcast:31,recordingStoppedBroadcast:32,peerDisplayNameEditBroadcast:33,mediaRoomTerminationBroadcastResponse:36,selectedPeerDiff:40,renegotiateSessionDescription:50,errorResponse:60,kickPeer:90,kickAll:91,changeDisplayName:92,hostControlPeer:93,hostControlAllPeers:94,audioActivity:100},iD={createChatChannel:0,getChatChannel:1,deprecatedGetAllChatChannels:2,getChannelMembers:3,updateChatChannel:4},sD={getUserPresets:0,updateUserPreset:1};function ia(t,e){return Object.keys(e).reduce((r,i)=>(r[i]=(t<<16)+e[i],r),{})}function Qv(t,e){return Object.keys(t).reduce((r,i)=>(r[i]=e|t[i],r),{})}const F=ia(JA,ZA),Ae=ia(KA,eD),$=ia(zA,tD),ei=ia(YA,rD),_s=ia(QA,iD),cr=Qv(Yv,16777216),br=Qv(Yv,50331648),Kc=ia(XA,sD);var nD=Object.defineProperty,aD=Object.getOwnPropertyDescriptor,mp=(t,e,r,i)=>{for(var s=i>1?void 0:i?aD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&nD(e,r,s),s},Zi,wa,Qm;const Qu=(Qm=class{constructor(t,e){g(this,Zi,void 0),g(this,wa,void 0),f(this,Zi,e),f(this,wa,t)}get telemetry(){return a(this,wa).getValue("telemetry")}get logger(){return a(this,wa).getValue("logger")}createChannel(t,e,r,i="public",s=!1){return u(this,null,function*(){const n={displayName:t,targetUserIds:e,displayPictureUrl:r,visibility:i,isDirectMessage:s};s&&(n.visibility="private");const o=yield a(this,Zi).sendMessagePromise(_s.createChatChannel,CM.toBinary(n)),c=Jr.fromBinary(o.payload).chatChannels;return Qu.formatChannel(c[0])})}updateChannel(t,e){return u(this,null,function*(){const r=yield a(this,Zi).sendMessagePromise(_s.updateChatChannel,RM.toBinary({chatChannelId:t,targetUserIds:e.memberIds,displayName:e.displayName,displayPictureUrl:e.displayPictureUrl,visibility:e.visibility})),i=Jr.fromBinary(r.payload).chatChannels;return Qu.formatChannel(i[0])})}static formatChannel(t){var e;const{latestMessageAndUnreadCount:r}=t,i=G(V({},t),{id:t.chatChannelId,memberIds:t.targetUserIds,unreadCount:(e=r==null?void 0:r.unreadCount)!=null?e:0});return r!=null&&r.message&&(i.latestMessage=oi.formatSocketServiceMessage(r.message)),delete i.chatChannelId,delete i.targetUserIds,delete i.latestMessageAndUnreadCount,i}getChannelMembers(t){return u(this,null,function*(){try{const e=yield a(this,Zi).sendMessagePromise(_s.getChannelMembers,DM.toBinary({chatChannelId:t}));return WM.fromBinary(e.payload).channelMembers.map(r=>{var i=r,{id:s}=i,n=fl(i,["id"]);return G(V({},n),{userId:s})})}catch{return[]}})}on(t,e){let r,i;switch(t){case _s.createChatChannel:{r=Jr.fromBinary.bind(Jr),i=Jr.create();break}case _s.updateChatChannel:{r=Jr.fromBinary.bind(Jr),i=Jr.create();break}}if(!r){this.logger.warn(`ChatChannelSocketHandler::Event ${t} is not recognized`);return}a(this,Zi).on(t,({payload:s})=>{let n=i;try{n=r(s)}catch(o){this.logger.error("ChatChannelSocketHandler::on::binary_decode_error",{error:o})}return e(n)})}},Zi=new WeakMap,wa=new WeakMap,Qm);let Vs=Qu;mp([k.trace("ChatChannelHandler.createChannel")],Vs.prototype,"createChannel",1);mp([k.trace("ChatChannelHandler.updateChannel")],Vs.prototype,"updateChannel",1);mp([k.trace("ChatChannelHandler.getChannelMembers")],Vs.prototype,"getChannelMembers",1);var oD=Object.defineProperty,cD=Object.getOwnPropertyDescriptor,Rr=(t,e,r,i)=>{for(var s=i>1?void 0:i?cD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&oD(e,r,s),s},_t=(t=>(t[t.TEXT=0]="TEXT",t[t.IMAGE=1]="IMAGE",t[t.FILE=2]="FILE",t[t.CUSTOM=3]="CUSTOM",t))(_t||{}),bt,ao;class dr{constructor(e,r){g(this,bt,void 0),g(this,ao,void 0),f(this,bt,r),f(this,ao,e)}get telemetry(){return a(this,ao).getValue("telemetry")}get logger(){return a(this,ao).getValue("logger")}getChatMessages(){return a(this,bt).sendMessagePromise(Ae.getMessages)}getChatMessagesPaginated(e,r,i,s=0,n=""){return u(this,null,function*(){const o={timeStamp:e,size:r,from:s,reversed:i,channelId:n},c=yield a(this,bt).sendMessagePromise(Ae.getPaginatedMessages,XR.toBinary(o));return c.payload?eM.fromBinary(c.payload):{messages:[],next:!1}})}sendMessageToRoom(e,r){const i={payloadType:r,payload:e};a(this,bt).sendMessage(Ae.sendMessageToRoom,iM.toBinary(i))}sendMessageToPeers(e,r,i){const s={payloadType:r,peerIds:i,payload:e};a(this,bt).sendMessage(Ae.sendMessageToPeers,aM.toBinary(s))}sendMessageToChannel(e,r,i){const s={payloadType:r,channelId:i,payload:e};a(this,bt).sendMessage(Ae.sendMessageToChannel,dM.toBinary(s))}sendMessage(e,r,i,s){if(s&&this.sendMessageToChannel(e,r,s),i&&i.length>0){this.sendMessageToPeers(e,r,i);return}this.sendMessageToRoom(e,r)}editMessage(e,r,i,s,n){return u(this,null,function*(){const o={chatId:e,payloadType:i,payload:r};s&&(o.channelId=s),n!==void 0&&(o.pinned=n);const c=yield a(this,bt).sendMessagePromise(Ae.editMessage,hM.toBinary(o));return Sc.fromBinary(c.payload).message})}deleteMessage(e,r){return u(this,null,function*(){const i={chatId:e};r&&(i.channelId=r);const s=yield a(this,bt).sendMessagePromise(Ae.deleteMessage,yM.toBinary(i)),n=Tc.fromBinary(s.payload);return V({id:n.chatId},n.channelId?{channelId:n.channelId}:{})})}searchMessages(e,r){return u(this,null,function*(){var i,s,n;const o={searchTerm:e,timeStamp:(i=r.timestamp)!=null?i:Date.now(),size:(s=r.size)!=null?s:75,from:0,reversed:(n=r.reversed)!=null?n:!0};r.channelId&&(o.channelId=r.channelId);try{const c=yield a(this,bt).sendMessagePromise(Ae.searchChannelMessages,kM.toBinary(o));return Kv.fromBinary(c.payload).messages}catch{return[]}})}getAllChannels(){return u(this,null,function*(){try{const e=yield a(this,bt).sendMessagePromise(Ae.getAllChatChannels);return Jr.fromBinary(e.payload).chatChannels.map(Vs.formatChannel)}catch{return[]}})}markLastReadMessage(e,r){return u(this,null,function*(){const i=yield a(this,bt).sendMessagePromise(Ae.markChannelIndexAsRead,bM.toBinary({channelId:e,userId:r.userId,channelIndex:r.channelIndex}));return _M.fromBinary(i.payload).channelIndex})}setPinState(e,r){return u(this,null,function*(){const i={chatId:e.id,pinned:r,channelId:e.channelId},s=yield a(this,bt).sendMessagePromise(Ae.pinMessage,mM.toBinary(i));return yc.fromBinary(s.payload)})}on(e,r){let i,s;switch(e){case Ae.sendMessageToRoom:{i=Yl.fromBinary.bind(Yl),s=Yl.create();break}case Ae.sendMessageToPeers:{i=Ql.fromBinary.bind(Ql),s=Ql.create();break}case Ae.editMessage:{i=Sc.fromBinary.bind(Sc),s=Sc.create();break}case Ae.pinMessage:{i=yc.fromBinary.bind(yc),s=yc.create();break}case Ae.deleteMessage:{i=Tc.fromBinary.bind(Tc),s=Tc.create();break}}if(!i){this.logger.warn(`ChatSocketHandler::Event ${e} is not recognized`);return}a(this,bt).on(e,({payload:n})=>{let o=s;try{o=i(n)}catch(c){this.logger.error("chatSocketHandler::on::binary_decode_error",{error:c})}return r(o)})}}bt=new WeakMap,ao=new WeakMap;Rr([k.trace("SocketService.getChatMessages")],dr.prototype,"getChatMessages",1);Rr([k.trace("SocketService.getChatMessagesPaginated")],dr.prototype,"getChatMessagesPaginated",1);Rr([k.trace("SocketService.sendMessageToRoom")],dr.prototype,"sendMessageToRoom",1);Rr([k.trace("SocketService.sendMessageToPeers")],dr.prototype,"sendMessageToPeers",1);Rr([k.trace("SocketService.sendMessageToChannel")],dr.prototype,"sendMessageToChannel",1);Rr([k.trace("SocketService.sendMessage")],dr.prototype,"sendMessage",1);Rr([k.trace("SocketService.editMessage")],dr.prototype,"editMessage",1);Rr([k.trace("SocketService.deleteMessage")],dr.prototype,"deleteMessage",1);Rr([k.trace("SocketService.searchMessages")],dr.prototype,"searchMessages",1);Rr([k.trace("SocketService.getAllChannels")],dr.prototype,"getAllChannels",1);Rr([k.trace("SocketService.markLastReadMessage")],dr.prototype,"markLastReadMessage",1);function dD(t){return t.replace(/([-_]\w)/g,e=>e[1].toUpperCase())}function _r(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(r=>_r(r));const e={};return Object.keys(t).forEach(r=>{const i=Jh(r)?r:dD(r);e[i]=_r(t[r])}),e}function lD(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function Xv(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(r=>Xv(r));const e={};return Object.keys(t).forEach(r=>{const i=Jh(r)?r:lD(r);e[i]=t[r]}),e}function Qd(t,e={}){return t==null?{}:(Object.getOwnPropertyNames(t).forEach(r=>{if(typeof t[r]!="function"){if(typeof t[r]=="object"){Qd(t[r],e[r]={});return}e[r]=t[r]}}),e)}class Xm{constructor(e){m(this,"defaults"),this.defaults={baseURL:e.baseURL,headers:{common:{}},timeout:e.timeout,retry:e.retry,retryDelay:e.retryDelay}}buildURL(e,r){const{baseURL:i}=this.defaults,s=e.startsWith("http")?e:`${i}${e.startsWith("/")?e:`/${e}`}`;if(r){const n=new URLSearchParams;return Object.entries(r).forEach(([o,c])=>{n.append(o,c)}),`${s}${s.includes("?")?"&":"?"}${n.toString()}`}return s}request(e){return u(this,null,function*(){var r;const i=((r=e.method)==null?void 0:r.toUpperCase())||"GET",s=this.buildURL(e.url||"",e.params),n=V(V({},this.defaults.headers.common),e.headers);i!=="GET"&&i!=="HEAD"&&e.data&&!n["Content-Type"]&&(n["Content-Type"]="application/json");const o=n["Content-Type"]==="application/json"?JSON.stringify(e.data):e.data,c={method:i,headers:n,body:i!=="GET"&&i!=="HEAD"&&e.data?o:void 0},d=e.timeout||this.defaults.timeout,l=e.retry!==void 0?e.retry:this.defaults.retry,h=e.retryDelay||this.defaults.retryDelay;try{const p=new AbortController,v=setTimeout(()=>p.abort(),d);c.signal=p.signal;const T=yield fetch(s,c);clearTimeout(v);let E=null;const C=T.headers.get("content-type");C&&C.includes("application/json")?E=yield T.json():E=yield T.text();const b={};T.headers.forEach((j,W)=>{b[W]=j});const P={data:E,status:T.status,statusText:T.statusText,headers:b,config:e};if(!T.ok)throw P;return P}catch(p){if(p instanceof Error&&l>0)return yield new Promise(v=>setTimeout(v,h)),this.defaults.baseURL==="https://api.dyte.io"?this.defaults.baseURL="https://api.cluster.dyte.in":this.defaults.baseURL==="https://api.cluster.dyte.in"&&(this.defaults.baseURL="https://api.dyte.io"),this.request(G(V({},e),{retry:l-1}));throw p}})}get(e){return u(this,arguments,function*(r,i={}){return this.request(G(V({},i),{method:"GET",url:r}))})}post(e,r){return u(this,arguments,function*(i,s,n={}){return this.request(G(V({},n),{method:"POST",url:i,data:s}))})}put(e,r){return u(this,arguments,function*(i,s,n={}){return this.request(G(V({},n),{method:"PUT",url:i,data:s}))})}}const uD=3,hD=30,pD=8e3;class mD{constructor(e,r){m(this,"ipInfo"),m(this,"fetchClient"),m(this,"requests"),m(this,"roomName"),m(this,"roomUUID"),m(this,"authToken"),m(this,"organizationId"),m(this,"iceServers"),m(this,"pluginInformation"),m(this,"userDetails"),m(this,"roomDetails"),m(this,"context"),this.context=e;const{timeout:i=pD,retry:s=uD,retryDelay:n=hD,baseURL:o="https://api.dyte.io",authToken:c,cachedUserDetails:d}=r||{};this.iceServers=d==null?void 0:d.iceServers,this.pluginInformation=d==null?void 0:d.pluginInformation,this.userDetails=d==null?void 0:d.userDetails,this.roomDetails=d==null?void 0:d.roomDetails,this.requests=new Xm({baseURL:o,timeout:i,retry:s,retryDelay:n,responseType:"json"}),this.fetchClient=new Xm({baseURL:"",timeout:i,retry:s,retryDelay:n,responseType:"json"}),this.setAuthToken(c,{bearer:!0});const l=this.requests.request.bind(this.requests);this.requests.request=h=>u(this,null,function*(){var p,v,T,E,C;const b=e.getValue("telemetry");try{b.injectContext(this.requests.defaults.headers.common);const P=yield l(h);return h.url!==b.logsEndpoint&&this.logger.debug("xhr::fetch",{networkCall:{status:P.status,statusText:P.statusText,baseURL:h.baseURL||this.requests.defaults.baseURL,url:h.url,method:h.method}}),P}catch(P){throw P?(((p=P.config)==null?void 0:p.url)!==b.logsEndpoint&&this.logger.error("xhr::fetch",{error:P,networkCall:{status:P.status,statusText:P.statusText,baseURL:((v=P.config)==null?void 0:v.baseURL)||this.requests.defaults.baseURL,url:(T=P.config)==null?void 0:T.url,retries:(E=P.config)==null?void 0:E.retry,method:(C=P.config)==null?void 0:C.method,isOnline:navigator.onLine?"online":"offline"}}),new I(P.message||"Network request failed","0011")):new I("Unknown network error occurred","0011")}})}get peerId(){return this.context.getValue("peerId")}get logger(){return this.context.getValue("logger")}setAuthToken(e,r){const{bearer:i}=r||{};this.authToken=e,this.requests.defaults.headers.common.Authorization=i?`Bearer ${e}`:e}setHeader(e,r){this.requests.defaults.headers.common[e]=r}setRoomName(e){this.roomName=e}setRoomUUID(e){this.roomUUID=e}setOrganizationId(e){this.organizationId=e}}var gD=Object.defineProperty,fD=Object.getOwnPropertyDescriptor,lr=(t,e,r,i)=>{for(var s=i>1?void 0:i?fD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&gD(e,r,s),s};class Zt extends mD{constructor(e,r){super(e,r),m(this,"telemetry"),this.telemetry=e.getValue("telemetry"),this.setHeader("x-dyte-web-core-version",e.getValue("sdkVersion"))}getIPDetails(){return u(this,null,function*(){var e;const{peerId:r}=this;try{const i=yield ep.getIPDetails({peerId:r,apiHostnames:Ov(this.context),logger:_v});if(this.logger.log("ipInfo",{ipInfo:i}),((e=i==null?void 0:i.loc)==null?void 0:e.length)>5)return i;throw Error("Insufficient data")}catch(i){this.logger.warn("ApiClient.getRoomNodeLinkAndTitleV1 Failed to get ip details",{error:{name:i.name,message:i.message}});return}})}getICEServers(){return u(this,null,function*(){if(this.iceServers)return this.iceServers;const{success:e,iceServers:r}=(yield this.requests.get("/iceservers")).data;if(e)return(r==null?void 0:r.length)>0&&(this.iceServers=r),r})}getPlugins(){return u(this,null,function*(){var e,r,i,s,n,o,c;if(this.pluginInformation)return this.pluginInformation;const{plugins:d}=(yield this.requests.get("/v2/plugins/user")).data.data,l=((r=(e=this.context.getValue("flagsmith").getValue(X.V1_PLUGINS))==null?void 0:e.toString())==null?void 0:r.split(","))||[],h=d.reduce((p,v)=>(p[l.includes(v.id)?"v1":"v2"].push(G(V({},v),{name:v.name.replace("v2","")})),p),{v1:[],v2:[]});return(n=(s=(i=this.context.getValue("modules"))==null?void 0:i.devTools)==null?void 0:s.plugins)!=null&&n.length&&((c=(o=this.context.getValue("modules"))==null?void 0:o.devTools)==null||c.plugins.forEach(p=>{var v,T,E;const C=G(V({},Ea),{tags:[...Ea.tags],baseUrl:`http://localhost:${p.port}`,name:p.name,picture:(v=p.picture)!=null?v:Ea.picture,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),id:p.id,organizationId:this.organizationId,description:(T=p.description)!=null?T:Ea.description,staggered:(E=p.staggered)!=null?E:Ea.staggered});h.v2.push(C)})),h.v2})}getPluginDetails(e){return u(this,null,function*(){const{plugin:r}=(yield this.requests.get(`/v2/plugins/view/${e}`)).data.data;return r})}getPluginConfig(e){return u(this,null,function*(){return(yield this.fetchClient.get(`${e}/dyte-config.json`)).data})}authorizePlugin(e){return u(this,null,function*(){const r={peerId:this.peerId},{token:i}=(yield this.requests.post(`/v2/plugins/authorize/${e}`,r)).data.data;return i})}getPresignedUrls(e,r){return u(this,null,function*(){const i=Zn(this.context,"chat_upload_expiry"),s={roomUUID:this.roomUUID,filename:e,expiry:typeof i=="number"?i:void 0};this.context.getValue("flagsmith").hasFeature(X.FEAT_CHAT_SDK)&&(s.viewType=r);const{getLocation:n,putLocation:o}=(yield this.requests.post("/v1/meetings/genPreSignedUploadUrl",s)).data.data;return{getLocation:n,putLocation:o}})}uploadFile(e,r){return u(this,null,function*(){if(navigator.isReactNative&&"uri"in e)try{yield fetch(r,{method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:{uri:e.uri,name:e.name}})}catch(i){this.logger.error(`sendFileMessage::${i}`)}else yield this.fetchClient.put(r,e,{headers:{"Content-Type":e.type}})})}startLivestreaming(e){return u(this,arguments,function*({manualIngestion:r}){const i=_r(yield this.requests.post(`/v2/meetings/${this.context.getValue("meetingId")}/livestreams`,{manual_ingest:!!r})).data.data;return{playbackUrl:i.playbackUrl,status:i.status,manualIngest:i.manualIngest,ingestionCredentials:i.streamKey?{ingestionServer:i.ingestServer,streamKey:i.streamKey}:null}})}stopLivestreaming(){return u(this,null,function*(){return this.requests.post(`/v2/meetings/${this.context.getValue("meetingId")}/active-livestream/stop`)})}getActiveLivestream(){return u(this,null,function*(){const e=_r((yield this.requests.get(`/v2/meetings/${this.context.getValue("meetingId")}/active-livestream`)).data.data);return{playbackUrl:e.playbackUrl,status:e.status,manualIngest:e.manualIngest,ingestionCredentials:e.streamKey?{ingestionServer:e.ingestServer,streamKey:e.streamKey}:null}})}getUserDetails(){return u(this,null,function*(){if(this.userDetails)return this.userDetails;const e=(yield this.requests.get("v2/internals/participant-details")).data.data;return _r(e)})}startRecording(e,r){return u(this,null,function*(){return(yield this.requests.post("/v2/recordings",G(V({},Xv(e)),{meeting_id:this.context.getValue("meetingId"),allow_multiple_recordings:!!r}))).data.data.id})}updateRecording(e,r){return u(this,null,function*(){return this.requests.put(`v2/recordings/${e}`,{action:r})})}getActiveRecording(){return u(this,null,function*(){const{status:e,id:r}=(yield this.requests.get(`v2/recordings/active-recording/${this.context.getValue("meetingId")}`)).data.data;return{status:e,id:r}})}getActiveTranscript(){return u(this,null,function*(){const{transcript_download_url:e}=(yield this.requests.get(`v2/meetings/${this.context.getValue("meetingId")}/active-transcript`)).data.data;try{return{transcript:(yield this.fetchClient.get(e)).data}}catch{throw new I("Cant fetch transcript s3 url","1801")}})}getRoomNodeData(){return u(this,null,function*(){const e=yield this.getIPDetails();if(this.ipInfo=e,this.roomDetails)return this.roomDetails;const{roomNodeLink:r,title:i,useHiveMedia:s,sfu:n}=_r((yield this.requests.post("v2/internals/rooms",{ip_information:e})).data.data);return{roomNodeUrl:r,meetingTitle:i,useHiveMedia:s!=null?s:!1,sfu:n}})}}lr([k.trace("APIClient.getIPDetails")],Zt.prototype,"getIPDetails",1);lr([k.trace("APIClient.getICEServers")],Zt.prototype,"getICEServers",1);lr([k.trace("APIClient.getPlugins")],Zt.prototype,"getPlugins",1);lr([k.trace("APIClient.startLivestreaming")],Zt.prototype,"startLivestreaming",1);lr([k.trace("APIClient.stopLivestreaming")],Zt.prototype,"stopLivestreaming",1);lr([k.trace("APIClient.getActiveLivestream")],Zt.prototype,"getActiveLivestream",1);lr([k.trace("APIClient.getUserDetails")],Zt.prototype,"getUserDetails",1);lr([k.trace("APIClient.startRecording")],Zt.prototype,"startRecording",1);lr([k.trace("APIClient.stopRecording")],Zt.prototype,"updateRecording",1);lr([k.trace("APIClient.getActiveRecording")],Zt.prototype,"getActiveRecording",1);lr([k.trace("APIClient.getActiveTranscript")],Zt.prototype,"getActiveTranscript",1);lr([k.trace("APIClient.getRoomNodeData")],Zt.prototype,"getRoomNodeData",1);let Xu;function vD(t,e){return Xu=new Zt(t,e),Xu}function pt(){return Xu}function yD(t,e){return`<blockquote>${e.replace(/<blockquote>[.\s\S]*<\/blockquote>\n\n/m,"")}</blockquote>
14
14
 
15
15
  ${t}`}const sa={maxInvocations:5,period:1};function Bt(t,e){return function(r,i,s){const n=s.value;let o=0,c=Date.now();return s.value=function(...d){const l=Date.now(),h=e?this[e]:t;if(l-c>h.period*1e3&&(c=l,o=0),o>=h.maxInvocations)throw new I(`Method rate limit ${h.maxInvocations} invocations/${h.period}sec exceeded`,"0013");return o+=1,n.apply(this,d)},s}}var SD=Object.defineProperty,TD=Object.getOwnPropertyDescriptor,vt=(t,e,r,i)=>{for(var s=i>1?void 0:i?TD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&SD(e,r,s),s};const kD=["text","image","file","custom","poll"],zc={maxInvocations:180,period:60};var ee,$s,ze,Js,Ks,eu,Zm,kc,tu,eg;let st=(eg=class extends Xt{constructor(t,e,r,i,s){const n=t.getValue("logger");super(n),g(this,eu),g(this,kc),m(this,"messages"),m(this,"channels",[]),g(this,ee,void 0),g(this,$s,void 0),g(this,ze,void 0),g(this,Js,void 0),g(this,Ks,void 0),m(this,"maxTextLimit",2e3),f(this,Ks,t),f(this,ze,e),f(this,Js,r),f(this,ee,i),f(this,$s,s),this.messages=[]}get telemetry(){return a(this,Ks).getValue("telemetry")}setMaxTextLimit(t){this.maxTextLimit=t}sendMessageInternal(t,e,r){return u(this,arguments,function*(i,s,n,o={}){switch(i.type){case"text":{const c=o.replyTo&&o.replyTo.type==="text"?yD(i.message,o.replyTo.message):i.message;yield this.sendTextMessageInternal(c,s,n);break}case"image":yield this.sendImageMessageInternal(i.image,s,n);break;case"file":yield this.sendFileMessageInternal(i.file,s,n);break;default:this.logger.error("sendMessage::message_type_not_supported",{dyteChat:{messageType:i.type}});break}})}sendTextMessageInternal(t,e,r){return u(this,null,function*(){var i,s,n,o,c,d;if(t.length>this.maxTextLimit)throw new I("Max character limit breached","0503");if(e&&e.length>0){if(!((i=a(this,ee).permissions)!=null&&i.chatPrivate.canSend)||!((s=a(this,ee).permissions)!=null&&s.chatPrivate.text))throw this.logger.error("sendTextMessage::private_chat_permission_denied"),new I("Could not send message to private chat.","0501")}else if(!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.canSend)||!((d=(c=a(this,ee).permissions)==null?void 0:c.chatPublic)!=null&&d.text))throw this.logger.error("sendTextMessage::public_chat_permission_denied"),new I("Could not send message to public chat.","0501");if(!t)throw this.logger.error("sendTextMessage::message_can_not_be_empty"),new I("Message can not be empty.","0502");if(r){a(this,ze).sendMessageToChannel(t,_t.TEXT,r);return}let l=[];e&&e.length>0&&(e.push(a(this,ee).id),l=a(this,$s).joined.toArray().filter(h=>e.includes(h.id)).map(h=>h.userId),l.push(a(this,ee).userId)),a(this,ze).sendMessage(t,_t.TEXT,e)})}sendImageMessageInternal(t,e,r){return u(this,null,function*(){var i,s,n,o,c,d;if(e&&e.length>0){if(!((i=a(this,ee).permissions)!=null&&i.chatPrivate.canSend)||!((s=a(this,ee).permissions)!=null&&s.chatPrivate.files)){this.logger.error("sendImageMessage::private_chat_permission_denied");return}}else if(!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.canSend)||!((d=(c=a(this,ee).permissions)==null?void 0:c.chatPublic)!=null&&d.files)){this.logger.error("sendImageMessage::permission_denied");return}if(!t){this.logger.error("sendImageMessage::required_argument_image_can_not_be_empty");return}if(!["image/gif","image/jpeg","image/png"].includes(t.type)){this.logger.error("sendImageMessage::image_type_not_supported",{dyteChat:{imageType:t.type}});return}try{const l=pt(),{getLocation:h,putLocation:p}=yield l.getPresignedUrls(t.name,a(this,ee).config.viewType);if(yield l.uploadFile(t,p),r){a(this,ze).sendMessageToChannel(h,_t.IMAGE,r);return}let v=[];e&&e.length>0&&(e.push(a(this,ee).id),v=a(this,$s).joined.toArray().filter(T=>e.includes(T.id)).map(T=>T.userId),v.push(a(this,ee).userId)),a(this,ze).sendMessage(h,_t.IMAGE,e)}catch{throw new I("Error sending image message.","0500",this.logger)}})}sendFileMessageInternal(t,e,r){return u(this,null,function*(){var i,s,n,o,c,d;if(e&&e.length>0){if(!((i=a(this,ee).permissions)!=null&&i.chatPrivate.canSend)||!((s=a(this,ee).permissions)!=null&&s.chatPrivate.files)){this.logger.error("sendFileMessage::private_chat_permission_denied");return}}else if(!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.canSend)||!((d=(c=a(this,ee).permissions)==null?void 0:c.chatPublic)!=null&&d.files)){this.logger.error("sendFileMessage::permission_denied");return}if(!t){this.logger.error("sendFileMessage::required_argument_file_can_not_be_empty");return}try{const l=pt(),{getLocation:h,putLocation:p}=yield l.getPresignedUrls(t.name,a(this,ee).config.viewType);if(yield l.uploadFile(t,p),r){a(this,ze).sendMessageToChannel(JSON.stringify({link:h,name:t.name,size:"size"in t?t.size:0}),_t.FILE,r);return}let v=[];e&&e.length>0&&(e.push(a(this,ee).id),v=a(this,$s).joined.toArray().filter(E=>e.includes(E.id)).map(E=>E.userId),v.push(a(this,ee).userId));const T=JSON.stringify({link:h,name:t.name,size:"size"in t?t.size:0});a(this,ze).sendMessage(T,_t.FILE,e)}catch{throw new I("Error sending file message.","0500",this.logger)}})}get rateLimits(){return zc}updateRateLimits(t,e){zc.maxInvocations=t,zc.period=e}sendTextMessage(t,e){return u(this,null,function*(){return this.sendTextMessageInternal(t,e)})}sendCustomMessage(t,e){return u(this,null,function*(){var r,i,s,n,o,c,d,l,h,p,v,T,E,C,b;if(e&&e.length>0){if(!((r=a(this,ee).permissions)!=null&&r.chatPrivate.canSend)||!((i=a(this,ee).permissions)!=null&&i.chatPrivate.files)||!((s=a(this,ee).permissions)!=null&&s.chatPrivate.text)){this.logger.error("sendCustomMessage::private_chat_permission_denied");return}}else if(!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.canSend)||!((d=(c=a(this,ee).permissions)==null?void 0:c.chatPublic)!=null&&d.files)||!((h=(l=a(this,ee).permissions)==null?void 0:l.chatPublic)!=null&&h.text)){this.logger.error("sendCustomMessage::permission_denied");return}const P=W=>u(this,null,function*(){try{if(typeof W=="string")return{link:W};const w=pt(),{getLocation:te,putLocation:re}=yield w.getPresignedUrls(W.name,a(this,ee).config.viewType);return yield w.uploadFile(W,re),{link:te,type:W.type,name:W.name,size:W.size}}catch{throw new I("Error sending image message.","0500",this.logger)}}),j=G(V({},t),{files:yield Promise.all((v=(p=t.files)!=null?p:[])==null?void 0:v.map(W=>u(this,null,function*(){return P(W)}))),images:yield Promise.all((E=(T=t.images)!=null?T:[])==null?void 0:E.map(W=>u(this,null,function*(){return P(W)}))),videos:yield Promise.all((b=(C=t.videos)!=null?C:[])==null?void 0:b.map(W=>u(this,null,function*(){return P(W)})))});a(this,ze).sendMessage(JSON.stringify(j),_t.CUSTOM,e)})}sendImageMessage(t,e){return u(this,null,function*(){return this.sendImageMessageInternal(t,e)})}sendFileMessage(t,e){return u(this,null,function*(){return this.sendFileMessageInternal(t,e)})}sendMessage(t,e){return u(this,null,function*(){return this.sendMessageInternal(t,e)})}editTextMessage(t,e,r){return u(this,null,function*(){var i,s,n,o,c,d;if(((s=(i=a(this,ee).permissions)==null?void 0:i.chatMessage)==null?void 0:s.canEdit)==="NONE")throw new I("Not permitted to edit messages","0501");if(!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.canSend)||!((d=(c=a(this,ee).permissions)==null?void 0:c.chatPublic)!=null&&d.text)){this.logger.error("editTextMessage::permission_denied");return}if(!e){this.logger.error("editTextMessage::message_can_not_be_empty");return}a(this,ze).editMessage(t,e,_t.TEXT,r)})}editImageMessage(t,e,r){return u(this,null,function*(){var i,s,n,o;if(!((s=(i=a(this,ee).permissions)==null?void 0:i.chatPublic)!=null&&s.canSend)||!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.files)){this.logger.error("editImageMessage::permission_denied");return}if(!e){this.logger.error("editImageMessage::required_argument_image_can_not_be_empty");return}if(!["image/gif","image/jpeg","image/png"].includes(e.type)){this.logger.error("sendImageMessage::image_type_not_supported",{dyteChat:{imageType:e.type}});return}try{const c=pt(),{getLocation:d,putLocation:l}=yield c.getPresignedUrls(e.name,a(this,ee).config.viewType);yield c.uploadFile(e,l),a(this,ze).editMessage(t,d,_t.IMAGE,r)}catch{throw new I("Error editing image message.","0500",this.logger)}})}editFileMessage(t,e,r){return u(this,null,function*(){var i,s,n,o;if(!((s=(i=a(this,ee).permissions)==null?void 0:i.chatPublic)!=null&&s.canSend)||!((o=(n=a(this,ee).permissions)==null?void 0:n.chatPublic)!=null&&o.files)){this.logger.error("sendFileMessage::permission_denied");return}if(!e){this.logger.error("sendFileMessage::required_argument_file_can_not_be_empty");return}try{const c=pt(),{getLocation:d,putLocation:l}=yield c.getPresignedUrls(e.name,a(this,ee).config.viewType);yield c.uploadFile(e,l),a(this,ze).editMessage(t,JSON.stringify({link:d,name:e.name,size:"size"in e?e.size:0}),_t.FILE,r)}catch{throw new I("Error editing file message.","0500",this.logger)}})}editMessage(t,e,r){return u(this,null,function*(){switch(e.type){case"text":{this.editTextMessage(t,e.message,r);break}case"image":{this.editImageMessage(t,e.image,r);break}case"file":{this.editFileMessage(t,e.file,r);break}default:{this.logger.error("editMessage::message_type_not_supported",{dyteChat:{messageType:e.type}});break}}})}deleteMessage(t,e){return u(this,null,function*(){var r,i;if(((i=(r=a(this,ee).permissions)==null?void 0:r.chatMessage)==null?void 0:i.canDelete)==="NONE")throw new I("Not permitted to delete messages","0501");a(this,ze).deleteMessage(t,e)})}getMessagesByUser(t){return this.messages.filter(e=>e.userId===t)}getMessagesByType(t){return this.messages.filter(e=>e.type===t)}pin(t){return u(this,null,function*(){if(!a(this,kc,tu))throw new I("Can`t pin message without joining room","0505");if(!a(this,ee).permissions.pinParticipant)throw new I("You do not have permission to pin messages.","0501");const e=this.messages.find(r=>r.id===t);if(e){a(this,ze).setPinState(e,!0);return}throw new I(`No message found with id: ${t}`,"0504")})}unpin(t){return u(this,null,function*(){if(!a(this,kc,tu))throw new I("Can`t unpin message without joining room","0505");if(!a(this,ee).permissions.pinParticipant)throw new I("You do not have permission to unpin messages.","0501");const e=this.messages.find(r=>r.id===t);if(e){a(this,ze).setPinState(e,!1);return}throw new I(`No message found with id: ${t}`,"0504")})}getMessages(t,e,r,i=0,s=void 0){return u(this,null,function*(){const n=yield a(this,ze).getChatMessagesPaginated(t,e,r,i,s);return{messages:n.messages.map(o=>oi.formatSocketServiceMessage(o)),next:n.next}})}createChannel(t,e){return u(this,arguments,function*(r,i,s={}){var n;const o=(n=a(this,ee).permissions)==null?void 0:n.chatChannel;if(o){if(o.canCreate==="NONE")throw new I("Not permitted to create channels","0501");if(s.visibility==="public"&&!(o.canCreate==="PUBLIC"||o.canCreate==="ALL"))throw new I("Not permitted to create public channels","0501");if(s.visibility==="private"&&!(o.canCreate==="PRIVATE"||o.canCreate==="ALL"))throw new I("Not permitted to create private channels","0501")}if(!r||r.trim().length===0)throw new I("channel name cannot be empty.","0510");const c=[...new Set([...i,a(this,ee).userId])];return yield a(this,Js).createChannel(r.trim(),c,s.displayPictureUrl,s.visibility,s.isDirectMessage)})}updateChannel(t,e){var r,i,s,n,o;const c=this.channels.find(h=>h.id===t),d=(r=a(this,ee).permissions)==null?void 0:r.chatChannel;if(d){if(d.canUpdate==="NONE")throw new I("Not permitted to update channels","0501");if(c.visibility==="public"&&!(d.canUpdate==="PUBLIC"||d.canUpdate==="ALL"))throw new I("Not permitted to update public channels","0501");if(c.visibility==="private"&&!(d.canUpdate==="PRIVATE"||d.canUpdate==="ALL"))throw new I("Not permitted to update private channels","0501")}const l={memberIds:(i=e.memberIds)!=null?i:c.memberIds,displayName:(s=e.displayName)!=null?s:c.displayName,displayPictureUrl:(n=e.displayPictureUrl)!=null?n:c.displayPictureUrl,visibility:(o=e.visibility)!=null?o:c.visibility};return a(this,Js).updateChannel(t,l)}sendMessageToChannel(t,e){return u(this,arguments,function*(r,i,s={}){return this.sendMessageInternal(r,null,i,s)})}getChannelMembers(t){return u(this,null,function*(){return a(this,Js).getChannelMembers(t)})}searchMessages(t){return u(this,arguments,function*(e,r={}){if(!a(this,Ks).getValue("flagsmith").hasFeature(X.FEAT_CHAT_SDK_SEARCH))throw new I("searchMessages is temporarily disabled!","0506");return(yield a(this,ze).searchMessages(e,r)).map(oi.formatSocketServiceMessage)})}markLastReadMessage(t,e){return u(this,null,function*(){yield a(this,ze).markLastReadMessage(t,e);const r=this.channels.find(i=>i.id===t);if(r){const i=G(V({},r),{unreadCount:0});this.channels=this.channels.map(s=>s.id===t?i:s),this.emit("channelMessageUpdate",i)}})}get pinned(){return this.messages.filter(t=>t.pinned)}},ee=new WeakMap,$s=new WeakMap,ze=new WeakMap,Js=new WeakMap,Ks=new WeakMap,eu=new WeakSet,Zm=function(){return a(this,Ks).getValue("connectionHandler")},kc=new WeakSet,tu=function(){return a(this,eu,Zm).socketJoined===!0},eg);vt([k.trace("DyteChat.sendTextMessage"),Bt(zc)],st.prototype,"sendTextMessage",1);vt([k.trace("DyteChat.sendImageMessage"),Bt({maxInvocations:20,period:60})],st.prototype,"sendImageMessage",1);vt([k.trace("DyteChat.sendFileMessage"),Bt({maxInvocations:20,period:60})],st.prototype,"sendFileMessage",1);vt([k.trace("DyteChat.sendMessage"),Bt({maxInvocations:180,period:60})],st.prototype,"sendMessage",1);vt([k.trace("DyteChat.editTextMessage")],st.prototype,"editTextMessage",1);vt([k.trace("DyteChat.editImageMessage")],st.prototype,"editImageMessage",1);vt([k.trace("DyteChat.editFileMessage")],st.prototype,"editFileMessage",1);vt([k.trace("DyteChat.editMessage")],st.prototype,"editMessage",1);vt([k.trace("DyteChat.deleteMessage")],st.prototype,"deleteMessage",1);vt([k.trace("DyteChat.createChannel")],st.prototype,"createChannel",1);vt([k.trace("DyteChat.updateChannel")],st.prototype,"updateChannel",1);vt([k.trace("DyteChat.sendMessageToChannel")],st.prototype,"sendMessageToChannel",1);vt([k.trace("DyteChat.getChannelMembers")],st.prototype,"getChannelMembers",1);vt([k.trace("DyteChat.searchMessages")],st.prototype,"searchMessages",1);vt([k.trace("DyteChat.markLastReadMessage")],st.prototype,"markLastReadMessage",1);st=vt([ft("0500")],st);var ED=Object.defineProperty,bD=Object.getOwnPropertyDescriptor,wD=(t,e,r,i)=>{for(var s=i>1?void 0:i?bD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&ED(e,r,s),s},es,tg;const ls=(tg=class{constructor(t,e,r,i,s){m(this,"chat"),m(this,"chatSocketHandler"),m(this,"chatChannelSocketHandler"),m(this,"self"),g(this,es,void 0),f(this,es,t),this.chatSocketHandler=e,this.chatChannelSocketHandler=r,this.chat=new st(t,e,r,i,s),this.self=i,this.setupEvents()}get telemetry(){return a(this,es).getValue("telemetry")}get logger(){return a(this,es).getValue("logger")}static init(t,e,r,i,s){return u(this,null,function*(){return new ls(t,e,r,i,s)})}static formatMessage(t){return G(V({},t),{time:new Date(t.time),type:kD[t.type]})}static formatSocketServiceMessage(t){const e=t.createdAt*1e3,r={displayName:t.displayName,id:t.chatId,time:e,timeMs:t.createdAtMs,type:t.payloadType,isEdited:t.isEdited,userId:t.userId,targetUserIds:t.targetUserIds,channelId:t.channelId,channelIndex:t.channelIndex,message:"",link:"",name:"",html:"",images:[],videos:[],files:[],size:0,pinned:t.pinned};switch(r.type){case _t.TEXT:{r.message=t.payload;break}case _t.IMAGE:{r.link=t.payload;break}case _t.FILE:{const{link:i,name:s,size:n}=JSON.parse(t.payload);r.link=i,r.name=s,r.size=n;break}case _t.CUSTOM:{const{html:i,images:s,message:n,videos:o,files:c}=JSON.parse(t.payload);r.message=n,r.html=i,r.images=s,r.videos=o,r.files=c;break}}return ls.formatMessage(r)}getChatMessages(){return u(this,null,function*(){if(this.self.config.viewType==="LIVESTREAM"||this.self.config.viewType==="CHAT"||a(this,es).getValue("flagsmith").hasFeature(X.FEAT_PAGINATED_CHAT))return;const t=yield this.chatSocketHandler.getChatMessages();if(!(t!=null&&t.payload))return;const e=Kv.fromBinary(t.payload).messages;this.chat.messages=e.map(r=>ls.formatSocketServiceMessage(r))})}setupEvents(){a(this,es).getValue("peerSessionStore").on(M.SOCKET_SERVICE_ROOM_JOINED,()=>u(this,null,function*(){this.getChatMessages()})),this.chatSocketHandler.on(Ae.sendMessageToRoom,t=>{const e=ls.formatSocketServiceMessage(t.message);if(!e.channelId)this.chat.messages=[...this.chat.messages,e];else{const r=this.chat.channels.find(i=>i.id===e.channelId);r&&(r.latestMessage=e,r.unreadCount+=1,this.chat.emit("channelMessageUpdate",r))}this.chat.emit("chatUpdate",{action:"add",message:e,messages:this.chat.messages})}),this.chatSocketHandler.on(Ae.sendMessageToPeers,t=>{const e=ls.formatSocketServiceMessage(t.message);this.chat.messages=[...this.chat.messages,e],this.chat.emit("chatUpdate",{action:"add",message:e,messages:this.chat.messages})}),this.chatSocketHandler.on(Ae.editMessage,t=>{const e=ls.formatSocketServiceMessage(t.message);if(e.channelId){this.chat.emit("chatUpdate",{action:"edit",message:e,messages:this.chat.messages});return}const r=this.chat.messages.findIndex(i=>i.id===e.id);r!==-1&&(this.chat.messages[r]=e,this.chat.emit("chatUpdate",{action:"edit",message:e,messages:this.chat.messages}))}),this.chatSocketHandler.on(Ae.deleteMessage,t=>{if(t.channelId){this.chat.emit("chatUpdate",{action:"delete",message:{id:t.chatId,channelId:t.channelId},messages:this.chat.messages});return}const e=this.chat.messages.findIndex(i=>i.id===t.chatId);if(e===-1)return;const[r]=this.chat.messages.splice(e,1);this.chat.emit("chatUpdate",{action:"delete",message:r,messages:this.chat.messages})}),this.chatChannelSocketHandler.on(_s.createChatChannel,t=>{const[e]=t.chatChannels,r=Vs.formatChannel(e);this.chat.channels.push(r),this.chat.emit("channelCreate",r)}),this.chatSocketHandler.on(Ae.pinMessage,t=>{const e=this.chat.messages.findIndex(i=>i.id===t.chatId);if(e===-1)return;const r=this.chat.messages[e];r.pinned=t.pinned,this.chat.messages[e]=r,this.chat.emit("chatUpdate",{action:"edit",message:r,messages:this.chat.messages})}),this.chatChannelSocketHandler.on(_s.updateChatChannel,t=>{const[e]=t.chatChannels,r=Vs.formatChannel(e);this.chat.channels=this.chat.channels.map(i=>i.id===r.id?r:i),this.chat.emit("channelUpdate",r)})}},es=new WeakMap,tg);let oi=ls;wD([k.trace("ChatController.setupEvents")],oi.prototype,"setupEvents",1);var _D=Object.defineProperty,ID=Object.getOwnPropertyDescriptor,CD=(t,e,r,i)=>{for(var s=i>1?void 0:i?ID(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&_D(e,r,s),s},ru,rg,iu,ig,_a,Ia,Ec,sg;let Zu=(sg=class extends Xt{constructor(t,e,r){const i=t.getValue("logger");super(i),g(this,ru),g(this,iu),m(this,"items"),g(this,_a,void 0),g(this,Ia,void 0),g(this,Ec,void 0),f(this,Ec,t),f(this,_a,e),f(this,Ia,r),this.items=[]}create(t,e,r=!1,i=!1){return u(this,null,function*(){if(!a(this,iu,ig))throw new I("Can't create polls without joining room","0705");if(!a(this,_a).permissions.polls.canCreate){this.logger.error("DytePolls::create::permission_denied");return}if(!t||!e){this.logger.error("DytePolls::question_and_options_can_not_be_empty",{dytePolls:{hasQuestion:!!t,optionsLength:e==null?void 0:e.length}});return}if(e.length<2){this.logger.error("DytePolls::there_must_be_at_least_two_options",{dytePolls:{hasQuestion:!!t,optionsLength:e.length}});return}yield a(this,Ia).createPoll(t,e,r,i)})}vote(t,e){return u(this,null,function*(){if(!a(this,_a).permissions.polls.canVote){this.logger.error("DytePolls::vote::permission_denied");return}yield a(this,Ia).votePoll(t,e)})}},ru=new WeakSet,rg=function(){return a(this,Ec).getValue("connectionHandler")},iu=new WeakSet,ig=function(){var t;return((t=a(this,ru,rg))==null?void 0:t.socketJoined)===!0},_a=new WeakMap,Ia=new WeakMap,Ec=new WeakMap,sg);Zu=CD([ft("0700")],Zu);var PD=Object.defineProperty,RD=Object.getOwnPropertyDescriptor,MD=(t,e,r,i)=>{for(var s=i>1?void 0:i?RD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&PD(e,r,s),s},ts,Ca,zs,ng;const Tn=(ng=class{constructor(t,e,r){m(this,"polls"),g(this,ts,void 0),g(this,Ca,void 0),g(this,zs,void 0),this.polls=new Zu(t,e,r),f(this,Ca,e),f(this,ts,t),f(this,zs,r),this.setupEvents()}get telemetry(){return a(this,ts).getValue("telemetry")}get logger(){return a(this,ts).getValue("logger")}static init(t,e,r){return u(this,null,function*(){return new Tn(t,e,r)})}canViewPolls(){return a(this,Ca).permissions.polls.canView}setupEvents(){const t={[ei.createPoll]:i=>{i.poll&&this.updatePoll(Tn.formatSocketServicePoll(i.poll))},[ei.updatePoll]:i=>{i.poll&&this.updatePoll(Tn.formatSocketServicePoll(i.poll))},[ei.votePoll]:i=>{i.poll&&this.updatePoll(Tn.formatSocketServicePoll(i.poll))}},e=()=>{a(this,ts).getValue("peerSessionStore").on(M.SOCKET_SERVICE_ROOM_JOINED,()=>{this.getPolls()}),Object.keys(t).map(Number).forEach(i=>{a(this,zs).on(i,t[i])})},r=()=>{a(this,ts).getValue("peerSessionStore").on(M.SOCKET_SERVICE_ROOM_JOINED,()=>{this.getPolls()}),Object.keys(t).map(Number).forEach(i=>{a(this,zs).removeListeners(i)})};a(this,Ca).permissions.on("permissionsUpdate",i=>u(this,null,function*(){var s;i!=null&&i.polls&&((s=i==null?void 0:i.polls)!=null&&s.canView?(yield this.getPolls(),e()):(this.polls.items=[],r()))})),this.canViewPolls()&&e()}updatePoll(t){if(!this.canViewPolls())return;const e=this.polls.items.findIndex(r=>r.id===t.id);if(e>-1){const r=JSON.stringify(this.polls.items[e]);this.polls.items[e]=t,r!==JSON.stringify(t)&&this.polls.emit("pollsUpdate",{polls:this.polls.items,newPoll:!1});return}this.polls.items=[...this.polls.items,t],this.polls.emit("pollsUpdate",{polls:this.polls.items,newPoll:!0})}getPolls(){return u(this,null,function*(){const t=yield a(this,zs).getPolls();if(!(t!=null&&t.payload))return;const{polls:e}=WA.fromBinary(t.payload);this.polls.items=e.map(r=>Tn.formatSocketServicePoll(r))})}static formatSocketServicePoll(t){const e=t.options.map(r=>({count:r.count,text:r.text,votes:r.votes.map(i=>({id:i.userId,name:i.name}))}));return{anonymous:t.anonymous,createdBy:t.createdBy,createdByUserId:t.createdByUserId,hideVotes:t.hideVotes,id:t.pollId,options:e,question:t.question,voted:t.votes}}},ts=new WeakMap,Ca=new WeakMap,zs=new WeakMap,ng);let Zv=Tn;MD([k.trace("PollController.setupEvents")],Zv.prototype,"setupEvents",1);var AD=Object.defineProperty,DD=Object.getOwnPropertyDescriptor,OD=(t,e,r,i)=>{for(var s=i>1?void 0:i?DD(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&AD(e,r,s),s},ey=(t=>(t[t.User=0]="User",t[t.Meeting=1]="Meeting",t))(ey||{}),Pa,bc,su,Ys,wc,ag;let eh=(ag=class extends Xt{constructor(t,e,r,i,s){const n=t.getValue("logger");super(n),g(this,bc),m(this,"selfActiveTab"),m(this,"broadcastTabChanges"),g(this,Pa,void 0),g(this,Ys,void 0),g(this,wc,void 0),m(this,"viewType"),m(this,"meetingStartedTimestamp"),m(this,"meetingTitle"),m(this,"sessionId"),f(this,Pa,t),f(this,Ys,e),this.viewType=r,f(this,wc,i),this.meetingTitle=s,this.broadcastTabChanges=e.permissions.canSpotlight}get socketState(){return a(this,bc,su).socketState}get mediaState(){return a(this,bc,su).mediaState}get meetingId(){return a(this,Pa).getValue("meetingId")}setBroadcastTabChanges(t){if(!a(this,Ys).permissions.canSpotlight)throw this.logger.error("DyteSpotlight::setSpotlighted::permission_denied"),new I("User does not have permission to toggle spotlight","0801");this.broadcastTabChanges=t,this.emit("broadcastTabChangesUpdate",this.broadcastTabChanges),this.broadcastTabChanges&&this.assertActiveTabToRoom()}setSelfActiveTab(t,e){var r;this.logger.info("DyteSpotlight::setActiveTab",{spotlight:{currentTab:{id:t.id,type:t.type}}}),this.selfActiveTab=t,e===0&&this.emit("selfTabUpdate",t),(r=a(this,Ys).permissions)!=null&&r.canSpotlight&&this.broadcastTabChanges&&e===0&&this.assertActiveTabToRoom()}assertActiveTabToRoom(){a(this,wc).broadcastMessage("spotlight",{userId:a(this,Ys).userId,currentTab:this.selfActiveTab})}},Pa=new WeakMap,bc=new WeakSet,su=function(){return a(this,Pa).getValue("connectionHandler")},Ys=new WeakMap,wc=new WeakMap,ag);eh=OD([ft("0800")],eh);function ND(t){let e="",r=[""];const i=[r];let s=0,n=0,o=!0,c;for(c of t)c==='"'?(o&&c===e&&(r[s]+=c),o=!o):c===","&&o?c=r[++s]="":c===`
@@ -20,4 +20,4 @@ ${t}`}const sa={maxInvocations:5,period:1};function Bt(t,e){return function(r,i,
20
20
  maxEnergy: ${a(this,Ts)}`),s===-1/0||r<1e-6?{energy:0,isVoice:!1}:((!a(this,Oi)||s<a(this,Oi))&&f(this,Oi,s),(!a(this,Ts)||s>a(this,Ts))&&f(this,Ts,s),{energy:(s-a(this,Oi))/(a(this,Ts)-a(this,Oi))*10||0,isVoice:i})},Rd=new WeakSet,xh=function(t){return t<5},Uh=new WeakSet,Ay=function(t=a(this,Jn)){var e;if(!a(this,Br)||!t){a(this,Wi).getValue("flagsmith").hasFeature(X.ENABLE_AUDIO_ACTIVITY_DEBUG_LOGS)&&this.logger.debug(`AudioActivityReporter: No producerId or energy to report: ${a(this,Br)}`);return}const r={producerId:a(this,Br),energy:Math.round(t),silent:U(e=ol,Rd,xh).call(e,t)};f(this,Ho,r.silent),this.reportRequest(r)},vu=new WeakSet,Lg=function(t){const e=Math.log10(t);return Math.round(e)},g(Fh,Rd),g(Fh,vu);const C1=(t=!1)=>{if("MediaStreamTrackGenerator"in window&&"AudioData"in window)try{const r=new window.MediaStreamTrackGenerator({kind:"audio"}),i=r.writable.getWriter(),s=48e3,n=128,o=1;let c=0,d=null;const l=()=>u(void 0,null,function*(){try{const p=new Float32Array(n*o),v=new window.AudioData({format:"f32",sampleRate:s,numberOfFrames:n,numberOfChannels:o,timestamp:c,data:p});c+=n/s*1e6,yield i.ready,yield i.write(v)}catch{d&&clearInterval(d),i.releaseLock(),r.writable.abort()}});d=window.setInterval(l,100);const h=new MediaStream([r]).getAudioTracks()[0];return h.addEventListener("ended",()=>{d&&clearInterval(d),i.releaseLock(),r.writable.abort()}),Object.assign(h,{fakeTracks:"fakeTracks:fakeAudioTrack"}),h.enabled=t,h}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 s=r.createGain();s.gain.value=0,i.connect(s);const n=r.createMediaStreamDestination();s.connect(n),i.start();const o=n.stream.getAudioTracks()[0];return o?(Object.assign(o,{fakeTracks:"fakeTracks:fakeAudioTrack"}),o.enabled=t,o):void 0}catch{return}},P1=(t=!1)=>{var e,r;const i=new MediaStream().getVideoTracks()[0],s=document.createElement("canvas");s.height=(e=i==null?void 0:i.getSettings().height)!=null?e:720,s.width=(r=i==null?void 0:i.getSettings().width)!=null?r:1280;const n=s.getContext("2d");n.fillStyle="black",n.fillRect(0,0,s.width,s.height),setInterval(()=>{n.fillStyle="black",n.fillRect(0,0,s.width,s.height)},1e3);const o=s.captureStream().getVideoTracks()[0];return Object.assign(o,{fakeTracks:"fakeTracks:fakeVideoTrack"}),o.enabled=t,o};var R1=Object.defineProperty,M1=Object.getOwnPropertyDescriptor,me=(t,e,r,i)=>{for(var s=i>1?void 0:i?M1(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&R1(e,r,s),s};const qt=["video/VP9","video/VP8"];var Vc,Lc,St,J,eo,$r,Dt,dn,ln,un,xc,pr,Ti,to,hn,pn,Ot,Gt,os,mn,yu,xg,Su,Ug,Tu,Fg,Uc,ku,Eu,bu,Bg,wu,Wg,_u,jg,Iu,Hg,lt,Tt,gn,ro,Cu,qg,Pu,Gg,Ru,$g;const Dy=(bu=class{constructor(t,e,r){g(this,os),g(this,yu),g(this,Su),g(this,Tu),g(this,Uc),g(this,wu),g(this,_u),g(this,Iu),g(this,lt),g(this,gn),g(this,Cu),g(this,Pu),g(this,Ru),m(this,"context"),m(this,"authToken"),m(this,"e2ee"),g(this,Vc,void 0),g(this,Lc,void 0),g(this,St,void 0),g(this,J,void 0),g(this,eo,void 0),g(this,$r,void 0),g(this,Dt,void 0),g(this,dn,void 0),g(this,ln,void 0),g(this,un,void 0),g(this,xc,void 0),g(this,pr,null),g(this,Ti,void 0),g(this,to,void 0),g(this,hn,void 0),g(this,pn,void 0),g(this,Ot,void 0),g(this,Gt,void 0);var i,s;this.context=t;const{socket:n}=r;this.mediaJoined=!1,f(this,hn,new Map([["video/VP9",new Set],["video/VP8",new Set]])),f(this,pn,new Map([["video/VP9",new Set],["video/VP8",new Set]])),f(this,$r,e),f(this,St,n),f(this,dn,!1),f(this,J,new b1(t,n,e)),f(this,Dt,a(this,J).events),f(this,Ti,new Set),f(this,Ot,new Map),f(this,ln,!1),f(this,un,new ch(t.getValue("logger"))),e===De.CF&&f(this,Gt,new Fh(this.context,a(this,J).socketHandler.audioActivity.bind(a(this,J).socketHandler))),this.e2ee=(s=(i=t.getValue("modules").e2ee)==null?void 0:i.enabled)!=null?s:!1,this.handleSocketEvents(),this.handleCallstatsEvents(),f(this,xc,lp(()=>u(this,null,function*(){if(!a(this,os,mn).mediaJoinAttempted)return;const{roomJoined:o}=yield this.joinRoom(a(this,Lc),a(this,Vc),!0,!0);o&&(this.context.getValue("peerSessionStore").emit(M.RESET_PRODUCER_STATE),this.context.getValue("peerSessionStore").emit(M.ROOM_NODE_RECONNECTED))}),5e3,{leading:!0,maxWait:1e3}))}get peerId(){return this.context.getValue("peerId")}get telemetry(){return this.context.getValue("telemetry")}get logger(){return this.context.getValue("logger")}get mediaJoined(){return a(this,os,mn).mediaJoined}set mediaJoined(t){a(this,os,mn).mediaJoined=t}reset(){a(this,J).closeAllProducers(),a(this,J).closeAllConsumers(),a(this,Ot).clear(),a(this,Ti).clear(),f(this,pr,null),a(this,un).stop(),a(this,J).stopAllTransports(),a(this,J).reset(),f(this,un,new ch)}joinRoom(t,e){return u(this,arguments,function*(r,i,s=!1,n=!1,o={}){a(this,os,mn).mediaJoinAttempted=!0,f(this,dn,!0),s&&this.reset();try{return yield a(this,un).push(()=>U(this,yu,xg).call(this,r,i,n,o),"joinRoom")}catch(c){return this.logger.error("Error in room joining process",{error:c}),this.context.getValue("peerSessionStore").emit(M.ROOM_NODE_FAILED),{roomJoined:!1}}})}initializeConnection(t,e){return u(this,arguments,function*(r,i,s=!1,n={}){return a(this,pr)?a(this,pr):(f(this,pr,(()=>u(this,null,function*(){try{yield U(this,Uc,ku).call(this,r,i,s,n)}catch(o){throw f(this,pr,null),o}}))()),a(this,pr))})}getConsumers(){return a(this,J).consumers}leaveRoom(){return u(this,null,function*(){a(this,J).stopAllTransports(),f(this,ln,!1),a(this,os,mn).mediaJoinAttempted=!1;const t={closeRoom:!1};a(this,St).sendMessagePromise(a(this,Dt).leaveRoom,CI.toBinary(t)).then(e=>{var r;(r=gC.fromBinary(e.payload))!=null&&r.closed&&this.logger.warn("Weird state on peer closed and should not happen")}).catch(e=>{this.logger.error("error on sending leave room request",{error:e})}),this.context.getValue("callstats").callEnded(),this.context.getValue("telemetry").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,J).createConsumers(t)})}closeConsumers(t){return u(this,null,function*(){if(!t.length)return;const e=t.reduce((r,i)=>{const s=a(this,J).producerIdToConsumerIdMap.get(i.producerId);return s?(r.push(s),r):(this.logger.warn(`consumer not found in close consumers: ${i.producerId}`),r)},[]);yield a(this,J).closeConsumers(e)})}_shareWebcam(t,e){return u(this,null,function*(){const r=e==="video/VP9"?Se.WEBCAM:Se.WEBCAM_BACKUP,i=U(this,lt,Tt).call(this,r);if(i){const h=yield i;if(a(this,J).producers.has(h)){const p=a(this,J).producers.get(h);if(!p.closed)return yield p.replaceTrack({track:t}),yield this.resumeWebcam(r),t;yield this.disableWebcam(e)}return this._shareWebcam(t,e)}const s=[e].concat(qt.filter(h=>h!==e)),n=U(this,Ru,$g).call(this,t,s),o=Zn(this.context,"disableSimulcast"),c=a(this,$r)===De.CF?X.ENABLE_CF_SIMULCAST:X.ENABLE_HIVE_SIMULCAST;!o&&this.context.getValue("flagsmith").hasFeature(c)?(this.logger.info(`Simulcast enabled for SFU: ${a(this,$r)}`),n.encodings=hO(this.context,t)):this.logger.info(`Simulcast disabled for webcam producer, SFU: ${a(this,$r)}`),this.context.getValue("flagsmith").hasFeature(X.TRACK_HINT)&&(n.track.contentHint=this.context.getValue("flagsmith").getValue(X.TRACK_HINT));const d=()=>{this.logger.info("Disabling video due to the producer closure"),a(this,Ot).delete(r)},l=a(this,J).createProducer(n,d);return U(this,gn,ro).call(this,r,l.then(h=>h.id)),l.then(h=>h.track)})}shareWebcam(t){return u(this,null,function*(){var e;if(t===void 0)return null;const r=(e=this.context.getValue("flagsmith").getValue(X.FORCE_VIDEO_CODEC))==null?void 0:e.toString();if(r)return this.logger.debug(`Calling _shareWebcam with forced video codec: ${r}`),this._shareWebcam(t,r);const i=qt.filter(s=>{var n,o;return((o=(n=a(this,eo).sender)==null?void 0:n.video)==null?void 0:o.codecs.findIndex(c=>c.mimeType===s))>=0&&a(this,pn).get(s).size>0});return i.length===0&&i.push(qt[0]),yield Promise.all(i.map(s=>(this.logger.debug(`Calling _shareWebcam with video codec: ${s}`),this._shareWebcam(t,s)))),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:Ie.isElectron()},stopTracks:!1},s=()=>{this.logger.info("Disabling screenShare due to the producer closure"),a(this,Ot).delete(Se.SCREENSHARE_VIDEO),a(this,Ot).delete(Se.SCREENSHARE_AUDIO)},n=a(this,J).createProducer(i,s);U(this,gn,ro).call(this,Se.SCREENSHARE_VIDEO,n.then(c=>c.id));let o;if(r){const c={track:r,codecOptions:[{name:"opus"}],appData:{screenShare:!0,e2ee:this.e2ee,supportsRemoteControl:Ie.isElectron()},stopTracks:!1,zeroRtpOnPause:a(this,$r)!==De.CF},d=()=>{};o=a(this,J).createProducer(c,d),U(this,gn,ro).call(this,Se.SCREENSHARE_AUDIO,o.then(l=>l.id))}yield Promise.all([n,o||Promise.resolve()]),this.context.getValue("callstats").screenShareStart()})}shareMic(t){return u(this,null,function*(){try{if(t===void 0)throw new Ut("track undefined");const e=U(this,lt,Tt).call(this,Se.MIC);if(e){const n=yield e;if(a(this,J).producers.has(n)){const o=a(this,J).producers.get(n);if(!o.closed){yield o.replaceTrack({track:t}),yield this.resumeMic(),a(this,Gt)&&(a(this,Gt).audioTrack=t,a(this,Gt).producerId=n,a(this,Gt).start());return}yield a(this,J).closeProducer(n,{stopTrack:!1})}yield this.shareMic(t);return}const r=U(this,Pu,Gg).call(this,t),i=()=>{a(this,Ot).delete(Se.MIC)},s=a(this,J).createProducer(r,i);U(this,gn,ro).call(this,Se.MIC,s.then(n=>n.id)),yield s.then(n=>{a(this,Gt)&&(a(this,Gt).audioTrack=n.track,a(this,Gt).producerId=n.id,a(this,Gt).start())})}catch(e){throw new I(e)}})}pauseMic(){return u(this,null,function*(){var t;const e=yield U(this,lt,Tt).call(this,Se.MIC),r=a(this,J).producers.get(e);if(!r){this.logger.error("pauseMic::could_not_find_mic_producer");return}if(r.paused){this.logger.info("pauseMic::mic_producer_already_paused");return}r.pause(),(t=a(this,Gt))==null||t.stop();const i={producerId:r.id,pause:!0};a(this,St).sendMessage(a(this,Dt).toggleProducer,vc.toBinary(i))})}pauseWebcam(){return u(this,null,function*(){const t=yield U(this,lt,Tt).call(this,Se.WEBCAM),e=yield U(this,lt,Tt).call(this,Se.WEBCAM_BACKUP),r=a(this,J).producers.get(t),i=a(this,J).producers.get(e);if(!r&&!i){this.logger.error("pauseWebcam::could_not_find_webcam_producer");return}const s=n=>{const o={producerId:n.id,pause:!0};a(this,St).sendMessage(a(this,Dt).toggleProducer,vc.toBinary(o))};r&&(r.pause(),s(r)),i&&(i.pause(),s(i))})}resumeMic(){return u(this,null,function*(){const t=yield U(this,lt,Tt).call(this,Se.MIC),e=a(this,J).producers.get(t);if(!e){this.logger.error("resumeMic::could_not_find_mic_producer");return}if(!e.pause){this.logger.info("resumeMic::mic_producer_already_resumed");return}e.resume(),e.appData.e2ee&&this.context.getValue("peerSessionStore").emit(M.E2EE_ACTIVE_PRODUCER,e);const r={producerId:e.id,pause:!1};a(this,St).sendMessage(a(this,Dt).toggleProducer,vc.toBinary(r))})}resumeWebcam(){return u(this,arguments,function*(t=Se.WEBCAM){const e=yield U(this,lt,Tt).call(this,t),r=a(this,J).producers.get(e);if(!r){this.logger.error("resumeWebcam::could_not_find_webcam_producer");return}if(!r.paused){this.logger.info("resumeWebcam::webcam_producer_already_resumed");return}r.resume(),r.appData.e2ee&&this.context.getValue("peerSessionStore").emit(M.E2EE_ACTIVE_PRODUCER,r);const i={producerId:r.id,pause:!1};a(this,St).sendMessage(a(this,Dt).toggleProducer,vc.toBinary(i))})}disableWebcam(t){return u(this,null,function*(){const e=t==="video/VP9"?Se.WEBCAM:Se.WEBCAM_BACKUP,r=yield U(this,lt,Tt).call(this,e);U(this,Cu,qg).call(this,e),r&&(yield a(this,J).closeProducer(r))})}disableMic(){return u(this,null,function*(){var t;const e=yield U(this,lt,Tt).call(this,Se.MIC);e&&(yield a(this,J).closeProducer(e)),(t=a(this,Gt))==null||t.stop(),a(this,Ot).delete(Se.MIC)})}disableScreenShare(){return u(this,null,function*(){this.logger.info("screen_sharing_stopped"),this.context.getValue("callstats").screenShareStop();const t=yield U(this,lt,Tt).call(this,Se.SCREENSHARE_VIDEO),e=yield U(this,lt,Tt).call(this,Se.SCREENSHARE_AUDIO);t&&(yield a(this,J).closeProducer(t)),e&&(yield a(this,J).closeProducer(e)),a(this,Ti).clear(),a(this,Ot).delete(Se.SCREENSHARE_VIDEO),a(this,Ot).delete(Se.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 U(this,lt,Tt).call(this,Se.WEBCAM),i=yield U(this,lt,Tt).call(this,Se.WEBCAM_BACKUP);yield a(this,J).closeProducer(r,{stopTrack:!1}),yield a(this,J).closeProducer(i,{stopTrack:!1}),this.shareWebcam(t)}if(e){const r=yield U(this,lt,Tt).call(this,Se.SCREENSHARE_VIDEO);yield a(this,J).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,J).socketHandler.changeDisplayName(r)))throw new Error("failed to change display name!")})}kick(t){const e={peerIds:[t]};a(this,J).socketHandler.kickPeer(e)}kickAll(){a(this,J).socketHandler.kickAll()}muteAll(t){return u(this,null,function*(){if(!(yield a(this,J).socketHandler.hostControlForAll("audio")))throw new Error("failed to mute all participant")})}muteAllVideo(){return u(this,null,function*(){if(!(yield a(this,J).socketHandler.hostControlForAll("video")))throw new Error("failed to mute all video participant")})}disableAudio(t){return u(this,null,function*(){if(!(yield a(this,J).socketHandler.hostControlForPeer(t,"audio")))throw new Error("failed to mute given participant")})}disableVideo(t){return u(this,null,function*(){if(!(yield a(this,J).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,St).sendMessagePromise(a(this,Dt).globalPinPeer,WI.toBinary(e))}catch(r){this.logger.error("Error in pinning peer:",{error:r})}})}validateScreenShare(t){return this.peerId===t.peerId&&a(this,J).producers.get(t.producerId)&&a(this,Ti).add(t.consumerPeerId),a(this,Ti).size}switchConsumersToLayer(t,e){return u(this,null,function*(){const r=t.map(i=>this.getConsumers().get(i));a(this,J).switchConsumersToLayer(r,e)})}handleSocketEvents(){return u(this,null,function*(){a(this,St).on(a(this,Dt).peerProducerCreateBroadcast,({payload:t})=>{var e,r;if(this.mediaJoined)try{const{participantId:i,producerState:s}=GC.fromBinary(t);if(i===this.peerId)return;if(s!=null&&s.mimeType||(s.mimeType=s.kind===Wr.AUDIO?"audio/opus":"video/VP8"),s.kind===Wr.VIDEO&&!s.screenShare&&((r=(e=a(this,eo).receiver)==null?void 0:e.video)==null?void 0:r.codecs.findIndex(n=>n.mimeType===qt[0]))>=0&&a(this,hn).get(qt[0]).has(i)&&s.mimeType!==qt[0]){this.logger.warn(`Ignoring producer: ${s.producerId}`);return}this.logger.info(`producer created broadcast: ${i}, producer state: ${s}`),this.context.getValue("peerSessionStore").emit(M.NEW_PRODUCER,{peerId:i,producer:G(V({},s),{kind:s.kind===Wr.AUDIO?"audio":"video",producingPeerId:i})})}catch(i){this.logger.error("error in peer-producer-create-broadcast",{error:i})}}),a(this,St).on(a(this,Dt).peerProducerToggleBroadcast,({payload:t})=>{if(this.mediaJoined)try{const{participantId:e,initiatorParticipantId:r,producerState:{kind:i,pause:s,producerId:n}}=Om.fromBinary(t),o=i===Wr.AUDIO?"audio":"video";if(this.logger.info(`producer toggle broadcast: ${e}, producerId: ${n}, kind:${o}, paused:${s} payload: ${JSON.stringify(Om.fromBinary(t))}`),e===this.peerId&&r!==this.peerId&&s&&this.context.getValue("peerSessionStore").emit(o==="audio"?M.MUTE_SELF:M.MUTE_SELF_VIDEO),e===this.peerId)return;this.context.getValue("peerSessionStore").emit(M.PRODUCER_TOGGLE,{peerId:e,producerId:n,paused:s,kind:o}),Array.from(this.getConsumers().values()).filter(c=>c.producerId===n).forEach(c=>{c.paused!==s&&(this.logger.debug(`consumer state mismatched for ${c.id}. updating consumer pause state ${c.paused} to ${s}`),s?(c.pause(),this.context.getValue("peerSessionStore").emit(M.CONSUMER_PAUSED,{id:c.id})):(c.resume(),this.context.getValue("peerSessionStore").emit(M.CONSUMER_RESUMED,{id:c.id})))})}catch(e){this.logger.error("error in producer toggle broadcast handler",{error:e})}}),a(this,St).on(a(this,Dt).peerLeaveBroadcast,({payload:t})=>{if(this.mediaJoined)try{const{participantId:e}=Gu.fromBinary(t);if(e===this.peerId)return;this.logger.info(`peer left broadcast:${e}`),a(this,Ti).delete(e),a(this,J).consumers.forEach(r=>{r.peerId===e&&r.close()}),this.context.getValue("peerSessionStore").emit(M.PEER_CLOSED,{id:e})}catch(e){this.logger.error("error in peer left broadcast",{error:e})}}),a(this,St).on(a(this,Dt).peerProducerCloseBroadcast,({payload:t})=>{if(this.mediaJoined)try{const{participantId:e,producerState:{producerId:r}}=KC.fromBinary(t);if(e===this.peerId)return;this.logger.info(`producer closed broadcast:${e}`),this.context.getValue("peerSessionStore").emit(M.PRODUCER_CLOSED,{peerId:e,producerId:r});const i=a(this,J).producerIdToConsumerIdMap.get(r);if(!i){this.logger.warn(`no consumer found for producer:${r}`);return}this.logger.info(`closing consumer ${i}, producer id: ${r}`),a(this,J).closeConsumer(i).then(()=>{this.logger.info(`closed consumer: ${i}`),a(this,J).producerIdToConsumerIdMap.delete(r),this.context.getValue("peerSessionStore").emit(M.CONSUMER_CLOSED,{id:i})}).catch(s=>{this.logger.error("error closing consumer",{error:s})})}catch(e){this.logger.error("error on producer close broadcast",{error:e})}}),a(this,St).on(a(this,Dt).mediaRoomTerminationBroadcastResponse,()=>{!this.mediaJoined&&!a(this,dn)&&!a(this,ln)||(this.logger.warn("media hub termination broadcast received, rejoining room"),this.context.getValue("peerSessionStore").emit(M.ROOM_NODE_DISCONNECTED),a(this,xc).call(this))})})}handleCallstatsEvents(){this.context.getValue("callstats").onConsumerScore(t=>{t.forEach((e,r)=>{const i=a(this,J).consumers.get(r);i&&this.context.getValue("peerSessionStore").emit(M.CONSUMER_SCORE_UPDATE,{id:r,kind:i.kind,peerId:i.peerId,score:e.score,scoreStats:e})})}),this.context.getValue("callstats").onProducerScore(t=>{t.forEach((e,r)=>{const i=Array.from(a(this,J).producers.values()).find(s=>s.id===r);i&&this.context.getValue("peerSessionStore").emit(M.PRODUCER_SCORE_UPDATE,{id:r,kind:i.kind,appData:i.appData,score:e.score,scoreStats:e})})})}handlePeerCapabilities(t,e){var r,i,s,n;for(let o=0;o<=qt.length;o+=1){const c=qt[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===qt.length-1){a(this,pn).get(c).add(t);break}}for(let o=0;o<=qt.length;o+=1){const c=qt[o];if(((n=(s=e==null?void 0:e.sender)==null?void 0:s.video)==null?void 0:n.codecs.findIndex(d=>d.mimeType===c))>=0||o===qt.length-1){a(this,hn).get(c).add(t);break}}}handlePeerLeaving(t){this.context.getValue("flagsmith").hasFeature(X.FORCE_VIDEO_CODEC)||(a(this,hn).forEach(e=>e.delete(t)),a(this,pn).forEach((e,r)=>{e.delete(t),!(e.size!==0||r===qt[0])&&this.disableWebcam(r)}))}},Vc=new WeakMap,Lc=new WeakMap,St=new WeakMap,J=new WeakMap,eo=new WeakMap,$r=new WeakMap,Dt=new WeakMap,dn=new WeakMap,ln=new WeakMap,un=new WeakMap,xc=new WeakMap,pr=new WeakMap,Ti=new WeakMap,to=new WeakMap,hn=new WeakMap,pn=new WeakMap,Ot=new WeakMap,Gt=new WeakMap,os=new WeakSet,mn=function(){return this.context.getValue("connectionHandler")},yu=new WeakSet,xg=function(t,e,r,i){return u(this,null,function*(){f(this,Lc,t);try{return a(this,pr)?yield a(this,pr):yield U(this,Uc,ku).call(this,t,e,r,i),U(this,Tu,Fg).call(this,e),{roomJoined:yield U(this,Su,Ug).call(this)}}catch(s){return this.logger.error("Failed to complete room join",{error:s}),{roomJoined:!1}}finally{f(this,pr,null)}})},Su=new WeakSet,Ug=function(){return u(this,null,function*(){try{this.mediaJoined=!0;const{roomState:t}=yield a(this,J).socketHandler.notifySelfJoinComplete();return f(this,Vc,t.roomUuid),f(this,ln,!0),f(this,dn,!1),!0}catch(t){return this.logger.error("Error completing room join",{error:t}),this.mediaJoined=!1,!1}})},Tu=new WeakSet,Fg=function(t){navigator.product!=="ReactNative"&&setTimeout(()=>{try{const e={userId:this.context.getValue("userId"),peerId:this.peerId,roomUUID:t,roomViewType:"groupCall",deviceInfo:G(V({},Ie.getDeviceInfo()),{userAgent:navigator.userAgent,memory:navigator.deviceMemory,cpus:navigator.hardwareConcurrency}),sdkName:this.context.getValue("sdkName"),sdkVersion:this.context.getValue("sdkVersion"),metaData:{},permissions:{}};this.context.getValue("callstats").roomJoined(e)}catch(e){this.logger.error("Error reporting room joined analytics",{error:e})}},0)},Uc=new WeakSet,ku=function(t,e,r,i){return u(this,null,function*(){var s,n;try{(n=a(this,to))!=null||f(this,to,U(s=Dy,Eu,Bg).call(s));const o=U(this,wu,Wg).call(this);yield U(this,_u,jg).call(this,t,e,r,o),yield a(this,J).setupTransports({send:!0,recv:!0}),yield U(this,Iu,Hg).call(this,i)}catch(o){throw this.logger.error("Failed to initialize connection",{error:o}),o}})},Eu=new WeakSet,Bg=function(){const{ipInfo:t}=pt();if(!(t!=null&&t.loc))return;const[e,r]=t.loc.split(",").map(parseFloat);return{latitude:e,longitude:r}},wu=new WeakSet,Wg=function(){var t;const e=(t=this.context.getValue("flagsmith").getValue(X.FORCE_VIDEO_CODEC))==null?void 0:t.toString(),r=l1(e);return f(this,eo,r),r},_u=new WeakSet,jg=function(t,e,r,i){return u(this,null,function*(){yield vy((s,n)=>u(this,null,function*(){if(!a(this,St).isConnected){n(new Error("Socket is not connected"));return}s>0&&this.logger.warn("Retry: send joinRoom message",{debuggingHint:`Retry attempt ${s}`});try{yield a(this,J).socketHandler.joinRoom(e,t,i,r,a(this,to))}catch(o){throw this.logger.error("Failed to send joinRoom message after retries",{error:o}),o}}),{delayTime:1e3,strategy:"exponential",maxRetryCount:this.context.getValue("flagsmith").hasFeature(X.ENABLE_HIVE_INFINITE_RETRIES)?1/0:3})})},Iu=new WeakSet,Hg=function(t){return u(this,null,function*(){if(!(a(this,$r)===De.HIVE||!this.context.getValue("flagsmith").hasFeature(X.PRECREATE_PRODUCERS)||!t))try{const e=[];if(t.canProduceVideo===q.Allowed&&e.push(this.shareWebcam(P1(!1))),t.canProduceAudio===q.Allowed){const r=C1(!1);r&&e.push(this.shareMic(r))}e.length>0&&(yield Promise.all(e))}catch(e){this.logger.warn("Failed to precreate producers",{error:e})}})},lt=new WeakSet,Tt=function(t){return a(this,Ot).get(t)},gn=new WeakSet,ro=function(t,e){return a(this,Ot).set(t,e)},Cu=new WeakSet,qg=function(t){return a(this,Ot).delete(t)},Pu=new WeakSet,Gg=function(t){return{track:t,encodings:[{priority:"high"}],codecOptions:[{name:"opus"}],appData:{e2ee:this.e2ee},stopTracks:!1,zeroRtpOnPause:a(this,$r)!==De.CF}},Ru=new WeakSet,$g=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}},g(bu,Eu),bu);let le=Dy;me([k.trace("MediaNodeClient.reset",{country:k.location.country})],le.prototype,"reset",1);me([k.trace("MediaNodeClient.joinRoom")],le.prototype,"joinRoom",1);me([k.trace("MediaNodeClient.leaveRoom")],le.prototype,"leaveRoom",1);me([k.trace("MediaNodeClient.activatePeers")],le.prototype,"activatePeers",1);me([k.trace("MediaNodeClient.createConsumers")],le.prototype,"createConsumers",1);me([k.trace("MediaNodeClient.closeConsumers")],le.prototype,"closeConsumers",1);me([k.trace("MediaNodeClient._shareWebcam")],le.prototype,"_shareWebcam",1);me([k.trace("MediaNodeClient.shareWebcam")],le.prototype,"shareWebcam",1);me([k.trace("MediaNodeClient.shareScreen")],le.prototype,"shareScreen",1);me([k.trace("MediaNodeClient.shareMic")],le.prototype,"shareMic",1);me([k.trace("MediaNodeClient.pauseMic")],le.prototype,"pauseMic",1);me([k.trace("MediaNodeClient.pauseWebcam")],le.prototype,"pauseWebcam",1);me([k.trace("MediaNodeClient.resumeMic")],le.prototype,"resumeMic",1);me([k.trace("MediaNodeClient.resumeWebcam")],le.prototype,"resumeWebcam",1);me([k.trace("MediaNodeClient.disableWebcam")],le.prototype,"disableWebcam",1);me([k.trace("HiveClient.disableMic")],le.prototype,"disableMic",1);me([k.trace("HiveClient.disableScreenShare")],le.prototype,"disableScreenShare",1);me([k.trace("MediaNodeClient.muteSelf")],le.prototype,"muteSelf",1);me([k.trace("MediaNodeClient.resetVideoProducers")],le.prototype,"resetVideoProducers",1);me([k.trace("MediaNodeClient.changeDisplayName")],le.prototype,"changeDisplayName",1);me([k.trace("MediaNodeClient.kickPeer")],le.prototype,"kick",1);me([k.trace("MediaNodeClient.kickAllPeers")],le.prototype,"kickAll",1);me([k.trace("MediaNodeClient.muteAll")],le.prototype,"muteAll",1);me([k.trace("MediaNodeClient.muteAllVideo")],le.prototype,"muteAllVideo",1);me([k.trace("MediaNodeClient.disableAudio")],le.prototype,"disableAudio",1);me([k.trace("MediaNodeClient.disableVideo")],le.prototype,"disableVideo",1);me([k.trace("MediaNodeClient.pinPeer")],le.prototype,"pinPeer",1);me([k.trace("MediaNodeClient.validateScreenShare")],le.prototype,"validateScreenShare",1);function Oy(t,e,r){const i=t.getValue("roomNodeClient");if(i){if(i)return i;throw new Error("Room node client already set up.")}const s=new le(t,e,r);return t.setValue("roomNodeClient",s),s}function Ny(t){const e=t.getValue("roomNodeClient");try{e==null||e.leaveRoom()}catch{t.getValue("logger").error("roomNodeClient::cleanupRoomNodeClient")}t.setValue("roomNodeClient",void 0)}var A1=Object.defineProperty,D1=Object.getOwnPropertyDescriptor,Gs=(t,e,r,i)=>{for(var s=i>1?void 0:i?D1(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&A1(e,r,s),s},fn,Dr,ie,Nt,$t,Jg;const Vy=(Jg=class{constructor(t,e,r,i){g(this,Nt),m(this,"self"),m(this,"authToken"),g(this,fn,void 0),m(this,"viewType"),g(this,Dr,void 0),g(this,ie,void 0);const{socket:s}=r,n=t.getValue("authToken");this.self=e,f(this,ie,t),this.viewType=i,this.authToken=n,f(this,fn,s),f(this,Dr,r),e.config.viewType!==Ft.Chat&&this.setupEvents()}get peerId(){return a(this,ie).getValue("peerId")}get telemetry(){return a(this,ie).getValue("telemetry")}get logger(){return a(this,ie).getValue("logger")}get mediaJoined(){return a(this,ie).getValue("connectionHandler").mediaJoined}static init(t,e,r,i,s){return u(this,null,function*(){const n=pt(),o=t.getValue("peerId"),c=!!t.getValue("cachedUserDetails"),d=yield nt.__init__(t,r,i,s,s.name,c);t.setValue("self",d);const l=t.getValue("logger");if(navigator.product!=="ReactNative"){const h=!t.getValue("flagsmith").hasFeature(X.PRECALL_BANDWIDTH_TEST);setTimeout(()=>u(this,null,function*(){const p=yield d.getAllDevices();l.info("populated_full_device_list",{devices:JSON.stringify(p)}),t.getValue("callstats").devices("AUDIO",p==null?void 0:p.filter(v=>v.kind==="audioinput")),t.getValue("callstats").devices("VIDEO",p==null?void 0:p.filter(v=>v.kind==="videoinput")),t.getValue("callstats").devices("SPEAKER",p==null?void 0:p.filter(v=>v.kind==="audiooutput")),l.info("Callstats:: initializing");try{yield t.getValue("callstats").initialize({peerId:o,engineName:Ie.getDeviceInfo().engineName,env:t.getValue("env"),iceServers:yield n.getICEServers(),apiBase:t.getValue("apiBase"),flags:t.getValue("flagsmith").getAllFlags(),logger:l,apiHostnames:Ov(t),skipConnectivityChecks:h}),l.info("Callstats:: initialized")}catch(v){l.error("Callstats:: initialization failed",{error:v})}}),0)}else l.info("Callstats:: Skipped initialization due to navigator product being ReactNative.");return new Vy(t,d,e,s.viewType)})}shareMediaTracks(){return u(this,null,function*(){var t;const{audioTrack:e,videoTrack:r,permissions:i,audioEnabled:s,videoEnabled:n,screenShareEnabled:o,screenShareTracks:c}=this.self;if(i.canProduceAudio===q.Allowed&&s)try{yield a(this,Nt,$t).shareMic(e),this.self.audioEnabled||a(this,Nt,$t).pauseMic()}catch{this.self.disableAudio()}if(i.canProduceVideo===q.Allowed&&n)try{const d=yield a(this,Nt,$t).shareWebcam(r);d&&d.id!==r.id&&a(this,ie).getValue("flagsmith").hasFeature(X.EXP_RESHARE)&&(yield a(this,Nt,$t).shareWebcam(d)),this.self.videoEnabled||a(this,Nt,$t).pauseWebcam()}catch{this.self.disableVideo()}if(i.canProduceScreenshare===q.Allowed&&o)try{yield(t=a(this,Nt,$t))==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(){this.logger.info("SelController.waitlisted"),this.self.waitlistStatus="waiting",this.self.roomState="waitlisted",this.self.emit("waitlisted")}waitlistAcceptHandler(){if(this.logger.info("SelController.waitlistAccepted"),this.self.waitlistStatus==="accepted"){this.logger.warn("SelfController.WAITLIST_ACCEPTED.UserAlreadyAccepted");return}this.self.waitlistStatus="accepted",this.joinRoom()}waitlistRejectedHandler(){if(this.logger.info("SelfController.waitlistRejected"),this.self.waitlistStatus==="rejected"){this.logger.warn("SelfController.WAITLIST_REJECTED.UserAlreadyRejected");return}this.self.waitlistStatus="rejected",this.leaveRoom("rejected")}resetSelf(t){return u(this,null,function*(){a(this,ie).getValue("callstats").callEnded(),a(this,Nt,$t).reset(),t&&(yield this.joinRoom(t))})}setupEvents(){a(this,ie).getValue("peerSessionStore").on(M.RESET_PRODUCER_STATE,()=>u(this,null,function*(){this.mediaJoined&&this.shareMediaTracks()})),a(this,ie).getValue("peerSessionStore").on(M.ROOM_NODE_RECONNECTED,()=>{this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:!0})}),a(this,ie).getValue("peerSessionStore").on(M.ROOM_NODE_DISCONNECTED,()=>{this.self.roomState!=="disconnected"&&(this.self.roomState="disconnected",this.self.emit("roomLeft",{state:"disconnected"}))}),a(this,ie).getValue("peerSessionStore").on(M.ROOM_NODE_FAILED,()=>{this.self.roomState="failed",this.self.emit("roomLeft",{state:"failed"})}),a(this,ie).getValue("peerSessionStore").on(M.SOCKET_SERVICE_RECONNECTED,({wasJoinAttempted:t})=>{t===!1&&(this.self.roomState="init"),this.resetSelf(t)}),a(this,ie).getValue("peerSessionStore").on(M.SOCKET_SERVICE_DISCONNECTED,({joinAttempted:t})=>{if(this.self.roomState==="disconnected")return;let{peerId:e}=this;t&&a(this,ie).getValue("flagsmith").hasFeature(X.REFRESH_ID_ON_DISCONNECTION)&&(e=Os()),a(this,fn).updateURL(e),a(this,ie).getValue("telemetry").resetPeerId(e),pt().setHeader("dyte-tracing-id",e),ai.remapContext(e,a(this,ie)),this.self.roomState="disconnected",this.self.emit("roomLeft",{state:"disconnected"})}),a(this,ie).getValue("peerSessionStore").on(M.SOCKET_SERVICE_FAILED,()=>{this.self.roomState="failed",this.self.emit("roomLeft",{state:"failed"})}),a(this,Dr).on(F.waitingRoomRequestAccepted,()=>{this.waitlistAcceptHandler()}),a(this,Dr).on(Kc.updateUserPreset,t=>{t.updatePeersPresets.forEach(e=>{e.userIds===this.self.userId&&a(this,ie).getValue("peerSessionStore").emit(M.UPDATE_PERMISSIONS,e.patch)})}),a(this,Dr).on(F.waitingRoomRequestDenied,()=>{this.waitlistRejectedHandler()}),a(this,Dr).on(F.kick,()=>{this.kickHandler({kickType:"kick"})}),a(this,Dr).on(F.kickAll,()=>{this.kickHandler({kickType:"kickAll"})}),a(this,ie).getValue("peerSessionStore").onAsync(M.JOIN_MEDIA_ROOM,this.joinMediaRoom.bind(this)),a(this,ie).getValue("peerSessionStore").on(M.PRODUCER_SCORE_UPDATE,({score:t,kind:e,appData:r,scoreStats:i})=>{var s;const n=(s=r==null?void 0:r.screenShare)!=null?s:!1;this.self.emit("mediaScoreUpdate",{kind:e,isScreenshare:n,score:t,participantId:this.self.id,scoreStats:i})}),a(this,ie).getValue("peerSessionStore").on(M.MUTE_SELF,()=>u(this,null,function*(){this.self.audioEnabled&&(yield this.self.disableAudio(),a(this,ie).getValue("callstats").audioOff())})),a(this,ie).getValue("peerSessionStore").on(M.MUTE_SELF_VIDEO,()=>u(this,null,function*(){this.self.videoEnabled&&(yield this.self.disableVideo(),a(this,ie).getValue("callstats").videoOff())})),a(this,ie).getValue("peerSessionStore").onAsync(M.LEAVE_MEDIA_ROOM,this.leaveMediaRoom.bind(this)),a(this,ie).getValue("peerSessionStore").on(M.PIP_HANGUP,this.leaveRoom.bind(this))}joinRoom(t=!1){return u(this,null,function*(){try{const{peer:e}=yield a(this,Dr).joinRoom(this.self);a(this,Dr).socket.flush();const r=gp(e.stageType);if(a(this,ie).setValue("stageStatus",r,!1),e.waitlisted){this.waitlistedHandler();return}yield this.joinMediaRoom(t),a(this,ie).notify("stageStatus")}catch(e){throw this.logger.error("Error in joinRoom",{error:e}),e}})}leaveRoom(t="left"){return u(this,null,function*(){var e,r;if(this.logger.info(`Leaving room with state: ${t}`),(e=a(this,ie).getValue("roomSocketHandler"))==null||e.cleanup(),t==="rejected"){this.self.roomState=t,this.self.emit("roomLeft",{state:t});return}this.self.setIsPinned(!1),a(this,ie).setValue("stageStatus","OFF_STAGE",!1),yield this.leaveMediaRoom(t),a(this,ie).notify("stageStatus");try{(r=a(this,fn))==null||r.disconnect()}catch{this.logger.error("SelfController::leaveRoom::socketDisconnect")}Ny(a(this,ie)),this.self.roomState=t,this.self.emit("roomLeft",{state:t}),this.logger.info(`roomLeft event emitted with state: ${t}`)})}joinMediaRoom(t=!1){return u(this,null,function*(){var e,r;const{peerId:i,viewType:s,meetingId:n,stageStatus:o,roomNodeOptions:c}=a(this,ie).getAllValues(),{sfu:d}=c;try{if(s===Ft.Livestream){if(o!=="ON_STAGE"){this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:t});return}Oy(a(this,ie),d,{socket:a(this,fn),peerId:i})}const{canProduceAudio:l,canProduceVideo:h,canProduceScreenshare:p}=this.self.permissions,{roomJoined:v}=(r=yield(e=a(this,Nt,$t))==null?void 0:e.joinRoom(this.self.name,n,t,t,{canProduceAudio:l,canProduceVideo:h,canProduceScreenshare:p}))!=null?r:{};if(!v)return;o==="ON_STAGE"&&(yield this.shareMediaTracks()),this.self.roomState="joined",this.self.emit("roomJoined",{reconnected:t})}catch(l){throw this.logger.error("Error:SelfController.mediaRoomJoin",{error:l}),new I("Error: could not join media room","0002")}})}leaveMediaRoom(t){return u(this,null,function*(){const e=a(this,ie).getValue("viewType");t!=="connected-meeting"&&(yield this.cleanupSelf()),!(t==="stageLeft"&&e===Ft.Webinar)&&a(this,Nt,$t)&&(a(this,Nt,$t).mediaJoined&&t!=="disconnected"&&(yield a(this,Nt,$t).leaveRoom()),!(t==="stageLeft"&&e===Ft.Livestream)&&(a(this,Nt,$t).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()})}},fn=new WeakMap,Dr=new WeakMap,ie=new WeakMap,Nt=new WeakSet,$t=function(){return a(this,ie).getValue("roomNodeClient")},Jg);let Yi=Vy;Gs([k.trace("SelfController.resetSelf")],Yi.prototype,"resetSelf",1);Gs([k.trace("SelfController.setupEvents")],Yi.prototype,"setupEvents",1);Gs([k.trace("SelfController.joinRoom")],Yi.prototype,"joinRoom",1);Gs([k.trace("SelfController.leaveRoom")],Yi.prototype,"leaveRoom",1);Gs([k.trace("SelfController.joinMediaRoom")],Yi.prototype,"joinMediaRoom",1);Gs([k.trace("SelfController.leaveMediaRoom")],Yi.prototype,"leaveMediaRoom",1);Gs([k.trace("SelfController.init")],Yi,"init",1);var Md;class O1{constructor(e){g(this,Md,void 0),f(this,Md,e)}on(e,r){let i;e===F.roomPeerCount?i=Lm.fromBinary.bind(Lm):i=Jm.fromBinary.bind(Jm),a(this,Md).on(e,({payload:s})=>{if(e===F.roomPeerCount&&!s)return;const n=i(s);r(n)})}}Md=new WeakMap;var Ad,Dd;class N1{constructor(e,r){g(this,Ad,void 0),g(this,Dd,void 0),f(this,Ad,r),f(this,Dd,e)}get logger(){return a(this,Dd).getValue("logger")}on(e,r){let i,s;switch(e){case F.transcript:{i=Jl.fromBinary.bind(Jl),s=Jl.create();break}default:{this.logger.debug("AISocketHandler switch case hit default, event not accounted for.");break}}a(this,Ad).on(e,({payload:n})=>{let o=s;try{o=i(n)}catch(c){this.logger.error("chatSocketHandler::on::binary_decode_error",{error:c})}return r(o)})}}Ad=new WeakMap,Dd=new WeakMap;var V1=Object.defineProperty,L1=Object.getOwnPropertyDescriptor,Cp=(t,e,r,i)=>{for(var s=i>1?void 0:i?L1(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&V1(e,r,s),s},Ni,Ro;class Al{constructor(e,r){g(this,Ni,void 0),g(this,Ro,void 0),f(this,Ni,r),f(this,Ro,e)}get logger(){return a(this,Ro).getValue("logger")}get telemetry(){return a(this,Ro).getValue("telemetry")}getPolls(){return a(this,Ni).sendMessagePromise(ei.getPolls)}createPoll(e,r,i=!1,s=!1){const n={anonymous:i,hideVotes:s,question:e,options:r};return a(this,Ni).sendMessage(ei.createPoll,LA.toBinary(n))}votePoll(e,r){const i={index:r,pollId:e};return a(this,Ni).sendMessage(ei.votePoll,UA.toBinary(i))}on(e,r){let i,s;switch(e){case ei.updatePoll:case ei.createPoll:case ei.votePoll:{i=Zl.fromBinary.bind(Zl),s=Zl.create();break}}a(this,Ni).on(e,({payload:n})=>{let o=s;try{o=i(n)}catch(c){this.logger.error("pollSocketHandler::on::binary_decode_error",{error:c})}return r(o)})}removeListeners(e){a(this,Ni).removeListeners(e)}}Ni=new WeakMap,Ro=new WeakMap;Cp([k.trace("PollSocketHandler.getPolls")],Al.prototype,"getPolls",1);Cp([k.trace("PollSocketHandler.createPoll")],Al.prototype,"createPoll",1);Cp([k.trace("PollSocketHandler.votePoll")],Al.prototype,"votePoll",1);var x1=Object.defineProperty,U1=Object.getOwnPropertyDescriptor,F1=(t,e,r,i)=>{for(var s=i>1?void 0:i?U1(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&x1(e,r,s),s},ar;class Ly{constructor(e,r){m(this,"socket"),g(this,ar,void 0),f(this,ar,e),this.socket=r,this.handleSocketEvents(),a(this,ar).setValue("roomSocketHandler",this)}get telemetry(){return a(this,ar).getValue("telemetry")}get logger(){return a(this,ar).getValue("logger")}cleanup(){var e;try{(e=this.socket)==null||e.disconnect()}catch{this.logger.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:""},s=this.socket.sendMessagePromise(F.joinRoom,bP.toBinary(i));try{const{peer:n}=Sn.fromBinary((yield s).payload);a(this,ar).getValue("connectionHandler").socketJoined=!0,a(this,ar).getValue("peerSessionStore").emit(M.SOCKET_SERVICE_ROOM_JOINED,{peer:n});const o=this.getRoomState(),c=this.getRoomPeersNonPaginated(),[{room:d},{peers:l}]=yield Promise.all([o,c]);return a(this,ar).getValue("peerSessionStore").emit(M.ROOM_STATE,d),a(this,ar).getValue("peerSessionStore").emit(M.SOCKET_PEERS,l),{peer:n}}catch(n){throw this.logger.error("RoomSocketHandler.joinRoom.failed",{error:n}),new I("Error: RoomSocketHandler.joinRoom failed.","0002",this.logger,n)}})}getAllAddedParticipants(){return u(this,null,function*(){try{return oR.fromBinary((yield this.socket.sendMessagePromise(F.getAllAddedParticipants)).payload).participants.map(e=>{var r=e,{id:i}=r,s=fl(r,["id"]);return G(V({},s),{userId:i})})}catch{return[]}})}getRoomPeers(e,r,i){return u(this,null,function*(){let s;try{const n={seachQuery:e,limit:r,offset:i},o=yield this.socket.sendMessagePromise(F.getRoomPeersInfo,pP.toBinary(n));s=Kl.fromBinary(o.payload)}catch(n){this.logger.error("getRoomPeers::binary_decode_error",{error:n})}return s})}getRoomPeersNonPaginated(){return u(this,null,function*(){let e;try{const r=yield this.socket.sendMessagePromise(F.getRoomPeersInfo);e=Kl.fromBinary(r.payload)}catch(r){this.logger.error("getRoomJoinedPeers::binary_decode_error",{error:r})}return e})}getStagePeers(){return u(this,null,function*(){let e;try{const r=yield this.socket.sendMessagePromise(F.getRoomPeersInfo);e=Kl.fromBinary(r.payload)}catch(r){this.logger.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(F.getPeerInfo,qv.toBinary({peerId:e}));r=Sn.fromBinary(i.payload)}catch(i){this.logger.error("getPeerInfo::binary_decode_error",{error:i})}return r})}getRoomState(){return u(this,null,function*(){let e=xm.create();try{const r=yield this.socket.sendMessagePromise(F.getRoomInfo);e=xm.fromBinary(r.payload)}catch(r){this.logger.error("getRoomState::binary_decode_error",{error:r})}return e})}getRoomStageState(){return u(this,null,function*(){let e=Wm.create();try{const r=yield this.socket.sendMessagePromise(F.getRoomStageState);e=Wm.fromBinary(r.payload)}catch(r){this.logger.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(F.broadcastMessage,ba.toBinary(i))})}broadcastToMeetings(e,r,i){return u(this,null,function*(){const s={type:e,payload:new TextEncoder().encode(JSON.stringify(i)),timestamp:Date.now(),ids:r,broadcastType:1};return this.socket.sendMessagePromise(F.broadcastToEntity,ba.toBinary(s))})}broadcastToPeers(e,r,i){return u(this,null,function*(){const s={type:e,payload:new TextEncoder().encode(JSON.stringify(i)),timestamp:Date.now(),ids:r,broadcastType:0};return this.socket.sendMessage(F.broadcastToEntity,ba.toBinary(s))})}leaveRoom(){return u(this,null,function*(){this.socket.joinAttempted=!1,this.socket.sendMessagePromise(F.leaveRoom,_P.toBinary({}))})}kick(e){return u(this,null,function*(){const r={peerIds:[e]};this.socket.sendMessage(F.kick,$v.toBinary(r))})}kickAll(e=!1){return u(this,null,function*(){const r={propagateKickAcrossRooms:e};this.socket.sendMessage(F.kickAll,Wv.toBinary(r))})}getWaitingRoomRequests(){this.socket.sendMessage(F.getWaitingRoomRequests)}acceptWaitingRoomRequest(e){const r={userIds:e};this.socket.sendMessage(F.acceptWaitingRoomRequests,pR.toBinary(r))}rejectWaitingRoomRequest(e){const r={userIds:e};this.socket.sendMessage(F.denyWaitingRoomRequests,gR.toBinary(r))}updatePermissions(e,r){return u(this,null,function*(){const i={updatePeersPresets:[]};return e.forEach(s=>{i.updatePeersPresets.push({userIds:s,patch:r})}),this.socket.sendMessagePromise(Kc.updateUserPreset,qR.toBinary(i))})}handleSocketEvents(){this.socket.on(F.broadcastMessage,({payload:e})=>{try{const r=ba.fromBinary(e);a(this,ar).getValue("peerSessionStore").emit(M.ROOM_MESSAGE,{payload:JSON.parse(new TextDecoder().decode(r.payload)),type:r.type,timestamp:r.timestamp})}catch(r){this.logger.error("failed to decode broadcast message:",r)}}),this.socket.on(F.broadcastToEntity,({payload:e})=>{try{const r=ba.fromBinary(e);a(this,ar).getValue("peerSessionStore").emit(M.MESSAGE,{payload:JSON.parse(new TextDecoder().decode(r.payload)),type:r.type,timestamp:r.timestamp})}catch(r){this.logger.error("failed to decode peer broadcast message:",r)}})}on(e,r){let i,s;switch(e){case F.joinRoom:case F.leaveRoom:case F.kick:case F.kickAll:{i=Sn.fromBinary.bind(Sn),s=Sn.create();break}case F.getWaitingRoomRequests:{i=(n,o)=>n?Bm.fromBinary(n,o):{requests:[]},s=Bm.create();break}case F.recordingPaused:case F.recordingStarted:case F.recordingStopped:{i=Ym.fromBinary.bind(Ym);break}case Kc.updateUserPreset:{i=jm.fromBinary.bind(jm);break}case br.peerJoinedBroadcast:case cr.peerJoinedBroadcast:{i=Am.fromBinary.bind(Am);break}case br.selfJoinComplete:case cr.selfJoinComplete:{i=qu.fromBinary.bind(qu);break}case br.globalPeerPinBroadcast:case cr.globalPeerPinBroadcast:{i=Nm.fromBinary.bind(Nm);break}case br.selectedPeer:case cr.selectedPeer:{i=Hu.fromBinary.bind(Hu);break}case br.selectedPeerDiff:case cr.selectedPeerDiff:{i=Mm.fromBinary.bind(Mm);break}case br.leaveRoom:case cr.leaveRoom:{i=Gu.fromBinary.bind(Gu);break}}this.socket.on(e,({payload:n})=>{let o=s;if(!i)return r(void 0);try{o=i(n)}catch(c){this.logger.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(Kc.getUserPresets,xR.toBinary(r)),s=WR.fromBinary(i.payload).peerPresets[0],n=new TextDecoder().decode(s.preset),o=JSON.parse(n).permissions;return{chat:o.chat,polls:o.polls,plugins:o.plugins}}catch(i){throw this.logger.error("Error in getting user preset",{error:i}),i}})}}ar=new WeakMap;F1([k.trace("RoomSocketHandler.joinRoom")],Ly.prototype,"joinRoom",1);var zt;class B1{constructor(e){g(this,zt,void 0),f(this,zt,e)}getStageRequests(){return u(this,null,function*(){const{payload:e}=yield a(this,zt).sendMessagePromise(F.getStageRequests);return e?Xl.fromBinary(e):{stageRequests:[]}})}requestAccess(){a(this,zt).sendMessage(F.requestStageAccess)}cancelRequestAccess(){a(this,zt).sendMessage(F.cancelStageRequest)}grantAccess(e){return u(this,null,function*(){const r={userIds:e};a(this,zt).sendMessage(F.grantStageAccess,IA.toBinary(r))})}denyAccess(e){return u(this,null,function*(){const r={userIds:e};a(this,zt).sendMessage(F.denyStageAccess,PA.toBinary(r))})}joinStage(){return a(this,zt).sendMessagePromise(F.joinStage,void 0,void 0,F.peerStageStatusUpdate)}leaveStage(e){const r={userIds:[e]};return a(this,zt).sendMessagePromise(F.leaveStage,zm.toBinary(r),void 0,F.peerStageStatusUpdate)}kick(e){const r={userIds:e};return a(this,zt).sendMessagePromise(F.leaveStage,zm.toBinary(r))}on(e,r){let i;switch(e){case F.grantStageAccess:case F.denyStageAccess:{i=void 0;break}case F.getStagePeers:{i=Km.fromBinary.bind(Km);break}case F.getStageRequests:case F.requestStageAccess:case F.cancelStageRequest:{i=Xl.fromBinary.bind(Xl);break}case F.peerStageStatusUpdate:{i=Vm.fromBinary.bind(Vm);break}}a(this,zt).on(e,({payload:s,id:n})=>{if(!s||!i)return r(void 0,n);const o=i(s);return r(o,n)})}getPeerInfo(e){return u(this,null,function*(){const r=yield a(this,zt).sendMessagePromise(F.getPeerInfo,qv.toBinary({peerId:e}));return Sn.fromBinary(r.payload)})}}zt=new WeakMap;var rt,Od;class W1{constructor(e,r){g(this,rt,void 0),g(this,Od,void 0),f(this,rt,r),f(this,Od,e)}get logger(){return a(this,Od).getValue("logger")}addPlugin(e,r){a(this,rt).sendMessage($.addPlugin,HM.toBinary({pluginId:e,staggered:r}))}removePlugin(e){a(this,rt).sendMessage($.removePlugin,GM.toBinary({pluginId:e,staggered:!1}))}getActivePlugins(){return u(this,null,function*(){const{payload:e}=yield a(this,rt).sendMessagePromise($.getPlugins);return e?mA.fromBinary(e):{plugins:[]}})}customPluginEventToRoom(e,r,i){const s={pluginId:e,pluginData:new TextEncoder().encode(JSON.stringify(r))};a(this,rt).sendMessage($.customPluginEventToRoom,tA.toBinary(s),i)}customPluginEventToPeers(e,r,i,s){const n={pluginId:e,peerIds:r,pluginData:new TextEncoder().encode(JSON.stringify(i))};a(this,rt).sendMessage($.customPluginEventToPeers,iA.toBinary(n),s)}enablePluginForRoom(e,r){a(this,rt).sendMessage($.enablePluginForRoom,JM.toBinary({pluginId:e}),r)}enablePluginForPeers(e,r,i){a(this,rt).sendMessage($.enablePluginForPeers,QM.toBinary({pluginId:e,peerIds:r}),i)}disablePluginForRoom(e,r){a(this,rt).sendMessage($.disablePluginForRoom,zM.toBinary({pluginId:e}),r)}disablePluginForPeers(e,r,i){a(this,rt).sendMessage($.disablePluginForPeers,ZM.toBinary({pluginId:e,peerIds:r}),i)}storeInsertKeys(e,r,i,s){const n={pluginId:e,storeName:r,insertKeys:i.map(o=>({storeKey:o.key,payload:new TextEncoder().encode(JSON.stringify(o.payload))}))};a(this,rt).sendMessage($.storeInsertKeys,Hm.toBinary(n),s)}storeGetKeys(e,r,i,s){const n={pluginId:e,storeName:r,getKeys:i.map(o=>({storeKey:o.key}))};a(this,rt).sendMessage($.storeGetKeys,oA.toBinary(n),s)}storeDeleteKeys(e,r,i,s){const n={pluginId:e,storeName:r,deleteKeys:i.map(o=>({storeKey:o.key}))};a(this,rt).sendMessage($.storeDeleteKeys,dA.toBinary(n),s)}storeDelete(e,r,i){a(this,rt).sendMessage($.storeDelete,uA.toBinary({pluginId:e,storeName:r}),i)}getPluginDataOld(e,r){this.logger.info("getPluginDataOld",{plugin:{id:e,storeName:r}})}storePluginDataOld(e,r,i){const s={pluginId:e,storeName:r,insertKeys:[{storeKey:i.key,payload:new TextEncoder().encode(JSON.stringify(i))}]};a(this,rt).sendMessage($.storeInsertKeys,Hm.toBinary(s))}on(e,r){let i;switch(e){case $.addPlugin:case $.enablePluginForPeers:case $.enablePluginForRoom:{i=zu.fromBinary.bind(zu);break}case $.removePlugin:case $.disablePluginForPeers:case $.disablePluginForRoom:{i=qm.fromBinary.bind(qm);break}case $.customPluginEventToPeers:case $.customPluginEventToRoom:{i=$m.fromBinary.bind($m);break}case $.storeInsertKeys:case $.storeGetKeys:case $.storeDeleteKeys:case $.storeDelete:{i=Gm.fromBinary.bind(Gm);break}}a(this,rt).on(e,({payload:s,id:n})=>{const o=i(s);return r(o,n)})}}rt=new WeakMap,Od=new WeakMap;var j1=Object.defineProperty,H1=(t,e,r)=>e in t?j1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,q1=(t,e,r)=>(H1(t,typeof e!="symbol"?e+"":e,r),r),Pp=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},N=(t,e,r)=>(Pp(t,e,"read from private field"),r?r.call(t):e.get(t)),we=(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)},de=(t,e,r,i)=>(Pp(t,e,"write to private field"),i?i.call(t,r):e.set(t,r),r),Re=(t,e,r)=>(Pp(t,e,"access private method"),r),cl={},G1={get exports(){return cl},set exports(t){cl=t}},Kn=typeof Reflect=="object"?Reflect:null,Kg=Kn&&typeof Kn.apply=="function"?Kn.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)},Nd;Kn&&typeof Kn.ownKeys=="function"?Nd=Kn.ownKeys:Object.getOwnPropertySymbols?Nd=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Nd=function(t){return Object.getOwnPropertyNames(t)};function $1(t){console&&console.warn&&console.warn(t)}var xy=Number.isNaN||function(t){return t!==t};function pe(){pe.init.call(this)}G1.exports=pe;cl.once=Y1;pe.EventEmitter=pe;pe.prototype._events=void 0;pe.prototype._eventsCount=0;pe.prototype._maxListeners=void 0;var zg=10;function Dl(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(pe,"defaultMaxListeners",{enumerable:!0,get:function(){return zg},set:function(t){if(typeof t!="number"||t<0||xy(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");zg=t}});pe.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};pe.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||xy(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 Uy(t){return t._maxListeners===void 0?pe.defaultMaxListeners:t._maxListeners}pe.prototype.getMaxListeners=function(){return Uy(this)};pe.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i=t==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var n;if(e.length>0&&(n=e[0]),n instanceof Error)throw n;var o=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw o.context=n,o}var c=s[t];if(c===void 0)return!1;if(typeof c=="function")Kg(c,this,e);else for(var d=c.length,l=Hy(c,d),r=0;r<d;++r)Kg(l[r],this,e);return!0};function Fy(t,e,r,i){var s,n,o;if(Dl(r),n=t._events,n===void 0?(n=t._events=Object.create(null),t._eventsCount=0):(n.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),n=t._events),o=n[e]),o===void 0)o=n[e]=r,++t._eventsCount;else if(typeof o=="function"?o=n[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),s=Uy(t),s>0&&o.length>s&&!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,$1(c)}return t}pe.prototype.addListener=function(t,e){return Fy(this,t,e,!1)};pe.prototype.on=pe.prototype.addListener;pe.prototype.prependListener=function(t,e){return Fy(this,t,e,!0)};function J1(){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},s=J1.bind(i);return s.listener=r,i.wrapFn=s,s}pe.prototype.once=function(t,e){return Dl(e),this.on(t,By(this,t,e)),this};pe.prototype.prependOnceListener=function(t,e){return Dl(e),this.prependListener(t,By(this,t,e)),this};pe.prototype.removeListener=function(t,e){var r,i,s,n,o;if(Dl(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(s=-1,n=r.length-1;n>=0;n--)if(r[n]===e||r[n].listener===e){o=r[n].listener,s=n;break}if(s<0)return this;s===0?r.shift():K1(r,s),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,o||e)}return this};pe.prototype.off=pe.prototype.removeListener;pe.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 s=Object.keys(r),n;for(i=0;i<s.length;++i)n=s[i],n!=="removeListener"&&this.removeAllListeners(n);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 Wy(t,e,r){var i=t._events;if(i===void 0)return[];var s=i[e];return s===void 0?[]:typeof s=="function"?r?[s.listener||s]:[s]:r?z1(s):Hy(s,s.length)}pe.prototype.listeners=function(t){return Wy(this,t,!0)};pe.prototype.rawListeners=function(t){return Wy(this,t,!1)};pe.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):jy.call(t,e)};pe.prototype.listenerCount=jy;function jy(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}pe.prototype.eventNames=function(){return this._eventsCount>0?Nd(this._events):[]};function Hy(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function K1(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function z1(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Y1(t,e){return new Promise(function(r,i){function s(o){t.removeListener(e,n),i(o)}function n(){typeof t.removeListener=="function"&&t.removeListener("error",s),r([].slice.call(arguments))}qy(t,e,n,{once:!0}),e!=="error"&&Q1(t,s,{once:!0})})}function Q1(t,e,r){typeof t.on=="function"&&qy(t,"error",e,r)}function qy(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 s(n){i.once&&t.removeEventListener(e,s),r(n)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}class X1 extends y{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 Yg=new X1;class Gy{static encode(e){return Yg.toBinary(e)}static decode(e){return Yg.fromBinary(new Uint8Array(e))}}function Z1(t,e){return Math.floor(Math.random()*(e-t+1)+t)}var Vi;class eN{constructor(e={}){q1(this,"opts"),we(this,Vi,void 0),this.opts={initialTimeout:e.initialTimeout||1e3,maxTimeout:e.maxTimeout||1e4,factor:e.factor||2},de(this,Vi,0)}wait(){return u(this,null,function*(){de(this,Vi,N(this,Vi)+1);const e=Z1(0,Math.min(this.opts.maxTimeout,this.opts.initialTimeout*cT(2,N(this,Vi))));yield new Promise(r=>{setTimeout(r,e)})})}getAttempts(){return N(this,Vi)}reset(){de(this,Vi,0)}}Vi=new WeakMap;const ki={debug:0,info:1,warn:2,error:3};var ks,Es;class tN{constructor(e){we(this,ks,void 0),we(this,Es,void 0),de(this,ks,console),de(this,Es,e)}debug(...e){ki[N(this,Es)]>ki.debug||N(this,ks).debug("[Sockrates]:",...e)}info(...e){ki[N(this,Es)]>ki.info||N(this,ks).info("[Sockrates]:",...e)}warn(...e){ki[N(this,Es)]>ki.warn||N(this,ks).warn("[Sockrates]:",...e)}error(...e){ki[N(this,Es)]>ki.error||N(this,ks).error("[Sockrates]:",...e)}}ks=new WeakMap,Es=new WeakMap;var $y=(t=>(t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSING=2]="CLOSING",t[t.CLOSED=3]="CLOSED",t))($y||{});const rN="2",iN="3";var Le,Vn,Pe,je,Li,it,ni,Hi,Er,Ln,Zr,Bh,Jy,Mo,Vd,Wh,Ky,jh,Qg,dl,Hh,qh,zy,qo,Ld,Go,ll,ul,Gh,zn,$o,Jo,hl;class sN{constructor(e,r){var i;we(this,Bh),we(this,Mo),we(this,Wh),we(this,jh),we(this,dl),we(this,qh),we(this,qo),we(this,Go),we(this,ul),we(this,zn),we(this,Jo),we(this,Le,void 0),we(this,Vn,void 0),we(this,Pe,void 0),we(this,je,void 0),we(this,Li,void 0),we(this,it,void 0),we(this,ni,void 0),we(this,Hi,void 0),we(this,Er,void 0),we(this,Ln,void 0),we(this,Zr,void 0);var s,n,o,c,d,l,h,p,v;de(this,Vn,e),de(this,Li,[]),de(this,it,new cl),de(this,ni,!0),de(this,Er,!1),de(this,Pe,r!=null?r:{}),(s=N(this,Pe)).autoReconnect!=null||(s.autoReconnect=!0),(n=N(this,Pe)).retryConnectionInterval!=null||(n.retryConnectionInterval=1e3),(o=N(this,Pe)).pingTimeout!=null||(o.pingTimeout=3e4),(c=N(this,Pe)).connectionTimeout!=null||(c.connectionTimeout=5e3),(d=N(this,Pe)).debug!=null||(d.debug=!0),(l=N(this,Pe)).maxReconnectionAttempts!=null||(l.maxReconnectionAttempts=10),(h=N(this,Pe)).disconnectOnPingTimeout!=null||(h.disconnectOnPingTimeout=!0),(p=N(this,Pe)).queueOnDisconnect!=null||(p.queueOnDisconnect=!1),(v=N(this,Pe)).flushOnReconnect!=null||(v.flushOnReconnect=!1),de(this,Hi,{code:void 0,reason:void 0}),de(this,je,(i=N(this,Pe).logger)!=null?i:new tN(N(this,Pe).debug?"debug":"info")),de(this,Zr,new eN)}get readyState(){var e;return(e=N(this,Le))==null?void 0:e.readyState}get url(){return N(this,Vn)}updateURL(e){de(this,Vn,e),Re(this,qh,zy).call(this)}get config(){return N(this,Pe)}get sendQueue(){return N(this,Li)}flush(){if(!N(this,Pe).queueOnDisconnect)return!1;const e=[];return N(this,Li).forEach(r=>{this.send(r.event,r.id,r.payload,r.metadata)||e.push(r)}),de(this,Li,e),N(this,Li)}connect(e=!1){return u(this,null,function*(){if(!e&&[0,1].includes(this.readyState)){N(this,je).debug("Websocket was already connecting or connected.");return}if(N(this,ni)!==!1)return new Promise((r,i)=>{Re(this,zn,$o).call(this),Re(this,Jo,hl).call(this);try{de(this,Le,new WebSocket(Re(this,Bh,Jy).call(this,N(this,Vn)))),N(this,Le).binaryType="arraybuffer",N(this,je).debug("Connecting");const s=setTimeout(()=>{N(this,je).debug("Connection timeout. Closing socket"),de(this,ni,!0),Re(this,Jo,hl).call(this),N(this,Le).close(3001,"Connection Timeout"),N(this,Pe).autoReconnect&&!N(this,Er)&&(N(this,it).emit("reconnecting"),Re(this,qo,Ld).call(this)),i(new Error("Connection timed out!"))},N(this,Pe).connectionTimeout);N(this,Le).onopen=()=>{N(this,je).debug(`Ready State: ${$y[N(this,Le).readyState]}`),s&&clearTimeout(s),Re(this,ul,Gh).call(this),de(this,Hi,{code:void 0,reason:void 0}),N(this,it).emit("connected"),N(this,Pe).flushOnReconnect&&this.flush(),r()},N(this,Le).onclose=n=>{try{s&&clearTimeout(s);const{code:o,reason:c}=n;i(c),N(this,je).debug("Socket closed. Close event:",{event:n}),N(this,je).debug(`Connection closed code: ${o}`),N(this,je).debug(`Connection closed reason: ${c}`),N(this,Er)||Re(this,dl,Hh).call(this,o,c)}catch(o){Re(this,Mo,Vd).call(this,o)}},N(this,Le).onerror=n=>{Re(this,Mo,Vd).call(this,n)},N(this,Le).onmessage=n=>Re(this,Wh,Ky).call(this,n)}catch(s){Re(this,Mo,Vd).call(this,s,i)}})})}send(e,r,i,s){const n={event:e,id:r,payload:i,metadata:s};if(N(this,Pe).queueOnDisconnect&&(!N(this,Le)||N(this,Le).readyState!==1))return N(this,je).debug("Queuing message since socket is not connected!",n),N(this,Li).push(n),!1;const o=Gy.encode(n);return Re(this,Go,ll).call(this,o)}emit(e,r,i,s){return this.send(e,r,i,s)}sendRaw(e){return Re(this,Go,ll).call(this,e)}receive(e,r){return N(this,it).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,it).on(e,r);return}this.receive(e,r)}removeAllListeners(){N(this,it).removeAllListeners()}removeReceiver(e,r){this.removeListener(e,r)}removeListener(e,r){N(this,it).removeListener(e.toString(),r)}removeReceivers(e){this.removeListeners(e)}removeListeners(e){N(this,it).listeners(e.toString()).map(r=>this.removeListener(e,r))}disconnect(){de(this,ni,!1),Re(this,zn,$o).call(this),this.removeAllListeners(),de(this,Hi,{code:1e3,reason:"Sockrates disconnect method called"}),N(this,Le).close(1e3,"Sockrates disconnect method called.")}}Le=new WeakMap,Vn=new WeakMap,Pe=new WeakMap,je=new WeakMap,Li=new WeakMap,it=new WeakMap,ni=new WeakMap,Hi=new WeakMap,Er=new WeakMap,Ln=new WeakMap,Zr=new WeakMap,Bh=new WeakSet,Jy=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)://.")},Mo=new WeakSet,Vd=function(t,e){N(this,je).error("Error:",{error:t}),N(this,it).emit("errored",{error:t}),e==null||e(t)},Wh=new WeakSet,Ky=function(t){if(Re(this,ul,Gh).call(this),t.data===rN){N(this,je).debug("Received ping from server"),Re(this,Go,ll).call(this,iN);return}const e=Gy.decode(t.data),{id:r,payload:i}=e;N(this,je).debug("Received message",{event:e.event,messageID:r}),N(this,it).emit(e.event.toString(),{id:r,payload:i})},jh=new WeakSet,Qg=function(){return N(this,Le).readyState===1},dl=new WeakSet,Hh=function(t,e){de(this,Hi,{reason:e,code:t}),N(this,it).emit("disconnected",{code:t,reason:e})},qh=new WeakSet,zy=function(){const{reason:t,code:e}=N(this,Hi);e&&e!==1e3&&N(this,ni)&&N(this,Pe).autoReconnect&&!N(this,Er)&&(N(this,je).debug(`Triggering reconnection due to ${t}.`),N(this,it).emit("reconnecting"),Re(this,qo,Ld).call(this))},qo=new WeakSet,Ld=function(t=!0){return u(this,null,function*(){if(t&&N(this,Er)){N(this,je).debug("Reconnect called when already in a reconnect loop. Ignoring.");return}if(N(this,Er)||N(this,Zr).reset(),N(this,Pe).maxReconnectionAttempts!==null&&N(this,Zr).getAttempts()>=N(this,Pe).maxReconnectionAttempts){N(this,it).emit("failed"),de(this,Er,!1);return}de(this,Er,!0),Re(this,Jo,hl).call(this),Re(this,zn,$o).call(this);try{if(yield N(this,Zr).wait(),N(this,ni)===!1)return;if(N(this,je).debug(`Reconnection attempt ${N(this,Zr).getAttempts()}`),N(this,it).emit("reconnectAttempt",{attempt:N(this,Zr).getAttempts()}),yield this.connect(),!Re(this,jh,Qg).call(this))throw Error("Reconnect Failed");de(this,Er,!1),de(this,Hi,{code:void 0,reason:void 0}),N(this,it).emit("reconnected")}catch{N(this,je).debug("Failed to reconnect."),N(this,it).emit("reconnectFailure",{attempt:N(this,Zr).getAttempts()}),Re(this,qo,Ld).call(this,!1)}})},Go=new WeakSet,ll=function(t){try{return N(this,Le).send(t),!0}catch(e){return N(this,je).error(e.message),!1}},ul=new WeakSet,Gh=function(){this.config.disconnectOnPingTimeout&&(N(this,je).debug("Resetting ping timeout"),Re(this,zn,$o).call(this),de(this,Ln,setTimeout(()=>{var t;N(this,je).debug("Disconnecting the socket due to ping timeout"),de(this,ni,!0);const e=3002,r="Ping timeout";(t=N(this,Le))==null||t.close(e,r),Re(this,dl,Hh).call(this,e,r)},N(this,Pe).pingTimeout)))},zn=new WeakSet,$o=function(){N(this,Ln)&&(clearTimeout(N(this,Ln)),de(this,Ln,void 0))},Jo=new WeakSet,hl=function(){N(this,Le)&&(N(this,Le).onopen=void 0,N(this,Le).onerror=void 0,N(this,Le).onmessage=void 0,N(this,Le).onclose=void 0)};var nN=Object.defineProperty,aN=Object.getOwnPropertyDescriptor,Ol=(t,e,r,i)=>{for(var s=i>1?void 0:i?aN(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&nN(e,r,s),s};const Xg=65535,oN=3e3;var cs,Oe,Ne,xe,mr,ut,Fc,Mu,Bc,Au,Zg;const Yy=(Zg=class{constructor(t,{peerId:e,meetingId:r,authToken:i,capabilities:s}){g(this,Ne),g(this,Fc),g(this,Bc),g(this,cs,void 0),g(this,Oe,void 0),m(this,"roomName"),m(this,"authToken"),m(this,"capabilities"),g(this,mr,void 0),g(this,ut,void 0);var n;if(!e||!r||!i)throw new I("peerId, meetingId, or authToken can not be empty","0404");f(this,mr,void 0),f(this,ut,t),this.capabilities=s,this.roomName=r,this.authToken=i,f(this,cs,U(this,Fc,Mu).call(this,e)),f(this,Oe,new sN(a(this,cs),{autoReconnect:!0,disconnectOnPingTimeout:(n=s.includes("PING"))!=null?n:!1,queueOnDisconnect:!0,flushOnReconnect:!1,logger:this.logger})),this.handleSocketConnectionEvents()}get joinAttempted(){return a(this,Ne,xe).socketJoinAttempted}set joinAttempted(t){a(this,Ne,xe).socketJoinAttempted=t}get telemetry(){return a(this,ut).getValue("telemetry")}get logger(){return a(this,ut).getValue("logger")}get peerId(){return a(this,ut).getValue("peerId")}updateURL(t){t!==this.peerId&&(f(this,cs,U(this,Fc,Mu).call(this,t)),this.logger.debug("SocketService:: Connection URL updated.")),a(this,Oe).updateURL(a(this,cs))}static getSocketEdgeDomain(t){return As({servicePrefix:"socket-edge",baseURI:t})}get url(){return a(this,cs)}connect(){return u(this,null,function*(){a(this,Ne,xe).socketJoinAttempted=!0,yield a(this,Oe).connect(),a(this,Ne,xe).socketJoinAttempted=!0,a(this,Ne,xe).socketState={state:"connected",reconnected:!1,reconnectionAttempt:void 0}})}disconnect(){a(this,Ne,xe).socketJoinAttempted=!1,a(this,Oe).disconnect(),a(this,Ne,xe).socketJoinAttempted=!0,a(this,Ne,xe).socketState={state:"disconnected",reconnected:!1,reconnectionAttempt:void 0}}get isConnected(){try{return a(this,Oe).readyState===1}catch{return!1}}sendMessage(t,e,r){const i={};return a(this,ut).getValue("telemetry").injectContext(i),a(this,Oe).send(t,r!=null?r:U(this,Bc,Au).call(this),e,new TextEncoder().encode(JSON.stringify(i)))}sendMessagePromise(t,e,r,i){const s=parseInt({}.SOCKET_SERVICE_MESSAGE_REQUEST_TIMEOUT,10)||2e4;return this.sendMessagePromiseWithTimeout({event:t,timeout:s,protobuf:e,messageId:r,resp:i})}sendMessagePromiseWithTimeout({event:t,timeout:e,protobuf:r,messageId:i,resp:s}){const n=s!=null?s:t;return new Promise((o,c)=>{const d=(T,E)=>{a(this,Oe).removeListener(n,T),a(this,Oe).removeListener(Xg,E),a(this,Oe).removeListener(cr.errorResponse,E),a(this,Oe).removeListener(br.errorResponse,E)},l=i!=null?i:U(this,Bc,Au).call(this),h={};a(this,ut).getValue("telemetry").injectContext(h);const p=({id:T,payload:E})=>{if(l===T){let C;try{const b=nC.fromBinary(E);C=new Error(b.errorMessage)}catch(b){C=new Error("failed to parse error message",{cause:b});try{const P=aP.fromBinary(E);C=new Error(P.message)}catch(P){C=new Error("failed to parse error message",{cause:P})}}c(C),d(v,p)}},v=({id:T,payload:E})=>{l===T&&(o({id:T,payload:E}),d(v,p))};a(this,Oe).on(n,v),a(this,Oe).on(Xg,p),a(this,Oe).on(cr.errorResponse,p),a(this,Oe).on(br.errorResponse,p),setTimeout(()=>{d(v,p),c(new Error(`request timeout for callback eventId:${t}`))},e),a(this,Oe).send(t,l,r,new TextEncoder().encode(JSON.stringify(h)))})}on(t,e){a(this,Oe).on(t,e)}onStateEvent(t,e){a(this,Oe).on(t,e)}removeListener(t,e){a(this,Oe).removeListener(t,e)}removeListeners(t){a(this,Oe).removeListeners(t)}flush(){return a(this,Oe).flush()}handleSocketConnectionEvents(){this.onStateEvent("connected",()=>u(this,null,function*(){this.logger.info("SocketService::Connected to socket-edge"),a(this,mr)&&(clearTimeout(a(this,mr)),f(this,mr,void 0)),a(this,Ne,xe).updateSocketConnectionState("connected")})),this.onStateEvent("disconnected",({code:t,reason:e})=>{var r;this.logger.info("SocketService::Disconnected from socket-edge",{error:{code:t,reason:e},country:k.location.country});const{recv:i,send:s}=(r=a(this,Ne,xe).mediaState)!=null?r:{};i!=null&&i.state&&(i==null?void 0:i.state)!==ta.CONNECTED||s!=null&&s.state&&(s==null?void 0:s.state)!==ta.CONNECTED?a(this,ut).getValue("peerSessionStore").emit(M.SOCKET_SERVICE_DISCONNECTED,{joinAttempted:a(this,Ne,xe).joinAttempted}):f(this,mr,setTimeout(()=>{a(this,ut).getValue("peerSessionStore").emit(M.SOCKET_SERVICE_DISCONNECTED,{joinAttempted:a(this,Ne,xe).joinAttempted}),f(this,mr,void 0)},oN)),a(this,Ne,xe).updateSocketConnectionState("disconnected")}),this.onStateEvent("reconnecting",()=>u(this,null,function*(){this.logger.info("SocketService::Reconnecting to socket-edge",{country:k.location.country}),a(this,Ne,xe).updateSocketConnectionState("reconnecting")})),this.onStateEvent("reconnectAttempt",t=>u(this,[t],function*({attempt:e}){this.logger.info("SocketService::Attempting to reconnect to socket-edge",{socket:{retryAttempt:e}}),a(this,Ne,xe).updateSocketConnectionState("reconnectAttempt",e)})),this.onStateEvent("reconnectFailure",({attempt:t})=>{this.logger.info("SocketService::Reconnect attempt to socket-edge failed",{socket:{retryAttempt:t}}),a(this,Ne,xe).updateSocketConnectionState("reconnectFailure",t)}),this.onStateEvent("reconnected",()=>u(this,null,function*(){this.logger.info("SocketService::Reconnected to socket-edge",{connectionState:{joinAttempted:a(this,Ne,xe).mediaJoinAttempted}}),a(this,mr)&&(clearTimeout(a(this,mr)),f(this,mr,void 0)),a(this,ut).getValue("peerSessionStore").emit(M.SOCKET_SERVICE_RECONNECTED,{wasJoinAttempted:a(this,Ne,xe).mediaJoinAttempted}),a(this,Ne,xe).updateSocketConnectionState("reconnected")})),this.onStateEvent("failed",()=>u(this,null,function*(){this.logger.info("SocketService::Failed to connect to socket-edge",{country:k.location.country}),a(this,ut).getValue("peerSessionStore").emit(M.SOCKET_SERVICE_FAILED),a(this,Ne,xe).updateSocketConnectionState("failed")}))}},cs=new WeakMap,Oe=new WeakMap,Ne=new WeakSet,xe=function(){return a(this,ut).getValue("connectionHandler")},mr=new WeakMap,ut=new WeakMap,Fc=new WeakSet,Mu=function(t){let e=Yy.getSocketEdgeDomain(a(this,ut).getValue("baseURI"));typeof Zn(a(this,ut),"socket_server_base")=="string"&&(e=Zn(a(this,ut),"socket_server_base"));const r=`wss://${e}`,i=new URL(`${r}/ws`),s=this.peerId,n=G(V({roomID:this.roomName,peerID:t,authToken:this.authToken,useMediaV2:!0},s!==t&&{oldPeerID:s}),{ping:this.capabilities.includes("PING"),capabilities:this.capabilities.map(o=>Yd[o]).join(" "),joinWithDetails:!0,useCfWorker:!0,useStartSession:!0});return Object.entries(n).forEach(([o,c])=>{i.searchParams.append(o,c.toString())}),i.href},Bc=new WeakSet,Au=function(){return`${this.peerId}-${(Math.random()+1).toString(36).substring(7)}`},Zg);let oc=Yy;Ol([k.trace("SocketService.connect")],oc.prototype,"connect",1);Ol([k.trace("SocketService.disconnect")],oc.prototype,"disconnect",1);Ol([k.trace("SocketService.sendMessagePromise")],oc.prototype,"sendMessagePromise",1);Ol([k.trace("SocketService.sendMessagePromiseWithTimeout")],oc.prototype,"sendMessagePromiseWithTimeout",1);class cN{constructor(e){m(this,"socketService"),this.socketService=e}handleConnectedRoomsDumpRaw({payload:e}){var r;const i=OP.fromBinary(e),s=i.meetings.map(n=>{var o;return{id:n.id,title:n.title,participants:(o=n.participants)!=null?o:[]}});return{parentMeeting:{id:i.parentMeeting.id,title:i.parentMeeting.title,participants:(r=i.parentMeeting.participants)!=null?r:[]},meetings:s}}handleTransferPeerRaw({payload:e}){const r=nR.fromBinary(e);return{authToken:r.authToken,meetingId:r.meetingId}}handleMovedPeerRaw({payload:e}){const r=Gv.fromBinary(e);return{meetingId:r.meetingId,customParticipantId:r.customParticipantId}}handleConnectedRoomsUpdatedRaw({payload:e}){return Fm.fromBinary(e).payloads.map(r=>({id:r.id,title:r.title}))}handleConnectedRoomsDeletedRaw({payload:e}){return zP.fromBinary(e).payloads}getConnectedRoomsDump(){return u(this,null,function*(){const e=yield this.socketService.sendMessagePromise(F.getConnectedRoomsDump);return this.handleConnectedRoomsDumpRaw(e)})}createConnectedRooms(e){return u(this,null,function*(){const{payload:r}=yield this.socketService.sendMessagePromise(F.createConnectedRooms,xP.toBinary({payloads:e}));return Fm.fromBinary(r).payloads.map(i=>({id:i.id,title:i.title}))})}updateConnectedRooms(e){return u(this,null,function*(){})}disableConnectedRooms(e){return u(this,null,function*(){const r=e.map(s=>({id:s})),i=yield this.socketService.sendMessagePromise(F.deleteConnectedRooms,JP.toBinary({payloads:r}));return this.handleConnectedRoomsDeletedRaw(i)})}movePeersBetweenRooms(e){return u(this,null,function*(){try{const r=yield this.socketService.sendMessagePromise(F.movePeers,tR.toBinary({sourceMeetingId:e.sourceMeetingId,destinationMeetingId:e.destinationMeetingId,participants:e.participants}));return new TextDecoder().decode(r.payload).includes("error")?{success:!1,error:"failed to move participants"}:{success:!0}}catch(r){return{success:!1,error:r}}})}}var dN=Object.defineProperty,lN=Object.getOwnPropertyDescriptor,uN=(t,e,r,i)=>{for(var s=i>1?void 0:i?lN(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&dN(e,r,s),s},Lr;class Qy extends Xt{constructor(e){const r=e.getValue("logger");super(r),m(this,"meetings",[]),m(this,"parentMeeting",null),g(this,Lr,void 0),f(this,Lr,e)}get supportsConnectedMeetings(){return a(this,Lr).getValue("self").id!==""}get isActive(){return this.meetings.length!==0}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 a(this,Lr).getValue("connectedMeetingsSocketHandler").getConnectedRoomsDump()})}createMeetings(e){return u(this,null,function*(){return this.validateConnectedMeetingsAction(),(yield a(this,Lr).getValue("connectedMeetingsSocketHandler").createConnectedRooms(e)).map(r=>({id:r.id,title:r.title}))})}updateMeetings(e){return u(this,null,function*(){this.validateConnectedMeetingsAction(),yield a(this,Lr).getValue("connectedMeetingsSocketHandler").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(s=>s.id)):Promise.resolve());return yield Promise.all(r),yield a(this,Lr).getValue("connectedMeetingsSocketHandler").disableConnectedRooms(e)})}moveParticipants(e,r,i){return u(this,null,function*(){this.validateConnectedMeetingsAction();const s=yield a(this,Lr).getValue("connectedMeetingsSocketHandler").movePeersBetweenRooms({sourceMeetingId:e,destinationMeetingId:r,participants:i.map(n=>({id:n}))});return s.success&&this.moveSuccessHandler(e,r,i),s})}moveParticipantsWithCustomPreset(e,r,i){return u(this,null,function*(){this.validateConnectedMeetingsAction();const s=yield a(this,Lr).getValue("connectedMeetingsSocketHandler").movePeersBetweenRooms({sourceMeetingId:e,destinationMeetingId:r,participants:i});return s.success&&this.moveSuccessHandler(e,r,i.map(n=>n.id)),s})}moveSuccessHandler(e,r,i){const s=new Map;[...this.parentMeeting.participants,...this.meetings.flatMap(n=>n.participants)].forEach(n=>s.set(n.id,n)),r===this.parentMeeting.id&&(this.parentMeeting.participants=this.parentMeeting.participants.concat(i.map(n=>s.get(n)))),e===this.parentMeeting.id&&(this.parentMeeting.participants=this.parentMeeting.participants.filter(n=>!i.includes(n.id))),this.meetings=this.meetings.map(n=>{if(r===n.id){const o=n.participants.concat(i.map(c=>s.get(c)));return G(V({},n),{participants:o})}if(e===n.id){const o=n.participants.filter(c=>!i.includes(c.id));return G(V({},n),{participants:o})}return n})}}Lr=new WeakMap;uN([Bt({maxInvocations:60,period:60})],Qy.prototype,"getConnectedMeetings",1);var hN=Object.defineProperty,pN=Object.getOwnPropertyDescriptor,Rp=(t,e,r,i)=>{for(var s=i>1?void 0:i?pN(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&hN(e,r,s),s},Ee,ef;const Xy=(ef=class{constructor(t){m(this,"connectedMeetings"),g(this,Ee,void 0),f(this,Ee,t),this.connectedMeetings=new Qy(t)}get telemetry(){return a(this,Ee).getValue("telemetry")}get logger(){return a(this,Ee).getValue("logger")}static init(t){const e=new Xy(t);return e.connectedMeetings.supportsConnectedMeetings&&(e.setupEvents(),t.getValue("self").once("roomJoined",()=>e.getConnectedMeetings())),e}getConnectedMeetings(){this.connectedMeetings.getConnectedMeetings()}setupEvents(){a(this,Ee).getValue("connectedMeetingsSocketHandler").socketService.on(F.getConnectedRoomsDump,this.handleConnectedRoomsDump.bind(this)),a(this,Ee).getValue("connectedMeetingsSocketHandler").socketService.on(F.transferPeer,this.handleTransferPeer.bind(this)),a(this,Ee).getValue("connectedMeetingsSocketHandler").socketService.on(F.movedPeer,this.handleMovedPeer.bind(this)),a(this,Ee).getValue("connectedMeetingsSocketHandler").socketService.on(F.connectedRoomsUpdated,this.handleConnectedRoomsUpdated.bind(this)),a(this,Ee).getValue("connectedMeetingsSocketHandler").socketService.on(F.connectedRoomsDeleted,this.handleConnectedRoomsDeleted.bind(this))}handleTransferPeer(t){const e=a(this,Ee).getValue("connectedMeetingsSocketHandler").handleTransferPeerRaw(t);return this.switchMeeting(e)}switchMeeting(t){return u(this,arguments,function*({authToken:e,meetingId:r}){var i,s,n,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.`);this.logger.info("ConnectedMeetingsController::switchMeeting:: asking ui-kit to show switching breakout UI"),this.connectedMeetings.emit("changingMeeting",r);const c={video:a(this,Ee).getValue("self").videoEnabled,audio:a(this,Ee).getValue("self").audioEnabled};try{a(this,Ee).getValue("self").cleanupEvents(),yield a(this,Ee).getValue("meeting").leave("connected-meeting")}catch(l){this.logger.error(`ConnectedMeetingsController:: switchMeeting:: issues in leaving previous meeting. Meeting Id: ${(s=(i=a(this,Ee).getValue("meeting"))==null?void 0:i.meta)==null?void 0:s.meetingId}`,{error:l})}this.logger.info(`ConnectedMeetingsController::switchMeeting:: initializing new meeting. Meeting Id: ${r}`);const d=yield eS.init(G(V({},a(this,Ee).getValue("options")),{cachedUserDetails:null,defaults:G(V(V({},a(this,Ee).getValue("options").defaults),c),{mediaHandler:a(this,Ee).getValue("self")}),authToken:e}));this.logger.info(`ConnectedMeetingsController::switchMeeting:: initialized new meeting. Meeting Id: ${(n=d==null?void 0:d.meta)==null?void 0:n.meetingId}`);try{const{hidden:l}=a(this,Ee).getValue("self");d.self.setName(a(this,Ee).getValue("self").name),yield d.join(),l&&d.self.hide()}catch(l){this.logger.error("ConnectedMeetingsController.joinRoom",{error:l})}return this.logger.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),d})}handleConnectedRoomsDump(t){const e=a(this,Ee).getValue("connectedMeetingsSocketHandler").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 a(this,Ee).getValue("connectedMeetingsSocketHandler").handleMovedPeerRaw(t)}handleConnectedRoomsUpdated(t){const e=a(this,Ee).getValue("connectedMeetingsSocketHandler").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(V({},i),{participants:[]}))}),this.connectedMeetings.meetings=Array.from(r.values()),this.emitStateUpdate()}handleConnectedRoomsDeleted(t){const e=a(this,Ee).getValue("connectedMeetingsSocketHandler").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})}},Ee=new WeakMap,ef);let Nl=Xy;Rp([k.trace("ConnectedMeetingsController.getConnectedMeetings")],Nl.prototype,"getConnectedMeetings",1);Rp([k.trace("ConnectedMeetingsController.setupEvents")],Nl.prototype,"setupEvents",1);Rp([k.trace("ConnectedMeetingsController.switchMeeting")],Nl.prototype,"switchMeeting",1);var mN=Object.defineProperty,gN=Object.getOwnPropertyDescriptor,Vl=(t,e,r,i)=>{for(var s=i>1?void 0:i?gN(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&mN(e,r,s),s};const xn=class{constructor(t,e,r){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"),m(this,"connectedMeetingsController"),m(this,"telemetry"),m(this,"logger"),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,this.connectedMeetingsController=e.connectedMeetingsController,this.telemetry=r.getValue("telemetry"),this.logger=r.getValue("logger")}static init(t){return u(this,null,function*(){var e,r;const{peerId:i,apiBase:s,authToken:n,meetingId:o,organizationId:c,cachedUserDetails:d,logger:l}=t.getAllValues();if(Ny(t),Ie.isSupported()===!1)throw new I("Browser not supported","0010",l,!0);const h=vD(t,{authToken:n,baseURL:s,cachedUserDetails:d});h.setRoomName(o),h.setRoomUUID(o),h.setOrganizationId(c),h.setHeader("dyte-tracing-id",i),t.setValue("apiClient",h);const p=new ZD(t);t.setValue("connectionHandler",p);const v=xn.createSocketService(t),T=v.connect(),E=h.getUserDetails(),C=h.getPlugins();let b=De.HIVE,P,j="";try{yield xn.setupFlagsmith(t)}catch(ae){l.error("Failed to setup flagsmith",{error:ae})}try{yield T}catch(ae){l.error("[Controller]: Failed to connect to socket server:",{error:ae})}try{({sfu:b,meetingTitle:j}=yield h.getRoomNodeData()),P=yield E,l.info(`SFU ${b} is being used.`),t.setValue("presetName",P.preset.name),t.setValue("roomNodeOptions",{sfu:b})}catch(ae){l.error("Failed to get room metadata",{error:ae})}const W=xO.init(P.preset,!t.getValue("modules").theme),w=s1.init(t,W.viewType,P.preset.permissions),te=xn.setupControllers(v,t,P,C,j,W,w);jD(W)&&((e=xn.createRoomNodeClient(t,v).initializeConnection(P.participant.name,o,!1,w))==null||e.catch(ae=>{l.error("[Controller]: Failed to queue partial media room promise:",{error:ae})})),k.location.country=(r=h.ipInfo)==null?void 0:r.country;const{controllers:re}=yield te;return F0(),new xn(s,re,t)})}static setupFlagsmith(t){return u(this,null,function*(){var e;const{peerId:r,baseURI:i,overrides:s,meetingId:n,organizationId:o,logger:c}=t.getAllValues(),d=U0(n),l=G(V({entity:ju.PEER,clientId:o,isAnonUser:!o,sdkVersion:t.getValue("sdkVersion"),presetName:t.getValue("presetName"),meetingHash:d,roomName:n},Ie.getDeviceInfo()),{isReactNative:navigator.isReactNative});try{const h=(e=s==null?void 0:s.whitelabelled_flags_endpoint)==null||e?As({servicePrefix:"flags",baseURI:i}):"edge.api.flagsmith.com";yield t.getValue("flagsmith").identify(`${ju.PEER}_${r}`,JSON.parse(JSON.stringify(l)),!1,5e3,h,c),c.info("flagsmith::allFlags",{flags:JSON.stringify(t.getValue("flagsmith").getAllFlags())},!0)}catch{c.error("Failed to fetch flagsmith flags")}})}static setupControllers(t,e,r,i,s,n,o){return u(this,null,function*(){var c,d,l;const h=e.getValue("modules"),{participant:p}=r,v=e.getValue("defaults"),T=e.getValue("logger"),{sfu:E}=e.getValue("roomNodeOptions"),{viewType:C,mediaConstraints:{audio:b}}=n;e.setValue("viewType",C),e.setValue("defaults",V({mediaConfiguration:{audio:{enableHighBitrate:(c=b.enableHighBitrate)!=null?c:!1,enableStereo:(d=b.enableStereo)!=null?d:!1}}},v)),e.setValue("maxPreferredStreams",Ie.isMobile()?n.maxVideoStreams.mobile:n.maxVideoStreams.desktop);let P,j,W,w,te,re,ae,Me,Xe;const jt=new N1(e,t),A=new cN(t);e.setValue("connectedMeetingsSocketHandler",A);const S=new Al(e,t),_=new dr(e,t),B=new B1(t),oe=new Ly(e,t),He=new W1(e,t),x=new O1(t),R=new Vs(e,t),ce=yield Yi.init(e,oe,p,o,n);e.setValue("selfController",ce);const Qi=yield iy.init(e,ce.self,oe,jt,s);if(h.participant&&(Me=new mi(e,ce.self,oe,E)),(l=h.e2ee)!=null&&l.enabled&&h.e2ee.manager.init(T,e.getValue("peerSessionStore")),h.chat&&(j=yield oi.init(e,_,R,ce.self,Me.participants)),h.internals&&(te=yield vp.init(e)),h.livestream&&n.viewType===Ft.Livestream&&e.getValue("flagsmith").hasFeature(X.LIVESTREAM)&&(ae=new hy(e,ce.self,x)),n.viewType!==Ft.Chat){if(h.poll&&(P=yield Zv.init(e,ce.self,S)),h.recording&&(re=new oy(e,ce.self,oe)),h.stage&&(W=new sy(e,B,oe,ce.self,Me.participants)),h.plugin){if(!Me)throw new I("The plugin module cannot be initialized without the `participant` module","0102");const Gr=yield i;w=yield ic.init(e,Gr,He,_,j==null?void 0:j.chat,ce.self,Me.participants,s)}if(h.connectedMeetings&&(Xe=yield Nl.init(e)),h.pip){const Gr=yield j0._init(e,ce.self);e.setValue("pip",Gr)}}const Xi={storesManager:new GO(e,He),pollController:P,selfController:ce,metaController:Qi,chatController:j,stageController:W,pluginController:w,recordingController:re,internalsController:te,livestreamController:ae,participantController:Me,connectedMeetingsController:Xe};return{theme:n,permissions:o,controllers:Xi}})}static createRoomNodeClient(t,e){const{peerId:r,roomNodeOptions:i}=t.getAllValues(),{sfu:s}=i;return Oy(t,s,{socket:e,peerId:r})}static createSocketService(t){const{peerId:e,meetingId:r,authToken:i}=t.getAllValues(),s=["PING"];return new oc(t,{peerId:e,meetingId:r,authToken:i,capabilities:s})}};let cc=xn;Vl([k.trace("Controller.init")],cc,"init",1);Vl([k.trace("setupFlagsmith")],cc,"setupFlagsmith",1);Vl([k.trace("Controller.createRoomNodeClient")],cc,"createRoomNodeClient",1);Vl([k.trace("Controller.createSocketService")],cc,"createSocketService",1);class fN{constructor(){m(this,"battery"),m(this,"logger"),m(this,"init",e=>u(this,null,function*(){this.logger=e;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(r){e.error("Error getting battery",r)}})),m(this,"updateChargeInfo",()=>{var e;this.logger.log(`Battery charging? ${(e=this.battery)!=null&&e.charging?"Yes":"No"}`)}),m(this,"updateLevelInfo",()=>{if(!this.battery){this.logger.log("Battery level: Not known");return}this.logger.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 tf=new fN;function vN(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:s}=JSON.parse(atob(t.split(".")[1]));if(!r)throw Error(`Received V1 auth token ${t}`);let n="dyte.io";e&&(n=e);const o=`https://${As({servicePrefix:"api",baseURI:n})}`;return{meetingId:r,orgId:i,participantId:s,baseURI:n,apiBase:o}}catch{throw new I("Invalid auth token","0004")}}var bs,Un,Fn,pl,$h,Zy;class yN{constructor(){g(this,$h),g(this,bs,new Audio),g(this,Un,new MediaStream),g(this,Fn,new Map),g(this,pl,void 0),a(this,bs).srcObject=a(this,Un),a(this,bs).autoplay=!0}playTracks(e){return u(this,null,function*(){return e.forEach(r=>{a(this,Fn).has(r.id)||(a(this,Un).addTrack(r),a(this,Fn).set(r.id,r))}),this.play()})}setSpeakerDevice(e){typeof HTMLAudioElement.prototype.setSinkId=="function"&&a(this,bs).setSinkId(e)}removeTrack(e){const r=a(this,Fn).get(e);r&&(a(this,Un).removeTrack(r),a(this,Fn).delete(e))}play(){return u(this,null,function*(){return a(this,bs).srcObject=a(this,Un),a(this,bs).play().catch(e=>{U(this,$h,Zy).call(this,e)})})}onError(e){f(this,pl,e)}}bs=new WeakMap,Un=new WeakMap,Fn=new WeakMap,pl=new WeakMap,$h=new WeakSet,Zy=function(t){var e;(e=a(this,pl))==null||e.call(this,t)};var Bn;class SN extends yN{constructor(){super(),g(this,Bn,void 0),f(this,Bn,new Map)}addParticipantTrack(e,r){a(this,Bn).set(e,r.id),this.playTracks([r])}removeParticipantTrack(e){const r=a(this,Bn).get(e);r&&this.removeTrack(r),a(this,Bn).delete(e)}}Bn=new WeakMap;var TN=Object.defineProperty,kN=Object.getOwnPropertyDescriptor,Ll=(t,e,r,i)=>{for(var s=i>1?void 0:i?kN(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(s=(i?o(e,r,s):o(s))||s);return i&&s&&TN(e,r,s),s},et,vn,rf;let Ki=(rf=class{constructor(t,e){g(this,et,void 0),g(this,vn,void 0),f(this,vn,t),f(this,et,e)}get peerId(){return a(this,vn).getValue("peerId")}static initMedia(t={},e=!1,r=void 0){var i;const s=(i=r==null?void 0:r.peerId)!=null?i:Os(),n=ai.createContext(s,{peerId:s}),o=n.getValue("logger");o.init(n);const c=new fy(o);return c.init(t,e,n),n.setValue("defaults",{mediaHandler:c}),c}static init(t){return u(this,null,function*(){var e,r,i,s,n,o,c;Ie.init();const{mediaHandler:d}=(e=t.defaults)!=null?e:{},l=(d==null?void 0:d.peerId)||((i=(r=t==null?void 0:t.cachedUserDetails)==null?void 0:r.peerId)!=null?i:Os()),{authToken:h,baseURI:p}=t,v=vN(h,p),{meetingId:T}=v,E=fl(v,["meetingId"]);window.__zone_symbol__DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION=!0;const C=Ki.setupContext(l,t,T,E),b=C.getValue("telemetry"),P=C.getValue("logger");hT(P),tf.init(P),b.init(C,{roomName:T,userId:E.participantId,organizationId:E.orgId,peerId:l},(n=(s=t.modules)==null?void 0:s.tracing)!=null?n:!0),P.init(C),P.info("DyteClient::init::options",{dyteClientInitOptions:G(V({},t),{authToken:`${(o=t.authToken)==null?void 0:o.slice(0,10)}...
23
- ${(c=t.authToken)==null?void 0:c.slice(-10)}`})});const j=yield cc.init(C),W=new Ki(C,j);return C.setValue("meeting",W),W})}static setupContext(t,e,r,i){var s,n;const o=ai.createContext(t,e),c=V(V({},M0),e==null?void 0:e.modules),d=e.defaults||{audio:!0,video:!0};return o.setValue("options",e),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",(s=e.overrides)!=null?s:{}),o.setValue("env",A0({baseURI:i.baseURI})),o.setValue("defaults",d),o.setValue("onError",e.onError||(()=>{})),o.setValue("cachedUserDetails",_r(e.cachedUserDetails)),o.setValue("sdkVersion","3.2.0-staging.3"),(n=e.modules)!=null&&n.experimentalAudioPlayback&&o.setValue("audioPlayback",new SN),o}join(){return u(this,null,function*(){const{selfController:t}=a(this,et);return t.self.roomJoined?null:t.joinRoom()})}leave(t){return u(this,null,function*(){tf.cleanup(),a(this,vn).getValue("peerSessionStore").reset();const{selfController:e}=a(this,et);return e.leaveRoom(t)})}get participants(){var t;return(t=a(this,et).participantController)==null?void 0:t.participants}get self(){var t;return(t=a(this,et).selfController)==null?void 0:t.self}get meta(){var t;return(t=a(this,et).metaController)==null?void 0:t.meta}get ai(){var t;return(t=a(this,et).metaController)==null?void 0:t.ai}get plugins(){var t;return(t=a(this,et).pluginController)==null?void 0:t.plugins}get chat(){var t;return(t=a(this,et).chatController)==null?void 0:t.chat}get polls(){var t;return(t=a(this,et).pollController)==null?void 0:t.polls}get connectedMeetings(){var t;return(t=a(this,et).connectedMeetingsController)==null?void 0:t.connectedMeetings}get recording(){var t;return(t=a(this,et).recordingController)==null?void 0:t.recording}get livestream(){var t;return(t=a(this,et).livestreamController)==null?void 0:t.livestream}get stage(){var t;return(t=a(this,et).stageController)==null?void 0:t.stage}get stores(){return a(this,et).storesManager}get audio(){return a(this,vn).getValue("audioPlayback")}get __internals__(){var t;return(t=a(this,et).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)})}},et=new WeakMap,vn=new WeakMap,rf);Ll([ft("0002"),pi.executeWithLock({methodName:"meeting.join",lockName:"DyteClient.join",timeout:3e3})],Ki.prototype,"join",1);Ll([ft("0003")],Ki.prototype,"leave",1);Ll([ft("0001"),pi.executeWithLock({methodName:"DyteClient.init",lockName:"DyteClient.init",timeout:3e3})],Ki,"init",1);Ki=Ll([ft("0000")],Ki);const eS=Ki;class EN{constructor(e){dc(this,"meeting");dc(this,"l");dc(this,"onUpdate",()=>{this.l.forEach(e=>{e()})});var r,i,s,n,o,c,d,l,h,p,v,T,E,C,b,P;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),(s=this.meeting.participants)==null||s.addListener("*",this.onUpdate),(o=(n=this.meeting.participants)==null?void 0:n.joined)==null||o.addListener("*",this.onUpdate),(d=(c=this.meeting.participants)==null?void 0:c.active)==null||d.addListener("*",this.onUpdate),(h=(l=this.meeting.participants)==null?void 0:l.waitlisted)==null||h.addListener("*",this.onUpdate),(p=this.meeting.stage)==null||p.addListener("*",this.onUpdate),(v=this.meeting.livestream)==null||v.addListener("*",this.onUpdate),(T=this.meeting.chat)==null||T.addListener("*",this.onUpdate),(E=this.meeting.plugins)==null||E.all.addListener("*",this.onUpdate),(C=this.meeting.recording)==null||C.addListener("*",this.onUpdate),(b=this.meeting.connectedMeetings)==null||b.addListener("*",this.onUpdate),(P=this.meeting.polls)==null||P.addListener("*",this.onUpdate)}clean(){var e,r,i,s,n,o,c,d,l,h,p,v,T,E,C,b;(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),(n=(s=this.meeting.participants)==null?void 0:s.joined)==null||n.removeListener("*",this.onUpdate),(c=(o=this.meeting.participants)==null?void 0:o.active)==null||c.removeListener("*",this.onUpdate),(l=(d=this.meeting.participants)==null?void 0:d.waitlisted)==null||l.removeListener("*",this.onUpdate),(h=this.meeting.stage)==null||h.removeListener("*",this.onUpdate),(p=this.meeting.livestream)==null||p.removeListener("*",this.onUpdate),(v=this.meeting.chat)==null||v.removeListener("*",this.onUpdate),(T=this.meeting.plugins)==null||T.all.removeListener("*",this.onUpdate),(E=this.meeting.recording)==null||E.removeListener("*",this.onUpdate),(C=this.meeting.connectedMeetings)==null||C.removeListener("*",this.onUpdate),(b=this.meeting.polls)==null||b.removeListener("*",this.onUpdate)}addListener(e){this.l.add(e)}removeListener(e){this.l.delete(e)}}const xl=Pt.createContext({meeting:void 0,updates:void 0});function bN({value:t,children:e,fallback:r}){const[i,s]=Pt.useState(),n=Pt.useRef();return Pt.useEffect(()=>(t&&s(new EN(t)),()=>{var o;(o=n.current)==null||o.clean()}),[t]),sS.default.createElement(xl.Provider,{value:{meeting:t,updates:i}},t?e:r)}const wN=()=>{const{meeting:t}=Pt.useContext(xl);if(!t)throw new Error("useDyteMeeting must be used within the DyteProvider");return{meeting:t}},_N=t=>{const e=Pt.useRef(!1),[r,i]=Pt.useState(),s=t==null?void 0:t.resetOnLeave,n=Pt.useCallback(async o=>{if(!e.current)return e.current=!0,eS.init(o).then(c=>(i(c),c)).finally(()=>{e.current=!1})},[]);return Pt.useEffect(()=>{if(!r||!s)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]),Pt.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,n]},IN=(t,e)=>!!(t!==e||Array.isArray(t)&&Array.isArray(e)&&t.length!==e.length),CN=t=>{const{meeting:e,updates:r}=Pt.useContext(xl);if(!e)throw new Error("useDyteSelector must be used within the DyteProvider");const i=Pt.useRef(t(e)),[,s]=Pt.useReducer(n=>n+1,0);return Pt.useEffect(()=>{const n=e&&t(e),o=()=>{const c=e&&t(e);IN(i.current,c)&&(i.current=c,s())};return n&&typeof n=="object"&&"addListener"in n?(n.addListener("*",s),()=>{n.removeListener("*",s)}):(r==null||r.addListener(o),()=>{r==null||r.removeListener(o)})},[e,r]),i.current};exports.RealtimeKitContext=xl;exports.RealtimeKitProvider=bN;exports.useRealtimeKitClient=_N;exports.useRealtimeKitMeeting=wN;exports.useRealtimeKitSelector=CN;
23
+ ${(c=t.authToken)==null?void 0:c.slice(-10)}`})});const j=yield cc.init(C),W=new Ki(C,j);return C.setValue("meeting",W),W})}static setupContext(t,e,r,i){var s,n;const o=ai.createContext(t,e),c=V(V({},M0),e==null?void 0:e.modules),d=e.defaults||{audio:!0,video:!0};return o.setValue("options",e),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",(s=e.overrides)!=null?s:{}),o.setValue("env",A0({baseURI:i.baseURI})),o.setValue("defaults",d),o.setValue("onError",e.onError||(()=>{})),o.setValue("cachedUserDetails",_r(e.cachedUserDetails)),o.setValue("sdkVersion","3.2.0-staging.4"),(n=e.modules)!=null&&n.experimentalAudioPlayback&&o.setValue("audioPlayback",new SN),o}join(){return u(this,null,function*(){const{selfController:t}=a(this,et);return t.self.roomJoined?null:t.joinRoom()})}leave(t){return u(this,null,function*(){tf.cleanup(),a(this,vn).getValue("peerSessionStore").reset();const{selfController:e}=a(this,et);return e.leaveRoom(t)})}get participants(){var t;return(t=a(this,et).participantController)==null?void 0:t.participants}get self(){var t;return(t=a(this,et).selfController)==null?void 0:t.self}get meta(){var t;return(t=a(this,et).metaController)==null?void 0:t.meta}get ai(){var t;return(t=a(this,et).metaController)==null?void 0:t.ai}get plugins(){var t;return(t=a(this,et).pluginController)==null?void 0:t.plugins}get chat(){var t;return(t=a(this,et).chatController)==null?void 0:t.chat}get polls(){var t;return(t=a(this,et).pollController)==null?void 0:t.polls}get connectedMeetings(){var t;return(t=a(this,et).connectedMeetingsController)==null?void 0:t.connectedMeetings}get recording(){var t;return(t=a(this,et).recordingController)==null?void 0:t.recording}get livestream(){var t;return(t=a(this,et).livestreamController)==null?void 0:t.livestream}get stage(){var t;return(t=a(this,et).stageController)==null?void 0:t.stage}get stores(){return a(this,et).storesManager}get audio(){return a(this,vn).getValue("audioPlayback")}get __internals__(){var t;return(t=a(this,et).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)})}},et=new WeakMap,vn=new WeakMap,rf);Ll([ft("0002"),pi.executeWithLock({methodName:"meeting.join",lockName:"DyteClient.join",timeout:3e3})],Ki.prototype,"join",1);Ll([ft("0003")],Ki.prototype,"leave",1);Ll([ft("0001"),pi.executeWithLock({methodName:"DyteClient.init",lockName:"DyteClient.init",timeout:3e3})],Ki,"init",1);Ki=Ll([ft("0000")],Ki);const eS=Ki;class EN{constructor(e){dc(this,"meeting");dc(this,"l");dc(this,"onUpdate",()=>{this.l.forEach(e=>{e()})});var r,i,s,n,o,c,d,l,h,p,v,T,E,C,b,P;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),(s=this.meeting.participants)==null||s.addListener("*",this.onUpdate),(o=(n=this.meeting.participants)==null?void 0:n.joined)==null||o.addListener("*",this.onUpdate),(d=(c=this.meeting.participants)==null?void 0:c.active)==null||d.addListener("*",this.onUpdate),(h=(l=this.meeting.participants)==null?void 0:l.waitlisted)==null||h.addListener("*",this.onUpdate),(p=this.meeting.stage)==null||p.addListener("*",this.onUpdate),(v=this.meeting.livestream)==null||v.addListener("*",this.onUpdate),(T=this.meeting.chat)==null||T.addListener("*",this.onUpdate),(E=this.meeting.plugins)==null||E.all.addListener("*",this.onUpdate),(C=this.meeting.recording)==null||C.addListener("*",this.onUpdate),(b=this.meeting.connectedMeetings)==null||b.addListener("*",this.onUpdate),(P=this.meeting.polls)==null||P.addListener("*",this.onUpdate)}clean(){var e,r,i,s,n,o,c,d,l,h,p,v,T,E,C,b;(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),(n=(s=this.meeting.participants)==null?void 0:s.joined)==null||n.removeListener("*",this.onUpdate),(c=(o=this.meeting.participants)==null?void 0:o.active)==null||c.removeListener("*",this.onUpdate),(l=(d=this.meeting.participants)==null?void 0:d.waitlisted)==null||l.removeListener("*",this.onUpdate),(h=this.meeting.stage)==null||h.removeListener("*",this.onUpdate),(p=this.meeting.livestream)==null||p.removeListener("*",this.onUpdate),(v=this.meeting.chat)==null||v.removeListener("*",this.onUpdate),(T=this.meeting.plugins)==null||T.all.removeListener("*",this.onUpdate),(E=this.meeting.recording)==null||E.removeListener("*",this.onUpdate),(C=this.meeting.connectedMeetings)==null||C.removeListener("*",this.onUpdate),(b=this.meeting.polls)==null||b.removeListener("*",this.onUpdate)}addListener(e){this.l.add(e)}removeListener(e){this.l.delete(e)}}const xl=Pt.createContext({meeting:void 0,updates:void 0});function bN({value:t,children:e,fallback:r}){const[i,s]=Pt.useState(),n=Pt.useRef();return Pt.useEffect(()=>(t&&s(new EN(t)),()=>{var o;(o=n.current)==null||o.clean()}),[t]),sS.default.createElement(xl.Provider,{value:{meeting:t,updates:i}},t?e:r)}const wN=()=>{const{meeting:t}=Pt.useContext(xl);if(!t)throw new Error("useDyteMeeting must be used within the DyteProvider");return{meeting:t}},_N=t=>{const e=Pt.useRef(!1),[r,i]=Pt.useState(),s=t==null?void 0:t.resetOnLeave,n=Pt.useCallback(async o=>{if(!e.current)return e.current=!0,eS.init(o).then(c=>(i(c),c)).finally(()=>{e.current=!1})},[]);return Pt.useEffect(()=>{if(!r||!s)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]),Pt.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,n]},IN=(t,e)=>!!(t!==e||Array.isArray(t)&&Array.isArray(e)&&t.length!==e.length),CN=t=>{const{meeting:e,updates:r}=Pt.useContext(xl);if(!e)throw new Error("useDyteSelector must be used within the DyteProvider");const i=Pt.useRef(t(e)),[,s]=Pt.useReducer(n=>n+1,0);return Pt.useEffect(()=>{const n=e&&t(e),o=()=>{const c=e&&t(e);IN(i.current,c)&&(i.current=c,s())};return n&&typeof n=="object"&&"addListener"in n?(n.addListener("*",s),()=>{n.removeListener("*",s)}):(r==null||r.addListener(o),()=>{r==null||r.removeListener(o)})},[e,r]),i.current};exports.RealtimeKitContext=xl;exports.RealtimeKitProvider=bN;exports.useRealtimeKitClient=_N;exports.useRealtimeKitMeeting=wN;exports.useRealtimeKitSelector=CN;