define(["loading","connectionManager","globalize","appRouter","emby-input","emby-scroller","material-icons","emby-button"],function(loading,connectionManager,globalize,appRouter){"use strict";function showAlert(input,thenFn){require(["alert"],function(alert){var promise=alert(input);thenFn&&promise.then(thenFn)})}return function(view,params){var greWidgetId;view.querySelector(".btnCancelSignup").addEventListener("click",function(){appRouter.back()}),view.querySelector("form").addEventListener("submit",function(e){loading.show();var greResponse=greWidgetId?grecaptcha.getResponse(greWidgetId):null;return function(view,greResponse){var submitData={email:view.querySelector("#txtSignupEmail",view).value,username:view.querySelector("#txtSignupUsername",view).value,password:view.querySelector("#txtSignupPassword",view).value,passwordConfirm:view.querySelector("#txtSignupPasswordConfirm",view).value};greResponse&&(submitData.grecaptcha=greResponse),connectionManager.signupForConnect(submitData).then(function(response){loading.hide(),showAlert({text:response.Validated?globalize.translate("MessageThankYouForConnectSignUpNoValidation"):globalize.translate("MessageThankYouForConnectSignUp")},function(){appRouter.showConnectLogin()})},function(result){loading.hide(),"passwordmatch"===result.errorCode?showAlert({text:globalize.translate("ErrorMessagePasswordNotMatchConfirm")}):"USERNAME_IN_USE"===result.errorCode?showAlert({text:globalize.translate("ErrorMessageUsernameInUse")}):"EMAIL_IN_USE"===result.errorCode?showAlert({text:globalize.translate("ErrorMessageEmailInUse")}):showAlert({text:globalize.translate("DefaultErrorMessage")})})}(view,greResponse),e.preventDefault(),e.stopPropagation(),!1}),0===window.location.href.toLowerCase().indexOf("https://")&&require(["https://www.google.com/recaptcha/api.js?render=explicit"],function(){setTimeout(function(){var recaptchaContainer=view.querySelector(".recaptchaContainer");greWidgetId=grecaptcha.render(recaptchaContainer,{sitekey:"6Le2LAgTAAAAAK06Wvttt_yUnbISTy6q3Azqp9po",theme:"dark"})},100)})}});