functiongetWindowLocationSearch(win){"use strict";varsearch=(win||window).location.search;if(!search){varindex=window.location.href.indexOf("?");index!=-1&&(search=window.location.href.substring(index))}returnsearch||""}functiongetParameterByName(name,url){"use strict";name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");varregexS="[\\?&]"+name+"=([^&#]*)",regex=newRegExp(regexS,"i"),results=regex.exec(url||getWindowLocationSearch());returnnull==results?"":decodeURIComponent(results[1].replace(/\+/g," "))}functionpageClassOn(eventName,className,fn){"use strict";document.addEventListener(eventName,function(e){vartarget=e.target;target.classList.contains(className)&&fn.call(target,e)})}functionpageIdOn(eventName,id,fn){"use strict";document.addEventListener(eventName,function(e){vartarget=e.target;target.id==id&&fn.call(target,e)})}varDashboard={isConnectMode:function(){if(AppInfo.isNativeApp)return!0;varurl=window.location.href.toLowerCase();returnurl.indexOf("mediabrowser.tv")!=-1||url.indexOf("emby.media")!=-1},isRunningInCordova:function(){return"cordova"==window.appMode},getCurrentUser:function(){returnwindow.ApiClient.getCurrentUser(!1)},serverAddress:function(){if(Dashboard.isConnectMode()){varapiClient=window.ApiClient;returnapiClient?apiClient.serverAddress():null}varurlLower=window.location.href.toLowerCase(),index=urlLower.lastIndexOf("/web");if(index!=-1)returnurlLower.substring(0,index);varloc=window.location,address=loc.protocol+"//"+loc.hostname;returnloc.port&&(address+=":"+loc.port),address},getCurrentUserId:function(){varapiClient=window.ApiClient;returnapiClient?apiClient.getCurrentUserId():null},onServerChanged:function(userId,accessToken,apiClient){apiClient=apiClient||window.ApiClient,window.ApiClient=apiClient},logout:function(logoutWithServer){functiononLogoutDone(){varloginPage;Dashboard.isConnectMode()?(loginPage="connectlogin.html",window.ApiClient=null):loginPage="login.html",Dashboard.navigate(loginPage)}logoutWithServer===!1?onLogoutDone():ConnectionManager.logout().then(onLogoutDone)},getConfigurationPageUrl:function(name){return"configurationpage?name="+encodeURIComponent(name)},navigate:function(url,preserveQueryString){if(!url)thrownewError("url cannot be null or empty");varqueryString=getWindowLocationSearch();returnpreserveQueryString&&queryString&&(url+=queryString),newPromise(function(resolve,reject){require(["appRouter"],function(appRouter){returnappRouter.show(url).then(resolve,reject)})})},processPluginConfigurationUpdateResult:function(){require(["loading","toast"],function(loading,toast){loading.hide(),toast(Globalize.translate("MessageSettingsSaved"))})},processServerConfigurationUpdateResult:function(result){require(["loading","toast"],function(loading,toast){loading.hide(),toast(Globalize.translate("MessageSettingsSaved"))})},processErrorResponse:function(response){require(["loading"],function(loading){loading.hide()});varstatus=""+response.status;response.statusText&&(status=response.statusText),Dashboard.alert({title:status,message:response.headers?response.headers.get("X-Application-Error-Code"):null})},alert:function(options){return"string"==typeofoptions?voidrequire(["toast"],function(toast){toast({text:options})}):voidrequire(["alert"],function(alert){alert({title:options.title||Globalize.translate("HeaderAlert"),text:options.message}).then(options.callback||function(){})})},restartServer:function(){varapiClient=window.ApiClient;apiClient&&(Dashboard.suppressAjaxErrors=!0,require(["loading"],function(loading){loading.show()}),apiClient.restartServer().then(function(){setTimeout(function(){Dashboard.reloadPageWhenServerAvailable()},250)},function(){Dashboard.suppressAjaxErrors=!1}))},reloadPageWhenServerAvailable:function(retryCount){varapiClient=window.ApiClient;apiClient&&apiClient.getJSON(apiClient.getUrl("System/Info")).then(function(info){info.HasPendingRestart?Dashboard.retryReload(retryCount):window.location.reload(!0)},function(){Dashboard.retryReload(retryCount)})},retryReload:function(retryCount){setTimeout(function(){retry
Dashboard.navigate("home.html?tab=1")},appRouter.showSettings=function(){Dashboard.navigate("mypreferencesmenu.html")},appRouter.showNowPlaying=function(){Dashboard.navigate("nowplaying.html")},appRouter.setTitle=function(title){LibraryMenu.setTitle(title)},appRouter.getRouteUrl=function(item,options){if(!item)thrownewError("item cannot be null");if(item.url)returnitem.url;varcontext=options?options.context:null,topParentId=options?options.topParentId||options.parentId:null;if("string"==typeofitem){if("downloads"===item)return"offline/offline.html";if("downloadsettings"===item)return"mysyncsettings.html";if("managedownloads"===item)return"managedownloads.html";if("manageserver"===item)return"dashboard.html";if("recordedtv"===item)return"livetv.html?tab=3&serverId="+options.serverId;if("nextup"===item)return"secondaryitems.html?type=nextup&serverId="+options.serverId;if("livetv"===item)return"guide"===options.section?"livetv.html?tab=1&serverId="+options.serverId:"movies"===options.section?"livetvitems.html?type=Programs&IsMovie=true&serverId="+options.serverId:"shows"===options.section?"livetvitems.html?type=Programs&IsSeries=true&IsMovie=false&IsNews=false&serverId="+options.serverId:"sports"===options.section?"livetvitems.html?type=Programs&IsSports=true&serverId="+options.serverId:"kids"===options.section?"livetvitems.html?type=Programs&IsKids=true&serverId="+options.serverId:"news"===options.section?"livetvitems.html?type=Programs&IsNews=true&serverId="+options.serverId:"onnow"===options.section?"livetvitems.html?type=Programs&IsAiring=true&serverId="+options.serverId:"dvrschedule"===options.section?"livetv.html?tab=4&serverId="+options.serverId:"livetv.html?serverId="+options.serverId}varurl,id=item.Id||item.ItemId,itemType=item.Type||(options?options.itemType:null),serverId=item.ServerId||options.serverId;if("SeriesTimer"==itemType)return"itemdetails.html?seriesTimerId="+id+"&serverId="+serverId;if("livetv"==item.CollectionType)return"livetv.html";if("channels"==item.CollectionType)return"channels.html";if("folders"===context||itemHelper.isLocalItem(item)){if(item.IsFolder&&"BoxSet"!=itemType&&"Series"!=itemType)returnid?"itemlist.html?parentId="+id+"&serverId="+serverId:"#"}else{if("movies"==item.CollectionType)returnurl="movies.html?topParentId="+item.Id,options&&"latest"===options.section&&(url+="&tab=1"),url;if("boxsets"==item.CollectionType)return"itemlist.html?topParentId="+item.Id+"&parentId="+item.Id+"&serverId="+serverId;if("tvshows"==item.CollectionType)returnurl="tv.html?topParentId="+item.Id,options&&"latest"===options.section&&(url+="&tab=2"),url;if("music"==item.CollectionType)return"music.html?topParentId="+item.Id;if("games"==item.CollectionType)returnid?"itemlist.html?parentId="+id+"&serverId="+serverId:"#";if("playlists"==item.CollectionType)return"playlists.html?topParentId="+item.Id;if("photos"==item.CollectionType)return"photos.html?topParentId="+item.Id}if("CollectionFolder"==itemType)return"itemlist.html?topParentId="+item.Id+"&parentId="+item.Id+"&serverId="+serverId;if("PhotoAlbum"==itemType)return"itemlist.html?context=photos&parentId="+id+"&serverId="+serverId;if("Playlist"==itemType)return"itemdetails.html?id="+id+"&serverId="+serverId;if("TvChannel"==itemType)return"itemdetails.html?id="+id+"&serverId="+serverId;if("Channel"==itemType)return"channelitems.html?id="+id+"&serverId="+serverId;if(item.IsFolder&&"Channel"==item.SourceType||"ChannelFolderItem"==itemType)return"channelitems.html?id="+item.ChannelId+"&folderId="+item.Id;if("Program"==itemType)return"itemdetails.html?id="+id+"&serverId="+serverId;if("BoxSet"==itemType)return"itemdetails.html?id="+id+"&serverId="+serverId;if("MusicAlbum"==itemType)return"itemdetails.html?id="+id+"&serverId="+serverId;if("GameSystem"==itemType)return"itemdetails.html?id="+id+"&serverId="+serverId;if("Genre"==itemType){vartype;switch(context){case"tvshows":type="Series";break;case"games":type="Game";break;default:type="Movie"}returnurl="secondaryitems.html?type="+type+"&genreId="+id+"&serverId="+serverId,topParentId&&(url+="&parentId="+