define(["userSettings","playbackManager","globalize","dialog"],function(userSettings,playbackManager,globalize,dialog){"use strict";function PlayQueueConfirmation(){this.name="Play Queue Confirmation",this.type="preplayintercept",this.id="playqueueconfirmation"}function showConfirmation(playOptions){var player=playbackManager.getCurrentPlayer(),options={text:globalize.translate("AfterThisPlaysConfirmation")},items=[];return items.push({name:globalize.translate("Keep"),id:"keep",type:"submit"}),items.push({name:globalize.translate("Clear"),id:"clear"}),items.push({name:globalize.translate("Cancel"),id:"cancel",type:"cancel"}),options.buttons=items,dialog(options).then(function(result){return"cancel"===result?Promise.reject():"keep"===result?function(options,player){var currentPlaylistIndex=playbackManager.getCurrentPlaylistIndex(player);return-1===currentPlaylistIndex?Promise.resolve():playbackManager.getPlaylist({StartIndex:currentPlaylistIndex},player).then(function(result){var items=options.items,previousItems=result.Items;if(!previousItems.length)return Promise.resolve();for(var i=0,length=previousItems.length;i<length;i++)items.push(previousItems[i])})}(playOptions,player):Promise.resolve()})}return PlayQueueConfirmation.prototype.intercept=function(options){if(!options.item)return Promise.resolve();if(options.isFirstItem&&"Audio"===options.mediaType&&playbackManager.isPlayingAudio()&&options.fullscreen){var currentPlaylistLength=playbackManager.getCurrentPlaylistLength();if(1<currentPlaylistLength)return showConfirmation(options)}return Promise.resolve()},PlayQueueConfirmation});