UNPKG

@liuyuzhao/ai-chat

Version:

A Vue 3 AI chat component with TypeScript support for Web, H5, and UniApp

2 lines (1 loc) 25.6 kB
"use strict";var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,r=(t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,a=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&r(e,n,t[n]);if(o)for(var n of o(t))l.call(t,n)&&r(e,n,t[n]);return e},c=(e,t,n)=>new Promise((o,s)=>{var l=e=>{try{a(n.next(e))}catch(t){s(t)}},r=e=>{try{a(n.throw(e))}catch(t){s(t)}},a=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,r);a((n=n.apply(e,t)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("vue"),d=require("marked"),u=require("dompurify");class A{constructor(e){var t,n;r(this,"symbol"!=typeof(t="config")?t+"":t,n),this.config=e}connect(e,t,n,o,s,l){return c(this,null,function*(){try{const r=new URLSearchParams,a=`${e[e.length-1][0].content}`;r.append("prompt",a),t&&r.append("sessionId",t),n.requestParams&&Object.entries(n.requestParams).forEach(([e,t])=>{r.append(e,String(t))}),r.has("lawyerName")||r.append("lawyerName",n.lawyerName||""),n.lawyerAllowedPort&&r.append("lawyerAllowedPort",n.lawyerAllowedPort||""),r.has("knowledgeCode")||r.append("knowledgeCode",n.knowledgeCode||""),r.has("hotIssues")||r.append("hotIssues",n.hotIssues||"");const c=`${n.apiUrl}/chat?${r.toString()}`;return yield this.connectWeb(c,n.headers,o,s,l)}catch(r){return s(new Error(`Failed to establish connection: ${r}`)),{close:()=>{}}}})}connectWeb(e,t,n,o,s){return c(this,null,function*(){const{EventSourcePolyfill:l}=yield Promise.resolve().then(()=>require("./eventsource-esBbfMJO.js")).then(e=>e.eventsource),r=new l(e,a({withCredentials:!1},t&&{headers:t}));return r.addEventListener("message",e=>{try{n(e.data)}catch(t){o(new Error(`Message parsing error: ${t}`))}}),r.addEventListener("error",e=>{o(new Error("Connection error occurred")),r.close()}),r.addEventListener("end",()=>{r.close(),null==s||s()}),r})}connectUniapp(e,t,n,o,s){const l=uni.request({url:e,method:"GET",header:t||{},responseType:"text",enableChunked:!0,success:e=>{try{n(e.data),null==s||s()}catch(t){o(new Error(`Message parsing error: ${t}`))}},fail:e=>{o(new Error("Connection error occurred"))}});return{close:()=>l.abort()}}}let g="";function f(e){const o=i.ref([]),s=i.ref(""),l=i.ref(!1),r=i.ref(null),d=i.ref(null),u=i.ref(null),f=i.ref(null),h=i.ref([]),p=i.ref([]),m=i.ref([]),E=i.ref(!1),w=i.ref(!1),y=i.ref(!1),C=i.ref(["hotQuestions","systemQuestions","lawyerQuestions"]),v=new Map;let B=null;const b=new A(e),Q=e=>{const t={hotQuestions:{category:"0",ref:h,loading:E},systemQuestions:{category:"1",ref:p,loading:w},lawyerQuestions:{category:"2",ref:m,loading:y}};return t[e]||t.lawyerQuestions},k=(e,t)=>{Q(e).loading.value=t},L=(e,t)=>{Q(e).ref.value=t},S=(...e)=>c(this,[...e],function*(e=[],t="lawyerQuestions",n=!1){return n?yield x(e,t):(B&&clearTimeout(B),new Promise(n=>{B=setTimeout(()=>c(this,null,function*(){yield x(e,t),n()}),300)}))}),x=(...t)=>c(this,[...t],function*(t=[],n="lawyerQuestions"){const o=`${n}-${t.join(",")}`,s=v.get(o),l=Date.now();if(s&&l-s.timestamp<3e5)L(n,s.data);else{k(n,!0);try{const s=Q(n),r=`${e.apiUrl}/hot-issues?category=${s.category}`,a=yield fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);const c=(yield a.json()).data||[];L(n,c),v.set(o,{data:c,timestamp:l})}catch(a){console.error(`获取${n}热点问题失败:`,a),L(n,[]),r.value=a instanceof Error?a:new Error("获取热点问题失败")}finally{k(n,!1)}}});i.onMounted(()=>c(this,null,function*(){if("lsyy"===e.knowledgeCode){const e=C.value.map(e=>S([],e,!0).catch(t=>{console.error(`初始化${e}失败:`,t)}));yield Promise.allSettled(e)}}));let I="",D=!1,T="",F=new Map,V=new Map;const N=()=>c(this,null,function*(){if(!s.value.trim()||l.value)return;const c={role:"user",content:s.value};o.value.push([c,{role:"assistant",content:""}]),s.value="",l.value=!0,g="",I="",D=!1,T="",F.clear();const i=a({},e);var A,h;f.value&&(i.requestParams=(A=a({},e.requestParams),h={hotIssues:f.value},t(A,n(h))),f.value=null);try{const e=yield b.connect(o.value,d.value,i,e=>{var t,n;g+=e;let r=g;for(;r.length>0;)try{let e=0,a=!1,c=!1,i=-1;for(let t=0;t<r.length;t++){const n=r[t];if(c)c=!1;else if("\\"!==n)if('"'!==n){if(!a)if("{"===n)e++;else if("}"===n&&(e--,0===e)){i=t+1;break}}else a=!a;else c=!0}if(i>0){const e=r.substring(0,i),a=JSON.parse(e);let c=a.choices[0].delta.content;if("[DONE]"===c)return l.value=!1,u.value=null,g="",I="",void F.clear();if(d.value=null!=(t=a.id)?t:"",c){const e=null!=(n=a.id)?n:"";T!==e&&(I="",D=!1,T=e,F.clear(),V.clear());const t=()=>"json_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),l=e=>`<div id="${e}" class="button-group" style="margin: 10px 0; display: flex; flex-wrap: wrap; gap: 8px; min-height: 40px; border: 1px dashed #ccc; padding: 8px; border-radius: 4px;"><span class="loading-text" style="color: #666; font-size: 12px;">正在加载按钮...</span></div>`,r=e=>`<div id="${e}" style="margin: 10px 0;"><table class="json-table" style="border-collapse: collapse; width: 100%; border: 1px solid #ddd;"><thead><tr><th style="border: 1px solid #ddd; padding: 12px; background: #f5f5f5;">正在加载表格...</th></tr></thead><tbody></tbody></table></div>`,i=(e,t)=>{let n="";if(Array.isArray(t)){if(0===t.length)return;const e=Object.keys(t[0]);n='<table class="json-table" style="border-collapse: collapse; width: 100%; border: 1px solid #ddd;">',n+="<thead><tr>",e.forEach(e=>{n+=`<th style="border: 1px solid #ddd; padding: 12px; background: #f5f5f5; font-weight: bold; text-align: left;">${e}</th>`}),n+="</tr></thead>",n+="<tbody>",t.forEach((t,o)=>{n+=`<tr style="background-color: ${o%2==0?"#ffffff":"#f9f9f9"};">`,e.forEach(e=>{n+=`<td style="border: 1px solid #ddd; padding: 12px;">${t[e]||""}</td>`}),n+="</tr>"}),n+="</tbody></table>"}else t.headers&&t.rows&&(n='<table class="json-table" style="border-collapse: collapse; width: 100%; border: 1px solid #ddd;">',n+="<thead><tr>",t.headers.forEach(e=>{n+=`<th style="border: 1px solid #ddd; padding: 12px; background: #f5f5f5; font-weight: bold; text-align: left;">${e}</th>`}),n+="</tr></thead>",n+="<tbody>",t.rows.forEach((e,t)=>{n+=`<tr style="background-color: ${t%2==0?"#ffffff":"#f9f9f9"};">`,e.forEach(e=>{n+=`<td style="border: 1px solid #ddd; padding: 12px;">${e}</td>`}),n+="</tr>"}),n+="</tbody></table>");setTimeout(()=>{const t=document.getElementById(e);t&&(t.innerHTML=n)},0)},d=(e,t)=>{const n=document.getElementById(e);if(!n)return;const o=n.querySelectorAll("button").length;if(0===o){const e=n.querySelector(".loading-text");e&&e.remove()}t.slice(o).forEach((e,t)=>{e&&e.trim()&&setTimeout(()=>{const t=document.createElement("button");t.className="msgButton",t.textContent=e.trim(),t.onclick=()=>{s.value=e.trim(),N()},t.style.opacity="0",t.style.transform="translateY(10px)",t.style.transition="all 0.3s ease",n.appendChild(t),setTimeout(()=>{t.style.opacity="1",t.style.transform="translateY(0)"},10)},150*t)})},u=e=>{const t=[];try{const n=e.match(new RegExp('"data"\\s*:\\s*\\[(.*?)\\]',"s"));if(n){const e=n[1].match(/"([^"]+)"/g);e&&e.forEach(e=>{const n=e.replace(/"/g,"").trim();n&&t.push(n)})}}catch(n){console.log("解析部分按钮数据失败:",n)}return t};I+=c;if(I.includes("begin")){const e=[...I.matchAll(/begin/g)],n=[...I.matchAll(/end/g)];if(e.length>n.length){const n=e.length-F.size;for(let e=0;e<n;e++){const e=t(),n=/begin([\s\S]*?)$/,s=I.match(n);if(s){const t=s[1].trim();let n="";if(t.includes('"type"')&&t.includes('"button"')){n=l(e),F.set(e,"button"),V.set(e,[]);o.value[o.value.length-1][1].content+=n,setTimeout(()=>{const n=u(t);n.length>0&&(V.set(e,n),d(e,n))},100)}else if(t.includes('"type"')&&t.includes('"table"')){n=r(e),F.set(e,"table");o.value[o.value.length-1][1].content+=n}}}}F.forEach((e,t)=>{if("button"===e){const e=/begin([\s\S]*?)(?:end|$)/,n=I.match(e);if(n){const e=n[1].trim(),o=u(e),s=V.get(t)||[];o.length>s.length&&(V.set(t,o),d(t,o))}}});const s=/begin([\s\S]*?)end/g,a=[...I.matchAll(s)];if(a.forEach((e,t)=>{const n=e[1].trim();try{const e=JSON.parse(n);if(e.type&&e.data){const n=Array.from(F.keys())[t];if(n){switch(e.type){case"button":const t=Array.isArray(e.data)?e.data:[],o=V.get(n)||[];t.length>o.length&&(V.set(n,t),d(n,t)),setTimeout(()=>{const e=document.getElementById(n);e&&(e.style.border="none")},150*t.length+200);break;case"table":i(n,e.data);break;default:console.warn("未知的JSON类型:",e.type)}F.delete(n),V.delete(n)}}}catch(o){console.log("JSON解析失败:",o)}}),a.length>0){let e=I;if(a.forEach(t=>{e=e.replace(t[0],"")}),e.trim()&&!e.includes("begin")){o.value[o.value.length-1][1].content+=e}I=e.includes("begin")?e:""}}else{o.value[o.value.length-1][1].content+=c,I=""}}}r=r.substring(i),g=r}catch(a){break}},e=>{r.value=e,l.value=!1,u.value=null,g="",I="",F.clear()});u.value=e}catch(p){r.value=p instanceof Error?p:new Error("连接失败"),l.value=!1,u.value=null}});return{messages:o,input:s,loading:l,error:r,sendMessage:N,stopGeneration:()=>{if(u.value&&"function"==typeof u.value.close){try{u.value.close()}catch(e){console.warn("关闭连接时出错:",e)}u.value=null,l.value=!1,o.value[o.value.length-1][1].stopMessage=!0,g="",I="",F.clear()}},hotQuestions:h,systemQuestions:p,lawyerQuestions:m,hotQuestionsLoading:E,systemQuestionsLoading:w,lawyerQuestionsLoading:y,refreshHotIssues:(e="lawyerQuestions")=>c(this,null,function*(){console.log("刷新热点问题",e);Array.from(v.keys()).filter(t=>t.startsWith(e)).forEach(e=>v.delete(e));try{yield S((()=>{switch(e){case"hotQuestions":return h.value.map(e=>e.id);case"systemQuestions":return p.value.map(e=>e.id);case"lawyerQuestions":return m.value.map(e=>e.id);default:return[]}})(),e)}catch(t){console.error("刷新热点问题失败:",t),r.value=t instanceof Error?t:new Error("刷新热点问题失败")}}),selectHotIssue:e=>{e&&e.question.trim()?l.value?console.warn("正在发送消息,请稍后再试"):(f.value=e.id,s.value=e.question,N()):console.warn("无效的热点问题:",e)}}}const h={class:"ai-chat-container"},p={key:0,class:"chat-header"},m={class:"ai-avatar"},E=["src"],w={class:"welcome-message"},y={key:1,class:"hot-questions-container"},C={class:"hot-questions"},v={class:"section-title"},B=["disabled"],b={class:"questions-list"},Q=["onClick"],k={key:0,class:"empty-questions"},L={class:"hot-questions"},S={class:"section-title"},x=["disabled"],I={class:"questions-list"},D=["onClick"],T={key:0,class:"empty-questions"},F={class:"message-content user"},V=["innerHTML"],N={class:"message-content assistant"},P={class:"message-label"},O={key:0,class:"assistant-loading"},U={key:1,class:"assistant-stop"},G=["innerHTML"],R={class:"chat-input"},J={class:"input-container"},K=["disabled"],M=["disabled"],W=((e,t)=>{const n=e.__vccOpts||e;for(const[o,s]of t)n[o]=s;return n})(i.defineComponent({__name:"AiChat",props:{config:{}},setup(e){const t=e,{messages:n,input:o,loading:s,sendMessage:l,stopGeneration:r,hotQuestions:a,systemQuestions:c,lawyerQuestions:A,hotQuestionsLoading:g,systemQuestionsLoading:W,lawyerQuestionsLoading:q,refreshHotIssues:Z,selectHotIssue:j}=f(t.config),H=i.ref(["查看被监管人","系统问题"]),Y=()=>{setTimeout(()=>{window.scrollTo({top:document.documentElement.scrollHeight,behavior:"smooth"})},100)};i.watch(()=>n.value.length,()=>{Y()}),i.watch(()=>n.value.length>0?n.value[n.value.length-1][1].content:"",()=>{Y()}),i.watch(s,e=>{e&&Y()});const z=e=>{if(!e)return"";const t=n.value.findIndex(t=>t[1].content===e),o=-1!==t?t:n.value.length-1;let s=e.replace(/onclick="selectPerson\('([^']+)',\s*(true|false)\)"/g,`onclick="selectPerson('$1', $2, ${o})"`);s=s.replace(/onclick="selectPerson\('([^']+)'\)"/g,`onclick="selectPerson('$1', false, ${o})"`);const l=new RegExp("(?<!\\w)((?:1[3-9]\\d{9})|(?:400-?\\d{3}-?\\d{4})|(?:0\\d{2,3}-?\\d{7,8})|(?:\\d{3,4}-\\d{7,8})|(?:\\(\\d{3,4}\\)\\d{7,8})|(?:\\d{6}))(?!\\w)","g");return s=s.replace(l,e=>`<a href="tel:${e.replace(/[-()]/g,"")}" style="color: #007bff; text-decoration: underline; cursor: pointer;">${e}</a>`),function(e){if(!e)return"";let t=e;if(t!==e)return u.sanitize(t,{ALLOWED_TAGS:["div","span","p","br","strong","em","code","pre","h1","h2","h3","h4","h5","h6","ul","ol","li","a","button","table","thead","tbody","tr","th","td"],ALLOWED_ATTR:["href","class","onclick","data-*","id","colspan","rowspan"]});const n=e.includes("<button"),o=e.includes("<table")||e.includes("<tr")||e.includes("<td")||e.includes("<th");if(n||o){const t=e.replace(/\n/g,"\n");return u.sanitize(t,{ALLOWED_TAGS:["p","br","strong","em","code","pre","blockquote","h1","h2","h3","h4","h5","h6","ul","ol","li","a","button","div","span","table","thead","tbody","tfoot","tr","th","td","caption"],ALLOWED_ATTR:["href","class","onclick","data-*","id","target","title","alt","src","width","height","colspan","rowspan","scope","style"]})}const s=e.includes("**")||e.includes("*")||e.includes("`")||e.includes("#")||e.includes("[")||e.includes("\n- ")||e.includes("\n1. ")||e.includes("|");let l=e;return l=s?d.marked.parse(e):e.replace(/\n/g,"<br>"),u.sanitize(l,{ALLOWED_TAGS:["p","br","strong","em","code","pre","blockquote","h1","h2","h3","h4","h5","h6","ul","ol","li","a","button","div","span","table","thead","tbody","tfoot","tr","th","td","caption"],ALLOWED_ATTR:["href","class","onclick","data-*","id","target","title","alt","src","width","height","colspan","rowspan","scope","style"]})}(s)},X=(e,s=!1,r)=>{const a=void 0!==r?r:n.value.length-1;if("lsyy"===t.config.knowledgeCode)o.value=`请提供关于 ${e} 的详细信息`,l();else if(a>=0&&a<n.value.length){const t=n.value[a][0].content;o.value=`${t}${t.includes(":")?`-${e}`:`:${e}`}`}else{const t=n.value[n.value.length-1][0].content;o.value=`${t}${t.includes(":")?`-${e}`:`:${e}`}`}};return"undefined"!=typeof window&&(window.selectPerson=X),(e,t)=>(i.openBlock(),i.createElementBlock("div",h,["lsyy"===e.config.knowledgeCode?(i.openBlock(),i.createElementBlock("div",p,[i.createElementVNode("div",m,[i.createElementVNode("img",{width:"100%",mode:"widthFix",src:i.unref("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAAAXNSR0IArs4c6QAAFSBJREFUeF7tXW2S1LgStJtrQTD8ZLkLxJ4A5gQv2Lss/GSI5Vq0X8jdbjw97bY+skpVUvLnvY2RJVWqMqtUstXjwH/uEfjv+/8eLkYcDw/jYXz7wqhp+tMmxuJxfFo3m47Tz8t/H45Pb97//ezvMV2yjT0ERntT4oy2EJiJfk3wVGKj4T0LxUUgKA5ohEX7owCIwpvf+RLVx+HV57mX2kRPNWUcnxZRePPh05fUx9leBwEKgA7Ou6M8i+7eyL5r3anBNA2P8/9hlhCJmHwzCoA8xpsjBNLPEb5Rwu9BuwgCM4Q9pOT+TgGQw/Zmz72TfgtuioGyI56HowAo4E7Sp4FMMUjDq6Q1BaAEvTvPkvQYYCkGGBy3eqEAAPG9FPLG4VS55z8oAkEMWC+AQjpQAAB4MtoDQEzogkKQANZOUwpAAZYkfgF4gEe5PSgHkQKQgSGJnwGa8CPMCvIApgAk4Pbfv1+/jNzfJyCm35RCkIY5BSACL0b8CJCMNaEQx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vb4zUgD0MY8esUkBWEV5kj7aFcQaUgDEoMV07H4bQMJjHEGoFwqAELCobl1lAQvZw5XiPKpDuYBoPxQAUXgxnVvOAsJntiQ7Zp1r9EIBqIF6xpgmRYCf2maspK1HKAC21mNzNha3Aq//+kT/ceI/W9PkAjpaQEv3A/BCTUeOc2eqFABn61g9E+Bruc485v50KQBOl7NGNsB79Zw6CzOA9hZusUhFCBj1m3UgZgCNLG0QgmDKeBjfFv1aD8/yG/GIODP+Dz5iatEYxhQWAAAAAElFTkSuQmCC"),alt:"AI头像"},null,8,E)]),i.createElementVNode("div",w," 你好,"+i.toDisplayString(e.config.lawyerName)+"律师,我是智能客服,很高兴为您服务。请选择您想询问的问题,或输入想要咨询的内容: ",1)])):i.createCommentVNode("",!0),"lsyy"===e.config.knowledgeCode?(i.openBlock(),i.createElementBlock("div",y,[i.createElementVNode("div",C,[i.createElementVNode("div",v,[t[6]||(t[6]=i.createElementVNode("span",null,"热门问题",-1)),i.createElementVNode("button",{class:"refresh-btn",onClick:t[0]||(t[0]=e=>i.unref(Z)("hotQuestions")),disabled:i.unref(g)},i.toDisplayString(i.unref(g)?"加载中...":"换一换"),9,B)]),i.createElementVNode("div",b,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(i.unref(a),(e,t)=>(i.openBlock(),i.createElementBlock("div",{class:"question-item",key:e.id,onClick:t=>i.unref(j)(e)},i.toDisplayString(t+1)+". "+i.toDisplayString(e.question),9,Q))),128)),0!==i.unref(a).length||i.unref(g)?i.createCommentVNode("",!0):(i.openBlock(),i.createElementBlock("div",k," 暂无热门问题 "))])]),i.createElementVNode("div",L,[i.createElementVNode("div",S,[t[7]||(t[7]=i.createElementVNode("span",null,"系统问题",-1)),i.createElementVNode("button",{class:"refresh-btn",onClick:t[1]||(t[1]=e=>i.unref(Z)("systemQuestions")),disabled:i.unref(W)},i.toDisplayString(i.unref(W)?"加载中...":"换一换"),9,x)]),i.createElementVNode("div",I,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(i.unref(c),(e,t)=>(i.openBlock(),i.createElementBlock("div",{class:"question-item",key:e.id,onClick:t=>i.unref(j)(e)},i.toDisplayString(t+1)+". "+i.toDisplayString(e.question),9,D))),128)),0!==i.unref(c).length||i.unref(W)?i.createCommentVNode("",!0):(i.openBlock(),i.createElementBlock("div",T," 暂无热门问题 "))])])])):i.createCommentVNode("",!0),i.unref(n).length>0?(i.openBlock(),i.createElementBlock("div",{key:2,class:i.normalizeClass(["chat-messages",{tag:H.value.length>0}])},[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(i.unref(n),(e,o)=>(i.openBlock(),i.createElementBlock("div",{class:"message-item",key:o},[i.createElementVNode("div",F,[t[8]||(t[8]=i.createElementVNode("div",{class:"message-label"},"问:",-1)),i.createElementVNode("div",{class:"user-message-text",innerHTML:z(e[0].content)},null,8,V)]),i.createElementVNode("div",N,[i.createElementVNode("div",P,[t[9]||(t[9]=i.createTextVNode(" 答: ",-1)),i.unref(s)&&o===i.unref(n).length-1?(i.openBlock(),i.createElementBlock("span",O)):i.createCommentVNode("",!0),e[1].stopMessage?(i.openBlock(),i.createElementBlock("span",U,"此问题用户停止咨询")):i.createCommentVNode("",!0)]),i.createElementVNode("div",{class:"message-text",innerHTML:z(e[1].content)},null,8,G)])]))),128))],2)):i.createCommentVNode("",!0),i.createElementVNode("div",R,[i.createElementVNode("div",J,[i.withDirectives(i.createElementVNode("input",{"onUpdate:modelValue":t[2]||(t[2]=e=>i.isRef(o)?o.value=e:null),onKeyup:t[3]||(t[3]=i.withKeys((...e)=>i.unref(l)&&i.unref(l)(...e),["enter"])),placeholder:"请输入想要咨询的问题",disabled:i.unref(s),class:"message-input"},null,40,K),[[i.vModelText,i.unref(o)]]),i.unref(s)?i.createCommentVNode("",!0):(i.openBlock(),i.createElementBlock("button",{key:0,onClick:t[4]||(t[4]=(...e)=>i.unref(l)&&i.unref(l)(...e)),disabled:!i.unref(o).trim(),class:"send-button"},t[10]||(t[10]=[i.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none"},[i.createElementVNode("path",{d:"M2 21L23 12L2 3V10L17 12L2 14V21Z",fill:"currentColor"})],-1)]),8,M)),i.unref(s)?(i.openBlock(),i.createElementBlock("button",{key:1,onClick:t[5]||(t[5]=(...e)=>i.unref(r)&&i.unref(r)(...e)),class:"stop-button"},t[11]||(t[11]=[i.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none"},[i.createElementVNode("rect",{x:"6",y:"6",width:"12",height:"12",fill:"currentColor"})],-1)]))):i.createCommentVNode("",!0)])])]))}}),[["__scopeId","data-v-ad0611dc"]]);exports.AIService=A,exports.AiChat=W,exports.default=W,exports.useAiChat=f;