import{p as W,a as s,f as $,B as q,g as u,c as f,e as z,t as U,l as V,n as X,r as j,I as N}from"./index-BPc98LNf.js";import{p as A}from"./purify.es-HRjpPm7y.js";import G from"./katex-XbL3y5x-.js";/* empty css                  */var J=$("<div><!></div>");function ee(T,r){W(r,!0);let _=s(r,"content",3,""),k=s(r,"allowHtml",3,!1),O=s(r,"syntaxHighlight",3,!0),g=s(r,"mathEnabled",3,!0),b=s(r,"padded",3,!0);const x=t=>t.replace(/</g,"&lt;").replace(/>/g,"&gt;"),C=()=>{const t=new N.Renderer;return k()||(t.html=({text:d})=>x(d)),O()||(t.code=({text:d,lang:e})=>`<pre><code class="${e?`language-${e}`:""}">${x(d)}</code></pre>`),t},R=t=>{if(!g()||typeof DOMParser>"u")return t;try{const e=new DOMParser().parseFromString(t,"text/html"),p=e.createTreeWalker(e.body,NodeFilter.SHOW_TEXT),w=[];for(;p.nextNode();){const o=p.currentNode,n=o.parentElement;n&&(n.tagName==="CODE"||n.tagName==="PRE")||w.push(o)}const I=/\$\$([^$]+)\$\$|\$([^$\n]+)\$/g;for(const o of w){const n=o.nodeValue??"";let a,l=0,E=!1;const c=e.createDocumentFragment();for(;(a=I.exec(n))!==null;){E=!0;const m=a[0],v=a[1],L=a[2],B=(v??L??"").trim(),H=!!v;a.index>l&&c.appendChild(e.createTextNode(n.slice(l,a.index)));let h=m;try{h=G.renderToString(B,{displayMode:H,throwOnError:!1})}catch{h=m}const M=e.createElement(H?"div":"span");M.innerHTML=h,c.appendChild(M),l=a.index+m.length}E&&(l<n.length&&c.appendChild(e.createTextNode(n.slice(l))),o.parentNode?.replaceChild(c,o))}return e.body.innerHTML}catch{return t}},S=f(C),D=f(()=>N.parse(_()||"",{async:!1,renderer:u(S)})),F=f(()=>A.sanitize(R(u(D)),{USE_PROFILES:{html:!0,svg:!1}}));var i=J();let y;var P=z(i);q(P,()=>u(F)),U(()=>y=V(i,1,"markdown markdown-content svelte-yueq7f",null,y,{math:g(),padded:b()})),X(T,i),j()}export{ee as default};
