define(["exports","./../emby-apiclient/connectionmanager.js","./../dom.js","./../common/playback/playbackmanager.js","./../common/methodtimer.js"],function(_exports,_connectionmanager,_dom,_playbackmanager,_methodtimer){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;var uiDependencies=["css!modules/backdrop/style.css"],supportsAsyncDecodedImages=_dom.default.supportsAsyncDecodedImages(),supportsObjectFit=CSS.supports("object-fit","contain"),supportsImgSrcSet="srcset"in HTMLImageElement.prototype,RotationIntervalMs=24e3;uiDependencies.length&&require(uiDependencies);var backdropContainer,hasExternalBackdrop,currentLoadingBackdrop,backgroundContainer,hasInternalBackdrop,rotationInterval,supportsCssAnimations=CSS.supports("animation-name","a");function enableAnimation(){return supportsCssAnimations&&_dom.default.supportsEventListenerOnce()}function enableRotation(){return!!enableAnimation()}function Backdrop(){}function mapImageSourceToUrl(source){return source.url}function getImageInfoId(imageInfo){var id=imageInfo.id;return id=id||(imageInfo.id=imageInfo.sources.map(mapImageSourceToUrl).join("|"))}function getFallbackImageSource(imageInfo){return imageInfo.sources[imageInfo.sources.length-1]}function mapSourceToString(source){return source.url+" "+source.width+"w"}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(imageInfo,animate){var elem=getBackdropContainer(),existingBackdropImage=elem.querySelector(".displayingBackdropImage");if(!currentLoadingBackdrop||getImageInfoId(currentLoadingBackdrop.imageInfo)!==getImageInfoId(imageInfo)){if(existingBackdropImage){if(existingBackdropImage.getAttribute("data-id")===getImageInfoId(imageInfo))return;existingBackdropImage.classList.remove("displayingBackdropImage")}currentLoadingBackdrop&&(currentLoadingBackdrop.destroy(),currentLoadingBackdrop=null);var instance=new Backdrop;instance.load(imageInfo,animate,elem,existingBackdropImage),currentLoadingBackdrop=instance}}function getImageSources(apiClient,itemId,imageOptions){var widths=apiClient.getDefaultImageSizes();return widths.push(function(widths){var width=_dom.default.getWindowSize().innerWidth;return widths.includes(width)?width:(width=100*Math.floor(width/100),Math.min(width,1920))}(widths)),apiClient.getImageUrls(itemId,imageOptions,{widths:widths})}function getPrimaryImageInfos(item,imageOptions,apiClient){return item.ImageTags&&item.ImageTags.Primary?[{sources:getImageSources(apiClient,item.Id,Object.assign(imageOptions,{type:"Primary",tag:item.ImageTags.Primary,EnableImageEnhancers:!1})),coverImage:item.PrimaryImageAspectRatio&&1.4<=item.PrimaryImageAspectRatio}]:item.PrimaryImageTag?[{sources:getImageSources(apiClient,item.PrimaryImageItemId||item.Id||item.ItemId,Object.assign(imageOptions,{type:"Primary",tag:item.PrimaryImageTag,EnableImageEnhancers:!1})),coverImage:item.PrimaryImageAspectRatio&&1.4<=item.PrimaryImageAspectRatio}]:[]}function getImageInfos(items,imageOptions,enablePrimaryImageBeforeInherited,allowPrimaryImage){for(var list=[],i=0,length=items.length;i=currentRotatingImages.length&&(force=0),setBackdropImage(currentRotatingImages[currentRotationIndex=force],animationEnabledByCaller),animationEnabledByCaller=!0)}function clearRotation(){rotationInterval&&rotationInterval.destroy(),rotationInterval=null,currentRotatingImages=[],currentRotationIndex=-1}_exports.default={setBackdrops:function(items,options){(items=getImageInfos(items,(options=options||{}).imageOptions,options.enablePrimaryImageBeforeInherited,options.allowPrimaryImage)).length?function(images,enableImageRotation,enableAnimation){!function(a,b){if(a===b)return 1;if(null!=a&&null!=b&&a.length===b.length){for(var i=0;i