"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[31599],{71147:function(e,t,r){t.J=void 0;var n,i,o=r(91261),s=r(68302),a=r(20217),l=r(22281),d=r(93218),u=r(46258),c=r(24286),h=r(39708),_=r(48927),p=r(63934),f=r(68920),g=r(57999),v=r(15883),y=r(78063),m=r(51417),S=r(48020),E=r(33790),T=r(75863),P=r(96798),C=r(80110),k=r(91037),R=r(73354),b=r(30617),w=r(18834),A=r(11202),W=r(63662),U=r(34167),D=r(22e3),L=r(5809),x=r(8339),O=r(28452),M=r(49328),G=r(41112),I=r(91552),F=r(76760),N=r(19546),V=r(86915),q=r(81008),B=r(92470),H=r(41145);(n=i||(i={})).ATTACH_QUEUE_START="Gluon.Player.attach_queue_start",n.ATTACH_QUEUE_END="Gluon.Player.attach_queue_end",n.ATTACH_QUEUE_MEASURE="Gluon.Player.attach_queue",n.ATTACH_START="Gluon.Player.attach_start",n.ATTACH_END="Gluon.Player.attach_end",n.ATTACH_MEASURE="Gluon.Player.attach",n.DETACH_QUEUE_START="Gluon.Player.detach_queue_start",n.DETACH_QUEUE_END="Gluon.Player.detach_queue_end",n.DETACH_QUEUE_MEASURE="Gluon.Player.detach_queue",n.DETACH_START="Gluon.Player.detach_start",n.DETACH_END="Gluon.Player.detach_end",n.DETACH_MEASURE="Gluon.Player.detach",n.RELOAD_QUEUE_START="Gluon.Player.reload_queue_start",n.RELOAD_QUEUE_END="Gluon.Player.reload_queue_end",n.RELOAD_QUEUE_MEASURE="Gluon.Player.reload_queue",n.RELOAD_START="Gluon.Player.reload_start",n.RELOAD_END="Gluon.Player.reload_end",n.RELOAD_MEASURE="Gluon.Player.reload";var j=function(){function e(e,t,r){var n=this;void 0===r&&(r={}),this.relativeBuffer={start:D.PlayerConstants.DEFAULT_RELATIVE_BUFFER_START,end:D.PlayerConstants.DEFAULT_RELATIVE_BUFFER_END},this.relativeAppend={start:D.PlayerConstants.DEFAULT_RELATIVE_APPEND_START,end:D.PlayerConstants.DEFAULT_RELATIVE_APPEND_END},this.onStateChanged=new a.Emitter,this.onTextCueChange=new a.Emitter,this.onTextCueGroupChange=new a.Emitter,this.onPeriodLoaded=new a.Emitter,this.onContentRangeChange=new a.Emitter,this.onError=new a.Emitter,this.onWarning=new a.Emitter,this._textSets=new P.HashMap,this._textEnabled=!1,this._currentText=[],this._bufferForPlaybackSeconds=D.PlayerConstants.DEFAULT_BUFFER_FOR_PLAYBACK_SECONDS,this._bufferUpdateSeconds=D.PlayerConstants.BUFFER_UPDATE_SECONDS,this._seekSnappingMode="async",this._seekSeq=0,this._playerUpdateSeconds=D.PlayerConstants.PLAYER_UPDATE_SECONDS,this._textUpdateSeconds=D.PlayerConstants.TEXT_UPDATE_SECONDS,this._seekPastEndRestart=D.PlayerConstants.DEFAULT_SEEK_PAST_END_RESTART_SECONDS,this._stallErrorThresholdSeconds=D.PlayerConstants.DEFAULT_STALL_TIME_ERROR_THRESHOLD_SECONDS,this._stallMitigationThresholdSeconds=D.PlayerConstants.DEFAULT_STALL_TIME_MITIGATION_THRESHOLD_SECONDS,this._errorRecoveryMaxAttempts=D.PlayerConstants.DEFAULT_ERROR_RECOVERY_MAX_ATTEMPTS,this._system=e,this._videoElement=t,this._system.supportsExactSeeks()||(this._seekSnapping="CLOSEST_VIDEO_SEGMENT_START"),this._bufferTimer=new s.AsyncTimer(this._system,function(){return n._onBufferTimerUpdate()}),this._playerTimer=new s.AsyncTimer(this._system,function(){return n._onPlayerTimerUpdate()}),this._sizeTimer=new s.AsyncTimer(this._system,function(){return n._onPlayerSizeUpdate()}),this._textTimer=new s.AsyncTimer(this._system,function(){return n._onTextCueUpdate()}),this._applyPlayerOptions(r),this._playerStateTracker=new l.PlayerStateTracker;var i=this._system.requiredStallSkippingWorkaround();"none"!==i&&(this._stallSkippingController=new y.StallSkippingController(this._system,i,{getCurrentPeriodRange:function(){return n._regionController.getCurrentPeriodRange()},getPlayerState:function(){return n._playerStateTracker.getCurrent()}})),this._stallTrackingController=new M.StallTrackingController(e,{getPlayerState:function(){return n.getPlayerState()},onPlayerStateChange:this.onStateChanged},this._stallErrorThresholdSeconds,this._stallMitigationThresholdSeconds),this._loadController=new f.PlayerLoadController(e,{reload:function(e){return n._reload(e)},attach:function(e){return n._attach(e)},detach:function(e){return n._detach(e)},seek:function(e){var t;return n._setPositionWhenReady(e.position,null===(t=e.adjustForLive)||void 0===t||t)}}),this._retryController=new S.RetryController,this._regionController=new m.RegionController(this._playerStateTracker.onStateChanged,{getState:function(){return n._playerStateTracker.getCurrent()},isLive:function(){return n._isLiveSession()},getPeriods:function(){return n._getLoadedPeriods()}}),this._endOfStreamController=new E.EndOfStreamController(this._system,{getCurrentPeriodRange:function(){return n._regionController.getCurrentPeriodRange()},getState:function(){return n._playerStateTracker.getCurrent()},playbackSession:function(){return n.getSession()},isLive:function(){return n._isLiveSession()}}),this._missingContentSkippingController=new N.MissingContentSkippingController(this.onStateChanged,this._system,{getCurrentPeriod:function(){var e;return null===(e=n.getSession())||void 0===e?void 0:e.getAppendPeriod()},getLiveContentRange:function(){if(n._isLiveSession())return n.getContentRange()},getOriginalStartTime:function(){if(n._isLiveSession())return n._originalStartTime},getLiveStart:function(){var e;if(n._isLiveSession())return null===(e=n._session)||void 0===e?void 0:e.getLiveStart()},getLiveEdge:function(){var e;if(n._isLiveSession())return null===(e=n._session)||void 0===e?void 0:e.getLiveEdge()}})}return Object.defineProperty(e.prototype,"playerVitals",{get:function(){return this._playerVitals},enumerable:!1,configurable:!0}),e.prototype.setPlayerVitals=function(e){if(void 0!==this._playerVitals)throw new x.InvalidOperationError("PlayerVitals is already set.");if(void 0!==this._session)throw new x.InvalidOperationError("PlayerVitals must be set before a session is attached.");this._playerVitals=e},e.prototype._hasEncrypted=function(e){var t,r=null===(t=this._session)||void 0===t?void 0:t.getLoadedBuffer();if(void 0===r)return!1;var n=r.mediaSourceController.getPipeline(e);if(void 0===n)return!1;for(var i=0,o=n.active.getAllRanges();if&&(this._system.logWarn("".concat(g," overstepped the live edge ").concat(f,". Updating position to live edge.")),s=f)):this._system.logWarn("Failed to adjust position ".concat(e.sessionInit.position," (origin=").concat(e.sessionInit.positionOrigin," contentStartTime=").concat(this._originalStartTime," availabilityStartTime=").concat(e.session.getLivePresentationStartTime(),")"))}if(this._seekPastEndRestart>=0&&!e.session.isLive&&void 0!==(v=U.PlayerUtil.getRangeOfPeriods(null!==(O=this._getLoadedPeriods())&&void 0!==O?O:[]))&&s>v.end-this._seekPastEndRestart&&(this._system.logWarn("Attempted to seek near/past the end of content: ".concat(s," with range [").concat(v.start,"-").concat(v.end,"] ").concat(e.isReload?"snapping to end":"seeking to start")),s=e.isReload?v.end:v.start),!(s!==i.currentTime))return[3,9];if(!((y=this._videoElement.setPositionWhenReady(s))instanceof Promise))return[3,7];return[4,y];case 6:H.sent(),H.label=7;case 7:if(!((i=this._videoElement.getState())instanceof Promise))return[3,9];return[4,i];case 8:i=H.sent(),H.label=9;case 9:if(this._playerStateTracker.setVideoState(i),void 0===(m=this._regionController.getPeriodForTime(s)))throw new W.PlayerNotLoadedError("Failed to find period for given time ".concat(s," with period info ").concat(this._getPeriodDebugInfo(null!==(M=this._getLoadedPeriods())&&void 0!==M?M:[])));if(this._session.setAppendPeriod(m),void 0!==this._playerVitals&&n.buffer.setPlayerVitals(this._playerVitals),void 0!==this._seekSnapping&&(this._seekSnapper=new R.SeekSnapper(this._seekSnapping,function(){return n.buffer.getPeriods()},function(e){return o.__awaiter(B,void 0,void 0,function(){var t,r;return o.__generator(this,function(i){switch(i.label){case 0:return[4,n.buffer.selectVariant(e)];case 1:return[2,null===(r=null===(t=i.sent().currentSelection)||void 0===t?void 0:t.video)||void 0===r?void 0:r.getDetails()]}})})})),S=U.PlayerUtil.isPeriodEncrypted(m),T=null==(E=n.buffer.drm)?void 0:E.getMediaKeys(),!(void 0!==E&&void 0!==T&&this._shouldAppendMediaKeys(S)))return[3,12];return[4,this._system.setMediaKeys(this._videoElement,T)];case 10:return H.sent(),P=this,[4,T.getStatusForPolicy({minHdcpVersion:"1.0"})];case 11:P._hdcpStatus=H.sent(),void 0!==this._hdcpStatus&&"usable"!==this._hdcpStatus&&this._system.logWarn("Probed non-usable HDCP status: ".concat(this._hdcpStatus)),this._system.requiresReattachOnKeyStatusesChange()&&E.onUpdated.on(this,function(){b.PromiseUtil.catchRejection(function(){if(!B._loadController.isReloading())return B._system.logInfo("reattaching media keys"),Promise.resolve(B._system.clearMediaKeys(B._videoElement)).then(function(){return B._system.setMediaKeys(B._videoElement,T)})},function(e){B._onError(d.WrappedError.wrap(e))})}),H.label=12;case 12:return n.buffer.onTextChange.on(this,function(e){B._textSets.set(e.source,e)}),n.buffer.onContentRangeChange.on(this,function(e){B.onContentRangeChange.emit(e)}),[4,n.buffer.attach(this._mediaSource)];case 13:if(H.sent(),void 0===this._gapSkipMaxSeconds&&void 0!==this._gapSkippingController&&(this._gapSkippingController.skipMaxSeconds=e.session.isLive?_.GapSkippingController.GAP_SKIP_MAX_SECONDS_LIVE:_.GapSkippingController.GAP_SKIP_MAX_SECONDS),null===(I=this._gapSkippingController)||void 0===I||I.onGapSeek.on(this,function(e){B.onWarning.emit(new k.WarningError("Skipping gap in buffered content from current position '".concat(e.currentTime,"' to buffered time '").concat(e.nextBufferedTime,"'"))),b.PromiseUtil.catchRejection(function(){return B._videoElement.setPositionWhenReady(e.nextBufferedTime)},function(e){B._onError(d.WrappedError.wrap(e))})}),null===(F=this._gapSkippingController)||void 0===F||F.start(),null===(N=this._stallSkippingController)||void 0===N||N.onStallSkip.on(this,function(e){var t=e.currentTime+D.PlayerConstants.STALL_SEEK_EPSILON;B.onWarning.emit(new k.WarningError("Attempting stall mitigation: setting current position (which is '".concat(e.currentTime,"') to '").concat(t,"'"))),b.PromiseUtil.catchRejection(function(){return o.__awaiter(B,void 0,void 0,function(){var e,r,n;return o.__generator(this,function(i){switch(i.label){case 0:return[4,B._system.requiresSafeSeek()?B.setPositionWhenReady(t):B._videoElement.setPositionWhenReady(t)];case 1:if(i.sent(),!(null===(n=this._stallSkippingController)||void 0===n))return[3,2];return[3,4];case 2:return r=(e=n).setStalledTime,[4,this._videoElement.getState()];case 3:r.apply(e,[i.sent().currentTime]),i.label=4;case 4:return[2]}})})},function(e){B._onError(d.WrappedError.wrap(e))})}),null===(V=this._stallSkippingController)||void 0===V||V.onWarning.on(this,function(e){return B.onWarning.emit(e)}),null===(q=this._stallSkippingController)||void 0===q||q.start(),this._stallTrackingController.onStallErrorTimeExceeded.on(this,function(e){var t,r="\nStall reason: ".concat(e.stallReason,"\nBuffered: ").concat(JSON.stringify(null===(t=B.getPlayerState().videoState)||void 0===t?void 0:t.buffered),"\nPipelines: ").concat(B._getPipelineStatusInformation(),"\nFirst observed at: ").concat(e.timeFirstObserved,"\nCurrent time: ").concat(e.currentTime);B._onError(new G.VideoStalledError("Stalled for more than ".concat(e.stallThreshold," seconds at ").concat(e.videoCurrentTime,".")+r,B._stallTrackingController.getMitigationAttempts()))}),this._stallTrackingController.onStallMitigationTimeExceeded.on(this,function(e){var t,r="\nStall reason: ".concat(e.stallReason,"\nBuffered: ").concat(JSON.stringify(null===(t=B.getPlayerState().videoState)||void 0===t?void 0:t.buffered),"\nPipelines: ").concat(B._getPipelineStatusInformation(),"\nFirst observed at: ").concat(e.timeFirstObserved,"\nCurrent time: ").concat(e.currentTime);"VIDEO_NOT_PROGRESSING"===e.stallReason?(B.onWarning.emit(new G.VideoStalledError("Attempting clear buffer mitigation for stall more than ".concat(e.stallThreshold," seconds at ").concat(e.videoCurrentTime,".")+r,B._stallTrackingController.getMitigationAttempts())),B._stallTrackingController.attemptedMitigationAt(e),b.PromiseUtil.catchRejection(function(){var e;return null===(e=B._getLoadedBuffer())||void 0===e?void 0:e.clearAsync()},function(e){B._onError(d.WrappedError.wrap(e))})):B.onWarning.emit(new G.VideoStalledError("Unable to attempt clear buffer mitigation for stall more than ".concat(e.stallThreshold," seconds at ").concat(e.videoCurrentTime,".")+r,B._stallTrackingController.getMitigationAttempts()))}),this._stallTrackingController.start(),this._loadController.onError.on(this,function(e){B._onError(new u.PlayerLoadError("Unexpected load controller failure",e))}),this._loadController.onWarning.on(this,function(e){return B.onWarning.emit(e)}),this._regionController.onWarning.on(this,function(e){return B.onWarning.emit(e)}),this._system.requiresSeekOnTrackChangeWorkaround()&&(this._seekOnTrackChangeWorkaround=new p.SeekOnTrackChangeWorkaround(this._system,n.buffer.onBufferItemPhaseChange,{getCurrentTime:function(){var e;return null===(e=B._playerStateTracker.getCurrent().videoState)||void 0===e?void 0:e.currentTime},setPositionWhenReady:function(e){return B._videoElement.setPositionWhenReady(e)}}),this._seekOnTrackChangeWorkaround.onError.on(this,function(e){return B._onError(e)}),this._seekOnTrackChangeWorkaround.start()),!(void 0!==this._seekSnapper))return[3,17];return[4,this._getSnappedPositionAsync(this._seekSnapper,s)];case 14:if(void 0!==(C=H.sent()))return[3,15];return this.onWarning.emit(new k.WarningError("unable to snap playhead from ".concat(s," to segment boundary (").concat(this._seekSnapping,")"))),[3,17];case 15:if(!(C!==s)||(this._system.logInfo("snapping playhead position from ".concat(s," to ").concat(C," (").concat(this._seekSnapping,")")),!((A=this._videoElement.setPositionWhenReady(C))instanceof Promise)))return[3,17];return[4,A];case 16:H.sent(),H.label=17;case 17:return this.onPeriodLoaded.emit(m),this._regionController.onPeriodChange.on(this,function(e){B._retryController.retryCounts.clear(),B._onPeriodChange(e.oldPeriodRange,e.newPeriodRange,e.position)}),this._regionController.start(m),this._endOfStreamController.start(),this._endOfStreamController.endOfStream.on(this,function(){b.PromiseUtil.catchRejection(function(){var e,t;if(void 0!==B._session&&B._session.noReloadBetweenCompatiblePeriods){var r=B._session.getAppendPeriod(),n=null===(e=B._session.getLoadedData())||void 0===e?void 0:e.manifest.getManifest();if(void 0!==r&&void 0!==n&&U.PlayerUtil.periodsCompatibleWithoutReload(n,r,void 0,B._system.requireSingleFramerate())){B._system.logVerbose("not calling endOfStream because approaching compatible period");return}}return null===(t=B._mediaSource)||void 0===t?void 0:t.endOfStream()},function(e){B._onError(d.WrappedError.wrap(e))})}),this._missingContentSkippingController.onMissingContentSeek.on(this,function(e){e.outsideLiveWindow?(B.onWarning.emit(new k.WarningError("Skipping missing content due to being outside live window, seeking from '".concat(e.currentTime,"' to '").concat(e.nextContentTime,"'"))),b.PromiseUtil.catchRejection(function(){return B.setPositionWhenReady(e.nextContentTime)},function(e){B._onError(d.WrappedError.wrap(e))})):(B.onWarning.emit(new k.WarningError("Skipping missing content, seeking from '".concat(e.currentTime,"' to '").concat(e.nextContentTime,"'"))),b.PromiseUtil.catchRejection(function(){return B._setPositionWhenReadyWithoutLiveCorrection(e.nextContentTime)},function(e){B._onError(d.WrappedError.wrap(e))}))}),this._missingContentSkippingController.start(this.getPlayerState()),this._setStateChangeHandlers(),[4,this._startTimers()];case 18:return H.sent(),[2]}})})})},e.prototype.detach=function(e){var t=this;return V.PerformanceUtil.wrap(this._system,"Gluon.Player.detach_queue_start","Gluon.Player.detach_queue_end","Gluon.Player.detach_queue",function(){return t._loadController.detach(null!=e?e:{})})},e.prototype._detach=function(e){var t=this;return V.PerformanceUtil.wrap(this._system,"Gluon.Player.detach_start","Gluon.Player.detach_end","Gluon.Player.detach",function(){return o.__awaiter(t,void 0,void 0,function(){var t,r,n,i,s,a,l,d,u,c,h,_,p,f,g;return o.__generator(this,function(o){switch(o.label){case 0:return t=this._session,this._session=void 0,this._lastVideoSize=void 0,[4,this._stopTimers()];case 1:return o.sent(),null===(a=this._gapSkippingController)||void 0===a||a.onGapSeek.off(this),null===(l=this._gapSkippingController)||void 0===l||l.stop(),null===(d=this._stallSkippingController)||void 0===d||d.onStallSkip.off(this),null===(u=this._stallSkippingController)||void 0===u||u.onWarning.off(this),null===(c=this._stallSkippingController)||void 0===c||c.stop(),this._stallTrackingController.onStallErrorTimeExceeded.off(this),this._stallTrackingController.onStallMitigationTimeExceeded.off(this),this._stallTrackingController.stop(),this._regionController.onPeriodChange.off(this),this._regionController.onWarning.off(this),this._regionController.stop(),this._loadController.onError.off(this),this._loadController.onWarning.off(this),null===(h=this._seekOnTrackChangeWorkaround)||void 0===h||h.onError.off(this),null===(_=this._seekOnTrackChangeWorkaround)||void 0===_||_.stop(),this._endOfStreamController.endOfStream.off(this),this._endOfStreamController.stop(),this._missingContentSkippingController.onMissingContentSeek.off(this),this._missingContentSkippingController.stop(),this._videoElement.onEnded.off(this),this._videoElement.onError.off(this),this._videoElement.onWarning.off(this),this._videoElement.onWaiting.off(this),this._videoElement.onLoadedData.off(this),null==t||t.onError.off(this),null==t||t.onWarning.off(this),this._playerStateTracker.reset(void 0),this._playerStateTracker.onStateChanged.off(this),r=null==t?void 0:t.getLoadedBuffer(),[4,null==t?void 0:t.unload(e)];case 2:if(n=null!==(p=o.sent())&&void 0!==p?p:{},null==r||r.onTextChange.off(this),null==r||r.onContentRangeChange.off(this),null===(f=null==r?void 0:r.drm)||void 0===f||f.onUpdated.off(this),i=this._videoElement.clearMediaSource(),s=this._system.clearMediaKeys(this._videoElement),!(i instanceof Promise||s instanceof Promise))return[3,4];return[4,b.PromiseUtil.waitAll([i,s])];case 3:o.sent(),o.label=4;case 4:return null===(g=this._mediaSource)||void 0===g||g.destroy(),this._mediaSource=void 0,this._hdcpStatus=void 0,this._seekSnapper=void 0,this._resetPlayerVitals(),[2,n]}})})})},e.prototype.reload=function(e){var t=this;return void 0===e&&(e={sequence:this._seekSeq}),this._recoverOrRethrowError(function(){return V.PerformanceUtil.wrap(t._system,"Gluon.Player.reload_queue_start","Gluon.Player.reload_queue_end","Gluon.Player.reload_queue",function(){return t._loadController.reload(e)})})},e.prototype._reload=function(e){var t=this;return V.PerformanceUtil.wrap(this._system,"Gluon.Player.reload_start","Gluon.Player.reload_end","Gluon.Player.reload",function(){return o.__awaiter(t,void 0,void 0,function(){var t,r,n,i,s,a,l,d,u,c,h;return o.__generator(this,function(o){switch(o.label){case 0:if(void 0===(t=this._session))throw new x.InvalidOperationError("Call to Player.reload without being attached");return r=null===(l=t.getLoadedData())||void 0===l?void 0:l.manifest,n=t.getEmittedTimedEvents(),i=null!==(d=e.position)&&void 0!==d?d:null===(u=this.getPlayerState().videoState)||void 0===u?void 0:u.currentTime,s=!0===e.useExistingDrm?void 0:new P.HashMap(null===(h=null===(c=t.getLoadedBuffer())||void 0===c?void 0:c.drm)||void 0===h?void 0:h.getStatusMap().values().map(function(e){return[e.keyId,e]})),[4,this._detach({keepDrm:e.useExistingDrm,drainBuffer:e.reuseDownloadedSegments})];case 1:if(a=o.sent(),!(void 0!==r))return[3,3];return[4,this._attach({session:t,manifest:r,isReload:!0,sessionInit:{drm:a.drm,emittedTimedEvents:n,keyStatusHintMap:s,keySystemDenylist:e.keySystemDenylist,position:i,sequence:e.sequence,hydrateBuffer:a,audioGroupOrder:e.audioCodecGroups,videoGroupOrder:e.videoCodecGroups,startAtLivePoint:!1}})];case 2:o.sent(),o.label=3;case 3:return this.onStateChanged.emit(this.getPlayerState()),[2]}})})})},e.getPlayerVersion=function(){return T.GLUON_VERSION},e.prototype.getVideoElement=function(){return this._videoElement},e.prototype.getSession=function(){return this._session},e.prototype.getPlayerState=function(){return this._playerStateTracker.getCurrent()},e.prototype.getContentRange=function(){var e;return null===(e=this._session)||void 0===e?void 0:e.getContentRange()},e.prototype.getTrackPreferences=function(){var e;return null===(e=this._session)||void 0===e?void 0:e.getTrackPreferences()},e.prototype.setTrackPreferences=function(e){var t=this;return this._recoverOrRethrowError(function(){return o.__awaiter(t,void 0,void 0,function(){var t;return o.__generator(this,function(r){switch(r.label){case 0:return[4,null===(t=this._session)||void 0===t?void 0:t.setTrackPreferences(e)];case 1:return r.sent(),[2]}})})})},e.prototype.setTextEnabled=function(e){var t;void 0===e&&(e=!0),e!==this._textEnabled&&(this._textEnabled=e,null===(t=this._session)||void 0===t||t.setTextEnabled(this._textEnabled),this._startTextTimer())},e.prototype._startTextTimer=function(){this._textTimer.tickEvery(this._textUpdateSeconds)},e.prototype.setVolumeWhenReady=function(e){var t=this;return this._recoverOrRethrowError(function(){return o.__awaiter(t,void 0,void 0,function(){return o.__generator(this,function(t){switch(t.label){case 0:return this._playerStateTracker.setVolume(e),[4,this._videoElement.setVolumeWhenReady(e)];case 1:return t.sent(),[2]}})})})},e.prototype.setPositionWhenReady=function(e){var t=this;return this._recoverOrRethrowError(function(){return t._system.requiresSafeSeek()?t._loadController.seek({position:e}):t._setPositionWhenReady(e)})},e.prototype._setPositionWhenReadyWithoutLiveCorrection=function(e){return o.__awaiter(this,void 0,void 0,function(){return o.__generator(this,function(t){return[2,this._system.requiresSafeSeek()?this._loadController.seek({position:e,adjustForLive:!1}):this._setPositionWhenReady(e,!1)]})})},e.prototype._setPositionWhenReady=function(e,t){var r,n;return void 0===t&&(t=!0),o.__awaiter(this,void 0,void 0,function(){var i,s,a,l,d,u,c,h,_,p,f,g=this;return o.__generator(this,function(v){switch(v.label){case 0:if(void 0!==this._safeSeeker)return this.onWarning.emit(new k.WarningError("ignoring request to seek to ".concat(e," because another seek is in progress"))),[2];if(++this._seekSeq,this._lastSeekPos=e,i=this._getLoadedBuffer(),void 0!==this._session&&this._session.isLive&&void 0!==i&&t&&void 0!==(s=this.getContentRange())&&(a=this._session.getLiveEdge(),l={start:s.start,end:null!=a?a:s.end},void 0!==(d=this._missingContentSkippingController.correctLivePosition(e,l))&&(e=d,this._system.logWarn("Attempted to seek out of live window. Corrected position to ".concat(e,".")))),!(void 0!==this._seekSnapper))return[3,4];if("sync"!==this._seekSnappingMode)return[3,1];return c=this._getSnappedPositionSync(this._seekSnapper,e,null===(r=this._playerStateTracker.getCurrent().variant)||void 0===r?void 0:r.videoDetails),[3,3];case 1:return[4,this._getSnappedPositionAsync(this._seekSnapper,e)];case 2:c=v.sent(),v.label=3;case 3:void 0===(u=c)?this.onWarning.emit(new k.WarningError("unable to snap seek from ".concat(e," to segment boundary (").concat(this._seekSnapping,")"))):u!==e&&(this._system.logInfo("snapping seek position from ".concat(e," to ").concat(u," (").concat(this._seekSnapping,")")),e=u),v.label=4;case 4:if(void 0!==(_=(h=this._playerStateTracker.getCurrent()).videoState)&&(p=o.__assign(o.__assign({},h),{playbackState:"SEEKING",videoState:o.__assign(o.__assign({},_),{currentTime:e})}),void 0!==(f=null===(n=this._gapSkippingController)||void 0===n?void 0:n.getSkippableGap(p))&&(this.onWarning.emit(new k.WarningError("Attempted to seek to ".concat(e," where a gap exists, jumping to ").concat(f," instead."))),e=f)),!(void 0!==i&&this._system.requiresSafeSeek()))return[3,9];this._safeSeeker=new C.SafeSeeker(this._system,i,this._videoElement,this._playerStateTracker,function(){return g._onBufferTimerUpdate()}),v.label=5;case 5:return v.trys.push([5,,7,8]),[4,this._safeSeeker.seek(e)];case 6:return v.sent(),[3,8];case 7:return this._safeSeeker=void 0,[7];case 8:return[3,11];case 9:return this._playerStateTracker.setPosition(e),[4,this._videoElement.setPositionWhenReady(e)];case 10:v.sent(),this._runBufferTimerUpdate(),v.label=11;case 11:return[2]}})})},e.prototype._getSnappedPositionAsync=function(e,t){return o.__awaiter(this,void 0,void 0,function(){var r;return o.__generator(this,function(n){switch(n.label){case 0:return r=this._adjustSnappedPosition,[4,e.snapToSegmentBoundary(t)];case 1:return[2,r.apply(this,[n.sent()])]}})})},e.prototype._getSnappedPositionSync=function(e,t,r){var n,i;if(void 0!==r){var o=e.snapToSegmentBoundarySync(t,r);return void 0===o&&this._system.logWarn("unable to synchronously snap seek from ".concat(t," because that falls outside the current period ([").concat(null===(n=r.segments.tryGetTiming(0))||void 0===n?void 0:n.start,"-").concat(null===(i=r.segments.tryGetTiming(r.segments.length-1))||void 0===i?void 0:i.end,"])")),this._adjustSnappedPosition(o)}this._system.logWarn("unable to synchronously snap seek from ".concat(t," due to lack of currently playing video details"))},e.prototype._adjustSnappedPosition=function(e){return void 0===e?e:e+.5*m.RegionController.DEFAULT_PADDING},e.prototype.setRateWhenReady=function(e){var t=this;return this._recoverOrRethrowError(function(){return o.__awaiter(t,void 0,void 0,function(){return o.__generator(this,function(t){return void 0!==this._safeSeeker?(this.onWarning.emit(new k.WarningError("ignoring request to set playback rate to ".concat(e," because a seek is in progress"))),[2]):(this._playerStateTracker.setRate(e),[2,this._videoElement.setRateWhenReady(e)])})})})},e.prototype._applyPlayerOptions=function(e){var t,r,n,i,o,s,a,l,d,u,c,h;this.relativeBuffer=null!==(t=e.relativeBuffer)&&void 0!==t?t:this.relativeBuffer,this.relativeAppend=null!==(r=e.relativeAppend)&&void 0!==r?r:this.relativeAppend,this._bufferUpdateSeconds=null!==(n=e.bufferUpdateSeconds)&&void 0!==n?n:this._bufferUpdateSeconds,this._bufferForPlaybackSeconds=null!==(i=e.bufferForPlaybackSeconds)&&void 0!==i?i:this._bufferForPlaybackSeconds,this._playerUpdateSeconds=null!==(o=e.playerUpdateSeconds)&&void 0!==o?o:this._playerUpdateSeconds,this._textUpdateSeconds=null!==(s=e.textUpdateSeconds)&&void 0!==s?s:this._textUpdateSeconds,this._adjustBufferForPlayback(),this._seekSnapping=null!==(a=e.seekSnapping)&&void 0!==a?a:this._seekSnapping,this._seekSnappingMode=null!==(l=e.seekSnappingMode)&&void 0!==l?l:this._seekSnappingMode,this._gapSkipMaxSeconds=e.gapSkipMaxSeconds,(void 0===e.gapSkipMaxSeconds||e.gapSkipMaxSeconds>0)&&this._createNewGapSkipController(e.gapSkipMaxSeconds,e.gapSkipMinBufferSeconds),this._seekPastEndRestart=null!==(d=e.seekPastEndRestartThreshold)&&void 0!==d?d:this._seekPastEndRestart,this._stallErrorThresholdSeconds=null!==(u=e.stallErrorThresholdSeconds)&&void 0!==u?u:this._stallErrorThresholdSeconds,this._stallMitigationThresholdSeconds=null!==(c=e.stallMitigationThresholdSeconds)&&void 0!==c?c:this._stallMitigationThresholdSeconds,this._errorRecoveryMaxAttempts=null!==(h=e.errorRecoveryMaxAttempts)&&void 0!==h?h:this._errorRecoveryMaxAttempts},e.prototype._createNewGapSkipController=function(e,t){var r=this;void 0===e&&(e=_.GapSkippingController.GAP_SKIP_MAX_SECONDS),void 0===t&&(t=_.GapSkippingController.GAP_SKIP_MIN_BUFFER_SECONDS),void 0!==this._gapSkippingController&&(this._gapSkippingController=void 0),this._gapSkippingController=new _.GapSkippingController({getCurrentPeriodRange:function(){return r._regionController.getCurrentPeriodRange()},stateChange:this.onStateChanged}),this._gapSkippingController.skipMaxSeconds=e,this._gapSkippingController.skipMinBufferSeconds=t},e.prototype._adjustBufferForPlayback=function(){this._bufferForPlaybackSeconds>this.relativeAppend.end-2&&(this._bufferForPlaybackSeconds=Math.max(0,this.relativeAppend.end-2),this._system.logWarn("clamping bufferForPlaybackSeconds to ".concat(this._bufferForPlaybackSeconds)))},e.prototype._attemptPeriodTransition=function(){var e;if(!this._loadController.isReloading()){var t=this._playerStateTracker.getCurrent();this._system.logVerbose("Attempting period transition at ".concat(null===(e=t.videoState)||void 0===e?void 0:e.currentTime)),this._regionController.tryUpdatePeriod(t)}},e.prototype._setStateChangeHandlers=function(){var e=this;this._videoElement.onEnded.off(this),this._videoElement.onEnded.on(this,function(t){e._playerStateTracker.setVideoState(t),e._system.logVerbose("Ended event fired at ".concat(t.currentTime,".")),e._attemptPeriodTransition()})},e.prototype._resetPlayerVitals=function(){var e;null===(e=this._playerVitals)||void 0===e||e.reset()},e.prototype._onError=function(e){var t=this,r=this._handleError(e);r instanceof d.WrappedError?this.onError.emit(new I.PlayerError("Playback error occurred and unable to fallback or retry.\n".concat(this._getRetryControllerInfo(),"\n").concat(this._getBufferLevelInformation(),"\n").concat(this._getLatestReloadReason()),r)):b.PromiseUtil.catchRejection(function(){return r},function(e){t._onError(d.WrappedError.wrap(e))})},e.prototype._handleError=function(e){var t,r,n,i,o,s,a=this,l=d.WrappedError.findFirst(e,q.SkipSegmentError);if(void 0!==l)return this.setPositionWhenReady(l.timeToJump);var u=d.WrappedError.findFirst(e,F.RetryableError);if(void 0!==u)return this._handleRetryableError(u);if(d.WrappedError.causedBy(e,c.OutputRestrictedError.NAME)||d.WrappedError.causedBy(e,O.CopyProtectionError.NAME)){var _=this._reloadForOutputRestrictedError(e);if(void 0!==_)return this.onWarning.emit(new k.WarningError("Reloading due to output being restricted",e)),this._latestReloadReason=e,this._latestReloadTime=Date.now(),this._loadController.reload(_)}if(d.WrappedError.causedBy(e,h.FormatChangedError.NAME))return this.onWarning.emit(new k.WarningError("Expected player reload caused by error: ".concat(e.toString()))),this._latestReloadReason=e,this._latestReloadTime=Date.now(),this._loadController.reload({useExistingDrm:this._shouldUseExistingDrmOnReload(),sequence:this._seekSeq});if(this._retryController.canRetry(e)){var p=this._retryController.getRetryRestrictions(e);return this.onWarning.emit(new k.WarningError("Retrying for retry controller with restrictions audio=".concat((null!==(t=null==p?void 0:p.audio)&&void 0!==t?t:[]).toString()," video=").concat((null!==(r=null==p?void 0:p.video)&&void 0!==r?r:[]).toString()," keySystemDenylist=").concat((null!==(n=null==p?void 0:p.keySystemDenylist)&&void 0!==n?n:[]).toString()),e)),null===(i=this._session)||void 0===i||i.onError.off(this),null===(o=this._session)||void 0===o||o.onError.on(this,function(e){a.onWarning.emit(new k.WarningError("ignoring session error while reloading "+String(e),e))}),this._retryController.markRetry(e),this._latestReloadReason=e,this._latestReloadTime=Date.now(),this._loadController.reload({position:null===(s=this.getPlayerState().videoState)||void 0===s?void 0:s.currentTime,sequence:this._seekSeq,useExistingDrm:!1,audioCodecGroups:null==p?void 0:p.audio,videoCodecGroups:null==p?void 0:p.video,keySystemDenylist:null==p?void 0:p.keySystemDenylist})}var f=d.WrappedError.findFirst(e,L.VideoElementError);if(void 0!==f){var g=this.getPlayerState(),v={bufferForPlaybackSeconds:this._bufferForPlaybackSeconds,variantData:g.variant,videoState:g.videoState};f.updateData(v)}return this._wrapPossibleHdcpError(e)},e.prototype._wrapPossibleHdcpError=function(e){var t=d.WrappedError.findFirst(e,L.VideoElementError),r=d.WrappedError.findFirst(e,B.NetworkRequestError),n=void 0!==r&&"license"===r.context.type&&void 0!==r.context.responseText&&r.context.responseText.indexOf("licence_challenge_error")>=0;if(void 0!==this._hdcpStatus&&"usable"!==this._hdcpStatus&&(void 0!==t||n))return new O.CopyProtectionError("HDCP error: ".concat(this._hdcpStatus),e);var i=d.WrappedError.findFirst(this._latestReloadReason,L.VideoElementError);return void 0!==t&&this._isLikelyHdcpError(t)||n&&void 0!==i&&this._isLikelyHdcpError(i)?new O.CopyProtectionError("Likely HDCP error",e):e},e.prototype._isLikelyHdcpError=function(e){if(void 0!==e.error.msExtendedCode){var t=H.StringUtil.signed32BitIntegerToHexString(e.error.msExtendedCode);return"80070005"===t||"C00D7159"===t||"C0262500"===t}return!!(3===e.error.code&&void 0!==e.error.message&&null!==e.error.message&&e.error.message.indexOf("PIPELINE_ERROR_DECODE: video decoder reinitialization failed")>=0)},e.prototype._recoverOrRethrowError=function(e){return o.__awaiter(this,void 0,void 0,function(){var t,r,n,i;return o.__generator(this,function(o){switch(o.label){case 0:t=e(),r=0,o.label=1;case 1:if(!(r0&&(e="Retry controller error data");var t=Array("".concat(e," at t=").concat(Date.now(),"."));return this._retryController.retryCounts.forEach(function(e,r){t.push("".concat(e,": ").concat(r.attemptedRetries," retries (").concat(r.retryCount," remaining) most recent retry at t=").concat(r.lastTimestamp,"."))}),t.join("\n")},e.prototype._getPipelineRanges=function(e){for(var t,r,n=new P.HashMap,i=0,o=null!==(r=null===(t=this._getLoadedBuffer())||void 0===t?void 0:t.getActivePipelines())&&void 0!==r?r:[];i0?e.join(""):"(no pipelines found)"},e.prototype._handleRetryableError=function(e){return o.__awaiter(this,void 0,void 0,function(){var t,r;return o.__generator(this,function(n){switch(n.label){case 0:return this.onWarning.emit(new k.WarningError("Attempting to retry retryable error",e.original)),t="READY"===this.getPlayerState().playbackState,r=void 0===this._nonReadyTime?void 0:(Date.now()-this._nonReadyTime)/1e3,[4,e.retry(t,r)];case 1:if(!n.sent())throw e.original;return[2]}})})},e.prototype._reloadForOutputRestrictedError=function(e){var t,r,n,i,o,s,a,l=this,u=d.WrappedError.causedBy(e,c.OutputRestrictedError.NAME)?c.OutputRestrictedError.NAME:d.WrappedError.causedBy(e,O.CopyProtectionError.NAME)?O.CopyProtectionError.NAME:void 0;if(void 0!==u){var h=null===(t=this._session)||void 0===t?void 0:t.getAppendPeriod(),_=null===(n=null===(r=this._getLoadedBuffer())||void 0===r?void 0:r.drm)||void 0===n?void 0:n.getChosenMediaKeyOptions();if(void 0===h||void 0===_||this._system.supportsMultiCodecMediaKeys())return u===O.CopyProtectionError.NAME?void 0:{useExistingDrm:this._shouldUseExistingDrmOnReload(),sequence:this._seekSeq};var p=U.PlayerUtil.groupKeyTypesByCodec(h.video,function(e){return l._system.resolveKeyType(e)});if(null!==(o=null===(i=p.tryGet(_.video[0].codec))||void 0===i?void 0:i.has("video-sd"))&&void 0!==o&&o)return u===O.CopyProtectionError.NAME?void 0:{useExistingDrm:this._shouldUseExistingDrmOnReload(),sequence:this._seekSeq};for(var f=[],g=0,v=["hevc","avc"];g0)return{useExistingDrm:!1,sequence:this._seekSeq,videoCodecGroups:f}}},e.prototype._onPeriodChange=function(e,t,r){var n,i=this;if(void 0===this._session){this.onWarning.emit(new k.WarningError("Got period change information without session"));return}if(void 0===e)this._system.logInfo("Adding initial period restriction with range=(".concat(t.start,"-").concat(t.end,")"));else{var o="from old range=(".concat(e.start,"-").concat(e.end,") to new range=(").concat(t.start,"-").concat(t.end,")");if(this._session.noReloadBetweenCompatiblePeriods){var s=this._session.getAppendPeriod(),a=this._regionController.getPeriodForTime(r),l=null===(n=this._session.getLoadedData())||void 0===n?void 0:n.manifest.getManifest();if(void 0!==s&&void 0!==a&&void 0!==l&&U.PlayerUtil.periodsCompatibleWithoutReload(l,s,a,this._system.requireSingleFramerate())){this._system.logInfo("Rolling through to compatible period at t='".concat(r,"', ").concat(o)),this._session.setAppendPeriod(a),this._regionController.stop(),this._regionController.start(a),this.onPeriodLoaded.emit(a);return}}this._system.logInfo("Reloading due to changed period at t='".concat(r,"', ").concat(o)),b.PromiseUtil.catchRejection(function(){return i._loadController.reload({position:r,sequence:i._seekSeq,useExistingDrm:i._shouldUseExistingDrmOnReload(),reuseDownloadedSegments:!0})},function(e){i._onError(d.WrappedError.wrap(e))})}},e.prototype._shouldUseExistingDrmOnReload=function(){return"single_period_new_drm"!==this._system.requiredMultiPeriodWorkaround()},e.prototype._getPeriodDebugInfo=function(e){return e.map(function(e){var t=U.PlayerUtil.getRangeOfPeriod(e);return"".concat(e.id,": ").concat(null==t?void 0:t.start,"-").concat(null==t?void 0:t.end)}).join(", ")},e.prototype._startTimers=function(){var e;return o.__awaiter(this,void 0,void 0,function(){var t=this;return o.__generator(this,function(r){switch(r.label){case 0:return[4,this._stopTimers()];case 1:if(r.sent(),this._startTextTimer(),(null===(e=this._session)||void 0===e?void 0:e.capVariantsToSize)!==!0)return[3,3];return this._sizeTimer.onError.on(this,function(e){return t._onError(e)}),[4,this._sizeTimer.tickNow()];case 2:r.sent(),this._sizeTimer.tickEvery(D.PlayerConstants.SIZE_UPDATE_SECONDS),r.label=3;case 3:return this._playerTimer.onError.on(this,function(e){return t._onError(e)}),[4,this._playerTimer.tickNow()];case 4:return r.sent(),this._playerTimer.tickEvery(this._playerUpdateSeconds),this._bufferTimer.onError.on(this,function(e){return t._onError(e)}),[4,this._bufferTimer.tickNow()];case 5:return r.sent(),this._bufferTimer.tickEvery(this._bufferUpdateSeconds),[2]}})})},e.prototype._stopTimers=function(){return o.__awaiter(this,void 0,void 0,function(){var e;return o.__generator(this,function(t){switch(t.label){case 0:return(e=[]).push(this._textTimer.stop()),e.push(this._sizeTimer.stop()),e.push(this._playerTimer.stop()),e.push(this._bufferTimer.stop()),[4,b.PromiseUtil.waitAll(e)];case 1:return t.sent(),this._textTimer.onError.off(this),this._sizeTimer.onError.off(this),this._playerTimer.onError.off(this),this._bufferTimer.onError.off(this),[2]}})})},e.prototype._getLoadedPeriods=function(){var e,t,r;return null===(r=null===(t=null===(e=this._session)||void 0===e?void 0:e.getLoadedData())||void 0===t?void 0:t.manifest.getManifest())||void 0===r?void 0:r.periods},e.prototype._getLoadedBuffer=function(){var e;return null===(e=this._session)||void 0===e?void 0:e.getLoadedBuffer()},e.prototype._isLiveSession=function(){return void 0!==this._session&&this._session.isLive},e.prototype._onPlayerSizeUpdate=function(){return o.__awaiter(this,void 0,void 0,function(){var e;return o.__generator(this,function(t){switch(t.label){case 0:if(!((e=this._videoElement.getSize())instanceof Promise))return[3,2];return[4,e];case 1:e=t.sent(),t.label=2;case 2:if(void 0===this._session)return[2];return(void 0===this._lastVideoSize||e.width!==this._lastVideoSize.width||e.height!==this._lastVideoSize.height)&&(this._lastVideoSize=e,this._session.setVideoSize(e)),[2]}})})},e.prototype._updateVideoBufferForPlaybackSeconds=function(e){var t,r=null===(t=this._regionController.getCurrentPeriodRange())||void 0===t?void 0:t.end,n=this._bufferForPlaybackSeconds;return void 0!==r&&(n=Math.min(Math.floor(r-e),n)),this._videoElement.setBufferForPlaybackSeconds(n)},e.prototype._onPlayerTimerUpdate=function(){var e;return o.__awaiter(this,void 0,void 0,function(){var t,r,n,i;return o.__generator(this,function(o){switch(o.label){case 0:if(!((t=this._videoElement.getState())instanceof Promise))return[3,2];return[4,t];case 1:t=o.sent(),o.label=2;case 2:if(this._playerStateTracker.setVideoState(t),!((r=this._updateVideoBufferForPlaybackSeconds(t.currentTime))instanceof Promise))return[3,4];return[4,r];case 3:o.sent(),o.label=4;case 4:return(null===(e=this._session)||void 0===e?void 0:e.cmcd)!==void 0&&(n=this._session.getLoadedData(),this._session.cmcd.setIsLive(void 0!==n?void 0!==n.manifest.getManifest().dynamicInfo:void 0)),i=this.getPlayerState(),this._shouldTryUpdatePeriod(t,i)&&this._regionController.tryUpdatePeriod(i),[2]}})})},e.prototype._shouldTryUpdatePeriod=function(e,t){if(void 0===this._session)return!0;var r,n=this._session.getAppendPeriod(),i=this._regionController.getPeriodForTime(e.currentTime),o=null===(r=this._session.getLoadedData())||void 0===r?void 0:r.manifest.getManifest();if(void 0===n||void 0===i||void 0===o)return!0;if(n===i)return!1;if("READY"===t.playbackState||"IDLE"===t.playbackState){var s=o.periods.indexOf(n),a=o.periods.indexOf(i);if(s<0||a<0||a!==s-1)return!0;var l=U.PlayerUtil.getRangeOfPeriod(n,"union");if(void 0!==l&&g.TimeRangeUtil.contains([l],e.currentTime))return this._system.logInfo("Not updating period from [".concat(n.start,"-").concat(n.end,"] to [").concat(i.start,"-").concat(i.end,"] at currentTime=").concat(e.currentTime," because that falls within stream range of current period [").concat(l.start,"-").concat(l.end,"]")),!1}return!0},e.prototype._runBufferTimerUpdate=function(){var e=this;b.PromiseUtil.catchRejection(function(){return e._onBufferTimerUpdate()},function(t){e._onError(d.WrappedError.wrap(t))})},e.prototype._onBufferTimerUpdate=function(){return o.__awaiter(this,void 0,void 0,function(){var e;return o.__generator(this,function(t){switch(t.label){case 0:if(!(void 0!==(e=this.getPlayerState()).videoState&&void 0!==this._session))return[3,2];return this._session.emitCurrentBandwidthEstimate(),[4,this._regionController.applyBufferRegions(this._session,e.videoState.currentTime,this.relativeBuffer,this.relativeAppend)];case 1:t.sent(),t.label=2;case 2:return[2]}})})},e.prototype._onTextCueUpdate=function(){return o.__awaiter(this,void 0,void 0,function(){var e,t,r,n=this;return o.__generator(this,function(i){switch(i.label){case 0:if(!this._textEnabled)return 0!==this._currentText.length&&(this._currentText=[],this._emitTextCueChange(this._currentText)),this._textTimer.stop().catch(function(){}),[2];if(!((e=this._videoElement.getState())instanceof Promise))return[3,2];return[4,e];case 1:e=i.sent(),i.label=2;case 2:return t=[],void 0!==(r=this._textSets.tryGet(this._getTextSource()))&&t.push.apply(t,r.text.find(e.currentTime)),(t.length!==this._currentText.length||t.some(function(e,r){return!v.VttUtil.isCueEqual(t[r],n._currentText[r])}))&&(this._currentText=t,this._emitTextCueChange(this._currentText)),[2]}})})},e.prototype._emitTextCueChange=function(e){this.onTextCueChange.emit(this._getTextCueChangePayload(e)),this.onTextCueGroupChange.emit({groups:e})},e.prototype._getTextCueChangePayload=function(e){for(var t=[],r=0;r0?s[0].service:"VTT"},e}();t.J=j}}]);