@luckylillia-dev/plugin-webqq 0.0.0-stage → 1.0.1
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.
- package/LICENSE +339 -0
- package/assets/LICENSE-dashboard-icons.txt +201 -0
- package/assets/README.md +7 -0
- package/assets/icon.svg +1 -0
- package/lib/client/chunks/WebQQEntry-34LQMVRZ.js +91 -0
- package/lib/client/chunks/chunk-JP6IZEMY.js +1 -0
- package/lib/client/index.js +10 -0
- package/lib/client/module.js +1 -0
- package/lib/client/style.css +2 -0
- package/lib/index.js +22774 -0
- package/lib/index.js.map +7 -0
- package/lib/types/actions.d.ts +4 -0
- package/lib/types/chats.d.ts +4 -0
- package/lib/types/events.d.ts +4 -0
- package/lib/types/groupFiles.d.ts +4 -0
- package/lib/types/index.d.ts +25 -0
- package/lib/types/media.d.ts +11 -0
- package/lib/types/members.d.ts +3 -0
- package/lib/types/messages.d.ts +5 -0
- package/lib/types/notifications.d.ts +3 -0
- package/lib/types/proxy.d.ts +3 -0
- package/lib/types/settings.d.ts +7 -0
- package/lib/types/upload.d.ts +3 -0
- package/lib/types/utils.d.ts +8 -0
- package/package.json +115 -6
- package/README.md +0 -3
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import{b as St,c as T}from"./chunk-JP6IZEMY.js";import{useEffect as Yi,useState as ed}from"react";import{forwardRef as Nd,createElement as Fd}from"react";var Bs=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function Us(e,o,t=[]){if(o==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:Bs(e),size:24,node:o,...t.length>0?{aliases:t}:{}}}var Os=e=>{let o="",t=!1;for(let a of e){if(a==="-"||a==="_"||a<=" "){t=o.length>0;continue}o.length===0?o+=a.toLowerCase():o+=t?a.toUpperCase():a,t=!1}return o};var zs=e=>{let o=Os(e);return o.charAt(0).toUpperCase()+o.slice(1)};import{forwardRef as Td,createElement as Ws}from"react";var Pa=(...e)=>e.filter((o,t,a)=>!!o&&o.trim()!==""&&a.indexOf(o)===t).join(" ").trim();var Ht={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function xr(e){return e!=null}function Hs(e,o={}){let t=o.attributeNames??{},a=f=>t[f]??f,r=e.size??e.width??Ht.width,s=e.size??e.height??Ht.height,l=e.aliases?.filter(f=>typeof f=="string"&&f.trim()!=="").map(f=>`lucide-${f}`)??[],n=[...e.name?[`lucide-${e.name}`]:[],...l],d=o.className?.split(" ").filter(Boolean)??[],c=o.includeDefaultClasses===!1?Pa(...d):Pa("lucide",...n,...d),i=o.absoluteStrokeWidth?Number(o.strokeWidth??Ht["stroke-width"])*Number(e.size??e.width??Ht.width)/Number(o.size??o.width??Ht.width):o.strokeWidth??Ht["stroke-width"];return["svg",{...Object.entries(Ht).reduce((f,[h,p])=>(f[a(h)]=p,f),{}),..."color"in o&&o.color&&{[a("stroke")]:o.color},..."size"in o&&xr(o.size)&&{[a("width")]:o.size,[a("height")]:o.size},..."width"in o&&xr(o.width)&&{[a("width")]:o.width},..."height"in o&&xr(o.height)&&{[a("height")]:o.height},[a("stroke-width")]:i,...c&&{[a("class")]:c},[a("viewBox")]:`0 0 ${r} ${s}`,...o.hasA11yProp===!1?{[a("aria-hidden")]:"true"}:{},..."attributes"in o&&o.attributes},e.node.map(f=>{let[h,p,m]=f,g=o.nonScalingStroke?{[a("vector-effect")]:"non-scaling-stroke",...p}:p;return m?[h,g,m]:[h,g]})]}function Gs(e,o={}){return Hs(e,{...o,attributeNames:{...o.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}var _s=e=>{for(let o in e)if(o.startsWith("aria-")||o==="role"||o==="title")return!0;return!1};import{createContext as Pd,useContext as Ad,useMemo as bf,createElement as vf}from"react";var Rd=Pd({});var js=()=>Ad(Rd);var Vs=Td(({color:e,size:o,width:t,height:a,strokeWidth:r,absoluteStrokeWidth:s,nonScalingStroke:l,className:n="",children:d,iconNode:c=[],icon:i={node:c,aliases:[],size:24},...u},f)=>{let{size:h=24,strokeWidth:p=2,absoluteStrokeWidth:m=!1,nonScalingStroke:g=!1,color:L="currentColor",className:C=""}=js()??{},I=!!d||_s(u),[A,b,F=[]]=Gs(i,{color:e??L,width:t??o??h,height:a??o??h,strokeWidth:r??p,absoluteStrokeWidth:s??m,nonScalingStroke:l??g,className:Pa(C,n),hasA11yProp:I,attributes:u});return Ws(A,{ref:f,...b},[...F.map(([M,O])=>Ws(M,O)),...Array.isArray(d)?d:[d]])});function k(e,o=[],t=[]){let a=typeof e=="string"?Us(e,o,t):e,r=Nd(({className:s,...l},n)=>Fd(Vs,{ref:n,icon:a,className:s,...l}));return a.name&&(r.displayName=zs(a.name)),r}var $s={name:"archive",size:24,node:[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]};$s.node;var Aa=k($s);var Xs={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};Xs.node;var Ra=k(Xs);var Ks={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};Ks.node;var Ta=k(Ks);var Qs={name:"at-sign",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]};Qs.node;var Na=k(Qs);var Js={name:"award",size:24,node:[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]};Js.node;var Fa=k(Js);var Zs={name:"ban",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]};Zs.node;var Da=k(Zs);var Ys={name:"bell-off",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]};Ys.node;var Ea=k(Ys);var en={name:"bell",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]};en.node;var Gt=k(en);var tn={name:"calendar",size:24,node:[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]]};tn.node;var qa=k(tn);var an={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};an.node;var Jt=k(an);var on={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};on.node;var Ba=k(on);var rn={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};rn.node;var Ze=k(rn);var sn={name:"circle-exclamation-point",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle","circle-alert"]};sn.node;var ut=k(sn);var nn={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};nn.node;var Ua=k(nn);var ln={name:"crown",size:24,node:[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]};ln.node;var ct=k(ln);var dn={name:"download",size:24,node:[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]};dn.node;var Tt=k(dn);var un={name:"face-slightly-smiling",size:24,node:[["path",{d:"M15 10V9",key:"4dkmfx"}],["path",{d:"M16.472 15a6 6 0 01-8.943 0",key:"7qomzy"}],["path",{d:"M9 10V9",key:"1lazqi"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],aliases:["smile"]};un.node;var bt=k(un);var cn={name:"file-text",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]};cn.node;var Zt=k(cn);var fn={name:"folder-open",size:24,node:[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]};fn.node;var Oa=k(fn);var mn={name:"folder-plus",size:24,node:[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};mn.node;var za=k(mn);var pn={name:"folder",size:24,node:[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};pn.node;var da=k(pn);var hn={name:"forward",size:24,node:[["path",{d:"m15 17 5-5-5-5",key:"nf172w"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]};hn.node;var Yt=k(hn);var gn={name:"hand",size:24,node:[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]};gn.node;var Ha=k(gn);var xn={name:"image",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]};xn.node;var Ga=k(xn);var Ln={name:"list-checks",size:24,node:[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]};Ln.node;var _a=k(Ln);var In={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};In.node;var K=k(In);var Cn={name:"log-out",size:24,node:[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]};Cn.node;var ea=k(Cn);var Sn={name:"maximize-2",size:24,node:[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]};Sn.node;var ja=k(Sn);var bn={name:"message-circle",size:24,node:[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]]};bn.node;var ua=k(bn);var vn={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]};vn.node;var Wa=k(vn);var yn={name:"paperclip",size:24,node:[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]};yn.node;var Va=k(yn);var wn={name:"pause",size:24,node:[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]};wn.node;var $a=k(wn);var kn={name:"pencil",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]};kn.node;var ca=k(kn);var Mn={name:"pin",size:24,node:[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]};Mn.node;var _t=k(Mn);var Pn={name:"play",size:24,node:[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]};Pn.node;var Xa=k(Pn);var An={name:"refresh-cw",size:24,node:[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]};An.node;var ta=k(An);var Rn={name:"reply",size:24,node:[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]]};Rn.node;var aa=k(Rn);var Tn={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};Tn.node;var Nt=k(Tn);var Nn={name:"send",size:24,node:[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]};Nn.node;var Ka=k(Nn);var Fn={name:"shield-exclamation-point",size:24,node:[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],aliases:["shield-alert"]};Fn.node;var jt=k(Fn);var Dn={name:"shield-off",size:24,node:[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]};Dn.node;var Qa=k(Dn);var En={name:"shield",size:24,node:[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]};En.node;var ft=k(En);var qn={name:"star",size:24,node:[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]};qn.node;var oa=k(qn);var Bn={name:"sticker",size:24,node:[["path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",key:"1dfntj"}],["path",{d:"M15 3v5a1 1 0 0 0 1 1h5",key:"6s6qgf"}],["path",{d:"M8 13h.01",key:"1sbv64"}],["path",{d:"M16 13h.01",key:"wip0gl"}],["path",{d:"M10 16s.8 1 2 1c1.3 0 2-1 2-1",key:"1vvgv3"}]]};Bn.node;var Ja=k(Bn);var Un={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]};Un.node;var Za=k(Un);var On={name:"trash",size:24,node:[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],aliases:["trash-2"]};On.node;var ze=k(On);var zn={name:"triangle-exclamation-point",size:24,node:[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["alert-triangle","triangle-alert"]};zn.node;var mt=k(zn);var Hn={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};Hn.node;var Ya=k(Hn);var Gn={name:"user-minus",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]};Gn.node;var eo=k(Gn);var _n={name:"user-plus",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]};_n.node;var to=k(_n);var jn={name:"user",size:24,node:[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]};jn.node;var ao=k(jn);var Wn={name:"users",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]};Wn.node;var pt=k(Wn);var Vn={name:"volume-x",size:24,node:[["path",{d:"M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z",key:"1p7khw"}],["path",{d:"m16.5 14.5 5-5",key:"cul3yw"}],["path",{d:"m16.5 9.5 5 5",key:"1akey5"}]]};Vn.node;var oo=k(Vn);var $n={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};$n.node;var we=k($n);import{useBots as ef,usePageView as tf,useSidebar as af}from"@luckylillia-dev/plugin-sdk/webui";import rt,{useEffect as lr,useCallback as Mt,useState as Kc}from"react";import{useState as Or,useMemo as vt,useRef as ou}from"react";import{createPortal as ru}from"react-dom";async function X(e,o={}){let t=await St().fetch(e,o);if(!t.ok){let a=`HTTP error! status: ${t.status}`;try{a=(await t.json()).message||a}catch{}throw new Error(a)}return t.json()}var Xn=null,Kn=null;function Qn(e,o){Xn=e,Kn=o}function st(){return Xn}function Ft(){return Kn}function Be(e,o=140){return`https://q1.qlogo.cn/g?b=qq&nk=${e}&s=${o}`}function ro(e){return`https://p.qlogo.cn/gh/${e}/${e}/640/`}async function Jn(){let e=await X("/api/webqq/rkey");if(!e.success)throw new Error(e.message||"\u83B7\u53D6 rkey \u5931\u8D25");return e.data}async function Zn(e){let o=await X("/api/webqq/self",{signal:e});if(!o.success)throw new Error(o.message||"\u83B7\u53D6\u767B\u5F55\u4FE1\u606F\u5931\u8D25");return o.data}async function Lr(){let e=await X("/api/webqq/friends");if(!e.success)throw new Error(e.message||"\u83B7\u53D6\u597D\u53CB\u5217\u8868\u5931\u8D25");let o=e.data,t=Object.values(o.categories).map(a=>{let r=o.friends.filter(s=>s.categoryId===a.categoryId).map(s=>({uid:s.uid,uin:s.uin.toString(),nickname:s.nick,remark:s.remark,avatar:Be(s.uin),online:s.status!==0}));return{categoryId:a.categoryId,categoryName:a.categoryName,categorySort:a.categorySortId,onlineCount:r.filter(s=>s.online).length,memberCount:a.categoryMemberCount,friends:r}});return t.sort((a,r)=>a.categorySort-r.categorySort),t}async function Ir(){let e=await X("/api/webqq/groups");if(!e.success)throw new Error(e.message||"\u83B7\u53D6\u7FA4\u7EC4\u5217\u8868\u5931\u8D25");return(e.data||[]).map(t=>({groupCode:t.groupCode.toString(),groupName:t.groupName,remarkName:t.remarkName||"",avatar:ro(t.groupCode),memberCount:t.memberCount,isTop:t.isTop||!1,msgMask:t.cmdUinMsgMask||1}))}async function Cr(){return[]}async function Ao(e,o,t,a=20,r){let s=new URLSearchParams({chatType:String(e),peerId:o,limit:a.toString()});t&&s.append("beforeMsgSeq",String(t)),r&&s.append("afterMsgSeq",String(r));let l=await X(`/api/webqq/messages?${s}`);if(!l.success)throw new Error(l.message||"\u83B7\u53D6\u6D88\u606F\u5386\u53F2\u5931\u8D25");return l.data||{messages:[],hasMore:!1}}async function Sr(e){let o=await X("/api/webqq/messages",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.success)throw new Error(o.message||"\u53D1\u9001\u6D88\u606F\u5931\u8D25");return o.data||{msgId:""}}async function Yn(e,o,t){let a=await X("/api/webqq/messages/forward",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({srcChatType:e.chatType,srcPeerId:e.peerId,msgSeq:o,targetChatType:t.chatType,targetPeerId:t.peerId})});if(!a.success)throw new Error(a.message||"\u8F6C\u53D1\u5931\u8D25")}async function el(e,o,t){let a=await X("/api/webqq/messages/forward-multi",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({srcChatType:e.chatType,srcPeerId:e.peerId,msgSeqs:o,targetChatType:t.chatType,targetPeerId:t.peerId})});if(!a.success)throw new Error(a.message||"\u5408\u5E76\u8F6C\u53D1\u5931\u8D25")}async function tl(e){let o=new FormData;o.append("image",e);let t=await X("/api/webqq/upload",{method:"POST",body:o});if(!t.success)throw new Error(t.message||"\u4E0A\u4F20\u56FE\u7247\u5931\u8D25");return t.data}async function al(e){let o=await X("/api/webqq/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageUrl:e})});if(!o.success)throw new Error(o.message||"\u4E0A\u4F20\u56FE\u7247\u5931\u8D25");return o.data}async function br(e){let o=new FormData;o.append("file",e);let t=await X("/api/webqq/upload-file",{method:"POST",body:o});if(!t.success)throw new Error(t.message||"\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25");return t.data}async function ol(e){let o=await X(`/api/webqq/members?groupCode=${e}`);if(!o.success)throw new Error(o.message||"\u83B7\u53D6\u7FA4\u6210\u5458\u5931\u8D25");return o.data||[]}async function rl(e,o){if(!e)throw new Error("getVideoUrl: \u9700\u8981 fileUuid");let t=new URLSearchParams({fileUuid:e,isGroup:String(o??!1)}),a=await X(`/api/webqq/video-url?${t}`);if(!a.success)throw new Error(a.message||"\u83B7\u53D6\u89C6\u9891 URL \u5931\u8D25");return a.data||""}async function sl(e,o,t){let a=await X("/api/webqq/messages/recall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatType:e,peerUid:o,msgId:t})});if(!a.success)throw new Error(a.message||"\u64A4\u56DE\u5931\u8D25")}async function so(e,o,t,a,r){let l=await X("/api/webqq/messages/emoji-like",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:o,msgSeq:t,emojiId:a,set:r})});if(!l.success)throw new Error(l.message||"\u8D34\u8868\u60C5\u5931\u8D25")}async function nl(e,o){let t=new URLSearchParams({groupCode:e,uid:o}),a=await X(`/api/webqq/group-member?${t}`);if(!a.success)throw new Error(a.message||"\u83B7\u53D6\u7FA4\u6210\u5458\u5931\u8D25");return a.data??null}async function vr(e,o){let t=new URLSearchParams;e&&t.set("uid",e),o&&t.set("uin",o);let a=await X(`/api/webqq/user?${t}`);if(!a.success)throw new Error(a.message||"\u83B7\u53D6\u7528\u6237\u8BE6\u60C5\u5931\u8D25");return a.data}async function ll(e,o){let t=new URLSearchParams({uin:e});o&&t.set("groupCode",o);let a=await X(`/api/webqq/uid?${t}`);if(!a.success)throw new Error(a.message||"uin \u8F6C uid \u5931\u8D25");return a.data||""}async function il(e){let o=new URLSearchParams({uid:e}),t=await X(`/api/webqq/uin?${o}`);if(!t.success)throw new Error(t.message||"uid \u8F6C uin \u5931\u8D25");return t.data||""}async function dl(e,o){try{if(o){let a=await nl(o,e);if(a)return a.cardName||a.nick||"\u672A\u77E5\u7528\u6237"}let t=await vr(e);return t.remark||t.nick||"\u672A\u77E5\u7528\u6237"}catch{return"\u672A\u77E5\u7528\u6237"}}async function yr(e,o,t){let s=await X(e===2?"/api/webqq/group/poke":"/api/webqq/friend/poke",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e===2?{groupCode:t,uin:o}:{uin:o})});if(!s.success)throw new Error(s.message||"\u6233\u4E00\u6233\u5931\u8D25")}async function ul(e,o,t,a){let r=await X("/api/webqq/messages/ptt-to-text",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({msgId:e,chatType:o,peerUid:t})});if(!r.success)throw new Error(r.message||"\u8BED\u97F3\u8F6C\u6587\u5B57\u5931\u8D25");return r.data||""}async function Ro(e,o,t=!1){let a=await X("/api/webqq/group/kick",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:e,uid:o,refuseForever:t})});if(!a.success)throw new Error(a.message||"\u8E22\u51FA\u5931\u8D25")}async function To(e,o,t){let a=await X("/api/webqq/group/ban",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:e,uid:o,duration:t})});if(!a.success)throw new Error(a.message||"\u7981\u8A00\u5931\u8D25")}async function No(e,o,t){let a=await X("/api/webqq/group/special-title",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:e,uid:o,title:t})});if(!a.success)throw new Error(a.message||"\u8BBE\u7F6E\u5934\u8854\u5931\u8D25")}async function cl(e,o,t){let a=await X("/api/webqq/group/member-role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:e,uid:o,isAdmin:t})});if(!a.success)throw new Error(a.message||"\u8BBE\u7F6E\u7BA1\u7406\u5458\u5931\u8D25")}async function fl(){let e=await X("/api/webqq/fav-emoji");if(!e.success)throw new Error(e.message||"\u83B7\u53D6\u6536\u85CF\u8868\u60C5\u5931\u8D25");return e.data?.emojiInfoList||[]}async function ml(e){let o=await X("/api/webqq/fav-emoji/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({emojiIds:[e]})});if(!o.success)throw new Error(o.message||"\u5220\u9664\u6536\u85CF\u8868\u60C5\u5931\u8D25");return o.data}async function pl(e){let o=await X("/api/webqq/fav-emoji/add-from-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})});if(!o.success)throw new Error(o.message||"\u6DFB\u52A0\u6536\u85CF\u8868\u60C5\u5931\u8D25");return o.data}function Dd(e,o,t){let a=`/api/webqq/audio-proxy?fileUuid=${encodeURIComponent(e)}&isGroup=${o}`;return t&&(a+=`&filePath=${encodeURIComponent(t)}`),a}async function hl(e,o,t,a){let r=await St().fetch(Dd(e,o,t),{signal:a});if(!r.ok){let s="\u83B7\u53D6\u8BED\u97F3\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";try{let l=await r.json();typeof l.message=="string"&&l.message&&(s=l.message)}catch{}throw new Error(s)}return r.blob()}async function gl(e){let o=await X("/api/webqq/group/quit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:e})});if(!o.success)throw new Error(o.message||"\u9000\u7FA4\u5931\u8D25")}async function wr(e,o="/"){let t=await X(`/api/webqq/group-files?groupCode=${encodeURIComponent(e)}&folderId=${encodeURIComponent(o)}`);if(!t.success)throw new Error(t.message||"\u83B7\u53D6\u7FA4\u6587\u4EF6\u5217\u8868\u5931\u8D25");return t.data||{files:[],folders:[]}}async function xl(e,o){let t=await X(`/api/webqq/group-file-url?groupCode=${encodeURIComponent(e)}&fileId=${encodeURIComponent(o)}`);if(!t.success)throw new Error(t.message||"\u83B7\u53D6\u4E0B\u8F7D\u94FE\u63A5\u5931\u8D25");return t.data.url}async function Ll(e,o,t){let a=await X(`/api/webqq/private-file-url?peerUid=${encodeURIComponent(e)}&fileId=${encodeURIComponent(o)}&isSelfSend=${t}`);if(!a.success)throw new Error(a.message||"\u83B7\u53D6\u4E0B\u8F7D\u94FE\u63A5\u5931\u8D25");return a.data.url}async function Fo(e,o){let a=e.startsWith("blob:")||e.startsWith("data:")?await fetch(e):await St().fetch(`/api/webqq/image-proxy?url=${encodeURIComponent(e)}`);if(!a.ok)throw new Error("\u4E0B\u8F7D\u56FE\u7247\u5931\u8D25");let r=await a.blob(),s=o||"image";if(!/\.[a-z0-9]+$/i.test(s)){let d=(r.type.split("/")[1]||"jpg").replace("jpeg","jpg");s=`${s}.${d}`}let l=URL.createObjectURL(r),n=document.createElement("a");n.href=l,n.download=s,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(l)}async function Il(e,o,t="/"){let{filePath:a,fileName:r}=await br(o),s=await X("/api/webqq/group-file/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:e,filePath:a,fileName:r,folderId:t})});if(!s.success)throw new Error(s.message||"\u4E0A\u4F20\u7FA4\u6587\u4EF6\u5931\u8D25");return s.data.fileId}async function Cl(e,o,t){let a=await X("/api/webqq/group-file/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:e,fileId:o,busId:t})});if(!a.success)throw new Error(a.message||"\u5220\u9664\u7FA4\u6587\u4EF6\u5931\u8D25")}async function Sl(e,o,t,a){let r=await X("/api/webqq/group-file/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:e,fileId:o,parentFolderId:t,newName:a})});if(!r.success)throw new Error(r.message||"\u91CD\u547D\u540D\u7FA4\u6587\u4EF6\u5931\u8D25")}async function bl(e,o){let t=await X("/api/webqq/group-folder/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:e,folderName:o})});if(!t.success)throw new Error(t.message||"\u65B0\u5EFA\u6587\u4EF6\u5939\u5931\u8D25")}async function vl(e,o){let t=await X("/api/webqq/group-folder/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:e,folderId:o})});if(!t.success)throw new Error(t.message||"\u5220\u9664\u6587\u4EF6\u5939\u5931\u8D25")}async function yl(e,o,t){let a=await X("/api/webqq/group-folder/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:e,folderId:o,newName:t})});if(!a.success)throw new Error(a.message||"\u91CD\u547D\u540D\u6587\u4EF6\u5939\u5931\u8D25")}async function no(e,o,t){let a=e;if(!a&&o&&(a=await ll(o)),!a)throw new Error("\u65E0\u6CD5\u83B7\u53D6\u7528\u6237\u4FE1\u606F");let r=await vr(a),s=o||r.uin||await il(a),l={uid:a,uin:s||"",nickname:r.nick||"",remark:r.remark||"",signature:r.bio||"",sex:r.gender??0,birthday:r.birthdayYear?`${r.birthdayYear}-${r.birthdayMonth}-${r.birthdayDay}`:"",location:[r.country,r.city].filter(Boolean).join(" ")||"",qid:r.qid||"",level:r.level||0,regTime:r.registerTime||void 0,avatar:Be(s||"")};if(t)try{let n=await nl(t,a);n&&(l.groupCard=n.cardName||"",l.groupRole=n.role===4?"owner":n.role===3?"admin":"member",l.groupTitle=n.specialTitle||"",l.groupLevel=n.level||0,l.joinTime=n.joinedAt,l.lastSpeakTime=n.lastSpokeAt)}catch{}return l}function wl(e,o,t){let a=St().authUrl("/api/webqq/events"),r,s=0,l=null,n=!1,d=()=>(r=new EventSource(a),r.addEventListener("message",i=>{try{let u=JSON.parse(i.data);e(u)}catch(u){console.error("\u89E3\u6790 SSE \u6D88\u606F\u5931\u8D25:",u)}}),r.addEventListener("connected",()=>{console.log("[SSE] \u8FDE\u63A5\u5DF2\u5EFA\u7ACB"),s=0}),r.onopen=()=>{console.log("[SSE] \u8FDE\u63A5\u6253\u5F00"),s>0&&(console.log("[SSE] \u91CD\u8FDE\u6210\u529F"),t?.()),s=0},r.onerror=i=>{if(console.error("[SSE] \u8FDE\u63A5\u9519\u8BEF:",i),n)return;r.close();let u=Math.min(1e3*Math.pow(2,s),3e4);s++,console.log(`[SSE] \u5C06\u5728 ${u}ms \u540E\u5C1D\u8BD5\u7B2C ${s} \u6B21\u91CD\u8FDE...`),l=setTimeout(()=>{n||(console.log("[SSE] \u6B63\u5728\u91CD\u8FDE..."),d())},u),o?.(i)},r);return r=d(),{close:()=>{n=!0,l&&(clearTimeout(l),l=null),r.close(),console.log("[SSE] \u8FDE\u63A5\u5DF2\u5173\u95ED")},get readyState(){return r.readyState},get url(){return r.url},addEventListener:r.addEventListener.bind(r),removeEventListener:r.removeEventListener.bind(r),dispatchEvent:r.dispatchEvent.bind(r),onerror:r.onerror,onmessage:r.onmessage,onopen:r.onopen,CONNECTING:EventSource.CONNECTING,OPEN:EventSource.OPEN,CLOSED:EventSource.CLOSED,withCredentials:r.withCredentials}}async function kl(e){let o=await X(`/api/webqq/forward-msg?resId=${encodeURIComponent(e)}`);if(!o.success)throw new Error(o.message||"\u83B7\u53D6\u5408\u5E76\u8F6C\u53D1\u6D88\u606F\u5931\u8D25");return o.data||[]}function Ml(e,o){if(!o.trim())return e;let t=o.toLowerCase();return e.filter(a=>a.groupName.toLowerCase().includes(t)||a.groupCode.includes(o))}function Pl(e,o){if(!o.trim())return e;let t=o.toLowerCase();return e.filter(a=>a.nickname.toLowerCase().includes(t)||a.card.toLowerCase().includes(t)||a.uin.includes(o))}function Al(e){let o=e.toLowerCase().split(".").pop()||"";return["jpg","jpeg","png","gif"].includes(o)}async function Rl(e){let o=await X(`/api/webqq/group-detail?groupCode=${e}`);if(!o.success)throw new Error(o.message||"\u83B7\u53D6\u7FA4\u8BE6\u60C5\u5931\u8D25");let t=o.data,a="",r="";if(t.ownerUid)try{r=await il(t.ownerUid),a=(await vr(t.ownerUid)).nick||r||""}catch{}return{groupCode:String(t.groupCode),groupName:t.groupName,remarkName:t.remark||"",avatar:ro(String(t.groupCode)),memberCount:t.memberCount??0,maxMemberCount:t.maxMemberCount,ownerUin:r,ownerName:a,createTime:t.createdAt||void 0,description:t.description||"",announcement:t.announcementPreview||""}}function lo(e){let o=new Date(e),t=new Date;if(o.toDateString()===t.toDateString())return o.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});let r=new Date(t);return r.setDate(r.getDate()-1),o.toDateString()===r.toDateString()?`\u6628\u5929 ${o.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})}`:o.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}async function Tl(e){let o=await X("/api/webqq/friend/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uid:e})});if(!o.success)throw new Error(o.message||"\u5220\u9664\u597D\u53CB\u5931\u8D25")}async function Nl(e,o,t){if(e===2){let a=await X("/api/webqq/group/set-top",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:o,isTop:t})});if(!a.success)throw new Error(a.message||"\u8BBE\u7F6E\u7F6E\u9876\u5931\u8D25")}else{let a=await ll(o);if(!a)throw new Error("\u65E0\u6CD5\u83B7\u53D6\u7528\u6237\u4FE1\u606F");let r=await X("/api/webqq/friend/set-top",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uid:a,isTop:t})});if(!r.success)throw new Error(r.message||"\u8BBE\u7F6E\u7F6E\u9876\u5931\u8D25")}}async function Fl(e,o){let t=await X("/api/webqq/group/msg-mask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupCode:e,msgMask:o})});if(!t.success)throw new Error(t.message||"\u8BBE\u7F6E\u6D88\u606F\u63A5\u6536\u65B9\u5F0F\u5931\u8D25")}async function Dl(){let e=await X("/api/webqq/notifications/group");if(!e.success)throw new Error(e.message||"\u83B7\u53D6\u7FA4\u901A\u77E5\u5931\u8D25");return e.data||[]}async function El(e,o,t){let a=await X("/api/webqq/notifications/group/handle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flag:e,action:o,reason:t})});if(!a.success)throw new Error(a.message||"\u5904\u7406\u7FA4\u901A\u77E5\u5931\u8D25")}async function kr(e,o){let t=await X("/api/webqq/notifications/friend/handle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flag:e,action:o})});if(!t.success)throw new Error(t.message||"\u5904\u7406\u597D\u53CB\u7533\u8BF7\u5931\u8D25")}async function ql(){let e=await X("/api/webqq/notifications/friend");if(!e.success)throw new Error(e.message||"\u83B7\u53D6\u597D\u53CB\u7533\u8BF7\u5931\u8D25");return e.data||[]}async function Bl(){let e=await X("/api/webqq/notifications/friend/doubt");if(!e.success)throw new Error(e.message||"\u83B7\u53D6\u88AB\u8FC7\u6EE4\u597D\u53CB\u7533\u8BF7\u5931\u8D25");return e.data||[]}async function Ul(e){let o=await X("/api/webqq/notifications/friend/doubt/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uid:e})});if(!o.success)throw new Error(o.message||"\u5904\u7406\u88AB\u8FC7\u6EE4\u597D\u53CB\u7533\u8BF7\u5931\u8D25")}var Ol=e=>{let o,t=new Set,a=(c,i)=>{let u=typeof c=="function"?c(o):c;if(!Object.is(u,o)){let f=o;o=i??(typeof u!="object"||u===null)?u:Object.assign({},o,u),t.forEach(h=>h(o,f))}},r=()=>o,n={setState:a,getState:r,getInitialState:()=>d,subscribe:c=>(t.add(c),()=>t.delete(c))},d=o=e(a,r,n);return n},zl=(e=>e?Ol(e):Ol);import Mr from"react";var Ed=e=>e;function qd(e,o=Ed){let t=Mr.useSyncExternalStore(e.subscribe,Mr.useCallback(()=>o(e.getState()),[e,o]),()=>o(e.getInitialState()));return Mr.useDebugValue(t),t}var Hl=e=>{let o=zl(e),t=a=>qd(o,a);return Object.assign(t,o),t},Do=(e=>e?Hl(e):Hl);function Pr(e,o){let t;try{t=e()}catch{return}return{getItem:r=>{var s;let l=d=>d===null?null:JSON.parse(d,o?.reviver),n=(s=t.getItem(r))!=null?s:null;return Ar(n)?n.then(l):l(n)},setItem:(r,s)=>t.setItem(r,JSON.stringify(s,o?.replacer)),removeItem:r=>t.removeItem(r)}}var Ar=e=>typeof e?.then=="function",Bd=e=>({then(o){return o?Rr(o)(e):this}}),Rr=e=>o=>{try{let t=e(o);return Ar(t)?t:Bd(t)}catch(t){return{then(a,r){return r?Rr(r)(t):this}}}},Ud=(e,o)=>(t,a,r)=>{let s={storage:Pr(()=>window.localStorage),partialize:g=>g,version:0,merge:(g,L)=>({...L,...g}),...o},l=!1,n=0,d=new Set,c=new Set,i=s.storage;if(!i)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),t(...g)},a,r);let u=()=>{let g=s.partialize({...a()});return i.setItem(s.name,{state:g,version:s.version})},f=r.setState;r.setState=(...g)=>(f(...g),u());let h=e((...g)=>(t(...g),u()),a,r);r.getInitialState=()=>h;let p,m=()=>{var g,L;if(!i)return;let C=++n;l=!1,d.forEach(A=>{var b;return A((b=a())!=null?b:h)});let I=((L=s.onRehydrateStorage)==null?void 0:L.call(s,(g=a())!=null?g:h))||void 0;return Rr(i.getItem.bind(i))(s.name).then(A=>{if(A)if(typeof A.version=="number"&&A.version!==s.version){if(s.migrate){let b=s.migrate(A.state,A.version);return Ar(b)?b.then(F=>[!0,F]):[!0,b]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,A.state];return[!1,void 0]}).then(A=>{var b;if(C!==n)return;let[F,M]=A;if(p=s.merge(M,(b=a())!=null?b:h),t(p,!0),F)return u()}).then(()=>{C===n&&(I?.(a(),void 0),p=a(),l=!0,c.forEach(A=>A(p)))}).then(()=>{},A=>{C===n&&I?.(void 0,A)})};return r.persist={setOptions:g=>{s={...s,...g},g.storage&&(i=g.storage)},clearStorage:()=>{++n,i?.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>{try{return Promise.resolve(m())}catch(g){return Promise.reject(g)}},hasHydrated:()=>l,onHydrate:g=>(d.add(g),()=>{d.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},s.skipHydration||m(),p||h},Gl=Ud;var Vl="webqq-storage",Dt="",$e=0,Od=Pr(()=>({getItem:e=>Dt?localStorage.getItem(`${Dt}-${e}`):null,setItem:(e,o)=>{Dt&&localStorage.setItem(`${Dt}-${e}`,o)},removeItem:e=>{Dt&&localStorage.removeItem(`${Dt}-${e}`)}})),zd=3600*1e3,_l=1800*1e3,io=new Map,Tr=new Set,Nr=new Set,Eo=()=>{Tr=new Set,Nr=new Set},fa=(e,o)=>Tr.has(`${e}_${o}`),$l=(e,o)=>{Tr.add(`${e}_${o}`)};var Xl=e=>Nr.has(e),Kl=e=>{Nr.add(e)},jl={friendCategories:[],groups:[],recentChats:[],groupLastTimeMap:{},groupLastMessageMap:{},expandedCategories:[],membersCache:{},showMemberPanel:!1,scrollPositions:{},contactsCacheTimestamp:0,unreadCounts:{},activeTab:"recent",currentChat:null},Wl={contactsLoading:!1,contactsError:null,groupAssistantMode:"normal",notifications:[],notificationUnreadCount:0},re=Do()(Gl((e,o)=>({...jl,...Wl,setFriendCategories:t=>e({friendCategories:t}),setGroups:t=>e({groups:t}),setRecentChats:t=>e({recentChats:t}),setContactsLoading:t=>e({contactsLoading:t}),setContactsError:t=>e({contactsError:t}),setCurrentChat:t=>e({currentChat:t}),setActiveTab:t=>e({activeTab:t}),setGroupAssistantMode:t=>e({groupAssistantMode:t}),enterGroupAssistant:()=>e({groupAssistantMode:"assistant"}),exitGroupAssistant:()=>e({groupAssistantMode:"normal"}),setUnreadCount:(t,a)=>e(r=>({unreadCounts:{...r.unreadCounts,[t]:a}})),incrementUnreadCount:t=>e(a=>({unreadCounts:{...a.unreadCounts,[t]:(a.unreadCounts[t]||0)+1}})),clearUnreadCount:t=>e(a=>{let{[t]:r,...s}=a.unreadCounts;return{unreadCounts:s}}),initUnreadCounts:t=>{let a={};t.forEach(r=>{r.unreadCount>0&&(a[`${r.chatType}_${r.peerId}`]=r.unreadCount)}),e({unreadCounts:a})},toggleCategory:t=>e(a=>{let r=new Set(a.expandedCategories);return r.has(t)?r.delete(t):r.add(t),{expandedCategories:Array.from(r)}}),setExpandedCategories:t=>e({expandedCategories:t}),getCachedMembers:t=>{let r=o().membersCache[t];return r&&Date.now()-r.timestamp<_l?r.members:null},setCachedMembers:(t,a)=>e(r=>{let s=Date.now(),l={};for(let[n,d]of Object.entries(r.membersCache))s-d.timestamp<_l&&(l[n]=d);return{membersCache:{...l,[t]:{members:a,timestamp:s}}}}),fetchGroupMembers:async(t,a=!1)=>{let r=$e,s=o();if(console.log("[Store] fetchGroupMembers called:",t,"forceRefresh:",a),!a){let d=s.getCachedMembers(t);if(d)return console.log("[Store] Cache hit, returning cached members"),d}let l=io.get(t);if(l)return console.log("[Store] Already loading, returning existing promise"),l;console.log("[Store] Fetching from API");let n=(async()=>{let d=await ol(t);return r!==$e?[]:(console.log("[Store] API success, caching members"),o().setCachedMembers(t,d),d)})().catch(d=>{if(r!==$e)return[];throw console.log("[Store] API error:",d.message),d}).finally(()=>{io.get(t)===n&&io.delete(t)});return io.set(t,n),n},setShowMemberPanel:t=>e({showMemberPanel:t}),addNotification:t=>e(a=>a.notifications.some(s=>s.type==="group-notify"&&t.type==="group-notify"||s.type==="friend-request"&&t.type==="friend-request"?s.data.flag===t.data.flag:!1)?{notifications:a.notifications.map(s=>s.type===t.type&&(s.type==="group-notify"&&t.type==="group-notify"&&s.data.flag===t.data.flag||s.type==="friend-request"&&t.type==="friend-request"&&s.data.flag===t.data.flag)?t:s)}:{notifications:[t,...a.notifications].slice(0,200),notificationUnreadCount:a.notificationUnreadCount+1}),setNotifications:t=>e({notifications:t}),clearNotificationUnread:()=>e({notificationUnreadCount:0}),updateNotificationStatus:(t,a,r)=>e(s=>({notifications:s.notifications.map(l=>{if(l.type===t){if(l.type==="group-notify"&&l.data.flag===a)return{...l,data:{...l.data,status:r}};if(l.type==="friend-request"&&l.data.flag===a)return{...l,data:{...l.data,isDecide:!0}}}return l})})),loadGroupNotifications:async()=>{let t=$e;try{let[a,r,s]=await Promise.all([Dl().catch(()=>[]),ql().catch(()=>[]),Bl().catch(()=>[])]);if(t!==$e)return;let l=a.map(f=>({type:"group-notify",data:f,time:f.actionTime?parseInt(f.actionTime)*1e3:parseInt(f.seq)/1e3})),n=r.map(f=>({type:"friend-request",data:f,time:f.reqTime?parseInt(f.reqTime)*1e3:Date.now()})),d=s.map(f=>({type:"doubt-buddy",data:f,time:f.reqTime?parseInt(f.reqTime)*1e3:Date.now()})),i=o().notifications.filter(f=>f.type!=="group-notify"&&f.type!=="friend-request"&&f.type!=="doubt-buddy"),u=[...l,...n,...d,...i].sort((f,h)=>h.time-f.time).slice(0,200);e({notifications:u})}catch(a){if(t!==$e)return;console.error("\u52A0\u8F7D\u901A\u77E5\u5931\u8D25:",a)}},getScrollPosition:(t,a)=>{let r=o(),s=`${t}_${a}`;return r.scrollPositions[s]||null},setScrollPosition:(t,a,r)=>e(s=>({scrollPositions:{...s.scrollPositions,[`${t}_${a}`]:r}})),clearScrollPosition:(t,a)=>e(r=>{let{[`${t}_${a}`]:s,...l}=r.scrollPositions;return{scrollPositions:l}}),isContactsCacheValid:()=>{let t=o();return t.contactsCacheTimestamp>0&&Date.now()-t.contactsCacheTimestamp<zd&&(t.friendCategories.length>0||t.groups.length>0)},loadContacts:async()=>{let t=$e,a=o();if(a.isContactsCacheValid()){a.refreshContacts();return}e({contactsLoading:!0,contactsError:null});try{let[r,s,l]=await Promise.all([Lr(),Ir(),Cr()]);if(t!==$e)return;let n=l.filter(p=>p.peerId&&p.peerId!=="0"&&p.peerId!==""),d=new Map;a.recentChats.forEach(p=>{p.peerId&&p.peerId!=="0"&&p.peerId!==""&&d.set(`${p.chatType}_${p.peerId}`,p)}),n.forEach(p=>{let m=`${p.chatType}_${p.peerId}`,g=d.get(m);g?(p.lastTime>g.lastTime||p.lastTime===g.lastTime&&!g.lastMessage&&p.lastMessage)&&d.set(m,p):d.set(m,p)});let c=Array.from(d.values()).sort((p,m)=>m.lastTime-p.lastTime),i={},u={};n.forEach(p=>{p.chatType===2&&(i[p.peerId]=p.lastTime,p.lastMessage&&(u[p.peerId]=p.lastMessage))}),e({friendCategories:r,groups:s,recentChats:c,groupLastTimeMap:i,groupLastMessageMap:u,contactsCacheTimestamp:Date.now(),contactsLoading:!1});let h={...o().unreadCounts};n.forEach(p=>{let m=`${p.chatType}_${p.peerId}`;!(m in h)&&p.unreadCount>0&&(h[m]=p.unreadCount)}),e({unreadCounts:h})}catch(r){if(t!==$e)return;e({contactsError:r.message||"\u52A0\u8F7D\u8054\u7CFB\u4EBA\u5931\u8D25",contactsLoading:!1})}},refreshContacts:async()=>{let t=$e;try{let[a,r,s]=await Promise.all([Lr(),Ir(),Cr()]);if(t!==$e)return;let l=s.filter(p=>p.peerId&&p.peerId!=="0"&&p.peerId!==""),n=o(),d=new Map;n.recentChats.forEach(p=>{p.peerId&&p.peerId!=="0"&&p.peerId!==""&&d.set(`${p.chatType}_${p.peerId}`,p)}),l.forEach(p=>{let m=`${p.chatType}_${p.peerId}`,g=d.get(m);g?(p.lastTime>g.lastTime||p.lastTime===g.lastTime&&!g.lastMessage&&p.lastMessage)&&d.set(m,p):d.set(m,p)});let c=Array.from(d.values()).sort((p,m)=>m.lastTime-p.lastTime),i={...n.groupLastTimeMap},u={...n.groupLastMessageMap};l.forEach(p=>{p.chatType===2&&(i[p.peerId]=p.lastTime,p.lastMessage&&(u[p.peerId]=p.lastMessage))}),e({friendCategories:a,groups:r,recentChats:c,groupLastTimeMap:i,groupLastMessageMap:u,contactsCacheTimestamp:Date.now()});let h={...o().unreadCounts};l.forEach(p=>{let m=`${p.chatType}_${p.peerId}`;!(m in h)&&p.unreadCount>0&&(h[m]=p.unreadCount)}),e({unreadCounts:h})}catch(a){if(t!==$e)return;console.error("Failed to refresh contacts:",a)}},updateRecentChat:(t,a,r,s,l,n)=>e(d=>{let c=d.recentChats.filter((m,g,L)=>L.findIndex(C=>C.chatType===m.chatType&&C.peerId===m.peerId)===g),i=c.find(m=>m.chatType===t&&m.peerId===a),u=d.currentChat,f=u?.chatType===t&&u?.peerId===a,h=t===2?{...d.groupLastTimeMap,[a]:s}:d.groupLastTimeMap,p=t===2?{...d.groupLastMessageMap,[a]:r||"[\u6D88\u606F]"}:d.groupLastMessageMap;if(i){let m=c.filter(I=>!(I.chatType===t&&I.peerId===a)),g={...i,lastMessage:r,lastTime:s,unreadCount:f?0:i.unreadCount+1};if(i.pinned){let I=m.filter(b=>b.pinned),A=m.filter(b=>!b.pinned);return{recentChats:[g,...I,...A],groupLastTimeMap:h,groupLastMessageMap:p}}let L=m.filter(I=>I.pinned),C=m.filter(I=>!I.pinned);return{recentChats:[...L,g,...C],groupLastTimeMap:h,groupLastMessageMap:p}}else{let m=l||a,g=n||"";if(t===1||t===100){for(let C of d.friendCategories){let I=C.friends.find(A=>A.uin===a);if(I){m=I.remark||I.nickname,g=I.avatar;break}}g||(g=Be(a))}else if(t===2){let C=d.groups.find(I=>I.groupCode===a);if(C){if(C.msgMask===2)return{groupLastTimeMap:h,groupLastMessageMap:p};m=C.groupName,g=C.avatar}g||(g=`https://p.qlogo.cn/gh/${a}/${a}/640/`)}return{recentChats:[{chatType:t,peerId:a,peerName:m,peerAvatar:g,lastMessage:r,lastTime:s,unreadCount:f?0:1},...c],groupLastTimeMap:h,groupLastMessageMap:p}}}),togglePinChat:async(t,a)=>{let r=$e,l=o().recentChats.find(d=>d.chatType===t&&d.peerId===a);if(!l)return;let n=!l.pinned;try{if(await Nl(t,a,n),r!==$e)return;e(d=>{let c=d.recentChats.map(i=>i.chatType===t&&i.peerId===a?{...i,pinned:n}:i);return c.sort((i,u)=>i.pinned&&!u.pinned?-1:!i.pinned&&u.pinned?1:u.lastTime-i.lastTime),{recentChats:c}})}catch(d){if(r!==$e)return;throw console.error("\u8BBE\u7F6E\u7F6E\u9876\u5931\u8D25:",d),d}},removeRecentChat:(t,a)=>e(r=>({recentChats:r.recentChats.filter(s=>!(s.chatType===t&&s.peerId===a))})),removeFriend:t=>e(a=>({friendCategories:a.friendCategories.map(s=>({...s,friends:s.friends.filter(l=>l.uid!==t),memberCount:s.friends.filter(l=>l.uid!==t).length}))}))}),{name:Vl,storage:Od,skipHydration:!0,partialize:e=>({_uin:Dt,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}),merge:(e,o)=>{let{_uin:t,...a}=e??{};return{...o,...jl,...a,...Wl}},onRehydrateStorage:()=>e=>{if(e&&e.recentChats){let o=new Set;e.recentChats=e.recentChats.filter(t=>{if(!t.peerId||t.peerId==="0"||t.peerId==="")return!1;let a=`${t.chatType}_${t.peerId}`;return o.has(a)?!1:(o.add(a),!0)})}}}));function Ql(e){if(!e||e===Dt)return;Dt=e,$e++,io.clear(),Eo();let o=`${e}-${Vl}`;try{let t=localStorage.getItem(o);t&&JSON.parse(t)?.state?._uin!==e&&localStorage.removeItem(o)}catch{localStorage.removeItem(o)}re.persist.rehydrate()}import{useState as qo,useRef as Fr,useEffect as Dr}from"react";import{createPortal as Jl}from"react-dom";import{Fragment as ei,jsx as ge,jsxs as Ue}from"react/jsx-runtime";function Bo(e,o,t){let[a,r]=qo({left:-9999,top:-9999,ready:!1});return Dr(()=>{r({left:-9999,top:-9999,ready:!1});let s=requestAnimationFrame(()=>{if(!t.current){r({left:e,top:o,ready:!0});return}let l=t.current.getBoundingClientRect(),n=10,d=e,c=o;e+l.width>window.innerWidth-n&&(d=e-l.width),d<n&&(d=n),o+l.height>window.innerHeight-n&&(c=o-l.height),c<n&&(c=n),r({left:d,top:c,ready:!0})});return()=>cancelAnimationFrame(s)},[e,o]),a}var Er=({groupCode:e,onClose:o})=>{let{groups:t,setGroups:a}=re(),[r,s]=qo(!1),l=Fr(null),n=async c=>{try{await Fl(e,c);let i=t.map(u=>u.groupCode===e?{...u,msgMask:c}:u);a(i)}catch(i){console.error("\u8BBE\u7F6E\u6D88\u606F\u63A5\u6536\u65B9\u5F0F\u5931\u8D25:",i),alert(`\u8BBE\u7F6E\u5931\u8D25: ${i.message||"\u672A\u77E5\u9519\u8BEF"}`)}o()},d=t.find(c=>c.groupCode===e)?.msgMask;return Ue("div",{className:"relative",children:[Ue("button",{onMouseEnter:()=>s(!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:[ge(Gt,{size:14,className:"flex-shrink-0"}),ge("span",{className:"flex-1",children:"\u6D88\u606F\u63A5\u6536\u65B9\u5F0F"}),ge(Ze,{size:14,className:"flex-shrink-0"})]}),r&&Ue("div",{ref:l,className:"absolute left-full top-0 ml-1 bg-popup r-control glass-pop origin-top-left py-1 min-w-[140px] z-[10000]",onMouseLeave:()=>s(!1),children:[Ue("button",{onClick:()=>n(1),className:"w-full px-3 py-2 text-left text-sm hover:bg-theme-item-hover flex items-center gap-2 text-theme",children:[ge(Gt,{size:14,className:"flex-shrink-0"}),ge("span",{className:"flex-1",children:"\u63A5\u6536\u5E76\u63D0\u9192"}),d===1&&ge("span",{className:"flex-shrink-0 text-pink-500",children:"\u2713"})]}),Ue("button",{onClick:()=>n(4),className:"w-full px-3 py-2 text-left text-sm hover:bg-theme-item-hover flex items-center gap-2 text-theme",children:[ge(Ea,{size:14,className:"flex-shrink-0"}),ge("span",{className:"flex-1",children:"\u63A5\u6536\u4F46\u4E0D\u63D0\u9192"}),d===4&&ge("span",{className:"flex-shrink-0 text-pink-500",children:"\u2713"})]}),Ue("button",{onClick:()=>n(2),className:"w-full px-3 py-2 text-left text-sm hover:bg-theme-item-hover flex items-center gap-2 text-theme",children:[ge(Aa,{size:14,className:"flex-shrink-0"}),ge("span",{className:"flex-1",children:"\u6536\u8FDB\u7FA4\u52A9\u624B"}),d===2&&ge("span",{className:"flex-shrink-0 text-pink-500",children:"\u2713"})]}),Ue("button",{onClick:()=>n(3),className:"w-full px-3 py-2 text-left text-sm hover:bg-theme-item-hover flex items-center gap-2 text-theme",children:[ge(Da,{size:14,className:"flex-shrink-0"}),ge("span",{className:"flex-1",children:"\u5C4F\u853D\u7FA4\u6D88\u606F"}),d===3&&ge("span",{className:"flex-shrink-0 text-pink-500",children:"\u2713"})]})]})]})},Zl=({friend:e,isSelected:o,onClick:t})=>{let{togglePinChat:a}=re(),[r,s]=qo(null),l=Fr(null),n=Bo(r?.x||0,r?.y||0,l),d=u=>{u.preventDefault(),u.stopPropagation(),s({x:u.clientX,y:u.clientY})},c=()=>s(null),i=async()=>{try{await a(1,e.uin)}catch(u){console.error("\u7F6E\u9876\u5931\u8D25:",u),alert(`\u7F6E\u9876\u5931\u8D25: ${u.message||"\u672A\u77E5\u9519\u8BEF"}`)}c()};return Dr(()=>{if(!r)return;let u=()=>c();return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[r]),Ue(ei,{children:[Ue("div",{onClick:t,onContextMenu:d,className:`flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors ${o?"bg-pink-500/20":"hover:bg-theme-item-hover"}`,children:[Ue("div",{className:"relative flex-shrink-0",children:[ge("img",{src:e.avatar,alt:e.nickname,className:"w-10 h-10 rounded-full object-cover",onError:u=>{u.currentTarget.src=Be(e.uin)}}),e.online&&ge("div",{className:"absolute bottom-0 right-0 w-3 h-3 bg-green-500 rounded-full border-2 border-white dark:border-neutral-800"})]}),Ue("div",{className:"flex-1 min-w-0",children:[ge("div",{className:"text-sm font-medium text-theme truncate",children:e.remark||e.nickname}),e.remark&&ge("div",{className:"text-xs text-theme-hint truncate",children:e.nickname})]})]}),r&&Jl(ge("div",{ref:l,className:"fixed glass glass-thick r-control glass-pop origin-top-left py-1 min-w-[120px] z-[9999]",style:{left:`${n.left}px`,top:`${n.top}px`,opacity:n.ready?1:0,pointerEvents:n.ready?"auto":"none"},onClick:u=>u.stopPropagation(),children:Ue("button",{onClick:i,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:[ge(_t,{size:14,className:"flex-shrink-0"}),ge("span",{className:"flex-1",children:e.topTime&&e.topTime!=="0"?"\u53D6\u6D88\u7F6E\u9876":"\u7F6E\u9876"})]})}),document.body)]})},Yl=({group:e,isSelected:o,onClick:t,showPinnedStyle:a=!1,unreadCount:r=0,subtitle:s})=>{let{togglePinChat:l}=re(),[n,d]=qo(null),c=Fr(null),i=Bo(n?.x||0,n?.y||0,c),u=p=>{p.preventDefault(),p.stopPropagation(),d({x:p.clientX,y:p.clientY})},f=()=>{d(null)},h=async()=>{try{await l(2,e.groupCode)}catch(p){console.error("\u7F6E\u9876\u5931\u8D25:",p),alert(`\u7F6E\u9876\u5931\u8D25: ${p.message||"\u672A\u77E5\u9519\u8BEF"}`)}f()};return Dr(()=>{if(!n)return;let p=()=>f();return document.addEventListener("click",p),()=>document.removeEventListener("click",p)},[n]),Ue(ei,{children:[Ue("div",{onClick:t,onContextMenu:u,className:`flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors ${o?"bg-pink-500/20":a&&e.isTop?"bg-theme-item-hover":"hover:bg-theme-item-hover"}`,children:[Ue("div",{className:"relative flex-shrink-0",children:[ge("img",{src:e.avatar,alt:e.groupName,className:"w-10 h-10 rounded-full object-cover",onError:p=>{p.currentTarget.src=`https://p.qlogo.cn/gh/${e.groupCode}/${e.groupCode}/640/`}}),r>0&&ge("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:r})]}),Ue("div",{className:"flex-1 min-w-0",children:[ge("div",{className:"text-sm font-medium text-theme truncate",children:e.groupName}),ge("div",{className:"text-xs text-theme-hint truncate",children:s||`${e.memberCount} \u4EBA`})]})]}),n&&Jl(Ue("div",{ref:c,className:"fixed glass glass-thick r-control glass-pop origin-top-left py-1 min-w-[160px] z-[9999]",style:{left:`${i.left}px`,top:`${i.top}px`,opacity:i.ready?1:0,pointerEvents:i.ready?"auto":"none"},onClick:p=>p.stopPropagation(),children:[Ue("button",{onClick:h,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:[ge(_t,{size:14,className:"flex-shrink-0"}),ge("span",{className:"flex-1",children:e.isTop?"\u53D6\u6D88\u7F6E\u9876":"\u7F6E\u9876"})]}),ge(Er,{groupCode:e.groupCode,onClose:f})]}),document.body)]})};import{useState as ht,useEffect as $d}from"react";import{useEffect as _d,useRef as jd}from"react";import{createPortal as Wd}from"react-dom";var Vd=({children:e})=>{let o=jd(null);return o.current||(o.current=document.createElement("div")),_d(()=>{let t=o.current;return document.body.appendChild(t),()=>{document.body.removeChild(t)}},[]),Wd(e,o.current)},qr=Vd;import{jsx as V,jsxs as se}from"react/jsx-runtime";function Uo(e){if(!e||e<=0)return"";let o=new Date(e),t=new Date;return o.toDateString()===t.toDateString()?o.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):o.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Xd(e){let o=e.user1.nickName||e.user1.uin||"\u672A\u77E5\u7528\u6237",t=e.user2.nickName||e.user2.uin||"";switch(e.notifyType){case 7:return`${o} \u7533\u8BF7\u52A0\u5165\u7FA4`;case 1:return`${t} \u9080\u8BF7\u4F60\u52A0\u5165\u7FA4`;case 5:return`${t} \u9080\u8BF7 ${o} \u52A0\u5165\u7FA4`;case 4:return`${o} \u5DF2\u52A0\u5165\u7FA4`;case 6:return`\u7BA1\u7406\u5458\u5DF2\u540C\u610F ${o} \u52A0\u5165\u7FA4`;case 2:return`${o} \u62D2\u7EDD\u4E86\u9080\u8BF7`;case 3:return`\u7BA1\u7406\u5458\u62D2\u7EDD\u4E86 ${o} \u7684\u52A0\u7FA4\u8BF7\u6C42`;case 8:return`${o} \u88AB\u8BBE\u4E3A\u7BA1\u7406\u5458`;case 9:return`${o} \u88AB ${t} \u79FB\u51FA\u7FA4`;case 10:return`\u4F60\u88AB ${t} \u79FB\u51FA\u7FA4`;case 11:return`${o} \u9000\u51FA\u4E86\u7FA4`;case 12:return"\u4F60\u88AB\u53D6\u6D88\u4E86\u7BA1\u7406\u5458";case 13:return`${o} \u88AB\u53D6\u6D88\u4E86\u7BA1\u7406\u5458`;case 14:return`\u7FA4\u4E3B\u5DF2\u8F6C\u8BA9\u7ED9 ${t}`;case 15:return`${o} \u5C06\u7FA4\u4E3B\u8F6C\u8BA9\u7ED9 ${t}`;default:return"\u7FA4\u901A\u77E5"}}function ti(e){return e.status===1&&(e.notifyType===7||e.notifyType===1||e.notifyType===5)}function Kd(e){switch(e.status){case 2:return"\u5DF2\u540C\u610F";case 3:return"\u5DF2\u62D2\u7EDD";case 4:return"\u5DF2\u5FFD\u7565";default:return null}}var Br="flex items-center gap-1 px-3 py-1 text-xs text-pink-500 hover:bg-pink-50 dark:hover:bg-pink-900/30 rounded-md transition-colors disabled:opacity-50",Ur="flex items-center gap-1 px-3 py-1 text-xs text-theme-secondary hover:bg-neutral-100 dark:hover:bg-neutral-700/50 rounded-md transition-colors disabled:opacity-50",Qd="flex items-center gap-1 px-3 py-1 text-xs text-red-500 hover:bg-red-50 dark:hover:bg-red-900/30 rounded-md transition-colors disabled:opacity-50",Jd="px-3 py-1 text-xs text-theme-muted hover:text-theme hover:bg-theme-item rounded-md transition-colors",Zd=({item:e,time:o})=>{let[t,a]=ht(null),[r,s]=ht(!1),[l,n]=ht(""),d=re(h=>h.updateNotificationStatus),c=async(h,p)=>{a(h);try{await El(e.flag,h,p),d("group-notify",e.flag,h==="approve"?2:3),T(h==="approve"?"\u5DF2\u540C\u610F":"\u5DF2\u62D2\u7EDD","success"),s(!1)}catch(m){T(m.message||"\u64CD\u4F5C\u5931\u8D25","error")}finally{a(null)}},i=Kd(e),u=ti(e),f=ro(e.group.groupCode);return se("div",{className:"flex items-start gap-3 px-3 py-3 hover:bg-theme-item-hover transition-colors",children:[V("img",{src:f,alt:"",className:"w-10 h-10 rounded-full flex-shrink-0 object-cover"}),se("div",{className:"flex-1 min-w-0",children:[se("div",{className:"flex items-center gap-2",children:[V("span",{className:"text-sm font-medium text-theme truncate",children:e.group.groupName}),e.doubt&&V("span",{className:"text-xs text-amber-500 flex-shrink-0",children:"\u88AB\u8FC7\u6EE4"}),V("span",{className:"text-xs text-theme-hint flex-shrink-0",children:Uo(o)})]}),V("div",{className:"text-xs text-theme-secondary mt-0.5",children:Xd(e)}),e.postscript&&se("div",{className:"text-xs text-theme-hint mt-1 bg-theme-input rounded px-2 py-1 break-words whitespace-pre-wrap",children:["\u9A8C\u8BC1\u4FE1\u606F\uFF1A",e.postscript]}),u&&!r&&se("div",{className:"flex gap-2 mt-2",children:[se("button",{onClick:()=>c("approve"),disabled:t!==null,className:Br,children:[t==="approve"?V(K,{size:12,className:"animate-spin"}):V(Jt,{size:12}),"\u540C\u610F"]}),se("button",{onClick:()=>s(!0),disabled:t!==null,className:Ur,children:[V(we,{size:12}),"\u62D2\u7EDD"]})]}),u&&r&&se("div",{className:"mt-2 space-y-1.5",children:[V("input",{type:"text",value:l,onChange:h=>n(h.target.value),placeholder:"\u62D2\u7EDD\u7406\u7531\uFF08\u53EF\u9009\uFF09",className:"w-full px-2 py-1 text-xs bg-theme-input text-theme rounded border border-theme-divider focus:outline-none focus:border-pink-400",onKeyDown:h=>{h.key==="Enter"&&c("reject",l)},autoFocus:!0}),se("div",{className:"flex gap-2",children:[se("button",{onClick:()=>c("reject",l),disabled:t!==null,className:Qd,children:[t==="reject"?V(K,{size:12,className:"animate-spin"}):V(we,{size:12}),"\u786E\u8BA4\u62D2\u7EDD"]}),V("button",{onClick:()=>{s(!1),n("")},disabled:t!==null,className:Jd,children:"\u53D6\u6D88"})]})]}),i&&V("div",{className:`text-xs mt-1 ${e.status===2?"text-pink-500":e.status===3?"text-theme-secondary":"text-theme-hint"}`,children:i})]})]})},Yd=({item:e,time:o})=>{let[t,a]=ht(null),[r,s]=ht(e.isDecide),[l,n]=ht(null),d=re(u=>u.updateNotificationStatus),c=async u=>{a(u);try{await kr(e.flag,u),d("friend-request",e.flag,0),s(!0),n(u),T(u==="approve"?"\u5DF2\u540C\u610F":"\u5DF2\u62D2\u7EDD","success")}catch(f){T(f.message||"\u64CD\u4F5C\u5931\u8D25","error")}finally{a(null)}},i=Be(e.friendUin);return se("div",{className:"flex items-start gap-3 px-3 py-3 hover:bg-theme-item-hover transition-colors",children:[V("img",{src:i,alt:"",className:"w-10 h-10 rounded-full flex-shrink-0 object-cover"}),se("div",{className:"flex-1 min-w-0",children:[se("div",{className:"flex items-center gap-2",children:[V("span",{className:"text-sm font-medium text-theme truncate",children:e.friendNick||e.friendUin}),V("span",{className:"text-xs text-theme-hint flex-shrink-0",children:Uo(o)})]}),V("div",{className:"text-xs text-theme-secondary mt-0.5",children:"\u8BF7\u6C42\u6DFB\u52A0\u4F60\u4E3A\u597D\u53CB"}),e.extWords&&se("div",{className:"text-xs text-theme-hint mt-1 bg-theme-input rounded px-2 py-1 break-words whitespace-pre-wrap",children:["\u9A8C\u8BC1\u4FE1\u606F\uFF1A",e.extWords]}),e.addSource&&se("div",{className:"text-xs text-theme-hint mt-0.5",children:["\u6765\u6E90\uFF1A",e.addSource]}),!r&&se("div",{className:"flex gap-2 mt-2",children:[se("button",{onClick:()=>c("approve"),disabled:t!==null,className:Br,children:[t==="approve"?V(K,{size:12,className:"animate-spin"}):V(Jt,{size:12}),"\u540C\u610F"]}),se("button",{onClick:()=>c("reject"),disabled:t!==null,className:Ur,children:[t==="reject"?V(K,{size:12,className:"animate-spin"}):V(we,{size:12}),"\u62D2\u7EDD"]})]}),r&&V("div",{className:`text-xs mt-1 ${l==="approve"?"text-pink-500":l==="reject"?"text-theme-secondary":"text-theme-hint"}`,children:l==="approve"?"\u5DF2\u540C\u610F":l==="reject"?"\u5DF2\u62D2\u7EDD":"\u5DF2\u5904\u7406"})]})]})},eu=({item:e,time:o})=>{let[t,a]=ht(null),[r,s]=ht(!1),[l,n]=ht(null),d=re(u=>u.updateNotificationStatus),c=async u=>{a(u);try{u==="approve"?await Ul(e.uid):await kr(e.uid,"reject"),d("doubt-buddy",e.flag,0),s(!0),n(u),T(u==="approve"?"\u5DF2\u540C\u610F":"\u5DF2\u62D2\u7EDD","success")}catch(f){T(f.message||"\u64CD\u4F5C\u5931\u8D25","error")}finally{a(null)}},i=Be(e.uid);return se("div",{className:"flex items-start gap-3 px-3 py-3 hover:bg-theme-item-hover transition-colors",children:[se("div",{className:"relative flex-shrink-0",children:[V("img",{src:i,alt:"",className:"w-10 h-10 rounded-full object-cover"}),V("div",{className:"absolute -bottom-0.5 -right-0.5 bg-amber-500 rounded-full p-0.5",children:V(jt,{size:10,className:"text-white"})})]}),se("div",{className:"flex-1 min-w-0",children:[se("div",{className:"flex items-center gap-2",children:[V("span",{className:"text-sm font-medium text-theme truncate",children:e.nick||e.uid}),V("span",{className:"text-xs text-amber-500 flex-shrink-0",children:"\u88AB\u8FC7\u6EE4"}),V("span",{className:"text-xs text-theme-hint flex-shrink-0",children:Uo(o)})]}),V("div",{className:"text-xs text-theme-secondary mt-0.5",children:"\u8BF7\u6C42\u6DFB\u52A0\u4F60\u4E3A\u597D\u53CB"}),e.msg&&se("div",{className:"text-xs text-theme-hint mt-1 bg-theme-input rounded px-2 py-1 break-words whitespace-pre-wrap",children:["\u9A8C\u8BC1\u4FE1\u606F\uFF1A",e.msg]}),e.source&&se("div",{className:"text-xs text-theme-hint mt-0.5",children:["\u6765\u6E90\uFF1A",e.source]}),e.reason&&se("div",{className:"text-xs text-amber-500/80 mt-0.5",children:["\u8FC7\u6EE4\u539F\u56E0\uFF1A",e.reason]}),!r&&se("div",{className:"flex gap-2 mt-2",children:[se("button",{onClick:()=>c("approve"),disabled:t!==null,className:Br,children:[t==="approve"?V(K,{size:12,className:"animate-spin"}):V(Jt,{size:12}),"\u540C\u610F"]}),se("button",{onClick:()=>c("reject"),disabled:t!==null,className:Ur,children:[t==="reject"?V(K,{size:12,className:"animate-spin"}):V(we,{size:12}),"\u62D2\u7EDD"]})]}),r&&V("div",{className:`text-xs mt-1 ${l==="approve"?"text-pink-500":"text-theme-secondary"}`,children:l==="approve"?"\u5DF2\u540C\u610F":"\u5DF2\u62D2\u7EDD"})]})]})},tu=({type:e,data:o,time:t})=>{let a=ro(o.groupCode),r=e==="group-dismiss"?mt:ea,s=e==="group-dismiss"?"\u7FA4\u5DF2\u89E3\u6563":"\u5DF2\u9000\u51FA\u7FA4\u804A";return se("div",{className:"flex items-start gap-3 px-3 py-3 hover:bg-theme-item-hover transition-colors",children:[se("div",{className:"relative flex-shrink-0",children:[V("img",{src:a,alt:"",className:"w-10 h-10 rounded-full object-cover"}),V("div",{className:"absolute -bottom-0.5 -right-0.5 bg-orange-500 rounded-full p-0.5",children:V(r,{size:10,className:"text-white"})})]}),se("div",{className:"flex-1 min-w-0",children:[se("div",{className:"flex items-center gap-2",children:[V("span",{className:"text-sm font-medium text-theme truncate",children:o.groupName||o.groupCode}),V("span",{className:"text-xs text-theme-hint flex-shrink-0",children:Uo(t)})]}),V("div",{className:"text-xs text-orange-500 mt-0.5",children:s})]})]})},au=()=>{let e=re(f=>f.notifications),o=re(f=>f.clearNotificationUnread),t=re(f=>f.loadGroupNotifications),[a,r]=ht(!1),[s,l]=ht("friend");$d(()=>{o()},[o]);let n=async()=>{r(!0);try{await t()}finally{r(!1)}},d=e.filter(f=>f.type==="friend-request"||f.type==="doubt-buddy"),c=e.filter(f=>f.type==="group-notify"||f.type==="group-dismiss"||f.type==="group-quit"),i=d.filter(f=>f.type==="friend-request"&&!f.data.isDecide||f.type==="doubt-buddy").length,u=c.filter(f=>f.type==="group-notify"&&ti(f.data)).length;return se("div",{className:"flex flex-col h-full",children:[se("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-theme-divider",children:[se("div",{className:"flex items-center gap-1",children:[se("button",{onClick:()=>l("friend"),className:`flex items-center gap-1 px-2.5 py-1.5 text-xs font-medium rounded-md transition-colors ${s==="friend"?"text-pink-600 dark:text-pink-400 bg-pink-50 dark:bg-pink-900/30":"text-theme-muted hover:text-theme hover:bg-theme-item"}`,children:[V(to,{size:13}),"\u597D\u53CB\u7533\u8BF7",i>0&&V("span",{className:"ml-0.5 min-w-[16px] h-[16px] bg-red-500 text-white text-[10px] font-medium rounded-full flex items-center justify-center px-1",children:i})]}),se("button",{onClick:()=>l("group"),className:`flex items-center gap-1 px-2.5 py-1.5 text-xs font-medium rounded-md transition-colors ${s==="group"?"text-pink-600 dark:text-pink-400 bg-pink-50 dark:bg-pink-900/30":"text-theme-muted hover:text-theme hover:bg-theme-item"}`,children:[V(pt,{size:13}),"\u7FA4\u901A\u77E5",u>0&&V("span",{className:"ml-0.5 min-w-[16px] h-[16px] bg-red-500 text-white text-[10px] font-medium rounded-full flex items-center justify-center px-1",children:u})]})]}),V("div",{className:"flex items-center gap-1.5",children:V("button",{onClick:n,disabled:a,className:"text-xs text-pink-500 hover:text-pink-600 disabled:opacity-50",children:a?V(K,{size:14,className:"animate-spin"}):"\u5237\u65B0"})})]}),V("div",{className:"flex-1 min-h-0 overflow-y-auto",children:(s==="friend"?d:c).length===0?V("div",{className:"flex items-center justify-center h-32 text-theme-hint text-sm",children:s==="friend"?"\u6682\u65E0\u597D\u53CB\u7533\u8BF7":"\u6682\u65E0\u7FA4\u901A\u77E5"}):V("div",{className:"divide-y divide-theme-divider",children:s==="friend"?d.map((f,h)=>f.type==="friend-request"?V(Yd,{item:f.data,time:f.time},`fr-${f.data.flag}-${h}`):f.type==="doubt-buddy"?V(eu,{item:f.data,time:f.time},`db-${f.data.flag}-${h}`):null):c.map((f,h)=>f.type==="group-notify"?V(Zd,{item:f.data,time:f.time},`gn-${f.data.flag}-${h}`):f.type==="group-dismiss"||f.type==="group-quit"?V(tu,{type:f.type,data:f.data,time:f.time},`info-${f.type}-${h}`):null)})})]})},ai=au;import{Fragment as si,jsx as te,jsxs as Ce}from"react/jsx-runtime";var su=({activeTab:e,onTabChange:o,friendCategories:t,groups:a,recentChats:r,unreadCounts:s,selectedPeerId:l,onSelectFriend:n,onSelectGroup:d,onSelectRecent:c})=>{let[i,u]=Or(""),{groupAssistantMode:f,enterGroupAssistant:h,exitGroupAssistant:p}=re(),m=re(M=>M.groupLastTimeMap),g=re(M=>M.groupLastMessageMap),L=vt(()=>{if(!i.trim())return t;let M=i.toLowerCase();return t.map(O=>({...O,friends:O.friends.filter(Z=>Z.nickname.toLowerCase().includes(M)||Z.remark.toLowerCase().includes(M)||Z.uin.includes(i))})).filter(O=>O.friends.length>0)},[t,i]),C=vt(()=>Ml(a,i),[a,i]),I=[{id:"recent",icon:Ua,label:"\u6700\u8FD1"},{id:"friends",icon:pt,label:"\u597D\u53CB"},{id:"groups",icon:ua,label:"\u7FA4\u7EC4"}],A=re(M=>M.notificationUnreadCount),[b,F]=Or(!1);return Ce("div",{className:"flex flex-col h-full",children:[Ce("div",{className:"flex items-center border-b border-theme-divider px-2 pt-2",children:[te("div",{className:"flex flex-1",children:I.map(M=>{let O=M.icon,Z=!b&&e===M.id;return Ce("button",{onClick:()=>{F(!1),o(M.id)},className:`flex-1 flex items-center justify-center gap-1.5 py-2.5 text-sm font-medium transition-colors rounded-t-lg ${Z?"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:[te(O,{size:16}),M.label]},M.id)})}),Ce("button",{onClick:()=>F(!b),className:`relative flex items-center justify-center w-9 h-9 rounded-lg transition-colors flex-shrink-0 ${b?"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:[te(Gt,{size:16}),A>0&&te("div",{className:"absolute top-1 right-1 min-w-[14px] h-[14px] bg-red-500 text-white text-[10px] font-medium rounded-full flex items-center justify-center px-0.5",children:A>99?"99+":A})]})]}),b?te("div",{className:"flex-1 min-h-0",children:te(ai,{onClose:()=>F(!1)})}):Ce(si,{children:[(e==="friends"||e==="groups")&&te("div",{className:"p-3",children:Ce("div",{className:"relative",children:[te(Nt,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-theme-hint"}),te("input",{type:"text",value:i,onChange:M=>u(M.target.value),placeholder:e==="friends"?"\u641C\u7D22\u597D\u53CB...":"\u641C\u7D22\u7FA4\u7EC4...",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"})]})}),Ce("div",{className:"flex-1 overflow-y-auto",children:[e==="recent"&&f==="normal"&&te(lu,{items:r,unreadCounts:s,selectedPeerId:l,onSelect:c,onEnterGroupAssistant:h}),e==="recent"&&f==="assistant"&&te(du,{groups:a,recentChats:r,groupLastTimeMap:m,groupLastMessageMap:g,unreadCounts:s,selectedPeerId:l,onSelect:d,onBack:p}),e==="friends"&&te(nu,{categories:L,selectedPeerId:l,onSelect:n}),e==="groups"&&te(oi,{items:C,unreadCounts:s,groupLastTimeMap:m,selectedPeerId:l,onSelect:d})]})]})]})},nu=({categories:e,selectedPeerId:o,onSelect:t})=>{let{expandedCategories:a,toggleCategory:r}=re(),s=vt(()=>new Set(a),[a]),l=vt(()=>e.map(n=>({...n,friends:[...n.friends].sort((d,c)=>{let i=!!(d.topTime&&d.topTime!=="0"),u=!!(c.topTime&&c.topTime!=="0");return i&&!u?-1:!i&&u?1:0})})),[e]);return l.length===0?te("div",{className:"flex items-center justify-center h-32 text-theme-hint text-sm",children:"\u6682\u65E0\u597D\u53CB"}):te("div",{className:"py-1",children:l.map(n=>{let d=s.has(n.categoryId);return Ce("div",{children:[Ce("div",{onClick:()=>r(n.categoryId),className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-theme-item-hover text-theme-secondary",children:[d?te(Ba,{size:14}):te(Ze,{size:14}),te("span",{className:"text-xs font-medium",children:n.categoryName}),Ce("span",{className:"text-xs text-theme-hint",children:[n.onlineCount,"/",n.memberCount]})]}),d&&n.friends.map(c=>te(Zl,{friend:c,isSelected:o===c.uin,onClick:()=>t(c)},c.uid))]},n.categoryId)})})},oi=({items:e,unreadCounts:o,selectedPeerId:t,onSelect:a,groupLastTimeMap:r,subtitleMap:s,showPinnedStyle:l=!1})=>{let n=vt(()=>[...e].sort((c,i)=>{if(c.isTop&&!i.isTop)return-1;if(!c.isTop&&i.isTop)return 1;if(r){let u=r[c.groupCode]||0,f=r[i.groupCode]||0;if(u!==f)return f-u}return 0}),[e,r]);return n.length===0?te("div",{className:"flex items-center justify-center h-32 text-theme-hint text-sm",children:"\u6682\u65E0\u7FA4\u7EC4"}):te("div",{className:"py-1",children:n.map(d=>{let c=o.get(`2_${d.groupCode}`)||0;return te(Yl,{group:d,isSelected:t===d.groupCode,onClick:()=>a(d),showPinnedStyle:l,unreadCount:c,subtitle:s?.[d.groupCode]},d.groupCode)})})},lu=({items:e,unreadCounts:o,selectedPeerId:t,onSelect:a,onEnterGroupAssistant:r})=>{let{togglePinChat:s,removeRecentChat:l,friendCategories:n,groups:d}=re(),[c,i]=Or(null),u=ou(null),f=Bo(c?.x||0,c?.y||0,u),h=vt(()=>{let b=d.filter(M=>M.msgMask===2),F=0;return b.forEach(M=>{let O=o.get(`2_${M.groupCode}`)||0;F+=O}),F},[d,o]),p=vt(()=>d.filter(b=>b.msgMask===2).length,[d]),m=vt(()=>e.filter(b=>b.chatType!==2?!0:d.find(M=>M.groupCode===b.peerId)?.msgMask!==2),[e,d]),g=b=>{if(b.chatType===2){let F=d.find(M=>M.groupCode===b.peerId);if(F?.remarkName&&F.remarkName!==F.groupName)return F.remarkName}else if(b.chatType===1||b.chatType===100)for(let F of n){let M=F.friends.find(O=>O.uin===b.peerId);if(M?.remark&&M.remark!==M.nickname)return M.remark}return b.peerName},L=(b,F)=>{b.preventDefault(),i({x:b.clientX,y:b.clientY,item:F})},C=()=>{i(null)},I=async()=>{if(c){try{await s(c.item.chatType,c.item.peerId)}catch(b){console.error("\u7F6E\u9876\u5931\u8D25:",b),alert(`\u7F6E\u9876\u5931\u8D25: ${b.message||"\u672A\u77E5\u9519\u8BEF"}`)}C()}},A=()=>{c&&(l(c.item.chatType,c.item.peerId),C())};return m.length===0&&p===0?te("div",{className:"flex items-center justify-center h-32 text-theme-hint text-sm",children:"\u6682\u65E0\u6700\u8FD1\u4F1A\u8BDD"}):Ce("div",{className:"py-1",onClick:C,children:[p>0&&Ce("div",{onClick:r,className:"flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors hover:bg-theme-item-hover",children:[Ce("div",{className:"relative flex-shrink-0",children:[te("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-blue-400 to-blue-600 flex items-center justify-center",children:te(ua,{size:20,className:"text-white"})}),h>0&&te("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:h})]}),Ce("div",{className:"flex-1 min-w-0",children:[te("div",{className:"flex items-center justify-between",children:te("span",{className:"text-sm font-medium text-theme",children:"\u7FA4\u52A9\u624B"})}),Ce("div",{className:"text-xs text-theme-hint truncate mt-0.5",children:[p," \u4E2A\u7FA4\u804A"]})]})]}),m.map(b=>te(iu,{item:b,displayName:g(b),unreadCount:o.get(`${b.chatType}_${b.peerId}`)||b.unreadCount,isSelected:t===b.peerId,onClick:()=>a(b),onContextMenu:F=>L(F,b)},`${b.chatType}_${b.peerId}`)),c&&ru(Ce(si,{children:[te("div",{className:"fixed inset-0 z-40",onClick:C,onContextMenu:b=>{b.preventDefault(),C()}}),Ce("div",{ref:u,className:"fixed z-50 bg-popup r-control glass-pop origin-top-left py-1 min-w-[160px]",style:{left:f.left,top:f.top,visibility:f.ready?"visible":"hidden"},onContextMenu:b=>b.preventDefault(),children:[Ce("button",{onClick:I,className:"w-full px-3 py-2 text-left text-sm hover:bg-theme-item-hover flex items-center gap-2 text-theme",children:[te(_t,{size:14,className:"flex-shrink-0"}),te("span",{className:"flex-1",children:c.item.pinned?"\u53D6\u6D88\u7F6E\u9876":"\u7F6E\u9876"})]}),c.item.chatType===2&&te(Er,{groupCode:c.item.peerId,onClose:C}),Ce("button",{onClick:A,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:[te(ze,{size:14,className:"flex-shrink-0"}),te("span",{className:"flex-1",children:"\u5220\u9664"})]})]})]}),document.body)]})},iu=({item:e,displayName:o,unreadCount:t,isSelected:a,onClick:r,onContextMenu:s})=>Ce("div",{onClick:r,onContextMenu:s,className:`flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors ${a?"bg-pink-500/20":e.pinned?"bg-theme-item-hover":"hover:bg-theme-item-hover"}`,children:[Ce("div",{className:"relative flex-shrink-0",children:[te("img",{src:e.peerAvatar,alt:o,className:"w-10 h-10 rounded-full object-cover"}),t>0&&te("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:t})]}),Ce("div",{className:"flex-1 min-w-0",children:[Ce("div",{className:"flex items-center justify-between",children:[te("span",{className:"text-sm font-medium text-theme truncate",children:o}),te("span",{className:"text-xs text-theme-hint flex-shrink-0 ml-2",children:lo(e.lastTime)})]}),te("div",{className:"text-xs text-theme-hint truncate mt-0.5",children:e.lastMessage})]})]}),du=({groups:e,recentChats:o,groupLastTimeMap:t,groupLastMessageMap:a,unreadCounts:r,selectedPeerId:s,onSelect:l,onBack:n})=>{let d=vt(()=>e.filter(i=>i.msgMask===2),[e]),c=vt(()=>{let i={...a};return o.forEach(u=>{u.chatType===2&&u.lastMessage&&(i[u.peerId]=u.lastMessage)}),i},[a,o]);return Ce("div",{className:"py-1",children:[Ce("div",{onClick:n,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:[te(Ze,{size:16,className:"transform rotate-180 text-theme-secondary"}),te("span",{className:"text-sm font-medium text-theme",children:"\u8FD4\u56DE\u6700\u8FD1\u4F1A\u8BDD"})]}),Ce("div",{className:"px-3 py-2 text-xs text-theme-hint",children:["\u7FA4\u52A9\u624B (",d.length,")"]}),d.length===0?te("div",{className:"flex items-center justify-center h-32 text-theme-hint text-sm",children:"\u6682\u65E0\u7FA4\u804A"}):te(oi,{items:d,unreadCounts:r,groupLastTimeMap:t,subtitleMap:c,selectedPeerId:s,onSelect:l,showPinnedStyle:!0})]})},ri=su;import{useState as Ie,useEffect as et,useLayoutEffect as Dc,useRef as De,useCallback as Ae,useMemo as it}from"react";import{createPortal as Ec}from"react-dom";import*as gt from"react";import{flushSync as Su}from"react-dom";function ni(e){return typeof e=="object"?e.key:e}function li(e,o){let t=e.length;return new Proxy(e,{get(a,r,s){if(typeof r=="string"){let l=r.charCodeAt(0);if(l>=48&&l<=57){let n=+r;if(Number.isInteger(n)&&n>=0&&n<t){let d=a[n];if(typeof d!="object"){let c=o[n*2];d=a[n]={index:n,key:d,start:c,size:o[n*2+1],end:c+o[n*2+1],lane:0}}return d}}if(r==="length")return t}return Reflect.get(a,r,s)}})}function ra(e,o,t){let a=t.initialDeps??[],r,s=!0;function l(){var n;let c=0,i=e();if(!(i.length!==a.length||i.some((h,p)=>a[p]!==h)))return r;a=i;let f=0;return r=o(...i),t?.onChange&&!(s&&t.skipInitialOnChange)&&t.onChange(r),s=!1,r}return l.updateDeps=n=>{a=n},l}function zr(e,o){if(e===void 0)throw new Error(`Unexpected undefined${o?`: ${o}`:""}`);return e}var Et=(e,o)=>Math.abs(e-o)<1.01,ii=(e,o,t)=>{let a;return Object.assign(function(...r){e.clearTimeout(a),a=e.setTimeout(()=>o.apply(this,r),t)},{cancel:()=>{e.clearTimeout(a)}})};function di({offset:e,isScrolling:o,elementMax:t,holdOffset:a,scrollOffset:r,pendingWrite:s,clampedMaxAtWrite:l}){var n;return o&&s===null&&e===r?"spurious":s!==null&&Math.abs(e-s.target)<1.5?"readBack":s!==null&&!s.smooth&&t!==null&&s.target>t+a+.5&&Math.abs(e-(t+a))<1.5||s!==null&&!s.smooth&&((n=s.lowMaxes)!=null&&n.some(d=>Math.abs(e-d)<1.5))?"clampedReadBack":l!==null&&Math.abs(e-l)<1.5?"clampedEcho":"external"}var uu=e=>e==="smooth"||e==="smoothFinishing";function ui({kind:e,offset:o,command:t,target:a}){return e!=="spurious"&&e!=="readBack"&&e!=="clampedReadBack"&&t?.index!=null&&t.phase!=="queued"&&!uu(t.phase)&&!Et(o,t.lastTargetOffset)&&!Et(o,a())&&e!=="clampedEcho"}var Hr=40;function ci(e){let o=e[e.length-1];if(o===void 0)return!1;let t=e.length-2;for(;t>=0&&o.t-e[t].t<Hr;)t--;if(t<0)return!1;let a=e[t],r=t-1;for(;r>=0&&a.t-e[r].t<Hr;)r--;if(r<0)return!1;let s=e[r],l=(o.offset-a.offset)/(o.t-a.t),n=(a.offset-s.offset)/(a.t-s.t);return l*n>=0&&Math.abs(l)>=2*Math.abs(n)&&Math.abs(l)-Math.abs(n)>=.8}function fi(e){let o=e[e.length-1];if(o===void 0)return!1;let t=e.length-2;for(;t>=0&&o.t-e[t].t<Hr;)t--;if(t<0)return!1;let a=e[t];return Math.abs(o.offset-a.offset)/(o.t-a.t)>=.05}var uo,co=()=>{if(uo!==void 0)return uo;if(typeof navigator>"u")return uo=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return uo=!0;let e=navigator.maxTouchPoints;return uo=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Gr,cu=()=>Gr!==void 0?Gr:Gr=co()&&typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("overflow-anchor: auto"),mi=()=>!co()||cu();var ma={capture:!0,passive:!0},Oo=class{constructor(o){this.host=o,this._touch=null,this.inMotion=()=>this._touch!==null&&this._touch.phase!=="lateFling",this.dragging=()=>{var t;return((t=this._touch)==null?void 0:t.phase)==="down"&&this._touch.moved},this.tail=()=>{var t;return((t=this._touch)==null?void 0:t.phase)==="tail"?this._touch.moved?"fling":"tap":null},this.onScroll=({isScrolling:t,ownReadBack:a,moved:r,external:s})=>{var l,n,d;return t&&((l=this._touch)==null?void 0:l.phase)==="tail"?this._openTail(this._touch.moved||!a,!1):((n=this._touch)==null?void 0:n.phase)==="lateFling"&&(this.host.now()>this._touch.until?this._touch=null:s&&t&&r&&this._openTail(!0,!1)),!a&&t&&r&&((d=this._touch)==null?void 0:d.phase)==="down"?(this._touch.moved=!0,!0):!1},this.touchStart=()=>{this.end(),this._touch={phase:"down",moved:!1}},this.touchEnd=()=>{var t;let a=((t=this._touch)==null?void 0:t.phase)==="down"&&this._touch.moved;this.end(),this._openTail(a,a)},this.end=()=>{var t;let a=this.host.getWindow();((t=this._touch)==null?void 0:t.phase)==="tail"&&a!=null&&a.clearTimeout(this._touch.timerId),this._touch=null},this.listen=t=>{let a=()=>this.touchStart(),r=()=>this.touchEnd();return t.addEventListener("touchstart",a,ma),t.addEventListener("touchend",r,ma),t.addEventListener("touchcancel",r,ma),()=>{t.removeEventListener("touchstart",a,ma),t.removeEventListener("touchend",r,ma),t.removeEventListener("touchcancel",r,ma),this.end()}},this._openTail=(t,a)=>{let r=this.host.getWindow();if(r==null)return;this.end();let s={phase:"tail",moved:t,awaitingFling:a,timerId:r.setTimeout(()=>{if(this.host.tailStillMoving()){this._openTail(s.moved,s.awaitingFling);return}this._touch=s.awaitingFling?{phase:"lateFling",until:this.host.now()+1e3}:null,this.host.onTailClosed()},150)};this._touch=s}}get touch(){return this._touch}};var pi=e=>{let{clientWidth:o,clientHeight:t}=e;return{width:o,height:t}},xi=e=>{let o=new Set;return{schedule:t=>{let a=e.requestAnimationFrame(()=>{o.delete(a),t()});o.add(a)},cancel:()=>{o.forEach(t=>e.cancelAnimationFrame(t)),o.clear()}}},fu=e=>e,mu=e=>{let o=e.overscan*Math.max(e.lanes??1,1),t=Math.max(e.startIndex-o,0),r=Math.min(e.endIndex+o,e.count-1)-t+1,s=new Array(r);for(let l=0;l<r;l++)s[l]=t+l;return s},Li=(e,o)=>{let t=e.scrollElement;if(!t)return;let a=e.targetWindow;if(!a)return;let r=n=>{let{width:d,height:c}=n;o({width:Math.round(d),height:Math.round(c)})};if(r(pi(t)),!a.ResizeObserver)return()=>{};let s=xi(a),l=new a.ResizeObserver(()=>{let n=()=>{r(pi(t))};e.options.useAnimationFrameWithResizeObserver?s.schedule(n):n()});return l.observe(t,{box:"content-box"}),()=>{l.unobserve(t),s.cancel()}},hi={passive:!0};var pu=typeof window>"u"?!0:"onscrollend"in window,hu=(e,o,t)=>{let a=e.scrollElement;if(!a)return;let r=e.targetWindow;if(!r)return;let s=e.options.useScrollendEvent&&pu,l=0,n=s?null:ii(r,()=>o(t(a),!1),e.options.isScrollingResetDelay),d=u=>()=>{l=t(a),n?.(),o(l,u)},c=d(!0),i=d(!1);return a.addEventListener("scroll",c,hi),s&&a.addEventListener("scrollend",i,hi),()=>{a.removeEventListener("scroll",c),s&&a.removeEventListener("scrollend",i),n?.cancel()}},Ii=(e,o)=>hu(e,o,t=>{let{horizontal:a,isRtl:r}=e.options;return a?t.scrollLeft*(r&&-1||1):t.scrollTop});var gu=(e,o,t)=>{if(t.options.useCachedMeasurements){let a=t.indexFromElement(e),r=t.options.getItemKey(a);return t.itemSizeCache.get(r)??t.options.estimateSize(a)}if(o?.borderBoxSize){let a=o.borderBoxSize[0];if(a)return Math.round(a[t.options.horizontal?"inlineSize":"blockSize"])}if(!o){let a=t.indexFromElement(e),r=t.options.getItemKey(a),s=t.itemSizeCache.get(r);if(s!==void 0)return s}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},xu=(e,{adjustments:o=0,behavior:t},a)=>{var r;let{scrollElement:s,options:l}=a,n=e+o,d=l.horizontal&&l.isRtl&&s!==null&&"ownerDocument"in s;(r=s?.scrollTo)==null||r.call(s,{[l.horizontal?"left":"top"]:d?-n:n,behavior:t})};var Ci=xu,gi=(e,o)=>e==="smooth"?o?"smoothLanded":"smooth":"instant",fo=e=>e?.phase==="smooth"||e?.phase==="smoothLanded";function Lu(e,o,t,a){if(o===0)return!1;let r=a(0),s=new Set,l=0;for(;l<e;){let d=t(l);if(d===r)break;s.add(d),l++}let n=e-l;if(n===0||n>=o)return!1;for(let d=0;d<n;d++)if(a(d)!==t(l+d))return!1;for(let d=n;d<o;d++)if(s.has(a(d)))return!1;return!0}var zo=class{constructor(o){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._iosGesture=new Oo({getWindow:()=>this.targetWindow,now:()=>this.now(),tailStillMoving:()=>{let t=this.scrollState;if(t?.phase!=="queued"||this.pendingWrite!==null)return!1;let a=this._readElementOffset();return a===null||this._lastElementOffset===null||Math.abs(a-this._lastElementOffset)<1?!1:(this._lastElementOffset=a,t.samples=[...t.samples??[],{t:this.now(),offset:a}],!0)},onTailClosed:()=>{let t=this.scrollState;t?.phase==="queued"&&fi(t.samples??[])&&(this.scrollState=null),this._flushHoldIfReady(!0),this._writeAwaitingCommand(),this._retryClampedAdjustment()}}),this._lastElementOffset=null,this.pendingWrite=null,this._clampedAdjustment=null,this.elementsCache=new Map,this._resizeBatch=null,this.now=()=>{var t,a,r;return((r=(a=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:a.now)==null?void 0:r.call(a))??Date.now()},this.observer=(()=>{let t=null,a=null,r=!1,s=!1,l=new Set,n=()=>{if(t)return t;let c=this.targetWindow;if(!c||!c.ResizeObserver)return null;let i=a=xi(c);return t=new c.ResizeObserver(u=>{let f=()=>{let h={sync:!1};this._resizeBatch=h;try{u.forEach(d)}finally{this._resizeBatch=null,h.notify&&(this.notify(h.sync),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment(),this.measureElement(null))}};if(this.options.useAnimationFrameWithResizeObserver)i.schedule(f);else{r=!0;try{f()}finally{r=!1}}})},d=c=>{let i=c.target,u=this.indexFromElement(i);if(!i.isConnected){this.observer.unobserve(i);for(let[f,h]of this.elementsCache)if(h===i){this.elementsCache.delete(f);break}return}this.isIndexInRange(u)&&this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(i,c,this))};return{disconnect:()=>{var c;(c=n())==null||c.disconnect(),a?.cancel(),l.clear(),s=!1,t=null,a=null},observe:c=>{let i=n();if(i){if(!r){i.observe(c,{box:"border-box"});return}l.add(c),s||(s=!0,a?.schedule(()=>{s=!1,l.forEach(u=>{u.isConnected&&t?.observe(u,{box:"border-box"})}),l.clear()}))}},unobserve:c=>{var i;l.delete(c),(i=n())==null||i.unobserve(c)}}})(),this.range=null,this.setOptions=t=>{var a;let r={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:fu,rangeExtractor:mu,onChange:()=>{},measureElement:gu,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(let i in t){let u=t[i];u!==void 0&&(r[i]=u)}let s=this.options,l=null,n=null,d=!1;if(s!==void 0&&s.enabled&&r.enabled&&r.anchorTo==="end"&&this.scrollElement!==null){let i=s.count,u=r.count,f=this.getMeasurements(),h=((a=this._singleLaneMeasurements)==null?void 0:a.items)??f,p=I=>ni(h[I]),m=i>0?p(0):null,g=i>0?p(i-1):null;if(u!==i||i>0&&u>0&&(r.getItemKey(0)!==m||r.getItemKey(u-1)!==g)){d=!0;let I=i>0?this.getVirtualItemForOffset(this.getScrollOffset())??f[0]:null;I&&(l=[I.key,this.getScrollOffset()-I.start]);let A=r.followOnAppend===!0?"auto":r.followOnAppend||null;A&&u>0&&this.isAtEnd(s.scrollEndThreshold)&&(i===0||r.getItemKey(u-1)!==g)&&(u>i||Lu(i,u,p,r.getItemKey))&&(n=A)}}this.options=r,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let c=null;if(l&&this.scrollOffset!==null&&!this._awaitingCommandReadBack()){let[i,u]=l,f=this.getMeasurements(),{count:h,getItemKey:p}=this.options,m=0;for(;m<h&&p(m)!==i;)m++;if(m<h){let g=f[m];if(g){let L=Math.max(0,g.start+u);!n&&L!==this.scrollOffset&&(c=L-this.scrollOffset,this.scrollOffset=L)}}}n?this.pendingScrollAnchor={kind:"follow",behavior:n}:c!==null&&(this._canWriteScroll()?this.pendingScrollAnchor={kind:"anchor",delta:c}:(this._holdOffset+=c,this._followOffsetTarget(c)))},this.notify=t=>{var a,r;(r=(a=this.options).onChange)==null||r.call(a,this,t)},this.maybeNotify=ra(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{var t;this.unsubs.filter(Boolean).forEach(a=>a()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,(t=this._momentumStop)==null||t.restore(),this._momentumStop=null,this.isScrolling=!1,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._clampedAdjustment=null,this.pendingWrite=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;let a=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==a){if(this.cleanup(),!a){this.maybeNotify();return}this.scrollElement=a,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,l)=>{var n,d,c,i;let u=l?this._elementMaxScrollOffset():null,f=this._reportedOverscroll;this._reportedOverscroll=s<0||u!==null&&s>u+1;let h=s;this._lastElementOffset=h,s=this._toLayoutOffset(s);let p=this._classifyScrollEvent(s,l,u);if(p==="spurious")return;p==="readBack"?s=this.pendingWrite.target:p==="clampedReadBack"&&((n=this.scrollState)==null?void 0:n.index)!=null&&s<this.getMaxScrollOffset()-1.5?this.scrollState.lastTargetOffset=s:ui({kind:p,offset:s,command:this.scrollState,target:()=>this.getScrollStateTarget(this.scrollState)})&&(this.scrollState=null),this.pendingWrite=null,this._clampedAdjustment!==null&&Math.abs(s-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null);let m=this.getScrollOffset(),g=this.scrollDirection;this.scrollDirection=l?m===s?this.scrollDirection:m<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=l;let L=this.scrollState;if(L?.phase==="queued"&&p==="external"&&l)if(f||this._reportedOverscroll)L.samples=[];else{let C=this.now();L.samples=[...(L.samples??[]).filter(I=>C-I.t<=200),{t:C,offset:h}],(g!==null&&this.scrollDirection!==g||ci(L.samples))&&(this.scrollState=null)}this._iosGesture.onScroll({isScrolling:l,ownReadBack:p==="readBack",moved:s!==m,external:p==="external"&&((d=this.scrollState)==null?void 0:d.phase)!=="smooth"&&((c=this.scrollState)==null?void 0:c.phase)!=="smoothFinishing"})&&((i=this.scrollState)==null?void 0:i.phase)==="queued"&&(this.scrollState=null),this._flushHoldIfReady(!0),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement&&this.unsubs.push(this._iosGesture.listen(this.scrollElement)),this._scrollToOffset(this.getScrollOffset())}this._noteClampMax();let r=this.pendingScrollAnchor;this.pendingScrollAnchor=null,r&&this.scrollElement&&this.options.enabled&&(r.kind==="anchor"?this._canWriteScroll()?fo(this.scrollState)&&!Et(this.getScrollOffset()-r.delta,this.scrollState.lastTargetOffset)||(this._followOffsetTarget(r.delta),this._scrollToOffset(this.getScrollOffset())):(this._holdOffset+=r.delta,this._followOffsetTarget(r.delta),this.notify(!1)):this.scrollToEnd({behavior:r.behavior})),this._flushHoldIfReady(!1),this._retryClampedAdjustment()},this._classifyScrollEvent=(t,a,r)=>{var s;return di({offset:t,isScrolling:a,elementMax:r,holdOffset:this._holdOffset,scrollOffset:this.scrollOffset,pendingWrite:this.pendingWrite,clampedMaxAtWrite:((s=this._clampedAdjustment)==null?void 0:s.maxAtWrite)??null})},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled||!this._canWriteScroll())return;let{target:t,maxAtWrite:a}=this._clampedAdjustment,r=this.getMaxScrollOffset();r>a+.5&&(this._clampedAdjustment=t>r+.5?{target:t,maxAtWrite:r}:null,this._scrollToOffset(t))},this._writeAwaitingCommand=()=>{let t=this.scrollState;if(t===null||t.phase!=="queued")return;let{behavior:a}=t;this.getMeasurements();let r=this.getScrollStateTarget(t);t.lastTargetOffset=r,this._clampedAdjustment=null,t.phase=gi(a,t.index!=null&&Et(r,this.getScrollOffset())),this._scrollToOffset(r,{behavior:a}),this.scheduleScrollReconcile()},this._readElementOffset=()=>{let t=this.scrollElement;if(t==null)return null;let{horizontal:a,isRtl:r}=this.options;return typeof t.scrollTop=="number"?a?t.scrollLeft*(r&&-1||1):t.scrollTop:typeof t.scrollY=="number"?a?t.scrollX:t.scrollY:null},this._canWriteScroll=()=>!(co()&&this._iosGesture.inMotion())&&!this._reportedOverscroll,this._flushHoldIfReady=t=>{var a;if(this._holdOffset===0||!this.scrollElement||!this.options.enabled||!this._canWriteScroll()||((a=this.scrollState)==null?void 0:a.phase)==="smooth")return;this._holdOffset=0,this.scrollOffset!==null&&this.scrollOffset<0&&(this.scrollOffset=0),this.notify(t);let r=this.getCommandWrittenOffset()??this.getScrollOffset();this._clampedAdjustment=this._clampedBy(r),this._scrollToOffset(r)},this.rafId=null,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.getMeasurementOptions=ra(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,a,r,s,l,n,d,c)=>(this.prevLanes!==void 0&&this.prevLanes!==n&&(this.lanesChangedFlag=!0),this.prevLanes=n,this.pendingMin=null,{count:t,paddingStart:a,scrollMargin:r,getItemKey:s,enabled:l,lanes:n,laneAssignmentMode:d,gap:c}),{key:!1}),this.isIndexInRange=t=>t>=0&&t<this.options.count,this.getMeasurements=ra(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:a,scrollMargin:r,getItemKey:s,enabled:l,lanes:n,laneAssignmentMode:d,gap:c},i)=>{var u;let f=this.itemSizeCache;if(!l)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(let C of this.laneAssignments.keys())C>=t&&this.laneAssignments.delete(C);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(C=>{this.itemSizeCache.set(C.key,C.size)}));let h=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),n===1){let C=t*2,I=(u=this._singleLaneMeasurements)==null?void 0:u.flat;if(!I||I.length<C){let M=new Float64Array(C);I&&h>0&&M.set(I.subarray(0,h*2)),I=M}let A=h===0?new Array(t):this._singleLaneMeasurements.items.slice(),b;if(h===0)b=a+r;else{let M=h-1;b=I[M*2]+I[M*2+1]+c}for(let M=h;M<t;M++){let O=s(M);A[M]=O;let Z=f.get(O),H=typeof Z=="number"?Z:this.options.estimateSize(M);I[M*2]=b,I[M*2+1]=H,b+=H+c}this._singleLaneMeasurements={flat:I,items:A};let F=li(A,I);return this.measurementsCache=F,F}let p=this.measurementsCache.slice(0,h),m=new Array(n).fill(void 0),g=new Float64Array(n),L=0;for(let C=0;C<h;C++){let I=p[C];I&&(m[I.lane]===void 0&&L++,m[I.lane]=C,g[I.lane]=I.end)}for(let C=h;C<t;C++){let I=s(C),A=this.laneAssignments.get(C),b,F,M=d==="estimate"||f.has(I);if(A!==void 0&&this.options.lanes>1){b=A;let W=m[b],le=W!==void 0?p[W]:void 0;F=le?le.end+c:a+r}else if(L===n){let W=0,le=g[0],R=m[0];for(let D=1;D<n;D++){let v=g[D];(v<le||v===le&&m[D]<R)&&(W=D,le=v,R=m[D])}b=W,F=le+c,M&&this.laneAssignments.set(C,b)}else b=C%this.options.lanes,F=a+r,M&&this.laneAssignments.set(C,b);let O=f.get(I),Z=typeof O=="number"?O:this.options.estimateSize(C),H=F+Z;p[C]={index:C,start:F,size:Z,end:H,key:I,lane:b},m[b]===void 0&&L++,m[b]=C,g[b]=H}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ra(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes,this._getLayoutTotalSize()+this.options.scrollMargin],(t,a,r,s,l)=>{if(t.length===0||a===0)return this.range=null,null;let n=Math.max(l-a,0);return this.range=Cu(t,a,Math.min(r,n),s,s===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range},{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ra(()=>{let t=null,a=null,r=this.calculateRange();return r&&(t=r.startIndex,a=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,a]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,a,this.options.lanes]},(t,a,r,s,l,n)=>s===null||l===null?[]:t({startIndex:s,endIndex:l,overscan:a,count:r,lanes:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{let a=this.options.indexAttribute,r=t.getAttribute(a);return r?parseInt(r,10):(console.warn(`Missing attribute name '${a}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var a;if(!fo(this.scrollState))return!0;let r=this.scrollState.index??((a=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:a.index);if(r!==void 0&&this.range){let s=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,r-s),n=Math.min(this.options.count-1,r+s);return t>=l&&t<=n}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((l,n)=>{l.isConnected||(this.observer.unobserve(l),this.elementsCache.delete(n))});return}let a=this.indexFromElement(t);if(!this.isIndexInRange(a))return;let r=this.options.getItemKey(a),s=this.elementsCache.get(r);s!==t&&(s&&this.observer.unobserve(s),this.observer.observe(t),this.elementsCache.set(r,t)),t.isConnected&&(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(a)&&this.resizeItem(a,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,a)=>{var r,s,l;if(!this.isIndexInRange(t))return;(r=this._resizeBatch)!=null&&r.sync&&this.getMeasurements();let n,d,c,i=(s=this._singleLaneMeasurements)==null?void 0:s.flat;if(this.options.lanes===1&&i!=null)c=this.options.getItemKey(t),d=i[t*2],n=i[t*2+1];else{let h=this.measurementsCache[t];if(!h)return;c=h.key,d=h.start,n=h.size}let u=this.itemSizeCache.get(c)??n,f=a-u;if(f!==0){let h=this.options.anchorTo==="end"&&!fo(this.scrollState)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,p=h?this._getLayoutTotalSize():0,m=this.getScrollOffset(),L=!this.itemSizeCache.has(c)?d<m:d+u<=m&&this.scrollDirection!=="backward",C=!fo(this.scrollState)&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:c,start:d,size:n,end:d+n,lane:0},f,this):L);(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(c,a),this.itemSizeCacheVersion++;let I=!1;if(this._awaitingCommandReadBack()||(h?I=this.applyScrollAdjustment(this._getLayoutTotalSize()-p):C&&(I=this.applyScrollAdjustment(f))),this._resizeBatch){this._resizeBatch.notify=!0,(l=this._resizeBatch).sync||(l.sync=I);return}this.notify(I),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment()}},this.getVirtualItems=ra(()=>[this.getVirtualIndexes(),this.getMeasurements(),this._holdOffset],(t,a,r)=>{let s=[];for(let l=0,n=t.length;l<n;l++){let d=t[l],c=a[d];s.push(r===0?c:{...c,start:c.start-r,end:c.end-r})}return s},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{var a;let r=this.getMeasurements();if(r.length===0)return;let s=(a=this._singleLaneMeasurements)==null?void 0:a.flat,l=this.options.lanes===1&&s!=null,n=Si(0,r.length-1,l?d=>s[d*2]:d=>zr(r[d]).start,t);return zr(r[n])},this._noteClampMax=()=>{if(!this._awaitingCommandReadBack())return;let t=this._elementMaxScrollOffset();if(t===null)return;let a=this.pendingWrite,r=Math.max(t,0)+this._holdOffset;if(r>=a.target)return;let s=a.lowMaxes??(a.lowMaxes=[]);s[s.length-1]!==r&&s.push(r)},this.getMaxScrollOffset=()=>(this._elementMaxScrollOffset()??0)+this._holdOffset,this._toLayoutOffset=t=>{var a;let r=t+this._holdOffset;return((a=this.pendingScrollAnchor)==null?void 0:a.kind)==="anchor"&&(r+=this.pendingScrollAnchor.delta),r},this._elementMaxScrollOffset=()=>{let t=this.scrollElement;if(t===null)return null;if("scrollHeight"in t)return this.options.horizontal?t.scrollWidth-t.clientWidth:t.scrollHeight-t.clientHeight;if("document"in t){let a=t.document.documentElement;return this.options.horizontal?a.scrollWidth-t.innerWidth:a.scrollHeight-t.innerHeight}return null},this._momentumStop=null,this._stopMomentum=t=>{let a=this.scrollElement,r=this.targetWindow;if(a===null||r===null)return;let s="document"in a?a.document.scrollingElement:a;if(!s?.style)return;if(this._momentumStop){this._momentumStop.done=t;return}let{style:l}=s,n=this.options.horizontal?"overflow-x":"overflow-y",d=l.getPropertyValue(n),c=l.getPropertyPriority(n),i=()=>this.options.horizontal?s.clientHeight:s.clientWidth,u=i();if(l.setProperty(n,"hidden","important"),i()!==u){l.setProperty(n,d,c);return}let f={restore:()=>l.getPropertyValue(n)!=="hidden"||l.getPropertyPriority(n)!=="important"?!1:(l.setProperty(n,d,c),!0),done:t};this._momentumStop=f,r.requestAnimationFrame(()=>r.requestAnimationFrame(()=>{this._momentumStop===f&&(this._momentumStop=null,f.restore()&&f.done())}))},this._clampedBy=t=>{let a=this._elementMaxScrollOffset();if(a===null)return null;let r=a+this._holdOffset;return t>r+.5?{target:t,maxAtWrite:r}:null},this.getVirtualDistanceFromEnd=()=>Math.max(this._getLayoutTotalSize()+this.options.scrollMargin-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,a,r=0)=>{if(!this.scrollElement)return 0;let s=this.getSize(),l=this.getScrollOffset();a==="auto"&&(a=t>=l+s?"end":"start"),a==="center"?t+=(r-s)/2:a==="end"&&(t-=s);let n=this.getMaxScrollOffset();return Math.max(Math.min(n,t),0)},this.getOffsetForIndex=(t,a="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));let r=this.getSize(),s=this.getScrollOffset(),l=this.getMeasurements()[t];if(!l)return;if(a==="auto")if(l.end>=s+r-this.options.scrollPaddingEnd)a="end";else if(l.start<=s+this.options.scrollPaddingStart)a="start";else return[s,a];if(a==="end"&&t===this.options.count-1){let d=this.getMaxScrollOffset(),c=d-this.options.paddingEnd+this.options.scrollPaddingEnd;return[Math.max(Math.min(c,d),0),a]}let n=a==="end"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(n,a,l.size),a]},this.scrollToOffset=(t,{align:a="start",behavior:r="auto"}={})=>{this._startScroll({index:null,align:a},this.getOffsetForAlignment(t,a),r,"absolute")},this.scrollToIndex=(t,{align:a="auto",behavior:r="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));let s=this.getOffsetForIndex(t,a);if(!s)return;let[l,n]=s;this._startScroll({index:t,align:n},l,r,"absolute")},this.scrollBy=(t,{behavior:a="auto"}={})=>{let r=this.getOffsetForAlignment((this.getCommandWrittenOffset()??this.getScrollOffset())+t,"start");this._startScroll({index:null,align:"start"},r,a,"relative")},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this._startScroll({index:this.options.count-1,align:"end",toEnd:!0},Math.max(this.getMaxScrollOffset(),0),t,"absolute");return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.cancelScroll=()=>{this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null},this.getTotalSize=()=>Math.max(this._getLayoutTotalSize()-this._holdOffset,0),this._getLayoutTotalSize=()=>{var t,a;let r=this.getMeasurements(),s;if(r.length===0)s=this.options.paddingStart;else if(this.options.lanes===1){let l=r.length-1,n=(t=this._singleLaneMeasurements)==null?void 0:t.flat;n!=null?s=n[l*2]+n[l*2+1]:s=((a=r[l])==null?void 0:a.end)??0}else{let l=Array(this.options.lanes).fill(null),n=r.length-1;for(;n>=0&&l.some(d=>d===null);){let d=r[n];l[d.lane]===null&&(l[d.lane]=d.end),n--}s=Math.max(...l.filter(d=>d!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let t=[];if(this.itemSizeCache.size===0)return t;let a=this.getMeasurements();for(let r of a)r&&this.itemSizeCache.has(r.key)&&t.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return t},this._scrollToOffset=(t,{adjustments:a,behavior:r}={})=>{let s={target:t+(a??0),smooth:r==="smooth"};return this.pendingWrite=s,this.options.scrollToFn(t-this._holdOffset,{behavior:r,adjustments:a},this),s},this.getCommandWrittenOffset=()=>this.scrollState!==null&&this.pendingWrite!==null&&!this.pendingWrite.smooth?this.pendingWrite.target:null,this._awaitingCommandReadBack=()=>{let t=this.getCommandWrittenOffset();return!(co()&&this._iosGesture.dragging())&&t!==null&&!Et(t,this.getScrollOffset())},this._followOffsetTarget=t=>{this.scrollState!==null&&this.scrollState.index==null&&(this.scrollState.lastTargetOffset+=t)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(o)}get scrollAdjustments(){return 0}applyScrollAdjustment(o,t){if(o===0)return!1;if(this._followOffsetTarget(o),this._canWriteScroll()){let a=this.getScrollOffset();this._clampedAdjustment=this._clampedBy(a+o);let r=this._scrollToOffset(a,{adjustments:o,behavior:t});return this.scrollOffset!==null&&(this.pendingWrite===r&&(this.scrollOffset+=o),this.scrollOffset<0&&(this.scrollOffset=0)),!0}else return this._holdOffset+=o,this.scrollOffset!==null&&(this.scrollOffset+=o),!0}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}getScrollStateTarget(o){let t=o.toEnd?[Math.max(this.getMaxScrollOffset(),0)]:o.index!=null?this.getOffsetForIndex(o.index,o.align):void 0;return t?t[0]:o.lastTargetOffset}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}if(this.scrollState.phase==="queued"){this.scheduleScrollReconcile();return}this.getMeasurements();let a=this.getScrollStateTarget(this.scrollState),r=this.scrollState.index==null?1:this.options.useAnimationFrameWithResizeObserver?3:2,s=a!==this.scrollState.lastTargetOffset;if(!s&&Et(a,this.getScrollOffset())){if(this.scrollState.phase==="smooth"?this.scrollState.phase="smoothLanded":this.scrollState.phase==="smoothFinishing"&&(this.scrollState.phase="instant"),this.scrollState.stableFrames++,this.scrollState.stableFrames>=r){this.getScrollOffset()!==a&&this._scrollToOffset(a,{behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,s){let l=this.getSize()||600,n=Math.abs(a-this.getScrollOffset()),d=fo(this.scrollState)&&n>l;this.scrollState.lastTargetOffset=a,d?this.scrollState.phase="smooth":this.scrollState.phase==="smooth"?this.scrollState.phase="smoothFinishing":this.scrollState.phase==="smoothLanded"&&(this.scrollState.phase="instant"),this._scrollToOffset(a,{behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}_startScroll(o,t,a,r){this.pendingScrollAnchor=null,this._clampedAdjustment=null;let s=this._iosGesture.tail();if(r==="absolute"&&s!==null){if(s==="fling"&&mi()){this._stopMomentum(()=>{let l=this.scrollState;l?.phase!=="queued"||this._iosGesture.tail()!=="fling"||this._reportedOverscroll||(this._iosGesture.end(),this._flushHoldIfReady(!0),this._writeAwaitingCommand())}),this.scrollState={...o,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,phase:"queued",behavior:a,samples:[]},this.scheduleScrollReconcile();return}this._iosGesture.end()}this.scrollState={...o,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,behavior:a,phase:gi(a,o.index!=null&&Et(t,this.getScrollOffset()))},this._scrollToOffset(t,{behavior:a}),this.scheduleScrollReconcile()}},Si=(e,o,t,a)=>{for(;e<=o;){let r=(e+o)/2|0,s=t(r);if(s<a)e=r+1;else if(s>a)o=r-1;else return r}return e>0?e-1:0};function Iu(e,o,t){let a=0;for(;a<=o;){let r=(a+o)/2|0,s=e[r*2];if(s<t)a=r+1;else if(s>t)o=r-1;else return r}return a>0?a-1:0}function Cu(e,o,t,a,r){let s=e.length-1;if(e.length<=a)return{startIndex:0,endIndex:s};if(a===1&&r!==null){let c=Iu(r,s,t),i=c,u=t+o;for(;i<s&&r[i*2]+r[i*2+1]<u;)i++;return{startIndex:c,endIndex:i}}let n=Si(0,s,c=>e[c].start,t),d=n;if(a===1)for(;d<s&&e[d].end<t+o;)d++;else if(a>1){let c=Array(a).fill(0);for(;d<s&&c.some(u=>u<t+o);){let u=e[d];c[u.lane]=u.end,d++}let i=Array(a).fill(t+o);for(;n>=0&&i.some(u=>u>=t);){let u=e[n];i[u.lane]=u.start,n--}n=Math.max(0,n-n%a),d=Math.min(s,d+(a-1-d%a))}return{startIndex:n,endIndex:d}}var _r=typeof document<"u"?gt.useLayoutEffect:gt.useEffect;function bu({useFlushSync:e=!0,directDomUpdates:o=!1,directDomUpdatesMode:t="transform",...a}){let r=gt.useReducer(f=>f+1,0)[1],s=gt.useRef({enabled:o,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});s.current.enabled=o,s.current.mode=t;let l=gt.useRef(!1),n=f=>{let h=s.current;if(!h.enabled||!h.container)return;let p=f.getTotalSize();if(p!==h.lastSize){h.lastSize=p;let m=f.options.horizontal?"width":"height";h.container.style[m]=`${p}px`}},d=(f,h,p)=>{let m=s.current,g=!!f.options.horizontal,L=h.start-f.options.scrollMargin;m.lastPositions.get(p)!==L&&(m.lastPositions.set(p,L),m.mode==="transform"?p.style.transform=g?`translate3d(${L}px, 0, 0)`:`translate3d(0, ${L}px, 0)`:p.style[g?"left":"top"]=`${L}px`)},c=f=>{let h=s.current;if(!(!h.enabled||!h.container)){n(f);for(let p of f.getVirtualItems()){let m=f.elementsCache.get(p.key);m&&d(f,p,m)}}},i={...a,onChange:(f,h)=>{var p;let m=s.current,g=!0;if(m.enabled){c(f);let L=f.range,C=m.prevRange;g=!C||C.isScrolling!==f.isScrolling||C.startIndex!==L?.startIndex||C.endIndex!==L?.endIndex,g&&(m.prevRange=L?{startIndex:L.startIndex,endIndex:L.endIndex,isScrolling:f.isScrolling}:null)}g&&(e&&h&&!l.current?Su(r):r()),(p=a.onChange)==null||p.call(a,f,h)}},[u]=gt.useState(()=>{let f=new zo(i),h=f.measureElement;return f.measureElement=p=>{l.current=!0;try{h(p)}finally{l.current=!1}let m=s.current;if(p!==null&&m.enabled&&m.container){let g=f.measurementsCache[f.indexFromElement(p)];g&&d(f,g,p)}},Object.assign(f,{containerRef:p=>{let m=s.current;m.container=p,m.lastSize=null,p!==null&&c(f)}})});return u.setOptions(i),_r(()=>u._didMount(),[]),_r(()=>(n(u),u._willUpdate())),_r(()=>{c(u)}),u}function Ho(e){return bu({observeElementRect:Li,observeElementOffset:Ii,scrollToFn:Ci,...e})}import{Slot as qc}from"@luckylillia-dev/plugin-sdk/webui";var bi="current-uin";function pa(){return localStorage.getItem(bi)||""}function vi(e){localStorage.setItem(bi,e)}var vu="webqq-messages",yu="webqq-messages-",wu=1,ha="messages",ki=100,sa=null,yi="";function ku(e){return`${yu}${e||"anon"}`}var wi=!1;function Mu(){if(!wi){wi=!0;try{indexedDB.deleteDatabase(vu)}catch{}}}function Mi(){Mu();let e=pa();if(sa&&yi!==e){try{sa.close()}catch{}sa=null}return sa?Promise.resolve(sa):new Promise((o,t)=>{let a=indexedDB.open(ku(e),wu);a.onerror=()=>t(a.error),a.onsuccess=()=>{sa=a.result,yi=e,o(sa)},a.onupgradeneeded=r=>{let s=r.target.result;s.objectStoreNames.contains(ha)||s.createObjectStore(ha,{keyPath:"chatKey"})}})}async function ga(e,o){try{let t=await Mi(),a=`${e}_${o}`;return new Promise(r=>{let n=t.transaction(ha,"readonly").objectStore(ha).get(a);n.onsuccess=()=>{let d=n.result;d&&d.messages?r(d.messages):r(null)},n.onerror=()=>r(null)})}catch{return null}}async function Wt(e,o,t){try{let a=await Mi(),r=`${e}_${o}`,s=t.slice(-ki);return new Promise((l,n)=>{let i=a.transaction(ha,"readwrite").objectStore(ha).put({chatKey:r,messages:s,timestamp:Date.now()});i.onsuccess=()=>l(),i.onerror=()=>n(i.error)})}catch(a){console.error("Failed to cache messages:",a)}}async function Go(e,o,t){try{let a=await ga(e,o);if(a){let r=[...a.slice(-(ki-1)),t];await Wt(e,o,r)}}catch(a){console.error("Failed to append message:",a)}}async function Pi(e,o,t){try{let a=await ga(e,o);if(a){let r=a.filter(s=>s.msgId!==t);await Wt(e,o,r)}}catch(a){console.error("Failed to remove message:",a)}}async function _o(e,o,t,a,r,s=!1){try{let l=await ga(e,o);if(!l)return;let n=l.map(d=>{if(String(d.msgSeq)!==String(t))return d;let c=d.emojiLikesList||[];if(r){let i=c.findIndex(u=>u.emojiId===a);if(i>=0){let u=[...c];return u[i]={...u[i],likesCnt:String(parseInt(u[i].likesCnt)+1),isClicked:u[i].isClicked||s},{...d,emojiLikesList:u}}else return{...d,emojiLikesList:[...c,{emojiId:a,emojiType:parseInt(a)>999?"2":"1",likesCnt:"1",isClicked:s}]}}else{let i=c.findIndex(u=>u.emojiId===a);if(i>=0){let u=[...c],f=parseInt(u[i].likesCnt)-1;return f<=0?u.splice(i,1):u[i]={...u[i],likesCnt:String(f),isClicked:s?!1:u[i].isClicked},{...d,emojiLikesList:u}}}return d});await Wt(e,o,n)}catch(l){console.error("Failed to update emoji reaction:",l)}}async function Ai(e,o,t,a){try{let r=await ga(e,o);if(!r)return!1;let s=!1,l=r.map(n=>n.msgId===t||a&&String(n.msgSeq)===String(a)?(s=!0,{...n,recallTime:String(Math.floor(Date.now()/1e3))}):n);return s&&await Wt(e,o,l),s}catch(r){return console.error("Failed to mark message as recalled:",r),!1}}import{useState as jr,useEffect as Pu,useRef as Au}from"react";import{createPortal as Ru}from"react-dom";import{Fragment as nt,jsx as ae,jsxs as he}from"react/jsx-runtime";var Tu=({level:e})=>{let o=e%4,t=Math.floor(e/4)%4,a=Math.floor(e/16)%4,r=Math.floor(e/64)%4,s=Math.floor(e/256),l=[];for(let n=0;n<s;n++)l.push(ae("span",{className:"text-amber-400 text-xs font-bold",title:"\u91D1\u4F01\u9E45",children:"\u{1F427}"},`penguin-${n}`));for(let n=0;n<r;n++)l.push(ae(ct,{size:14,className:"text-amber-500"},`crown-${n}`));for(let n=0;n<a;n++)l.push(ae(Za,{size:14,className:"text-orange-400"},`sun-${n}`));for(let n=0;n<t;n++)l.push(ae(Wa,{size:14,className:"text-blue-400"},`moon-${n}`));for(let n=0;n<o;n++)l.push(ae(oa,{size:14,className:"text-yellow-400 fill-yellow-400"},`star-${n}`));return ae("div",{className:"flex items-center gap-0.5 flex-wrap",children:l})},mo=({profile:e,loading:o,position:t,onClose:a,isFriend:r,onFriendDeleted:s})=>{let l=Au(null),[n,d]=jr({left:t.x,top:t.y}),[c,i]=jr(!1),[u,f]=jr(!1);if(Pu(()=>{if(!l.current)return;let I=320,A=l.current.offsetHeight||400,b=t.x,F=t.y;b+I>window.innerWidth-20&&(b=window.innerWidth-I-20),b<20&&(b=20),F+A>window.innerHeight-20&&(F=window.innerHeight-A-20),F<20&&(F=20),d({left:b,top:F})},[t,e,o]),!e&&!o)return null;let h=I=>I===1?"\u7537":I===2?"\u5973":"",p=I=>{if(!I)return"";let A=new Date(I*1e3),b=new Date,F=b.getFullYear()-A.getFullYear(),M=b.getMonth()-A.getMonth(),O=F+(M<0?-1:0);if(O<1){let Z=F*12+M;return Z>0?`${Z}\u4E2A\u6708`:"\u4E0D\u8DB31\u4E2A\u6708"}return`${O}\u5E74`},m=I=>I==="owner"?"\u7FA4\u4E3B":I==="admin"?"\u7BA1\u7406\u5458":"",g=I=>I==="owner"?"bg-amber-500 text-white":I==="admin"?"bg-green-500 text-white":"",L=async()=>{if(e){f(!0);try{await Tl(e.uid),T("\u5DF2\u5220\u9664\u597D\u53CB","success"),s?.(e.uid),a()}catch(I){T(I.message||"\u5220\u9664\u597D\u53CB\u5931\u8D25","error")}finally{f(!1),i(!1)}}},C=I=>I?new Date(I*1e3).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"";return Ru(he(nt,{children:[ae("div",{className:"fixed inset-0 z-40",onClick:a}),he("div",{ref:l,className:"fixed z-50 r-card overflow-hidden bg-popup glass-pop origin-top-left",style:{left:n.left,top:n.top,width:320,maxHeight:"calc(100vh - 40px)"},onClick:I=>I.stopPropagation(),children:[o?ae("div",{className:"flex items-center justify-center h-40",children:ae(K,{size:24,className:"animate-spin text-pink-500"})}):e&&he(nt,{children:[he("div",{className:"bg-gradient-to-r from-pink-400 to-amber-300 p-4 relative",children:[r&&!e.groupRole&&ae("button",{onClick:()=>i(!0),className:"absolute top-2 right-2 p-1.5 rounded-full bg-white/20 hover:bg-white/40 text-white transition-colors",title:"\u5220\u9664\u597D\u53CB",children:ae(ze,{size:16})}),he("div",{className:"flex items-start gap-4",children:[ae("img",{src:e.avatar,alt:e.nickname,className:"w-16 h-16 rounded-full border-3 border-white/80 object-cover flex-shrink-0"}),he("div",{className:"flex-1 min-w-0 text-white pt-1",children:[he("div",{className:"flex items-center gap-2 mb-1",children:[ae("span",{className:"font-bold text-lg truncate",children:e.nickname}),e.groupRole&&m(e.groupRole)&&ae("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${g(e.groupRole)}`,children:m(e.groupRole)})]}),e.remark&&e.remark!==e.nickname&&he("div",{className:"text-white/80 text-sm truncate mb-1",children:["\u5907\u6CE8: ",e.remark]}),ae("div",{className:"text-white/90 text-sm",children:e.uin}),e.qid&&he("div",{className:"text-white/70 text-xs mt-0.5",children:["QID: ",e.qid]})]})]})]}),he("div",{className:"p-4 overflow-y-auto",style:{maxHeight:"calc(100vh - 40px - 120px)"},children:[e.signature&&ae("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}),he("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[h(e.sex)&&he(nt,{children:[ae("span",{className:"text-theme-hint",children:"\u6027\u522B"}),ae("span",{className:"text-theme",children:h(e.sex)})]}),e.birthday&&e.birthday!=="0-0-0"&&he(nt,{children:[ae("span",{className:"text-theme-hint",children:"\u751F\u65E5"}),ae("span",{className:"text-theme",children:e.birthday})]}),p(e.regTime)&&he(nt,{children:[ae("span",{className:"text-theme-hint",children:"Q\u9F84"}),ae("span",{className:"text-theme",children:p(e.regTime)})]}),e.level>0&&he(nt,{children:[ae("span",{className:"text-theme-hint",children:"\u7B49\u7EA7"}),he("div",{className:"flex items-center gap-2",children:[he("span",{className:"text-theme",children:["Lv.",e.level]}),ae(Tu,{level:e.level})]})]})]}),!!(e.groupCard||e.groupTitle||e.groupLevel||e.joinTime||e.lastSpeakTime)&&he(nt,{children:[ae("div",{className:"border-t border-theme-divider my-3"}),ae("div",{className:"text-xs text-theme-hint mb-2",children:"\u7FA4\u4FE1\u606F"}),he("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.groupCard&&he(nt,{children:[ae("span",{className:"text-theme-hint",children:"\u7FA4\u540D\u7247"}),ae("span",{className:"text-theme truncate",children:e.groupCard})]}),e.groupTitle&&he(nt,{children:[ae("span",{className:"text-theme-hint",children:"\u7FA4\u5934\u8854"}),ae("span",{className:"text-pink-500",children:e.groupTitle})]}),e.groupLevel!==void 0&&e.groupLevel>0&&he(nt,{children:[ae("span",{className:"text-theme-hint",children:"\u7FA4\u7B49\u7EA7"}),he("span",{className:"text-theme",children:["Lv.",e.groupLevel]})]}),!!e.joinTime&&he(nt,{children:[ae("span",{className:"text-theme-hint",children:"\u5165\u7FA4\u65F6\u95F4"}),ae("span",{className:"text-theme",children:C(e.joinTime)})]}),!!e.lastSpeakTime&&he(nt,{children:[ae("span",{className:"text-theme-hint",children:"\u6700\u540E\u53D1\u8A00"}),ae("span",{className:"text-theme",children:C(e.lastSpeakTime)})]})]})]})]})]}),c&&e&&ae("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center rounded-xl",children:he("div",{className:"bg-popup m-4 p-4 rounded-lg shadow-lg max-w-[280px]",children:[he("div",{className:"flex items-center justify-between mb-3",children:[ae("span",{className:"font-medium text-theme",children:"\u5220\u9664\u597D\u53CB"}),ae("button",{onClick:()=>i(!1),className:"text-theme-muted hover:text-theme",children:ae(we,{size:18})})]}),he("p",{className:"text-sm text-theme-secondary mb-4",children:["\u786E\u5B9A\u8981\u5220\u9664\u597D\u53CB ",ae("span",{className:"font-medium text-theme",children:e.remark||e.nickname})," \u5417\uFF1F\u5220\u9664\u540E\u5C06\u65E0\u6CD5\u6062\u590D\u3002"]}),he("div",{className:"flex gap-2 justify-end",children:[ae("button",{onClick:()=>i(!1),className:"px-3 py-1.5 text-sm rounded-lg bg-theme-item hover:bg-theme-hover text-theme transition-colors",disabled:u,children:"\u53D6\u6D88"}),he("button",{onClick:L,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:u,children:[u&&ae(K,{size:14,className:"animate-spin"}),"\u5220\u9664"]})]})]})})]})]}),document.body)};import{useState as Ri,useEffect as Nu,useRef as Fu}from"react";import{createPortal as Du}from"react-dom";import{Fragment as qt,jsx as Le,jsxs as Me}from"react/jsx-runtime";var Wr=({profile:e,loading:o,position:t,onClose:a,onQuitGroup:r})=>{let s=Fu(null),[l,n]=Ri({left:t.x,top:t.y}),[d,c]=Ri(!1),i=Ft(),u=e?.ownerUin===i;if(Nu(()=>{if(!s.current)return;let m=320,g=s.current.offsetHeight||300,L=t.x,C=t.y;L+m>window.innerWidth-20&&(L=window.innerWidth-m-20),L<20&&(L=20),C+g>window.innerHeight-20&&(C=window.innerHeight-g-20),C<20&&(C=20),n({left:L,top:C})},[t,e,o]),!e&&!o)return null;let f=m=>m?new Date(m*1e3).toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}):"",h=()=>{c(!0)},p=()=>{e&&r&&r(e.groupCode,u),c(!1),a()};return Du(Me(qt,{children:[Le("div",{className:"fixed inset-0 z-40",onClick:a}),Le("div",{ref:s,className:"fixed z-50 r-card overflow-hidden bg-popup glass-pop origin-top-left",style:{left:l.left,top:l.top,width:320,maxHeight:"calc(100vh - 40px)"},onClick:m=>m.stopPropagation(),children:o?Le("div",{className:"flex items-center justify-center h-40",children:Le(K,{size:24,className:"animate-spin text-pink-500"})}):e&&Me(qt,{children:[Me("div",{className:"bg-gradient-to-r from-blue-400 to-cyan-300 p-4 relative",children:[r&&Le("button",{onClick:h,className:"absolute top-3 right-3 p-1.5 rounded-full bg-white/20 hover:bg-white/30 text-white transition-colors",title:u?"\u89E3\u6563\u8BE5\u7FA4":"\u9000\u51FA\u8BE5\u7FA4",children:Le(ea,{size:16})}),Me("div",{className:"flex items-start gap-4",children:[Le("img",{src:e.avatar,alt:e.groupName,className:"w-16 h-16 rounded-lg border-3 border-white/80 object-cover flex-shrink-0"}),Me("div",{className:"flex-1 min-w-0 text-white pt-1 pr-6",children:[Le("div",{className:"font-bold text-lg truncate mb-1",children:e.groupName}),e.remarkName&&e.remarkName!==e.groupName&&Me("div",{className:"text-white/80 text-sm truncate mb-1",children:["\u5907\u6CE8: ",e.remarkName]}),Le("div",{className:"text-white/90 text-sm",children:e.groupCode})]})]})]}),Me("div",{className:"p-4 overflow-y-auto",style:{maxHeight:"calc(100vh - 40px - 140px)"},children:[Me("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[Me("span",{className:"text-theme-hint flex items-center gap-1",children:[Le(pt,{size:14}),"\u6210\u5458"]}),Me("span",{className:"text-theme",children:[e.memberCount,e.maxMemberCount?` / ${e.maxMemberCount}`:""]}),e.ownerName&&Me(qt,{children:[Me("span",{className:"text-theme-hint flex items-center gap-1",children:[Le(ct,{size:14}),"\u7FA4\u4E3B"]}),Le("span",{className:"text-theme truncate",children:e.ownerName})]}),e.createTime&&Me(qt,{children:[Me("span",{className:"text-theme-hint flex items-center gap-1",children:[Le(qa,{size:14}),"\u521B\u5EFA"]}),Le("span",{className:"text-theme",children:f(e.createTime)})]})]}),e.description&&Me(qt,{children:[Le("div",{className:"border-t border-theme-divider my-3"}),Le("div",{className:"text-xs text-theme-hint mb-2",children:"\u7FA4\u7B80\u4ECB"}),Le("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&&Me(qt,{children:[Le("div",{className:"border-t border-theme-divider my-3"}),Me("div",{className:"text-xs text-theme-hint mb-2 flex items-center gap-1",children:[Le(ft,{size:12}),"\u7FA4\u516C\u544A"]}),Le("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})]})]})]})}),d&&e&&Me(qt,{children:[Le("div",{className:"fixed inset-0 z-[60] bg-black/50",onClick:()=>c(!1)}),Me("div",{className:"fixed z-[70] top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 glass glass-thick r-panel glass-pop p-6 min-w-[320px]",children:[Le("h3",{className:"text-lg font-medium text-theme mb-4",children:u?"\u786E\u8BA4\u89E3\u6563\u7FA4\u804A":"\u786E\u8BA4\u9000\u51FA\u7FA4\u804A"}),Le("p",{className:"text-theme-secondary mb-6",children:u?Me(qt,{children:["\u786E\u5B9A\u8981\u89E3\u6563\u7FA4 ",Le("span",{className:"font-medium text-theme",children:e.groupName})," \u5417\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\uFF0C\u6240\u6709\u7FA4\u6210\u5458\u5C06\u88AB\u79FB\u51FA\u3002"]}):Me(qt,{children:["\u786E\u5B9A\u8981\u9000\u51FA\u7FA4 ",Le("span",{className:"font-medium text-theme",children:e.groupName})," \u5417\uFF1F"]})}),Me("div",{className:"flex justify-end gap-3",children:[Le("button",{onClick:()=>c(!1),className:"px-4 py-2 text-sm text-theme-secondary hover:bg-theme-item rounded-lg transition-colors",children:"\u53D6\u6D88"}),Le("button",{onClick:p,className:"px-4 py-2 text-sm bg-red-500 hover:bg-red-600 text-white rounded-lg transition-colors",children:u?"\u786E\u8BA4\u89E3\u6563":"\u786E\u8BA4\u9000\u51FA"})]})]})]})]}),document.body)};import{useState as Vr,useEffect as Eu}from"react";import{createPortal as Ti}from"react-dom";import{jsx as yt,jsxs as $r}from"react/jsx-runtime";var Xr=({url:e,onClose:o})=>e?Ti($r("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-black/80",onClick:o,children:[yt("button",{onClick:async a=>{a.stopPropagation();try{let r=new URL(e,location.origin).pathname.split("/").pop()||"image";await Fo(e,r)}catch(r){T(r.message||"\u4E0B\u8F7D\u5931\u8D25","error")}},title:"\u4E0B\u8F7D\u56FE\u7247",className:"absolute top-4 right-16 p-2 text-white/80 hover:text-white bg-black/50 rounded-full",children:yt(Tt,{size:24})}),yt("button",{onClick:o,className:"absolute top-4 right-4 p-2 text-white/80 hover:text-white bg-black/50 rounded-full",children:yt(we,{size:24})}),yt("img",{src:e,alt:"\u9884\u89C8",className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:a=>a.stopPropagation()})]}),document.body):null,Kr=({videoInfo:e,onClose:o})=>{let[t,a]=Vr(null),[r,s]=Vr(!1),[l,n]=Vr(null);return Eu(()=>{if(!e){a(null),n(null);return}s(!0),n(null),rl(e.fileUuid,e.isGroup).then(a).catch(d=>n(d.message||"\u83B7\u53D6\u89C6\u9891\u5931\u8D25")).finally(()=>s(!1))},[e]),e?Ti($r("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-black/80",onClick:o,children:[yt("button",{onClick:o,className:"absolute top-4 right-4 p-2 text-white/80 hover:text-white bg-black/50 rounded-full z-10",children:yt(we,{size:24})}),r&&$r("div",{className:"text-white flex items-center gap-2",children:[yt(K,{size:24,className:"animate-spin"}),"\u52A0\u8F7D\u4E2D..."]}),l&&yt("div",{className:"text-red-400",children:l}),t&&!r&&yt("video",{src:t,controls:!0,autoPlay:!0,className:"max-w-[90vw] max-h-[90vh]",onClick:d=>d.stopPropagation()})]}),document.body):null};import wt,{useState as Xe,useEffect as Jr,memo as Zr,useRef as Qr}from"react";import{createPortal as Uu}from"react-dom";import{Slot as Ou}from"@luckylillia-dev/plugin-sdk/webui";var Ni=new WeakMap;function jo(e){let o=Ni.get(e);return o||(o={msgId:e.msgId,msgSeq:String(e.msgSeq),chatType:Number(e.chatType),peerId:String(e.peerUin),senderUin:String(e.senderUin),senderName:e.sendMemberName||e.sendNickName||String(e.senderUin),time:Number(e.msgTime),text:(e.elements??[]).map(t=>t.textElement?.content??"").join(""),self:e.senderUid===st()},Ni.set(e,o)),o}var qu=600*1e3,Bu=30*1e3,Bt=Do((e,o)=>({privateRkey:"",groupRkey:"",fetchedAt:0,loading:!1,ensureRkey:()=>{let{fetchedAt:t,loading:a}=o();a||t&&Date.now()-t<qu||o().refresh()},refresh:async()=>{let{loading:t,fetchedAt:a}=o();if(!t&&!(a&&Date.now()-a<Bu)){e({loading:!0});try{let r=await Jn();e({privateRkey:r.private_rkey||"",groupRkey:r.group_rkey||"",fetchedAt:Date.now(),loading:!1})}catch{e({loading:!1})}}}}));import{Fragment as Vo,jsx as U,jsxs as be}from"react/jsx-runtime";var po=wt.createContext(null),Wo=wt.createContext(null),Yr=wt.createContext(null),es=wt.createContext(null),ts=(e,o)=>{if(!e)return"";if(e.startsWith("blob:"))return e;if(e.includes("qpic.cn")||e.includes("multimedia.nt.qq.com.cn")){if(e.includes("rkey="))return e;try{let t=new URL(e).searchParams.get("appid");if(t==="1406"&&o?.privateRkey)return e+o.privateRkey;if(t==="1407"&&o?.groupRkey)return e+o.groupRkey}catch{}return e}return e},ho=Zr(({element:e,message:o})=>U(Ou,{name:"webqq.message.element",match:String(e.elementType),props:{element:e,message:o&&jo(o)},children:U(zu,{element:e,message:o})})),zu=Zr(({element:e,message:o})=>{let[t,a]=Xe(!1),[r,s]=Xe(!1),[l,n]=Xe(!1),[d,c]=Xe(!1),i=wt.useContext(po),u=wt.useContext(Wo),f=wt.useContext(Yr),h=Bt(m=>m.privateRkey),p=Bt(m=>m.groupRkey);if(Jr(()=>{e.picElement&&Bt.getState().ensureRkey()},[e]),e.textElement)return U("span",{className:"whitespace-pre-wrap break-all",style:{overflowWrap:"anywhere",wordBreak:"break-all"},children:e.textElement.content});if(e.picElement){let m=e.picElement,g=m.originImageUrl?m.originImageUrl.startsWith("http")?m.originImageUrl:`https://gchat.qpic.cn${m.originImageUrl}`:"",L=ts(g,{privateRkey:h,groupRkey:p}),C=200,I=300,A=m.picWidth||200,b=m.picHeight||200;return b>C&&(A=A*C/b,b=C),A>I&&(b=b*I/A,A=I),be("div",{className:"relative rounded-lg overflow-hidden bg-theme-item cursor-pointer",style:{width:A,height:b},onClick:()=>i?.showPreview(L),onContextMenu:M=>{o&&(M.preventDefault(),M.stopPropagation(),f?.showMenu(M,o,e.elementId))},children:[!t&&!r&&U("div",{className:"absolute inset-0 flex items-center justify-center text-theme-hint",children:U(K,{size:24,className:"animate-spin"})}),r&&U("div",{className:"absolute inset-0 flex items-center justify-center text-theme-hint text-xs",children:"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25"}),U("img",{src:L,alt:"\u56FE\u7247",loading:"lazy",referrerPolicy:"no-referrer",className:`w-full h-full object-cover transition-opacity ${t?"opacity-100":"opacity-0"}`,onLoad:()=>a(!0),onError:()=>{s(!0),Bt.getState().refresh()}})]})}if(e.faceElement){let m=e.faceElement.faceIndex,g=e.faceElement.faceText;return U("img",{src:`/face/${m}.png`,alt:g||`[\u8868\u60C5${m}]`,title:g||`\u8868\u60C5${m}`,className:"inline-block align-text-bottom",style:{width:24,height:24},onError:L=>{let C=L.target;C.style.display="none";let I=document.createElement("span");I.textContent=g||`[\u8868\u60C5${m}]`,C.parentNode?.insertBefore(I,C)}})}if(e.fileElement){let m=e.fileElement,g=o?.chatType===2,L=g?{fileId:m.fileUuid,folderId:m.folderId}:void 0,C=o&&!g&&m.fileUuid?{fileId:m.fileUuid,peerUid:o.peerUid,isSelfSend:o.senderUid===st()}:void 0;return U(Hu,{fileName:m.fileName,fileSize:m.fileSize,groupFile:L,privateFile:C})}if(e.pttElement)return U(_u,{element:e,message:o});if(e.videoElement){let m=e.videoElement,g=200,L=300,C=m.thumbWidth||200,I=m.thumbHeight||150;I>g&&(C=C*g/I,I=g),C>L&&(I=I*L/C,C=L);let A="";if(m.thumbPath){let H;m.thumbPath instanceof Map?H=m.thumbPath.values().next().value:typeof m.thumbPath=="object"&&(H=Object.values(m.thumbPath)[0]),H&&(A=St().authUrl(`/api/webqq/file-proxy?path=${encodeURIComponent(H)}`))}let b=m.fileTime||0,F=Math.floor(b/60),M=b%60,O=`${F}:${M.toString().padStart(2,"0")}`;return be("div",{className:"relative rounded-lg overflow-hidden bg-theme-item cursor-pointer group",style:{width:C,height:I},onClick:()=>{m.fileUuid&&u?.showPreview(m.fileUuid,o?.chatType===2)},children:[U("div",{className:"absolute inset-0 fill-quiet"}),A?be(Vo,{children:[!l&&!d&&U("div",{className:"absolute inset-0 flex items-center justify-center text-theme-hint",children:U(K,{size:24,className:"animate-spin"})}),U("img",{src:A,alt:"\u89C6\u9891\u7F29\u7565\u56FE",loading:"lazy",className:`absolute inset-0 w-full h-full object-cover transition-opacity ${l?"opacity-100":"opacity-0"}`,onLoad:()=>n(!0),onError:()=>c(!0)})]}):U("div",{className:"absolute inset-0 flex items-center justify-center text-theme-hint text-xs",children:"\u89C6\u9891"}),U("div",{className:"absolute inset-0 flex items-center justify-center",children:U("div",{className:"w-12 h-12 rounded-full bg-black/50 flex items-center justify-center group-hover:bg-black/70 transition-colors",children:U("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"}})})}),U("div",{className:"absolute bottom-1 right-1 px-1.5 py-0.5 bg-black/60 rounded text-white text-xs",children:O})]})}if(e.grayTipElement){let m=e.grayTipElement;if(m.jsonGrayTipElement?.jsonStr)try{let g=JSON.parse(m.jsonGrayTipElement.jsonStr);if(g.items){let L=g.items.map(C=>C.txt||"").join("");return U("span",{className:"text-theme-hint text-xs",children:L||"[\u6233\u4E00\u6233]"})}}catch{}return U("span",{className:"text-theme-hint text-xs",children:"[\u7CFB\u7EDF\u63D0\u793A]"})}if(e.multiForwardMsgElement)return U($u,{element:e});if(e.arkElement){try{let m=JSON.parse(e.arkElement.bytesData);if(m.app==="com.tencent.multimsg"&&m.meta?.detail?.resid)return U(Xu,{arkData:m})}catch{}return U("span",{children:"[\u5361\u7247\u6D88\u606F]"})}if(e.marketFaceElement){let{emojiId:m,faceName:g,supportSize:L}=e.marketFaceElement,{width:C=200,height:I=200}=L?.[0]??{},b=`https://gxh.vip.qq.com/club/item/parcel/item/${m.substring(0,2)}/${m}/raw${Math.min(C,300)}.gif`;return U("img",{src:b,alt:g||"[\u8868\u60C5\u5305]",title:g,className:"inline-block align-text-bottom rounded",style:{maxWidth:Math.min(C,200),maxHeight:Math.min(I,200)},onError:F=>{let M=F.target;M.style.display="none";let O=document.createElement("span");O.textContent=`[${g||"\u8868\u60C5\u5305"}]`,M.parentNode?.insertBefore(O,M)}})}return null}),Hu=Zr(({fileName:e,fileSize:o,groupFile:t,privateFile:a})=>{let r=Gu(o),s=wt.useContext(es),[l,n]=Xe(!1),d=!!t&&!!s,c=!!a,i=d||c;return be("div",{className:`flex items-center gap-3 px-3 py-2.5 rounded-lg bg-white/5 dark:bg-white/5 border border-white/10 min-w-[220px] max-w-[280px]${i?" cursor-pointer hover:bg-white/10 transition-colors":""}`,onClick:i?async()=>{if(d){s.open(t);return}if(c&&!l){n(!0);try{let f=await Ll(a.peerUid,a.fileId,a.isSelfSend);window.open(f,"_blank")}catch(f){T(f.message||"\u4E0B\u8F7D\u5931\u8D25","error")}finally{n(!1)}}}:void 0,title:d?"\u5728\u7FA4\u6587\u4EF6\u4E2D\u67E5\u770B":c?"\u70B9\u51FB\u4E0B\u8F7D":void 0,children:[be("div",{className:"flex-1 min-w-0",children:[U("div",{className:"text-sm font-medium leading-snug line-clamp-2 break-all",children:e}),r&&U("div",{className:"text-xs opacity-60 mt-1",children:r})]}),U("div",{className:"flex-shrink-0 w-10 h-10 rounded bg-white/10 flex items-center justify-center",children:l?U(K,{className:"w-5 h-5 opacity-70 animate-spin"}):U(Zt,{className:"w-5 h-5 opacity-70"})})]})});function Gu(e){if(!e||e<=0)return"";let o=["B","KB","MB","GB","TB"],t=0,a=e;for(;a>=1024&&t<o.length-1;)a/=1024,t++;return`${a.toFixed(a>=100||t===0?0:a>=10?1:2)} ${o[t]}`}var as=e=>!!(e.textElement||e.picElement||e.fileElement||e.pttElement||e.videoElement||e.faceElement||e.grayTipElement||e.arkElement||e.marketFaceElement||e.multiForwardMsgElement),os=e=>!e.elements||e.elements.length===0?!1:e.elements.every(o=>o.grayTipElement||o.replyElement),_u=({element:e,message:o})=>{let[t,a]=Xe(null),[r,s]=Xe(!1),[l,n]=Xe(!1),[d,c]=Xe(!1),[i,u]=Xe(!1),f=Qr(null),h=Qr(null),p=Qr(null);Jr(()=>()=>{p.current?.abort(),f.current&&(f.current.onended=null,f.current.onerror=null,f.current.onloadeddata=null,f.current.pause(),f.current.src=""),h.current&&URL.revokeObjectURL(h.current)},[]);let m=e.pttElement,g=m.duration||0,L=Math.floor(g/60),C=g%60,I=L>0?`${L}:${C.toString().padStart(2,"0")}`:`${C}"`,A=m.text,b=80,M=Math.min(200,Math.max(b,b+g*3)),O=async()=>{if(!o||!m.fileUuid&&!m.filePath||i)return;if(d&&f.current){f.current.pause(),c(!1);return}if(f.current&&f.current.readyState>=2){try{if(await f.current.play(),p.current?.signal.aborted)return;c(!0)}catch{if(p.current?.signal.aborted)return;c(!1),T("\u8BED\u97F3\u64AD\u653E\u5931\u8D25\uFF0C\u8BF7\u518D\u6B21\u70B9\u51FB\u64AD\u653E","error")}return}u(!0);let H=new AbortController;p.current=H;try{let W=o.chatType===2,le=await hl(m.fileUuid||"",W,m.filePath,H.signal);if(H.signal.aborted)return;f.current&&(f.current.onended=null,f.current.onerror=null,f.current.onloadeddata=null,f.current.pause(),f.current.src=""),h.current&&URL.revokeObjectURL(h.current);let R=URL.createObjectURL(le);h.current=R;let D=new Audio;f.current=D,D.onended=()=>c(!1),D.onerror=()=>{c(!1),u(!1),T("\u8BED\u97F3\u65E0\u6CD5\u64AD\u653E\uFF0C\u8BF7\u91CD\u8BD5","error")},D.onloadeddata=async()=>{u(!1);try{if(await D.play(),H.signal.aborted)return;c(!0)}catch{if(H.signal.aborted)return;c(!1),T("\u8BED\u97F3\u64AD\u653E\u5931\u8D25\uFF0C\u8BF7\u518D\u6B21\u70B9\u51FB\u64AD\u653E","error")}},D.src=R}catch(W){if(H.signal.aborted)return;T(W instanceof Error?W.message:"\u83B7\u53D6\u8BED\u97F3\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5","error"),c(!1),u(!1)}},Z=async()=>{if(!(!o||r||t!==null)){s(!0),n(!1);try{let H=await ul(o.msgId,o.chatType,o.peerUid,e);a(H||"(\u65E0\u6CD5\u8BC6\u522B)")}catch(H){console.error("\u8BED\u97F3\u8F6C\u6587\u5B57\u5931\u8D25:",H),n(!0),a("\u8F6C\u6362\u5931\u8D25")}finally{s(!1)}}};return be("div",{className:"flex flex-col gap-1",children:[be("div",{className:"flex items-center gap-2",children:[be("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:M},onClick:O,title:"\u70B9\u51FB\u64AD\u653E",children:[i?U(K,{size:16,className:"text-green-600 dark:text-green-400 flex-shrink-0 animate-spin"}):d?U($a,{size:16,className:"text-green-600 dark:text-green-400 flex-shrink-0"}):U(Xa,{size:16,className:"text-green-600 dark:text-green-400 flex-shrink-0"}),U("div",{className:"flex-1 flex items-center gap-0.5",children:[1,2,3,4,5].map(H=>U("div",{className:`w-0.5 bg-green-400 dark:bg-green-500 rounded-full transition-all ${d?"animate-pulse":""}`,style:{height:`${8+Math.random()*8}px`}},H))}),U("span",{className:"text-xs text-green-700 dark:text-green-300 flex-shrink-0",children:I})]}),!A&&t===null&&U("button",{onClick:Z,disabled:r,className:"w-6 h-6 flex items-center justify-center rounded-full fill-quiet fill-quiet-hover 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:"\u8BED\u97F3\u8F6C\u6587\u5B57",children:r?U(K,{size:12,className:"animate-spin"}):"\u6587"})]}),(A||t)&&U("div",{className:`text-sm px-3 py-1.5 fill-quiet r-control max-w-[250px] ${l?"text-red-500":"text-theme-secondary"}`,children:A||t})]})},ju=({segment:e})=>{let o=wt.useContext(po),t=Bt(r=>r.privateRkey),a=Bt(r=>r.groupRkey);if(Jr(()=>{e.type==="image"&&Bt.getState().ensureRkey()},[e]),e.type==="text"&&e.data.text)return U("span",{className:"whitespace-pre-wrap break-all",style:{overflowWrap:"anywhere"},children:e.data.text});if(e.type==="image"&&e.data.url){let r=ts(e.data.url,{privateRkey:t,groupRkey:a});return U("img",{src:r,alt:"\u56FE\u7247",loading:"lazy",referrerPolicy:"no-referrer",className:"max-w-[200px] max-h-[150px] rounded-lg cursor-pointer object-cover",onClick:()=>o?.showPreview(r),onError:()=>Bt.getState().refresh()})}return e.type==="face"&&e.data.faceId!==void 0?U("img",{src:`/face/${e.data.faceId}.png`,alt:`[\u8868\u60C5${e.data.faceId}]`,className:"inline-block align-text-bottom",style:{width:24,height:24},onError:r=>{let s=r.target;s.style.display="none";let l=document.createElement("span");l.textContent=`[\u8868\u60C5${e.data.faceId}]`,s.parentNode?.insertBefore(l,s)}}):e.type==="forward"&&e.data.resId?U(Wu,{resId:e.data.resId,title:e.data.title||"[\u804A\u5929\u8BB0\u5F55]"}):null},Wu=({resId:e,title:o})=>{let[t,a]=Xe(!1);return be(Vo,{children:[be("div",{className:"flex items-center gap-2 px-3 py-2 fill-quiet r-control cursor-pointer fill-quiet-hover transition-colors",onClick:()=>a(!0),children:[U("span",{className:"text-sm text-theme-secondary",children:o}),U(Ze,{size:14,className:"text-theme-hint flex-shrink-0"})]}),t&&U(rs,{resId:e,title:o,onClose:()=>a(!1)})]})};function Vu(e){let o=e.match(/<title[^>]*color="#000000"[^>]*>(.*?)<\/title>/)?.[1]||"[\u804A\u5929\u8BB0\u5F55]",a=e.match(/<title[^>]*color="#777777"[^>]*>(.*?)<\/title>/g)?.map(s=>s.replace(/<[^>]+>/g,""))||[],r=e.match(/<summary[^>]*>(.*?)<\/summary>/)?.[1]||"";return{title:o,previews:a,summary:r}}var $u=({element:e})=>{let[o,t]=Xe(!1),a=e.multiForwardMsgElement,{title:r,previews:s,summary:l}=Vu(a.xmlContent);return be(Vo,{children:[be("div",{className:"w-[240px] fill-quiet r-control overflow-hidden cursor-pointer fill-quiet-hover transition-colors border border-theme-divider",onClick:()=>t(!0),children:[be("div",{className:"px-3 pt-2.5 pb-1",children:[U("div",{className:"text-sm font-medium text-theme mb-1.5",children:r}),s.map((n,d)=>U("div",{className:"text-xs text-theme-secondary truncate leading-5",children:n},d))]}),be("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-theme-divider",children:[U("span",{className:"text-xs text-theme-hint",children:l}),U(Ze,{size:12,className:"text-theme-hint"})]})]}),o&&U(rs,{resId:a.resId,title:r,onClose:()=>t(!1)})]})},Xu=({arkData:e})=>{let[o,t]=Xe(!1),a=e.meta?.detail||{},r=a.source||"[\u804A\u5929\u8BB0\u5F55]",s=(a.news||[]).map(d=>d.text||""),l=a.summary||"",n=a.resid||"";return be(Vo,{children:[be("div",{className:"w-[240px] fill-quiet r-control overflow-hidden cursor-pointer fill-quiet-hover transition-colors border border-theme-divider",onClick:()=>t(!0),children:[be("div",{className:"px-3 pt-2.5 pb-1",children:[U("div",{className:"text-sm font-medium text-theme mb-1.5",children:r}),s.map((d,c)=>U("div",{className:"text-xs text-theme-secondary truncate leading-5",children:d},c))]}),be("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-theme-divider",children:[U("span",{className:"text-xs text-theme-hint",children:l}),U(Ze,{size:12,className:"text-theme-hint"})]})]}),o&&U(rs,{resId:n,title:r,onClose:()=>t(!1)})]})},rs=({resId:e,title:o,onClose:t})=>{let[a,r]=Xe([]),[s,l]=Xe(!0),[n,d]=Xe(null);wt.useEffect(()=>{let i=!1;return(async()=>{try{l(!0),d(null);let f=await kl(e);i||r(f)}catch(f){i||d(f.message||"\u52A0\u8F7D\u5931\u8D25")}finally{i||l(!1)}})(),()=>{i=!0}},[e]);let c=i=>i?new Date(i*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):"";return Uu(U("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center scrim",onClick:t,children:be("div",{className:"glass glass-thick r-window glass-pop w-[90vw] max-w-[480px] max-h-[80vh] flex flex-col overflow-hidden",onClick:i=>i.stopPropagation(),children:[be("div",{className:"flex items-center justify-between px-4 py-3 border-b border-theme-divider flex-shrink-0",children:[U("span",{className:"font-medium text-theme",children:o}),U("button",{onClick:t,className:"p-1 rounded-full fill-quiet-hover transition-colors",children:U(we,{size:18,className:"text-theme-hint"})})]}),be("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:[s&&U("div",{className:"flex items-center justify-center py-8",children:U(K,{size:24,className:"animate-spin text-pink-500"})}),n&&U("div",{className:"text-center py-8 text-red-500 text-sm",children:n}),!s&&!n&&a.length===0&&U("div",{className:"text-center py-8 text-theme-hint text-sm",children:"\u6682\u65E0\u6D88\u606F"}),!s&&!n&&a.map((i,u)=>be("div",{className:"flex gap-2",children:[U("img",{src:Be(i.senderUin),alt:i.senderName,className:"w-7 h-7 rounded-full object-cover flex-shrink-0 mt-0.5"}),be("div",{className:"flex-1 min-w-0",children:[be("div",{className:"flex items-center gap-2 mb-0.5",children:[U("span",{className:"text-xs font-medium text-theme-secondary",children:i.senderName}),U("span",{className:"text-xs text-theme-hint",children:c(i.time)})]}),be("div",{className:"text-sm text-theme break-words",children:[i.segments.map((f,h)=>U(ju,{segment:f},h)),i.segments.length===0&&U("span",{className:"text-theme-hint",children:"[\u4E0D\u652F\u6301\u7684\u6D88\u606F\u7C7B\u578B]"})]})]})]},u))]})]})}),document.body)};import Ye,{useState as Fi,useEffect as Ku,memo as $o}from"react";import{Slot as Qu,useSlotMatches as Ju}from"@luckylillia-dev/plugin-sdk/webui";import{jsx as oe,jsxs as Je}from"react/jsx-runtime";var Xo=Ye.createContext(null),ss=Ye.createContext(null),ns=Ye.createContext(null),Ko=Ye.createContext(null),Qo=Ye.createContext(null),Jo=Ye.createContext(null),Zo=Ye.createContext(null),Zu=e=>{for(let o of e.elements)if(o.grayTipElement?.jsonGrayTipElement?.jsonStr)try{let t=JSON.parse(o.grayTipElement.jsonGrayTipElement.jsonStr);if(t.items){let a=t.items.some(r=>r.type==="qq"&&r.uid);return{items:t.items,hasUid:a}}}catch{}return null},na=new Map,Yu=$o(({message:e,groupCode:o})=>{let t=na.get(e.msgId),[a,r]=Fi(t??"[\u7CFB\u7EDF\u63D0\u793A]"),s=st();return Ku(()=>{if(na.has(e.msgId)){r(na.get(e.msgId));return}let l=Zu(e);if(!l){for(let i of e.elements)if(i.grayTipElement?.xmlElement?.content){let u=i.grayTipElement.xmlElement.content.replace(/<[^>]+>/g,"");na.set(e.msgId,u),r(u);return}na.set(e.msgId,"[\u7CFB\u7EDF\u63D0\u793A]"),r("[\u7CFB\u7EDF\u63D0\u793A]");return}let{items:n,hasUid:d}=l;if(!d){let u=n.map(f=>f.txt||"").join("")||"[\u7CFB\u7EDF\u63D0\u793A]";na.set(e.msgId,u),r(u);return}(async()=>{let i=[],u=0;for(let h of n)if(h.type==="qq"&&h.uid)if(h.uid===s)i.push(oe("span",{className:"text-blue-500",children:"\u4F60"},u++));else{let p=await dl(h.uid,o);i.push(oe("span",{className:"text-blue-500",children:p},u++))}else h.type==="nor"&&h.txt&&i.push(oe("span",{children:h.txt},u++));let f=i.length>0?i:"[\u7CFB\u7EDF\u63D0\u793A]";na.set(e.msgId,f),r(f)})()},[e.msgId,s,o]),oe("div",{className:"flex justify-center py-2",children:oe("span",{className:"text-xs text-theme-hint bg-theme-item/50 px-3 py-1 rounded-full",children:a})})}),ls=$o(({message:e,allMessages:o,isHighlighted:t})=>{if(os(e)){let v=e.chatType===2?String(e.peerUin):void 0;return oe(Yu,{message:e,groupCode:v})}let a=st(),r=a?e.senderUid===a:!1,s=Ye.useContext(Xo),l=Ye.useContext(Ko),n=Ye.useContext(Qo),d=Ye.useContext(Jo),c=Ye.useContext(Zo),i=Ye.useContext(ss),u=Ju("webqq.message.element"),f=e.sendMemberName||e.sendNickName||String(e.senderUin);if(e.chatType===1&&!r&&c){let v=c.getFriend(String(e.senderUin));v&&(f=v.remark||v.nickname||f)}let h=Be(e.senderUin),p=Number(e.msgTime)*1e3,m,g,L;if(e.chatType===2){let v=e.msgAttrs;if(v){let E=(w=>{if(v instanceof Map)return v.get(w);if(typeof v=="object")return v[w.toString()]})(2);E?.groupHonor&&(m=E.groupHonor.level,g=E.groupHonor.uniqueTitle||void 0)}if(d){let E=d.getMembers(String(e.peerUin))?.find(w=>w.uid===e.senderUid||w.uin===String(e.senderUin));E&&(L=E.role,m===void 0&&E.level&&(m=E.level),!g&&E.specialTitle&&(g=E.specialTitle))}}if(!e.elements||!Array.isArray(e.elements))return null;let C=e.recallTime&&e.recallTime!=="0",I=e.elements.find(v=>v.replyElement)?.replyElement,A=e.elements.filter(v=>!v.replyElement);if(!(A.some(v=>as(v)||u.includes(String(v.elementType)))||I))return null;let F=A.length===1&&A[0].pttElement&&!I,M=I?.replayMsgSeq??I?.replyMsgSeq,O=I?o.find(v=>v.msgId===I.replayMsgId||String(v.msgSeq)===String(M)):null,Z=v=>{i?.enabled||(v.preventDefault(),v.stopPropagation(),s?.showMenu(v,e))},H=v=>{v.preventDefault(),v.stopPropagation(),l?.showMenu(v,{senderUid:e.senderUid,senderUin:String(e.senderUin),senderName:f,chatType:e.chatType,groupCode:e.chatType===2?String(e.peerUin):void 0})},W=v=>{("ontouchstart"in window||navigator.maxTouchPoints>0)&&(v.preventDefault(),v.stopPropagation(),l?.showMenu(v,{senderUid:e.senderUid,senderUin:String(e.senderUin),senderName:f,chatType:e.chatType,groupCode:e.chatType===2?String(e.peerUin):void 0}))},le=()=>{I&&n?.scrollToMessage(I.replayMsgId,M===void 0?void 0:String(M))},R=Je("div",{className:`flex gap-2 w-full ${r?"flex-row-reverse":""} ${t?"animate-pulse fill-selected r-control -mx-2 px-2":""}`,children:[oe("img",{src:h,alt:f,loading:"lazy",className:"w-8 h-8 rounded-full object-cover flex-shrink-0 cursor-pointer hover:opacity-80 transition-opacity",onClick:W,onContextMenu:H}),Je("div",{className:`flex flex-col ${r?"items-end":"items-start"} max-w-[calc(100%-48px)] md:max-w-[70%] min-w-0 overflow-hidden`,children:[Je("div",{className:`flex items-center gap-1.5 mb-1 ${r?"flex-row-reverse":""}`,children:[oe("span",{className:"text-xs text-theme-hint",children:f}),m!==void 0&&m>0&&Je("span",{className:"text-xs px-1 py-0.5 fill-quiet text-theme-secondary r-inner",children:["Lv.",m]}),L==="owner"&&oe("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:g||"\u7FA4\u4E3B"}),L==="admin"&&oe("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:g||"\u7BA1\u7406\u5458"}),L==="member"&&g&&oe("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:g})]}),oe(Qu,{name:"webqq.message.bubble",props:{message:jo(e)},children:F?Je("div",{onContextMenu:Z,className:C?"opacity-50":"",children:[A.map((v,B)=>oe(ho,{element:v,message:e},B)),C&&oe("div",{className:"text-xs text-theme-muted italic mt-1",children:"\u5DF2\u64A4\u56DE"})]}):Je("div",{className:"relative",children:[Je("div",{className:`rounded-[18px] px-4 py-2 min-w-[80px] max-w-full break-words overflow-hidden bg-theme-item text-theme ${C?"opacity-50":""}`,onContextMenu:Z,children:[I&&oe("div",{className:"text-xs mb-2 pb-2 border-b border-theme-divider cursor-pointer hover:opacity-80 transition-opacity",onClick:le,children:oe("div",{className:"bg-theme-input rounded px-2 py-1",children:O?Je("div",{className:"space-y-1",children:[Je("div",{className:"font-medium text-theme-secondary",children:[O.sendMemberName||O.sendNickName||O.senderUin,":"]}),oe("div",{className:"text-theme-muted",children:O.elements?.filter(v=>!v.replyElement).map((v,B)=>oe(ho,{element:v},B))})]}):oe("span",{className:"text-theme-muted",children:I.sourceMsgText||"[\u6D88\u606F]"})})}),A.map((v,B)=>oe(ho,{element:v,message:e},B))]}),C&&oe("div",{className:"text-xs text-theme-muted italic mt-1",children:"\u5DF2\u64A4\u56DE"})]})}),oe(tc,{message:e,isSelf:r}),oe("span",{className:"text-xs text-theme-hint mt-1",children:lo(p)})]})]});if(!i?.enabled)return R;let D=i.isSelected(e.msgId);return Je("div",{onClick:()=>i.toggle(e.msgId),className:`flex items-center gap-2 cursor-pointer rounded-lg -mx-2 px-2 py-1 transition-colors ${D?"fill-selected":"hover:bg-theme-item-hover"}`,children:[oe("input",{type:"checkbox",checked:D,readOnly:!0,className:"w-4 h-4 flex-shrink-0 accent-pink-500 pointer-events-none"}),oe("div",{className:"flex-1 min-w-0 pointer-events-none",children:R})]})});function ec(e,o){return o==="2"?`/face/emoji-${parseInt(e).toString(16)}.png`:`/face/${e}.png`}var tc=$o(({message:e,isSelf:o})=>{let[t,a]=Fi(null),r=Ye.useContext(ns);if(!e.emojiLikesList||e.emojiLikesList.length===0)return null;let s=async(l,n)=>{if(!t){a(l);try{await so(e.chatType,String(e.peerUin),e.msgSeq,l,!n),r?.onSelfReact(e.msgSeq,l,!n,String(e.peerUin))}catch(d){T(d.message||"\u64CD\u4F5C\u5931\u8D25","error")}finally{a(null)}}};return oe("div",{className:`flex flex-wrap gap-1 mt-1 ${o?"justify-end":"justify-start"}`,children:e.emojiLikesList.map((l,n)=>{let d=ec(l.emojiId,l.emojiType);return Je("button",{onClick:()=>s(l.emojiId,l.isClicked),disabled:t===l.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 ${l.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"} ${t===l.emojiId?"opacity-50":""}`,title:l.isClicked?"\u70B9\u51FB\u53D6\u6D88":"\u70B9\u51FB\u8DDF\u8D34",children:[oe("img",{src:d,alt:`\u8868\u60C5${l.emojiId}`,className:"w-4 h-4",onError:c=>{if(l.emojiType==="2"){let i=c.target,u=String.fromCodePoint(parseInt(l.emojiId));i.style.display="none",i.insertAdjacentHTML("afterend",`<span class="text-sm">${u}</span>`)}}}),oe("span",{className:"text-theme-secondary",children:l.likesCnt})]},`${l.emojiId}-${n}`)})})}),is=$o(({message:e,onRetry:o})=>{let t=Ft(),a=t?Be(t):"";return Je("div",{className:"flex gap-2 flex-row-reverse w-full",children:[a&&oe("img",{src:a,alt:"\u6211",loading:"lazy",className:"w-8 h-8 rounded-full object-cover flex-shrink-0"}),Je("div",{className:"flex flex-col items-end max-w-[calc(100%-48px)] md:max-w-[70%] min-w-0 overflow-hidden",children:[oe("span",{className:"text-xs text-theme-hint mb-1",children:"\u6211"}),Je("div",{className:"flex items-end gap-1",children:[e.status==="failed"&&oe("button",{onClick:o,className:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/30 rounded",title:"\u91CD\u65B0\u53D1\u9001",children:oe(ta,{size:14})}),oe("div",{className:"rounded-[18px] px-4 py-2 bg-theme-item text-theme min-w-[80px] max-w-full break-words overflow-hidden",children:e.items.map((r,s)=>r.type==="text"&&r.content?oe("span",{className:"whitespace-pre-wrap break-words",children:r.content},s):r.type==="face"&&r.faceId!==void 0?oe("img",{src:`/face/${r.faceId}.png`,alt:`[\u8868\u60C5${r.faceId}]`,className:"inline-block align-text-bottom",style:{width:24,height:24}},s):r.type==="image"&&r.imageUrl?oe("img",{src:r.imageUrl,alt:"\u56FE\u7247",loading:"lazy",className:"max-w-full rounded-lg",style:{maxHeight:"200px"}},s):r.type==="at"&&r.atName?Je("span",{className:"text-blue-500",children:["@",r.atName]},s):null)}),e.status==="sending"&&oe(K,{size:14,className:"animate-spin text-theme-hint"}),e.status==="failed"&&oe(ut,{size:14,className:"text-red-500"})]}),oe("span",{className:"text-xs text-theme-hint mt-1",children:lo(e.timestamp)})]})]})});import{useState as go}from"react";import{createPortal as ds}from"react-dom";import{Fragment as us,jsx as Se,jsxs as Ne}from"react/jsx-runtime";var Yo=({name:e,onMute:o,onClose:t})=>{let[a,r]=go(0),[s,l]=go(0),[n,d]=go(0),[c,i]=go(0),u=()=>{let h=a+s*60+n*3600+c*86400;h>0&&o(h)},f=a+s*60+n*3600+c*86400;return ds(Ne(us,{children:[Se("div",{className:"fixed inset-0 z-50 bg-black/30",onClick:t}),Ne("div",{className:"fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 glass glass-thick r-panel glass-pop p-6 min-w-[340px]",children:[Ne("h3",{className:"text-lg font-medium text-theme mb-4",children:["\u7981\u8A00 ",e]}),Ne("div",{className:"mb-4",children:[Se("p",{className:"text-sm text-theme-secondary mb-3",children:"\u8BBE\u7F6E\u7981\u8A00\u65F6\u957F\uFF1A"}),Ne("div",{className:"grid grid-cols-4 gap-2",children:[Ne("div",{className:"flex flex-col items-center",children:[Se("input",{type:"number",min:0,max:59,value:a,onChange:h=>r(Math.min(59,Math.max(0,parseInt(h.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"}),Se("span",{className:"text-xs text-theme-secondary mt-1",children:"\u79D2"})]}),Ne("div",{className:"flex flex-col items-center",children:[Se("input",{type:"number",min:0,max:59,value:s,onChange:h=>l(Math.min(59,Math.max(0,parseInt(h.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"}),Se("span",{className:"text-xs text-theme-secondary mt-1",children:"\u5206\u949F"})]}),Ne("div",{className:"flex flex-col items-center",children:[Se("input",{type:"number",min:0,max:23,value:n,onChange:h=>d(Math.min(23,Math.max(0,parseInt(h.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"}),Se("span",{className:"text-xs text-theme-secondary mt-1",children:"\u5C0F\u65F6"})]}),Ne("div",{className:"flex flex-col items-center",children:[Se("input",{type:"number",min:0,max:29,value:c,onChange:h=>i(Math.min(29,Math.max(0,parseInt(h.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"}),Se("span",{className:"text-xs text-theme-secondary mt-1",children:"\u5929"})]})]}),Se("p",{className:"text-xs text-theme-secondary mt-2 text-center",children:"\u6700\u957F29\u592923\u5C0F\u65F659\u520659\u79D2"})]}),Ne("div",{className:"flex justify-between",children:[Se("button",{onClick:()=>o(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:"\u89E3\u9664\u7981\u8A00"}),Ne("div",{className:"flex gap-2",children:[Se("button",{onClick:t,className:"px-4 py-2 text-sm text-theme-secondary hover:bg-theme-item rounded-lg transition-colors",children:"\u53D6\u6D88"}),Se("button",{onClick:u,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:"\u786E\u8BA4\u7981\u8A00"})]})]})]})]}),document.body)},er=({name:e,groupName:o,onConfirm:t,onClose:a})=>ds(Ne(us,{children:[Se("div",{className:"fixed inset-0 z-50 bg-black/50",onClick:a}),Ne("div",{className:"fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 glass glass-thick r-panel glass-pop p-6 min-w-[320px]",children:[Se("h3",{className:"text-lg font-medium text-theme mb-4",children:"\u786E\u8BA4\u8E22\u51FA"}),Ne("p",{className:"text-theme-secondary mb-6",children:["\u786E\u5B9A\u8981\u5C06 ",Se("span",{className:"font-medium text-theme",children:e})," \u79FB\u51FA\u7FA4 ",Se("span",{className:"font-medium text-theme",children:o})," \u5417\uFF1F"]}),Ne("div",{className:"flex justify-end gap-3",children:[Se("button",{onClick:a,className:"px-4 py-2 text-sm text-theme-secondary hover:bg-theme-item rounded-lg transition-colors",children:"\u53D6\u6D88"}),Se("button",{onClick:t,className:"px-4 py-2 text-sm bg-red-500 text-white hover:bg-red-600 rounded-lg transition-colors",children:"\u786E\u8BA4\u8E22\u51FA"})]})]})]}),document.body),tr=({name:e,onConfirm:o,onClose:t})=>{let[a,r]=go("");return ds(Ne(us,{children:[Se("div",{className:"fixed inset-0 z-50 bg-black/30",onClick:t}),Ne("div",{className:"fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 glass glass-thick r-panel glass-pop p-6 min-w-[320px]",children:[Se("h3",{className:"text-lg font-medium text-theme mb-4",children:"\u8BBE\u7F6E\u5934\u8854"}),Ne("p",{className:"text-sm text-theme-secondary mb-3",children:["\u4E3A ",e," \u8BBE\u7F6E\u4E13\u5C5E\u5934\u8854\uFF1A"]}),Se("input",{type:"text",maxLength:12,value:a,onChange:s=>r(s.target.value),placeholder:"\u7559\u7A7A\u6E05\u9664\u5934\u8854",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:s=>{s.key==="Enter"&&o(a.trim())}}),Se("p",{className:"text-xs text-theme-secondary mt-2",children:"\u4E2D\u6587\u6700\u591A6\u5B57\uFF0C\u82F1\u6587\u6700\u591A12\u5B57\uFF0C\u6309\u56DE\u8F66\u786E\u8BA4"}),Ne("div",{className:"flex justify-end gap-2 mt-4",children:[Se("button",{onClick:t,className:"px-4 py-2 text-sm text-theme-secondary hover:bg-theme-item rounded-lg transition-colors",children:"\u53D6\u6D88"}),Se("button",{onClick:()=>o(a.trim()),className:"px-4 py-2 text-sm bg-pink-500 text-white hover:bg-pink-600 rounded-lg transition-colors",children:"\u786E\u8BA4"})]})]})]}),document.body)};import{useState as ac,useEffect as oc,useRef as Di}from"react";import{createPortal as Ei}from"react-dom";import{Fragment as cs,jsx as He,jsxs as Fe}from"react/jsx-runtime";function qi(e,o,t){let[a,r]=ac({left:-9999,top:-9999,ready:!1});return oc(()=>{r({left:-9999,top:-9999,ready:!1});let s=requestAnimationFrame(()=>{if(!t.current){r({left:e,top:o,ready:!0});return}let l=t.current.getBoundingClientRect(),n=10,d=e,c=o;e+l.width>window.innerWidth-n&&(d=e-l.width),d<n&&(d=n),o+l.height>window.innerHeight-n&&(c=o-l.height),c<n&&(c=n),r({left:d,top:c,ready:!0})});return()=>cancelAnimationFrame(s)},[e,o]),a}var Bi=({contextMenu:e,session:o,getCachedMembers:t,onClose:a,onReply:r,onEmojiReaction:s,onRecall:l,onForward:n,onMultiSelect:d})=>{let c=e.message,i=st(),u=i&&c.senderUid===i,f=c.chatType===2,h=f&&o?t(o.peerId):null,m=(h&&i?h.find(W=>W.uid===i):null)?.role,g=m==="owner",L=m==="admin"||m==="owner",I=(h?h.find(W=>W.uid===c.senderUid):null)?.role,b=u||f&&(g||L&&!(I==="admin"||I==="owner")),F=!!e.elementId,M=Di(null),O=qi(e.x,e.y,M),Z=async()=>{if(e.elementId){a();try{let R=c.elements.find(B=>B.elementId===e.elementId)?.picElement?.originImageUrl||"";if(!R){T("\u56FE\u7247\u5730\u5740\u4E3A\u7A7A\uFF0C\u65E0\u6CD5\u6DFB\u52A0","error");return}let D=R.startsWith("http")?R:`https://gchat.qpic.cn${R}`,v=await pl(D);v.result===0?T(v.isExist?"\u8868\u60C5\u5DF2\u5B58\u5728":"\u5DF2\u6DFB\u52A0\u5230\u8868\u60C5","success"):T(v.errMsg||"\u6DFB\u52A0\u5931\u8D25","error")}catch(W){T(W.message||"\u6DFB\u52A0\u5931\u8D25","error")}}},H=async()=>{if(e.elementId){a();try{let le=c.elements.find(v=>v.elementId===e.elementId)?.picElement,R=le?.originImageUrl||"";if(!R){T("\u56FE\u7247\u5730\u5740\u4E3A\u7A7A\uFF0C\u65E0\u6CD5\u4E0B\u8F7D","error");return}let D=R.startsWith("http")?R:`https://gchat.qpic.cn${R}`;await Fo(D,le?.fileName||le?.md5HexStr)}catch(W){T(W.message||"\u4E0B\u8F7D\u5931\u8D25","error")}}};return Ei(Fe(cs,{children:[He("div",{className:"fixed inset-0 z-40",onClick:a,onContextMenu:W=>{W.preventDefault(),a()}}),Fe("div",{ref:M,className:"fixed z-50 bg-popup r-control glass-pop origin-top-left py-1 min-w-[100px]",style:{left:O.left,top:O.top,visibility:O.ready?"visible":"hidden"},onContextMenu:W=>W.preventDefault(),children:[Fe("button",{onClick:()=>{r(c),a()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[He(aa,{size:14})," \u56DE\u590D"]}),!F&&Fe(cs,{children:[Fe("button",{onClick:()=>{n(c),a()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[He(Yt,{size:14})," \u8F6C\u53D1"]}),Fe("button",{onClick:()=>{d(c),a()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[He(_a,{size:14})," \u591A\u9009\u8F6C\u53D1"]})]}),o.chatType===2&&Fe("button",{onClick:()=>{s(c,e.x,e.y),a()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[He(bt,{size:14})," \u8D34\u8868\u60C5"]}),F&&Fe("button",{onClick:H,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[He(Tt,{size:14})," \u4E0B\u8F7D\u56FE\u7247"]}),F&&Fe("button",{onClick:Z,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[He(oa,{size:14})," \u6DFB\u52A0\u5230\u8868\u60C5"]}),b&&Fe("button",{onClick:async()=>{a();try{await sl(c.chatType,c.peerUid,c.msgId),l(c.msgId),T("\u6D88\u606F\u5DF2\u64A4\u56DE","success")}catch(W){T(W.message||"\u64A4\u56DE\u5931\u8D25","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:[He(ze,{size:14})," \u64A4\u56DE"]})]})]}),document.body)},ar=({avatarContextMenu:e,getCachedMembers:o,onClose:t,onInsertAt:a,onShowProfile:r,onSetTitle:s,onMute:l,onKick:n,onAdminChanged:d,groupName:c})=>{let i=st(),u=e.groupCode?o(e.groupCode):null,h=(u&&i?u.find(H=>H.uid===i):null)?.role,p=h==="owner",m=h==="admin",L=(u?u.find(H=>H.uid===e.senderUid):null)?.role,C=L==="admin",I=p||m&&L==="member",A=p||m&&L==="member",b=e.senderUid===i,F=p&&!b,M=Di(null),O=qi(e.x,e.y,M),Z=async()=>{let H=e;t();try{await cl(H.groupCode,H.senderUid,!C),T(C?"\u5DF2\u53D6\u6D88\u7BA1\u7406\u5458":"\u5DF2\u8BBE\u4E3A\u7BA1\u7406\u5458","success"),d?.()}catch(W){T(W.message||"\u64CD\u4F5C\u5931\u8D25","error")}};return Ei(Fe(cs,{children:[He("div",{className:"fixed inset-0 z-40",onClick:t,onContextMenu:H=>{H.preventDefault(),t()}}),Fe("div",{ref:M,className:"fixed z-50 bg-popup r-control glass-pop origin-top-left py-1 min-w-[120px]",style:{left:O.left,top:O.top,visibility:O.ready?"visible":"hidden"},onContextMenu:H=>H.preventDefault(),children:[e.chatType===2&&Fe("button",{onClick:()=>{a(e.senderUid,e.senderUin,e.senderName),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:[He(Na,{size:14})," \u53EC\u5524ta"]}),Fe("button",{onClick:async()=>{let H=e;t();try{H.chatType===2&&H.groupCode?await yr(H.chatType,parseInt(H.senderUin),parseInt(H.groupCode)):await yr(H.chatType,parseInt(H.senderUin))}catch(W){T(W.message||"\u6233\u4E00\u6233\u5931\u8D25","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:[He(Ha,{size:14})," \u6233\u4E00\u6233"]}),Fe("button",{onClick:()=>{r(e.senderUid,e.senderUin,e.x,e.y,e.groupCode),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:[He(ao,{size:14})," \u67E5\u770B\u8D44\u6599"]}),e.chatType===2&&e.groupCode&&p&&Fe("button",{onClick:()=>{s(e.senderUid,e.senderName,e.groupCode),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:[He(Fa,{size:14})," \u8BBE\u7F6E\u5934\u8854"]}),e.chatType===2&&e.groupCode&&F&&Fe("button",{onClick:Z,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-theme hover:bg-theme-item-hover transition-colors",children:[C?He(Qa,{size:14}):He(ft,{size:14}),C?"\u53D6\u6D88\u7BA1\u7406\u5458":"\u8BBE\u4E3A\u7BA1\u7406\u5458"]}),e.chatType===2&&e.groupCode&&!b&&I&&Fe("button",{onClick:()=>{l(e.senderUid,e.senderName,e.groupCode),t()},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:[He(oo,{size:14})," \u7981\u8A00"]}),e.chatType===2&&e.groupCode&&!b&&A&&Fe("button",{onClick:()=>{n(e.senderUid,e.senderName,e.groupCode,c||e.groupCode),t()},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:[He(eo,{size:14})," \u8E22\u51FA\u7FA4"]})]})]}),document.body)};import{useRef as Ca,useCallback as xt,useState as Sa,forwardRef as Mc,useImperativeHandle as Pc,useEffect as Ac}from"react";import{useRef as fs,useCallback as Ge,forwardRef as rc,useImperativeHandle as sc,useState as nc}from"react";import{jsx as Ui,jsxs as lc}from"react/jsx-runtime";var ms=rc(({placeholder:e="\u8F93\u5165\u6D88\u606F...",disabled:o=!1,onEnter:t,onPaste:a,onChange:r,onMentionChange:s},l)=>{let n=fs(null),d=fs(!1),c=fs(null),[i,u]=nc(!1),f=Ge(()=>{let R=n.current;if(!R)return[];let D=[],v=R.childNodes;for(let B=0;B<v.length;B++){let E=v[B];if(E.nodeType===Node.TEXT_NODE){let q=(E.textContent||"").replace(/\u200B/g,"");q&&D.push({type:"text",content:q})}else if(E.nodeType===Node.ELEMENT_NODE){let w=E;if(w.dataset.type==="face")D.push({type:"face",faceId:parseInt(w.dataset.faceId||"0")});else if(w.dataset.type==="image")D.push({type:"image",imageUrl:w.dataset.imageUrl,imageFile:w.__file});else if(w.dataset.type==="at")D.push({type:"at",atUid:w.dataset.atUid,atUin:w.dataset.atUin,atName:w.dataset.atName});else if(w.tagName==="BR")D.push({type:"text",content:`
|
|
2
|
+
`});else{let Y=(w.textContent||"").replace(/\u200B/g,"");Y&&D.push({type:"text",content:Y})}}}return D},[]),h=Ge(()=>{let R=f();return R.length===0||R.length===1&&R[0].type==="text"&&!R[0].content?.trim()},[f]),p=Ge(()=>{let R=window.getSelection();if(!R||R.rangeCount===0)return{top:0,left:0};let v=R.getRangeAt(0).getBoundingClientRect(),B=n.current?.getBoundingClientRect();return B?{top:B.bottom-v.top+8,left:v.left-B.left}:{top:0,left:0}},[]),m=Ge(()=>{if(!c.current)return"";let R=window.getSelection();if(!R||R.rangeCount===0)return"";let D=R.getRangeAt(0),{node:v,offset:B}=c.current;return D.startContainer!==v?"":(v.textContent||"").slice(B,D.startOffset)},[]),g=Ge(()=>{c.current=null,u(!1),s?.({active:!1,query:"",position:{top:0,left:0}})},[s]),L=Ge(()=>{let R=window.getSelection();if(!R||R.rangeCount===0)return;let D=R.getRangeAt(0),v=D.startContainer;if(v.nodeType!==Node.TEXT_NODE){i&&g();return}let B=v.textContent||"",E=D.startOffset;if(i&&c.current){if(c.current.node===v&&E>=c.current.offset){let Y=m();Y.includes(" ")?g():s?.({active:!0,query:Y,position:p()})}else g();return}let w=B.slice(0,E),q=w.lastIndexOf("@");if(q!==-1){let Y=q>0?w[q-1]:" ";if(Y===" "||Y===`
|
|
3
|
+
`||q===0){let ie=w.slice(q+1);ie.includes(" ")||(c.current={node:v,offset:q+1},u(!0),s?.({active:!0,query:ie,position:p()}))}}},[i,m,p,g,s]),C=Ge(R=>{let D=n.current;if(!D)return;g();let v=document.createTextNode(R),B=window.getSelection();if(B&&B.rangeCount>0){let E=B.getRangeAt(0);D.contains(E.commonAncestorContainer)?(E.deleteContents(),E.insertNode(v),E.setStartAfter(v),E.setEndAfter(v),B.removeAllRanges(),B.addRange(E)):D.appendChild(v)}else D.appendChild(v);D.focus(),r?.(f())},[r,f,g]),I=Ge(R=>{let D=n.current;if(!D)return;g();let v=document.createElement("span");v.contentEditable="false",v.dataset.type="face",v.dataset.faceId=String(R),v.className="inline-block align-middle mx-0.5 select-all",v.innerHTML=`<img src="/face/${R}.png" alt="[\u8868\u60C5]" class="w-6 h-6 inline-block" draggable="false" />`;let B=window.getSelection();if(B&&B.rangeCount>0){let E=B.getRangeAt(0);if(D.contains(E.commonAncestorContainer)){E.deleteContents(),E.insertNode(v);let w=document.createTextNode("\u200B");v.after(w),E.setStartAfter(w),E.setEndAfter(w),B.removeAllRanges(),B.addRange(E)}else{D.appendChild(v);let w=document.createTextNode("\u200B");D.appendChild(w)}}else{D.appendChild(v);let E=document.createTextNode("\u200B");D.appendChild(E)}D.focus(),r?.(f())},[r,f,g]),A=Ge((R,D)=>{let v=n.current;if(!v)return;g();let B=document.createElement("span");B.contentEditable="false",B.dataset.type="image",B.dataset.imageUrl=D,R&&(B.__file=R),B.className="inline-block align-middle mx-0.5 select-all",B.innerHTML=`<img src="${D}" alt="[\u56FE\u7247]" class="h-16 max-w-[200px] rounded inline-block object-cover" draggable="false" />`;let E=window.getSelection();if(E&&E.rangeCount>0){let w=E.getRangeAt(0);if(v.contains(w.commonAncestorContainer)){w.deleteContents(),w.insertNode(B);let q=document.createTextNode("\u200B");B.after(q),w.setStartAfter(q),w.setEndAfter(q),E.removeAllRanges(),E.addRange(w)}else{v.appendChild(B);let q=document.createTextNode("\u200B");v.appendChild(q)}}else{v.appendChild(B);let w=document.createTextNode("\u200B");v.appendChild(w)}v.focus(),r?.(f())},[r,f,g]),b=Ge((R,D,v)=>{let B=n.current;if(!B)return;if(i&&c.current){let{node:ie,offset:Oe}=c.current,Ke=window.getSelection();if(Ke&&Ke.rangeCount>0){let Ee=Ke.getRangeAt(0),j=document.createRange();j.setStart(ie,Oe-1),j.setEnd(Ee.startContainer,Ee.startOffset),j.deleteContents()}}g();let E=document.createElement("span");E.contentEditable="false",E.dataset.type="at",E.dataset.atUid=R,E.dataset.atUin=D,E.dataset.atName=v,E.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",E.textContent=`@${v}`;let w=window.getSelection();if(w&&w.rangeCount>0){let ie=w.getRangeAt(0);B.contains(ie.commonAncestorContainer)?(ie.deleteContents(),ie.insertNode(E),ie.setStartAfter(E),ie.setEndAfter(E),w.removeAllRanges(),w.addRange(ie)):B.appendChild(E)}else B.appendChild(E);let q=document.createTextNode(" ");E.after(q);let Y=document.createRange();Y.setStartAfter(q),Y.setEndAfter(q),w?.removeAllRanges(),w?.addRange(Y),B.focus(),r?.(f())},[i,r,f,g]),F=Ge(()=>{let R=n.current;R&&(R.innerHTML="",g(),r?.([]))},[r,g]),M=Ge(()=>{let R=n.current;if(!R)return;R.focus();let D=window.getSelection();if(D){let v=document.createRange();v.selectNodeContents(R),v.collapse(!1),D.removeAllRanges(),D.addRange(v)}},[]);sc(l,()=>({focus:M,clear:F,insertFace:I,insertText:C,insertImage:A,insertAt:b,getContent:f,isEmpty:h,cancelMention:g}),[M,F,I,C,A,b,f,h,g]);let O=Ge(R=>{if(i){if(["ArrowUp","ArrowDown","Enter","Tab"].includes(R.key))return;if(R.key==="Escape"){R.preventDefault(),g();return}}R.key==="Enter"&&!R.shiftKey&&!d.current&&!i&&(R.preventDefault(),t?.())},[t,i,g]),Z=Ge(()=>{L(),r?.(f())},[r,f,L]),H=Ge(R=>{let D=R.clipboardData?.items;if(D){for(let B=0;B<D.length;B++)if(D[B].type.startsWith("image/")){R.preventDefault(),a?.(R);return}}R.preventDefault();let v=R.clipboardData?.getData("text/plain");v&&document.execCommand("insertText",!1,v)},[a]),W=Ge(()=>{setTimeout(L,0)},[L]),le=Ge(()=>{setTimeout(()=>{i&&g()},200)},[i,g]);return lc("div",{className:"relative",children:[Ui("div",{ref:n,contentEditable:!o,onKeyDown:O,onInput:Z,onPaste:H,onClick:W,onBlur:le,onCompositionStart:()=>{d.current=!0},onCompositionEnd:()=>{d.current=!1,Z()},className:`min-h-[36px] max-h-[120px] overflow-y-auto px-3 py-2 outline-none text-theme whitespace-pre-wrap break-words ${o?"opacity-50 cursor-not-allowed":""}`,style:{wordBreak:"break-word"},"data-placeholder":e,suppressContentEditableWarning:!0}),Ui("style",{children:`
|
|
4
|
+
[data-placeholder]:empty:before {
|
|
5
|
+
content: attr(data-placeholder);
|
|
6
|
+
color: var(--theme-hint, #9ca3af);
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
}
|
|
9
|
+
`})]})});ms.displayName="RichInput";import{useState as ic,useEffect as or,useRef as dc,useMemo as uc}from"react";import{jsx as kt,jsxs as ps}from"react/jsx-runtime";var Oi=({members:e,loading:o,query:t,onSelect:a,onClose:r})=>{let s=dc(null),[l,n]=ic(0),d=uc(()=>{if(!t)return e.slice(0,20);let i=t.toLowerCase();return e.filter(u=>u.nickname.toLowerCase().includes(i)||u.card?.toLowerCase().includes(i)||u.uin.includes(t)).slice(0,20)},[e,t]);or(()=>{n(0)},[t]),or(()=>{let i=u=>{u.key==="ArrowDown"?(u.preventDefault(),n(f=>Math.min(f+1,d.length-1))):u.key==="ArrowUp"?(u.preventDefault(),n(f=>Math.max(f-1,0))):u.key==="Enter"||u.key==="Tab"?(u.preventDefault(),d[l]&&a(d[l])):u.key==="Escape"&&(u.preventDefault(),r())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[d,l,a,r]),or(()=>{let i=u=>{s.current&&!s.current.contains(u.target)&&r()};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]),or(()=>{let i=s.current;if(!i)return;let u=i.querySelector(`[data-index="${l}"]`);u&&u.scrollIntoView({block:"nearest"})},[l]);let c=i=>i==="owner"?kt(ct,{size:12,className:"text-yellow-500"}):i==="admin"?kt(ft,{size:12,className:"text-green-500"}):null;return kt("div",{ref:s,className:"absolute z-50 glass glass-thick glass-dense r-card glass-pop origin-bottom-left overflow-hidden",style:{bottom:"100%",left:0,marginBottom:8,minWidth:240,maxWidth:300},children:o?kt("div",{className:"flex items-center justify-center py-4",children:kt(K,{size:20,className:"animate-spin text-pink-500"})}):d.length===0?kt("div",{className:"py-3 px-4 text-sm text-theme-muted text-center",children:t?"\u6CA1\u6709\u5339\u914D\u7684\u6210\u5458":"\u6682\u65E0\u6210\u5458"}):kt("div",{className:"max-h-[200px] overflow-y-auto py-1",children:d.map((i,u)=>ps("div",{"data-index":u,onClick:()=>a(i),className:`flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors ${u===l?"bg-pink-50 dark:bg-pink-900/30":"hover:bg-theme-item-hover"}`,children:[kt("img",{src:i.avatar||`https://q1.qlogo.cn/g?b=qq&nk=${i.uin}&s=40`,alt:"",className:"w-7 h-7 rounded-full flex-shrink-0",loading:"lazy"}),ps("div",{className:"flex-1 min-w-0",children:[ps("div",{className:"flex items-center gap-1",children:[kt("span",{className:"text-sm text-theme truncate",children:i.card||i.nickname}),c(i.role)]}),i.card&&i.card!==i.nickname&&kt("div",{className:"text-xs text-theme-muted truncate",children:i.nickname})]})]},i.uid))})})};import{useState as hs,useEffect as cc,useRef as fc}from"react";import{Fragment as xc,jsx as lt,jsxs as rr}from"react/jsx-runtime";var mc=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,41,42,43,46,49,53,56,59,60,63,64,66,67,74,75,76,77,78,79,85,86,89,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,114,116,118,119,120,121,123,124,125,129,137,144,146,147,169,171,172,173,174,175,176,177,178,179,181,182,183,185,187,201,212,262,263,264,265,266,267,268,269,270,271,272,273,277,281,282,283,284,285,286,287,289,293,294,295,297,298,299,300,302,303,305,306,307,311,312,314,317,318,319,320,323,324,325,326,332,333,334,336,337,338,339,341,342,343,344,345,346,347,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,415,416,417,419,420,421,422,423,424,425,426,427,428,429,430,431,432,451,453,454,458,459,460,461,462],pc=[{codePoint:9728,char:"\u2600"},{codePoint:9749,char:"\u2615"},{codePoint:9786,char:"\u263A"},{codePoint:10024,char:"\u2728"},{codePoint:10068,char:"\u2754"},{codePoint:127801,char:"\u{1F339}"},{codePoint:127817,char:"\u{1F349}"},{codePoint:127822,char:"\u{1F34E}"},{codePoint:127827,char:"\u{1F353}"},{codePoint:127836,char:"\u{1F35C}"},{codePoint:127838,char:"\u{1F35E}"},{codePoint:127847,char:"\u{1F367}"},{codePoint:127866,char:"\u{1F37A}"},{codePoint:127867,char:"\u{1F37B}"},{codePoint:127881,char:"\u{1F389}"},{codePoint:127978,char:"\u{1F3EA}"},{codePoint:128014,char:"\u{1F40E}"},{codePoint:128020,char:"\u{1F414}"},{codePoint:128027,char:"\u{1F41B}"},{codePoint:128046,char:"\u{1F42E}"},{codePoint:128051,char:"\u{1F433}"},{codePoint:128053,char:"\u{1F435}"},{codePoint:128054,char:"\u{1F436}"},{codePoint:128055,char:"\u{1F437}"},{codePoint:128056,char:"\u{1F438}"},{codePoint:128064,char:"\u{1F440}"},{codePoint:128070,char:"\u{1F446}"},{codePoint:128074,char:"\u{1F44A}"},{codePoint:128076,char:"\u{1F44C}"},{codePoint:128077,char:"\u{1F44D}"},{codePoint:128078,char:"\u{1F44E}"},{codePoint:128079,char:"\u{1F44F}"},{codePoint:128098,char:"\u{1F462}"},{codePoint:128102,char:"\u{1F466}"},{codePoint:128103,char:"\u{1F467}"},{codePoint:128123,char:"\u{1F47B}"},{codePoint:128137,char:"\u{1F489}"},{codePoint:128147,char:"\u{1F493}"},{codePoint:128157,char:"\u{1F49D}"},{codePoint:128163,char:"\u{1F4A3}"},{codePoint:128164,char:"\u{1F4A4}"},{codePoint:128166,char:"\u{1F4A6}"},{codePoint:128168,char:"\u{1F4A8}"},{codePoint:128169,char:"\u{1F4A9}"},{codePoint:128170,char:"\u{1F4AA}"},{codePoint:128235,char:"\u{1F4EB}"},{codePoint:128293,char:"\u{1F525}"},{codePoint:128299,char:"\u{1F52B}"},{codePoint:128513,char:"\u{1F601}"},{codePoint:128514,char:"\u{1F602}"},{codePoint:128516,char:"\u{1F604}"},{codePoint:128522,char:"\u{1F60A}"},{codePoint:128524,char:"\u{1F60C}"},{codePoint:128525,char:"\u{1F60D}"},{codePoint:128527,char:"\u{1F60F}"},{codePoint:128530,char:"\u{1F612}"},{codePoint:128531,char:"\u{1F613}"},{codePoint:128532,char:"\u{1F614}"},{codePoint:128536,char:"\u{1F618}"},{codePoint:128538,char:"\u{1F61A}"},{codePoint:128540,char:"\u{1F61C}"},{codePoint:128541,char:"\u{1F61D}"},{codePoint:128557,char:"\u{1F62D}"},{codePoint:128560,char:"\u{1F630}"},{codePoint:128561,char:"\u{1F631}"},{codePoint:128563,char:"\u{1F633}"},{codePoint:128591,char:"\u{1F64F}"},{codePoint:128684,char:"\u{1F6AC}"}],hc="webqq_recent_emojis";function Hi(){let e=pa();return e?`${e}-${hc}`:null}var gc=10;function sr(){let e=Hi();if(!e)return[];try{let o=localStorage.getItem(e);if(!o)return[];let t=JSON.parse(o);return Array.isArray(t)&&t.length>0&&typeof t[0]=="number"?t.map(a=>({type:"face",faceId:a})):t}catch{return[]}}function zi(e){let o=Hi();if(!o)return;let t=sr().filter(a=>a.type!==e.type?!0:a.type==="face"?a.faceId!==e.faceId:a.codePoint!==e.codePoint);t.unshift(e),localStorage.setItem(o,JSON.stringify(t.slice(0,gc)))}var xo=({onSelect:e,onSelectEmoji:o,onClose:t,position:a,inline:r})=>{let[s,l]=hs(new Set),[n,d]=hs(sr()),[c,i]=hs("qq"),u=fc(null);cc(()=>{let m=g=>{u.current&&!u.current.contains(g.target)&&t()};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[t]);let f=m=>{zi({type:"face",faceId:m}),d(sr()),e(m)},h=(m,g)=>{zi({type:"emoji",codePoint:m,char:g}),d(sr()),o&&o(g)},p=(m,g)=>m.type==="face"&&m.faceId!==void 0?lt("button",{onClick:()=>f(m.faceId),className:"w-8 h-8 flex items-center justify-center hover:bg-theme-item rounded transition-colors",title:`\u8868\u60C5 ${m.faceId}`,children:lt("img",{src:`/face/${m.faceId}.png`,alt:`\u8868\u60C5${m.faceId}`,className:"w-6 h-6"})},`recent-face-${m.faceId}`):m.type==="emoji"&&m.char?lt("button",{onClick:()=>h(m.codePoint,m.char),className:"w-8 h-8 flex items-center justify-center hover:bg-theme-item rounded transition-colors text-xl",title:m.char,children:m.char},`recent-emoji-${m.codePoint}`):null;return rr("div",{ref:u,className:`${r?"":"absolute bottom-full left-0 mb-2"} glass glass-thick glass-dense r-card glass-pop origin-bottom-left z-50`,style:a?{left:a.x,bottom:a.y}:void 0,children:[rr("div",{className:"flex border-b border-theme-divider",children:[lt("button",{className:`flex-1 px-3 py-2 text-sm ${c==="qq"?"text-pink-500 border-b-2 border-pink-500":"text-theme-secondary"}`,onClick:()=>i("qq"),children:"QQ\u8868\u60C5"}),lt("button",{className:`flex-1 px-3 py-2 text-sm ${c==="emoji"?"text-pink-500 border-b-2 border-pink-500":"text-theme-secondary"}`,onClick:()=>i("emoji"),children:"Emoji"})]}),rr("div",{className:"p-2 max-h-[280px] overflow-y-auto w-[320px]",children:[n.length>0&&rr(xc,{children:[lt("div",{className:"text-xs text-theme-hint mb-1",children:"\u6700\u8FD1\u4F7F\u7528"}),lt("div",{className:"grid grid-cols-8 gap-1 mb-2 pb-2 border-b border-theme-divider",children:n.map((m,g)=>p(m,g))})]}),c==="qq"?lt("div",{className:"grid grid-cols-8 gap-1",children:mc.map(m=>lt("button",{onClick:()=>f(m),className:"w-8 h-8 flex items-center justify-center hover:bg-theme-item rounded transition-colors",title:`\u8868\u60C5 ${m}`,children:lt("img",{src:`/face/${m}.png`,alt:`\u8868\u60C5${m}`,className:`w-6 h-6 transition-opacity ${s.has(m)?"opacity-100":"opacity-0"}`,onLoad:()=>l(g=>new Set(g).add(m)),onError:g=>{g.target.style.display="none"}})},m))}):lt("div",{className:"grid grid-cols-8 gap-1",children:pc.map(({codePoint:m,char:g})=>lt("button",{onClick:()=>h(m,g),className:"w-8 h-8 flex items-center justify-center hover:bg-theme-item rounded transition-colors text-xl",title:g,children:g},m))})]})]})};import{useState as La,useEffect as gs,useRef as xs}from"react";import{createPortal as Lc}from"react-dom";import{Fragment as Ls,jsx as _e,jsxs as Ia}from"react/jsx-runtime";var xa=null;var Ic="webqq_recent_fav_emojis",Cc=10;function Is(){let e=pa();return e?`${e}-${Ic}`:null}function Lo(){let e=Is();if(!e)return[];try{let o=localStorage.getItem(e);return o?JSON.parse(o):[]}catch{return[]}}function Sc(e){let o=Is();if(!o)return;let t=Lo().filter(a=>a.emoId!==e.emoId);t.unshift(e),localStorage.setItem(o,JSON.stringify(t.slice(0,Cc)))}function bc(e){let o=Is();if(!o)return;let t=Lo().filter(a=>a.emoId!==e);localStorage.setItem(o,JSON.stringify(t))}var vc=({x:e,y:o,onClose:t,onDelete:a})=>{let r=xs(null),[s,l]=La({left:e,top:o});return gs(()=>{if(!r.current)return;let n=r.current.getBoundingClientRect(),d=10,c=e,i=o;e+n.width>window.innerWidth-d&&(c=e-n.width),c<d&&(c=d),o+n.height>window.innerHeight-d&&(i=o-n.height),i<d&&(i=d),l({left:c,top:i})},[e,o]),Lc(Ia(Ls,{children:[_e("div",{className:"fixed inset-0 z-[60]",onClick:t,onContextMenu:n=>{n.preventDefault(),t()}}),_e("div",{ref:r,className:"fixed z-[60] bg-popup r-control glass-pop origin-top-left py-1 min-w-[100px]",style:{left:s.left,top:s.top},onContextMenu:n=>n.preventDefault(),children:Ia("button",{onClick:a,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:[_e(ze,{size:14})," \u5220\u9664"]})})]}),document.body)},Cs=({onSelect:e,onClose:o})=>{let[t,a]=La(xa||[]),[r,s]=La(!xa),[l,n]=La(null),[d,c]=La(Lo()),[i,u]=La(null),f=xs(null);gs(()=>{if(xa){a(xa),s(!1);return}(async()=>{try{let I=(await fl()).map(A=>({emoId:A.emoId,resId:A.resId||"",url:A.url,desc:A.desc||""}));xa=I,a(I)}catch{n("\u52A0\u8F7D\u5931\u8D25")}finally{s(!1)}})()},[]);let h=xs(i);h.current=i,gs(()=>{let L=C=>{h.current||f.current&&!f.current.contains(C.target)&&o()};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[o]);let p=L=>{Sc(L),c(Lo()),e(L)},m=(L,C)=>{L.preventDefault(),L.stopPropagation(),u({x:L.clientX,y:L.clientY,emoji:C})},g=async()=>{if(!i)return;let{emoji:L}=i;u(null);try{let C=await ml(L.resId);if(C.result===0){T("\u5DF2\u5220\u9664","success");let I=t.filter(A=>A.emoId!==L.emoId);a(I),xa=I,bc(L.emoId),c(Lo())}else T(C.errMsg||"\u5220\u9664\u5931\u8D25","error")}catch(C){T(C.message||"\u5220\u9664\u5931\u8D25","error")}};return Ia("div",{ref:f,className:"absolute bottom-full left-0 mb-2 glass glass-thick glass-dense r-card glass-pop origin-bottom-left z-50 w-[320px]",children:[_e("div",{className:"p-2 border-b border-theme-divider text-sm text-theme-secondary",children:"\u6536\u85CF\u8868\u60C5"}),Ia("div",{className:"p-2 max-h-[300px] overflow-y-auto",children:[d.length>0&&Ia(Ls,{children:[_e("div",{className:"text-xs text-theme-hint mb-1",children:"\u6700\u8FD1\u4F7F\u7528"}),_e("div",{className:"grid grid-cols-4 gap-1 mb-2 pb-2 border-b border-theme-divider",children:d.map(L=>_e("button",{onClick:()=>p(L),onContextMenu:C=>m(C,L),className:"p-1 rounded-lg hover:bg-theme-item transition-colors",title:L.desc,children:_e("img",{src:L.url,alt:L.desc,className:"w-16 h-16 object-contain"})},`recent-${L.emoId}`))})]}),r?_e("div",{className:"flex items-center justify-center py-8",children:_e(K,{size:24,className:"animate-spin text-pink-500"})}):l?_e("div",{className:"text-center py-8 text-theme-hint text-sm",children:l}):t.length===0?_e("div",{className:"text-center py-8 text-theme-hint text-sm",children:"\u6682\u65E0\u6536\u85CF\u8868\u60C5"}):Ia(Ls,{children:[_e("div",{className:"text-xs text-theme-hint mb-1",children:"\u5168\u90E8"}),_e("div",{className:"grid grid-cols-4 gap-1",children:t.map(L=>_e("button",{onClick:()=>p(L),onContextMenu:C=>m(C,L),className:"p-1 rounded-lg hover:bg-theme-item transition-colors",title:L.desc,children:_e("img",{src:L.url,alt:L.desc,className:"w-16 h-16 object-contain",loading:"lazy"})},L.emoId))})]})]}),i&&_e(vc,{x:i.x,y:i.y,emoji:i.emoji,onClose:()=>u(null),onDelete:g})]})};import{createPortal as yc}from"react-dom";import{Fragment as wc,jsx as Ss,jsxs as kc}from"react/jsx-runtime";var bs=({target:e,onClose:o,onReacted:t,containerRef:a})=>{let r=async d=>{let c=e.message;o();try{await so(c.chatType,String(c.peerUin),c.msgSeq,String(d),!0),t?.(String(d))}catch(i){T(i.message||"\u8D34\u8868\u60C5\u5931\u8D25","error")}},s=async d=>{let c=e.message;o();try{let i=d.codePointAt(0);if(!i){T("\u65E0\u6548\u7684\u8868\u60C5","error");return}await so(c.chatType,String(c.peerUin),c.msgSeq,String(i),!0),t?.(String(i))}catch(i){T(i.message||"\u8D34\u8868\u60C5\u5931\u8D25","error")}},n=(()=>{if(a?.current){let d=a.current.getBoundingClientRect();return{left:d.left+d.width/2,top:d.top+d.height/2}}return{left:window.innerWidth/2,top:window.innerHeight/2}})();return yc(kc(wc,{children:[Ss("div",{className:"fixed inset-0 z-40 bg-black/20",onClick:o}),Ss("div",{className:"fixed z-50 -translate-x-1/2 -translate-y-1/2",style:{left:n.left,top:n.top},children:Ss(xo,{onSelect:r,onSelectEmoji:s,onClose:o,inline:!0})})]}),document.body)};import{jsx as ye,jsxs as ba}from"react/jsx-runtime";var vs=Mc((e,o)=>{let{session:t,replyTo:a,onReplyCancel:r,onSendStart:s,onSendEnd:l,onTempMessage:n,onTempMessageRemove:d,onTempMessageFail:c}=e,i=Ca(null),u=Ca(null),f=Ca(null),[h,p]=Sa(!1),[m,g]=Sa(!1),[L,C]=Sa(!1),[I,A]=Sa({active:!1,query:"",position:{top:0,left:0}}),[b,F]=Sa([]),[M,O]=Sa(!1),{getCachedMembers:Z,fetchGroupMembers:H}=re(),W=Ca(null),le=Ca(Z);le.current=Z;let R=Ca(H);R.current=H,Pc(o,()=>({insertAt:(j,ce,fe)=>{i.current?.insertAt(j,ce,fe)},insertText:j=>{i.current?.insertText(j)},focus:()=>{i.current?.focus()}}),[]),Ac(()=>{let j=t?.chatType===2?t.peerId:null;if(W.current=j,!j){F([]),O(!1);return}let ce=!fa(2,j);if(!ce){let fe=le.current(j);if(fe){F(fe),O(!1);return}}O(!0),F([]),R.current(j,ce).then(fe=>{W.current===j&&(F(fe),O(!1))}).catch(()=>{W.current===j&&O(!1)})},[t?.chatType,t?.peerId]);let D=xt(j=>{if(t?.chatType!==2){A({active:!1,query:"",position:{top:0,left:0}});return}A(j)},[t?.chatType]),v=xt(j=>{i.current?.insertAt(j.uid,j.uin,j.card||j.nickname)},[]),B=xt(()=>{i.current?.cancelMention()},[]),E=xt(async()=>{if(!t||!i.current)return;let j=i.current.getContent();if(i.current.isEmpty())return;s();let fe=a;i.current.clear(),r(),C(!1),setTimeout(()=>i.current?.focus(),0);let qe=j.map($=>({type:$.type,content:$.content,faceId:$.faceId,imageUrl:$.imageUrl,atName:$.atName})),P=`temp_${Date.now()}`;n({msgId:P,items:qe,timestamp:Date.now(),status:"sending"});try{let $=[];fe&&$.push({type:"reply",msgId:fe.msgId,msgSeq:fe.msgSeq});for(let ne of j)if(ne.type==="text"&&ne.content)$.push({type:"text",text:ne.content});else if(ne.type==="face"&&ne.faceId!==void 0)$.push({type:"face",faceId:ne.faceId});else if(ne.type==="image"){if(ne.imageFile){let ke=await tl(ne.imageFile);$.push({type:"image",imagePath:ke.imagePath})}else if(ne.imageUrl){let ke=await al(ne.imageUrl);$.push({type:"image",imagePath:ke.imagePath})}}else ne.type==="at"&&ne.atUid&&$.push({type:"at",uid:ne.atUid,uin:ne.atUin,name:ne.atName});if($.length===0){d(P);return}await Sr({chatType:t.chatType,peerId:t.peerId,content:$}),d(P)}catch{T("\u53D1\u9001\u5931\u8D25","error"),c(P)}finally{l()}},[t,a,s,l,r,n,d,c]),w=xt(j=>{i.current?.insertFace(j),p(!1)},[]),q=xt(j=>{i.current?.insertText(j),p(!1)},[]),Y=xt(j=>{g(!1),i.current?.insertImage(null,j.url)},[]),ie=xt(j=>{let ce=j.target.files?.[0];if(ce){if(!Al(ce.name)){T("\u4E0D\u652F\u6301\u7684\u56FE\u7247\u683C\u5F0F\uFF0C\u4EC5\u652F\u6301 JPG\u3001PNG\u3001GIF","error");return}i.current?.insertImage(ce,URL.createObjectURL(ce)),u.current&&(u.current.value="")}},[]),Oe=xt(async j=>{let ce=j.target.files?.[0];if(!ce||!t)return;if(ce.size>100*1024*1024){T("\u6587\u4EF6\u8FC7\u5927\uFF0C\u6700\u5927\u652F\u6301 100MB","error");return}f.current&&(f.current.value=""),s();let fe=`temp_${Date.now()}`;n({msgId:fe,items:[{type:"text",content:`[\u6587\u4EF6] ${ce.name}`}],timestamp:Date.now(),status:"sending"});try{let qe=await br(ce);await Sr({chatType:t.chatType,peerId:t.peerId,content:[{type:"file",filePath:qe.filePath,fileName:qe.fileName}]}),d(fe)}catch{T("\u53D1\u9001\u5931\u8D25","error"),c(fe)}finally{l()}},[t,s,l,n,d,c]),Ke=xt(j=>{let ce=j.clipboardData?.items;if(ce){for(let fe=0;fe<ce.length;fe++)if(ce[fe].type.startsWith("image/")){let qe=ce[fe].getAsFile();if(!qe)continue;let P=qe.type.split("/")[1]?.toLowerCase();if(!["jpeg","jpg","png","gif"].includes(P)){T("\u4E0D\u652F\u6301\u7684\u56FE\u7247\u683C\u5F0F","error");return}i.current?.insertImage(qe,URL.createObjectURL(qe));return}}},[]),Ee=xt(j=>{C(j.length>0&&!(j.length===1&&j[0].type==="text"&&!j[0].content?.trim()))},[]);return ba("div",{className:"glass-bar hairline-t",children:[a&&ye("div",{className:"px-4 py-2 hairline-b bg-theme-item",children:ba("div",{className:"flex items-center gap-2",children:[ye(aa,{size:16,className:"text-pink-500 flex-shrink-0"}),ba("div",{className:"flex-1 min-w-0 text-sm text-theme-secondary truncate",children:["\u56DE\u590D ",a.sendMemberName||a.sendNickName||a.senderUin,"\uFF1A",a.elements?.filter(j=>!j.replyElement).map((j,ce)=>j.textElement?ye("span",{children:j.textElement.content},ce):j.picElement?ye("span",{children:"[\u56FE\u7247]"},ce):j.faceElement?ye("span",{children:"[\u8868\u60C5]"},ce):null)]}),ye("button",{onClick:r,className:"p-1 text-theme-hint hover:text-theme rounded",children:ye(we,{size:16})})]})}),ba("div",{className:"px-4 pt-0.5 pb-3",children:[ba("div",{className:"flex items-center gap-1 mb-2 relative",children:[ye("button",{onClick:()=>{p(!h),g(!1)},className:`p-2 rounded-lg transition-colors ${h?"text-pink-500 bg-pink-50 dark:bg-pink-900/30":"text-theme-muted hover:text-pink-500 hover:bg-pink-50 dark:hover:bg-pink-900/30"}`,title:"\u8868\u60C5",children:ye(bt,{size:18})}),ye("button",{onClick:()=>{g(!m),p(!1)},className:`p-2 rounded-lg transition-colors ${m?"text-pink-500 bg-pink-50 dark:bg-pink-900/30":"text-theme-muted hover:text-pink-500 hover:bg-pink-50 dark:hover:bg-pink-900/30"}`,title:"\u6536\u85CF\u8868\u60C5",children:ye(Ja,{size:18})}),ye("button",{onClick:()=>u.current?.click(),className:"p-2 text-theme-muted hover:text-pink-500 hover:bg-pink-50 dark:hover:bg-pink-900/30 rounded-lg transition-colors",title:"\u56FE\u7247",children:ye(Ga,{size:18})}),ye("button",{onClick:()=>f.current?.click(),className:"p-2 text-theme-muted hover:text-pink-500 hover:bg-pink-50 dark:hover:bg-pink-900/30 rounded-lg transition-colors",title:"\u6587\u4EF6",children:ye(Va,{size:18})}),h&&ye(xo,{onSelect:w,onSelectEmoji:q,onClose:()=>p(!1)}),m&&ye(Cs,{onSelect:Y,onClose:()=>g(!1)})]}),ba("div",{className:"flex items-end gap-2 relative",children:[ye("input",{type:"file",ref:u,onChange:ie,accept:"image/jpeg,image/png,image/gif",className:"hidden"}),ye("input",{type:"file",ref:f,onChange:Oe,className:"hidden"}),ye("div",{className:"flex-1 bg-theme-input border border-theme-input rounded-xl focus-within:ring-2 focus-within:ring-pink-500/20 overflow-hidden",children:ye(ms,{ref:i,placeholder:"\u8F93\u5165\u6D88\u606F...",onEnter:E,onPaste:Ke,onChange:Ee,onMentionChange:D})}),I.active&&t?.chatType===2&&ye(Oi,{members:b,loading:M,query:I.query,position:I.position,onSelect:v,onClose:B}),ye("button",{onClick:E,disabled:!L,className:"p-2.5 bg-pink-500 text-white rounded-full hover:bg-pink-600 disabled:opacity-50 disabled:cursor-not-allowed flex-shrink-0",children:ye(Ka,{size:20})})]})]})]})});vs.displayName="ChatInput";import{useState as Rc,useMemo as Gi}from"react";import{createPortal as Tc}from"react-dom";import{Fragment as Fc,jsx as Lt,jsxs as Ut}from"react/jsx-runtime";var Nc=({count:e,onSelect:o,onClose:t,sending:a})=>{let{recentChats:r,friendCategories:s,groups:l}=re(),[n,d]=Rc(""),c=Gi(()=>{let u=new Set,f=[],h=p=>{if(p.chatType!==1&&p.chatType!==2)return;let m=`${p.chatType}_${p.peerId}`;u.has(m)||(u.add(m),f.push(p))};for(let p of r)h({chatType:p.chatType,peerId:p.peerId,name:p.peerName,avatar:p.peerAvatar});for(let p of l)h({chatType:2,peerId:p.groupCode,name:p.remarkName||p.groupName,avatar:p.avatar});for(let p of s)for(let m of p.friends)h({chatType:1,peerId:m.uin,name:m.remark||m.nickname,avatar:m.avatar});return f},[r,s,l]),i=Gi(()=>{let u=n.trim().toLowerCase();return u?c.filter(f=>f.name.toLowerCase().includes(u)||f.peerId.includes(u)):c},[c,n]);return Tc(Ut(Fc,{children:[Lt("div",{className:"fixed inset-0 z-[60] bg-black/40",onClick:a?void 0:t}),Ut("div",{className:"fixed z-[60] top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 glass glass-thick r-panel glass-pop w-[360px] max-w-[92vw] max-h-[70vh] flex flex-col",children:[Ut("div",{className:"flex items-center justify-between px-4 py-3 border-b border-theme-divider",children:[Ut("div",{className:"font-medium text-theme",children:["\u8F6C\u53D1\u5230",e>1?`\uFF08\u5408\u5E76 ${e} \u6761\uFF09`:""]}),Lt("button",{onClick:t,disabled:a,className:"p-1.5 text-theme-hint hover:text-theme hover:bg-theme-item rounded-lg transition-colors disabled:opacity-50",children:Lt(we,{size:18})})]}),Lt("div",{className:"p-3 border-b border-theme-divider",children:Ut("div",{className:"relative",children:[Lt(Nt,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-theme-hint"}),Lt("input",{autoFocus:!0,value:n,onChange:u=>d(u.target.value),placeholder:"\u641C\u7D22\u4F1A\u8BDD / \u597D\u53CB / \u7FA4",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"})]})}),Ut("div",{className:"flex-1 overflow-y-auto py-1 relative",children:[a&&Lt("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-[rgb(var(--glass-tint)/0.6)]",children:Lt(K,{size:24,className:"animate-spin text-pink-500"})}),i.length===0?Lt("div",{className:"flex items-center justify-center h-24 text-theme-hint text-sm",children:"\u672A\u627E\u5230\u4F1A\u8BDD"}):i.map(u=>Ut("button",{onClick:()=>o(u),disabled:a,className:"w-full flex items-center gap-3 px-3 py-2 hover:bg-theme-item-hover transition-colors text-left disabled:opacity-50",children:[Lt("img",{src:u.avatar,alt:u.name,loading:"lazy",className:"w-9 h-9 rounded-full object-cover flex-shrink-0",onError:f=>{f.currentTarget.src=u.chatType===2?`https://p.qlogo.cn/gh/${u.peerId}/${u.peerId}/100/`:`https://q1.qlogo.cn/g?b=qq&nk=${u.peerId}&s=100`}}),Ut("div",{className:"flex-1 min-w-0",children:[Lt("div",{className:"text-sm text-theme truncate",children:u.name}),Ut("div",{className:"text-xs text-theme-hint truncate",children:[u.chatType===2?"\u7FA4\u804A":"\u597D\u53CB"," \xB7 ",u.peerId]})]})]},`${u.chatType}_${u.peerId}`))]})]})]}),document.body)},_i=Nc;import{Fragment as zc,jsx as G,jsxs as je}from"react/jsx-runtime";function Bc(e){let o=parseInt(e);return o>1e3?`/face/emoji-${o.toString(16)}.png`:`/face/${e}.png`}var Uc=({tip:e,onScrollToMessage:o})=>{let t=Bc(e.emojiId),a=parseInt(e.emojiId);return G("div",{className:"flex justify-center py-2",children:je("span",{className:"text-xs text-theme-hint bg-theme-item/50 px-3 py-1 rounded-full",children:[G("span",{className:"text-blue-500",children:e.userName}),G("span",{children:" \u56DE\u5E94\u4E86"}),G("span",{className:"text-blue-500 cursor-pointer hover:underline",onClick:()=>o(e.msgSeq),children:"\u6D88\u606F"}),G("span",{children:" "}),G("img",{src:t,alt:"emoji",className:"inline-block w-4 h-4 align-text-bottom",onError:r=>{let s=r.target;s.dataset.fallback||(s.dataset.fallback="1",a>1e3?(s.style.display="none",s.insertAdjacentHTML("afterend",`<span class="text-sm">${String.fromCodePoint(a)}</span>`)):s.src=`https://gxh.vip.qq.com/club/item/parcel/item/${e.emojiId.slice(0,2)}/${e.emojiId}/100x100.png`)}})]})})},Oc=({session:e,onShowMembers:o,onShowFiles:t,onNewMessageCallback:a,onEmojiReactionCallback:r,onMessageRecalledCallback:s,appendInputMention:l,onAppendInputMentionConsumed:n,onBack:d,showBackButton:c})=>{let[i,u]=Ie([]),[f,h]=Ie([]),[p,m]=Ie([]),[g,L]=Ie(!1),[C,I]=Ie(!1),[A,b]=Ie(!0),[F,M]=Ie(null),[O,Z]=Ie(null),[H,W]=Ie(null),[le,R]=Ie(null),[D,v]=Ie(null),[B,E]=Ie(null),[w,q]=Ie(null),[Y,ie]=Ie(!1),[Oe,Ke]=Ie(null),[Ee,j]=Ie(null),[ce,fe]=Ie(null),[qe,P]=Ie(null),[$,ne]=Ie(null),[ke,Vt]=Ie(!1),[Q,de]=Ie(!1),[J,We]=Ie(new Set),[Pe,ot]=Ie(null),[Pt,It]=Ie(!1),[Re,At]=Ie(null),ad=it(()=>({showPreview:x=>M(x)}),[]),od=it(()=>({showPreview:(x,S)=>Z({fileUuid:x,isGroup:S})}),[]),rd=it(()=>({open:x=>t?.(x)}),[t]),sd=it(()=>({showMenu:(x,S)=>{R({x:x.clientX,y:x.clientY,message:S})}}),[]),ks=Ae(x=>{We(S=>{let y=new Set(S);return y.has(x)?y.delete(x):y.add(x),y})},[]),nd=it(()=>({enabled:Q,isSelected:x=>J.has(x),toggle:ks}),[Q,J,ks]),ir=Ae(()=>{de(!1),We(new Set)},[]),ld=Ae(()=>i.filter(x=>J.has(x.msgId)).map(x=>Number(x.msgSeq)).filter(x=>Number.isFinite(x)),[i,J]),id=Ae(async x=>{if(!(!Pe||!e)){It(!0);try{let S={chatType:Number(e.chatType),peerId:e.peerId},y={chatType:x.chatType,peerId:x.peerId};Pe.single?await Yn(S,Pe.msgSeqs[0],y):await el(S,Pe.msgSeqs,y),ot(null),ir(),At(x)}catch(S){T(S.message||"\u8F6C\u53D1\u5931\u8D25","error")}finally{It(!1)}}},[Pe,e,ir]),dd=Ae(()=>{Re&&(re.getState().setCurrentChat({chatType:Re.chatType,peerId:Re.peerId,peerName:Re.name,peerAvatar:Re.avatar}),At(null))},[Re]),ud=it(()=>({showMenu:(x,S,y)=>{R({x:x.clientX,y:x.clientY,message:S,elementId:y})}}),[]),cd=it(()=>({showMenu:(x,S)=>{v({x:x.clientX,y:x.clientY,...S})}}),[]),{getCachedMembers:So,setCachedMembers:rf,fetchGroupMembers:fd,friendCategories:Ms}=re(),Ps=De(null),la=De(null),va=De(null),ya=De(e),$t=De(!0),dr=De(!1),As=De(null),bo=De([]),wa=De(new Map),Rs=De(null),ur=De(!1),vo=De(null),Ts=De(!0),md=De(0),cr=De(!1);et(()=>{ya.current=e},[e]);let dt=it(()=>{let x=new Set,S=i.filter(z=>!z||!z.elements||!Array.isArray(z.elements)||x.has(z.msgId)?!1:(x.add(z.msgId),!0)).map(z=>({type:"raw",data:z})),y=f.map(z=>({type:"temp",data:z})),N=p.map(z=>({type:"system",data:z})),_=[...S,...y,...N];return _.sort((z,me)=>{let ue=pe=>pe.type==="raw"?Number(pe.data.msgTime)*1e3:(pe.type==="temp",pe.data.timestamp);return ue(z)-ue(me)}),bo.current=_,_},[i,f,p]),Rt=Ho({count:dt.length,getScrollElement:()=>la.current,estimateSize:()=>80,overscan:5}),fr=Ae((x,S)=>{let y=dt.findIndex(N=>N.type!=="raw"?!1:N.data.msgId===x||!!S&&String(N.data.msgSeq)===String(S));if(y!==-1){Rt.scrollToIndex(y,{align:"center"});let N=dt[y];N.type==="raw"&&(Ke(N.data.msgId),setTimeout(()=>Ke(null),2e3))}},[dt,Rt]),pd=it(()=>({scrollToMessage:fr}),[fr]),hd=it(()=>({getMembers:x=>So(x)}),[So]),gd=it(()=>({getFriend:x=>{for(let S of Ms){let y=S.friends.find(N=>N.uin===x);if(y)return{uid:y.uid,uin:y.uin,nickname:y.nickname,remark:y.remark}}return null}}),[Ms]),Xt=Ae(()=>{bo.current.length>0&&Rt.scrollToIndex(bo.current.length-1,{align:"end"});let x=la.current;x&&(x.scrollTop=x.scrollHeight)},[Rt]),[Ns,Fs]=Ie(!1),Ds=De(0),ka=De(null),yo=Ae(()=>{ka.current!==null&&(cancelAnimationFrame(ka.current),ka.current=null)},[]),wo=Ae((x=800)=>{Ds.current=Date.now()+x,yo();let S=()=>{if(Date.now()>Ds.current){ka.current=null;return}Xt(),ka.current=requestAnimationFrame(S)};S()},[Xt,yo]);et(()=>{let x=e?`${e.chatType}_${e.peerId}`:null;x!==As.current&&(As.current=x,dr.current=!1,ie(!1),Fs(!0))},[e?.chatType,e?.peerId]),et(()=>{de(!1),We(new Set),ot(null),At(null)},[e?.chatType,e?.peerId]),et(()=>{if(!Ns||g)return;let x=0,S=0,y=Date.now(),N=5e3,_=()=>{let z=la.current,me=!!z&&z.scrollHeight>0&&bo.current.length>0;if(me?(Xt(),S=z.scrollHeight<=z.clientHeight||z.scrollHeight-z.scrollTop-z.clientHeight<4?S+1:0):S=0,me&&S>=5||Date.now()-y>N){Fs(!1),dr.current=!0,ie(!0);return}x=requestAnimationFrame(_)};return x=requestAnimationFrame(_),()=>cancelAnimationFrame(x)},[Ns,g,Xt]),et(()=>()=>yo(),[yo]),et(()=>{$t.current&&dt.length>0&&(Xt(),$t.current=!1)},[dt.length,Xt]),et(()=>(a&&a(S=>{if(!S||!S.msgId||!S.elements||!Array.isArray(S.elements))return;let y=st();u(N=>{if(N.some(me=>me&&me.msgId===S.msgId))return N;let _=[...N,S],z=ya.current;return z&&Go(z.chatType,z.peerId,S),_}),S.senderUid===y&&h(N=>{let _=N.filter(z=>z.status==="sending");return _.length===0?N:(console.warn(`[SSE] \u6536\u5230\u81EA\u5DF1\u7684\u6D88\u606F\u65F6\uFF0C\u4ECD\u5B58\u5728 ${_.length} \u6761\u4E34\u65F6\u6D88\u606F\uFF0C\u73B0\u5DF2\u6E05\u9664`,_),N.filter(z=>z.status!=="sending"))})}),()=>{a&&a(null)}),[a]);let mr=Ae(x=>{let S=Ft(),y=!!S&&x.userId===S;if(u(N=>N.map(_=>{if(String(_.msgSeq)!==String(x.msgSeq))return _;let z=_.emojiLikesList||[];if(x.isAdd){let me=z.findIndex(ue=>ue.emojiId===x.emojiId);if(me>=0){let ue=[...z];return ue[me]={...ue[me],likesCnt:String(parseInt(ue[me].likesCnt)+1),isClicked:ue[me].isClicked||y},{..._,emojiLikesList:ue}}else return{..._,emojiLikesList:[...z,{emojiId:x.emojiId,emojiType:parseInt(x.emojiId)>999?"2":"1",likesCnt:"1",isClicked:y}]}}else{let me=z.findIndex(ue=>ue.emojiId===x.emojiId);if(me>=0){let ue=[...z],pe=parseInt(ue[me].likesCnt)-1;return pe<=0?ue.splice(me,1):ue[me]={...ue[me],likesCnt:String(pe),isClicked:y?!1:ue[me].isClicked},{..._,emojiLikesList:ue}}}return _})),x.isAdd&&!y){let N={id:`tip_${Date.now()}_${Math.random()}`,type:"emoji-reaction",userName:x.userName,emojiId:x.emojiId,msgSeq:x.msgSeq,timestamp:Date.now()};m(_=>[..._,N])}},[]),pr=Ae((x,S,y,N)=>{let _=Ft()||"";mr({groupCode:N,msgSeq:String(x),emojiId:S,userId:_,userName:"",isAdd:y}),_o(2,N,String(x),S,y,!0)},[mr]),xd=it(()=>({onSelfReact:pr}),[pr]);et(()=>(r&&r(S=>{mr(S)}),()=>{r&&r(null)}),[r]),et(()=>(s&&s(S=>{u(y=>y.map(N=>N.msgId===S.msgId||S.msgSeq&&String(N.msgSeq)===String(S.msgSeq)?{...N,recallTime:String(Math.floor(Date.now()/1e3))}:N))}),()=>{s&&s(null)}),[s]);let Es=(x,S)=>`${x}_${S}`,qs=Ae(async(x,S)=>{if(!e)return;let y=e.chatType,N=e.peerId,_=()=>{let z=ya.current;return z&&z.chatType===y&&z.peerId===N};console.log("[ChatWindow] loadMessages called:",{chatType:y,peerId:N,beforeMsgSeq:x,afterMsgSeq:S}),x?I(!0):L(!0),x&&i.length>0&&(vo.current=i[0]?.msgId||null);try{let z=await Ao(y,N,x,20,S);if(console.log("[ChatWindow] API response:",{messagesCount:z.messages.length,hasMore:z.hasMore}),!_()){console.log("[ChatWindow] Session changed after API call, skipping");return}let me=z.messages.filter(ue=>ue!=null&&ue.elements&&Array.isArray(ue.elements));return console.log("[ChatWindow] Valid messages:",me.length),u(ue=>{let pe=new Set(ue.map(Qe=>Qe.msgId)),Ve=me.filter(Qe=>!pe.has(Qe.msgId)),Te=x?[...Ve,...ue]:[...ue,...Ve];return Te.sort((Qe,Po)=>Number(Qe.msgTime)-Number(Po.msgTime)),console.log("[ChatWindow] Merged messages:",Te.length,"new:",Ve.length),Wt(y,N,Te),Te}),b(z.hasMore),{validMessages:me,hasMore:z.hasMore}}catch(z){if(console.error("[ChatWindow] loadMessages error:",z),vo.current=null,!_())return;T(x?"\u52A0\u8F7D\u66F4\u591A\u6D88\u606F\u5931\u8D25":"\u52A0\u8F7D\u6D88\u606F\u5931\u8D25","error")}finally{_()&&(L(!1),I(!1))}},[e,i]),Ld=Ae(async x=>{if(!e)return;let S=e.chatType,y=e.peerId;L(!0);let N=()=>{let _=ya.current;return _&&_.chatType===S&&_.peerId===y};try{let _=await Ao(S,y);if(!N()){console.log("[ChatWindow] Session changed during API call, skipping");return}let z=_.messages.filter(pe=>pe!=null&&pe.elements&&Array.isArray(pe.elements));if(console.log("[ChatWindow] Latest messages from API:",z.length),z.length===0){b(!1);return}let me=new Set(x.map(pe=>pe.msgId));if(z.some(pe=>me.has(pe.msgId))||x.length===0){console.log("[ChatWindow] Has overlap with cache, merging directly");let Ve=[...x,...z].filter((Te,Qe,Po)=>Po.findIndex(Ma=>Ma.msgId===Te.msgId)===Qe);Ve.sort((Te,Qe)=>Number(Te.msgTime)-Number(Qe.msgTime)),u(Ve),Wt(S,y,Ve),b(_.hasMore)}else{console.log("[ChatWindow] No overlap, need to fill gap");let pe=[...z],Ve=z[0]?.msgSeq,Te=_.hasMore,Qe=x[x.length-1]?.msgSeq;for(let Kt=0;Kt<10&&Te;Kt++){if(!N()){console.log("[ChatWindow] Session changed during gap fill, skipping");return}let ia=await Ao(S,y,Ve),Qt=ia.messages.filter(Ct=>Ct!=null&&Ct.elements&&Array.isArray(Ct.elements));if(Qt.length===0)break;pe=[...Qt,...pe],Ve=Qt[0]?.msgSeq,Te=ia.hasMore;let gr=new Set(Qt.map(Ct=>Ct.msgId));if(x.some(Ct=>gr.has(Ct.msgId))||!!Qe&&Qt.some(Ct=>Number(Ct.msgSeq)<=Number(Qe))){console.log("[ChatWindow] Connected with cache after",Kt+1,"iterations");break}}let Ma=[...x,...pe].filter((Kt,ia,Qt)=>Qt.findIndex(gr=>gr.msgId===Kt.msgId)===ia);Ma.sort((Kt,ia)=>Number(Kt.msgTime)-Number(ia.msgTime)),u(Ma),Wt(S,y,Ma),b(Te)}}catch(_){console.error("[ChatWindow] loadMessagesAndMergeWithCache error:",_),T("\u52A0\u8F7D\u6D88\u606F\u5931\u8D25","error")}finally{N()&&L(!1)}},[e]);et(()=>{let x=vo.current;if(x&&dt.length>0){let S=dt.findIndex(y=>y.type==="raw"&&y.data.msgId===x);S!==-1&&Rt.scrollToIndex(S,{align:"start"}),vo.current=null}},[dt,Rt]),et(()=>{if(e){let x=++md.current,S=Es(e.chatType,e.peerId),y=e.chatType,N=e.peerId;console.log("[ChatWindow] Session changed:",{chatType:y,peerId:N,version:x}),cr.current=!1,L(!1);let _=wa.current.get(S);_&&_.length>0?(console.log("[ChatWindow] Memory cache hit:",_.length,"messages"),u(_)):(console.log("[ChatWindow] Memory cache miss"),u([])),h([]),m([]),$t.current=!0;let z=Ts.current,me=fa(y,N),ue=z||!me;console.log("[ChatWindow] Check load:",{isFirstMount:z,hasVisited:me,shouldLoadFromApi:ue}),ga(y,N).then(async pe=>{let Ve=ya.current;if(!Ve||Ve.chatType!==y||Ve.peerId!==N){console.log("[ChatWindow] Session changed after IndexedDB read, skipping");return}let Te=[];pe&&pe.length>0?(Te=pe.filter(Qe=>Qe.elements&&Array.isArray(Qe.elements)),console.log("[ChatWindow] IndexedDB cache hit:",Te.length,"valid messages"),Te.length>0&&(wa.current.set(S,Te),u(Te))):console.log("[ChatWindow] IndexedDB cache miss"),ue&&!cr.current&&(cr.current=!0,Ts.current=!1,$l(y,N),console.log("[ChatWindow] Calling loadMessagesAndMergeWithCache()"),await Ld(Te))})}else u([]),h([]),m([])},[e?.peerId,e?.chatType]),et(()=>{if(e&&i.length>0){let x=Es(e.chatType,e.peerId);wa.current.set(x,i)}},[i,e?.chatType,e?.peerId]),et(()=>{let x=Rs.current,S=la.current;if(!x||!S)return;let y=new IntersectionObserver(N=>{if(N[0].isIntersecting&&dr.current&&A&&!ur.current&&!g&&i.length>0){let z=i[0]?.msgSeq;z&&(ur.current=!0,qs(z).finally(()=>{ur.current=!1}))}},{root:S,rootMargin:"50px 0px 0px 0px",threshold:0});return y.observe(x),()=>y.disconnect()},[A,i,qs]);let Id=Ae(()=>{let x=la.current;if(!x||i.length===0)return;let S=x.scrollHeight-x.scrollTop-x.clientHeight<100;$t.current=S,Vt(!S)},[i]),Cd=Ae(x=>{h(S=>S.filter(y=>y.msgId!==x.msgId))},[]),Sd=Ae(async(x,S,y,N,_)=>{E({profile:null,loading:!0,position:{x:y,y:N}});try{let z=await no(x,S,_);E({profile:z,loading:!1,position:{x:y,y:N}})}catch{E(null),T("\u83B7\u53D6\u7528\u6237\u8D44\u6599\u5931\u8D25","error")}},[]),bd=Ae(x=>{h(S=>[...S,x]),$t.current=!0},[]),vd=Ae(()=>{$t.current=!0,Vt(!1),wo(900)},[wo]),yd=Ae(()=>{$t.current=!0,wo(1400)},[wo]),wd=Ae(x=>{h(S=>S.filter(y=>y.msgId!==x))},[]),kd=Ae(x=>{h(S=>S.map(y=>y.msgId===x?{...y,status:"failed"}:y))},[]);et(()=>{l&&(va.current?.insertAt?.(l.uid,l.uin,l.name),va.current?.focus?.(),n?.())},[l,n]);let ko=De(null),Mo=De(null),[hr,Md]=Ie({head:56,foot:72});return Dc(()=>{let x=()=>Md({head:ko.current?.offsetHeight??0,foot:Mo.current?.offsetHeight??0}),S=new ResizeObserver(x);return ko.current&&S.observe(ko.current),Mo.current&&S.observe(Mo.current),x(),()=>S.disconnect()},[e?.peerId]),e?G(po.Provider,{value:ad,children:G(Wo.Provider,{value:od,children:G(es.Provider,{value:rd,children:G(Yr.Provider,{value:ud,children:G(Xo.Provider,{value:sd,children:G(Ko.Provider,{value:cd,children:G(Qo.Provider,{value:pd,children:G(Jo.Provider,{value:hd,children:G(Zo.Provider,{value:gd,children:G(ss.Provider,{value:nd,children:je(ns.Provider,{value:xd,children:[je("div",{ref:Ps,className:"flex flex-col h-full relative",children:[je("div",{ref:ko,className:"absolute top-0 left-0 right-0 z-20 glass-bar hairline-b flex items-center justify-between px-2 md:px-4 py-3",children:[c&&G("button",{onClick:d,className:"p-2 mr-1 text-theme-muted hover:text-theme hover:bg-theme-item rounded-lg transition-colors md:hidden",children:G(Ta,{size:20})}),je("div",{className:"flex items-center gap-3 cursor-pointer hover:opacity-80 transition-opacity flex-1 min-w-0",onClick:async x=>{let S=x.currentTarget.getBoundingClientRect(),y=S.left,N=S.bottom+8;if(e.chatType===2){q({profile:null,loading:!0,position:{x:y,y:N}});try{let _=await Rl(e.peerId);q({profile:_,loading:!1,position:{x:y,y:N}})}catch{q(null),T("\u83B7\u53D6\u7FA4\u8D44\u6599\u5931\u8D25","error")}}else{E({profile:null,loading:!0,position:{x:y,y:N}});try{let{friendCategories:_}=re.getState(),z="";for(let ue of _){let pe=ue.friends.find(Ve=>Ve.uin===e.peerId);if(pe){z=pe.uid;break}}let me=await no(z||void 0,e.peerId);E({profile:me,loading:!1,position:{x:y,y:N}})}catch(_){console.log(_),E(null),T("\u83B7\u53D6\u7528\u6237\u8D44\u6599\u5931\u8D25","error")}}},children:[G("img",{src:e.peerAvatar,alt:e.peerName,className:"w-10 h-10 rounded-full object-cover flex-shrink-0"}),je("div",{className:"min-w-0",children:[G("div",{className:"font-medium text-theme truncate",children:(()=>{let{groups:x,friendCategories:S}=re.getState();if(e.chatType===2){let y=x.find(N=>N.groupCode===e.peerId);if(y?.remarkName&&y.remarkName!==y.groupName)return`${y.remarkName}(${y.groupName})`}else for(let y of S){let N=y.friends.find(_=>_.uin===e.peerId);if(N?.remark&&N.remark!==N.nickname)return`${N.remark}(${N.nickname})`}return e.peerName})()}),G("div",{className:"text-xs text-theme-hint",children:e.chatType===2?(()=>{let{groups:x}=re.getState(),S=x.find(y=>y.groupCode===e.peerId);return`\u7FA4\u804A ${e.peerId}${S?.memberCount?` \xB7 ${S.memberCount}\u4EBA`:""}`})():e.chatType===100?`\u4E34\u65F6\u4F1A\u8BDD ${e.peerId}`:`\u79C1\u804A ${e.peerId}`})]})]}),je("div",{className:"flex items-center flex-shrink-0 empty:hidden",children:[G(qc,{name:"webqq.chat.actions",props:{chat:{chatType:Number(e.chatType),peerId:e.peerId,name:e.peerName}}}),e.chatType===2&&t&&G("button",{onClick:()=>t(),className:"p-2 text-theme-muted hover:text-theme hover:bg-theme-item rounded-lg",title:"\u7FA4\u6587\u4EF6",children:G(Oa,{size:20})}),e.chatType===2&&o&&G("button",{onClick:o,className:"p-2 text-theme-muted hover:text-theme hover:bg-theme-item rounded-lg",title:"\u67E5\u770B\u7FA4\u6210\u5458",children:G(pt,{size:20})})]})]}),je("div",{ref:la,onScroll:Id,className:"flex-1 overflow-y-auto overflow-x-hidden px-4",style:{paddingTop:hr.head+16,paddingBottom:hr.foot+16},children:[G("div",{ref:Rs,className:"h-1"}),C&&G("div",{className:"flex justify-center py-2",children:G(K,{size:20,className:"animate-spin text-pink-500"})}),g?G("div",{className:"flex items-center justify-center h-full",children:G(K,{size:32,className:"animate-spin text-pink-500"})}):dt.length===0?G("div",{className:"flex items-center justify-center h-full text-theme-hint",children:"\u6682\u65E0\u6D88\u606F"}):G("div",{style:{height:`${Rt.getTotalSize()}px`,width:"100%",position:"relative",opacity:Y?1:0},className:"overflow-hidden",children:Rt.getVirtualItems().map(x=>{let S=dt[x.index];return G("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${x.start}px)`,padding:"8px 0"},"data-index":x.index,ref:Rt.measureElement,className:"overflow-hidden box-border",children:S.type==="raw"?G(ls,{message:S.data,allMessages:i,isHighlighted:Oe===S.data.msgId}):S.type==="temp"?G(is,{message:S.data,onRetry:()=>Cd(S.data)}):G(Uc,{tip:S.data,onScrollToMessage:y=>fr("",y)})},x.key)})})]}),ke&&G("button",{onClick:Xt,className:"absolute right-4 w-7 h-7 glass glass-chrome glass-interactive r-capsule flex items-center justify-center text-theme-muted hover:text-theme transition-all z-30",style:{bottom:hr.foot+16},title:"\u6EDA\u52A8\u5230\u5E95\u90E8",children:G(Ra,{size:12})}),G("div",{ref:Mo,className:"absolute bottom-0 left-0 right-0 z-20",children:Q?je("div",{className:"glass-bar hairline-t px-4 py-3 flex items-center justify-between gap-3",children:[je("span",{className:"text-sm text-theme-secondary",children:["\u5DF2\u9009 ",J.size," \u6761"]}),je("div",{className:"flex items-center gap-2",children:[G("button",{onClick:ir,className:"px-4 py-1.5 text-sm text-theme-hint hover:text-theme transition-colors",children:"\u53D6\u6D88"}),je("button",{onClick:()=>{let x=ld();if(x.length===0){T("\u8BF7\u5148\u9009\u62E9\u6D88\u606F","warning");return}ot({single:!1,msgSeqs:x})},disabled:J.size===0,className:"px-4 py-1.5 text-sm gradient-primary text-white rounded-full font-medium disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1.5 transition-all",children:[G(Yt,{size:15})," \u8F6C\u53D1 (",J.size,")"]})]})]}):G(vs,{ref:va,session:e,replyTo:H,onReplyCancel:()=>W(null),onSendStart:vd,onSendEnd:yd,onTempMessage:bd,onTempMessageRemove:wd,onTempMessageFail:kd})})]}),le&&G(Bi,{contextMenu:le,session:e,getCachedMembers:So,onClose:()=>R(null),onReply:x=>{W(x),setTimeout(()=>va.current?.focus?.(),50)},onEmojiReaction:(x,S,y)=>ne({message:x,x:S,y}),onRecall:x=>{if(u(S=>S.filter(y=>y.msgId!==x)),e){let S=`${e.chatType}_${e.peerId}`,y=wa.current.get(S);y&&wa.current.set(S,y.filter(N=>N.msgId!==x)),Pi(e.chatType,e.peerId,x)}},onForward:x=>ot({single:!0,msgSeqs:[Number(x.msgSeq)]}),onMultiSelect:x=>{de(!0),We(new Set([x.msgId]))}}),$&&G(bs,{target:$,onClose:()=>ne(null),onReacted:x=>{let S=$.message;pr(S.msgSeq,x,!0,String(S.peerUin))},containerRef:Ps}),D&&G(ar,{avatarContextMenu:D,getCachedMembers:So,onClose:()=>v(null),onInsertAt:(x,S,y)=>va.current?.insertAt?.(x,S,y),onShowProfile:Sd,onSetTitle:(x,S,y)=>P({uid:x,name:S,groupCode:y}),onMute:(x,S,y)=>fe({uid:x,name:S,groupCode:y}),onKick:(x,S,y,N)=>j({uid:x,name:S,groupCode:y,groupName:N}),onAdminChanged:()=>e&&fd(e.peerId,!0),groupName:e?.peerName}),B&&G(mo,{profile:B.profile,loading:B.loading,position:B.position,onClose:()=>E(null),isFriend:e?.chatType===1,onFriendDeleted:x=>{let{removeFriend:S,setCurrentChat:y,removeRecentChat:N}=re.getState();S(x),e?.chatType===1&&(y(null),N(1,e.peerId))}}),w&&G(Wr,{profile:w.profile,loading:w.loading,position:w.position,onClose:()=>q(null),onQuitGroup:async(x,S)=>{try{await gl(x),T(S?"\u7FA4\u5DF2\u89E3\u6563":"\u5DF2\u9000\u51FA\u7FA4\u804A","success");let{setCurrentChat:y,removeRecentChat:N}=re.getState();y(null),N(2,x)}catch(y){T(y.message||(S?"\u89E3\u6563\u5931\u8D25":"\u9000\u7FA4\u5931\u8D25"),"error")}}}),Ee&&G(er,{name:Ee.name,groupName:Ee.groupName,onConfirm:async()=>{let{uid:x,name:S,groupCode:y}=Ee;j(null);try{await Ro(y,x),T(`\u5DF2\u5C06 ${S} \u79FB\u51FA\u7FA4\u804A`,"success")}catch(N){T(N.message||"\u8E22\u51FA\u5931\u8D25","error")}},onClose:()=>j(null)}),ce&&G(Yo,{name:ce.name,onMute:async x=>{let{uid:S,name:y,groupCode:N}=ce;fe(null);try{if(await To(N,S,x),x===0)T(`\u5DF2\u89E3\u9664 ${y} \u7684\u7981\u8A00`,"success");else{let _=x>=86400?`${Math.floor(x/86400)}\u5929`:x>=3600?`${Math.floor(x/3600)}\u5C0F\u65F6`:x>=60?`${Math.floor(x/60)}\u5206\u949F`:`${x}\u79D2`;T(`\u5DF2\u7981\u8A00 ${y} ${_}`,"success")}}catch(_){T(_.message||"\u7981\u8A00\u5931\u8D25","error")}},onClose:()=>fe(null)}),qe&&G(tr,{name:qe.name,onConfirm:async x=>{let{uid:S,name:y,groupCode:N}=qe;P(null);try{await No(N,S,x),T(x?`\u5DF2\u8BBE\u7F6E ${y} \u7684\u5934\u8854\u4E3A\u300C${x}\u300D`:`\u5DF2\u6E05\u9664 ${y} \u7684\u5934\u8854`,"success")}catch(_){T(_.message||"\u8BBE\u7F6E\u5934\u8854\u5931\u8D25","error")}},onClose:()=>P(null)}),G(Xr,{url:F,onClose:()=>M(null)}),G(Kr,{videoInfo:O,onClose:()=>Z(null)}),Pe&&G(_i,{count:Pe.msgSeqs.length,sending:Pt,onSelect:id,onClose:()=>ot(null)}),Re&&Ec(je(zc,{children:[G("div",{className:"fixed inset-0 z-[60] bg-black/40",onClick:()=>At(null)}),je("div",{className:"fixed z-[60] top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 glass glass-thick r-panel glass-pop p-5 w-80 max-w-[90vw]",children:[G("div",{className:"font-medium text-theme mb-2",children:"\u8F6C\u53D1\u6210\u529F"}),je("div",{className:"text-sm text-theme-secondary mb-4 break-all",children:["\u662F\u5426\u8DF3\u8F6C\u5230\u300C",Re.name,"\u300D\uFF1F"]}),je("div",{className:"flex justify-end gap-2",children:[G("button",{onClick:()=>At(null),className:"px-4 py-1.5 text-sm text-theme-hint hover:text-theme transition-colors",children:"\u7559\u5728\u5F53\u524D"}),G("button",{onClick:dd,className:"px-4 py-1.5 text-sm btn-primary transition-all",children:"\u8DF3\u8F6C\u8FC7\u53BB"})]})]})]}),document.body)]})})})})})})})})})})}):G("div",{className:"flex-1 flex items-center justify-center bg-theme-item",children:je("div",{className:"text-center text-theme-hint",children:[G("div",{className:"text-6xl mb-4",children:"\u{1F4AC}"}),G("p",{children:"\u9009\u62E9\u4E00\u4E2A\u8054\u7CFB\u4EBA\u5F00\u59CB\u804A\u5929"})]})})},ji=Oc;import{useState as Ot,useEffect as Wi,useMemo as Vi,useCallback as $i,useRef as Io}from"react";import{jsx as ve,jsxs as zt}from"react/jsx-runtime";var Hc=({member:e,onContextMenu:o,onClick:t})=>{let a=e.card||e.nickname,r=e.role==="owner"?ve(ct,{size:14,className:"text-yellow-500"}):e.role==="admin"?ve(ft,{size:14,className:"text-blue-500"}):null;return zt("div",{className:"flex items-center gap-3 px-3 py-2 hover:bg-theme-item-hover transition-colors cursor-pointer",onClick:l=>{("ontouchstart"in window||navigator.maxTouchPoints>0)&&t?.(l)},onContextMenu:o,children:[ve("img",{src:e.avatar,alt:a,className:"w-8 h-8 rounded-full object-cover flex-shrink-0",loading:"lazy",onError:l=>{l.currentTarget.src=Be(e.uin)}}),zt("div",{className:"flex-1 min-w-0",children:[zt("div",{className:"flex items-center gap-1.5",children:[ve("span",{className:"text-sm text-theme truncate",children:a}),r]}),e.card&&e.card!==e.nickname&&ve("div",{className:"text-xs text-theme-hint truncate",children:e.nickname})]})]})},Gc=({groupCode:e,onClose:o,onAtMember:t})=>{let[a,r]=Ot([]),[s,l]=Ot(!1),[n,d]=Ot(""),[c,i]=Ot(null),[u,f]=Ot(null),[h,p]=Ot(null),[m,g]=Ot(null),[L,C]=Ot(null),[I,A]=Ot(null),{getCachedMembers:b,fetchGroupMembers:F,currentChat:M}=re(),O=Io(null),Z=Io(e);Wi(()=>{Z.current=e},[e]);let H=Io(b);H.current=b;let W=Io(F);W.current=F;let le=Io(!1);Wi(()=>{let w=e,q=!fa(2,w),Y=Xl(w);console.log("[GroupMemberPanel] useEffect triggered:",{groupCode:w,isFirstVisit:q,alreadyFetched:Y});let ie=H.current(w);if(ie&&(console.log("[GroupMemberPanel] Cache hit:",ie.length,"members"),r(ie),i(null),Y)){l(!1);return}if(Y){l(!1);return}if(le.current){console.log("[GroupMemberPanel] Already loading, skip");return}return console.log("[GroupMemberPanel] Fetching from API, isFirstVisit:",q),le.current=!0,ie||(l(!0),i(null),r([])),W.current(w,q).then(Oe=>{console.log("[GroupMemberPanel] API success:",Oe.length,"members, currentGroupCode:",Z.current),Z.current===w&&(r(Oe),l(!1),Kl(w))}).catch(Oe=>{console.log("[GroupMemberPanel] API error:",Oe.message),Z.current===w&&(ie||i(Oe.message||"\u52A0\u8F7D\u7FA4\u6210\u5458\u5931\u8D25"),T("\u52A0\u8F7D\u7FA4\u6210\u5458\u5931\u8D25","error"),l(!1))}).finally(()=>{Z.current===w&&(le.current=!1)}),()=>{console.log("[GroupMemberPanel] Cleanup, reset isLoading"),le.current=!1}},[e]);let R=Vi(()=>Pl(a,n),[a,n]),D=Ho({count:R.length,getScrollElement:()=>O.current,estimateSize:()=>48,overscan:5}),v=Vi(()=>{let w=a.filter(Y=>Y.role==="owner").length,q=a.filter(Y=>Y.role==="admin").length;return{owner:w,admin:q,total:a.length}},[a]),B=$i((w,q)=>{w.preventDefault(),w.stopPropagation(),f({x:w.clientX,y:w.clientY,senderUid:q.uid,senderUin:q.uin,senderName:q.card||q.nickname,chatType:2,groupCode:e})},[e]),E=$i(async(w,q,Y,ie,Oe)=>{let Ke={x:Y,y:ie};p({profile:null,loading:!0,position:Ke});try{let Ee=await no(w,q,Oe);p({profile:Ee,loading:!1,position:Ke})}catch(Ee){T(Ee.message||"\u83B7\u53D6\u8D44\u6599\u5931\u8D25","error"),p(null)}},[]);return zt("div",{className:"flex flex-col h-full",children:[zt("div",{className:"flex items-center justify-between px-4 py-3 border-b border-theme-divider",children:[zt("div",{children:[ve("div",{className:"font-medium text-theme",children:"\u7FA4\u6210\u5458"}),zt("div",{className:"text-xs text-theme-hint",children:[v.total," \u4EBA"]})]}),ve("button",{onClick:o,className:"p-1.5 text-theme-hint hover:text-theme hover:bg-theme-item rounded-lg transition-colors",children:ve(we,{size:18})})]}),ve("div",{className:"p-3",children:zt("div",{className:"relative",children:[ve(Nt,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-theme-hint"}),ve("input",{type:"text",value:n,onChange:w=>d(w.target.value),placeholder:"\u641C\u7D22\u6210\u5458...",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"})]})}),ve("div",{ref:O,className:"flex-1 overflow-y-auto",children:s?ve("div",{className:"flex items-center justify-center h-32",children:ve(K,{size:24,className:"animate-spin text-pink-500"})}):c?zt("div",{className:"flex flex-col items-center justify-center h-32 gap-2",children:[ve("p",{className:"text-sm text-red-500",children:c}),ve("button",{onClick:()=>F(e),className:"text-sm text-pink-500 hover:text-pink-600",children:"\u91CD\u8BD5"})]}):R.length===0?ve("div",{className:"flex items-center justify-center h-32 text-theme-hint text-sm",children:n?"\u672A\u627E\u5230\u5339\u914D\u7684\u6210\u5458":"\u6682\u65E0\u6210\u5458"}):ve("div",{className:"py-1 relative",style:{height:D.getTotalSize()},children:D.getVirtualItems().map(w=>{let q=R[w.index];return ve("div",{className:"absolute left-0 right-0",style:{top:w.start,height:w.size},children:ve(Hc,{member:q,onClick:Y=>B(Y,q),onContextMenu:Y=>B(Y,q)})},q.uid)})})}),u&&ve(ar,{avatarContextMenu:u,getCachedMembers:b,onClose:()=>f(null),onInsertAt:(w,q,Y)=>{t?.({uid:w,uin:q,name:Y})},onShowProfile:E,onSetTitle:(w,q)=>A({uid:w,name:q}),onMute:(w,q)=>g({uid:w,name:q}),onKick:(w,q)=>C({uid:w,name:q}),onAdminChanged:()=>F(e,!0),groupName:M?.peerName}),h&&ve(mo,{profile:h.profile,loading:h.loading,position:h.position,onClose:()=>p(null)}),m&&ve(Yo,{name:m.name,onMute:async w=>{let{uid:q,name:Y}=m;g(null);try{if(await To(e,q,w),w===0)T(`\u5DF2\u89E3\u9664 ${Y} \u7684\u7981\u8A00`,"success");else{let ie=w>=86400?`${Math.floor(w/86400)}\u5929`:w>=3600?`${Math.floor(w/3600)}\u5C0F\u65F6`:w>=60?`${Math.floor(w/60)}\u5206\u949F`:`${w}\u79D2`;T(`\u5DF2\u7981\u8A00 ${Y} ${ie}`,"success")}}catch(ie){T(ie.message||"\u7981\u8A00\u5931\u8D25","error")}},onClose:()=>g(null)}),L&&ve(er,{name:L.name,groupName:M?.peerName||e,onConfirm:async()=>{let{uid:w,name:q}=L;C(null);try{await Ro(e,w),T(`\u5DF2\u5C06 ${q} \u79FB\u51FA\u7FA4\u804A`,"success")}catch(Y){T(Y.message||"\u8E22\u51FA\u5931\u8D25","error")}},onClose:()=>C(null)}),I&&ve(tr,{name:I.name,onConfirm:async w=>{let{uid:q,name:Y}=I;A(null);try{await No(e,q,w),T(w?`\u5DF2\u8BBE\u7F6E ${Y} \u7684\u5934\u8854\u4E3A\u300C${w}\u300D`:`\u5DF2\u6E05\u9664 ${Y} \u7684\u5934\u8854`,"success")}catch(ie){T(ie.message||"\u8BBE\u7F6E\u5934\u8854\u5931\u8D25","error")}},onClose:()=>A(null)})]})},Xi=Gc;import _c,{useState as tt,useEffect as ys,useCallback as jc,useRef as Ki}from"react";import{jsx as ee,jsxs as xe}from"react/jsx-runtime";function Wc(e){return!e||e<=0?"0 B":e<1024?e+" B":e<1024*1024?(e/1024).toFixed(1)+" KB":e<1024*1024*1024?(e/1024/1024).toFixed(1)+" MB":(e/1024/1024/1024).toFixed(2)+" GB"}function Vc(e){return e?new Date(e*1e3).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):""}var $c=({groupCode:e,onClose:o,locateTarget:t})=>{let[a,r]=tt([]),[s,l]=tt([]),[n,d]=tt(!1),[c,i]=tt(null),[u,f]=tt(!1),[h,p]=tt([]),[m,g]=tt(null),[L,C]=tt(""),[I,A]=tt(!1),[b,F]=tt(""),[M,O]=tt(null),[Z,H]=tt(!1),[W,le]=tt(null),[R,D]=tt(null),v=Ki(new Map),B=(P,$,ne)=>{let ke=P.currentTarget.getBoundingClientRect(),Vt=Math.min(ke.left,window.innerWidth-268);le({title:$,detail:ne,x:Math.max(8,Vt),y:ke.bottom+4})},E=Ki(null),w=h.length>0?h[h.length-1].folderId:"/",q=jc(async()=>{d(!0),i(null);try{let P=await wr(e,w);r(P.files),l(P.folders)}catch(P){i(P.message||"\u83B7\u53D6\u7FA4\u6587\u4EF6\u5931\u8D25")}finally{d(!1)}},[e,w]);ys(()=>{q()},[q]),ys(()=>{if(!t)return;let{folderId:P,fileId:$}=t;if(D($),!P||P==="/"){p([]);return}let ne=!1;return wr(e,"/").then(ke=>{if(ne)return;let Vt=ke.folders.find(Q=>Q.folderId===P);p([{folderId:P,folderName:Vt?.folderName||P}])}).catch(()=>{ne||p([{folderId:P,folderName:P}])}),()=>{ne=!0}},[t?.folderId,t?.fileId,e]),ys(()=>{if(!R||n)return;let P=a.find(ke=>ke.fileId===R||ke.fileName===R);if(!P)return;v.current.get(P.fileId)?.scrollIntoView({behavior:"smooth",block:"center"});let ne=setTimeout(()=>D(null),2500);return()=>clearTimeout(ne)},[R,a,n]);let Y=P=>{p($=>[...$,{folderId:P.folderId,folderName:P.folderName}])},ie=P=>{p($=>$.slice(0,P+1))},Oe=()=>E.current?.click(),Ke=async P=>{let $=P.target.files?.[0];if(P.target&&(P.target.value=""),!!$){if($.size>2*1024*1024*1024){T("\u6587\u4EF6\u8FC7\u5927\uFF0C\u6700\u5927\u652F\u6301 2GB","error");return}f(!0),T(`\u6B63\u5728\u4E0A\u4F20 ${$.name}...`,"warning");try{await Il(e,$,w),T("\u4E0A\u4F20\u6210\u529F","success"),q()}catch(ne){T(`${ne.message||"\u4E0A\u4F20\u5931\u8D25"}\uFF0C\u53EF\u80FD\u8BE5\u7FA4\u4E0D\u5141\u8BB8\u4E0A\u4F20\u7FA4\u6587\u4EF6`,"error")}finally{f(!1)}}},Ee=async P=>{try{let $=await xl(e,P.fileId);window.open($+encodeURIComponent(P.fileName),"_blank")}catch($){T($.message||"\u83B7\u53D6\u4E0B\u8F7D\u94FE\u63A5\u5931\u8D25","error")}},j=async()=>{if(!(!M||Z)){H(!0);try{M.type==="file"?await Cl(e,M.id,M.busId):await vl(e,M.id),T("\u5DF2\u5220\u9664","success"),O(null),q()}catch(P){T(P.message||"\u5220\u9664\u5931\u8D25","error")}finally{H(!1)}}},ce=(P,$,ne,ke)=>{g({type:P,id:$,oldName:ne,busId:ke}),C(ne)},fe=async()=>{if(!m)return;let P=L.trim();if(!P||P===m.oldName){g(null);return}try{m.type==="file"?await Sl(e,m.id,w,P):await yl(e,m.id,P),T("\u5DF2\u91CD\u547D\u540D","success"),g(null),q()}catch($){T($.message||"\u91CD\u547D\u540D\u5931\u8D25","error")}},qe=async()=>{let P=b.trim();if(!P){A(!1);return}try{await bl(e,P),T("\u6587\u4EF6\u5939\u5DF2\u521B\u5EFA","success"),A(!1),F(""),q()}catch($){T($.message||"\u65B0\u5EFA\u6587\u4EF6\u5939\u5931\u8D25","error")}};return xe("div",{className:"flex flex-col h-full",children:[xe("div",{className:"flex items-center justify-between px-4 py-3 border-b border-theme-divider",children:[ee("div",{className:"font-medium text-theme",children:"\u7FA4\u6587\u4EF6"}),xe("div",{className:"flex items-center gap-1",children:[ee("button",{onClick:q,title:"\u5237\u65B0",className:"p-1.5 text-theme-hint hover:text-theme hover:bg-theme-item rounded-lg transition-colors",children:ee(ta,{size:16})}),ee("button",{onClick:o,className:"p-1.5 text-theme-hint hover:text-theme hover:bg-theme-item rounded-lg transition-colors",children:ee(we,{size:18})})]})]}),xe("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-theme-divider",children:[xe("button",{onClick:Oe,disabled:u,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:[u?ee(K,{size:15,className:"animate-spin"}):ee(Ya,{size:15}),"\u4E0A\u4F20"]}),h.length===0&&xe("button",{onClick:()=>{A(!0),F("")},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-theme-item hover:bg-theme-item-hover text-theme rounded-lg transition-colors",children:[ee(za,{size:15}),"\u65B0\u5EFA\u6587\u4EF6\u5939"]}),ee("input",{ref:E,type:"file",className:"hidden",onChange:Ke})]}),xe("div",{className:"flex items-center flex-wrap gap-0.5 px-3 py-2 text-sm text-theme-hint border-b border-theme-divider",children:[ee("button",{onClick:()=>ie(-1),className:`hover:text-pink-500 transition-colors ${h.length===0?"text-theme font-medium":""}`,children:"\u5168\u90E8\u6587\u4EF6"}),h.map((P,$)=>xe(_c.Fragment,{children:[ee(Ze,{size:14,className:"text-theme-hint/60"}),ee("button",{onClick:()=>ie($),className:`hover:text-pink-500 transition-colors truncate max-w-[120px] ${$===h.length-1?"text-theme font-medium":""}`,children:P.folderName})]},P.folderId))]}),I&&xe("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-theme-divider bg-theme-item/40",children:[ee(da,{size:16,className:"text-yellow-500 flex-shrink-0"}),ee("input",{autoFocus:!0,value:b,onChange:P=>F(P.target.value),onKeyDown:P=>{P.key==="Enter"&&qe(),P.key==="Escape"&&A(!1)},placeholder:"\u6587\u4EF6\u5939\u540D\u79F0",className:"flex-1 min-w-0 px-2 py-1 text-sm bg-theme-input border border-theme-input rounded focus:outline-none focus:ring-2 focus:ring-pink-500/20 focus:border-pink-500/50 text-theme"}),ee("button",{onClick:qe,className:"text-sm text-pink-500 hover:text-pink-600",children:"\u786E\u5B9A"}),ee("button",{onClick:()=>A(!1),className:"text-sm text-theme-hint hover:text-theme",children:"\u53D6\u6D88"})]}),ee("div",{className:"flex-1 overflow-y-auto",children:n?ee("div",{className:"flex items-center justify-center h-32",children:ee(K,{size:24,className:"animate-spin text-pink-500"})}):c?xe("div",{className:"flex flex-col items-center justify-center h-32 gap-2",children:[ee("p",{className:"text-sm text-red-500",children:c}),ee("button",{onClick:q,className:"text-sm text-pink-500 hover:text-pink-600",children:"\u91CD\u8BD5"})]}):s.length===0&&a.length===0?ee("div",{className:"flex items-center justify-center h-32 text-theme-hint text-sm",children:"\u6B64\u76EE\u5F55\u6682\u65E0\u6587\u4EF6"}):xe("div",{className:"py-1",children:[s.map(P=>xe("div",{className:"group flex items-center gap-3 px-3 py-2 hover:bg-theme-item-hover transition-colors",children:[xe("button",{onClick:()=>Y(P),className:"flex items-center gap-3 flex-1 min-w-0 text-left",children:[ee(da,{size:20,className:"text-yellow-500 flex-shrink-0"}),xe("div",{className:"flex-1 min-w-0",onMouseEnter:$=>B($,P.folderName,`${P.fileCount} \u4E2A\u6587\u4EF6 \xB7 ${P.creatorName}`),onMouseLeave:()=>le(null),children:[ee("div",{className:"text-sm text-theme truncate",children:P.folderName}),xe("div",{className:"text-xs text-theme-hint truncate",children:[P.fileCount," \u4E2A\u6587\u4EF6 \xB7 ",P.creatorName]})]})]}),xe("div",{className:"flex md:hidden md:group-hover:flex items-center gap-0.5 flex-shrink-0",children:[ee("button",{onClick:()=>ce("folder",P.folderId,P.folderName),title:"\u91CD\u547D\u540D",className:"p-1.5 text-theme-hint hover:text-theme hover:bg-theme-item rounded transition-colors",children:ee(ca,{size:14})}),ee("button",{onClick:()=>O({type:"folder",id:P.folderId,name:P.folderName}),title:"\u5220\u9664",className:"p-1.5 text-theme-hint hover:text-red-500 hover:bg-theme-item rounded transition-colors",children:ee(ze,{size:14})})]})]},P.folderId)),a.map(P=>{let $=`${Wc(P.fileSize)} \xB7 ${P.uploaderName||""}${P.uploadTime?` \xB7 ${Vc(P.uploadTime)}`:""}`,ne=R!=null&&(P.fileId===R||P.fileName===R);return xe("div",{ref:ke=>{ke?v.current.set(P.fileId,ke):v.current.delete(P.fileId)},className:`group flex items-center gap-3 px-3 py-2 transition-colors ${ne?"bg-pink-500/10 ring-1 ring-inset ring-pink-500/60":"hover:bg-theme-item-hover"}`,children:[ee(Zt,{size:20,className:"text-blue-400 flex-shrink-0"}),xe("div",{className:"flex-1 min-w-0",onMouseEnter:ke=>B(ke,P.fileName,$),onMouseLeave:()=>le(null),children:[ee("div",{className:"text-sm text-theme truncate",children:P.fileName}),ee("div",{className:"text-xs text-theme-hint truncate",children:$})]}),xe("div",{className:"flex md:hidden md:group-hover:flex items-center gap-0.5 flex-shrink-0",children:[ee("button",{onClick:()=>Ee(P),title:"\u4E0B\u8F7D",className:"p-1.5 text-theme-hint hover:text-pink-500 hover:bg-theme-item rounded transition-colors",children:ee(Tt,{size:14})}),ee("button",{onClick:()=>ce("file",P.fileId,P.fileName,P.busId),title:"\u91CD\u547D\u540D",className:"p-1.5 text-theme-hint hover:text-theme hover:bg-theme-item rounded transition-colors",children:ee(ca,{size:14})}),ee("button",{onClick:()=>O({type:"file",id:P.fileId,busId:P.busId,name:P.fileName}),title:"\u5220\u9664",className:"p-1.5 text-theme-hint hover:text-red-500 hover:bg-theme-item rounded transition-colors",children:ee(ze,{size:14})})]})]},P.fileId)})]})}),m&&ee("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/40",children:xe("div",{className:"glass glass-thick r-panel glass-pop p-5 w-80 max-w-[90vw]",children:[xe("div",{className:"font-medium text-theme mb-3",children:["\u91CD\u547D\u540D",m.type==="folder"?"\u6587\u4EF6\u5939":"\u6587\u4EF6"]}),ee("input",{autoFocus:!0,value:L,onChange:P=>C(P.target.value),onKeyDown:P=>{P.key==="Enter"&&fe(),P.key==="Escape"&&g(null)},className:"w-full px-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"}),xe("div",{className:"flex justify-end gap-2 mt-4",children:[ee("button",{onClick:()=>g(null),className:"px-4 py-1.5 text-sm text-theme-hint hover:text-theme transition-colors",children:"\u53D6\u6D88"}),ee("button",{onClick:fe,className:"px-4 py-1.5 text-sm btn-primary transition-all",children:"\u786E\u5B9A"})]})]})}),M&&ee("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/40",children:xe("div",{className:"glass glass-thick r-panel glass-pop p-5 w-80 max-w-[90vw]",children:[xe("div",{className:"font-medium text-theme mb-2",children:["\u5220\u9664",M.type==="folder"?"\u6587\u4EF6\u5939":"\u6587\u4EF6"]}),xe("div",{className:"text-sm text-theme-secondary mb-4 break-all",children:["\u786E\u5B9A\u5220\u9664",M.type==="folder"?"\u6587\u4EF6\u5939":"\u6587\u4EF6","\u300C",M.name,"\u300D",M.type==="folder"?"\u53CA\u5176\u4E2D\u6240\u6709\u6587\u4EF6\uFF1F":"\uFF1F","\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002"]}),xe("div",{className:"flex justify-end gap-2",children:[ee("button",{onClick:()=>O(null),disabled:Z,className:"px-4 py-1.5 text-sm text-theme-hint hover:text-theme transition-colors disabled:opacity-50",children:"\u53D6\u6D88"}),xe("button",{onClick:j,disabled:Z,className:"px-4 py-1.5 text-sm bg-red-500 hover:bg-red-600 text-white rounded-lg transition-colors disabled:opacity-50 flex items-center gap-1.5",children:[Z&&ee(K,{size:14,className:"animate-spin"}),"\u5220\u9664"]})]})]})}),W&&ee(qr,{children:xe("div",{className:"fixed z-[100] pointer-events-none max-w-[260px] px-3 py-2 glass glass-thick r-control",style:{left:W.x,top:W.y},children:[ee("div",{className:"text-sm text-theme break-all",children:W.title}),ee("div",{className:"text-xs text-theme-secondary break-all mt-0.5",children:W.detail})]})})]})},Qi=$c;import{usePluginConfig as Xc}from"@luckylillia-dev/plugin-sdk/webui";function nr(){let{value:e}=Xc();return{autoHideSidebar:e?.autoHideSidebar??!1,fullscreenButton:e?.fullscreenButton??!0}}import{Fragment as Zc,jsx as at,jsxs as ws}from"react/jsx-runtime";function Qc(e){if(!e||!e.elements||!Array.isArray(e.elements))return"[\u6D88\u606F]";let o=[];for(let a of e.elements){if(a.textElement?.content){o.push(a.textElement.content);continue}if(a.picElement){o.push("[\u56FE\u7247]");continue}if(a.faceElement){o.push("[\u8868\u60C5]");continue}if(a.fileElement){o.push("[\u6587\u4EF6]");continue}if(a.pttElement){o.push("[\u8BED\u97F3]");continue}if(a.videoElement){o.push("[\u89C6\u9891]");continue}if(a.replyElement){o.push("[\u56DE\u590D]");continue}if(a.multiForwardMsgElement){o.push("[\u804A\u5929\u8BB0\u5F55]");continue}if(a.arkElement)try{if(JSON.parse(a.arkElement.bytesData).app==="com.tencent.multimsg"){o.push("[\u804A\u5929\u8BB0\u5F55]");continue}}catch{}}let t=o.join("").replace(/\s+/g," ").trim();return t?/^@[^\s]+$/.test(t)?`${t} [\u63D0\u53CA]`:t:"[\u6D88\u606F]"}var Jc=({isFullscreen:e=!1})=>{let o=rt.useRef(null),t=rt.useRef(null),a=rt.useRef(null),r=rt.useRef([]),[,s]=rt.useState(0),{fullscreenButton:l}=nr(),{friendCategories:n,groups:d,contactsLoading:c,contactsError:i,currentChat:u,activeTab:f,unreadCounts:h,showMemberPanel:p,setCurrentChat:m,setActiveTab:g,setShowMemberPanel:L,clearUnreadCount:C,incrementUnreadCount:I,updateRecentChat:A,loadContacts:b,setRecentChats:F}=re(),M=re(Q=>Q.recentChats),O=re(Q=>Q.addNotification),Z=re(Q=>Q.loadGroupNotifications),[H,W]=rt.useState(null),[le,R]=rt.useState(!1),[D,v]=rt.useState(null),B=Mt(Q=>{if(Q){v(Q),R(!0),L(!1);return}v(null),R(de=>{let J=!de;return J&&L(!1),J})},[L]),E=Mt(()=>{L(!p),p||R(!1)},[p,L]),w=Mt(Q=>{W(Q)},[]),q=Mt(()=>{W(null)},[]);lr(()=>{Eo(),b(),Z()},[b,Z]),lr(()=>{i&&T(i,"error")},[i]);let Y=rt.useRef(u);lr(()=>{Y.current=u},[u]);let ie=rt.useCallback(Q=>{if(o.current=Q,Q&&r.current.length>0){let de=[...r.current];r.current=[],de.forEach(J=>Q(J))}s(de=>de+1)},[]),Oe=rt.useCallback(Q=>{t.current=Q},[]),Ke=rt.useCallback(Q=>{a.current=Q},[]);lr(()=>{let Q=wl(de=>{if(de.type==="message-created"||de.type==="message-sent"){let J=de.data;if(!J||!J.msgId||!J.elements||!Array.isArray(J.elements)){console.warn("SSE \u6536\u5230\u65E0\u6548\u6D88\u606F:",J);return}let We=J.chatType,Pe=String(J.peerUin||J.peerUid),ot=`${We}_${Pe}`,Pt=Y.current;Go(We,Pe,J),Pt&&Pt.chatType===We&&Pt.peerId===Pe?o.current?o.current(J):r.current.push(J):I(ot);let It=Qc(J),Re,At;We===2?(Re=J.peerName||void 0,At=`https://p.qlogo.cn/gh/${Pe}/${Pe}/640/`):(Re=J.sendNickName||J.sendMemberName||void 0,At=Be(Pe)),A(We,Pe,It,J.msgTime*1e3,Re,At)}else if(de.type==="emoji-reaction"){let{groupCode:J,msgSeq:We,emojiId:Pe,userId:ot,userName:Pt,isAdd:It}=de.data;if(ot&&String(ot)===String(Ft()))return;let Re=Y.current;_o(2,J,We,Pe,It),Re&&Re.chatType===2&&Re.peerId===J&&t.current&&t.current({groupCode:J,msgSeq:We,emojiId:Pe,userId:ot,userName:Pt,isAdd:It})}else if(de.type==="message-deleted"){let{msgId:J,msgSeq:We,chatType:Pe,peerUid:ot,peerUin:Pt}=de.data,It=Pt||ot,Re=Y.current;Ai(Pe,It,J,We),Re&&Re.chatType===Pe&&Re.peerId===It&&a.current&&a.current({msgId:J,msgSeq:We})}else if(de.type==="group-notify"){let J=de.data;O({type:"group-notify",data:J,time:J.actionTime?parseInt(J.actionTime)*1e3:Date.now()})}else if(de.type==="friend-request"){let J=de.data;O({type:"friend-request",data:J,time:J.reqTime?parseInt(J.reqTime)*1e3:Date.now()})}else de.type==="group-dismiss"?O({type:"group-dismiss",data:de.data,time:Date.now()}):de.type==="group-quit"&&O({type:"group-quit",data:de.data,time:Date.now()})},de=>{console.error("SSE \u8FDE\u63A5\u9519\u8BEF:",de)},()=>{console.log("[WebQQ] SSE \u91CD\u8FDE\u6210\u529F\uFF0C\u91CD\u7F6E\u5DF2\u8BBF\u95EE\u804A\u5929\u6807\u5FD7"),Eo(),b()});return()=>{Q.close()}},[I,A,b,O]);let Ee=Mt(Q=>{r.current=[],m(Q),v(null),Q.chatType!==2&&(L(!1),R(!1));let de=`${Q.chatType}_${Q.peerId}`;C(de),F(M.map(J=>J.chatType===Q.chatType&&J.peerId===Q.peerId?{...J,unreadCount:0}:J))},[m,C,F,M,L]),[j,ce]=Kc(!1),fe=Mt(Q=>{Ee(Q),ce(!0)},[Ee]),qe=Mt(()=>{ce(!1)},[]),P=Mt(Q=>{let de={chatType:1,peerId:Q.uin,peerName:Q.remark||Q.nickname,peerAvatar:Q.avatar};fe(de)},[fe]),$=Mt(Q=>{let de={chatType:2,peerId:Q.groupCode,peerName:Q.groupName,peerAvatar:Q.avatar};fe(de)},[fe]),ne=Mt(Q=>{let de={chatType:Q.chatType,peerId:Q.peerId,peerName:Q.peerName,peerAvatar:Q.peerAvatar};fe(de)},[fe]),ke=rt.useMemo(()=>new Map(Object.entries(h)),[h]);return c&&n.length===0&&d.length===0?at("div",{className:"flex items-center justify-center h-[calc(100vh-200px)]",children:at(K,{size:48,className:"animate-spin text-pink-500"})}):i&&n.length===0&&d.length===0?ws("div",{className:"flex flex-col items-center justify-center h-[calc(100vh-200px)] gap-4",children:[at("p",{className:"text-red-500",children:i}),at("button",{onClick:()=>b(),className:"px-4 py-2 bg-pink-500 text-white rounded-lg hover:bg-pink-600 transition-colors",children:"\u91CD\u8BD5"})]}):ws(Zc,{children:[ws("div",{className:"flex h-[calc(100vh-80px)] md:h-[calc(100vh-120px)] glass glass-regular rounded-none md:r-panel overflow-hidden",children:[at("div",{className:`
|
|
10
|
+
w-full md:w-72 md:hairline-r flex-shrink-0
|
|
11
|
+
${j?"hidden md:block":"block"}
|
|
12
|
+
`,children:at(ri,{activeTab:f,onTabChange:g,friendCategories:n,groups:d,recentChats:M,unreadCounts:ke,selectedPeerId:u?.peerId,onSelectFriend:P,onSelectGroup:$,onSelectRecent:ne})}),at("div",{className:`
|
|
13
|
+
flex-1 flex flex-col min-w-0
|
|
14
|
+
${j?"block":"hidden md:flex"}
|
|
15
|
+
`,children:at(ji,{session:u,onShowMembers:E,onShowFiles:B,onNewMessageCallback:ie,onEmojiReactionCallback:Oe,onMessageRecalledCallback:Ke,appendInputMention:H,onAppendInputMentionConsumed:q,onBack:qe,showBackButton:j})}),p&&u?.chatType===2&&at("div",{className:"fixed inset-0 z-50 bg-[rgb(var(--glass-tint)/0.92)] backdrop-blur-xl md:static md:inset-auto md:z-auto md:bg-transparent md:backdrop-blur-none md:w-64 md:hairline-l md:flex-shrink-0",children:at(Xi,{groupCode:u.peerId,onClose:()=>L(!1),onAtMember:w})}),le&&u?.chatType===2&&at("div",{className:"fixed inset-0 z-50 bg-[rgb(var(--glass-tint)/0.92)] backdrop-blur-xl md:static md:inset-auto md:z-auto md:bg-transparent md:backdrop-blur-none md:w-80 md:hairline-l md:flex-shrink-0",children:at(Qi,{groupCode:u.peerId,locateTarget:D,onClose:()=>{R(!1),v(null)}})})]}),!e&&l&&at("button",{onClick:()=>window.open(St().pageHref("webqq",{fullscreen:!0}),"_blank"),className:"fixed top-4 right-4 md:top-auto md:bottom-6 md:right-6 z-50 p-3 glass glass-chrome glass-interactive r-capsule text-[var(--accent)] transition-all duration-200 group",title:"\u5728\u65B0\u7A97\u53E3\u4E2D\u5168\u5C4F\u6253\u5F00",children:at(ja,{size:20,className:"group-hover:scale-110 transition-transform"})})]})},Ji=Jc;function Yc(e){return new Promise(o=>{let t=()=>{clearTimeout(a),e.removeEventListener("abort",t),o()},a=setTimeout(t,2e3);e.addEventListener("abort",t,{once:!0}),e.aborted&&t()})}async function Zi(e,o,t,a){for(;!o.aborted;){try{let r=await e(o);if(o.aborted)return;if(r.online&&r.uin&&r.uid)return a?.(r),r;t({message:"NTQQ \u8D26\u53F7\u8FD8\u6CA1\u6709\u767B\u5F55\uFF0C\u767B\u5F55\u540E\u4F1A\u81EA\u52A8\u8FDB\u5165\u804A\u5929",error:!1})}catch(r){if(o.aborted)return;t({message:r instanceof Error?r.message:"\u83B7\u53D6\u767B\u5F55\u4FE1\u606F\u5931\u8D25",error:!0})}await Yc(o)}}import{jsx as Co,jsxs as td}from"react/jsx-runtime";var of=()=>{let{fullscreen:e}=tf(),{setCollapsed:o}=af(),{autoHideSidebar:t}=nr(),a=ef()?.find(d=>d.platform==="ntqq"),[r,s]=ed(null),[l,n]=ed(null);return Yi(()=>{t&&!e&&o(!0)},[t,e,o]),Yi(()=>{let d=new AbortController;return s(null),n(null),Zi(Zn,d.signal,n,c=>{Qn(c.uid,c.uin),vi(c.uin),Ql(c.uin)}).then(c=>{!c||d.signal.aborted||(n(null),s(c.uin))}),()=>d.abort()},[a?.selfId,a?.status]),l?td("div",{className:"card p-6 flex items-center gap-3 text-sm",role:"status",children:[Co(K,{size:18,className:"animate-spin text-pink-500 shrink-0"}),td("div",{className:l.error?"text-red-500":"text-theme-secondary",children:[l.message,l.error&&Co("p",{className:"mt-1 text-xs text-theme-muted",children:"\u6B63\u5728\u91CD\u8BD5\u8FDE\u63A5..."})]})]}):r?Co(Ji,{isFullscreen:e},r):Co("div",{className:"flex justify-center py-16",children:Co(K,{size:40,className:"animate-spin text-pink-500"})})},YC=of;export{YC as default};
|
|
16
|
+
/*! Bundled license information:
|
|
17
|
+
|
|
18
|
+
lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs:
|
|
19
|
+
lucide-react/dist/esm/shared/src/utils/toLucideIconData.mjs:
|
|
20
|
+
lucide-react/dist/esm/shared/src/utils/toCamelCase.mjs:
|
|
21
|
+
lucide-react/dist/esm/shared/src/utils/toPascalCase.mjs:
|
|
22
|
+
lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs:
|
|
23
|
+
lucide-react/dist/esm/shared/src/build/defaultAttributes.mjs:
|
|
24
|
+
lucide-react/dist/esm/shared/src/build/buildLucideIconNode.mjs:
|
|
25
|
+
lucide-react/dist/esm/shared/src/build/buildLucideIconForReact.mjs:
|
|
26
|
+
lucide-react/dist/esm/shared/src/utils/hasA11yProp.mjs:
|
|
27
|
+
lucide-react/dist/esm/context.mjs:
|
|
28
|
+
lucide-react/dist/esm/Icon.mjs:
|
|
29
|
+
lucide-react/dist/esm/createLucideIcon.mjs:
|
|
30
|
+
lucide-react/dist/esm/icons/archive.mjs:
|
|
31
|
+
lucide-react/dist/esm/icons/arrow-down.mjs:
|
|
32
|
+
lucide-react/dist/esm/icons/arrow-left.mjs:
|
|
33
|
+
lucide-react/dist/esm/icons/at-sign.mjs:
|
|
34
|
+
lucide-react/dist/esm/icons/award.mjs:
|
|
35
|
+
lucide-react/dist/esm/icons/ban.mjs:
|
|
36
|
+
lucide-react/dist/esm/icons/bell-off.mjs:
|
|
37
|
+
lucide-react/dist/esm/icons/bell.mjs:
|
|
38
|
+
lucide-react/dist/esm/icons/calendar.mjs:
|
|
39
|
+
lucide-react/dist/esm/icons/check.mjs:
|
|
40
|
+
lucide-react/dist/esm/icons/chevron-down.mjs:
|
|
41
|
+
lucide-react/dist/esm/icons/chevron-right.mjs:
|
|
42
|
+
lucide-react/dist/esm/icons/circle-exclamation-point.mjs:
|
|
43
|
+
lucide-react/dist/esm/icons/clock.mjs:
|
|
44
|
+
lucide-react/dist/esm/icons/crown.mjs:
|
|
45
|
+
lucide-react/dist/esm/icons/download.mjs:
|
|
46
|
+
lucide-react/dist/esm/icons/face-slightly-smiling.mjs:
|
|
47
|
+
lucide-react/dist/esm/icons/file-text.mjs:
|
|
48
|
+
lucide-react/dist/esm/icons/folder-open.mjs:
|
|
49
|
+
lucide-react/dist/esm/icons/folder-plus.mjs:
|
|
50
|
+
lucide-react/dist/esm/icons/folder.mjs:
|
|
51
|
+
lucide-react/dist/esm/icons/forward.mjs:
|
|
52
|
+
lucide-react/dist/esm/icons/hand.mjs:
|
|
53
|
+
lucide-react/dist/esm/icons/image.mjs:
|
|
54
|
+
lucide-react/dist/esm/icons/list-checks.mjs:
|
|
55
|
+
lucide-react/dist/esm/icons/loader-circle.mjs:
|
|
56
|
+
lucide-react/dist/esm/icons/log-out.mjs:
|
|
57
|
+
lucide-react/dist/esm/icons/maximize-2.mjs:
|
|
58
|
+
lucide-react/dist/esm/icons/message-circle.mjs:
|
|
59
|
+
lucide-react/dist/esm/icons/moon.mjs:
|
|
60
|
+
lucide-react/dist/esm/icons/paperclip.mjs:
|
|
61
|
+
lucide-react/dist/esm/icons/pause.mjs:
|
|
62
|
+
lucide-react/dist/esm/icons/pencil.mjs:
|
|
63
|
+
lucide-react/dist/esm/icons/pin.mjs:
|
|
64
|
+
lucide-react/dist/esm/icons/play.mjs:
|
|
65
|
+
lucide-react/dist/esm/icons/refresh-cw.mjs:
|
|
66
|
+
lucide-react/dist/esm/icons/reply.mjs:
|
|
67
|
+
lucide-react/dist/esm/icons/search.mjs:
|
|
68
|
+
lucide-react/dist/esm/icons/send.mjs:
|
|
69
|
+
lucide-react/dist/esm/icons/shield-exclamation-point.mjs:
|
|
70
|
+
lucide-react/dist/esm/icons/shield-off.mjs:
|
|
71
|
+
lucide-react/dist/esm/icons/shield.mjs:
|
|
72
|
+
lucide-react/dist/esm/icons/star.mjs:
|
|
73
|
+
lucide-react/dist/esm/icons/sticker.mjs:
|
|
74
|
+
lucide-react/dist/esm/icons/sun.mjs:
|
|
75
|
+
lucide-react/dist/esm/icons/trash.mjs:
|
|
76
|
+
lucide-react/dist/esm/icons/triangle-exclamation-point.mjs:
|
|
77
|
+
lucide-react/dist/esm/icons/upload.mjs:
|
|
78
|
+
lucide-react/dist/esm/icons/user-minus.mjs:
|
|
79
|
+
lucide-react/dist/esm/icons/user-plus.mjs:
|
|
80
|
+
lucide-react/dist/esm/icons/user.mjs:
|
|
81
|
+
lucide-react/dist/esm/icons/users.mjs:
|
|
82
|
+
lucide-react/dist/esm/icons/volume-x.mjs:
|
|
83
|
+
lucide-react/dist/esm/icons/x.mjs:
|
|
84
|
+
lucide-react/dist/esm/lucide-react.mjs:
|
|
85
|
+
(**
|
|
86
|
+
* @license lucide-react v1.73.0 - ISC
|
|
87
|
+
*
|
|
88
|
+
* This source code is licensed under the ISC license.
|
|
89
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
90
|
+
*)
|
|
91
|
+
*/
|