import{U as n,R as J,O as k,V as u,Z as v,Y as _,X as s,M as K,$ as Q,aa as ee,E as ae,av as le,aC as te,au as p,at as oe,N as se,W as r,aB as ne,e,az as f}from"./vendor-CsGITfgk.js";import{d as ce,a4 as ue,a3 as re,e as de,bj as me,g as U,f as ie,cq as pe,o as fe,q as ge,cr as ve}from"./index-CsCqMgta.js";const _e={};function be(d,w){const t=n("VcButton"),b=n("VcModal");return k(),J(b,{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(()=>[v(_(d.$t("shared.account.profile_update_success_modal.ok_button")),1)]),_:1},8,["onClick"])]),default:u(()=>[v(" "+_(d.$t("shared.account.profile_update_success_modal.message")),1)]),_:1},8,["title"])}const Ce=ce(_e,[["render",be]]),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=K({__name:"profile",setup(d){const{t:w}=Q(),{user:t,updateUser:b}=ue(),{themeContext:c}=re(),{openModal:q}=de(),{currentLanguage:T,removeLocaleFromUrl:x,unpinLocale:E}=me(),{currentCurrency:I,supportedCurrencies:F,saveCurrencyCode:W}=pe(),{mutate:z}=ee(ve),A=fe(),{storeId:D,cultureName:H}=U;ie({title:ae(()=>w("pages.account.profile.meta.title"))});const P=le(te({firstName:p().trim().required().max(g),lastName:p().trim().required().max(g),defaultLanguage:p(),currencyCode:p()}));function B(){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:R,resetForm:X}=oe({validationSchema:P,initialValues:B()}),[V]=m("firstName"),[N]=m("lastName"),[h]=m("defaultLanguage"),[$]=m("currencyCode");function j(){E(),x()}async function G(){if(t.value?.contact?.currencyCode){await z({command:{storeId:D,userId:t.value.id,newCurrencyCode:t.value.contact.currencyCode,cultureName:H,currencyCode:U.currencyCode}});const a=F.value.find(l=>l.code===t.value.contact.currencyCode);a&&W(a.code,!1)}}const M=R(async a=>{await b(a),X({values:B()}),q({component:Ce,props:{async onClose(){T.value.cultureName!==a.defaultLanguage&&j(),I.value.code!==a.currencyCode&&await G(),A.emit(ge),location.reload()}}})});return(a,l)=>{const O=n("VcTypography"),L=n("VcInput"),S=n("VcSelect"),Y=n("VcButton"),Z=n("VcWidget");return k(),se("div",null,[s(O,{tag:"h1"},{default:u(()=>[v(_(a.$t("pages.account.profile.title")),1)]),_:1}),s(Z,{size:"lg"},{default:u(()=>[r("form",{class:"flex flex-col lg:w-1/2",onSubmit:l[4]||(l[4]=ne((...o)=>e(M)&&e(M)(...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(S,{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(S,{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(Y,{disabled:!e(y).dirty||!e(y).valid||e(y).pending,loading:e(C),type:"submit",class:"w-full lg:w-48"},{default:u(()=>[v(_(a.$t("common.buttons.update")),1)]),_:1},8,["disabled","loading"])])],32)]),_:1})])}}});export{we as default};
//# sourceMappingURL=profile-CWbhfUhw.js.map
