function anonymous(module,exports,require ) { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},t=e.parcelRequirec887_kd6oi;t.register("hszax",function(n,s){function r(e,t,n,s){Object.defineProperty(e,t,{get:n,set:s,enumerable:!0,configurable:!0})}var i=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==e?e:{}).parcelRequire94c2_uo2xw,a=i.register;a("8mF5Z",function(e,t){r(e.exports,"RistrettoPlayerWrapper",function(){return h});var n=i("bsvQL"),s=i("hJ7nZ"),a=i("4gxuw"),o=i("giOKx");let l={framesDecoded:{originalPath:"inbound-rtp:video.framesDecoded",modifier:"raw",reducer:"sum",filter:"number"},nackCount:{originalPath:"inbound-rtp:video.nackCount",modifier:"raw",reducer:"sum",filter:"number"},totalFreezesDuration:{originalPath:"inbound-rtp:video.totalFreezesDuration",modifier:"raw",reducer:"sum",filter:"number"},totalPausesDuration:{originalPath:"inbound-rtp:video.totalPausesDuration",modifier:"raw",reducer:"sum",filter:"number"},fecPacketsReceived:{originalPath:"inbound-rtp.fecPacketsReceived",modifier:"raw",reducer:"sum",filter:"number"},fecPacketsDiscarded:{originalPath:"inbound-rtp.fecPacketsDiscarded",modifier:"raw",reducer:"sum",filter:"number"},framesReceived:{originalPath:"inbound-rtp:video.framesReceived",modifier:"raw",reducer:"sum",filter:"number"},packetsLost:{originalPath:"inbound-rtp.packetsLost",modifier:"raw",reducer:"sum",filter:"number"},packetsDiscarded:{originalPath:"inbound-rtp.packetsDiscarded",modifier:"raw",reducer:"sum",filter:"number"},packetsReceived:{originalPath:"inbound-rtp.packetsReceived",modifier:"raw",reducer:"sum",filter:"number"},totalRoundTripTime:{originalPath:"candidate-pair.totalRoundTripTime",modifier:"raw",reducer:"sum",filter:"nonzero"},responsesReceived:{originalPath:"candidate-pair.responsesReceived",modifier:"raw",reducer:"sum",filter:"nonzero"},audioJitter:{originalPath:"inbound-rtp:audio.jitter",modifier:"raw",reducer:"sum",filter:"number"},videoJitter:{originalPath:"inbound-rtp:video.jitter",modifier:"raw",reducer:"sum",filter:"number"}},c=Object.keys(l);class h extends a.AbstractWrapper{constructor(e,t={}){super(e,t),this._ristrettoModuleCache=null,this._abrResolutions=[],this._isABREnabled=!1,this._isLoadingPlayerModule=!1,this._logLevels=[],this._ristrettoPlaybackStateToMMPStateMap=null,this._toggleTurnServersListener=e.subscribe(o.EPlayersEvents.TOGGLE_TURN_SERVERS,this._toggleTURNServers)}destroy(){return this._eventBusInstance.unsubscribe(this._toggleTurnServersListener),super.destroy()}setStreamConfig(e){return e?.WebRTCSignallingUrl?(this._lastKnownStreamConfig={WebRTCStreamId:e.WebRTCStreamId,WebRTCACLToken:e?.WebRTCACLToken,WebRTCSignallingUrl:e?.WebRTCSignallingUrl},this._setStreamConfig()):this._lastKnownStreamConfig=null,this}enableAbr(){return this._isABREnabled=!0,this._playerInstance?.enableABR(),this}disableAbr(){return this._isABREnabled=!1,this._playerInstance?.disableABR(),this}setAbrResolutions(e){return this._abrResolutions=e,this._playerInstance?.setAbrResolutionsVariants(e),this}setLoggerLevel(e){this._playerInstance?.setLoggerLevels(e),this._logLevels=e}setResolutionByName(e){return this._playerInstance?.setQualityByName(e),this}setResolutionByBitrate(e){return this._playerInstance?.setQualityByBitrate(e),this}recreatePlayerInstance(){this._playerInstance&&!this._persistent&&(this.destroy(),this._playerInstance=null),this._createPlayerInstance()}setPlayerConfig(e){return this._lastKnownConfig=e,this._lastKnownConfig.peerConnectionConfig||(this._lastKnownConfig.peerConnectionConfig={}),this._lastKnownConfig.peerConnectionConfig?.statsCollectionScheme?this._lastKnownConfig.peerConnectionConfig.statsCollectionScheme={...this._lastKnownConfig.peerConnectionConfig.statsCollectionScheme,...l}:this._lastKnownConfig.peerConnectionConfig={statsCollectionScheme:l},this._playerInstance?.setConfig(e,!0),this}get version(){return this._playerInstance?.version}_attachEventListeners(){this._ristrettoModuleCache&&this._playerInstance&&(this._playerInstance.addEventListener(this._ristrettoModuleCache.ECommonEvents.DEBUGGER_CONNECTED,this._onDebuggerConnected),this._playerInstance.addEventListener(this._ristrettoModuleCache.EPlayerEvent.PLAY_STATE_CHANGED,this._onPlaybackStateChanged),this._playerInstance.addEventListener(this._ristrettoModuleCache.ECommonEvents.ERROR,this._onRistrettoError),this._playerInstance.addEventListener(this._ristrettoModuleCache.ECommonEvents.PEER_METRICS_AVAILABLE,this._onPeerMetricsAvailable),this._playerInstance.addEventListener(this._ristrettoModuleCache.ECommonEvents.LIFECYCLE_EVENT,this._onLifecycleEventReported),this._playerInstance.addEventListener(this._ristrettoModuleCache.ECommonEvents.LIFECYCLE_ERROR,this._onLifecycleErrorReported),this._playerInstance.addEventListener(this._ristrettoModuleCache.ECommonEvents.RESOLUTION_SWITCH_AUTO,this._onRenditionSwitchAuto),this._playerInstance.addEventListener(this._ristrettoModuleCache.ECommonEvents.RESOLUTIONS_AVAILABLE,this._onResolutionsAvailable),this._playerInstance.addEventListener(this._ristrettoModuleCache.ECommonEvents.QUALITY_CHANGED,this._onQualityChanged))}_detachEventListeners(){this._ristrettoModuleCache&&this._playerInstance&&(this._playerInstance.removeEventListener(this._ristrettoModuleCache.ECommonEvents.DEBUGGER_CONNECTED,this._onDebuggerConnected),this._playerInstance.removeEventListener(this._ristrettoModuleCache.EPlayerEvent.PLAY_STATE_CHANGED,this._onPlaybackStateChanged),this._playerInstance.removeEventListener(this._ristrettoModuleCache.ECommonEvents.ERROR,this._onRistrettoError),this._playerInstance.removeEventListener(this._ristrettoModuleCache.ECommonEvents.PEER_METRICS_AVAILABLE,this._onPeerMetricsAvailable),this._playerInstance.removeEventListener(this._ristrettoModuleCache.ECommonEvents.RESOLUTION_SWITCH_AUTO,this._onRenditionSwitchAuto),this._playerInstance.removeEventListener(this._ristrettoModuleCache.ECommonEvents.RESOLUTIONS_AVAILABLE,this._onResolutionsAvailable),this._playerInstance.removeEventListener(this._ristrettoModuleCache.ECommonEvents.QUALITY_CHANGED,this._onQualityChanged))}_createPlayerInstance(){if(!this._ristrettoModuleCache){this._loadRistrettoModule();return}this._persistent&&this._playerInstance||(this._destroyPlayerInstance(),this._playerInstance=new this._ristrettoModuleCache.Player),this._lastKnownConfig&&this._playerInstance.setConfig(this._lastKnownConfig,!0),this._playerInstance?.setConfig({peerConnectionConfig:{statsCollectionScheme:l,statsGatheringPeriod:500}}),this._setStreamConfig(),this._playerInstance.setAppKey(this._appKey),this._videoElement&&this._playerInstance.setVideoElement(this._videoElement),this._attachEventListeners(),this._playerInstance?.setAppKey("callbackApp"),this._isStarted&&this._playerInstance?.start(),this._isABREnabled?this._playerInstance?.enableABR():this._playerInstance?.disableABR(),this._playerInstance?.setAbrResolutionsVariants(this._abrResolutions),this._playerInstance?.setLoggerLevels(this._logLevels)}_setStreamConfig(){this._playerInstance&&this._lastKnownStreamConfig&&this._playerInstance?.setStreamConfig({aclToken:this._lastKnownStreamConfig.WebRTCACLToken,streamId:this._lastKnownStreamConfig.WebRTCStreamId,wsUrl:this._lastKnownStreamConfig.WebRTCSignallingUrl},!0)}async _loadRistrettoModule(){if(this._isLoadingPlayerModule)return;this._isLoadingPlayerModule=!0;let{EStreamStatus:e,Player:t,ECommonEvents:n,EPlayerEvent:r}=await i("h9Af4");this._ristrettoModuleCache={EStreamStatus:e,Player:t,ECommonEvents:n,EPlayerEvent:r},this._ristrettoPlaybackStateToMMPStateMap={[e.UNKNOWN]:s.EPlaybackState.IDLE,[e.CONNECTING]:s.EPlaybackState.LOADING,[e.LIVE]:s.EPlaybackState.PLAYING,[e.FINISHED]:s.EPlaybackState.PAUSED,[e.ERRORED]:s.EPlaybackState.ERROR},this._isLoadingPlayerModule=!1,this._createPlayerInstance()}_onDebuggerConnected({detail:{debuggerUrl:e}}){this._eventBusInstance.publish(o.EPlayersEvents.DEBUGGER_CONNECTED,{debuggerUrl:e})}_onPlaybackStateChanged({detail:{prevState:e,nextState:t}}){this._ristrettoPlaybackStateToMMPStateMap&&this._eventBusInstance.publish(o.EPlayersEvents.PLAYBACK_STATE_CHANGED,{nextState:this._ristrettoPlaybackStateToMMPStateMap[t],prevState:this._ristrettoPlaybackStateToMMPStateMap[e]})}_onRistrettoError({detail:e}){this._eventBusInstance.publish(o.EPlayersEvents.ERROR,{error:Error(`Ristretto player error: ${e.info}`),isFatal:e.isFatal,playerType:s.EPlayerType.WEBRTC})}_onPeerMetricsAvailable({detail:{metrics:e}}){let t=c.reduce((t,n)=>(Object.hasOwn(e,n)&&(t[n]=e[n]),t),{});this._metricsCollector?.registerMetrics(t)}_onLifecycleEventReported({detail:{eventType:e}}){this._metricsCollector?.registerEvent(e)}_onLifecycleErrorReported({detail:{errorType:e,nativeError:t}}){this._metricsCollector?.registerEvent(e,{errorMessage:t?.message||""})}_onResolutionsAvailable({detail:{resolutions:e}}){this._eventBusInstance.publish(o.EPlayersEvents.RESOLUTIONS_AVAILABLE,{resolutions:e})}_onRenditionSwitchAuto({detail:{prevResolution:e,nextResolution:t}}){this._metricsCollector?.registerEvent("RenditionSwitchedAuto",{prevResolution:e,nextResolution:t}),this._eventBusInstance.publish(o.EPlayersEvents.AUTO_RESOLUTION_SWITCHED,{name:t})}_toggleTURNServers({shouldUseTURNServers:e}){this._playerInstance?.toggleTURNServersUsage(e)}_onQualityChanged({detail:{name:e}}){this._eventBusInstance.publish(o.EPlayersEvents.RESOLUTION_SWITCHED,{name:e})}}(0,n.__decorate)([s.bind],h.prototype,"_onDebuggerConnected",null),(0,n.__decorate)([s.bind],h.prototype,"_onPlaybackStateChanged",null),(0,n.__decorate)([s.bind],h.prototype,"_onRistrettoError",null),(0,n.__decorate)([s.bind],h.prototype,"_onPeerMetricsAvailable",null),(0,n.__decorate)([s.bind],h.prototype,"_onLifecycleEventReported",null),(0,n.__decorate)([s.bind],h.prototype,"_onLifecycleErrorReported",null),(0,n.__decorate)([s.bind],h.prototype,"_onResolutionsAvailable",null),(0,n.__decorate)([s.bind],h.prototype,"_onRenditionSwitchAuto",null),(0,n.__decorate)([s.bind],h.prototype,"_toggleTURNServers",null),(0,n.__decorate)([s.bind],h.prototype,"_onQualityChanged",null)}),a("4gxuw",function(e,t){r(e.exports,"AbstractWrapper",function(){return s});var n=i("giOKx");class s{constructor(e,t={}){this._videoElement=null,this._lastKnownConfig={},this._lastKnownStreamConfig=null,this._playerInstance=null,this._metricsCollector=null,this._eventBusInstance=e,this._eventBusInstance.publish(n.EPlayersEvents.MODULE_LOADED,{}),this._persistent=!!t.persistent}setMetricsCollector(e){this._metricsCollector=e}destroy(){return this._destroyPlayerInstance(),this._isStarted=!1,this}setAppKey(e){return this._appKey=e,this}setVideoElement(e){return this._videoElement=e,e&&this._playerInstance?.setVideoElement(e),this}recreatePlayerInstance(){this._playerInstance&&(this.destroy(),this._playerInstance=null),this._createPlayerInstance()}start(){return this._playerInstance||this.recreatePlayerInstance(),this._playerInstance?.start(),this._isStarted=!0,this}stop(){return this._isStarted=!1,this._persistent&&this._playerInstance&&"stop"in this._playerInstance?this._playerInstance.stop():this._destroyPlayerInstance(),this}setPlayerConfig(e){return this._lastKnownConfig=e,this._playerInstance?.setConfig(e,!0),this}_destroyPlayerInstance(){this._playerInstance&&(this._detachEventListeners(),this._playerInstance.destroy(),this._playerInstance=null)}}}),a("h9Af4",function(e,n){e.exports=t("4BzYh").then(()=>i("2vSYt"))})}),t.register("4BzYh",function(e,n){e.exports=Promise.resolve(require("./module.30c25c82.fee69b18.js")).then(()=>t("lg7QL"))});//# sourceMappingURL=RistrettoPlaying.b65db6a5.1de050ba.js.map }