llonebot-dist 7.9.2 → 7.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -436,7 +436,7 @@ Error generating stack: `+i.message+`
436
436
  disabled:opacity-50 disabled:cursor-not-allowed`,children:r?s.jsxs(s.Fragment,{children:[s.jsx(p0,{className:"animate-spin",size:16}),"发送中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(ss,{size:16}),"发送测试邮件"]})})})]})]})},tg=({config:e,emailConfig:t,onChange:n,onEmailChange:r,onOpenChangePassword:l})=>{var c,u;const i=(d,m)=>{n({...e,[d]:m})},o=d=>{const m={...d,smtp:{...d.smtp,port:d.smtp.port||587}};r(m)},a={enabled:!1,smtp:{host:"",port:587,secure:!1,auth:{user:"",pass:""}},from:"",to:""};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"card p-6 relative z-[100]",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-blue-500 to-indigo-600 flex items-center justify-center",children:s.jsx(Ll,{size:20,className:"text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"WebUI 服务"}),s.jsx("p",{className:"text-sm text-theme-secondary",children:"WebUI 访问地址和端口配置,如果是 Docker 不建议更改此项,否则可能无法访问"})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("label",{className:"block",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Pl,{size:16,className:"text-blue-600"}),s.jsx("span",{className:"text-sm font-medium text-theme-secondary",children:"监听地址"})]}),s.jsx(ls,{value:((c=e.webui)==null?void 0:c.host)??"127.0.0.1",onChange:d=>{var m,f;n({...e,webui:{enable:((m=e.webui)==null?void 0:m.enable)??!0,port:((f=e.webui)==null?void 0:f.port)||6099,host:d}})}}),s.jsx("p",{className:"text-xs text-theme-muted mt-2",children:"选择 WebUI 监听的网络地址"})]}),s.jsxs("label",{className:"block",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Ll,{size:16,className:"text-blue-600"}),s.jsx("span",{className:"text-sm font-medium text-theme-secondary",children:"端口"})]}),s.jsx("input",{type:"number",value:((u=e.webui)==null?void 0:u.port)||6099,onChange:d=>{var m,f;return n({...e,webui:{enable:((m=e.webui)==null?void 0:m.enable)??!0,host:((f=e.webui)==null?void 0:f.host)||"127.0.0.1",port:parseInt(d.target.value)}})},min:"1",max:"65535",className:"input-field",placeholder:"6099"}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"WebUI 服务端口(1-65535)"})]})]})]}),s.jsx(eg,{value:t||a,onChange:o}),s.jsxs("div",{className:"card p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl gradient-primary-br flex items-center justify-center",children:s.jsx(Pl,{size:20,className:"text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"系统功能"}),s.jsx("p",{className:"text-sm text-theme-secondary",children:"基础功能开关配置"})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 bg-theme-item rounded-xl bg-item-hover transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(u0,{size:20,className:"text-green-600"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-theme",children:"日志记录"}),s.jsx("div",{className:"text-xs text-theme-muted mt-0.5",children:"启用后记录详细的运行日志"})]})]}),s.jsx("input",{type:"checkbox",checked:e.log,onChange:d=>i("log",d.target.checked),className:"switch-toggle"})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-theme-item rounded-xl bg-item-hover transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(lh,{size:20,className:"text-pink-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-theme",children:"本地文件转URL"}),s.jsx("div",{className:"text-xs text-theme-muted mt-0.5",children:"启用后可将本地文件转换为URL链接"})]})]}),s.jsx("input",{type:"checkbox",checked:e.enableLocalFile2Url,onChange:d=>i("enableLocalFile2Url",d.target.checked),className:"switch-toggle"})]})]})]}),s.jsxs("div",{className:"card p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-orange-500 to-red-600 flex items-center justify-center",children:s.jsx(It,{size:20,className:"text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"文件管理"}),s.jsx("p",{className:"text-sm text-theme-secondary",children:"自动清理文件相关配置"})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 bg-theme-item rounded-xl bg-item-hover transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(It,{size:20,className:"text-red-600"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-theme",children:"自动删除收到的文件"}),s.jsx("div",{className:"text-xs text-theme-muted mt-0.5",children:"启用后将自动清理接收的临时文件"})]})]}),s.jsx("input",{type:"checkbox",checked:e.autoDeleteFile,onChange:d=>i("autoDeleteFile",d.target.checked),className:"switch-toggle"})]}),e.autoDeleteFile&&s.jsx("div",{className:"pl-4",children:s.jsxs("label",{className:"block",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Ur,{size:16,className:"text-theme-secondary"}),s.jsx("span",{className:"text-sm font-medium text-theme-secondary",children:"自动删除时间(秒)"})]}),s.jsx("input",{type:"number",value:e.autoDeleteFileSecond,onChange:d=>i("autoDeleteFileSecond",parseInt(d.target.value)),min:"1",max:"3600",className:"input-field",placeholder:"60"}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"文件接收后多少秒自动删除(1-3600秒)"})]})})]})]}),s.jsxs("div",{className:"card p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-pink-400 to-rose-500 flex items-center justify-center",children:s.jsx(Ur,{size:20,className:"text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"缓存设置"}),s.jsx("p",{className:"text-sm text-theme-secondary",children:"消息缓存相关配置"})]})]}),s.jsxs("label",{className:"block",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Ur,{size:16,className:"text-pink-500"}),s.jsx("span",{className:"text-sm font-medium text-theme-secondary",children:"消息缓存过期时间"})]}),s.jsx(H0,{value:e.msgCacheExpire||120,onChange:d=>i("msgCacheExpire",d),maxDays:1,showSeconds:!1}),s.jsx("p",{className:"text-xs text-theme-muted mt-2",children:"消息在缓存中保留的时间,最长1天"})]})]}),s.jsxs("div",{className:"card p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-green-500 to-teal-600 flex items-center justify-center",children:s.jsx(gu,{size:20,className:"text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"扩展功能"}),s.jsx("p",{className:"text-sm text-theme-secondary",children:"第三方服务配置"})]})]}),s.jsxs("label",{className:"block",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(gu,{size:16,className:"text-green-600"}),s.jsx("span",{className:"text-sm font-medium text-theme-secondary",children:"音乐签名地址"})]}),s.jsx("input",{type:"text",value:e.musicSignUrl,onChange:d=>i("musicSignUrl",d.target.value),placeholder:"https://example.com/sign",className:"input-field"}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"用于音乐卡片签名的服务地址"})]})]}),s.jsxs("div",{className:"card p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-red-500 to-pink-600 flex items-center justify-center",children:s.jsx(ms,{size:20,className:"text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"安全设置"}),s.jsx("p",{className:"text-sm text-theme-secondary",children:"WebUI 访问控制"})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-theme-item rounded-xl bg-item-hover transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(zl,{size:20,className:"text-red-600"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-theme",children:"WebUI 访问密码"}),s.jsx("div",{className:"text-xs text-theme-muted mt-0.5",children:"用于保护 WebUI 访问的密码"})]})]}),s.jsxs("button",{onClick:l,className:"px-4 py-2 gradient-primary text-white rounded-lg text-sm font-medium hover:shadow-lg transition-all flex items-center gap-2",children:[s.jsx(w0,{size:16}),"修改密码"]})]})]})]})};function vh(e,t){const n=e.trim();return n?t!==void 0&&n.length<t?{isValid:!1,error:`密码长度不能少于${t}位`}:/[\r\n]/.test(n)?{isValid:!1,error:"密码不能包含换行符!"}:/[^\x20-\x7E\t]/.test(n)?{isValid:!1,error:"密码不能包含中文等特殊字符!"}:/[\x00-\x08\x0A-\x1F\x7F]/.test(n)?{isValid:!1,error:"密码包含不可见的控制字符!"}:{isValid:!0}:{isValid:!1,error:"密码不能为空"}}const ng=({visible:e,onClose:t,onSuccess:n})=>{const[r,l]=p.useState(""),[i,o]=p.useState(""),[a,c]=p.useState(!1),[u,d]=p.useState(!1),[m,f]=p.useState(!1),[y,w]=p.useState(""),k=p.useRef(null);p.useEffect(()=>{e&&k.current&&setTimeout(()=>{var h;return(h=k.current)==null?void 0:h.focus()},100)},[e]),p.useEffect(()=>{e&&(l(""),o(""),c(!1),d(!1),w(""))},[e]);const j=async()=>{const h=vh(r,6);if(!h.isValid){w(h.error||"密码验证失败");return}if(r!==i){w("两次输入的密码不一致");return}f(!0),w("");try{const x=await je("/api/set-token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:r})});x.success?(Y("密码修改成功","success"),n(),t()):w(x.message||"密码修改失败")}catch(x){w(x.message||"密码修改失败")}finally{f(!1)}},g=h=>{h.key==="Enter"&&j()};return e?s.jsx(s.Fragment,{children:s.jsx("div",{className:"fixed inset-0 bg-black/30 backdrop-blur-sm flex items-center justify-center p-4",style:{zIndex:9e3},onClick:h=>h.target===h.currentTarget&&t(),children:s.jsxs("div",{className:"bg-white/90 dark:bg-neutral-800/90 backdrop-blur-xl rounded-3xl shadow-2xl w-full max-w-md transform transition-all",children:[s.jsxs("div",{className:"flex items-center gap-3 p-6 border-b border-white/20 dark:border-neutral-700/50",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-red-500 to-pink-600 flex items-center justify-center",children:s.jsx(zl,{size:20,className:"text-white"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-xl font-semibold text-theme",children:"修改 WebUI 密码"}),s.jsx("p",{className:"text-sm text-theme-secondary mt-0.5",children:"请输入新密码"})]}),s.jsx("button",{onClick:t,className:"text-theme-hint hover:text-theme transition-colors",children:s.jsx(ht,{size:24})})]}),s.jsxs("div",{className:"p-6 space-y-4",children:[y&&s.jsx("div",{className:"p-3 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-800 rounded-xl text-red-600 dark:text-red-400 text-sm",children:y}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"新密码"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:k,type:a?"text":"password",value:r,onChange:h=>{l(h.target.value),w("")},onKeyPress:g,placeholder:"请输入新密码(支持数字、字母、符号)",className:"input-field pr-12",autoComplete:"new-password"}),s.jsx("button",{type:"button",onClick:()=>c(!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-theme-hint hover:text-theme transition-colors",children:a?s.jsx(sn,{size:20}):s.jsx(Ft,{size:20})})]}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"密码长度至少6位"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"确认密码"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:u?"text":"password",value:i,onChange:h=>{o(h.target.value),w("")},onKeyPress:g,placeholder:"请再次输入新密码",className:"input-field pr-12",autoComplete:"new-password"}),s.jsx("button",{type:"button",onClick:()=>d(!u),className:"absolute right-3 top-1/2 -translate-y-1/2 text-theme-hint hover:text-theme transition-colors",children:u?s.jsx(sn,{size:20}):s.jsx(Ft,{size:20})})]})]})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-white/20 dark:border-neutral-700/50",children:[s.jsx("button",{onClick:t,disabled:m,className:"px-6 py-2.5 text-theme-secondary hover:bg-theme-item rounded-lg font-medium transition-colors disabled:opacity-50",children:"取消"}),s.jsx("button",{onClick:j,disabled:m||!r.trim()||!i.trim(),className:"px-6 py-2.5 gradient-primary text-white rounded-lg font-medium hover:shadow-lg transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none",children:m?"修改中...":"确定修改"})]})]})})}):null},Ds=({visible:e,onConfirm:t,onClose:n,error:r})=>{const[l,i]=p.useState(""),[o,a]=p.useState(!1),[c,u]=p.useState(""),d=p.useRef(null);p.useEffect(()=>{e&&d.current&&setTimeout(()=>{var y;return(y=d.current)==null?void 0:y.focus()},100)},[e]),p.useEffect(()=>{e&&(i(""),a(!1),u(""))},[e]);const m=()=>{const y=vh(l);if(!y.isValid){u(y.error||"密码验证失败");return}u(""),t(l.trim())},f=y=>{y.key==="Enter"&&m()};return p.useEffect(()=>{if(!e)return;const y=w=>{w.key==="Escape"&&(w.preventDefault(),w.stopPropagation())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[e]),e?s.jsx(s.Fragment,{children:s.jsx("div",{className:"fixed inset-0 bg-black/30 dark:bg-black/50 backdrop-blur-sm flex items-center justify-center p-4",style:{zIndex:9e3},onClick:y=>y.target===y.currentTarget&&(n==null?void 0:n()),children:s.jsxs("div",{className:"bg-white/90 dark:bg-neutral-800/90 backdrop-blur-xl rounded-3xl shadow-2xl w-full max-w-md transform transition-all",children:[s.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-white/20 dark:border-neutral-700/50",children:[s.jsx("h3",{className:"text-xl font-semibold text-theme",children:r||"WebUI 密码"}),n&&s.jsx("button",{onClick:n,className:"text-theme-hint hover:text-theme transition-colors",children:s.jsx(ht,{size:24})})]}),s.jsx("div",{className:"p-6",children:s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:d,type:o?"text":"password",value:l,onChange:y=>{i(y.target.value),c&&u("")},onKeyPress:f,placeholder:"请输入密码(支持数字、字母、符号)",className:`w-full px-4 py-3 pr-12 border rounded-xl focus:outline-none focus:ring-2 transition-all bg-theme-input backdrop-blur-sm text-theme placeholder:text-theme-hint ${c?"border-red-300 focus:ring-red-500 focus:border-red-500":"border-theme-input focus:ring-pink-500 focus:border-transparent"}`,autoComplete:"off"}),s.jsx("button",{type:"button",onClick:()=>a(!o),className:"absolute right-3 top-1/2 -translate-y-1/2 text-theme-hint hover:text-theme transition-colors",children:o?s.jsx(sn,{size:20}):s.jsx(Ft,{size:20})})]}),c&&s.jsx("p",{className:"text-sm text-red-500 px-1",children:c})]})}),s.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-white/20 dark:border-neutral-700/50",children:[n&&s.jsx("button",{onClick:n,className:"px-6 py-2.5 text-theme-secondary hover:bg-theme-item rounded-lg font-medium transition-colors",children:"取消"}),s.jsx("button",{onClick:m,disabled:!l.trim(),className:"px-6 py-2.5 gradient-primary text-white rounded-lg font-medium hover:shadow-lg transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none",children:"确定"})]})]})})}):null},rg=({onLoginSuccess:e})=>{const[t,n]=p.useState("quick"),[r,l]=p.useState(!1),[i,o]=p.useState(!1),[a,c]=p.useState(!1),[u,d]=p.useState(""),[m,f]=p.useState([]),[y,w]=p.useState(null),k=p.useRef(null),j=p.useRef(null),g=p.useRef(null),h=p.useRef(!1),x=p.useRef(!1),v={scanning:"扫描成功,请在手机上确认",success:"登录成功",expired:"二维码已过期,请刷新",error:"登录失败,请重试","":""},N=p.useCallback(()=>{h.current=!1,g.current&&(clearTimeout(g.current),g.current=null)},[]),S=p.useCallback(async()=>{if(h.current)return;h.current=!0;const E=60;let _=0;const U=async()=>{if(_>=E){N(),Y("登录超时,请重试","error"),t==="qr"&&d("error");return}_++;try{const D=await je("/api/login-info");if(D.success&&D.data.online===!0){N(),Y("登录成功!正在跳转到主页面...","success"),t==="qr"&&d("success"),setTimeout(()=>e(),1e3);return}g.current=setTimeout(U,3e3)}catch{g.current=setTimeout(U,3e3)}};await U()},[t,e,N]),T=p.useCallback(E=>{if(!k.current)return;const U=k.current.getContext("2d");if(!U)return;const D=new Image;D.onload=()=>{U.clearRect(0,0,200,200),U.drawImage(D,0,0,200,200)},D.src=E},[]),M=p.useCallback(async()=>{if(k.current)try{const E=await je("/api/login-qrcode");if(E.success&&E.data){T(E.data.pngBase64QrcodeData);const _=E.data.expireTime*1e3;j.current&&clearInterval(j.current),j.current=setTimeout(()=>{c(!0),d("expired"),N()},_),c(!1),d(""),Y("请使用手机QQ扫码登录","warning"),await S()}else throw new Error(E.message||"获取二维码失败")}catch(E){Y(E.message||"获取二维码失败","error")}},[T,S,N]),q=p.useCallback(async()=>{await M(),Y("二维码已刷新","success")},[M]),R=p.useCallback(async()=>{if(!x.current){x.current=!0;try{const E=await je("/api/quick-login-list");if(E.success&&E.data&&E.data.LocalLoginInfoList){const _=E.data.LocalLoginInfoList.filter(U=>U.isQuickLogin&&!U.isUserLogin);f(_),_.length>0?w(U=>U??_[0]):n("qr")}else f([])}catch{Y("获取快速登录列表失败","error"),f([])}}},[]),V=p.useCallback(async()=>{if(y){o(!0);try{const _=(await je("/api/quick-login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uin:y.uin})})).data;if(_.result==="0")Y(`正在登录 ${y.nickName}...`,"success"),await S();else throw new Error(_.loginErrorInfo.errMsg||"登录失败")}catch(E){Y(E.message,"error"),n("qr")}finally{o(!1)}}},[y,S]),C=()=>l(!r),b=E=>{w(E),l(!1)};return p.useEffect(()=>(x.current||R(),()=>{j.current&&clearInterval(j.current),N()}),[]),p.useEffect(()=>{t==="qr"?setTimeout(()=>M(),100):j.current&&clearInterval(j.current),t==="quick"&&m.length===0&&!x.current&&R()},[t,m.length,M]),s.jsx("div",{className:"relative min-h-screen flex flex-col items-center justify-center p-5",children:s.jsxs("div",{className:"bg-white/50 dark:bg-neutral-800/70 backdrop-blur-2xl rounded-3xl p-10 shadow-xl border border-white/30 dark:border-neutral-700/50 min-w-[320px] text-center relative z-10",children:[t==="quick"&&s.jsxs("div",{className:"flex flex-col items-center gap-6",children:[!r&&y&&s.jsxs("div",{className:"flex flex-col items-center cursor-pointer p-4 rounded-2xl transition-colors hover:bg-pink-50 dark:hover:bg-pink-900/30",onClick:C,children:[s.jsx("div",{className:"w-20 h-20 rounded-full overflow-hidden mb-3 shadow-lg",children:s.jsx("img",{src:y.faceUrl,alt:y.nickName,className:"w-full h-full object-cover"})}),s.jsx("div",{className:"text-base text-theme mb-2",children:y.nickName})]}),r&&s.jsx("div",{className:"grid grid-cols-2 gap-4 my-5 w-full max-w-md",children:m.map(E=>s.jsxs("div",{className:"flex flex-col items-center p-4 rounded-2xl cursor-pointer transition-all border-2 border-transparent hover:bg-pink-50 dark:hover:bg-pink-900/30 hover:border-pink-500",onClick:()=>b(E),children:[s.jsx("div",{className:"w-[60px] h-[60px] rounded-full overflow-hidden mb-2 shadow-md",children:s.jsx("img",{src:E.faceUrl,alt:E.nickName,className:"w-full h-full object-cover"})}),s.jsx("div",{className:"text-sm text-theme text-center truncate w-full px-1",children:E.nickName})]},E.uin))}),!r&&s.jsx("button",{onClick:V,disabled:!y||i,className:"w-[280px] h-11 gradient-primary text-white rounded-full font-medium text-base disabled:opacity-50 disabled:cursor-not-allowed hover:shadow-lg transition-all flex items-center justify-center gap-2",children:i?s.jsxs(s.Fragment,{children:[s.jsx(Se,{size:20,className:"animate-spin"}),"登录中..."]}):"登录"}),s.jsxs("div",{className:"flex gap-6 justify-center",children:[!r&&s.jsx("button",{onClick:C,className:"text-pink-500 text-sm hover:underline",children:"切换账号"}),s.jsx("button",{onClick:()=>n("qr"),className:"text-pink-500 text-sm hover:underline",children:"扫码登录"})]})]}),t==="qr"&&s.jsxs("div",{className:"flex flex-col items-center gap-5",children:[s.jsx("div",{className:"relative inline-block",children:s.jsxs("div",{className:"relative p-5 bg-white rounded-2xl shadow-lg",children:[s.jsx("canvas",{ref:k,width:"200",height:"200",className:"block rounded-lg"}),a&&s.jsxs("div",{className:"absolute inset-0 bg-black/70 flex flex-col items-center justify-center text-white cursor-pointer rounded-2xl transition-opacity hover:opacity-90",onClick:q,children:[s.jsx(oh,{size:32,className:"mb-2"}),s.jsx("div",{children:"点击刷新"})]})]})}),s.jsx("div",{className:"text-theme-secondary",children:"请使用手机QQ扫码登录"}),u&&s.jsx("div",{className:`text-sm px-4 py-2 rounded-lg ${u==="success"?"bg-green-100 text-green-800":u==="error"||u==="expired"?"bg-red-100 text-red-800":"bg-blue-100 text-blue-800"}`,children:v[u]})]}),s.jsx("div",{className:"mt-6",children:t==="qr"&&m.length>0&&s.jsx("button",{onClick:()=>n("quick"),className:"text-pink-500 text-sm hover:underline",children:"快速登录"})})]})})};let wh=null,kh=null;function jh(e,t){wh=e,kh=t}function cr(){return wh}function li(){return kh}function _l(e){return`https://q1.qlogo.cn/g?b=qq&nk=${e}&s=640`}function is(e){return`https://p.qlogo.cn/gh/${e}/${e}/640/`}async function Nh(){const e=await je("/api/login-info");if(!e.success)throw new Error(e.message||"获取登录信息失败");const t=e.data;return jh(t.uid,t.uin),t}async function Al(){const e=await te("ntFriendApi","getBuddyV2",[!0]),t=await te("ntFriendApi","getBuddyList",[]),n=new Map;for(const l of t)n.set(l.uid,l);const r=(e.data||[]).map(l=>{const i=(l.buddyUids||[]).map(o=>n.get(o)).filter(o=>o).map(o=>{var a,c,u,d;return{uid:o.uid,uin:o.uin,nickname:((a=o.coreInfo)==null?void 0:a.nick)||"",remark:((c=o.coreInfo)==null?void 0:c.remark)||"",avatar:_l(o.uin),online:((u=o.status)==null?void 0:u.status)===10||!1,topTime:((d=o.relationFlags)==null?void 0:d.topTime)||"0"}});return{categoryId:l.categoryId,categoryName:l.categroyName||"我的好友",categorySort:l.categorySortId,onlineCount:l.onlineCount||0,memberCount:l.categroyMbCount||i.length,friends:i}});return r.sort((l,i)=>l.categorySort-i.categorySort),r}async function Fl(){return(await te("ntGroupApi","getGroups",[!1])).map(t=>({groupCode:t.groupCode,groupName:t.groupName,remarkName:t.remarkName||"",avatar:is(t.groupCode),memberCount:t.memberCount,isTop:t.isTop||!1,msgMask:t.cmdUinMsgMask||1}))}async function Wo(){const e=await te("ntUserApi","getRecentContactListSnapShot",[50]),[t,n]=await Promise.all([Fl(),Al()]),r=new Map,l=[];t.forEach(c=>{c.msgMask!==2&&(r.set(`2_${c.groupCode}`,c.isTop),c.isTop&&l.push(c))});const i=[];n.forEach(c=>{c.friends.forEach(u=>{const d=!!u.topTime&&u.topTime!=="0";r.set(`1_${u.uin}`,d),d&&i.push(u)})});const o=new Set,a=e.info.changedList.filter(c=>{const u=c.peerUin||c.peerUid;return u&&u!=="0"&&u!==""}).map(c=>{const u=c.chatType,d=u===2,m=d?c.peerUin||c.peerUid:c.peerUin;o.add(`${u}_${m}`);const f=`${u}_${m}`,y=r.get(f)||!1;return{chatType:u,peerId:m,peerName:c.peerName||c.remark||c.peerUin,peerAvatar:d?is(m):_l(c.peerUin),lastMessage:sg(c.abstractContent),lastTime:parseInt(c.msgTime)*1e3,unreadCount:parseInt(c.unreadCnt)||0,pinned:y}});return l.forEach(c=>{const u=`2_${c.groupCode}`;o.has(u)||a.push({chatType:2,peerId:c.groupCode,peerName:c.groupName,peerAvatar:is(c.groupCode),lastMessage:"",lastTime:Date.now(),unreadCount:0,pinned:!0})}),i.forEach(c=>{const u=`1_${c.uin}`;o.has(u)||a.push({chatType:1,peerId:c.uin,peerName:c.remark||c.nickname,peerAvatar:_l(c.uin),lastMessage:"",lastTime:Date.now(),unreadCount:0,pinned:!0})}),a.sort((c,u)=>c.pinned&&!u.pinned?-1:!c.pinned&&u.pinned?1:u.lastTime-c.lastTime),a}function sg(e){const t=r=>{var i,o,a;if(!r)return"";if(typeof r=="string")return r;const l=r.content||r.text||r.recentAbstract||((i=r.textElement)==null?void 0:i.content)||((a=(o=r.grayTipElement)==null?void 0:o.jsonGrayTipElement)==null?void 0:a.recentAbstract);return typeof l=="string"&&l.trim()?l:r.picElement||r.imageElement||r.type===2||r.elementType===2?"[图片]":r.faceElement||r.marketFaceElement||r.type===3||r.elementType===6?"[表情]":r.fileElement||r.type===6||r.elementType===3?"[文件]":r.pttElement||r.voiceElement||r.elementType===4?"[语音]":r.videoElement||r.elementType===5?"[视频]":""};return e?Array.isArray(e)?e.map(t).filter(Boolean).join("")||"[消息]":t(e)||"[消息]":"[消息]"}async function ll(e,t,n,r=20,l){const i=new URLSearchParams({chatType:String(e),peerId:t,limit:r.toString()});n&&i.append("beforeMsgSeq",n),l&&i.append("afterMsgSeq",l);const o=await je(`/api/webqq/messages?${i}`);if(!o.success)throw new Error(o.message||"获取消息历史失败");return o.data||{messages:[],hasMore:!1}}async function Ho(e){const t=await je("/api/webqq/messages",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.success)throw new Error(t.message||"发送消息失败");return t.data||{msgId:""}}async function bh(e){const t=new FormData;t.append("image",e);const n=await je("/api/webqq/upload",{method:"POST",body:t});if(!n.success)throw new Error(n.message||"上传图片失败");return n.data}async function Sh(e){const t=await je("/api/webqq/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageUrl:e})});if(!t.success)throw new Error(t.message||"上传图片失败");return t.data}async function Ch(e){const t=new FormData;t.append("file",e);const n=await je("/api/webqq/upload-file",{method:"POST",body:t});if(!n.success)throw new Error(n.message||"上传文件失败");return n.data}async function lg(e){const t=await je(`/api/webqq/members?groupCode=${e}`);if(!t.success)throw new Error(t.message||"获取群成员失败");return t.data||[]}async function ig(e){const t=await je(`/api/webqq/user-info?uid=${encodeURIComponent(e)}`);if(!t.success)throw new Error(t.message||"获取用户信息失败");return t.data}async function te(e,t,n=[]){const r=await je(`/api/ntcall/${e}/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({args:n})});if(!r.success)throw new Error(r.message||"NT API 调用失败");return r.data}async function Eh(e,t,n,r){return await te("ntFileApi","getVideoUrl",[{chatType:e,peerUid:t,guildId:""},n,r])}async function Mh(e,t,n){await te("ntMsgApi","recallMsg",[{chatType:e,peerUid:t,guildId:""},[n]])}async function Th(e,t){var n,r;try{if(t){const i=await te("ntGroupApi","getGroupMember",[t,e,!1]);if(i)return i.cardName||i.nick||"未知用户"}const l=await te("ntUserApi","getUserSimpleInfo",[e,!1]);return((n=l==null?void 0:l.coreInfo)==null?void 0:n.remark)||((r=l==null?void 0:l.coreInfo)==null?void 0:r.nick)||"未知用户"}catch{return"未知用户"}}async function $l(e,t,n){e===2&&n?await te("pmhq","sendGroupPoke",[Number(n),Number(t)]):await te("pmhq","sendFriendPoke",[Number(t)])}async function Ih(e,t,n,r){return await te("ntMsgApi","translatePtt2Text",[e,{chatType:t,peerUid:n,guildId:""},r])||""}async function Ph(e,t,n=!1){const r=await te("ntGroupApi","kickMember",[e,[t],n,""]);if((r==null?void 0:r.errCode)!==0)throw new Error((r==null?void 0:r.errMsg)||"踢出失败")}async function zh(e,t,n){await te("ntGroupApi","banMember",[e,[{uid:t,timeStamp:n}]])}async function Lh(e,t,n){await te("pmhq","setSpecialTitle",[parseInt(e),t,n])}function Rh(e,t,n){const r=hs();let l=`/api/webqq/audio-proxy?fileUuid=${encodeURIComponent(e)}&isGroup=${t}&token=${encodeURIComponent(r||"")}`;return n&&(l+=`&filePath=${encodeURIComponent(n)}`),l}async function _h(e){const t=await te("ntGroupApi","quitGroup",[e]);if((t==null?void 0:t.result)!==0)throw new Error((t==null?void 0:t.errMsg)||"退群失败")}async function Ul(e,t,n){var y;let r=e;if(!r&&t&&(r=await te("ntUserApi","getUidByUin",[t])),!r)throw new Error("无法获取用户信息");const i=(await te("ntUserApi","fetchUserDetailInfo",[r])).detail[r];if(!i)throw new Error("用户不存在");let o=t||i.uin;o||(o=await te("ntUserApi","getUinByUid",[r]));const a=i.simpleInfo,c=a==null?void 0:a.coreInfo,u=a==null?void 0:a.baseInfo,d=i.commonExt;let m=((y=d==null?void 0:d.qqLevel)==null?void 0:y.level)||0;if(m===0&&o)try{m=await te("pmhq","fetchUserLevel",[parseInt(o)])}catch{}const f={uid:r,uin:o||"",nickname:(c==null?void 0:c.nick)||"",remark:(c==null?void 0:c.remark)||"",signature:(u==null?void 0:u.longNick)||"",sex:(u==null?void 0:u.sex)??0,birthday:u!=null&&u.birthday_year?`${u.birthday_year}-${u.birthday_month}-${u.birthday_day}`:"",location:"",qid:(u==null?void 0:u.qid)||"",level:m,regTime:(d==null?void 0:d.regTime)||void 0,avatar:`https://q1.qlogo.cn/g?b=qq&nk=${o}&s=640`};if(n)try{const w=await te("ntGroupApi","getGroupMember",[n,r,!1]);w&&(f.groupCard=w.cardName||"",f.groupRole=w.role===4?"owner":w.role===3?"admin":"member",f.groupTitle=w.memberSpecialTitle||"",f.groupLevel=w.memberRealLevel||w.memberLevel||0,f.joinTime=w.joinTime,f.lastSpeakTime=w.lastSpeakTime)}catch{}return f}function Ah(e,t,n){const r=hs(),l=r?`/api/webqq/events?token=${encodeURIComponent(r)}`:"/api/webqq/events";let i,o=0,a=null,c=!1;const u=()=>(i=new EventSource(l),i.addEventListener("message",m=>{try{const f=JSON.parse(m.data);e(f)}catch(f){console.error("解析 SSE 消息失败:",f)}}),i.addEventListener("connected",()=>{console.log("[SSE] 连接已建立"),o=0}),i.onopen=()=>{console.log("[SSE] 连接打开"),o>0&&(console.log("[SSE] 重连成功"),n==null||n()),o=0},i.onerror=m=>{if(console.error("[SSE] 连接错误:",m),c)return;i.close();const f=Math.min(1e3*Math.pow(2,o),3e4);o++,console.log(`[SSE] 将在 ${f}ms 后尝试第 ${o} 次重连...`),a=setTimeout(()=>{c||(console.log("[SSE] 正在重连..."),u())},f),t==null||t(m)},i);return i=u(),{close:()=>{c=!0,a&&(clearTimeout(a),a=null),i.close(),console.log("[SSE] 连接已关闭")},get readyState(){return i.readyState},get url(){return i.url},addEventListener:i.addEventListener.bind(i),removeEventListener:i.removeEventListener.bind(i),dispatchEvent:i.dispatchEvent.bind(i),onerror:i.onerror,onmessage:i.onmessage,onopen:i.onopen,CONNECTING:EventSource.CONNECTING,OPEN:EventSource.OPEN,CLOSED:EventSource.CLOSED,withCredentials:i.withCredentials}}function Fh(e,t){if(!t.trim())return e;const n=t.toLowerCase();return e.filter(r=>r.groupName.toLowerCase().includes(n)||r.groupCode.includes(t))}function $h(e,t){if(!t.trim())return e;const n=t.toLowerCase();return e.filter(r=>r.nickname.toLowerCase().includes(n)||r.card.toLowerCase().includes(n)||r.uin.includes(t))}function Uh(e){const t=e.toLowerCase().split(".").pop()||"";return["jpg","jpeg","png","gif"].includes(t)}function og(e){return!e||e.trim().length===0}async function Dh(e){var r,l,i;const t=await te("ntGroupApi","getGroupAllInfo",[e]);console.log("[WebQQ] 群资料:",{groupCode:t.groupCode,groupName:t.groupName,fingerMemo:t.fingerMemo,fingerMemoLength:(r=t.fingerMemo)==null?void 0:r.length,groupMemo:t.groupMemo,groupMemoLength:(l=t.groupMemo)==null?void 0:l.length,richFingerMemo:t.richFingerMemo});let n="";if(t.ownerUid)try{const o=await te("ntUserApi","getUinByUid",[t.ownerUid]),a=await te("ntUserApi","getUserSimpleInfo",[t.ownerUid,!1]);n=((i=a==null?void 0:a.coreInfo)==null?void 0:i.nick)||o||""}catch{}return{groupCode:t.groupCode,groupName:t.groupName,remarkName:t.remarkName||"",avatar:is(t.groupCode),memberCount:t.memberNum,maxMemberCount:t.maxMemberNum,ownerUin:t.ownerUid?await te("ntUserApi","getUinByUid",[t.ownerUid]).catch(()=>""):"",ownerName:n,createTime:t.cmdUinJoinTime||void 0,description:t.richFingerMemo||t.fingerMemo||"",announcement:t.groupMemo||""}}function ii(e){const t=new Date(e),n=new Date;if(t.toDateString()===n.toDateString())return t.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});const l=new Date(n);return l.setDate(l.getDate()-1),t.toDateString()===l.toDateString()?`昨天 ${t.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})}`:t.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}async function Oh(e){const t=await te("ntFriendApi","delBuddy",[e]);if((t==null?void 0:t.result)!==0)throw new Error((t==null?void 0:t.errMsg)||"删除好友失败")}async function ag(e,t,n){if(e===2){const r=await te("ntGroupApi","setTop",[t,n]);if((r==null?void 0:r.result)!==0)throw new Error((r==null?void 0:r.errMsg)||"设置置顶失败")}else{const r=await te("ntFriendApi","setTop",[t,n]);if((r==null?void 0:r.result)!==0)throw new Error((r==null?void 0:r.errMsg)||"设置置顶失败")}}var Ct=(e=>(e[e.AllowNotify=1]="AllowNotify",e[e.BoxNotNotify=2]="BoxNotNotify",e[e.NotAllow=3]="NotAllow",e[e.AllowNotNotify=4]="AllowNotNotify",e))(Ct||{});async function qh(e,t){const n=await te("ntGroupApi","setGroupMsgMask",[e,t]);if((n==null?void 0:n.result)!==0)throw new Error((n==null?void 0:n.errMsg)||"设置消息接收方式失败")}const Eu=Object.freeze(Object.defineProperty({__proto__:null,GroupMsgMask:Ct,createEventSource:Ah,deleteFriend:Oh,filterGroups:Fh,filterMembers:$h,formatMessageTime:ii,getAudioProxyUrl:Rh,getFriends:Al,getGroupAvatar:is,getGroupMembers:lg,getGroupProfile:Dh,getGroups:Fl,getLoginInfo:Nh,getMessages:ll,getRecentChats:Wo,getSelfUid:cr,getSelfUin:li,getUserAvatar:_l,getUserDisplayName:Th,getUserInfo:ig,getUserProfile:Ul,getVideoUrl:Eh,isEmptyMessage:og,isValidImageFormat:Uh,kickGroupMember:Ph,muteGroupMember:zh,ntCall:te,quitGroup:_h,recallMessage:Mh,sendMessage:Ho,sendPoke:$l,setGroupMsgMask:qh,setMemberTitle:Lh,setRecentChatTop:ag,setSelfInfo:jh,translatePttToText:Ih,uploadFile:Ch,uploadImage:bh,uploadImageByUrl:Sh},Symbol.toStringTag,{value:"Module"})),cg="modulepreload",ug=function(e){return"/"+e},Mu={},Tu=function(t,n,r){let l=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));l=Promise.allSettled(n.map(c=>{if(c=ug(c),c in Mu)return;Mu[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const m=document.createElement("link");if(m.rel=u?"stylesheet":cg,u||(m.as="script"),m.crossOrigin="",m.href=c,a&&m.setAttribute("nonce",a),document.head.appendChild(m),u)return new Promise((f,y)=>{m.addEventListener("load",f),m.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return l.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return t().catch(i)})},dg=60*60*1e3,Iu=30*60*1e3,Os=new Map;let Ba=new Set,Va=new Set;const Pu=()=>{Ba=new Set,Va=new Set},Qa=(e,t)=>Ba.has(`${e}_${t}`),mg=(e,t)=>{Ba.add(`${e}_${t}`)},hg=e=>Va.has(e),fg=e=>{Va.add(e)},ze=qa()(Wa((e,t)=>({friendCategories:[],groups:[],recentChats:[],groupLastTimeMap:{},groupLastMessageMap:{},contactsLoading:!1,contactsError:null,currentChat:null,activeTab:"recent",groupAssistantMode:"normal",unreadCounts:{},expandedCategories:[],membersCache:{},showMemberPanel:!1,scrollPositions:{},contactsCacheTimestamp:0,setFriendCategories:n=>e({friendCategories:n}),setGroups:n=>e({groups:n}),setRecentChats:n=>e({recentChats:n}),setContactsLoading:n=>e({contactsLoading:n}),setContactsError:n=>e({contactsError:n}),setCurrentChat:n=>e({currentChat:n}),setActiveTab:n=>e({activeTab:n}),setGroupAssistantMode:n=>e({groupAssistantMode:n}),enterGroupAssistant:()=>e({groupAssistantMode:"assistant"}),exitGroupAssistant:()=>e({groupAssistantMode:"normal"}),setUnreadCount:(n,r)=>e(l=>({unreadCounts:{...l.unreadCounts,[n]:r}})),incrementUnreadCount:n=>e(r=>({unreadCounts:{...r.unreadCounts,[n]:(r.unreadCounts[n]||0)+1}})),clearUnreadCount:n=>e(r=>{const{[n]:l,...i}=r.unreadCounts;return{unreadCounts:i}}),initUnreadCounts:n=>{const r={};n.forEach(l=>{l.unreadCount>0&&(r[`${l.chatType}_${l.peerId}`]=l.unreadCount)}),e({unreadCounts:r})},toggleCategory:n=>e(r=>{const l=new Set(r.expandedCategories);return l.has(n)?l.delete(n):l.add(n),{expandedCategories:Array.from(l)}}),setExpandedCategories:n=>e({expandedCategories:n}),getCachedMembers:n=>{const l=t().membersCache[n];return l&&Date.now()-l.timestamp<Iu?l.members:null},setCachedMembers:(n,r)=>e(l=>{const i=Date.now(),o={};for(const[a,c]of Object.entries(l.membersCache))i-c.timestamp<Iu&&(o[a]=c);return{membersCache:{...o,[n]:{members:r,timestamp:i}}}}),fetchGroupMembers:async(n,r=!1)=>{const l=t();if(console.log("[Store] fetchGroupMembers called:",n,"forceRefresh:",r),!r){const a=l.getCachedMembers(n);if(a)return console.log("[Store] Cache hit, returning cached members"),a}const i=Os.get(n);if(i)return console.log("[Store] Already loading, returning existing promise"),i;console.log("[Store] Fetching from API");const o=(async()=>{const{getGroupMembers:a}=await Tu(async()=>{const{getGroupMembers:u}=await Promise.resolve().then(()=>Eu);return{getGroupMembers:u}},void 0),c=await a(n);return console.log("[Store] API success, caching members"),t().setCachedMembers(n,c),Os.delete(n),c})().catch(a=>{throw console.log("[Store] API error:",a.message),Os.delete(n),a});return Os.set(n,o),o},setShowMemberPanel:n=>e({showMemberPanel:n}),getScrollPosition:(n,r)=>{const l=t(),i=`${n}_${r}`;return l.scrollPositions[i]||null},setScrollPosition:(n,r,l)=>e(i=>({scrollPositions:{...i.scrollPositions,[`${n}_${r}`]:l}})),clearScrollPosition:(n,r)=>e(l=>{const{[`${n}_${r}`]:i,...o}=l.scrollPositions;return{scrollPositions:o}}),isContactsCacheValid:()=>{const n=t();return n.contactsCacheTimestamp>0&&Date.now()-n.contactsCacheTimestamp<dg&&(n.friendCategories.length>0||n.groups.length>0)},loadContacts:async()=>{const n=t();if(n.isContactsCacheValid()){n.refreshContacts();return}e({contactsLoading:!0,contactsError:null});try{const[r,l,i]=await Promise.all([Al(),Fl(),Wo()]),o=i.filter(y=>y.peerId&&y.peerId!=="0"&&y.peerId!==""),a=new Map;n.recentChats.forEach(y=>{y.peerId&&y.peerId!=="0"&&y.peerId!==""&&a.set(`${y.chatType}_${y.peerId}`,y)}),o.forEach(y=>{const w=`${y.chatType}_${y.peerId}`,k=a.get(w);k?(y.lastTime>k.lastTime||y.lastTime===k.lastTime&&!k.lastMessage&&y.lastMessage)&&a.set(w,y):a.set(w,y)});const c=Array.from(a.values()).sort((y,w)=>w.lastTime-y.lastTime),u={},d={};o.forEach(y=>{y.chatType===2&&(u[y.peerId]=y.lastTime,y.lastMessage&&(d[y.peerId]=y.lastMessage))}),e({friendCategories:r,groups:l,recentChats:c,groupLastTimeMap:u,groupLastMessageMap:d,contactsCacheTimestamp:Date.now(),contactsLoading:!1});const f={...t().unreadCounts};o.forEach(y=>{const w=`${y.chatType}_${y.peerId}`;!(w in f)&&y.unreadCount>0&&(f[w]=y.unreadCount)}),e({unreadCounts:f})}catch(r){e({contactsError:r.message||"加载联系人失败",contactsLoading:!1})}},refreshContacts:async()=>{try{const[n,r,l]=await Promise.all([Al(),Fl(),Wo()]),i=l.filter(y=>y.peerId&&y.peerId!=="0"&&y.peerId!==""),o=t(),a=new Map;o.recentChats.forEach(y=>{y.peerId&&y.peerId!=="0"&&y.peerId!==""&&a.set(`${y.chatType}_${y.peerId}`,y)}),i.forEach(y=>{const w=`${y.chatType}_${y.peerId}`,k=a.get(w);k?(y.lastTime>k.lastTime||y.lastTime===k.lastTime&&!k.lastMessage&&y.lastMessage)&&a.set(w,y):a.set(w,y)});const c=Array.from(a.values()).sort((y,w)=>w.lastTime-y.lastTime),u={...o.groupLastTimeMap},d={...o.groupLastMessageMap};i.forEach(y=>{y.chatType===2&&(u[y.peerId]=y.lastTime,y.lastMessage&&(d[y.peerId]=y.lastMessage))}),e({friendCategories:n,groups:r,recentChats:c,groupLastTimeMap:u,groupLastMessageMap:d,contactsCacheTimestamp:Date.now()});const f={...t().unreadCounts};i.forEach(y=>{const w=`${y.chatType}_${y.peerId}`;!(w in f)&&y.unreadCount>0&&(f[w]=y.unreadCount)}),e({unreadCounts:f})}catch(n){console.error("Failed to refresh contacts:",n)}},updateRecentChat:(n,r,l,i,o,a)=>e(c=>{const u=c.recentChats.filter((k,j,g)=>g.findIndex(h=>h.chatType===k.chatType&&h.peerId===k.peerId)===j),d=u.find(k=>k.chatType===n&&k.peerId===r),m=c.currentChat,f=(m==null?void 0:m.chatType)===n&&(m==null?void 0:m.peerId)===r,y=n===2?{...c.groupLastTimeMap,[r]:i}:c.groupLastTimeMap,w=n===2?{...c.groupLastMessageMap,[r]:l||"[消息]"}:c.groupLastMessageMap;if(d){const k=u.filter(x=>!(x.chatType===n&&x.peerId===r)),j={...d,lastMessage:l,lastTime:i,unreadCount:f?0:d.unreadCount+1};if(d.pinned){const x=k.filter(N=>N.pinned),v=k.filter(N=>!N.pinned);return{recentChats:[j,...x,...v],groupLastTimeMap:y,groupLastMessageMap:w}}const g=k.filter(x=>x.pinned),h=k.filter(x=>!x.pinned);return{recentChats:[...g,j,...h],groupLastTimeMap:y,groupLastMessageMap:w}}else{let k=o||r,j=a||"";if(n===1||n===100){for(const h of c.friendCategories){const x=h.friends.find(v=>v.uin===r);if(x){k=x.remark||x.nickname,j=x.avatar;break}}j||(j=`https://q1.qlogo.cn/g?b=qq&nk=${r}&s=640`)}else if(n===2){const h=c.groups.find(x=>x.groupCode===r);if(h){if(h.msgMask===2)return{groupLastTimeMap:y,groupLastMessageMap:w};k=h.groupName,j=h.avatar}j||(j=`https://p.qlogo.cn/gh/${r}/${r}/640/`)}return{recentChats:[{chatType:n,peerId:r,peerName:k,peerAvatar:j,lastMessage:l,lastTime:i,unreadCount:f?0:1},...u],groupLastTimeMap:y,groupLastMessageMap:w}}}),togglePinChat:async(n,r)=>{const i=t().recentChats.find(a=>a.chatType===n&&a.peerId===r);if(!i)return;const o=!i.pinned;try{const{setRecentChatTop:a}=await Tu(async()=>{const{setRecentChatTop:c}=await Promise.resolve().then(()=>Eu);return{setRecentChatTop:c}},void 0);await a(n,r,o),e(c=>{const u=c.recentChats.map(d=>d.chatType===n&&d.peerId===r?{...d,pinned:o}:d);return u.sort((d,m)=>d.pinned&&!m.pinned?-1:!d.pinned&&m.pinned?1:m.lastTime-d.lastTime),{recentChats:u}})}catch(a){throw console.error("设置置顶失败:",a),a}},removeRecentChat:(n,r)=>e(l=>({recentChats:l.recentChats.filter(i=>!(i.chatType===n&&i.peerId===r))})),removeFriend:n=>e(r=>({friendCategories:r.friendCategories.map(i=>({...i,friends:i.friends.filter(o=>o.uid!==n),memberCount:i.friends.filter(o=>o.uid!==n).length}))}))}),{name:"webqq-storage",partialize:e=>({friendCategories:e.friendCategories,groups:e.groups,recentChats:e.recentChats,groupLastTimeMap:e.groupLastTimeMap,groupLastMessageMap:e.groupLastMessageMap,expandedCategories:e.expandedCategories,membersCache:e.membersCache,showMemberPanel:e.showMemberPanel,scrollPositions:e.scrollPositions,contactsCacheTimestamp:e.contactsCacheTimestamp,unreadCounts:e.unreadCounts,activeTab:e.activeTab,currentChat:e.currentChat}),onRehydrateStorage:()=>e=>{if(e&&e.recentChats){const t=new Set;e.recentChats=e.recentChats.filter(n=>{if(!n.peerId||n.peerId==="0"||n.peerId==="")return!1;const r=`${n.chatType}_${n.peerId}`;return t.has(r)?!1:(t.add(r),!0)})}}}));function Ga(e,t,n){const[r,l]=p.useState({left:-9999,top:-9999,ready:!1});return p.useEffect(()=>{l({left:-9999,top:-9999,ready:!1});const i=requestAnimationFrame(()=>{if(!n.current){l({left:e,top:t,ready:!0});return}const o=n.current.getBoundingClientRect(),a=10;let c=e,u=t;e+o.width>window.innerWidth-a&&(c=e-o.width),c<a&&(c=a),t+o.height>window.innerHeight-a&&(u=t-o.height),u<a&&(u=a),l({left:c,top:u,ready:!0})});return()=>cancelAnimationFrame(i)},[e,t]),r}const Wh=({groupCode:e,onClose:t})=>{var u;const{groups:n,setGroups:r}=ze(),[l,i]=p.useState(!1),o=p.useRef(null),a=async d=>{try{await qh(e,d);const m=n.map(f=>f.groupCode===e?{...f,msgMask:d}:f);r(m)}catch(m){console.error("设置消息接收方式失败:",m),alert(`设置失败: ${m.message||"未知错误"}`)}t()},c=(u=n.find(d=>d.groupCode===e))==null?void 0:u.msgMask;return s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onMouseEnter:()=>i(!0),className:"w-full px-3 py-2 text-left text-sm hover:bg-theme-item-hover flex items-center gap-2 text-theme",children:[s.jsx(pu,{size:14,className:"flex-shrink-0"}),s.jsx("span",{className:"flex-1",children:"消息接收方式"}),s.jsx(ni,{size:14,className:"flex-shrink-0"})]}),l&&s.jsxs("div",{ref:o,className:"absolute left-full top-0 ml-1 bg-popup backdrop-blur-sm border border-theme-divider rounded-lg shadow-lg py-1 min-w-[140px] z-[10000]",onMouseLeave:()=>i(!1),children:[s.jsxs("button",{onClick:()=>a(Ct.AllowNotify),className:"w-full px-3 py-2 text-left text-sm hover:bg-theme-item-hover flex items-center gap-2 text-theme",children:[s.jsx(pu,{size:14,className:"flex-shrink-0"}),s.jsx("span",{className:"flex-1",children:"接收并提醒"}),c===Ct.AllowNotify&&s.jsx("span",{className:"flex-shrink-0 text-pink-500",children:"✓"})]}),s.jsxs("button",{onClick:()=>a(Ct.AllowNotNotify),className:"w-full px-3 py-2 text-left text-sm hover:bg-theme-item-hover flex items-center gap-2 text-theme",children:[s.jsx(s0,{size:14,className:"flex-shrink-0"}),s.jsx("span",{className:"flex-1",children:"接收但不提醒"}),c===Ct.AllowNotNotify&&s.jsx("span",{className:"flex-shrink-0 text-pink-500",children:"✓"})]}),s.jsxs("button",{onClick:()=>a(Ct.BoxNotNotify),className:"w-full px-3 py-2 text-left text-sm hover:bg-theme-item-hover flex items-center gap-2 text-theme",children:[s.jsx(e0,{size:14,className:"flex-shrink-0"}),s.jsx("span",{className:"flex-1",children:"收进群助手"}),c===Ct.BoxNotNotify&&s.jsx("span",{className:"flex-shrink-0 text-pink-500",children:"✓"})]}),s.jsxs("button",{onClick:()=>a(Ct.NotAllow),className:"w-full px-3 py-2 text-left text-sm hover:bg-theme-item-hover flex items-center gap-2 text-theme",children:[s.jsx(r0,{size:14,className:"flex-shrink-0"}),s.jsx("span",{className:"flex-1",children:"屏蔽群消息"}),c===Ct.NotAllow&&s.jsx("span",{className:"flex-shrink-0 text-pink-500",children:"✓"})]})]})]})},pg=({friend:e,isSelected:t,onClick:n})=>{const{togglePinChat:r}=ze(),[l,i]=p.useState(null),o=p.useRef(null),a=Ga((l==null?void 0:l.x)||0,(l==null?void 0:l.y)||0,o),c=m=>{m.preventDefault(),m.stopPropagation(),i({x:m.clientX,y:m.clientY})},u=()=>i(null),d=async()=>{try{await r(1,e.uin)}catch(m){console.error("置顶失败:",m),alert(`置顶失败: ${m.message||"未知错误"}`)}u()};return p.useEffect(()=>{if(!l)return;const m=()=>u();return document.addEventListener("click",m),()=>document.removeEventListener("click",m)},[l]),s.jsxs(s.Fragment,{children:[s.jsxs("div",{onClick:n,onContextMenu:c,className:`flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors ${t?"bg-pink-500/20":"hover:bg-theme-item-hover"}`,children:[s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx("img",{src:e.avatar,alt:e.nickname,className:"w-10 h-10 rounded-full object-cover",onError:m=>{m.currentTarget.src=`https://q1.qlogo.cn/g?b=qq&nk=${e.uin}&s=640`}}),e.online&&s.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 bg-green-500 rounded-full border-2 border-white dark:border-neutral-800"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-theme truncate",children:e.remark||e.nickname}),e.remark&&s.jsx("div",{className:"text-xs text-theme-hint truncate",children:e.nickname})]})]}),l&&Ie.createPortal(s.jsx("div",{ref:o,className:"fixed bg-white dark:bg-neutral-800 rounded-lg shadow-lg border border-neutral-200 dark:border-neutral-700 py-1 min-w-[120px] z-[9999]",style:{left:`${a.left}px`,top:`${a.top}px`,opacity:a.ready?1:0,pointerEvents:a.ready?"auto":"none"},onClick:m=>m.stopPropagation(),children:s.jsxs("button",{onClick:d,className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-100 dark:hover:bg-neutral-700 flex items-center gap-2 text-theme",children:[s.jsx(Oa,{size:14,className:"flex-shrink-0"}),s.jsx("span",{className:"flex-1",children:e.topTime&&e.topTime!=="0"?"取消置顶":"置顶"})]})}),document.body)]})},xg=({group:e,isSelected:t,onClick:n,showPinnedStyle:r=!1,unreadCount:l=0,subtitle:i})=>{const{togglePinChat:o}=ze(),[a,c]=p.useState(null),u=p.useRef(null),d=Ga((a==null?void 0:a.x)||0,(a==null?void 0:a.y)||0,u),m=w=>{w.preventDefault(),w.stopPropagation(),c({x:w.clientX,y:w.clientY})},f=()=>{c(null)},y=async()=>{try{await o(2,e.groupCode)}catch(w){console.error("置顶失败:",w),alert(`置顶失败: ${w.message||"未知错误"}`)}f()};return p.useEffect(()=>{if(!a)return;const w=()=>f();return document.addEventListener("click",w),()=>document.removeEventListener("click",w)},[a]),s.jsxs(s.Fragment,{children:[s.jsxs("div",{onClick:n,onContextMenu:m,className:`flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors ${t?"bg-pink-500/20":r&&e.isTop?"bg-theme-item-hover":"hover:bg-theme-item-hover"}`,children:[s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx("img",{src:e.avatar,alt:e.groupName,className:"w-10 h-10 rounded-full object-cover",onError:w=>{w.currentTarget.src=`https://p.qlogo.cn/gh/${e.groupCode}/${e.groupCode}/640/`}}),l>0&&s.jsx("div",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] bg-red-500 text-white text-xs font-medium rounded-full flex items-center justify-center px-1",children:l})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-theme truncate",children:e.groupName}),s.jsx("div",{className:"text-xs text-theme-hint truncate",children:i||`${e.memberCount} 人`})]})]}),a&&Ie.createPortal(s.jsxs("div",{ref:u,className:"fixed bg-white dark:bg-neutral-800 rounded-lg shadow-lg border border-neutral-200 dark:border-neutral-700 py-1 min-w-[160px] z-[9999]",style:{left:`${d.left}px`,top:`${d.top}px`,opacity:d.ready?1:0,pointerEvents:d.ready?"auto":"none"},onClick:w=>w.stopPropagation(),children:[s.jsxs("button",{onClick:y,className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-100 dark:hover:bg-neutral-700 flex items-center gap-2 text-theme",children:[s.jsx(Oa,{size:14,className:"flex-shrink-0"}),s.jsx("span",{className:"flex-1",children:e.isTop?"取消置顶":"置顶"})]}),s.jsx(Wh,{groupCode:e.groupCode,onClose:f})]}),document.body)]})},gg=({activeTab:e,onTabChange:t,friendCategories:n,groups:r,recentChats:l,unreadCounts:i,selectedPeerId:o,onSelectFriend:a,onSelectGroup:c,onSelectRecent:u})=>{const[d,m]=p.useState(""),{groupAssistantMode:f,enterGroupAssistant:y,exitGroupAssistant:w}=ze(),k=ze(v=>v.groupLastTimeMap),j=ze(v=>v.groupLastMessageMap),g=p.useMemo(()=>{if(!d.trim())return n;const v=d.toLowerCase();return n.map(N=>({...N,friends:N.friends.filter(S=>S.nickname.toLowerCase().includes(v)||S.remark.toLowerCase().includes(v)||S.uin.includes(d))})).filter(N=>N.friends.length>0)},[n,d]),h=p.useMemo(()=>Fh(r,d),[r,d]),x=[{id:"recent",icon:Ur,label:"最近"},{id:"friends",icon:si,label:"好友"},{id:"groups",icon:Da,label:"群组"}];return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{className:"flex border-b border-theme-divider px-2 pt-2",children:x.map(v=>{const N=v.icon,S=e===v.id;return s.jsxs("button",{onClick:()=>t(v.id),className:`flex-1 flex items-center justify-center gap-1.5 py-2.5 text-sm font-medium transition-colors rounded-t-lg ${S?"text-pink-600 dark:text-pink-400 bg-pink-50/50 dark:bg-pink-900/30":"text-theme-muted hover:text-theme hover:bg-theme-item"}`,children:[s.jsx(N,{size:16}),v.label]},v.id)})}),e!=="recent"&&s.jsx("div",{className:"p-3",children:s.jsxs("div",{className:"relative",children:[s.jsx(ch,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-theme-hint"}),s.jsx("input",{type:"text",value:d,onChange:v=>m(v.target.value),placeholder:e==="friends"?"搜索好友...":"搜索群组...",className:"w-full pl-9 pr-3 py-2 text-sm bg-theme-input border border-theme-input rounded-lg focus:outline-none focus:ring-2 focus:ring-pink-500/20 focus:border-pink-500/50 text-theme placeholder:text-theme-hint"})]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e==="recent"&&f==="normal"&&s.jsx(vg,{items:l,unreadCounts:i,selectedPeerId:o,onSelect:u,onEnterGroupAssistant:y}),e==="recent"&&f==="assistant"&&s.jsx(kg,{groups:r,recentChats:l,groupLastTimeMap:k,groupLastMessageMap:j,unreadCounts:i,selectedPeerId:o,onSelect:c,onBack:w}),e==="friends"&&s.jsx(yg,{categories:g,selectedPeerId:o,onSelect:a}),e==="groups"&&s.jsx(Hh,{items:h,unreadCounts:i,groupLastTimeMap:k,selectedPeerId:o,onSelect:c})]})]})},yg=({categories:e,selectedPeerId:t,onSelect:n})=>{const{expandedCategories:r,toggleCategory:l}=ze(),i=p.useMemo(()=>new Set(r),[r]),o=p.useMemo(()=>e.map(a=>({...a,friends:[...a.friends].sort((c,u)=>{const d=!!(c.topTime&&c.topTime!=="0"),m=!!(u.topTime&&u.topTime!=="0");return d&&!m?-1:!d&&m?1:0})})),[e]);return o.length===0?s.jsx("div",{className:"flex items-center justify-center h-32 text-theme-hint text-sm",children:"暂无好友"}):s.jsx("div",{className:"py-1",children:o.map(a=>{const c=i.has(a.categoryId);return s.jsxs("div",{children:[s.jsxs("div",{onClick:()=>l(a.categoryId),className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-theme-item-hover text-theme-secondary",children:[c?s.jsx(eh,{size:14}):s.jsx(ni,{size:14}),s.jsx("span",{className:"text-xs font-medium",children:a.categoryName}),s.jsxs("span",{className:"text-xs text-theme-hint",children:[a.onlineCount,"/",a.memberCount]})]}),c&&a.friends.map(u=>s.jsx(pg,{friend:u,isSelected:t===u.uin,onClick:()=>n(u)},u.uid))]},a.categoryId)})})},Hh=({items:e,unreadCounts:t,selectedPeerId:n,onSelect:r,groupLastTimeMap:l,subtitleMap:i,showPinnedStyle:o=!1})=>{const a=p.useMemo(()=>[...e].sort((u,d)=>{if(u.isTop&&!d.isTop)return-1;if(!u.isTop&&d.isTop)return 1;if(l){const m=l[u.groupCode]||0,f=l[d.groupCode]||0;if(m!==f)return f-m}return 0}),[e,l]);return a.length===0?s.jsx("div",{className:"flex items-center justify-center h-32 text-theme-hint text-sm",children:"暂无群组"}):s.jsx("div",{className:"py-1",children:a.map(c=>{const u=t.get(`2_${c.groupCode}`)||0;return s.jsx(xg,{group:c,isSelected:n===c.groupCode,onClick:()=>r(c),showPinnedStyle:o,unreadCount:u,subtitle:i==null?void 0:i[c.groupCode]},c.groupCode)})})},vg=({items:e,unreadCounts:t,selectedPeerId:n,onSelect:r,onEnterGroupAssistant:l})=>{const{togglePinChat:i,removeRecentChat:o,friendCategories:a,groups:c}=ze(),[u,d]=p.useState(null),m=p.useRef(null),f=Ga((u==null?void 0:u.x)||0,(u==null?void 0:u.y)||0,m),y=p.useMemo(()=>{const N=c.filter(T=>T.msgMask===2);let S=0;return N.forEach(T=>{const M=t.get(`2_${T.groupCode}`)||0;S+=M}),S},[c,t]),w=p.useMemo(()=>c.filter(N=>N.msgMask===2).length,[c]),k=p.useMemo(()=>e.filter(N=>{if(N.chatType!==2)return!0;const S=c.find(T=>T.groupCode===N.peerId);return(S==null?void 0:S.msgMask)!==2}),[e,c]),j=N=>{if(N.chatType===2){const S=c.find(T=>T.groupCode===N.peerId);if(S!=null&&S.remarkName&&S.remarkName!==S.groupName)return S.remarkName}else if(N.chatType===1||N.chatType===100)for(const S of a){const T=S.friends.find(M=>M.uin===N.peerId);if(T!=null&&T.remark&&T.remark!==T.nickname)return T.remark}return N.peerName},g=(N,S)=>{N.preventDefault(),d({x:N.clientX,y:N.clientY,item:S})},h=()=>{d(null)},x=async()=>{if(u){try{await i(u.item.chatType,u.item.peerId)}catch(N){console.error("置顶失败:",N),alert(`置顶失败: ${N.message||"未知错误"}`)}h()}},v=()=>{u&&(o(u.item.chatType,u.item.peerId),h())};return k.length===0&&w===0?s.jsx("div",{className:"flex items-center justify-center h-32 text-theme-hint text-sm",children:"暂无最近会话"}):s.jsxs("div",{className:"py-1",onClick:h,children:[w>0&&s.jsxs("div",{onClick:l,className:"flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors hover:bg-theme-item-hover",children:[s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-blue-400 to-blue-600 flex items-center justify-center",children:s.jsx(Da,{size:20,className:"text-white"})}),y>0&&s.jsx("div",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] bg-red-500 text-white text-xs font-medium rounded-full flex items-center justify-center px-1",children:y})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsx("span",{className:"text-sm font-medium text-theme",children:"群助手"})}),s.jsxs("div",{className:"text-xs text-theme-hint truncate mt-0.5",children:[w," 个群聊"]})]})]}),k.map(N=>s.jsx(wg,{item:N,displayName:j(N),unreadCount:t.get(`${N.chatType}_${N.peerId}`)||N.unreadCount,isSelected:n===N.peerId,onClick:()=>r(N),onContextMenu:S=>g(S,N)},`${N.chatType}_${N.peerId}`)),u&&Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:h,onContextMenu:N=>{N.preventDefault(),h()}}),s.jsxs("div",{ref:m,className:"fixed z-50 bg-popup backdrop-blur-sm border border-theme-divider rounded-lg shadow-lg py-1 min-w-[160px]",style:{left:f.left,top:f.top,visibility:f.ready?"visible":"hidden"},onContextMenu:N=>N.preventDefault(),children:[s.jsxs("button",{onClick:x,className:"w-full px-3 py-2 text-left text-sm hover:bg-theme-item-hover flex items-center gap-2 text-theme",children:[s.jsx(Oa,{size:14,className:"flex-shrink-0"}),s.jsx("span",{className:"flex-1",children:u.item.pinned?"取消置顶":"置顶"})]}),u.item.chatType===2&&s.jsx(Wh,{groupCode:u.item.peerId,onClose:h}),s.jsxs("button",{onClick:v,className:"w-full px-3 py-2 text-left text-sm hover:bg-theme-item-hover flex items-center gap-2 text-red-500",children:[s.jsx(It,{size:14,className:"flex-shrink-0"}),s.jsx("span",{className:"flex-1",children:"删除"})]})]})]}),document.body)]})},wg=({item:e,displayName:t,unreadCount:n,isSelected:r,onClick:l,onContextMenu:i})=>s.jsxs("div",{onClick:l,onContextMenu:i,className:`flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors ${r?"bg-pink-500/20":e.pinned?"bg-theme-item-hover":"hover:bg-theme-item-hover"}`,children:[s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx("img",{src:e.peerAvatar,alt:t,className:"w-10 h-10 rounded-full object-cover"}),n>0&&s.jsx("div",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] bg-red-500 text-white text-xs font-medium rounded-full flex items-center justify-center px-1",children:n})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-theme truncate",children:t}),s.jsx("span",{className:"text-xs text-theme-hint flex-shrink-0 ml-2",children:ii(e.lastTime)})]}),s.jsx("div",{className:"text-xs text-theme-hint truncate mt-0.5",children:e.lastMessage})]})]}),kg=({groups:e,recentChats:t,groupLastTimeMap:n,groupLastMessageMap:r,unreadCounts:l,selectedPeerId:i,onSelect:o,onBack:a})=>{const c=p.useMemo(()=>e.filter(d=>d.msgMask===2),[e]),u=p.useMemo(()=>{const d={...r};return t.forEach(m=>{m.chatType===2&&m.lastMessage&&(d[m.peerId]=m.lastMessage)}),d},[r,t]);return s.jsxs("div",{className:"py-1",children:[s.jsxs("div",{onClick:a,className:"flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors hover:bg-theme-item-hover border-b border-theme-divider",children:[s.jsx(ni,{size:16,className:"transform rotate-180 text-theme-secondary"}),s.jsx("span",{className:"text-sm font-medium text-theme",children:"返回最近会话"})]}),s.jsxs("div",{className:"px-3 py-2 text-xs text-theme-hint",children:["群助手 (",c.length,")"]}),c.length===0?s.jsx("div",{className:"flex items-center justify-center h-32 text-theme-hint text-sm",children:"暂无群聊"}):s.jsx(Hh,{items:c,unreadCounts:l,groupLastTimeMap:n,subtitleMap:u,selectedPeerId:i,onSelect:o,showPinnedStyle:!0})]})};function zn(e,t,n){let r=n.initialDeps??[],l,i=!0;function o(){var a,c,u;let d;n.key&&((a=n.debug)!=null&&a.call(n))&&(d=Date.now());const m=e();if(!(m.length!==r.length||m.some((w,k)=>r[k]!==w)))return l;r=m;let y;if(n.key&&((c=n.debug)!=null&&c.call(n))&&(y=Date.now()),l=t(...m),n.key&&((u=n.debug)!=null&&u.call(n))){const w=Math.round((Date.now()-d)*100)/100,k=Math.round((Date.now()-y)*100)/100,j=k/16,g=(h,x)=>{for(h=String(h);h.length<x;)h=" "+h;return h};console.info(`%c⏱ ${g(k,5)} /${g(w,5)} ms`,`
437
437
  font-size: .6rem;
438
438
  font-weight: bold;
439
- color: hsl(${Math.max(0,Math.min(120-120*j,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(l),i=!1,l}return o.updateDeps=a=>{r=a},o}function zu(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const jg=(e,t)=>Math.abs(e-t)<1.01,Ng=(e,t,n)=>{let r;return function(...l){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,l),n)}},Lu=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},bg=e=>e,Sg=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let l=t;l<=n;l++)r.push(l);return r},Cg=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const l=o=>{const{width:a,height:c}=o;t({width:Math.round(a),height:Math.round(c)})};if(l(Lu(n)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(o=>{const a=()=>{const c=o[0];if(c!=null&&c.borderBoxSize){const u=c.borderBoxSize[0];if(u){l({width:u.inlineSize,height:u.blockSize});return}}l(Lu(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},Ru={passive:!0},_u=typeof window>"u"?!0:"onscrollend"in window,Eg=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let l=0;const i=e.options.useScrollendEvent&&_u?()=>{}:Ng(r,()=>{t(l,!1)},e.options.isScrollingResetDelay),o=d=>()=>{const{horizontal:m,isRtl:f}=e.options;l=m?n.scrollLeft*(f&&-1||1):n.scrollTop,i(),t(l,d)},a=o(!0),c=o(!1);n.addEventListener("scroll",a,Ru);const u=e.options.useScrollendEvent&&_u;return u&&n.addEventListener("scrollend",c,Ru),()=>{n.removeEventListener("scroll",a),u&&n.removeEventListener("scrollend",c)}},Mg=(e,t,n)=>{if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},Tg=(e,{adjustments:t=0,behavior:n},r)=>{var l,i;const o=e+t;(i=(l=r.scrollElement)==null?void 0:l.scrollTo)==null||i.call(l,{[r.options.horizontal?"left":"top"]:o,behavior:n})};class Ig{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(l=>{l.forEach(i=>{const o=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var l;(l=r())==null||l.disconnect(),n=null},observe:l=>{var i;return(i=r())==null?void 0:i.observe(l,{box:"border-box"})},unobserve:l=>{var i;return(i=r())==null?void 0:i.unobserve(l)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,l])=>{typeof l>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:bg,rangeExtractor:Sg,onChange:()=>{},measureElement:Mg,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,l;(l=(r=this.options).onChange)==null||l.call(r,this,n)},this.maybeNotify=zn(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(l=>{this.observer.observe(l)}),this.unsubs.push(this.options.observeElementRect(this,l=>{this.scrollRect=l,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(l,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<l?"forward":"backward":null,this.scrollOffset=l,this.isScrolling=i,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const l=new Map,i=new Map;for(let o=r-1;o>=0;o--){const a=n[o];if(l.has(a.lane))continue;const c=i.get(a.lane);if(c==null||a.end>c.end?i.set(a.lane,a):a.end<c.end&&l.set(a.lane,!0),l.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=zn(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(n,r,l,i,o,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:l,getItemKey:i,enabled:o,lanes:a}),{key:!1}),this.getMeasurements=zn(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:l,getItemKey:i,enabled:o,lanes:a},c)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const f of this.laneAssignments.keys())f>=n&&this.laneAssignments.delete(f);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(f=>{this.itemSizeCache.set(f.key,f.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1);const d=this.measurementsCache.slice(0,u),m=new Array(a).fill(void 0);for(let f=0;f<u;f++){const y=d[f];y&&(m[y.lane]=f)}for(let f=u;f<n;f++){const y=i(f),w=this.laneAssignments.get(f);let k,j;if(w!==void 0&&this.options.lanes>1){k=w;const v=m[k],N=v!==void 0?d[v]:void 0;j=N?N.end+this.options.gap:r+l}else{const v=this.options.lanes===1?d[f-1]:this.getFurthestMeasurement(d,f);j=v?v.end+this.options.gap:r+l,k=v?v.lane:f%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(f,k)}const g=c.get(y),h=typeof g=="number"?g:this.options.estimateSize(f),x=j+h;d[f]={index:f,start:j,size:h,end:x,key:y,lane:k},m[k]=f}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=zn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,l,i)=>this.range=n.length>0&&r>0?Pg({measurements:n,outerSize:r,scrollOffset:l,lanes:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=zn(()=>{let n=null,r=null;const l=this.calculateRange();return l&&(n=l.startIndex,r=l.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,l,i,o)=>i===null||o===null?[]:n({startIndex:i,endIndex:o,overscan:r,count:l}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,l=n.getAttribute(r);return l?parseInt(l,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const l=this.indexFromElement(n),i=this.measurementsCache[l];if(!i)return;const o=i.key,a=this.elementsCache.get(o);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(o,n)),n.isConnected&&this.resizeItem(l,this.options.measureElement(n,r,this))},this.resizeItem=(n,r)=>{const l=this.measurementsCache[n];if(!l)return;const i=this.itemSizeCache.get(l.key)??l.size,o=r-i;o!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(l,o,this):l.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(l.index),this.itemSizeCache=new Map(this.itemSizeCache.set(l.key,r)),this.notify(!1))},this.measureElement=n=>{if(!n){this.elementsCache.forEach((r,l)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(l))});return}this._measureElement(n,void 0)},this.getVirtualItems=zn(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const l=[];for(let i=0,o=n.length;i<o;i++){const a=n[i],c=r[a];l.push(c)}return l},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return zu(r[Bh(0,r.length-1,l=>zu(r[l]).start,n)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(n,r,l=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),o=this.getScrollOffset();r==="auto"&&(r=n>=o+i?"end":"start"),r==="center"?n+=(l-i)/2:r==="end"&&(n-=i);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const l=this.measurementsCache[n];if(!l)return;const i=this.getSize(),o=this.getScrollOffset();if(r==="auto")if(l.end>=o+i-this.options.scrollPaddingEnd)r="end";else if(l.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const a=r==="end"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,r,l.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(n,{align:r="start",behavior:l}={})=>{l==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:l})},this.scrollToIndex=(n,{align:r="auto",behavior:l}={})=>{l==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),n=Math.max(0,Math.min(n,this.options.count-1)),this.currentScrollToIndex=n;let i=0;const o=10,a=u=>{if(!this.targetWindow)return;const d=this.getOffsetForIndex(n,u);if(!d){console.warn("Failed to get offset for index:",n);return}const[m,f]=d;this._scrollToOffset(m,{adjustments:void 0,behavior:l}),this.targetWindow.requestAnimationFrame(()=>{const y=()=>{if(this.currentScrollToIndex!==n)return;const w=this.getScrollOffset(),k=this.getOffsetForIndex(n,f);if(!k){console.warn("Failed to get offset for index:",n);return}jg(k[0],w)||c(f)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(y):y()})},c=u=>{this.targetWindow&&this.currentScrollToIndex===n&&(i++,i<o?this.targetWindow.requestAnimationFrame(()=>a(u)):console.warn(`Failed to scroll to index ${n} after ${o} attempts.`))};a(r)},this.scrollBy=(n,{behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let l;if(r.length===0)l=this.options.paddingStart;else if(this.options.lanes===1)l=((n=r[r.length-1])==null?void 0:n.end)??0;else{const i=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&i.some(a=>a===null);){const a=r[o];i[a.lane]===null&&(i[a.lane]=a.end),o--}l=Math.max(...i.filter(a=>a!==null))}return Math.max(l-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:l})=>{this.options.scrollToFn(n,{behavior:l,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}}const Bh=(e,t,n,r)=>{for(;e<=t;){const l=(e+t)/2|0,i=n(l);if(i<r)e=l+1;else if(i>r)t=l-1;else return l}return e>0?e-1:0};function Pg({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const l=e.length-1,i=c=>e[c].start;if(e.length<=r)return{startIndex:0,endIndex:l};let o=Bh(0,l,i,n),a=o;if(r===1)for(;a<l&&e[a].end<n+t;)a++;else if(r>1){const c=Array(r).fill(0);for(;a<l&&c.some(d=>d<n+t);){const d=e[a];c[d.lane]=d.end,a++}const u=Array(r).fill(n+t);for(;o>=0&&u.some(d=>d>=n);){const d=e[o];u[d.lane]=d.start,o--}o=Math.max(0,o-o%r),a=Math.min(l,a+(r-1-a%r))}return{startIndex:o,endIndex:a}}const Au=typeof document<"u"?p.useLayoutEffect:p.useEffect;function zg({useFlushSync:e=!0,...t}){const n=p.useReducer(()=>({}),{})[1],r={...t,onChange:(i,o)=>{var a;e&&o?Ie.flushSync(n):n(),(a=t.onChange)==null||a.call(t,i,o)}},[l]=p.useState(()=>new Ig(r));return l.setOptions(r),Au(()=>l._didMount(),[]),Au(()=>l._willUpdate()),l}function Vh(e){return zg({observeElementRect:Cg,observeElementOffset:Eg,scrollToFn:Tg,...e})}const Lg="webqq-messages",Rg=1,lr="messages",Qh=100;let qs=null;function Gh(){return qs?Promise.resolve(qs):new Promise((e,t)=>{const n=indexedDB.open(Lg,Rg);n.onerror=()=>t(n.error),n.onsuccess=()=>{qs=n.result,e(qs)},n.onupgradeneeded=r=>{const l=r.target.result;l.objectStoreNames.contains(lr)||l.createObjectStore(lr,{keyPath:"chatKey"})}})}async function fs(e,t){try{const n=await Gh(),r=`${e}_${t}`;return new Promise(l=>{const a=n.transaction(lr,"readonly").objectStore(lr).get(r);a.onsuccess=()=>{const c=a.result;c&&c.messages?l(c.messages):l(null)},a.onerror=()=>l(null)})}catch{return null}}async function kn(e,t,n){try{const r=await Gh(),l=`${e}_${t}`,i=n.slice(-Qh);return new Promise((o,a)=>{const d=r.transaction(lr,"readwrite").objectStore(lr).put({chatKey:l,messages:i,timestamp:Date.now()});d.onsuccess=()=>o(),d.onerror=()=>a(d.error)})}catch(r){console.error("Failed to cache messages:",r)}}async function Kh(e,t,n){try{const r=await fs(e,t);if(r){const l=[...r.slice(-(Qh-1)),n];await kn(e,t,l)}}catch(r){console.error("Failed to append message:",r)}}async function _g(e,t,n){try{const r=await fs(e,t);if(r){const l=r.filter(i=>i.msgId!==n);await kn(e,t,l)}}catch(r){console.error("Failed to remove message:",r)}}async function Ag(e,t,n,r,l){try{const i=await fs(e,t);if(!i)return;const o=i.map(a=>{if(a.msgSeq!==n)return a;const c=a.emojiLikesList||[];if(l){const u=c.findIndex(d=>d.emojiId===r);if(u>=0){const d=[...c];return d[u]={...d[u],likesCnt:String(parseInt(d[u].likesCnt)+1)},{...a,emojiLikesList:d}}else return{...a,emojiLikesList:[...c,{emojiId:r,emojiType:parseInt(r)>999?"2":"1",likesCnt:"1",isClicked:!1}]}}else{const u=c.findIndex(d=>d.emojiId===r);if(u>=0){const d=[...c],m=parseInt(d[u].likesCnt)-1;return m<=0?d.splice(u,1):d[u]={...d[u],likesCnt:String(m)},{...a,emojiLikesList:d}}}return a});await kn(e,t,o)}catch(i){console.error("Failed to update emoji reaction:",i)}}async function Fg(e,t,n,r){try{const l=await fs(e,t);if(!l)return!1;let i=!1;const o=l.map(a=>a.msgId===n||r&&a.msgSeq===r?(i=!0,{...a,recallTime:String(Math.floor(Date.now()/1e3))}):a);return i&&await kn(e,t,o),i}catch(l){return console.error("Failed to mark message as recalled:",l),!1}}const $g=({level:e})=>{const t=e%4,n=Math.floor(e/4)%4,r=Math.floor(e/16)%4,l=Math.floor(e/64)%4,i=Math.floor(e/256),o=[];for(let a=0;a<i;a++)o.push(s.jsx("span",{className:"text-amber-400 text-xs font-bold",title:"金企鹅",children:"🐧"},`penguin-${a}`));for(let a=0;a<l;a++)o.push(s.jsx(ri,{size:14,className:"text-amber-500"},`crown-${a}`));for(let a=0;a<r;a++)o.push(s.jsx(hh,{size:14,className:"text-orange-400"},`sun-${a}`));for(let a=0;a<n;a++)o.push(s.jsx(sh,{size:14,className:"text-blue-400"},`moon-${a}`));for(let a=0;a<t;a++)o.push(s.jsx(mh,{size:14,className:"text-yellow-400 fill-yellow-400"},`star-${a}`));return s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:o})},Yh=({profile:e,loading:t,position:n,onClose:r,isFriend:l,onFriendDeleted:i})=>{const o=p.useRef(null),[a,c]=p.useState({left:n.x,top:n.y}),[u,d]=p.useState(!1),[m,f]=p.useState(!1);if(p.useEffect(()=>{if(!o.current)return;const x=320,v=o.current.offsetHeight||400;let N=n.x,S=n.y;N+x>window.innerWidth-20&&(N=window.innerWidth-x-20),N<20&&(N=20),S+v>window.innerHeight-20&&(S=window.innerHeight-v-20),S<20&&(S=20),c({left:N,top:S})},[n,e,t]),!e&&!t)return null;const y=x=>x===1?"男":x===2?"女":"",w=x=>{if(!x)return"";const v=new Date(x*1e3),N=new Date,S=N.getFullYear()-v.getFullYear(),T=N.getMonth()-v.getMonth(),M=S+(T<0?-1:0);if(M<1){const q=S*12+T;return q>0?`${q}个月`:"不足1个月"}return`${M}年`},k=x=>x==="owner"?"群主":x==="admin"?"管理员":"",j=x=>x==="owner"?"bg-amber-500 text-white":x==="admin"?"bg-green-500 text-white":"",g=async()=>{if(e){f(!0);try{await Oh(e.uid),Y("已删除好友","success"),i==null||i(e.uid),r()}catch(x){Y(x.message||"删除好友失败","error")}finally{f(!1),d(!1)}}},h=x=>x?new Date(x*1e3).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"";return Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:r}),s.jsxs("div",{ref:o,className:"fixed z-50 border border-theme-divider rounded-xl shadow-xl overflow-hidden bg-popup backdrop-blur-sm",style:{left:a.left,top:a.top,width:320,maxHeight:"calc(100vh - 40px)"},onClick:x=>x.stopPropagation(),children:[t?s.jsx("div",{className:"flex items-center justify-center h-40",children:s.jsx(Se,{size:24,className:"animate-spin text-pink-500"})}):e&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"bg-gradient-to-r from-pink-400 to-amber-300 p-4 relative",children:[l&&!e.groupRole&&s.jsx("button",{onClick:()=>d(!0),className:"absolute top-2 right-2 p-1.5 rounded-full bg-white/20 hover:bg-white/40 text-white transition-colors",title:"删除好友",children:s.jsx(It,{size:16})}),s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("img",{src:e.avatar,alt:e.nickname,className:"w-16 h-16 rounded-full border-3 border-white/80 object-cover flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0 text-white pt-1",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("span",{className:"font-bold text-lg truncate",children:e.nickname}),e.groupRole&&k(e.groupRole)&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${j(e.groupRole)}`,children:k(e.groupRole)})]}),e.remark&&e.remark!==e.nickname&&s.jsxs("div",{className:"text-white/80 text-sm truncate mb-1",children:["备注: ",e.remark]}),s.jsx("div",{className:"text-white/90 text-sm",children:e.uin}),e.qid&&s.jsxs("div",{className:"text-white/70 text-xs mt-0.5",children:["QID: ",e.qid]})]})]})]}),s.jsxs("div",{className:"p-4 overflow-y-auto",style:{maxHeight:"calc(100vh - 40px - 120px)"},children:[e.signature&&s.jsx("div",{className:"text-theme-secondary text-sm mb-3 bg-theme-item/50 rounded-lg px-3 py-2 max-h-24 overflow-y-auto break-words",children:e.signature}),s.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[y(e.sex)&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"性别"}),s.jsx("span",{className:"text-theme",children:y(e.sex)})]}),e.birthday&&e.birthday!=="0-0-0"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"生日"}),s.jsx("span",{className:"text-theme",children:e.birthday})]}),w(e.regTime)&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"Q龄"}),s.jsx("span",{className:"text-theme",children:w(e.regTime)})]}),e.level>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"等级"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-theme",children:["Lv.",e.level]}),s.jsx($g,{level:e.level})]})]})]}),(e.groupCard||e.groupTitle||e.groupLevel)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-theme-divider my-3"}),s.jsx("div",{className:"text-xs text-theme-hint mb-2",children:"群信息"}),s.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.groupCard&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"群名片"}),s.jsx("span",{className:"text-theme truncate",children:e.groupCard})]}),e.groupTitle&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"群头衔"}),s.jsx("span",{className:"text-pink-500",children:e.groupTitle})]}),e.groupLevel!==void 0&&e.groupLevel>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"群等级"}),s.jsxs("span",{className:"text-theme",children:["Lv.",e.groupLevel]})]}),e.joinTime&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"入群时间"}),s.jsx("span",{className:"text-theme",children:h(e.joinTime)})]}),e.lastSpeakTime&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"最后发言"}),s.jsx("span",{className:"text-theme",children:h(e.lastSpeakTime)})]})]})]})]})]}),u&&e&&s.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center rounded-xl",children:s.jsxs("div",{className:"bg-popup m-4 p-4 rounded-lg shadow-lg max-w-[280px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("span",{className:"font-medium text-theme",children:"删除好友"}),s.jsx("button",{onClick:()=>d(!1),className:"text-theme-muted hover:text-theme",children:s.jsx(ht,{size:18})})]}),s.jsxs("p",{className:"text-sm text-theme-secondary mb-4",children:["确定要删除好友 ",s.jsx("span",{className:"font-medium text-theme",children:e.remark||e.nickname})," 吗?删除后将无法恢复。"]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx("button",{onClick:()=>d(!1),className:"px-3 py-1.5 text-sm rounded-lg bg-theme-item hover:bg-theme-hover text-theme transition-colors",disabled:m,children:"取消"}),s.jsxs("button",{onClick:g,className:"px-3 py-1.5 text-sm rounded-lg bg-red-500 hover:bg-red-600 text-white transition-colors flex items-center gap-1",disabled:m,children:[m&&s.jsx(Se,{size:14,className:"animate-spin"}),"删除"]})]})]})})]})]}),document.body)},Ug=({profile:e,loading:t,position:n,onClose:r,onQuitGroup:l})=>{const i=p.useRef(null),[o,a]=p.useState({left:n.x,top:n.y}),[c,u]=p.useState(!1),d=li(),m=(e==null?void 0:e.ownerUin)===d;if(p.useEffect(()=>{if(!i.current)return;const k=320,j=i.current.offsetHeight||300;let g=n.x,h=n.y;g+k>window.innerWidth-20&&(g=window.innerWidth-k-20),g<20&&(g=20),h+j>window.innerHeight-20&&(h=window.innerHeight-j-20),h<20&&(h=20),a({left:g,top:h})},[n,e,t]),!e&&!t)return null;const f=k=>k?new Date(k*1e3).toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}):"",y=()=>{u(!0)},w=()=>{e&&l&&l(e.groupCode,m),u(!1),r()};return Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:r}),s.jsx("div",{ref:i,className:"fixed z-50 border border-theme-divider rounded-xl shadow-xl overflow-hidden bg-popup backdrop-blur-sm",style:{left:o.left,top:o.top,width:320,maxHeight:"calc(100vh - 40px)"},onClick:k=>k.stopPropagation(),children:t?s.jsx("div",{className:"flex items-center justify-center h-40",children:s.jsx(Se,{size:24,className:"animate-spin text-pink-500"})}):e&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"bg-gradient-to-r from-blue-400 to-cyan-300 p-4 relative",children:[l&&s.jsx("button",{onClick:y,className:"absolute top-3 right-3 p-1.5 rounded-full bg-white/20 hover:bg-white/30 text-white transition-colors",title:m?"解散该群":"退出该群",children:s.jsx(x0,{size:16})}),s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("img",{src:e.avatar,alt:e.groupName,className:"w-16 h-16 rounded-lg border-3 border-white/80 object-cover flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0 text-white pt-1 pr-6",children:[s.jsx("div",{className:"font-bold text-lg truncate mb-1",children:e.groupName}),e.remarkName&&e.remarkName!==e.groupName&&s.jsxs("div",{className:"text-white/80 text-sm truncate mb-1",children:["备注: ",e.remarkName]}),s.jsx("div",{className:"text-white/90 text-sm",children:e.groupCode})]})]})]}),s.jsxs("div",{className:"p-4 overflow-y-auto",style:{maxHeight:"calc(100vh - 40px - 140px)"},children:[s.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[s.jsxs("span",{className:"text-theme-hint flex items-center gap-1",children:[s.jsx(si,{size:14}),"成员"]}),s.jsxs("span",{className:"text-theme",children:[e.memberCount,e.maxMemberCount?` / ${e.maxMemberCount}`:""]}),e.ownerName&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-theme-hint flex items-center gap-1",children:[s.jsx(ri,{size:14}),"群主"]}),s.jsx("span",{className:"text-theme truncate",children:e.ownerName})]}),e.createTime&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-theme-hint flex items-center gap-1",children:[s.jsx(o0,{size:14}),"创建"]}),s.jsx("span",{className:"text-theme",children:f(e.createTime)})]})]}),e.description&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-theme-divider my-3"}),s.jsx("div",{className:"text-xs text-theme-hint mb-2",children:"群简介"}),s.jsx("div",{className:"text-theme-secondary text-sm bg-theme-item/50 rounded-lg px-3 py-2 break-words whitespace-pre-wrap",style:{maxHeight:"120px",overflowY:"auto"},children:e.description})]}),e.announcement&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-theme-divider my-3"}),s.jsxs("div",{className:"text-xs text-theme-hint mb-2 flex items-center gap-1",children:[s.jsx(ms,{size:12}),"群公告"]}),s.jsx("div",{className:"text-theme-secondary text-sm bg-theme-item/50 rounded-lg px-3 py-2 break-words whitespace-pre-wrap",style:{maxHeight:"120px",overflowY:"auto"},children:e.announcement})]})]})]})}),c&&e&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[60] bg-black/50",onClick:()=>u(!1)}),s.jsxs("div",{className:"fixed z-[70] top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-theme-card border border-theme-divider rounded-xl shadow-xl p-6 min-w-[320px]",children:[s.jsx("h3",{className:"text-lg font-medium text-theme mb-4",children:m?"确认解散群聊":"确认退出群聊"}),s.jsx("p",{className:"text-theme-secondary mb-6",children:m?s.jsxs(s.Fragment,{children:["确定要解散群 ",s.jsx("span",{className:"font-medium text-theme",children:e.groupName})," 吗?此操作不可撤销,所有群成员将被移出。"]}):s.jsxs(s.Fragment,{children:["确定要退出群 ",s.jsx("span",{className:"font-medium text-theme",children:e.groupName})," 吗?"]})}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx("button",{onClick:()=>u(!1),className:"px-4 py-2 text-sm text-theme-secondary hover:bg-theme-item rounded-lg transition-colors",children:"取消"}),s.jsx("button",{onClick:w,className:"px-4 py-2 text-sm bg-red-500 hover:bg-red-600 text-white rounded-lg transition-colors",children:m?"确认解散":"确认退出"})]})]})]})]}),document.body)},Dg=({url:e,onClose:t})=>e?Ie.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[s.jsx("button",{onClick:t,className:"absolute top-4 right-4 p-2 text-white/80 hover:text-white bg-black/50 rounded-full",children:s.jsx(ht,{size:24})}),s.jsx("img",{src:e,alt:"预览",className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:n=>n.stopPropagation()})]}),document.body):null,Og=({videoInfo:e,onClose:t})=>{const[n,r]=p.useState(null),[l,i]=p.useState(!1),[o,a]=p.useState(null);return p.useEffect(()=>{if(!e){r(null),a(null);return}i(!0),a(null),Eh(e.chatType,e.peerUid,e.msgId,e.elementId).then(r).catch(c=>a(c.message||"获取视频失败")).finally(()=>i(!1))},[e]),e?Ie.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[s.jsx("button",{onClick:t,className:"absolute top-4 right-4 p-2 text-white/80 hover:text-white bg-black/50 rounded-full z-10",children:s.jsx(ht,{size:24})}),l&&s.jsxs("div",{className:"text-white flex items-center gap-2",children:[s.jsx(Se,{size:24,className:"animate-spin"}),"加载中..."]}),o&&s.jsx("div",{className:"text-red-400",children:o}),n&&!l&&s.jsx("video",{src:n,controls:!0,autoPlay:!0,className:"max-w-[90vw] max-h-[90vh]",onClick:c=>c.stopPropagation()})]}),document.body):null},Xh=ce.createContext(null),Jh=ce.createContext(null),Zh=ce.createContext(null),qg=e=>e?e.startsWith("blob:")?e:e.includes("qpic.cn")||e.includes("multimedia.nt.qq.com.cn")?`/api/webqq/image-proxy?url=${encodeURIComponent(e)}&token=${encodeURIComponent(hs()||"")}`:e:"",Wi=p.memo(({element:e,message:t})=>{var y;const[n,r]=p.useState(!1),[l,i]=p.useState(!1),[o,a]=p.useState(!1),[c,u]=p.useState(!1),d=ce.useContext(Xh),m=ce.useContext(Jh),f=ce.useContext(Zh);if(e.textElement)return s.jsx("span",{className:"whitespace-pre-wrap break-all",style:{overflowWrap:"anywhere",wordBreak:"break-all"},children:e.textElement.content});if(e.picElement){const w=e.picElement;let k=w.originImageUrl?w.originImageUrl.startsWith("http")?w.originImageUrl:`https://gchat.qpic.cn${w.originImageUrl}`:"";const j=qg(k),g=200,h=300;let x=w.picWidth||200,v=w.picHeight||200;v>g&&(x=x*g/v,v=g),x>h&&(v=v*h/x,x=h);const N=S=>{t&&(S.preventDefault(),S.stopPropagation(),f==null||f.showMenu(S,t,e.elementId))};return s.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-theme-item cursor-pointer",style:{width:x,height:v},onClick:()=>d==null?void 0:d.showPreview(j),onContextMenu:N,children:[!n&&!l&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-theme-hint",children:s.jsx(Se,{size:24,className:"animate-spin"})}),l&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-theme-hint text-xs",children:"图片加载失败"}),s.jsx("img",{src:j,alt:"图片",loading:"lazy",className:`w-full h-full object-cover transition-opacity ${n?"opacity-100":"opacity-0"}`,onLoad:()=>r(!0),onError:()=>i(!0)})]})}if(e.faceElement){const w=e.faceElement.faceIndex,k=e.faceElement.faceText;return s.jsx("img",{src:`/face/${w}.png`,alt:k||`[表情${w}]`,title:k||`表情${w}`,className:"inline-block align-text-bottom",style:{width:24,height:24},onError:j=>{var x;const g=j.target;g.style.display="none";const h=document.createElement("span");h.textContent=k||`[表情${w}]`,(x=g.parentNode)==null||x.insertBefore(h,g)}})}if(e.fileElement)return s.jsxs("span",{children:["[文件: ",e.fileElement.fileName,"]"]});if(e.pttElement)return s.jsx(Bg,{element:e,message:t});if(e.videoElement){const w=e.videoElement,k=200,j=300;let g=w.thumbWidth||200,h=w.thumbHeight||150;h>k&&(g=g*k/h,h=k),g>j&&(h=h*j/g,g=j);let x="";if(w.thumbPath){let q;w.thumbPath instanceof Map?q=w.thumbPath.values().next().value:typeof w.thumbPath=="object"&&(q=Object.values(w.thumbPath)[0]),q&&(x=`/api/webqq/file-proxy?path=${encodeURIComponent(q)}&token=${encodeURIComponent(hs()||"")}`)}const v=w.fileTime||0,N=Math.floor(v/60),S=v%60,T=`${N}:${S.toString().padStart(2,"0")}`,M=()=>{t&&e.elementId&&(m==null||m.showPreview(t.chatType,t.peerUid,t.msgId,e.elementId))};return s.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-theme-item cursor-pointer group",style:{width:g,height:h},onClick:M,children:[s.jsx("div",{className:"absolute inset-0 bg-gray-200 dark:bg-gray-700"}),x?s.jsxs(s.Fragment,{children:[!o&&!c&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-theme-hint",children:s.jsx(Se,{size:24,className:"animate-spin"})}),s.jsx("img",{src:x,alt:"视频缩略图",loading:"lazy",className:`absolute inset-0 w-full h-full object-cover transition-opacity ${o?"opacity-100":"opacity-0"}`,onLoad:()=>a(!0),onError:()=>u(!0)})]}):s.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-theme-hint text-xs",children:"视频"}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsx("div",{className:"w-12 h-12 rounded-full bg-black/50 flex items-center justify-center group-hover:bg-black/70 transition-colors",children:s.jsx("div",{className:"w-0 h-0 border-t-8 border-t-transparent border-l-12 border-l-white border-b-8 border-b-transparent ml-1",style:{borderLeftWidth:"14px"}})})}),s.jsx("div",{className:"absolute bottom-1 right-1 px-1.5 py-0.5 bg-black/60 rounded text-white text-xs",children:T})]})}if(e.grayTipElement){const w=e.grayTipElement;if((y=w.jsonGrayTipElement)!=null&&y.jsonStr)try{const k=JSON.parse(w.jsonGrayTipElement.jsonStr);if(k.items){const j=k.items.map(g=>g.txt||"").join("");return s.jsx("span",{className:"text-theme-hint text-xs",children:j||"[戳一戳]"})}}catch{}return s.jsx("span",{className:"text-theme-hint text-xs",children:"[系统提示]"})}if(e.arkElement)return s.jsx("span",{children:"[卡片消息]"});if(e.marketFaceElement){const{emojiId:w,faceName:k,supportSize:j}=e.marketFaceElement,{width:g=200,height:h=200}=(j==null?void 0:j[0])??{},v=`https://gxh.vip.qq.com/club/item/parcel/item/${w.substring(0,2)}/${w}/raw${Math.min(g,300)}.gif`;return s.jsx("img",{src:v,alt:k||"[表情包]",title:k,className:"inline-block align-text-bottom rounded",style:{maxWidth:Math.min(g,200),maxHeight:Math.min(h,200)},onError:N=>{var M;const S=N.target;S.style.display="none";const T=document.createElement("span");T.textContent=`[${k||"表情包"}]`,(M=S.parentNode)==null||M.insertBefore(T,S)}})}return null}),Wg=e=>!!(e.textElement||e.picElement||e.fileElement||e.pttElement||e.videoElement||e.faceElement||e.grayTipElement||e.arkElement||e.marketFaceElement),Hg=e=>!e.elements||e.elements.length===0?!1:e.elements.every(t=>t.grayTipElement||t.replyElement),Bg=({element:e,message:t})=>{const[n,r]=p.useState(null),[l,i]=p.useState(!1),[o,a]=p.useState(!1),[c,u]=p.useState(!1),[d,m]=p.useState(!1),f=p.useRef(null),y=e.pttElement,w=y.duration||0,k=Math.floor(w/60),j=w%60,g=k>0?`${k}:${j.toString().padStart(2,"0")}`:`${j}"`,h=y.text,x=80,N=Math.min(200,Math.max(x,x+w*3)),S=async()=>{if(!(!t||!y.fileUuid||d)){if(c&&f.current){f.current.pause(),u(!1);return}if(f.current&&f.current.readyState>=2){f.current.play(),u(!0);return}m(!0);try{const M=t.chatType===2;console.log("pttElement:",y);const q=Rh(y.fileUuid,M,y.filePath);console.log("音频代理URL:",q);const R=new Audio;f.current=R,R.onended=()=>u(!1),R.onerror=V=>{fetch(q).then(C=>C.text()).then(C=>{console.error("音频加载错误,响应内容:",C.substring(0,200))}).catch(()=>{}),console.error("音频加载错误:",V,R.error,"URL:",q),u(!1),m(!1)},R.onloadeddata=async()=>{m(!1);try{await R.play(),u(!0)}catch(V){console.error("播放失败:",V)}},R.src=q}catch(M){console.error("获取语音URL失败:",M),m(!1)}}},T=async()=>{if(!(!t||l||n!==null)){i(!0),a(!1);try{const M=await Ih(t.msgId,t.chatType,t.peerUid,e);r(M||"(无法识别)")}catch(M){console.error("语音转文字失败:",M),a(!0),r("转换失败")}finally{i(!1)}}};return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-green-100 dark:bg-green-900/40 rounded-full cursor-pointer hover:bg-green-200 dark:hover:bg-green-900/60 transition-colors",style:{width:N},onClick:S,title:"点击播放",children:[d?s.jsx(Se,{size:16,className:"text-green-600 dark:text-green-400 flex-shrink-0 animate-spin"}):c?s.jsx(Uo,{size:16,className:"text-green-600 dark:text-green-400 flex-shrink-0"}):s.jsx(Do,{size:16,className:"text-green-600 dark:text-green-400 flex-shrink-0"}),s.jsx("div",{className:"flex-1 flex items-center gap-0.5",children:[1,2,3,4,5].map(M=>s.jsx("div",{className:`w-0.5 bg-green-400 dark:bg-green-500 rounded-full transition-all ${c?"animate-pulse":""}`,style:{height:`${8+Math.random()*8}px`}},M))}),s.jsx("span",{className:"text-xs text-green-700 dark:text-green-300 flex-shrink-0",children:g})]}),!h&&n===null&&s.jsx("button",{onClick:T,disabled:l,className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-500 dark:text-gray-300 hover:text-gray-700 dark:hover:text-white text-xs font-medium transition-colors disabled:opacity-50",title:"语音转文字",children:l?s.jsx(Se,{size:12,className:"animate-spin"}):"文"})]}),(h||n)&&s.jsx("div",{className:`text-sm px-3 py-1.5 bg-gray-100 dark:bg-gray-800 rounded-lg max-w-[250px] ${o?"text-red-500":"text-theme-secondary"}`,children:h||n})]})},ef=ce.createContext(null),tf=ce.createContext(null),nf=ce.createContext(null),rf=ce.createContext(null),sf=ce.createContext(null),Vg=e=>{var t,n;for(const r of e.elements)if((n=(t=r.grayTipElement)==null?void 0:t.jsonGrayTipElement)!=null&&n.jsonStr)try{const l=JSON.parse(r.grayTipElement.jsonGrayTipElement.jsonStr);if(l.items){const i=l.items.some(o=>o.type==="qq"&&o.uid);return{items:l.items,hasUid:i}}}catch{}return null},hn=new Map,Qg=p.memo(({message:e,groupCode:t})=>{const n=hn.get(e.msgId),[r,l]=p.useState(n??"[系统提示]"),i=cr();return p.useEffect(()=>{var d,m;if(hn.has(e.msgId)){l(hn.get(e.msgId));return}const o=Vg(e);if(!o){for(const f of e.elements)if((m=(d=f.grayTipElement)==null?void 0:d.xmlElement)!=null&&m.content){const y=f.grayTipElement.xmlElement.content.replace(/<[^>]+>/g,"");hn.set(e.msgId,y),l(y);return}hn.set(e.msgId,"[系统提示]"),l("[系统提示]");return}const{items:a,hasUid:c}=o;if(!c){const y=a.map(w=>w.txt||"").join("")||"[系统提示]";hn.set(e.msgId,y),l(y);return}(async()=>{const f=[];let y=0;for(const k of a)if(k.type==="qq"&&k.uid)if(k.uid===i)f.push(s.jsx("span",{className:"text-blue-500",children:"你"},y++));else{const j=await Th(k.uid,t);f.push(s.jsx("span",{className:"text-blue-500",children:j},y++))}else k.type==="nor"&&k.txt&&f.push(s.jsx("span",{children:k.txt},y++));const w=f.length>0?f:"[系统提示]";hn.set(e.msgId,w),l(w)})()},[e.msgId,i,t]),s.jsx("div",{className:"flex justify-center py-2",children:s.jsx("span",{className:"text-xs text-theme-hint bg-theme-item/50 px-3 py-1 rounded-full",children:r})})}),Gg=p.memo(({message:e,allMessages:t,isHighlighted:n})=>{var R,V;if(Hg(e)){const C=e.chatType===2?e.peerUin:void 0;return s.jsx(Qg,{message:e,groupCode:C})}const r=cr(),l=r?e.senderUid===r:!1,i=ce.useContext(ef),o=ce.useContext(tf),a=ce.useContext(nf),c=ce.useContext(rf),u=ce.useContext(sf);let d=e.sendMemberName||e.sendNickName||e.senderUin;if(e.chatType===1&&!l&&u){const C=u.getFriend(e.senderUin);C&&(d=C.remark||C.nickname||d)}const m=`https://q1.qlogo.cn/g?b=qq&nk=${e.senderUin}&s=640`,f=parseInt(e.msgTime)*1e3;let y,w,k;if(e.chatType===2){const C=e.msgAttrs;if(C){const E=(_=>{if(C instanceof Map)return C.get(_);if(typeof C=="object")return C[_.toString()]})(2);E!=null&&E.groupHonor&&(y=E.groupHonor.level,w=E.groupHonor.uniqueTitle||void 0)}if(c){const b=c.getMembers(e.peerUin),E=b==null?void 0:b.find(_=>_.uid===e.senderUid||_.uin===e.senderUin);E&&(k=E.role,y===void 0&&E.level&&(y=E.level),!w&&E.specialTitle&&(w=E.specialTitle))}}if(!e.elements||!Array.isArray(e.elements))return null;const j=e.recallTime&&e.recallTime!=="0",g=(R=e.elements.find(C=>C.replyElement))==null?void 0:R.replyElement,h=e.elements.filter(C=>!C.replyElement);if(!(h.some(Wg)||g))return null;const v=h.length===1&&h[0].pttElement&&!g,N=g?t.find(C=>C.msgId===g.replayMsgId||C.msgSeq===g.replayMsgSeq):null,S=C=>{C.preventDefault(),C.stopPropagation(),i==null||i.showMenu(C,e)},T=C=>{C.preventDefault(),C.stopPropagation(),o==null||o.showMenu(C,{senderUid:e.senderUid,senderUin:e.senderUin,senderName:d,chatType:e.chatType,groupCode:e.chatType===2?e.peerUin:void 0})},M=C=>{("ontouchstart"in window||navigator.maxTouchPoints>0)&&(C.preventDefault(),C.stopPropagation(),o==null||o.showMenu(C,{senderUid:e.senderUid,senderUin:e.senderUin,senderName:d,chatType:e.chatType,groupCode:e.chatType===2?e.peerUin:void 0}))},q=()=>{g&&(a==null||a.scrollToMessage(g.replayMsgId,g.replayMsgSeq))};return s.jsxs("div",{className:`flex gap-2 w-full ${l?"flex-row-reverse":""} ${n?"animate-pulse bg-pink-100 dark:bg-pink-900/30 rounded-lg -mx-2 px-2":""}`,children:[s.jsx("img",{src:m,alt:d,loading:"lazy",className:"w-8 h-8 rounded-full object-cover flex-shrink-0 cursor-pointer hover:opacity-80 transition-opacity",onClick:M,onContextMenu:T}),s.jsxs("div",{className:`flex flex-col ${l?"items-end":"items-start"} max-w-[calc(100%-48px)] md:max-w-[70%] min-w-0 overflow-hidden`,children:[s.jsxs("div",{className:`flex items-center gap-1.5 mb-1 ${l?"flex-row-reverse":""}`,children:[s.jsx("span",{className:"text-xs text-theme-hint",children:d}),y!==void 0&&y>0&&s.jsxs("span",{className:"text-xs px-1 py-0.5 bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300 rounded",children:["Lv.",y]}),k==="owner"&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-amber-100 dark:bg-amber-900/50 text-amber-600 dark:text-amber-300 rounded",children:w||"群主"}),k==="admin"&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-blue-100 dark:bg-blue-900/50 text-blue-600 dark:text-blue-300 rounded",children:w||"管理员"}),k==="member"&&w&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-pink-100 dark:bg-pink-900/50 text-pink-600 dark:text-pink-300 rounded",children:w})]}),v?s.jsxs("div",{onContextMenu:S,className:j?"opacity-50":"",children:[h.map((C,b)=>s.jsx(Wi,{element:C,message:e},b)),j&&s.jsx("div",{className:"text-xs text-theme-muted italic mt-1",children:"已撤回"})]}):s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:`rounded-2xl px-4 py-2 min-w-[80px] max-w-full break-words overflow-hidden bg-theme-item text-theme shadow-sm ${l?"rounded-tr-sm":"rounded-tl-sm"} ${j?"opacity-50":""}`,onContextMenu:S,children:[g&&s.jsx("div",{className:"text-xs mb-2 pb-2 border-b border-theme-divider cursor-pointer hover:opacity-80 transition-opacity",onClick:q,children:s.jsx("div",{className:"bg-theme-input rounded px-2 py-1",children:N?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"font-medium text-theme-secondary",children:[N.sendMemberName||N.sendNickName||N.senderUin,":"]}),s.jsx("div",{className:"text-theme-muted",children:(V=N.elements)==null?void 0:V.filter(C=>!C.replyElement).map((C,b)=>s.jsx(Wi,{element:C},b))})]}):s.jsx("span",{className:"text-theme-muted",children:g.sourceMsgText||"[消息]"})})}),h.map((C,b)=>s.jsx(Wi,{element:C,message:e},b))]}),j&&s.jsx("div",{className:"text-xs text-theme-muted italic mt-1",children:"已撤回"})]}),s.jsx(Yg,{message:e,isSelf:l}),s.jsx("span",{className:"text-xs text-theme-hint mt-1",children:ii(f)})]})]})});function Kg(e,t){return t==="2"?`/face/emoji-${parseInt(e).toString(16)}.png`:`/face/${e}.png`}const Yg=p.memo(({message:e,isSelf:t})=>{const[n,r]=p.useState(null);if(!e.emojiLikesList||e.emojiLikesList.length===0)return null;const l=async(i,o)=>{if(!n){r(i);try{const a={chatType:e.chatType,peerUid:e.peerUin,guildId:""};await te("ntMsgApi","setEmojiLike",[a,e.msgSeq,i,!o])}catch(a){Y(a.message||"操作失败","error")}finally{r(null)}}};return s.jsx("div",{className:`flex flex-wrap gap-1 mt-1 ${t?"justify-end":"justify-start"}`,children:e.emojiLikesList.map((i,o)=>{const a=Kg(i.emojiId,i.emojiType);return s.jsxs("button",{onClick:()=>l(i.emojiId,i.isClicked),disabled:n===i.emojiId,className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-xs transition-all cursor-pointer hover:scale-105 active:scale-95 ${i.isClicked?"bg-pink-100 dark:bg-pink-900/40 border border-pink-300 dark:border-pink-700":"bg-theme-item border border-theme-divider hover:border-pink-300 dark:hover:border-pink-700"} ${n===i.emojiId?"opacity-50":""}`,title:i.isClicked?"点击取消":"点击跟贴",children:[s.jsx("img",{src:a,alt:`表情${i.emojiId}`,className:"w-4 h-4",onError:c=>{if(i.emojiType==="2"){const u=c.target,d=String.fromCodePoint(parseInt(i.emojiId));u.style.display="none",u.insertAdjacentHTML("afterend",`<span class="text-sm">${d}</span>`)}}}),s.jsx("span",{className:"text-theme-secondary",children:i.likesCnt})]},`${i.emojiId}-${o}`)})})}),Xg=p.memo(({message:e,onRetry:t})=>{const n=li(),r=n?`https://q1.qlogo.cn/g?b=qq&nk=${n}&s=640`:"";return s.jsxs("div",{className:"flex gap-2 flex-row-reverse w-full",children:[r&&s.jsx("img",{src:r,alt:"我",loading:"lazy",className:"w-8 h-8 rounded-full object-cover flex-shrink-0"}),s.jsxs("div",{className:"flex flex-col items-end max-w-[calc(100%-48px)] md:max-w-[70%] min-w-0 overflow-hidden",children:[s.jsx("span",{className:"text-xs text-theme-hint mb-1",children:"我"}),s.jsxs("div",{className:"flex items-end gap-1",children:[e.status==="failed"&&s.jsx("button",{onClick:t,className:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/30 rounded",title:"重新发送",children:s.jsx(oh,{size:14})}),s.jsx("div",{className:"rounded-2xl px-4 py-2 bg-theme-item text-theme rounded-tr-sm min-w-[80px] max-w-full break-words overflow-hidden shadow-sm",children:e.items.map((l,i)=>l.type==="text"&&l.content?s.jsx("span",{className:"whitespace-pre-wrap break-words",children:l.content},i):l.type==="face"&&l.faceId!==void 0?s.jsx("img",{src:`/face/${l.faceId}.png`,alt:`[表情${l.faceId}]`,className:"inline-block align-text-bottom",style:{width:24,height:24}},i):l.type==="image"&&l.imageUrl?s.jsx("img",{src:l.imageUrl,alt:"图片",loading:"lazy",className:"max-w-full rounded-lg",style:{maxHeight:"200px"}},i):l.type==="at"&&l.atName?s.jsxs("span",{className:"text-blue-500",children:["@",l.atName]},i):null)}),e.status==="sending"&&s.jsx(Se,{size:14,className:"animate-spin text-theme-hint"}),e.status==="failed"&&s.jsx(Jm,{size:14,className:"text-red-500"})]}),s.jsx("span",{className:"text-xs text-theme-hint mt-1",children:ii(e.timestamp)})]})]})}),Jg=({name:e,onMute:t,onClose:n})=>{const[r,l]=p.useState(0),[i,o]=p.useState(0),[a,c]=p.useState(0),[u,d]=p.useState(0),m=()=>{const y=r+i*60+a*3600+u*86400;y>0&&t(y)},f=r+i*60+a*3600+u*86400;return Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-50 bg-black/30",onClick:n}),s.jsxs("div",{className:"fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-theme-card backdrop-blur-xl border border-theme-divider rounded-xl shadow-xl p-6 min-w-[340px]",children:[s.jsxs("h3",{className:"text-lg font-medium text-theme mb-4",children:["禁言 ",e]}),s.jsxs("div",{className:"mb-4",children:[s.jsx("p",{className:"text-sm text-theme-secondary mb-3",children:"设置禁言时长:"}),s.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("input",{type:"number",min:0,max:59,value:r,onChange:y=>l(Math.min(59,Math.max(0,parseInt(y.target.value)||0))),className:"w-full px-2 py-2 text-center bg-theme-input border border-theme-input rounded-lg text-theme focus:outline-none focus:ring-2 focus:ring-pink-500/20"}),s.jsx("span",{className:"text-xs text-theme-secondary mt-1",children:"秒"})]}),s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("input",{type:"number",min:0,max:59,value:i,onChange:y=>o(Math.min(59,Math.max(0,parseInt(y.target.value)||0))),className:"w-full px-2 py-2 text-center bg-theme-input border border-theme-input rounded-lg text-theme focus:outline-none focus:ring-2 focus:ring-pink-500/20"}),s.jsx("span",{className:"text-xs text-theme-secondary mt-1",children:"分钟"})]}),s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("input",{type:"number",min:0,max:23,value:a,onChange:y=>c(Math.min(23,Math.max(0,parseInt(y.target.value)||0))),className:"w-full px-2 py-2 text-center bg-theme-input border border-theme-input rounded-lg text-theme focus:outline-none focus:ring-2 focus:ring-pink-500/20"}),s.jsx("span",{className:"text-xs text-theme-secondary mt-1",children:"小时"})]}),s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("input",{type:"number",min:0,max:29,value:u,onChange:y=>d(Math.min(29,Math.max(0,parseInt(y.target.value)||0))),className:"w-full px-2 py-2 text-center bg-theme-input border border-theme-input rounded-lg text-theme focus:outline-none focus:ring-2 focus:ring-pink-500/20"}),s.jsx("span",{className:"text-xs text-theme-secondary mt-1",children:"天"})]})]}),s.jsx("p",{className:"text-xs text-theme-secondary mt-2 text-center",children:"最长29天23小时59分59秒"})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("button",{onClick:()=>t(0),className:"px-4 py-2 text-sm text-green-500 hover:bg-green-50 dark:hover:bg-green-900/30 rounded-lg transition-colors",children:"解除禁言"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:n,className:"px-4 py-2 text-sm text-theme-secondary hover:bg-theme-item rounded-lg transition-colors",children:"取消"}),s.jsx("button",{onClick:m,disabled:f===0,className:"px-4 py-2 text-sm bg-orange-500 text-white hover:bg-orange-600 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"确认禁言"})]})]})]})]}),document.body)},Zg=({name:e,groupName:t,onConfirm:n,onClose:r})=>Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-50 bg-black/50",onClick:r}),s.jsxs("div",{className:"fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-theme-card border border-theme-divider rounded-xl shadow-xl p-6 min-w-[320px]",children:[s.jsx("h3",{className:"text-lg font-medium text-theme mb-4",children:"确认踢出"}),s.jsxs("p",{className:"text-theme-secondary mb-6",children:["确定要将 ",s.jsx("span",{className:"font-medium text-theme",children:e})," 移出群 ",s.jsx("span",{className:"font-medium text-theme",children:t})," 吗?"]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx("button",{onClick:r,className:"px-4 py-2 text-sm text-theme-secondary hover:bg-theme-item rounded-lg transition-colors",children:"取消"}),s.jsx("button",{onClick:n,className:"px-4 py-2 text-sm bg-red-500 text-white hover:bg-red-600 rounded-lg transition-colors",children:"确认踢出"})]})]})]}),document.body),ey=({name:e,onConfirm:t,onClose:n})=>{const[r,l]=p.useState("");return Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-50 bg-black/30",onClick:n}),s.jsxs("div",{className:"fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-theme-card backdrop-blur-xl border border-theme-divider rounded-xl shadow-xl p-6 min-w-[320px]",children:[s.jsx("h3",{className:"text-lg font-medium text-theme mb-4",children:"设置头衔"}),s.jsxs("p",{className:"text-sm text-theme-secondary mb-3",children:["为 ",e," 设置专属头衔:"]}),s.jsx("input",{type:"text",maxLength:12,value:r,onChange:i=>l(i.target.value),placeholder:"留空清除头衔",className:"w-full px-3 py-2 bg-theme-input border border-theme-input rounded-lg text-theme focus:outline-none focus:ring-2 focus:ring-pink-500/20 placeholder:text-theme-hint",autoFocus:!0,onKeyDown:i=>{i.key==="Enter"&&t(r.trim())}}),s.jsx("p",{className:"text-xs text-theme-secondary mt-2",children:"中文最多6字,英文最多12字,按回车确认"}),s.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[s.jsx("button",{onClick:n,className:"px-4 py-2 text-sm text-theme-secondary hover:bg-theme-item rounded-lg transition-colors",children:"取消"}),s.jsx("button",{onClick:()=>t(r.trim()),className:"px-4 py-2 text-sm bg-pink-500 text-white hover:bg-pink-600 rounded-lg transition-colors",children:"确认"})]})]})]}),document.body)};function lf(e,t,n){const[r,l]=p.useState({left:-9999,top:-9999,ready:!1});return p.useEffect(()=>{l({left:-9999,top:-9999,ready:!1});const i=requestAnimationFrame(()=>{if(!n.current){l({left:e,top:t,ready:!0});return}const o=n.current.getBoundingClientRect(),a=10;let c=e,u=t;e+o.width>window.innerWidth-a&&(c=e-o.width),c<a&&(c=a),t+o.height>window.innerHeight-a&&(u=t-o.height),u<a&&(u=a),l({left:c,top:u,ready:!0})});return()=>cancelAnimationFrame(i)},[e,t]),r}const ty=({contextMenu:e,session:t,getCachedMembers:n,onClose:r,onReply:l,onEmojiReaction:i,onRecall:o})=>{const a=e.message,c=cr(),u=c&&a.senderUid===c,d=a.chatType===2,m=d&&t?n(t.peerId):null,f=m&&c?m.find(M=>M.uid===c):null,y=f==null?void 0:f.role,w=y==="owner",k=y==="admin"||y==="owner",j=m?m.find(M=>M.uid===a.senderUid):null,g=j==null?void 0:j.role,x=u||d&&(w||k&&!(g==="admin"||g==="owner")),v=!!e.elementId,N=p.useRef(null),S=lf(e.x,e.y,N),T=async()=>{if(e.elementId){r();try{const M=await te("ntFileApi","downloadMedia",[a.msgId,a.chatType,a.peerUid,e.elementId,"",""]);if(!M){Y("图片下载失败","error");return}const q=await te("ntMsgApi","addFavEmoji",[M]);q.result===0?Y(q.isExist?"表情已存在":"已添加到表情","success"):Y(q.errMsg||"添加失败","error")}catch(M){Y(M.message||"添加失败","error")}}};return Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:r,onContextMenu:M=>{M.preventDefault(),r()}}),s.jsxs("div",{ref:N,className:"fixed z-50 bg-popup backdrop-blur-sm border border-theme-divider rounded-lg shadow-lg py-1 min-w-[100px]",style:{left:S.left,top:S.top,visibility:S.ready?"visible":"hidden"},onContextMenu:M=>M.preventDefault(),children:[s.jsxs("button",{onClick:()=>{l(a),r()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(ah,{size:14})," 回复"]}),t.chatType===2&&s.jsxs("button",{onClick:()=>{i(a,e.x,e.y),r()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(dh,{size:14})," 贴表情"]}),v&&s.jsxs("button",{onClick:T,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(mh,{size:14})," 添加到表情"]}),x&&s.jsxs("button",{onClick:async()=>{r();try{await Mh(a.chatType,a.peerUid,a.msgId),o(a.msgId),Y("消息已撤回","success")}catch(M){Y(M.message||"撤回失败","error")}},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-500 hover:bg-theme-item-hover transition-colors",children:[s.jsx(It,{size:14})," 撤回"]})]})]}),document.body)},ny=({avatarContextMenu:e,getCachedMembers:t,onClose:n,onInsertAt:r,onShowProfile:l,onSetTitle:i,onMute:o,onKick:a,onAdminChanged:c,groupName:u})=>{const d=cr(),m=e.groupCode?t(e.groupCode):null,f=m&&d?m.find(R=>R.uid===d):null,y=f==null?void 0:f.role,w=y==="owner",k=y==="admin",j=m?m.find(R=>R.uid===e.senderUid):null,g=j==null?void 0:j.role,h=g==="admin",x=w||k&&g==="member",v=w||k&&g==="member",N=e.senderUid===d,S=w&&!N,T=p.useRef(null),M=lf(e.x,e.y,T),q=async()=>{const R=e;n();try{const V=h?2:3;await te("ntGroupApi","setMemberRole",[R.groupCode,R.senderUid,V]),Y(h?"已取消管理员":"已设为管理员","success"),c==null||c()}catch(V){Y(V.message||"操作失败","error")}};return Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:n,onContextMenu:R=>{R.preventDefault(),n()}}),s.jsxs("div",{ref:T,className:"fixed z-50 bg-popup backdrop-blur-sm border border-theme-divider rounded-lg shadow-lg py-1 min-w-[120px]",style:{left:M.left,top:M.top,visibility:M.ready?"visible":"hidden"},onContextMenu:R=>R.preventDefault(),children:[e.chatType===2&&s.jsxs("button",{onClick:()=>{r(e.senderUid,e.senderUin,e.senderName),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(Zm,{size:14})," 召唤ta"]}),s.jsxs("button",{onClick:async()=>{const R=e;n();try{R.chatType===2&&R.groupCode?await $l(R.chatType,parseInt(R.senderUin),parseInt(R.groupCode)):await $l(R.chatType,parseInt(R.senderUin))}catch(V){Y(V.message||"戳一戳失败","error")}},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(th,{size:14})," 戳一戳"]}),s.jsxs("button",{onClick:()=>{l(e.senderUid,e.senderUin,e.x,e.y,e.groupCode),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(fh,{size:14})," 查看资料"]}),e.chatType===2&&e.groupCode&&w&&s.jsxs("button",{onClick:()=>{i(e.senderUid,e.senderName,e.groupCode),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(n0,{size:14})," 设置头衔"]}),e.chatType===2&&e.groupCode&&S&&s.jsxs("button",{onClick:q,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[h?s.jsx(j0,{size:14}):s.jsx(ms,{size:14}),h?"取消管理员":"设为管理员"]}),e.chatType===2&&e.groupCode&&!N&&x&&s.jsxs("button",{onClick:()=>{o(e.senderUid,e.senderName,e.groupCode),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-orange-500 hover:bg-theme-item-hover transition-colors",children:[s.jsx(E0,{size:14})," 禁言"]}),e.chatType===2&&e.groupCode&&!N&&v&&s.jsxs("button",{onClick:()=>{a(e.senderUid,e.senderName,e.groupCode,u||e.groupCode),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-500 hover:bg-theme-item-hover transition-colors",children:[s.jsx(S0,{size:14})," 踢出群"]})]})]}),document.body)},of=p.forwardRef(({placeholder:e="输入消息...",disabled:t=!1,onEnter:n,onPaste:r,onChange:l,onMentionChange:i},o)=>{const a=p.useRef(null),c=p.useRef(!1),u=p.useRef(null),[d,m]=p.useState(!1),f=p.useCallback(()=>{const b=a.current;if(!b)return[];const E=[],_=b.childNodes;for(let U=0;U<_.length;U++){const D=_[U];if(D.nodeType===Node.TEXT_NODE){const W=(D.textContent||"").replace(/\u200B/g,"");W&&E.push({type:"text",content:W})}else if(D.nodeType===Node.ELEMENT_NODE){const P=D;if(P.dataset.type==="face")E.push({type:"face",faceId:parseInt(P.dataset.faceId||"0")});else if(P.dataset.type==="image")E.push({type:"image",imageUrl:P.dataset.imageUrl,imageFile:P.__file});else if(P.dataset.type==="at")E.push({type:"at",atUid:P.dataset.atUid,atUin:P.dataset.atUin,atName:P.dataset.atName});else if(P.tagName==="BR")E.push({type:"text",content:`
439
+ color: hsl(${Math.max(0,Math.min(120-120*j,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(l),i=!1,l}return o.updateDeps=a=>{r=a},o}function zu(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const jg=(e,t)=>Math.abs(e-t)<1.01,Ng=(e,t,n)=>{let r;return function(...l){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,l),n)}},Lu=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},bg=e=>e,Sg=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let l=t;l<=n;l++)r.push(l);return r},Cg=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const l=o=>{const{width:a,height:c}=o;t({width:Math.round(a),height:Math.round(c)})};if(l(Lu(n)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(o=>{const a=()=>{const c=o[0];if(c!=null&&c.borderBoxSize){const u=c.borderBoxSize[0];if(u){l({width:u.inlineSize,height:u.blockSize});return}}l(Lu(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},Ru={passive:!0},_u=typeof window>"u"?!0:"onscrollend"in window,Eg=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let l=0;const i=e.options.useScrollendEvent&&_u?()=>{}:Ng(r,()=>{t(l,!1)},e.options.isScrollingResetDelay),o=d=>()=>{const{horizontal:m,isRtl:f}=e.options;l=m?n.scrollLeft*(f&&-1||1):n.scrollTop,i(),t(l,d)},a=o(!0),c=o(!1);n.addEventListener("scroll",a,Ru);const u=e.options.useScrollendEvent&&_u;return u&&n.addEventListener("scrollend",c,Ru),()=>{n.removeEventListener("scroll",a),u&&n.removeEventListener("scrollend",c)}},Mg=(e,t,n)=>{if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},Tg=(e,{adjustments:t=0,behavior:n},r)=>{var l,i;const o=e+t;(i=(l=r.scrollElement)==null?void 0:l.scrollTo)==null||i.call(l,{[r.options.horizontal?"left":"top"]:o,behavior:n})};class Ig{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(l=>{l.forEach(i=>{const o=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var l;(l=r())==null||l.disconnect(),n=null},observe:l=>{var i;return(i=r())==null?void 0:i.observe(l,{box:"border-box"})},unobserve:l=>{var i;return(i=r())==null?void 0:i.unobserve(l)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,l])=>{typeof l>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:bg,rangeExtractor:Sg,onChange:()=>{},measureElement:Mg,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,l;(l=(r=this.options).onChange)==null||l.call(r,this,n)},this.maybeNotify=zn(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(l=>{this.observer.observe(l)}),this.unsubs.push(this.options.observeElementRect(this,l=>{this.scrollRect=l,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(l,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<l?"forward":"backward":null,this.scrollOffset=l,this.isScrolling=i,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const l=new Map,i=new Map;for(let o=r-1;o>=0;o--){const a=n[o];if(l.has(a.lane))continue;const c=i.get(a.lane);if(c==null||a.end>c.end?i.set(a.lane,a):a.end<c.end&&l.set(a.lane,!0),l.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=zn(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(n,r,l,i,o,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:l,getItemKey:i,enabled:o,lanes:a}),{key:!1}),this.getMeasurements=zn(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:l,getItemKey:i,enabled:o,lanes:a},c)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const f of this.laneAssignments.keys())f>=n&&this.laneAssignments.delete(f);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(f=>{this.itemSizeCache.set(f.key,f.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1);const d=this.measurementsCache.slice(0,u),m=new Array(a).fill(void 0);for(let f=0;f<u;f++){const y=d[f];y&&(m[y.lane]=f)}for(let f=u;f<n;f++){const y=i(f),w=this.laneAssignments.get(f);let k,j;if(w!==void 0&&this.options.lanes>1){k=w;const v=m[k],N=v!==void 0?d[v]:void 0;j=N?N.end+this.options.gap:r+l}else{const v=this.options.lanes===1?d[f-1]:this.getFurthestMeasurement(d,f);j=v?v.end+this.options.gap:r+l,k=v?v.lane:f%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(f,k)}const g=c.get(y),h=typeof g=="number"?g:this.options.estimateSize(f),x=j+h;d[f]={index:f,start:j,size:h,end:x,key:y,lane:k},m[k]=f}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=zn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,l,i)=>this.range=n.length>0&&r>0?Pg({measurements:n,outerSize:r,scrollOffset:l,lanes:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=zn(()=>{let n=null,r=null;const l=this.calculateRange();return l&&(n=l.startIndex,r=l.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,l,i,o)=>i===null||o===null?[]:n({startIndex:i,endIndex:o,overscan:r,count:l}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,l=n.getAttribute(r);return l?parseInt(l,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const l=this.indexFromElement(n),i=this.measurementsCache[l];if(!i)return;const o=i.key,a=this.elementsCache.get(o);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(o,n)),n.isConnected&&this.resizeItem(l,this.options.measureElement(n,r,this))},this.resizeItem=(n,r)=>{const l=this.measurementsCache[n];if(!l)return;const i=this.itemSizeCache.get(l.key)??l.size,o=r-i;o!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(l,o,this):l.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(l.index),this.itemSizeCache=new Map(this.itemSizeCache.set(l.key,r)),this.notify(!1))},this.measureElement=n=>{if(!n){this.elementsCache.forEach((r,l)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(l))});return}this._measureElement(n,void 0)},this.getVirtualItems=zn(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const l=[];for(let i=0,o=n.length;i<o;i++){const a=n[i],c=r[a];l.push(c)}return l},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return zu(r[Bh(0,r.length-1,l=>zu(r[l]).start,n)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(n,r,l=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),o=this.getScrollOffset();r==="auto"&&(r=n>=o+i?"end":"start"),r==="center"?n+=(l-i)/2:r==="end"&&(n-=i);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const l=this.measurementsCache[n];if(!l)return;const i=this.getSize(),o=this.getScrollOffset();if(r==="auto")if(l.end>=o+i-this.options.scrollPaddingEnd)r="end";else if(l.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const a=r==="end"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,r,l.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(n,{align:r="start",behavior:l}={})=>{l==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:l})},this.scrollToIndex=(n,{align:r="auto",behavior:l}={})=>{l==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),n=Math.max(0,Math.min(n,this.options.count-1)),this.currentScrollToIndex=n;let i=0;const o=10,a=u=>{if(!this.targetWindow)return;const d=this.getOffsetForIndex(n,u);if(!d){console.warn("Failed to get offset for index:",n);return}const[m,f]=d;this._scrollToOffset(m,{adjustments:void 0,behavior:l}),this.targetWindow.requestAnimationFrame(()=>{if(!this.targetWindow)return;const y=()=>{if(this.currentScrollToIndex!==n)return;const w=this.getScrollOffset(),k=this.getOffsetForIndex(n,f);if(!k){console.warn("Failed to get offset for index:",n);return}jg(k[0],w)||c(f)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(y):y()})},c=u=>{this.targetWindow&&this.currentScrollToIndex===n&&(i++,i<o?this.targetWindow.requestAnimationFrame(()=>a(u)):console.warn(`Failed to scroll to index ${n} after ${o} attempts.`))};a(r)},this.scrollBy=(n,{behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let l;if(r.length===0)l=this.options.paddingStart;else if(this.options.lanes===1)l=((n=r[r.length-1])==null?void 0:n.end)??0;else{const i=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&i.some(a=>a===null);){const a=r[o];i[a.lane]===null&&(i[a.lane]=a.end),o--}l=Math.max(...i.filter(a=>a!==null))}return Math.max(l-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:l})=>{this.options.scrollToFn(n,{behavior:l,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}}const Bh=(e,t,n,r)=>{for(;e<=t;){const l=(e+t)/2|0,i=n(l);if(i<r)e=l+1;else if(i>r)t=l-1;else return l}return e>0?e-1:0};function Pg({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const l=e.length-1,i=c=>e[c].start;if(e.length<=r)return{startIndex:0,endIndex:l};let o=Bh(0,l,i,n),a=o;if(r===1)for(;a<l&&e[a].end<n+t;)a++;else if(r>1){const c=Array(r).fill(0);for(;a<l&&c.some(d=>d<n+t);){const d=e[a];c[d.lane]=d.end,a++}const u=Array(r).fill(n+t);for(;o>=0&&u.some(d=>d>=n);){const d=e[o];u[d.lane]=d.start,o--}o=Math.max(0,o-o%r),a=Math.min(l,a+(r-1-a%r))}return{startIndex:o,endIndex:a}}const Au=typeof document<"u"?p.useLayoutEffect:p.useEffect;function zg({useFlushSync:e=!0,...t}){const n=p.useReducer(()=>({}),{})[1],r={...t,onChange:(i,o)=>{var a;e&&o?Ie.flushSync(n):n(),(a=t.onChange)==null||a.call(t,i,o)}},[l]=p.useState(()=>new Ig(r));return l.setOptions(r),Au(()=>l._didMount(),[]),Au(()=>l._willUpdate()),l}function Vh(e){return zg({observeElementRect:Cg,observeElementOffset:Eg,scrollToFn:Tg,...e})}const Lg="webqq-messages",Rg=1,lr="messages",Qh=100;let qs=null;function Gh(){return qs?Promise.resolve(qs):new Promise((e,t)=>{const n=indexedDB.open(Lg,Rg);n.onerror=()=>t(n.error),n.onsuccess=()=>{qs=n.result,e(qs)},n.onupgradeneeded=r=>{const l=r.target.result;l.objectStoreNames.contains(lr)||l.createObjectStore(lr,{keyPath:"chatKey"})}})}async function fs(e,t){try{const n=await Gh(),r=`${e}_${t}`;return new Promise(l=>{const a=n.transaction(lr,"readonly").objectStore(lr).get(r);a.onsuccess=()=>{const c=a.result;c&&c.messages?l(c.messages):l(null)},a.onerror=()=>l(null)})}catch{return null}}async function kn(e,t,n){try{const r=await Gh(),l=`${e}_${t}`,i=n.slice(-Qh);return new Promise((o,a)=>{const d=r.transaction(lr,"readwrite").objectStore(lr).put({chatKey:l,messages:i,timestamp:Date.now()});d.onsuccess=()=>o(),d.onerror=()=>a(d.error)})}catch(r){console.error("Failed to cache messages:",r)}}async function Kh(e,t,n){try{const r=await fs(e,t);if(r){const l=[...r.slice(-(Qh-1)),n];await kn(e,t,l)}}catch(r){console.error("Failed to append message:",r)}}async function _g(e,t,n){try{const r=await fs(e,t);if(r){const l=r.filter(i=>i.msgId!==n);await kn(e,t,l)}}catch(r){console.error("Failed to remove message:",r)}}async function Ag(e,t,n,r,l){try{const i=await fs(e,t);if(!i)return;const o=i.map(a=>{if(a.msgSeq!==n)return a;const c=a.emojiLikesList||[];if(l){const u=c.findIndex(d=>d.emojiId===r);if(u>=0){const d=[...c];return d[u]={...d[u],likesCnt:String(parseInt(d[u].likesCnt)+1)},{...a,emojiLikesList:d}}else return{...a,emojiLikesList:[...c,{emojiId:r,emojiType:parseInt(r)>999?"2":"1",likesCnt:"1",isClicked:!1}]}}else{const u=c.findIndex(d=>d.emojiId===r);if(u>=0){const d=[...c],m=parseInt(d[u].likesCnt)-1;return m<=0?d.splice(u,1):d[u]={...d[u],likesCnt:String(m)},{...a,emojiLikesList:d}}}return a});await kn(e,t,o)}catch(i){console.error("Failed to update emoji reaction:",i)}}async function Fg(e,t,n,r){try{const l=await fs(e,t);if(!l)return!1;let i=!1;const o=l.map(a=>a.msgId===n||r&&a.msgSeq===r?(i=!0,{...a,recallTime:String(Math.floor(Date.now()/1e3))}):a);return i&&await kn(e,t,o),i}catch(l){return console.error("Failed to mark message as recalled:",l),!1}}const $g=({level:e})=>{const t=e%4,n=Math.floor(e/4)%4,r=Math.floor(e/16)%4,l=Math.floor(e/64)%4,i=Math.floor(e/256),o=[];for(let a=0;a<i;a++)o.push(s.jsx("span",{className:"text-amber-400 text-xs font-bold",title:"金企鹅",children:"🐧"},`penguin-${a}`));for(let a=0;a<l;a++)o.push(s.jsx(ri,{size:14,className:"text-amber-500"},`crown-${a}`));for(let a=0;a<r;a++)o.push(s.jsx(hh,{size:14,className:"text-orange-400"},`sun-${a}`));for(let a=0;a<n;a++)o.push(s.jsx(sh,{size:14,className:"text-blue-400"},`moon-${a}`));for(let a=0;a<t;a++)o.push(s.jsx(mh,{size:14,className:"text-yellow-400 fill-yellow-400"},`star-${a}`));return s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:o})},Yh=({profile:e,loading:t,position:n,onClose:r,isFriend:l,onFriendDeleted:i})=>{const o=p.useRef(null),[a,c]=p.useState({left:n.x,top:n.y}),[u,d]=p.useState(!1),[m,f]=p.useState(!1);if(p.useEffect(()=>{if(!o.current)return;const x=320,v=o.current.offsetHeight||400;let N=n.x,S=n.y;N+x>window.innerWidth-20&&(N=window.innerWidth-x-20),N<20&&(N=20),S+v>window.innerHeight-20&&(S=window.innerHeight-v-20),S<20&&(S=20),c({left:N,top:S})},[n,e,t]),!e&&!t)return null;const y=x=>x===1?"男":x===2?"女":"",w=x=>{if(!x)return"";const v=new Date(x*1e3),N=new Date,S=N.getFullYear()-v.getFullYear(),T=N.getMonth()-v.getMonth(),M=S+(T<0?-1:0);if(M<1){const q=S*12+T;return q>0?`${q}个月`:"不足1个月"}return`${M}年`},k=x=>x==="owner"?"群主":x==="admin"?"管理员":"",j=x=>x==="owner"?"bg-amber-500 text-white":x==="admin"?"bg-green-500 text-white":"",g=async()=>{if(e){f(!0);try{await Oh(e.uid),Y("已删除好友","success"),i==null||i(e.uid),r()}catch(x){Y(x.message||"删除好友失败","error")}finally{f(!1),d(!1)}}},h=x=>x?new Date(x*1e3).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"";return Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:r}),s.jsxs("div",{ref:o,className:"fixed z-50 border border-theme-divider rounded-xl shadow-xl overflow-hidden bg-popup backdrop-blur-sm",style:{left:a.left,top:a.top,width:320,maxHeight:"calc(100vh - 40px)"},onClick:x=>x.stopPropagation(),children:[t?s.jsx("div",{className:"flex items-center justify-center h-40",children:s.jsx(Se,{size:24,className:"animate-spin text-pink-500"})}):e&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"bg-gradient-to-r from-pink-400 to-amber-300 p-4 relative",children:[l&&!e.groupRole&&s.jsx("button",{onClick:()=>d(!0),className:"absolute top-2 right-2 p-1.5 rounded-full bg-white/20 hover:bg-white/40 text-white transition-colors",title:"删除好友",children:s.jsx(It,{size:16})}),s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("img",{src:e.avatar,alt:e.nickname,className:"w-16 h-16 rounded-full border-3 border-white/80 object-cover flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0 text-white pt-1",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("span",{className:"font-bold text-lg truncate",children:e.nickname}),e.groupRole&&k(e.groupRole)&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${j(e.groupRole)}`,children:k(e.groupRole)})]}),e.remark&&e.remark!==e.nickname&&s.jsxs("div",{className:"text-white/80 text-sm truncate mb-1",children:["备注: ",e.remark]}),s.jsx("div",{className:"text-white/90 text-sm",children:e.uin}),e.qid&&s.jsxs("div",{className:"text-white/70 text-xs mt-0.5",children:["QID: ",e.qid]})]})]})]}),s.jsxs("div",{className:"p-4 overflow-y-auto",style:{maxHeight:"calc(100vh - 40px - 120px)"},children:[e.signature&&s.jsx("div",{className:"text-theme-secondary text-sm mb-3 bg-theme-item/50 rounded-lg px-3 py-2 max-h-24 overflow-y-auto break-words",children:e.signature}),s.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[y(e.sex)&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"性别"}),s.jsx("span",{className:"text-theme",children:y(e.sex)})]}),e.birthday&&e.birthday!=="0-0-0"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"生日"}),s.jsx("span",{className:"text-theme",children:e.birthday})]}),w(e.regTime)&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"Q龄"}),s.jsx("span",{className:"text-theme",children:w(e.regTime)})]}),e.level>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"等级"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-theme",children:["Lv.",e.level]}),s.jsx($g,{level:e.level})]})]})]}),(e.groupCard||e.groupTitle||e.groupLevel)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-theme-divider my-3"}),s.jsx("div",{className:"text-xs text-theme-hint mb-2",children:"群信息"}),s.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.groupCard&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"群名片"}),s.jsx("span",{className:"text-theme truncate",children:e.groupCard})]}),e.groupTitle&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"群头衔"}),s.jsx("span",{className:"text-pink-500",children:e.groupTitle})]}),e.groupLevel!==void 0&&e.groupLevel>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"群等级"}),s.jsxs("span",{className:"text-theme",children:["Lv.",e.groupLevel]})]}),e.joinTime&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"入群时间"}),s.jsx("span",{className:"text-theme",children:h(e.joinTime)})]}),e.lastSpeakTime&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-theme-hint",children:"最后发言"}),s.jsx("span",{className:"text-theme",children:h(e.lastSpeakTime)})]})]})]})]})]}),u&&e&&s.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center rounded-xl",children:s.jsxs("div",{className:"bg-popup m-4 p-4 rounded-lg shadow-lg max-w-[280px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("span",{className:"font-medium text-theme",children:"删除好友"}),s.jsx("button",{onClick:()=>d(!1),className:"text-theme-muted hover:text-theme",children:s.jsx(ht,{size:18})})]}),s.jsxs("p",{className:"text-sm text-theme-secondary mb-4",children:["确定要删除好友 ",s.jsx("span",{className:"font-medium text-theme",children:e.remark||e.nickname})," 吗?删除后将无法恢复。"]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx("button",{onClick:()=>d(!1),className:"px-3 py-1.5 text-sm rounded-lg bg-theme-item hover:bg-theme-hover text-theme transition-colors",disabled:m,children:"取消"}),s.jsxs("button",{onClick:g,className:"px-3 py-1.5 text-sm rounded-lg bg-red-500 hover:bg-red-600 text-white transition-colors flex items-center gap-1",disabled:m,children:[m&&s.jsx(Se,{size:14,className:"animate-spin"}),"删除"]})]})]})})]})]}),document.body)},Ug=({profile:e,loading:t,position:n,onClose:r,onQuitGroup:l})=>{const i=p.useRef(null),[o,a]=p.useState({left:n.x,top:n.y}),[c,u]=p.useState(!1),d=li(),m=(e==null?void 0:e.ownerUin)===d;if(p.useEffect(()=>{if(!i.current)return;const k=320,j=i.current.offsetHeight||300;let g=n.x,h=n.y;g+k>window.innerWidth-20&&(g=window.innerWidth-k-20),g<20&&(g=20),h+j>window.innerHeight-20&&(h=window.innerHeight-j-20),h<20&&(h=20),a({left:g,top:h})},[n,e,t]),!e&&!t)return null;const f=k=>k?new Date(k*1e3).toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}):"",y=()=>{u(!0)},w=()=>{e&&l&&l(e.groupCode,m),u(!1),r()};return Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:r}),s.jsx("div",{ref:i,className:"fixed z-50 border border-theme-divider rounded-xl shadow-xl overflow-hidden bg-popup backdrop-blur-sm",style:{left:o.left,top:o.top,width:320,maxHeight:"calc(100vh - 40px)"},onClick:k=>k.stopPropagation(),children:t?s.jsx("div",{className:"flex items-center justify-center h-40",children:s.jsx(Se,{size:24,className:"animate-spin text-pink-500"})}):e&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"bg-gradient-to-r from-blue-400 to-cyan-300 p-4 relative",children:[l&&s.jsx("button",{onClick:y,className:"absolute top-3 right-3 p-1.5 rounded-full bg-white/20 hover:bg-white/30 text-white transition-colors",title:m?"解散该群":"退出该群",children:s.jsx(x0,{size:16})}),s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("img",{src:e.avatar,alt:e.groupName,className:"w-16 h-16 rounded-lg border-3 border-white/80 object-cover flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0 text-white pt-1 pr-6",children:[s.jsx("div",{className:"font-bold text-lg truncate mb-1",children:e.groupName}),e.remarkName&&e.remarkName!==e.groupName&&s.jsxs("div",{className:"text-white/80 text-sm truncate mb-1",children:["备注: ",e.remarkName]}),s.jsx("div",{className:"text-white/90 text-sm",children:e.groupCode})]})]})]}),s.jsxs("div",{className:"p-4 overflow-y-auto",style:{maxHeight:"calc(100vh - 40px - 140px)"},children:[s.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[s.jsxs("span",{className:"text-theme-hint flex items-center gap-1",children:[s.jsx(si,{size:14}),"成员"]}),s.jsxs("span",{className:"text-theme",children:[e.memberCount,e.maxMemberCount?` / ${e.maxMemberCount}`:""]}),e.ownerName&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-theme-hint flex items-center gap-1",children:[s.jsx(ri,{size:14}),"群主"]}),s.jsx("span",{className:"text-theme truncate",children:e.ownerName})]}),e.createTime&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-theme-hint flex items-center gap-1",children:[s.jsx(o0,{size:14}),"创建"]}),s.jsx("span",{className:"text-theme",children:f(e.createTime)})]})]}),e.description&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-theme-divider my-3"}),s.jsx("div",{className:"text-xs text-theme-hint mb-2",children:"群简介"}),s.jsx("div",{className:"text-theme-secondary text-sm bg-theme-item/50 rounded-lg px-3 py-2 break-words whitespace-pre-wrap",style:{maxHeight:"120px",overflowY:"auto"},children:e.description})]}),e.announcement&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-theme-divider my-3"}),s.jsxs("div",{className:"text-xs text-theme-hint mb-2 flex items-center gap-1",children:[s.jsx(ms,{size:12}),"群公告"]}),s.jsx("div",{className:"text-theme-secondary text-sm bg-theme-item/50 rounded-lg px-3 py-2 break-words whitespace-pre-wrap",style:{maxHeight:"120px",overflowY:"auto"},children:e.announcement})]})]})]})}),c&&e&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[60] bg-black/50",onClick:()=>u(!1)}),s.jsxs("div",{className:"fixed z-[70] top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-theme-card border border-theme-divider rounded-xl shadow-xl p-6 min-w-[320px]",children:[s.jsx("h3",{className:"text-lg font-medium text-theme mb-4",children:m?"确认解散群聊":"确认退出群聊"}),s.jsx("p",{className:"text-theme-secondary mb-6",children:m?s.jsxs(s.Fragment,{children:["确定要解散群 ",s.jsx("span",{className:"font-medium text-theme",children:e.groupName})," 吗?此操作不可撤销,所有群成员将被移出。"]}):s.jsxs(s.Fragment,{children:["确定要退出群 ",s.jsx("span",{className:"font-medium text-theme",children:e.groupName})," 吗?"]})}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx("button",{onClick:()=>u(!1),className:"px-4 py-2 text-sm text-theme-secondary hover:bg-theme-item rounded-lg transition-colors",children:"取消"}),s.jsx("button",{onClick:w,className:"px-4 py-2 text-sm bg-red-500 hover:bg-red-600 text-white rounded-lg transition-colors",children:m?"确认解散":"确认退出"})]})]})]})]}),document.body)},Dg=({url:e,onClose:t})=>e?Ie.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[s.jsx("button",{onClick:t,className:"absolute top-4 right-4 p-2 text-white/80 hover:text-white bg-black/50 rounded-full",children:s.jsx(ht,{size:24})}),s.jsx("img",{src:e,alt:"预览",className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:n=>n.stopPropagation()})]}),document.body):null,Og=({videoInfo:e,onClose:t})=>{const[n,r]=p.useState(null),[l,i]=p.useState(!1),[o,a]=p.useState(null);return p.useEffect(()=>{if(!e){r(null),a(null);return}i(!0),a(null),Eh(e.chatType,e.peerUid,e.msgId,e.elementId).then(r).catch(c=>a(c.message||"获取视频失败")).finally(()=>i(!1))},[e]),e?Ie.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[s.jsx("button",{onClick:t,className:"absolute top-4 right-4 p-2 text-white/80 hover:text-white bg-black/50 rounded-full z-10",children:s.jsx(ht,{size:24})}),l&&s.jsxs("div",{className:"text-white flex items-center gap-2",children:[s.jsx(Se,{size:24,className:"animate-spin"}),"加载中..."]}),o&&s.jsx("div",{className:"text-red-400",children:o}),n&&!l&&s.jsx("video",{src:n,controls:!0,autoPlay:!0,className:"max-w-[90vw] max-h-[90vh]",onClick:c=>c.stopPropagation()})]}),document.body):null},Xh=ce.createContext(null),Jh=ce.createContext(null),Zh=ce.createContext(null),qg=e=>e?e.startsWith("blob:")?e:e.includes("qpic.cn")||e.includes("multimedia.nt.qq.com.cn")?`/api/webqq/image-proxy?url=${encodeURIComponent(e)}&token=${encodeURIComponent(hs()||"")}`:e:"",Wi=p.memo(({element:e,message:t})=>{var y;const[n,r]=p.useState(!1),[l,i]=p.useState(!1),[o,a]=p.useState(!1),[c,u]=p.useState(!1),d=ce.useContext(Xh),m=ce.useContext(Jh),f=ce.useContext(Zh);if(e.textElement)return s.jsx("span",{className:"whitespace-pre-wrap break-all",style:{overflowWrap:"anywhere",wordBreak:"break-all"},children:e.textElement.content});if(e.picElement){const w=e.picElement;let k=w.originImageUrl?w.originImageUrl.startsWith("http")?w.originImageUrl:`https://gchat.qpic.cn${w.originImageUrl}`:"";const j=qg(k),g=200,h=300;let x=w.picWidth||200,v=w.picHeight||200;v>g&&(x=x*g/v,v=g),x>h&&(v=v*h/x,x=h);const N=S=>{t&&(S.preventDefault(),S.stopPropagation(),f==null||f.showMenu(S,t,e.elementId))};return s.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-theme-item cursor-pointer",style:{width:x,height:v},onClick:()=>d==null?void 0:d.showPreview(j),onContextMenu:N,children:[!n&&!l&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-theme-hint",children:s.jsx(Se,{size:24,className:"animate-spin"})}),l&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-theme-hint text-xs",children:"图片加载失败"}),s.jsx("img",{src:j,alt:"图片",loading:"lazy",className:`w-full h-full object-cover transition-opacity ${n?"opacity-100":"opacity-0"}`,onLoad:()=>r(!0),onError:()=>i(!0)})]})}if(e.faceElement){const w=e.faceElement.faceIndex,k=e.faceElement.faceText;return s.jsx("img",{src:`/face/${w}.png`,alt:k||`[表情${w}]`,title:k||`表情${w}`,className:"inline-block align-text-bottom",style:{width:24,height:24},onError:j=>{var x;const g=j.target;g.style.display="none";const h=document.createElement("span");h.textContent=k||`[表情${w}]`,(x=g.parentNode)==null||x.insertBefore(h,g)}})}if(e.fileElement)return s.jsxs("span",{children:["[文件: ",e.fileElement.fileName,"]"]});if(e.pttElement)return s.jsx(Bg,{element:e,message:t});if(e.videoElement){const w=e.videoElement,k=200,j=300;let g=w.thumbWidth||200,h=w.thumbHeight||150;h>k&&(g=g*k/h,h=k),g>j&&(h=h*j/g,g=j);let x="";if(w.thumbPath){let q;w.thumbPath instanceof Map?q=w.thumbPath.values().next().value:typeof w.thumbPath=="object"&&(q=Object.values(w.thumbPath)[0]),q&&(x=`/api/webqq/file-proxy?path=${encodeURIComponent(q)}&token=${encodeURIComponent(hs()||"")}`)}const v=w.fileTime||0,N=Math.floor(v/60),S=v%60,T=`${N}:${S.toString().padStart(2,"0")}`,M=()=>{t&&e.elementId&&(m==null||m.showPreview(t.chatType,t.peerUid,t.msgId,e.elementId))};return s.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-theme-item cursor-pointer group",style:{width:g,height:h},onClick:M,children:[s.jsx("div",{className:"absolute inset-0 bg-gray-200 dark:bg-gray-700"}),x?s.jsxs(s.Fragment,{children:[!o&&!c&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-theme-hint",children:s.jsx(Se,{size:24,className:"animate-spin"})}),s.jsx("img",{src:x,alt:"视频缩略图",loading:"lazy",className:`absolute inset-0 w-full h-full object-cover transition-opacity ${o?"opacity-100":"opacity-0"}`,onLoad:()=>a(!0),onError:()=>u(!0)})]}):s.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-theme-hint text-xs",children:"视频"}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsx("div",{className:"w-12 h-12 rounded-full bg-black/50 flex items-center justify-center group-hover:bg-black/70 transition-colors",children:s.jsx("div",{className:"w-0 h-0 border-t-8 border-t-transparent border-l-12 border-l-white border-b-8 border-b-transparent ml-1",style:{borderLeftWidth:"14px"}})})}),s.jsx("div",{className:"absolute bottom-1 right-1 px-1.5 py-0.5 bg-black/60 rounded text-white text-xs",children:T})]})}if(e.grayTipElement){const w=e.grayTipElement;if((y=w.jsonGrayTipElement)!=null&&y.jsonStr)try{const k=JSON.parse(w.jsonGrayTipElement.jsonStr);if(k.items){const j=k.items.map(g=>g.txt||"").join("");return s.jsx("span",{className:"text-theme-hint text-xs",children:j||"[戳一戳]"})}}catch{}return s.jsx("span",{className:"text-theme-hint text-xs",children:"[系统提示]"})}if(e.arkElement)return s.jsx("span",{children:"[卡片消息]"});if(e.marketFaceElement){const{emojiId:w,faceName:k,supportSize:j}=e.marketFaceElement,{width:g=200,height:h=200}=(j==null?void 0:j[0])??{},v=`https://gxh.vip.qq.com/club/item/parcel/item/${w.substring(0,2)}/${w}/raw${Math.min(g,300)}.gif`;return s.jsx("img",{src:v,alt:k||"[表情包]",title:k,className:"inline-block align-text-bottom rounded",style:{maxWidth:Math.min(g,200),maxHeight:Math.min(h,200)},onError:N=>{var M;const S=N.target;S.style.display="none";const T=document.createElement("span");T.textContent=`[${k||"表情包"}]`,(M=S.parentNode)==null||M.insertBefore(T,S)}})}return null}),Wg=e=>!!(e.textElement||e.picElement||e.fileElement||e.pttElement||e.videoElement||e.faceElement||e.grayTipElement||e.arkElement||e.marketFaceElement),Hg=e=>!e.elements||e.elements.length===0?!1:e.elements.every(t=>t.grayTipElement||t.replyElement),Bg=({element:e,message:t})=>{const[n,r]=p.useState(null),[l,i]=p.useState(!1),[o,a]=p.useState(!1),[c,u]=p.useState(!1),[d,m]=p.useState(!1),f=p.useRef(null),y=e.pttElement,w=y.duration||0,k=Math.floor(w/60),j=w%60,g=k>0?`${k}:${j.toString().padStart(2,"0")}`:`${j}"`,h=y.text,x=80,N=Math.min(200,Math.max(x,x+w*3)),S=async()=>{if(!(!t||!y.fileUuid||d)){if(c&&f.current){f.current.pause(),u(!1);return}if(f.current&&f.current.readyState>=2){f.current.play(),u(!0);return}m(!0);try{const M=t.chatType===2;console.log("pttElement:",y);const q=Rh(y.fileUuid,M,y.filePath);console.log("音频代理URL:",q);const R=new Audio;f.current=R,R.onended=()=>u(!1),R.onerror=V=>{fetch(q).then(C=>C.text()).then(C=>{console.error("音频加载错误,响应内容:",C.substring(0,200))}).catch(()=>{}),console.error("音频加载错误:",V,R.error,"URL:",q),u(!1),m(!1)},R.onloadeddata=async()=>{m(!1);try{await R.play(),u(!0)}catch(V){console.error("播放失败:",V)}},R.src=q}catch(M){console.error("获取语音URL失败:",M),m(!1)}}},T=async()=>{if(!(!t||l||n!==null)){i(!0),a(!1);try{const M=await Ih(t.msgId,t.chatType,t.peerUid,e);r(M||"(无法识别)")}catch(M){console.error("语音转文字失败:",M),a(!0),r("转换失败")}finally{i(!1)}}};return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-green-100 dark:bg-green-900/40 rounded-full cursor-pointer hover:bg-green-200 dark:hover:bg-green-900/60 transition-colors",style:{width:N},onClick:S,title:"点击播放",children:[d?s.jsx(Se,{size:16,className:"text-green-600 dark:text-green-400 flex-shrink-0 animate-spin"}):c?s.jsx(Uo,{size:16,className:"text-green-600 dark:text-green-400 flex-shrink-0"}):s.jsx(Do,{size:16,className:"text-green-600 dark:text-green-400 flex-shrink-0"}),s.jsx("div",{className:"flex-1 flex items-center gap-0.5",children:[1,2,3,4,5].map(M=>s.jsx("div",{className:`w-0.5 bg-green-400 dark:bg-green-500 rounded-full transition-all ${c?"animate-pulse":""}`,style:{height:`${8+Math.random()*8}px`}},M))}),s.jsx("span",{className:"text-xs text-green-700 dark:text-green-300 flex-shrink-0",children:g})]}),!h&&n===null&&s.jsx("button",{onClick:T,disabled:l,className:"w-6 h-6 flex items-center justify-center rounded-full bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-500 dark:text-gray-300 hover:text-gray-700 dark:hover:text-white text-xs font-medium transition-colors disabled:opacity-50",title:"语音转文字",children:l?s.jsx(Se,{size:12,className:"animate-spin"}):"文"})]}),(h||n)&&s.jsx("div",{className:`text-sm px-3 py-1.5 bg-gray-100 dark:bg-gray-800 rounded-lg max-w-[250px] ${o?"text-red-500":"text-theme-secondary"}`,children:h||n})]})},ef=ce.createContext(null),tf=ce.createContext(null),nf=ce.createContext(null),rf=ce.createContext(null),sf=ce.createContext(null),Vg=e=>{var t,n;for(const r of e.elements)if((n=(t=r.grayTipElement)==null?void 0:t.jsonGrayTipElement)!=null&&n.jsonStr)try{const l=JSON.parse(r.grayTipElement.jsonGrayTipElement.jsonStr);if(l.items){const i=l.items.some(o=>o.type==="qq"&&o.uid);return{items:l.items,hasUid:i}}}catch{}return null},hn=new Map,Qg=p.memo(({message:e,groupCode:t})=>{const n=hn.get(e.msgId),[r,l]=p.useState(n??"[系统提示]"),i=cr();return p.useEffect(()=>{var d,m;if(hn.has(e.msgId)){l(hn.get(e.msgId));return}const o=Vg(e);if(!o){for(const f of e.elements)if((m=(d=f.grayTipElement)==null?void 0:d.xmlElement)!=null&&m.content){const y=f.grayTipElement.xmlElement.content.replace(/<[^>]+>/g,"");hn.set(e.msgId,y),l(y);return}hn.set(e.msgId,"[系统提示]"),l("[系统提示]");return}const{items:a,hasUid:c}=o;if(!c){const y=a.map(w=>w.txt||"").join("")||"[系统提示]";hn.set(e.msgId,y),l(y);return}(async()=>{const f=[];let y=0;for(const k of a)if(k.type==="qq"&&k.uid)if(k.uid===i)f.push(s.jsx("span",{className:"text-blue-500",children:"你"},y++));else{const j=await Th(k.uid,t);f.push(s.jsx("span",{className:"text-blue-500",children:j},y++))}else k.type==="nor"&&k.txt&&f.push(s.jsx("span",{children:k.txt},y++));const w=f.length>0?f:"[系统提示]";hn.set(e.msgId,w),l(w)})()},[e.msgId,i,t]),s.jsx("div",{className:"flex justify-center py-2",children:s.jsx("span",{className:"text-xs text-theme-hint bg-theme-item/50 px-3 py-1 rounded-full",children:r})})}),Gg=p.memo(({message:e,allMessages:t,isHighlighted:n})=>{var R,V;if(Hg(e)){const C=e.chatType===2?e.peerUin:void 0;return s.jsx(Qg,{message:e,groupCode:C})}const r=cr(),l=r?e.senderUid===r:!1,i=ce.useContext(ef),o=ce.useContext(tf),a=ce.useContext(nf),c=ce.useContext(rf),u=ce.useContext(sf);let d=e.sendMemberName||e.sendNickName||e.senderUin;if(e.chatType===1&&!l&&u){const C=u.getFriend(e.senderUin);C&&(d=C.remark||C.nickname||d)}const m=`https://q1.qlogo.cn/g?b=qq&nk=${e.senderUin}&s=640`,f=parseInt(e.msgTime)*1e3;let y,w,k;if(e.chatType===2){const C=e.msgAttrs;if(C){const E=(_=>{if(C instanceof Map)return C.get(_);if(typeof C=="object")return C[_.toString()]})(2);E!=null&&E.groupHonor&&(y=E.groupHonor.level,w=E.groupHonor.uniqueTitle||void 0)}if(c){const b=c.getMembers(e.peerUin),E=b==null?void 0:b.find(_=>_.uid===e.senderUid||_.uin===e.senderUin);E&&(k=E.role,y===void 0&&E.level&&(y=E.level),!w&&E.specialTitle&&(w=E.specialTitle))}}if(!e.elements||!Array.isArray(e.elements))return null;const j=e.recallTime&&e.recallTime!=="0",g=(R=e.elements.find(C=>C.replyElement))==null?void 0:R.replyElement,h=e.elements.filter(C=>!C.replyElement);if(!(h.some(Wg)||g))return null;const v=h.length===1&&h[0].pttElement&&!g,N=g?t.find(C=>C.msgId===g.replayMsgId||C.msgSeq===g.replayMsgSeq):null,S=C=>{C.preventDefault(),C.stopPropagation(),i==null||i.showMenu(C,e)},T=C=>{C.preventDefault(),C.stopPropagation(),o==null||o.showMenu(C,{senderUid:e.senderUid,senderUin:e.senderUin,senderName:d,chatType:e.chatType,groupCode:e.chatType===2?e.peerUin:void 0})},M=C=>{("ontouchstart"in window||navigator.maxTouchPoints>0)&&(C.preventDefault(),C.stopPropagation(),o==null||o.showMenu(C,{senderUid:e.senderUid,senderUin:e.senderUin,senderName:d,chatType:e.chatType,groupCode:e.chatType===2?e.peerUin:void 0}))},q=()=>{g&&(a==null||a.scrollToMessage(g.replayMsgId,g.replayMsgSeq))};return s.jsxs("div",{className:`flex gap-2 w-full ${l?"flex-row-reverse":""} ${n?"animate-pulse bg-pink-100 dark:bg-pink-900/30 rounded-lg -mx-2 px-2":""}`,children:[s.jsx("img",{src:m,alt:d,loading:"lazy",className:"w-8 h-8 rounded-full object-cover flex-shrink-0 cursor-pointer hover:opacity-80 transition-opacity",onClick:M,onContextMenu:T}),s.jsxs("div",{className:`flex flex-col ${l?"items-end":"items-start"} max-w-[calc(100%-48px)] md:max-w-[70%] min-w-0 overflow-hidden`,children:[s.jsxs("div",{className:`flex items-center gap-1.5 mb-1 ${l?"flex-row-reverse":""}`,children:[s.jsx("span",{className:"text-xs text-theme-hint",children:d}),y!==void 0&&y>0&&s.jsxs("span",{className:"text-xs px-1 py-0.5 bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300 rounded",children:["Lv.",y]}),k==="owner"&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-amber-100 dark:bg-amber-900/50 text-amber-600 dark:text-amber-300 rounded",children:w||"群主"}),k==="admin"&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-blue-100 dark:bg-blue-900/50 text-blue-600 dark:text-blue-300 rounded",children:w||"管理员"}),k==="member"&&w&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-pink-100 dark:bg-pink-900/50 text-pink-600 dark:text-pink-300 rounded",children:w})]}),v?s.jsxs("div",{onContextMenu:S,className:j?"opacity-50":"",children:[h.map((C,b)=>s.jsx(Wi,{element:C,message:e},b)),j&&s.jsx("div",{className:"text-xs text-theme-muted italic mt-1",children:"已撤回"})]}):s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:`rounded-2xl px-4 py-2 min-w-[80px] max-w-full break-words overflow-hidden bg-theme-item text-theme shadow-sm ${l?"rounded-tr-sm":"rounded-tl-sm"} ${j?"opacity-50":""}`,onContextMenu:S,children:[g&&s.jsx("div",{className:"text-xs mb-2 pb-2 border-b border-theme-divider cursor-pointer hover:opacity-80 transition-opacity",onClick:q,children:s.jsx("div",{className:"bg-theme-input rounded px-2 py-1",children:N?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"font-medium text-theme-secondary",children:[N.sendMemberName||N.sendNickName||N.senderUin,":"]}),s.jsx("div",{className:"text-theme-muted",children:(V=N.elements)==null?void 0:V.filter(C=>!C.replyElement).map((C,b)=>s.jsx(Wi,{element:C},b))})]}):s.jsx("span",{className:"text-theme-muted",children:g.sourceMsgText||"[消息]"})})}),h.map((C,b)=>s.jsx(Wi,{element:C,message:e},b))]}),j&&s.jsx("div",{className:"text-xs text-theme-muted italic mt-1",children:"已撤回"})]}),s.jsx(Yg,{message:e,isSelf:l}),s.jsx("span",{className:"text-xs text-theme-hint mt-1",children:ii(f)})]})]})});function Kg(e,t){return t==="2"?`/face/emoji-${parseInt(e).toString(16)}.png`:`/face/${e}.png`}const Yg=p.memo(({message:e,isSelf:t})=>{const[n,r]=p.useState(null);if(!e.emojiLikesList||e.emojiLikesList.length===0)return null;const l=async(i,o)=>{if(!n){r(i);try{const a={chatType:e.chatType,peerUid:e.peerUin,guildId:""};await te("ntMsgApi","setEmojiLike",[a,e.msgSeq,i,!o])}catch(a){Y(a.message||"操作失败","error")}finally{r(null)}}};return s.jsx("div",{className:`flex flex-wrap gap-1 mt-1 ${t?"justify-end":"justify-start"}`,children:e.emojiLikesList.map((i,o)=>{const a=Kg(i.emojiId,i.emojiType);return s.jsxs("button",{onClick:()=>l(i.emojiId,i.isClicked),disabled:n===i.emojiId,className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-xs transition-all cursor-pointer hover:scale-105 active:scale-95 ${i.isClicked?"bg-pink-100 dark:bg-pink-900/40 border border-pink-300 dark:border-pink-700":"bg-theme-item border border-theme-divider hover:border-pink-300 dark:hover:border-pink-700"} ${n===i.emojiId?"opacity-50":""}`,title:i.isClicked?"点击取消":"点击跟贴",children:[s.jsx("img",{src:a,alt:`表情${i.emojiId}`,className:"w-4 h-4",onError:c=>{if(i.emojiType==="2"){const u=c.target,d=String.fromCodePoint(parseInt(i.emojiId));u.style.display="none",u.insertAdjacentHTML("afterend",`<span class="text-sm">${d}</span>`)}}}),s.jsx("span",{className:"text-theme-secondary",children:i.likesCnt})]},`${i.emojiId}-${o}`)})})}),Xg=p.memo(({message:e,onRetry:t})=>{const n=li(),r=n?`https://q1.qlogo.cn/g?b=qq&nk=${n}&s=640`:"";return s.jsxs("div",{className:"flex gap-2 flex-row-reverse w-full",children:[r&&s.jsx("img",{src:r,alt:"我",loading:"lazy",className:"w-8 h-8 rounded-full object-cover flex-shrink-0"}),s.jsxs("div",{className:"flex flex-col items-end max-w-[calc(100%-48px)] md:max-w-[70%] min-w-0 overflow-hidden",children:[s.jsx("span",{className:"text-xs text-theme-hint mb-1",children:"我"}),s.jsxs("div",{className:"flex items-end gap-1",children:[e.status==="failed"&&s.jsx("button",{onClick:t,className:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/30 rounded",title:"重新发送",children:s.jsx(oh,{size:14})}),s.jsx("div",{className:"rounded-2xl px-4 py-2 bg-theme-item text-theme rounded-tr-sm min-w-[80px] max-w-full break-words overflow-hidden shadow-sm",children:e.items.map((l,i)=>l.type==="text"&&l.content?s.jsx("span",{className:"whitespace-pre-wrap break-words",children:l.content},i):l.type==="face"&&l.faceId!==void 0?s.jsx("img",{src:`/face/${l.faceId}.png`,alt:`[表情${l.faceId}]`,className:"inline-block align-text-bottom",style:{width:24,height:24}},i):l.type==="image"&&l.imageUrl?s.jsx("img",{src:l.imageUrl,alt:"图片",loading:"lazy",className:"max-w-full rounded-lg",style:{maxHeight:"200px"}},i):l.type==="at"&&l.atName?s.jsxs("span",{className:"text-blue-500",children:["@",l.atName]},i):null)}),e.status==="sending"&&s.jsx(Se,{size:14,className:"animate-spin text-theme-hint"}),e.status==="failed"&&s.jsx(Jm,{size:14,className:"text-red-500"})]}),s.jsx("span",{className:"text-xs text-theme-hint mt-1",children:ii(e.timestamp)})]})]})}),Jg=({name:e,onMute:t,onClose:n})=>{const[r,l]=p.useState(0),[i,o]=p.useState(0),[a,c]=p.useState(0),[u,d]=p.useState(0),m=()=>{const y=r+i*60+a*3600+u*86400;y>0&&t(y)},f=r+i*60+a*3600+u*86400;return Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-50 bg-black/30",onClick:n}),s.jsxs("div",{className:"fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-theme-card backdrop-blur-xl border border-theme-divider rounded-xl shadow-xl p-6 min-w-[340px]",children:[s.jsxs("h3",{className:"text-lg font-medium text-theme mb-4",children:["禁言 ",e]}),s.jsxs("div",{className:"mb-4",children:[s.jsx("p",{className:"text-sm text-theme-secondary mb-3",children:"设置禁言时长:"}),s.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("input",{type:"number",min:0,max:59,value:r,onChange:y=>l(Math.min(59,Math.max(0,parseInt(y.target.value)||0))),className:"w-full px-2 py-2 text-center bg-theme-input border border-theme-input rounded-lg text-theme focus:outline-none focus:ring-2 focus:ring-pink-500/20"}),s.jsx("span",{className:"text-xs text-theme-secondary mt-1",children:"秒"})]}),s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("input",{type:"number",min:0,max:59,value:i,onChange:y=>o(Math.min(59,Math.max(0,parseInt(y.target.value)||0))),className:"w-full px-2 py-2 text-center bg-theme-input border border-theme-input rounded-lg text-theme focus:outline-none focus:ring-2 focus:ring-pink-500/20"}),s.jsx("span",{className:"text-xs text-theme-secondary mt-1",children:"分钟"})]}),s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("input",{type:"number",min:0,max:23,value:a,onChange:y=>c(Math.min(23,Math.max(0,parseInt(y.target.value)||0))),className:"w-full px-2 py-2 text-center bg-theme-input border border-theme-input rounded-lg text-theme focus:outline-none focus:ring-2 focus:ring-pink-500/20"}),s.jsx("span",{className:"text-xs text-theme-secondary mt-1",children:"小时"})]}),s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("input",{type:"number",min:0,max:29,value:u,onChange:y=>d(Math.min(29,Math.max(0,parseInt(y.target.value)||0))),className:"w-full px-2 py-2 text-center bg-theme-input border border-theme-input rounded-lg text-theme focus:outline-none focus:ring-2 focus:ring-pink-500/20"}),s.jsx("span",{className:"text-xs text-theme-secondary mt-1",children:"天"})]})]}),s.jsx("p",{className:"text-xs text-theme-secondary mt-2 text-center",children:"最长29天23小时59分59秒"})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("button",{onClick:()=>t(0),className:"px-4 py-2 text-sm text-green-500 hover:bg-green-50 dark:hover:bg-green-900/30 rounded-lg transition-colors",children:"解除禁言"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:n,className:"px-4 py-2 text-sm text-theme-secondary hover:bg-theme-item rounded-lg transition-colors",children:"取消"}),s.jsx("button",{onClick:m,disabled:f===0,className:"px-4 py-2 text-sm bg-orange-500 text-white hover:bg-orange-600 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"确认禁言"})]})]})]})]}),document.body)},Zg=({name:e,groupName:t,onConfirm:n,onClose:r})=>Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-50 bg-black/50",onClick:r}),s.jsxs("div",{className:"fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-theme-card border border-theme-divider rounded-xl shadow-xl p-6 min-w-[320px]",children:[s.jsx("h3",{className:"text-lg font-medium text-theme mb-4",children:"确认踢出"}),s.jsxs("p",{className:"text-theme-secondary mb-6",children:["确定要将 ",s.jsx("span",{className:"font-medium text-theme",children:e})," 移出群 ",s.jsx("span",{className:"font-medium text-theme",children:t})," 吗?"]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx("button",{onClick:r,className:"px-4 py-2 text-sm text-theme-secondary hover:bg-theme-item rounded-lg transition-colors",children:"取消"}),s.jsx("button",{onClick:n,className:"px-4 py-2 text-sm bg-red-500 text-white hover:bg-red-600 rounded-lg transition-colors",children:"确认踢出"})]})]})]}),document.body),ey=({name:e,onConfirm:t,onClose:n})=>{const[r,l]=p.useState("");return Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-50 bg-black/30",onClick:n}),s.jsxs("div",{className:"fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-theme-card backdrop-blur-xl border border-theme-divider rounded-xl shadow-xl p-6 min-w-[320px]",children:[s.jsx("h3",{className:"text-lg font-medium text-theme mb-4",children:"设置头衔"}),s.jsxs("p",{className:"text-sm text-theme-secondary mb-3",children:["为 ",e," 设置专属头衔:"]}),s.jsx("input",{type:"text",maxLength:12,value:r,onChange:i=>l(i.target.value),placeholder:"留空清除头衔",className:"w-full px-3 py-2 bg-theme-input border border-theme-input rounded-lg text-theme focus:outline-none focus:ring-2 focus:ring-pink-500/20 placeholder:text-theme-hint",autoFocus:!0,onKeyDown:i=>{i.key==="Enter"&&t(r.trim())}}),s.jsx("p",{className:"text-xs text-theme-secondary mt-2",children:"中文最多6字,英文最多12字,按回车确认"}),s.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[s.jsx("button",{onClick:n,className:"px-4 py-2 text-sm text-theme-secondary hover:bg-theme-item rounded-lg transition-colors",children:"取消"}),s.jsx("button",{onClick:()=>t(r.trim()),className:"px-4 py-2 text-sm bg-pink-500 text-white hover:bg-pink-600 rounded-lg transition-colors",children:"确认"})]})]})]}),document.body)};function lf(e,t,n){const[r,l]=p.useState({left:-9999,top:-9999,ready:!1});return p.useEffect(()=>{l({left:-9999,top:-9999,ready:!1});const i=requestAnimationFrame(()=>{if(!n.current){l({left:e,top:t,ready:!0});return}const o=n.current.getBoundingClientRect(),a=10;let c=e,u=t;e+o.width>window.innerWidth-a&&(c=e-o.width),c<a&&(c=a),t+o.height>window.innerHeight-a&&(u=t-o.height),u<a&&(u=a),l({left:c,top:u,ready:!0})});return()=>cancelAnimationFrame(i)},[e,t]),r}const ty=({contextMenu:e,session:t,getCachedMembers:n,onClose:r,onReply:l,onEmojiReaction:i,onRecall:o})=>{const a=e.message,c=cr(),u=c&&a.senderUid===c,d=a.chatType===2,m=d&&t?n(t.peerId):null,f=m&&c?m.find(M=>M.uid===c):null,y=f==null?void 0:f.role,w=y==="owner",k=y==="admin"||y==="owner",j=m?m.find(M=>M.uid===a.senderUid):null,g=j==null?void 0:j.role,x=u||d&&(w||k&&!(g==="admin"||g==="owner")),v=!!e.elementId,N=p.useRef(null),S=lf(e.x,e.y,N),T=async()=>{if(e.elementId){r();try{const M=await te("ntFileApi","downloadMedia",[a.msgId,a.chatType,a.peerUid,e.elementId,"",""]);if(!M){Y("图片下载失败","error");return}const q=await te("ntMsgApi","addFavEmoji",[M]);q.result===0?Y(q.isExist?"表情已存在":"已添加到表情","success"):Y(q.errMsg||"添加失败","error")}catch(M){Y(M.message||"添加失败","error")}}};return Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:r,onContextMenu:M=>{M.preventDefault(),r()}}),s.jsxs("div",{ref:N,className:"fixed z-50 bg-popup backdrop-blur-sm border border-theme-divider rounded-lg shadow-lg py-1 min-w-[100px]",style:{left:S.left,top:S.top,visibility:S.ready?"visible":"hidden"},onContextMenu:M=>M.preventDefault(),children:[s.jsxs("button",{onClick:()=>{l(a),r()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(ah,{size:14})," 回复"]}),t.chatType===2&&s.jsxs("button",{onClick:()=>{i(a,e.x,e.y),r()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(dh,{size:14})," 贴表情"]}),v&&s.jsxs("button",{onClick:T,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(mh,{size:14})," 添加到表情"]}),x&&s.jsxs("button",{onClick:async()=>{r();try{await Mh(a.chatType,a.peerUid,a.msgId),o(a.msgId),Y("消息已撤回","success")}catch(M){Y(M.message||"撤回失败","error")}},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-500 hover:bg-theme-item-hover transition-colors",children:[s.jsx(It,{size:14})," 撤回"]})]})]}),document.body)},ny=({avatarContextMenu:e,getCachedMembers:t,onClose:n,onInsertAt:r,onShowProfile:l,onSetTitle:i,onMute:o,onKick:a,onAdminChanged:c,groupName:u})=>{const d=cr(),m=e.groupCode?t(e.groupCode):null,f=m&&d?m.find(R=>R.uid===d):null,y=f==null?void 0:f.role,w=y==="owner",k=y==="admin",j=m?m.find(R=>R.uid===e.senderUid):null,g=j==null?void 0:j.role,h=g==="admin",x=w||k&&g==="member",v=w||k&&g==="member",N=e.senderUid===d,S=w&&!N,T=p.useRef(null),M=lf(e.x,e.y,T),q=async()=>{const R=e;n();try{const V=h?2:3;await te("ntGroupApi","setMemberRole",[R.groupCode,R.senderUid,V]),Y(h?"已取消管理员":"已设为管理员","success"),c==null||c()}catch(V){Y(V.message||"操作失败","error")}};return Ie.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:n,onContextMenu:R=>{R.preventDefault(),n()}}),s.jsxs("div",{ref:T,className:"fixed z-50 bg-popup backdrop-blur-sm border border-theme-divider rounded-lg shadow-lg py-1 min-w-[120px]",style:{left:M.left,top:M.top,visibility:M.ready?"visible":"hidden"},onContextMenu:R=>R.preventDefault(),children:[e.chatType===2&&s.jsxs("button",{onClick:()=>{r(e.senderUid,e.senderUin,e.senderName),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(Zm,{size:14})," 召唤ta"]}),s.jsxs("button",{onClick:async()=>{const R=e;n();try{R.chatType===2&&R.groupCode?await $l(R.chatType,parseInt(R.senderUin),parseInt(R.groupCode)):await $l(R.chatType,parseInt(R.senderUin))}catch(V){Y(V.message||"戳一戳失败","error")}},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(th,{size:14})," 戳一戳"]}),s.jsxs("button",{onClick:()=>{l(e.senderUid,e.senderUin,e.x,e.y,e.groupCode),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(fh,{size:14})," 查看资料"]}),e.chatType===2&&e.groupCode&&w&&s.jsxs("button",{onClick:()=>{i(e.senderUid,e.senderName,e.groupCode),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[s.jsx(n0,{size:14})," 设置头衔"]}),e.chatType===2&&e.groupCode&&S&&s.jsxs("button",{onClick:q,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[h?s.jsx(j0,{size:14}):s.jsx(ms,{size:14}),h?"取消管理员":"设为管理员"]}),e.chatType===2&&e.groupCode&&!N&&x&&s.jsxs("button",{onClick:()=>{o(e.senderUid,e.senderName,e.groupCode),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-orange-500 hover:bg-theme-item-hover transition-colors",children:[s.jsx(E0,{size:14})," 禁言"]}),e.chatType===2&&e.groupCode&&!N&&v&&s.jsxs("button",{onClick:()=>{a(e.senderUid,e.senderName,e.groupCode,u||e.groupCode),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-500 hover:bg-theme-item-hover transition-colors",children:[s.jsx(S0,{size:14})," 踢出群"]})]})]}),document.body)},of=p.forwardRef(({placeholder:e="输入消息...",disabled:t=!1,onEnter:n,onPaste:r,onChange:l,onMentionChange:i},o)=>{const a=p.useRef(null),c=p.useRef(!1),u=p.useRef(null),[d,m]=p.useState(!1),f=p.useCallback(()=>{const b=a.current;if(!b)return[];const E=[],_=b.childNodes;for(let U=0;U<_.length;U++){const D=_[U];if(D.nodeType===Node.TEXT_NODE){const W=(D.textContent||"").replace(/\u200B/g,"");W&&E.push({type:"text",content:W})}else if(D.nodeType===Node.ELEMENT_NODE){const P=D;if(P.dataset.type==="face")E.push({type:"face",faceId:parseInt(P.dataset.faceId||"0")});else if(P.dataset.type==="image")E.push({type:"image",imageUrl:P.dataset.imageUrl,imageFile:P.__file});else if(P.dataset.type==="at")E.push({type:"at",atUid:P.dataset.atUid,atUin:P.dataset.atUin,atName:P.dataset.atName});else if(P.tagName==="BR")E.push({type:"text",content:`
440
440
  `});else{const K=(P.textContent||"").replace(/\u200B/g,"");K&&E.push({type:"text",content:K})}}}return E},[]),y=p.useCallback(()=>{var E;const b=f();return b.length===0||b.length===1&&b[0].type==="text"&&!((E=b[0].content)!=null&&E.trim())},[f]),w=p.useCallback(()=>{var D;const b=window.getSelection();if(!b||b.rangeCount===0)return{top:0,left:0};const _=b.getRangeAt(0).getBoundingClientRect(),U=(D=a.current)==null?void 0:D.getBoundingClientRect();return U?{top:U.bottom-_.top+8,left:_.left-U.left}:{top:0,left:0}},[]),k=p.useCallback(()=>{if(!u.current)return"";const b=window.getSelection();if(!b||b.rangeCount===0)return"";const E=b.getRangeAt(0),{node:_,offset:U}=u.current;return E.startContainer!==_?"":(_.textContent||"").slice(U,E.startOffset)},[]),j=p.useCallback(()=>{u.current=null,m(!1),i==null||i({active:!1,query:"",position:{top:0,left:0}})},[i]),g=p.useCallback(()=>{const b=window.getSelection();if(!b||b.rangeCount===0)return;const E=b.getRangeAt(0),_=E.startContainer;if(_.nodeType!==Node.TEXT_NODE){d&&j();return}const U=_.textContent||"",D=E.startOffset;if(d&&u.current){if(u.current.node===_&&D>=u.current.offset){const K=k();K.includes(" ")?j():i==null||i({active:!0,query:K,position:w()})}else j();return}const P=U.slice(0,D),W=P.lastIndexOf("@");if(W!==-1){const K=W>0?P[W-1]:" ";if(K===" "||K===`
441
441
  `||W===0){const J=P.slice(W+1);J.includes(" ")||(u.current={node:_,offset:W+1},m(!0),i==null||i({active:!0,query:J,position:w()}))}}},[d,k,w,j,i]),h=p.useCallback(b=>{const E=a.current;if(!E)return;j();const _=document.createTextNode(b),U=window.getSelection();if(U&&U.rangeCount>0){const D=U.getRangeAt(0);E.contains(D.commonAncestorContainer)?(D.deleteContents(),D.insertNode(_),D.setStartAfter(_),D.setEndAfter(_),U.removeAllRanges(),U.addRange(D)):E.appendChild(_)}else E.appendChild(_);E.focus(),l==null||l(f())},[l,f,j]),x=p.useCallback(b=>{const E=a.current;if(!E)return;j();const _=document.createElement("span");_.contentEditable="false",_.dataset.type="face",_.dataset.faceId=String(b),_.className="inline-block align-middle mx-0.5 select-all",_.innerHTML=`<img src="/face/${b}.png" alt="[表情]" class="w-6 h-6 inline-block" draggable="false" />`;const U=window.getSelection();if(U&&U.rangeCount>0){const D=U.getRangeAt(0);if(E.contains(D.commonAncestorContainer)){D.deleteContents(),D.insertNode(_);const P=document.createTextNode("​");_.after(P),D.setStartAfter(P),D.setEndAfter(P),U.removeAllRanges(),U.addRange(D)}else{E.appendChild(_);const P=document.createTextNode("​");E.appendChild(P)}}else{E.appendChild(_);const D=document.createTextNode("​");E.appendChild(D)}E.focus(),l==null||l(f())},[l,f,j]),v=p.useCallback((b,E)=>{const _=a.current;if(!_)return;j();const U=document.createElement("span");U.contentEditable="false",U.dataset.type="image",U.dataset.imageUrl=E,b&&(U.__file=b),U.className="inline-block align-middle mx-0.5 select-all",U.innerHTML=`<img src="${E}" alt="[图片]" class="h-16 max-w-[200px] rounded inline-block object-cover" draggable="false" />`;const D=window.getSelection();if(D&&D.rangeCount>0){const P=D.getRangeAt(0);if(_.contains(P.commonAncestorContainer)){P.deleteContents(),P.insertNode(U);const W=document.createTextNode("​");U.after(W),P.setStartAfter(W),P.setEndAfter(W),D.removeAllRanges(),D.addRange(P)}else{_.appendChild(U);const W=document.createTextNode("​");_.appendChild(W)}}else{_.appendChild(U);const P=document.createTextNode("​");_.appendChild(P)}_.focus(),l==null||l(f())},[l,f,j]),N=p.useCallback((b,E,_)=>{const U=a.current;if(!U)return;if(d&&u.current){const{node:J,offset:ae}=u.current,ge=window.getSelection();if(ge&&ge.rangeCount>0){const Ce=ge.getRangeAt(0),Q=document.createRange();Q.setStart(J,ae-1),Q.setEnd(Ce.startContainer,Ce.startOffset),Q.deleteContents()}}j();const D=document.createElement("span");D.contentEditable="false",D.dataset.type="at",D.dataset.atUid=b,D.dataset.atUin=E,D.dataset.atName=_,D.className="inline-block align-middle mx-0.5 px-1 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-300 text-sm rounded select-all",D.textContent=`@${_}`;const P=window.getSelection();if(P&&P.rangeCount>0){const J=P.getRangeAt(0);U.contains(J.commonAncestorContainer)?(J.deleteContents(),J.insertNode(D),J.setStartAfter(D),J.setEndAfter(D),P.removeAllRanges(),P.addRange(J)):U.appendChild(D)}else U.appendChild(D);const W=document.createTextNode(" ");D.after(W);const K=document.createRange();K.setStartAfter(W),K.setEndAfter(W),P==null||P.removeAllRanges(),P==null||P.addRange(K),U.focus(),l==null||l(f())},[d,l,f,j]),S=p.useCallback(()=>{const b=a.current;b&&(b.innerHTML="",j(),l==null||l([]))},[l,j]),T=p.useCallback(()=>{const b=a.current;if(!b)return;b.focus();const E=window.getSelection();if(E){const _=document.createRange();_.selectNodeContents(b),_.collapse(!1),E.removeAllRanges(),E.addRange(_)}},[]);p.useImperativeHandle(o,()=>({focus:T,clear:S,insertFace:x,insertText:h,insertImage:v,insertAt:N,getContent:f,isEmpty:y,cancelMention:j}),[T,S,x,h,v,N,f,y,j]);const M=p.useCallback(b=>{if(d){if(["ArrowUp","ArrowDown","Enter","Tab"].includes(b.key))return;if(b.key==="Escape"){b.preventDefault(),j();return}}b.key==="Enter"&&!b.shiftKey&&!c.current&&!d&&(b.preventDefault(),n==null||n())},[n,d,j]),q=p.useCallback(()=>{g(),l==null||l(f())},[l,f,g]),R=p.useCallback(b=>{var U,D;const E=(U=b.clipboardData)==null?void 0:U.items;if(E){for(let P=0;P<E.length;P++)if(E[P].type.startsWith("image/")){b.preventDefault(),r==null||r(b);return}}b.preventDefault();const _=(D=b.clipboardData)==null?void 0:D.getData("text/plain");_&&document.execCommand("insertText",!1,_)},[r]),V=p.useCallback(()=>{setTimeout(g,0)},[g]),C=p.useCallback(()=>{setTimeout(()=>{d&&j()},200)},[d,j]);return s.jsxs("div",{className:"relative",children:[s.jsx("div",{ref:a,contentEditable:!t,onKeyDown:M,onInput:q,onPaste:R,onClick:V,onBlur:C,onCompositionStart:()=>{c.current=!0},onCompositionEnd:()=>{c.current=!1,q()},className:`min-h-[36px] max-h-[120px] overflow-y-auto px-3 py-2 outline-none text-theme whitespace-pre-wrap break-words ${t?"opacity-50 cursor-not-allowed":""}`,style:{wordBreak:"break-word"},"data-placeholder":e,suppressContentEditableWarning:!0}),s.jsx("style",{children:`
442
442
  [data-placeholder]:empty:before {
@@ -450,4 +450,4 @@ Error generating stack: `+i.message+`
450
450
  `,children:s.jsx(gg,{activeTab:f,onTabChange:j,friendCategories:a,groups:c,recentChats:T,unreadCounts:Ce,selectedPeerId:m==null?void 0:m.peerId,onSelectFriend:J,onSelectGroup:ae,onSelectRecent:ge})}),s.jsx("div",{className:`
451
451
  flex-1 flex flex-col min-w-0
452
452
  ${D?"block":"hidden md:flex"}
453
- `,children:s.jsx(py,{session:m,onShowMembers:()=>g(!w),onNewMessageCallback:b,onEmojiReactionCallback:E,onMessageRecalledCallback:_,appendInputMention:M,onAppendInputMentionConsumed:V,onBack:K,showBackButton:D})}),w&&(m==null?void 0:m.chatType)===2&&s.jsx("div",{className:"fixed inset-0 z-50 bg-white/85 dark:bg-neutral-900/85 backdrop-blur-xl md:static md:inset-auto md:z-auto md:bg-transparent md:backdrop-blur-none md:w-64 md:border-l md:border-theme-divider md:flex-shrink-0",children:s.jsx(gy,{groupCode:m.peerId,onClose:()=>g(!1),onAtMember:R})})]}),!e&&o&&s.jsx("button",{onClick:()=>window.open("#webqq-fullscreen","_blank"),className:"fixed bottom-6 right-6 z-50 p-3 bg-pink-500/70 hover:bg-pink-500/90 text-white rounded-full shadow-lg hover:shadow-xl transition-all duration-200 group backdrop-blur-sm",title:"在新窗口中全屏打开",children:s.jsx(g0,{size:20,className:"group-hover:scale-110 transition-transform"})})]})},vy=()=>s.jsx("div",{className:"h-screen bg-theme p-4 md:p-8",children:s.jsx(df,{isFullscreen:!0})}),wy={enable:!0,connect:[]},ky={enable:!1,host:"127.0.0.1",port:5600,token:""},jy={enable:!1,reportSelfMessage:!1,http:{host:"127.0.0.1",port:3010,prefix:"",accessToken:""},webhook:{urls:[],accessToken:""}},Ny={enable:!0,host:"127.0.0.1",port:3080},by={webui:Ny,milky:jy,satori:ky,ob11:wy,enableLocalFile2Url:!1,log:!0,autoDeleteFile:!1,autoDeleteFileSecond:60,musicSignUrl:"https://ss.xingzhige.com/music_card/card",msgCacheExpire:120,ffmpeg:"",rawMsgPB:!1},$u="7.9.2";function Sy(){const e=()=>{const Q=window.location.hash.slice(1);return["dashboard","onebot","satori","milky","logs","other","webqq","webqq-fullscreen","about"].includes(Q)?Q:"dashboard"},[t,n]=p.useState(e),[r,l]=p.useState(by),[i,o]=p.useState(null),[a,c]=p.useState(!1),[u,d]=p.useState(!1),[m,f]=p.useState(!0),[y,w]=p.useState(null),[k,j]=p.useState(!1),[g,h]=p.useState(""),[x,v]=p.useState(null),[N,S]=p.useState(!1),[T,M]=p.useState(!1),[q,R]=p.useState(!1),[V,C]=p.useState(!1),[b,E]=p.useState(""),[_,U]=p.useState(!1),[D,P]=p.useState(!1),[W,K]=p.useState(!1),{autoHideSidebarInWebQQ:J}=Ha();p.useEffect(()=>{W0(async Q=>new Promise(I=>{h(Q||""),j(!0),v(()=>I)}))},[]),p.useEffect(()=>{window.location.hash=t},[t]),p.useEffect(()=>{J&&t==="webqq"&&P(!0)},[t,J]),p.useEffect(()=>{const Q=()=>{const I=window.location.hash.slice(1);["dashboard","onebot","satori","milky","logs","other","webqq","webqq-fullscreen","about"].includes(I)&&n(I)};return window.addEventListener("hashchange",Q),()=>window.removeEventListener("hashchange",Q)},[]);const ae=p.useCallback(Q=>{Q.trim()?(j(!1),h(""),x&&(x(Q),v(null))):h("密码不能为空")},[x]);p.useEffect(()=>{(async()=>{var I;try{const F=await je("/api/config");if(F.success&&F.data.selfInfo.online){d(!0),w({nick:F.data.selfInfo.nick||"",uin:F.data.selfInfo.uin}),l(F.data.config);try{const H=await je("/api/email/config");H.success&&H.data&&o(H.data)}catch(H){console.error("Failed to fetch email config:",H)}try{const H=await je("/api/device-info");H.success&&((I=H.data)!=null&&I.buildVer)&&E(H.data.buildVer)}catch(H){console.error("Failed to fetch device info:",H)}}else d(!1)}catch(F){console.error("Failed to check login status:",F),d(!1)}finally{f(!1)}})()},[]);const ge=p.useCallback(async(Q,I)=>{try{c(!0);const F=Q||r,H=I!==void 0?I:i,se=await je("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:F})});if(!se.success){Y(se.message||"保存失败","error");return}if(H)try{const le=await je("/api/email/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)});if(!le.success){Y(`主配置已保存,但邮件配置保存失败:${le.message}`,"warning");return}}catch(le){Y(`主配置已保存,但邮件配置保存失败:${le.message}`,"warning");return}Y("配置保存成功","success")}catch(F){Y(F.message||"保存失败","error")}finally{c(!1)}},[r,i]),Ce=p.useCallback(()=>{window.location.reload()},[]);return m?s.jsxs(s.Fragment,{children:[s.jsx(As,{}),s.jsx("div",{className:"relative flex items-center justify-center min-h-screen z-10",children:s.jsx(Se,{size:48,className:"animate-spin text-pink-500"})}),s.jsx(Ds,{visible:k,onConfirm:ae,error:g})]}):u?t==="webqq-fullscreen"?s.jsxs(s.Fragment,{children:[s.jsx(As,{}),s.jsx(vy,{}),s.jsx(Ds,{visible:k,onConfirm:ae,error:g}),s.jsx(Di,{})]}):s.jsxs("div",{className:"flex min-h-screen",children:[s.jsx(As,{}),s.jsx(B0,{activeTab:t,onTabChange:n,accountInfo:y||void 0,isOpen:_,onClose:()=>U(!1),collapsed:D,onToggleCollapse:()=>P(!D),onOpenSettings:()=>K(!0)}),s.jsxs("main",{className:`flex-1 overflow-auto z-10 transition-all duration-300 ${D?"":"md:ml-64"}`,children:[s.jsxs("div",{className:"md:hidden sticky top-0 z-30 bg-theme-card/95 backdrop-blur-xl border-b border-theme-divider px-4 py-3 flex items-center gap-3",children:[s.jsx("button",{onClick:()=>U(!0),className:"p-2 text-theme-muted hover:text-theme hover:bg-theme-item rounded-lg transition-colors",children:s.jsx(y0,{size:24})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:"/logo.jpg",alt:"Logo",className:"w-8 h-8 rounded-lg"}),s.jsx("span",{className:"font-semibold text-theme",children:"LLBot"})]})]}),s.jsxs("div",{className:"p-4 md:p-8 max-w-6xl mx-auto",children:[s.jsxs("div",{className:"mb-8 hidden md:block",children:[s.jsx("h2",{className:"text-3xl font-bold text-white mb-2",children:t==="dashboard"&&"Dashboard"}),s.jsx("p",{className:"text-white/80",children:t==="dashboard"&&"欢迎使用 Lucky Lillia Bot"})]}),t==="dashboard"&&s.jsx(Y0,{llbotVersion:$u,qqVersion:b}),t==="webqq"&&s.jsx(df,{}),t==="logs"&&s.jsx(X0,{}),t==="onebot"&&s.jsx(J0,{config:r.ob11,onChange:Q=>{const I={...r,ob11:Q};l(I)},onSave:Q=>{if(Q){const I={...r,ob11:Q};ge(I)}else ge()}}),t==="satori"&&s.jsxs("div",{className:"card p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl gradient-primary-br flex items-center justify-center",children:s.jsx(Ua,{size:24,className:"text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"Satori 协议"}),s.jsx("p",{className:"text-sm text-theme-secondary",children:"配置 Satori 协议相关设置"})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 bg-theme-item rounded-xl hover:bg-theme-item-hover transition-colors",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-theme",children:"启用 Satori 协议"}),s.jsx("div",{className:"text-xs text-theme-muted mt-0.5",children:"开启后将支持 Satori 协议连接"})]}),s.jsx("input",{type:"checkbox",checked:r.satori.enable,onChange:Q=>l({...r,satori:{...r.satori,enable:Q.target.checked}}),className:"switch-toggle"})]}),r.satori.enable&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"监听地址"}),s.jsx(ls,{value:r.satori.host,onChange:Q=>l({...r,satori:{...r.satori,host:Q}})}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"选择服务监听的网络地址"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"Satori 端口"}),s.jsx("input",{type:"number",value:r.satori.port,onChange:Q=>l({...r,satori:{...r.satori,port:parseInt(Q.target.value)}}),min:"1",max:"65535",placeholder:"5500",className:"input-field"}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"Satori 服务监听端口(1-65535)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"Satori Token"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:N?"text":"password",value:r.satori.token,onChange:Q=>l({...r,satori:{...r.satori,token:Q.target.value}}),placeholder:"请输入 Satori Token",className:"input-field pr-12"}),s.jsx("button",{type:"button",onClick:()=>S(!N),className:"absolute right-3 top-1/2 -translate-y-1/2 text-theme-hint hover:text-theme transition-colors p-1",children:N?s.jsx(sn,{size:20}):s.jsx(Ft,{size:20})})]}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"用于 Satori 连接验证的 Token"})]})]})]}),s.jsx("div",{className:"mt-6 flex justify-end",children:s.jsx("button",{onClick:()=>{var Q;if(r.satori.host===""&&r.satori.enable&&!((Q=r.satori.token)!=null&&Q.trim())){Y("当监听所有地址时,必须设置 Satori Token!","error");return}ge()},disabled:a,className:"btn-primary flex items-center gap-2",children:a?s.jsxs(s.Fragment,{children:[s.jsx(Se,{size:20,className:"animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ui,{size:20}),"保存配置"]})})})]}),t==="milky"&&s.jsxs("div",{className:"card p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-pink-500 to-rose-600 flex items-center justify-center",children:s.jsx(rh,{size:24,className:"text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"Milky 协议"}),s.jsx("p",{className:"text-sm text-theme-secondary",children:"配置 Milky 协议相关设置"})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 bg-theme-item rounded-xl hover:bg-theme-item-hover transition-colors",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-theme",children:"启用 Milky 协议"}),s.jsx("div",{className:"text-xs text-theme-muted mt-0.5",children:"开启后将支持 Milky 协议连接"})]}),s.jsx("input",{type:"checkbox",checked:r.milky.enable,onChange:Q=>l({...r,milky:{...r.milky,enable:Q.target.checked}}),className:"switch-toggle"})]}),r.milky.enable&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between p-4 bg-theme-item rounded-xl hover:bg-theme-item-hover transition-colors",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-theme",children:"上报自己发送的消息"}),s.jsx("div",{className:"text-xs text-theme-muted mt-0.5",children:"启用后将上报自己发送的消息"})]}),s.jsx("input",{type:"checkbox",checked:r.milky.reportSelfMessage,onChange:Q=>l({...r,milky:{...r.milky,reportSelfMessage:Q.target.checked}}),className:"switch-toggle"})]}),s.jsxs("div",{className:"border-t border-theme-divider pt-4 mt-4",children:[s.jsx("h4",{className:"text-md font-semibold text-theme mb-4",children:"HTTP 配置"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"监听地址"}),s.jsx(ls,{value:r.milky.http.host,onChange:Q=>l({...r,milky:{...r.milky,http:{...r.milky.http,host:Q}}})}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"选择服务监听的网络地址"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"HTTP 端口"}),s.jsx("input",{type:"number",value:r.milky.http.port,onChange:Q=>l({...r,milky:{...r.milky,http:{...r.milky.http,port:parseInt(Q.target.value)}}}),min:"1",max:"65535",placeholder:"3010",className:"input-field"}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"Milky HTTP 服务监听端口(1-65535)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"路径前缀"}),s.jsx("input",{type:"text",value:r.milky.http.prefix,onChange:Q=>l({...r,milky:{...r.milky,http:{...r.milky.http,prefix:Q.target.value}}}),placeholder:"/api",className:"input-field"}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"HTTP API 路径前缀(可选)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"Access Token"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:T?"text":"password",value:r.milky.http.accessToken,onChange:Q=>l({...r,milky:{...r.milky,http:{...r.milky.http,accessToken:Q.target.value}}}),placeholder:"请输入 Access Token",className:"input-field pr-12"}),s.jsx("button",{type:"button",onClick:()=>M(!T),className:"absolute right-3 top-1/2 -translate-y-1/2 text-theme-hint hover:text-theme transition-colors p-1",children:T?s.jsx(sn,{size:20}):s.jsx(Ft,{size:20})})]}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"用于 Milky HTTP 连接验证的 Token"})]})]})]}),s.jsxs("div",{className:"border-t border-theme-divider pt-4 mt-4",children:[s.jsx("h4",{className:"text-md font-semibold text-theme mb-4",children:"Webhook 配置"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"Webhook URLs"}),s.jsxs("div",{className:"space-y-2",children:[r.milky.webhook.urls.map((Q,I)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:Q,onChange:F=>{const H=[...r.milky.webhook.urls];H[I]=F.target.value,l({...r,milky:{...r.milky,webhook:{...r.milky.webhook,urls:H}}})},placeholder:"http:// 或 https://",className:`input-field flex-1 ${Q&&!Q.match(/^https?:\/\//)?"border-red-300 focus:ring-red-500":""}`}),s.jsx("button",{type:"button",onClick:()=>{const F=r.milky.webhook.urls.filter((H,se)=>se!==I);l({...r,milky:{...r.milky,webhook:{...r.milky.webhook,urls:F}}})},className:"p-2 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/30 rounded-lg transition-colors",title:"删除",children:s.jsx(It,{size:18})})]},I)),r.milky.webhook.urls.some(Q=>Q&&!Q.match(/^https?:\/\//))&&s.jsx("p",{className:"text-xs text-red-500",children:"URL 必须以 http:// 或 https:// 开头"}),s.jsxs("button",{type:"button",onClick:()=>{l({...r,milky:{...r.milky,webhook:{...r.milky.webhook,urls:[...r.milky.webhook.urls,""]}}})},className:"flex items-center gap-2 px-4 py-2 text-pink-500 hover:bg-pink-50 dark:hover:bg-pink-900/30 rounded-lg transition-colors text-sm font-medium",children:[s.jsx(ih,{size:18}),"添加 Webhook URL"]})]}),s.jsx("p",{className:"text-xs text-theme-muted mt-2",children:"事件上报的 Webhook 地址"})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"Access Token"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:q?"text":"password",value:r.milky.webhook.accessToken,onChange:Q=>l({...r,milky:{...r.milky,webhook:{...r.milky.webhook,accessToken:Q.target.value}}}),placeholder:"请输入 Access Token",className:"input-field pr-12"}),s.jsx("button",{type:"button",onClick:()=>R(!q),className:"absolute right-3 top-1/2 -translate-y-1/2 text-theme-hint hover:text-theme transition-colors p-1",children:q?s.jsx(sn,{size:20}):s.jsx(Ft,{size:20})})]}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"用于 Webhook 请求验证的 Token"})]})]})]})]}),s.jsx("div",{className:"mt-6 flex justify-end",children:s.jsx("button",{onClick:()=>{var F;if(r.milky.http.host===""&&r.milky.enable&&!((F=r.milky.http.accessToken)!=null&&F.trim())){Y("当监听所有地址时,必须设置 Milky Access Token!","error");return}if(r.milky.webhook.urls.filter(H=>H.trim()&&!H.match(/^https?:\/\//)).length>0){Y("Webhook URL 必须以 http:// 或 https:// 开头","error");return}const I={...r,milky:{...r.milky,webhook:{...r.milky.webhook,urls:r.milky.webhook.urls.filter(H=>H.trim())}}};l(I),ge(I)},disabled:a,className:"btn-primary flex items-center gap-2",children:a?s.jsxs(s.Fragment,{children:[s.jsx(Se,{size:20,className:"animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ui,{size:20}),"保存配置"]})})})]}),t==="other"&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"pb-24",children:s.jsx(tg,{config:r,emailConfig:i,onChange:l,onEmailChange:o,onOpenChangePassword:()=>C(!0)})}),s.jsx("div",{className:"fixed bottom-8 right-8 z-40",children:s.jsx("button",{onClick:()=>ge(),disabled:a,className:"btn-primary flex items-center gap-2 shadow-2xl hover:shadow-3xl",children:a?s.jsxs(s.Fragment,{children:[s.jsx(Se,{size:20,className:"animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ui,{size:20}),"保存配置"]})})})]}),t==="about"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"card p-8 text-center",children:[s.jsx("div",{className:"w-20 h-20 rounded-3xl overflow-hidden mx-auto mb-6 shadow-lg",children:s.jsx("img",{src:"/logo.jpg",alt:"Logo",className:"w-full h-full object-cover"})}),s.jsx("h1",{className:"text-3xl font-bold text-theme mb-2",children:"Lucky Lillia Bot"}),s.jsx("p",{className:"text-theme-secondary mb-6",children:"使你的 QQNT 支持 OneBot 11 协议、Satori 协议、Milky 协议进行 QQ 机器人开发"}),s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/LLOneBot/LuckyLilliaBot",target:"_blank",rel:"noopener noreferrer",className:"px-6 py-2.5 bg-gray-800 dark:bg-neutral-700 text-white rounded-xl hover:bg-gray-900 dark:hover:bg-neutral-600 transition-colors flex items-center gap-2",children:[s.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{fillRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",clipRule:"evenodd"})}),"GitHub"]}),s.jsxs("a",{href:"https://luckylillia.com",target:"_blank",rel:"noopener noreferrer",className:"px-6 py-2.5 gradient-primary text-white rounded-xl hover:shadow-lg transition-all flex items-center gap-2",children:[s.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),"文档"]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"card p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl gradient-primary-br flex items-center justify-center",children:s.jsx("svg",{className:"w-6 h-6 text-white",fill:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M16.5 3c-1.862 0-3.505.928-4.5 2.344C11.005 3.928 9.362 3 7.5 3 4.462 3 2 5.462 2 8.5c0 4.171 4.912 8.213 6.281 9.49a2.94 2.94 0 0 0 2.438.94 2.94 2.94 0 0 0 2.438-.94C14.588 16.713 19.5 12.671 19.5 8.5 19.5 5.462 17.038 3 16.5 3z"})})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"Telegram 群"}),s.jsx("p",{className:"text-sm text-theme-secondary"})]})]}),s.jsx("a",{href:"https://t.me/+nLZEnpne-pQ1OWFl",target:"_blank",rel:"noopener noreferrer",className:"text-pink-500 hover:text-pink-600 hover:underline text-sm break-all",children:"https://t.me/+nLZEnpne-pQ1OWFl"})]}),s.jsxs("div",{className:"card p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-green-500 to-emerald-600 flex items-center justify-center",children:s.jsx("svg",{className:"w-6 h-6 text-white",fill:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M16.5 3c-1.862 0-3.505.928-4.5 2.344C11.005 3.928 9.362 3 7.5 3 4.462 3 2 5.462 2 8.5c0 4.171 4.912 8.213 6.281 9.49a2.94 2.94 0 0 0 2.438.94 2.94 2.94 0 0 0 2.438-.94C14.588 16.713 19.5 12.671 19.5 8.5 19.5 5.462 17.038 3 16.5 3z"})})}),s.jsx("div",{children:s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"QQ 群"})})]}),s.jsx("div",{className:"flex items-center gap-3",children:s.jsx("a",{href:"https://qm.qq.com/q/EZndy3xntQ",target:"_blank",rel:"noopener noreferrer",className:" text-pink-500 hover:text-pink-600 hover:underline",children:"545402644"})})]})]}),s.jsx("div",{className:"card p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl gradient-primary-br flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-theme",children:"版本信息"}),s.jsxs("div",{className:"text-xs text-theme-muted",children:["Lucky Lillia Bot ",$u]}),b&&s.jsxs("div",{className:"text-xs text-theme-muted",children:["QQ ",b]})]})]}),s.jsxs("div",{className:"text-sm text-theme-secondary",children:["WebUI Powered by ",s.jsx("span",{className:"font-semibold text-pink-500",children:"React + Tailwind"})]})]})})]})]})]}),a&&s.jsx("div",{className:"fixed inset-0 bg-black/20 dark:bg-black/40 flex items-center justify-center",style:{zIndex:9e3},children:s.jsxs("div",{className:"bg-theme-card backdrop-blur-xl rounded-2xl p-6 shadow-2xl",children:[s.jsx(Se,{size:48,className:"animate-spin text-pink-500 mx-auto"}),s.jsx("p",{className:"mt-4 text-theme",children:"加载中..."})]})}),s.jsx(Ds,{visible:k,onConfirm:ae,error:g}),s.jsx(ng,{visible:V,onClose:()=>C(!1),onSuccess:()=>{window.location.reload()}}),s.jsx(Di,{}),s.jsx($0,{visible:W,onClose:()=>K(!1)})]}):s.jsxs(s.Fragment,{children:[s.jsx(As,{}),s.jsx(rg,{onLoginSuccess:Ce}),s.jsx(Ds,{visible:k,onConfirm:ae,error:g}),s.jsx(Di,{})]})}const Uu=localStorage.getItem("llbot-theme");if(Uu)try{const{state:e}=JSON.parse(Uu);e!=null&&e.isDark&&document.documentElement.classList.add("dark")}catch{}Hi.createRoot(document.getElementById("root")).render(s.jsx(ce.StrictMode,{children:s.jsx(Sy,{})}));
453
+ `,children:s.jsx(py,{session:m,onShowMembers:()=>g(!w),onNewMessageCallback:b,onEmojiReactionCallback:E,onMessageRecalledCallback:_,appendInputMention:M,onAppendInputMentionConsumed:V,onBack:K,showBackButton:D})}),w&&(m==null?void 0:m.chatType)===2&&s.jsx("div",{className:"fixed inset-0 z-50 bg-white/85 dark:bg-neutral-900/85 backdrop-blur-xl md:static md:inset-auto md:z-auto md:bg-transparent md:backdrop-blur-none md:w-64 md:border-l md:border-theme-divider md:flex-shrink-0",children:s.jsx(gy,{groupCode:m.peerId,onClose:()=>g(!1),onAtMember:R})})]}),!e&&o&&s.jsx("button",{onClick:()=>window.open("#webqq-fullscreen","_blank"),className:"fixed bottom-6 right-6 z-50 p-3 bg-pink-500/70 hover:bg-pink-500/90 text-white rounded-full shadow-lg hover:shadow-xl transition-all duration-200 group backdrop-blur-sm",title:"在新窗口中全屏打开",children:s.jsx(g0,{size:20,className:"group-hover:scale-110 transition-transform"})})]})},vy=()=>s.jsx("div",{className:"h-screen bg-theme p-4 md:p-8",children:s.jsx(df,{isFullscreen:!0})}),wy={enable:!0,connect:[]},ky={enable:!1,host:"127.0.0.1",port:5600,token:""},jy={enable:!1,reportSelfMessage:!1,http:{host:"127.0.0.1",port:3010,prefix:"",accessToken:""},webhook:{urls:[],accessToken:""}},Ny={enable:!0,host:"127.0.0.1",port:3080},by={webui:Ny,milky:jy,satori:ky,ob11:wy,enableLocalFile2Url:!1,log:!0,autoDeleteFile:!1,autoDeleteFileSecond:60,musicSignUrl:"https://ss.xingzhige.com/music_card/card",msgCacheExpire:120,ffmpeg:"",rawMsgPB:!1},$u="7.9.3";function Sy(){const e=()=>{const Q=window.location.hash.slice(1);return["dashboard","onebot","satori","milky","logs","other","webqq","webqq-fullscreen","about"].includes(Q)?Q:"dashboard"},[t,n]=p.useState(e),[r,l]=p.useState(by),[i,o]=p.useState(null),[a,c]=p.useState(!1),[u,d]=p.useState(!1),[m,f]=p.useState(!0),[y,w]=p.useState(null),[k,j]=p.useState(!1),[g,h]=p.useState(""),[x,v]=p.useState(null),[N,S]=p.useState(!1),[T,M]=p.useState(!1),[q,R]=p.useState(!1),[V,C]=p.useState(!1),[b,E]=p.useState(""),[_,U]=p.useState(!1),[D,P]=p.useState(!1),[W,K]=p.useState(!1),{autoHideSidebarInWebQQ:J}=Ha();p.useEffect(()=>{W0(async Q=>new Promise(I=>{h(Q||""),j(!0),v(()=>I)}))},[]),p.useEffect(()=>{window.location.hash=t},[t]),p.useEffect(()=>{J&&t==="webqq"&&P(!0)},[t,J]),p.useEffect(()=>{const Q=()=>{const I=window.location.hash.slice(1);["dashboard","onebot","satori","milky","logs","other","webqq","webqq-fullscreen","about"].includes(I)&&n(I)};return window.addEventListener("hashchange",Q),()=>window.removeEventListener("hashchange",Q)},[]);const ae=p.useCallback(Q=>{Q.trim()?(j(!1),h(""),x&&(x(Q),v(null))):h("密码不能为空")},[x]);p.useEffect(()=>{(async()=>{var I;try{const F=await je("/api/config");if(F.success&&F.data.selfInfo.online){d(!0),w({nick:F.data.selfInfo.nick||"",uin:F.data.selfInfo.uin}),l(F.data.config);try{const H=await je("/api/email/config");H.success&&H.data&&o(H.data)}catch(H){console.error("Failed to fetch email config:",H)}try{const H=await je("/api/device-info");H.success&&((I=H.data)!=null&&I.buildVer)&&E(H.data.buildVer)}catch(H){console.error("Failed to fetch device info:",H)}}else d(!1)}catch(F){console.error("Failed to check login status:",F),d(!1)}finally{f(!1)}})()},[]);const ge=p.useCallback(async(Q,I)=>{try{c(!0);const F=Q||r,H=I!==void 0?I:i,se=await je("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:F})});if(!se.success){Y(se.message||"保存失败","error");return}if(H)try{const le=await je("/api/email/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)});if(!le.success){Y(`主配置已保存,但邮件配置保存失败:${le.message}`,"warning");return}}catch(le){Y(`主配置已保存,但邮件配置保存失败:${le.message}`,"warning");return}Y("配置保存成功","success")}catch(F){Y(F.message||"保存失败","error")}finally{c(!1)}},[r,i]),Ce=p.useCallback(()=>{window.location.reload()},[]);return m?s.jsxs(s.Fragment,{children:[s.jsx(As,{}),s.jsx("div",{className:"relative flex items-center justify-center min-h-screen z-10",children:s.jsx(Se,{size:48,className:"animate-spin text-pink-500"})}),s.jsx(Ds,{visible:k,onConfirm:ae,error:g})]}):u?t==="webqq-fullscreen"?s.jsxs(s.Fragment,{children:[s.jsx(As,{}),s.jsx(vy,{}),s.jsx(Ds,{visible:k,onConfirm:ae,error:g}),s.jsx(Di,{})]}):s.jsxs("div",{className:"flex min-h-screen",children:[s.jsx(As,{}),s.jsx(B0,{activeTab:t,onTabChange:n,accountInfo:y||void 0,isOpen:_,onClose:()=>U(!1),collapsed:D,onToggleCollapse:()=>P(!D),onOpenSettings:()=>K(!0)}),s.jsxs("main",{className:`flex-1 overflow-auto z-10 transition-all duration-300 ${D?"":"md:ml-64"}`,children:[s.jsxs("div",{className:"md:hidden sticky top-0 z-30 bg-theme-card/95 backdrop-blur-xl border-b border-theme-divider px-4 py-3 flex items-center gap-3",children:[s.jsx("button",{onClick:()=>U(!0),className:"p-2 text-theme-muted hover:text-theme hover:bg-theme-item rounded-lg transition-colors",children:s.jsx(y0,{size:24})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:"/logo.jpg",alt:"Logo",className:"w-8 h-8 rounded-lg"}),s.jsx("span",{className:"font-semibold text-theme",children:"LLBot"})]})]}),s.jsxs("div",{className:"p-4 md:p-8 max-w-6xl mx-auto",children:[s.jsxs("div",{className:"mb-8 hidden md:block",children:[s.jsx("h2",{className:"text-3xl font-bold text-white mb-2",children:t==="dashboard"&&"Dashboard"}),s.jsx("p",{className:"text-white/80",children:t==="dashboard"&&"欢迎使用 Lucky Lillia Bot"})]}),t==="dashboard"&&s.jsx(Y0,{llbotVersion:$u,qqVersion:b}),t==="webqq"&&s.jsx(df,{}),t==="logs"&&s.jsx(X0,{}),t==="onebot"&&s.jsx(J0,{config:r.ob11,onChange:Q=>{const I={...r,ob11:Q};l(I)},onSave:Q=>{if(Q){const I={...r,ob11:Q};ge(I)}else ge()}}),t==="satori"&&s.jsxs("div",{className:"card p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl gradient-primary-br flex items-center justify-center",children:s.jsx(Ua,{size:24,className:"text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"Satori 协议"}),s.jsx("p",{className:"text-sm text-theme-secondary",children:"配置 Satori 协议相关设置"})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 bg-theme-item rounded-xl hover:bg-theme-item-hover transition-colors",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-theme",children:"启用 Satori 协议"}),s.jsx("div",{className:"text-xs text-theme-muted mt-0.5",children:"开启后将支持 Satori 协议连接"})]}),s.jsx("input",{type:"checkbox",checked:r.satori.enable,onChange:Q=>l({...r,satori:{...r.satori,enable:Q.target.checked}}),className:"switch-toggle"})]}),r.satori.enable&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"监听地址"}),s.jsx(ls,{value:r.satori.host,onChange:Q=>l({...r,satori:{...r.satori,host:Q}})}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"选择服务监听的网络地址"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"Satori 端口"}),s.jsx("input",{type:"number",value:r.satori.port,onChange:Q=>l({...r,satori:{...r.satori,port:parseInt(Q.target.value)}}),min:"1",max:"65535",placeholder:"5500",className:"input-field"}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"Satori 服务监听端口(1-65535)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"Satori Token"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:N?"text":"password",value:r.satori.token,onChange:Q=>l({...r,satori:{...r.satori,token:Q.target.value}}),placeholder:"请输入 Satori Token",className:"input-field pr-12"}),s.jsx("button",{type:"button",onClick:()=>S(!N),className:"absolute right-3 top-1/2 -translate-y-1/2 text-theme-hint hover:text-theme transition-colors p-1",children:N?s.jsx(sn,{size:20}):s.jsx(Ft,{size:20})})]}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"用于 Satori 连接验证的 Token"})]})]})]}),s.jsx("div",{className:"mt-6 flex justify-end",children:s.jsx("button",{onClick:()=>{var Q;if(r.satori.host===""&&r.satori.enable&&!((Q=r.satori.token)!=null&&Q.trim())){Y("当监听所有地址时,必须设置 Satori Token!","error");return}ge()},disabled:a,className:"btn-primary flex items-center gap-2",children:a?s.jsxs(s.Fragment,{children:[s.jsx(Se,{size:20,className:"animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ui,{size:20}),"保存配置"]})})})]}),t==="milky"&&s.jsxs("div",{className:"card p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-pink-500 to-rose-600 flex items-center justify-center",children:s.jsx(rh,{size:24,className:"text-white"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"Milky 协议"}),s.jsx("p",{className:"text-sm text-theme-secondary",children:"配置 Milky 协议相关设置"})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 bg-theme-item rounded-xl hover:bg-theme-item-hover transition-colors",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-theme",children:"启用 Milky 协议"}),s.jsx("div",{className:"text-xs text-theme-muted mt-0.5",children:"开启后将支持 Milky 协议连接"})]}),s.jsx("input",{type:"checkbox",checked:r.milky.enable,onChange:Q=>l({...r,milky:{...r.milky,enable:Q.target.checked}}),className:"switch-toggle"})]}),r.milky.enable&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between p-4 bg-theme-item rounded-xl hover:bg-theme-item-hover transition-colors",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-theme",children:"上报自己发送的消息"}),s.jsx("div",{className:"text-xs text-theme-muted mt-0.5",children:"启用后将上报自己发送的消息"})]}),s.jsx("input",{type:"checkbox",checked:r.milky.reportSelfMessage,onChange:Q=>l({...r,milky:{...r.milky,reportSelfMessage:Q.target.checked}}),className:"switch-toggle"})]}),s.jsxs("div",{className:"border-t border-theme-divider pt-4 mt-4",children:[s.jsx("h4",{className:"text-md font-semibold text-theme mb-4",children:"HTTP 配置"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"监听地址"}),s.jsx(ls,{value:r.milky.http.host,onChange:Q=>l({...r,milky:{...r.milky,http:{...r.milky.http,host:Q}}})}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"选择服务监听的网络地址"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"HTTP 端口"}),s.jsx("input",{type:"number",value:r.milky.http.port,onChange:Q=>l({...r,milky:{...r.milky,http:{...r.milky.http,port:parseInt(Q.target.value)}}}),min:"1",max:"65535",placeholder:"3010",className:"input-field"}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"Milky HTTP 服务监听端口(1-65535)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"路径前缀"}),s.jsx("input",{type:"text",value:r.milky.http.prefix,onChange:Q=>l({...r,milky:{...r.milky,http:{...r.milky.http,prefix:Q.target.value}}}),placeholder:"/api",className:"input-field"}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"HTTP API 路径前缀(可选)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"Access Token"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:T?"text":"password",value:r.milky.http.accessToken,onChange:Q=>l({...r,milky:{...r.milky,http:{...r.milky.http,accessToken:Q.target.value}}}),placeholder:"请输入 Access Token",className:"input-field pr-12"}),s.jsx("button",{type:"button",onClick:()=>M(!T),className:"absolute right-3 top-1/2 -translate-y-1/2 text-theme-hint hover:text-theme transition-colors p-1",children:T?s.jsx(sn,{size:20}):s.jsx(Ft,{size:20})})]}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"用于 Milky HTTP 连接验证的 Token"})]})]})]}),s.jsxs("div",{className:"border-t border-theme-divider pt-4 mt-4",children:[s.jsx("h4",{className:"text-md font-semibold text-theme mb-4",children:"Webhook 配置"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"Webhook URLs"}),s.jsxs("div",{className:"space-y-2",children:[r.milky.webhook.urls.map((Q,I)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:Q,onChange:F=>{const H=[...r.milky.webhook.urls];H[I]=F.target.value,l({...r,milky:{...r.milky,webhook:{...r.milky.webhook,urls:H}}})},placeholder:"http:// 或 https://",className:`input-field flex-1 ${Q&&!Q.match(/^https?:\/\//)?"border-red-300 focus:ring-red-500":""}`}),s.jsx("button",{type:"button",onClick:()=>{const F=r.milky.webhook.urls.filter((H,se)=>se!==I);l({...r,milky:{...r.milky,webhook:{...r.milky.webhook,urls:F}}})},className:"p-2 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/30 rounded-lg transition-colors",title:"删除",children:s.jsx(It,{size:18})})]},I)),r.milky.webhook.urls.some(Q=>Q&&!Q.match(/^https?:\/\//))&&s.jsx("p",{className:"text-xs text-red-500",children:"URL 必须以 http:// 或 https:// 开头"}),s.jsxs("button",{type:"button",onClick:()=>{l({...r,milky:{...r.milky,webhook:{...r.milky.webhook,urls:[...r.milky.webhook.urls,""]}}})},className:"flex items-center gap-2 px-4 py-2 text-pink-500 hover:bg-pink-50 dark:hover:bg-pink-900/30 rounded-lg transition-colors text-sm font-medium",children:[s.jsx(ih,{size:18}),"添加 Webhook URL"]})]}),s.jsx("p",{className:"text-xs text-theme-muted mt-2",children:"事件上报的 Webhook 地址"})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-sm font-medium text-theme-secondary mb-2",children:"Access Token"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:q?"text":"password",value:r.milky.webhook.accessToken,onChange:Q=>l({...r,milky:{...r.milky,webhook:{...r.milky.webhook,accessToken:Q.target.value}}}),placeholder:"请输入 Access Token",className:"input-field pr-12"}),s.jsx("button",{type:"button",onClick:()=>R(!q),className:"absolute right-3 top-1/2 -translate-y-1/2 text-theme-hint hover:text-theme transition-colors p-1",children:q?s.jsx(sn,{size:20}):s.jsx(Ft,{size:20})})]}),s.jsx("p",{className:"text-xs text-theme-muted mt-1",children:"用于 Webhook 请求验证的 Token"})]})]})]})]}),s.jsx("div",{className:"mt-6 flex justify-end",children:s.jsx("button",{onClick:()=>{var F;if(r.milky.http.host===""&&r.milky.enable&&!((F=r.milky.http.accessToken)!=null&&F.trim())){Y("当监听所有地址时,必须设置 Milky Access Token!","error");return}if(r.milky.webhook.urls.filter(H=>H.trim()&&!H.match(/^https?:\/\//)).length>0){Y("Webhook URL 必须以 http:// 或 https:// 开头","error");return}const I={...r,milky:{...r.milky,webhook:{...r.milky.webhook,urls:r.milky.webhook.urls.filter(H=>H.trim())}}};l(I),ge(I)},disabled:a,className:"btn-primary flex items-center gap-2",children:a?s.jsxs(s.Fragment,{children:[s.jsx(Se,{size:20,className:"animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ui,{size:20}),"保存配置"]})})})]}),t==="other"&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"pb-24",children:s.jsx(tg,{config:r,emailConfig:i,onChange:l,onEmailChange:o,onOpenChangePassword:()=>C(!0)})}),s.jsx("div",{className:"fixed bottom-8 right-8 z-40",children:s.jsx("button",{onClick:()=>ge(),disabled:a,className:"btn-primary flex items-center gap-2 shadow-2xl hover:shadow-3xl",children:a?s.jsxs(s.Fragment,{children:[s.jsx(Se,{size:20,className:"animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ui,{size:20}),"保存配置"]})})})]}),t==="about"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"card p-8 text-center",children:[s.jsx("div",{className:"w-20 h-20 rounded-3xl overflow-hidden mx-auto mb-6 shadow-lg",children:s.jsx("img",{src:"/logo.jpg",alt:"Logo",className:"w-full h-full object-cover"})}),s.jsx("h1",{className:"text-3xl font-bold text-theme mb-2",children:"Lucky Lillia Bot"}),s.jsx("p",{className:"text-theme-secondary mb-6",children:"使你的 QQNT 支持 OneBot 11 协议、Satori 协议、Milky 协议进行 QQ 机器人开发"}),s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/LLOneBot/LuckyLilliaBot",target:"_blank",rel:"noopener noreferrer",className:"px-6 py-2.5 bg-gray-800 dark:bg-neutral-700 text-white rounded-xl hover:bg-gray-900 dark:hover:bg-neutral-600 transition-colors flex items-center gap-2",children:[s.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{fillRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",clipRule:"evenodd"})}),"GitHub"]}),s.jsxs("a",{href:"https://luckylillia.com",target:"_blank",rel:"noopener noreferrer",className:"px-6 py-2.5 gradient-primary text-white rounded-xl hover:shadow-lg transition-all flex items-center gap-2",children:[s.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),"文档"]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"card p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl gradient-primary-br flex items-center justify-center",children:s.jsx("svg",{className:"w-6 h-6 text-white",fill:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M16.5 3c-1.862 0-3.505.928-4.5 2.344C11.005 3.928 9.362 3 7.5 3 4.462 3 2 5.462 2 8.5c0 4.171 4.912 8.213 6.281 9.49a2.94 2.94 0 0 0 2.438.94 2.94 2.94 0 0 0 2.438-.94C14.588 16.713 19.5 12.671 19.5 8.5 19.5 5.462 17.038 3 16.5 3z"})})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"Telegram 群"}),s.jsx("p",{className:"text-sm text-theme-secondary"})]})]}),s.jsx("a",{href:"https://t.me/+nLZEnpne-pQ1OWFl",target:"_blank",rel:"noopener noreferrer",className:"text-pink-500 hover:text-pink-600 hover:underline text-sm break-all",children:"https://t.me/+nLZEnpne-pQ1OWFl"})]}),s.jsxs("div",{className:"card p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-green-500 to-emerald-600 flex items-center justify-center",children:s.jsx("svg",{className:"w-6 h-6 text-white",fill:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M16.5 3c-1.862 0-3.505.928-4.5 2.344C11.005 3.928 9.362 3 7.5 3 4.462 3 2 5.462 2 8.5c0 4.171 4.912 8.213 6.281 9.49a2.94 2.94 0 0 0 2.438.94 2.94 2.94 0 0 0 2.438-.94C14.588 16.713 19.5 12.671 19.5 8.5 19.5 5.462 17.038 3 16.5 3z"})})}),s.jsx("div",{children:s.jsx("h3",{className:"text-lg font-semibold text-theme",children:"QQ 群"})})]}),s.jsx("div",{className:"flex items-center gap-3",children:s.jsx("a",{href:"https://qm.qq.com/q/EZndy3xntQ",target:"_blank",rel:"noopener noreferrer",className:" text-pink-500 hover:text-pink-600 hover:underline",children:"545402644"})})]})]}),s.jsx("div",{className:"card p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl gradient-primary-br flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-theme",children:"版本信息"}),s.jsxs("div",{className:"text-xs text-theme-muted",children:["Lucky Lillia Bot ",$u]}),b&&s.jsxs("div",{className:"text-xs text-theme-muted",children:["QQ ",b]})]})]}),s.jsxs("div",{className:"text-sm text-theme-secondary",children:["WebUI Powered by ",s.jsx("span",{className:"font-semibold text-pink-500",children:"React + Tailwind"})]})]})})]})]})]}),a&&s.jsx("div",{className:"fixed inset-0 bg-black/20 dark:bg-black/40 flex items-center justify-center",style:{zIndex:9e3},children:s.jsxs("div",{className:"bg-theme-card backdrop-blur-xl rounded-2xl p-6 shadow-2xl",children:[s.jsx(Se,{size:48,className:"animate-spin text-pink-500 mx-auto"}),s.jsx("p",{className:"mt-4 text-theme",children:"加载中..."})]})}),s.jsx(Ds,{visible:k,onConfirm:ae,error:g}),s.jsx(ng,{visible:V,onClose:()=>C(!1),onSuccess:()=>{window.location.reload()}}),s.jsx(Di,{}),s.jsx($0,{visible:W,onClose:()=>K(!1)})]}):s.jsxs(s.Fragment,{children:[s.jsx(As,{}),s.jsx(rg,{onLoginSuccess:Ce}),s.jsx(Ds,{visible:k,onConfirm:ae,error:g}),s.jsx(Di,{})]})}const Uu=localStorage.getItem("llbot-theme");if(Uu)try{const{state:e}=JSON.parse(Uu);e!=null&&e.isDark&&document.documentElement.classList.add("dark")}catch{}Hi.createRoot(document.getElementById("root")).render(s.jsx(ce.StrictMode,{children:s.jsx(Sy,{})}));