import{n as e}from"./pagination-BklXHwQ9.js";import{t}from"./tabs-B0pGTc5N.js";import{t as n}from"./card-BDbI8Gdq.js";import{t as r}from"./list-DldRat7g.js";import{t as i}from"./upload-DrAEBKrg.js";import{t as a}from"./tag-Bn-IyYw0.js";import{B as o,Ca as s,Ct as c,Dt as l,Ea as u,G as d,Lt as f,P as p,Pt as m,S as h,U as g,_,c as v,d as y,g as b,gn as x,h as S,hn as C,j as w,l as T,m as E,o as D,rt as O,s as k,wn as A}from"./index-DThTpSPU.js";var j=u(s(),1),M=u(C(),1),N=k(),{Text:P}=O,F=()=>{let t=T(e=>e.userinfo),n=T(e=>e.info),[r]=m.useForm(),[a,o]=(0,j.useState)(!1),{t:s}=v();return(0,N.jsxs)(`div`,{className:`w-full px-6 py-4`,children:[(0,N.jsxs)(`div`,{className:`flex flex-col items-center mb-3`,children:[(0,N.jsx)(A,{size:120,src:t?.avatar_url,className:`mb-4 border-2 border-gray-200`}),(0,N.jsx)(i,{name:`file`,action:`/index.php/admin/uploadAvatar`,headers:{Authorization:`Bearer ${localStorage.getItem(`token`)}`},showUploadList:!1,onChange:async e=>{e.file.status===`done`&&(c.success(s(`user.profile.baseInfo.avatarSuccess`)),await n())},children:(0,N.jsx)(x,{icon:(0,N.jsx)(_,{}),children:s(`user.profile.baseInfo.updateAvatar`)})}),(0,N.jsx)(`p`,{className:`text-gray-500 text-sm mt-2`,children:s(`user.profile.baseInfo.updateAvatarDesc`)})]}),(0,N.jsxs)(m,{form:r,layout:`vertical`,onFinish:async e=>{try{o(!0),await E(e),await n(),c.success(s(`user.profile.baseInfo.success`))}finally{o(!1)}},initialValues:{bio:t?.bio,email:t?.email,mobile:t?.mobile,nickname:t?.nickname,sex:t?.sex,username:t?.username},children:[(0,N.jsx)(m.Item,{label:s(`user.profile.baseInfo.username`),name:`username`,rules:[{required:!0,message:s(`user.profile.baseInfo.username.message`)}],children:(0,N.jsx)(l,{disabled:!0})}),(0,N.jsx)(m.Item,{label:s(`user.profile.baseInfo.nickname`),name:`nickname`,rules:[{required:!0,message:s(`user.profile.baseInfo.nickname.message`)}],children:(0,N.jsx)(l,{})}),(0,N.jsx)(m.Item,{label:s(`user.profile.baseInfo.sex`),name:`sex`,children:(0,N.jsx)(e.Group,{options:[{value:0,label:s(`user.profile.baseInfo.sex.0`)},{value:1,label:s(`user.profile.baseInfo.sex.1`)}]})}),(0,N.jsx)(m.Item,{label:s(`user.profile.baseInfo.bio`),name:`bio`,children:(0,N.jsx)(l.TextArea,{rows:4})}),(0,N.jsx)(m.Item,{label:s(`user.profile.baseInfo.email`),name:`email`,rules:[{type:`email`,message:s(`user.profile.baseInfo.email.typeMessage`)},{required:!0,message:s(`user.profile.baseInfo.email.requiredMessage`)}],children:(0,N.jsx)(l,{})}),(0,N.jsx)(m.Item,{label:s(`user.profile.baseInfo.mobile`),name:`mobile`,rules:[{required:!0,message:s(`user.profile.baseInfo.mobile.message`)}],children:(0,N.jsx)(l,{})}),(0,N.jsx)(m.Item,{children:(0,N.jsx)(x,{type:`primary`,htmlType:`submit`,size:`large`,loading:a,block:!0,children:s(`user.profile.baseInfo.submit`)})})]})]})},I=()=>{let[e]=m.useForm(),[t,n]=(0,j.useState)(!1),{t:r}=v();return(0,N.jsxs)(m,{form:e,layout:`vertical`,onFinish:async t=>{try{n(!0),await S(t),e.resetFields(),c.success(r(`user.profile.changePassword.success`))}finally{n(!1)}},className:`w-full px-6 py-4`,children:[(0,N.jsx)(m.Item,{label:r(`user.profile.changePassword.oldPassword`),name:`oldPassword`,rules:[{required:!0,message:r(`user.profile.changePassword.oldPassword.message`)}],children:(0,N.jsx)(l.Password,{})}),(0,N.jsx)(m.Item,{label:r(`user.profile.changePassword.newPassword`),name:`newPassword`,rules:[{required:!0,message:r(`user.profile.changePassword.requiredMessage`)},{min:8,message:r(`user.profile.changePassword.minMessage`)}],children:(0,N.jsx)(l.Password,{})}),(0,N.jsx)(m.Item,{label:r(`user.profile.changePassword.rePassword`),name:`rePassword`,dependencies:[`newPassword`],rules:[{required:!0,message:r(`user.profile.changePassword.requiredMessage`)},({getFieldValue:e})=>({validator(t,n){return!n||e(`newPassword`)===n?Promise.resolve():Promise.reject(Error(r(`user.profile.changePassword.rePassword.message`)))}})],children:(0,N.jsx)(l.Password,{})}),(0,N.jsx)(x,{type:`primary`,block:!0,htmlType:`submit`,size:`large`,loading:t,children:r(`user.profile.changePassword.submit`)})]})},L=()=>{let[e,t]=(0,j.useState)([]),{t:n}=v();(0,j.useEffect)(()=>{y().then(e=>t(e.data.data||[]))},[]);let i=({browser:e})=>{let t={Chrome:`🚀`,Firefox:`🦊`,Safari:`🍎`,Edge:`🌊`},n=Object.keys(t).find(t=>e?.includes(t));return(0,N.jsx)(`span`,{children:n?t[n]:`💻`})};return(0,N.jsx)(r,{dataSource:e,className:`w-full px-6 py-4 overflow-auto`,locale:{emptyText:n(`user.profile.loginLog.empty`)},renderItem:e=>(0,N.jsxs)(r.Item,{style:{minWidth:600},children:[(0,N.jsx)(A,{size:`large`,icon:(0,N.jsx)(b,{}),style:{backgroundColor:e.status===`0`?`#87d068`:`#f56a00`,marginRight:16}}),(0,N.jsxs)(`div`,{className:`flex-1`,children:[(0,N.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,N.jsx)(P,{strong:!0,className:`mr-3 text-base`,children:e.username}),e.status===`0`?(0,N.jsx)(a,{color:`green`,icon:(0,N.jsx)(d,{}),children:n(`user.profile.loginLog.success`)}):(0,N.jsx)(a,{color:`red`,icon:(0,N.jsx)(g,{}),children:n(`user.profile.loginLog.error`)}),(0,N.jsx)(P,{type:`secondary`,className:`ml-auto`,children:(0,M.default)(e.login_time).format(`YYYY-MM-DD HH:mm:ss`)})]}),(0,N.jsxs)(f,{size:`large`,wrap:!0,children:[(0,N.jsxs)(`div`,{className:`flex items-center`,children:[(0,N.jsx)(p,{className:`mr-1 text-blue-500`}),(0,N.jsx)(P,{type:`secondary`,children:e.ipaddr})]}),(0,N.jsxs)(`div`,{className:`flex items-center`,children:[(0,N.jsx)(o,{className:`mr-1 text-green-500`}),(0,N.jsx)(P,{type:`secondary`,children:e.login_location})]}),(0,N.jsxs)(`div`,{className:`flex items-center`,children:[(0,N.jsx)(i,{browser:e.browser}),(0,N.jsx)(P,{type:`secondary`,className:`ml-1`,children:e.browser})]}),(0,N.jsxs)(P,{type:`secondary`,children:[`OS: `,e.os]})]})]})]})})},R=()=>{let[e,r]=(0,j.useState)(`info`),{t:i}=v(),a=D(),o=[{label:(0,N.jsxs)(`span`,{className:`flex items-center`,children:[(0,N.jsx)(b,{className:`mr-2`}),a?null:i(`user.profile.baseInfo`)]}),key:`info`,children:(0,N.jsx)(F,{})},{label:(0,N.jsxs)(`span`,{className:`flex items-center`,children:[(0,N.jsx)(w,{className:`mr-2`}),a?null:i(`user.profile.changePassword`)]}),key:`security`,children:(0,N.jsx)(I,{})},{label:(0,N.jsxs)(`span`,{className:`flex items-center`,children:[(0,N.jsx)(h,{className:`mr-2`}),a?null:i(`user.profile.loginLog`)]}),key:`loginlog`,children:(0,N.jsx)(L,{})}];return(0,N.jsx)(n,{title:i(`user.profile.title`),variant:`borderless`,style:{maxWidth:800,width:`100%`},styles:{body:{paddingInline:0,paddingRight:25,display:`flex`}},children:(0,N.jsx)(t,{activeKey:e,onChange:r,tabPlacement:`start`,className:`min-h-[500px] w-full`,items:o})})};export{R as default};