import{n as m}from"./rolldown-runtime-M0oDzQ_3.js";import{$t as M,En as r,Kn as S,On as c,Qt as A,Rn as T,Rt as E,Xt as _,Zn as K,Zt as p,an as X,en as B,hn as $,in as q,pn as L,yn as f}from"./ui-vendor-CepnLjNg.js";import{c as D,l as F}from"./vue-vendor-BQwgTLLQ.js";import{n as Q,t as U}from"./_plugin-vue_export-helper-D2UTCjuN.js";import{X as j,h as z,m as G}from"./index-8_-Evm_R.js";import{i as J,n as W,r as Y,t as ee}from"./VirtualMessageList-bb5lw7-0.js";import{n as se,t as te}from"./MessageItem-C6M-4-Ga.js";var b,V,w,d,k,I=m((()=>{E(),j(),D(),W(),se(),G(),Y(),b={class:"empty-state"},V={key:0,class:"history-loader"},w={key:0,class:"history-loader-spinner"},d=new Map,k=X({__name:"HistoryMessageList",props:{session:{},loadOlder:{type:Function}},setup(x,{expose:H}){const l=x,n=z(),{toolTraceVisible:N}=J(),{t:O}=F(),a=T(null),i=T(null),t=_(()=>l.session||null),P=_(()=>t.value?.id?`history-${t.value.id}`:"history-empty"),R=_(()=>(t.value?.messages||[]).filter(e=>e.role==="tool"?N.value&&!!e.toolName:!!e.content?.trim()));function v(e=200){return a.value?.isNearBottom(e)??!0}function o(){a.value?.scrollToBottom()}function u(e){a.value?.scrollToMessage(e)}function C(e,s){a.value?.scrollToAnchor(e,s)}function g(e){if(!e)return;const s=a.value?.captureViewportPosition()??null;s&&d.set(e,s)}function h(e){if(t.value?.id!==e)return;if(n.focusMessageId){i.value=null,u(n.focusMessageId);return}const s=d.get(e);if(s){i.value=null,s.wasNearBottom?o():a.value?.restoreViewportPosition(s);return}o(),(t.value?.messages.length||0)>0&&(i.value=null)}async function Z(){const e=t.value;if(!e?.hasMoreBefore||e.isLoadingOlderMessages||!l.loadOlder)return;const s=a.value?.captureScrollPosition()??null;await l.loadOlder(e.id)&&(await L(),a.value?.restoreScrollPosition(s))}return r(()=>t.value?.id,async(e,s)=>{g(s),e&&(i.value=e,await L(),h(e))},{immediate:!0}),r(()=>n.focusMessageId,e=>{e&&u(e)}),r(()=>(t.value?.messages||[])[(t.value?.messages||[]).length-1]?.content,e=>{i.value!==t.value?.id&&e&&v()&&o()}),r(()=>(t.value?.messages||[]).length,e=>{if(e===0)return;const s=t.value?.id;if(s&&i.value===s){h(s);return}v()&&o()},{flush:"post"}),$(()=>{g(t.value?.id)}),H({scrollToBottom:o,scrollToMessage:u,scrollToAnchor:C}),(e,s)=>(f(),A(ee,{key:P.value,ref_key:"listRef",ref:a,messages:R.value,onTopReach:Z},{empty:c(()=>[p("div",b,[s[0]||(s[0]=p("img",{src:"/logo.png",alt:"Hermes",class:"empty-logo"},null,-1)),p("p",null,K(S(O)("chat.emptyState")),1)])]),before:c(()=>[t.value?.hasMoreBefore||t.value?.isLoadingOlderMessages?(f(),B("div",V,[t.value?.isLoadingOlderMessages?(f(),B("span",w)):M("",!0)])):M("",!0)]),item:c(({message:y})=>[q(te,{message:y,highlight:S(n).focusMessageId===y.id},null,8,["message","highlight"])]),_:1},8,["messages"]))}})})),ae=m((()=>{})),ie,ve=m((()=>{I(),I(),ae(),Q(),ie=U(k,[["__scopeId","data-v-db0888a6"]])}));export{ve as n,ie as t};
