markstream-vue 1.0.3-beta.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -11
- package/README.zh-CN.md +5 -2
- package/dist/CodeBlockNode.js +1 -1
- package/dist/CodeBlockShell.vue_vue_type_style_index_0_lang.js +1 -1
- package/dist/diagramHeight.js +1 -0
- package/dist/exports.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +1 -1
- package/dist/index.px.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/index10.js +1 -1
- package/dist/index11.js +1 -1
- package/dist/index5.js +1 -1
- package/dist/index6.js +1 -1
- package/dist/index7.js +1 -1
- package/dist/index8.js +1 -1
- package/dist/index9.js +1 -1
- package/dist/mermaidSequenceSemicolons.js +1 -0
- package/dist/tailwind.js +0 -0
- package/dist/workers/mermaidCdnWorker.js +1 -1
- package/dist/workers/mermaidParser.worker.js +1 -1
- package/package.json +16 -2
package/dist/index11.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=(t,n,l)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[n]=l,i=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&a(e,n,t[n]);if(l)for(var n of l(t))r.call(t,n)&&a(e,n,t[n]);return e},u=(e,t,n)=>new Promise((l,o)=>{var r=e=>{try{i(n.next(e))}catch(t){o(t)}},a=e=>{try{i(n.throw(e))}catch(t){o(t)}},i=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,a);i((n=n.apply(e,t)).next())});import{defineComponent as s,ref as c,computed as d,useAttrs as v,inject as m,watch as f,onBeforeUnmount as h,nextTick as p,onMounted as g,onUnmounted as w,openBlock as y,createElementBlock as k,normalizeClass as x,renderSlot as b,createElementVNode as M,unref as T,toDisplayString as C,createCommentVNode as B,normalizeStyle as P,withDirectives as O,mergeProps as S,toHandlers as D,createBlock as E,Teleport as F,createVNode as j,Transition as z,withCtx as $,withModifiers as H,vShow as L}from"vue";import{ap as A,ar as R,ah as N,a9 as _,am as X,ae as Y,Z as q,a8 as I,K as Z,y as V}from"./exports.js";import{M as W}from"./index2.js";import{safeRaf as U}from"./utils/safeRaf.js";import{g as G,c as K,f as J,t as Q}from"./workers-mermaidWorkerClient.js";import{toSafeSvgElement as ee}from"stream-markdown-parser";const te=["data-markstream-mode","data-markstream-pending"],ne={key:0,class:"mermaid-block-header flex items-center justify-between border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)]"},le={key:0},oe={key:1,class:"flex items-center gap-x-2 overflow-hidden"},re=["innerHTML"],ae={key:2},ie={key:3,class:"mermaid-mode-toggle-group flex items-center gap-0.5"},ue={class:"flex items-center gap-x-1"},se={class:"flex items-center gap-x-1"},ce={key:4},de={key:5,class:"mermaid-header-actions flex items-center"},ve=["aria-pressed"],me={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},fe={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},he=["aria-label","disabled"],pe=["aria-label","disabled"],ge={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},we={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},ye={key:0,class:"mermaid-source-panel"},ke={class:"mermaid-source-code text-sm font-mono whitespace-pre-wrap"},xe={key:1,class:"relative"},be={key:0,class:"absolute top-2 right-2 z-10 rounded-lg"},Me={class:"flex items-center gap-2 backdrop-blur rounded-lg"},Te={class:"dialog-panel mermaid-modal-panel relative w-full h-full max-w-full max-h-full rounded overflow-hidden"},Ce={class:"absolute top-6 right-6 z-50 flex items-center gap-2"},Be="mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded",Pe=/* @__PURE__ */V(/* @__PURE__ */s({__name:"MermaidBlockNode",props:{node:{},maxHeight:{default:void 0},estimatedPreviewHeightPx:{},loading:{type:Boolean,default:!0},isDark:{type:Boolean},workerTimeoutMs:{default:1400},parseTimeoutMs:{default:1800},renderTimeoutMs:{default:2500},fullRenderTimeoutMs:{default:4e3},renderDebounceMs:{default:300},contentStableDelayMs:{default:500},previewPollDelayMs:{default:800},previewPollMaxDelayMs:{default:4e3},previewPollMaxAttempts:{default:12},showHeader:{type:Boolean,default:!0},showModeToggle:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExportButton:{type:Boolean,default:!0},showFullscreenButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showZoomControls:{type:Boolean,default:!0},enableWheelZoom:{type:Boolean,default:!1},isStrict:{type:Boolean,default:!0},enableMermaidInteractions:{type:Boolean,default:!1},showTooltips:{type:Boolean,default:!0},onRenderError:{}},emits:["copy","export","openModal","toggleMode"],setup(e,{emit:l}){var o,r;const a=e,s=l,V={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0},Pe=c(!1),Oe=c("undefined"==typeof window),Se=d(()=>a.isStrict?"strict":"loose"),De=d(()=>({startOnLoad:!1,securityLevel:Se.value,dompurifyConfig:"strict"===Se.value?V:void 0,flowchart:"strict"===Se.value?{htmlLabels:!1}:void 0}));function Ee(e){if(e)try{e.replaceChildren()}catch(t){e.innerHTML=""}}function Fe(e,t,n={}){if(!e)return null;const l=function(e,t){if(!e)return null;const n=ee(t);if(!n)return null;const l=function(e,t){const n=Array.from(e.childNodes),l=document.createElement("div");return l.dataset.mermaidSvgLayer="1",l.style.zIndex="1",l.appendChild(t),e.insertBefore(l,e.firstChild),n.length>0&&function(e){const t=()=>{var t;for(const n of e)null==(t=n.parentNode)||t.removeChild(n)};"function"==typeof requestAnimationFrame?requestAnimationFrame(()=>{requestAnimationFrame(t)}):setTimeout(t,32)}(n),l}(e,n);return{svg:n.outerHTML,bindTarget:l}}(e,t);return l||n.keepPreviousOnFailure||Ee(e),l}let je=null;function ze(e){if(a.enableMermaidInteractions&&(null==e?void 0:e.querySelector("svg")))try{null==je||je(e)}catch(t){}}const{t:$e}=A();function He(){return u(this,null,function*(){try{const e=yield G();return Pe.value=!!e,e}catch(e){throw Pe.value=!1,e}finally{Oe.value=!0}})}const Le=c(!1),Ae=c(!1),Re=c(),Ne=c(),_e=c(),Xe=c(),Ye=c(null),qe=R(),Ie=c(null),Ze=c("undefined"==typeof window),Ve=v(),We=m(W,null);let Ue="",Ge=0,Ke=0;const Je=d(()=>N(a,Ve));function Qe(){const e=Je.value;e&&(Ue&&Ue!==e&&(null==We||We.markSettled(Ue),Ge=0),Ue=e,Ge+=1,Ke+=1,1===Ge&&(null==We||We.markPending(e)))}function et(){return u(this,null,function*(){const e=Ue;if(!e)return;if(Ge=Math.max(0,Ge-1),Ge>0)return;Ue="";const t=++Ke;yield p(),t===Ke&&(function(e=Je.value){e&&Re.value&&(null==We||We.reportHeight(e,Re.value.offsetHeight))}(e),null==We||We.markSettled(e))})}function tt(){const e=Ue;e&&(Ue="",Ge=0,Ke+=1,null==We||We.markSettled(e))}const nt=c(),lt=d(()=>a.node.code.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"));function ot(){var e;return function(e){const t=function(){var e;const t=Ne.value?getComputedStyle(Ne.value).getPropertyValue("--ms-size-diagram-min-height").trim():"";return null!=(e=Y(t))?e:360}(),n=kn();return Z(e,t,n)}(null!=(e=Y(a.estimatedPreviewHeightPx))?e:q(lt.value))}function rt(){return`${ot()}px`}const at=c(null);function it(){var e;return!!(null==(e=_e.value)?void 0:e.querySelector("svg"))}function ut(){return!1!==a.loading&&(it()||!!at.value)}const st=c(1),ct=c(0),dt=c(0),vt=c(!1),mt=c({x:0,y:0}),ft=c(!0),ht=c(!1),pt=c(!1),gt=c(null),wt=c(0),yt=c(!1),kt=d(()=>{var e;return Math.max(0,null!=(e=a.renderDebounceMs)?e:300)}),xt=d(()=>{var e;return Math.max(0,null!=(e=a.contentStableDelayMs)?e:500)}),bt=d(()=>{var e;return Math.max(120,null!=(e=a.previewPollDelayMs)?e:800)}),Mt=d(()=>{var e;return Math.max(bt.value,null!=(e=a.previewPollMaxDelayMs)?e:4e3)}),Tt=d(()=>{var e;return Math.max(1,Math.trunc(null!=(e=a.previewPollMaxAttempts)?e:12))}),Ct=d(()=>!1!==a.loading);let Bt=null,Pt=null,Ot=null,St=0;const Dt=null!=(o=globalThis.requestIdleCallback)?o:(e,t)=>setTimeout(()=>e({didTimeout:!0}),16);function Et(){return Ze.value&&!Ae.value}function Ft(){null!=Ot&&(globalThis.clearTimeout(Ot),Ot=null)}function jt(){Ft(),Ot=globalThis.setTimeout(()=>{Ot=null,Et()&&Dt(()=>{Et()&&Xn()},{timeout:500})},kt.value)}function zt(){null!=Pt&&(globalThis.clearTimeout(Pt),Pt=null)}function $t(e=600){if("undefined"==typeof globalThis)return;const t=Math.max(0,e);zt(),Pt=globalThis.setTimeout(()=>{Pt=null,a.loading||pt.value||!Et()?$t(Math.min(1200,Math.max(300,1.2*t))):jt()},t)}const Ht=c(rt()),Lt=c(Ht.value);let At=null;const Rt=c(!1),Nt=c(!1),_t=c({}),Xt=c(""),Yt=c(0);let qt=null;const It=c(!1),Zt=d(()=>{var e,t;return!(Ae.value||Oe.value&&(ft.value||!pt.value&&!gt.value&&(Rt.value||It.value&&Boolean(null==(t=null==(e=_e.value)?void 0:e.textContent)?void 0:t.trim()))))}),Vt=c({zoom:1,translateX:0,translateY:0,containerHeight:Ht.value}),Wt=d(()=>a.enableWheelZoom?{wheel:jn}:{}),Ut=d(()=>{var e,t,n,l;return{worker:null!=(e=a.workerTimeoutMs)?e:1400,parse:null!=(t=a.parseTimeoutMs)?t:1800,render:null!=(n=a.renderTimeoutMs)?n:2500,fullRender:null!=(l=a.fullRenderTimeoutMs)?l:4e3}}),Gt=null!=(r=globalThis.cancelIdleCallback)?r:e=>clearTimeout(e);let Kt=null,Jt=null,Qt=!1,en=bt.value,tn=null,nn=0,ln=!0,on=0;function rn(e,t){const n=null==t?void 0:t.timeoutMs,l=null==t?void 0:t.signal;if(null==l?void 0:l.aborted)return Promise.reject(new DOMException("Aborted","AbortError"));let o=null,r=!1,a=null;return new Promise((t,i)=>{const u=()=>{null!=o&&clearTimeout(o),a&&l&&l.removeEventListener("abort",a)};n&&n>0&&(o=globalThis.setTimeout(()=>{r||(r=!0,u(),i(new Error("Operation timed out")))},n)),l&&(a=()=>{r||(r=!0,u(),i(new DOMException("Aborted","AbortError")))},l.addEventListener("abort",a)),e().then(e=>{r||(r=!0,u(),t(e))}).catch(e=>{r||(r=!0,u(),i(e))})})}function an(e){if("undefined"==typeof document)return;if(!_e.value)return;if("function"==typeof a.onRenderError&&!0===a.onRenderError(e,lt.value,_e.value))return It.value=!0,void Yn();const t=document.createElement("div");t.style.padding="var(--ms-inset-panel-body)",t.style.color="hsl(var(--ms-destructive))",t.textContent="Failed to render diagram: ";const n=document.createElement("span");n.textContent=e instanceof Error?e.message:"Unknown error",t.appendChild(n),Ee(_e.value),_e.value.appendChild(t);const l=_e.value?getComputedStyle(_e.value).getPropertyValue("--ms-size-diagram-min-height").trim():"";Ht.value=l||"360px",Lt.value=Ht.value,It.value=!0,Yn()}"undefined"!=typeof window&&f(()=>Ne.value,e=>{var t;if(null==(t=Ie.value)||t.destroy(),Ie.value=null,!e)return void(Ze.value=!1);const n=qe(e,{rootMargin:"400px"});Ie.value=n,Ze.value=n.isVisible.value,n.whenVisible.then(()=>{Ze.value=!0})},{immediate:!0}),h(()=>{var e;null==(e=Ie.value)||e.destroy(),Ie.value=null,tt(),Ft()});const un=d(()=>!1!==a.showTooltips);function sn(e){return!e||e.disabled}function cn(e,t,n="top"){if(!un.value)return;if(sn(e.currentTarget))return;const l=e,o=null!=(null==l?void 0:l.clientX)&&null!=(null==l?void 0:l.clientY)?{x:l.clientX,y:l.clientY}:void 0;X(e.currentTarget,t,n,!1,o,a.isDark)}function dn(){un.value&&_()}function vn(e){if(!un.value)return;if(sn(e.currentTarget))return;const t=Le.value?$e("common.copied")||"Copied":$e("common.copy")||"Copy",n=e,l=null!=(null==n?void 0:n.clientX)&&null!=(null==n?void 0:n.clientY)?{x:n.clientX,y:n.clientY}:void 0;X(e.currentTarget,t,"top",!1,l,a.isDark)}function mn(e,t){const n={theme:"dark"===t?"dark":"default"};"strict"===Se.value&&(n.flowchart={htmlLabels:!1});const l=`%%{init: ${JSON.stringify(n)}}%%\n`;return e.trimStart().startsWith("%%{")?e:l+e}function fn(){return ln&&!ft.value&&!Rt.value&&!It.value}function hn(e){const t=e.trim();return!(!t||t.startsWith("%%"))&&!/^(?:gantt|title|dateformat|axisformat|tickinterval|excludes|section|todaymarker|topaxis|weekday|weekend|acctitle|accdescr|accdescrmultiline)\b/i.test(t)&&t.includes(":")}function pn(e){if("gantt"===I(e))return function(e){var t;const n=e.split(/\r?\n/);for(!/\r?\n$/.test(e)&&n.length>0&&n.pop();n.length>0;){const e=null==(t=n[n.length-1])?void 0:t.trim();if(e&&!e.startsWith("%%")){if(hn(e))break;n.pop()}else n.pop()}return n.some(hn)?n.join("\n"):""}(e);const t=e.split(/\r?\n/);for(;t.length>0;){const e=t[t.length-1].trimEnd();if(""!==e){if(!(/^[-=~>|<\s]+$/.test(e.trim())||/(?:--|==|~~|->|<-|-\||-\)|-x|o-|\|-|\.-)\s*$/.test(e)||/[-|><]$/.test(e)||/(?:graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt)\s*$/i.test(e)))break;t.pop()}else t.pop()}return t.join("\n")}function gn(e,t,n){return u(this,null,function*(){var l;try{return yield K(e,t,null!=(l=null==n?void 0:n.timeoutMs)?l:Ut.value.worker)}catch(o){return yield function(e,t,n){return u(this,null,function*(){var l,o;const r=yield He();if(!r)return;const a=r,i=mn(e,t);if("function"==typeof a.parse)return yield rn(()=>a.parse(i),{timeoutMs:null!=(l=null==n?void 0:n.timeoutMs)?l:Ut.value.parse,signal:null==n?void 0:n.signal}),!0;const u=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;return yield rn(()=>r.render(u,i),{timeoutMs:null!=(o=null==n?void 0:n.timeoutMs)?o:Ut.value.render,signal:null==n?void 0:n.signal}),!0})}(e,t,n)}})}function wn(e,t,n){return u(this,null,function*(){var l;if("gantt"===I(e)){const l=pn(e);if(!l.trim())return{fullOk:!1,prefixOk:!1};try{if(yield gn(l,t,n))return l===e?{fullOk:!0,prefixOk:!1}:{fullOk:!1,prefixOk:!0,prefix:l}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}return{fullOk:!1,prefixOk:!1}}try{if(yield gn(e,t,n))return{fullOk:!0,prefixOk:!1}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}let o=pn(e);if(o&&o.trim()&&o!==e)try{try{const r=yield J(e,t,null!=(l=null==n?void 0:n.timeoutMs)?l:Ut.value.worker);r&&r.trim()&&(o=r)}catch(r){}if(yield gn(o,t,n))return{fullOk:!1,prefixOk:!0,prefix:o}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}return{fullOk:!1,prefixOk:!1}})}const yn=d(()=>ft.value||pt.value||Ae.value);function kn(){if("none"===a.maxHeight)return null;if(null!=a.maxHeight){const e=Number.parseFloat(String(a.maxHeight));if(Number.isFinite(e))return e}const e=Ne.value;if(e){const t=getComputedStyle(e).getPropertyValue("--ms-size-code-max-height").trim(),n=Number.parseFloat(t);if(Number.isFinite(n))return n}return 500}function xn(e,t){if(!Ne.value||!_e.value)return;const n=!(null==t?void 0:t.force)&&!1!==a.loading&&it(),l=_e.value.querySelector("svg");if(!l)return;let o=0,r=0;const i=l.getAttribute("viewBox"),u=l.getAttribute("width"),s=l.getAttribute("height");if(i){const e=i.split(" ");4===e.length&&(o=Number.parseFloat(e[2]),r=Number.parseFloat(e[3]))}if(o&&r||u&&s&&(o=Number.parseFloat(u),r=Number.parseFloat(s)),Number.isNaN(o)||Number.isNaN(r)||o<=0||r<=0)try{const e=l.getBBox();e&&e.width>0&&e.height>0&&(o=e.width,r=e.height)}catch(c){return void console.error("Failed to get SVG BBox:",c)}if(o>0&&r>0){const t=r/o,i=null!=e?e:Ne.value.clientWidth,u=l.getBoundingClientRect().width,s=u>0?u:i,c=kn(),d=s*t,v=null==c?d:Math.min(d,c),m=Math.max(v,ot());Lt.value=`${Math.max(d,m)}px`,n||null!=Y(a.estimatedPreviewHeightPx)||(Ht.value=`${m}px`)}}const bn=c(!1),Mn=d(()=>({transform:`translate(${ct.value}px, ${dt.value}px) scale(${st.value})`}));function Tn(e){"Escape"===e.key&&bn.value&&Bn()}function Cn(){var e;if(!Ne.value||!Xe.value)return!1;if("1"===(null==(e=Xe.value.firstElementChild)?void 0:e.getAttribute("data-mermaid-modal-clone")))return!0;const t=Ne.value.cloneNode(!0);t.dataset.mermaidModalClone="1",t.classList.add("fullscreen"),t.style.height="100%",t.style.maxHeight="100%";const n=t.querySelector("[data-mermaid-wrapper]");return n&&(Ye.value=n,n.style.transform=Mn.value.transform),Ee(Xe.value),Xe.value.appendChild(t),ze(t),!0}function Bn(){if(bn.value=!1,Xe.value&&Ee(Xe.value),Ye.value=null,"undefined"!=typeof document)try{document.body.style.overflow=""}catch(e){}if("undefined"!=typeof window)try{window.removeEventListener("keydown",Tn)}catch(e){}}function Pn(){st.value<3&&(st.value+=.1)}function On(){st.value>.5&&(st.value-=.1)}function Sn(){st.value=1,ct.value=0,dt.value=0}function Dn(e){vt.value=!0,e instanceof MouseEvent?mt.value={x:e.clientX-ct.value,y:e.clientY-dt.value}:mt.value={x:e.touches[0].clientX-ct.value,y:e.touches[0].clientY-dt.value}}function En(e){if(!vt.value)return;let t,n;e instanceof MouseEvent?(t=e.clientX,n=e.clientY):(t=e.touches[0].clientX,n=e.touches[0].clientY),ct.value=t-mt.value.x,dt.value=n-mt.value.y}function Fn(){vt.value=!1}function jn(e){if(a.enableWheelZoom&&(e.ctrlKey||e.metaKey)){if(e.preventDefault(),!Ne.value)return;const t=Ne.value.getBoundingClientRect(),n=e.clientX-t.left,l=e.clientY-t.top,o=n-t.width/2,r=l-t.height/2,a=(o-ct.value)/st.value,i=(r-dt.value)/st.value,u=.01,s=-e.deltaY*u,c=Math.min(Math.max(st.value+s,.5),3);c!==st.value&&(ct.value=o-a*c,dt.value=r-i*c,st.value=c)}}function zn(){return u(this,null,function*(){try{const e=lt.value,t={payload:{type:"copy",text:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};if(s("copy",t),t.defaultPrevented)return;"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(e)),Le.value=!0,setTimeout(()=>{Le.value=!1},1e3)}catch(e){console.error("Failed to copy:",e)}})}function $n(){var e;const t=null==(e=_e.value)?void 0:e.querySelector("svg");if(!t)return void console.error("SVG element not found");const n=(new XMLSerializer).serializeToString(t),l={payload:{type:"export"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:t,svgString:n};s("export",l),l.defaultPrevented||function(e,t=null){u(this,null,function*(){try{const l=null!=t?t:(new XMLSerializer).serializeToString(e),o=new Blob([l],{type:"image/svg+xml;charset=utf-8"}),r=URL.createObjectURL(o);if("undefined"!=typeof document){const e=document.createElement("a");e.href=r,e.download=`mermaid-diagram-${Date.now()}.svg`;try{document.body.appendChild(e),e.click(),document.body.removeChild(e)}catch(n){}URL.revokeObjectURL(r)}}catch(l){console.error("Failed to export SVG:",l)}})}(t,n)}function Hn(){var e,t;const n=null!=(t=null==(e=_e.value)?void 0:e.querySelector("svg"))?t:null,l=n?(new XMLSerializer).serializeToString(n):null,o={payload:{type:"open-modal"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:n,svgString:l};s("openModal",o),o.defaultPrevented||function(){if(bn.value=!0,"undefined"!=typeof document)try{document.body.style.overflow="hidden"}catch(e){}if("undefined"!=typeof window)try{window.addEventListener("keydown",Tn)}catch(e){}p(()=>{Cn()||p(Cn)})}()}function Ln(e){const t={payload:{type:"toggle-mode",target:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};s("toggleMode",e,t),t.defaultPrevented||An(e)}function An(e){return u(this,null,function*(){const t=nt.value;if(!t)return ht.value=!0,void(ft.value="source"===e);const n=t.getBoundingClientRect().height;t.style.height=`${n}px`,t.style.overflow="hidden",ht.value=!0,ft.value="source"===e,yield p();const l=t.scrollHeight;t.style.transition="height var(--ms-duration-standard) var(--ms-ease-standard)",t.offsetHeight,t.style.height=`${l}px`;const o=()=>{t.style.transition="",t.style.height="",t.style.overflow="",t.removeEventListener("transitionend",r)};function r(){o()}t.addEventListener("transitionend",r),setTimeout(()=>o(),220)})}function Rn(){return u(this,null,function*(){return pt.value?gt.value:_e.value||(yield p(),_e.value)?(pt.value=!0,Qe(),gt.value=u(null,null,function*(){var e,l,o,r;try{const u=yield He();if(!u)return;const s=`mermaid-${Date.now()}-${Math.random().toString(36).substring(2,11)}`;Rt.value||Nt.value||null==(e=u.initialize)||e.call(u,(o=i({},De.value),r={dompurifyConfig:i({},V)},t(o,n(r))));const c=function(e,t=lt.value){const n=t,l={theme:"dark"===e?"dark":"default"};"strict"===Se.value&&(l.flowchart={htmlLabels:!1});const o=`%%{init: ${JSON.stringify(l)}}%%\n`;return n.trim().startsWith("%%{")?n:o+n}(a.isDark?"dark":"light"),d=yield rn(()=>u.render(s,c),{timeoutMs:Ut.value.fullRender}),v=null==d?void 0:d.svg;if(_e.value){const e=Fe(_e.value,v,{keepPreviousOnFailure:!1!==a.loading});if(!e)return Nt.value&&(Nt.value=!1),!1;const t=null!=(l=null==d?void 0:d.bindFunctions)?l:null;je=t,ze(e.bindTarget),Rt.value||Nt.value||(U(()=>xn()),Rt.value=!0,Vt.value={zoom:st.value,translateX:ct.value,translateY:dt.value,containerHeight:Ht.value});const n=a.isDark?"dark":"light";e&&(_t.value[n]={svg:e.svg,bindFunctions:t}),Nt.value&&(Nt.value=!1),It.value=!1,St=0,zt()}return!0}catch(u){const e=function(e){const t="string"==typeof e?e:"string"==typeof(null==e?void 0:e.message)?e.message:"";return"string"==typeof t&&/timed out/i.test(t)}(u),t=St+1;return e&&t<=3?(St=t,$t(Math.min(1200,600*t))):(St=0,zt(),!1===a.loading&&console.error("Failed to render mermaid diagram:",u),!1===a.loading&&an(u)),!1}finally{pt.value=!1,gt.value=null,et()}}),gt.value):void console.warn("Mermaid container not ready")})}function Nn(){return u(this,null,function*(){var e,t,n;const l=lt.value;if(!l.trim()){if(ut())return;return _e.value&&Ee(_e.value),at.value=null,Xt.value="",void(It.value=!1)}if(!Pe.value||!Et())return;const o=l.replace(/\s+/g,"");Rt.value&&o===Xt.value&&(null==(e=_e.value)?void 0:e.querySelector("svg"))||(yield Rn())&&(Xt.value=o,at.value=null!=(n=null==(t=_e.value)?void 0:t.innerHTML)?n:null,It.value=!1)})}function _n(e){return u(this,null,function*(){var t;if(fn()&&(_e.value||(yield p(),_e.value))&&!pt.value){pt.value=!0,Qe();try{const n=yield He();if(!n)return;const l=`mermaid-partial-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,o=a.isDark?"dark":"light",r=pn(e),i=mn(r&&r.trim()?r:e,o),u=yield rn(()=>n.render(l,i),{timeoutMs:Ut.value.render}),s=null==u?void 0:u.svg;if(_e.value&&s){const e=Fe(_e.value,s,{keepPreviousOnFailure:!0});e&&(je=null!=(t=null==u?void 0:u.bindFunctions)?t:null,ze(e.bindTarget),U(()=>xn()))}}catch(n){}finally{pt.value=!1,et()}}})}function Xn(){return u(this,null,function*(){var e,t,n;const l=Date.now(),o=++Yt.value;Qe();try{qt&&qt.abort(),qt=new AbortController;const i=qt.signal,u=a.isDark?"dark":"light",s=lt.value,c=s.replace(/\s+/g,"");if(!s.trim()){if(ut())return;return _e.value&&Ee(_e.value),at.value=null,Xt.value="",void(It.value=!1)}if(c===Xt.value)return;try{const n=yield wn(s,u,{signal:i,timeoutMs:Ut.value.worker});if(n.fullOk){if(!(yield Rn()))return;return void(Yt.value===o&&(at.value=null!=(t=null==(e=_e.value)?void 0:e.innerHTML)?t:null,Xt.value=c,It.value=!1))}const r=nn&&l<=nn;if(n.prefixOk&&n.prefix&&fn()&&!r)return void(yield _n(n.prefix))}catch(r){if("AbortError"===(null==r?void 0:r.name))return}if(Yt.value!==o)return;if(It.value)return;const d=_t.value[u];if(d&&_e.value){const e=Fe(_e.value,d.svg);e&&(je=null!=(n=d.bindFunctions)?n:null,ze(e.bindTarget))}}finally{et()}})}function Yn(){Qt&&(Qt=!1,en=bt.value,ln=!1,tn&&(tn.abort(),tn=null),Kt&&(globalThis.clearTimeout(Kt),Kt=null),Jt&&(Gt(Jt),Jt=null),nn=Date.now())}function qn(){if(Yn(),Ft(),qt){try{qt.abort()}catch(e){}qt=null}if(tn){try{tn.abort()}catch(e){}tn=null}Q(),zt(),St=0}function In(e=bt.value){Qt&&(on>=Tt.value?Yn():(Kt&&globalThis.clearTimeout(Kt),Kt=globalThis.setTimeout(()=>{Jt=Dt(()=>u(null,null,function*(){if(!Qt)return;if(!Et())return void Yn();if(ft.value||Rt.value)return void Yn();const e=a.isDark?"dark":"light",t=lt.value;if(!t.trim())return!1===a.loading?void Yn():void In(en);if(on++,on>Tt.value)Yn();else{tn&&tn.abort(),tn=new AbortController;try{const n=yield wn(t,e,{signal:tn.signal,timeoutMs:Ut.value.worker});if(n.fullOk){if((yield Rn())&&Rt.value)return void Yn()}else n.prefixOk&&n.prefix&&fn()&&(yield _n(n.prefix))}catch(n){}en=Math.min(Math.floor(1.5*en),Mt.value),In(en)}}),{timeout:500})},e)))}function Zn(){Qt||Ct.value&&Pe.value&&Et()&&(ft.value||Rt.value||(Qt=!0,nn=0,ln=!0,on=0,en=bt.value,In(en)))}return f(Xe,e=>{bn.value&&e&&Cn()}),f(Mn,e=>{bn.value&&Ye.value&&(Ye.value.style.transform=e.transform)},{immediate:!0}),f(un,e=>{e||_()}),f(()=>lt.value,e=>{if((e.trim()||!1===a.loading)&&(Rt.value=!1,_t.value={}),!Ct.value)return Yn(),void(Et()&&!ft.value&&Nn());Et()&&jt(),!ft.value&&Pe.value&&Et()?Zn():Yn(),function(){if(!Ct.value)return;if(!ft.value)return;if(!Pe.value)return;const e=lt.value.length;e!==wt.value&&(yt.value=!0,wt.value=e,Bt&&clearTimeout(Bt),Bt=setTimeout(()=>{yt.value&&ft.value&<.value.trim()&&(yt.value=!1,An("preview"))},xt.value))}()}),f(()=>a.isDark,()=>u(null,null,function*(){var e;if(!Rt.value)return;if(It.value)return;const t=a.isDark?"dark":"light",n=_t.value[t];if(n){if(_e.value){const t=Fe(_e.value,n.svg);t&&(je=null!=(e=n.bindFunctions)?e:null,ze(t.bindTarget))}return}const l={zoom:st.value,translateX:ct.value,translateY:dt.value,containerHeight:Ht.value},o=1!==st.value||0!==ct.value||0!==dt.value;Nt.value=!0,o&&(st.value=1,ct.value=0,dt.value=0,yield p()),yield Rn(),o&&(yield p(),st.value=l.zoom,ct.value=l.translateX,dt.value=l.translateY,Ht.value=l.containerHeight,Vt.value=l)})),f(()=>ft.value,e=>u(null,null,function*(){var t;if(e)Yn(),Rt.value&&(Vt.value={zoom:st.value,translateX:ct.value,translateY:dt.value,containerHeight:Ht.value});else{if(It.value)return;const e=a.isDark?"dark":"light";if(Rt.value&&_t.value[e]){if(yield p(),_e.value){const n=_t.value[e],l=Fe(_e.value,n.svg);l&&(je=null!=(t=n.bindFunctions)?t:null,ze(l.bindTarget))}return st.value=Vt.value.zoom,ct.value=Vt.value.translateX,dt.value=Vt.value.translateY,void(Ht.value=Vt.value.containerHeight)}if(yield p(),!Pe.value||!Et())return;if(!Ct.value)return Yn(),void(yield Nn());Zn(),yield Xn()}})),f(()=>a.loading,(e,t)=>u(null,null,function*(){var n;if(!0===t&&!1===e){const e=lt.value.trim();if(!e)return _e.value&&Ee(_e.value),at.value=null,Xt.value="",It.value=!1,qn();const t=a.isDark?"dark":"light",o=e.replace(/\s+/g,"");if(Rt.value&&o===Xt.value){if(yield p(),_e.value&&!_e.value.querySelector("svg")&&_t.value[t]){const e=_t.value[t],l=Fe(_e.value,e.svg);l&&(je=null!=(n=e.bindFunctions)?n:null,ze(l.bindTarget))}return xn(void 0,{force:!0}),void qn()}try{if(yield gn(e,t,{timeoutMs:Ut.value.worker}),!(yield Rn()))return;Xt.value=o,It.value=!1,qn()}catch(l){qn(),an(l)}}})),f(Ne,e=>{At&&At.disconnect(),e&&(At=new ResizeObserver(e=>{e&&e.length>0&&!ft.value&&!Ae.value&&U(()=>{xn(e[0].contentRect.width)})}),At.observe(e))},{immediate:!0}),g(()=>u(null,null,function*(){He().catch(e=>{Pe.value=!1,console.warn("[markstream-vue] Failed to initialize mermaid renderer. Call enableMermaid() to configure a loader.",e)}),yield p(),ht.value||(ft.value=!Pe.value),Et()&&(Ct.value?(jt(),wt.value=lt.value.length):ft.value||Nn())})),f(()=>Pe.value,e=>{ht.value||(ft.value=!e)}),f(()=>a.maxHeight,()=>{p(()=>{xn()})}),f([()=>a.estimatedPreviewHeightPx,()=>lt.value],()=>{Rt.value||it()||ft.value||(Ht.value=rt(),Lt.value=Ht.value)}),f(()=>Ze.value,e=>{e&&(Rt.value||(Ct.value?(jt(),wt.value=lt.value.length):Nn()),a.loading||Rt.value||Nn(),!ft.value&&Pe.value&&Ct.value&&Zn())},{immediate:!1}),w(()=>{Bt&&clearTimeout(Bt),Ft(),At&&At.disconnect(),qt&&(qt.abort(),qt=null),Q(),Yn(),zt(),tt()}),f(()=>Ae.value,e=>u(null,null,function*(){e?(Yn(),qt&&qt.abort()):Et()&&!Rt.value&&(yield p(),Ct.value?(jt(),Zn()):ft.value||Nn())}),{immediate:!1}),(e,t)=>(y(),k("div",{ref_key:"blockContainer",ref:Re,class:x(["mermaid-block-container rounded-lg border overflow-hidden",[{"is-rendering":a.loading,dark:a.isDark}]]),"data-markstream-mermaid":"1","data-markstream-mode":ft.value?"fallback":Rt.value?"preview":"pending","data-markstream-pending":Zt.value?"true":void 0},[a.showHeader?(y(),k("div",ne,[e.$slots["header-left"]?(y(),k("div",le,[b(e.$slots,"header-left",{},void 0,!0)])):(y(),k("div",oe,[M("span",{class:"icon-slot action-icon shrink-0",innerHTML:T('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#ca9ee6" stroke-linecap="round" stroke-linejoin="round" d="M1.5 2.5c0 6 2.25 5.75 4 7 .83.67 1.17 2 1 4h3c-.17-2 .17-3.33 1-4 1.75-1.25 4-1 4-7C12 2.5 10 3 8 7 6 3 4 2.5 1.5 2.5" />\n</svg>\n')},null,8,re),t[21]||(t[21]=M("span",{class:"mermaid-label-text text-[length:var(--ms-text-label)] font-medium font-mono truncate"},"Mermaid",-1))])),e.$slots["header-center"]?(y(),k("div",ae,[b(e.$slots,"header-center",{},void 0,!0)])):a.showModeToggle&&Pe.value?(y(),k("div",ie,[M("button",{class:x(["mermaid-mode-btn px-2 py-0.5 rounded transition-colors",[ft.value?"":"is-active"]]),onClick:t[0]||(t[0]=()=>Ln("preview")),onMouseenter:t[1]||(t[1]=e=>cn(e,T($e)("common.preview")||"Preview")),onFocus:t[2]||(t[2]=e=>cn(e,T($e)("common.preview")||"Preview")),onMouseleave:dn,onBlur:dn},[M("div",ue,[t[22]||(t[22]=M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),M("circle",{cx:"12",cy:"12",r:"3"})])],-1)),M("span",null,C(T($e)("common.preview")||"Preview"),1)])],34),M("button",{class:x(["mermaid-mode-btn px-2 py-0.5 rounded transition-colors",[ft.value?"is-active":""]]),onClick:t[3]||(t[3]=()=>Ln("source")),onMouseenter:t[4]||(t[4]=e=>cn(e,T($e)("common.source")||"Source")),onFocus:t[5]||(t[5]=e=>cn(e,T($e)("common.source")||"Source")),onMouseleave:dn,onBlur:dn},[M("div",se,[t[23]||(t[23]=M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m16 18l6-6l-6-6M8 6l-6 6l6 6"})],-1)),M("span",null,C(T($e)("common.source")||"Source"),1)])],34)])):B("",!0),e.$slots["header-right"]?(y(),k("div",ce,[b(e.$slots,"header-right",{},void 0,!0)])):(y(),k("div",de,[a.showCollapseButton?(y(),k("button",{key:0,class:x(Be),"aria-pressed":Ae.value,onClick:t[6]||(t[6]=e=>Ae.value=!Ae.value),onMouseenter:t[7]||(t[7]=e=>cn(e,Ae.value?T($e)("common.expand")||"Expand":T($e)("common.collapse")||"Collapse")),onFocus:t[8]||(t[8]=e=>cn(e,Ae.value?T($e)("common.expand")||"Expand":T($e)("common.collapse")||"Collapse")),onMouseleave:dn,onBlur:dn},[(y(),k("svg",{style:P({rotate:Ae.value?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[...t[24]||(t[24]=[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,ve)):B("",!0),a.showCopyButton?(y(),k("button",{key:1,class:x(Be),onClick:zn,onMouseenter:t[9]||(t[9]=e=>vn(e)),onFocus:t[10]||(t[10]=e=>vn(e)),onMouseleave:dn,onBlur:dn},[Le.value?(y(),k("svg",fe,[...t[26]||(t[26]=[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(y(),k("svg",me,[...t[25]||(t[25]=[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),M("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],32)):B("",!0),a.showExportButton&&Pe.value?(y(),k("button",{key:2,class:x(`${Be} ${yn.value?"opacity-50 cursor-not-allowed":""}`),"aria-label":T($e)("common.export")||"Export",disabled:yn.value,onClick:$n,onMouseenter:t[11]||(t[11]=e=>cn(e,T($e)("common.export")||"Export")),onFocus:t[12]||(t[12]=e=>cn(e,T($e)("common.export")||"Export")),onMouseleave:dn,onBlur:dn},[...t[27]||(t[27]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),M("path",{d:"m7 10l5 5l5-5"})])],-1)])],42,he)):B("",!0),a.showFullscreenButton&&Pe.value?(y(),k("button",{key:3,class:x(`${Be} ${yn.value?"opacity-50 cursor-not-allowed":""}`),"aria-label":bn.value?T($e)("common.minimize")||"Minimize":T($e)("common.open")||"Open",disabled:yn.value,onClick:Hn,onMouseenter:t[13]||(t[13]=e=>cn(e,bn.value?T($e)("common.minimize")||"Minimize":T($e)("common.open")||"Open")),onFocus:t[14]||(t[14]=e=>cn(e,bn.value?T($e)("common.minimize")||"Minimize":T($e)("common.open")||"Open")),onMouseleave:dn,onBlur:dn},[bn.value?(y(),k("svg",we,[...t[29]||(t[29]=[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"},null,-1)])])):(y(),k("svg",ge,[...t[28]||(t[28]=[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"},null,-1)])]))],42,pe)):B("",!0)]))])):B("",!0),O(M("div",{ref_key:"modeContainerRef",ref:nt},[ft.value?(y(),k("div",ye,[M("pre",ke,C(lt.value),1)])):(y(),k("div",xe,[a.showZoomControls?(y(),k("div",be,[M("div",Me,[M("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Pn,onMouseenter:t[15]||(t[15]=e=>cn(e,T($e)("common.zoomIn")||"Zoom in")),onFocus:t[16]||(t[16]=e=>cn(e,T($e)("common.zoomIn")||"Zoom in")),onMouseleave:dn,onBlur:dn},[...t[30]||(t[30]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("circle",{cx:"11",cy:"11",r:"8"}),M("path",{d:"m21 21l-4.35-4.35M11 8v6m-3-3h6"})])],-1)])],32),M("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:On,onMouseenter:t[17]||(t[17]=e=>cn(e,T($e)("common.zoomOut")||"Zoom out")),onFocus:t[18]||(t[18]=e=>cn(e,T($e)("common.zoomOut")||"Zoom out")),onMouseleave:dn,onBlur:dn},[...t[31]||(t[31]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("circle",{cx:"11",cy:"11",r:"8"}),M("path",{d:"m21 21l-4.35-4.35M8 11h6"})])],-1)])],32),M("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] text-[length:var(--ms-text-label)] rounded transition-colors",onClick:Sn,onMouseenter:t[19]||(t[19]=e=>cn(e,T($e)("common.resetZoom")||"Reset zoom")),onFocus:t[20]||(t[20]=e=>cn(e,T($e)("common.resetZoom")||"Reset zoom")),onMouseleave:dn,onBlur:dn},C(Math.round(100*st.value))+"% ",33)])])):B("",!0),M("div",S({ref_key:"mermaidContainer",ref:Ne,class:"mermaid-preview-area relative overflow-hidden block transition-[height] ease-out",style:{height:Ht.value}},D(Wt.value,!0),{onMousedown:Dn,onMousemove:En,onMouseup:Fn,onMouseleave:Fn,onTouchstartPassive:Dn,onTouchmovePassive:En,onTouchendPassive:Fn}),[M("div",{"data-mermaid-wrapper":"",class:x(["absolute inset-0 cursor-grab",{"cursor-grabbing":vt.value}]),style:P(Mn.value)},[M("div",{ref_key:"mermaidContent",ref:_e,class:"_mermaid w-full text-center flex items-center justify-center min-h-full",style:P({height:Lt.value})},null,4)],6)],16),(y(),E(F,{to:"body"},[M("div",{class:x(["markstream-vue",{dark:a.isDark}])},[j(z,{name:"mermaid-dialog",appear:""},{default:$(()=>[bn.value?(y(),k("div",{key:0,class:"mermaid-modal-overlay fixed inset-0 z-50 flex items-center justify-center p-4",onClick:H(Bn,["self"])},[M("div",Te,[M("div",Ce,[M("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Pn},[...t[32]||(t[32]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("circle",{cx:"11",cy:"11",r:"8"}),M("path",{d:"m21 21l-4.35-4.35M11 8v6m-3-3h6"})])],-1)])]),M("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:On},[...t[33]||(t[33]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("circle",{cx:"11",cy:"11",r:"8"}),M("path",{d:"m21 21l-4.35-4.35M8 11h6"})])],-1)])]),M("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] text-[length:var(--ms-text-label)] rounded transition-colors",onClick:Sn},C(Math.round(100*st.value))+"% ",1),M("button",{class:"mermaid-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Bn},[...t[34]||(t[34]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"})],-1)])])]),M("div",S({ref_key:"modalContent",ref:Xe,class:"w-full h-full flex items-center justify-center p-4 overflow-hidden"},D(Wt.value,!0),{onMousedown:Dn,onMousemove:En,onMouseup:Fn,onMouseleave:Fn,onTouchstartPassive:Dn,onTouchmovePassive:En,onTouchendPassive:Fn}),null,16)])])):B("",!0)]),_:1})],2)]))]))],512),[[L,!Ae.value]])],10,te))}}),[["__scopeId","data-v-e9775fad"]]);Pe.install=e=>{e.component(Pe.__name,Pe)};export{Pe as default};
|
|
1
|
+
var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=(t,n,l)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[n]=l,i=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&a(e,n,t[n]);if(l)for(var n of l(t))r.call(t,n)&&a(e,n,t[n]);return e},u=(e,t,n)=>new Promise((l,o)=>{var r=e=>{try{i(n.next(e))}catch(t){o(t)}},a=e=>{try{i(n.throw(e))}catch(t){o(t)}},i=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,a);i((n=n.apply(e,t)).next())});import{defineComponent as s,ref as c,computed as d,useAttrs as v,inject as m,watch as f,onBeforeUnmount as h,nextTick as p,onMounted as g,onUnmounted as w,openBlock as y,createElementBlock as k,normalizeClass as x,renderSlot as b,createElementVNode as M,unref as T,toDisplayString as C,createCommentVNode as B,normalizeStyle as P,withDirectives as S,mergeProps as O,toHandlers as D,createBlock as E,Teleport as F,createVNode as j,Transition as $,withCtx as z,withModifiers as H,vShow as L}from"vue";import{aj as A,al as R,ab as N,a4 as _,ag as X,y as Y}from"./exports.js";import{p as q,b as I,g as V,a as Z}from"./diagramHeight.js";import{e as W}from"./mermaidSequenceSemicolons.js";import{M as U}from"./index2.js";import{safeRaf as G}from"./utils/safeRaf.js";import{g as J,c as K,f as Q,t as ee}from"./workers-mermaidWorkerClient.js";import{toSafeSvgElement as te}from"stream-markdown-parser";const ne=["data-markstream-mode","data-markstream-pending"],le={key:0,class:"mermaid-block-header flex items-center justify-between border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)]"},oe={key:0},re={key:1,class:"flex items-center gap-x-2 overflow-hidden"},ae=["innerHTML"],ie={key:2},ue={key:3,class:"mermaid-mode-toggle-group flex items-center gap-0.5"},se={class:"flex items-center gap-x-1"},ce={class:"flex items-center gap-x-1"},de={key:4},ve={key:5,class:"mermaid-header-actions flex items-center"},me=["aria-pressed"],fe={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},he={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},pe=["aria-label","disabled"],ge=["aria-label","disabled"],we={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},ye={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},ke={key:0,class:"mermaid-source-panel"},xe={class:"mermaid-source-code text-sm font-mono whitespace-pre-wrap"},be={key:1,class:"relative"},Me={key:0,class:"absolute top-2 right-2 z-10 rounded-lg"},Te={class:"flex items-center gap-2 backdrop-blur rounded-lg"},Ce={class:"dialog-panel mermaid-modal-panel relative w-full h-full max-w-full max-h-full rounded overflow-hidden"},Be={class:"absolute top-6 right-6 z-50 flex items-center gap-2"},Pe="mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded",Se=/* @__PURE__ */Y(/* @__PURE__ */s({__name:"MermaidBlockNode",props:{node:{},maxHeight:{default:void 0},estimatedPreviewHeightPx:{},loading:{type:Boolean,default:!0},isDark:{type:Boolean},workerTimeoutMs:{default:1400},parseTimeoutMs:{default:1800},renderTimeoutMs:{default:2500},fullRenderTimeoutMs:{default:4e3},renderDebounceMs:{default:300},contentStableDelayMs:{default:500},previewPollDelayMs:{default:800},previewPollMaxDelayMs:{default:4e3},previewPollMaxAttempts:{default:12},showHeader:{type:Boolean,default:!0},showModeToggle:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExportButton:{type:Boolean,default:!0},showFullscreenButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showZoomControls:{type:Boolean,default:!0},enableWheelZoom:{type:Boolean,default:!1},isStrict:{type:Boolean,default:!0},enableMermaidInteractions:{type:Boolean,default:!1},showTooltips:{type:Boolean,default:!0},onRenderError:{}},emits:["copy","export","openModal","toggleMode"],setup(e,{emit:l}){var o,r;const a=e,s=l,Y={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0},Se=c(!1),Oe=c("undefined"==typeof window),De=d(()=>a.isStrict?"strict":"loose"),Ee=d(()=>({startOnLoad:!1,securityLevel:De.value,dompurifyConfig:"strict"===De.value?Y:void 0,flowchart:"strict"===De.value?{htmlLabels:!1}:void 0}));function Fe(e){if(e)try{e.replaceChildren()}catch(t){e.innerHTML=""}}function je(e,t,n={}){if(!e)return null;const l=function(e,t){if(!e)return null;const n=te(t);if(!n)return null;const l=function(e,t){const n=Array.from(e.childNodes),l=document.createElement("div");return l.dataset.mermaidSvgLayer="1",l.style.zIndex="1",l.appendChild(t),e.insertBefore(l,e.firstChild),n.length>0&&function(e){const t=()=>{var t;for(const n of e)null==(t=n.parentNode)||t.removeChild(n)};"function"==typeof requestAnimationFrame?requestAnimationFrame(()=>{requestAnimationFrame(t)}):setTimeout(t,32)}(n),l}(e,n);return{svg:n.outerHTML,bindTarget:l}}(e,t);return l||n.keepPreviousOnFailure||Fe(e),l}let $e=null;function ze(e){if(a.enableMermaidInteractions&&(null==e?void 0:e.querySelector("svg")))try{null==$e||$e(e)}catch(t){}}const{t:He}=A();function Le(){return u(this,null,function*(){try{const e=yield J();return Se.value=!!e,e}catch(e){throw Se.value=!1,e}finally{Oe.value=!0}})}const Ae=c(!1),Re=c(!1),Ne=c(),_e=c(),Xe=c(),Ye=c(),qe=c(null),Ie=R(),Ve=c(null),Ze=c("undefined"==typeof window),We=v(),Ue=m(U,null);let Ge="",Je=0,Ke=0;const Qe=d(()=>N(a,We));function et(){const e=Qe.value;e&&(Ge&&Ge!==e&&(null==Ue||Ue.markSettled(Ge),Je=0),Ge=e,Je+=1,Ke+=1,1===Je&&(null==Ue||Ue.markPending(e)))}function tt(){return u(this,null,function*(){const e=Ge;if(!e)return;if(Je=Math.max(0,Je-1),Je>0)return;Ge="";const t=++Ke;yield p(),t===Ke&&(function(e=Qe.value){e&&Ne.value&&(null==Ue||Ue.reportHeight(e,Ne.value.offsetHeight))}(e),null==Ue||Ue.markSettled(e))})}function nt(){const e=Ge;e&&(Ge="",Je=0,Ke+=1,null==Ue||Ue.markSettled(e))}const lt=c(),ot=d(()=>a.node.code.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"));function rt(){var e;return function(e){const t=function(){var e;const t=_e.value?getComputedStyle(_e.value).getPropertyValue("--ms-size-diagram-min-height").trim():"";return null!=(e=q(t))?e:360}(),n=Tn();return Z(e,t,n)}(null!=(e=q(a.estimatedPreviewHeightPx))?e:I(ot.value))}function at(){return`${rt()}px`}const it=c(null);function ut(){var e;return!!(null==(e=Xe.value)?void 0:e.querySelector("svg"))}function st(){return!1!==a.loading&&(ut()||!!it.value)}const ct=c(1),dt=c(0),vt=c(0),mt=c(!1),ft=c({x:0,y:0}),ht=c(!0),pt=c(!1),gt=c(!1),wt=c(null),yt=c(0),kt=c(!1),xt=d(()=>{var e;return Math.max(0,null!=(e=a.renderDebounceMs)?e:300)}),bt=d(()=>{var e;return Math.max(0,null!=(e=a.contentStableDelayMs)?e:500)}),Mt=d(()=>{var e;return Math.max(120,null!=(e=a.previewPollDelayMs)?e:800)}),Tt=d(()=>{var e;return Math.max(Mt.value,null!=(e=a.previewPollMaxDelayMs)?e:4e3)}),Ct=d(()=>{var e;return Math.max(1,Math.trunc(null!=(e=a.previewPollMaxAttempts)?e:12))}),Bt=d(()=>!1!==a.loading);let Pt=null,St=null,Ot=null,Dt=0;const Et=null!=(o=globalThis.requestIdleCallback)?o:(e,t)=>setTimeout(()=>e({didTimeout:!0}),16);function Ft(){return Ze.value&&!Re.value}function jt(){null!=Ot&&(globalThis.clearTimeout(Ot),Ot=null)}function $t(){jt(),Ot=globalThis.setTimeout(()=>{Ot=null,Ft()&&Et(()=>{Ft()&&Vn()},{timeout:500})},xt.value)}function zt(){null!=St&&(globalThis.clearTimeout(St),St=null)}function Ht(e=600){if("undefined"==typeof globalThis)return;const t=Math.max(0,e);zt(),St=globalThis.setTimeout(()=>{St=null,a.loading||gt.value||!Ft()?Ht(Math.min(1200,Math.max(300,1.2*t))):$t()},t)}const Lt=c(at()),At=c(Lt.value);let Rt=null;const Nt=c(!1),_t=c(!1),Xt=c({}),Yt=c(""),qt=c(0);let It=null;const Vt=c(!1),Zt=d(()=>{var e,t;return!(Re.value||Oe.value&&(ht.value||!gt.value&&!wt.value&&(Nt.value||Vt.value&&Boolean(null==(t=null==(e=Xe.value)?void 0:e.textContent)?void 0:t.trim()))))}),Wt=c({zoom:1,translateX:0,translateY:0,containerHeight:Lt.value}),Ut=d(()=>a.enableWheelZoom?{wheel:Ln}:{}),Gt=d(()=>{var e,t,n,l;return{worker:null!=(e=a.workerTimeoutMs)?e:1400,parse:null!=(t=a.parseTimeoutMs)?t:1800,render:null!=(n=a.renderTimeoutMs)?n:2500,fullRender:null!=(l=a.fullRenderTimeoutMs)?l:4e3}}),Jt=null!=(r=globalThis.cancelIdleCallback)?r:e=>clearTimeout(e);let Kt=null,Qt=null,en=!1,tn=Mt.value,nn=null,ln=0,on=!0,rn=0;function an(e,t){const n=null==t?void 0:t.timeoutMs,l=null==t?void 0:t.signal;if(null==l?void 0:l.aborted)return Promise.reject(new DOMException("Aborted","AbortError"));let o=null,r=!1,a=null;return new Promise((t,i)=>{const u=()=>{null!=o&&clearTimeout(o),a&&l&&l.removeEventListener("abort",a)};n&&n>0&&(o=globalThis.setTimeout(()=>{r||(r=!0,u(),i(new Error("Operation timed out")))},n)),l&&(a=()=>{r||(r=!0,u(),i(new DOMException("Aborted","AbortError")))},l.addEventListener("abort",a)),e().then(e=>{r||(r=!0,u(),t(e))}).catch(e=>{r||(r=!0,u(),i(e))})})}function un(e){if("undefined"==typeof document)return;if(!Xe.value)return;if("function"==typeof a.onRenderError&&!0===a.onRenderError(e,ot.value,Xe.value))return Vt.value=!0,void Zn();const t=document.createElement("div");t.style.padding="var(--ms-inset-panel-body)",t.style.color="hsl(var(--ms-destructive))",t.textContent="Failed to render diagram: ";const n=document.createElement("span");n.textContent=e instanceof Error?e.message:"Unknown error",t.appendChild(n),Fe(Xe.value),Xe.value.appendChild(t);const l=Xe.value?getComputedStyle(Xe.value).getPropertyValue("--ms-size-diagram-min-height").trim():"";Lt.value=l||"360px",At.value=Lt.value,Vt.value=!0,Zn()}function sn(e){const t="string"==typeof e?e:"string"==typeof(null==e?void 0:e.message)?e.message:"";return"string"==typeof t&&/timed out/i.test(t)}function cn(e){return!sn(e)&&!function(e){return"AbortError"===(null==e?void 0:e.name)}(e)}"undefined"!=typeof window&&f(()=>_e.value,e=>{var t;if(null==(t=Ve.value)||t.destroy(),Ve.value=null,!e)return void(Ze.value=!1);const n=Ie(e,{rootMargin:"400px"});Ve.value=n,Ze.value=n.isVisible.value,n.whenVisible.then(()=>{Ze.value=!0})},{immediate:!0}),h(()=>{var e;null==(e=Ve.value)||e.destroy(),Ve.value=null,nt(),jt()});const dn=d(()=>!1!==a.showTooltips);function vn(e){return!e||e.disabled}function mn(e,t,n="top"){if(!dn.value)return;if(vn(e.currentTarget))return;const l=e,o=null!=(null==l?void 0:l.clientX)&&null!=(null==l?void 0:l.clientY)?{x:l.clientX,y:l.clientY}:void 0;X(e.currentTarget,t,n,!1,o,a.isDark)}function fn(){dn.value&&_()}function hn(e){if(!dn.value)return;if(vn(e.currentTarget))return;const t=Ae.value?He("common.copied")||"Copied":He("common.copy")||"Copy",n=e,l=null!=(null==n?void 0:n.clientX)&&null!=(null==n?void 0:n.clientY)?{x:n.clientX,y:n.clientY}:void 0;X(e.currentTarget,t,"top",!1,l,a.isDark)}function pn(e,t){const n={theme:"dark"===t?"dark":"default"};"strict"===De.value&&(n.flowchart={htmlLabels:!1});const l=`%%{init: ${JSON.stringify(n)}}%%\n`;return e.trimStart().startsWith("%%{")?e:l+e}function gn(){return on&&!ht.value&&!Nt.value&&!Vt.value}function wn(e){const t=e.trim();return!(!t||t.startsWith("%%"))&&!/^(?:gantt|title|dateformat|axisformat|tickinterval|excludes|section|todaymarker|topaxis|weekday|weekend|acctitle|accdescr|accdescrmultiline)\b/i.test(t)&&t.includes(":")}function yn(e){if("gantt"===V(e))return function(e){var t;const n=e.split(/\r?\n/);for(!/\r?\n$/.test(e)&&n.length>0&&n.pop();n.length>0;){const e=null==(t=n[n.length-1])?void 0:t.trim();if(e&&!e.startsWith("%%")){if(wn(e))break;n.pop()}else n.pop()}return n.some(wn)?n.join("\n"):""}(e);const t=e.split(/\r?\n/);for(;t.length>0;){const e=t[t.length-1].trimEnd();if(""!==e){if(!(/^[-=~>|<\s]+$/.test(e.trim())||/(?:--|==|~~|->|<-|-\||-\)|-x|o-|\|-|\.-)\s*$/.test(e)||/[-|><]$/.test(e)||/(?:graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt)\s*$/i.test(e)))break;t.pop()}else t.pop()}return t.join("\n")}function kn(e,t,n,l){return u(this,null,function*(){try{return yield an(()=>e.render(t,n),{timeoutMs:l})}catch(o){if(!cn(o))throw o;const a=W(n);if(a===n)throw o;try{return yield an(()=>e.render(`${t}-retry`,a),{timeoutMs:l})}catch(r){throw o}}})}function xn(e,t,n){return u(this,null,function*(){var l;try{return yield K(e,t,null!=(l=null==n?void 0:n.timeoutMs)?l:Gt.value.worker)}catch(o){return yield function(e,t,n){return u(this,null,function*(){var l,r,a,i;const u=yield Le();if(!u)return;const s=u,c=pn(e,t);if("function"==typeof s.parse){try{yield an(()=>s.parse(c),{timeoutMs:null!=(l=null==n?void 0:n.timeoutMs)?l:Gt.value.parse,signal:null==n?void 0:n.signal})}catch(v){if(!cn(v))throw v;const e=W(c);if(e===c)throw v;try{yield an(()=>s.parse(e),{timeoutMs:null!=(r=null==n?void 0:n.timeoutMs)?r:Gt.value.parse,signal:null==n?void 0:n.signal})}catch(o){throw v}}return!0}const d=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;try{yield an(()=>u.render(d,c),{timeoutMs:null!=(a=null==n?void 0:n.timeoutMs)?a:Gt.value.render,signal:null==n?void 0:n.signal})}catch(v){if(!cn(v))throw v;const e=W(c);if(e===c)throw v;try{yield an(()=>u.render(`${d}-retry`,e),{timeoutMs:null!=(i=null==n?void 0:n.timeoutMs)?i:Gt.value.render,signal:null==n?void 0:n.signal})}catch(o){throw v}}return!0})}(e,t,n)}})}function bn(e,t,n){return u(this,null,function*(){var l;if("gantt"===V(e)){const l=yn(e);if(!l.trim())return{fullOk:!1,prefixOk:!1};try{if(yield xn(l,t,n))return l===e?{fullOk:!0,prefixOk:!1}:{fullOk:!1,prefixOk:!0,prefix:l}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}return{fullOk:!1,prefixOk:!1}}try{if(yield xn(e,t,n))return{fullOk:!0,prefixOk:!1}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}let o=yn(e);if(o&&o.trim()&&o!==e)try{try{const r=yield Q(e,t,null!=(l=null==n?void 0:n.timeoutMs)?l:Gt.value.worker);r&&r.trim()&&(o=r)}catch(r){}if(yield xn(o,t,n))return{fullOk:!1,prefixOk:!0,prefix:o}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}return{fullOk:!1,prefixOk:!1}})}const Mn=d(()=>ht.value||gt.value||Re.value);function Tn(){if("none"===a.maxHeight)return null;if(null!=a.maxHeight){const e=Number.parseFloat(String(a.maxHeight));if(Number.isFinite(e))return e}const e=_e.value;if(e){const t=getComputedStyle(e).getPropertyValue("--ms-size-code-max-height").trim(),n=Number.parseFloat(t);if(Number.isFinite(n))return n}return 500}function Cn(e,t){if(!_e.value||!Xe.value)return;const n=!(null==t?void 0:t.force)&&!1!==a.loading&&ut(),l=Xe.value.querySelector("svg");if(!l)return;let o=0,r=0;const i=l.getAttribute("viewBox"),u=l.getAttribute("width"),s=l.getAttribute("height");if(i){const e=i.split(" ");4===e.length&&(o=Number.parseFloat(e[2]),r=Number.parseFloat(e[3]))}if(o&&r||u&&s&&(o=Number.parseFloat(u),r=Number.parseFloat(s)),Number.isNaN(o)||Number.isNaN(r)||o<=0||r<=0)try{const e=l.getBBox();e&&e.width>0&&e.height>0&&(o=e.width,r=e.height)}catch(c){return void console.error("Failed to get SVG BBox:",c)}if(o>0&&r>0){const t=r/o,i=null!=e?e:_e.value.clientWidth,u=l.getBoundingClientRect().width,s=u>0?u:i,c=Tn(),d=s*t,v=null==c?d:Math.min(d,c),m=Math.max(v,rt());At.value=`${Math.max(d,m)}px`,n||null!=q(a.estimatedPreviewHeightPx)||(Lt.value=`${m}px`)}}const Bn=c(!1),Pn=d(()=>({transform:`translate(${dt.value}px, ${vt.value}px) scale(${ct.value})`}));function Sn(e){"Escape"===e.key&&Bn.value&&Dn()}function On(){var e;if(!_e.value||!Ye.value)return!1;if("1"===(null==(e=Ye.value.firstElementChild)?void 0:e.getAttribute("data-mermaid-modal-clone")))return!0;const t=_e.value.cloneNode(!0);t.dataset.mermaidModalClone="1",t.classList.add("fullscreen"),t.style.height="100%",t.style.maxHeight="100%";const n=t.querySelector("[data-mermaid-wrapper]");return n&&(qe.value=n,n.style.transform=Pn.value.transform),Fe(Ye.value),Ye.value.appendChild(t),ze(t),!0}function Dn(){if(Bn.value=!1,Ye.value&&Fe(Ye.value),qe.value=null,"undefined"!=typeof document)try{document.body.style.overflow=""}catch(e){}if("undefined"!=typeof window)try{window.removeEventListener("keydown",Sn)}catch(e){}}function En(){ct.value<3&&(ct.value+=.1)}function Fn(){ct.value>.5&&(ct.value-=.1)}function jn(){ct.value=1,dt.value=0,vt.value=0}function $n(e){mt.value=!0,e instanceof MouseEvent?ft.value={x:e.clientX-dt.value,y:e.clientY-vt.value}:ft.value={x:e.touches[0].clientX-dt.value,y:e.touches[0].clientY-vt.value}}function zn(e){if(!mt.value)return;let t,n;e instanceof MouseEvent?(t=e.clientX,n=e.clientY):(t=e.touches[0].clientX,n=e.touches[0].clientY),dt.value=t-ft.value.x,vt.value=n-ft.value.y}function Hn(){mt.value=!1}function Ln(e){if(a.enableWheelZoom&&(e.ctrlKey||e.metaKey)){if(e.preventDefault(),!_e.value)return;const t=_e.value.getBoundingClientRect(),n=e.clientX-t.left,l=e.clientY-t.top,o=n-t.width/2,r=l-t.height/2,a=(o-dt.value)/ct.value,i=(r-vt.value)/ct.value,u=.01,s=-e.deltaY*u,c=Math.min(Math.max(ct.value+s,.5),3);c!==ct.value&&(dt.value=o-a*c,vt.value=r-i*c,ct.value=c)}}function An(){return u(this,null,function*(){try{const e=ot.value,t={payload:{type:"copy",text:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};if(s("copy",t),t.defaultPrevented)return;"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(e)),Ae.value=!0,setTimeout(()=>{Ae.value=!1},1e3)}catch(e){console.error("Failed to copy:",e)}})}function Rn(){var e;const t=null==(e=Xe.value)?void 0:e.querySelector("svg");if(!t)return void console.error("SVG element not found");const n=(new XMLSerializer).serializeToString(t),l={payload:{type:"export"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:t,svgString:n};s("export",l),l.defaultPrevented||function(e,t=null){u(this,null,function*(){try{const l=null!=t?t:(new XMLSerializer).serializeToString(e),o=new Blob([l],{type:"image/svg+xml;charset=utf-8"}),r=URL.createObjectURL(o);if("undefined"!=typeof document){const e=document.createElement("a");e.href=r,e.download=`mermaid-diagram-${Date.now()}.svg`;try{document.body.appendChild(e),e.click(),document.body.removeChild(e)}catch(n){}URL.revokeObjectURL(r)}}catch(l){console.error("Failed to export SVG:",l)}})}(t,n)}function Nn(){var e,t;const n=null!=(t=null==(e=Xe.value)?void 0:e.querySelector("svg"))?t:null,l=n?(new XMLSerializer).serializeToString(n):null,o={payload:{type:"open-modal"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:n,svgString:l};s("openModal",o),o.defaultPrevented||function(){if(Bn.value=!0,"undefined"!=typeof document)try{document.body.style.overflow="hidden"}catch(e){}if("undefined"!=typeof window)try{window.addEventListener("keydown",Sn)}catch(e){}p(()=>{On()||p(On)})}()}function _n(e){const t={payload:{type:"toggle-mode",target:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};s("toggleMode",e,t),t.defaultPrevented||Xn(e)}function Xn(e){return u(this,null,function*(){const t=lt.value;if(!t)return pt.value=!0,void(ht.value="source"===e);const n=t.getBoundingClientRect().height;t.style.height=`${n}px`,t.style.overflow="hidden",pt.value=!0,ht.value="source"===e,yield p();const l=t.scrollHeight;t.style.transition="height var(--ms-duration-standard) var(--ms-ease-standard)",t.offsetHeight,t.style.height=`${l}px`;const o=()=>{t.style.transition="",t.style.height="",t.style.overflow="",t.removeEventListener("transitionend",r)};function r(){o()}t.addEventListener("transitionend",r),setTimeout(()=>o(),220)})}function Yn(){return u(this,null,function*(){return gt.value?wt.value:Xe.value||(yield p(),Xe.value)?(gt.value=!0,et(),wt.value=u(null,null,function*(){var e,l,o,r;try{const u=yield Le();if(!u)return;const s=`mermaid-${Date.now()}-${Math.random().toString(36).substring(2,11)}`;Nt.value||_t.value||null==(e=u.initialize)||e.call(u,(o=i({},Ee.value),r={dompurifyConfig:i({},Y)},t(o,n(r))));const c=function(e,t=ot.value){const n=t,l={theme:"dark"===e?"dark":"default"};"strict"===De.value&&(l.flowchart={htmlLabels:!1});const o=`%%{init: ${JSON.stringify(l)}}%%\n`;return n.trim().startsWith("%%{")?n:o+n}(a.isDark?"dark":"light"),d=yield kn(u,s,c,Gt.value.fullRender),v=null==d?void 0:d.svg;if(Xe.value){const e=je(Xe.value,v,{keepPreviousOnFailure:!1!==a.loading});if(!e)return _t.value&&(_t.value=!1),!1;const t=null!=(l=null==d?void 0:d.bindFunctions)?l:null;$e=t,ze(e.bindTarget),Nt.value||_t.value||(G(()=>Cn()),Nt.value=!0,Wt.value={zoom:ct.value,translateX:dt.value,translateY:vt.value,containerHeight:Lt.value});const n=a.isDark?"dark":"light";e&&(Xt.value[n]={svg:e.svg,bindFunctions:t}),_t.value&&(_t.value=!1),Vt.value=!1,Dt=0,zt()}return!0}catch(u){const e=sn(u),t=Dt+1;return e&&t<=3?(Dt=t,Ht(Math.min(1200,600*t))):(Dt=0,zt(),!1===a.loading&&console.error("Failed to render mermaid diagram:",u),!1===a.loading&&un(u)),!1}finally{gt.value=!1,wt.value=null,tt()}}),wt.value):void console.warn("Mermaid container not ready")})}function qn(){return u(this,null,function*(){var e,t,n;const l=ot.value;if(!l.trim()){if(st())return;return Xe.value&&Fe(Xe.value),it.value=null,Yt.value="",void(Vt.value=!1)}if(!Se.value||!Ft())return;const o=l.replace(/\s+/g,"");Nt.value&&o===Yt.value&&(null==(e=Xe.value)?void 0:e.querySelector("svg"))||(yield Yn())&&(Yt.value=o,it.value=null!=(n=null==(t=Xe.value)?void 0:t.innerHTML)?n:null,Vt.value=!1)})}function In(e){return u(this,null,function*(){var t;if(gn()&&(Xe.value||(yield p(),Xe.value))&&!gt.value){gt.value=!0,et();try{const n=yield Le();if(!n)return;const l=`mermaid-partial-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,o=a.isDark?"dark":"light",r=yn(e),i=pn(r&&r.trim()?r:e,o),u=yield kn(n,l,i,Gt.value.render),s=null==u?void 0:u.svg;if(Xe.value&&s){const e=je(Xe.value,s,{keepPreviousOnFailure:!0});e&&($e=null!=(t=null==u?void 0:u.bindFunctions)?t:null,ze(e.bindTarget),G(()=>Cn()))}}catch(n){}finally{gt.value=!1,tt()}}})}function Vn(){return u(this,null,function*(){var e,t,n;const l=Date.now(),o=++qt.value;et();try{It&&It.abort(),It=new AbortController;const i=It.signal,u=a.isDark?"dark":"light",s=ot.value,c=s.replace(/\s+/g,"");if(!s.trim()){if(st())return;return Xe.value&&Fe(Xe.value),it.value=null,Yt.value="",void(Vt.value=!1)}if(c===Yt.value)return;try{const n=yield bn(s,u,{signal:i,timeoutMs:Gt.value.worker});if(n.fullOk){if(!(yield Yn()))return;return void(qt.value===o&&(it.value=null!=(t=null==(e=Xe.value)?void 0:e.innerHTML)?t:null,Yt.value=c,Vt.value=!1))}const r=ln&&l<=ln;if(n.prefixOk&&n.prefix&&gn()&&!r)return void(yield In(n.prefix))}catch(r){if("AbortError"===(null==r?void 0:r.name))return}if(qt.value!==o)return;if(Vt.value)return;const d=Xt.value[u];if(d&&Xe.value){const e=je(Xe.value,d.svg);e&&($e=null!=(n=d.bindFunctions)?n:null,ze(e.bindTarget))}}finally{tt()}})}function Zn(){en&&(en=!1,tn=Mt.value,on=!1,nn&&(nn.abort(),nn=null),Kt&&(globalThis.clearTimeout(Kt),Kt=null),Qt&&(Jt(Qt),Qt=null),ln=Date.now())}function Wn(){if(Zn(),jt(),It){try{It.abort()}catch(e){}It=null}if(nn){try{nn.abort()}catch(e){}nn=null}ee(),zt(),Dt=0}function Un(e=Mt.value){en&&(rn>=Ct.value?Zn():(Kt&&globalThis.clearTimeout(Kt),Kt=globalThis.setTimeout(()=>{Qt=Et(()=>u(null,null,function*(){if(!en)return;if(!Ft())return void Zn();if(ht.value||Nt.value)return void Zn();const e=a.isDark?"dark":"light",t=ot.value;if(!t.trim())return!1===a.loading?void Zn():void Un(tn);if(rn++,rn>Ct.value)Zn();else{nn&&nn.abort(),nn=new AbortController;try{const n=yield bn(t,e,{signal:nn.signal,timeoutMs:Gt.value.worker});if(n.fullOk){if((yield Yn())&&Nt.value)return void Zn()}else n.prefixOk&&n.prefix&&gn()&&(yield In(n.prefix))}catch(n){}tn=Math.min(Math.floor(1.5*tn),Tt.value),Un(tn)}}),{timeout:500})},e)))}function Gn(){en||Bt.value&&Se.value&&Ft()&&(ht.value||Nt.value||(en=!0,ln=0,on=!0,rn=0,tn=Mt.value,Un(tn)))}return f(Ye,e=>{Bn.value&&e&&On()}),f(Pn,e=>{Bn.value&&qe.value&&(qe.value.style.transform=e.transform)},{immediate:!0}),f(dn,e=>{e||_()}),f(()=>ot.value,e=>{if((e.trim()||!1===a.loading)&&(Nt.value=!1,Xt.value={}),!Bt.value)return Zn(),void(Ft()&&!ht.value&&qn());Ft()&&$t(),!ht.value&&Se.value&&Ft()?Gn():Zn(),function(){if(!Bt.value)return;if(!ht.value)return;if(!Se.value)return;const e=ot.value.length;e!==yt.value&&(kt.value=!0,yt.value=e,Pt&&clearTimeout(Pt),Pt=setTimeout(()=>{kt.value&&ht.value&&ot.value.trim()&&(kt.value=!1,Xn("preview"))},bt.value))}()}),f(()=>a.isDark,()=>u(null,null,function*(){var e;if(!Nt.value)return;if(Vt.value)return;const t=a.isDark?"dark":"light",n=Xt.value[t];if(n){if(Xe.value){const t=je(Xe.value,n.svg);t&&($e=null!=(e=n.bindFunctions)?e:null,ze(t.bindTarget))}return}const l={zoom:ct.value,translateX:dt.value,translateY:vt.value,containerHeight:Lt.value},o=1!==ct.value||0!==dt.value||0!==vt.value;_t.value=!0,o&&(ct.value=1,dt.value=0,vt.value=0,yield p()),yield Yn(),o&&(yield p(),ct.value=l.zoom,dt.value=l.translateX,vt.value=l.translateY,Lt.value=l.containerHeight,Wt.value=l)})),f(()=>ht.value,e=>u(null,null,function*(){var t;if(e)Zn(),Nt.value&&(Wt.value={zoom:ct.value,translateX:dt.value,translateY:vt.value,containerHeight:Lt.value});else{if(Vt.value)return;const e=a.isDark?"dark":"light";if(Nt.value&&Xt.value[e]){if(yield p(),Xe.value){const n=Xt.value[e],l=je(Xe.value,n.svg);l&&($e=null!=(t=n.bindFunctions)?t:null,ze(l.bindTarget))}return ct.value=Wt.value.zoom,dt.value=Wt.value.translateX,vt.value=Wt.value.translateY,void(Lt.value=Wt.value.containerHeight)}if(yield p(),!Se.value||!Ft())return;if(!Bt.value)return Zn(),void(yield qn());Gn(),yield Vn()}})),f(()=>a.loading,(e,t)=>u(null,null,function*(){var n;if(!0===t&&!1===e){const e=ot.value.trim();if(!e)return Xe.value&&Fe(Xe.value),it.value=null,Yt.value="",Vt.value=!1,Wn();const t=a.isDark?"dark":"light",o=e.replace(/\s+/g,"");if(Nt.value&&o===Yt.value){if(yield p(),Xe.value&&!Xe.value.querySelector("svg")&&Xt.value[t]){const e=Xt.value[t],l=je(Xe.value,e.svg);l&&($e=null!=(n=e.bindFunctions)?n:null,ze(l.bindTarget))}return Cn(void 0,{force:!0}),void Wn()}try{if(yield xn(e,t,{timeoutMs:Gt.value.worker}),!(yield Yn()))return;Yt.value=o,Vt.value=!1,Wn()}catch(l){Wn(),un(l)}}})),f(_e,e=>{Rt&&Rt.disconnect(),e&&(Rt=new ResizeObserver(e=>{e&&e.length>0&&!ht.value&&!Re.value&&G(()=>{Cn(e[0].contentRect.width)})}),Rt.observe(e))},{immediate:!0}),g(()=>u(null,null,function*(){Le().catch(e=>{Se.value=!1,console.warn("[markstream-vue] Failed to initialize mermaid renderer. Call enableMermaid() to configure a loader.",e)}),yield p(),pt.value||(ht.value=!Se.value),Ft()&&(Bt.value?($t(),yt.value=ot.value.length):ht.value||qn())})),f(()=>Se.value,e=>{pt.value||(ht.value=!e)}),f(()=>a.maxHeight,()=>{p(()=>{Cn()})}),f([()=>a.estimatedPreviewHeightPx,()=>ot.value],()=>{Nt.value||ut()||ht.value||(Lt.value=at(),At.value=Lt.value)}),f(()=>Ze.value,e=>{e&&(Nt.value||(Bt.value?($t(),yt.value=ot.value.length):qn()),a.loading||Nt.value||qn(),!ht.value&&Se.value&&Bt.value&&Gn())},{immediate:!1}),w(()=>{Pt&&clearTimeout(Pt),jt(),Rt&&Rt.disconnect(),It&&(It.abort(),It=null),ee(),Zn(),zt(),nt()}),f(()=>Re.value,e=>u(null,null,function*(){e?(Zn(),It&&It.abort()):Ft()&&!Nt.value&&(yield p(),Bt.value?($t(),Gn()):ht.value||qn())}),{immediate:!1}),(e,t)=>(y(),k("div",{ref_key:"blockContainer",ref:Ne,class:x(["mermaid-block-container rounded-lg border overflow-hidden",[{"is-rendering":a.loading,dark:a.isDark}]]),"data-markstream-mermaid":"1","data-markstream-mode":ht.value?"fallback":Nt.value?"preview":"pending","data-markstream-pending":Zt.value?"true":void 0},[a.showHeader?(y(),k("div",le,[e.$slots["header-left"]?(y(),k("div",oe,[b(e.$slots,"header-left",{},void 0,!0)])):(y(),k("div",re,[M("span",{class:"icon-slot action-icon shrink-0",innerHTML:T('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\n <path fill="none" stroke="#ca9ee6" stroke-linecap="round" stroke-linejoin="round" d="M1.5 2.5c0 6 2.25 5.75 4 7 .83.67 1.17 2 1 4h3c-.17-2 .17-3.33 1-4 1.75-1.25 4-1 4-7C12 2.5 10 3 8 7 6 3 4 2.5 1.5 2.5" />\n</svg>\n')},null,8,ae),t[21]||(t[21]=M("span",{class:"mermaid-label-text text-[length:var(--ms-text-label)] font-medium font-mono truncate"},"Mermaid",-1))])),e.$slots["header-center"]?(y(),k("div",ie,[b(e.$slots,"header-center",{},void 0,!0)])):a.showModeToggle&&Se.value?(y(),k("div",ue,[M("button",{class:x(["mermaid-mode-btn px-2 py-0.5 rounded transition-colors",[ht.value?"":"is-active"]]),onClick:t[0]||(t[0]=()=>_n("preview")),onMouseenter:t[1]||(t[1]=e=>mn(e,T(He)("common.preview")||"Preview")),onFocus:t[2]||(t[2]=e=>mn(e,T(He)("common.preview")||"Preview")),onMouseleave:fn,onBlur:fn},[M("div",se,[t[22]||(t[22]=M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),M("circle",{cx:"12",cy:"12",r:"3"})])],-1)),M("span",null,C(T(He)("common.preview")||"Preview"),1)])],34),M("button",{class:x(["mermaid-mode-btn px-2 py-0.5 rounded transition-colors",[ht.value?"is-active":""]]),onClick:t[3]||(t[3]=()=>_n("source")),onMouseenter:t[4]||(t[4]=e=>mn(e,T(He)("common.source")||"Source")),onFocus:t[5]||(t[5]=e=>mn(e,T(He)("common.source")||"Source")),onMouseleave:fn,onBlur:fn},[M("div",ce,[t[23]||(t[23]=M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m16 18l6-6l-6-6M8 6l-6 6l6 6"})],-1)),M("span",null,C(T(He)("common.source")||"Source"),1)])],34)])):B("",!0),e.$slots["header-right"]?(y(),k("div",de,[b(e.$slots,"header-right",{},void 0,!0)])):(y(),k("div",ve,[a.showCollapseButton?(y(),k("button",{key:0,class:x(Pe),"aria-pressed":Re.value,onClick:t[6]||(t[6]=e=>Re.value=!Re.value),onMouseenter:t[7]||(t[7]=e=>mn(e,Re.value?T(He)("common.expand")||"Expand":T(He)("common.collapse")||"Collapse")),onFocus:t[8]||(t[8]=e=>mn(e,Re.value?T(He)("common.expand")||"Expand":T(He)("common.collapse")||"Collapse")),onMouseleave:fn,onBlur:fn},[(y(),k("svg",{style:P({rotate:Re.value?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[...t[24]||(t[24]=[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,me)):B("",!0),a.showCopyButton?(y(),k("button",{key:1,class:x(Pe),onClick:An,onMouseenter:t[9]||(t[9]=e=>hn(e)),onFocus:t[10]||(t[10]=e=>hn(e)),onMouseleave:fn,onBlur:fn},[Ae.value?(y(),k("svg",he,[...t[26]||(t[26]=[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(y(),k("svg",fe,[...t[25]||(t[25]=[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),M("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],32)):B("",!0),a.showExportButton&&Se.value?(y(),k("button",{key:2,class:x(`${Pe} ${Mn.value?"opacity-50 cursor-not-allowed":""}`),"aria-label":T(He)("common.export")||"Export",disabled:Mn.value,onClick:Rn,onMouseenter:t[11]||(t[11]=e=>mn(e,T(He)("common.export")||"Export")),onFocus:t[12]||(t[12]=e=>mn(e,T(He)("common.export")||"Export")),onMouseleave:fn,onBlur:fn},[...t[27]||(t[27]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),M("path",{d:"m7 10l5 5l5-5"})])],-1)])],42,pe)):B("",!0),a.showFullscreenButton&&Se.value?(y(),k("button",{key:3,class:x(`${Pe} ${Mn.value?"opacity-50 cursor-not-allowed":""}`),"aria-label":Bn.value?T(He)("common.minimize")||"Minimize":T(He)("common.open")||"Open",disabled:Mn.value,onClick:Nn,onMouseenter:t[13]||(t[13]=e=>mn(e,Bn.value?T(He)("common.minimize")||"Minimize":T(He)("common.open")||"Open")),onFocus:t[14]||(t[14]=e=>mn(e,Bn.value?T(He)("common.minimize")||"Minimize":T(He)("common.open")||"Open")),onMouseleave:fn,onBlur:fn},[Bn.value?(y(),k("svg",ye,[...t[29]||(t[29]=[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"},null,-1)])])):(y(),k("svg",we,[...t[28]||(t[28]=[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"},null,-1)])]))],42,ge)):B("",!0)]))])):B("",!0),S(M("div",{ref_key:"modeContainerRef",ref:lt},[ht.value?(y(),k("div",ke,[M("pre",xe,C(ot.value),1)])):(y(),k("div",be,[a.showZoomControls?(y(),k("div",Me,[M("div",Te,[M("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:En,onMouseenter:t[15]||(t[15]=e=>mn(e,T(He)("common.zoomIn")||"Zoom in")),onFocus:t[16]||(t[16]=e=>mn(e,T(He)("common.zoomIn")||"Zoom in")),onMouseleave:fn,onBlur:fn},[...t[30]||(t[30]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("circle",{cx:"11",cy:"11",r:"8"}),M("path",{d:"m21 21l-4.35-4.35M11 8v6m-3-3h6"})])],-1)])],32),M("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Fn,onMouseenter:t[17]||(t[17]=e=>mn(e,T(He)("common.zoomOut")||"Zoom out")),onFocus:t[18]||(t[18]=e=>mn(e,T(He)("common.zoomOut")||"Zoom out")),onMouseleave:fn,onBlur:fn},[...t[31]||(t[31]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("circle",{cx:"11",cy:"11",r:"8"}),M("path",{d:"m21 21l-4.35-4.35M8 11h6"})])],-1)])],32),M("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] text-[length:var(--ms-text-label)] rounded transition-colors",onClick:jn,onMouseenter:t[19]||(t[19]=e=>mn(e,T(He)("common.resetZoom")||"Reset zoom")),onFocus:t[20]||(t[20]=e=>mn(e,T(He)("common.resetZoom")||"Reset zoom")),onMouseleave:fn,onBlur:fn},C(Math.round(100*ct.value))+"% ",33)])])):B("",!0),M("div",O({ref_key:"mermaidContainer",ref:_e,class:"mermaid-preview-area relative overflow-hidden block transition-[height] ease-out",style:{height:Lt.value}},D(Ut.value,!0),{onMousedown:$n,onMousemove:zn,onMouseup:Hn,onMouseleave:Hn,onTouchstartPassive:$n,onTouchmovePassive:zn,onTouchendPassive:Hn}),[M("div",{"data-mermaid-wrapper":"",class:x(["absolute inset-0 cursor-grab",{"cursor-grabbing":mt.value}]),style:P(Pn.value)},[M("div",{ref_key:"mermaidContent",ref:Xe,class:"_mermaid w-full text-center flex items-center justify-center min-h-full",style:P({height:At.value})},null,4)],6)],16),(y(),E(F,{to:"body"},[M("div",{class:x(["markstream-vue",{dark:a.isDark}])},[j($,{name:"mermaid-dialog",appear:""},{default:z(()=>[Bn.value?(y(),k("div",{key:0,class:"mermaid-modal-overlay fixed inset-0 z-50 flex items-center justify-center p-4",onClick:H(Dn,["self"])},[M("div",Ce,[M("div",Be,[M("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:En},[...t[32]||(t[32]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("circle",{cx:"11",cy:"11",r:"8"}),M("path",{d:"m21 21l-4.35-4.35M11 8v6m-3-3h6"})])],-1)])]),M("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Fn},[...t[33]||(t[33]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("circle",{cx:"11",cy:"11",r:"8"}),M("path",{d:"m21 21l-4.35-4.35M8 11h6"})])],-1)])]),M("button",{class:"mermaid-action-btn p-[var(--ms-action-btn-padding)] text-[length:var(--ms-text-label)] rounded transition-colors",onClick:jn},C(Math.round(100*ct.value))+"% ",1),M("button",{class:"mermaid-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded transition-colors",onClick:Dn},[...t[34]||(t[34]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"})],-1)])])]),M("div",O({ref_key:"modalContent",ref:Ye,class:"w-full h-full flex items-center justify-center p-4 overflow-hidden"},D(Ut.value,!0),{onMousedown:$n,onMousemove:zn,onMouseup:Hn,onMouseleave:Hn,onTouchstartPassive:$n,onTouchmovePassive:zn,onTouchendPassive:Hn}),null,16)])])):B("",!0)]),_:1})],2)]))]))],512),[[L,!Re.value]])],10,ne))}}),[["__scopeId","data-v-07b7ab60"]]);Se.install=e=>{e.component(Se.__name,Se)};export{Se as default};
|
package/dist/index5.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=(e,n,l)=>new Promise((t,a)=>{var o=e=>{try{u(l.next(e))}catch(n){a(n)}},r=e=>{try{u(l.throw(e))}catch(n){a(n)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,r);u((l=l.apply(e,n)).next())});import{defineComponent as n,ref as l,inject as t,computed as a,watch as o,onMounted as r,onBeforeUnmount as u,openBlock as i,createElementBlock as d,normalizeStyle as c,createVNode as v,Transition as s,withCtx as m,createElementVNode as f,createCommentVNode as h,normalizeClass as g,toDisplayString as k,nextTick as p}from"vue";import{
|
|
1
|
+
var e=(e,n,l)=>new Promise((t,a)=>{var o=e=>{try{u(l.next(e))}catch(n){a(n)}},r=e=>{try{u(l.throw(e))}catch(n){a(n)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,r);u((l=l.apply(e,n)).next())});import{defineComponent as n,ref as l,inject as t,computed as a,watch as o,onMounted as r,onBeforeUnmount as u,openBlock as i,createElementBlock as d,normalizeStyle as c,createVNode as v,Transition as s,withCtx as m,createElementVNode as f,createCommentVNode as h,normalizeClass as g,toDisplayString as k,nextTick as p}from"vue";import{ab as y,ai as x,al as b,y as _}from"./exports.js";import{M as w}from"./index2.js";import{n as S,f as R,j as T,b as E,k as M,W as O}from"./workers-katexWorkerClient.js";const H=["data-markstream-mode","data-markstream-pending"],K={key:0,class:"math-loading-overlay"},I=["innerHTML"],j={key:1,class:"math-block__fallback text-left"},W=/* @__PURE__ */_(/* @__PURE__ */n({__name:"MathBlockNode",props:{node:{},indexKey:{},cacheScope:{}},setup(n){const _=n,W=l(null),$=t(w,null),A=a(()=>S(_.node.content)),L=a(()=>y(_,{})),N=function(){if(!_.node.content)return{html:"",text:_.node.raw,loading:!1};const e=R();if(!e)return{html:"",text:_.node.loading?"":_.node.raw,loading:_.node.loading};try{return{html:e.renderToString(A.value,{throwOnError:_.node.loading,displayMode:!0}),text:"",loading:!1}}catch(n){return{html:"",text:_.node.loading?"":_.node.raw,loading:_.node.loading}}}(),P=l(N.html),z=l(N.text);let B=!1,C=0,D=!1,F=null;const U=x(),V=b();let X=null,q=null,G="";const J=l(N.loading),Q=l(!1),Y=l(ne());function Z(e){null!=e&&e!==C||(Q.value=!1)}function ee(){var e;if(null==_.indexKey)return"";const n=null!=(e=_.cacheScope)?e:null==U?void 0:U.scope;return`${null!=n&&String(n).length>0?`${String(n)}:`:""}math-block:${String(_.indexKey)}`}function ne(){var e;const n=ee();return n&&null!=(e=null==U?void 0:U.cache.get(n))?e:0}function le(e){if(!Number.isFinite(e)||e<=0)return;const n=Math.max(Y.value,e);if(n===Y.value)return;Y.value=n;const l=ee();l&&(null==U||U.cache.set(l,n))}function te(){p(()=>{var e,n;le(null!=(n=null==(e=W.value)?void 0:e.offsetHeight)?n:0)})}function ae(){const e=G;$&&e&&(G="",$.markSettled(e))}function oe(){return e(this,null,function*(){if(D)return ae(),void Z();F&&(F.abort(),F=null);const n=++C;if(!_.node.content)return ae(),Z(),J.value=!1,P.value="",z.value=_.node.raw,B=!0,void te();const l=new AbortController;if(F=l,Q.value=!0,!B)try{!X&&W.value&&(X=V(W.value)),yield null==X?void 0:X.whenVisible}catch(t){}D||n!==C||l.signal.aborted?D||Z(n):(function(){const e=L.value;$&&e&&G!==e&&(G&&$.markSettled(G),G=e,$.markPending(e))}(),T(A.value,!0,{timeout:3e3,waitTimeout:2e3,maxRetries:1,signal:l.signal}).then(e=>{D||n!==C||(P.value=e,z.value="",B=!0,J.value=!1,te())}).catch(l=>e(null,null,function*(){if(D||n!==C)return;const e=(null==l?void 0:l.code)||(null==l?void 0:l.name),a="KATEX_DISABLED"===e;if("WORKER_INIT_ERROR"===e||(null==l?void 0:l.fallbackToRenderer)||e===O||"WORKER_TIMEOUT"===e){const e=yield E();if(D||n!==C)return;if(e){try{const n=e.renderToString(A.value,{throwOnError:_.node.loading,displayMode:!0});P.value=n,z.value="",B=!0,J.value=!1,te(),M(A.value,!0,n)}catch(t){}return}}if(a||!_.node.loading)return J.value=!1,P.value="",z.value=_.node.raw,void te();B||(J.value=!0)})).finally(()=>{D||n!==C||(Z(n),function(){const e=G;$&&e&&(G="",p(()=>{var n,l;if(!D){const t=null!=(l=null==(n=W.value)?void 0:n.offsetHeight)?l:0;t>0&&$.reportHeight(e,t)}$.markSettled(e)}))}())}))})}return(N.html||N.text)&&(B=!0),o(()=>_.node.content,()=>{oe()},{flush:"post"}),o([()=>_.indexKey,()=>_.cacheScope],()=>{Y.value=ne(),te()}),r(()=>{"undefined"!=typeof ResizeObserver&&W.value&&(q=new ResizeObserver(()=>{var e,n;le(null!=(n=null==(e=W.value)?void 0:e.offsetHeight)?n:0)}),q.observe(W.value)),te(),P.value||oe()}),u(()=>{var e;D=!0,ae(),F&&(F.abort(),F=null),null==q||q.disconnect(),q=null,null==(e=null==X?void 0:X.destroy)||e.call(X),X=null}),(e,n)=>(i(),d("div",{ref_key:"containerEl",ref:W,class:"math-block text-center overflow-x-auto relative","data-markstream-math":"block","data-markstream-mode":P.value?"katex":z.value?"fallback":"loading","data-markstream-pending":Q.value?"true":void 0,style:c(Y.value?{minHeight:`${Y.value}px`}:void 0)},[v(s,{name:"math-fade"},{default:m(()=>[!J.value||P.value||z.value?h("",!0):(i(),d("div",K,[...n[0]||(n[0]=[f("div",{class:"math-loading-spinner"},null,-1)])]))]),_:1}),P.value?(i(),d("div",{key:0,class:g(["math-block__content",{"math-rendering":J.value}]),innerHTML:P.value},null,10,I)):z.value?(i(),d("pre",j,k(z.value),1)):(i(),d("div",{key:2,class:g(["math-block__content",{"math-rendering":J.value}])},null,2))],12,H))}}),[["__scopeId","data-v-38e7acf6"]]);W.install=e=>{e.component(W.__name,W)};export{W as default};
|
package/dist/index6.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=(e,a,n)=>new Promise((l,t)=>{var r=e=>{try{i(n.next(e))}catch(a){t(a)}},o=e=>{try{i(n.throw(e))}catch(a){t(a)}},i=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,o);i((n=n.apply(e,a)).next())});import{defineComponent as a,ref as n,computed as l,watch as t,onMounted as r,onBeforeUnmount as o,openBlock as i,createElementBlock as u,toDisplayString as s,createBlock as d,Transition as v,withCtx as c,createElementVNode as m,renderSlot as f,createCommentVNode as h}from"vue";import{
|
|
1
|
+
var e=(e,a,n)=>new Promise((l,t)=>{var r=e=>{try{i(n.next(e))}catch(a){t(a)}},o=e=>{try{i(n.throw(e))}catch(a){t(a)}},i=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,o);i((n=n.apply(e,a)).next())});import{defineComponent as a,ref as n,computed as l,watch as t,onMounted as r,onBeforeUnmount as o,openBlock as i,createElementBlock as u,toDisplayString as s,createBlock as d,Transition as v,withCtx as c,createElementVNode as m,renderSlot as f,createCommentVNode as h}from"vue";import{al as p,y as g}from"./exports.js";import{n as k,f as y,j as _,b as w,k as x,W as b}from"./workers-katexWorkerClient.js";const T=["data-markstream-mode","data-markstream-pending"],E=["innerHTML"],R={key:1,class:"math-inline math-inline--fallback"},I={class:"math-inline__loading",role:"status","aria-live":"polite"},M=/* @__PURE__ */g(/* @__PURE__ */a({__name:"MathInlineNode",props:{node:{}},setup(a){const g=a,M=n(null),O=l(()=>"$$"===g.node.markup),L=l(()=>k(g.node.content)),W=function(){if(!g.node.content)return{html:"",text:g.node.raw,loading:!1};const e=y();if(!e)return{html:"",text:g.node.raw,loading:!1};try{return{html:e.renderToString(L.value,{throwOnError:g.node.loading,displayMode:O.value}),text:"",loading:!1}}catch(a){return{html:"",text:g.node.raw,loading:!1}}}(),j=n(W.html),A=n(W.text);let K=!1,S=0,$=!1,C=null;const D=n(W.loading),H=n(!1),N=p();let P=null;function B(e){null!=e&&e!==S||(H.value=!1)}function U(){return e(this,null,function*(){if($)return;C&&(C.abort(),C=null);const a=++S;if(!g.node.content)return B(),D.value=!1,j.value="",A.value=g.node.raw,void(K=!0);const n=new AbortController;if(C=n,H.value=!0,!K)try{!P&&M.value&&(P=N(M.value)),yield null==P?void 0:P.whenVisible}catch(l){}$||a!==S||n.signal.aborted?B(a):_(L.value,O.value,{timeout:1500,waitTimeout:0,maxRetries:0,signal:n.signal}).then(e=>{$||a!==S||(j.value=e,A.value="",D.value=!1,K=!0)}).catch(n=>e(null,null,function*(){if($||a!==S)return;const e=(null==n?void 0:n.code)||(null==n?void 0:n.name),t="KATEX_DISABLED"===e;if("WORKER_INIT_ERROR"===e||(null==n?void 0:n.fallbackToRenderer)||e===b||"WORKER_TIMEOUT"===e){const e=yield w();if($||a!==S)return;if(e){try{const a=e.renderToString(L.value,{throwOnError:g.node.loading,displayMode:O.value});j.value=a,A.value="",D.value=!1,K=!0,x(L.value,O.value,a)}catch(l){}return}}if(t||!g.node.loading)return D.value=!1,j.value="",void(A.value=g.node.raw);K||(D.value=!0)})).finally(()=>{$||B(a)})})}return(W.html||W.text)&&(K=!0),t(()=>g.node.content,()=>{U()}),r(()=>{j.value||U()}),o(()=>{var e;$=!0,C&&(C.abort(),C=null),null==(e=null==P?void 0:P.destroy)||e.call(P),P=null}),(e,a)=>(i(),u("span",{ref_key:"containerEl",ref:M,class:"math-inline-wrapper","data-markstream-math":"inline","data-markstream-mode":j.value?"katex":A.value?"fallback":"loading","data-markstream-pending":H.value?"true":void 0},[j.value?(i(),u("span",{key:0,class:"math-inline",innerHTML:j.value},null,8,E)):A.value?(i(),u("span",R,s(A.value),1)):D.value?(i(),d(v,{key:2,name:"table-node-fade"},{default:c(()=>[m("span",I,[f(e.$slots,"loading",{isLoading:D.value},()=>[a[0]||(a[0]=m("span",{class:"math-inline__spinner animate-spin","aria-hidden":"true"},null,-1)),a[1]||(a[1]=m("span",{class:"sr-only"},"Loading",-1))],!0)])]),_:3})):h("",!0)],8,T))}}),[["__scopeId","data-v-7b64afc7"]]);M.install=e=>{e.component(M.__name,M)};export{M as default};
|
package/dist/index7.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,r=(t,o,n)=>o in t?e(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,l=(e,l)=>{for(var a in l||(l={}))o.call(l,a)&&r(e,a,l[a]);if(t)for(var a of t(l))n.call(l,a)&&r(e,a,l[a]);return e},a=(e,t,o)=>new Promise((n,r)=>{var l=e=>{try{i(o.next(e))}catch(t){r(t)}},a=e=>{try{i(o.throw(e))}catch(t){r(t)}},i=e=>e.done?n(e.value):Promise.resolve(e.value).then(l,a);i((o=o.apply(e,t)).next())});import{defineComponent as i,useAttrs as u,inject as s,ref as d,computed as c,watch as v,nextTick as m,onMounted as p,onBeforeUnmount as f,openBlock as g,createElementBlock as y,normalizeClass as h,createElementVNode as w,unref as b,toDisplayString as k,createCommentVNode as x,normalizeStyle as B,withDirectives as D,vShow as C}from"vue";import{ap as M,ar as E,ah as A,am as T,a9 as j,a0 as O,y as H}from"./exports.js";import{M as F}from"./index2.js";const S=["data-markstream-mode"],I={key:0,class:"d2-block-header flex justify-between items-center border-b"},L={class:"d2-header-actions flex items-center"},N={key:0,class:"d2-mode-toggle flex items-center gap-0.5"},P=["aria-label"],R={key:0,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},_={key:1,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},$=["aria-label"],U=["aria-pressed"],V={key:0,class:"d2-source"},X={class:"d2-code"},Y={key:0,class:"d2-error mt-2 text-xs"},q={key:1},z={key:0,class:"d2-source"},G={class:"d2-code"},J={key:0,class:"d2-error mt-2 text-xs"},K=["innerHTML"],Q={key:0,class:"d2-error px-4 pb-3 text-xs"},W=/* @__PURE__ */H(/* @__PURE__ */i({__name:"D2BlockNode",props:{node:{},maxHeight:{default:void 0},loading:{type:Boolean,default:!0},isDark:{type:Boolean},progressiveRender:{type:Boolean,default:!0},progressiveIntervalMs:{default:700},themeId:{},darkThemeId:{},showHeader:{type:Boolean,default:!0},showModeToggle:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExportButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0}},setup(e){const t=e,o=u(),n=s(F,null),{t:r}=M(),i=d(!1),H=d(!1),W=d(!1),Z=d(!1),ee=d(null),te=d(!1),oe=d(""),ne=d(0),re=d(null),le=d(null),ae=d(null),ie=E(),ue=d(null),se=d("undefined"==typeof window),de=c(()=>{var e;return null!=(e=t.node.code)?e:""}),ce=c(()=>A(t,o)),ve=c(()=>`${t.isDark?"dark":"light"}:${de.value}`),me=c(()=>W.value||!Z.value||!oe.value),pe=c(()=>!!oe.value),fe=c(()=>{if(me.value&&le.value)return{minHeight:`${le.value}px`}}),ge=c(()=>"none"===t.maxHeight?{maxHeight:"none"}:null!=t.maxHeight?{maxHeight:"number"==typeof t.maxHeight?`${t.maxHeight}px`:String(t.maxHeight)}:void 0),ye="undefined"!=typeof window;let he=null,we=!1,be=!1,ke=0,xe=null,Be=!1,De=null,Ce="",Me="";"undefined"!=typeof window&&v(()=>ae.value,e=>{var t;if(null==(t=ue.value)||t.destroy(),ue.value=null,!e)return void(se.value=!1);const o=ie(e,{rootMargin:"160px"});ue.value=o,se.value=o.isVisible.value,o.whenVisible.then(()=>{se.value=!0})},{immediate:!0});const Ee={N1:"#E5E7EB",N2:"#CBD5E1",N3:"#94A3B8",N4:"#64748B",N5:"#475569",N6:"#334155",N7:"#0B1220",B1:"#60A5FA",B2:"#3B82F6",B3:"#2563EB",B4:"#1D4ED8",B5:"#1E40AF",B6:"#111827",AA2:"#22D3EE",AA4:"#0EA5E9",AA5:"#0284C7",AB4:"#FBBF24",AB5:"#F59E0B"};function Ae(e){return!e||e.disabled}function Te(e,o,n="top"){if(Ae(e.currentTarget))return;const r=e,l=null!=(null==r?void 0:r.clientX)&&null!=(null==r?void 0:r.clientY)?{x:r.clientX,y:r.clientY}:void 0;T(e.currentTarget,o,n,!1,l,t.isDark)}function je(){j()}function Oe(e){if(Ae(e.currentTarget))return;const o=i.value?r("common.copied")||"Copied":r("common.copy")||"Copy",n=e,l=null!=(null==n?void 0:n.clientX)&&null!=(null==n?void 0:n.clientY)?{x:n.clientX,y:n.clientY}:void 0;T(e.currentTarget,o,"top",!1,l,t.isDark)}function He(){return a(this,null,function*(){try{const e=de.value;"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(e)),i.value=!0,setTimeout(()=>{i.value=!1},1e3)}catch(e){console.error("Copy failed:",e)}})}function Fe(){H.value=!H.value}function Se(e){W.value="source"===e}const Ie=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],Le=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function Ne(e){if(!e)return"";const t=e.trim();return Le.test(t)?t:""}function Pe(){oe.value=""}function Re(){return a(this,null,function*(){var e,o,r,i,u;if(!ye||be)return;if(!se.value)return;if(t.loading&&!t.progressiveRender)return;const s=ve.value;if(s===Ce&&!ee.value&&oe.value)return Z.value=!0,void(t.loading&&(W.value=!1));const d=de.value;if(!d)return Pe(),ee.value=null,void(Ce="");const c=++ne.value;te.value=!0,ee.value=null,function(){const e=ce.value;n&&e&&Me!==e&&(Me&&n.markSettled(Me),Me=e,n.markPending(e))}();try{const n=yield function(){return a(this,null,function*(){if(he)return he;const e=yield O();if(!e)return null;if("function"==typeof e){const t=new e;return t&&"function"==typeof t.compile?he=t:"function"==typeof e.compile&&(he=e),he}return(null==e?void 0:e.D2)&&"function"==typeof e.D2?(he=new e.D2,he):("function"==typeof e.compile&&(he=e),he)})}();if(!n)return Z.value=!1,W.value=!0,Pe(),void(ee.value="D2 is not available.");if("function"!=typeof n.compile||"function"!=typeof n.render)throw new TypeError("D2 instance is missing compile/render methods.");Z.value=!0;const v=yield n.compile(d);if(c!==ne.value)return;const m=null!=(e=null==v?void 0:v.diagram)?e:v,p=null!=(r=null!=(o=null==v?void 0:v.renderOptions)?o:null==v?void 0:v.options)?r:{},f=null!=(i=t.themeId)?i:p.themeID,g=null!=(u=t.darkThemeId)?u:p.darkThemeID,y=l({},p);if(y.themeID=t.isDark&&null!=g?g:f,y.darkThemeID=null,y.darkThemeOverrides=null,t.isDark){const e=p.themeOverrides&&"object"==typeof p.themeOverrides?p.themeOverrides:null;y.themeOverrides=l(l({},Ee),e||{})}const h=yield n.render(m,y);if(c!==ne.value)return;const w=function(e){return e?"string"==typeof e?e:"string"==typeof e.svg?e.svg:"string"==typeof e.data?e.data:"":""}(h);if(!w)throw new Error("D2 render returned empty output.");!function(e){const t=function(e){if("undefined"==typeof window||"undefined"==typeof DOMParser)return"";if(!e)return"";const t=e.replace(/["']\s*javascript:/gi,"#").replace(/\bjavascript:/gi,"#").replace(/["']\s*vbscript:/gi,"#").replace(/\bvbscript:/gi,"#").replace(/\bdata:text\/html/gi,"#"),o=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!o||"svg"!==o.nodeName.toLowerCase())return"";const n=o;return function(e){const t=/* @__PURE__ */new Set(["script"]),o=[e,...Array.from(e.querySelectorAll("*"))];for(const n of o){if(t.has(n.tagName.toLowerCase())){n.remove();continue}const e=Array.from(n.attributes);for(const t of e){const e=t.name;if(/^on/i.test(e))n.removeAttribute(e);else{if("style"===e&&t.value){const o=t.value;if(Ie.some(e=>e.test(o))){n.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&t.value){const o=Ne(t.value);if(!o){n.removeAttribute(e);continue}o!==t.value&&n.setAttribute(e,o)}}}}}(n),n.classList.add("markstream-d2-root-svg"),n.outerHTML}(e);oe.value=t||""}(w),Ce=s,t.loading&&(W.value=!1),ee.value=null}catch(v){if(c!==ne.value)return;const e=(null==v?void 0:v.message)?String(v.message):"D2 render failed.";t.loading||(ee.value=e),Ce="",e.includes("@terrastruct/d2")&&(Z.value=!1,W.value=!0)}finally{c===ne.value&&(te.value=!1,Be?(Be=!1,_e()):function(){const e=Me;n&&e&&(Me="",m(()=>{var t,o;if(!be){const r=null!=(o=null==(t=ae.value)?void 0:t.offsetHeight)?o:0;r>0&&n.reportHeight(e,r)}n.markSettled(e)}))}())}})}function _e(e=!1){if(we)return;if(!ye)return;if(be)return;if(te.value)return void(Be=!0);const o=Math.max(120,Number(t.progressiveIntervalMs)||0),n=Date.now()-ke;if(!e&&n<o)return Be=!0,void(null==xe&&(xe=window.setTimeout(()=>{xe=null,Be&&(Be=!1,_e(!0))},Math.max(0,o-n))));we=!0;const r=()=>{we=!1,ke=Date.now(),Re()};"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(r):setTimeout(r,0)}function $e(){if(oe.value)try{const e=new Blob([oe.value],{type:"image/svg+xml;charset=utf-8"}),t=URL.createObjectURL(e);if("undefined"!=typeof document){const e=document.createElement("a");e.href=t,e.download=`d2-diagram-${Date.now()}.svg`,document.body.appendChild(e),e.click(),document.body.removeChild(e)}URL.revokeObjectURL(t)}catch(e){console.error("Failed to export SVG:",e)}}function Ue(){const e=re.value;if(!e)return;const t=e.getBoundingClientRect().height;t>0&&(le.value=t)}return v(()=>[t.node.code,t.loading,t.isDark],()=>{_e()},{immediate:!0}),v(()=>t.loading,(e,t)=>{t&&!e&&_e(!0)}),v(()=>se.value,e=>{e&&_e(!0)}),v(()=>[me.value,oe.value,de.value],()=>{m(()=>{Ue()})}),p(()=>{m(()=>{Ue()}),"undefined"!=typeof ResizeObserver&&(De=new ResizeObserver(()=>{Ue()}),re.value&&De.observe(re.value))}),f(()=>{var e;be=!0,function(){const e=Me;n&&e&&(Me="",n.markSettled(e))}(),Ce="",null==(e=ue.value)||e.destroy(),ue.value=null,null!=xe&&(clearTimeout(xe),xe=null),null==De||De.disconnect(),De=null}),(e,o)=>(g(),y("div",{ref_key:"viewportTarget",ref:ae,class:h(["d2-block-container rounded-lg border overflow-hidden",{dark:t.isDark}]),"data-markstream-d2":"1","data-markstream-mode":me.value?"fallback":"preview"},[t.showHeader?(g(),y("div",I,[o[16]||(o[16]=w("div",{class:"flex items-center gap-x-2"},[w("span",{class:"d2-label font-medium font-mono"},"D2")],-1)),w("div",L,[t.showModeToggle?(g(),y("div",N,[w("button",{type:"button",class:h(["mode-btn px-2 py-0.5 rounded",W.value?"":"is-active"]),onClick:o[0]||(o[0]=e=>Se("preview")),onMouseenter:o[1]||(o[1]=e=>Te(e,b(r)("common.preview")||"Preview")),onFocus:o[2]||(o[2]=e=>Te(e,b(r)("common.preview")||"Preview")),onMouseleave:je,onBlur:je},k(b(r)("common.preview")||"Preview"),35),w("button",{type:"button",class:h(["mode-btn px-2 py-0.5 rounded",W.value?"is-active":""]),onClick:o[3]||(o[3]=e=>Se("source")),onMouseenter:o[4]||(o[4]=e=>Te(e,b(r)("common.source")||"Source")),onFocus:o[5]||(o[5]=e=>Te(e,b(r)("common.source")||"Source")),onMouseleave:je,onBlur:je},k(b(r)("common.source")||"Source"),35)])):x("",!0),t.showCopyButton?(g(),y("button",{key:1,type:"button",class:"d2-action-btn p-[var(--ms-action-btn-padding)] rounded-md","aria-label":i.value?b(r)("common.copied")||"Copied":b(r)("common.copy")||"Copy",onClick:He,onMouseenter:o[6]||(o[6]=e=>Oe(e)),onFocus:o[7]||(o[7]=e=>Oe(e)),onMouseleave:je,onBlur:je},[i.value?(g(),y("svg",_,[...o[13]||(o[13]=[w("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(g(),y("svg",R,[...o[12]||(o[12]=[w("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[w("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),w("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],40,P)):x("",!0),t.showExportButton&&oe.value?(g(),y("button",{key:2,type:"button",class:"d2-action-btn p-[var(--ms-action-btn-padding)] rounded-md","aria-label":b(r)("common.export")||"Export",onClick:$e,onMouseenter:o[8]||(o[8]=e=>Te(e,b(r)("common.export")||"Export")),onFocus:o[9]||(o[9]=e=>Te(e,b(r)("common.export")||"Export")),onMouseleave:je,onBlur:je},[...o[14]||(o[14]=[w("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[w("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 3v12m0-12l-4 4m4-4l4 4M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4"})],-1)])],40,$)):x("",!0),t.showCollapseButton?(g(),y("button",{key:3,type:"button",class:"d2-action-btn p-[var(--ms-action-btn-padding)] rounded-md","aria-pressed":H.value,onClick:Fe,onMouseenter:o[10]||(o[10]=e=>Te(e,H.value?b(r)("common.expand")||"Expand":b(r)("common.collapse")||"Collapse")),onFocus:o[11]||(o[11]=e=>Te(e,H.value?b(r)("common.expand")||"Expand":b(r)("common.collapse")||"Collapse")),onMouseleave:je,onBlur:je},[(g(),y("svg",{style:B({rotate:H.value?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[...o[15]||(o[15]=[w("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,U)):x("",!0)])])):x("",!0),D(w("div",{ref_key:"bodyRef",ref:re,class:"d2-block-body",style:B(fe.value)},[t.loading&&!pe.value?(g(),y("div",V,[w("pre",X,[w("code",null,k(de.value),1)]),ee.value?(g(),y("p",Y,k(ee.value),1)):x("",!0)])):(g(),y("div",q,[me.value?(g(),y("div",z,[w("pre",G,[w("code",null,k(de.value),1)]),ee.value?(g(),y("p",J,k(ee.value),1)):x("",!0)])):(g(),y("div",{key:1,class:"d2-render",style:B(ge.value)},[w("div",{class:"d2-svg",innerHTML:oe.value},null,8,K),ee.value?(g(),y("p",Q,k(ee.value),1)):x("",!0)],4))]))],4),[[C,!H.value]])],10,S))}}),[["__scopeId","data-v-1b958e6b"]]);W.install=e=>{e.component(W.__name,W)};export{W as default};
|
|
1
|
+
var e=Object.defineProperty,t=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,r=(t,o,n)=>o in t?e(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,l=(e,l)=>{for(var a in l||(l={}))o.call(l,a)&&r(e,a,l[a]);if(t)for(var a of t(l))n.call(l,a)&&r(e,a,l[a]);return e},a=(e,t,o)=>new Promise((n,r)=>{var l=e=>{try{i(o.next(e))}catch(t){r(t)}},a=e=>{try{i(o.throw(e))}catch(t){r(t)}},i=e=>e.done?n(e.value):Promise.resolve(e.value).then(l,a);i((o=o.apply(e,t)).next())});import{defineComponent as i,useAttrs as u,inject as s,ref as d,computed as c,watch as v,nextTick as m,onMounted as p,onBeforeUnmount as f,openBlock as g,createElementBlock as y,normalizeClass as h,createElementVNode as w,unref as b,toDisplayString as k,createCommentVNode as x,normalizeStyle as B,withDirectives as D,vShow as C}from"vue";import{aj as M,al as E,ab as A,ag as T,a4 as j,X as O,y as H}from"./exports.js";import{M as F}from"./index2.js";const S=["data-markstream-mode"],I={key:0,class:"d2-block-header flex justify-between items-center border-b"},L={class:"d2-header-actions flex items-center"},N={key:0,class:"d2-mode-toggle flex items-center gap-0.5"},P=["aria-label"],R={key:0,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},_={key:1,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},X=["aria-label"],$=["aria-pressed"],U={key:0,class:"d2-source"},V={class:"d2-code"},Y={key:0,class:"d2-error mt-2 text-xs"},q={key:1},z={key:0,class:"d2-source"},G={class:"d2-code"},J={key:0,class:"d2-error mt-2 text-xs"},K=["innerHTML"],Q={key:0,class:"d2-error px-4 pb-3 text-xs"},W=/* @__PURE__ */H(/* @__PURE__ */i({__name:"D2BlockNode",props:{node:{},maxHeight:{default:void 0},loading:{type:Boolean,default:!0},isDark:{type:Boolean},progressiveRender:{type:Boolean,default:!0},progressiveIntervalMs:{default:700},themeId:{},darkThemeId:{},showHeader:{type:Boolean,default:!0},showModeToggle:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExportButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0}},setup(e){const t=e,o=u(),n=s(F,null),{t:r}=M(),i=d(!1),H=d(!1),W=d(!1),Z=d(!1),ee=d(null),te=d(!1),oe=d(""),ne=d(0),re=d(null),le=d(null),ae=d(null),ie=E(),ue=d(null),se=d("undefined"==typeof window),de=c(()=>{var e;return null!=(e=t.node.code)?e:""}),ce=c(()=>A(t,o)),ve=c(()=>`${t.isDark?"dark":"light"}:${de.value}`),me=c(()=>W.value||!Z.value||!oe.value),pe=c(()=>!!oe.value),fe=c(()=>{if(me.value&&le.value)return{minHeight:`${le.value}px`}}),ge=c(()=>"none"===t.maxHeight?{maxHeight:"none"}:null!=t.maxHeight?{maxHeight:"number"==typeof t.maxHeight?`${t.maxHeight}px`:String(t.maxHeight)}:void 0),ye="undefined"!=typeof window;let he=null,we=!1,be=!1,ke=0,xe=null,Be=!1,De=null,Ce="",Me="";"undefined"!=typeof window&&v(()=>ae.value,e=>{var t;if(null==(t=ue.value)||t.destroy(),ue.value=null,!e)return void(se.value=!1);const o=ie(e,{rootMargin:"160px"});ue.value=o,se.value=o.isVisible.value,o.whenVisible.then(()=>{se.value=!0})},{immediate:!0});const Ee={N1:"#E5E7EB",N2:"#CBD5E1",N3:"#94A3B8",N4:"#64748B",N5:"#475569",N6:"#334155",N7:"#0B1220",B1:"#60A5FA",B2:"#3B82F6",B3:"#2563EB",B4:"#1D4ED8",B5:"#1E40AF",B6:"#111827",AA2:"#22D3EE",AA4:"#0EA5E9",AA5:"#0284C7",AB4:"#FBBF24",AB5:"#F59E0B"};function Ae(e){return!e||e.disabled}function Te(e,o,n="top"){if(Ae(e.currentTarget))return;const r=e,l=null!=(null==r?void 0:r.clientX)&&null!=(null==r?void 0:r.clientY)?{x:r.clientX,y:r.clientY}:void 0;T(e.currentTarget,o,n,!1,l,t.isDark)}function je(){j()}function Oe(e){if(Ae(e.currentTarget))return;const o=i.value?r("common.copied")||"Copied":r("common.copy")||"Copy",n=e,l=null!=(null==n?void 0:n.clientX)&&null!=(null==n?void 0:n.clientY)?{x:n.clientX,y:n.clientY}:void 0;T(e.currentTarget,o,"top",!1,l,t.isDark)}function He(){return a(this,null,function*(){try{const e=de.value;"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(e)),i.value=!0,setTimeout(()=>{i.value=!1},1e3)}catch(e){console.error("Copy failed:",e)}})}function Fe(){H.value=!H.value}function Se(e){W.value="source"===e}const Ie=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],Le=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function Ne(e){if(!e)return"";const t=e.trim();return Le.test(t)?t:""}function Pe(){oe.value=""}function Re(){return a(this,null,function*(){var e,o,r,i,u;if(!ye||be)return;if(!se.value)return;if(t.loading&&!t.progressiveRender)return;const s=ve.value;if(s===Ce&&!ee.value&&oe.value)return Z.value=!0,void(t.loading&&(W.value=!1));const d=de.value;if(!d)return Pe(),ee.value=null,void(Ce="");const c=++ne.value;te.value=!0,ee.value=null,function(){const e=ce.value;n&&e&&Me!==e&&(Me&&n.markSettled(Me),Me=e,n.markPending(e))}();try{const n=yield function(){return a(this,null,function*(){if(he)return he;const e=yield O();if(!e)return null;if("function"==typeof e){const t=new e;return t&&"function"==typeof t.compile?he=t:"function"==typeof e.compile&&(he=e),he}return(null==e?void 0:e.D2)&&"function"==typeof e.D2?(he=new e.D2,he):("function"==typeof e.compile&&(he=e),he)})}();if(!n)return Z.value=!1,W.value=!0,Pe(),void(ee.value="D2 is not available.");if("function"!=typeof n.compile||"function"!=typeof n.render)throw new TypeError("D2 instance is missing compile/render methods.");Z.value=!0;const v=yield n.compile(d);if(c!==ne.value)return;const m=null!=(e=null==v?void 0:v.diagram)?e:v,p=null!=(r=null!=(o=null==v?void 0:v.renderOptions)?o:null==v?void 0:v.options)?r:{},f=null!=(i=t.themeId)?i:p.themeID,g=null!=(u=t.darkThemeId)?u:p.darkThemeID,y=l({},p);if(y.themeID=t.isDark&&null!=g?g:f,y.darkThemeID=null,y.darkThemeOverrides=null,t.isDark){const e=p.themeOverrides&&"object"==typeof p.themeOverrides?p.themeOverrides:null;y.themeOverrides=l(l({},Ee),e||{})}const h=yield n.render(m,y);if(c!==ne.value)return;const w=function(e){return e?"string"==typeof e?e:"string"==typeof e.svg?e.svg:"string"==typeof e.data?e.data:"":""}(h);if(!w)throw new Error("D2 render returned empty output.");!function(e){const t=function(e){if("undefined"==typeof window||"undefined"==typeof DOMParser)return"";if(!e)return"";const t=e.replace(/["']\s*javascript:/gi,"#").replace(/\bjavascript:/gi,"#").replace(/["']\s*vbscript:/gi,"#").replace(/\bvbscript:/gi,"#").replace(/\bdata:text\/html/gi,"#"),o=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!o||"svg"!==o.nodeName.toLowerCase())return"";const n=o;return function(e){const t=/* @__PURE__ */new Set(["script"]),o=[e,...Array.from(e.querySelectorAll("*"))];for(const n of o){if(t.has(n.tagName.toLowerCase())){n.remove();continue}const e=Array.from(n.attributes);for(const t of e){const e=t.name;if(/^on/i.test(e))n.removeAttribute(e);else{if("style"===e&&t.value){const o=t.value;if(Ie.some(e=>e.test(o))){n.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&t.value){const o=Ne(t.value);if(!o){n.removeAttribute(e);continue}o!==t.value&&n.setAttribute(e,o)}}}}}(n),n.classList.add("markstream-d2-root-svg"),n.outerHTML}(e);oe.value=t||""}(w),Ce=s,t.loading&&(W.value=!1),ee.value=null}catch(v){if(c!==ne.value)return;const e=(null==v?void 0:v.message)?String(v.message):"D2 render failed.";t.loading||(ee.value=e),Ce="",e.includes("@terrastruct/d2")&&(Z.value=!1,W.value=!0)}finally{c===ne.value&&(te.value=!1,Be?(Be=!1,_e()):function(){const e=Me;n&&e&&(Me="",m(()=>{var t,o;if(!be){const r=null!=(o=null==(t=ae.value)?void 0:t.offsetHeight)?o:0;r>0&&n.reportHeight(e,r)}n.markSettled(e)}))}())}})}function _e(e=!1){if(we)return;if(!ye)return;if(be)return;if(te.value)return void(Be=!0);const o=Math.max(120,Number(t.progressiveIntervalMs)||0),n=Date.now()-ke;if(!e&&n<o)return Be=!0,void(null==xe&&(xe=window.setTimeout(()=>{xe=null,Be&&(Be=!1,_e(!0))},Math.max(0,o-n))));we=!0;const r=()=>{we=!1,ke=Date.now(),Re()};"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(r):setTimeout(r,0)}function Xe(){if(oe.value)try{const e=new Blob([oe.value],{type:"image/svg+xml;charset=utf-8"}),t=URL.createObjectURL(e);if("undefined"!=typeof document){const e=document.createElement("a");e.href=t,e.download=`d2-diagram-${Date.now()}.svg`,document.body.appendChild(e),e.click(),document.body.removeChild(e)}URL.revokeObjectURL(t)}catch(e){console.error("Failed to export SVG:",e)}}function $e(){const e=re.value;if(!e)return;const t=e.getBoundingClientRect().height;t>0&&(le.value=t)}return v(()=>[t.node.code,t.loading,t.isDark],()=>{_e()},{immediate:!0}),v(()=>t.loading,(e,t)=>{t&&!e&&_e(!0)}),v(()=>se.value,e=>{e&&_e(!0)}),v(()=>[me.value,oe.value,de.value],()=>{m(()=>{$e()})}),p(()=>{m(()=>{$e()}),"undefined"!=typeof ResizeObserver&&(De=new ResizeObserver(()=>{$e()}),re.value&&De.observe(re.value))}),f(()=>{var e;be=!0,function(){const e=Me;n&&e&&(Me="",n.markSettled(e))}(),Ce="",null==(e=ue.value)||e.destroy(),ue.value=null,null!=xe&&(clearTimeout(xe),xe=null),null==De||De.disconnect(),De=null}),(e,o)=>(g(),y("div",{ref_key:"viewportTarget",ref:ae,class:h(["d2-block-container rounded-lg border overflow-hidden",{dark:t.isDark}]),"data-markstream-d2":"1","data-markstream-mode":me.value?"fallback":"preview"},[t.showHeader?(g(),y("div",I,[o[16]||(o[16]=w("div",{class:"flex items-center gap-x-2"},[w("span",{class:"d2-label font-medium font-mono"},"D2")],-1)),w("div",L,[t.showModeToggle?(g(),y("div",N,[w("button",{type:"button",class:h(["mode-btn px-2 py-0.5 rounded",W.value?"":"is-active"]),onClick:o[0]||(o[0]=e=>Se("preview")),onMouseenter:o[1]||(o[1]=e=>Te(e,b(r)("common.preview")||"Preview")),onFocus:o[2]||(o[2]=e=>Te(e,b(r)("common.preview")||"Preview")),onMouseleave:je,onBlur:je},k(b(r)("common.preview")||"Preview"),35),w("button",{type:"button",class:h(["mode-btn px-2 py-0.5 rounded",W.value?"is-active":""]),onClick:o[3]||(o[3]=e=>Se("source")),onMouseenter:o[4]||(o[4]=e=>Te(e,b(r)("common.source")||"Source")),onFocus:o[5]||(o[5]=e=>Te(e,b(r)("common.source")||"Source")),onMouseleave:je,onBlur:je},k(b(r)("common.source")||"Source"),35)])):x("",!0),t.showCopyButton?(g(),y("button",{key:1,type:"button",class:"d2-action-btn p-[var(--ms-action-btn-padding)] rounded-md","aria-label":i.value?b(r)("common.copied")||"Copied":b(r)("common.copy")||"Copy",onClick:He,onMouseenter:o[6]||(o[6]=e=>Oe(e)),onFocus:o[7]||(o[7]=e=>Oe(e)),onMouseleave:je,onBlur:je},[i.value?(g(),y("svg",_,[...o[13]||(o[13]=[w("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(g(),y("svg",R,[...o[12]||(o[12]=[w("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[w("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),w("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],40,P)):x("",!0),t.showExportButton&&oe.value?(g(),y("button",{key:2,type:"button",class:"d2-action-btn p-[var(--ms-action-btn-padding)] rounded-md","aria-label":b(r)("common.export")||"Export",onClick:Xe,onMouseenter:o[8]||(o[8]=e=>Te(e,b(r)("common.export")||"Export")),onFocus:o[9]||(o[9]=e=>Te(e,b(r)("common.export")||"Export")),onMouseleave:je,onBlur:je},[...o[14]||(o[14]=[w("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[w("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 3v12m0-12l-4 4m4-4l4 4M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4"})],-1)])],40,X)):x("",!0),t.showCollapseButton?(g(),y("button",{key:3,type:"button",class:"d2-action-btn p-[var(--ms-action-btn-padding)] rounded-md","aria-pressed":H.value,onClick:Fe,onMouseenter:o[10]||(o[10]=e=>Te(e,H.value?b(r)("common.expand")||"Expand":b(r)("common.collapse")||"Collapse")),onFocus:o[11]||(o[11]=e=>Te(e,H.value?b(r)("common.expand")||"Expand":b(r)("common.collapse")||"Collapse")),onMouseleave:je,onBlur:je},[(g(),y("svg",{style:B({rotate:H.value?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[...o[15]||(o[15]=[w("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,$)):x("",!0)])])):x("",!0),D(w("div",{ref_key:"bodyRef",ref:re,class:"d2-block-body",style:B(fe.value)},[t.loading&&!pe.value?(g(),y("div",U,[w("pre",V,[w("code",null,k(de.value),1)]),ee.value?(g(),y("p",Y,k(ee.value),1)):x("",!0)])):(g(),y("div",q,[me.value?(g(),y("div",z,[w("pre",G,[w("code",null,k(de.value),1)]),ee.value?(g(),y("p",J,k(ee.value),1)):x("",!0)])):(g(),y("div",{key:1,class:"d2-render",style:B(ge.value)},[w("div",{class:"d2-svg",innerHTML:oe.value},null,8,K),ee.value?(g(),y("p",Q,k(ee.value),1)):x("",!0)],4))]))],4),[[C,!H.value]])],10,S))}}),[["__scopeId","data-v-1b958e6b"]]);W.install=e=>{e.component(W.__name,W)};export{W as default};
|
package/dist/index8.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,n=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,l=(n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,a=(e,a)=>{for(var r in a||(a={}))t.call(a,r)&&l(e,r,a[r]);if(n)for(var r of n(a))o.call(a,r)&&l(e,r,a[r]);return e},r=(e,n,t)=>new Promise((o,l)=>{var a=e=>{try{i(t.next(e))}catch(n){l(n)}},r=e=>{try{i(t.throw(e))}catch(n){l(n)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(a,r);i((t=t.apply(e,n)).next())});import{defineComponent as i,ref as u,shallowRef as s,watch as d,computed as c,onMounted as v,onBeforeUnmount as f,nextTick as h,openBlock as p,createElementBlock as g,normalizeClass as y,normalizeStyle as m,createVNode as w,createSlots as k,withCtx as b,createElementVNode as x,createCommentVNode as B,renderSlot as C,toDisplayString as S}from"vue";import{getHighlightRegistrationKey as T,getRuntimeShikiRegistrationConfig as H,normalizeShikiLanguage as M,registerHighlightOnce as _}from"markstream-core";import{ap as F,ar as L,a9 as O,am as P,ab as $,y as z}from"./exports.js";import{c as N,l as D,g as j,n as E}from"./index2.js";import{_ as I}from"./CodeBlockShell.vue_vue_type_style_index_0_lang.js";const W={class:"code-header-main"},R=["innerHTML"],U={class:"code-header-copy"},V={class:"code-header-title"},q=["innerHTML"],A=/* @__PURE__ */z(/* @__PURE__ */i({__name:"MarkdownCodeBlockNode",props:{node:{},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},darkTheme:{default:"vitesse-dark"},lightTheme:{default:"vitesse-light"},isDark:{type:Boolean,default:!1},isShowPreview:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},autoScrollOnUpdate:{type:Boolean,default:!0},autoScrollInitial:{type:Boolean,default:!0},estimatedHeightPx:{},estimatedContentHeightPx:{},themes:{},langs:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0}},emits:["previewCode","copy"],setup(e,{emit:n}){const t=e,o=n,{t:l}=F(),i=u(nn(t.node.language,t.node.code,tn())),z=u(!1),A=u(!1),G=u(!1),J=u(null),K=u(null),Q=u(null),X=u(""),Y=u(!1);let Z,ee="",ne=0,te=null;const oe=L(),le=s(null),ae=u("undefined"==typeof window);"undefined"!=typeof window&&d(()=>J.value,(e,n,t)=>{var o;if(null==(o=le.value)||o.destroy(),le.value=null,!e)return void(ae.value=!1);let l=!0;const a=oe(e,{rootMargin:"400px"});le.value=a,ae.value=a.isVisible.value,a.whenVisible.then(()=>{l&&le.value===a&&(ae.value=!0)}).catch(()=>{}),t(()=>{l=!1,a.destroy(),le.value===a&&(le.value=null)})},{immediate:!0});const re=u(!1!==t.autoScrollInitial),ie=u(0),ue=c(()=>!1!==t.autoScrollOnUpdate),se=u(14),de=u(se.value),ce=c(()=>{const e=se.value,n=de.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof n&&Number.isFinite(n)&&n>0}),ve=c(()=>{const e=i.value.trim().toLowerCase();return N[e]||e.charAt(0).toUpperCase()+e.slice(1)}),fe=c(()=>{D.value;const e=i.value.trim().toLowerCase();return j(e.split(":")[0])}),he=c(()=>{const e=i.value.trim().toLowerCase();return t.isShowPreview&&("html"===e||"svg"===e)}),pe=c(()=>{const e={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},o=n(t.minWidth),l=n(t.maxWidth);return o&&(e.minWidth=o),l&&(e.maxWidth=l),e}),ge=c(()=>{const e=t.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}),ye=c(()=>null!=ge.value&&!Y.value),me=c(()=>a({fontSize:`${de.value}px`},ye.value?{minHeight:`${ge.value}px`}:{})),we=c(()=>!1!==t.showTooltips);function ke(e,n){const t=String(null!=e?e:"");return n?t:t.replace(/\r\n$|\n$|\r$/,"")}const be=c(()=>ke(t.node.code,!0===t.node.loading));function xe(){return t.isDark?t.darkTheme:t.lightTheme}function Be(e){if(te=null,_e(),!e)return Se(),ee="",X.value="",void(Y.value=!1);var n;X.value=`<pre class="shiki shiki-fallback"><code>${n=e,n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`,Y.value=!1}function Ce(){X.value="",Y.value=!0}function Se(){Q.value&&(Q.value.innerHTML="")}function Te(){var e;const n=Q.value;return!!n&&(n.childNodes.length>0||Boolean(null==(e=n.textContent)?void 0:e.trim().length))}function He(e,n,t){return`${null!=e?e:""}\0${n}\0${t}`}function Me(e){ee=e,Ce()}function _e(e){null==e||e.disconnect(),e&&Z!==e||(Z=void 0)}function Fe(e,n){_e();const t=Q.value;if(!t||"undefined"==typeof MutationObserver)return;te=null;const o=new MutationObserver(()=>{ne+=1;const t=te;if(t)return Qe(e)?void(ne!==n&&Te()&&(te=null,_e(o),Me(t))):(te=null,void _e(o))});Z=o,o.observe(t,{childList:!0,subtree:!0,characterData:!0,attributes:!0})}function Le(e,n,t,o){return r(this,null,function*(){var l;if(te=t,yield h(),!Qe(e))return;const a=Te(),r=ne!==n,i=void 0!==o&&(null==(l=Q.value)?void 0:l.innerHTML)!==o;a&&(!ee||r||i||ee===t)&&(te=null,_e(),Me(t))})}let Oe,Pe,$e,ze=null,Ne=null,De="",je=0,Ee=0,Ie=!1;const We=/* @__PURE__ */new Set,Re=/* @__PURE__ */new Set,Ue=/* @__PURE__ */new Set,Ve=$();let qe=!1,Ae=null,Ge=!1,Je=!1;function Ke(){return Ee+=1,Ee}function Qe(e=Ee){return!Ie&&e===Ee}function Xe(){const e=Oe;Oe=void 0,ze=null,ee="",te=null,Re.clear();try{null==e||e.dispose()}catch(n){Ve&&console.warn("[MarkdownCodeBlockNode] Failed to dispose Shiki renderer.",n)}finally{Se(),Y.value=!1}}const Ye=c(()=>T(t.themes,t.langs));function Ze(){return{hasRegisterHighlight:Boolean($e),hasCreateRenderer:Boolean(Pe)}}function en(e,n){var t;const o=Ze(),l=H(e,n,o);return(null==(t=l.rendererOptions.langs)?void 0:t.length)&&Ue.has(l.key)?H(e,void 0,o):l}function nn(e,n,t){return t&&!String(null!=n?n:"")?"plain":E(String(null!=e?e:""))}function tn(){return"boolean"==typeof t.node.loading?t.node.loading:!0===t.loading}function on(e,n){return r(this,arguments,function*(e,n,t=Ee){if(!Oe||!Qe(t))return;const o=function(e){return M(e)||"plaintext"}(function(e,n,t){return t&&!String(null!=n?n:"")?"plaintext":String(null!=e?e:"")}(n,e,tn())),l=n=>r(null,null,function*(){if(Oe&&Qe(t)){"plaintext"!==o&&(n&&Re.add(o),n&&Ve&&!We.has(o)&&(We.add(o),console.warn(`[MarkdownCodeBlockNode] Failed to render language "${o}", retrying as plaintext.`,n)));try{return yield Oe.updateCode(e,"plaintext"),Qe(t)?"plaintext":void 0}catch(l){if(!Qe(t))return;return void(Ve&&console.warn("[MarkdownCodeBlockNode] Failed to render code block even as plaintext.",l))}}});if("plaintext"!==o&&Re.has(o))return l();try{return yield Oe.updateCode(e,o),Qe(t)?o:void 0}catch(a){if(!Qe(t))return;return"plaintext"!==o?l(a):void(Ve&&console.warn("[MarkdownCodeBlockNode] Failed to render code block even as plaintext.",a))}})}function ln(e,n){return r(this,null,function*(){if(!$e)return"ready";if(De!==n)return"stale";if(Ne===n)return"ready";const t=++je;try{yield _($e,e,n)}catch(o){return t!==je||De!==n?"stale":"failed"}return t!==je||De!==n?"stale":(Ne=n,"ready")})}function an(e,n){return r(this,null,function*(){const t=yield ln(e,n);return"failed"!==t?t:De!==n?"stale":ln(e,n)})}function rn(){return r(this,arguments,function*(e=Ke()){try{yield function(e){return r(this,null,function*(){var n,o;if(!Qe(e))return;const l=be.value;if(!ae.value)return void Be(l);if(yield function(){return r(this,null,function*(){if(!Pe&&!Ge)return Ae||(Ae=r(null,null,function*(){try{const e=yield import("stream-markdown"),n=e.createShikiStreamRenderer;if("function"!=typeof n)throw new TypeError("stream-markdown.createShikiStreamRenderer is not available");Pe=n;const t=e.registerHighlight;$e="function"==typeof t?t:void 0,Ge=!1,Je=!1}catch(e){Ge=!0,Ve&&!Je&&(Je=!0,console.warn("[MarkdownCodeBlockNode] stream-markdown not available:",e))}finally{Ae=null}}),Ae)})}(),!Qe(e))return;if(!K.value||!Q.value)return void Be(l);let i=en(t.themes,t.langs);i.ignoredLangs&&Ve&&!qe&&(qe=!0,console.warn("[MarkdownCodeBlockNode] `langs` requires stream-markdown >=0.0.15 with registerHighlight(); ignoring `langs` and using stream-markdown default language preload."));let u=i.rendererOptions,s=i.key;De=s;let d=Boolean(Oe&&ze!==s);d&&Be(l);let c=yield an(i.registerOptions,s);if("failed"===c&&(null==(n=u.langs)?void 0:n.length)&&(Ue.add(s),Ve&&console.warn("[MarkdownCodeBlockNode] Failed to register configured Shiki languages; retrying without `langs`.",{langs:u.langs}),i=H(t.themes,void 0,Ze()),u=i.rendererOptions,s=i.key,De=s,c=yield an(i.registerOptions,s)),!Qe(e)||"stale"===c)return;if(d=Boolean(Oe&&ze!==s),"failed"===c)return void(d&&Oe&&Te()?Ce():Be(l));if(d&&Xe(),!Oe&&Pe&&(Oe=Pe(Q.value,a({theme:xe()},u)),ze=s,Y.value=!0),!Oe)return void Be(l);if(!1===t.stream&&t.loading)return void Be(l);Be(l);const v=ne,f=null==(o=Q.value)?void 0:o.innerHTML;Fe(e,v);const h=yield on(l,t.node.language,e);Qe(e)&&(h?yield Le(e,v,He(s,h,l),f):(te=null,_e()))})}(e)}catch(n){if(!Qe(e))return;Ve&&console.warn("[MarkdownCodeBlockNode] Failed to initialize Shiki renderer.",n),Be(be.value)}})}function un(){const e=K.value;if(!e||A.value||!ue.value)return;const n=e.scrollTop;n<ie.value?re.value=!1:function(e,n=50){return e.scrollHeight-e.scrollTop-e.clientHeight<=n}(e)&&(re.value=!0),ie.value=n}function sn(){return r(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(t.node.code)),z.value=!0,o("copy",t.node.code),setTimeout(()=>{z.value=!1},1e3)}catch(e){console.error("Copy failed:",e)}})}function dn(e){if(A.value=!A.value,e&&we.value){const n=function(e){const n=e.currentTarget||e.target;return!n||n.disabled?null:n}(e);if(n){const e=A.value?l("common.collapse")||"Collapse":l("common.expand")||"Expand";P(n,e,"top",!1,void 0,t.isDark)}}const n=K.value;n&&(A.value?(n.style.maxHeight="none",n.style["overflow-y"]="visible",n.style["overflow-x"]="auto"):(n.style.maxHeight="",n.style.overflow="auto",ue.value&&(re.value=!0,h(()=>{n.scrollHeight>n.clientHeight&&(n.scrollTop=n.scrollHeight)}))))}function cn(){G.value=!G.value}function vn(){const e=Math.min(36,de.value+1);de.value=e}function fn(){const e=Math.max(10,de.value-1);de.value=e}function hn(){de.value=se.value}function pn(){if(!he.value)return;const e=E(i.value||t.node.language).toLowerCase(),n="html"===e?"HTML Preview":"SVG Preview";o("previewCode",{type:"html"===e?"text/html":"image/svg+xml",content:t.node.code,title:n})}return Be(be.value),v(()=>{ae.value?rn():Be(be.value)}),f(()=>{var e;Ie=!0,Ee+=1,null==(e=le.value)||e.destroy(),le.value=null,null==Z||Z.disconnect(),Z=void 0,te=null,Xe()}),d(Ye,()=>r(null,null,function*(){ae.value&&(yield rn())})),d(()=>t.loading,e=>{e||(ae.value?rn():Be(be.value))}),d(()=>ae.value,e=>{e&&rn()}),d(we,e=>{e||O()}),d(()=>t.autoScrollInitial,e=>{re.value=!1!==e}),d(()=>[t.node.code,t.node.language,t.node.loading,t.loading],e=>r(null,[e],function*([e,n,o,l]){var a;const r=Ke(),u="boolean"==typeof o?o:!0===l,s=ke(e,u),d=nn(n,e,u);if(d!==i.value&&(i.value=d),!ae.value)return void Be(s);if(!K.value||!Q.value)return void Be(s);if(!e)return void Be("");if(!Oe||function(){const e=en(t.themes,t.langs);return Boolean(Oe&&ze!==e.key)}())return Be(s),void(yield rn(r));if(!Qe(r))return;if(!Oe)return;if(!1===t.stream&&t.loading)return;Be(s);const c=ne,v=null==(a=Q.value)?void 0:a.innerHTML;Fe(r,c);const f=yield on(s,n,r);Qe(r)&&(f?yield Le(r,c,He(null!=ze?ze:Ye.value,f,s),v):(te=null,_e()))})),d(()=>[t.darkTheme,t.lightTheme,t.isDark],()=>r(null,null,function*(){ae.value&&K.value&&Q.value&&(Oe||(yield rn()),null==Oe||Oe.setTheme(xe()))})),d(()=>t.node.code,()=>r(null,null,function*(){if(A.value||!ue.value||!re.value)return;yield h();const e=K.value;e&&e.scrollHeight>e.clientHeight&&(e.scrollTop=e.scrollHeight)})),(n,o)=>(p(),g("div",{ref_key:"container",ref:J,style:m(pe.value),class:y(["code-block-container rounded-lg border overflow-hidden",{dark:t.isDark}])},[w(I,{"show-header":t.showHeader,"show-collapse-button":t.showCollapseButton,"show-font-size-buttons":t.showFontSizeButtons,"enable-font-size-control":t.enableFontSizeControl,"show-copy-button":t.showCopyButton,"show-expand-button":t.showExpandButton,"show-preview-button":t.showPreviewButton,"show-tooltips":t.showTooltips,"is-dark":t.isDark,loading:t.loading,stream:t.stream,"is-collapsed":G.value,"is-expanded":A.value,"copy-text":z.value,"is-previewable":he.value,"code-font-size":de.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":se.value,"font-baseline-ready":ce.value,onToggleCollapse:cn,onDecreaseFont:fn,onResetFont:hn,onIncreaseFont:vn,onCopy:sn,onToggleExpand:dn,onPreview:pn},k({"header-left":b(()=>[C(n.$slots,"header-left",{},()=>[x("div",W,[x("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:fe.value},null,8,R),x("div",U,[x("div",V,S(ve.value),1)])])],!0)]),loading:b(()=>[C(n.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[o[0]||(o[0]=x("div",{class:"loading-skeleton"},[x("div",{class:"skeleton-line"}),x("div",{class:"skeleton-line"}),x("div",{class:"skeleton-line short"})],-1))],!0)]),default:b(()=>[x("div",{ref_key:"codeBlockContent",ref:K,class:"code-block-content",style:m(me.value),onScroll:un},[x("div",{ref_key:"rendererTarget",ref:Q,class:"code-block-render"},null,512),!Y.value&&X.value?(p(),g("div",{key:0,class:"code-fallback-plain",innerHTML:X.value},null,8,q)):B("",!0)],36)]),_:2},[n.$slots["header-right"]?{name:"header-right",fn:b(()=>[C(n.$slots,"header-right",{},void 0,!0)]),key:"0"}:void 0]),1032,["show-header","show-collapse-button","show-font-size-buttons","enable-font-size-control","show-copy-button","show-expand-button","show-preview-button","show-tooltips","is-dark","loading","stream","is-collapsed","is-expanded","copy-text","is-previewable","code-font-size","default-code-font-size","font-baseline-ready"])],6))}}),[["__scopeId","data-v-2c616963"]]);A.install=e=>{e.component(A.__name,A)};export{A as default};
|
|
1
|
+
var e=Object.defineProperty,n=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,l=(n,t,o)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,a=(e,a)=>{for(var r in a||(a={}))t.call(a,r)&&l(e,r,a[r]);if(n)for(var r of n(a))o.call(a,r)&&l(e,r,a[r]);return e},r=(e,n,t)=>new Promise((o,l)=>{var a=e=>{try{i(t.next(e))}catch(n){l(n)}},r=e=>{try{i(t.throw(e))}catch(n){l(n)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(a,r);i((t=t.apply(e,n)).next())});import{defineComponent as i,ref as u,shallowRef as s,watch as d,computed as c,onMounted as v,onBeforeUnmount as f,nextTick as h,openBlock as p,createElementBlock as g,normalizeClass as y,normalizeStyle as m,createVNode as w,createSlots as k,withCtx as b,createElementVNode as x,createCommentVNode as B,renderSlot as C,toDisplayString as S}from"vue";import{getHighlightRegistrationKey as T,getRuntimeShikiRegistrationConfig as H,normalizeShikiLanguage as M,registerHighlightOnce as _}from"markstream-core";import{aj as F,al as L,a4 as O,ag as P,a6 as $,y as z}from"./exports.js";import{c as N,l as j,g as D,n as E}from"./index2.js";import{_ as I}from"./CodeBlockShell.vue_vue_type_style_index_0_lang.js";const W={class:"code-header-main"},R=["innerHTML"],U={class:"code-header-copy"},V={class:"code-header-title"},q=["innerHTML"],A=/* @__PURE__ */z(/* @__PURE__ */i({__name:"MarkdownCodeBlockNode",props:{node:{},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},darkTheme:{default:"vitesse-dark"},lightTheme:{default:"vitesse-light"},isDark:{type:Boolean,default:!1},isShowPreview:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},autoScrollOnUpdate:{type:Boolean,default:!0},autoScrollInitial:{type:Boolean,default:!0},estimatedHeightPx:{},estimatedContentHeightPx:{},themes:{},langs:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0}},emits:["previewCode","copy"],setup(e,{emit:n}){const t=e,o=n,{t:l}=F(),i=u(nn(t.node.language,t.node.code,tn())),z=u(!1),A=u(!1),G=u(!1),J=u(null),K=u(null),Q=u(null),X=u(""),Y=u(!1);let Z,ee="",ne=0,te=null;const oe=L(),le=s(null),ae=u("undefined"==typeof window);"undefined"!=typeof window&&d(()=>J.value,(e,n,t)=>{var o;if(null==(o=le.value)||o.destroy(),le.value=null,!e)return void(ae.value=!1);let l=!0;const a=oe(e,{rootMargin:"400px"});le.value=a,ae.value=a.isVisible.value,a.whenVisible.then(()=>{l&&le.value===a&&(ae.value=!0)}).catch(()=>{}),t(()=>{l=!1,a.destroy(),le.value===a&&(le.value=null)})},{immediate:!0});const re=u(!1!==t.autoScrollInitial),ie=u(0),ue=c(()=>!1!==t.autoScrollOnUpdate),se=u(14),de=u(se.value),ce=c(()=>{const e=se.value,n=de.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof n&&Number.isFinite(n)&&n>0}),ve=c(()=>{const e=i.value.trim().toLowerCase();return N[e]||e.charAt(0).toUpperCase()+e.slice(1)}),fe=c(()=>{j.value;const e=i.value.trim().toLowerCase();return D(e.split(":")[0])}),he=c(()=>{const e=i.value.trim().toLowerCase();return t.isShowPreview&&("html"===e||"svg"===e)}),pe=c(()=>{const e={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},o=n(t.minWidth),l=n(t.maxWidth);return o&&(e.minWidth=o),l&&(e.maxWidth=l),e}),ge=c(()=>{const e=t.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}),ye=c(()=>null!=ge.value&&!Y.value),me=c(()=>a({fontSize:`${de.value}px`},ye.value?{minHeight:`${ge.value}px`}:{})),we=c(()=>!1!==t.showTooltips);function ke(e,n){const t=String(null!=e?e:"");return n?t:t.replace(/\r\n$|\n$|\r$/,"")}const be=c(()=>ke(t.node.code,!0===t.node.loading));function xe(){return t.isDark?t.darkTheme:t.lightTheme}function Be(e){if(te=null,_e(),!e)return Se(),ee="",X.value="",void(Y.value=!1);var n;X.value=`<pre class="shiki shiki-fallback"><code>${n=e,n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`,Y.value=!1}function Ce(){X.value="",Y.value=!0}function Se(){Q.value&&(Q.value.innerHTML="")}function Te(){var e;const n=Q.value;return!!n&&(n.childNodes.length>0||Boolean(null==(e=n.textContent)?void 0:e.trim().length))}function He(e,n,t){return`${null!=e?e:""}\0${n}\0${t}`}function Me(e){ee=e,Ce()}function _e(e){null==e||e.disconnect(),e&&Z!==e||(Z=void 0)}function Fe(e,n){_e();const t=Q.value;if(!t||"undefined"==typeof MutationObserver)return;te=null;const o=new MutationObserver(()=>{ne+=1;const t=te;if(t)return Qe(e)?void(ne!==n&&Te()&&(te=null,_e(o),Me(t))):(te=null,void _e(o))});Z=o,o.observe(t,{childList:!0,subtree:!0,characterData:!0,attributes:!0})}function Le(e,n,t,o){return r(this,null,function*(){var l;if(te=t,yield h(),!Qe(e))return;const a=Te(),r=ne!==n,i=void 0!==o&&(null==(l=Q.value)?void 0:l.innerHTML)!==o;a&&(!ee||r||i||ee===t)&&(te=null,_e(),Me(t))})}let Oe,Pe,$e,ze=null,Ne=null,je="",De=0,Ee=0,Ie=!1;const We=/* @__PURE__ */new Set,Re=/* @__PURE__ */new Set,Ue=/* @__PURE__ */new Set,Ve=$();let qe=!1,Ae=null,Ge=!1,Je=!1;function Ke(){return Ee+=1,Ee}function Qe(e=Ee){return!Ie&&e===Ee}function Xe(){const e=Oe;Oe=void 0,ze=null,ee="",te=null,Re.clear();try{null==e||e.dispose()}catch(n){Ve&&console.warn("[MarkdownCodeBlockNode] Failed to dispose Shiki renderer.",n)}finally{Se(),Y.value=!1}}const Ye=c(()=>T(t.themes,t.langs));function Ze(){return{hasRegisterHighlight:Boolean($e),hasCreateRenderer:Boolean(Pe)}}function en(e,n){var t;const o=Ze(),l=H(e,n,o);return(null==(t=l.rendererOptions.langs)?void 0:t.length)&&Ue.has(l.key)?H(e,void 0,o):l}function nn(e,n,t){return t&&!String(null!=n?n:"")?"plain":E(String(null!=e?e:""))}function tn(){return"boolean"==typeof t.node.loading?t.node.loading:!0===t.loading}function on(e,n){return r(this,arguments,function*(e,n,t=Ee){if(!Oe||!Qe(t))return;const o=function(e){return M(e)||"plaintext"}(function(e,n,t){return t&&!String(null!=n?n:"")?"plaintext":String(null!=e?e:"")}(n,e,tn())),l=n=>r(null,null,function*(){if(Oe&&Qe(t)){"plaintext"!==o&&(n&&Re.add(o),n&&Ve&&!We.has(o)&&(We.add(o),console.warn(`[MarkdownCodeBlockNode] Failed to render language "${o}", retrying as plaintext.`,n)));try{return yield Oe.updateCode(e,"plaintext"),Qe(t)?"plaintext":void 0}catch(l){if(!Qe(t))return;return void(Ve&&console.warn("[MarkdownCodeBlockNode] Failed to render code block even as plaintext.",l))}}});if("plaintext"!==o&&Re.has(o))return l();try{return yield Oe.updateCode(e,o),Qe(t)?o:void 0}catch(a){if(!Qe(t))return;return"plaintext"!==o?l(a):void(Ve&&console.warn("[MarkdownCodeBlockNode] Failed to render code block even as plaintext.",a))}})}function ln(e,n){return r(this,null,function*(){if(!$e)return"ready";if(je!==n)return"stale";if(Ne===n)return"ready";const t=++De;try{yield _($e,e,n)}catch(o){return t!==De||je!==n?"stale":"failed"}return t!==De||je!==n?"stale":(Ne=n,"ready")})}function an(e,n){return r(this,null,function*(){const t=yield ln(e,n);return"failed"!==t?t:je!==n?"stale":ln(e,n)})}function rn(){return r(this,arguments,function*(e=Ke()){try{yield function(e){return r(this,null,function*(){var n,o;if(!Qe(e))return;const l=be.value;if(!ae.value)return void Be(l);if(yield function(){return r(this,null,function*(){if(!Pe&&!Ge)return Ae||(Ae=r(null,null,function*(){try{const e=yield import("stream-markdown"),n=e.createShikiStreamRenderer;if("function"!=typeof n)throw new TypeError("stream-markdown.createShikiStreamRenderer is not available");Pe=n;const t=e.registerHighlight;$e="function"==typeof t?t:void 0,Ge=!1,Je=!1}catch(e){Ge=!0,Ve&&!Je&&(Je=!0,console.warn("[MarkdownCodeBlockNode] stream-markdown not available:",e))}finally{Ae=null}}),Ae)})}(),!Qe(e))return;if(!K.value||!Q.value)return void Be(l);let i=en(t.themes,t.langs);i.ignoredLangs&&Ve&&!qe&&(qe=!0,console.warn("[MarkdownCodeBlockNode] `langs` requires stream-markdown >=0.0.15 with registerHighlight(); ignoring `langs` and using stream-markdown default language preload."));let u=i.rendererOptions,s=i.key;je=s;let d=Boolean(Oe&&ze!==s);d&&Be(l);let c=yield an(i.registerOptions,s);if("failed"===c&&(null==(n=u.langs)?void 0:n.length)&&(Ue.add(s),Ve&&console.warn("[MarkdownCodeBlockNode] Failed to register configured Shiki languages; retrying without `langs`.",{langs:u.langs}),i=H(t.themes,void 0,Ze()),u=i.rendererOptions,s=i.key,je=s,c=yield an(i.registerOptions,s)),!Qe(e)||"stale"===c)return;if(d=Boolean(Oe&&ze!==s),"failed"===c)return void(d&&Oe&&Te()?Ce():Be(l));if(d&&Xe(),!Oe&&Pe&&(Oe=Pe(Q.value,a({theme:xe()},u)),ze=s,Y.value=!0),!Oe)return void Be(l);if(!1===t.stream&&t.loading)return void Be(l);Be(l);const v=ne,f=null==(o=Q.value)?void 0:o.innerHTML;Fe(e,v);const h=yield on(l,t.node.language,e);Qe(e)&&(h?yield Le(e,v,He(s,h,l),f):(te=null,_e()))})}(e)}catch(n){if(!Qe(e))return;Ve&&console.warn("[MarkdownCodeBlockNode] Failed to initialize Shiki renderer.",n),Be(be.value)}})}function un(){const e=K.value;if(!e||A.value||!ue.value)return;const n=e.scrollTop;n<ie.value?re.value=!1:function(e,n=50){return e.scrollHeight-e.scrollTop-e.clientHeight<=n}(e)&&(re.value=!0),ie.value=n}function sn(){return r(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(t.node.code)),z.value=!0,o("copy",t.node.code),setTimeout(()=>{z.value=!1},1e3)}catch(e){console.error("Copy failed:",e)}})}function dn(e){if(A.value=!A.value,e&&we.value){const n=function(e){const n=e.currentTarget||e.target;return!n||n.disabled?null:n}(e);if(n){const e=A.value?l("common.collapse")||"Collapse":l("common.expand")||"Expand";P(n,e,"top",!1,void 0,t.isDark)}}const n=K.value;n&&(A.value?(n.style.maxHeight="none",n.style["overflow-y"]="visible",n.style["overflow-x"]="auto"):(n.style.maxHeight="",n.style.overflow="auto",ue.value&&(re.value=!0,h(()=>{n.scrollHeight>n.clientHeight&&(n.scrollTop=n.scrollHeight)}))))}function cn(){G.value=!G.value}function vn(){const e=Math.min(36,de.value+1);de.value=e}function fn(){const e=Math.max(10,de.value-1);de.value=e}function hn(){de.value=se.value}function pn(){if(!he.value)return;const e=E(i.value||t.node.language).toLowerCase(),n="html"===e?"HTML Preview":"SVG Preview";o("previewCode",{type:"html"===e?"text/html":"image/svg+xml",content:t.node.code,title:n})}return Be(be.value),v(()=>{ae.value?rn():Be(be.value)}),f(()=>{var e;Ie=!0,Ee+=1,null==(e=le.value)||e.destroy(),le.value=null,null==Z||Z.disconnect(),Z=void 0,te=null,Xe()}),d(Ye,()=>r(null,null,function*(){ae.value&&(yield rn())})),d(()=>t.loading,e=>{e||(ae.value?rn():Be(be.value))}),d(()=>ae.value,e=>{e&&rn()}),d(we,e=>{e||O()}),d(()=>t.autoScrollInitial,e=>{re.value=!1!==e}),d(()=>[t.node.code,t.node.language,t.node.loading,t.loading],e=>r(null,[e],function*([e,n,o,l]){var a;const r=Ke(),u="boolean"==typeof o?o:!0===l,s=ke(e,u),d=nn(n,e,u);if(d!==i.value&&(i.value=d),!ae.value)return void Be(s);if(!K.value||!Q.value)return void Be(s);if(!e)return void Be("");if(!Oe||function(){const e=en(t.themes,t.langs);return Boolean(Oe&&ze!==e.key)}())return Be(s),void(yield rn(r));if(!Qe(r))return;if(!Oe)return;if(!1===t.stream&&t.loading)return;Be(s);const c=ne,v=null==(a=Q.value)?void 0:a.innerHTML;Fe(r,c);const f=yield on(s,n,r);Qe(r)&&(f?yield Le(r,c,He(null!=ze?ze:Ye.value,f,s),v):(te=null,_e()))})),d(()=>[t.darkTheme,t.lightTheme,t.isDark],()=>r(null,null,function*(){ae.value&&K.value&&Q.value&&(Oe||(yield rn()),null==Oe||Oe.setTheme(xe()))})),d(()=>t.node.code,()=>r(null,null,function*(){if(A.value||!ue.value||!re.value)return;yield h();const e=K.value;e&&e.scrollHeight>e.clientHeight&&(e.scrollTop=e.scrollHeight)})),(n,o)=>(p(),g("div",{ref_key:"container",ref:J,style:m(pe.value),class:y(["code-block-container rounded-lg border overflow-hidden",{dark:t.isDark}])},[w(I,{"show-header":t.showHeader,"show-collapse-button":t.showCollapseButton,"show-font-size-buttons":t.showFontSizeButtons,"enable-font-size-control":t.enableFontSizeControl,"show-copy-button":t.showCopyButton,"show-expand-button":t.showExpandButton,"show-preview-button":t.showPreviewButton,"show-tooltips":t.showTooltips,"is-dark":t.isDark,loading:t.loading,stream:t.stream,"is-collapsed":G.value,"is-expanded":A.value,"copy-text":z.value,"is-previewable":he.value,"code-font-size":de.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":se.value,"font-baseline-ready":ce.value,onToggleCollapse:cn,onDecreaseFont:fn,onResetFont:hn,onIncreaseFont:vn,onCopy:sn,onToggleExpand:dn,onPreview:pn},k({"header-left":b(()=>[C(n.$slots,"header-left",{},()=>[x("div",W,[x("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:fe.value},null,8,R),x("div",U,[x("div",V,S(ve.value),1)])])],!0)]),loading:b(()=>[C(n.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[o[0]||(o[0]=x("div",{class:"loading-skeleton"},[x("div",{class:"skeleton-line"}),x("div",{class:"skeleton-line"}),x("div",{class:"skeleton-line short"})],-1))],!0)]),default:b(()=>[x("div",{ref_key:"codeBlockContent",ref:K,class:"code-block-content",style:m(me.value),onScroll:un},[x("div",{ref_key:"rendererTarget",ref:Q,class:"code-block-render"},null,512),!Y.value&&X.value?(p(),g("div",{key:0,class:"code-fallback-plain",innerHTML:X.value},null,8,q)):B("",!0)],36)]),_:2},[n.$slots["header-right"]?{name:"header-right",fn:b(()=>[C(n.$slots,"header-right",{},void 0,!0)]),key:"0"}:void 0]),1032,["show-header","show-collapse-button","show-font-size-buttons","enable-font-size-control","show-copy-button","show-expand-button","show-preview-button","show-tooltips","is-dark","loading","stream","is-collapsed","is-expanded","copy-text","is-previewable","code-font-size","default-code-font-size","font-baseline-ready"])],6))}}),[["__scopeId","data-v-2c616963"]]);A.install=e=>{e.component(A.__name,A)};export{A as default};
|