import{r as registerInstance,h}from"./index-102043e0.js";import{T as TextField}from"./index-336ef773.js";import{V as ValidatorEmail}from"./ValidatorEmail-df7a1b77.js";import{V as ValidatorLength}from"./ValidatorLength-f56a7c14.js";import"./BaseField-461b6d0c.js";import"./InterceptorHandler-6474bcf4.js";var formFields=function(r){return[new TextField("firstName","","First name","").setValue(r.firstName).setErrorTitle("Name").require(),new TextField("lastName","","Last name","").setValue(r.lastName).setErrorTitle("Surname").require(),new TextField("email","","Email","","email").setValue(r.email).setErrorTitle("Email").addInterceptor("onSubmit",new ValidatorEmail).require(),new TextField("password","","Password","","password").setErrorTitle("Password").addInterceptor("onSubmit",new ValidatorLength(6,24)).require()]};function getFormErrors(r){if(!r){return undefined}if(r.status===401){return["Credentials are not valid."]}else{return["Unexpected error."]}}var KimlikRegisterForm=function(){function r(r){var e=this;registerInstance(this,r);this.data={};this.onSubmit=function(r){var t=r.detail.values;var i=t.email,a=t.firstName,s=t.lastName,o=t.password;e.progressing=true;e.api.register(i,a,s,o).then(e.onSucceed,e.onError)};this.onSucceed=function(r){e.api.addAuthInterceptor(r.jwt);e.progressing=false;if(e.onRegister){e.onRegister(r)}if(e.redirect){window.location=e.redirect}};this.onError=function(r){e.error=r;e.progressing=false}}r.prototype.render=function(){var r=this,e=r.data,t=r.error,i=r.progressing;return h("doldurma-form",{fields:formFields(e),onSubmit:this.onSubmit,submitButtonLabel:"Register",progressing:i,formErrors:getFormErrors(t)})};return r}();export{KimlikRegisterForm as kimlik_register_form};