define(["globalize","connectionManager","appRouter","emby-scroller","emby-input","emby-button"],function(globalize,connectionManager,appRouter){"use strict";function onBackClick(){appRouter.back()}function alertText(options){require(["alert"],function(alert){alert(options)})}function processForgotPasswordResult(result){if("ContactAdmin"!==result.Action)if("InNetworkRequired"!==result.Action){if("PinCode"===result.Action){var msg=globalize.translate("ForgotPasswordFileCreated");return msg+="<br/>",msg+="<br/>",msg+=result.PinFile,void alertText({html:msg+="<br/>",title:globalize.translate("HeaderForgotPassword")})}}else alertText({text:globalize.translate("ForgotPasswordInNetworkRequired"),title:globalize.translate("HeaderForgotPassword")});else alertText({text:globalize.translate("ContactAdminToResetPassword"),title:globalize.translate("HeaderForgotPassword")})}return function(view,params){view.querySelector(".btnCancel").addEventListener("click",onBackClick),view.querySelector("form").addEventListener("submit",function(e){var apiClient=connectionManager.getApiClient(params.serverId);return apiClient.ajax({type:"POST",url:apiClient.getUrl("Users/ForgotPassword"),dataType:"json",data:{EnteredUsername:view.querySelector("#txtName").value}}).then(processForgotPasswordResult),e.preventDefault(),!1})}});