import{d as I,U as x,a as h,T as M,W as B,bk as O,o as p,e as C,w as L,p as N,b as S,aL as A,a6 as b,t as D}from"./index-DSCno0m2.js";import{d as K,E as V,x as W,i as H,e as U,I as J,J as P}from"./index-3OlSoxmB.js";import"./chatbot-Dfd2mpvB.js";import"./FormItem-CHgZe7qM.js";import"./Alert-Cm6VlYYh.js";import"./Flex-CK9o7tXW.js";import"./get-slot-Bk_rJcZu.js";import"./assistant-Vu8dw-ko.js";var E=(f,e,u)=>new Promise((c,a)=>{var t=n=>{try{v(u.next(n))}catch(l){a(l)}},s=n=>{try{v(u.throw(n))}catch(l){a(l)}},v=n=>n.done?c(n.value):Promise.resolve(n.value).then(t,s);v((u=u.apply(f,e)).next())});const z=["data-markstream-mode"],X={key:0,class:"math-loading-overlay"},j=["innerHTML"],q={key:1,class:"math-block__fallback text-left"},w=K(I({__name:"MathBlockNode",props:{node:{}},setup(f){const e=f,u=x(null),c=(function(){if(!e.node.content)return{html:"",text:e.node.raw,loading:!1};const r=V();if(!r)return{html:"",text:e.node.raw,loading:!1};try{return{html:r.renderToString(e.node.content,{throwOnError:e.node.loading,displayMode:!0}),text:"",loading:!1}}catch{return{html:"",text:e.node.raw,loading:!1}}})(),a=x(c.html),t=x(c.text);let s=!1,v=0,n=!1,l=null;const T=W();let d=null;const o=x(c.loading);function y(){return E(this,null,function*(){if(n)return;if(!e.node.content)return o.value=!1,a.value="",t.value=e.node.raw,void(s=!0);if(!s)try{!d&&u.value&&(d=T(u.value)),yield d?.whenVisible}catch{}l&&(l.abort(),l=null);const r=++v,m=new AbortController;l=m,H(e.node.content,!0,{timeout:3e3,waitTimeout:2e3,maxRetries:1,signal:m.signal}).then(i=>{n||r!==v||(a.value=i,t.value="",s=!0,o.value=!1)}).catch(i=>E(null,null,function*(){if(n||r!==v)return;const k=i?.code||i?.name,R=k==="KATEX_DISABLED";if(k==="WORKER_INIT_ERROR"||i?.fallbackToRenderer||k===U||k==="WORKER_TIMEOUT"){const _=yield J();if(_){try{const g=_.renderToString(e.node.content,{throwOnError:e.node.loading,displayMode:!0});a.value=g,t.value="",s=!0,o.value=!1,P(e.node.content,!0,g)}catch{}return}}if(R)return o.value=!1,a.value="",void(t.value=e.node.raw);s||(o.value=!0),e.node.loading||(o.value=!1,a.value="",t.value=e.node.raw)}))})}return(c.html||c.text)&&(s=!0),M(()=>e.node.content,()=>{y()}),B(()=>{a.value||y()}),O(()=>{var r;n=!0,l&&(l.abort(),l=null),(r=d?.destroy)==null||r.call(d),d=null}),(r,m)=>(p(),h("div",{ref_key:"containerEl",ref:u,class:"math-block text-center overflow-x-auto relative min-h-[40px]","data-markstream-math":"block","data-markstream-mode":a.value?"katex":t.value?"fallback":"loading"},[C(A,{name:"math-fade"},{default:L(()=>[!o.value||a.value||t.value?N("",!0):(p(),h("div",X,[...m[0]||(m[0]=[S("div",{class:"math-loading-spinner"},null,-1)])]))]),_:1}),a.value?(p(),h("div",{key:0,class:b(["math-block__content",{"math-rendering":o.value}]),innerHTML:a.value},null,10,j)):t.value?(p(),h("pre",q,D(t.value),1)):(p(),h("div",{key:2,class:b(["math-block__content",{"math-rendering":o.value}])},null,2))],8,z))}}),[["__scopeId","data-v-5d203bbc"]]);w.install=f=>{f.component(w.__name,w)};export{w as default};
