define(["./../modules/dom.js","./../modules/common/globalize.js","./../modules/loading/loading.js","./../modules/common/responsehelper.js","./../modules/common/pluginmanager.js"],function(_dom,_globalize,_loading,_responsehelper,_pluginmanager){function getWindowLocationSearch(win){var index,win=(win||globalThis).location.search;return win||-1!==(index=globalThis.location.href.indexOf("?"))&&(win=globalThis.location.href.substring(index)),win||""}globalThis.getWindowLocationSearch=getWindowLocationSearch,globalThis.getParameterByName=function(name,url){name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");name=new RegExp("[\\?&]"+name+"=([^&#]*)","i").exec(url||getWindowLocationSearch());return null==name?"":decodeURIComponent(name[1].replace(/\+/g," "))};var Dashboard=globalThis.Dashboard||(globalThis.Dashboard={});Dashboard.confirm=function(message,title,callback){var options;options=message,Emby.importModule("./modules/common/dialogs/confirm.js").then(function(confirm){return confirm(options)}).then(function(){callback(!0)},function(){callback(!1)})},Dashboard.showLoadingMsg=function(){_loading.default.show()},Dashboard.hideLoadingMsg=function(){_loading.default.hide()},Dashboard.getCurrentUser=function(){return ApiClient.getCurrentUser()},Dashboard.getCurrentUserId=function(){return ApiClient.getCurrentUserId()},Dashboard.navigate=function(url,preserveQueryString){var queryString;if(url)return queryString=getWindowLocationSearch(),preserveQueryString&&queryString&&(url+=queryString),Emby.importModule("./modules/approuter.js").then(function(appRouter){return appRouter.show(url)});throw new Error("url cannot be null or empty")},Dashboard.processPluginConfigurationUpdateResult=function(){_loading.default.hide(),_responsehelper.default.handleConfigurationSavedResponse()},Dashboard.getConfigurationPageUrl=function(name){return _pluginmanager.default.getConfigurationPageUrl(name)},Dashboard.getConfigurationResourceUrl=function(name){return _pluginmanager.default.getConfigurationResourceUrl(name)},Dashboard.alert=function(options){"string"==typeof options?function(options){Emby.importModule("./modules/toast/toast.js").then(function(toast){return toast(options)})}({text:options}):function(options){return Emby.importModule("./modules/common/dialogs/alert.js").then(function(alert){return alert(options)})}({title:options.title||_globalize.default.translate("HeaderAlert"),text:options.message}).then(options.callback||function(){})},Dashboard.processServerConfigurationUpdateResult=function(response){return _responsehelper.default.handleConfigurationSavedResponse(response)},Dashboard.processErrorResponse=function(response){return _responsehelper.default.handleErrorResponse(response)},globalThis.pageClassOn=function(eventName,className,fn){document.addEventListener(eventName,function(e){var target=e.target;target.classList.contains(className)&&fn.call(target,e)})},globalThis.pageIdOn=function(eventName,id,fn){document.addEventListener(eventName,function(e){var target=e.target;target.id===id&&fn.call(target,e)})},_dom.default.parentWithClass=function(elem,classNames){return Array.isArray(classNames)?elem.closest("."+classNames.join(",.")):elem.closest("."+classNames)}});