import{S as u,P as Y,M as E,T as d,X as V,W as N,V as s,K as ee,Z as ae,aa as le,B as te,at as oe,aB as se,as as v,ar as ne,L as ce,U as i,aA as ue,b as a,az as y}from"./vendor-bSWkQivH.js";import{e as re,Q as de,O as me,h as ie,ba as pe,bO as fe,g as q,i as ge,bb as be,r as _e,s as ve}from"./index-Dqv5IkpS.js";const ye={};function Ce(p,U){const o=u("VcButton"),h=u("VcModal");return E(),Y(h,{variant:"success",title:p.$t("shared.account.profile_update_success_modal.title"),icon:"apply"},{actions:d(({close:r})=>[s(o,{class:"mx-auto",onClick:r},{default:d(()=>[V(N(p.$t("shared.account.profile_update_success_modal.ok_button")),1)]),_:2},1032,["onClick"])]),default:d(()=>[V(" "+N(p.$t("shared.account.profile_update_success_modal.message")),1)]),_:1},8,["title"])}const Ve=re(ye,[["render",Ce]]),Ne={class:"flex gap-4"},he={class:"grow"},$e={class:"grow"},Le={class:"mt-5 w-1/2 self-center lg:self-auto"},C=64,Se=ee({__name:"profile",setup(p){const{t:U}=ae(),{user:o,updateUser:h}=de(),{themeContext:r}=me(),{openModal:F}=ie(),{currentLanguage:A,removeLocaleFromUrl:P,unpinLocale:W}=pe(),{currentCurrency:z,supportedCurrencies:D,saveCurrencyCode:H}=be(),{mutate:O}=le(fe),X=_e(),{storeId:G,cultureName:K}=q;ge({title:te(()=>U("pages.account.profile.meta.title"))});const Q=oe(se({firstName:v().trim().required().max(C),lastName:v().trim().required().max(C),defaultLanguage:v(),currencyCode:v()}));function T(){var e,l,c,n,m,b,_,t,x,I;return{firstName:((e=o.value.contact)==null?void 0:e.firstName)??"",lastName:((l=o.value.contact)==null?void 0:l.lastName)??"",defaultLanguage:((n=(c=o.value)==null?void 0:c.contact)==null?void 0:n.defaultLanguage)??((b=(m=r.value)==null?void 0:m.defaultLanguage)==null?void 0:b.cultureName),currencyCode:((t=(_=o.value)==null?void 0:_.contact)==null?void 0:t.currencyCode)??((I=(x=r.value)==null?void 0:x.defaultCurrency)==null?void 0:I.code)}}const{defineField:f,errors:g,isSubmitting:$,meta:L,handleSubmit:R,resetForm:Z}=ne({validationSchema:Q,initialValues:T()}),[w]=f("firstName"),[B]=f("lastName"),[S]=f("defaultLanguage"),[M]=f("currencyCode");function j(){W(),P()}async function J(){var e,l;if((l=(e=o.value)==null?void 0:e.contact)!=null&&l.currencyCode){await O({command:{storeId:G,userId:o.value.id,newCurrencyCode:o.value.contact.currencyCode,cultureName:K,currencyCode:q.currencyCode}});const c=D.value.find(n=>n.code===o.value.contact.currencyCode);c&&H(c.code,!1)}}const k=R(async e=>{await h(e),Z({values:T()}),F({component:Ve,props:{async onClose(){A.value.cultureName!==e.defaultLanguage&&j(),z.value.code!==e.currencyCode&&await J(),X.emit(ve),location.reload()}}})});return(e,l)=>{const c=u("VcTypography"),n=u("VcInput"),m=u("VcSelect"),b=u("VcButton"),_=u("VcWidget");return E(),ce("div",null,[s(c,{tag:"h1"},{default:d(()=>[V(N(e.$t("pages.account.profile.title")),1)]),_:1}),s(_,{size:"lg",class:"polygon-bg [--polygon-bg-position:right_bottom_-180px]"},{default:d(()=>[i("form",{class:"flex flex-col lg:w-1/2",onSubmit:l[4]||(l[4]=ue((...t)=>a(k)&&a(k)(...t),["prevent"]))},[s(n,{modelValue:a(w),"onUpdate:modelValue":l[0]||(l[0]=t=>y(w)?w.value=t:null),label:e.$t("common.labels.first_name"),placeholder:e.$t("common.placeholders.first_name"),disabled:a($),maxlength:C,message:a(g).firstName,error:!!a(g).firstName,name:"firstName",class:"mb-5",required:""},null,8,["modelValue","label","placeholder","disabled","message","error"]),s(n,{modelValue:a(B),"onUpdate:modelValue":l[1]||(l[1]=t=>y(B)?B.value=t:null),label:e.$t("common.labels.last_name"),placeholder:e.$t("common.placeholders.first_name"),disabled:a($),maxlength:C,message:a(g).lastName,error:!!a(g).lastName,name:"lastName",class:"mb-5",required:""},null,8,["modelValue","label","placeholder","disabled","message","error"]),s(n,{"model-value":a(o).email,label:e.$t("common.labels.email"),placeholder:e.$t("common.placeholders.first_name"),name:"email",autocomplete:"off",class:"mb-5",disabled:""},null,8,["model-value","label","placeholder"]),i("div",Ne,[i("div",he,[s(m,{modelValue:a(S),"onUpdate:modelValue":l[2]||(l[2]=t=>y(S)?S.value=t:null),items:a(r).availableLanguages,label:e.$t("common.labels.default_language"),"text-field":"nativeName","value-field":"cultureName"},null,8,["modelValue","items","label"])]),i("div",$e,[s(m,{modelValue:a(M),"onUpdate:modelValue":l[3]||(l[3]=t=>y(M)?M.value=t:null),items:a(r).availableCurrencies,label:e.$t("common.labels.default_currency"),"text-field":"code","value-field":"code"},null,8,["modelValue","items","label"])])]),i("div",Le,[s(b,{disabled:!a(L).dirty||!a(L).valid||a(L).pending,loading:a($),type:"submit",class:"w-full lg:w-48"},{default:d(()=>[V(N(e.$t("common.buttons.update")),1)]),_:1},8,["disabled","loading"])])],32)]),_:1})])}}});export{Se as default};
//# sourceMappingURL=profile-DDc7aDpE.js.map
