import{u as _e}from"./vue-i18n-90d534a9.js";import{u as be}from"./vue-router-7f882520.js";import{c as pe,a as we,u as De,E as Se,i as Te,b as re,d as he,D as Le,n as me,b9 as Me,b0 as Oe,g as te,f as se,ax as Ae,aw as fe,p as Ee,M as $e,J as Ne,aT as Pe,at as Re,w as ve,v as Fe,l as Ge,I as B,P as Y,q as Z,t as Ue,Y as Be,y as Ve}from"./index-ae60edf9.js";import"./index-fc073ec7.js";import{S as Je}from"./index-7aceb4e5.js";import{_ as ze}from"./index.vue_vue_type_script_setup_true_lang-1170722e.js";import{D as ne}from"./index-b61dcf4f.js";import{_ as Q}from"./index.vue_vue_type_script_setup_true_lang-e7eadba1.js";import{_ as je}from"./index.vue_vue_type_script_setup_true_lang-bf293ef7.js";import{V as ie}from"./virtual-list-b1ee24f1.js";import{C as i}from"./data-7f4000cb.js";import{u as He}from"./useSendMessage-e9c396f5.js";import{S as Ke}from"./open-im-sdk-wasm-f19f04ec.js";import{d as oe,b as L,k as P,j as Xe,w as le,$ as y,T as Ye,n as qe,l as Ze,ar as Qe,o as w,c as H,u as d,O as V,P as J,aX as ce,a as N,bj as ue,F as W,aI as de}from"./@vue-cb50a1c4.js";import{s as We}from"./function-call-079e4448.js";import"./@intlify-1c0af683.js";import"./dayjs-4460abc8.js";import"./@amap-aca98dec.js";import"./pinia-de4079f2.js";import"./axios-7d5a0a64.js";import"./form-data-497f8b5e.js";import"./uuid-a960c1f4.js";import"./date-fns-f56f60e6.js";import"./@babel-7fd5df1e.js";import"./mitt-f7ef348c.js";import"./@vueuse-19adab01.js";import"./livekit-client-ca552de3.js";import"./@livekit-3058dbe8.js";import"./loglevel-e40a507a.js";import"./rxjs-2154ddb2.js";import"./tslib-8dbab242.js";import"./@vuemap-5ebdc63e.js";import"./lodash-es-91418b19.js";import"./use-id-22cfdfcf.js";import"./index-597402db.js";import"./arrows_left-f963ef62.js";import"./back-099fa84a.js";import"./index-e4a7d928.js";function et(){const r="A".charCodeAt(0);return Array(26).fill("").map((a,D)=>String.fromCharCode(r+D))}const[ge,ee]=pe("index-bar"),tt={sticky:Le,zIndex:me,teleport:[String,Object],highlightColor:String,stickyOffsetTop:Me(0),indexList:{type:Array,default:et}},xe=Symbol(ge);var st=oe({name:ge,props:tt,emits:["select","change"],setup(r,{emit:x,slots:a}){const D=L(),O=L(),v=L(""),k=we(),S=De(D),{children:c,linkChildren:T}=Se(xe);let p;T({props:r});const I=P(()=>{if(Te(r.zIndex))return{zIndex:+r.zIndex+1}}),u=P(()=>{if(r.highlightColor)return{color:r.highlightColor}}),h=(s,n)=>{for(let m=c.length-1;m>=0;m--){const g=m>0?n[m-1].height:0,f=r.sticky?g+r.stickyOffsetTop:0;if(s+f>=n[m].top)return m}return-1},F=s=>c.find(n=>String(n.index)===s),C=()=>{if(Oe(D))return;const{sticky:s,indexList:n}=r,m=te(S.value),g=se(S),f=c.map($=>$.getRect(S.value,g));let _=-1;if(p){const $=F(p);if($){const b=$.getRect(S.value,g);_=h(b.top,f)}}else _=h(m,f);v.value=n[_],s&&c.forEach(($,b)=>{const{state:e,$el:t}=$;if(b===_||b===_-1){const o=t.getBoundingClientRect();e.left=o.left,e.width=o.width}else e.left=null,e.width=null;if(b===_)e.active=!0,e.top=Math.max(r.stickyOffsetTop,f[b].top-m)+g.top;else if(b===_-1&&p===""){const o=f[_].top-m;e.active=o>0,e.top=o+g.top-f[b].height}else e.active=!1}),p=""},K=()=>{qe(C)};re("scroll",C,{target:S,passive:!0}),Xe(K),le(()=>r.indexList,K),le(v,s=>{s&&x("change",s)});const X=()=>r.indexList.map(s=>{const n=s===v.value;return y("span",{class:ee("index",{active:n}),style:n?u.value:void 0,"data-index":s},[s])}),G=s=>{p=String(s);const n=F(p);if(n){const m=te(S.value),g=se(S),{offsetHeight:f}=document.documentElement;if(n.$el.scrollIntoView(),m===f-g.height){C();return}r.sticky&&r.stickyOffsetTop&&Ae(fe()-r.stickyOffsetTop),x("select",n.index)}},A=s=>{const{index:n}=s.dataset;n&&G(n)},z=s=>{A(s.target)};let U;const q=s=>{if(k.move(s),k.isVertical()){Ee(s);const{clientX:n,clientY:m}=s.touches[0],g=document.elementFromPoint(n,m);if(g){const{index:f}=g.dataset;f&&U!==f&&(U=f,A(g))}}},E=()=>y("div",{ref:O,class:ee("sidebar"),style:I.value,onClick:z,onTouchstartPassive:k.start},[X()]);return he({scrollTo:G}),re("touchmove",q,{target:O}),()=>{var s;return y("div",{ref:D,class:ee()},[r.teleport?y(Ye,{to:r.teleport},{default:()=>[E()]}):E(),(s=a.default)==null?void 0:s.call(a)])}}});const[ot,at]=pe("index-anchor"),rt={index:me};var nt=oe({name:ot,props:rt,setup(r,{slots:x}){const a=Ze({top:0,left:null,rect:{top:0,height:0},width:null,active:!1}),D=L(),{parent:O}=$e(xe);if(!O)return;const v=()=>a.active&&O.props.sticky,k=P(()=>{const{zIndex:c,highlightColor:T}=O.props;if(v())return Ne(Pe(c),{left:a.left?`${a.left}px`:void 0,width:a.width?`${a.width}px`:void 0,transform:a.top?`translate3d(0, ${a.top}px, 0)`:void 0,color:T})});return he({state:a,getRect:(c,T)=>{const p=se(D);return a.rect.height=p.height,c===window||c===document.body?a.rect.top=p.top+fe():a.rect.top=p.top+te(c)-T.top,a.rect}}),()=>{const c=v();return y("div",{ref:D,style:{height:c?`${a.rect.height}px`:void 0}},[y("div",{style:k.value,class:[at({sticky:c}),{[Re]:c}]},[x.default?x.default():r.index])])}}});const it=ve(nt),lt=ve(st);const ct={class:"page_container"},ut=N("div",{class:"mb-[10px]"},null,-1),dt={key:1,class:"flex h-[28px] items-center justify-start pl-5 text-xs text-sub-text"},pt={class:"flex-1 overflow-hidden"},ht={class:"flex h-screen flex-col"},mt={class:"flex justify-between bg-white px-[22px] pt-3"},ft=N("div",null,null,-1),vt={class:"flex-1 overflow-x-hidden overflow-y-scroll bg-white"},ts=oe({__name:"index",setup(r){const{t:x}=_e(),a=[{idx:0,title:x("contactMenu.myGoodFriend")},{idx:1,title:x("contactMenu.myGroup")}],D=[i.ForwardMessage,i.MergeMessage,i.ShareCard,i.MomentsPermissionUser],O=[i.ForwardMessage,i.MergeMessage,i.ShareCard],v=be(),k=Fe(),S=Ge(),{sendMessage:c}=He(),T=L(0),p=L(!1),I=L(""),u=L([]),h=L([]),F=L([]),C=history.state.chooseType,K=P(()=>D.includes(C)),X=P(()=>O.includes(C)),G=P(()=>[...u.value,...h.value]),A=P(()=>Ve(I.value?k.storeFriendList.filter(e=>e.nickname.includes(I.value)):k.storeFriendList)),z=S.storeConversationList.filter(e=>e.conversationType!==Ke.Notification&&(I.value?e.showName.includes(I.value):!0)),U=P(()=>I.value?k.storeGroupList.filter(e=>e.groupName.includes(I.value)):k.storeGroupList),q=C!==i.LaunchGroup,E=C!==i.ChooseCard;Qe(()=>{const e=history.state;u.value=e.prevCheckedUserList?JSON.parse(e.prevCheckedUserList):[],h.value=e.prevCheckedGroupList?JSON.parse(e.prevCheckedGroupList):[],s()});const s=()=>{history.state.chooseType===i.InviteGroup&&B.getSpecifiedGroupMembersInfo({groupID:history.state.extraData,userIDList:k.storeFriendList.map(e=>e.userID)}).then(({data:e})=>{F.value=e.map(t=>t.userID)})},n=e=>{p.value=!0,T.value=e},m=e=>{e.userID?f(e):_(e)},g=e=>{F.value.includes(e.userID)||(E?f(e):We({message:x("messageTip.sendCard",{name:e.nickname}),beforeClose:t=>new Promise(async o=>{if(t==="confirm"){const R=(await B.createCardMessage(e)).data;await c({message:R}),o(!0),setTimeout(()=>Y.emit("CHAT_MAIN_SCROLL_TO_BOTTOM",!1)),v.back()}else o(!0)})}))},f=e=>{const t=u.value.findIndex(o=>o.userID===e.userID);if(t>-1){const o=[...u.value];o.splice(t,1),u.value=[...o]}else u.value=[...u.value,e]},_=e=>{const t=h.value.findIndex(o=>o.groupID===e.groupID);if(t>-1){const o=[...h.value];o.splice(t,1),h.value=[...o]}else h.value=[...h.value,e]},$=e=>{if(e.groupID){const t=h.value.findIndex(R=>R.groupID===e.groupID),o=[...h.value];o.splice(t,1),h.value=[...o]}else{const t=u.value.findIndex(R=>R.userID===e.userID),o=[...u.value];o.splice(t,1),u.value=[...o]}},b=async()=>{switch(console.log("confirm"),C){case i.LaunchGroup:v.replace({path:"createGroup",state:{prevCheckedUserList:JSON.stringify(u.value),extraData:history.state.extraData}}),v.go(-1);break;case i.ForwardMessage:case i.MergeMessage:case i.ShareCard:G.value.map(async e=>{let t;C===i.ForwardMessage?t=(await B.createForwardMessage(JSON.parse(history.state.extraData))).data:C===i.MergeMessage?t=(await B.createMergerMessage(JSON.parse(history.state.extraData))).data:t=(await B.createCardMessage(JSON.parse(history.state.extraData))).data,await c({message:t,recvID:e.userID,groupID:e.groupID})}),Y.emit("UPDATE_MULTIPLE_CHECK_STATE",!1),Z({message:x("messageTip.sendSuccess"),onClose:v.back});break;case i.InviteGroup:B.inviteUserToGroup({groupID:history.state.extraData,userIDList:G.value.map(e=>e.userID),reason:""}).then(()=>Z({message:x("messageTip.inviteSuccess")})).catch(()=>Z({message:x("messageTip.inviteFailed")})).finally(()=>v.back());break;case i.MomentsUser:Y.emit("MOMENTS_SELECT_AT_USER",JSON.stringify(u.value)),v.back();break;case i.MomentsPermissionUser:Y.emit("MOMENTS_SELECT_PERMISSION_USER",JSON.stringify({userList:u.value,groupList:h.value})),v.back();break}};return(e,t)=>{const o=Je,R=Ue,ye=it,Ie=lt,ke=Be;return w(),H("div",ct,[y(ze,{router:q,title:e.$t("contactMenu.contacts"),onLeftClick:b},null,8,["title"]),y(o,{modelValue:I.value,"onUpdate:modelValue":t[0]||(t[0]=l=>I.value=l),placeholder:e.$t("placeholder.search")},null,8,["modelValue","placeholder"]),ut,y(ne,{arrow:"",lable:a[0].title,content:"",onClick:t[1]||(t[1]=l=>n(a[0].idx))},null,8,["lable"]),d(K)?(w(),V(ne,{key:0,arrow:"",lable:a[1].title,content:"",onClick:t[2]||(t[2]=l=>n(a[1].idx))},null,8,["lable"])):J("",!0),d(X)?(w(),H("div",dt,ce(e.$t("contactMenu.recentSession")),1)):J("",!0),N("div",pt,[d(X)&&d(z).length>0?(w(),V(d(ie),{key:0,class:"my_scrollbar h-full overflow-scroll bg-white","data-key":"groupID","data-sources":d(z),"data-component":Q,"estimate-size":88,"extra-props":l=>({total:d(z).length,showCheck:E,checked:!![...h.value,...u.value].find(M=>M.groupID&&M.groupID===l.groupID||M.userID&&M.userID===l.userID),onClick:()=>m(l)})},null,8,["data-sources","extra-props"])):J("",!0)]),E?(w(),V(je,{key:2,"all-checked-list":d(G),total:999,onRemove:$,onConfirm:b},null,8,["all-checked-list"])):J("",!0),y(ke,{show:p.value,"onUpdate:show":t[5]||(t[5]=l=>p.value=l),position:"bottom",round:"",onClickOverlay:t[6]||(t[6]=l=>p.value=!1),class:"!bg-[#F7F7F7]"},{default:ue(()=>[N("div",ht,[N("div",mt,[N("div",{onClick:t[3]||(t[3]=l=>p.value=!1)},[y(R,{name:"arrow-down"})]),N("div",null,ce(a[T.value].title),1),ft]),y(o,{modelValue:I.value,"onUpdate:modelValue":t[4]||(t[4]=l=>I.value=l),placeholder:e.$t("placeholder.search")},null,8,["modelValue","placeholder"]),N("div",vt,[T.value===0&&d(A).indexList.length>0?(w(),V(Ie,{key:0,"index-list":d(A).indexList},{default:ue(()=>[(w(!0),H(W,null,de(d(A).indexList,(l,M)=>(w(),H(W,null,[y(ye,{index:l},null,8,["index"]),(w(!0),H(W,null,de(d(A).dataList[M],(j,Ce)=>(w(),V(Q,{class:"bg-white",key:j.userID,source:j,total:d(A).dataList[M].length,index:Ce,showCheck:E,disabled:F.value.includes(j.userID),checked:u.value.findIndex(ae=>ae.userID===j.userID)>-1,onClick:ae=>g(j)},null,8,["source","total","index","disabled","checked","onClick"]))),128))],64))),256))]),_:1},8,["index-list"])):J("",!0),T.value===1&&d(U).length>0?(w(),V(d(ie),{key:1,class:"my_scrollbar h-full overflow-y-auto overflow-x-hidden bg-white","data-key":"groupID","data-sources":d(U),"data-component":Q,"estimate-size":88,"extra-props":l=>({subKey:"memberCount",total:d(U).length,showCheck:E,checked:h.value.findIndex(M=>M.groupID===l.groupID)>-1,onClick:()=>_(l)})},null,8,["data-sources","extra-props"])):J("",!0)])])]),_:1},8,["show"])])}}});export{ts as default};