define(["browser","connectionManager","playbackManager","dom","Modernizr","css!./style"],function(browser,connectionManager,playbackManager,dom,Modernizr){"use strict";function enableAnimation(){return Modernizr.cssanimations&&dom.supportsEventListenerOnce()}function enableRotation(){return!!enableAnimation()}function Backdrop(){}var backdropContainer,hasExternalBackdrop,currentLoadingBackdrop,backgroundContainer,hasInternalBackdrop;function getBackdropContainer(){return(backdropContainer=backdropContainer||document.querySelector(".backdropContainer"))||((backdropContainer=document.createElement("div")).classList.add("backdropContainer"),document.body.insertBefore(backdropContainer,document.body.firstChild)),backdropContainer}function clearBackdrop(clearAll){clearRotation(),currentLoadingBackdrop&&(currentLoadingBackdrop.destroy(),currentLoadingBackdrop=null),getBackdropContainer().innerHTML="",clearAll&&(hasExternalBackdrop=!1),internalBackdrop(!1)}function getBackgroundContainer(){return backgroundContainer=backgroundContainer||document.querySelector(".backgroundContainer")}function setBackgroundContainerBackgroundEnabled(){hasInternalBackdrop||hasExternalBackdrop?getBackgroundContainer().classList.add("withBackdrop"):getBackgroundContainer().classList.remove("withBackdrop")}function internalBackdrop(enabled){hasInternalBackdrop=enabled,setBackgroundContainerBackgroundEnabled()}function setBackdropImage(url,animate){currentLoadingBackdrop&&(currentLoadingBackdrop.destroy(),currentLoadingBackdrop=null);var elem=getBackdropContainer(),existingBackdropImage=elem.querySelector(".displayingBackdropImage");if(existingBackdropImage){if(existingBackdropImage.getAttribute("data-url")===url)return;existingBackdropImage.classList.remove("displayingBackdropImage")}var instance=new Backdrop;instance.load(url,animate,elem,existingBackdropImage),currentLoadingBackdrop=instance}Backdrop.prototype.load=function(url,animate,parent,existingBackdropImage){var img=new Image,self=this;this.previousBackdropImage=existingBackdropImage,img.onload=function(){var backdropImage,onAnimationComplete;self.isDestroyed?self.removePreviousBackdropImage():((backdropImage=document.createElement("div")).classList.add("backdropImage","displayingBackdropImage"),backdropImage.style.backgroundImage="url('"+url+"')",backdropImage.setAttribute("data-url",url),backdropImage.setAttribute("loading","lazy"),self.elem=backdropImage,internalBackdrop(!0),animate&&enableAnimation()&&backdropImage.classList.add("backdropImageFadeIn"),parent.appendChild(backdropImage),enableAnimation()?(onAnimationComplete=function(){dom.removeEventListener(backdropImage,dom.whichAnimationEvent(),onAnimationComplete,{once:!0}),dom.removeEventListener(backdropImage,dom.whichAnimationCancelEvent(),onAnimationComplete,{once:!0}),self.removePreviousBackdropImage()},dom.addEventListener(backdropImage,dom.whichAnimationEvent(),onAnimationComplete,{once:!0}),dom.addEventListener(backdropImage,dom.whichAnimationCancelEvent(),onAnimationComplete,{once:!0})):self.removePreviousBackdropImage())},img.src=url,this.url=url},Backdrop.prototype.removePreviousBackdropImage=function(){var existingBackdropImage=this.previousBackdropImage;existingBackdropImage&&existingBackdropImage.parentNode&&existingBackdropImage.parentNode.removeChild(existingBackdropImage)},Backdrop.prototype.cancelAnimation=function(){var elem=this.elem;elem&&(elem.classList.remove("backdropImageFadeIn"),this.elem=null)},Backdrop.prototype.destroy=function(){this.isDestroyed=!0,this.cancelAnimation(),this.removePreviousBackdropImage()};var rotationInterval,standardWidths=[480,720,1280,1440,1920];function getBackdropMaxWidth(){var width=dom.getWindowSize().innerWidth;if(standardWidths.includes(width))return width;width=100*Math.floor(width/100);return Math.min(width,1920)}function getImageUrls(items,imageOptions){for(var list=[],i=0,length=items.length;i=currentRotatingImages.length&&(newIndex=0),setBackdropImage(currentRotatingImages[currentRotationIndex=newIndex],animationEnabledByCaller),animationEnabledByCaller=!0)}function clearRotation(){rotationInterval&&clearInterval(rotationInterval),rotationInterval=null,currentRotatingImages=[],currentRotationIndex=-1}return{getImageUrls:getImageUrls,setBackdrops:function(items,imageOptions,enableImageRotation,enableAnimation){var images=getImageUrls(items,imageOptions);images.length?function(images,enableImageRotation,enableAnimation){if(function(a,b){if(a===b)return 1;if(null!=a&&null!=b&&a.length===b.length){for(var i=0;i