/* Local, pinned Markdown renderer compatible with the marked.parse API used by the chat UI. */ (function () { const escape = value => String(value).replace(/[&<>"']/g, character => ({"&":"&","<":"<",">":">","\"":""","'":"'"}[character])); const inline = value => escape(value) .replace(/`([^`]+)`/g, "$1") .replace(/\*\*([^*]+)\*\*/g, "$1") .replace(/__([^_]+)__/g, "$1") .replace(/\*([^*]+)\*/g, "$1") .replace(/_([^_]+)_/g, "$1") .replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, '$1'); window.marked = {parse(markdown) { return String(markdown || "").split(/\n{2,}/).map(block => { const lines = block.split("\n"); if (/^### /.test(lines[0])) return `

${inline(lines[0].slice(4))}

`; if (/^## /.test(lines[0])) return `

${inline(lines[0].slice(3))}

`; if (/^# /.test(lines[0])) return `

${inline(lines[0].slice(2))}

`; return `

${lines.map(inline).join("
")}

`; }).join(""); }}; }());