define(["exports","./../loading/loading.js","./globalize.js"],function(_exports,_loading,_globalize){function ResponseHelper(){}function showAlertAndReject(options,response){function onDone(){return Promise.reject(response)}return function(options){return Emby.importModule("./modules/common/dialogs/alert.js").then(function(alert){return alert(options)})}(options).then(onDone,onDone)}function getErrorInfo(response){var errorCode=response.errorCode||response,errorTitle=response.errorTitle;switch(errorCode){case"noitems":return Promise.resolve({text:_globalize.default.translate("NoSelectedItemsSupportOperation"),response:response});case"nocommands":return Promise.resolve({text:_globalize.default.translate("NoOperationsForSelectedItems"),response:response});case"RateLimitExceeded":return Promise.resolve({title:errorTitle||_globalize.default.translate("HeaderPlaybackError"),text:_globalize.default.translate("RateLimitExceeded"),response:response});case"NoPlayableItems":case"NoCompatibleStream":case"PlaceHolder":return Promise.resolve({title:errorTitle||_globalize.default.translate("HeaderPlaybackError"),text:_globalize.default.translate("PlaybackError"+errorCode),response:response})}errorTitle||401===response.status&&(errorTitle=_globalize.default.translate("HeaderSignInError"));var msg=[];return response.errorMessagePreamble&&msg.push(response.errorMessagePreamble),response.text?response.text().then(function(responseText){return responseText&&msg.push(responseText),{title:errorTitle||_globalize.default.translate("Error"),text:msg.join("\n\n")||_globalize.default.translate("DefaultErrorMessage"),html:msg.join("<br/><br/>")||_globalize.default.translate("DefaultErrorMessage"),response:response,centerText:msg.length<2}}):Promise.resolve({title:errorTitle||_globalize.default.translate("Error"),text:msg.join("\n\n")||_globalize.default.translate("DefaultErrorMessage"),html:msg.join("<br/><br/>")||_globalize.default.translate("DefaultErrorMessage"),response:response,centerText:msg.length<2})}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,ResponseHelper.prototype.handleConfigurationSavedResponse=function(response){var options;return _loading.default.hide(),options=_globalize.default.translate("SettingsSaved"),Emby.importModule("./modules/toast/toast.js").then(function(toast){toast(options)}),Promise.resolve(response)},ResponseHelper.prototype.getErrorInfo=getErrorInfo,ResponseHelper.prototype.handleErrorResponse=function(response){return _loading.default.hide(),console.log((response||"Error")+" - "+(new Error).stack),getErrorInfo(response).then(function(errorInfo){return showAlertAndReject(errorInfo)})};_exports.default=new ResponseHelper});