import{e as R,r as p,g as C,q as M,h as b,o as _,c as E,b as B,w as I,a as T,x as O,T as V,n as K}from"./index-WOIPm_2l.js";import{J as N,o as A,X as L,K as X,M as D,V as H}from"./MessageList-DFdDzCzJ.js";import"./toast-CbgsPrO_.js";var g=(d,e,r)=>new Promise((a,u)=>{var v=l=>{try{t(r.next(l))}catch(n){u(n)}},i=l=>{try{t(r.throw(l))}catch(n){u(n)}},t=l=>l.done?a(l.value):Promise.resolve(l.value).then(v,i);t((r=r.apply(d,e)).next())});const P={key:0,class:"math-loading-overlay"},w=N(R({__name:"MathBlockNode",props:{node:{}},setup(d){const e=d,r=p(null),a=p(null);let u=!1,v=0,i=!1,t=null;const l=A();let n=null;const s=p(!0);function x(){return g(this,null,function*(){if(!a.value||i)return;if(!e.node.content)return s.value=!1,a.value.textContent=e.node.raw,void(u=!0);if(!u)try{!n&&r.value&&(n=l(r.value)),yield n==null?void 0:n.whenVisible}catch{}t&&(t.abort(),t=null);const c=++v,f=new AbortController;t=f,L(e.node.content,!0,{timeout:3e3,waitTimeout:2e3,maxRetries:1,signal:f.signal}).then(o=>{i||c!==v||a.value&&(a.value.innerHTML=o,u=!0,s.value=!1)}).catch(o=>g(null,null,function*(){if(i||c!==v||!a.value)return;const m=(o==null?void 0:o.code)||(o==null?void 0:o.name),k=m==="KATEX_DISABLED";if(m==="WORKER_INIT_ERROR"||o!=null&&o.fallbackToRenderer||m===X||m==="WORKER_TIMEOUT"){const y=yield D();if(y){try{const h=y.renderToString(e.node.content,{throwOnError:e.node.loading,displayMode:!0});a.value.innerHTML=h,u=!0,s.value=!1,H(e.node.content,!0,h)}catch{}return}}if(k)return s.value=!1,void(a.value.textContent=e.node.raw);u||(s.value=!0),e.node.loading||(s.value=!1,a.value.textContent=e.node.raw)}))})}return C(()=>e.node.content,()=>{x()}),M(()=>{x()}),b(()=>{var c;i=!0,t&&(t.abort(),t=null),(c=n==null?void 0:n.destroy)==null||c.call(n),n=null}),(c,f)=>(_(),E("div",{ref_key:"containerEl",ref:r,class:"math-block text-center overflow-x-auto relative min-h-[40px]"},[B(V,{name:"math-fade"},{default:I(()=>[s.value?(_(),E("div",P,[...f[0]||(f[0]=[T("div",{class:"math-loading-spinner"},null,-1)])])):O("",!0)]),_:1}),T("div",{ref_key:"mathBlockElement",ref:a,class:K({"math-rendering":s.value})},null,2)],512))}}),[["__scopeId","data-v-f432e706"]]);w.install=d=>{d.component(w.__name,w)};export{w as default};
