rt-chat-messages 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/chat-messages.es.js +287 -281
- package/dist/chat-messages.umd.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(z,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("markdown-it"),require("@vscode/markdown-it-katex"),require("mermaid")):typeof define=="function"&&define.amd?define(["exports","vue","markdown-it","@vscode/markdown-it-katex","mermaid"],e):(z=typeof globalThis<"u"?globalThis:z||self,e(z.ChatMessages={},z.Vue,z.markdownit,z.markdownItKatex,z.mermaid))})(this,(function(z,e,we,Ce,ce){"use strict";const Ee={class:"cm-dialog__body"},Be=e.defineComponent({__name:"Dialog",props:{visible:{type:Boolean,default:!1},width:{default:"50%"},fullscreen:{type:Boolean,default:!1},showClose:{type:Boolean,default:!0},closeOnClickModal:{type:Boolean,default:!0},appendToBody:{type:Boolean,default:!0}},emits:["update:visible","close"],setup(o,{emit:h}){const k=o,l=h,M=e.ref(!1);e.onMounted(()=>{M.value=!0});const E=e.computed(()=>k.fullscreen?{width:"100%",height:"100%",margin:0}:{width:k.width}),N=()=>{l("update:visible",!1),l("close")},B=()=>{k.closeOnClickModal&&N()};return(b,w)=>M.value?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:"body"},[o.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["cm-dialog-overlay",{"is-fullscreen":o.fullscreen}]),onClick:e.withModifiers(B,["self"])},[e.createElementVNode("div",{class:"cm-dialog",style:e.normalizeStyle(E.value),role:"dialog","aria-modal":"true"},[e.createElementVNode("div",Ee,[e.renderSlot(b.$slots,"default",{},void 0,!0)]),o.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:"cm-dialog__close",onClick:N},[...w[0]||(w[0]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16"},[e.createElementVNode("path",{fill:"currentColor",d:"M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"})],-1)])])):e.createCommentVNode("",!0)],4)],2)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}),U=(o,h)=>{const k=o.__vccOpts||o;for(const[l,M]of h)k[l]=M;return k},te=U(Be,[["__scopeId","data-v-efdf0259"]]),Me=["disabled"],Ve={key:0,class:"cm-icon-loading"},L=U(e.defineComponent({__name:"Button",props:{type:{default:"default"},size:{default:"default"},circle:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:["click"],setup(o,{emit:h}){const k=o,l=h,M=E=>{k.disabled||k.loading||l("click",E)};return(E,N)=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["cm-button",[`cm-button--${o.type}`,`cm-button--${o.size}`,{"is-circle":o.circle,"is-disabled":o.disabled,"is-loading":o.loading}]]),disabled:o.disabled||o.loading,onClick:M},[o.loading?(e.openBlock(),e.createElementBlock("span",Ve,[...N[0]||(N[0]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"1em",height:"1em"},[e.createElementVNode("path",{fill:"currentColor",d:"M512 64a448 448 0 0 1 448 448 32 32 0 1 1-64 0 416 416 0 0 0-416-416 416 416 0 0 0-416 416 32 32 0 1 1-64 0 448 448 0 0 1 448-448z"})],-1)])])):e.renderSlot(E.$slots,"default",{key:1},void 0,!0)],10,Me))}}),[["__scopeId","data-v-bab126c7"]]),T=(o,h)=>e.defineComponent({name:o,render(){return e.h("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",width:"1em",height:"1em",fill:"currentColor",style:"vertical-align: middle"},[e.h("path",{d:h})])}}),G=T("Close","M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"),ie=T("ZoomIn","M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm268.48-154.56a32 32 0 0 0-32 32v90.496h-90.56a32 32 0 0 0 0 64h90.56v90.56a32 32 0 0 0 64 0v-90.496h90.496a32 32 0 0 0 0-64H373.632v-90.56a32 32 0 0 0-32-32z"),de=T("ZoomOut","M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm145.92-58.56a32 32 0 0 0 0 64h245.12a32 32 0 0 0 0-64H219.072z"),me=T("Document","M854.6 288.7c0.4 0 0.7 0 1 0v431.5c0 17.6-14.4 32-32 32H200.4c-17.6 0-32-14.4-32-32l0-575.2c0-17.6 14.4-32 32-32h391.5c0 0.3 0 0.7 0 1l0 142.1c0 17.6 14.4 32.1 32 32.1h142.6c0-0.4 0-0.7 0-1.1L854.6 288.7zM790.2 220.2L668 97.9v122.3h122.2zM240 448h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h384a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64z"),ge=T("Download","M505.7 661a8 8 0 0 0 12.6 0l112-141.7c4.1-5.2 0.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"),Ne=T("VideoPlay","M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-48-247.616L668.608 512 464 375.616v272.768zm10.656-340.32a32 32 0 0 1 32 32V673.92a32 32 0 0 1-50.208 26.24l-236.8-161.92a32 32 0 0 1 0-52.48l236.8-161.92a32 32 0 0 1 18.208-5.632z"),_e=T("VideoPause","M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-96-544a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32zm192 0a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32z"),Se=T("ArrowLeft","M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"),xe=T("ArrowRight","M340.864 149.312a29.12 29.12 0 0 0-41.728 0 30.592 30.592 0 0 0 0 42.752L611.072 511.936 299.136 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L672.448 534.272a32 32 0 0 0 0-44.672L340.864 149.312z"),fe=T("Spinner","M512 64a448 448 0 0 1 448 448 32 32 0 1 1-64 0 416 416 0 0 0-416-416 416 416 0 0 0-416 416 32 32 0 1 1-64 0 448 448 0 0 1 448-448z"),he=T("Check","M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z"),be=T("ChevronUp","M854.6 642.5l-320-320c-12.5-12.5-32.8-12.5-45.3 0l-320 320c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L512 390.6l297.4 297.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3z"),$e=T("ChevronDown","M854.6 381.5l-320 320c-12.5 12.5-32.8 12.5-45.3 0l-320-320c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L512 633.4l297.4-297.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3z"),ve=["src","alt"],ze={class:"preview-controls"},Le={class:"cm-button-group"},Te={key:0,class:"mobile-close-hint"},De=["innerHTML"],Ie={class:"preview-controls"},Ae={class:"cm-button-group"},He={key:0,class:"mobile-close-hint"},ae=U(e.defineComponent({__name:"MarkdownMessage",props:{content:{},isStreaming:{type:Boolean,default:!1}},setup(o){const h=o,k=e.ref(),l=e.ref(),M=e.ref(!1),E=e.ref(""),N=e.ref(""),B=e.ref(!1),b=e.ref(""),w=e.ref(!1),c=e.ref(1),m=e.ref({x:0,y:0}),C=e.ref(!1),_=e.ref({x:0,y:0}),V=e.ref(1),y=e.ref({x:0,y:0}),Y=e.ref(!1),O=e.ref({x:0,y:0}),W=e.ref(""),R=e.ref(new Map);let X=0;ce.initialize({startOnLoad:!1,theme:"default",securityLevel:"loose",fontFamily:"inherit"});const Q=t=>{const a=t.renderer.rules.fence;t.renderer.rules.fence=(s,g,r,n,d)=>{const p=s[g],v=p.content.trim();return(p.info?p.info.trim():"")==="mermaid"?(X++,`<div class="mermaid-container"><pre class="mermaid" data-mermaid-id="${`mermaid-${Date.now()}-${X}`}">${v}</pre></div>`):a(s,g,r,n,d)}},F=new we({html:!0,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkify:!0,typographer:!0,quotes:`""''`,highlight:function(t,a){return a&&a.trim()?`<pre class="hljs language-${a}"><code>${(g=>g.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"))(t)}</code></pre>`:`<pre class="hljs"><code>${t}</code></pre>`}}),Z=F.renderer.rules.image||function(t,a,s,g,r){return r.renderToken(t,a,s)};F.renderer.rules.image=function(t,a,s,g,r){const n=t[a],d=n.attrIndex("src");if(d>=0){const p=n.attrs[d][1],x="img-"+(I=>{let $=0;for(let D=0;D<I.length;D++){const H=I.charCodeAt(D);$=($<<5)-$+H,$=$&$}return Math.abs($).toString(36)})(p);n.attrSet("id",x),n.attrSet("data-image-id",x),n.attrSet("key",x),n.attrSet("loading","eager"),n.attrSet("decoding","async"),n.attrSet("fetchpriority","high"),n.attrSet("data-src",p),n.attrSet("data-cached","true")}return Z(t,a,s,g,r)},F.use(Ce,{throwOnError:!1,errorColor:"#cc0000"}),F.use(Q);const oe=t=>{const a=t.match(/```[\w]*\n/g),s=t.match(/\n```/g),g=(a==null?void 0:a.length)||0,r=(s==null?void 0:s.length)||0;return g>r&&(t+="\n```"),t},ee=t=>{if(!t)return"";t=t.replace(/;;\s*$/g,""),t=t.replace(/;;\s*$/g,"");const a=/^```(?:markdown|md)\s*\n([\s\S]*?)\n```$/,s=t.match(a);if(s)t=s[1];else{const g=/^```\s*\n([\s\S]*?)\n```$/,r=t.match(g);if(r){const n=r[1];(/^#{1,6}\s/.test(n)||/^\*{1,2}[^*]+\*{1,2}/.test(n)||/^[-*+]\s/.test(n)||/^\d+\.\s/.test(n)||/!\[.*?\]\(.*?\)/.test(n)||/\[.*?\]\(.*?\)/.test(n)||/^\|.+\|/.test(n)||/^\|[\s-:]+\|/m.test(n))&&(t=n)}}if(h.isStreaming){const g=/^```(?:markdown|md)?\s*\n/;if(g.test(t)){const n=t.replace(g,"");(/^#{1,6}\s/.test(n)||/^\|.+\|/.test(n)||/^\|[\s-:]+\|/m.test(n)||/!\[.*?\]\(.*?\)/.test(n)||/\[.*?\]\(.*?\)/.test(n))&&(t=t.replace(g,""))}if(/^```(?:markdown|md)?\s*\n/.test(h.content)){const n=/\n```\s*$/;n.test(t)&&(t=t.replace(n,""))}}return t=t.replace(/```(?:markdown|md)\s*\n([\s\S]*?)\n```/g,(g,r)=>r),h.isStreaming&&(t=oe(t)),t},se=t=>{if(!t.includes("<img"))return t;const a=/<img[^>]*?src="([^"]*)"[^>]*?>/g;let s,g=t;const r=[];for(;(s=a.exec(t))!==null;){const n=s[0],d=s[1];if(R.value.has(d)){const p=R.value.get(d);n!==p&&r.push({original:n,cached:p})}else R.value.set(d,n)}for(const{original:n,cached:d}of r)g=g.replace(n,d);return g},le=t=>{if(!l.value)return;const a=l.value;if(!h.isStreaming||a.children.length===0){a.innerHTML=t,h.isStreaming||e.nextTick(()=>{ye(),u()});return}const s=document.createElement("div");s.innerHTML=t;const g=new Map;a.querySelectorAll("img[data-image-id]").forEach(n=>{const d=n.getAttribute("data-image-id");d&&g.set(d,n)}),s.querySelectorAll("img[data-image-id]").forEach(n=>{const d=n.getAttribute("data-image-id");if(d&&g.has(d)){const p=g.get(d);n.parentNode&&n.parentNode.replaceChild(p,n)}});const r=document.createDocumentFragment();for(;s.firstChild;)r.appendChild(s.firstChild);a.innerHTML="",a.appendChild(r)},P=()=>{try{if(!h.content){W.value="",l.value&&(l.value.innerHTML=""),h.isStreaming||R.value.clear();return}const t=ee(h.content);let a=F.render(t);h.isStreaming&&a.includes("<img")&&(a=se(a)),a!==W.value&&(W.value=a,le(a)),h.isStreaming||R.value.clear()}catch(t){console.error("Markdown rendering error:",t),l.value&&(l.value.innerHTML=`<pre style="white-space: pre-wrap; word-wrap: break-word;">${h.content}</pre>`)}};e.watch(()=>h.content,P),e.watch(()=>h.isStreaming,(t,a)=>{a&&!t&&e.nextTick(()=>{P()})});const i=()=>{w.value=window.innerWidth<768},f=t=>{let a=t;return a=a.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1"),[/([A-Za-z0-9_]+)\[([^\]]*[\u4e00-\u9fa5]+[^\]]*)\]/g,/([A-Za-z0-9_]+)\(([^)]*[\u4e00-\u9fa5]+[^)]*)\)/g,/([A-Za-z0-9_]+)\{([^}]*[\u4e00-\u9fa5]+[^}]*)\}/g].forEach(g=>{a=a.replace(g,(r,n,d)=>{if(d.startsWith('"')&&d.endsWith('"'))return r;let p=d.replace(/^["']+|["']+$/g,"").replace(/["]/g,'\\"');return r.includes("[")?`${n}["${p}"]`:r.includes("(")?`${n}("${p}")`:r.includes("{")?`${n}{"${p}"}`:r})}),a},u=async()=>{var a,s;if(h.isStreaming||(await e.nextTick(),!k.value))return;const t=k.value.querySelectorAll(".mermaid");if(t.length!==0)for(const g of Array.from(t)){const r=g;let n=(a=r.textContent)==null?void 0:a.trim();if(n&&r.getAttribute("data-processed")!=="true")try{r.setAttribute("data-processed","true"),n=f(n);const d=r.getAttribute("data-mermaid-id")||`mermaid-${Date.now()}-${Math.random()}`,{svg:p}=await ce.render(d,n),v=r.parentElement;if(v){const x=document.createElement("div");x.className="mermaid-svg",x.innerHTML=p,x.setAttribute("data-mermaid-svg","true"),x.style.cursor="pointer",x.title="Click to zoom",x.addEventListener("click",I=>{I.preventDefault(),I.stopPropagation(),b.value=p,V.value=1,y.value={x:0,y:0},B.value=!0}),v.replaceChild(x,r)}}catch(d){console.error("Mermaid render failure:",d);const p=document.createElement("div");p.className="mermaid-error",p.textContent=`Mermaid render error: ${d}`,(s=r.parentElement)==null||s.replaceChild(p,r)}}},S=t=>{t.preventDefault(),t.stopPropagation();const a=t.target;E.value=a.src,N.value=a.alt||"Image Preview",c.value=1,m.value={x:0,y:0},M.value=!0},A=()=>{c.value<=1&&(m.value={x:0,y:0})},Ht=()=>{c.value=Math.min(c.value+1,10),A()},Rt=()=>{c.value=Math.max(c.value-1,.5),A()},pe=()=>{c.value=1,m.value={x:0,y:0}},Ft=()=>{c.value<=1&&(M.value=!1)},Pt=t=>{t.preventDefault();const a=t.deltaY>0?-.5:.5,s=Math.max(.5,Math.min(10,c.value+a));c.value=s,A()},Ut=t=>{var n;if(c.value<=1)return;t.preventDefault(),C.value=!0,_.value={x:t.clientX-m.value.x,y:t.clientY-m.value.y};const a=t.target,s=(n=a.parentElement)==null?void 0:n.getBoundingClientRect(),g=d=>{if(!C.value||!s)return;let p=d.clientX-_.value.x,v=d.clientY-_.value.y;const x=a.offsetWidth,I=a.offsetHeight,$=x*c.value,D=I*c.value,H=.3,re=s.width*(1-H-.5)-$/2,j=$/2-s.width*(1-H-.5),K=s.height*(1-H-.5)-D/2,q=D/2-s.height*(1-H-.5);$>s.width?p=Math.max(re,Math.min(j,p)):p=0,D>s.height?v=Math.max(K,Math.min(q,v)):v=0,m.value={x:p,y:v}},r=()=>{C.value=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",r)},Yt=t=>{var v;if(t.touches.length!==1)return;const a=t.touches[0],s=a.clientX,g=a.clientY;if(c.value<=1)return;C.value=!0,_.value={x:s-m.value.x,y:g-m.value.y};const r=t.target,n=(v=r.parentElement)==null?void 0:v.getBoundingClientRect(),d=x=>{if(!C.value||x.touches.length!==1||!n)return;const I=x.touches[0];let $=I.clientX-_.value.x,D=I.clientY-_.value.y;const H=r.offsetWidth,re=r.offsetHeight,j=H*c.value,K=re*c.value,q=.3,jt=n.width*(1-q-.5)-j/2,Kt=j/2-n.width*(1-q-.5),Gt=n.height*(1-q-.5)-K/2,Jt=K/2-n.height*(1-q-.5);j>n.width?$=Math.max(jt,Math.min(Kt,$)):$=0,K>n.height?D=Math.max(Gt,Math.min(Jt,D)):D=0,m.value={x:$,y:D}},p=()=>{C.value=!1,document.removeEventListener("touchmove",d),document.removeEventListener("touchend",p)};document.addEventListener("touchmove",d,{passive:!1}),document.addEventListener("touchend",p)},Ot=()=>{V.value=Math.min(V.value+1,10)},Wt=()=>{V.value=Math.max(V.value-1,.5)},ke=()=>{V.value=1,y.value={x:0,y:0}},Xt=t=>{t.preventDefault();const a=t.deltaY>0?-.5:.5;V.value=Math.max(.5,Math.min(10,V.value+a))},qt=t=>{var n,d;if(V.value<=1)return;t.preventDefault(),Y.value=!0,O.value={x:t.clientX-y.value.x,y:t.clientY-y.value.y};const s=(d=(n=t.target.closest(".mermaid-preview-content"))==null?void 0:n.parentElement)==null?void 0:d.getBoundingClientRect(),g=p=>{if(!Y.value||!s)return;let v=p.clientX-O.value.x,x=p.clientY-O.value.y;y.value={x:v,y:x}},r=()=>{Y.value=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",r)},Zt=t=>{},ye=()=>{h.isStreaming||e.nextTick(()=>{if(!k.value)return;k.value.querySelectorAll(".markdown-content img").forEach(a=>{const s=a;s.getAttribute("data-processed")!=="true"&&(s.setAttribute("data-processed","true"),s.style.cursor="pointer",s.addEventListener("click",S))})})};return e.onMounted(()=>{i(),window.addEventListener("resize",i),P(),ye(),u()}),e.onUnmounted(()=>{k.value&&k.value.querySelectorAll(".markdown-content img").forEach(a=>{a.removeEventListener("click",S)})}),(t,a)=>(e.openBlock(),e.createElementBlock("div",{class:"markdown-message",ref_key:"markdownContainer",ref:k},[e.createElementVNode("div",{ref_key:"markdownContent",ref:l,class:"markdown-content"},null,512),e.createVNode(te,{visible:M.value,"onUpdate:visible":a[2]||(a[2]=s=>M.value=s),width:w.value?"95vw":"80vw",fullscreen:w.value,class:"image-preview-dialog","close-on-click-modal":!1,"append-to-body":""},{default:e.withCtx(()=>[e.createElementVNode("div",{class:"image-preview-container",onClick:a[1]||(a[1]=e.withModifiers(s=>M.value=!1,["self"]))},[e.createElementVNode("img",{src:E.value,alt:N.value,class:"preview-image",style:e.normalizeStyle({transform:`translate(${m.value.x}px, ${m.value.y}px) scale(${c.value})`}),onWheel:e.withModifiers(Pt,["prevent"]),onDblclick:pe,onMousedown:Ut,onTouchstart:e.withModifiers(Yt,["prevent"]),onClick:Ft},null,44,ve),e.createElementVNode("div",ze,[e.createElementVNode("div",Le,[e.createVNode(L,{size:"small",onClick:Rt,disabled:c.value<=.5},{default:e.withCtx(()=>[e.createVNode(e.unref(de))]),_:1},8,["disabled"]),e.createVNode(L,{size:"small",onClick:pe},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(Math.round(c.value*100))+"% ",1)]),_:1}),e.createVNode(L,{size:"small",onClick:Ht,disabled:c.value>=10},{default:e.withCtx(()=>[e.createVNode(e.unref(ie))]),_:1},8,["disabled"])]),e.createVNode(L,{size:"small",onClick:a[0]||(a[0]=s=>M.value=!1),type:"danger"},{default:e.withCtx(()=>[e.createVNode(e.unref(G))]),_:1})]),w.value?(e.openBlock(),e.createElementBlock("div",Te,"双击重置 · 轻触关闭")):e.createCommentVNode("",!0)])]),_:1},8,["visible","width","fullscreen"]),e.createVNode(te,{visible:B.value,"onUpdate:visible":a[5]||(a[5]=s=>B.value=s),width:w.value?"95vw":"90vw",fullscreen:w.value,class:"mermaid-preview-dialog","close-on-click-modal":!1,"append-to-body":""},{default:e.withCtx(()=>[e.createElementVNode("div",{class:"mermaid-preview-container",onClick:a[4]||(a[4]=e.withModifiers(s=>B.value=!1,["self"]))},[e.createElementVNode("div",{class:"mermaid-preview-content",innerHTML:b.value,style:e.normalizeStyle({transform:`translate(${y.value.x}px, ${y.value.y}px) scale(${V.value})`}),onWheel:e.withModifiers(Xt,["prevent"]),onDblclick:ke,onMousedown:qt,onTouchstart:e.withModifiers(Zt,["prevent"])},null,44,De),e.createElementVNode("div",Ie,[e.createElementVNode("div",Ae,[e.createVNode(L,{size:"small",onClick:Wt,disabled:V.value<=.5},{default:e.withCtx(()=>[e.createVNode(e.unref(de))]),_:1},8,["disabled"]),e.createVNode(L,{size:"small",onClick:ke},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(Math.round(V.value*100))+"% ",1)]),_:1}),e.createVNode(L,{size:"small",onClick:Ot,disabled:V.value>=10},{default:e.withCtx(()=>[e.createVNode(e.unref(ie))]),_:1},8,["disabled"])]),e.createVNode(L,{size:"small",onClick:a[3]||(a[3]=s=>B.value=!1),type:"danger"},{default:e.withCtx(()=>[e.createVNode(e.unref(G))]),_:1})]),w.value?(e.openBlock(),e.createElementBlock("div",He,"双击重置 · 轻触关闭")):e.createCommentVNode("",!0)])]),_:1},8,["visible","width","fullscreen"])],512))}}),[["__scopeId","data-v-e47faf67"]]),Re={key:0,class:"text-content"},Fe={key:1,class:"images-content"},Pe=["onClick"],Ue=["src","alt","onError"],Ye={key:0,class:"more-images"},Oe={key:2,class:"attachments-content"},We={class:"file-icon-wrapper"},Xe={class:"attachment-info"},qe={class:"attachment-name"},Ze={class:"attachment-size"},je={key:3,class:"files-content"},Ke=["onClick"],Ge={class:"file-icon-wrapper-small"},Je={class:"file-info"},Qe={class:"file-name"},et={class:"file-type"},tt={class:"file-actions"},at={key:4,class:"audio-content"},nt={class:"audio-player"},ot={class:"audio-info"},st={class:"audio-progress"},lt={class:"progress-bar"},rt={class:"audio-time"},ct={class:"image-preview-container"},it=["src"],dt={key:0,class:"image-nav"},mt={class:"image-counter"},J=U(e.defineComponent({__name:"MultimodalMessage",props:{message:{},isUser:{type:Boolean,default:!1},isStreaming:{type:Boolean,default:!1}},setup(o){const h=o,k=e.computed(()=>{try{return h.message.metadata?JSON.parse(h.message.metadata):{}}catch{return{}}}),l=e.computed(()=>k.value.imageUrls||[]),M=e.computed(()=>k.value.fileUrls||[]),E=e.computed(()=>k.value.audioUrl),N=e.computed(()=>h.message.attachments&&h.message.attachments.length>0?h.message.attachments:k.value.attachments&&Array.isArray(k.value.attachments)?k.value.attachments:[]),B=e.ref(!1),b=e.ref(""),w=e.ref(0),c=e.ref(!1),m=e.ref(!1),C=e.ref(0),_=e.ref(0),V=e.computed(()=>_.value>0?C.value/_.value*100:0);let y=null;const Y=(i,f)=>{b.value=i,w.value=f,B.value=!0},O=()=>{w.value>0&&(w.value--,b.value=l.value[w.value])},W=()=>{w.value<l.value.length-1&&(w.value++,b.value=l.value[w.value])},R=(i,f)=>{console.error("Image load failed:",f);const u=i.target;u.style.display="none"},X=i=>{try{const u=new URL(i).pathname,S=u.substring(u.lastIndexOf("/")+1);return decodeURIComponent(S)||"Unknown File"}catch{return"Unknown File"}},Q=i=>{var S;return((S=X(i).split(".").pop())==null?void 0:S.toUpperCase())||"FILE"},F=i=>{const f=Q(i).toLowerCase();["jpg","jpeg","png","gif","webp","pdf"].includes(f)?window.open(i,"_blank"):Z(i)},Z=i=>{try{const f=document.createElement("a");f.href=i,f.download=X(i),f.target="_blank",document.body.appendChild(f),f.click(),document.body.removeChild(f)}catch(f){console.error("Download failed:",f),alert("下载失败")}},oe=async()=>{if(E.value)try{y||(y=new Audio,y.src=E.value,y.addEventListener("loadedmetadata",()=>{_.value=(y==null?void 0:y.duration)||0}),y.addEventListener("timeupdate",()=>{C.value=(y==null?void 0:y.currentTime)||0}),y.addEventListener("ended",()=>{c.value=!1,C.value=0}),y.addEventListener("error",i=>{console.error("Audio playback error:",i),m.value=!1,c.value=!1})),c.value?(y.pause(),c.value=!1):(m.value=!0,await y.play(),c.value=!0,m.value=!1)}catch(i){console.error("Audio playback failed:",i),m.value=!1,c.value=!1}},ee=i=>{const f=Math.floor(i/60),u=Math.floor(i%60);return`${f}:${u.toString().padStart(2,"0")}`},se=i=>{if(i===0)return"0 B";const f=1024,u=["B","KB","MB","GB"],S=Math.floor(Math.log(i)/Math.log(f));return(i/Math.pow(f,S)).toFixed(2)+u[S]},le=i=>{var u;return((u=i.split(".").pop())==null?void 0:u.toUpperCase())||"FILE"},P=i=>{B.value&&(i.key==="ArrowLeft"?O():i.key==="ArrowRight"?W():i.key==="Escape"&&(B.value=!1))};return e.watch(B,i=>{i?document.addEventListener("keydown",P):document.removeEventListener("keydown",P)}),e.onUnmounted(()=>{y&&(y.pause(),y=null),document.removeEventListener("keydown",P)}),(i,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["multimodal-message",{"is-user":o.isUser,"is-assistant":!o.isUser}])},[o.message.content?(e.openBlock(),e.createElementBlock("div",Re,[e.createVNode(ae,{content:o.message.content,"is-streaming":o.isStreaming},null,8,["content","is-streaming"])])):e.createCommentVNode("",!0),l.value&&l.value.length>0?(e.openBlock(),e.createElementBlock("div",Fe,[e.createElementVNode("div",{class:e.normalizeClass(["images-grid",`grid-${Math.min(l.value.length,4)}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.slice(0,4),(u,S)=>(e.openBlock(),e.createElementBlock("div",{key:S,class:"image-item",onClick:A=>Y(u,S)},[e.createElementVNode("img",{src:u,alt:`图片 ${S+1}`,onError:A=>R(A,u),loading:"lazy"},null,40,Ue),S===3&&l.value.length>4?(e.openBlock(),e.createElementBlock("div",Ye," +"+e.toDisplayString(l.value.length-4),1)):e.createCommentVNode("",!0)],8,Pe))),128))],2)])):e.createCommentVNode("",!0),N.value&&N.value.length>0?(e.openBlock(),e.createElementBlock("div",Oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.value,(u,S)=>(e.openBlock(),e.createElementBlock("div",{key:S,class:"attachment-item"},[e.createElementVNode("div",We,[e.createVNode(e.unref(me),{class:"file-icon"})]),e.createElementVNode("div",Xe,[e.createElementVNode("span",qe,e.toDisplayString(u.name),1),e.createElementVNode("span",Ze,e.toDisplayString(le(u.name))+" "+e.toDisplayString(se(u.size)),1)])]))),128))])):e.createCommentVNode("",!0),M.value&&M.value.length>0?(e.openBlock(),e.createElementBlock("div",je,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,(u,S)=>(e.openBlock(),e.createElementBlock("div",{key:S,class:"file-item",onClick:A=>F(u)},[e.createElementVNode("div",Ge,[e.createVNode(e.unref(me),{class:"file-icon"})]),e.createElementVNode("div",Je,[e.createElementVNode("span",Qe,e.toDisplayString(X(u)),1),e.createElementVNode("span",et,e.toDisplayString(Q(u)),1)]),e.createElementVNode("div",tt,[e.createVNode(L,{size:"small",type:"text",onClick:e.withModifiers(A=>Z(u),["stop"])},{default:e.withCtx(()=>[e.createVNode(e.unref(ge))]),_:1},8,["onClick"])])],8,Ke))),128))])):e.createCommentVNode("",!0),E.value?(e.openBlock(),e.createElementBlock("div",at,[e.createElementVNode("div",nt,[e.createVNode(L,{onClick:oe,loading:m.value,circle:"",size:"small",class:"play-btn"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c.value?e.unref(_e):e.unref(Ne))))]),_:1},8,["loading"]),e.createElementVNode("div",ot,[e.createElementVNode("div",st,[e.createElementVNode("div",lt,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:V.value+"%"})},null,4)])]),e.createElementVNode("div",rt,[e.createElementVNode("span",null,e.toDisplayString(ee(C.value)),1),f[4]||(f[4]=e.createElementVNode("span",null,"/",-1)),e.createElementVNode("span",null,e.toDisplayString(ee(_.value)),1)])]),e.createVNode(L,{onClick:f[0]||(f[0]=u=>Z(E.value)),size:"small",type:"text",class:"download-btn"},{default:e.withCtx(()=>[e.createVNode(e.unref(ge))]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(te,{visible:B.value,"onUpdate:visible":f[3]||(f[3]=u=>B.value=u),width:"90%","show-close":!1,"append-to-body":"",class:"image-preview-dialog-wrapper"},{default:e.withCtx(()=>[e.createElementVNode("div",ct,[e.createElementVNode("img",{src:b.value,alt:"预览图片",class:"preview-image",onClick:f[1]||(f[1]=u=>B.value=!1)},null,8,it),l.value&&l.value.length>1?(e.openBlock(),e.createElementBlock("div",dt,[e.createVNode(L,{onClick:O,disabled:w.value===0,circle:"",class:"nav-btn"},{default:e.withCtx(()=>[e.createVNode(e.unref(Se))]),_:1},8,["disabled"]),e.createElementVNode("span",mt,e.toDisplayString(w.value+1)+" / "+e.toDisplayString(l.value.length),1),e.createVNode(L,{onClick:W,disabled:w.value===l.value.length-1,circle:"",class:"nav-btn"},{default:e.withCtx(()=>[e.createVNode(e.unref(xe))]),_:1},8,["disabled"])])):e.createCommentVNode("",!0),e.createVNode(L,{onClick:f[2]||(f[2]=u=>B.value=!1),class:"close-btn",circle:""},{default:e.withCtx(()=>[e.createVNode(e.unref(G))]),_:1})])]),_:1},8,["visible"])],2))}}),[["__scopeId","data-v-7795fedb"]]),gt={key:0,class:"agent-steps"},ft={class:"steps-indicator"},ht={key:0,class:"icon-running"},ut={key:1,class:"icon-completed"},pt={class:"steps-summary"},kt={class:"icon-chevron"},yt={class:"steps-list"},wt={class:"step-icon"},Ct={key:3,class:"icon-dot"},Et={class:"step-name"},ne=U(e.defineComponent({__name:"AgentSteps",props:{steps:{}},emits:["resize"],setup(o,{emit:h}){const k=o,l=e.ref(!0),M=h,E=()=>{l.value=!l.value,setTimeout(()=>{M("resize")},300)},N=e.computed(()=>k.steps.some(b=>b.status==="running")),B=e.computed(()=>{const b=k.steps.find(c=>c.status==="running");if(b)return`正在${b.displayName}...`;const w=k.steps.filter(c=>c.status==="completed").length;return w===k.steps.length?"处理完成":`已完成 ${w}/${k.steps.length} 个步骤`});return(b,w)=>o.steps.length>0?(e.openBlock(),e.createElementBlock("div",gt,[e.createElementVNode("div",{class:"steps-header",onClick:E},[e.createElementVNode("div",ft,[N.value?(e.openBlock(),e.createElementBlock("div",ht,[e.createVNode(e.unref(fe))])):(e.openBlock(),e.createElementBlock("div",ut,[e.createVNode(e.unref(he))]))]),e.createElementVNode("span",pt,e.toDisplayString(B.value),1),e.createElementVNode("div",kt,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.value?e.unref(be):e.unref($e))))])]),e.withDirectives(e.createElementVNode("div",yt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.steps,c=>(e.openBlock(),e.createElementBlock("div",{key:c.name,class:e.normalizeClass(["step-item",{"is-running":c.status==="running","is-completed":c.status==="completed","is-error":c.status==="error"}])},[e.createElementVNode("div",wt,[c.status==="running"?(e.openBlock(),e.createBlock(e.unref(fe),{key:0,class:"icon-spin"})):c.status==="completed"?(e.openBlock(),e.createBlock(e.unref(he),{key:1})):c.status==="error"?(e.openBlock(),e.createBlock(e.unref(G),{key:2})):(e.openBlock(),e.createElementBlock("div",Ct))]),e.createElementVNode("span",Et,e.toDisplayString(c.displayName),1)],2))),128))],512),[[e.vShow,l.value]])])):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-181f5844"]]),Bt={class:"chat-message-list-root"},Mt={key:0,class:"bg-grid"},Vt={key:0,class:"welcome-screen"},Nt={class:"welcome-content"},_t={class:"welcome-logo"},St=["src"],xt={key:1,class:"default-logo"},bt={class:"welcome-title"},$t={key:1,class:"messages-container"},vt={key:0,class:"message-bubble user-bubble"},zt={key:1,class:"message-content assistant-content"},Lt={class:"message-bubble assistant-bubble"},Tt={key:1,class:"message-actions"},Dt=["onClick"],It={key:0,class:"message-row message-assistant"},ue=U(e.defineComponent({__name:"ChatMessageList",props:{messages:{default:()=>[]},isStreaming:{type:Boolean,default:!1},isTyping:{type:Boolean,default:!1},showWelcome:{type:Boolean,default:!0},appName:{default:"AI助手"},appLogo:{},agentSteps:{},showAgentSteps:{type:Boolean,default:!0},autoScroll:{type:Boolean,default:!0},contentPaddingTop:{default:"80px"},contentPaddingBottom:{default:"140px"},showBackground:{type:Boolean,default:!0}},emits:["copy","scroll","scroll-bottom"],setup(o,{expose:h,emit:k}){const l=o,M=k,E=e.ref(null),N=e.ref(!1),B=async(m="smooth")=>{await e.nextTick(),E.value&&E.value.scrollTo({top:E.value.scrollHeight,behavior:m})},b=m=>{M("scroll",m);const C=m.target;if(!C)return;const{scrollTop:_,scrollHeight:V,clientHeight:y}=C;V-_-y<50?(N.value=!1,M("scroll-bottom")):l.isStreaming&&(N.value=!0)};e.watch(()=>l.messages.length,async()=>{l.autoScroll&&!N.value&&B()}),e.watch(()=>{var m;return(m=l.messages[l.messages.length-1])==null?void 0:m.content},async(m,C)=>{l.isStreaming&&l.autoScroll&&!N.value&&m&&C&&m.length>C.length&&E.value&&(E.value.scrollTop=E.value.scrollHeight)}),e.watch(()=>l.isTyping,m=>{m&&l.autoScroll&&B()});const w=m=>{M("copy",m),navigator.clipboard&&m.content&&navigator.clipboard.writeText(m.content)};e.watch(()=>l.agentSteps,()=>{l.autoScroll&&!N.value&&B()},{deep:!0});const c=()=>{l.autoScroll&&!N.value&&B()};return h({scrollToBottom:B,containerRef:E}),(m,C)=>(e.openBlock(),e.createElementBlock("div",Bt,[o.showBackground?(e.openBlock(),e.createElementBlock("div",Mt)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"chat-message-list",ref_key:"containerRef",ref:E,onScroll:b,style:e.normalizeStyle({paddingTop:o.contentPaddingTop,paddingBottom:o.contentPaddingBottom})},[o.showWelcome&&o.messages.length===0?(e.openBlock(),e.createElementBlock("div",Vt,[e.renderSlot(m.$slots,"welcome",{},()=>[e.createElementVNode("div",Nt,[e.createElementVNode("div",_t,[o.appLogo?(e.openBlock(),e.createElementBlock("img",{key:0,src:o.appLogo,alt:"Logo"},null,8,St)):(e.openBlock(),e.createElementBlock("div",xt,[...C[0]||(C[0]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"32",height:"32"},[e.createElementVNode("path",{fill:"currentColor",d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"})],-1)])]))]),e.createElementVNode("h2",bt,e.toDisplayString(o.appName),1),C[1]||(C[1]=e.createElementVNode("p",{class:"welcome-desc"},"今天有什么可以帮您?",-1))])],!0)])):(e.openBlock(),e.createElementBlock("div",$t,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.messages,(_,V)=>(e.openBlock(),e.createElementBlock("div",{key:_.id||V,class:e.normalizeClass(["message-row",_.role==="user"?"message-user":"message-assistant"])},[_.role==="user"?(e.openBlock(),e.createElementBlock("div",vt,[e.createVNode(J,{message:_,"is-user":!0},null,8,["message"])])):(e.openBlock(),e.createElementBlock("div",zt,[o.showAgentSteps&&V===o.messages.length-1&&o.agentSteps&&o.agentSteps.length>0?(e.openBlock(),e.createBlock(ne,{key:0,steps:o.agentSteps,onResize:c},null,8,["steps"])):e.createCommentVNode("",!0),e.createElementVNode("div",Lt,[e.createVNode(J,{message:_,"is-user":!1,"is-streaming":o.isStreaming&&V===o.messages.length-1},null,8,["message","is-streaming"])]),_.content&&!(o.isStreaming&&V===o.messages.length-1)?(e.openBlock(),e.createElementBlock("div",Tt,[e.createElementVNode("button",{class:"action-btn",onClick:y=>w(_),title:"复制"},[...C[2]||(C[2]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"12",height:"12"},[e.createElementVNode("path",{fill:"currentColor",d:"M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c6 6 14.1 9.4 22.6 9.4H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM352 853.3V704h149.3l-149.3 149.3zM224 256h448v640H416V672c0-17.7-14.3-32-32-32H224V256z"})],-1),e.createElementVNode("span",null,"复制",-1)])],8,Dt)])):e.createCommentVNode("",!0)]))],2))),128)),o.isTyping?(e.openBlock(),e.createElementBlock("div",It,[...C[3]||(C[3]=[e.createElementVNode("div",{class:"typing-indicator"},[e.createElementVNode("div",{class:"typing-dot"}),e.createElementVNode("div",{class:"typing-dot",style:{"animation-delay":"0.2s"}}),e.createElementVNode("div",{class:"typing-dot",style:{"animation-delay":"0.4s"}})],-1)])])):e.createCommentVNode("",!0)]))],36)]))}}),[["__scopeId","data-v-e2996e5d"]]),At={install(o){o.component("ChatMessageList",ue),o.component("MultimodalMessage",J),o.component("MarkdownMessage",ae),o.component("AgentSteps",ne)}};z.AgentSteps=ne,z.ChatMessageList=ue,z.MarkdownMessage=ae,z.MultimodalMessage=J,z.default=At,Object.defineProperties(z,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1
|
+
(function(z,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("markdown-it"),require("@vscode/markdown-it-katex"),require("mermaid")):typeof define=="function"&&define.amd?define(["exports","vue","markdown-it","@vscode/markdown-it-katex","mermaid"],e):(z=typeof globalThis<"u"?globalThis:z||self,e(z.ChatMessages={},z.Vue,z.markdownit,z.markdownItKatex,z.mermaid))})(this,(function(z,e,we,Ce,ce){"use strict";const Ee={class:"cm-dialog__body"},Be=e.defineComponent({__name:"Dialog",props:{visible:{type:Boolean,default:!1},width:{default:"50%"},fullscreen:{type:Boolean,default:!1},showClose:{type:Boolean,default:!0},closeOnClickModal:{type:Boolean,default:!0},appendToBody:{type:Boolean,default:!0}},emits:["update:visible","close"],setup(o,{emit:h}){const k=o,l=h,N=e.ref(!1);e.onMounted(()=>{N.value=!0});const E=e.computed(()=>k.fullscreen?{width:"100%",height:"100%",margin:0}:{width:k.width}),_=()=>{l("update:visible",!1),l("close")},B=()=>{k.closeOnClickModal&&_()};return(b,C)=>N.value?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:"body"},[o.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["cm-dialog-overlay",{"is-fullscreen":o.fullscreen}]),onClick:e.withModifiers(B,["self"])},[e.createElementVNode("div",{class:"cm-dialog",style:e.normalizeStyle(E.value),role:"dialog","aria-modal":"true"},[e.createElementVNode("div",Ee,[e.renderSlot(b.$slots,"default",{},void 0,!0)]),o.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:"cm-dialog__close",onClick:_},[...C[0]||(C[0]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16"},[e.createElementVNode("path",{fill:"currentColor",d:"M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"})],-1)])])):e.createCommentVNode("",!0)],4)],2)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}),U=(o,h)=>{const k=o.__vccOpts||o;for(const[l,N]of h)k[l]=N;return k},te=U(Be,[["__scopeId","data-v-efdf0259"]]),Me=["disabled"],Ne={key:0,class:"cm-icon-loading"},L=U(e.defineComponent({__name:"Button",props:{type:{default:"default"},size:{default:"default"},circle:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:["click"],setup(o,{emit:h}){const k=o,l=h,N=E=>{k.disabled||k.loading||l("click",E)};return(E,_)=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["cm-button",[`cm-button--${o.type}`,`cm-button--${o.size}`,{"is-circle":o.circle,"is-disabled":o.disabled,"is-loading":o.loading}]]),disabled:o.disabled||o.loading,onClick:N},[o.loading?(e.openBlock(),e.createElementBlock("span",Ne,[..._[0]||(_[0]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"1em",height:"1em"},[e.createElementVNode("path",{fill:"currentColor",d:"M512 64a448 448 0 0 1 448 448 32 32 0 1 1-64 0 416 416 0 0 0-416-416 416 416 0 0 0-416 416 32 32 0 1 1-64 0 448 448 0 0 1 448-448z"})],-1)])])):e.renderSlot(E.$slots,"default",{key:1},void 0,!0)],10,Me))}}),[["__scopeId","data-v-bab126c7"]]),T=(o,h)=>e.defineComponent({name:o,render(){return e.h("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",width:"1em",height:"1em",fill:"currentColor",style:"vertical-align: middle"},[e.h("path",{d:h})])}}),G=T("Close","M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"),ie=T("ZoomIn","M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm268.48-154.56a32 32 0 0 0-32 32v90.496h-90.56a32 32 0 0 0 0 64h90.56v90.56a32 32 0 0 0 64 0v-90.496h90.496a32 32 0 0 0 0-64H373.632v-90.56a32 32 0 0 0-32-32z"),de=T("ZoomOut","M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm145.92-58.56a32 32 0 0 0 0 64h245.12a32 32 0 0 0 0-64H219.072z"),me=T("Document","M854.6 288.7c0.4 0 0.7 0 1 0v431.5c0 17.6-14.4 32-32 32H200.4c-17.6 0-32-14.4-32-32l0-575.2c0-17.6 14.4-32 32-32h391.5c0 0.3 0 0.7 0 1l0 142.1c0 17.6 14.4 32.1 32 32.1h142.6c0-0.4 0-0.7 0-1.1L854.6 288.7zM790.2 220.2L668 97.9v122.3h122.2zM240 448h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h384a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64z"),ge=T("Download","M505.7 661a8 8 0 0 0 12.6 0l112-141.7c4.1-5.2 0.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"),Ve=T("VideoPlay","M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-48-247.616L668.608 512 464 375.616v272.768zm10.656-340.32a32 32 0 0 1 32 32V673.92a32 32 0 0 1-50.208 26.24l-236.8-161.92a32 32 0 0 1 0-52.48l236.8-161.92a32 32 0 0 1 18.208-5.632z"),_e=T("VideoPause","M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-96-544a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32zm192 0a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32z"),xe=T("ArrowLeft","M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"),Se=T("ArrowRight","M340.864 149.312a29.12 29.12 0 0 0-41.728 0 30.592 30.592 0 0 0 0 42.752L611.072 511.936 299.136 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L672.448 534.272a32 32 0 0 0 0-44.672L340.864 149.312z"),fe=T("Spinner","M512 64a448 448 0 0 1 448 448 32 32 0 1 1-64 0 416 416 0 0 0-416-416 416 416 0 0 0-416 416 32 32 0 1 1-64 0 448 448 0 0 1 448-448z"),he=T("Check","M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z"),be=T("ChevronUp","M854.6 642.5l-320-320c-12.5-12.5-32.8-12.5-45.3 0l-320 320c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L512 390.6l297.4 297.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3z"),$e=T("ChevronDown","M854.6 381.5l-320 320c-12.5 12.5-32.8 12.5-45.3 0l-320-320c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L512 633.4l297.4-297.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3z"),ve=["src","alt"],ze={class:"preview-controls"},Le={class:"cm-button-group"},Te={key:0,class:"mobile-close-hint"},De=["innerHTML"],Ie={class:"preview-controls"},Ae={class:"cm-button-group"},He={key:0,class:"mobile-close-hint"},ae=U(e.defineComponent({__name:"MarkdownMessage",props:{content:{},isStreaming:{type:Boolean,default:!1}},setup(o){const h=o,k=e.ref(),l=e.ref(),N=e.ref(!1),E=e.ref(""),_=e.ref(""),B=e.ref(!1),b=e.ref(""),C=e.ref(!1),c=e.ref(1),i=e.ref({x:0,y:0}),y=e.ref(!1),V=e.ref({x:0,y:0}),M=e.ref(1),w=e.ref({x:0,y:0}),Y=e.ref(!1),O=e.ref({x:0,y:0}),W=e.ref(""),R=e.ref(new Map);let X=0;ce.initialize({startOnLoad:!1,theme:"default",securityLevel:"loose",fontFamily:"inherit"});const Q=t=>{const a=t.renderer.rules.fence;t.renderer.rules.fence=(s,g,r,n,m)=>{const p=s[g],v=p.content.trim();return(p.info?p.info.trim():"")==="mermaid"?(X++,`<div class="mermaid-container"><pre class="mermaid" data-mermaid-id="${`mermaid-${Date.now()}-${X}`}">${v}</pre></div>`):a(s,g,r,n,m)}},F=new we({html:!0,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkify:!0,typographer:!0,quotes:`""''`,highlight:function(t,a){return a&&a.trim()?`<pre class="hljs language-${a}"><code>${(g=>g.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"))(t)}</code></pre>`:`<pre class="hljs"><code>${t}</code></pre>`}}),Z=F.renderer.rules.image||function(t,a,s,g,r){return r.renderToken(t,a,s)};F.renderer.rules.image=function(t,a,s,g,r){const n=t[a],m=n.attrIndex("src");if(m>=0){const p=n.attrs[m][1],S="img-"+(I=>{let $=0;for(let D=0;D<I.length;D++){const H=I.charCodeAt(D);$=($<<5)-$+H,$=$&$}return Math.abs($).toString(36)})(p);n.attrSet("id",S),n.attrSet("data-image-id",S),n.attrSet("key",S),n.attrSet("loading","eager"),n.attrSet("decoding","async"),n.attrSet("fetchpriority","high"),n.attrSet("data-src",p),n.attrSet("data-cached","true")}return Z(t,a,s,g,r)},F.use(Ce,{throwOnError:!1,errorColor:"#cc0000"}),F.use(Q);const oe=t=>{const a=t.match(/```[\w]*\n/g),s=t.match(/\n```/g),g=(a==null?void 0:a.length)||0,r=(s==null?void 0:s.length)||0;return g>r&&(t+="\n```"),t},ee=t=>{if(!t)return"";t=t.replace(/;;\s*$/g,""),t=t.replace(/;;\s*$/g,"");const a=/^```(?:markdown|md)\s*\n([\s\S]*?)\n```$/,s=t.match(a);if(s)t=s[1];else{const g=/^```\s*\n([\s\S]*?)\n```$/,r=t.match(g);if(r){const n=r[1];(/^#{1,6}\s/.test(n)||/^\*{1,2}[^*]+\*{1,2}/.test(n)||/^[-*+]\s/.test(n)||/^\d+\.\s/.test(n)||/!\[.*?\]\(.*?\)/.test(n)||/\[.*?\]\(.*?\)/.test(n)||/^\|.+\|/.test(n)||/^\|[\s-:]+\|/m.test(n))&&(t=n)}}if(h.isStreaming){const g=/^```(?:markdown|md)?\s*\n/;if(g.test(t)){const n=t.replace(g,"");(/^#{1,6}\s/.test(n)||/^\|.+\|/.test(n)||/^\|[\s-:]+\|/m.test(n)||/!\[.*?\]\(.*?\)/.test(n)||/\[.*?\]\(.*?\)/.test(n))&&(t=t.replace(g,""))}if(/^```(?:markdown|md)?\s*\n/.test(h.content)){const n=/\n```\s*$/;n.test(t)&&(t=t.replace(n,""))}}return t=t.replace(/```(?:markdown|md)\s*\n([\s\S]*?)\n```/g,(g,r)=>r),h.isStreaming&&(t=oe(t)),t},se=t=>{if(!t.includes("<img"))return t;const a=/<img[^>]*?src="([^"]*)"[^>]*?>/g;let s,g=t;const r=[];for(;(s=a.exec(t))!==null;){const n=s[0],m=s[1];if(R.value.has(m)){const p=R.value.get(m);n!==p&&r.push({original:n,cached:p})}else R.value.set(m,n)}for(const{original:n,cached:m}of r)g=g.replace(n,m);return g},le=t=>{if(!l.value)return;const a=l.value;if(!h.isStreaming||a.children.length===0){a.innerHTML=t,h.isStreaming||e.nextTick(()=>{ye(),u()});return}const s=document.createElement("div");s.innerHTML=t;const g=new Map;a.querySelectorAll("img[data-image-id]").forEach(n=>{const m=n.getAttribute("data-image-id");m&&g.set(m,n)}),s.querySelectorAll("img[data-image-id]").forEach(n=>{const m=n.getAttribute("data-image-id");if(m&&g.has(m)){const p=g.get(m);n.parentNode&&n.parentNode.replaceChild(p,n)}});const r=document.createDocumentFragment();for(;s.firstChild;)r.appendChild(s.firstChild);a.innerHTML="",a.appendChild(r)},P=()=>{try{if(!h.content){W.value="",l.value&&(l.value.innerHTML=""),h.isStreaming||R.value.clear();return}const t=ee(h.content);let a=F.render(t);h.isStreaming&&a.includes("<img")&&(a=se(a)),a!==W.value&&(W.value=a,le(a)),h.isStreaming||R.value.clear()}catch(t){console.error("Markdown rendering error:",t),l.value&&(l.value.innerHTML=`<pre style="white-space: pre-wrap; word-wrap: break-word;">${h.content}</pre>`)}};e.watch(()=>h.content,P),e.watch(()=>h.isStreaming,(t,a)=>{a&&!t&&e.nextTick(()=>{P()})});const d=()=>{C.value=window.innerWidth<768},f=t=>{let a=t;return a=a.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1"),[/([A-Za-z0-9_]+)\[([^\]]*[\u4e00-\u9fa5]+[^\]]*)\]/g,/([A-Za-z0-9_]+)\(([^)]*[\u4e00-\u9fa5]+[^)]*)\)/g,/([A-Za-z0-9_]+)\{([^}]*[\u4e00-\u9fa5]+[^}]*)\}/g].forEach(g=>{a=a.replace(g,(r,n,m)=>{if(m.startsWith('"')&&m.endsWith('"'))return r;let p=m.replace(/^["']+|["']+$/g,"").replace(/["]/g,'\\"');return r.includes("[")?`${n}["${p}"]`:r.includes("(")?`${n}("${p}")`:r.includes("{")?`${n}{"${p}"}`:r})}),a},u=async()=>{var a,s;if(h.isStreaming||(await e.nextTick(),!k.value))return;const t=k.value.querySelectorAll(".mermaid");if(t.length!==0)for(const g of Array.from(t)){const r=g;let n=(a=r.textContent)==null?void 0:a.trim();if(n&&r.getAttribute("data-processed")!=="true")try{r.setAttribute("data-processed","true"),n=f(n);const m=r.getAttribute("data-mermaid-id")||`mermaid-${Date.now()}-${Math.random()}`,{svg:p}=await ce.render(m,n),v=r.parentElement;if(v){const S=document.createElement("div");S.className="mermaid-svg",S.innerHTML=p,S.setAttribute("data-mermaid-svg","true"),S.style.cursor="pointer",S.title="Click to zoom",S.addEventListener("click",I=>{I.preventDefault(),I.stopPropagation(),b.value=p,M.value=1,w.value={x:0,y:0},B.value=!0}),v.replaceChild(S,r)}}catch(m){console.error("Mermaid render failure:",m);const p=document.createElement("div");p.className="mermaid-error",p.textContent=`Mermaid render error: ${m}`,(s=r.parentElement)==null||s.replaceChild(p,r)}}},x=t=>{t.preventDefault(),t.stopPropagation();const a=t.target;E.value=a.src,_.value=a.alt||"Image Preview",c.value=1,i.value={x:0,y:0},N.value=!0},A=()=>{c.value<=1&&(i.value={x:0,y:0})},Ht=()=>{c.value=Math.min(c.value+1,10),A()},Rt=()=>{c.value=Math.max(c.value-1,.5),A()},pe=()=>{c.value=1,i.value={x:0,y:0}},Ft=()=>{c.value<=1&&(N.value=!1)},Pt=t=>{t.preventDefault();const a=t.deltaY>0?-.5:.5,s=Math.max(.5,Math.min(10,c.value+a));c.value=s,A()},Ut=t=>{var n;if(c.value<=1)return;t.preventDefault(),y.value=!0,V.value={x:t.clientX-i.value.x,y:t.clientY-i.value.y};const a=t.target,s=(n=a.parentElement)==null?void 0:n.getBoundingClientRect(),g=m=>{if(!y.value||!s)return;let p=m.clientX-V.value.x,v=m.clientY-V.value.y;const S=a.offsetWidth,I=a.offsetHeight,$=S*c.value,D=I*c.value,H=.3,re=s.width*(1-H-.5)-$/2,j=$/2-s.width*(1-H-.5),K=s.height*(1-H-.5)-D/2,q=D/2-s.height*(1-H-.5);$>s.width?p=Math.max(re,Math.min(j,p)):p=0,D>s.height?v=Math.max(K,Math.min(q,v)):v=0,i.value={x:p,y:v}},r=()=>{y.value=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",r)},Yt=t=>{var v;if(t.touches.length!==1)return;const a=t.touches[0],s=a.clientX,g=a.clientY;if(c.value<=1)return;y.value=!0,V.value={x:s-i.value.x,y:g-i.value.y};const r=t.target,n=(v=r.parentElement)==null?void 0:v.getBoundingClientRect(),m=S=>{if(!y.value||S.touches.length!==1||!n)return;const I=S.touches[0];let $=I.clientX-V.value.x,D=I.clientY-V.value.y;const H=r.offsetWidth,re=r.offsetHeight,j=H*c.value,K=re*c.value,q=.3,jt=n.width*(1-q-.5)-j/2,Kt=j/2-n.width*(1-q-.5),Gt=n.height*(1-q-.5)-K/2,Jt=K/2-n.height*(1-q-.5);j>n.width?$=Math.max(jt,Math.min(Kt,$)):$=0,K>n.height?D=Math.max(Gt,Math.min(Jt,D)):D=0,i.value={x:$,y:D}},p=()=>{y.value=!1,document.removeEventListener("touchmove",m),document.removeEventListener("touchend",p)};document.addEventListener("touchmove",m,{passive:!1}),document.addEventListener("touchend",p)},Ot=()=>{M.value=Math.min(M.value+1,10)},Wt=()=>{M.value=Math.max(M.value-1,.5)},ke=()=>{M.value=1,w.value={x:0,y:0}},Xt=t=>{t.preventDefault();const a=t.deltaY>0?-.5:.5;M.value=Math.max(.5,Math.min(10,M.value+a))},qt=t=>{var n,m;if(M.value<=1)return;t.preventDefault(),Y.value=!0,O.value={x:t.clientX-w.value.x,y:t.clientY-w.value.y};const s=(m=(n=t.target.closest(".mermaid-preview-content"))==null?void 0:n.parentElement)==null?void 0:m.getBoundingClientRect(),g=p=>{if(!Y.value||!s)return;let v=p.clientX-O.value.x,S=p.clientY-O.value.y;w.value={x:v,y:S}},r=()=>{Y.value=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",r)},Zt=t=>{},ye=()=>{h.isStreaming||e.nextTick(()=>{if(!k.value)return;k.value.querySelectorAll(".markdown-content img").forEach(a=>{const s=a;s.getAttribute("data-processed")!=="true"&&(s.setAttribute("data-processed","true"),s.style.cursor="pointer",s.addEventListener("click",x))})})};return e.onMounted(()=>{d(),window.addEventListener("resize",d),P(),ye(),u()}),e.onUnmounted(()=>{k.value&&k.value.querySelectorAll(".markdown-content img").forEach(a=>{a.removeEventListener("click",x)})}),(t,a)=>(e.openBlock(),e.createElementBlock("div",{class:"markdown-message",ref_key:"markdownContainer",ref:k},[e.createElementVNode("div",{ref_key:"markdownContent",ref:l,class:"markdown-content"},null,512),e.createVNode(te,{visible:N.value,"onUpdate:visible":a[2]||(a[2]=s=>N.value=s),width:C.value?"95vw":"80vw",fullscreen:C.value,class:"image-preview-dialog","close-on-click-modal":!1,"append-to-body":""},{default:e.withCtx(()=>[e.createElementVNode("div",{class:"image-preview-container",onClick:a[1]||(a[1]=e.withModifiers(s=>N.value=!1,["self"]))},[e.createElementVNode("img",{src:E.value,alt:_.value,class:"preview-image",style:e.normalizeStyle({transform:`translate(${i.value.x}px, ${i.value.y}px) scale(${c.value})`}),onWheel:e.withModifiers(Pt,["prevent"]),onDblclick:pe,onMousedown:Ut,onTouchstart:e.withModifiers(Yt,["prevent"]),onClick:Ft},null,44,ve),e.createElementVNode("div",ze,[e.createElementVNode("div",Le,[e.createVNode(L,{size:"small",onClick:Rt,disabled:c.value<=.5},{default:e.withCtx(()=>[e.createVNode(e.unref(de))]),_:1},8,["disabled"]),e.createVNode(L,{size:"small",onClick:pe},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(Math.round(c.value*100))+"% ",1)]),_:1}),e.createVNode(L,{size:"small",onClick:Ht,disabled:c.value>=10},{default:e.withCtx(()=>[e.createVNode(e.unref(ie))]),_:1},8,["disabled"])]),e.createVNode(L,{size:"small",onClick:a[0]||(a[0]=s=>N.value=!1),type:"danger"},{default:e.withCtx(()=>[e.createVNode(e.unref(G))]),_:1})]),C.value?(e.openBlock(),e.createElementBlock("div",Te,"双击重置 · 轻触关闭")):e.createCommentVNode("",!0)])]),_:1},8,["visible","width","fullscreen"]),e.createVNode(te,{visible:B.value,"onUpdate:visible":a[5]||(a[5]=s=>B.value=s),width:C.value?"95vw":"90vw",fullscreen:C.value,class:"mermaid-preview-dialog","close-on-click-modal":!1,"append-to-body":""},{default:e.withCtx(()=>[e.createElementVNode("div",{class:"mermaid-preview-container",onClick:a[4]||(a[4]=e.withModifiers(s=>B.value=!1,["self"]))},[e.createElementVNode("div",{class:"mermaid-preview-content",innerHTML:b.value,style:e.normalizeStyle({transform:`translate(${w.value.x}px, ${w.value.y}px) scale(${M.value})`}),onWheel:e.withModifiers(Xt,["prevent"]),onDblclick:ke,onMousedown:qt,onTouchstart:e.withModifiers(Zt,["prevent"])},null,44,De),e.createElementVNode("div",Ie,[e.createElementVNode("div",Ae,[e.createVNode(L,{size:"small",onClick:Wt,disabled:M.value<=.5},{default:e.withCtx(()=>[e.createVNode(e.unref(de))]),_:1},8,["disabled"]),e.createVNode(L,{size:"small",onClick:ke},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(Math.round(M.value*100))+"% ",1)]),_:1}),e.createVNode(L,{size:"small",onClick:Ot,disabled:M.value>=10},{default:e.withCtx(()=>[e.createVNode(e.unref(ie))]),_:1},8,["disabled"])]),e.createVNode(L,{size:"small",onClick:a[3]||(a[3]=s=>B.value=!1),type:"danger"},{default:e.withCtx(()=>[e.createVNode(e.unref(G))]),_:1})]),C.value?(e.openBlock(),e.createElementBlock("div",He,"双击重置 · 轻触关闭")):e.createCommentVNode("",!0)])]),_:1},8,["visible","width","fullscreen"])],512))}}),[["__scopeId","data-v-e47faf67"]]),Re={key:0,class:"text-content"},Fe={key:1,class:"images-content"},Pe=["onClick"],Ue=["src","alt","onError"],Ye={key:0,class:"more-images"},Oe={key:2,class:"attachments-content"},We={class:"file-icon-wrapper"},Xe={class:"attachment-info"},qe={class:"attachment-name"},Ze={class:"attachment-size"},je={key:3,class:"files-content"},Ke=["onClick"],Ge={class:"file-icon-wrapper-small"},Je={class:"file-info"},Qe={class:"file-name"},et={class:"file-type"},tt={class:"file-actions"},at={key:4,class:"audio-content"},nt={class:"audio-player"},ot={class:"audio-info"},st={class:"audio-progress"},lt={class:"progress-bar"},rt={class:"audio-time"},ct={class:"image-preview-container"},it=["src"],dt={key:0,class:"image-nav"},mt={class:"image-counter"},J=U(e.defineComponent({__name:"MultimodalMessage",props:{message:{},isUser:{type:Boolean,default:!1},isStreaming:{type:Boolean,default:!1}},setup(o){const h=o,k=e.computed(()=>{try{return h.message.metadata?JSON.parse(h.message.metadata):{}}catch{return{}}}),l=e.computed(()=>k.value.imageUrls||[]),N=e.computed(()=>k.value.fileUrls||[]),E=e.computed(()=>k.value.audioUrl),_=e.computed(()=>h.message.attachments&&h.message.attachments.length>0?h.message.attachments:k.value.attachments&&Array.isArray(k.value.attachments)?k.value.attachments:[]),B=e.ref(!1),b=e.ref(""),C=e.ref(0),c=e.ref(!1),i=e.ref(!1),y=e.ref(0),V=e.ref(0),M=e.computed(()=>V.value>0?y.value/V.value*100:0);let w=null;const Y=(d,f)=>{b.value=d,C.value=f,B.value=!0},O=()=>{C.value>0&&(C.value--,b.value=l.value[C.value])},W=()=>{C.value<l.value.length-1&&(C.value++,b.value=l.value[C.value])},R=(d,f)=>{console.error("Image load failed:",f);const u=d.target;u.style.display="none"},X=d=>{try{const u=new URL(d).pathname,x=u.substring(u.lastIndexOf("/")+1);return decodeURIComponent(x)||"Unknown File"}catch{return"Unknown File"}},Q=d=>{var x;return((x=X(d).split(".").pop())==null?void 0:x.toUpperCase())||"FILE"},F=d=>{const f=Q(d).toLowerCase();["jpg","jpeg","png","gif","webp","pdf"].includes(f)?window.open(d,"_blank"):Z(d)},Z=d=>{try{const f=document.createElement("a");f.href=d,f.download=X(d),f.target="_blank",document.body.appendChild(f),f.click(),document.body.removeChild(f)}catch(f){console.error("Download failed:",f),alert("下载失败")}},oe=async()=>{if(E.value)try{w||(w=new Audio,w.src=E.value,w.addEventListener("loadedmetadata",()=>{V.value=(w==null?void 0:w.duration)||0}),w.addEventListener("timeupdate",()=>{y.value=(w==null?void 0:w.currentTime)||0}),w.addEventListener("ended",()=>{c.value=!1,y.value=0}),w.addEventListener("error",d=>{console.error("Audio playback error:",d),i.value=!1,c.value=!1})),c.value?(w.pause(),c.value=!1):(i.value=!0,await w.play(),c.value=!0,i.value=!1)}catch(d){console.error("Audio playback failed:",d),i.value=!1,c.value=!1}},ee=d=>{const f=Math.floor(d/60),u=Math.floor(d%60);return`${f}:${u.toString().padStart(2,"0")}`},se=d=>{if(d===0)return"0 B";const f=1024,u=["B","KB","MB","GB"],x=Math.floor(Math.log(d)/Math.log(f));return(d/Math.pow(f,x)).toFixed(2)+u[x]},le=d=>{var u;return((u=d.split(".").pop())==null?void 0:u.toUpperCase())||"FILE"},P=d=>{B.value&&(d.key==="ArrowLeft"?O():d.key==="ArrowRight"?W():d.key==="Escape"&&(B.value=!1))};return e.watch(B,d=>{d?document.addEventListener("keydown",P):document.removeEventListener("keydown",P)}),e.onUnmounted(()=>{w&&(w.pause(),w=null),document.removeEventListener("keydown",P)}),(d,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["multimodal-message",{"is-user":o.isUser,"is-assistant":!o.isUser}])},[o.message.content?(e.openBlock(),e.createElementBlock("div",Re,[e.createVNode(ae,{content:o.message.content,"is-streaming":o.isStreaming},null,8,["content","is-streaming"])])):e.createCommentVNode("",!0),l.value&&l.value.length>0?(e.openBlock(),e.createElementBlock("div",Fe,[e.createElementVNode("div",{class:e.normalizeClass(["images-grid",`grid-${Math.min(l.value.length,4)}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.slice(0,4),(u,x)=>(e.openBlock(),e.createElementBlock("div",{key:x,class:"image-item",onClick:A=>Y(u,x)},[e.createElementVNode("img",{src:u,alt:`图片 ${x+1}`,onError:A=>R(A,u),loading:"lazy"},null,40,Ue),x===3&&l.value.length>4?(e.openBlock(),e.createElementBlock("div",Ye," +"+e.toDisplayString(l.value.length-4),1)):e.createCommentVNode("",!0)],8,Pe))),128))],2)])):e.createCommentVNode("",!0),_.value&&_.value.length>0?(e.openBlock(),e.createElementBlock("div",Oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,(u,x)=>(e.openBlock(),e.createElementBlock("div",{key:x,class:"attachment-item"},[e.createElementVNode("div",We,[e.createVNode(e.unref(me),{class:"file-icon"})]),e.createElementVNode("div",Xe,[e.createElementVNode("span",qe,e.toDisplayString(u.name),1),e.createElementVNode("span",Ze,e.toDisplayString(le(u.name))+" "+e.toDisplayString(se(u.size)),1)])]))),128))])):e.createCommentVNode("",!0),N.value&&N.value.length>0?(e.openBlock(),e.createElementBlock("div",je,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.value,(u,x)=>(e.openBlock(),e.createElementBlock("div",{key:x,class:"file-item",onClick:A=>F(u)},[e.createElementVNode("div",Ge,[e.createVNode(e.unref(me),{class:"file-icon"})]),e.createElementVNode("div",Je,[e.createElementVNode("span",Qe,e.toDisplayString(X(u)),1),e.createElementVNode("span",et,e.toDisplayString(Q(u)),1)]),e.createElementVNode("div",tt,[e.createVNode(L,{size:"small",type:"text",onClick:e.withModifiers(A=>Z(u),["stop"])},{default:e.withCtx(()=>[e.createVNode(e.unref(ge))]),_:1},8,["onClick"])])],8,Ke))),128))])):e.createCommentVNode("",!0),E.value?(e.openBlock(),e.createElementBlock("div",at,[e.createElementVNode("div",nt,[e.createVNode(L,{onClick:oe,loading:i.value,circle:"",size:"small",class:"play-btn"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c.value?e.unref(_e):e.unref(Ve))))]),_:1},8,["loading"]),e.createElementVNode("div",ot,[e.createElementVNode("div",st,[e.createElementVNode("div",lt,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:M.value+"%"})},null,4)])]),e.createElementVNode("div",rt,[e.createElementVNode("span",null,e.toDisplayString(ee(y.value)),1),f[4]||(f[4]=e.createElementVNode("span",null,"/",-1)),e.createElementVNode("span",null,e.toDisplayString(ee(V.value)),1)])]),e.createVNode(L,{onClick:f[0]||(f[0]=u=>Z(E.value)),size:"small",type:"text",class:"download-btn"},{default:e.withCtx(()=>[e.createVNode(e.unref(ge))]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(te,{visible:B.value,"onUpdate:visible":f[3]||(f[3]=u=>B.value=u),width:"90%","show-close":!1,"append-to-body":"",class:"image-preview-dialog-wrapper"},{default:e.withCtx(()=>[e.createElementVNode("div",ct,[e.createElementVNode("img",{src:b.value,alt:"预览图片",class:"preview-image",onClick:f[1]||(f[1]=u=>B.value=!1)},null,8,it),l.value&&l.value.length>1?(e.openBlock(),e.createElementBlock("div",dt,[e.createVNode(L,{onClick:O,disabled:C.value===0,circle:"",class:"nav-btn"},{default:e.withCtx(()=>[e.createVNode(e.unref(xe))]),_:1},8,["disabled"]),e.createElementVNode("span",mt,e.toDisplayString(C.value+1)+" / "+e.toDisplayString(l.value.length),1),e.createVNode(L,{onClick:W,disabled:C.value===l.value.length-1,circle:"",class:"nav-btn"},{default:e.withCtx(()=>[e.createVNode(e.unref(Se))]),_:1},8,["disabled"])])):e.createCommentVNode("",!0),e.createVNode(L,{onClick:f[2]||(f[2]=u=>B.value=!1),class:"close-btn",circle:""},{default:e.withCtx(()=>[e.createVNode(e.unref(G))]),_:1})])]),_:1},8,["visible"])],2))}}),[["__scopeId","data-v-7795fedb"]]),gt={key:0,class:"agent-steps"},ft={class:"steps-indicator"},ht={key:0,class:"icon-running"},ut={key:1,class:"icon-completed"},pt={class:"steps-summary"},kt={class:"icon-chevron"},yt={class:"steps-list"},wt={class:"step-icon"},Ct={key:3,class:"icon-dot"},Et={class:"step-name"},ne=U(e.defineComponent({__name:"AgentSteps",props:{steps:{}},emits:["resize"],setup(o,{emit:h}){const k=o,l=e.ref(!0),N=h,E=()=>{l.value=!l.value,setTimeout(()=>{N("resize")},300)},_=e.computed(()=>k.steps.some(b=>b.status==="running")),B=e.computed(()=>{const b=k.steps.find(c=>c.status==="running");if(b)return`正在${b.displayName}...`;const C=k.steps.filter(c=>c.status==="completed").length;return C===k.steps.length?"处理完成":`已完成 ${C}/${k.steps.length} 个步骤`});return(b,C)=>o.steps.length>0?(e.openBlock(),e.createElementBlock("div",gt,[e.createElementVNode("div",{class:"steps-header",onClick:E},[e.createElementVNode("div",ft,[_.value?(e.openBlock(),e.createElementBlock("div",ht,[e.createVNode(e.unref(fe))])):(e.openBlock(),e.createElementBlock("div",ut,[e.createVNode(e.unref(he))]))]),e.createElementVNode("span",pt,e.toDisplayString(B.value),1),e.createElementVNode("div",kt,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.value?e.unref(be):e.unref($e))))])]),e.withDirectives(e.createElementVNode("div",yt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.steps,c=>(e.openBlock(),e.createElementBlock("div",{key:c.name,class:e.normalizeClass(["step-item",{"is-running":c.status==="running","is-completed":c.status==="completed","is-error":c.status==="error"}])},[e.createElementVNode("div",wt,[c.status==="running"?(e.openBlock(),e.createBlock(e.unref(fe),{key:0,class:"icon-spin"})):c.status==="completed"?(e.openBlock(),e.createBlock(e.unref(he),{key:1})):c.status==="error"?(e.openBlock(),e.createBlock(e.unref(G),{key:2})):(e.openBlock(),e.createElementBlock("div",Ct))]),e.createElementVNode("span",Et,e.toDisplayString(c.displayName),1)],2))),128))],512),[[e.vShow,l.value]])])):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-181f5844"]]),Bt={class:"chat-message-list-root"},Mt={key:0,class:"bg-grid"},Nt={key:0,class:"welcome-screen"},Vt={class:"welcome-content"},_t={class:"welcome-logo"},xt=["src"],St={key:1,class:"default-logo"},bt={class:"welcome-title"},$t={key:1,class:"messages-container"},vt={key:0,class:"message-bubble user-bubble"},zt={key:1,class:"message-content assistant-content"},Lt={class:"message-bubble assistant-bubble"},Tt={key:1,class:"message-actions"},Dt=["onClick"],It={key:0,class:"message-row message-assistant"},ue=U(e.defineComponent({__name:"ChatMessageList",props:{messages:{default:()=>[]},isStreaming:{type:Boolean,default:!1},isTyping:{type:Boolean,default:!1},showWelcome:{type:Boolean,default:!0},appName:{default:"AI助手"},appLogo:{},agentSteps:{},showAgentSteps:{type:Boolean,default:!0},autoScroll:{type:Boolean,default:!0},contentPaddingTop:{default:"80px"},contentPaddingBottom:{default:"140px"},showBackground:{type:Boolean,default:!0}},emits:["copy","scroll","scroll-bottom"],setup(o,{expose:h,emit:k}){const l=o,N=k,E=e.ref(null),_=e.ref(!1),B=async(i="smooth")=>{await e.nextTick(),E.value&&E.value.scrollTo({top:E.value.scrollHeight,behavior:i})},b=i=>{N("scroll",i);const y=i.target;if(!y)return;const{scrollTop:V,scrollHeight:M,clientHeight:w}=y;M-V-w<50?(_.value=!1,N("scroll-bottom")):_.value=!0};e.watch(()=>l.messages.length,async(i,y)=>{i>(y||0)&&(_.value=!1),l.autoScroll&&!_.value&&B()}),e.watch(()=>{var i;return(i=l.messages[l.messages.length-1])==null?void 0:i.content},async(i,y)=>{if(l.isStreaming&&l.autoScroll&&!_.value){const V=(i==null?void 0:i.length)||0,M=(y==null?void 0:y.length)||0;V>M&&E.value&&E.value.scrollTo({top:E.value.scrollHeight,behavior:"instant"})}}),e.watch(()=>l.isTyping,i=>{i&&l.autoScroll&&B()});const C=i=>{N("copy",i),navigator.clipboard&&i.content&&navigator.clipboard.writeText(i.content)};e.watch(()=>l.agentSteps,()=>{l.autoScroll&&!_.value&&B()},{deep:!0});const c=()=>{l.autoScroll&&!_.value&&B()};return h({scrollToBottom:B,containerRef:E}),(i,y)=>(e.openBlock(),e.createElementBlock("div",Bt,[o.showBackground?(e.openBlock(),e.createElementBlock("div",Mt)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"chat-message-list",ref_key:"containerRef",ref:E,onScroll:b,style:e.normalizeStyle({paddingTop:o.contentPaddingTop,paddingBottom:o.contentPaddingBottom})},[o.showWelcome&&o.messages.length===0?(e.openBlock(),e.createElementBlock("div",Nt,[e.renderSlot(i.$slots,"welcome",{},()=>[e.createElementVNode("div",Vt,[e.createElementVNode("div",_t,[o.appLogo?(e.openBlock(),e.createElementBlock("img",{key:0,src:o.appLogo,alt:"Logo"},null,8,xt)):(e.openBlock(),e.createElementBlock("div",St,[...y[0]||(y[0]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"32",height:"32"},[e.createElementVNode("path",{fill:"currentColor",d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"})],-1)])]))]),e.createElementVNode("h2",bt,e.toDisplayString(o.appName),1),y[1]||(y[1]=e.createElementVNode("p",{class:"welcome-desc"},"今天有什么可以帮您?",-1))])],!0)])):(e.openBlock(),e.createElementBlock("div",$t,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.messages,(V,M)=>(e.openBlock(),e.createElementBlock("div",{key:V.id||M,class:e.normalizeClass(["message-row",V.role==="user"?"message-user":"message-assistant"])},[V.role==="user"?(e.openBlock(),e.createElementBlock("div",vt,[e.createVNode(J,{message:V,"is-user":!0},null,8,["message"])])):(e.openBlock(),e.createElementBlock("div",zt,[o.showAgentSteps&&M===o.messages.length-1&&o.agentSteps&&o.agentSteps.length>0?(e.openBlock(),e.createBlock(ne,{key:0,steps:o.agentSteps,onResize:c},null,8,["steps"])):e.createCommentVNode("",!0),e.createElementVNode("div",Lt,[e.createVNode(J,{message:V,"is-user":!1,"is-streaming":o.isStreaming&&M===o.messages.length-1},null,8,["message","is-streaming"])]),V.content&&!(o.isStreaming&&M===o.messages.length-1)?(e.openBlock(),e.createElementBlock("div",Tt,[e.createElementVNode("button",{class:"action-btn",onClick:w=>C(V),title:"复制"},[...y[2]||(y[2]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"12",height:"12"},[e.createElementVNode("path",{fill:"currentColor",d:"M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c6 6 14.1 9.4 22.6 9.4H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM352 853.3V704h149.3l-149.3 149.3zM224 256h448v640H416V672c0-17.7-14.3-32-32-32H224V256z"})],-1),e.createElementVNode("span",null,"复制",-1)])],8,Dt)])):e.createCommentVNode("",!0)]))],2))),128)),o.isTyping?(e.openBlock(),e.createElementBlock("div",It,[...y[3]||(y[3]=[e.createElementVNode("div",{class:"typing-indicator"},[e.createElementVNode("div",{class:"typing-dot"}),e.createElementVNode("div",{class:"typing-dot",style:{"animation-delay":"0.2s"}}),e.createElementVNode("div",{class:"typing-dot",style:{"animation-delay":"0.4s"}})],-1)])])):e.createCommentVNode("",!0)]))],36)]))}}),[["__scopeId","data-v-02d657d5"]]),At={install(o){o.component("ChatMessageList",ue),o.component("MultimodalMessage",J),o.component("MarkdownMessage",ae),o.component("AgentSteps",ne)}};z.AgentSteps=ne,z.ChatMessageList=ue,z.MarkdownMessage=ae,z.MultimodalMessage=J,z.default=At,Object.defineProperties(z,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|