import{c as H,o as $,a as w,G as W,f as C,e as E,l as dt,m as N,k as bt,B as I,z as Ht,$ as Ct,b as _t,P as nt,F as lt,X as vt,p as Q,J as Yt,u as gt,y as U,V as it,W as Lt}from"./vue-vendor-DFp1TAzT.js";import Tt from"./LayoutExperience-C3ahvMz_.js";import xt from"./ContentContainer-BkDr8C6J.js";import{C as It}from"./ChatAsideMenu-Cwns4euQ.js";/* empty css */import{R as Ot}from"./index-U3R6SK30.js";/* empty css */import{S as $t}from"./index-BxD3mOH6.js";import{_ as Z}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{g as At,w as ft,x as jt,A as Mt,u as Nt,M as zt,C as Bt,D as Dt,E as Et,B as Vt,F as Wt}from"./index-DnA7c2zK.js";import{M as ht}from"./index-DigFQsek.js";import"./index-hmv2WlAb.js";import{D as Ft,a as Rt,E as Ut}from"./index-5eccc1md.js";/* empty css *//* empty css */import{a as Jt}from"./api-conversation-board-CVJtKW8T.js";import{u as qt}from"./use-all-agents-bqejCrim.js";import{g as mt}from"./icon-map-MpRwWyE4.js";import"./Header-lDD5HsBz.js";import"./index-OgjmcynJ.js";import"./use-logout-DDPtkfbU.js";import"./use-current-user-B4spLlql.js";import"./login-C8fAoDY3.js";/* empty css */import"./index-DSNA9Bkq.js";import"./index-DSCt_yo-.js";var St={exports:{}};(function(s,l){(function(a,o){s.exports=o()})(ft,function(){var a=1e3,o=6e4,y=36e5,M="millisecond",d="second",m="minute",u="hour",i="day",g="week",D="month",k="quarter",f="year",Y="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+)?$/,F=/\[([^\]]+)]|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,J={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(c){var n=["th","st","nd","rd"],t=c%100;return"["+c+(n[(t-20)%10]||n[t]||n[0])+"]"}},V=function(c,n,t){var r=String(c);return!r||r.length>=n?c:""+Array(n+1-r.length).join(t)+c},tt={s:V,z:function(c){var n=-c.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 c(n,t){if(n.date()1)return c(h[0])}else{var S=n.name;R[S]=n,e=S}return!r&&e&&(q=e),e||!r&&q},v=function(c,n){if(ot(c))return c.clone();var t=typeof n=="object"?n:{};return t.date=c,t.args=arguments,new z(t)},p=tt;p.l=L,p.i=ot,p.w=function(c,n){return v(c,{locale:n.$L,utc:n.$u,x:n.$x,$offset:n.$offset})};var z=function(){function c(t){this.$L=L(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[ct]=!0}var n=c.prototype;return n.parse=function(t){this.$d=function(r){var e=r.date,_=r.utc;if(e===null)return new Date(NaN);if(p.u(e))return new Date;if(e instanceof Date)return new Date(e);if(typeof e=="string"&&!/Z$/i.test(e)){var h=e.match(X);if(h){var S=h[2]-1||0,b=(h[7]||"0").substring(0,3);return _?new Date(Date.UTC(h[1],S,h[3]||1,h[4]||0,h[5]||0,h[6]||0,b)):new Date(h[1],S,h[3]||1,h[4]||0,h[5]||0,h[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 p},n.isValid=function(){return this.$d.toString()!==x},n.isSame=function(t,r){var e=v(t);return this.startOf(r)<=e&&e<=this.endOf(r)},n.isAfter=function(t,r){return v(t)o.value.length!==0),M=i=>{o.value=i.target.value},d=i=>{o.value=i.target.value},m=i=>{i.keyCode===13&&a("search",o.value)},u=()=>{o.value="",a("search",o.value)};return(i,g)=>{const D=dt("icon-search"),k=dt("icon-close");return $(),H("div",Xt,[w("div",te,[w("div",ee,[I(D)]),w("div",ne,[Ht(w("input",{type:"text",class:"search-input",placeholder:i.$t("conversation.search_history"),"onUpdate:modelValue":g[0]||(g[0]=f=>o.value=f),onInput:M,onChange:d,onKeyup:m},null,40,se),[[Ct,o.value]])]),y.value?($(),H("div",{key:0,class:"search-input-icon icon-clear",onClick:u},[I(k)])):N("",!0),bt(i.$slots,"default",{},void 0,!0)])])}}},re=Z(oe,[["__scopeId","data-v-1dec778c"]]);var ae={exports:{}};(function(s,l){(function(a,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(a){var o=["th","st","nd","rd"],y=a%100;return"["+a+(o[(y-20)%10]||o[y]||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,l)=>{if(!l)return st(s).format("HH:mm");if(l==="zh")return st(s).locale("zh-cn").format("HH:mm");if(l==="en")return st(s).format("HH:mm")},pt=(s,l)=>l&&l==="zh"?st(s).locale("zh-cn").format("MM-DD"):st(s).format("MM-DD"),_e=s=>{const l=s.agent_id;if(!l)return Promise.reject(new Error("前端异常:Invalid Agent ID"));const a=`/api/agent/${l}/sessions`,o={};return"per_page"in s&&(o.limit=s.per_page/1),"page"in s&&(o.page=s.page/1),"search"in s&&s.search&&(o.keyword=s.search),jt({url:a,method:"get",params:o})},he=s=>(Mt({conversation_ids:[s]}),new Promise((a,o)=>{setTimeout(()=>{a({code:200,data:!0,msg:""})},1e3)})),me={__name:"BtnHistoryItemDelete",props:{target_id:String},emits:["deleteSuccess"],setup(s,{emit:l}){const a=s,o=l,y=Nt();C(1),C("");const M=()=>{const m=y.t("conversation.are_you_sure");y.t("conversation.btn_yes"),y.t("conversation.btn_no"),zt.warning({title:m,hideCancel:!1,"modal-class":"history-chat-remove-modal",onOk(u){},async onBeforeOk(){try{return await d()===200}catch{return!1}},onCancel(){}})},d=()=>new Promise((m,u)=>{he(a.target_id).then(i=>{if(i.code/1===200){const g=y.t("conversation.del_success");ht.success(g),o("deleteSuccess"),m(200)}else ht.warning(i.msg)}).catch(i=>{ht.warning(i.msg),u(i)})});return(m,u)=>{const i=dt("icon-delete");return $(),H("span",{onClick:M,class:"btn-delete"},[I(i)])}}},fe=Z(me,[["__scopeId","data-v-6d4c8119"]]),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:l}){const a=s,o=l,y=C(!1),M=Bt(),d=E(()=>a.history.client_field_content_type==="label"),m=E(()=>a.history.client_field_content_type==="content"),u=E(()=>m.value&&!y.value),i=E(()=>{const f={"conversation-history-item":!0};return f[`item-${a.index}`]=!0,f[`item-${a.history.id}`]=!0,f[a.history.client_field_timestamp_type]=!0,d.value&&(f["conversation-history-section-title"]=!0),m.value&&(f["conversation-history-section-data"]=!0),f}),g=E(()=>{const f=a.history.client_field_timestamp_type,Y=a.history.create_time,x=M.value;return f==="today"?de(Y,x):f==="month"||f==="earlier"?pt(Y,x):""}),D=()=>{o("active",a.history.id)},k=()=>{y.value=!0};return(f,Y)=>($(),H(nt,null,[d.value?($(),H("div",{key:0,class:_t([i.value,"history-block-title"])},[s.history.client_field_timestamp_type==="today"?($(),H(nt,{key:0},[lt(W(f.$t("conversation.history_today")),1)],64)):N("",!0),s.history.client_field_timestamp_type==="month"?($(),H(nt,{key:1},[lt(W(f.$t("conversation.history_month")),1)],64)):N("",!0),s.history.client_field_timestamp_type==="earlier"?($(),H(nt,{key:2},[lt(W(f.$t("conversation.history_earlier")),1)],64)):N("",!0)],2)):N("",!0),u.value?($(),H("div",{key:1,class:_t(i.value)},[w("div",{class:"history-item-icon",onClick:D},[w("img",{src:s.agent_icon},null,8,pe)]),w("div",ye,[w("div",{class:"history-item-intro-title",onClick:D},W(s.history.name),1)]),w("div",ve,[w("span",ge,W(g.value),1),w("span",$e,[I(fe,{target_id:s.history.id,onDeleteSuccess:k},null,8,["target_id"])])])],2)):N("",!0)],64))}},De=Z(Me,[["__scopeId","data-v-2878449a"]]),Se={key:0,class:"history-item-icon can-loadmore"},ke={__name:"HistoryLoadMore",props:{can_loadmore:Boolean},emits:["loadmore"],setup(s,{emit:l}){const a=s,o=l,y=E(()=>{const d={"conversation-history-item":!0};return d["load-more"]=!0,d}),M=()=>{a.can_loadmore&&o("loadmore")};return(d,m)=>($(),H("div",{class:_t(y.value),onClick:M},[s.can_loadmore?($(),H("div",Se,W(d.$t("conversation.history_loadmore")),1)):N("",!0)],2))}},we=Z(ke,[["__scopeId","data-v-5b5acaf3"]]),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:l}){const a=l,o=E(()=>"conversation-history-list"),y=m=>{a("active",m)},M=m=>{a("delete",m)},d=()=>{a("loadmore")};return(m,u)=>($(),H("div",be,[w("div",{class:_t(o.value)},[($(!0),H(nt,null,vt(s.list,(i,g)=>($(),Q(De,{key:i.id,history:i,index:g,agent_icon:s.agent_icon,onActive:y,onDelete:M},null,8,["history","index","agent_icon"]))),128)),I(we,{can_loadmore:s.can_loadmore,onLoadmore:d},null,8,["can_loadmore"])],2)]))}},Ce=Z(He,[["__scopeId","data-v-01810f5f"]]);function Ye(s){const l=C(1),a=C(""),o=C([]),y=qt(),M=()=>({});return{getAgentList:()=>{const m=y.agents;if(m.length!==0){typeof s=="function"&&s(m),o.value=m;return}const u=M();l.value=2,a.value="",Jt(u).then(i=>{if(i.code/1===200){const g=i.data;g.length!==0&&typeof s=="function"&&s(g),o.value=g,y.setList(g),l.value=3,a.value="success"}else l.value=4,a.value=err.message}).catch(i=>{console.log(i),l.value=5,a.value=i.msg})},api_status:l,api_message:a,list_agents:o}}function Le(s){const l=Mt(s);Dt.setItem(l)}function yt(){const s=Dt.getItem(),l=Et(s);return l===null?null:l}const Te=Yt("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,Le(s)}}}),xe=["src"],Ie={class:"label-text"},Oe={class:"nav-item-icon arrow-down"},Ae={class:"dropdown-container"},je=["src"],Ne={class:"dropdown-item-text"},ze={__name:"HistoryTypeDropdown",props:{list_status:Number},emits:["typeSelected"],setup(s,{emit:l}){const a=s,o=Te(),{api_status:y,list_agents:M,getAgentList:d}=Ye(k=>{var f;if(o.search_type){const Y=((f=o.search_type)==null?void 0:f.id)||"";let x=null;const X=k.length;for(let F=0;F{var k;return((k=o==null?void 0:o.search_type)==null?void 0:k.name)||""}),i=E(()=>o.search_type&&o.search_type.icon?mt(o.search_type.icon):""),g=E(()=>a.list_status===2),D=k=>{o.setType(k),m("typeSelected",k)};return gt(()=>{d()}),(k,f)=>{const Y=dt("icon-down"),x=Vt,X=$t,F=Ft,J=Rt;return $(),Q(J,{trigger:"hover",defaultValue:u.value},{content:U(()=>[($(!0),H(nt,null,vt(it(M),(V,tt)=>($(),Q(F,{key:V.id,disabled:g.value,value:V.name,onClick:q=>D(V)},{default:U(()=>[w("div",Ae,[w("img",{src:it(mt)(V.icon),class:"agent-icon-img"},null,8,je),w("span",Ne,W(V.name),1)])]),_:2},1032,["disabled","value","onClick"]))),128))]),default:U(()=>[it(y)===1||it(y)===3?($(),Q(x,{key:0,class:"history-type-btn",type:"text"},{default:U(()=>[w("img",{src:i.value,class:"agent-icon-img"},null,8,xe),w("span",Ie,W(u.value),1),w("span",Oe,[I(Y,{class:"arrow-down"})])]),_:1})):N("",!0),it(y)===2?($(),Q(x,{key:1,class:"history-type-btn",type:"text"},{default:U(()=>[I(X,{size:16})]),_:1})):N("",!0)]),_:1},8,["defaultValue"])}}},Be=Z(ze,[["__scopeId","data-v-395eca17"]]),Ee={class:"conversation-history-container"},Ve={class:"conversation-history-main"},We={key:1,class:"infomations-container"},Fe={key:2,class:"infomations-container"},Re={key:3,class:"infomations-container"},Ue={key:4,class:"infomations-container"},Je={__name:"ConversationHistoryContainer",emits:["historyActive"],setup(s,{emit:l}){const a=l,o=C(1),y=C(50),M=C(""),d=C(""),m=C(!0),u=C(1),i=C(""),g=C([]),D=C(0),k=C(0),f=C(0),Y=C(""),x=le(),F=x-wt-ue;function J(L){L.forEach((v,p)=>{let z=null;const O=v,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?(D.value===0&&(z={client_field_content_type:"label",client_field_timestamp_type:"today",id:"today"}),O.client_field_timestamp_type="today",O.client_field_content_type="content",D.value=D.value+1):tF?(k.value===0&&(z={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):(f.value===0&&(z={client_field_content_type:"label",client_field_timestamp_type:"earlier",id:"earlier"}),O.client_field_timestamp_type="earlier",O.client_field_content_type="content",f.value=f.value+1),z&&g.value.push(z),g.value.push(O)})}const V=()=>({search:M.value,page:o.value,per_page:y.value,agent_id:d.value}),tt=()=>{const L=V();u.value=2,i.value="",_e(L).then(v=>{if(v.code/1===200){const p=v.data;p.length{u.value=5,i.value=v.message})},q=()=>{u.value!==2&&m.value&&(o.value=o.value+1,tt())},R=L=>{a("historyActive",{agent_id:d.value,target_id:L})},ct=L=>{u.value!==2&&(M.value=L,o.value=1,g.value=[],tt())},ot=L=>{u.value!==2&&L&&(D.value=0,k.value=0,f.value=0,Y.value=mt(L.icon),d.value=L.id,o.value=1,g.value=[],tt())};return gt(()=>{}),(L,v)=>{const p=$t,z=Ut,O=Ot;return $(),H("div",Ee,[v[1]||(v[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:u.value},null,8,["list_status"])]),_:1}),g.value.length!==0?($(),Q(Ce,{key:0,list:g.value,can_loadmore:m.value,agent_icon:Y.value,onLoadmore:q,onActive:R},null,8,["list","can_loadmore","agent_icon"])):N("",!0),u.value===1||u.value===2?($(),H("div",We,[I(p,{size:32})])):N("",!0),u.value===3&&g.value.length===0?($(),H("div",Fe,[I(z,null,{default:U(()=>[lt(W(L.$t("conversation.history_empty")),1)]),_:1})])):N("",!0),u.value===4?($(),H("div",Re,[I(O,{status:"warning",title:i.value},null,8,["title"])])):N("",!0),u.value===5?($(),H("div",Ue,[I(O,{status:"error",title:i.value},null,8,["title"])])):N("",!0),v[0]||(v[0]=w("div",{class:"conversation-history-placeholder"},null,-1))]),v[2]||(v[2]=w("div",{class:"conversation-history-right"},null,-1))])}}},qe=Z(Je,[["__scopeId","data-v-bb45cfe5"]]),Pe="/assets/history-bg-Cuh6wzmt.png",Dn={__name:"ConversationHistory",setup(s){const l=Lt(),a=Wt(),o=E(()=>a.value==="light"?{backgroundImage:`url(${Pe})`,backgroundRepeat:"no-repeat",backgroundSize:"cover"}:{}),y=({target_id:M,agent_id:d})=>{l.push({path:"/chat/qa",query:{session:M,agent:d}})};return(M,d)=>($(),Q(Tt,null,{default:U(()=>[I(xt,{containerStyle:o.value,id:"fjkdsdajfklgjsklfjskdlf"},{default:U(()=>[I(It),I(qe,{onHistoryActive:y})]),_:1},8,["containerStyle"])]),_:1}))}};export{Dn as default};