0||e<0)?new b(t):(n<0?t=t.takeRight(-n):n&&(t=t.drop(n)),e!==o&&(e=S(e),t=e<0?t.dropRight(-e):t.take(e-n)),t)},b.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},b.prototype.toArray=function(){return this.take(zn)},Yn(b.prototype,function(n,e){var t=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),i=u[r?"take"+(e=="last"?"Right":""):e],f=r||/^find/.test(e);i&&(u.prototype[e]=function(){var l=this.__wrapped__,a=r?[1]:arguments,c=l instanceof b,p=a[0],_=c||L(l),d=function(O){var W=i.apply(u,pe([O],a));return r&&v?W[0]:W};_&&t&&typeof p=="function"&&p.length!=1&&(c=_=!1);var v=this.__chain__,w=!!this.__actions__.length,y=f&&!v,I=c&&!w;if(!f&&_){l=I?l:new b(this);var T=n.apply(l,a);return T.__actions__.push({func:cr,args:[d],thisArg:o}),new Cn(T,v)}return y&&I?n.apply(this,a):(T=this.thru(d),y?r?T.value()[0]:T.value():T)})}),Sn(["pop","push","shift","sort","splice","unshift"],function(n){var e=Ut[n],t=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",r=/^(?:pop|shift)$/.test(n);u.prototype[n]=function(){var i=arguments;if(r&&!this.__chain__){var f=this.value();return e.apply(L(f)?f:[],i)}return this[t](function(l){return e.apply(L(l)?l:[],i)})}}),Yn(b.prototype,function(n,e){var t=u[e];if(t){var r=t.name+"";P.call(ze,r)||(ze[r]=[]),ze[r].push({name:e,func:t})}}),ze[ir(o,kn).name]=[{name:"wrapper",func:o}],b.prototype.clone=Da,b.prototype.reverse=Na,b.prototype.value=Ha,u.prototype.at=_h,u.prototype.chain=dh,u.prototype.commit=vh,u.prototype.next=mh,u.prototype.plant=xh,u.prototype.reverse=Ah,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=yh,u.prototype.first=u.prototype.head,lt&&(u.prototype[lt]=wh),u}),$e=va();Ee?((Ee.exports=$e)._=$e,Hr._=$e):en._=$e}).call(Q_)})(Lt,Lt.exports)),Lt.exports}var V_=k_();const j_={name:"jeecg-tool-exec",component:F_},n0={name:"jeecg-chart",component:P_},Zi=new Map,Mo=[];Po(j_);Po(n0);const Fo="jeecg-tag";function e0(N){const Fn=N.renderer.rules.html_block||function(o,Kn){return o[Kn].content};N.renderer.rules.html_block=function(o,Kn){const nn=o[Kn].content;let Y=!1;for(const on of Mo){const X=new RegExp(`<${on}(\\s|>)`,"i"),cn=new RegExp(`${on}>`,"i");if(X.test(nn)||cn.test(nn)){Y=!0;break}}if(Y){const on=document.createElement("div");on.innerHTML=nn;const X=on.firstElementChild;return X.classList.add(Fo),X.outerHTML}return Fn(o,Kn)}}function Po(N){Zi.has(N.name)||(N.component=U_(N.component),Zi.set(N.name,N),Mo.push(N.name))}const t0=["innerHTML"],r0=["src"],i0={style:{"max-width":"240px",overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"}},u0={key:1,class:"error-message"},f0=["innerHTML"],o0=D_({__name:"chatText",props:["dateTime","text","inversion","error","errorMsg","currentToolTag","loading","referenceKnowledge","isLast"],setup(N){const Fn=Be(),{domainUrl:o}=L_(),{getIsMobile:Kn}=M_(),rn=N,nn=Be(),Y=Be(),on=Be(""),X=Be(!1),cn=Be(""),Xn=Be([]),hn=new O_({html:!0,linkify:!0,highlight(R,x){if(!!(x&&zi.getLanguage(x))){const F=x!=null?x:"";return kn(zi.highlight(R,{language:F}).value,F)}return kn(zi.highlightAuto(R).value,"")}});hn.use(e0),hn.use(b_,{attrs:{target:"_blank",rel:"noopener"}}),hn.use(W_,{blockClass:"katexmath-block rounded-md p-[10px]",errorColor:" #cc0000"});const Rt=V_.throttle(()=>{var x;let R=(x=rn.text)!=null?x:"";if(rn.inversion!=="user"){R=Me(R),R=vn(R),cn.value=hn.render(R),ce();return}cn.value=R.replace(`
`,"
")},100),Qn=Oo(()=>{const{loading:R,referenceKnowledge:x}=rn;return R?!1:Array.isArray(x)&&x.length>0}),ae=Oo(()=>{if(Qn.value)return!1;const R=rn.text||"";if(!R)return!1;const x=/!\[.*?\]\(.*?\)/g;return x.test(R)?R.replace(x,"").trim().length===0:!1});Io(()=>rn.text,()=>Rt(),{immediate:!0}),Io(()=>rn.currentToolTag,()=>{const{isLast:R,inversion:x,currentToolTag:K,loading:F}=rn;R&&x!="user"&&K&&F&&(cn.value+=hn.render(K),ce())},{immediate:!0});function Me(R){const x=/!\[([^\]]*)\]\(([^)]+)\s=([0-9]+)\)/g;R=R.replace(x,(Vn,$,Q,he)=>{let Fe=/#\s*{\s*domainURL\s*}/g;return Q=Q.replace(Fe,o),``});const K=/!\[([^\]]*)\]\(([^)]+)\)/g,F=R.match(K),Ln=F?F.length:0;return Ln>0&&(R=R.replace(K,(Vn,$,Q)=>{let he=/#\s*{\s*domainURL\s*}/g;return Q=Q.replace(he,o),Ln>1?``:``})),R}function vn(R){const x=/!\[([^\]]*)\]\(.*?#\s*{\s*domainURL\s*}.*?\)/g;return R.replace(x,K=>{let F=/#\s*{\s*domainURL\s*}/g;return K.replace(F,o)})}function kn(R,x){return`${R}
`}function Ve(){nn.value&&nn.value.querySelectorAll(".code-block-header__copy").forEach(x=>{x.addEventListener("click",()=>{var F,Ln;const K=(Ln=(F=x.parentElement)==null?void 0:F.nextElementSibling)==null?void 0:Ln.textContent;K&&Tr(K).then(()=>{x.textContent="复制成功",setTimeout(()=>{x.textContent="复制代码"},1e3)})})})}function Pn(){nn.value&&nn.value.querySelectorAll(".code-block-header__copy").forEach(x=>{x.removeEventListener("click",()=>{})})}function se(){nn.value&&nn.value.querySelectorAll("img").forEach(x=>{x.addEventListener("click",()=>{on.value=x.src,X.value=!0})})}function Un(){nn.value&&nn.value.querySelectorAll("img").forEach(x=>{x.removeEventListener("click",()=>{})})}function Te(){X.value=!1,on.value=""}function mn(){window.innerWidth>600&&window.innerWidth<1024?Fn.value=window.innerWidth-120+"px":window.innerWidth<600&&(Fn.value=window.innerWidth-60+"px")}function ce(){return So(this,null,function*(){if(yield N_(),!Y.value)return;Xn.value=[],Y.value.querySelectorAll("."+Fo).forEach(x=>{const K=x.nodeName.toLowerCase(),F=Zi.get(K);if(!F)return;const Ln=x.querySelector("render");if(!Ln){if(rn.loading){x.innerHTML='图表渲染中,请稍候...
';return}x.innerHTML='模型返回的图表渲染格式不正确,请优化提示词或重新尝试。
';return}const Vn=x.querySelector("data"),$=(Vn==null?void 0:Vn.textContent)||"";je(F,$,Ln)})})}function je(R,x,K){Xn.value.push({key:R_(R.name+"_"+x).toString(),to:K,tag:R,data:x})}H_(()=>{Ve(),se(),mn(),window.addEventListener("resize",mn)}),G_(()=>{Ve(),se()}),$_(()=>{Pn(),Un(),window.removeEventListener("resize",mn)});function Tr(R){return new Promise((x,K)=>{try{const F=document.createElement("textarea");F.setAttribute("readonly","readonly"),F.value=R,document.body.appendChild(F),F.select(),document.execCommand("copy")&&document.execCommand("copy"),document.body.removeChild(F),x(R)}catch(F){K(F)}})}return(R,x)=>{const K=X_,F=S_,Ln=J_,Vn=I_;return Mn(),ye(Ar,null,[cn.value!=""||N.error?(Mn(),ye("div",{key:0,class:Co(["textWrap",[N.inversion==="user"?"self":ae.value?"chatgpt-image":"chatgpt"]]),ref_key:"textRef",ref:nn},[N.inversion!="user"?(Mn(),ye("div",{key:0,style:q_({width:bo(Kn)?Fn.value:"auto"})},[Tt("div",{ref_key:"markdownBodyRef",ref:Y,class:Co(["markdown-body",{"markdown-body-generate":N.loading}]),innerHTML:cn.value},null,10,t0),Qn.value?(Mn(),ye(Ar,{key:0},[yr(K,{orientation:"left"},{default:Et(()=>[...x[0]||(x[0]=[K_("引用",-1)])]),_:1}),(Mn(!0),ye(Ar,null,Wo(N.referenceKnowledge,($,Q)=>{var he;return Mn(),xr(Vn,{key:Q,title:(he=$.content)==null?void 0:he.substring(0,800)},{default:Et(()=>[yr(Ln,{style:{"min-width":"80px",background:"#F7F8FA","padding-inline":"0 7px"}},{default:Et(()=>[yr(F,{style:{"min-height":"30px","padding-left":"4px","padding-right":"4px","background-color":"#F0F1F6",color:"#788194"}},{default:Et(()=>[Tt("div",null,Yi("chunk-"+$.chunk),1)]),_:2},1024),yr(F,{style:{"min-height":"30px","padding-left":"4px"}},{default:Et(()=>[Tt("img",{src:bo(Z_),width:"14",height:"14",style:{position:"relative",top:"-2px"}},null,8,r0),Tt("div",i0,Yi($.docName),1)]),_:2},1024)]),_:2},1024)]),_:2},1032,["title"])}),128))],64)):yt("",!0),N.error?(Mn(),ye("div",u0,[Tt("p",null,Yi(N.errorMsg),1)])):yt("",!0)],4)):(Mn(),ye("div",{key:1,class:"msg",innerHTML:cn.value},null,8,f0))],2)):yt("",!0),X.value?(Mn(),xr(B_,{key:1,imageUrl:on.value,onHide:Te},null,8,["imageUrl"])):yt("",!0),Xn.value.length?(Mn(!0),ye(Ar,{key:2},Wo(Xn.value,$=>(Mn(),xr(Y_,{key:$.key,to:$.to},[(Mn(),xr(z_($.tag.component),{data:$.data,loading:N.loading},null,8,["data","loading"]))],8,["to"]))),128)):yt("",!0)],64)}}}),qd=C_(o0,[["__scopeId","data-v-1704ab8a"]]);export{qd as default};