import{e as h,i as z,A as x,r as F,k as I,Y as O,x as S,m as i,o as f,n as e,w as r,a as p,b as a,C as m,d as u,t as c,_ as P}from"./BoB2h2qv.js";import{_ as k}from"./Bj6F-phl.js";import{_ as T}from"./_43AjLD4.js";import{a as v,b,_ as V}from"./flZqRd3D.js";import{_ as g}from"./BipjDKWG.js";import{M as D}from"./CLJgW9n6.js";import{u as E}from"./Bindkcrd.js";const Y={class:"space-y-4"},q={class:"flex justify-end gap-2"},G=h({__name:"change-password",props:{visible:{type:Boolean}},emits:["update:visible"],setup($,{emit:U}){const{createUser:N}=E(),{t:n}=z(),A=U,s=x({current_secret_key:"",new_secret_key:"",re_new_secret_key:""}),t=x({current_secret_key:"",new_secret_key:"",re_new_secret_key:""}),d=F(!1),w=I(),{$api:M}=O(),C=S({get(){return $.visible},set(o){y(o)}});function B(){s.current_secret_key="",s.new_secret_key="",s.re_new_secret_key="",Object.keys(t).forEach(o=>{t[o]=""})}function y(o=!1){A("update:visible",o),o||(B(),d.value=!1)}function K(){return t.current_secret_key=s.current_secret_key?"":n("Please enter current password"),t.new_secret_key=s.new_secret_key?"":n("Please enter new password"),s.re_new_secret_key?s.re_new_secret_key!==s.new_secret_key?t.re_new_secret_key=n("The two passwords are inconsistent"):t.re_new_secret_key="":t.re_new_secret_key=n("Please enter new password again"),!t.current_secret_key&&!t.new_secret_key&&!t.re_new_secret_key}async function j(){if(!K()){w.error(n("Please fill in the correct format"));return}d.value=!0;try{const o=await M.get("/accountinfo");await N({accessKey:o.account_name,secretKey:s.new_secret_key,status:"enabled"}),w.success(n("Updated successfully")),y()}catch(o){console.error(o),w.error(n("Update failed"))}finally{d.value=!1}}return(o,l)=>(f(),i(D,{modelValue:C.value,"onUpdate:modelValue":l[4]||(l[4]=_=>C.value=_),title:e(n)("Change current account password"),size:"md","close-on-backdrop":!1},{footer:r(()=>[p("div",q,[a(e(P),{variant:"outline",onClick:l[3]||(l[3]=_=>y())},{default:r(()=>[u(c(e(n)("Cancel")),1)]),_:1}),a(e(P),{variant:"default",disabled:d.value,onClick:j},{default:r(()=>[d.value?(f(),i(e(T),{key:0,class:"size-4"})):m("",!0),p("span",null,c(e(n)("Submit")),1)]),_:1},8,["disabled"])])]),default:r(()=>[p("div",Y,[a(e(V),null,{default:r(()=>[a(e(v),{for:"password-current"},{default:r(()=>[u(c(e(n)("Current Password")),1)]),_:1}),a(e(b),null,{default:r(()=>[a(e(k),{id:"password-current",modelValue:s.current_secret_key,"onUpdate:modelValue":l[0]||(l[0]=_=>s.current_secret_key=_),type:"password",autocomplete:"off"},null,8,["modelValue"])]),_:1}),t.current_secret_key?(f(),i(e(g),{key:0,class:"text-destructive"},{default:r(()=>[u(c(t.current_secret_key),1)]),_:1})):m("",!0)]),_:1}),a(e(V),null,{default:r(()=>[a(e(v),{for:"password-new"},{default:r(()=>[u(c(e(n)("New Password")),1)]),_:1}),a(e(b),null,{default:r(()=>[a(e(k),{id:"password-new",modelValue:s.new_secret_key,"onUpdate:modelValue":l[1]||(l[1]=_=>s.new_secret_key=_),type:"password",autocomplete:"off"},null,8,["modelValue"])]),_:1}),t.new_secret_key?(f(),i(e(g),{key:0,class:"text-destructive"},{default:r(()=>[u(c(t.new_secret_key),1)]),_:1})):m("",!0)]),_:1}),a(e(V),null,{default:r(()=>[a(e(v),{for:"password-new-confirm"},{default:r(()=>[u(c(e(n)("Confirm New Password")),1)]),_:1}),a(e(b),null,{default:r(()=>[a(e(k),{id:"password-new-confirm",modelValue:s.re_new_secret_key,"onUpdate:modelValue":l[2]||(l[2]=_=>s.re_new_secret_key=_),type:"password",autocomplete:"off",disabled:!s.new_secret_key},null,8,["modelValue","disabled"])]),_:1}),t.re_new_secret_key?(f(),i(e(g),{key:0,class:"text-destructive"},{default:r(()=>[u(c(t.re_new_secret_key),1)]),_:1})):m("",!0)]),_:1})])]),_:1},8,["modelValue","title"]))}}),Z=Object.assign(G,{__name:"AccessKeysChangePassword"});export{Z as A};
