const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-mermaid-CH7SGc99.js","assets/vendor-canvas-D39yWul6.js","assets/vendor-react-96lCPsRK.js","assets/vendor-canvas-BZV40eAE.css","assets/vendor-syntax-DuHI9Ok6.js","assets/vendor-markdown-CimbIo6Y.js"])))=>i.map(i=>d[i]);
import{b}from"./vendor-syntax-DuHI9Ok6.js";import{r as t,j as e}from"./vendor-react-96lCPsRK.js";import"./vendor-markdown-CimbIo6Y.js";let m=!1;async function h(){const r=await b(()=>import("./vendor-mermaid-CH7SGc99.js").then(s=>s.a7),__vite__mapDeps([0,1,2,3,4,5]));return m||(r.default.initialize({startOnLoad:!1,theme:"dark",themeVariables:{darkMode:!0,background:"#1e293b",primaryColor:"#3b82f6",primaryTextColor:"#e2e8f0",primaryBorderColor:"#475569",lineColor:"#64748b",secondaryColor:"#1e40af",tertiaryColor:"#0f172a",fontFamily:"ui-sans-serif, system-ui, sans-serif",fontSize:"14px"},flowchart:{htmlLabels:!0,curve:"basis"},sequence:{mirrorActors:!1}}),m=!0),r.default}function w({code:r}){const s=t.useRef(null),o=t.useId().replace(/:/g,"-"),[i,n]=t.useState(null),[u,d]=t.useState(null),[f,c]=t.useState(!1);t.useEffect(()=>{let l=!1;return(async()=>{try{const a=await h(),{svg:x}=await a.render(`mermaid${o}`,r.trim());l||(n(x),d(null))}catch(a){l||(d((a==null?void 0:a.message)||"Failed to render diagram"),n(null))}})(),()=>{l=!0}},[r,o]);const p=()=>{navigator.clipboard.writeText(r).then(()=>{c(!0),setTimeout(()=>c(!1),1500)}).catch(()=>{})};return u?e.jsxs("div",{className:"my-2 rounded-lg border border-red-500/30 bg-red-950/20 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("svg",{className:"w-4 h-4 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})}),e.jsx("span",{className:"text-xs font-medium text-red-400",children:"Mermaid diagram error"})]}),e.jsx("pre",{className:"text-xs text-red-300/70 whitespace-pre-wrap font-mono",children:r})]}):e.jsxs("div",{className:"relative group my-2 rounded-lg border border-slate-700 bg-slate-900/50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-slate-700/50 bg-slate-800/30",children:[e.jsx("span",{className:"text-xs text-slate-400 font-medium uppercase",children:"mermaid"}),e.jsx("button",{type:"button",onClick:p,className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs px-2 py-0.5 rounded bg-slate-700/80 hover:bg-slate-700 text-slate-300 border border-slate-600",children:f?"Copied":"Copy source"})]}),e.jsx("div",{ref:s,className:"flex items-center justify-center p-4 min-h-[80px] overflow-x-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:i?{__html:i}:void 0,children:!i&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),"Rendering diagram..."]})})]})}export{w as default};
