import{K as ge,k as se,w as ve,C as fe,b as ye,R as ke}from"./element-plus.ff90c99c.js";import{d as xe,E as we,$ as I,r as P,i as Ee,D as Fe,o as r,c as a,a as i,W as g,Q as O,u as w,F as q,a9 as V,V as y,T as k,R as j,X as oe,bg as Ce,bf as Se}from"./@vue.f8dfc830.js";import{M as be}from"./@element-plus.0374639c.js";import{j as H,C as De,l as Le,m as Ie,R as T,n as Re,o as Te,P as Ae,f as B,p as Be,a as Me,d as Ue}from"./index.872975fb.js";import{l as Ne}from"./lodash.3e731b89.js";import{N as A}from"./nprogress.f73355d0.js";import{b as Pe}from"./axios.c2babb35.js";import"./lodash-es.a73406b7.js";import"./@vueuse.a2e59ee9.js";import"./@popperjs.36402333.js";import"./@ctrl.b082b0c1.js";import"./dayjs.7f1be2bc.js";import"./@amap.8a62addd.js";import"./async-validator.fb49d0f5.js";import"./memoize-one.4ee5c96d.js";import"./escape-html.e5dfadb9.js";import"./normalize-wheel-es.8aeb3683.js";import"./@floating-ui.34a21088.js";import"./vue-router.6d4cf914.js";import"./pinia.4b196199.js";import"./vue-demi.b3a9cad9.js";import"./css-color-function.3a7f085f.js";import"./color.5ae3e2dd.js";import"./clone.7bcb5228.js";import"./color-convert.755d189f.js";import"./color-name.e7a4e1d3.js";import"./color-string.e356f5de.js";import"./balanced-match.d2a36341.js";import"./debug.37836f15.js";import"./ms.a9ae1d6d.js";import"./vue-clipboard3.dca5bca3.js";import"./clipboard.16e4491b.js";import"./echarts.ac57a99a.js";import"./zrender.d54ce080.js";import"./tslib.60310f1a.js";import"./highlight.js.dba6fa1b.js";import"./@highlightjs.79024f1a.js";const Oe="/admin/assets/XC.f7ab4c6f.png",qe="/admin/assets/SP.95ba535e.png",Ve={requestInterceptorsHook(o){var x;A.start();const{withToken:F,isParamsToData:C}=o.requestOptions,d=o.params||{},h=o.headers||{};if(F){const v=Le();h.token=v}return C&&!Reflect.has(o,"data")&&((x=o.method)==null?void 0:x.toUpperCase())===Ie.POST&&(o.data=d,o.params={}),o.headers=h,o},requestInterceptorsCatchHook(o){return A.done(),o},async responseInterceptorsHook(o){A.done();const{isTransformResponse:F,isReturnDefaultResponse:C}=o.config.requestOptions;if(C)return o;if(!F)return o.data;const{code:d,data:h,show:x,msg:v}=o.data;switch(d){case T.SUCCESS:return x&&v&&B.msgSuccess(v),h;case T.FAIL:return x&&v&&B.msgError(v),Promise.reject(h);case T.LOGIN_FAILURE:return Re(),Te.push(Ae.LOGIN),Promise.reject();case T.OPEN_NEW_PAGE:return window.location.href=h.url,h;default:return h}},responseInterceptorsCatchHook(o){return A.done(),o.code!==Pe.exports.AxiosError.ERR_CANCELED&&o.message&&B.msgError(o.message),Promise.reject(o)}},je={timeout:H.timeout,baseURL:H.baseUrl,headers:{"Content-Type":De.JSON,version:H.version},axiosHooks:Ve,requestOptions:{isParamsToData:!0,isReturnDefaultResponse:!1,isTransformResponse:!0,urlPrefix:"",ignoreCancelToken:!1,withToken:!0,isOpenRetry:!0,retryCount:2}};function He(o){return new Be(Ne.exports.merge(je,o||{}))}const M=He(),We=o=>M.post({url:"/common/im/doBindUid",data:o}),$e=o=>M.post({url:"/common/im/sendTextMsg",data:o}),W=o=>M.post({url:"/common/im/msgList",data:o}),ne=o=>M.post({url:"/common/im/contactList",data:o}),U=o=>(Ce("data-v-981f48df"),o=o(),Se(),o),Ye={class:"box"},ze={class:"talk-list"},Ge={class:"mt-4 serch"},Je=U(()=>i("div",{style:{height:"5vh"}},null,-1)),Ke=["onClick"],Xe={class:"l"},Qe={style:{position:"relative"}},Ze={key:0,class:"brage"},et={class:"tit-a"},tt={key:0,class:"value"},st={key:1,class:"value"},ot={key:2,class:"value"},nt={class:"r"},rt={class:"talk-detail",id:"content"},at={class:"top"},it=U(()=>i("div",{style:{height:"4vh"}},null,-1)),lt={key:0,class:"my_task"},ct={class:"content"},ut={key:0},dt=["href"],_t={key:1},pt={key:1},mt={key:2},ht=["src"],gt={key:1,class:"to_task"},vt={class:"content"},ft={key:0},yt=["href"],kt={key:1},xt={key:1},wt={key:2},Et=["src"],Ft={class:"my_task"},Ct={class:"content"},St={style:{width:"120px","margin-right":"10px"}},bt=["src"],Dt=["src"],Lt={class:"bottom"},It={style:{display:"flex"}},Rt=U(()=>i("img",{class:"img_cls",src:Oe,style:{width:"50px",height:"50px"}},null,-1)),Tt=U(()=>i("img",{style:{width:"50px",height:"50px"},src:qe},null,-1)),At="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",Bt=xe({__name:"index",setup(o){const F=we("base_url").replace("adminapi",""),C=Me(),d=C.userInfo.id;let h=1,x=null;const v=I([]),$=e=>{v[0]=e.content},re=e=>{e.target.scrollTop<=0&&(h++,W({from_user_id:d,to_user_id:x,scene:1,page_no:h,page_size:10}).then(n=>{n.length<=0||(c.talkList=n.reverse().concat(c.talkList),e.target.scrollTop=100)}))};let Y=!1;const l=I([]);let z=I([]);const c=I({name:"",to_user_id:"",talkList:[],index:0});ne({user_id:d}).then(e=>{e.forEach(t=>{l.push(t),z.push(t)}),console.log(z,6666),c.name=l[0].name,c.to_user_id=l[0].id,x=l[0].id,W({from_user_id:d,to_user_id:l[0].id,scene:1,page_no:1,page_size:10}).then(t=>{c.talkList=t.reverse()})});const N=P(""),ae=()=>{ne({user_id:d,keywords:N.value}).then(e=>{l.splice(0,l.length),e.forEach(t=>{l.push(t)})})},G=e=>{var t=/^(https?:\/\/|www\.|.*\.com).*$/i;return t.test(e)},S=P(""),J=()=>{!S.value||$e({from_user_id:d,to_user_id:c.to_user_id,type:"text",content:S.value,scene:1,msg_id:E.value}).then(e=>{c.talkList.push(e),l[c.index].last_msg_content=S.value,l[c.index].last_msg_time=e.create_time,l[c.index].last_msg_type="text",D(),S.value="",R()})},ie=t=>{var t=window.event||t;t.keyCode==13&&J()};let E=P("");const R=()=>{var e=new Date().getTime(),t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var u=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(n=="x"?u:u&3|8).toString(16)});E.value=t};R();const _=I([]);let K=()=>({status:!1,localType:null,localSrc:null,type:"",percentage:0,msg_id:E.value});const le=e=>{if(console.log(e.type),!e.type.includes("image"))return se.error("\u8BF7\u9009\u62E9\u6B63\u786E\u7684\u56FE\u7247\u683C\u5F0F!!"),!1;_.push(K());let t="image";var n=_.findIndex(function(m){return m.msg_id===E.value});let u=e;_[n].type=t;const p=u;var f=new FileReader;f.readAsDataURL(p),f.onloadend=function(m){var s;_[n].status=!0,_[n].localSrc=(s=m.target)==null?void 0:s.result,D(),R()}},ce=e=>{if(!e.type.includes("video"))return se.error("\u8BF7\u9009\u62E9\u6B63\u786E\u7684\u89C6\u9891\u683C\u5F0F!!"),!1;_.push(K());let t="video";var n=_.findIndex(function(m){return m.msg_id===E.value});let u=e;_[n].type=t;const p=u;var f=new FileReader;f.readAsDataURL(p),f.onloadend=function(m){var s;_[n].status=!0,_[n].localSrc=(s=m.target)==null?void 0:s.result,D(),R()}},X=e=>{e.show==0?c.talkList.push(e.data):B.msgError(e.msg);var t=_.findIndex(function(n){return n.msg_id===e.data.msg_id});_[t].status=!1,l[c.index].last_msg_type=e.data.type,console.log(e.data)},ue=(e,t)=>{l[t].no_read_num=0,c.name=e.name,c.to_user_id=e.id,c.index=t,x=e.id,W({from_user_id:d,to_user_id:e.id,scene:1,page_no:1,page_size:10}).then(n=>{c.talkList=n.reverse(),D()})};let Q=null;Ee(()=>{Q=document.getElementById("center")});const D=()=>{setTimeout(()=>{Q.scrollTop=9999999},100)},Z=e=>{const t=new Date,n=new Date(e*1e3);if(ee(t,n)){const f=n.getHours(),m=n.getMinutes();return f+":"+(m<10?"0"+m:m)}else if(de(t,n))return"\u6628\u5929";const u=n.getMonth()+1,p=n.getDate();return u+"\u6708"+p+"\u65E5"},ee=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),de=(e,t)=>{const n=new Date(e.getFullYear(),e.getMonth(),e.getDate()-1);return ee(n,t)},L=new WebSocket("wss://worker-task.lihaink.cn/wss"),_e=e=>{console.log("WebSocket\u8FDE\u63A5\u5DF2\u6253\u5F00")},pe=e=>{let t=JSON.parse(e.data);if(Y){if(t.id){var n=l.findIndex(function(u){return u.id==t.from_user_id});t.from_user_id==c.to_user_id?(console.log(t,"\u6536\u5230scoket\u6D88\u606F"),c.talkList.push(t),l[n].last_msg_content=t.content,l[n].last_msg_time=t.create_time,l[n].last_msg_type=t.type,D()):(l[n].no_read_num++,l[n].last_msg_content=t.content,l[n].last_msg_time=t.create_time,l[n].last_msg_type=t.type)}}else{let u=JSON.parse(e.data).client_id;We({client_id:u,user_id:d,scene:1}).then(p=>{Y=!0,console.log("\u7ED1\u5B9A\u6210\u529F")})}console.log(t)},me=e=>{console.log("WebSocket\u8FDE\u63A5\u5DF2\u5173\u95ED")},he=e=>{console.error("WebSocket\u8FDE\u63A5\u53D1\u751F\u9519\u8BEF")};return L.addEventListener("open",_e),L.addEventListener("message",pe),L.addEventListener("close",me),L.addEventListener("error",he),Fe(()=>{L.close()}),(e,t)=>{const n=ve,u=fe,p=ye,f=ge,m=ke;return r(),a("div",Ye,[i("div",ze,[i("div",Ge,[g(u,{modelValue:N.value,"onUpdate:modelValue":t[0]||(t[0]=s=>N.value=s),placeholder:"\u641C\u7D22\u8054\u7CFB\u4EBA",class:"input-with-select"},{append:O(()=>[g(n,{icon:w(be),onClick:ae},null,8,["icon"])]),_:1},8,["modelValue"])]),Je,(r(!0),a(q,null,V(l,(s,b)=>(r(),a("div",{class:"contacts",key:b,onClick:te=>ue(s,b)},[i("div",Xe,[i("div",Qe,[g(p,{style:{width:"40px",height:"40px"},src:s.avatar},null,8,["src"]),s.no_read_num?(r(),a("div",Ze,y(s.no_read_num),1)):k("",!0)]),i("div",et,[i("div",null,y(s.name),1),s.last_msg_type=="text"?(r(),a("div",tt,y(s.last_msg_content),1)):k("",!0),s.last_msg_type=="image"?(r(),a("div",st,"[\u56FE\u7247]")):k("",!0),s.last_msg_type=="video"?(r(),a("div",ot,"[\u89C6\u9891]")):k("",!0)])]),i("div",nt,y(Z(s.last_msg_time)),1)],8,Ke))),128))]),i("div",rt,[i("div",at,y(c.name),1),it,i("div",{class:"center",id:"center",onScroll:re},[(r(!0),a(q,null,V(c.talkList,(s,b)=>(r(),a("div",{class:"talk",key:b},[j(i("div",{style:{"text-align":"center"}},y(Z(s.create_time)),513),[[oe,b%5==0]]),s.from_user_id==w(d)?(r(),a("div",lt,[i("div",ct,[s.type=="text"?(r(),a("div",ut,[G(s.content)?(r(),a("a",{key:0,href:s.content,target:"_blank",style:{color:"#576B95"}},y(s.content),9,dt)):(r(),a("div",_t,y(s.content),1))])):k("",!0),s.type=="image"?(r(),a("div",pt,[g(p,{style:{width:"100px",height:"auto"},src:s.content,"preview-src-list":v,onClick:te=>$(s)},null,8,["src","preview-src-list","onClick"])])):k("",!0),s.type=="video"?(r(),a("div",mt,[i("video",{controls:"",src:s.content},null,8,ht)])):k("",!0)]),g(p,{style:{width:"40px",height:"40px"},src:w(C).userInfo.avatar},null,8,["src"])])):(r(),a("div",gt,[g(p,{style:{width:"40px",height:"40px","margin-right":"5px"},src:s.from_user_avatar},null,8,["src"]),i("div",vt,[s.type=="text"?(r(),a("div",ft,[G(s.content)?(r(),a("a",{key:0,href:s.content,target:"_blank",style:{color:"#576B95"}},y(s.content),9,yt)):(r(),a("div",kt,y(s.content),1))])):k("",!0),s.type=="image"?(r(),a("div",xt,[g(p,{style:{width:"100px",height:"auto"},src:s.content,"preview-src-list":v,onClick:te=>$(s)},null,8,["src","preview-src-list","onClick"])])):k("",!0),s.type=="video"?(r(),a("div",wt,[i("video",{controls:"",src:s.content},null,8,Et)])):k("",!0)])]))]))),128)),(r(!0),a(q,null,V(_,(s,b)=>j((r(),a("div",Ft,[j((r(),a("div",Ct,[i("div",St,[s.type=="video"?(r(),a("video",{key:0,controls:"",src:s.localSrc},null,8,bt)):(r(),a("img",{key:1,controls:"",src:s.localSrc},null,8,Dt))])])),[[m,!0]]),g(p,{style:{width:"40px",height:"40px","margin-right":"10px"},src:At})],512)),[[oe,s.status]])),256))],32),i("div",Lt,[i("div",It,[g(f,{action:w(F)+"/common/im/sendFileMsg",data:{from_user_id:w(d),to_user_id:c.to_user_id,scene:1,type:"image",msg_id:w(E)},multiple:"","show-file-list":!1,"on-success":X,"before-upload":le},{default:O(()=>[Rt]),_:1},8,["action","data"]),g(f,{action:w(F)+"/common/im/sendFileMsg",data:{from_user_id:w(d),to_user_id:c.to_user_id,scene:1,type:"video",msg_id:w(E)},multiple:"","show-file-list":!1,"on-success":X,"before-upload":ce},{default:O(()=>[Tt]),_:1},8,["action","data"])]),g(u,{modelValue:S.value,"onUpdate:modelValue":t[1]||(t[1]=s=>S.value=s),style:{border:"none",outline:"none"},placeholder:"\u8BF7\u8F93\u5165...",onKeydown:t[2]||(t[2]=s=>ie(e.event))},null,8,["modelValue"]),i("div",{class:"send-btn",onClick:J},"\u53D1\u9001")])])])}}});const fs=Ue(Bt,[["__scopeId","data-v-981f48df"]]);export{fs as default};