import{N as u,K as Z,E as I,O as d,S as V,R as N,Q as s,C as ee,V as ae,a6 as le,q as te,an as oe,ao as se,ap as v,aq as ne,D as ce,P as i,bg as ue,u as a,at as y}from"./vendor-BGtMsOoo.js";import{e as re,Q as de,O as me,h as ie,bp as pe,bU as fe,g as E,i as ge,bq as be,r as _e,s as ve}from"./index-CRze-aDK.js";const ye={};function Ce(p,U){const o=u("VcButton"),h=u("VcModal");return I(),Z(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,Be=ee({__name:"profile",setup(p){const{t:U}=ae(),{user:o,updateUser:h}=de(),{themeContext:r}=me(),{openModal:F}=ie(),{currentLanguage:D,removeLocaleFromUrl:P,unpinLocale:A}=pe(),{currentCurrency:H,supportedCurrencies:O,saveCurrencyCode:Q}=be(),{mutate:R}=le(fe),W=_e(),{storeId:z,cultureName:G}=E;ge({title:te(()=>U("pages.account.profile.meta.title"))});const K=oe(se({firstName:v().trim().required().max(C),lastName:v().trim().required().max(C),defaultLanguage:v(),currencyCode:v()}));function q(){var e,l,c,n,m,b,_,t,x,T;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)??((T=(x=r.value)==null?void 0:x.defaultCurrency)==null?void 0:T.code)}}const{defineField:f,errors:g,isSubmitting:$,meta:L,handleSubmit:X,resetForm:j}=ne({validationSchema:K,initialValues:q()}),[w]=f("firstName"),[S]=f("lastName"),[B]=f("defaultLanguage"),[M]=f("currencyCode");function J(){A(),P()}async function Y(){var e,l;if((l=(e=o.value)==null?void 0:e.contact)!=null&&l.currencyCode){await R({command:{storeId:z,userId:o.value.id,newCurrencyCode:o.value.contact.currencyCode,cultureName:G,currencyCode:E.currencyCode}});const c=O.value.find(n=>n.code===o.value.contact.currencyCode);c&&Q(c.code,!1)}}const k=X(async e=>{await h(e),j({values:q()}),F({component:Ve,props:{async onClose(){D.value.cultureName!==e.defaultLanguage&&J(),H.value.code!==e.currencyCode&&await Y(),W.emit(ve),location.reload()}}})});return(e,l)=>{const c=u("VcTypography"),n=u("VcInput"),m=u("VcSelect"),b=u("VcButton"),_=u("VcWidget");return I(),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(S),"onUpdate:modelValue":l[1]||(l[1]=t=>y(S)?S.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(B),"onUpdate:modelValue":l[2]||(l[2]=t=>y(B)?B.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{Be as default};
//# sourceMappingURL=profile-9I2bBmx8.js.map
