define(["playbackManager","events","globalize","inputManager","layoutManager","userSettings"],function(playbackManager,events,globalize,inputManager,layoutManager,userSettings){"use strict";function confirmStillPlaying(){var maxIdleTime=userSettings.stillWatchingTimeMs();return maxIdleTime<=0?Promise.resolve():inputManager.idleTime()<maxIdleTime?Promise.resolve():require(["confirm"]).then(function(responses){return(0,responses[0])({title:null,text:globalize.translate("AreYouStillWatching"),confirmText:globalize.translate("Yes"),cancelText:globalize.translate("No"),timeout:6e4})})}return function(){var confirmTimeout;function resetConfirmTimer(){clearConfirmTimer(),confirmTimeout=setTimeout(onConfirmTimeout,6e4)}function clearConfirmTimer(){confirmTimeout&&(clearTimeout(confirmTimeout),confirmTimeout=null)}function onConfirmTimeout(){confirmStillPlaying().then(resetConfirmTimer,function(result){"cancel"!==result&&"_timeout"!==result||playbackManager.stop()})}this.name="Are You Still Watching?",this.type="preplayintercept",this.id="stillplaying",this.intercept=function(options){return clearConfirmTimer(),"Video"!==options.mediaType?Promise.resolve():options.fullscreen?confirmStillPlaying():Promise.resolve()},events.on(playbackManager,"playbackstart",function(e,player,state){"Video"===(state.NowPlayingItem||{}).MediaType&&!player.isExternalPlayer&&!layoutManager.mobile&&0<userSettings.stillWatchingTimeMs()?resetConfirmTimer():clearConfirmTimer()}),events.on(playbackManager,"playbackstop",clearConfirmTimer)}});