1import{_ as I}from"./6HuN2jx9.js";import{_ as q}from"./DnMM_Yjt.js";import{u as F,d as M,s as D,z as L,g as e,e as c,f as _,h as t,t as l,i as b,l as R,k as O,j as g,E as k,K as x,L as $,D as C,M as S,r as A,p as U}from"./CFxGRstO.js";import{y as G}from"./C97LyYTF.js";import{c as j,a as N,u as z,b as T}from"./CgWzIhW9.js";import{i as H}from"./Dhu0ts9N.js";import{_ as Y}from"./DlAUqK2U.js";import{_ as K}from"./CR0-Au_c.js";import"./Cpj98o6Y.js";import"./B2a-ywG8.js";import"./BWBHGvIx.js";import"./-vsEa_js.js";const{addCustomEmailValidator:P}=G();P();function Q(){const{t:i}=F(),s=i("validation.email.enter_valid");return j({email:N().required(s).email(s),reason:N().required(i("validation.reason.required")).min(10,i("validation.reason.too_short")).max(500,i("validation.reason.too_long"))})}const W={key:0,class:"tw-mx-auto"},J={class:"tw-text-h4 !tw-text-yellow !tw-mb-4 tw-text-center password-form-header"},X={class:"sign-in-block tw-mx-auto tw-text-center tw-w-5/12"},Z={key:1,class:"tw-mx-auto"},ee={class:"tw-text-h4 !tw-text-yellow !tw-mb-4 tw-text-center password-form-header"},te={class:"sign-in-block tw-mx-auto"},ae={class:"tw-mb-4"},oe={class:"tw-mb-4"},ne={for:"current-email",class:"form-label"},se=["value"],le={class:"tw-mb-4"},ie={for:"newEmail",class:"form-label"},re=["disabled"],me={key:0,class:"error-msg invalid-feedback"},ce={class:"tw-mb-4"},de={for:"reason",class:"form-label"},_e=["disabled"],ue={key:0,class:"error-msg invalid-feedback"},pe={class:"tw-flex tw-flex-col lg:tw-flex-row-reverse tw-gap-2 tw-py-2 tw-my-4"},fe=M({__name:"EmailChangeForm",props:{backRoute:{}},setup(i){const{t:s}=F(),r=A(),u=A(!1),p=D().user?.email,{isSubmitting:f,errors:m,setFieldError:v,handleSubmit:V,meta:B}=z({validationSchema:Q()}),{value:h}=T("email"),{value:w}=T("reason"),E=V(async n=>{const a={EMAIL_NOT_CHANGED:s("validation.email.not_changed"),TOO_MANY_EMAIL_CHANGE_REQUESTS:s("validation.email.too_many_requests"),EMAIL_IS_ALREADY_REGISTERED:s("validation.email.already_exists"),1:s("validation.password.wrong_current")};if(r.value="",L("change_email_banned").value)return r.value=s("validation.email.too_many_requests"),!1;const d={...n};if(d.email===p)return v("email",s("validation.email.must_be_different")),!1;const o=await $fetch("/api/account/change-email",{method:"POST",body:d});o.success?(r.value="",u.value=!0):o.error_code&&(r.value=a[o.error_code])});return(n,a)=>{const y=I,d=q;return e(u)?(c(),_("div",W,[t("h1",J,l(n.$t("account.profile.change_email_form.sent")),1),t("div",X,[b(y,{to:i.backRoute,class:"btn btn-md btn-primary btn-spinner ripple"},{default:R(()=>[O(l(n.$t("account.profile.change_email_form.back_to_profile")),1)]),_:1},8,["to"])])])):(c(),_("div",Z,[t("h1",ee,l(n.$t("account.profile.change_email_form.title")),1),t("div",te,[e(r)?(c(),_("div",{key:0,class:"alert alert-danger tw-text-center",role:"alert",onClick:a[0]||(a[0]=o=>r.value="")},[t("b",null,l(n.$t("account.profile.change_email_form.failed")),1),t("p",ae,l(e(r)),1)])):g("",!0),t("form",{onSubmit:a[6]||(a[6]=k((...o)=>e(E)&&e(E)(...o),["prevent"]))},[t("div",null,[t("div",oe,[t("label",ne,l(n.$t("account.profile.change_email_form.current_email_label")),1),t("input",{id:"current-email",value:e(p),readonly:!0,disabled:!0,type:"email",class:"form-control"},null,8,se)]),t("div",le,[t("label",ie,l(n.$t("account.profile.change_email_form.new_email_label")),1),x(t("input",{id:"newEmail","onUpdate:modelValue":a[1]||(a[1]=o=>S(h)?h.value=o:null),disabled:e(f),class:C([[e(m).email&&"is-invalid"],"form-control form-control"]),type:"email",onFocus:a[2]||(a[2]=o=>e(v)("email",""))},null,42,re),[[$,e(h)]]),e(m).email?(c(),_("div",me,l(e(m).email),1)):g("",!0)]),t("div",ce,[t("label",de,l(n.$t("account.profile.change_email_form.reason_label")),1),x(t("textarea",{id:"reason","onUpdate:modelValue":a[3]||(a[3]=o=>S(w)?w.value=o:null),class:C([[e(m).reason&&"is-invalid"],"form-control form-control"]),disabled:e(f),onFocus:a[4]||(a[4]=o=>e(v)("reason",""))},null,42,_e),[[$,e(w)]]),e(m).reason?(c(),_("div",ue,l(e(m).reason),1)):g("",!0)])]),t("div",pe,[b(d,{label:n.$t("account.profile.change_email_form.request_button"),class:"btn btn-md btn-primary btn-spinner",type:"submit",disabled:e(f)||!e(H)(e(m))&&e(B).touched,loading:e(f)},null,8,["label","disabled","loading"]),b(d,{label:n.$t("account.profile.change_email_form.back_to_profile"),class:"btn btn-md btn-outline-primary btn-spinner ripple tw-flex-1",onClick:a[5]||(a[5]=k(o=>n.$router.push(i.backRoute),["prevent"]))},null,8,["label"])])],32)])]))}}}),be=Object.assign(Y(fe,[["__scopeId","data-v-5ed0c7b7"]]),{__name:"AccountEmailChangeForm"}),Ne=M({__name:"change-email",setup(i){return(s,r)=>{const u=be,p=K;return c(),U(p,null,{default:R(()=>[b(u,{"back-route":"/account/profile"})]),_:1})}}});
1export{Ne as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.