import{bQ as S,M as $,bS as D,aU as g,bT as C,bE as N,aD as U,az as A,aL as y,u as T,bb as K,s as V,bJ as W,v as x,aY as H,g as P,t as j,q as B,bU as z,bV as X,bW as Y,bX as q,bY as J}from"./index-DZSqyBof.js";var I=(p,a,i)=>new Promise((h,d)=>{var c=n=>{try{l(i.next(n))}catch(o){d(o)}},t=n=>{try{l(i.throw(n))}catch(o){d(o)}},l=n=>n.done?h(n.value):Promise.resolve(n.value).then(c,t);l((i=i.apply(p,a)).next())});const Q=["data-markstream-mode","data-markstream-pending"],F=["innerHTML"],G={key:1,class:"math-inline math-inline--fallback"},Z={class:"math-inline__loading",role:"status","aria-live":"polite"},E=S($({__name:"MathInlineNode",props:{node:{}},setup(p){const a=p,i=g(null),h=B(()=>a.node.markup==="$$"),d=B(()=>z(a.node.content)),c=(function(){if(!a.node.content)return{html:"",text:a.node.raw,loading:!1};const e=D();if(!e)return{html:"",text:a.node.raw,loading:!1};try{return{html:e.renderToString(d.value,{throwOnError:a.node.loading,displayMode:h.value}),text:"",loading:!1}}catch{return{html:"",text:a.node.raw,loading:!1}}})(),t=g(c.html),l=g(c.text);let n=!1,o=0,v=!1,m=null;const f=g(c.loading),k=g(!1),L=C();let u=null;function w(e){e!=null&&e!==o||(k.value=!1)}function M(){return I(this,null,function*(){if(v)return;m&&(m.abort(),m=null);const e=++o;if(!a.node.content)return w(),f.value=!1,t.value="",l.value=a.node.raw,void(n=!0);const r=new AbortController;if(m=r,k.value=!0,!n)try{!u&&i.value&&(u=L(i.value)),yield u?.whenVisible}catch{}v||e!==o||r.signal.aborted?w(e):X(d.value,h.value,{timeout:1500,waitTimeout:0,maxRetries:0,signal:r.signal}).then(s=>{v||e!==o||(t.value=s,l.value="",f.value=!1,n=!0)}).catch(s=>I(null,null,function*(){if(v||e!==o)return;const b=s?.code||s?.name,O=b==="KATEX_DISABLED";if(b==="WORKER_INIT_ERROR"||s?.fallbackToRenderer||b===Y||b==="WORKER_TIMEOUT"){const R=yield q();if(v||e!==o)return;if(R){try{const _=R.renderToString(d.value,{throwOnError:a.node.loading,displayMode:h.value});t.value=_,l.value="",f.value=!1,n=!0,J(d.value,h.value,_)}catch{}return}}if(O||!a.node.loading)return f.value=!1,t.value="",void(l.value=a.node.raw);n||(f.value=!0)})).finally(()=>{v||w(e)})})}return(c.html||c.text)&&(n=!0),N(()=>a.node.content,()=>{M()}),U(()=>{t.value||M()}),A(()=>{var e;v=!0,m&&(m.abort(),m=null),(e=u?.destroy)==null||e.call(u),u=null}),(e,r)=>(y(),T("span",{ref_key:"containerEl",ref:i,class:"math-inline-wrapper","data-markstream-math":"inline","data-markstream-mode":t.value?"katex":l.value?"fallback":"loading","data-markstream-pending":k.value?"true":void 0},[t.value?(y(),T("span",{key:0,class:"math-inline",innerHTML:t.value},null,8,F)):l.value?(y(),T("span",G,K(l.value),1)):f.value?(y(),V(P,{key:2,name:"table-node-fade"},{default:W(()=>[x("span",Z,[H(e.$slots,"loading",{isLoading:f.value},()=>[r[0]||(r[0]=x("span",{class:"math-inline__spinner animate-spin","aria-hidden":"true"},null,-1)),r[1]||(r[1]=x("span",{class:"sr-only"},"Loading",-1))],!0)])]),_:3})):j("",!0)],8,Q))}}),[["__scopeId","data-v-7b64afc7"]]);E.install=p=>{p.component(E.__name,E)};export{E as default};
