import{defineComponent as y,ref as n,computed as C,onMounted as b,watch as T,onBeforeUnmount as v,h as f,nextTick as h}from"vue";import{atou as x,LoadingIcon as g}from"vuepress-shared/client";import"../styles/mermaid.scss";const B=e=>({dark:e,background:e?"#1e1e1e":"#fff",primaryColor:e?"#389d70":"#4abf8a",primaryBorderColor:e?"#389d70":"#4abf8a",primaryTextColor:"#fff",secondaryColor:"#ffb500",secondaryBorderColor:e?"#fff":"#000",secondaryTextColor:e?"#ddd":"#333",tertiaryColor:e?"#282828":"#efeef4",tertiaryBorderColor:e?"#bbb":"#242424",tertiaryTextColor:e?"#ddd":"#333",noteBkgColor:e?"#f6d365":"#fff5ad",noteTextColor:"#242424",noteBorderColor:e?"#f6d365":"#333",lineColor:e?"#d3d3d3":"#333",textColor:e?"#fff":"#242424",mainBkg:e?"#389d70":"#4abf8a",errorBkgColor:"#eb4d5d",errorTextColor:"#fff",nodeBorder:e?"#389d70":"#4abf8a",nodeTextColor:e?"#fff":"#242424",signalTextColor:e?"#9e9e9e":"#242424",classText:"#fff",labelColor:"#fff",fillType0:e?"#cf1322":"#f1636e",fillType1:"#f39c12",fillType2:"#2ecc71",fillType3:"#fa541c",fillType4:"#25a55b",fillType5:"#13c2c2",fillType6:"#096dd9",fillType7:"#aa6fe9"});var M=y({name:"Mermaid",props:{id:{type:String,required:!0},code:{type:String,required:!0}},setup(e){let a=null;const s=n(),l=n(""),d=n(!1),m=C(()=>x(e.code)),c=async()=>Promise.all([import("mermaid/dist/mermaid.esm.min.mjs"),import("@mermaid-js/mermaid-mindmap/dist/mermaid-mindmap.esm.min.mjs"),new Promise(r=>setTimeout(r,MARKDOWN_ENHANCE_DELAY))]).then(async([{default:r},{default:i}])=>{try{await r.registerExternalDiagrams([i])}catch{}const t=document.createElement("div");t.style.position="relative",t.style.top="-9999px";const u=p=>{l.value=p,document.body.removeChild(t)},o={useMaxWidth:!1};r.initialize({theme:"base",themeVariables:B(d.value),flowchart:o,sequence:o,journey:o,gantt:o,er:o,pie:o,...MERMAID_OPTIONS,startOnLoad:!1}),l.value="",document.body.appendChild(t),await h(),await r.renderAsync(e.id,m.value,u,t)});return b(()=>{const r=document.querySelector("html"),i=()=>r.classList.contains("dark")||r.getAttribute("data-theme")==="dark";d.value=i(),c(),a=new MutationObserver(()=>{d.value=i()}),a.observe(r,{attributeFilter:["class","data-theme"],attributes:!0}),T(d,()=>c())}),v(()=>{a==null||a.disconnect()}),()=>f("div",{ref:s,class:"mermaid-wrapper"},l.value?f("div",{class:"content",innerHTML:l.value}):f(g,{class:"mermaid-loading",height:96}))}});export{M as default};
//# sourceMappingURL=Mermaid.js.map
