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