import './async-Djx13DAD.js';
import { d as attr_class, f as html } from './index-B7gr0Dsc.js';
import { v as vt } from './MarkdownCode.svelte_svelte_type_style_lang-DJRtJayx.js';
import { Z as Ze } from './index35-D6cyUa2I.js';

function d(n){return Ze(n)}const g=["!--","!doctype","a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","big","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","small","source","span","strike","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr"],B=["g","defs","use","symbol","rect","circle","ellipse","line","polyline","polygon","path","image","text","tspan","textPath","linearGradient","radialGradient","stop","pattern","clipPath","mask","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feGaussianBlur","feMerge","feMorphology","feOffset","feSpecularLighting","feTurbulence","feMergeNode","feFuncR","feFuncG","feFuncB","feFuncA","feDistantLight","fePointLight","feSpotLight","feFlood","feTile","animate","animateTransform","animateMotion","mpath","set","view","cursor","foreignObject","desc","title","metadata","switch"],E=[...g,...B.filter(n=>!g.includes(n))];function P(n,u){n.component(h=>{let{chatbot:b=true,message:o,sanitize_html:_=true,latex_delimiters:l=[],render_markdown:p=true,line_breaks:x=true,header_links:k=false,allow_tags:c=false,theme_mode:R="system"}=u;const y=vt({header_links:k,line_breaks:x,latex_delimiters:l||[]});let v=o&&o.trim()?L(o):"";function f(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function w(a,e){if(e===true){const s=/<\/?([a-zA-Z][a-zA-Z0-9-]*)([\s>])/g;return a.replace(s,(t,r,i)=>E.includes(r.toLowerCase())?t:t.replace(/</g,"&lt;").replace(/>/g,"&gt;"))}if(Array.isArray(e)){const s=e.map(r=>({open:new RegExp(`<(${r})(\\s+[^>]*)?>`,"gi"),close:new RegExp(`</(${r})>`,"gi")}));let t=a;return s.forEach(r=>{t=t.replace(r.open,i=>i.replace(/</g,"&lt;").replace(/>/g,"&gt;")),t=t.replace(r.close,i=>i.replace(/</g,"&lt;").replace(/>/g,"&gt;"));}),t}return a}function L(a){let e=a;if(p){const s=[];l.forEach((t,r)=>{const i=f(t.left),$=f(t.right),C=new RegExp(`${i}([\\s\\S]+?)${$}`,"g");e=e.replace(C,(M,z)=>(s.push(M),`%%%LATEX_BLOCK_${s.length-1}%%%`));}),e=y.parse(e),e=e.replace(/%%%LATEX_BLOCK_(\d+)%%%/g,(t,r)=>s[parseInt(r,10)]);}return c&&(e=w(e,c)),_&&d&&(e=d(e)),e}h.push(`<span${attr_class("md svelte-1hf8a14",void 0,{chatbot:b,prose:p})}>${html(v)}</span>`);});}

export { P };
//# sourceMappingURL=MarkdownCode-zMHESTz4.js.map
