import{c as H,o as $,a as w,J as W,j as C,e as E,p as dt,q as z,m as bt,D as I,B as Ht,a2 as Ct,b as _t,F as nt,I as lt,_ as vt,s as Q,M as Tt,x as gt,A as U,P as it,Z as Yt}from"./vue-vendor-BOX7Kenj.js";import Lt from"./LayoutExperience-D6yoiMh6.js";import xt from"./ContentContainer-DTYObT5L.js";import{C as It}from"./ChatAsideMenu-C-shzSsG.js";/* empty css */import{R as Ot}from"./index-bj4xFXb1.js";/* empty css */import{S as $t}from"./index-DhKoY12H.js";import{k as At,G as ft,_ as Z,H as Nt,K as Mt,u as jt,M as zt,L as Bt,N as Dt,O as Et,B as Vt,P as Wt}from"./index-_atq84Ji.js";import{M as ht}from"./index-ugL_7kbA.js";import"./index-BgDRZce_.js";import"./index-B3rE5vt3.js";/* empty css *//* empty css */import{a as Rt}from"./api-conversation-board-DAbGckM4.js";import{u as Ft}from"./use-all-agents-CZkOEwaY.js";import{g as mt}from"./icon-map-MpRwWyE4.js";import{D as Ut,a as qt,E as Jt}from"./index-BlAITTqL.js";import"./Header-yzyZK0DX.js";import"./index-BHTmVRE6.js";import"./use-platform-information-GvgnOcMD.js";import"./use-logout-Ba_afPHl.js";import"./use-current-user-CN6jUr4a.js";import"./login-QSRFfQ9t.js";/* empty css */import"./index-B4JT3Sd4.js";import"./index-C38sh2pa.js";var St={exports:{}};(function(s,h){(function(i,o){s.exports=o()})(ft,function(){var i=1e3,o=6e4,f=36e5,g="millisecond",a="second",l="minute",c="hour",m="day",S="week",M="month",k="quarter",p="year",T="date",x="Invalid Date",X=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,R=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,q={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(u){var n=["th","st","nd","rd"],t=u%100;return"["+u+(n[(t-20)%10]||n[t]||n[0])+"]"}},V=function(u,n,t){var r=String(u);return!r||r.length>=n?u:""+Array(n+1-r.length).join(t)+u},tt={s:V,z:function(u){var n=-u.utcOffset(),t=Math.abs(n),r=Math.floor(t/60),e=t%60;return(n<=0?"+":"-")+V(r,2,"0")+":"+V(e,2,"0")},m:function u(n,t){if(n.date()1)return u(_[0])}else{var D=n.name;F[D]=n,e=D}return!r&&e&&(J=e),e||!r&&J},y=function(u,n){if(ot(u))return u.clone();var t=typeof n=="object"?n:{};return t.date=u,t.args=arguments,new N(t)},v=tt;v.l=Y,v.i=ot,v.w=function(u,n){return y(u,{locale:n.$L,utc:n.$u,x:n.$x,$offset:n.$offset})};var N=function(){function u(t){this.$L=Y(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[ct]=!0}var n=u.prototype;return n.parse=function(t){this.$d=function(r){var e=r.date,d=r.utc;if(e===null)return new Date(NaN);if(v.u(e))return new Date;if(e instanceof Date)return new Date(e);if(typeof e=="string"&&!/Z$/i.test(e)){var _=e.match(X);if(_){var D=_[2]-1||0,b=(_[7]||"0").substring(0,3);return d?new Date(Date.UTC(_[1],D,_[3]||1,_[4]||0,_[5]||0,_[6]||0,b)):new Date(_[1],D,_[3]||1,_[4]||0,_[5]||0,_[6]||0,b)}}return new Date(e)}(t),this.init()},n.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},n.$utils=function(){return v},n.isValid=function(){return this.$d.toString()!==x},n.isSame=function(t,r){var e=y(t);return this.startOf(r)<=e&&e<=this.endOf(r)},n.isAfter=function(t,r){return y(t)o.value.length!==0),g=m=>{o.value=m.target.value},a=m=>{o.value=m.target.value},l=m=>{m.keyCode===13&&i("search",o.value)},c=()=>{o.value="",i("search",o.value)};return(m,S)=>{const M=dt("icon-search"),k=dt("icon-close");return $(),H("div",Xt,[w("div",te,[w("div",ee,[I(M)]),w("div",ne,[Ht(w("input",{type:"text",class:"search-input",placeholder:m.$t("conversation.search_history"),"onUpdate:modelValue":S[0]||(S[0]=p=>o.value=p),onInput:g,onChange:a,onKeyup:l},null,40,se),[[Ct,o.value]])]),f.value?($(),H("div",{key:0,class:"search-input-icon icon-clear",onClick:c},[I(k)])):z("",!0),bt(m.$slots,"default",{},void 0,!0)])])}}},re=Z(oe,[["__scopeId","data-v-f3dff79d"]]);var ae={exports:{}};(function(s,h){(function(i,o){s.exports=o()})(ft,function(){return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(i){var o=["th","st","nd","rd"],f=i%100;return"["+i+(o[(f-20)%10]||o[f]||o[0])+"]"}}})})(ae);const ie=1e3*60,ce=ie*60,wt=ce*24,ue=wt*30,le=()=>{const s=new Date;return s.setHours(0,0,0,0),s.getTime()},de=(s,h)=>{if(!h)return st(s).format("HH:mm");if(h==="zh")return st(s).locale("zh-cn").format("HH:mm");if(h==="en")return st(s).format("HH:mm")},pt=(s,h)=>h&&h==="zh"?st(s).locale("zh-cn").format("MM-DD"):st(s).format("MM-DD"),_e=s=>{const h=s.agent_id,i="/api/v1/chat/sessions",o={chatId:h};return"per_page"in s&&(o.pageSize=s.per_page/1),"page"in s&&(o.current=s.page/1),"search"in s&&s.search&&(o.keyword=s.search),new Promise((f,g)=>{Nt({url:i,method:"get",params:o}).then(a=>{f({code:200,data:a})}).catch(a=>{g(a)})})},he=s=>(Mt({conversation_ids:[s]}),new Promise((i,o)=>{setTimeout(()=>{i({code:200,data:!0,msg:""})},1e3)})),me={__name:"BtnHistoryItemDelete",props:{target_id:String},emits:["deleteSuccess"],setup(s,{emit:h}){const i=s,o=h,f=jt();C(1),C("");const g=()=>{const l=f.t("conversation.are_you_sure");f.t("conversation.btn_yes"),f.t("conversation.btn_no"),zt.warning({title:l,hideCancel:!1,"modal-class":"history-chat-remove-modal",onOk(c){},async onBeforeOk(){try{return await a()===200}catch{return!1}},onCancel(){}})},a=()=>new Promise((l,c)=>{he(i.target_id).then(m=>{if(m.code/1===200){const S=f.t("conversation.del_success");ht.success(S),o("deleteSuccess"),l(200)}else ht.warning(m.msg)}).catch(m=>{ht.warning(m.msg),c(m)})});return(l,c)=>{const m=dt("icon-delete");return $(),H("span",{onClick:g,class:"btn-delete"},[I(m)])}}},fe=Z(me,[["__scopeId","data-v-f9e9d87d"]]),pe=["src"],ye={class:"history-item-intro"},ve={class:"history-item-actions"},ge={class:"history-item-time"},$e={class:"history-item-delete"},Me={__name:"HistoryItem",props:{history:Object,index:Number,agent_icon:String},emits:["active","delete"],setup(s,{emit:h}){const i=s,o=h,f=C(!1),g=Bt(),a=E(()=>i.history.client_field_content_type==="label"),l=E(()=>i.history.client_field_content_type==="content"),c=E(()=>l.value&&!f.value),m=E(()=>{const p={"conversation-history-item":!0};return p[`item-${i.index}`]=!0,p[`item-${i.history.session_id}`]=!0,p[i.history.client_field_timestamp_type]=!0,a.value&&(p["conversation-history-section-title"]=!0),l.value&&(p["conversation-history-section-data"]=!0),p}),S=E(()=>{const p=i.history.client_field_timestamp_type,T=i.history.create_time,x=g.value;return p==="today"?de(T,x):p==="month"||p==="earlier"?pt(T,x):""}),M=()=>{o("active",i.history.session_id)},k=()=>{f.value=!0};return(p,T)=>($(),H(nt,null,[a.value?($(),H("div",{key:0,class:_t([m.value,"history-block-title"])},[s.history.client_field_timestamp_type==="today"?($(),H(nt,{key:0},[lt(W(p.$t("conversation.history_today")),1)],64)):z("",!0),s.history.client_field_timestamp_type==="month"?($(),H(nt,{key:1},[lt(W(p.$t("conversation.history_month")),1)],64)):z("",!0),s.history.client_field_timestamp_type==="earlier"?($(),H(nt,{key:2},[lt(W(p.$t("conversation.history_earlier")),1)],64)):z("",!0)],2)):z("",!0),c.value?($(),H("div",{key:1,class:_t(m.value)},[w("div",{class:"history-item-icon",onClick:M},[w("img",{src:s.agent_icon},null,8,pe)]),w("div",ye,[w("div",{class:"history-item-intro-title",onClick:M},W(s.history.name),1)]),w("div",ve,[w("span",ge,W(S.value),1),w("span",$e,[I(fe,{target_id:s.history.id,onDeleteSuccess:k},null,8,["target_id"])])])],2)):z("",!0)],64))}},De=Z(Me,[["__scopeId","data-v-9c2477a8"]]),Se={key:0,class:"history-item-icon can-loadmore"},ke={__name:"HistoryLoadMore",props:{can_loadmore:Boolean},emits:["loadmore"],setup(s,{emit:h}){const i=s,o=h,f=E(()=>{const a={"conversation-history-item":!0};return a["load-more"]=!0,a}),g=()=>{i.can_loadmore&&o("loadmore")};return(a,l)=>($(),H("div",{class:_t(f.value),onClick:g},[s.can_loadmore?($(),H("div",Se,W(a.$t("conversation.history_loadmore")),1)):z("",!0)],2))}},we=Z(ke,[["__scopeId","data-v-01b3fb14"]]),be={class:"conversation-history-list-section"},He={__name:"HistoryList",props:{list:Array,can_loadmore:Boolean,agent_icon:String},emits:["active","delete","loadmore"],setup(s,{emit:h}){const i=h,o=E(()=>"conversation-history-list"),f=l=>{i("active",l)},g=l=>{i("delete",l)},a=()=>{i("loadmore")};return(l,c)=>($(),H("div",be,[w("div",{class:_t(o.value)},[($(!0),H(nt,null,vt(s.list,(m,S)=>($(),Q(De,{key:m.id,history:m,index:S,agent_icon:s.agent_icon,onActive:f,onDelete:g},null,8,["history","index","agent_icon"]))),128)),I(we,{can_loadmore:s.can_loadmore,onLoadmore:a},null,8,["can_loadmore"])],2)]))}},Ce=Z(He,[["__scopeId","data-v-4bed9682"]]);function Te(s){const h=C(1),i=C(""),o=C([]);Ft();const f=()=>({});return{getAgentList:()=>{const a=f();h.value=2,i.value="",Rt(a).then(l=>{if(l.code/1===200){const c=l.data;c.length!==0&&typeof s=="function"&&s(c),c.unshift({id:"",name:"全部"}),o.value=c,console.log(o.value),h.value=3,i.value="success"}else h.value=4,i.value=err.message}).catch(l=>{console.log(l),h.value=5,i.value=l.msg})},api_status:h,api_message:i,list_agents:o}}function Ye(s){const h=Mt(s);Dt.setItem(h)}function yt(){const s=Dt.getItem(),h=Et(s);return h===null?null:h}const Le=Tt("recent_history_search_type",{state:()=>({search_type:yt()}),actions:{getType(){return this.search_type.length===0?(this.search_type=yt(),this.search_type):this.search_type},setType(s){this.search_type=s,Ye(s)}}}),xe=["src"],Ie={class:"label-text"},Oe={class:"nav-item-icon arrow-down"},Ae={class:"dropdown-container"},Ne=["src"],je={class:"dropdown-item-text"},ze={__name:"HistoryTypeDropdown",props:{list_status:Number},emits:["typeSelected"],setup(s,{emit:h}){const i=s,o=Le(),{api_status:f,list_agents:g,getAgentList:a}=Te(k=>{var p;if(o.search_type){const T=((p=o.search_type)==null?void 0:p.id)||"";let x=null;const X=k.length;for(let R=0;R{var k;return console.log("recentSearchType.search_type",o.search_type),((k=o==null?void 0:o.search_type)==null?void 0:k.name)||""}),m=E(()=>o.search_type&&o.search_type.icon?mt(o.search_type.icon):""),S=E(()=>i.list_status===2),M=k=>{o.setType(k),l("typeSelected",k)};return gt(()=>{a()}),(k,p)=>{const T=dt("icon-down"),x=Vt,X=$t,R=Ut,q=qt;return $(),Q(q,{trigger:"hover",defaultValue:c.value},{content:U(()=>[($(!0),H(nt,null,vt(it(g),(V,tt)=>($(),Q(R,{key:V.id,disabled:S.value,value:V.name,onClick:J=>M(V)},{default:U(()=>[w("div",Ae,[w("img",{src:it(mt)(V.icon),class:"agent-icon-img"},null,8,Ne),w("span",je,W(V.name),1)])]),_:2},1032,["disabled","value","onClick"]))),128))]),default:U(()=>[it(f)===1||it(f)===3?($(),Q(x,{key:0,class:"history-type-btn",type:"text"},{default:U(()=>[w("img",{src:m.value,class:"agent-icon-img"},null,8,xe),w("span",Ie,W(c.value),1),w("span",Oe,[I(T,{class:"arrow-down"})])]),_:1})):z("",!0),it(f)===2?($(),Q(x,{key:1,class:"history-type-btn",type:"text"},{default:U(()=>[I(X,{size:16})]),_:1})):z("",!0)]),_:1},8,["defaultValue"])}}},Be=Z(ze,[["__scopeId","data-v-cb594c2a"]]),Ee={class:"conversation-history-container"},Ve={class:"conversation-history-main"},We={key:1,class:"infomations-container"},Re={key:2,class:"infomations-container"},Fe={key:3,class:"infomations-container"},Ue={key:4,class:"infomations-container"},qe={__name:"ConversationHistoryContainer",emits:["historyActive"],setup(s,{emit:h}){const i=h,o=C(1),f=C(50),g=C(""),a=C(""),l=C(!0),c=C(1),m=C(""),S=C([]),M=C(0),k=C(0),p=C(0),T=C(""),x=le(),R=x-wt-ue;function q(Y){Y.forEach((y,v)=>{let N=null;const O=y,n=new Date(O.create_date).getTime();let t=null;if(isNaN(n)){const e=new Date(O.updated_time).getTime();isNaN(e)?t=Date.now():t=e}else t=n;O.create_time=t,t>=x?(M.value===0&&(N={client_field_content_type:"label",client_field_timestamp_type:"today",id:"today"}),O.client_field_timestamp_type="today",O.client_field_content_type="content",M.value=M.value+1):tR?(k.value===0&&(N={client_field_content_type:"label",client_field_timestamp_type:"month",id:"month"}),O.client_field_timestamp_type="month",O.client_field_content_type="content",k.value=k.value+1):(p.value===0&&(N={client_field_content_type:"label",client_field_timestamp_type:"earlier",id:"earlier"}),O.client_field_timestamp_type="earlier",O.client_field_content_type="content",p.value=p.value+1),N&&S.value.push(N),S.value.push(O)})}const V=()=>({search:g.value,page:o.value,per_page:f.value,agent_id:a.value}),tt=()=>{const Y=V();c.value=2,m.value="",_e(Y).then(y=>{if(y.code/1===200){const N=y.data.rows;N.length{c.value=5,m.value=y.message})},J=()=>{c.value!==2&&l.value&&(o.value=o.value+1,tt())},F=Y=>{i("historyActive",{agent_id:a.value,target_id:Y})},ct=Y=>{c.value!==2&&(g.value=Y,o.value=1,S.value=[],tt())},ot=Y=>{c.value!==2&&Y&&(M.value=0,k.value=0,p.value=0,T.value=mt(Y.icon),a.value=Y.id,o.value=1,S.value=[],tt())};return gt(()=>{}),(Y,y)=>{const v=$t,N=Jt,O=Ot;return $(),H("div",Ee,[y[1]||(y[1]=w("div",{class:"conversation-history-left"},null,-1)),w("div",Ve,[I(Qt),I(re,{onSearch:ct},{default:U(()=>[I(Be,{onTypeSelected:ot,list_status:c.value},null,8,["list_status"])]),_:1}),S.value.length!==0?($(),Q(Ce,{key:0,list:S.value,can_loadmore:l.value,agent_icon:T.value,onLoadmore:J,onActive:F},null,8,["list","can_loadmore","agent_icon"])):z("",!0),c.value===1||c.value===2?($(),H("div",We,[I(v,{size:32})])):z("",!0),c.value===3&&S.value.length===0?($(),H("div",Re,[I(N,null,{default:U(()=>[lt(W(Y.$t("conversation.history_empty")),1)]),_:1})])):z("",!0),c.value===4?($(),H("div",Fe,[I(O,{status:"warning",title:m.value},null,8,["title"])])):z("",!0),c.value===5?($(),H("div",Ue,[I(O,{status:"error",title:m.value},null,8,["title"])])):z("",!0),y[0]||(y[0]=w("div",{class:"conversation-history-placeholder"},null,-1))]),y[2]||(y[2]=w("div",{class:"conversation-history-right"},null,-1))])}}},Je=Z(qe,[["__scopeId","data-v-f10b2a3a"]]),Pe="/assets/history-bg-Cuh6wzmt.png",Sn={__name:"ConversationHistory",setup(s){const h=Yt(),i=Wt(),o=E(()=>i.value==="light"?{backgroundImage:`url(${Pe})`,backgroundRepeat:"no-repeat",backgroundSize:"cover"}:{}),f=({target_id:g,agent_id:a})=>{const l={session:g};a&&(l.agent=a),h.push({path:"/chat/qa",query:l})};return(g,a)=>($(),Q(Lt,null,{default:U(()=>[I(xt,{containerStyle:o.value,id:"fjkdsdajfklgjsklfjskdlf"},{default:U(()=>[I(It),I(Je,{onHistoryActive:f})]),_:1},8,["containerStyle"])]),_:1}))}};export{Sn as default};