Files
Ydisks-Xianyu-Helper/internal/webui/static/assets/Chat-DJNDDkT1.js
T
Christ 3b67ab81ee 修复:禁止批量铺货误读多工作表内容
- 按 workbook 关系定位唯一 XLSX 工作表并拒绝多表或损坏结构
- 重置表格文件控件以支持同一路径文件重新选择
- 补齐应用层、HTTP 与前端文件选择回归测试
2026-08-20 21:15:21 +08:00

2 lines
47 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{d as S,j as e,a as n}from"./react-vendor-Bf9ELcll.js";import{L as oe}from"./vendor-BE-_xUHH.js";import{B as pe}from"./audio-codec-mjVr_wwJ.js";import{L as $,al as de,am as me,q as ge,an as xe,ao as ue,M as z0,I as he,R as _e,ad as D0,k as be,ap as fe,t as W0,aq as je,ar as we,ai as J0,X as Ne}from"./icons-vendor-B5fJPoU1.js";import{g as U0,p as ye,b as Q0,m as V0,s as Ce,d as Oe,e as ve,f as ke,h as Z0}from"./index-C6RECy_0.js";const F0="ydisks:chat-audio-play",Se=[6,10,15,8,17,12,7,16,11,6,14,9];function Re(r){const c=r.trim();if(typeof location>"u"||location.protocol!=="https:")return c;try{const a=new URL(c);return a.protocol==="http:"&&a.hostname.endsWith(".aliyuncs.com")&&(a.protocol="https:"),a.toString()}catch{return c}}function q0(r){const c=Number.isFinite(r)?Math.max(0,Math.floor(r)):0,a=Math.floor(c/60),i=c%60;return`${a}:${i.toString().padStart(2,"0")}`}function T0(r){window.dispatchEvent(new CustomEvent(F0,{detail:r}))}const Ee=({messageKey:r,src:c,outgoing:a,initialDuration:i=0})=>{const x=S.useRef(null),N=S.useRef(0),[d,R]=S.useState("idle"),[E,L]=S.useState(i),[W,q]=S.useState(0);S.useEffect(()=>(()=>{var u;N.current+=1,(u=x.current)==null||u.destroy(),x.current=null}),[c]),S.useEffect(()=>{L(Math.max(0,i))},[i]),S.useEffect(()=>{const u=b=>{const j=b.detail,y=x.current;j!==r&&(y!=null&&y.isPlaying())&&y.pause()};return window.addEventListener(F0,u),(()=>window.removeEventListener(F0,u))},[r]),S.useEffect(()=>{if(d!=="playing")return;const u=window.setInterval(()=>{const b=x.current;b&&q(b.getCurrentPosition())},100);return(()=>window.clearInterval(u))},[d]);const T=(u,b)=>{const j=()=>N.current===b&&x.current===u;u.onPlay(()=>{j()&&R("playing")}),u.onResume(()=>{j()&&R("playing")}),u.onPause(()=>{j()&&R("paused")}),u.onStop(()=>{j()&&(R("idle"),q(0))}),u.onEnded(()=>{j()&&(R("idle"),q(0))})},n0=async()=>{var j;const u=x.current;if(u!=null&&u.isPlaying()){u.pause();return}if(u!=null&&u.isPaused()){T0(r),u.resume();return}if(u!=null&&u.isInit()){T0(r),u.play();return}if(d==="loading")return;const b=N.current+1;N.current=b,R("loading"),q(0);try{const y=new pe;if(x.current=y,T(y,b),await y.initWithUrl(Re(c)),N.current!==b||x.current!==y){y.destroy();return}L(y.getDuration()||Math.max(0,i)),T0(r),y.play()}catch{if(N.current!==b)return;(j=x.current)==null||j.destroy(),x.current=null,R("error"),q(0)}},A=d==="playing"||d==="paused"?W:E,G=E>0?d==="playing"||d==="paused"?`${q0(A)} / ${q0(E)}`:q0(E):"--:--",D=d==="loading"?"正在解码":d==="playing"?"正在播放":d==="paused"?"已暂停":d==="error"?"加载失败,点击重试":"语音消息",k=d==="playing"?"暂停语音消息":d==="paused"?"继续播放语音消息":d==="error"?"重新加载语音消息":d==="loading"?"正在加载语音消息":"播放语音消息";return e.jsxs("div",{className:`flex h-11 min-w-56 items-center gap-2 rounded-2xl border px-2 shadow-sm ${a?"rounded-br-md border-sky-400 bg-sky-500 text-white":"rounded-bl-md border-slate-200 bg-white text-slate-800"}`,children:[e.jsx("button",{type:"button","aria-label":k,title:k,disabled:d==="loading",onClick:(()=>void n0()),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full transition focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-wait ${a?"bg-white text-sky-600 hover:bg-sky-50 focus-visible:ring-white":"bg-sky-50 text-sky-600 hover:bg-sky-100 focus-visible:ring-sky-400"}`,children:d==="loading"?e.jsx($,{className:"h-4 w-4 animate-spin"}):d==="playing"?e.jsx(de,{className:"h-4 w-4 fill-current"}):d==="error"?e.jsx(me,{className:"h-4 w-4"}):e.jsx(ge,{className:"ml-px h-4 w-4 fill-current"})}),e.jsxs("div",{className:"min-w-0 flex flex-1 items-center gap-2",children:[e.jsx("div",{className:"flex h-5 flex-1 items-center gap-0.5","aria-hidden":"true",children:Se.map((u,b)=>e.jsx("span",{className:`w-0.5 rounded-full ${d==="playing"?"animate-pulse":""} ${a?"bg-sky-100":d==="error"?"bg-red-300":"bg-sky-400"}`,style:{height:`${u}px`,animationDelay:`${b*45}ms`}},`${r}-${b}`))}),e.jsx("span",{className:`shrink-0 font-mono text-[11px] font-semibold tabular-nums ${a?"text-sky-100":d==="error"?"text-red-500":"text-slate-500"}`,children:G}),e.jsx("span",{className:"sr-only",children:D})]})]})},X0=[["尊嘟假嘟","https://img.alicdn.com/imgextra/i2/O1CN01hWzOgD1KcmFEIaGwE_!!6000000001185-2-tps-64-64.png_110x10000.jpg_.webp"],["鸡哔你","https://img.alicdn.com/imgextra/i1/O1CN01P9TVJl1JCqCZcQIdW_!!6000000000993-2-tps-64-64.png_110x10000.jpg_.webp"],["谁懂啊","https://img.alicdn.com/imgextra/i1/O1CN01r9qUnx1g3tcrtSmcs_!!6000000004087-2-tps-64-64.png_110x10000.jpg_.webp"],["吗喽","https://img.alicdn.com/imgextra/i4/O1CN01dTynZh1LnbIYTHI1D_!!6000000001344-2-tps-64-64.png_110x10000.jpg_.webp"],["功德+1","https://img.alicdn.com/imgextra/i1/O1CN01l1G5pS1IVn37pfQJi_!!6000000000899-2-tps-64-64.png_110x10000.jpg_.webp"],["city不city啊","https://img.alicdn.com/imgextra/i2/O1CN01zRjPTR29lWHqabmDA_!!6000000008108-2-tps-64-64.png_110x10000.jpg_.webp"],["激推","https://img.alicdn.com/imgextra/i3/O1CN01ADTJ6u1khypfxbfnQ_!!6000000004716-2-tps-64-64.png_110x10000.jpg_.webp"],["微笑","https://img.alicdn.com/imgextra/i1/O1CN017b61R51wRk2lVV7vx_!!6000000006305-2-tps-980-980.png_110x10000.jpg_.webp"],["龇牙","https://img.alicdn.com/imgextra/i2/O1CN01nmOh4S22Yxz8IdEVf_!!6000000007133-2-tps-980-980.png_110x10000.jpg_.webp"],["流泪","https://img.alicdn.com/imgextra/i2/O1CN01Ec1EaL1zqQETcM2dX_!!6000000006765-2-tps-980-980.png_110x10000.jpg_.webp"],["尴尬","https://img.alicdn.com/imgextra/i2/O1CN01UrWH7a1ZVBrgRYXlc_!!6000000003199-2-tps-980-980.png_110x10000.jpg_.webp"],["撇嘴","https://img.alicdn.com/imgextra/i2/O1CN01Sr7o2b1lUWg5KfOD8_!!6000000004822-2-tps-980-980.png_110x10000.jpg_.webp"],["破涕为笑","https://img.alicdn.com/imgextra/i4/O1CN01pPetah1gkwndfn7Fs_!!6000000004181-2-tps-980-980.png_110x10000.jpg_.webp"],["捂脸哭","https://img.alicdn.com/imgextra/i2/O1CN0170KgpE1dE1TuQgd66_!!6000000003703-2-tps-980-980.png_110x10000.jpg_.webp"],["害羞","https://img.alicdn.com/imgextra/i3/O1CN01ZoB0Lb1ps7XpqP8PQ_!!6000000005415-2-tps-980-980.png_110x10000.jpg_.webp"],["感动","https://img.alicdn.com/imgextra/i2/O1CN01wqD4ly29yndR3Qp3A_!!6000000008137-2-tps-980-980.png_110x10000.jpg_.webp"],["滴泪","https://img.alicdn.com/imgextra/i1/O1CN01MpkJ3L1oUTTqfryOn_!!6000000005228-2-tps-980-980.png_110x10000.jpg_.webp"],["暗中观察","https://img.alicdn.com/imgextra/i1/O1CN010LO9yj272W07GlLls_!!6000000007739-2-tps-980-980.png_110x10000.jpg_.webp"],["偷笑","https://img.alicdn.com/imgextra/i4/O1CN01vJtO031g818IuYO7x_!!6000000004096-2-tps-980-980.png_110x10000.jpg_.webp"],["ok","https://img.alicdn.com/imgextra/i3/O1CN01QRkqDF25tz0WcANje_!!6000000007585-2-tps-980-980.png_110x10000.jpg_.webp"],["送花","https://img.alicdn.com/imgextra/i2/O1CN01PpzBNX1JNpeJBWnvr_!!6000000001017-2-tps-980-980.png_110x10000.jpg_.webp"],["大哭","https://img.alicdn.com/imgextra/i4/O1CN014TiaNb1ViEgNvRrTB_!!6000000002686-2-tps-980-980.png_110x10000.jpg_.webp"],["色","https://img.alicdn.com/imgextra/i2/O1CN01840t1B1JaCLGvHnBK_!!6000000001044-2-tps-980-980.png_110x10000.jpg_.webp"],["惊慌","https://img.alicdn.com/imgextra/i1/O1CN01mnqO7G1LAfUnfAN2U_!!6000000001259-2-tps-980-980.png_110x10000.jpg_.webp"],["惊讶","https://img.alicdn.com/imgextra/i3/O1CN0127IeyS1Kw0p0P4jzI_!!6000000001227-2-tps-980-980.png_110x10000.jpg_.webp"],["得意","https://img.alicdn.com/imgextra/i4/O1CN018QUnFv1WpOUES9POZ_!!6000000002837-2-tps-980-980.png_110x10000.jpg_.webp"],["睡","https://img.alicdn.com/imgextra/i2/O1CN01RprGZl1lqVgnEJLCx_!!6000000004870-2-tps-980-980.png_110x10000.jpg_.webp"],["不好意思","https://img.alicdn.com/imgextra/i3/O1CN01rMJJgn1SUXzuVpUhO_!!6000000002250-2-tps-980-980.png_110x10000.jpg_.webp"],["托腮","https://img.alicdn.com/imgextra/i1/O1CN01w3reBU1d3wlgOBtyZ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["发怒","https://img.alicdn.com/imgextra/i2/O1CN013Wzy8d2A8PxGJZPpT_!!6000000008158-2-tps-980-980.png_110x10000.jpg_.webp"],["难过","https://img.alicdn.com/imgextra/i2/O1CN01zcwaSh1G9gZCFuFal_!!6000000000580-2-tps-980-980.png_110x10000.jpg_.webp"],["调皮","https://img.alicdn.com/imgextra/i3/O1CN01Zd1YHi1TI0lwpBe8c_!!6000000002358-2-tps-980-980.png_110x10000.jpg_.webp"],["愉快","https://img.alicdn.com/imgextra/i2/O1CN0145wDk21SWpyjTvsvA_!!6000000002255-2-tps-980-980.png_110x10000.jpg_.webp"],["白眼","https://img.alicdn.com/imgextra/i4/O1CN01nexGth1hwEAT1SHO2_!!6000000004341-2-tps-980-980.png_110x10000.jpg_.webp"],["拒绝","https://img.alicdn.com/imgextra/i2/O1CN01nqusqS1uHXzoUcpXr_!!6000000006012-2-tps-980-980.png_110x10000.jpg_.webp"],["期待","https://img.alicdn.com/imgextra/i3/O1CN01M44QY11Oh8Q5PdMIx_!!6000000001736-2-tps-980-980.png_110x10000.jpg_.webp"],["困","https://img.alicdn.com/imgextra/i4/O1CN01J4hFFz1Y9pmNdBq76_!!6000000003017-2-tps-980-980.png_110x10000.jpg_.webp"],["流汗","https://img.alicdn.com/imgextra/i4/O1CN01BU3NZ21gdcSjkqnST_!!6000000004165-2-tps-980-980.png_110x10000.jpg_.webp"],["憨笑","https://img.alicdn.com/imgextra/i2/O1CN01Pee9Ql1SJ661eH9By_!!6000000002225-2-tps-980-980.png_110x10000.jpg_.webp"],["耶","https://img.alicdn.com/imgextra/i2/O1CN01pFicsL1ipBhIqzcgs_!!6000000004461-2-tps-980-980.png_110x10000.jpg_.webp"],["奋斗","https://img.alicdn.com/imgextra/i3/O1CN01ZhQ4AV25xBmTK3CnF_!!6000000007592-2-tps-980-980.png_110x10000.jpg_.webp"],["咒骂","https://img.alicdn.com/imgextra/i3/O1CN01r1Zh9927QKb4pnf7k_!!6000000007791-2-tps-980-980.png_110x10000.jpg_.webp"],["疑问","https://img.alicdn.com/imgextra/i4/O1CN01UZqbzt29MmlNctCQS_!!6000000008054-2-tps-980-980.png_110x10000.jpg_.webp"],["嘘","https://img.alicdn.com/imgextra/i1/O1CN01qBlYkM1ojaYF75On5_!!6000000005261-2-tps-980-980.png_110x10000.jpg_.webp"],["晕","https://img.alicdn.com/imgextra/i2/O1CN014zhM2h1wPuSUFoMwV_!!6000000006301-2-tps-980-980.png_110x10000.jpg_.webp"],["开心到模糊","https://img.alicdn.com/imgextra/i1/O1CN01T1Dy271j6akZWo7Vr_!!6000000004499-2-tps-980-980.png_110x10000.jpg_.webp"],["衰","https://img.alicdn.com/imgextra/i1/O1CN01aOXsNr1LmgMvtyzOO_!!6000000001342-2-tps-980-980.png_110x10000.jpg_.webp"],["委屈","https://img.alicdn.com/imgextra/i2/O1CN013J0bMk1QNYih3UFTk_!!6000000001964-2-tps-980-980.png_110x10000.jpg_.webp"],["再见","https://img.alicdn.com/imgextra/i2/O1CN01IHKsQx1UdpFgeTHcA_!!6000000002541-2-tps-980-980.png_110x10000.jpg_.webp"],["鼓掌","https://img.alicdn.com/imgextra/i4/O1CN01DHxB5s1G1RRBxekIu_!!6000000000562-2-tps-980-980.png_110x10000.jpg_.webp"],["吐","https://img.alicdn.com/imgextra/i1/O1CN01xyVxH21LNUaMgW4hh_!!6000000001287-2-tps-980-980.png_110x10000.jpg_.webp"],["坏笑","https://img.alicdn.com/imgextra/i1/O1CN01zV7opv1bIU6iI8OhM_!!6000000003442-2-tps-980-980.png_110x10000.jpg_.webp"],["抠鼻","https://img.alicdn.com/imgextra/i1/O1CN01QOanju1sNqCrtYstu_!!6000000005755-2-tps-980-980.png_110x10000.jpg_.webp"],["叹气","https://img.alicdn.com/imgextra/i3/O1CN01RElx7R1QD1c8ZN07f_!!6000000001941-2-tps-980-980.png_110x10000.jpg_.webp"],["无聊","https://img.alicdn.com/imgextra/i2/O1CN01d91LnZ1UJDQjKCouC_!!6000000002496-2-tps-980-980.png_110x10000.jpg_.webp"],["思考","https://img.alicdn.com/imgextra/i2/O1CN01wQjg2f1tO84ZWitn9_!!6000000005891-2-tps-980-980.png_110x10000.jpg_.webp"],["呆","https://img.alicdn.com/imgextra/i1/O1CN01GLqBWC1DGbhqmpD2L_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["哇哦","https://img.alicdn.com/imgextra/i2/O1CN01MtLpS21qRO2bnAA5k_!!6000000005492-2-tps-980-980.png_110x10000.jpg_.webp"],["飞吻","https://img.alicdn.com/imgextra/i4/O1CN01q1WpFE25ljsNKjvHX_!!6000000007567-2-tps-980-980.png_110x10000.jpg_.webp"],["好喜欢","https://img.alicdn.com/imgextra/i2/O1CN01mD4iQM1O57XyQ5SHD_!!6000000001653-2-tps-980-980.png_110x10000.jpg_.webp"],["拜托","https://img.alicdn.com/imgextra/i4/O1CN01SQgrTH1dzCH3pIyRN_!!6000000003806-2-tps-980-980.png_110x10000.jpg_.webp"],["真棒","https://img.alicdn.com/imgextra/i2/O1CN017fcAmd1SCgYCj9Upk_!!6000000002211-2-tps-980-980.png_110x10000.jpg_.webp"],["流鼻血","https://img.alicdn.com/imgextra/i3/O1CN0139JscY1rC6RS9GR4j_!!6000000005594-2-tps-980-980.png_110x10000.jpg_.webp"],["费解","https://img.alicdn.com/imgextra/i1/O1CN01FqAVvR1tyJMPj13ie_!!6000000005970-2-tps-980-980.png_110x10000.jpg_.webp"],["秃头","https://img.alicdn.com/imgextra/i4/O1CN01ZF4bV11thMhqm2Z1h_!!6000000005933-2-tps-980-980.png_110x10000.jpg_.webp"],["嘿哈","https://img.alicdn.com/imgextra/i4/O1CN01ObcOw61FOVlvQg7Mw_!!6000000000477-2-tps-980-980.png_110x10000.jpg_.webp"],["吃土","https://img.alicdn.com/imgextra/i3/O1CN01Z6nJ1b1ZYr22YseHN_!!6000000003207-2-tps-980-980.png_110x10000.jpg_.webp"],["机智","https://img.alicdn.com/imgextra/i1/O1CN01rfKY351zDUZJlBiir_!!6000000006680-2-tps-980-980.png_110x10000.jpg_.webp"],["举杯","https://img.alicdn.com/imgextra/i4/O1CN01R2tn4F1mn8NuEIE8J_!!6000000004998-2-tps-980-980.png_110x10000.jpg_.webp"],["握手","https://img.alicdn.com/imgextra/i4/O1CN01NDcA251JDkvuFhSDb_!!6000000000995-2-tps-980-980.png_110x10000.jpg_.webp"],["挥手","https://img.alicdn.com/imgextra/i4/O1CN01iVN0ht1TmEuSwauGt_!!6000000002424-2-tps-980-980.png_110x10000.jpg_.webp"],["yeah","https://img.alicdn.com/imgextra/i3/O1CN01opt7hh27Wk8omjR4t_!!6000000007805-2-tps-980-980.png_110x10000.jpg_.webp"],["666","https://img.alicdn.com/imgextra/i3/O1CN01YRWDPF1OjQOpXeuTC_!!6000000001741-2-tps-980-980.png_110x10000.jpg_.webp"],["棒","https://img.alicdn.com/imgextra/i3/O1CN01agprvs1HU7rPRxOnB_!!6000000000760-2-tps-980-980.png_110x10000.jpg_.webp"],["爱你","https://img.alicdn.com/imgextra/i1/O1CN01SzxgcH1GSSo6Lwmwk_!!6000000000621-2-tps-980-980.png_110x10000.jpg_.webp"],["比心","https://img.alicdn.com/imgextra/i1/O1CN01YHZ39t1DeQIeb0TWQ_!!6000000000241-2-tps-980-980.png_110x10000.jpg_.webp"],["感谢","https://img.alicdn.com/imgextra/i3/O1CN01ywacF81baLYNeyK1n_!!6000000003481-2-tps-980-980.png_110x10000.jpg_.webp"],["拍手","https://img.alicdn.com/imgextra/i4/O1CN01wbj4wv1K7ArD9AU44_!!6000000001116-2-tps-980-980.png_110x10000.jpg_.webp"],["拉钩","https://img.alicdn.com/imgextra/i1/O1CN01dePkKH1HOd6ivAcu8_!!6000000000748-2-tps-980-980.png_110x10000.jpg_.webp"],["没钱","https://img.alicdn.com/imgextra/i3/O1CN01qhxGjp1zD2AfqmWx5_!!6000000006679-2-tps-980-980.png_110x10000.jpg_.webp"],["小刀","https://img.alicdn.com/imgextra/i3/O1CN01tFVx5Y1T2thPjhR6b_!!6000000002325-2-tps-980-980.png_110x10000.jpg_.webp"],["不刀","https://img.alicdn.com/imgextra/i4/O1CN01zTxff61clcvOcTS3n_!!6000000003641-2-tps-980-980.png_110x10000.jpg_.webp"],["同出","https://img.alicdn.com/imgextra/i3/O1CN01URKas6249R8ozS98O_!!6000000007348-2-tps-980-980.png_110x10000.jpg_.webp"],["递钱","https://img.alicdn.com/imgextra/i4/O1CN01PzhgV51FLlOaZHZ6n_!!6000000000471-2-tps-980-980.png_110x10000.jpg_.webp"],["数钱","https://img.alicdn.com/imgextra/i3/O1CN01CzXXvp23khkljToQH_!!6000000007294-2-tps-980-980.png_110x10000.jpg_.webp"],["打call","https://img.alicdn.com/imgextra/i1/O1CN01X7VUVm1il48IYv8Qw_!!6000000004452-2-tps-980-980.png_110x10000.jpg_.webp"],["号外","https://img.alicdn.com/imgextra/i2/O1CN01vg6xSM1Vxo9EKyfjR_!!6000000002720-2-tps-980-980.png_110x10000.jpg_.webp"],["包邮","https://img.alicdn.com/imgextra/i3/O1CN01yVS7ys24jA22oVZ2T_!!6000000007426-2-tps-980-980.png_110x10000.jpg_.webp"],["求赞","https://img.alicdn.com/imgextra/i1/O1CN01Xwqi5A1giCQMRcX6N_!!6000000004175-2-tps-980-980.png_110x10000.jpg_.webp"],["非主流","https://img.alicdn.com/imgextra/i1/O1CN013wyI1j1hlEfDUoATI_!!6000000004317-2-tps-980-980.png_110x10000.jpg_.webp"],["吃瓜","https://img.alicdn.com/imgextra/i1/O1CN01LLOFsh1UUCw0deZba_!!6000000002520-2-tps-980-980.png_110x10000.jpg_.webp"],["种草","https://img.alicdn.com/imgextra/i2/O1CN01ooeRC81hA8a4x9S3q_!!6000000004236-2-tps-980-980.png_110x10000.jpg_.webp"],["佛系","https://img.alicdn.com/imgextra/i4/O1CN01BYXEe321GMHMZ9w66_!!6000000006957-2-tps-980-980.png_110x10000.jpg_.webp"],["超便宜","https://img.alicdn.com/imgextra/i4/O1CN01mqgSZi1Er4rOIDiP7_!!6000000000404-2-tps-980-980.png_110x10000.jpg_.webp"],["拥抱","https://img.alicdn.com/imgextra/i1/O1CN01yuGD9c1hJkttfKHAm_!!6000000004257-2-tps-980-980.png_110x10000.jpg_.webp"],["摊手","https://img.alicdn.com/imgextra/i2/O1CN014AiIqE1o9repE6STR_!!6000000005183-2-tps-980-980.png_110x10000.jpg_.webp"],["举手","https://img.alicdn.com/imgextra/i1/O1CN01xizuHZ1WPkJCogbuj_!!6000000002781-2-tps-980-980.png_110x10000.jpg_.webp"],["蹲","https://img.alicdn.com/imgextra/i3/O1CN01Midjjn1FrMj2CWer6_!!6000000000540-2-tps-980-980.png_110x10000.jpg_.webp"],["跪了","https://img.alicdn.com/imgextra/i3/O1CN01F2y52j24E16L6RIjF_!!6000000007358-2-tps-980-980.png_110x10000.jpg_.webp"],["拜","https://img.alicdn.com/imgextra/i4/O1CN01Jldd1G1oXDrEHH2qr_!!6000000005234-2-tps-980-980.png_110x10000.jpg_.webp"],["排","https://img.alicdn.com/imgextra/i3/O1CN01uSUmYD1jD0IJf0UVU_!!6000000004513-2-tps-980-980.png_110x10000.jpg_.webp"],["旺财","https://img.alicdn.com/imgextra/i3/O1CN01A25Mv01DKjGseAmuP_!!6000000000198-2-tps-980-980.png_110x10000.jpg_.webp"],["招财猫","https://img.alicdn.com/imgextra/i3/O1CN01WmJ7Sr20EhDyp86Bd_!!6000000006818-2-tps-980-980.png_110x10000.jpg_.webp"],["酸了","https://img.alicdn.com/imgextra/i3/O1CN01UFgjn61JJi5Iqxdk7_!!6000000001008-2-tps-980-980.png_110x10000.jpg_.webp"],["鸭鸭","https://img.alicdn.com/imgextra/i3/O1CN01pHSCSQ1deaS8WDiqG_!!6000000003761-2-tps-980-980.png_110x10000.jpg_.webp"],["方了","https://img.alicdn.com/imgextra/i3/O1CN01br7g711whlu8xOPUt_!!6000000006340-2-tps-980-980.png_110x10000.jpg_.webp"],["白菜","https://img.alicdn.com/imgextra/i1/O1CN01KABFLt24WKwXjVp08_!!6000000007398-2-tps-980-980.png_110x10000.jpg_.webp"],["桃子","https://img.alicdn.com/imgextra/i1/O1CN01CQhhPH1vJfRjDGBv5_!!6000000006152-2-tps-980-980.png_110x10000.jpg_.webp"],["打包","https://img.alicdn.com/imgextra/i3/O1CN01oYOkUI1VT7c0ivZHV_!!6000000002653-2-tps-980-980.png_110x10000.jpg_.webp"],["沙发","https://img.alicdn.com/imgextra/i4/O1CN018qUFaE1DGbhqpMIit_!!6000000000189-2-tps-980-980.png_110x10000.jpg_.webp"],["南","https://img.alicdn.com/imgextra/i1/O1CN01ZSA6wg1PEZKf4h99R_!!6000000001809-2-tps-980-980.png_110x10000.jpg_.webp"],["盯","https://img.alicdn.com/imgextra/i4/O1CN01OWB1Gx1s01bzBhHN6_!!6000000005703-2-tps-980-980.png_110x10000.jpg_.webp"],["hot","https://img.alicdn.com/imgextra/i4/O1CN01DDD9uA22cAl7VDH7d_!!6000000007140-2-tps-980-980.png_110x10000.jpg_.webp"],["new","https://img.alicdn.com/imgextra/i3/O1CN01rRJXJo1qwzN4YnOHX_!!6000000005561-2-tps-980-980.png_110x10000.jpg_.webp"],["cool","https://img.alicdn.com/imgextra/i4/O1CN013bUubF2855qb2Qt5l_!!6000000007880-2-tps-980-980.png_110x10000.jpg_.webp"],["1","https://img.alicdn.com/imgextra/i1/O1CN01U8XG5y1Ie22frQHCQ_!!6000000000917-2-tps-980-980.png_110x10000.jpg_.webp"],["可","https://img.alicdn.com/imgextra/i2/O1CN01SMjtPG1iJaN17p94N_!!6000000004392-2-tps-980-980.png_110x10000.jpg_.webp"],["搬砖","https://img.alicdn.com/imgextra/i1/O1CN01GbqW6G1LOrm0Gllcb_!!6000000001290-2-tps-980-980.png_110x10000.jpg_.webp"],["菜狗","https://img.alicdn.com/imgextra/i2/O1CN01VtN0t91USNLmvfmol_!!6000000002516-2-tps-980-980.png_110x10000.jpg_.webp"],["开心面具","https://img.alicdn.com/imgextra/i3/O1CN017elkpk22EoYlBPKd3_!!6000000007089-2-tps-980-980.png_110x10000.jpg_.webp"],["快递","https://img.alicdn.com/imgextra/i2/O1CN01AmUZXk1d3wle5O8IJ_!!6000000003681-2-tps-980-980.png_110x10000.jpg_.webp"],["裂开","https://img.alicdn.com/imgextra/i1/O1CN01BihwvO1a5N9bFt0LU_!!6000000003278-2-tps-980-980.png_110x10000.jpg_.webp"],["啤酒","https://img.alicdn.com/imgextra/i4/O1CN01jDkgEj1WvLdXUVBDx_!!6000000002850-2-tps-980-980.png_110x10000.jpg_.webp"],["瑞思拜","https://img.alicdn.com/imgextra/i4/O1CN011gR0Um1K3VgpYjPOi_!!6000000001108-2-tps-980-980.png_110x10000.jpg_.webp"],["小丑","https://img.alicdn.com/imgextra/i3/O1CN01jMikhO1NJUM15XKTf_!!6000000001549-2-tps-980-980.png_110x10000.jpg_.webp"],["爱心","https://img.alicdn.com/imgextra/i1/O1CN015RVSWf23s25eETJqO_!!6000000007310-2-tps-980-980.png_110x10000.jpg_.webp"]],Ie=r=>r,Le=new Map(X0.map(([r,c])=>[r,c])),Me=r=>r.split(/(\[[^\]]+\])/g).map((c,a)=>{const i=c.startsWith("[")?Le.get(c.slice(1,-1)):void 0;return i?e.jsx("img",{src:i,alt:c,title:c,className:"mx-0.5 inline-block h-7 w-7 align-middle"},a):e.jsx(S.Fragment,{children:c},a)}),A0=r=>{const c=Number.isFinite(r)?Math.max(0,Math.floor(r)):0;return c>99?"99+":String(c)},$0=r=>(Number.isFinite(r)?Math.max(0,Math.floor(r)):0)<10?"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-red-500 text-[10px] font-bold leading-none text-white":"inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full bg-red-500 px-1.5 text-[10px] font-bold leading-none text-white",G0=(r,c)=>r.filter(a=>a.direction==="incoming"&&a.message_type!=="system"&&!a.message_key.startsWith("in-")).map(a=>({messageId:a.message_key,sessionId:c,cid:`${c}@goofish`,conversationType:1})),De=(r,c,a)=>{const i=c.trim().toLowerCase();return r.filter(x=>a&&x.unread_count<=0?!1:i?[x.buyer_name,x.buyer_id,x.item_title,x.last_message].some(N=>(N||"").toLowerCase().includes(i)):!0)},Ue=(r,c)=>{const a=new Set(r.map(i=>i.message_key));return[...c.filter(i=>!a.has(i.message_key)),...r]},P0=(r,c)=>{const a=r.findIndex(i=>i.message_key===c.message_key);return a<0?[...r,c]:r.map((i,x)=>x===a?c:i)},qe=(r,c)=>{if(c.direction!=="incoming"||c.message_type==="system")return r;const a=c.sent_at>0?c.sent_at:Date.now();return r.map(i=>i.chat_id===c.chat_id&&i.direction==="outgoing"&&i.status==="sent"&&i.sent_at<=c.sent_at?{...i,read_status:2,read_at:a}:i)},v=(r,c,a)=>r===c&&!a.aborted,a0=r=>r instanceof Error&&r.message==="请求已取消",Te=r=>{if(!r)return"";const c=new Date(r<1e10?r*1e3:r),a=new Date;return c.toDateString()===a.toDateString()?c.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}):c.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})},Ae=r=>new Date(r<1e10?r*1e3:r).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}),Pe=()=>{const[r,c]=n.useState([]),[a,i]=n.useState(""),[x,N]=n.useState({}),[d,R]=n.useState(""),[E,L]=n.useState([]),[W,q]=n.useState(""),[T,n0]=n.useState(!1),[A,G]=n.useState(""),[D,k]=n.useState(null),[u,b]=n.useState(!0),[j,y]=n.useState(!1),[X,f0]=n.useState(!1),[i0,j0]=n.useState(!1),[w0,r0]=n.useState(),[l0,c0]=n.useState({}),[o0,p0]=n.useState({}),[d0,m0]=n.useState(!1),[v0,k0]=n.useState(!1),[I,B]=n.useState(!1),[S0,O]=n.useState(""),[R0,E0]=n.useState("connecting"),[Y,g0]=n.useState(null),[K,x0]=n.useState(null),P=n.useRef(""),e0=n.useRef(""),J=n.useRef(null),t0=n.useRef({accountID:"",chatID:""}),u0=n.useRef(!0),s=n.useRef(!1),_=n.useRef(null),U=n.useRef(new Set),F=n.useRef(0),Q=n.useRef(null),V=n.useRef(0),I0=n.useRef(null),Z=n.useRef(0),h0=n.useRef(null),_0=n.useRef(0),N0=n.useRef(null),H=n.useRef(0),s0=n.useRef(null);n.useEffect(()=>{P.current=a},[a]),n.useEffect(()=>{e0.current=d},[d]);const b0=n.useCallback(async t=>{var m;const l=++F.current;(m=Q.current)==null||m.abort();const o=new AbortController;Q.current=o;try{const p=await U0(t,void 0,{signal:o.signal},!0);if(!v(F.current,l,o.signal))return[];const g=p.sessions.map(h=>t===P.current&&h.chat_id===e0.current?{...h,unread_count:0}:h);return N(h=>({...h,[t]:g})),c0(h=>({...h,[t]:p.next_cursor})),p0(h=>({...h,[t]:p.has_more})),g}catch(p){return v(F.current,l,o.signal)&&!a0(p)&&O(p instanceof Error?p.message:"同步会话失败"),[]}},[]);n.useEffect(()=>{const t=new AbortController;return(async()=>{var o;b(!0);try{const[m,p]=await Promise.all([ke({signal:t.signal}),Z0({signal:t.signal})]),h=m.map(C=>{var z,B0;return{...C,runtime_state:((z=p[C.id])==null?void 0:z.state)||(C.enabled?"connecting":"disabled"),runtime_connected:((B0=p[C.id])==null?void 0:B0.connected)===!0}}).filter(C=>C.enabled),w=await Promise.all(h.map(async C=>[C.id,await U0(C.id,void 0,{signal:t.signal})]));if(t.signal.aborted)return;c(h),N(Object.fromEntries(w.map(([C,z])=>[C,z.sessions]))),c0(Object.fromEntries(w.map(([C,z])=>[C,z.next_cursor]))),p0(Object.fromEntries(w.map(([C,z])=>[C,z.has_more])));const M=window.localStorage.getItem("ydisks.chat.account.v1")||"",M0=h.some(C=>C.id===M)?M:((o=h[0])==null?void 0:o.id)||"";i(M0)}catch(m){t.signal.aborted||O(m instanceof Error?m.message:"加载聊天数据失败")}finally{t.signal.aborted||b(!1)}})(),(()=>t.abort())},[]),n.useEffect(()=>{let t=!1,l=0,o=null;const m=async()=>{o=new AbortController;try{const p=await Z0({signal:o.signal,timeoutMs:1e4});t||c(g=>g.map(h=>{var w,M;return{...h,runtime_state:((w=p[h.id])==null?void 0:w.state)||h.runtime_state,runtime_connected:((M=p[h.id])==null?void 0:M.connected)??h.runtime_connected}}))}catch{}finally{t||(l=window.setTimeout(m,3e3))}};return l=window.setTimeout(m,3e3),(()=>{t=!0,window.clearTimeout(l),o==null||o.abort()})},[]),n.useEffect(()=>{if(!a)return;window.localStorage.setItem("ydisks.chat.account.v1",a);const t=x[a]||[];R(l=>{var o;return t.some(m=>m.chat_id===l)?l:((o=t[0])==null?void 0:o.chat_id)||""})},[a,x]),n.useEffect(()=>{const t=Object.keys(x).length;if(u||r.length>0&&t===0)return;const l=Object.values(x).some(o=>o.some(m=>m.unread_count>0));ye(l)},[r.length,u,x]),n.useEffect(()=>{!a||U.current.has(a)||(U.current.add(a),b0(a))},[a,b0]),n.useEffect(()=>{var o,m;if(!a||!d){V.current+=1,Z.current+=1,(o=h0.current)==null||o.abort(),s.current=!1,L([]);return}const t=++V.current;(m=I0.current)==null||m.abort();const l=new AbortController;return I0.current=l,y(!0),Q0(a,d,void 0,void 0,{signal:l.signal}).then(p=>{if(!v(V.current,t,l.signal))return;const g=G0(p.messages,d);V0(a,d,g,{signal:l.signal}),L(p.messages),j0(p.has_more),r0(p.next_cursor),p.session&&N(h=>({...h,[a]:(h[a]||[]).map(w=>{var M;return w.chat_id===((M=p.session)==null?void 0:M.chat_id)?p.session:w})})),N(h=>({...h,[a]:(h[a]||[]).map(w=>w.chat_id===d?{...w,unread_count:0}:w)}))}).catch(p=>{v(V.current,t,l.signal)&&!a0(p)&&O(p instanceof Error?p.message:"加载消息失败")}).finally(()=>{v(V.current,t,l.signal)&&y(!1)}),(()=>l.abort())},[a,d]),n.useEffect(()=>{var t;(t=N0.current)==null||t.abort(),_0.current+=1},[a]),n.useEffect(()=>{var t;(t=s0.current)==null||t.abort(),H.current+=1},[a,d]),n.useEffect(()=>{k(null)},[a,d]),n.useEffect(()=>{var t;Z.current+=1,(t=h0.current)==null||t.abort(),s.current=!1},[a,d]),n.useEffect(()=>(()=>{var t,l,o,m,p;(t=Q.current)==null||t.abort(),(l=I0.current)==null||l.abort(),Z.current+=1,(o=h0.current)==null||o.abort(),(m=N0.current)==null||m.abort(),(p=s0.current)==null||p.abort()}),[]),n.useEffect(()=>{const t=D;return(()=>{t&&URL.revokeObjectURL(t.url)})},[D]);const Y0=n.useCallback(async()=>{var g,h;if(!a||!d||X||!i0)return;const t=J.current,l=(t==null?void 0:t.scrollHeight)||0,o=V.current,m=++Z.current;(g=h0.current)==null||g.abort();const p=new AbortController;h0.current=p,s.current=!0,f0(!0),O("");try{const w=(h=E[0])==null?void 0:h.id,M=await Q0(a,d,w0,w,{signal:p.signal});if(!v(V.current,o,p.signal)||m!==Z.current)return;L(M0=>Ue(M0,M.messages)),j0(M.has_more),r0(M.next_cursor),requestAnimationFrame(()=>{m===Z.current&&!p.signal.aborted&&t&&(t.scrollTop+=t.scrollHeight-l)})}catch(w){s.current=!1,a0(w)||O(w instanceof Error?w.message:"加载历史消息失败")}finally{m===Z.current&&f0(!1)}},[a,d,i0,w0,E,X]),H0=n.useCallback(t=>{const l=t.account_id;if(N(o=>{const m=o[l]||[];return m.some(g=>g.chat_id===t.chat_id)?{...o,[l]:m.map(g=>g.chat_id===t.chat_id?{...g,last_message:t.content,last_message_at:t.sent_at,unread_count:t.direction==="incoming"&&t.message_type!=="system"&&(P.current!==l||e0.current!==t.chat_id)?g.unread_count+1:g.unread_count}:g).sort((g,h)=>h.last_message_at-g.last_message_at)}:(b0(l),o)}),P.current===l&&e0.current===t.chat_id&&(L(o=>qe(P0(o,t),t)),t.direction==="incoming"&&t.message_type!=="system")){const o=G0([t],t.chat_id);V0(l,t.chat_id,o)}},[b0]);n.useEffect(()=>Ce(l=>{if(l.type==="connection"){E0(l.state);return}H0(l.message)}),[H0]);const K0=n.useCallback(()=>{const t=J.current;if(!t)return;const l=t.scrollHeight-t.scrollTop-t.clientHeight;u0.current=l<=48},[]);n.useLayoutEffect(()=>{const t=t0.current.accountID!==a||t0.current.chatID!==d;t0.current={accountID:a,chatID:d},t&&(u0.current=!0);const l=J.current;if(l){if(s.current){s.current=!1;return}(j||u0.current)&&(l.scrollTop=l.scrollHeight)}},[a,d,E,j]);const ee=r.find(t=>t.id===a),y0=x[a]||[],f=y0.find(t=>t.chat_id===d),te=n.useMemo(()=>De(y0,W,T),[y0,W,T]),se=n.useCallback(t=>(x[t]||[]).reduce((l,o)=>l+o.unread_count,0),[x]),ae=n.useCallback(async()=>{var m;if(!a||d0||!o0[a])return;const t=++_0.current;(m=N0.current)==null||m.abort();const l=new AbortController;N0.current=l;const o=a;m0(!0),O("");try{const p=await U0(o,l0[o],{signal:l.signal},!0);if(!v(_0.current,t,l.signal))return;N(g=>({...g,[o]:p.sessions})),c0(g=>({...g,[o]:p.next_cursor})),p0(g=>({...g,[o]:p.has_more}))}catch(p){v(_0.current,t,l.signal)&&!a0(p)&&O(p instanceof Error?p.message:"加载历史联系人失败")}finally{v(_0.current,t,l.signal)&&m0(!1)}},[a,l0,d0,o0]),C0=n.useCallback(async(t,l)=>{var p;if(!f||!a||I)return;const o=++H.current;(p=s0.current)==null||p.abort();const m=new AbortController;s0.current=m,B(!0),O("");try{const g=await Oe({account_id:a,chat_id:f.chat_id,buyer_id:f.buyer_id,buyer_name:f.buyer_name,item_id:f.item_id,item_title:f.item_title,text:t},{signal:m.signal});if(!v(H.current,o,m.signal))return;G(""),g0(null),L(h=>P0(h,g.message))}catch(g){v(H.current,o,m.signal)&&(l&&g0(t),a0(g)||O(g instanceof Error?g.message:"消息发送失败"))}finally{v(H.current,o,m.signal)&&B(!1)}},[a,f,I]),O0=n.useCallback(async(t,l)=>{var p;if(!f||!a||I)return;const o=++H.current;(p=s0.current)==null||p.abort();const m=new AbortController;s0.current=m,B(!0),O("");try{const g=await ve({account_id:a,chat_id:f.chat_id,buyer_id:f.buyer_id,buyer_name:f.buyer_name,buyer_avatar_url:f.buyer_avatar_url,item_id:f.item_id,item_title:f.item_title,image:t},{signal:m.signal});if(!v(H.current,o,m.signal))return;x0(null),L(h=>P0(h,g.message))}catch(g){v(H.current,o,m.signal)&&(l&&x0(t),a0(g)||O(g instanceof Error?g.message:"图片发送失败"))}finally{v(H.current,o,m.signal)&&(B(!1),_.current&&(_.current.value=""))}},[a,f,I]),ne=n.useCallback(async()=>{const t=A.trim();!t||!f||!a||I||await C0(t,!0)},[a,A,f,C0,I]),L0=n.useCallback(async t=>{if(!(!t||!f||!a||I)){if(!t.type.startsWith("image/")){O("仅支持粘贴/发送图片文件");return}O(""),k({file:t,url:URL.createObjectURL(t)})}},[a,f,I]),ie=n.useCallback(async t=>{const l=t.find(o=>o.type.startsWith("image/"));l&&await L0(l)},[L0]),re=n.useCallback(()=>{k(null),_.current&&(_.current.value="")},[]),le=n.useCallback(async()=>{if(!D||!f||!a||I)return;const t=D.file;k(null),await O0(t,!0)},[a,D,f,O0,I]),ce=n.useCallback(async()=>{Y?await C0(Y,!1):K&&await O0(K,!1)},[K,Y,O0,C0]);return{accounts:r,activeAccountID:a,activeSessions:y0,selectedSession:f,activeAccount:ee,messages:E,search:W,unreadOnly:T,draft:A,loading:u,messagesLoading:j,olderLoading:X,hasOlder:i0,contactsLoading:d0,hasMoreContacts:o0[a]===!0,emojiOpen:v0,sending:I,error:S0,liveState:R0,pendingImage:D,activeChatID:d,filteredSessions:te,scrollRef:J,imageInputRef:_,setActiveAccountID:i,setActiveChatID:R,setSearch:q,setUnreadOnly:n0,setDraft:G,setEmojiOpen:k0,reloadSessions:b0,loadMoreContacts:ae,loadOlderMessages:Y0,handleMessageScroll:K0,handleSend:ne,handleImage:L0,handlePastedImages:ie,confirmSendImage:le,closeImagePreview:re,retrySend:ce,retryAvailable:!!(Y||K),unreadForAccount:se,emojiURL:Ie,xianyuEmojis:X0,renderXianyuText:Me,formatClock:Te,messageTime:Ae}},Je=()=>{const{accounts:r,activeAccountID:c,activeChatID:a,activeAccount:i,selectedSession:x,filteredSessions:N,messages:d,search:R,unreadOnly:E,draft:L,loading:W,messagesLoading:q,olderLoading:T,hasOlder:n0,contactsLoading:A,hasMoreContacts:G,emojiOpen:D,sending:k,error:u,liveState:b,pendingImage:j,scrollRef:y,imageInputRef:X,setActiveAccountID:f0,setActiveChatID:i0,setSearch:j0,setUnreadOnly:w0,setDraft:r0,setEmojiOpen:l0,reloadSessions:c0,loadMoreContacts:o0,loadOlderMessages:p0,handleMessageScroll:d0,handleSend:m0,handleImage:v0,handlePastedImages:k0,confirmSendImage:I,closeImagePreview:B,retrySend:S0,retryAvailable:O,unreadForAccount:R0,emojiURL:E0,xianyuEmojis:Y,renderXianyuText:g0,formatClock:K,messageTime:x0}=Pe(),P=S.useMemo(()=>d.filter(s=>s.message_type==="image"),[d]),e0=S.useMemo(()=>P.map(s=>({src:s.content,alt:"聊天图片"})),[P]),[J,t0]=S.useState(-1),u0=S.useCallback(s=>{t0(P.findIndex(_=>_.message_key===s))},[P]);return W?e.jsx("div",{className:"flex h-[calc(100vh-4rem)] items-center justify-center",children:e.jsx($,{className:"h-8 w-8 animate-spin text-sky-500"})}):e.jsxs("section",{className:"flex h-[calc(100vh-4rem)] min-h-[560px] flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-chat",children:[e.jsxs("header",{className:"border-b border-slate-200 bg-slate-50/70 px-5 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-black tracking-tight text-slate-950",children:"在线聊天"}),e.jsx("p",{className:"mt-0.5 text-xs font-medium text-slate-500",children:"复用账号实时连接,消息按账号完全隔离"})]}),e.jsxs("div",{className:`flex items-center gap-2 rounded-full px-3 py-1.5 text-xs font-bold ${b==="online"?"bg-emerald-50 text-emerald-700":b==="connecting"?"bg-amber-50 text-amber-700":"bg-red-50 text-red-700"}`,children:[b==="online"?e.jsx(xe,{className:"h-3.5 w-3.5"}):e.jsx(ue,{className:"h-3.5 w-3.5"}),b==="online"?"实时同步中":b==="connecting"?"正在连接":"连接已断开"]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto pb-0",role:"tablist","aria-label":"聊天账号",children:r.map(s=>{const _=s.id===c,U=R0(s.id),F=A0(U),Q=s.runtime_state==="online";return e.jsxs("button",{type:"button",role:"tab","aria-selected":_,onClick:(()=>f0(s.id)),className:`relative flex h-11 shrink-0 items-center gap-2 border-b-2 px-3 text-sm font-extrabold transition-colors ${_?"border-sky-500 text-sky-700":"border-transparent text-slate-500 hover:text-slate-900"}`,children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${Q?"bg-emerald-500":"bg-slate-300"}`}),e.jsx("span",{className:"max-w-36 truncate",children:s.nickname||s.remark||s.id}),U>0&&e.jsx("span",{"aria-label":`未读消息 ${F} 条`,className:$0(U),children:F})]},s.id)})})]}),r.length===0?e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(z0,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-800",children:"暂无启用账号"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"先在账号管理中启用账号,聊天会话会自动出现。"})]}):e.jsxs("div",{className:"grid min-h-0 flex-1 overflow-hidden grid-cols-[320px_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"flex min-h-0 flex-col border-r border-slate-200 bg-slate-50/40",children:[e.jsxs("div",{className:"space-y-3 border-b border-slate-200 p-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(he,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:R,onChange:(s=>j0(s.target.value)),placeholder:"搜索用户、商品或消息",className:"h-10 w-full rounded-xl border border-slate-200 bg-white pl-9 pr-3 text-sm outline-none transition focus:border-sky-400 focus:ring-2 focus:ring-sky-100"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:(()=>w0(s=>!s)),className:`rounded-lg px-2.5 py-1.5 text-xs font-bold ${E?"bg-sky-100 text-sky-700":"text-slate-500 hover:bg-slate-100"}`,children:E?"只看未读":"全部会话"}),e.jsx("button",{type:"button",title:"刷新会话",onClick:(()=>void c0(c)),className:"rounded-lg p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700",children:e.jsx(_e,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[N.map(s=>e.jsxs("button",{type:"button",onClick:(()=>i0(s.chat_id)),className:`flex w-full gap-3 border-b border-slate-100 p-3.5 text-left transition-colors ${s.chat_id===a?"bg-white shadow-chat-active":"hover:bg-white/80"}`,children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-slate-200 text-slate-500",children:s.buyer_avatar_url?e.jsx("img",{src:s.buyer_avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx(D0,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"truncate text-sm font-extrabold text-slate-900",children:s.buyer_name||`用户 ${s.buyer_id}`})}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs text-slate-500",children:s.last_message||"暂无消息"}),s.unread_count>0&&e.jsx("span",{"aria-label":`未读消息 ${A0(s.unread_count)} 条`,className:`ml-auto ${$0(s.unread_count)}`,children:A0(s.unread_count)})]}),s.item_title&&e.jsxs("div",{className:"mt-1.5 truncate text-[10px] font-medium text-sky-700",children:["商品 · ",s.item_title]})]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium text-slate-400",children:K(s.last_message_at)}),s.item_image_url&&e.jsx("img",{src:s.item_image_url,alt:"",className:"h-9 w-11 rounded-[4px] border border-slate-200 object-cover"})]})]},s.chat_id)),N.length===0&&e.jsx("div",{className:"px-6 py-16 text-center text-sm text-slate-400",children:"当前账号暂无匹配会话"}),G&&!R&&!E&&e.jsx("div",{className:"flex justify-center p-4",children:e.jsxs("button",{type:"button",onClick:(()=>void o0()),disabled:A,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-xs font-bold text-slate-500 shadow-sm hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[A&&e.jsx($,{className:"h-3.5 w-3.5 animate-spin"}),A?"正在加载":"加载更多历史联系人"]})})]})]}),e.jsx("main",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-surface-subtle",children:x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-16 shrink-0 items-center border-b border-slate-200 bg-white px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-black text-slate-950",children:x.buyer_name||x.buyer_id}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-slate-500",children:["用户 ID:",x.buyer_id]})]}),e.jsx("span",{className:`ml-auto rounded-full px-2.5 py-1 text-[10px] font-bold ${(i==null?void 0:i.runtime_state)==="online"?"bg-emerald-50 text-emerald-700":"bg-slate-100 text-slate-500"}`,children:(i==null?void 0:i.runtime_state)==="online"?"账号在线":"账号离线"})]}),e.jsx("div",{ref:y,onScroll:d0,className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:q?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx($,{className:"h-6 w-6 animate-spin text-sky-500"})}):e.jsxs(e.Fragment,{children:[n0&&e.jsx("div",{className:"flex justify-center pb-1",children:e.jsxs("button",{type:"button",onClick:(()=>void p0()),disabled:T,className:"flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-1.5 text-xs font-bold text-slate-500 shadow-sm transition hover:border-sky-200 hover:text-sky-600 disabled:opacity-50",children:[T&&e.jsx($,{className:"h-3.5 w-3.5 animate-spin"}),T?"正在加载":"加载更早消息"]})}),d.map(s=>{const _=s.direction==="outgoing";return s.message_type==="system"?e.jsx("div",{className:"flex justify-center py-1",children:e.jsxs("div",{className:"max-w-[82%] rounded-xl border border-slate-200 bg-slate-100 px-4 py-2 text-center text-xs leading-5 text-slate-500",children:[g0(s.content),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:x0(s.sent_at)})]})},s.message_key):e.jsxs("div",{className:`flex items-end gap-2.5 ${_?"justify-end":"justify-start"}`,children:[!_&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-slate-200 ring-2 ring-white",children:x.buyer_avatar_url?e.jsx("img",{src:x.buyer_avatar_url,alt:x.buyer_name||"用户",className:"h-full w-full object-cover"}):e.jsx(D0,{className:"m-2 h-5 w-5 text-slate-500"})}),e.jsxs("div",{className:`max-w-[72%] ${_?"items-end":"items-start"} flex flex-col`,children:[e.jsx("div",{className:"mb-1 px-1 text-[10px] font-semibold text-slate-400",children:_?(i==null?void 0:i.nickname)||(i==null?void 0:i.remark)||"我":x.buyer_name||s.sender_name||x.buyer_id}),s.message_type==="image"?e.jsx("button",{type:"button",title:"点击预览大图",onClick:u0.bind(null,s.message_key),className:`block cursor-zoom-in overflow-hidden rounded-2xl border bg-white p-1 text-left shadow-sm ${_?"rounded-br-md border-sky-200":"rounded-bl-md border-slate-200"}`,children:e.jsx("img",{src:s.content,alt:"聊天图片",className:"max-h-80 max-w-full rounded-xl object-contain"})}):s.message_type==="video"?e.jsx("video",{src:s.content,controls:!0,preload:"metadata",className:"max-h-80 max-w-full rounded-2xl bg-black"}):s.message_type==="audio"?e.jsx(Ee,{messageKey:s.message_key,src:s.content,outgoing:_,initialDuration:s.media_duration}):e.jsx("div",{className:`rounded-2xl px-4 py-2.5 text-sm leading-6 shadow-sm ${_?"rounded-br-md bg-sky-500 text-white":"rounded-bl-md border border-slate-200 bg-white text-slate-800"}`,children:g0(s.content)}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 text-[10px] text-slate-400",children:[x0(s.sent_at),_&&(s.status==="failed"?e.jsx(be,{className:"h-3 w-3 text-red-500","aria-label":"发送失败"}):s.read_status===2?e.jsx(fe,{className:"h-3 w-3 text-sky-500","aria-label":"对方已读"}):s.status==="sent"?e.jsx(W0,{className:"h-3 w-3 text-sky-500","aria-label":"已发送未读"}):e.jsx(W0,{className:"h-3 w-3","aria-label":"发送中"}))]})]}),_&&e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-full bg-sky-100 ring-2 ring-white",children:i!=null&&i.avatar_url?e.jsx("img",{src:i.avatar_url,alt:"我",className:"h-full w-full object-cover"}):e.jsx(D0,{className:"m-2 h-5 w-5 text-sky-600"})})]},s.message_key)})]})}),u&&e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-red-100 bg-red-50 px-5 py-2 text-xs font-medium text-red-700",children:[e.jsx("span",{children:u}),O&&e.jsx("button",{type:"button",className:"font-bold underline",onClick:(()=>void S0()),children:"重试发送"})]}),e.jsxs("div",{className:"relative z-10 shrink-0 border-t border-slate-200 bg-white p-4 shadow-chat-input",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",onClick:(()=>l0(s=>!s)),disabled:k||(i==null?void 0:i.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"闲鱼表情",children:e.jsx(je,{className:"h-5 w-5"})}),D&&e.jsxs("div",{className:"absolute bottom-11 left-0 z-30 w-[360px] rounded-2xl border border-slate-200 bg-white p-3 shadow-2xl",children:[e.jsx("div",{className:"mb-2 text-xs font-bold text-slate-500",children:"全部表情"}),e.jsx("div",{className:"grid max-h-72 grid-cols-8 gap-1 overflow-y-auto",children:Y.map(([s,_])=>e.jsx("button",{type:"button",title:`[${s}]`,onClick:(()=>{r0(U=>U+`[${s}]`),l0(!1)}),className:"flex h-10 w-10 items-center justify-center rounded-lg hover:bg-slate-100",children:e.jsx("img",{src:E0(_),alt:`[${s}]`,className:"h-8 w-8 object-contain"})},s))})]})]}),e.jsx("input",{ref:X,type:"file",accept:"image/*",className:"hidden",onChange:(s=>{var _;return void v0((_=s.target.files)==null?void 0:_[0])})}),e.jsx("button",{type:"button",onClick:(()=>{var s;return(s=X.current)==null?void 0:s.click()}),disabled:k||(i==null?void 0:i.runtime_state)!=="online",className:"rounded-lg p-2 text-slate-500 transition hover:bg-sky-50 hover:text-sky-600 disabled:opacity-40",title:"发送图片(最大 10MB)",children:e.jsx(we,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex items-end gap-3 rounded-2xl border border-slate-200 bg-slate-50 p-2 transition focus-within:border-sky-400 focus-within:ring-2 focus-within:ring-sky-100",children:[e.jsx("textarea",{value:L,onChange:(s=>r0(s.target.value)),rows:2,maxLength:2e3,onKeyDown:(s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),m0())}),onPaste:(s=>{var F;const _=Array.from(((F=s.clipboardData)==null?void 0:F.files)||[]);_.find(Q=>Q.type.startsWith("image/"))&&(s.preventDefault(),k0(_))}),disabled:(i==null?void 0:i.runtime_state)!=="online",placeholder:(i==null?void 0:i.runtime_state)==="online"?"输入消息,Enter 发送,Shift + Enter 换行,Ctrl + V 粘贴图片":"账号离线,暂时无法发送",className:"max-h-32 min-h-12 flex-1 resize-none bg-transparent px-2 py-2 text-sm leading-6 outline-none disabled:cursor-not-allowed"}),e.jsx("button",{type:"button",onClick:(()=>void m0()),disabled:!L.trim()||k||(i==null?void 0:i.runtime_state)!=="online",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-sky-500 text-white shadow-md shadow-sky-100 transition hover:bg-sky-600 disabled:cursor-not-allowed disabled:bg-slate-300 disabled:shadow-none","aria-label":"发送消息",children:k?e.jsx($,{className:"h-4 w-4 animate-spin"}):e.jsx(J0,{className:"h-4 w-4"})})]})]})]}):e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center text-center",children:[e.jsx(z0,{className:"h-12 w-12 text-slate-300"}),e.jsx("h3",{className:"mt-4 font-black text-slate-700",children:"选择一个用户开始聊天"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"该账号的新消息会实时出现在左侧列表。"})]})})]}),j&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-950/60 p-4",onClick:B,children:e.jsxs("div",{className:"flex max-h-full w-full max-w-2xl flex-col overflow-hidden rounded-2xl bg-white shadow-2xl",onClick:(s=>s.stopPropagation()),children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-slate-200 px-5 py-3",children:[e.jsx("div",{className:"text-sm font-black text-slate-900",children:"发送图片预览"}),e.jsx("button",{type:"button",title:"取消",onClick:B,className:"rounded-lg p-1.5 text-slate-400 transition hover:bg-slate-100 hover:text-slate-700",children:e.jsx(Ne,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-slate-100 p-4",children:e.jsx("img",{src:j.url,alt:"待发送图片预览",className:"max-h-[55vh] max-w-full rounded-xl object-contain"})}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-slate-200 px-5 py-3",children:[e.jsxs("div",{className:"min-w-0 truncate text-xs text-slate-500",children:[j.file.name||"粘贴的图片"," · ",(j.file.size/1024).toFixed(0)," KB"]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("button",{type:"button",onClick:B,className:"rounded-xl px-4 py-2 text-sm font-bold text-slate-600 transition hover:bg-slate-100",children:"取消"}),e.jsxs("button",{type:"button",onClick:(()=>void I()),disabled:k||(i==null?void 0:i.runtime_state)!=="online",className:"flex items-center gap-2 rounded-xl bg-sky-500 px-4 py-2 text-sm font-bold text-white shadow-md shadow-sky-100 transition hover:bg-sky-600 disabled:cursor-not-allowed disabled:opacity-50",children:[k?e.jsx($,{className:"h-4 w-4 animate-spin"}):e.jsx(J0,{className:"h-4 w-4"}),"发送"]})]})]})]})}),e.jsx(oe,{open:J>=0,index:Math.max(J,0),close:(()=>t0(-1)),slides:e0})]})};export{Je as default};