import{C as e,E as t,Ht as n,Lt as r,Q as i,R as a,W as o,_ as s,d as c,g as l,gt as u,lt as d,ut as f,v as p,w as m,y as h}from"./vue.runtime.esm-bundler-56z_v_HH.js";import{t as g}from"./store-DIrP_oUf.js";import{n as _}from"./vue-i18n-DhldrKy8.js";import{A as v,D as y,M as b,O as x,P as S,T as C}from"./main-CkEZzrzw.js";var w={class:`text-sm leading-snug text-muted`,style:{"max-width":`680px`}},T={class:`grid gap-6 sm:grid-col-1 md:grid-cols-2 mt-6`},E=t({__name:`CustomerSettingsView`,setup(t){let E=g(),{t:D,tm:O}=_(),k=f([]),A=f(!1),j=f(null),M=f(!1),N=f(!1),P=f(!1),F=d({name:E.userForm.name,email:E.userForm.email,password:``,confirm_password:``});typeof E.userForm.avatar==`string`&&E.userForm.avatar&&k.value.push({image:E.userForm.avatar});let I=C(l(()=>({name:{required:y.withMessage(D(`validation.required`),b),minLength:y.withMessage(D(`validation.name_min_length`,{count:3}),v(3))},email:{required:y.withMessage(D(`validation.required`),b),email:y.withMessage(D(`validation.email_incorrect`),x)},password:{minLength:y.withMessage(D(`validation.password_min_length`,{count:8}),v(8))},confirm_password:{sameAsPassword:y.withMessage(D(`validation.password_incorrect`),S(F.password))}})),F);function L(e,t){j.value=t}function R(){j.value=null,P.value=!0}async function z(){if(I.value.$touch(),I.value.$invalid)return;A.value=!0;let e=new FormData;e.append(`name`,F.name),e.append(`email`,F.email),F.password&&e.append(`password`,F.password),j.value&&e.append(`customer_avatar`,j.value),e.append(`is_customer_avatar_removed`,String(P.value));try{(await E.updateCurrentUser(e)).data.data&&(F.password=``,F.confirm_password=``,j.value=null,P.value=!1)}finally{A.value=!1}}return(t,l)=>{let d=o(`BaseBreadcrumbItem`),f=o(`BaseBreadcrumb`),g=o(`BasePageHeader`),_=o(`BaseFileUploader`),v=o(`BaseInputGroup`),y=o(`BaseInput`),b=o(`BaseIcon`),x=o(`BaseButton`),S=o(`BaseCard`),C=o(`BasePage`);return a(),p(C,null,{default:i(()=>[m(g,{title:t.$t(`settings.account_settings.account_settings`)},{default:i(()=>[m(f,null,{default:i(()=>[m(d,{title:t.$t(`general.home`),to:`/${u(E).companySlug}/customer/dashboard`},null,8,[`title`,`to`]),m(d,{title:t.$t(`settings.account_settings.account_settings`),to:`#`,active:``},null,8,[`title`])]),_:1})]),_:1},8,[`title`]),s(`form`,{onSubmit:c(z,[`prevent`])},[m(S,null,{default:i(()=>[s(`p`,w,n(t.$t(`settings.account_settings.section_description`)),1),s(`div`,T,[m(v,{label:t.$t(`settings.account_settings.profile_picture`)},{default:i(()=>[m(_,{modelValue:k.value,"onUpdate:modelValue":l[0]||=e=>k.value=e,avatar:!0,accept:`image/*`,onChange:L,onRemove:R},null,8,[`modelValue`])]),_:1},8,[`label`]),l[11]||=s(`span`,null,null,-1),m(v,{label:t.$t(`settings.account_settings.name`),error:u(I).name.$error?String(u(I).name.$errors[0]?.$message):void 0,required:``},{default:i(()=>[m(y,{modelValue:F.name,"onUpdate:modelValue":l[1]||=e=>F.name=e,invalid:u(I).name.$error,onInput:l[2]||=e=>u(I).name.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`label`,`error`]),m(v,{label:t.$t(`settings.account_settings.email`),error:u(I).email.$error?String(u(I).email.$errors[0]?.$message):void 0,required:``},{default:i(()=>[m(y,{modelValue:F.email,"onUpdate:modelValue":l[3]||=e=>F.email=e,invalid:u(I).email.$error,onInput:l[4]||=e=>u(I).email.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`label`,`error`]),m(v,{error:u(I).password.$error?String(u(I).password.$errors[0]?.$message):void 0,label:t.$t(`settings.account_settings.password`)},{default:i(()=>[m(y,{modelValue:F.password,"onUpdate:modelValue":l[6]||=e=>F.password=e,type:M.value?`text`:`password`,invalid:u(I).password.$error,onInput:l[7]||=e=>u(I).password.$touch()},{right:i(()=>[m(b,{name:M.value?`EyeIcon`:`EyeSlashIcon`,class:`mr-1 text-muted cursor-pointer`,onClick:l[5]||=e=>M.value=!M.value},null,8,[`name`])]),_:1},8,[`modelValue`,`type`,`invalid`])]),_:1},8,[`error`,`label`]),m(v,{label:t.$t(`settings.account_settings.confirm_password`),error:u(I).confirm_password.$error?String(u(I).confirm_password.$errors[0]?.$message):void 0},{default:i(()=>[m(y,{modelValue:F.confirm_password,"onUpdate:modelValue":l[9]||=e=>F.confirm_password=e,type:N.value?`text`:`password`,invalid:u(I).confirm_password.$error,onInput:l[10]||=e=>u(I).confirm_password.$touch()},{right:i(()=>[m(b,{name:N.value?`EyeIcon`:`EyeSlashIcon`,class:`mr-1 text-muted cursor-pointer`,onClick:l[8]||=e=>N.value=!N.value},null,8,[`name`])]),_:1},8,[`modelValue`,`type`,`invalid`])]),_:1},8,[`label`,`error`])]),m(x,{loading:A.value,disabled:A.value,class:`mt-6`},{left:i(e=>[A.value?h(``,!0):(a(),p(b,{key:0,name:`ArrowDownOnSquareIcon`,class:r(e.class)},null,8,[`class`]))]),default:i(()=>[e(` `+n(t.$t(`general.save`)),1)]),_:1},8,[`loading`,`disabled`])]),_:1})],32)]),_:1})}}});export{E as default};