import{u as _,r as i,j as e,A as R,R as U,T as M,B as m,x as D,y as E,a as L,z as $,c as q,C,e as z,D as H,E as V,s as u,k as X,F as G}from"./index-BGI3tmtB.js";import{P as K}from"./index-xsV5o4zp.js";import{F as r}from"./index-BuOmEnKg.js";import{R as W,C as P}from"./row-C3H8lbGw.js";import{C as v,T as J}from"./index-DxgbQv5l.js";import{T as p}from"./index-bzjak6Z4.js";import{I as l}from"./index-FqFqpoYX.js";import{A as O}from"./index-BYcWf3Qn.js";import{D as Q}from"./index-DkdVsa1N.js";import"./useForm-BpWJqkw6.js";const{Paragraph:I,Title:Y,Text:Z}=M;function me(){const{t:s}=_(),[S,f]=i.useState(!1),[x,n]=i.useState(!1),[ee,y]=i.useState(!1),[T,h]=i.useState(!1),[o,k]=i.useState(null),[a,j]=i.useState(null),[c]=r.useForm(),[d]=r.useForm(),b=async()=>{f(!0);try{const t=await z();k(t),c.setFieldsValue(t)}finally{f(!1)}},B=async()=>{y(!0);try{const t=await H();j(t)}finally{y(!1)}};i.useEffect(()=>{b(),B()},[]);const F=async()=>{try{const t=await c.validateFields();n(!0),await V(t),u.success(s("common.success")),b()}finally{n(!1)}},N=async()=>{try{const t=await d.validateFields();n(!0),await X(t),u.success(s("common.success")),d.resetFields()}finally{n(!1)}},A=async()=>{try{h(!0);const t=await G();j(t),u.success(s("common.success"))}finally{h(!1)}},g=t=>t||"-";return e.jsxs("div",{className:"app-page app-page--contained",style:{maxWidth:1024,width:"100%",margin:"0 auto"},children:[e.jsx(K,{title:s("profile.title"),subtitle:s("profile.subtitle")}),e.jsxs(W,{gutter:24,children:[e.jsx(P,{xs:24,lg:8,children:e.jsxs(v,{className:"app-page__content-card text-center",loading:S,children:[e.jsx(R,{size:80,icon:e.jsx(U,{}),style:{backgroundColor:"#1677ff",marginBottom:16}}),e.jsx(Y,{level:5,style:{margin:0},children:o==null?void 0:o.displayName}),e.jsxs(Z,{type:"secondary",children:["@",o==null?void 0:o.username]}),e.jsx("div",{className:"mt-4",children:o!=null&&o.isPlatformAdmin?e.jsx(p,{color:"gold",children:s("users.platformAdmin")}):e.jsx(p,{color:"blue",children:s("profile.standardUser")})})]})}),e.jsx(P,{xs:24,lg:16,children:e.jsx(v,{className:"app-page__content-card",children:e.jsx(J,{defaultActiveKey:"basic",items:[{key:"basic",label:e.jsxs("span",{children:[e.jsx(E,{})," ",s("profile.basicInfo")]}),children:e.jsxs(r,{form:c,layout:"vertical",onFinish:F,style:{marginTop:16},children:[e.jsx(r.Item,{label:s("users.displayName"),name:"displayName",rules:[{required:!0}],children:e.jsx(l,{})}),e.jsx(r.Item,{label:s("users.email"),name:"email",children:e.jsx(l,{})}),e.jsx(r.Item,{label:s("users.phone"),name:"phone",children:e.jsx(l,{})}),e.jsx("div",{className:"app-page__page-actions",style:{margin:"8px 0 0"},children:e.jsx(m,{type:"primary",icon:e.jsx(D,{}),loading:x,onClick:()=>c.submit(),children:s("profile.saveChanges")})})]})},{key:"password",label:e.jsxs("span",{children:[e.jsx(L,{})," ",s("profile.security")]}),children:e.jsxs(r,{form:d,layout:"vertical",onFinish:N,style:{marginTop:16},children:[e.jsx(r.Item,{label:s("profile.currentPassword"),name:"oldPassword",rules:[{required:!0}],children:e.jsx(l.Password,{})}),e.jsx(r.Item,{label:s("profile.newPassword"),name:"newPassword",rules:[{required:!0,min:6}],children:e.jsx(l.Password,{})}),e.jsx(r.Item,{label:s("profile.confirmNewPassword"),name:"confirmPassword",dependencies:["newPassword"],rules:[{required:!0},({getFieldValue:t})=>({validator(se,w){return!w||t("newPassword")===w?Promise.resolve():Promise.reject(new Error(s("profile.passwordsDoNotMatch")))}})],children:e.jsx(l.Password,{})}),e.jsx("div",{className:"app-page__page-actions",style:{margin:"8px 0 0"},children:e.jsx(m,{type:"primary",danger:!0,loading:x,onClick:()=>d.submit(),children:s("profile.updatePassword")})})]})},{key:"bot-credential",label:e.jsxs("span",{children:[e.jsx(C,{})," ",s("profile.botCredentialTab")]}),children:e.jsx("div",{style:{marginTop:16},children:e.jsxs($,{direction:"vertical",size:16,style:{width:"100%"},children:[e.jsx(O,{type:"info",showIcon:!0,message:s("profile.botCredentialHint"),description:s("profile.botCredentialHintDesc")}),e.jsx(Q,{bordered:!0,size:"middle",column:1,items:[{key:"bind-status",label:s("profile.botBindStatus"),children:a!=null&&a.bound?e.jsx(p,{color:"success",children:s("profile.botBound")}):e.jsx(p,{children:s("profile.botUnbound")})},{key:"bot-id",label:"X-Bot-Id",children:a!=null&&a.botId?e.jsx(I,{copyable:{text:a.botId},style:{marginBottom:0},children:a.botId}):"-"},{key:"bot-secret",label:"X-Bot-Secret",children:a!=null&&a.botSecret?e.jsx(I,{copyable:{text:a.botSecret},style:{marginBottom:0},children:a.botSecret}):s("profile.botSecretHidden")},{key:"last-access-time",label:s("profile.botLastAccessTime"),children:g(a==null?void 0:a.lastAccessTime)},{key:"last-access-ip",label:s("profile.botLastAccessIp"),children:g(a==null?void 0:a.lastAccessIp)}]}),e.jsx("div",{className:"app-page__page-actions",style:{margin:"8px 0 0"},children:e.jsx(m,{type:"primary",icon:a!=null&&a.bound?e.jsx(q,{}):e.jsx(C,{}),loading:T,onClick:A,children:a!=null&&a.bound?s("profile.regenerateBotCredential"):s("profile.generateBotCredential")})})]})})}]})})})]})]})}export{me as default};