markstream-react 0.0.52 → 0.0.53
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 +43 -6
- package/dist/Tooltip-DSM4ImfZ.js +207 -0
- package/dist/codeBlockExtraProps-RaPzFq78.js +3 -0
- package/dist/index-D0DspXy9.js +85 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.px.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/markstream-react.css +1 -1
- package/dist/next.d.ts +41 -18
- package/dist/next.js +1 -1
- package/dist/server.d.ts +28 -5
- package/dist/server.js +1 -1
- package/dist/tailwind.cjs +1 -1
- package/dist/tailwind.js +1 -1
- package/dist/types/components/HtmlInlineNode/HtmlInlineNode.d.ts +4 -1
- package/dist/types/components/NodeRenderer.d.ts +2 -1
- package/dist/types/customComponents.d.ts +20 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/next.d.ts +7 -3
- package/dist/types/renderers/renderNode.d.ts +1 -1
- package/dist/types/server-renderer/index.d.ts +6 -2
- package/dist/types/server.d.ts +2 -2
- package/dist/types/types.d.ts +8 -3
- package/dist/types/utils/customHtmlTag.d.ts +5 -4
- package/dist/types/utils/htmlToReact.d.ts +17 -6
- package/package.json +6 -6
- package/dist/Tooltip-Ux2h3oiV.js +0 -207
- package/dist/codeBlockExtraProps-NhTjbA1T.js +0 -3
- package/dist/index-DdaK6qko.js +0 -85
package/dist/Tooltip-Ux2h3oiV.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import{jsxs as e,jsx as n,Fragment as t}from"react/jsx-runtime";import r,{useMemo as o,useState as i,createContext as l,useContext as a,useRef as c,useEffect as s,useCallback as d,useSyncExternalStore as u,useLayoutEffect as m}from"react";import{sanitizeHtmlTokenAttrs as h,NON_STRUCTURING_HTML_TAGS as f,isHtmlTagBlocked as p,sanitizeHtmlContent as g,BLOCKED_HTML_TAGS as v,isHtmlTagHardBlocked as w,convertHtmlAttrsToProps as y,sanitizeImageSrc as x,sanitizeHtmlAttrs as k,shouldOpenLinkInNewTab as b,toSafeSvgElement as C,getHtmlTagFromContent as M,stripCustomHtmlWrapper as N,shouldRenderUnknownHtmlTagAsText as B,mergeCustomHtmlTags as S,getMarkdown as T,parseMarkdownToStructure as L}from"stream-markdown-parser";import{x as E,q as D,F as $,z as P,j as R,n as _,w as A,E as H,h as I,i as W,G as F,o as O,k as j,r as z,H as K,l as V,A as X,t as U,c as q,e as Y,p as Z,s as G,a as J,d as Q,B as ee,m as ne,y as te,g as re}from"./codeBlockExtraProps-NhTjbA1T.js";import{createSmoothMarkdownStream as oe,resolveStreamingTextUpdate as ie,normalizeShikiLanguage as le,getHighlightRegistrationKey as ae,registerHighlightOnce as ce,getRuntimeShikiRegistrationConfig as se}from"markstream-core";import{createPortal as de}from"react-dom";import{autoUpdate as ue,computePosition as me,offset as he,flip as fe,shift as pe}from"@floating-ui/dom";const ge={note:"ℹ️",info:"ℹ️",tip:"💡",warning:"⚠️",danger:"❗",error:"⛔",caution:"⚠️"};function ve(t){const{node:r,ctx:l,renderNode:a,indexKey:c,isDark:s}=t,d=String(r.kind||"note"),u=o(()=>r.title&&String(r.title).trim().length?String(r.title):d.charAt(0).toUpperCase()+d.slice(1),[d,r.title]),[m,h]=i(()=>{var e;return!!r.collapsible&&!(null==(e=r.open)||e)}),f=o(()=>`admonition-${Math.random().toString(36).slice(2,9)}`,[]);/* @__PURE__ */
|
|
2
|
-
return e("div",{className:`admonition admonition-${d}${s?" is-dark":""}`,"data-index-key":c,children:[
|
|
3
|
-
/* @__PURE__ */e("div",{id:f,className:"admonition-header",children:[ge[d]&&/* @__PURE__ */n("span",{className:"admonition-icon",children:ge[d]}),
|
|
4
|
-
/* @__PURE__ */n("span",{className:"admonition-title",children:u}),r.collapsible&&/* @__PURE__ */n("button",{type:"button",className:"admonition-toggle","aria-expanded":!m,"aria-controls":`${f}-content`,title:m?"Expand":"Collapse",onClick:()=>h(e=>!e),children:/* @__PURE__ */n("span",{children:m?"▶":"▼"})})]}),!m&&/* @__PURE__ */n("div",{id:`${f}-content`,className:"admonition-content","aria-labelledby":f,children:l&&a?E(r.children,l,String(null!=c?c:f),a):null})]})}const we=l(!1),ye=l(null);function xe(){return a(ye)}const ke=l(null);function be(e,n){var t,r;const o="undefined"!=typeof window&&"undefined"!=typeof document,i=o?null!=(t=window.requestIdleCallback)?t:e=>window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),16):null,l=o?null!=(r=window.cancelIdleCallback)?r:e=>window.clearTimeout(e):null;let a=null,c=null;const s=/* @__PURE__ */new Map,d=/* @__PURE__ */new Set;let u=null;const m=()=>{if(!s.size){try{null==a||a.disconnect()}catch{}a=null,c=null,d.size||(()=>{if(null!=u){try{null==l||l(u)}catch{}u=null}})()}},h=e=>{const n=s.get(e);if(n){n.state.current=!0;try{n.resolve()}catch{}try{null==a||a.unobserve(e)}catch{}s.delete(e),d.delete(e),m()}},f=()=>{i&&null==u&&d.size&&(u=i(()=>{u=null;const e=d.values().next().value;e&&(d.delete(e),h(e),d.size&&f())},{timeout:1200}))};return(t,r)=>{var i,l;const u={current:!1};let p,g=!1;const v=new Promise(e=>{p=()=>{g||(g=!0,e())}}),w=()=>{if(s.has(t)){s.delete(t);try{null==a||a.unobserve(t)}catch{}}d.delete(t),m()};if(!o||!n())return u.current=!0,p(),{isVisible:()=>!0,whenVisible:v,destroy:w};const y=((n,t)=>{if(!o)return null;if("undefined"==typeof IntersectionObserver)return null;const r=((n,t)=>{var r;return{root:null!=(r=e())?r:null,rootMargin:n,threshold:t}})(n,t);if(a&&(l=r,(i=c)&&i.root===l.root&&i.rootMargin===l.rootMargin&&i.threshold===l.threshold))return a;var i,l;if(a)try{a.disconnect()}catch{}a=new IntersectionObserver(e=>{for(const n of e)(n.isIntersecting||n.intersectionRatio>0)&&h(n.target)},{root:r.root,rootMargin:r.rootMargin,threshold:r.threshold}),c=r;for(const e of s.keys())a.observe(e);return a})(null!=(i=null==r?void 0:r.rootMargin)?i:"300px",null!=(l=null==r?void 0:r.threshold)?l:0);return y?(s.set(t,{resolve:p,state:u}),y.observe(t),d.add(t),f(),{isVisible:()=>u.current,whenVisible:v,destroy:w}):(u.current=!0,p(),{isVisible:()=>!0,whenVisible:v,destroy:w})}}const Ce=be(()=>null,()=>!0);function Me({getRoot:e,enabled:t=!0,children:r}){const i=c(t);i.current=t;const l=c(e);l.current=e;const a=o(()=>be(()=>{var e,n;return null!=(n=null==(e=l.current)?void 0:e.call(l))?n:null},()=>i.current),[]);/* @__PURE__ */
|
|
5
|
-
return n(ke.Provider,{value:a,children:r})}function Ne(){var e;return null!=(e=a(ke))?e:Ce}function Be(e={}){const n=c(null);n.current||(n.current=oe(e));const t=n.current,[r,l]=i(()=>t.getSnapshot());return s(()=>{const e=t.subscribe(()=>{l(t.getSnapshot())});return t.resume(),l(t.getSnapshot()),()=>{e(),t.pause()}},[t]),o(()=>({...r,enqueue:t.enqueue,finish:t.finish,flush:t.flush,reset:t.reset,pause:t.pause,resume:t.resume,getSnapshot:t.getSnapshot}),[t,r])}function Se(e){const{node:t}=e;/* @__PURE__ */
|
|
6
|
-
return n("span",{className:"checkbox-node",children:/* @__PURE__ */n("input",{type:"checkbox",checked:Boolean(t.checked),disabled:!0,className:"checkbox-input",readOnly:!0})})}const Te={"common.copy":"Copy","common.copied":"Copied","common.decrease":"Decrease","common.reset":"Reset","common.increase":"Increase","common.expand":"Expand","common.collapse":"Collapse","common.preview":"Preview","common.source":"Source","common.export":"Export","common.open":"Open","common.close":"Close","common.zoomIn":"Zoom in","common.zoomOut":"Zoom out","common.resetZoom":"Reset zoom","image.loadError":"Image failed to load","image.loading":"Loading image..."};function Le(e){Object.assign(Te,e)}function Ee(){return{t:e=>{var n;return null!=(n=Te[e])?n:function(e){return(e.split(".").pop()||e).replace(/[_-]/g," ").replace(/([A-Z])/g," $1").replace(/\s+/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}(e)}}}let De=null,$e=null,Pe=null,Re=null,_e=null,Ae=null;function He(){Re&&(clearTimeout(Re),Re=null),_e&&(clearTimeout(_e),_e=null)}async function Ie(e){if(!De||!$e)return;const{x:n,y:t}=await me($e,De,{placement:e,middleware:[he(8),fe(),pe({padding:8})],strategy:"fixed"});De.style.transform=`translate3d(${Math.round(n)}px, ${Math.round(t)}px, 0)`}function We(e,n,t="top",r=!1,o,i){if(!e||"undefined"==typeof document)return;if(De||"undefined"==typeof document||(De=document.createElement("div"),De.className="ms-tooltip",De.setAttribute("role","tooltip"),De.dataset.visible="false",De.style.position="fixed",De.style.left="0px",De.style.top="0px",De.style.transform="translate3d(0,0,0)",document.body.appendChild(De)),!De)return;He();const l=async()=>{if(De){$e=e,De.textContent=n,De.dataset.placement=t,De.dataset.dark=function(e){if("boolean"==typeof e)return e;if("undefined"!=typeof document)try{if(document.documentElement.classList.contains("dark"))return!0}catch{}if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{return window.matchMedia("(prefers-color-scheme: dark)").matches}catch{}return!1}(i)?"true":"false",De.dataset.visible="false",Ae=`tooltip-${Date.now()}-${Math.random().toString(36).slice(2)}`,De.id=Ae;try{e.setAttribute("aria-describedby",Ae)}catch{}await Ie(t),De.dataset.visible="true",null==Pe||Pe(),Pe=ue(e,De,()=>{Ie(t)})}};r?l():Re=setTimeout(l,80)}function Fe(e=!1){if(!De)return;He();const n=()=>{if(De){if(De.dataset.visible="false",$e&&Ae)try{$e.removeAttribute("aria-describedby")}catch{}$e=null,Ae=null,Pe&&(Pe(),Pe=null)}};e?n():_e=setTimeout(n,120)}const Oe=void 0!==import.meta&&Boolean(!1);let je=null;function ze(t){const{t:r}=Ee(),i=o(()=>{const e=t.code||"",n=e.trim().toLowerCase();return n.startsWith("<!doctype")||n.startsWith("<html")||n.startsWith("<body")?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${t.isDark?"#020617":"#ffffff"};\n color: ${t.isDark?"#e5e7eb":"#020617"};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`},[t.code,t.isDark]),l=o(()=>{return e=t.htmlPreviewSandbox,n=t.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!Oe||"undefined"==typeof console||je===e)return;const n=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);n.has("allow-scripts")&&n.has("allow-same-origin")&&(je=e,console.warn("[markstream-react] htmlPreviewSandbox contains both allow-scripts and allow-same-origin. Use this only for fully trusted content served from an isolated origin."))}(e),e):void 0!==e?"":!0===n?"allow-scripts":"";var e,n},[t.htmlPreviewAllowScripts,t.htmlPreviewSandbox]);return s(()=>{const e=e=>{var n;"Escape"!==e.key&&"Esc"!==e.key||null==(n=t.onClose)||n.call(t)};return"undefined"!=typeof window&&window.addEventListener("keydown",e),()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",e)}},[t]),"undefined"==typeof document?null:de(
|
|
7
|
-
/* @__PURE__ */n("div",{className:"html-preview-frame__backdrop"+(t.isDark?" html-preview-frame__backdrop--dark":""),onClick:()=>{var e;return null==(e=t.onClose)?void 0:e.call(t)},children:/* @__PURE__ */e("div",{className:"html-preview-frame"+(t.isDark?" html-preview-frame--dark":""),onClick:e=>e.stopPropagation(),children:[
|
|
8
|
-
/* @__PURE__ */e("div",{className:"html-preview-frame__header",children:[
|
|
9
|
-
/* @__PURE__ */e("div",{className:"html-preview-frame__title",children:[
|
|
10
|
-
/* @__PURE__ */n("span",{className:"html-preview-frame__dot"}),
|
|
11
|
-
/* @__PURE__ */n("span",{className:"html-preview-frame__label",children:t.title||`HTML ${r("common.preview")}`})]}),
|
|
12
|
-
/* @__PURE__ */n("button",{type:"button",className:"html-preview-frame__close"+(t.isDark?" html-preview-frame__close--dark":""),onClick:()=>{var e;return null==(e=t.onClose)?void 0:e.call(t)},children:"×"})]}),
|
|
13
|
-
/* @__PURE__ */n("iframe",{className:"html-preview-frame__iframe",sandbox:l,referrerPolicy:"no-referrer",src:"about:blank",srcDoc:i,title:t.title||"Preview"})]})}),document.body)}let Ke=!1,Ve=null,Xe=!1;async function Ue(){if(Ve)return Ve;if(Xe)return null;try{return Ve=await import("stream-monaco"),await async function(e){if(Ke)return;Ke=!0;const n=null==globalThis?void 0:globalThis.MonacoEnvironment;(!n||"function"!=typeof n.getWorker&&"function"!=typeof n.getWorkerUrl)&&(null==e?void 0:e.preloadMonacoWorkers)&&await e.preloadMonacoWorkers()}(Ve),Ve}catch{return Xe=!0,null}}let qe=null,Ye=!1,Ze=null,Ge=null,Je=null,Qe=null,en=null;const nn=/* @__PURE__ */new WeakMap;let tn=0;function rn(e,n){const t=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&e&&"name"in e)return String(e.name);if("object"==typeof e){const n=nn.get(e);if(n)return n;try{const n=JSON.stringify(e);if(n)return nn.set(e,n),n}catch{}const t="__theme_"+ ++tn;return nn.set(e,t),t}return String(e)}(e);return t?(qe!==n&&(qe=n),Ye||en!==t?!Ze||Qe!==t&&Ge!==t?(Je=e,Qe=t,Ze||(Ye=!0,Ze=(async()=>{for(;null!=Je&&null!=Qe;){const e=Je,n=Qe;if(Je=null,Qe=null,en===n)continue;const t=qe;if(!t)break;try{Ge=n,await Promise.resolve(t(e)),en=n}catch{}}})().finally(()=>{Ye=!1,Ze=null,Ge=null}),Ze)):Ze:Promise.resolve()):Promise.resolve()}let on=null,ln=null,an=null;const cn=/* @__PURE__ */new Set,sn=/* @__PURE__ */new WeakMap;let dn=0;function un(){for(const e of Array.from(cn))try{e()}catch{}}function mn(e){var n;return String(null!=(n=String(null!=e?e:"").split(/\s+/g)[0])?n:"").split(":")[0].toLowerCase().replace(/[^\w-]/g,"")||"plaintext"}function hn(e){const n=String(null!=e?e:"");return n?n.split(/\r\n|\n|\r/):[]}function fn(e){return e.startsWith("-")&&!e.startsWith("---")}function pn(e){return e.startsWith("+")&&!e.startsWith("+++")}function gn(e,n){return t=e[n],!(0===String(null!=t?t:"").trim().length)||n<e.length-1;var t}function vn(e,n,t,r,o={}){const i=0===String(null!=e?e:"").trim().length;return{code:e,empty:i,kind:i&&"hunk"!==n&&!o.preserveBlankKind?"context":n,key:t,number:r}}function wn(e,n){const t=hn(e),r=hn(n),o=function(e,n){const t=e.length,r=n.length;if((t+1)*(r+1)>15e5)return null;const o=r+1,i=new Uint16Array((t+1)*(r+1));for(let s=t-1;s>=0;s--)for(let t=r-1;t>=0;t--){const r=s*o+t;e[s]===n[t]?i[r]=i[(s+1)*o+t+1]+1:i[r]=Math.max(i[(s+1)*o+t],i[s*o+t+1])}const l=[];let a=0,c=0;for(;a<t&&c<r;)e[a]===n[c]?(l.push({originalIndex:a,modifiedIndex:c}),a++,c++):i[(a+1)*o+c]>=i[a*o+c+1]?a++:c++;return l}(t,r);if(o){const e=[];let n=0,i=0;for(const l of o){for(;n<l.originalIndex;)e.push(vn(t[n],"removed",`inline-removed-source-${n}`,"",{preserveBlankKind:gn(t,n)})),n++;for(;i<l.modifiedIndex;)e.push(vn(r[i],"added",`inline-added-source-${i}`,i+1,{preserveBlankKind:gn(r,i)})),i++;e.push(vn(r[l.modifiedIndex],"context",`inline-context-source-${l.originalIndex}-${l.modifiedIndex}`,l.modifiedIndex+1)),n=l.originalIndex+1,i=l.modifiedIndex+1}for(;n<t.length;)e.push(vn(t[n],"removed",`inline-removed-source-${n}`,"",{preserveBlankKind:gn(t,n)})),n++;for(;i<r.length;)e.push(vn(r[i],"added",`inline-added-source-${i}`,i+1,{preserveBlankKind:gn(r,i)})),i++;return e}const i=[];let l=0,a=t.length-1,c=r.length-1;for(;l<=a&&l<=c&&t[l]===r[l];)i.push(vn(r[l],"context",`inline-prefix-${l}`,l+1)),l++;const s=[];for(;a>=l&&c>=l&&t[a]===r[c];)s.unshift(vn(r[c],"context",`inline-suffix-${c}`,c+1)),a--,c--;for(let d=l;d<=a;d++)i.push(vn(t[d],"removed",`inline-removed-source-${d}`,"",{preserveBlankKind:gn(t,d)}));for(let d=l;d<=c;d++)i.push(vn(r[d],"added",`inline-added-source-${d}`,d+1,{preserveBlankKind:gn(r,d)}));return i.concat(s)}function yn(e,n=!1,t=mn(null==e?void 0:e.language)){const r=(o=null==e?void 0:e.code,String(null!=o?o:"").split(/\r\n|\n|\r/));var o;if(!function(e,n,t){const r=e.some(e=>fn(e)),o=e.some(e=>pn(e));return r&&o||function(e,n){var t,r,o;if("diff"===n)return!0;const i=null!=(o=null==(r=String(null!=(t=null==e?void 0:e.raw)?t:"").split(/\r?\n/,1)[0])?void 0:r.trim())?o:"";return/^`{3,}\s*diff(?:\s|$)|^~{3,}\s*diff(?:\s|$)/.test(i)}(n,t)&&(r||o)}(r,e,t)&&function(e){return null!=(null==e?void 0:e.originalCode)||null!=(null==e?void 0:e.updatedCode)}(e)){if(n)return[{key:"inline",className:"markstream-pre__diff-pane--inline",lines:wn(null==e?void 0:e.originalCode,null==e?void 0:e.updatedCode)}];const t=hn(null==e?void 0:e.originalCode),r=hn(null==e?void 0:e.updatedCode);return[{key:"original",className:"markstream-pre__diff-pane--original",lines:t.map((e,n)=>vn(e,r[n]===e?"context":"removed",`original-${n}`,n+1,{preserveBlankKind:gn(t,n)}))},{key:"modified",className:"markstream-pre__diff-pane--modified",lines:r.map((e,n)=>vn(e,t[n]===e?"context":"added",`modified-${n}`,n+1,{preserveBlankKind:gn(r,n)}))}]}if(n){const e=function(e){let n=1;return e.map((e,t)=>e.startsWith("@@")?vn(e,"hunk",`inline-hunk-${t}`,""):fn(e)?vn(e.slice(1),"removed",`inline-removed-${t}`,"",{preserveBlankKind:!0}):pn(e)?vn(e.slice(1),"added",`inline-added-${t}`,n++,{preserveBlankKind:!0}):vn(e.startsWith(" ")?e.slice(1):e,"context",`inline-context-${t}`,n++))}(r);return[{key:"inline",className:"markstream-pre__diff-pane--inline",lines:e}]}const i=[],l=[];let a=1,c=1;for(const[s,d]of r.entries())if(d.startsWith("@@"))i.push(vn(d,"hunk",`original-hunk-${s}`,"")),l.push(vn(d,"hunk",`modified-hunk-${s}`,""));else if(fn(d))i.push(vn(d.slice(1),"removed",`original-removed-${s}`,a++,{preserveBlankKind:!0}));else if(pn(d))l.push(vn(d.slice(1),"added",`modified-added-${s}`,c++,{preserveBlankKind:!0}));else{const e=d.startsWith(" ")?d.slice(1):d;i.push(vn(e,"context",`original-context-${s}`,a++)),l.push(vn(e,"context",`modified-context-${s}`,c++))}return[{key:"original",className:"markstream-pre__diff-pane--original",lines:i},{key:"modified",className:"markstream-pre__diff-pane--modified",lines:l}]}function xn({node:t,className:r,diffInline:i,showLineNumbers:l,style:a}){const c=o(()=>mn(null==t?void 0:t.language),[t]),s=`language-${c}`,d=c?`Code block: ${c}`:"Code block",u=!0===l&&!0===(null==t?void 0:t.diff),m=o(()=>u?yn(t,!0===i,c):[],[i,u,t,c]),h=o(()=>function(e){var n,t;if(!0===(null==e?void 0:e.diff))return String(null!=(n=null==e?void 0:e.code)?n:"");const r=String(null!=(t=null==e?void 0:e.code)?t:"");return!0===(null==e?void 0:e.loading)?r:r.replace(/\r\n$|\n$|\r$/,"")}(t),[t]);/* @__PURE__ */
|
|
14
|
-
return n("pre",{className:[s,r,l?"markstream-pre--line-numbers":"",u?"markstream-pre--diff-preview":"",u&&i?"markstream-pre--diff-inline":""].filter(Boolean).join(" "),style:a,"aria-busy":!0===(null==t?void 0:t.loading),"aria-label":d,"data-language":c,"data-markstream-line-numbers":l?"1":void 0,"data-markstream-pre":"1",tabIndex:0,children:/* @__PURE__ */n("code",u?{translate:"no",className:"markstream-pre__diff-code",children:m.map(t=>/* @__PURE__ */n("span",{className:["markstream-pre__diff-pane",t.className].join(" "),children:t.lines.map(t=>/* @__PURE__ */e("span",{className:["markstream-pre__diff-line",`markstream-pre__diff-line--${t.kind}`,t.empty?"markstream-pre__diff-line--empty":""].filter(Boolean).join(" "),children:[
|
|
15
|
-
/* @__PURE__ */n("span",{className:"markstream-pre__diff-rail","aria-hidden":"true"}),
|
|
16
|
-
/* @__PURE__ */n("span",{className:"markstream-pre__diff-number","aria-hidden":"true",children:t.number}),
|
|
17
|
-
/* @__PURE__ */n("span",{className:"markstream-pre__diff-content",children:/* @__PURE__ */n("span",{className:"markstream-pre__diff-content-inner",children:t.code})})]},t.key))},t.key))}:{translate:"no",children:h})})}const kn={isShowPreview:!0,loading:!0,stream:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0},bn=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});function Cn(e){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:void 0}function Mn(e){var n;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const t=e;return{...bn,...t,enabled:null==(n=t.enabled)||n}}return{...bn}}function Nn(e,n){var t,r;const o=n?{...n}:{};if(!e)return o;const i=void 0===o.diffHideUnchangedRegions?{...bn}:Mn(o.diffHideUnchangedRegions),l=void 0===o.hideUnchangedRegions?void 0:Mn(o.hideUnchangedRegions),a=null!=(t=o.diffUnchangedRegionStyle)?t:"line-info";return{maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:4,lineNumbersMinChars:2,glyphMargin:!1,minimap:{enabled:!1},renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,diffHideUnchangedRegions:i,useInlineViewWhenSpaceIsLimited:null!=(r=o.useInlineViewWhenSpaceIsLimited)&&r,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:a,diffHunkActionsOnHover:!1,diffHunkHoverHideDelayMs:160,...o,...void 0===l?{}:{hideUnchangedRegions:l},diffHideUnchangedRegions:i}}function Bn(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function Sn(e){const n=String(null!=e?e:"").match(/\d+(?:\.\d+)?/g);if(!n||n.length<3)return null;const[t,r,o]=n.slice(0,3).map(Number);return.2126*t+.7152*r+.0722*o}function Tn(r){var l;const a={...kn,...r},{node:u,isDark:m,loading:h,stream:f,isShowPreview:p,enableFontSizeControl:g,darkTheme:v,lightTheme:w,monacoOptions:y,themes:x,minWidth:k,maxWidth:b,showHeader:C,showCopyButton:M,showExpandButton:N,showPreviewButton:B,showCollapseButton:S,showFontSizeButtons:T,showTooltips:L}=a,E=c(null),A=c(null),H=c(null),I=c(null),W=c(null),F=c(null),O=c(null),j=c(0),z=c(null),K=c(null),V=Ne(),X=c(y),U=c(null),q=c(null),Y=c([]),Z=c(null),G=c(!1),[J,Q]=i(!1),[ee,ne]=i(()=>"undefined"==typeof window),[te,re]=i(!1),[oe,ie]=i(!1),[le,ae]=i(!1),[ce,se]=i(()=>u.language||"plaintext"),[de,ue]=i(()=>D(u.language)),[me,he]=i(!1),[fe,pe]=i(!1),[ge,ve]=i(!1),[we,ye]=i(!1),[xe,ke]=i(0),{t:be}=Ee();s(()=>{G.current=fe},[fe]);const Ce=o(()=>Nn(Boolean(u.diff),y),[y,u.diff]),[Me,Be]=i(()=>{var e;const n=Number(null==(e=Nn(Boolean(u.diff),y))?void 0:e.fontSize);return Number.isFinite(n)&&n>0?n:12}),[Se,Te]=i(Me),Le=o(()=>!1!==L,[L]),De=d(()=>{var e,n;const t=null!=(n=null==(e=X.current)?void 0:e.MAX_HEIGHT)?n:500;if("number"==typeof t&&Number.isFinite(t))return Math.max(80,t);const r=String(t).match(/^(\d+(?:\.\d+)?)/),o=r?Number.parseFloat(r[1]):500;return Number.isFinite(o)?Math.max(80,o):500},[]),$e=d(e=>{var n,t,r,o;if(J)return;const i=E.current,l=H.current;if(!i||!l)return;const a="diff"===F.current?null==(n=l.getDiffEditorView)?void 0:n.call(l):null==(t=l.getEditorView)?void 0:t.call(l);if(!a)return;const c=De();try{null==(r=a.updateOptions)||r.call(a,{automaticLayout:e})}catch{}const s="diff"===F.current,d=s?"important":"";e?(i.style.minHeight="0px",i.style.setProperty("max-height","none",d),i.style.overflow="visible"):(i.style.minHeight="0px",i.style.setProperty("max-height",`${Math.ceil(c)}px`,d),i.style.overflow=s?"hidden":"auto");try{const n=()=>{if(s){const e=function(e){if("undefined"==typeof window)return null;try{const n=e.getBoundingClientRect();if(n.width<=0)return null;const t=[".editor.original .view-lines .view-line",".editor.modified .view-lines .view-line",".editor.original .margin-view-overlays .line-numbers",".editor.modified .margin-view-overlays .line-numbers",".editor.original .view-zones > div",".editor.modified .view-zones > div",".editor.original .margin-view-zones > div",".editor.modified .margin-view-zones > div",".editor.original .diff-hidden-lines",".editor.modified .diff-hidden-lines",".stream-monaco-diff-unchanged-bridge"];let r=0;for(const o of Array.from(e.querySelectorAll(t.join(",")))){if(!(o instanceof HTMLElement))continue;const e=window.getComputedStyle(o);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const t=o.getBoundingClientRect();t.height<=0||t.bottom<=n.top||(r=Math.max(r,t.bottom-n.top))}return r>0?Math.ceil(r+4):null}catch{return null}}(i);if(null!=e)return e}if("function"==typeof a.getContentHeight)return a.getContentHeight();if(s&&"function"==typeof a.getModifiedEditor){const e=a.getModifiedEditor();if(e&&"function"==typeof e.getContentHeight)return e.getContentHeight()}},t=Number(n());if(Number.isFinite(t)&&t>0){const n=e?t:Math.min(t,c);i.style.setProperty("height",`${Math.ceil(Math.max(1,n))}px`,d)}null==(o=a.layout)||o.call(a)}catch{}},[De,J]),Pe=d(e=>{if($e(e),"undefined"==typeof window||"function"!=typeof window.requestAnimationFrame)return;const n=window.requestAnimationFrame(()=>{$e(e),window.requestAnimationFrame(()=>$e(e))});return window.setTimeout(()=>$e(e),180),()=>window.cancelAnimationFrame(n)},[$e]),Re=d(()=>{var e,n;for(const t of Y.current)try{"function"==typeof t?t():null==(e=null==t?void 0:t.dispose)||e.call(t)}catch{}Y.current=[],null==(n=Z.current)||n.disconnect(),Z.current=null},[]),_e=d(()=>{var e,n,t;Re();const r=H.current,o=E.current;if(!r||!o||"diff"!==F.current)return;const i=()=>Pe(G.current),l=(e,n)=>{try{const t=null==e?void 0:e[n];if("function"!=typeof t)return;const r=t.call(e,i);r&&Y.current.push(r)}catch{}},a=null==(e=r.getDiffEditorView)?void 0:e.call(r),c=null==(n=null==a?void 0:a.getOriginalEditor)?void 0:n.call(a),s=null==(t=null==a?void 0:a.getModifiedEditor)?void 0:t.call(a);if(l(a,"onDidUpdateDiff"),l(c,"onDidContentSizeChange"),l(s,"onDidContentSizeChange"),l(c,"onDidLayoutChange"),l(s,"onDidLayoutChange"),"undefined"!=typeof window&&"function"==typeof window.MutationObserver){const e=new window.MutationObserver(e=>{e.some(e=>"childList"===e.type||"attributes"===e.type&&e.target!==o)&&i()});e.observe(o,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),Z.current=e}},[Re,Pe]);s(()=>$(()=>{ke(e=>e+1)}),[]),s(()=>{ue(D(u.language))},[u.language]);const Ae=c(u);Ae.current=u;const He=d(()=>{var e;j.current+=1;try{null==(e=I.current)||e.call(I)}catch{}Re(),W.current=null,F.current=null,O.current=null,ae(!1),ie(!1)},[Re]),Ie=d(()=>{var e,n,t,r,o,i;const l=E.current,a=A.current;if(!l||!a)return;if(u.diff)return a.style.removeProperty("--vscode-editor-foreground"),a.style.removeProperty("--vscode-editor-background"),void a.style.removeProperty("--vscode-editor-selectionBackground");const c=null!=(e=l.querySelector(".monaco-editor"))?e:l;try{const e="undefined"!=typeof window&&window.getComputedStyle?window.getComputedStyle(c):null,l=String(null!=(n=null==e?void 0:e.getPropertyValue("--vscode-editor-foreground"))?n:"").trim()||String(null!=(t=null==e?void 0:e.color)?t:"").trim(),s=String(null!=(r=null==e?void 0:e.getPropertyValue("--vscode-editor-background"))?r:"").trim()||String(null!=(o=null==e?void 0:e.backgroundColor)?o:"").trim(),d=String(null!=(i=null==e?void 0:e.getPropertyValue("--vscode-editor-selectionBackground"))?i:"").trim();if(function(e,n,t,r){if(!t)return!1;const o=Sn(e),i=Sn(n);return r?null!=o&&o>170||null!=i&&i<110:null!=o&&o<85||null!=i&&i>190}(s,l,"plaintext"===P(String(u.language||de||ce||"plaintext")),a.classList.contains("is-dark")))return a.style.removeProperty("--vscode-editor-foreground"),a.style.removeProperty("--vscode-editor-background"),void a.style.removeProperty("--vscode-editor-selectionBackground");l&&a.style.setProperty("--vscode-editor-foreground",l),s&&a.style.setProperty("--vscode-editor-background",s),d&&a.style.setProperty("--vscode-editor-selectionBackground",d)}catch{}},[de,ce,u.diff,u.language]),Oe=o(()=>m?v:w,[v,m,w]),je=d(()=>{var e;const n=null==Ce?void 0:Ce.theme,t=null!=(e=null!=Oe?Oe:n)?e:on,r=Array.isArray(x)?x:[];if(!r.length||null==t)return t;const o=Bn(t),i=r.map(e=>Bn(e)).filter(e=>!!e);if(!o||i.includes(o))return t;const l=Bn(n);return null!=n&&l&&i.includes(l)?n:r[0]},[Oe,Ce,x]),Ke=o(()=>je(),[je]),Ve=o(()=>function(e,n){var t;const r=(null!=(t=Bn(e))?t:"").toLowerCase();return r?["dark","night","moon","black","dracula","mocha","frappe","macchiato","palenight","ocean","poimandres","monokai","laserwave","tokyo","slack-dark","rose-pine","github-dark","material-theme","one-dark","catppuccin-mocha","catppuccin-frappe","catppuccin-macchiato"].some(e=>r.includes(e))&&!["light","latte","dawn","lotus"].some(e=>r.includes(e)):n}(Ke,Boolean(m)),[m,Ke]),Xe=o(()=>{if(!u.diff)return Ve?"dark":"light";const e=null==Ce?void 0:Ce.diffAppearance;return"light"===e||"dark"===e?e:m?"dark":"light"},[m,u.diff,Ve,Ce]),qe=o(()=>u.diff?"dark"===Xe:Ve,[Xe,u.diff,Ve]),Ye=o(()=>{var e,n,t,r;const o=Ce,i=null!=(n=null!=(e=Cn(null==o?void 0:o.fontSize))?e:Se)?n:12,l=null!=(t=Cn(null==o?void 0:o.lineHeight))?t:12===i?18:Math.max(12,Math.round(1.5*i)),a="string"==typeof(null==o?void 0:o.fontFamily)&&o.fontFamily.trim()?o.fontFamily.trim():void 0,c=function(e){var n,t;if(!e||"object"!=typeof e)return{top:0,bottom:0};const r=e;return{top:null!=(n=Cn(r.top))?n:0,bottom:null!=(t=Cn(r.bottom))?t:0}}(null==o?void 0:o.padding),s=null!=(r=Cn(null==o?void 0:o.tabSize))?r:4;return{fontFamily:a,fontSize:i,lineHeight:l,paddingBottom:c.bottom,paddingTop:c.top,tabSize:s}},[Se,Ce]),Ze=o(()=>!!u.diff&&!1===(null==Ce?void 0:Ce.renderSideBySide),[u.diff,Ce]),Ge=o(()=>{const e={"--markstream-code-padding-left":"62px","--markstream-pre-diff-line-height":`${Ye.lineHeight}px`,"--markstream-pre-line-number-top":`${Ye.paddingTop}px`,"--markstream-pre-line-number-width":"36px","--markstream-pre-line-number-gap":"0px",fontSize:`${Ye.fontSize}px`,lineHeight:`${Ye.lineHeight}px`,paddingBottom:`${Ye.paddingBottom}px`,paddingTop:`${Ye.paddingTop}px`,tabSize:Ye.tabSize};return Ye.fontFamily&&(e.fontFamily=Ye.fontFamily),e},[Ye]),Je=d(()=>{const e={wordWrap:"on",wrappingIndent:"same",themes:x,...Ce||{},theme:Ke,...u.diff?{diffAppearance:Xe}:{},onThemeChange(){Ie()}};return u.diff&&(null!=e.fontSize||(e.fontSize=Ye.fontSize),null!=e.lineHeight||(e.lineHeight=Ye.lineHeight),null!=e.padding||(e.padding={top:Ye.paddingTop,bottom:Ye.paddingBottom}),null!=e.tabSize||(e.tabSize=Ye.tabSize),Ye.fontFamily&&(null!=e.fontFamily||(e.fontFamily=Ye.fontFamily))),e},[Xe,u.diff,Ye,Ke,Ce,Ie,x]),Qe=d(()=>{const e=Je(),n=U.current;if(!n)return U.current=e,e;for(const t of Object.keys(n))t in e||delete n[t];return Object.assign(n,e),n},[Je]),en=o(()=>{var e,n,t,r,o,i,l;return JSON.stringify({diffLineStyle:null!=(e=null==Ce?void 0:Ce.diffLineStyle)?e:"background",diffUnchangedRegionStyle:null!=(n=null==Ce?void 0:Ce.diffUnchangedRegionStyle)?n:"line-info",diffHideUnchangedRegions:null==(t=null==Ce?void 0:Ce.diffHideUnchangedRegions)||t,renderSideBySide:null==(r=null==Ce?void 0:Ce.renderSideBySide)||r,enableSplitViewResizing:null==(o=null==Ce?void 0:Ce.enableSplitViewResizing)||o,ignoreTrimWhitespace:null==(i=null==Ce?void 0:Ce.ignoreTrimWhitespace)||i,originalEditable:null!=(l=null==Ce?void 0:Ce.originalEditable)&&l})},[Ce]);s(()=>{X.current=Ce,Qe()},[Ce,Qe]),s(()=>()=>{var e,n,t;j.current+=1,null==(e=I.current)||e.call(I),Re(),I.current=null,W.current=null,F.current=null,O.current=null,z.current=null,null==(t=null==(n=K.current)?void 0:n.destroy)||t.call(n),K.current=null},[Re]),s(()=>{var e,n;if("undefined"==typeof window)return;if(ee)return;const t=A.current;if(!t)return;null==(n=null==(e=K.current)?void 0:e.destroy)||n.call(e);const r=V(t,{rootMargin:"400px"});return K.current=r,r.isVisible()&&ne(!0),r.whenVisible.then(()=>ne(!0)),()=>{r.destroy(),K.current===r&&(K.current=null)}},[V,ee]),s(()=>{let e=!0;return"undefined"==typeof window?()=>{e=!1}:H.current?(Qe(),()=>{e=!1}):((async()=>{try{const t=await Ue();if(!e)return;if(!t)return void Q(!0);const r=t.useMonaco,o=t.detectLanguage;if("function"==typeof o&&(z.current=o),"function"!=typeof r)return void Q(!0);const i=r(Qe());H.current=i,"function"==typeof(n=i.setTheme)&&(an=n,null!=on&&null!=ln&&rn(on,an).then(()=>un()).catch(()=>{})),I.current="function"==typeof i.safeClean?()=>i.safeClean():"function"==typeof i.cleanupEditor?()=>i.cleanupEditor():null,re(!0)}catch{e&&Q(!0)}var n})(),()=>{e=!1})},[Qe]),s(()=>{var e;if(!u.language&&!de&&z.current)try{const n=z.current(String(null!=(e=u.code)?e:""));n&&se(n)}catch{}},[de,u.code,u.language]);const nn=o(()=>String(u.language||de||ce||"plaintext"),[de,ce,u.language]),tn=o(()=>D(nn),[nn]),sn=o(()=>P(tn),[tn]),dn=o(()=>"plaintext"===sn,[sn]),mn=o(()=>R(tn),[tn,xe]),hn=o(()=>!!p&&("html"===tn||"svg"===tn),[tn,p]),fn=o(()=>{const e=tn;return e?_[e]||e.charAt(0).toUpperCase()+e.slice(1):_[""]||"Plain Text"},[tn]),pn=o(()=>{var e,n,t;return u.diff?null!=(n=null!=(e=u.updatedCode)?e:u.code)?n:"":null!=(t=u.code)?t:""},[u.code,u.diff,u.updatedCode]),gn=o(()=>{const e=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},n={},t=e(k),r=e(b);return t&&(n.minWidth=t),r&&(n.maxWidth=r),u.diff?(n.color="var(--markstream-diff-shell-fg)",n.borderColor="var(--markstream-diff-shell-border)"):(n.color=`var(--vscode-editor-foreground, ${qe?"#e5e7eb":"#111827"})`,n.backgroundColor=`var(--vscode-editor-background, ${qe?"#111827":"#ffffff"})`,n.borderColor=qe?"rgb(55 65 81 / 0.3)":"rgb(229 231 235)"),n},[b,k,u.diff,qe]),vn=o(()=>{if(!u.diff)return{color:`var(--vscode-editor-foreground, ${qe?"#e5e7eb":"#111827"})`,backgroundColor:`var(--vscode-editor-background, ${qe?"#111827":"#ffffff"})`}},[u.diff,qe]),wn=!1===f&&h;s(()=>{if(J)return;if(!te)return;if(!oe||!ee)return;const e=H.current;Qe();const n=()=>{var n;u.diff&&(null==(n=null==e?void 0:e.refreshDiffPresentation)||n.call(e)),Ie(),ge||null==("undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>Pe(fe)):null)&&Pe(fe)};(null==e?void 0:e.setTheme)&&Ke?rn(Ke,e.setTheme).then(n).catch(()=>{}):n()},[ge,oe,Xe,fe,te,u.diff,Ke,Pe,Ie,Qe,J,ee]),s(()=>{var e;if("undefined"!=typeof window)return e=()=>{Ie()},cn.add(e),()=>{cn.delete(e)}},[Ie]);const yn=d(async()=>{var e,n;if(J)return null;if(!ee)return null;if(ge)return null;if(wn)return null;const t=H.current,r=E.current;if(!t||!r||!t.createEditor)return null;Qe();const o=Ae.current,i=o.diff?"diff":"single",l=O.current,a="diff"===i?Boolean(null==(e=t.getDiffEditorView)?void 0:e.call(t)):Boolean(null==(n=t.getEditorView)?void 0:n.call(t));if(F.current===i&&l===r&&a)return null;if(W.current)return W.current;j.current+=1;const c=j.current;ie(!0);const s=(async()=>{var e,n,i,l,a,s,d,u,m,h;try{null==(e=I.current)||e.call(I),F.current=null,O.current=null,ae(!1);const f=sn;if(o.diff?"function"==typeof t.createDiffEditor?(F.current="diff",await t.createDiffEditor(r,String(null!=(n=o.originalCode)?n:""),String(null!=(i=o.updatedCode)?i:""),f)):(F.current="single",await t.createEditor(r,String(null!=(a=null!=(l=o.updatedCode)?l:o.code)?a:""),f)):(F.current="single",await t.createEditor(r,String(null!=(s=o.code)?s:""),f)),O.current=r,j.current!==c)return;const p=Number(null==(d=X.current)?void 0:d.fontSize);if(Number.isFinite(p)&&p>0){Be(p),Te(p);try{const e="diff"===F.current?null==(u=t.getDiffEditorView)?void 0:u.call(t):null==(m=t.getEditorView)?void 0:m.call(t);null==(h=null==e?void 0:e.updateOptions)||h.call(e,{fontSize:p,automaticLayout:!1})}catch{}}_e(),Ie(),fe||ge||Pe(!1),ae(!0)}catch{j.current===c&&Q(!0)}})().finally(()=>{W.current===s&&(W.current=null)});return W.current=s,s},[_e,Re,ge,fe,sn,Pe,wn,Ie,Qe,J,ee]);s(()=>{Qe();const e=q.current;if(q.current=en,!u.diff)return;if(J)return;if(!te||!ee||!oe)return;if(ge||wn)return;if(e===en)return;let n=!1;return(async()=>{if(He(),!n)try{await yn()}catch{}})(),()=>{n=!0}},[ge,oe,yn,te,en,u.diff,He,wn,Qe,J,ee]),s(()=>{J||te&&ee&&(ge||wn?He():yn())},[ge,yn,te,He,wn,J,ee]),s(()=>{var e;if(J)return;if(!te)return;if(!ee)return;if(ge)return;if(wn)return;const n=H.current;if(!n)return;const t=String(null!=(e=u.code)?e:"");(async()=>{var e,r;let o=de;if(!o&&z.current)try{o=D(z.current(t)),o&&ue(o)}catch{}const i=P(o||tn);if(n.createEditor&&E.current){try{await Promise.resolve(yn())}catch{}const e=W.current;if(e)try{await e}catch{}}try{u.diff&&n.updateDiff?await Promise.resolve(n.updateDiff(String(null!=(e=u.originalCode)?e:""),String(null!=(r=u.updatedCode)?r:""),i)):n.updateCode&&await Promise.resolve(n.updateCode(t,i))}catch{}Pe(fe)})()},[tn,de,ge,oe,yn,fe,te,u.code,u.diff,u.originalCode,u.updatedCode,Pe,wn,J,ee]),s(()=>{if(J)return;if(!te)return;if(!ee)return;if(ge)return;if(wn)return;if(!fe&&h)return;const e="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>Pe(fe)):null;return null==e&&Pe(fe),()=>{null!=e&&"undefined"!=typeof window&&"function"==typeof window.cancelAnimationFrame&&window.cancelAnimationFrame(e)}},[ge,fe,h,te,Pe,wn,J,ee]),s(()=>{var e,n,t;if(!g)return;if(J)return;const r=H.current;if(r){try{const o="diff"===F.current?null==(e=r.getDiffEditorView)?void 0:e.call(r):null==(n=r.getEditorView)?void 0:n.call(r);null==(t=null==o?void 0:o.updateOptions)||t.call(o,{fontSize:Se})}catch{}Pe(fe)}},[g,fe,Se,u.diff,Pe,J]),s(()=>{Le||Fe(!0)},[Le]);const bn=d((e,n)=>{if(!Le)return;const t=e.currentTarget;t&&!t.disabled&&("clientX"in e&&(e.clientX,e.clientY),We(t,n,"top",!1,0,qe))},[qe,Le]),Mn=d(()=>{Le&&Fe()},[Le]),Tn=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(String(pn)),he(!0),null==(e=a.onCopy)||e.call(a,String(pn)),setTimeout(()=>he(!1),1e3)}catch{}},[a,pn]),Ln=d(()=>{if(!hn)return;const e="html"===tn?"text/html":"image/svg+xml",n="html"===tn?be("artifacts.htmlPreviewTitle")||"HTML Preview":be("artifacts.svgPreviewTitle")||"SVG Preview";"function"!=typeof a.onPreviewCode?"html"===tn&&ye(e=>!e):a.onPreviewCode({node:u,artifactType:e,artifactTitle:n,id:`temp-${tn}-${Date.now()}`})},[tn,hn,u,a,be]);return J?/* @__PURE__ */n(xn,{className:"code-fallback-plain m-0",diffInline:Ze,node:u,showLineNumbers:Boolean(u.diff),style:Ge}):/* @__PURE__ */e("div",{ref:A,className:["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",qe?"border-gray-700/30 bg-gray-900":"border-gray-200 bg-white",h?"is-rendering":"",qe?"is-dark":"",u.diff?"is-diff":"",dn?"is-plain-text":""].join(" "),style:gn,children:[C&&/* @__PURE__ */e("div",{className:"code-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5",style:vn,children:[
|
|
18
|
-
/* @__PURE__ */e("div",{className:"flex items-center space-x-2 flex-1 overflow-hidden",children:[
|
|
19
|
-
/* @__PURE__ */n("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:mn}}),
|
|
20
|
-
/* @__PURE__ */n("span",{className:"text-sm font-medium font-mono truncate",children:fn})]}),
|
|
21
|
-
/* @__PURE__ */e("div",{className:"flex items-center space-x-2",children:[S&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":ge,onClick:()=>ve(e=>!e),onMouseEnter:e=>bn(e,ge?be("common.expand")||"Expand":be("common.collapse")||"Collapse"),onFocus:e=>bn(e,ge?be("common.expand")||"Expand":be("common.collapse")||"Collapse"),onMouseLeave:Mn,onBlur:Mn,children:/* @__PURE__ */n("svg",{style:{rotate:ge?"0deg":"90deg"},xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),T&&g&&/* @__PURE__ */e(t,{children:[
|
|
22
|
-
/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:Se<=10,onClick:()=>Te(e=>Math.max(10,e-1)),onMouseEnter:e=>bn(e,be("common.decrease")||"Decrease"),onFocus:e=>bn(e,be("common.decrease")||"Decrease"),onMouseLeave:Mn,onBlur:Mn,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14"})})}),
|
|
23
|
-
/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:Se===Me,onClick:()=>Te(Me),onMouseEnter:e=>bn(e,be("common.reset")||"Reset"),onFocus:e=>bn(e,be("common.reset")||"Reset"),onMouseLeave:Mn,onBlur:Mn,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
24
|
-
/* @__PURE__ */n("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),
|
|
25
|
-
/* @__PURE__ */n("path",{d:"M3 3v5h5"})]})})}),
|
|
26
|
-
/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:Se>=36,onClick:()=>Te(e=>Math.min(36,e+1)),onMouseEnter:e=>bn(e,be("common.increase")||"Increase"),onFocus:e=>bn(e,be("common.increase")||"Increase"),onMouseLeave:Mn,onBlur:Mn,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14m-7-7v14"})})})]}),M&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":me?be("common.copied")||"Copied":be("common.copy")||"Copy",onClick:Tn,onMouseEnter:e=>bn(e,me?be("common.copied")||"Copied":be("common.copy")||"Copy"),onFocus:e=>bn(e,me?be("common.copied")||"Copied":be("common.copy")||"Copy"),onMouseLeave:Mn,onBlur:Mn,children:/* @__PURE__ */n("svg",me?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
27
|
-
/* @__PURE__ */n("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
|
|
28
|
-
/* @__PURE__ */n("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),N&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":fe,onClick:e=>{pe(e=>!e),bn(e,fe?be("common.expand")||"Expand":be("common.collapse")||"Collapse")},onMouseEnter:e=>bn(e,fe?be("common.collapse")||"Collapse":be("common.expand")||"Expand"),onFocus:e=>bn(e,fe?be("common.collapse")||"Collapse":be("common.expand")||"Expand"),onMouseLeave:Mn,onBlur:Mn,children:/* @__PURE__ */n("svg",fe?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})}),hn&&B&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":be("common.preview")||"Preview",onClick:Ln,onMouseEnter:e=>bn(e,be("common.preview")||"Preview"),onFocus:e=>bn(e,be("common.preview")||"Preview"),onMouseLeave:Mn,onBlur:Mn,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",children:/* @__PURE__ */e("g",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",children:[
|
|
29
|
-
/* @__PURE__ */n("path",{d:"M23.628 7.41c-.12-1.172-.08-3.583-.9-4.233c-1.921-1.51-6.143-1.11-8.815-1.19c-3.481-.15-7.193.14-10.625.24a.34.34 0 0 0 0 .67c3.472-.05 7.074-.29 10.575-.09c2.471.15 6.653-.14 8.254 1.16c.4.33.41 2.732.49 3.582a42 42 0 0 1 .08 9.005a13.8 13.8 0 0 1-.45 3.001c-2.42 1.4-19.69 2.381-20.72.55a21 21 0 0 1-.65-4.632a41.5 41.5 0 0 1 .12-7.964c.08 0 7.334.33 12.586.24c2.331 0 4.682-.13 6.764-.21a.33.33 0 0 0 0-.66c-7.714-.16-12.897-.43-19.31.05c.11-1.38.48-3.922.38-4.002a.3.3 0 0 0-.42 0c-.37.41-.29 1.77-.36 2.251s-.14 1.07-.2 1.6a45 45 0 0 0-.36 8.645a21.8 21.8 0 0 0 .66 5.002c1.46 2.702 17.248 1.461 20.95.43c1.45-.4 1.69-.8 1.871-1.95c.575-3.809.602-7.68.08-11.496"}),
|
|
30
|
-
/* @__PURE__ */n("path",{d:"M4.528 5.237a.84.84 0 0 0-.21-1c-.77-.41-1.71.39-1 1.1a.83.83 0 0 0 1.21-.1m2.632-.25c.14-.14.19-.84-.2-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.2-.09m2.88 0a.83.83 0 0 0-.21-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.21-.09m-4.29 8.735c0 .08.23 2.471.31 2.561a.371.371 0 0 0 .63-.14c0-.09 0 0 .15-1.72a10 10 0 0 0-.11-2.232a5.3 5.3 0 0 1-.26-1.37a.3.3 0 0 0-.54-.24a6.8 6.8 0 0 0-.2 2.33c-1.281-.38-1.121.13-1.131-.42a15 15 0 0 0-.19-1.93c-.16-.17-.36-.17-.51.14a20 20 0 0 0-.43 3.471c.04.773.18 1.536.42 2.272c.26.4.7.22.7-.1c0-.09-.16-.09 0-1.862c.06-1.18-.23-.3 1.16-.76m5.033-2.552c.32-.07.41-.28.39-.37c0-.55-3.322-.34-3.462-.24s-.2.18-.18.28s0 .11 0 .16a3.8 3.8 0 0 0 1.591.361v.82a15 15 0 0 0-.13 3.132c0 .2-.09.94.17 1.16a.34.34 0 0 0 .48 0c.125-.35.196-.718.21-1.09a8 8 0 0 0 .14-3.232c0-.13.05-.7-.1-.89a8 8 0 0 0 .89-.09m5.544-.181a.69.69 0 0 0-.89-.44a2.8 2.8 0 0 0-1.252 1.001a2.3 2.3 0 0 0-.41-.83a1 1 0 0 0-1.6.27a7 7 0 0 0-.35 2.07c0 .571 0 2.642.06 2.762c.14 1.09 1 .51.63.13a17.6 17.6 0 0 1 .38-3.962c.32-1.18.32.2.39.51s.11 1.081.73 1.081s.48-.93 1.401-1.78q.075 1.345 0 2.69a15 15 0 0 0 0 1.811a.34.34 0 0 0 .68 0q.112-.861.11-1.73a16.7 16.7 0 0 0 .12-3.582m1.441-.201c-.05.16-.3 3.002-.31 3.202a6.3 6.3 0 0 0 .21 1.741c.33 1 1.21 1.07 2.291.82a3.7 3.7 0 0 0 1.14-.23c.21-.22.10-.59-.41-.64q-.817.096-1.64.07c-.44-.07-.34 0-.67-4.442q.015-.185 0-.37a.316.316 0 0 0-.23-.38a.316.316 0 0 0-.38.23"})]})})})]})]}),
|
|
31
|
-
/* @__PURE__ */e("div",{className:`code-block-body${ge?" code-block-body--collapsed":""}${fe?" code-block-body--expanded":""}`,children:[!ge&&(!!f||!h)&&(J?/* @__PURE__ */n(xn,{node:u}):/* @__PURE__ */e("div",{className:"code-editor-layer",children:[
|
|
32
|
-
/* @__PURE__ */n("div",{ref:E,className:"code-editor-container"+(f?"":" code-height-placeholder"),style:{visibility:le?"visible":"hidden"},"aria-hidden":!le}),!le&&/* @__PURE__ */n("div",{className:"code-editor-fallback-surface",children:/* @__PURE__ */n(xn,{className:"code-fallback-plain m-0",diffInline:Ze,node:u,showLineNumbers:Boolean(u.diff),style:Ge})})]})),!f&&h&&/* @__PURE__ */n("div",{className:"code-loading-placeholder",children:/* @__PURE__ */e("div",{className:"loading-skeleton",children:[
|
|
33
|
-
/* @__PURE__ */n("div",{className:"skeleton-line"}),
|
|
34
|
-
/* @__PURE__ */n("div",{className:"skeleton-line"}),
|
|
35
|
-
/* @__PURE__ */n("div",{className:"skeleton-line short"})]})})]}),we&&!a.onPreviewCode&&hn&&"html"===tn&&/* @__PURE__ */n(ze,{code:String(null!=(l=u.code)?l:""),htmlPreviewAllowScripts:a.htmlPreviewAllowScripts,htmlPreviewSandbox:a.htmlPreviewSandbox,isDark:m,onClose:()=>ye(!1)}),
|
|
36
|
-
/* @__PURE__ */n("span",{className:"sr-only","aria-live":"polite",role:"status",children:me?be("common.copied")||"Copied":""})]})}function Ln(e){var n,t,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(n=0;n<o;n++)e[n]&&(t=Ln(e[n]))&&(r&&(r+=" "),r+=t)}else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function En(){for(var e,n,t=0,r="",o=arguments.length;t<o;t++)(e=arguments[t])&&(n=Ln(e))&&(r&&(r+=" "),r+=n);return r}const Dn=()=>import("@terrastruct/d2");let $n=null,Pn=Dn;function Rn(e){Pn=e,$n=null}function _n(e){Rn(null!=e?e:Dn)}function An(){Rn(null)}function Hn(){return"function"==typeof Pn}async function In(){if($n)return $n;const e=Pn;if(!e)return null;let n;try{n=await e()}catch(t){if(e===Dn)throw new Error('Optional dependency "@terrastruct/d2" is not installed. Please install it to enable D2 diagrams.');throw t}return n?($n=function(e){var n;if(!e)return e;if(e.D2&&"function"==typeof e.D2)return e.D2;if(e.default&&e.default.D2&&"function"==typeof e.default.D2)return e.default.D2;const t=null!=(n=e.default)?n:e;return"function"==typeof t?t:(null==t?void 0:t.D2)&&"function"==typeof t.D2?t.D2:t}(n),$n):null}const Wn={maxHeight:"500px",loading:!0,progressiveRender:!0,progressiveIntervalMs:700,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showCollapseButton:!0},Fn={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"},On=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],jn=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function zn(e){if(!e)return"";const n=e.trim();return jn.test(n)?n:""}function Kn(r){var l,a;const u={...Wn,...r},{t:m}=Ee(),[h,f]=i(!1),[p,g]=i(!1),[v,w]=i(!1),[y,x]=i(!1),[k,b]=i(null),[C,M]=i(""),[N,B]=i(null),[S,T]=i(!1),[L,E]=i(()=>"undefined"==typeof window),D=c(0),$=c(null),P=c(!1),R=c(!1),_=c(0),A=c(null),H=c(!1),I=c(null),W=c(null),F=c(null),O=c(null),j=c(!1),z=c(()=>{}),K=Ne(),V=null!=(a=null==(l=u.node)?void 0:l.code)?a:"",X=v||!y||!C,U=!!C,q=o(()=>{if(u.maxHeight)return{maxHeight:"number"==typeof u.maxHeight?`${u.maxHeight}px`:String(u.maxHeight)}},[u.maxHeight]),Y=o(()=>{if(X&&N)return{minHeight:`${N}px`}},[N,X]);s(()=>{j.current=S},[S]),s(()=>{const e=I.current;if(!e)return;const n=K(e,{rootMargin:"160px"});return W.current=n,n.isVisible()&&E(!0),n.whenVisible.then(()=>E(!0)),()=>{n.destroy(),W.current=null}},[K]);const Z=d(()=>{const e=F.current;if(!e)return;const n=e.getBoundingClientRect().height;n>0&&B(e=>e!==n?n:e)},[]),G=d((e=!1)=>{if(P.current||"undefined"==typeof window)return;if(R.current)return;if(!L)return;if(j.current)return void(H.current=!0);const n=Math.max(120,Number(u.progressiveIntervalMs)||0),t=Date.now()-_.current;if(!e&&t<n)return H.current=!0,void(null==A.current&&(A.current=window.setTimeout(()=>{A.current=null,H.current&&(H.current=!1,G(!0))},Math.max(0,n-t))));P.current=!0;const r=()=>{P.current=!1,_.current=Date.now(),z.current()};"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(r):setTimeout(r,0)},[u.progressiveIntervalMs,L]),J=d(async()=>{if($.current)return $.current;const e=await In();if(!e)return null;if("function"==typeof e){const n=new e;return n&&"function"==typeof n.compile?$.current=n:"function"==typeof e.compile&&($.current=e),$.current}return(null==e?void 0:e.D2)&&"function"==typeof e.D2?($.current=new e.D2,$.current):("function"==typeof e.compile&&($.current=e),$.current)},[]),Q=d(async()=>{var e,n,t,r,o;if("undefined"==typeof window||R.current)return;if(!L)return;if(u.loading&&!u.progressiveRender)return;if(!V)return M(""),void b(null);const i=++D.current;T(!0),b(null);try{const l=await J();if(!l)return x(!1),w(!0),M(""),void b("D2 is not available.");if("function"!=typeof l.compile||"function"!=typeof l.render)throw new Error("D2 instance is missing compile/render methods.");x(!0);const a=await l.compile(V);if(i!==D.current)return;const c=null!=(e=null==a?void 0:a.diagram)?e:a,s=null!=(t=null!=(n=null==a?void 0:a.renderOptions)?n:null==a?void 0:a.options)?t:{},d=null!=(r=u.themeId)?r:s.themeID,m=null!=(o=u.darkThemeId)?o:s.darkThemeID,h={...s};if(h.themeID=u.isDark&&null!=m?m:d,h.darkThemeID=null,h.darkThemeOverrides=null,u.isDark){const e=s.themeOverrides&&"object"==typeof s.themeOverrides?s.themeOverrides:null;h.themeOverrides={...Fn,...e||{}}}const f=await l.render(c,h);if(i!==D.current)return;const p=function(e){return e?"string"==typeof e?e:"string"==typeof e.svg?e.svg:"string"==typeof e.data?e.data:"":""}(f);if(!p)throw new Error("D2 render returned empty output.");const g=function(e){if("undefined"==typeof window||"undefined"==typeof DOMParser)return"";if(!e)return"";const n=e.replace(/["']\s*javascript:/gi,"#").replace(/\bjavascript:/gi,"#").replace(/["']\s*vbscript:/gi,"#").replace(/\bvbscript:/gi,"#").replace(/\bdata:text\/html/gi,"#"),t=(new DOMParser).parseFromString(n,"image/svg+xml").documentElement;if(!t||"svg"!==t.nodeName.toLowerCase())return"";const r=t;return function(e){const n=/* @__PURE__ */new Set(["script"]),t=[e,...Array.from(e.querySelectorAll("*"))];for(const r of t){if(n.has(r.tagName.toLowerCase())){r.remove();continue}const e=Array.from(r.attributes);for(const n of e){const e=n.name;if(/^on/i.test(e))r.removeAttribute(e);else{if("style"===e&&n.value){const t=n.value;if(On.some(e=>e.test(t))){r.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&n.value){const t=zn(n.value);if(!t){r.removeAttribute(e);continue}t!==n.value&&r.setAttribute(e,t)}}}}}(r),r.classList.add("markstream-d2-root-svg"),r.outerHTML}(p);M(g||""),u.loading&&w(!1),b(null)}catch(l){if(i!==D.current)return;const e=(null==l?void 0:l.message)?String(l.message):"D2 render failed.";u.loading||b(e),e.includes("@terrastruct/d2")&&(x(!1),w(!0))}finally{i===D.current&&(T(!1),H.current&&(H.current=!1,G()))}},[V,J,u.darkThemeId,u.isDark,u.loading,u.progressiveRender,u.themeId,G,L]);s(()=>{z.current=Q},[Q]);const ee=d(async()=>{var e;try{(null==(e=null==navigator?void 0:navigator.clipboard)?void 0:e.writeText)&&await navigator.clipboard.writeText(V),f(!0),setTimeout(()=>f(!1),1e3)}catch{}},[V]),ne=d(()=>{if(C)try{const e=new Blob([C],{type:"image/svg+xml;charset=utf-8"}),n=URL.createObjectURL(e),t=document.createElement("a");t.href=n,t.download=`d2-diagram-${Date.now()}.svg`,document.body.appendChild(t),t.click(),document.body.removeChild(t),URL.revokeObjectURL(n)}catch(e){console.error("Failed to export SVG:",e)}},[C]),te=d((e,n)=>{var t;(t=e.currentTarget)&&!t.disabled&&We(e.currentTarget,n,"top",!1,(e.clientX,e.clientY),u.isDark)},[u.isDark]),re=d(()=>{Fe()},[]);return s(()=>{G()},[V,u.loading,u.isDark,G]),s(()=>{u.loading||G(!0)},[u.loading,G]),s(()=>{const e=requestAnimationFrame(()=>Z());return()=>cancelAnimationFrame(e)},[X,C,V,Z]),s(()=>{R.current=!1,G();const e=requestAnimationFrame(()=>Z());if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{Z()});O.current=e,F.current&&e.observe(F.current)}return()=>{var n;R.current=!0,null!=A.current&&(clearTimeout(A.current),A.current=null),null==(n=O.current)||n.disconnect(),O.current=null,cancelAnimationFrame(e)}},[G,Z]),/* @__PURE__ */e("div",{ref:I,className:En("d2-block my-4 rounded-lg border overflow-hidden shadow-sm",u.isDark?"border-gray-700/30 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900"),children:[u.showHeader&&/* @__PURE__ */e("div",{className:"d2-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5",style:{color:"var(--vscode-editor-foreground)",backgroundColor:"var(--vscode-editor-background)"},children:[
|
|
37
|
-
/* @__PURE__ */n("div",{className:"flex items-center gap-x-2",children:/* @__PURE__ */n("span",{className:"text-sm font-medium font-mono",children:"D2"})}),
|
|
38
|
-
/* @__PURE__ */e("div",{className:"flex items-center gap-x-2",children:[u.showModeToggle&&/* @__PURE__ */e("div",{className:En("flex items-center gap-x-1 rounded-md p-0.5",u.isDark?"bg-gray-700":"bg-gray-100"),children:[
|
|
39
|
-
/* @__PURE__ */n("button",{type:"button",className:En("mode-btn px-2 py-1 text-xs rounded",!v&&"is-active"),onClick:()=>w(!1),onMouseEnter:e=>te(e,m("common.preview")||"Preview"),onFocus:e=>te(e,m("common.preview")||"Preview"),onMouseLeave:re,onBlur:re,children:m("common.preview")||"Preview"}),
|
|
40
|
-
/* @__PURE__ */n("button",{type:"button",className:En("mode-btn px-2 py-1 text-xs rounded",v&&"is-active"),onClick:()=>w(!0),onMouseEnter:e=>te(e,m("common.source")||"Source"),onFocus:e=>te(e,m("common.source")||"Source"),onMouseLeave:re,onBlur:re,children:m("common.source")||"Source"})]}),u.showCopyButton&&/* @__PURE__ */n("button",{type:"button",className:"d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":h?m("common.copied")||"Copied":m("common.copy")||"Copy",onClick:ee,onMouseEnter:e=>te(e,h?m("common.copied")||"Copied":m("common.copy")||"Copy"),onFocus:e=>te(e,h?m("common.copied")||"Copied":m("common.copy")||"Copy"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */n("svg",h?{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
41
|
-
/* @__PURE__ */n("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
|
|
42
|
-
/* @__PURE__ */n("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),u.showExportButton&&C&&/* @__PURE__ */n("button",{type:"button",className:"d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":m("common.export")||"Export",onClick:ne,onMouseEnter:e=>te(e,m("common.export")||"Export"),onFocus:e=>te(e,m("common.export")||"Export"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 3v12m0-12l-4 4m4-4l4 4M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4"})})}),u.showCollapseButton&&/* @__PURE__ */n("button",{type:"button",className:"d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":p,onClick:()=>g(e=>!e),onMouseEnter:e=>te(e,p?m("common.expand")||"Expand":m("common.collapse")||"Collapse"),onFocus:e=>te(e,p?m("common.expand")||"Expand":m("common.collapse")||"Collapse"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */n("svg",{style:{transform:`rotate(${p?0:90}deg)`},xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})})]})]}),!p&&/* @__PURE__ */n("div",{ref:F,className:"d2-block-body",style:Y,children:u.loading&&!U?/* @__PURE__ */e("div",{className:"d2-source px-4 py-4",children:[
|
|
43
|
-
/* @__PURE__ */n("pre",{className:"d2-code",children:/* @__PURE__ */n("code",{children:V})}),k&&/* @__PURE__ */n("p",{className:"d2-error mt-2 text-xs",children:k})]}):/* @__PURE__ */n(t,{children:/* @__PURE__ */e("div",X?{className:"d2-source px-4 py-4",children:[
|
|
44
|
-
/* @__PURE__ */n("pre",{className:"d2-code",children:/* @__PURE__ */n("code",{children:V})}),k&&/* @__PURE__ */n("p",{className:"d2-error mt-2 text-xs",children:k})]}:{className:"d2-render",style:q,children:[
|
|
45
|
-
/* @__PURE__ */n("div",{className:"d2-svg",dangerouslySetInnerHTML:{__html:C}}),k&&/* @__PURE__ */n("p",{className:"d2-error px-4 pb-3 text-xs",children:k})]})})})]})}function Vn(t){const{node:r,ctx:o,renderNode:i,indexKey:l}=t,a=Array.isArray(r.items)?r.items:[];/* @__PURE__ */
|
|
46
|
-
return n("dl",{className:"definition-list","data-index-key":l,children:a.map((t,r)=>/* @__PURE__ */e("div",{className:"mb-4",children:[
|
|
47
|
-
/* @__PURE__ */n("dt",{className:"definition-term font-semibold",children:o&&i?A(t.term,o,`${String(null!=l?l:"definition")}-term-${r}`,i):null}),
|
|
48
|
-
/* @__PURE__ */n("dd",{className:"definition-desc ml-4",children:o&&i?A(t.definition,o,`${String(null!=l?l:"definition")}-desc-${r}`,i):null})]},`${String(null!=l?l:"definition")}-${r}`))})}function Xn(e){var t;const{node:r}=e;/* @__PURE__ */
|
|
49
|
-
return n("span",{className:"emoji-node",children:null!=(t=r.name)?t:r.markup})}function Un(e){/* @__PURE__ */
|
|
50
|
-
return n("em",{className:"emphasis-node",children:e.children})}function qn(e){const{node:t}=e,r=d(e=>{var n;if(e.preventDefault(),"undefined"==typeof document)return;const r=document.getElementById(`fnref-${String(null!=(n=t.id)?n:"")}`);r&&r.scrollIntoView({behavior:"smooth"})},[t.id]);/* @__PURE__ */
|
|
51
|
-
return n("a",{className:"footnote-anchor text-sm hover:underline cursor-pointer",href:`#fnref-${t.id}`,title:`返回引用 ${t.id}`,onClick:r,children:"↩︎"})}function Yn(e){const{node:t,ctx:r,renderNode:o,indexKey:i}=e;/* @__PURE__ */
|
|
52
|
-
return n("div",{id:`fnref--${t.id}`,className:"footnote-node flex text-sm leading-relaxed border-t border-[var(--footnote-border,#eaecef)] pt-2",children:/* @__PURE__ */n("div",{className:"flex-1",children:r&&o?E(t.children,r,String(null!=i?i:`footnote-${t.id}`),o):null})})}function Zn(t){const{node:r}=t,i=o(()=>`#fnref--${r.id}`,[r.id]),l=o(()=>({href:i}),[i]),a=d(e=>{if(e.preventDefault(),"undefined"==typeof document)return;const n=document.querySelector(i);n&&n.scrollIntoView({behavior:"smooth"})},[i]);/* @__PURE__ */
|
|
53
|
-
return n("sup",{id:`fnref-${r.id}`,className:"footnote-reference",onClick:a,children:/* @__PURE__ */e("span",{...l,title:`查看脚注 ${r.id}`,className:"footnote-link cursor-pointer",children:["[",r.id,"]"]})})}function Gn(e){/* @__PURE__ */
|
|
54
|
-
return n("br",{className:"hard-break"})}function Jn(e){const{node:t,ctx:r,renderNode:o,indexKey:i,children:l}=e,a=Math.min(6,Math.max(1,Number(t.level)||1)),c=`h${a}`,s=null==t?void 0:t.attrs,{class:d,className:u,style:m,...h}=null!=s?s:{};/* @__PURE__ */
|
|
55
|
-
return n(c,{dir:"auto",className:En("heading-node font-semibold",`heading-${a}`,d,u),..."object"==typeof m&&null!=m?{style:m}:{},...h,children:null!=l?l:r&&o?E(t.children,r,String(null!=i?i:`heading-${a}`),o):null})}function Qn(e){/* @__PURE__ */
|
|
56
|
-
return n("mark",{className:"highlight-node",children:e.children})}function et(l){var a,d,m;const{node:v,placeholder:w,customId:y}=l,x=null!=(m=null!=(d=l.htmlPolicy)?d:null==(a=l.ctx)?void 0:a.htmlPolicy)?m:"safe",k=Ne(),[b,C]=i(null),M=c(null),[N,B]=i(()=>"undefined"==typeof window),[S,T]=i(v.content),L=Boolean(v.loading),D=u(H,I,I),$=o(()=>{var e;return null!=(e=l.customComponents)?e:W(y)},[y,l.customComponents,D]);s(()=>{var e;if("undefined"==typeof window)return void B(!0);if(null==(e=M.current)||e.destroy(),M.current=null,!L)return B(!0),void T(v.content);if(!b)return void B(!1);const n=k(b,{rootMargin:"400px"});return M.current=n,n.isVisible()&&B(!0),n.whenVisible.then(()=>B(!0)).catch(()=>{}),()=>{n.destroy(),M.current=null}},[b,L,v.content,k]),s(()=>()=>{var e;null==(e=M.current)||e.destroy(),M.current=null},[]),s(()=>{L&&!N||T(v.content)},[L,v.content,N]);const P=o(()=>{var e;const n=F(h(null!=(e=v.attrs)?e:void 0,x));return n?O(n):void 0},[x,v.attrs]),R=o(()=>{var e;return String(null!=(e=v.tag)?e:"").trim()},[v.tag]),_=o(()=>{var e;const n=F(h(null!=(e=v.attrs)?e:void 0,x,R));return n?O(n):void 0},[x,v.attrs,R]),A=o(()=>Array.isArray(v.children)?v.children:[],[v.children]),K=A.length>0&&!!R&&!f.has(R.toLowerCase())&&!p(R,x)&&!!l.ctx&&!!l.renderNode,V=o(()=>function(e){const n={...e||{}},t="string"==typeof n.className?n.className.trim():"";return n.className=t?`html-block-node ${t}`:"html-block-node",n}(_),[_]),X=o(()=>{var e;return"escape"!==x&&j(null!=(e=v.content)?e:"",$)},[$,x,v.content]),U=o(()=>X&&v.content?z(v.content,$,x):null,[$,x,v.content,X]),q=o(()=>g(null!=S?S:"",x),[x,S]),Y=o(()=>{var e;return K&&l.ctx&&l.renderNode?E(A,l.ctx,`${String(null!=(e=l.indexKey)?e:"html-block")}-structured`,l.renderNode):null},[K,l.ctx,l.indexKey,l.renderNode,A]),Z=/* @__PURE__ */n("div",{className:"html-block-node__placeholder",children:null!=w?w:/* @__PURE__ */e(t,{children:[
|
|
57
|
-
/* @__PURE__ */n("span",{className:"html-block-node__placeholder-bar"}),
|
|
58
|
-
/* @__PURE__ */n("span",{className:"html-block-node__placeholder-bar w-4/5"}),
|
|
59
|
-
/* @__PURE__ */n("span",{className:"html-block-node__placeholder-bar w-2/3"})]})});return K?r.createElement(R,{...V,ref:C},N?Y:Z):/* @__PURE__ */n("div",{ref:C,className:"html-block-node",...P,children:N?X&&U?/* @__PURE__ */n(t,{children:U}):/* @__PURE__ */n("div",{dangerouslySetInnerHTML:{__html:q}}):Z})}const nt=(()=>{try{return Boolean(!1)}catch{}return!1})();function tt(e){nt&&console.warn(e)}function rt(e,n,t=!1){const r=Object.entries(null!=n?n:{}),o=r.length>0?r.map(([e,n])=>""===n?` ${e}`:` ${e}="${n}"`).join(""):"";return t?`<${e}${o} />`:`<${e}${o}>`}function ot(e,n){Array.isArray(n)?e.push(...n):null!=n&&e.push(n)}function it(e,n,t,o,i,l){const a=V(e,o);if(v.has(e.toLowerCase())||!a&&w(e,l))return null;if(!a&&p(e,l))return[rt(e,n),...t,`</${e}>`];const c=X(n,l,e),s=c.key,d=null!=s&&""!==s?s:i;if(a){const n=o[e]||o[e.toLowerCase()],i=function(e){return y(e)}(c);return r.createElement(n,{...i,key:d},...t)}return r.createElement(e,{...O(c),key:d},...t)}function lt(e){var t,o,l;const{node:a,customId:d}=e,u=null!=(l=null!=(o=e.htmlPolicy)?o:null==(t=e.ctx)?void 0:t.htmlPolicy)?l:"safe",m=c(null),[h,f]=i(!1);s(()=>{f(!0)},[]);const y=W(d),x=r.useMemo(()=>{var e;return g(null!=(e=a.content)?e:"",u)},[u,a.content]),k=r.useMemo(()=>{const e=a.content;if(!e)return{mode:"html",content:""};if("escape"===u)return{mode:"html",content:e};if(!j(e,y))return{mode:"html",content:e};const n=function(e,n,t="safe"){if(!e)return[];try{const r=function(e,n,t="safe"){let r=0;const o=[],i=[];for(const l of e)if("text"===l.type){if(o.length>0&&o[o.length-1].hardBlocked)continue;(o.length>0?o[o.length-1].children:i).push(l.content)}else if("self_closing"===l.type){const e=V(l.tagName,n);if(v.has(l.tagName.toLowerCase())||!e&&w(l.tagName,t))continue;if(!e&&p(l.tagName,t)){(o.length>0?o[o.length-1].children:i).push(rt(l.tagName,l.attrs||{},!0));continue}const a=it(l.tagName,l.attrs||{},[],n,"ms-html-"+r++,t);ot(o.length>0?o[o.length-1].children:i,a)}else if("tag_open"===l.type){const e=o.length>0&&o[o.length-1].hardBlocked,r=V(l.tagName,n);o.push({tagName:l.tagName,children:[],attrs:l.attrs,customComponent:r,hardBlocked:e||v.has(l.tagName.toLowerCase())||!r&&w(l.tagName,t),softBlocked:!e&&!r&&p(l.tagName,t)})}else if("tag_close"===l.type){const e=l.tagName.toLowerCase();let a=-1;for(let n=o.length-1;n>=0;n--)if(o[n].tagName.toLowerCase()===e){a=n;break}if(-1!==a)for(;o.length>a;){const l=o.pop();let c;c=l.hardBlocked?null:l.softBlocked?[rt(l.tagName,l.attrs||{}),...l.children,`</${l.tagName}>`]:it(l.tagName,l.attrs||{},l.children,n,"ms-html-"+r++,t),o.length>0?ot(o[o.length-1].children,c):ot(i,c),l.tagName.toLowerCase()!==e&&o.length>a&&tt(`Auto-closing unclosed tag: <${l.tagName}>`)}else tt(`Ignoring closing tag with no matching opening tag: </${l.tagName}>`)}for(;o.length>0;){const e=o.pop();let l;l=e.hardBlocked?null:e.softBlocked?[rt(e.tagName,e.attrs||{}),...e.children,`</${e.tagName}>`]:it(e.tagName,e.attrs||{},e.children,n,"ms-html-"+r++,t),ot(i,l),tt(`Auto-closing unclosed tag: <${e.tagName}>`)}return i}(K(e),n,t);return r}catch(o){return r=o,nt&&console.error("Failed to parse HTML to React nodes:",r),null}var r}(e,y,u);return null===n?{mode:"html",content:e}:{mode:"dynamic",nodes:n}},[y,u,a.content]);return s(()=>{if(!h||!m.current||"html"!==k.mode)return;const e=m.current;e.innerHTML="";const n=document.createElement("template");n.innerHTML=x,e.appendChild(n.content.cloneNode(!0))},[k.mode,h,x]),a.loading&&!a.autoClosed?/* @__PURE__ */n("span",{className:"html-inline-node html-inline-node--loading",children:a.content}):"dynamic"===k.mode?/* @__PURE__ */n("span",{className:"html-inline-node",style:{display:"inline"},children:k.nodes}):/* @__PURE__ */n("span",{ref:m,className:"html-inline-node",style:{display:"inline"}})}const at={fallbackSrc:"",lazy:!0,usePlaceholder:!0};function ct(e,n,t){return t||e?{src:e,stage:"primary"}:n?{src:n,stage:"fallback"}:{src:"",stage:"failed"}}function st(r){var o,l,a,c,d,u;const m={...at,...r},h=x(m.node.src),f=x(m.fallbackSrc),p=ct(h,f,m.node.loading),[g,v]=i(!1),[w,y]=i(!1),[k,b]=i(p.src),[C,M]=i(p.stage),N=k;s(()=>{const e=ct(h,f,m.node.loading);b(e.src),M(e.stage),v(!1),y("failed"===e.stage)},[h,f,m.node.loading]);return!m.node.loading&&"failed"!==C&&N?/* @__PURE__ */n("img",{src:N,alt:String(null!=(l=null!=(o=m.node.alt)?o:m.node.title)?l:""),title:String(null!=(c=null!=(a=m.node.title)?a:m.node.alt)?c:""),className:"image-node__img"+(g?" is-loaded":""),loading:m.lazy?"lazy":"eager",decoding:"async",tabIndex:g?0:-1,"aria-label":null!=(d=m.node.alt)?d:"Preview image",onError:()=>{var e;if("primary"===C&&f&&f!==k)return b(f),M("fallback"),v(!1),void y(!1);M("failed"),y(!0),null==(e=m.onError)||e.call(m,k)},onLoad:()=>{var e;v(!0),y(!1),null==(e=m.onLoad)||e.call(m,N)},onClick:e=>{var n;e.preventDefault(),g&&!w&&(null==(n=m.onClick)||n.call(m,[e,N]))}},"image"):m.node.loading&&!w?/* @__PURE__ */n("span",{className:"image-node__placeholder",children:m.usePlaceholder?/* @__PURE__ */e(t,{children:[
|
|
60
|
-
/* @__PURE__ */n("span",{className:"image-node__spinner","aria-hidden":"true"}),
|
|
61
|
-
/* @__PURE__ */n("span",{className:"image-node__placeholder-text",children:"Loading image..."})]}):/* @__PURE__ */n("span",{className:"image-node__placeholder-text",children:null!=(u=m.node.raw)?u:"Loading image…"})},"placeholder"):m.node.loading||"failed"!==C?null:/* @__PURE__ */e("span",{className:"image-node__error",children:[
|
|
62
|
-
/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24","aria-hidden":"true",children:/* @__PURE__ */n("path",{fill:"currentColor",d:"M2 2h20v10h-2V4H4v9.586l5-5L14.414 14L13 15.414l-4-4l-5 5V20h8v2H2zm13.547 5a1 1 0 1 0 0 2a1 1 0 0 0 0-2m-3 1a3 3 0 1 1 6 0a3 3 0 0 1-6 0m3.625 6.757L19 17.586l2.828-2.829l1.415 1.415L20.414 19l2.829 2.828l-1.415 1.415L19 20.414l-2.828 2.829l-1.415-1.415L17.586 19l-2.829-2.828z"})}),
|
|
63
|
-
/* @__PURE__ */n("span",{className:"image-node__placeholder-text",children:"Image failed to load"})]})}let dt=null,ut=null;const mt=/* @__PURE__ */n("svg",{width:"1em",height:"1em",viewBox:"0 0 291 300",fill:"none",className:"w-4 h-4 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",children:/* @__PURE__ */e("g",{children:[
|
|
64
|
-
/* @__PURE__ */n("path",{d:"M140.904 239.376C128.83 239.683 119.675 239.299 115.448 243.843C110.902 248.07 111.288 257.227 110.979 269.302C111.118 274.675 111.118 279.478 111.472 283.52C111.662 285.638 111.95 287.547 112.406 289.224C112.411 289.243 112.416 289.259 112.422 289.28C112.462 289.419 112.496 289.558 112.539 289.691C113.168 291.787 114.088 293.491 115.446 294.758C116.662 296.064 118.283 296.963 120.264 297.69C120.36 297.614 120.464 297.646 120.555 297.675C120.56 297.68 120.56 297.68 120.566 297.68C120.848 297.768 121.142 297.846 121.443 297.923C121.454 297.923 121.464 297.928 121.478 297.934C122.875 298.272 124.424 298.507 126.11 298.678C126.326 298.696 126.542 298.718 126.763 298.739C130.79 299.086 135.558 299.088 140.904 299.222C152.974 298.912 162.128 299.302 166.36 294.758C170.904 290.526 170.515 281.371 170.824 269.302C170.515 257.227 170.907 248.07 166.36 243.843C162.131 239.299 152.974 239.683 140.904 239.376Z",fill:"#FF6376"}),
|
|
65
|
-
/* @__PURE__ */n("path",{d:"M21.2155 128.398C12.6555 128.616 6.16484 128.339 3.16751 131.56C-0.0538222 134.56 0.218178 141.054 -0.000488281 149.608C0.218178 158.168 -0.0538222 164.659 3.16751 167.656C6.16484 170.878 12.6555 170.606 21.2155 170.824C25.0262 170.726 28.4288 170.726 31.2955 170.475C32.7968 170.342 34.1488 170.136 35.3382 169.814C35.3542 169.811 35.3648 169.806 35.3782 169.803C35.4768 169.774 35.5755 169.747 35.6688 169.718C37.1568 169.272 38.3648 168.622 39.2635 167.656C40.1915 166.795 40.8262 165.646 41.2715 164.243C41.2875 164.174 41.3115 164.102 41.3328 164.035C41.3328 164.035 41.3355 164.032 41.3355 164.027C41.3968 163.827 41.4529 163.622 41.5062 163.406C41.5062 163.398 41.5115 163.392 41.5142 163.382C41.7542 162.392 41.9222 161.294 42.0422 160.096C42.0555 159.944 42.0715 159.792 42.0848 159.635C42.3328 156.779 42.3328 153.398 42.4262 149.608C42.2075 141.054 42.4848 134.56 39.2635 131.56C36.2635 128.339 29.7728 128.616 21.2155 128.398Z",fill:"#FFCCCC"}),
|
|
66
|
-
/* @__PURE__ */n("path",{d:"M81.0595 184.171C70.8568 184.433 63.1208 184.102 59.5475 187.942C55.7075 191.518 56.0328 199.254 55.7742 209.454C56.0328 219.657 55.7075 227.393 59.5475 230.963C63.1208 234.803 70.8568 234.478 81.0595 234.739C85.6008 234.622 89.6595 234.622 93.0728 234.323C94.8648 234.163 96.4755 233.921 97.8942 233.534C97.9102 233.529 97.9235 233.526 97.9422 233.521C98.0568 233.486 98.1742 233.457 98.2888 233.422C100.06 232.889 101.5 232.113 102.569 230.963C103.676 229.937 104.433 228.566 104.964 226.894C104.985 226.811 105.012 226.726 105.036 226.646C105.041 226.643 105.041 226.643 105.041 226.638C105.116 226.401 105.18 226.153 105.244 225.897C105.244 225.889 105.249 225.881 105.254 225.867C105.54 224.689 105.74 223.379 105.881 221.953C105.9 221.771 105.916 221.59 105.934 221.403C106.228 218.001 106.228 213.969 106.342 209.454C106.081 199.254 106.412 191.518 102.572 187.942C98.9955 184.102 91.2568 184.433 81.0595 184.171Z",fill:"#FF939F"}),
|
|
67
|
-
/* @__PURE__ */n("path",{d:"M260.591 151.87C215.652 151.87 203.02 164.523 203.02 209.462H198.476C198.476 164.523 185.836 151.881 140.895 151.881V147.337C185.836 147.337 198.487 134.705 198.487 89.7659H203.02C203.02 134.705 215.652 147.337 260.591 147.337V151.87ZM286.052 124.158C281.82 119.614 272.66 120.001 260.591 119.689C248.521 119.385 239.361 119.771 235.129 115.227C230.585 110.995 230.983 101.846 230.671 89.7659C230.513 83.7312 230.535 78.4272 230.023 74.1019C229.513 69.7659 228.481 66.4219 226.209 64.3046C221.967 59.7606 212.817 60.1472 200.748 59.8459C188.681 60.1472 179.519 59.7606 175.287 64.3046C170.753 68.5366 171.129 77.6966 170.828 89.7659C170.516 101.835 170.9 110.995 166.356 115.227C162.124 119.771 152.985 119.374 140.905 119.689C138.873 119.739 136.924 119.771 135.071 119.811C119.313 118.697 106.337 112.318 106.337 89.7659C106.212 84.6699 106.233 80.1792 105.807 76.5206C105.367 72.8726 104.492 70.0379 102.575 68.2566C99.0013 64.4112 91.2573 64.7446 81.0653 64.4832C70.86 64.7446 63.1186 64.4112 59.5533 68.2566C55.708 71.8299 56.0306 79.5632 55.7693 89.7659C56.0306 99.9686 55.708 107.702 59.5533 111.278C63.1186 115.113 70.86 114.79 81.0653 115.049C103.617 115.049 109.996 128.035 111.1 143.803C111.068 145.659 111.028 147.587 110.975 149.619C111.121 154.987 111.121 159.79 111.476 163.835C111.663 165.95 111.945 167.857 112.404 169.534C112.412 169.555 112.412 169.566 112.423 169.598C112.465 169.734 112.497 169.867 112.537 170.003C113.164 172.099 114.092 173.809 115.447 175.07C116.665 176.371 118.281 177.278 120.271 177.905C120.364 177.934 120.46 177.955 120.564 177.987C120.855 178.081 121.145 178.153 121.439 178.238C121.46 178.238 121.471 178.238 121.479 178.249C122.876 178.582 124.42 178.822 126.108 178.987C126.327 179.009 126.545 179.03 126.764 179.051C130.788 179.395 135.559 179.395 140.905 179.529C152.975 179.843 162.124 179.457 166.356 184.001C170.9 188.233 170.516 197.371 170.828 209.451C171.129 221.529 170.743 230.681 175.287 234.91C179.519 239.454 188.681 239.07 200.748 239.371C206.127 239.235 210.921 239.235 214.975 238.881C217.079 238.694 218.985 238.403 220.676 237.955C220.695 237.945 220.705 237.934 220.727 237.934C220.873 237.891 220.999 237.859 221.135 237.819C223.228 237.193 224.937 236.265 226.209 234.91C227.511 233.691 228.409 232.065 229.044 230.097C229.065 230.003 229.095 229.899 229.127 229.803V229.793C229.22 229.513 229.295 229.222 229.367 228.918C229.367 228.897 229.377 228.897 229.377 228.878C229.721 227.481 229.951 225.937 230.127 224.249C230.137 224.03 230.169 223.811 230.191 223.593C230.535 219.571 230.535 214.798 230.671 209.451C230.972 197.371 230.585 188.233 235.129 184.001C239.361 179.457 248.511 179.843 260.591 179.529C272.66 179.227 281.82 179.614 286.052 175.07C290.596 170.838 290.209 161.689 290.511 149.619C290.209 137.539 290.596 128.379 286.052 124.158Z",fill:"#FF356A"}),
|
|
68
|
-
/* @__PURE__ */n("path",{d:"M112.405 49.848C112.411 49.8694 112.416 49.8827 112.421 49.904C112.461 50.0427 112.499 50.1814 112.539 50.3147C113.171 52.4134 114.088 54.1147 115.448 55.384C116.661 56.6907 118.283 57.5894 120.264 58.2134C120.36 58.24 120.464 58.2694 120.555 58.3014C120.56 58.3067 120.56 58.3067 120.565 58.3067C120.848 58.3947 121.141 58.4694 121.443 58.5467C121.453 58.5467 121.464 58.552 121.48 58.5574C122.875 58.896 124.424 59.1334 126.112 59.3014C126.325 59.3227 126.541 59.3414 126.763 59.3627C130.789 59.712 135.56 59.712 140.904 59.8454C152.973 59.5387 162.128 59.928 166.36 55.384C170.907 51.152 170.515 41.9947 170.824 29.9254C170.517 17.8507 170.907 8.69602 166.363 4.46935C162.131 -0.0746511 152.973 0.309349 140.904 1.52588e-05C128.829 0.309349 119.675 -0.0746511 115.448 4.46935C110.904 8.69602 111.288 17.8507 110.979 29.9254C111.117 35.3014 111.117 40.1014 111.472 44.144C111.661 46.2614 111.949 48.1707 112.405 49.848Z",fill:"#FF6376"})]})}),ht={maxHeight:"500px",loading:!0,showHeader:!0,showCopyButton:!0,showCollapseButton:!0,showModeToggle:!0,showExportButton:!0,showFullscreenButton:!0,showZoomControls:!0};function ft(r){var l;const a={...ht,...r},{t:u}=Ee(),[m,h]=i(!1),[f,p]=i(!1),[g,v]=i(!1),[w,y]=i(!1),[x,k]=i(()=>"undefined"==typeof window),b=a.node.code,C=o(()=>a.maxHeight&&"none"!==a.maxHeight?U(a.maxHeight):null,[a.maxHeight]),M=o(()=>{var e;return q(null!=(e=U(a.estimatedPreviewHeightPx))?e:Y(b),void 0,C)},[b,C,a.estimatedPreviewHeightPx]),[N,B]=i(`${M}px`),[S,T]=i(!1),[L,E]=i(1),[D,$]=i({x:0,y:0}),[P,R]=i(!1),_=c(null),A=c(null),H=c(null),I=c(null),W=c(null),F=c({x:0,y:0}),O=c(null),j=Ne(),z=d(e=>{if(!a.maxHeight||"none"===a.maxHeight)return`${Math.max(e,M)}px`;const n=Number.parseFloat(String(a.maxHeight));return Number.isFinite(n)?`${Math.max(Math.min(e,n),M)}px`:`${Math.max(e,M)}px`},[M,a.maxHeight]),K=d(()=>{const e=_.current;if(!e)return;const n=e.scrollHeight;n>0&&B(z(n))},[z]);s(()=>{g||f||B(e=>{const n=U(e);return null!=n&&n>=M?e:`${M}px`})},[M,f,g]);const V=d(async()=>{var e,n;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(b)),h(!0),null==(n=a.onCopy)||n.call(a,b),setTimeout(()=>h(!1),1e3)}catch{}},[b,a]),X=d(async()=>{var e,n;if(!x)return;if(!_.current)return;const t=_.current;try{const r=await async function(){return ut||dt||(dt=import("@antv/infographic").then(e=>{const n=e&&e.default?e.default:e;let t=n;return"function"==typeof n&&n.prototype&&n.prototype.render?t=n:e.Infographic?t=e.Infographic:n&&n.Infographic&&(t=n.Infographic),ut=t,t}).catch(e=>(console.warn("Failed to load @antv/infographic",e),null)),dt)}();if(!r)return void console.warn("Infographic library failed to load.");O.current&&(null==(n=(e=O.current).destroy)||n.call(e),O.current=null),t.innerHTML="";const o=new r({container:t,width:"100%",height:"100%"});O.current=o,o.render(b),T(!0),setTimeout(()=>{K()},0)}catch(r){console.error("Failed to render infographic:",r),T(!1),t.innerHTML=`<div class="text-red-500 p-4">Failed to render infographic: ${r instanceof Error?r.message:"Unknown error"}</div>`}},[b,K,x]);s(()=>{const e=A.current;if(!e)return;const n=j(e,{rootMargin:"160px"});return H.current=n,n.isVisible()&&k(!0),n.whenVisible.then(()=>k(!0)),()=>{n.destroy(),H.current=null}},[j]),s(()=>{!x||g||f||X()},[b,f,X,g,x]),s(()=>()=>{var e,n;O.current&&(null==(n=(e=O.current).destroy)||n.call(e),O.current=null)},[]);const Z=d(()=>{y(!1),I.current&&(I.current.innerHTML=""),W.current=null,document.body.style.overflow=""},[]),G=d(()=>{y(!0),document.body.style.overflow="hidden"},[]);s(()=>{if(!w)return;const e=e=>{"Escape"===e.key&&Z()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[w,Z]),s(()=>{w&&setTimeout(()=>{if(_.current&&I.current){I.current.innerHTML="";const e=document.createElement("div");Object.assign(e.style,{transition:"transform 0.1s ease",transformOrigin:"center center",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"});const n=_.current.cloneNode(!0);n.classList.add("fullscreen"),n.style.height="auto",e.appendChild(n),I.current.appendChild(e),W.current=e,e.style.transform=`translate(${D.x}px, ${D.y}px) scale(${L})`}},0)},[w]),s(()=>{w&&W.current&&(W.current.style.transform=`translate(${D.x}px, ${D.y}px) scale(${L})`)},[w,D,L]);const J=d(()=>{var e;const n=null==(e=_.current)?void 0:e.querySelector("svg");if(!n)return;const t=(new XMLSerializer).serializeToString(n),r=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=`infographic-${Date.now()}.svg`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)},[]),Q=e=>{R(!0);const n="touches"in e?e.touches[0].clientX:e.clientX,t="touches"in e?e.touches[0].clientY:e.clientY;F.current={x:n-D.x,y:t-D.y}},ee=e=>{if(!P)return;const n="touches"in e?e.touches[0].clientX:e.clientX,t="touches"in e?e.touches[0].clientY:e.clientY;$({x:n-F.current.x,y:t-F.current.y})},ne=()=>R(!1),te=a.isDark?"p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200":"p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700",re=g||f;/* @__PURE__ */
|
|
69
|
-
return e(t,{children:[
|
|
70
|
-
/* @__PURE__ */e("div",{ref:A,"data-markstream-infographic":"1","data-markstream-mode":g?"source":S?"preview":"pending",className:En("my-4 rounded-lg border overflow-hidden shadow-sm",a.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":a.loading}),children:[a.showHeader&&/* @__PURE__ */e("div",{className:En("flex justify-between items-center px-4 py-2.5 border-b",a.isDark?"bg-gray-800 border-gray-700/30":"bg-gray-50 border-gray-200"),children:[
|
|
71
|
-
/* @__PURE__ */e("div",{className:"flex items-center gap-x-2 overflow-hidden",children:[mt,
|
|
72
|
-
/* @__PURE__ */n("span",{className:En("text-sm font-medium font-mono truncate",a.isDark?"text-gray-400":"text-gray-600"),children:"Infographic"})]}),a.showModeToggle&&/* @__PURE__ */e("div",{className:En("flex items-center gap-x-1 rounded-md p-0.5",a.isDark?"bg-gray-700":"bg-gray-100"),children:[
|
|
73
|
-
/* @__PURE__ */n("button",{className:En("px-2.5 py-1 text-xs rounded transition-colors",g?a.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700":a.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm"),onClick:()=>v(!1),onMouseEnter:e=>We(e.currentTarget,u("common.preview")||"Preview","top",!1,0,a.isDark),onMouseLeave:()=>Fe(),children:/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
|
|
74
|
-
/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
75
|
-
/* @__PURE__ */n("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"}),
|
|
76
|
-
/* @__PURE__ */n("circle",{cx:"12",cy:"12",r:"3"})]})}),
|
|
77
|
-
/* @__PURE__ */n("span",{children:u("common.preview")||"Preview"})]})}),
|
|
78
|
-
/* @__PURE__ */n("button",{className:En("px-2.5 py-1 text-xs rounded transition-colors",g?a.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm":a.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),onClick:()=>v(!0),onMouseEnter:e=>We(e.currentTarget,u("common.source")||"Source","top",!1,0,a.isDark),onMouseLeave:()=>Fe(),children:/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
|
|
79
|
-
/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m16 18l6-6l-6-6M8 6l-6 6l6 6"})}),
|
|
80
|
-
/* @__PURE__ */n("span",{children:u("common.source")||"Source"})]})})]}),
|
|
81
|
-
/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[a.showCollapseButton&&/* @__PURE__ */n("button",{className:te,onClick:()=>p(!f),onMouseEnter:e=>We(e.currentTarget,f?u("common.expand")||"Expand":u("common.collapse")||"Collapse","top",!1,0,a.isDark),onMouseLeave:()=>Fe(),children:/* @__PURE__ */n("svg",{style:{rotate:f?"0deg":"90deg"},xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),a.showCopyButton&&/* @__PURE__ */n("button",{className:te,onClick:V,onMouseEnter:e=>We(e.currentTarget,m?u("common.copied")||"Copied":u("common.copy")||"Copy","top",!1,0,a.isDark),onMouseLeave:()=>Fe(),children:/* @__PURE__ */n("svg",m?{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
82
|
-
/* @__PURE__ */n("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
|
|
83
|
-
/* @__PURE__ */n("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),a.showExportButton&&/* @__PURE__ */n("button",{className:En(te,re&&"opacity-50 cursor-not-allowed"),disabled:re,onClick:J,onMouseEnter:e=>We(e.currentTarget,u("common.export")||"Export","top",!1,0,a.isDark),onMouseLeave:()=>Fe(),children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
84
|
-
/* @__PURE__ */n("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),
|
|
85
|
-
/* @__PURE__ */n("path",{d:"m7 10l5 5l5-5"})]})})}),a.showFullscreenButton&&/* @__PURE__ */n("button",{className:En(te,re&&"opacity-50 cursor-not-allowed"),disabled:re,onClick:G,onMouseEnter:e=>We(e.currentTarget,w?u("common.minimize")||"Minimize":u("common.open")||"Open","top",!1,0,a.isDark),onMouseLeave:()=>Fe(),children:/* @__PURE__ */n("svg",w?{xmlns:"http://www.w3.org/2000/svg",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})})]})]}),!f&&/* @__PURE__ */n("div",{children:g?/* @__PURE__ */n("div",{className:En("p-4",a.isDark?"bg-gray-900":"bg-gray-50"),children:/* @__PURE__ */n("pre",{className:En("text-sm font-mono whitespace-pre-wrap",a.isDark?"text-gray-300":"text-gray-700"),children:b})}):/* @__PURE__ */e("div",{className:"relative",children:[a.showZoomControls&&/* @__PURE__ */n("div",{className:"absolute top-2 right-2 z-10 rounded-lg",children:/* @__PURE__ */e("div",{className:"flex items-center gap-2 backdrop-blur rounded-lg",children:[
|
|
86
|
-
/* @__PURE__ */n("button",{className:En("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.min(L+.1,3)),children:"+"}),
|
|
87
|
-
/* @__PURE__ */n("button",{className:En("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.max(L-.1,.5)),children:"-"}),
|
|
88
|
-
/* @__PURE__ */e("button",{className:En("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{E(1),$({x:0,y:0})},children:[Math.round(100*L),"%"]})]})}),
|
|
89
|
-
/* @__PURE__ */n("div",{className:En("infographic-preview min-h-[360px] relative transition-all duration-100 overflow-hidden block",a.isDark?"bg-gray-900":"bg-gray-50"),style:{height:N,maxHeight:null!=(l=a.maxHeight)?l:void 0},onMouseDown:Q,onMouseMove:ee,onMouseUp:ne,onMouseLeave:ne,onTouchStart:Q,onTouchMove:ee,onTouchEnd:ne,children:/* @__PURE__ */n("div",{className:En("absolute inset-0 cursor-grab",P&&"cursor-grabbing"),style:{transform:`translate(${D.x}px, ${D.y}px) scale(${L})`},children:/* @__PURE__ */n("div",{ref:_,className:"w-full text-center flex items-center justify-center min-h-full"})})})]})})]}),w&&"undefined"!=typeof document&&de(
|
|
90
|
-
/* @__PURE__ */n("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:Z,role:"dialog","aria-modal":"true",children:/* @__PURE__ */e("div",{className:En("dialog-panel relative w-full h-full max-w-full max-h-full rounded shadow-lg overflow-hidden",a.isDark?"bg-gray-900":"bg-white"),onClick:e=>e.stopPropagation(),children:[
|
|
91
|
-
/* @__PURE__ */e("div",{className:"absolute top-6 right-6 z-50 flex items-center gap-2",children:[
|
|
92
|
-
/* @__PURE__ */n("button",{className:En("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.min(L+.1,3)),children:"+"}),
|
|
93
|
-
/* @__PURE__ */n("button",{className:En("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.max(L-.1,.5)),children:"-"}),
|
|
94
|
-
/* @__PURE__ */e("button",{className:En("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{E(1),$({x:0,y:0})},children:[Math.round(100*L),"%"]}),
|
|
95
|
-
/* @__PURE__ */n("button",{className:En("inline-flex items-center justify-center p-2 rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:Z,children:"X"})]}),
|
|
96
|
-
/* @__PURE__ */n("div",{ref:I,className:En("w-full h-full flex items-center justify-center p-4 overflow-hidden",!P&&"cursor-grab",P&&"cursor-grabbing"),onMouseDown:Q,onMouseMove:ee,onMouseUp:ne,onMouseLeave:ne,onTouchStart:Q,onTouchMove:ee,onTouchEnd:ne})]})}),document.body)]})}function pt(r){var o,l;const{node:a,children:d,ctx:u,indexKey:m,fade:h}=r,f=String(null!=(o=a.code)?o:""),p=null==(l=null!=h?h:null==u?void 0:u.fade)||l,g=null==m||""===m?"":String(m),[v,w]=i(f),[y,x]=i(""),[k,b]=i(0),C=xe(),M=c(void 0),N=c({settledContent:f,streamedDelta:""}),B=(e,n)=>{N.current={settledContent:e,streamedDelta:n},w(e),x(n)},S=()=>{const{settledContent:e,streamedDelta:n}=N.current;return e+n};return s(()=>{var e,n;const t=null!=(e=null==C?void 0:C.getStreamRenderVersion())?e:null==u?void 0:u.streamRenderVersion,r=t!==M.current;if(null!=d)return B("",""),void(M.current=t);const o=null!=(n=null==C?void 0:C.textStreamState)?n:null==u?void 0:u.textStreamState,i=N.current,l=g?null==o?void 0:o.get(g):void 0,a=ie({nextContent:f,persistedContent:l,currentState:i,typewriterEnabled:p,streamRenderVersionChanged:r});B(a.settledContent,a.streamedDelta),a.appended&&b(e=>e+1),g&&(null==o||o.set(g,f)),M.current=t},[d,f,C,null==u?void 0:u.textStreamState,null==u?void 0:u.streamRenderVersion,g,p]),s(()=>{if(p)return;const e=S();B(e,"")},[p]),/* @__PURE__ */n("code",{className:"inline-code inline text-[85%] px-1 py-0.5 rounded font-mono bg-[hsl(var(--secondary))] whitespace-normal break-words max-w-full",children:d||/* @__PURE__ */e(t,{children:[v?/* @__PURE__ */n("span",{children:v}):null,y?/* @__PURE__ */n("span",{className:En("text-node-stream-delta",k%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"),onAnimationEnd:()=>{N.current.streamedDelta&&B(S(),"")},children:y}):null]})})}function gt(e){/* @__PURE__ */
|
|
97
|
-
return n("ins",{className:"insert-node",children:e.children})}function vt(t){var r,o;const{node:l,children:a,ctx:d,indexKey:u,fade:m}=t,h=String(null!=(r=l.content)?r:""),f=null==(o=null!=m?m:null==d?void 0:d.fade)||o,p=null==u||""===u?"":String(u),[g,v]=i(h),[w,y]=i(""),[x,k]=i(0),b=xe(),C=c(void 0),M=c({settledContent:h,streamedDelta:""}),N=(e,n)=>{M.current={settledContent:e,streamedDelta:n},v(e),y(n)},B=()=>{const{settledContent:e,streamedDelta:n}=M.current;return e+n};return s(()=>{var e,n;const t=null!=(e=null==b?void 0:b.getStreamRenderVersion())?e:null==d?void 0:d.streamRenderVersion,r=t!==C.current;if(null!=a)return N("",""),void(C.current=t);const o=null!=(n=null==b?void 0:b.textStreamState)?n:null==d?void 0:d.textStreamState,i=M.current,l=p?null==o?void 0:o.get(p):void 0,c=ie({nextContent:h,persistedContent:l,currentState:i,typewriterEnabled:f,streamRenderVersionChanged:r});N(c.settledContent,c.streamedDelta),c.appended&&k(e=>e+1),p&&(null==o||o.set(p,h)),C.current=t},[a,h,b,null==d?void 0:d.textStreamState,null==d?void 0:d.streamRenderVersion,p,f]),s(()=>{if(f)return;const e=B();N(e,"")},[f]),null!=a?/* @__PURE__ */n("span",{className:En("text-node whitespace-pre-wrap break-words",l.center&&"text-node-center"),children:a}):/* @__PURE__ */e("span",{className:En("text-node whitespace-pre-wrap break-words",l.center&&"text-node-center"),children:[g?/* @__PURE__ */n("span",{children:g}):null,w?/* @__PURE__ */n("span",{className:En("text-node-stream-delta",x%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"),onAnimationEnd:()=>{M.current.streamedDelta&&N(B(),"")},children:w}):null]})}function wt(t){var r,i,l;const{node:a,ctx:c,renderNode:s,indexKey:u}=t,m=!1!==t.showTooltip,h=null!=(r=t.isDark)?r:null==c?void 0:c.isDark,f=o(()=>{var e,n,r,o,i,l;const a=void 0!==t.underlineBottom?"number"==typeof t.underlineBottom?`${t.underlineBottom}px`:String(t.underlineBottom):"-3px",c=null!=(e=t.animationOpacity)?e:.35,s=Math.max(.12,Math.min(.5*c,c));return{"--link-color":null!=(n=t.color)?n:"#0366d6","--underline-height":`${null!=(r=t.underlineHeight)?r:2}px`,"--underline-bottom":a,"--underline-opacity":String(c),"--underline-rest-opacity":String(s),"--underline-duration":`${null!=(o=t.animationDuration)?o:1.6}s`,"--underline-timing":null!=(i=t.animationTiming)?i:"ease-in-out","--underline-iteration":"number"==typeof t.animationIteration?String(t.animationIteration):null!=(l=t.animationIteration)?l:"infinite"}},[t.animationDuration,t.animationIteration,t.animationOpacity,t.animationTiming,t.color,t.underlineBottom,t.underlineHeight]),p=o(()=>{var e;return k({href:String(null!=(e=a.href)?e:"")}).href},[a.href]),g="string"==typeof a.title&&a.title.trim().length>0?a.title:String(null!=p?p:""),v=b(p),w=d(e=>{m&&We(e.currentTarget,String(a.title||p||a.text||""),"top",!1,(e.clientX,e.clientY),h)},[h,a.text,a.title,p,m]),y=d(()=>{m&&Fe()},[m]);return a.loading?/* @__PURE__ */n("span",{className:"link-loading inline-flex items-baseline gap-1.5","aria-hidden":"false",style:f,children:/* @__PURE__ */e("span",{className:"link-text-wrapper relative inline-flex",children:[
|
|
98
|
-
/* @__PURE__ */n("span",{className:"leading-[normal] link-text",children:/* @__PURE__ */n(vt,{node:{type:"text",content:String(null!=(i=a.text)?i:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-loading`,typewriter:t.typewriter})}),
|
|
99
|
-
/* @__PURE__ */n("span",{className:"link-loading-indicator","aria-hidden":"true"})]})}):/* @__PURE__ */n("a",{className:"link-node",href:p||void 0,title:m?"":g,"aria-label":`Link: ${g}`,target:v?"_blank":void 0,rel:v?"noopener noreferrer":void 0,style:f,onMouseEnter:w,onMouseLeave:y,children:c&&s?E(a.children,c,String(null!=u?u:"link"),s):/* @__PURE__ */n(vt,{node:{type:"text",content:String(null!=(l=a.text)?l:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-fallback`,typewriter:t.typewriter})})}function yt(e){const{node:t,ctx:r,renderNode:o,value:i,indexKey:l,children:a}=e;/* @__PURE__ */
|
|
100
|
-
return n("li",{className:"list-item pl-1.5 my-2",dir:"auto",value:null==i?void 0:i,children:null!=a?a:r&&o?E(t.children,r,String(null!=l?l:"list-item"),o):null})}function xt(e){var t;const{node:r,ctx:o,renderNode:i,indexKey:l}=e,a=r.ordered?"ol":"ul",c=r.ordered&&r.start?r.start:void 0,s=o&&W(o.customId).list_item||yt;/* @__PURE__ */
|
|
101
|
-
return n(a,{className:En("list-node my-5 pl-[calc(13/8*1em)]",r.ordered?"list-decimal":"list-disc max-lg:my-[calc(4/3*1em)] max-lg:pl-[calc(14/9*1em)]"),start:c,children:null==(t=r.items)?void 0:t.map((e,t)=>{var a;/* @__PURE__ */
|
|
102
|
-
return n(s,{node:e,value:r.ordered?(null!=(a=r.start)?a:1)+t:void 0,ctx:o,renderNode:i,indexKey:`${String(null!=l?l:"list")}-${t}`,customId:null==o?void 0:o.customId,isDark:null==o?void 0:o.isDark,typewriter:null==o?void 0:o.typewriter},`${String(null!=l?l:"list")}-${t}`)})})}let kt=null,bt=null,Ct=!1;const Mt=/* @__PURE__ */new Map,Nt=/* @__PURE__ */new Map;let Bt=5;const St=/* @__PURE__ */new Set;function Tt(){if(Mt.size<Bt&&St.size){const e=Array.from(St);St.clear();for(const n of e)try{n()}catch{}}}function Lt(e){kt=e,bt=null,kt.onmessage=e=>{const{id:n,html:t,error:r}=e.data,o=Mt.get(n);if(o)if(Mt.delete(n),clearTimeout(o.timeoutId),Tt(),r)o.reject(new Error(r));else{const{content:n,displayMode:r}=e.data;if(n){const e=`${r?"d":"i"}:${n}`;if(Nt.set(e,t),Nt.size>200){const e=Nt.keys().next().value;Nt.delete(e)}}o.resolve(t)}},kt.onerror=e=>{console.error("[katexWorkerClient] Worker error:",e);for(const[n,t]of Mt.entries())clearTimeout(t.timeoutId),t.reject(new Error(`Worker error: ${e.message}`));Mt.clear(),Tt()}}function Et(){var e;kt&&(null==(e=kt.terminate)||e.call(kt)),kt=null,bt=null}function Dt(e){Ct=!!e,kt&&kt.postMessage({type:"init",debug:Ct})}const $t="WORKER_BUSY";async function Pt(e,n=!0,t=2e3,r){performance.now();const o=Z(e);if(bt)return Promise.reject(bt);const i=`${n?"d":"i"}:${o}`,l=Nt.get(i);if(l)return Promise.resolve(l);const a=kt||(bt=new Error("[katexWorkerClient] No worker instance set. Please inject a Worker via setKaTeXWorker()."),bt.name="WORKER_INIT_ERROR",bt.code="WORKER_INIT_ERROR",null);if(!a)return Promise.reject(bt);if(Mt.size>=Bt){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=$t,e.busy=!0,e.inFlight=Mt.size,e.max=Bt,Promise.reject(e)}return new Promise((e,i)=>{if(null==r?void 0:r.aborted){const e=new Error("Aborted");return e.name="AbortError",void i(e)}const l=Math.random().toString(36).slice(2),c=setTimeout(()=>{Mt.delete(l);const e=new Error("Worker render timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT",i(e),Tt()},t),s=()=>{},d=()=>{Mt.delete(l),clearTimeout(c),St.delete(s);const e=new Error("Aborted");e.name="AbortError",i(e),Tt()};r&&r.addEventListener("abort",d,{once:!0}),Mt.set(l,{resolve:n=>{r&&r.removeEventListener("abort",d),e(n)},reject:e=>{r&&r.removeEventListener("abort",d),i(e)},timeoutId:c});try{a.postMessage({id:l,content:o,displayMode:n,debug:Ct})}catch(u){Mt.delete(l),clearTimeout(c),r&&r.removeEventListener("abort",d),i(u),Tt()}})}function Rt(e,n,t){const r=`${n?"d":"i"}:${Z(e)}`;if(Nt.set(r,t),Nt.size>200){const e=Nt.keys().next().value;Nt.delete(e)}}function _t(){Nt.clear()}function At(e){Bt=Math.max(1,Math.floor(e)),Tt()}function Ht(e=1500,n){return Mt.size<Bt?Promise.resolve():new Promise((t,r)=>{if(null==n?void 0:n.aborted){const e=new Error("Aborted");return e.name="AbortError",void r(e)}let o=null;function i(){St.delete(l),null!=o&&clearTimeout(o),n&&n.removeEventListener("abort",a)}function l(){i(),t()}function a(){i();const e=new Error("Aborted");e.name="AbortError",r(e)}o=e>0?setTimeout(()=>{i(),r(new Error("Timeout waiting for worker slot"))},e):null,n&&n.addEventListener("abort",a,{once:!0}),St.add(l)})}const It={timeout:2e3,waitTimeout:1500,backoffMs:30,maxRetries:1};function Wt(e){null!=e.timeout&&(It.timeout=Math.max(0,Math.floor(e.timeout))),null!=e.waitTimeout&&(It.waitTimeout=Math.max(0,Math.floor(e.waitTimeout))),null!=e.backoffMs&&(It.backoffMs=Math.max(0,Math.floor(e.backoffMs))),null!=e.maxRetries&&(It.maxRetries=Math.max(0,Math.floor(e.maxRetries)))}function Ft(){return{...It}}async function Ot(e,n=!0,t={}){var r,o,i,l;const a=null!=(r=t.timeout)?r:It.timeout,c=null!=(o=t.waitTimeout)?o:It.waitTimeout,s=null!=(i=t.backoffMs)?i:It.backoffMs,d=null!=(l=t.maxRetries)?l:It.maxRetries,u=Number.isFinite(d)?Math.max(0,Math.min(Math.floor(d),8)):It.maxRetries,m=t.signal;let h=0;for(;;){if(null==m?void 0:m.aborted){const e=new Error("Aborted");throw e.name="AbortError",e}try{return await Pt(e,n,a,m)}catch(f){if((null==f?void 0:f.code)!==$t||h>=u)throw f;if(h++,await Ht(c,m).catch(()=>{}),null==m?void 0:m.aborted){const e=new Error("Aborted");throw e.name="AbortError",e}s>0&&await new Promise(e=>setTimeout(e,s*h))}}}let jt=null,zt=!1;async function Kt(){if(jt)return jt;if(zt)return null;try{return jt=await import("katex"),await import("katex/contrib/mhchem"),jt}catch{return zt=!0,null}}function Vt({node:e}){const t=c(null),r=c(null),o=c(null),l=Ne(),[a,d]=i(!0),[u,m]=i(()=>"undefined"==typeof window),h=c(0);return s(()=>{const e=t.current;if(!e)return;const n=l(e,{rootMargin:"400px"});return o.current=n,n.isVisible()&&m(!0),n.whenVisible.then(()=>m(!0)),()=>{n.destroy(),o.current=null}},[l]),s(()=>{var n;const t=Z(null!=(n=e.content)?n:"");if(!t)return r.current&&(r.current.innerHTML=""),void d(!1);if(!u)return void d(!0);let o=!1;const i=new AbortController,l=++h.current;return Ot(t,!0,{timeout:3e3,waitTimeout:2e3,maxRetries:1,signal:i.signal}).then(e=>{o||l!==h.current||(r.current&&(r.current.innerHTML=e),d(!1))}).catch(async n=>{if(o||l!==h.current)return;if(!r.current)return;const i=(null==n?void 0:n.code)||(null==n?void 0:n.name);if("WORKER_INIT_ERROR"===i||(null==n?void 0:n.fallbackToRenderer)||i===$t||"WORKER_TIMEOUT"===i){const n=await Kt();if(n)try{const i=n.renderToString(t,{throwOnError:e.loading,displayMode:!0});return void(!o&&l===h.current&&r.current&&(r.current.innerHTML=i,d(!1),Rt(t,!0,i)))}catch{}}e.loading||(r.current.textContent=e.raw,d(!1))}),()=>{o=!0,i.abort()}},[e.content,e.loading,e.raw,u]),/* @__PURE__ */n("div",{ref:t,className:"math-block text-center overflow-x-auto relative min-h-[40px]",children:/* @__PURE__ */n("div",{ref:r,className:a?"math-rendering":void 0})})}function Xt({node:t}){const r=c(null),o=c(null),l=c(null),a=Ne(),[d,u]=i(!0),[m,h]=i(()=>"undefined"==typeof window),f=c(0);return s(()=>{const e=r.current;if(!e)return;const n=a(e,{rootMargin:"400px"});return l.current=n,n.isVisible()&&h(!0),n.whenVisible.then(()=>h(!0)),()=>{n.destroy(),l.current=null}},[a]),s(()=>{var e;const n=Z(null!=(e=t.content)?e:"");if(!n)return o.current&&(o.current.innerHTML=""),void u(!1);if(!m)return void u(!0);let r=!1;const i=new AbortController,l=++f.current,a="$$"===t.markup;return Ot(n,a,{timeout:1500,waitTimeout:0,maxRetries:0,signal:i.signal}).then(e=>{r||l!==f.current||o.current&&(o.current.innerHTML=e,u(!1))}).catch(async e=>{if(r||l!==f.current)return;if(!o.current)return;const i=(null==e?void 0:e.code)||(null==e?void 0:e.name);if("WORKER_INIT_ERROR"===i||(null==e?void 0:e.fallbackToRenderer)||i===$t||"WORKER_TIMEOUT"===i){const e=await Kt();if(e)try{const i=e.renderToString(n,{throwOnError:t.loading,displayMode:a});return void(!r&&l===f.current&&o.current&&(o.current.innerHTML=i,u(!1),Rt(n,a,i)))}catch{}}t.loading||(o.current.textContent=t.raw,u(!1))}),()=>{r=!0,i.abort()}},[t.content,t.loading,t.raw,t.markup,m]),/* @__PURE__ */e("span",{ref:r,className:"math-inline-wrapper",children:[
|
|
103
|
-
/* @__PURE__ */n("span",{ref:o,className:"math-inline"+(d?" math-inline--hidden":"")}),d&&/* @__PURE__ */e("span",{className:"math-inline__loading",role:"status","aria-live":"polite",children:[
|
|
104
|
-
/* @__PURE__ */n("span",{className:"math-inline__spinner","aria-hidden":"true"}),
|
|
105
|
-
/* @__PURE__ */n("span",{className:"sr-only",children:"Loading"})]})]})}function Ut(e){try{if("undefined"!=typeof globalThis&&"function"==typeof globalThis.requestAnimationFrame)return globalThis.requestAnimationFrame(e)}catch{}return globalThis.setTimeout(e,0)}let qt=null,Yt=null;const Zt=/* @__PURE__ */new Map;let Gt=5,Jt=!1;function Qt(e){Jt=!!e}function er(e){Number.isFinite(e)&&e>0&&(Gt=Math.floor(e))}function nr(){return{inFlight:Zt.size,max:Gt}}const tr="WORKER_BUSY";function rr(e){qt=e,Yt=null;const n=e;qt.onmessage=e=>{if(qt!==n)return;const{id:t,ok:r,result:o,error:i}=e.data,l=Zt.get(t);l&&(!1===r||i?l.reject(new Error(i||"Unknown error")):l.resolve(o))},qt.onerror=e=>{var t,r;if(qt===n)if(0!==Zt.size){try{Jt?console.error("[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e)}catch{}for(const[n,t]of Zt.entries())t.reject(new Error(`Worker error: ${e.message}`));Zt.clear()}else null==(t=console.debug)||t.call(console,"[mermaidWorkerClient] Worker error (no pending):",(null==e?void 0:e.message)||e)},qt.onmessageerror=e=>{var t,r;if(qt===n)if(0!==Zt.size){try{Jt?console.error("[mermaidWorkerClient] Worker messageerror:",e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker messageerror:",e)}catch{}for(const[e,n]of Zt.entries())n.reject(new Error("Worker messageerror"));Zt.clear()}else null==(t=console.debug)||t.call(console,"[mermaidWorkerClient] Worker messageerror (no pending):",e)}}function or(){var e;if(qt)try{for(const[e,n]of Zt.entries())n.reject(new Error("Worker cleared"));Zt.clear(),null==(e=qt.terminate)||e.call(qt)}catch{}qt=null,Yt=null}function ir(e,n,t=1400){if(Yt)return Promise.reject(Yt);const r=qt||(Yt=new Error("[mermaidWorkerClient] No worker instance set. Please inject a Worker via setMermaidWorker()."),Yt.name="WORKER_INIT_ERROR",Yt.code="WORKER_INIT_ERROR",null);if(!r)return Promise.reject(Yt);if(Zt.size>=Gt){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=tr,e.inFlight=Zt.size,e.max=Gt,Promise.reject(e)}return new Promise((o,i)=>{const l=Math.random().toString(36).slice(2);let a=!1,c=null;const s=()=>{a||(a=!0,null!=c&&clearTimeout(c),Zt.delete(l))},d={resolve:e=>{s(),o(e)},reject:e=>{s(),i(e)}};Zt.set(l,d);try{r.postMessage({id:l,action:e,payload:n})}catch(u){return Zt.delete(l),void i(u)}c=setTimeout(()=>{const e=new Error("Worker call timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT";const n=Zt.get(l);null==n||n.reject(e)},t)})}async function lr(e,n,t=1400){return ir("canParse",{code:e,theme:n},t)}async function ar(e,n,t=2400){return ir("findPrefix",{code:e,theme:n},t)}function cr(){var e;null==(e=null==qt?void 0:qt.terminate)||e.call(qt),qt=null,Yt=null,Zt.clear()}let sr=null,dr=!1,ur=null,mr=null;function hr(e,n){var t;if(!e||!n)return;const r=function(e){var n,t;return`${String(null!=(n=null==e?void 0:e.securityLevel)?n:"strict")}|htmlLabels:${!1===(null==(t=null==e?void 0:e.flowchart)?void 0:t.htmlLabels)?"0":"1"}`}(n);if(ur!==r)try{"function"==typeof e.initialize?e.initialize(n):(null==(t=e.mermaidAPI)?void 0:t.initialize)&&e.mermaidAPI.initialize(n),ur=r}catch{}}const fr="undefined"!=typeof window?m:s,pr={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0};function gr(e){if(e)try{e.replaceChildren()}catch{e.innerHTML=""}}function vr(e,n,t={}){if(!e)return"";const r=function(e,n){if(!e)return"";const t=C(n);return t?(gr(e),e.appendChild(t),e.innerHTML):""}(e,n);return r||t.keepPreviousOnFailure||gr(e),r}function wr(e,n,t){if(t&&(null==e?void 0:e.querySelector("svg")))try{null==n||n(e)}catch{}}const yr={maxHeight:"500px",loading:!0,workerTimeoutMs:1400,parseTimeoutMs:1800,renderTimeoutMs:2500,fullRenderTimeoutMs:4e3,renderDebounceMs:300,contentStableDelayMs:500,previewPollDelayMs:800,previewPollMaxDelayMs:4e3,previewPollMaxAttempts:12,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showFullscreenButton:!0,showCollapseButton:!0,showZoomControls:!0,enableWheelZoom:!1,isStrict:!0,enableMermaidInteractions:!1};function xr(r){var l,a,u,h,f,p,g,v,w,y;const x={...yr,...r},{t:k}=Ee(),b=o(()=>R("mermaid"),[]),C=null!=(a=null==(l=x.node)?void 0:l.code)?a:"",M=o(()=>C.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"),[C]),N=null!=(u=x.workerTimeoutMs)?u:yr.workerTimeoutMs,B=null!=(h=x.parseTimeoutMs)?h:yr.parseTimeoutMs,S=null!=(f=x.renderTimeoutMs)?f:yr.renderTimeoutMs,T=null!=(p=x.fullRenderTimeoutMs)?p:yr.fullRenderTimeoutMs,L=Math.max(0,null!=(g=x.renderDebounceMs)?g:yr.renderDebounceMs),E=o(()=>x.maxHeight&&"none"!==x.maxHeight?G(x.maxHeight):null,[x.maxHeight]),D=o(()=>{var e;return J(null!=(e=G(x.estimatedPreviewHeightPx))?e:Q(M),void 0,E)},[M,E,x.estimatedPreviewHeightPx]),[$,P]=i(!1),[_,A]=i(!1),[H,I]=i(!1),[W,F]=i(!1),[O,j]=i(1),[z,K]=i({x:0,y:0}),[V,X]=i(!1),[U,q]=i(!1),[Y,Z]=i(!1),[ee,ne]=i(null),[te,re]=i(!1),[oe,ie]=i(`${D}px`),[le,ae]=i("undefined"==typeof window),ce=c(null),se=c(null),ue=c(null),me=c(null),he=c(null),fe=c(null),pe=c(null),ge=c({x:0,y:0}),ve=c(0),we=c({}),ye=c(null),xe=c(""),ke=c(!1),be=c(null),Ce=c(!1),Me=c({zoom:1,translateX:0,translateY:0,containerHeight:oe||"360px"}),Be=Ne(),Se=Boolean(null!=(w=null==(v=x.node)?void 0:v.loading)?w:x.loading),Te=x.isDark?"dark":"light",Le=Boolean(x.isStrict),De=!0===x.enableMermaidInteractions,$e=o(()=>Le?{startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,dompurifyConfig:pr,flowchart:{htmlLabels:!1}}:{startOnLoad:!1,securityLevel:"loose",suppressErrorRendering:!0},[Le]);s(()=>{Ce.current=Y},[Y]),s(()=>{_||H||ie(e=>{const n=G(e);return null!=n&&n>=D?e:`${D}px`})},[D,H,_]),s(()=>{we.current={}},[Te,M,Le]),s(()=>{let e=!1;return(async()=>{const n=await async function(e){if(sr)return hr(sr,e),sr;if(mr){const n=await mr;return n&&hr(n,e),n}if(dr)return null;try{dr=!0,mr=(async()=>{try{const n=await import("mermaid"),t=(null==n?void 0:n.default)||n;if(sr=(null==t?void 0:t.default)?t.default:(null==t?void 0:t.mermaidAPI)?t:(null==t?void 0:t.mermaid)?t.mermaid:t,!sr)throw new Error("Mermaid module did not export expected API");return hr(sr,null!=e?e:{startOnLoad:!1,securityLevel:"strict",flowchart:{htmlLabels:!1}}),sr}catch(n){return console.warn("[markstream-react] Failed to load mermaid:",n),null}finally{mr=null}})();const n=await mr;return n&&hr(n,e),n}catch{return null}}($e);e||(ce.current=n,P(Boolean(n)),ke.current||A(!n))})(),()=>{e=!0}},[$e]),s(()=>{const e=se.current;if(!e)return;const n=Be(e,{rootMargin:"400px"});return be.current=n,n.isVisible()&&ae(!0),n.whenVisible.then(()=>ae(!0)),()=>{n.destroy(),be.current=null}},[Be]),s(()=>{if("undefined"==typeof document)return;if(!te)return;const e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[te]);const Pe=d(()=>E,[E]),Re=d(e=>{const n=se.current,t=me.current;if(!n||!t)return;const r=t.querySelector("svg");if(!r)return;let o=0,i=0;const l=r.getAttribute("viewBox");if(l){const e=l.split(" ");4===e.length&&(o=Number.parseFloat(e[2]),i=Number.parseFloat(e[3]))}if(o&&i||!r.hasAttribute("width")||!r.hasAttribute("height")||(o=Number.parseFloat(r.getAttribute("width")||"0"),i=Number.parseFloat(r.getAttribute("height")||"0")),!o||!i||Number.isNaN(o)||Number.isNaN(i))try{const e=r.getBBox();o=e.width,i=e.height}catch{return}if(!(o>0&&i>0))return;const a=(null!=e?e:n.clientWidth)*(i/o),c=Number.isFinite(a)&&a>0?a:i,s=Pe(),d=null==s?c:Math.min(c,s);ie(`${"none"===x.maxHeight?d:Math.max(d,D)}px`)},[D,x.maxHeight,Pe]);s(()=>{if(!se.current||"undefined"==typeof ResizeObserver)return;if(_||H)return;const e=new ResizeObserver(e=>{if(!e.length)return;const n=e[0].contentRect.width;Ut(()=>Re(n))});return e.observe(se.current),()=>e.disconnect()},[H,_,Re]),s(()=>{_||H||Re()},[H,x.maxHeight,_,Re]),s(()=>()=>{cr()},[]),m(()=>{var e;const n=we.current[Te];!_&&me.current&&(null==n?void 0:n.svg)&&(vr(me.current,n.svg)&&(ye.current=null!=(e=n.bindFunctions)?e:null,wr(me.current,n.bindFunctions,De)),Ut(()=>Re()))},[De,_,Te,Re]);const _e=d(async(e,n,t)=>{var r;if(!ce.current||!me.current)return!1;q(!0);try{const o=`mermaid-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=Cr(e,n),l=await Sr(()=>ce.current.render(o,i),{timeoutMs:T,signal:t});if(!(null==l?void 0:l.svg))return!1;const a=vr(me.current,l.svg);return!!a&&(ye.current=null!=(r=l.bindFunctions)?r:null,wr(me.current,l.bindFunctions,De),Re(),we.current[n]={svg:a,bindFunctions:l.bindFunctions},Z(!0),ne(null),!0)}catch(o){if(!Se){if("function"==typeof x.onRenderError&&me.current&&!0===x.onRenderError(o,M,me.current))return!1;ne(o instanceof Error?o.message:String(o))}return!1}finally{q(!1)}},[De,T,Se,Re]),Ae=d(async(e,n,t)=>{var r;if(ce.current&&me.current){q(!0);try{const o=`mermaid-preview-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=Cr(Br(e)||e,n),l=await Sr(()=>ce.current.render(o,i),{timeoutMs:S,signal:t});if(null==l?void 0:l.svg){const e=vr(me.current,l.svg,{keepPreviousOnFailure:!0});e&&(ye.current=null!=(r=l.bindFunctions)?r:null,wr(me.current,l.bindFunctions,De)),e&&Re()}}catch{}finally{q(!1)}}},[De,S,Se,Re]),He=d(async(e,n)=>{if(!e.trim())return gr(me.current),Z(!1),void(xe.current="");const t=e.replace(/\s+/g,"");if(t===xe.current&&Ce.current)return;const r=++ve.current;if("gantt"===Mr(e)){const i=Br(e);if(!i.trim())return;try{if(await br(i,Te,{workerTimeout:N,parseTimeout:B,mermaid:ce.current,signal:n}),(null==n?void 0:n.aborted)||ve.current!==r)return;i===e?await _e(e,Te,n)&&(xe.current=t):await Ae(i,Te,n)}catch(o){if("AbortError"===(null==o?void 0:o.name))return}return}try{if(await br(e,Te,{workerTimeout:N,parseTimeout:B,mermaid:ce.current,signal:n}),(null==n?void 0:n.aborted)||ve.current!==r)return;return void(await _e(e,Te,n)&&(xe.current=t))}catch(o){if("AbortError"===(null==o?void 0:o.name))return}try{const t=await async function(e,n,t){try{const r=await ar(e,n,t.workerTimeout);if(r)return r}catch(o){if("AbortError"===(null==o?void 0:o.name))throw o}return Br(e)}(e,Te,{workerTimeout:N,signal:n});if(!t||(null==n?void 0:n.aborted)||ve.current!==r)return;await Ae(t,Te,n)}catch{}},[B,_e,Ae,Te,N]),Ie=d(()=>le&&!_&&!H,[H,_,le]);s(()=>{if(!Ie())return;if(!ce.current)return;const e=new AbortController,n=window.setTimeout(()=>{!e.signal.aborted&&Ie()&&He(M,e.signal)},L);return()=>{e.abort(),window.clearTimeout(n)}},[M,Ie,$,He,L]);const Oe=d((e,n)=>{e.clientX,e.clientY,We(e.currentTarget,n,"top",!1,0,x.isDark)},[x.isDark]),je=d(async()=>{var e,n;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(M)),F(!0),null==(n=x.onCopy)||n.call(x,M),setTimeout(()=>F(!1),1e3)}catch{}},[M,x]),ze=d(()=>{var e,n,t;const r=null!=(n=null==(e=me.current)?void 0:e.querySelector("svg"))?n:null;if(!r)return;const o=Tr(r),i={payload:{type:"export"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(t=x.onExport)||t.call(x,i),i.defaultPrevented||function(e,n){const t=null!=n?n:Tr(e),r=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=`mermaid-${Date.now()}.svg`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}(r,o)},[x]),Ke=d(()=>{pe.current=null,gr(fe.current)},[]),Ve=d(()=>{re(!1),Ke()},[Ke]),Xe=d(()=>{var e,n,t;const r=null!=(n=null==(e=me.current)?void 0:e.querySelector("svg"))?n:null,o=r?Tr(r):null,i={payload:{type:"open-modal"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(t=x.onOpenModal)||t.call(x,i),i.defaultPrevented||re(!0)},[x]);s(()=>{if(!te)return;if("undefined"==typeof window)return;const e=e=>{"Escape"===e.key&&Ve()};try{window.addEventListener("keydown",e)}catch{}return()=>{try{window.removeEventListener("keydown",e)}catch{}}},[Ve,te]),fr(()=>{var e,n;if(!te)return;const t=fe.current,r=se.current;if(!t||!r)return;const o=`translate(${z.x}px, ${z.y}px) scale(${O})`,i=r.cloneNode(!0);i.classList.add("fullscreen"),i.style.height="100%",i.style.maxHeight="100%";const l=i.querySelector("[data-mermaid-wrapper]");l&&(pe.current=l,l.style.transform=o),gr(t),t.appendChild(i),wr(t,null!=(n=ye.current)?n:null==(e=we.current[Te])?void 0:e.bindFunctions,De)},[De,te,Te]),s(()=>{te&&pe.current&&(pe.current.style.transform=`translate(${z.x}px, ${z.y}px) scale(${O})`)},[te,z.x,z.y,O]);const Ue=_||U||H,qe=o(()=>x.isDark?"mermaid-action-btn p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200":"mermaid-action-btn p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700",[x.isDark]),Ye=d(e=>{var n;const t={payload:{type:"toggle-mode",target:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};if(null==(n=x.onToggleMode)||n.call(x,e,t),!t.defaultPrevented)if(ke.current=!0,"preview"===e){A(!1);const e=Me.current;j(e.zoom),K({x:e.translateX,y:e.translateY}),ie(e.containerHeight)}else Me.current={zoom:O,translateX:z.x,translateY:z.y,containerHeight:oe},A(!0)},[M,oe,He,x,Te,z.x,z.y,Re,O]),Ze=d(e=>{if(!1===x.enableWheelZoom)return;if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const n=se.current;if(!n)return;const t=n.getBoundingClientRect(),r=e.clientX-t.left-z.x,o=e.clientY-t.top-z.y,i=.01*-e.deltaY,l=kr(O+i,.5,3);if(l===O)return;const a=l/O;K({x:z.x-r*(a-1),y:z.y-o*(a-1)}),j(l)},[z,O]),Ge=d((e,n)=>{X(!0),ge.current={x:e-z.x,y:n-z.y}},[z.x,z.y]),Je=d((e,n)=>{V&&K({x:e-ge.current.x,y:n-ge.current.y})},[V]),Qe=d(()=>{X(!1)},[]),en=/* @__PURE__ */e("div",{className:"relative",children:[x.showZoomControls&&/* @__PURE__ */n("div",{className:"absolute top-2 right-2 z-10 rounded-lg",children:/* @__PURE__ */e("div",{className:"flex items-center gap-2 backdrop-blur rounded-lg",children:[
|
|
106
|
-
/* @__PURE__ */n("button",{type:"button",className:En("p-2 text-xs rounded transition-colors",x.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onMouseEnter:e=>Oe(e,k("common.zoomIn")),onMouseLeave:()=>Fe(),onClick:()=>j(kr(O+.1,.5,3)),children:"+"}),
|
|
107
|
-
/* @__PURE__ */n("button",{type:"button",className:En("p-2 text-xs rounded transition-colors",x.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onMouseEnter:e=>Oe(e,k("common.zoomOut")),onMouseLeave:()=>Fe(),onClick:()=>j(kr(O-.1,.5,3)),children:"−"}),
|
|
108
|
-
/* @__PURE__ */e("button",{type:"button",className:En("p-2 text-xs rounded transition-colors",x.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onMouseEnter:e=>Oe(e,k("common.resetZoom")),onMouseLeave:()=>Fe(),onClick:()=>{j(1),K({x:0,y:0})},children:[Math.round(100*O),"%"]})]})}),
|
|
109
|
-
/* @__PURE__ */e("div",{ref:se,className:En("min-h-[360px] relative overflow-hidden block transition-[height] duration-150 ease-out",x.isDark?"bg-gray-900":"bg-gray-50"),style:{height:oe,maxHeight:null!=(y=x.maxHeight)?y:void 0},onWheel:Ze,onMouseDown:e=>{0===e.button&&(e.preventDefault(),Ge(e.clientX,e.clientY))},onMouseMove:e=>Je(e.clientX,e.clientY),onMouseUp:Qe,onMouseLeave:Qe,onTouchStart:e=>{const n=e.touches[0];n&&Ge(n.clientX,n.clientY)},onTouchMove:e=>{const n=e.touches[0];n&&Je(n.clientX,n.clientY)},onTouchEnd:Qe,children:[
|
|
110
|
-
/* @__PURE__ */n("div",{ref:ue,"data-mermaid-wrapper":!0,className:En("absolute inset-0 cursor-grab",{"cursor-grabbing":V}),style:{transform:`translate(${z.x}px, ${z.y}px) scale(${O})`},children:/* @__PURE__ */n("div",{ref:me,className:"_mermaid w-full text-center flex items-center justify-center min-h-full"})}),(U||Se)&&/* @__PURE__ */e("div",{className:"mermaid-loading",children:[
|
|
111
|
-
/* @__PURE__ */n("span",{className:"mermaid-spinner"}),
|
|
112
|
-
/* @__PURE__ */n("span",{children:"Rendering diagram…"})]})]})]}),nn=x.showHeader&&/* @__PURE__ */e("div",{className:En("mermaid-block-header flex justify-between items-center px-4 py-2.5 border-b",x.isDark?"bg-gray-800 border-gray-700/30":"bg-gray-50 border-gray-200"),children:[
|
|
113
|
-
/* @__PURE__ */e("div",{className:"flex items-center space-x-2 overflow-hidden",children:[
|
|
114
|
-
/* @__PURE__ */n("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:b}}),
|
|
115
|
-
/* @__PURE__ */n("span",{className:En("text-sm font-medium font-mono truncate",x.isDark?"text-gray-400":"text-gray-600"),children:"Mermaid"})]}),x.showModeToggle&&$&&/* @__PURE__ */e("div",{className:En("flex items-center space-x-1 rounded-md p-0.5",x.isDark?"bg-gray-700":"bg-gray-100"),children:[
|
|
116
|
-
/* @__PURE__ */n("button",{type:"button",className:En("px-2.5 py-1 text-xs rounded transition-colors",_?x.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700":x.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm"),onClick:()=>Ye("preview"),onMouseEnter:e=>Oe(e,k("common.preview")),onFocus:e=>Oe(e,k("common.preview")),onMouseLeave:()=>Fe(),onBlur:()=>Fe(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
|
|
117
|
-
/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
118
|
-
/* @__PURE__ */n("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"}),
|
|
119
|
-
/* @__PURE__ */n("circle",{cx:"12",cy:"12",r:"3"})]})}),
|
|
120
|
-
/* @__PURE__ */n("span",{children:k("common.preview")})]})}),
|
|
121
|
-
/* @__PURE__ */n("button",{type:"button",className:En("px-2.5 py-1 text-xs rounded transition-colors",_?x.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm":x.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),onClick:()=>Ye("source"),onMouseEnter:e=>Oe(e,k("common.source")),onFocus:e=>Oe(e,k("common.source")),onMouseLeave:()=>Fe(),onBlur:()=>Fe(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
|
|
122
|
-
/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m16 18l6-6l-6-6M8 6l-6 6l6 6"})}),
|
|
123
|
-
/* @__PURE__ */n("span",{children:k("common.source")})]})})]}),
|
|
124
|
-
/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[x.showCollapseButton&&/* @__PURE__ */n("button",{type:"button",className:qe,"aria-pressed":H,onClick:()=>I(e=>!e),onMouseEnter:e=>Oe(e,k(H?"common.expand":"common.collapse")),onFocus:e=>Oe(e,k(H?"common.expand":"common.collapse")),onMouseLeave:()=>Fe(),onBlur:()=>Fe(),children:/* @__PURE__ */n("svg",{style:{rotate:H?"0deg":"90deg"},xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),x.showCopyButton&&/* @__PURE__ */n("button",{type:"button",className:qe,onClick:je,onMouseEnter:e=>Oe(e,k(W?"common.copied":"common.copy")),onFocus:e=>Oe(e,k(W?"common.copied":"common.copy")),onMouseLeave:()=>Fe(),onBlur:()=>Fe(),children:/* @__PURE__ */n("svg",W?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
125
|
-
/* @__PURE__ */n("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
|
|
126
|
-
/* @__PURE__ */n("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),x.showExportButton&&$&&/* @__PURE__ */n("button",{type:"button",className:En(qe,Ue?"opacity-50 cursor-not-allowed":""),disabled:Ue,onClick:ze,onMouseEnter:e=>Oe(e,k("common.export")),onFocus:e=>Oe(e,k("common.export")),onMouseLeave:()=>Fe(),onBlur:()=>Fe(),children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
127
|
-
/* @__PURE__ */n("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),
|
|
128
|
-
/* @__PURE__ */n("path",{d:"m7 10l5 5l5-5"})]})})}),x.showFullscreenButton&&$&&/* @__PURE__ */n("button",{type:"button",className:En(qe,Ue?"opacity-50 cursor-not-allowed":""),disabled:Ue,onClick:te?Ve:Xe,onMouseEnter:e=>Oe(e,k(te?"common.minimize":"common.open")),onFocus:e=>Oe(e,k(te?"common.minimize":"common.open")),onMouseLeave:()=>Fe(),onBlur:()=>Fe(),children:/* @__PURE__ */n("svg",te?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})})]})]}),tn=/* @__PURE__ */e("div",{children:[_?/* @__PURE__ */n("div",{className:En("p-4",x.isDark?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-700"),children:/* @__PURE__ */n("pre",{className:"text-sm font-mono whitespace-pre-wrap",children:M})}):en,ee&&/* @__PURE__ */n("div",{className:"mermaid-error",children:ee})]});/* @__PURE__ */
|
|
129
|
-
return e(t,{children:[
|
|
130
|
-
/* @__PURE__ */e("div",{"data-markstream-mermaid":"1","data-markstream-mode":_?"source":Y?"preview":"pending",className:En("my-4 rounded-lg border overflow-hidden shadow-sm mermaid-block",x.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":Se}),children:[nn,
|
|
131
|
-
/* @__PURE__ */n("div",{ref:he,style:{display:H?"none":""},children:tn})]}),te&&"undefined"!=typeof document&&de(
|
|
132
|
-
/* @__PURE__ */n("div",{className:"mermaid-modal-overlay",onClick:()=>Ve(),children:/* @__PURE__ */e("div",{className:En("mermaid-modal-panel",{"is-dark":x.isDark}),role:"dialog","aria-modal":"true",onClick:e=>e.stopPropagation(),children:[
|
|
133
|
-
/* @__PURE__ */e("div",{className:"mermaid-modal-header",children:[
|
|
134
|
-
/* @__PURE__ */n("span",{className:"mermaid-modal-title",children:`Mermaid ${k("common.preview")}`}),
|
|
135
|
-
/* @__PURE__ */n("button",{type:"button",className:"mermaid-modal-close",onClick:Ve,children:k("common.close")})]}),
|
|
136
|
-
/* @__PURE__ */n("div",{className:"mermaid-modal-body",children:/* @__PURE__ */n("div",{ref:fe,className:"mermaid-modal-content"})})]})}),document.body)]})}function kr(e,n,t){return Math.min(Math.max(e,n),t)}async function br(e,n,t){try{if(await lr(e,n,t.workerTimeout))return!0}catch(l){if("AbortError"===(null==l?void 0:l.name))throw l}if(!t.mermaid)throw new Error("Mermaid not available");const r=Cr(e,n),o=t.mermaid;if("function"==typeof o.parse)return await Sr(()=>o.parse(r),{timeoutMs:t.parseTimeout,signal:t.signal}),!0;const i=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;return await Sr(()=>o.render(i,r),{timeoutMs:t.parseTimeout,signal:t.signal}),!0}function Cr(e,n){return e.trimStart().startsWith("%%{")?e:`%%{init: {"theme": "${"dark"===n?"dark":"default"}"}}%%\n${e}`}function Mr(e){var n;for(const t of e.split(/\r?\n/)){const e=t.trim();if(!e||e.startsWith("%%"))continue;const r=e.match(/^([A-Z][\w-]*)\b/i);return(null==(n=null==r?void 0:r[1])?void 0:n.toLowerCase())||""}return""}function Nr(e){const n=e.trim();return!(!n||n.startsWith("%%"))&&!/^(?:gantt|title|dateformat|axisformat|tickinterval|excludes|section|todaymarker|topaxis|weekday|weekend|acctitle|accdescr|accdescrmultiline)\b/i.test(n)&&n.includes(":")}function Br(e){if("gantt"===Mr(e))return function(e){var n;const t=e.split(/\r?\n/);for(!/\r?\n$/.test(e)&&t.length>0&&t.pop();t.length>0;){const e=null==(n=t[t.length-1])?void 0:n.trim();if(e&&!e.startsWith("%%")){if(Nr(e))break;t.pop()}else t.pop()}return t.some(Nr)?t.join("\n"):""}(e);const n=e.split("\n");for(;n.length>0;){const e=n[n.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;n.pop()}else n.pop()}return n.join("\n")}async function Sr(e,n={}){const{timeoutMs:t,signal:r}=n;return(null==r?void 0:r.aborted)?Promise.reject(new DOMException("Aborted","AbortError")):new Promise((n,o)=>{let i=!1,l=null;function a(){i||(i=!0,c(),o(new DOMException("Aborted","AbortError")))}function c(){null!=l&&clearTimeout(l),r&&r.removeEventListener("abort",a)}r&&r.addEventListener("abort",a,{once:!0}),t&&t>0&&(l=setTimeout(()=>{i||(i=!0,c(),o(new Error("Operation timed out")))},t)),e().then(e=>{i||(i=!0,c(),n(e))}).catch(e=>{i||(i=!0,c(),o(e))})})}function Tr(e){return(new XMLSerializer).serializeToString(e)}function Lr(n){const{node:t}=n;/* @__PURE__ */
|
|
137
|
-
return e("div",{className:"unknown-node text-sm text-gray-500 italic",children:["Unsupported node type:"," ",String(null==t?void 0:t.type)]})}function Er(e){var n;return"text"===(null==e?void 0:e.type)&&""===String(null!=(n=null==e?void 0:e.content)?n:"").trim()}function Dr(e,t,o,i){const l=e.filter(e=>!Er(e)),a=l.length>0&&l.every(e=>"image"===e.type||function(e){var n;const t=function(e){return"link"===(null==e?void 0:e.type)&&Array.isArray(null==e?void 0:e.children)?e.children.filter(e=>!Er(e)):[]}(e);return 1===t.length&&"image"===(null==(n=t[0])?void 0:n.type)}(e));if(!a||l.length<=1)return E(e,o,i,t);const c=[];for(let n=0;n<e.length;n++){const t=e[n];if(!Er(t)){c.push(t);continue}const r=c.length>0,o=e.slice(n+1).some(e=>!Er(e));r&&o&&c.push({...t,content:" ",raw:" "})}return c.map((e,l)=>{var c;return a&&Er(e)?/* @__PURE__ */n(r.Fragment,{children:String(null!=(c=null==e?void 0:e.content)?c:"")},`${i}-${l}`):t(e,`${i}-${l}`,o)})}function $r(e){var o,i;const{node:l,ctx:a,renderNode:c,indexKey:s,children:d}=e;if(!a||!c)/* @__PURE__ */
|
|
138
|
-
return n("p",{dir:"auto",className:"paragraph-node",children:d});const u=null!=(o=l.children)?o:[],m=null!=(i=a.customComponents)?i:W(a.customId),h=[],f=[],p=()=>{if(!f.length)return;const e=h.length;h.push(
|
|
139
|
-
/* @__PURE__ */n("p",{dir:"auto",className:"paragraph-node",children:Dr(f.slice(),c,a,`${String(null!=s?s:"paragraph")}-${e}`)},`${String(null!=s?s:"paragraph")}-inline-${e}`)),f.length=0};return u.forEach((e,t)=>{ee.has(e.type)||ne(e,m,a.customHtmlTags)?(p(),h.push(
|
|
140
|
-
/* @__PURE__ */n(r.Fragment,{children:c(e,`${String(null!=s?s:"paragraph")}-block-${t}`,a)},`${String(null!=s?s:"paragraph")}-block-${t}`))):f.push(e)}),p(),h.length?/* @__PURE__ */n(t,{children:h}):/* @__PURE__ */n("p",{dir:"auto",className:"paragraph-node",children:Dr(u,c,a,String(null!=s?s:"paragraph"))})}function Pr(e){const{node:t}=e,r=d(n=>{var r;null==(r=e.onClick)||r.call(e,n,t.id,e.messageId,e.threadId)},[t.id,e]);/* @__PURE__ */
|
|
141
|
-
return n("span",{className:"reference-node cursor-pointer bg-[hsl(var(--muted))] text-xs rounded-md px-1.5 mx-0.5 hover:bg-[hsl(var(--secondary))]",role:"button",tabIndex:0,onClick:r,onMouseEnter:n=>{var r;null==(r=e.onMouseEnter)||r.call(e,n,t.id,e.messageId,e.threadId)},onMouseLeave:n=>{var r;null==(r=e.onMouseLeave)||r.call(e,n,t.id,e.messageId,e.threadId)},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||r(e)},children:t.id})}function Rr(e){/* @__PURE__ */
|
|
142
|
-
return n("s",{className:"strikethrough-node",children:e.children})}function _r(e){/* @__PURE__ */
|
|
143
|
-
return n("strong",{className:"strong-node",children:e.children})}function Ar(e){/* @__PURE__ */
|
|
144
|
-
return n("sub",{className:"subscript-node",children:e.children})}function Hr(e){/* @__PURE__ */
|
|
145
|
-
return n("sup",{className:"superscript-node",children:e.children})}function Ir(t){var o;const{node:i,ctx:l,renderNode:a,indexKey:c}=t,s=Array.isArray(null==(o=null==i?void 0:i.header)?void 0:o.cells)?i.header.cells:[],d=Boolean(null==i?void 0:i.loading),u=Array.isArray(null==i?void 0:i.rows)?i.rows:[],m=r.useRef(null),h=r.useRef(null),f=r.useRef(null),[p,g]=r.useState([]),v=e=>"right"===e?"text-right":"center"===e?"text-center":"text-left",w=()=>{const e=f.current;e&&(window.removeEventListener("pointermove",e.move),window.removeEventListener("pointerup",e.stop),window.removeEventListener("pointercancel",e.stop),f.current=null),h.current=null};return r.useEffect(()=>(w(),g([]),w),[s.length]),/* @__PURE__ */e("div",{className:"table-node-wrapper","data-index-key":c,children:[
|
|
146
|
-
/* @__PURE__ */e("table",{ref:m,className:En("my-8 text-sm table-node",d&&"table-node--loading"),"aria-busy":d,children:[p.length>0&&/* @__PURE__ */n("colgroup",{children:s.map((e,t)=>/* @__PURE__ */n("col",{style:p[t]>0?{width:`${p[t]}px`}:void 0},`col-${t}`))}),
|
|
147
|
-
/* @__PURE__ */n("thead",{className:"border-[var(--table-border,#cbd5e1)]",children:/* @__PURE__ */n("tr",{className:"border-b",children:s.map((t,r)=>/* @__PURE__ */e("th",{className:En("font-semibold p-[calc(4/7*1em)]",v(t.align)),dir:"auto",children:[l&&a?A(t.children,l,`${String(null!=c?c:"table")}-th-${r}`,a):null,r<s.length-1&&/* @__PURE__ */n("button",{type:"button",className:"table-node__resize-handle","aria-label":`Resize columns ${r+1} and ${r+2}`,onPointerDown:e=>((e,n)=>{if(0!==n.button)return;const t=(()=>{var e;const n=null==(e=m.current)?void 0:e.querySelectorAll("thead th");return Array.from(null!=n?n:[],e=>Math.round(e.getBoundingClientRect().width))})(),r=t[e],o=t[e+1];if(!r||!o)return;n.preventDefault(),w(),h.current={index:e,startX:n.clientX,startWidth:r,nextStartWidth:o,widths:t},g(t);const i=e=>{const n=h.current;if(!n)return;e.preventDefault();const t=n.startWidth+n.nextStartWidth,r=Math.min(48,Math.floor(t/2)),o=Math.max(r,Math.min(t-r,Math.round(n.startWidth+e.clientX-n.startX))),i=[...n.widths];i[n.index]=o,i[n.index+1]=t-o,g(i)},l=()=>{w()};f.current={move:i,stop:l},window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l)})(r,e)})]},`header-${r}`))})}),
|
|
148
|
-
/* @__PURE__ */n("tbody",{children:u.map((e,t)=>{var r;/* @__PURE__ */
|
|
149
|
-
return n("tr",{className:En("border-[var(--table-border,#cbd5e1)]",t<u.length-1&&"border-b"),children:null==(r=e.cells)?void 0:r.map((e,r)=>/* @__PURE__ */n("td",{className:En("p-[calc(4/7*1em)]",v(e.align)),dir:"auto",children:l&&a?A(e.children,l,`${String(null!=c?c:"table")}-row-${t}-${r}`,a):null},`cell-${t}-${r}`))},`row-${t}`)})})]}),d&&/* @__PURE__ */e("div",{className:"table-node__loading",role:"status","aria-live":"polite",children:[
|
|
150
|
-
/* @__PURE__ */n("span",{className:"table-node__spinner","aria-hidden":"true"}),
|
|
151
|
-
/* @__PURE__ */n("span",{className:"sr-only",children:"Loading"})]})]})}function Wr(){/* @__PURE__ */
|
|
152
|
-
return n("hr",{className:"hr-node thematic-break"})}function Fr(e){const{node:t,ctx:i,renderNode:l,indexKey:a}=e,c=`vmr-container vmr-container-${t.name}`,s=o(()=>{if(t.attrs)return Array.isArray(t.attrs)?F(t.attrs):t.attrs},[t.attrs]);/* @__PURE__ */
|
|
153
|
-
return n("div",{className:c,...s,children:i&&l&&Array.isArray(t.children)?t.children.map((e,t)=>/* @__PURE__ */n(r.Fragment,{children:l(e,`${String(null!=a?a:"vmr-container")}-${t}`,i)},`${String(null!=a?a:"vmr-container")}-${t}`)):null})}function Or(e,n,t,o,i={}){var l,a,c,s,d,u;const m=re(o.codeBlockProps),h=o.events.onHandleArtifactClick?e=>{var r,i;const l="image/svg+xml"===e.type?"image/svg+xml":"text/html";null==(i=(r=o.events).onHandleArtifactClick)||i.call(r,{node:null==e.content?n:{...n,code:e.content},artifactType:l,artifactTitle:e.title||("image/svg+xml"===l?"SVG Preview":"HTML Preview"),id:String(t)})}:void 0;return r.createElement(e,{key:t,node:n,loading:Boolean(n.loading),stream:o.codeBlockStream,customId:o.customId,isDark:o.isDark,darkTheme:null==(l=o.codeBlockThemes)?void 0:l.darkTheme,lightTheme:null==(a=o.codeBlockThemes)?void 0:a.lightTheme,themes:null==(c=o.codeBlockThemes)?void 0:c.themes,langs:null==(s=o.codeBlockThemes)?void 0:s.langs,minWidth:null==(d=o.codeBlockThemes)?void 0:d.minWidth,maxWidth:null==(u=o.codeBlockThemes)?void 0:u.maxWidth,onCopy:o.events.onCopy,onPreviewCode:h,...m,...i,ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade})}function jr(e,n,t,o,i={}){return r.createElement(e,{key:t,node:n,isDark:o.isDark,...i})}function zr(e,t,o){var i,l,a,c,s,d,u,m,h;const f=null!=(i=o.customComponents)?i:W(o.customId),p="code_block"===e.type?null:f[e.type];if(p)return r.createElement(p,{key:t,node:e,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade});if("html_block"===e.type||"html_inline"===e.type){const i=te(e,f,o.customHtmlTags),h=String(null!=(l=e.tag)?l:"").trim().toLowerCase()||M(e.content),p=null!=(a=null==i?void 0:i.tag)?a:h;if(p){const l=null!=(c=null==i?void 0:i.component)?c:f[p],a=null!=(d=null==i?void 0:i.isWhitelisted)?d:(null!=(s=o.customHtmlTags)?s:[]).some(e=>e.toLowerCase()===p);if(a&&l){const n={...e,type:p,tag:p,content:N(e.content,p)};return r.createElement(l,{key:t,node:n,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade})}const h=String(null!=(m=null!=(u=e.content)?u:e.raw)?m:"");if(!a&&B(h,p))return"html_inline"===e.type?/* @__PURE__ */n(vt,{node:{type:"text",content:h,raw:h},ctx:o,indexKey:t,typewriter:o.typewriter,fade:o.fade},t):/* @__PURE__ */n($r,{node:{type:"paragraph",children:[{type:"text",content:h,raw:h}],raw:h},ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t)}}switch(e.type){case"text":/* @__PURE__ */
|
|
154
|
-
return n(vt,{node:e,ctx:o,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"text_special":/* @__PURE__ */
|
|
155
|
-
return n(vt,{node:{type:"text",content:null!=(h=e.content)?h:"",center:e.center},ctx:o,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"paragraph":/* @__PURE__ */
|
|
156
|
-
return n($r,{node:e,ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"heading":/* @__PURE__ */
|
|
157
|
-
return n(Jn,{node:e,ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"blockquote":/* @__PURE__ */
|
|
158
|
-
return n(Zr,{node:e,ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"list":/* @__PURE__ */
|
|
159
|
-
return n(xt,{node:e,ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"list_item":/* @__PURE__ */
|
|
160
|
-
return n(yt,{node:e,ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"table":/* @__PURE__ */
|
|
161
|
-
return n(Ir,{node:e,ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"definition_list":/* @__PURE__ */
|
|
162
|
-
return n(Vn,{node:e,ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"footnote":/* @__PURE__ */
|
|
163
|
-
return n(Yn,{node:e,ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"footnote_reference":/* @__PURE__ */
|
|
164
|
-
return n(Zn,{node:e},t);case"footnote_anchor":/* @__PURE__ */
|
|
165
|
-
return n(qn,{node:e},t);case"admonition":/* @__PURE__ */
|
|
166
|
-
return n(ve,{node:e,ctx:o,renderNode:zr,indexKey:t,isDark:o.isDark,typewriter:o.typewriter,fade:o.fade},t);case"hardbreak":/* @__PURE__ */
|
|
167
|
-
return n(Gn,{node:e,typewriter:o.typewriter,fade:o.fade},t);case"link":/* @__PURE__ */
|
|
168
|
-
return n(wt,{node:e,ctx:o,renderNode:zr,indexKey:t,isDark:o.isDark,showTooltip:"boolean"==typeof o.showTooltips?o.showTooltips:void 0,typewriter:o.typewriter,fade:o.fade},t);case"image":/* @__PURE__ */
|
|
169
|
-
return n(st,{node:e},t);case"inline_code":/* @__PURE__ */
|
|
170
|
-
return n(pt,{node:e,ctx:o,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"code_block":return function(e,t,r,o){var i,l,a,c;const s=function(e){const n=String((null==e?void 0:e.language)||"").trim();if(!n)return"";const[t]=n.split(/\s+/),[r]=t.split(":");return r.toLowerCase()}(e),d=D(s),u=function(e,n){const t=n.trim().toLowerCase();if(!t)return null;for(const r of[t,D(t),le(t)]){const n=r&&e[r];if(n)return n}return null}(o,s);if("mermaid"===d){const i=function(e,n){var t,r;const o={...n.mermaidProps||{}};return null==G(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=J(Q(String(null!=(t=null==e?void 0:e.code)?t:"")),void 0,"none"===o.maxHeight?null:null!=(r=G(o.maxHeight))?r:void 0)),o}(e,r),l=u||o.mermaid;if(l)return jr(l,e,t,r,i);if(!r.renderCodeBlocksAsPre)/* @__PURE__ */
|
|
171
|
-
return n(xr,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...i},t)}if("infographic"===d){const i=function(e,n){var t,r;const o={...n.infographicProps||{}};return null==U(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=q(Y(String(null!=(t=null==e?void 0:e.code)?t:"")),void 0,"none"===o.maxHeight?null:null!=(r=U(o.maxHeight))?r:void 0)),o}(e,r),l=u||o.infographic;return l?jr(l,e,t,r,i):/* @__PURE__ */n(ft,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...i},t)}if("d2"===d||"d2lang"===d){const i=u||o.d2;return i?jr(i,e,t,r,r.d2Props||{}):/* @__PURE__ */n(Kn,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...r.d2Props||{}},t)}if(u)return Or(u,e,t,r);const m=o.code_block;return m?Or(m,e,t,r):r.renderCodeBlocksAsPre||"mermaid"===d?/* @__PURE__ */n(xn,{node:e},t):/* @__PURE__ */n(Tn,{node:e,loading:Boolean(e.loading),stream:r.codeBlockStream,monacoOptions:null==(i=r.codeBlockThemes)?void 0:i.monacoOptions,themes:null==(l=r.codeBlockThemes)?void 0:l.themes,minWidth:null==(a=r.codeBlockThemes)?void 0:a.minWidth,maxWidth:null==(c=r.codeBlockThemes)?void 0:c.maxWidth,isDark:r.isDark,onCopy:r.events.onCopy,...re(r.codeBlockProps,{omit:["langs"]})},t)}(e,t,o,f);case"strong":/* @__PURE__ */
|
|
172
|
-
return n(_r,{node:e,children:E(e.children,o,`${String(t)}-strong`,zr)},t);case"emphasis":/* @__PURE__ */
|
|
173
|
-
return n(Un,{node:e,children:E(e.children,o,`${String(t)}-em`,zr)},t);case"strikethrough":/* @__PURE__ */
|
|
174
|
-
return n(Rr,{node:e,children:E(e.children,o,`${String(t)}-strike`,zr)},t);case"highlight":/* @__PURE__ */
|
|
175
|
-
return n(Qn,{node:e,children:E(e.children,o,`${String(t)}-highlight`,zr)},t);case"insert":/* @__PURE__ */
|
|
176
|
-
return n(gt,{node:e,children:E(e.children,o,`${String(t)}-insert`,zr)},t);case"subscript":/* @__PURE__ */
|
|
177
|
-
return n(Ar,{node:e,children:E(e.children,o,`${String(t)}-sub`,zr)},t);case"superscript":/* @__PURE__ */
|
|
178
|
-
return n(Hr,{node:e,children:E(e.children,o,`${String(t)}-sup`,zr)},t);case"checkbox":case"checkbox_input":/* @__PURE__ */
|
|
179
|
-
return n(Se,{node:e,typewriter:o.typewriter,fade:o.fade},t);case"emoji":/* @__PURE__ */
|
|
180
|
-
return n(Xn,{node:e,typewriter:o.typewriter,fade:o.fade},t);case"thematic_break":/* @__PURE__ */
|
|
181
|
-
return n(Wr,{},t);case"math_inline":/* @__PURE__ */
|
|
182
|
-
return n(Xt,{node:e},t);case"math_block":/* @__PURE__ */
|
|
183
|
-
return n(Vt,{node:e},t);case"reference":/* @__PURE__ */
|
|
184
|
-
return n(Pr,{node:e,ctx:o,typewriter:o.typewriter,fade:o.fade},t);case"html_block":case"html_inline":return"html_block"===e.type?/* @__PURE__ */n(et,{node:e,ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade,customId:o.customId},t):/* @__PURE__ */n(lt,{node:e,ctx:o,typewriter:o.typewriter,fade:o.fade,customId:o.customId},t);case"vmr_container":/* @__PURE__ */
|
|
185
|
-
return n(Fr,{node:e,ctx:o,renderNode:zr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"label_open":case"label_close":return null;default:/* @__PURE__ */
|
|
186
|
-
return n(Lr,{node:e},t)}}const Kr={codeBlockStream:!0,typewriter:!1,fade:!0,smoothStreaming:"auto",batchRendering:!0,initialRenderBatchSize:40,renderBatchSize:80,renderBatchDelay:16,renderBatchBudgetMs:6,renderBatchIdleTimeoutMs:120,deferNodesUntilVisible:!0,maxLiveNodes:320,liveNodeBuffer:60},Vr=T();function Xr(e,n){if(e.type!==n.type)return!1;if(e.raw!==n.raw)return!1;if("code_block"===e.type||"code_block"===n.type){if(e.loading!==n.loading)return!1;if(e.diff!==n.diff)return!1}return!0}const Ur=r.memo(({node:e,nodeKey:n,renderCtx:t})=>zr(e,n,t),(e,n)=>e.node===n.node&&e.renderCtx===n.renderCtx&&e.nodeKey===n.nodeKey),qr=r.memo(({props:t,parsedNodes:r,renderCtx:l,indexPrefix:a,containerRef:u,showTypewriterCursor:m,typewriterCursorRef:h})=>{var f,p,g,v,w,y,x;const k=Ne(),b="undefined"!=typeof window,C="undefined"!=typeof window&&"function"==typeof window.requestIdleCallback,M=Math.max(0,Math.trunc(null!=(f=t.renderBatchSize)?f:80)),N=Math.max(0,Math.trunc(null!=(p=t.initialRenderBatchSize)?p:M||r.length)),B=!1!==t.batchRendering&&M>0&&b,S=Math.max(0,null!=(g=t.liveNodeBuffer)?g:60),T=Math.max(1,null!=(v=t.maxLiveNodes)?v:320),L=(null!=(w=t.maxLiveNodes)?w:0)>0&&r.length>T,E=!1!==t.viewportPriority,D=B&&(null!=(y=t.maxLiveNodes)?y:0)<=0,$=o(()=>{var e;return!1!==t.deferNodesUntilVisible&&!((null!=(e=t.maxLiveNodes)?e:0)<=0)&&!L&&!(r.length>900)&&E},[r.length,t.deferNodesUntilVisible,t.maxLiveNodes,E,L]),[P,R]=i(()=>D?Math.min(r.length,N):r.length),_=c(P);s(()=>{_.current=P},[P]);const A=D?P:r.length,[H,I]=i(0),[W,F]=i({start:0,end:r.length}),O=c(/* @__PURE__ */new Map),[j,z]=i(0),K=c({}),V=c(/* @__PURE__ */new Map),X=c(/* @__PURE__ */new Map),U=c(/* @__PURE__ */new Map),q=c(/* @__PURE__ */new Map),Y=c(/* @__PURE__ */new Set),Z=c(P),G=c(null),J=c(null),Q=c(null),ee=c(!1),ne=c(null),te=c(Math.max(1,M||1)),re=c(r.length),oe=c({key:t.indexKey,total:r.length}),ie=c({batchSize:M,initial:N,delay:null!=(x=t.renderBatchDelay)?x:16,enabled:D}),le=$||L,ae=o(()=>{const e=O.current;if(!e.size)return 32;let n=0;for(const t of e.values())n+=t;return Math.max(16,n/e.size)},[j]),ce=o(()=>{if(!L)return r.map((e,n)=>({node:e,index:n}));const e=r.length,n=Math.max(0,Math.min(W.start,e)),t=Math.max(n,Math.min(W.end,e));return r.slice(n,t).map((e,t)=>({node:e,index:n+t}))},[r,W,L]),se=o(()=>{if(!L)return r.length;const e=Math.max(W.end+S,N),n=Math.min(r.length,e);return Math.max(P,n)},[r.length,L,W.end,S,N,P]);re.current=se;const de=d((e,n)=>{var t;if(e>=n)return 0;const r=O.current;let o=0;for(let i=e;i<n;i++)o+=null!=(t=r.get(i))?t:ae;return o},[ae]),ue=L?de(0,Math.min(W.start,r.length)):0,me=L?de(Math.min(W.end,r.length),r.length):0,he=d(()=>{null!=G.current&&"function"==typeof cancelAnimationFrame&&(cancelAnimationFrame(G.current),G.current=null),null!=J.current&&(window.clearTimeout(J.current),J.current=null),null!=Q.current&&"function"==typeof window.cancelIdleCallback&&(window.cancelIdleCallback(Q.current),Q.current=null),ee.current=!1,ne.current=null},[]),fe=d(e=>{var n;if(!D)return;const r=Math.max(2,null!=(n=t.renderBatchBudgetMs)?n:6),o=Math.max(1,M||1),i=Math.max(1,Math.floor(o/4));e>1.2*r?te.current=Math.max(i,Math.floor(.7*te.current)):e<.5*r&&te.current<o&&(te.current=Math.min(o,Math.ceil(1.2*te.current)))},[D,t.renderBatchBudgetMs,M]),pe=d((e,n={})=>{var r,o;if(!D)return;const i=re.current;if(_.current>=i)return;const l=Math.max(1,e),a=e=>{const n="undefined"!=typeof performance?performance.now():Date.now();R(n=>{const t=Math.min(re.current,n+Math.max(1,e));return _.current=t,t});const t="undefined"!=typeof performance?performance.now():Date.now();fe(t-n)},c=()=>{const e=Math.max(1,Math.round(te.current));pe(e)},s=e=>{var n;G.current=null,J.current=null,Q.current=null,ee.current=!1;const r=ne.current;if(ne.current=null,a(null!=r?r:l),_.current>=re.current)return;if(!e)return void c();const o=Math.max(2,null!=(n=t.renderBatchBudgetMs)?n:6);for(;_.current<re.current&&!(("function"==typeof e.timeRemaining?e.timeRemaining():0)<=.5*o);)a(Math.max(1,Math.round(te.current)));_.current<re.current&&c()};if(!b||n.immediate)return void s();const d=Math.max(0,null!=(r=t.renderBatchDelay)?r:16);if(ne.current=null!=ne.current?Math.max(ne.current,l):l,!ee.current){if(ee.current=!0,C){const e=Math.max(0,null!=(o=t.renderBatchIdleTimeoutMs)?o:120);return void(Q.current=window.requestIdleCallback(e=>s(e),{timeout:e}))}"function"==typeof requestAnimationFrame?G.current=requestAnimationFrame(()=>{0!==d?J.current=window.setTimeout(()=>s(),d):s()}):J.current=window.setTimeout(()=>s(),d)}},[fe,C,D,b,t.renderBatchDelay,t.renderBatchBudgetMs,t.renderBatchIdleTimeoutMs]);s(()=>{var e;const n=t.indexKey,o=r.length,i=oe.current,l=void 0!==n?n!==i.key:o!==i.total;oe.current={key:n,total:o};const a=ie.current,c=null!=(e=t.renderBatchDelay)?e:16,s=a.batchSize!==M||a.initial!==N||a.delay!==c||a.enabled!==D;if(ie.current={batchSize:M,initial:N,delay:c,enabled:D},(l||s||!D)&&he(),(l||s)&&(te.current=Math.max(1,M||1),Y.current.clear()),!o)return _.current=0,void R(0);const d=re.current;if(!D)return _.current=d,void R(d);if(l||s){const e=Math.min(d,N);return _.current=e,R(e),void(e<d&&pe(Math.max(1,N),{immediate:!b}))}const u=Math.min(_.current,d);u!==_.current&&(_.current=u,R(u)),_.current<d&&pe(Math.max(1,M||1))},[he,D,b,r.length,t.indexKey,t.renderBatchDelay,M,N,pe]),s(()=>{if(!L)return void F({start:0,end:r.length});const e=r.length;if(!e)return void F({start:0,end:0});const n=Math.max(0,Math.min(H,e-1));let t=Math.max(0,n-S),o=Math.min(e,n+S+1);const i=o-t;if(i>T){const e=i-T;t+=Math.ceil(e/2),o-=Math.floor(e/2)}else if(i<T){const n=T-i;t=Math.max(0,t-Math.ceil(n/2)),o=Math.min(e,o+Math.floor(n/2))}F({start:t,end:o})},[H,S,T,r.length,L]),s(()=>()=>{he();for(const e of V.current.values())e.destroy();V.current.clear()},[he]);const ge=d(e=>{for(const[n,t]of V.current.entries())n>=e&&(t.destroy(),V.current.delete(n),delete K.current[n],X.current.delete(n),U.current.delete(n),q.current.delete(n))},[]);s(()=>{ge(A)},[ge,A]),s(()=>{const e=r.length;let n=!1;for(const t of Array.from(O.current.keys()))t>=e&&(O.current.delete(t),n=!0);n&&z(e=>e+1);for(const t of Object.keys(K.current))Number(t)>=e&&delete K.current[t];for(const t of Array.from(Y.current))t>=e&&Y.current.delete(t)},[r.length]);const ve=d((e,n)=>{$&&n&&(K.current[e]=!0),n&&L&&I(n=>e>n?e:n)},[$,L]),we=d(e=>{const n=V.current.get(e);n&&(n.destroy(),V.current.delete(e))},[]),ye=d((e,n)=>{const t=X.current;if(n?t.set(e,n):t.delete(e),!le||!n)return we(e),$&&!n&&delete K.current[e],void(n&&ve(e,!0));if(e<N&&!L)return we(e),void ve(e,!0);we(e);const r=k(n,{rootMargin:"400px"});V.current.set(e,r),r.isVisible()&&ve(e,!0),r.whenVisible.then(()=>ve(e,!0)).catch(()=>{})},[$,we,ve,k,N,le,L]),xe=d(e=>{const n=U.current.get(e);if(n)return n;const t=n=>ye(e,n);return U.current.set(e,t),t},[ye]),ke=d((e,n)=>{if(!n)return void(O.current.has(e)&&(O.current.delete(e),z(e=>e+1)));const t=()=>{const t=n.offsetHeight;t&&O.current.get(e)!==t&&(O.current.set(e,t),z(e=>e+1))};"function"==typeof queueMicrotask?queueMicrotask(t):Promise.resolve().then(t)},[]),be=d(e=>{const n=q.current.get(e);if(n)return n;const t=n=>ke(e,n);return q.current.set(e,t),t},[ke]),Ce=d(e=>!(D&&e>=_.current)&&(!$||e<N||!0===K.current[e]),[$,D,N]),Me=d(e=>n=>{if(!e)return;const t=n.target;(null==t?void 0:t.closest("[data-node-index]"))&&e(n)},[]);s(()=>{for(const[e,n]of X.current.entries())n&&ye(e,n)},[ye]),s(()=>{L&&P>Z.current&&I(P-1),Z.current=P},[P,L]);const Be=L?/* @__PURE__ */n("div",{className:"node-spacer",style:{height:`${ue}px`},"aria-hidden":"true"}):null,Se=L?/* @__PURE__ */n("div",{className:"node-spacer",style:{height:`${me}px`},"aria-hidden":"true"}):null;/* @__PURE__ */
|
|
187
|
-
return e("div",{ref:u,className:`markstream-react markdown-renderer${t.isDark?" dark":""}${L?" virtualized":""}`,"data-custom-id":t.customId,onClick:t.onClick,onMouseOver:Me(t.onMouseOver),onMouseOut:Me(t.onMouseOut),children:[Be,ce.map(({node:e,index:r})=>{var o;const i=Ce(r),c=null!=(o=O.current.get(r))?o:ae,s=!1!==t.fade&&"code_block"!==e.type&&!Y.current.has(r)&&i;return s&&Y.current.add(r),/* @__PURE__ */n("div",{ref:xe(r),className:"node-slot","data-node-index":r,"data-node-type":e.type,children:/* @__PURE__ */n("div",i?{ref:be(r),className:"node-content"+(s?" fade-node typewriter-node":""),children:/* @__PURE__ */n(Ur,{node:e,nodeKey:`${a}-${r}`,renderCtx:l})}:{className:"node-placeholder",style:{height:`${c}px`}})},`${a}-${r}`)}),Se,m&&/* @__PURE__ */n("span",{ref:h,className:"typewriter-cursor","aria-hidden":"true"})]})},function(e,n){if(e.renderCtx!==n.renderCtx)return!1;if(e.indexPrefix!==n.indexPrefix)return!1;if(e.containerRef!==n.containerRef)return!1;if(e.showTypewriterCursor!==n.showTypewriterCursor)return!1;const t=e.parsedNodes,r=n.parsedNodes;if(t===r)return!0;if(t.length!==r.length)return!1;for(let l=0;l<t.length;l++)if(t[l]!==r[l])return!1;const o=e.props,i=n.props;return o.isDark===i.isDark&&o.typewriter===i.typewriter&&o.fade===i.fade&&o.batchRendering===i.batchRendering&&o.initialRenderBatchSize===i.initialRenderBatchSize&&o.renderBatchSize===i.renderBatchSize&&o.renderBatchDelay===i.renderBatchDelay&&o.renderBatchBudgetMs===i.renderBatchBudgetMs&&o.renderBatchIdleTimeoutMs===i.renderBatchIdleTimeoutMs&&o.deferNodesUntilVisible===i.deferNodesUntilVisible&&o.maxLiveNodes===i.maxLiveNodes&&o.liveNodeBuffer===i.liveNodeBuffer&&o.viewportPriority===i.viewportPriority&&o.indexKey===i.indexKey&&o.onClick===i.onClick&&o.onMouseOver===i.onMouseOver&&o.onMouseOut===i.onMouseOut}),Yr=e=>{var t,l;const a={...Kr,...e},m=c(null),h=c(null),f=c(/* @__PURE__ */new Map),p=c(0),g=c(null),v=Be(a.smoothStreamingOptions),w=r.useContext(we),[y,x]=i(()=>!0===a.smoothStreaming);s(()=>{x(!0)},[]);const k=Array.isArray(a.nodes)&&a.nodes.length>0,b=o(()=>{var e;return!1!==a.smoothStreaming&&!k&&(!0===a.smoothStreaming||!w)&&(!0===a.smoothStreaming||!0===a.typewriter||(null!=(e=a.maxLiveNodes)?e:0)<=0)},[k,w,a.maxLiveNodes,a.smoothStreaming,a.typewriter]),C=y&&b,M=C?v.visible:null!=(t=a.content)?t:"",N=o(()=>{var e,n;const t=null!=(e=a.parseOptions)?e:{};return null!=(n=a.final)?n:t.final},[a.final,a.parseOptions]),B=null!=(l=a.content)?l:"",E=k||v.source===B,$=o(()=>C&&null!=N?Boolean(N&&E&&v.caughtUp):N,[N,E,v.caughtUp,C]),P=c(null),[R,_]=i(!1),A=c(void 0),F=c(0),O=o(()=>/* @__PURE__ */new Set(["code_block","admonition","table","math_block","html_block","image"]),[]),j=d(e=>{if(!e||"object"!=typeof e)return!1;const n=e.type;return"string"==typeof n&&O.has(n)},[O]),z=d(e=>{var n,t;if(!e||"object"!=typeof e)return 0;const r=e,o=null!=(t=null!=(n=r.raw)?n:r.content)?t:r.code;if("string"==typeof o)return o.length;const i=r.children;if(Array.isArray(i))return i.reduce((e,n)=>e+z(n),0);const l=r.items;return Array.isArray(l)?l.reduce((e,n)=>e+z(n),0):0},[]),K=d(()=>{var e,n;return(null==(e=a.nodes)?void 0:e.length)?a.nodes.reduce((e,n)=>e+z(n),0):(null!=(n=a.content)?n:"").length},[a.nodes,a.content,z]),V=d(()=>{A.current&&(clearTimeout(A.current),A.current=void 0)},[]),X=d(e=>{const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){var n;if(!(null!=(n=e.textContent)?n:"").trim())return NodeFilter.FILTER_REJECT;const t=e.parentElement;return t?t.closest('.typewriter-cursor, .height-estimation-probes, [data-node-type="code_block"], [data-node-type="admonition"], [data-node-type="table"], [data-node-type="math_block"], [data-node-type="html_block"], [data-node-type="image"], script, style')?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});let t=null,r=n.nextNode();for(;r;)t=r,r=n.nextNode();return t},[]),U=d(()=>{var e,n;if("undefined"==typeof window||!R||!m.current||!P.current)return;const t=m.current,r=P.current,o=X(t),i=t.getBoundingClientRect();let l=0,a=0,c=20;if(null==o?void 0:o.textContent){const r=document.createRange(),s=o.textContent.length;r.setStart(o,Math.max(0,s-1)),r.setEnd(o,s);const d="function"==typeof r.getClientRects?r.getClientRects():void 0,u=null!=(n=null==d?void 0:d[d.length-1])?n:null==(e=o.parentElement)?void 0:e.getBoundingClientRect();u&&(l=u.right-i.left+t.scrollLeft,a=u.top-i.top+t.scrollTop,c=u.height||c),r.detach()}r.style.transform=`translate(${Math.max(0,l)}px, ${Math.max(0,a)}px)`,r.style.height=`${c}px`},[R,m,X]);s(()=>{R&&requestAnimationFrame(()=>{U()})},[R,U]),s(()=>()=>{V()},[V]);const q=k?a.nodes:M;g.current!==q&&(p.current+=1,g.current=q);const Y=u(H,I,I),Z=o(()=>W(a.customId),[a.customId,Y]),G=o(()=>a.customId?`renderer-${a.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,[a.customId]),J=o(()=>{var e,n;const t=null!=(n=(null!=(e=a.parseOptions)?e:{}).customHtmlTags)?n:[];return S(a.customHtmlTags,Array.isArray(t)?t:[])},[a.customId,a.customHtmlTags,a.parseOptions,Y]),Q=o(()=>{const e=J;return e&&0!==e.length?T(G,{customHtmlTags:e}):T(G)},[G,J]),ee=o(()=>{const e=Q;return a.customMarkdownIt?a.customMarkdownIt(e):e},[Q,a.customMarkdownIt]),ne=o(()=>{var e;const n=null!=(e=a.parseOptions)?e:{},t=$,r=null!=t,o=J.length>0;return r||o?{...n,...r?{final:t}:{},...o?{customHtmlTags:J}:{}}:n},[J,$,a.parseOptions]),te=o(()=>{const e=Boolean(a.debugPerformance)&&"undefined"!=typeof console&&"undefined"!=typeof performance,n=e?performance.now():0;let t=[];return k?t=a.nodes.map(e=>({...e})):M&&(t=L(M,null!=ee?ee:Vr,ne)),e&&console.info("[markstream-react][perf] parse(sync)",{ms:Math.round(performance.now()-n),nodes:t.length,contentLength:M.length}),t},[a.debugPerformance,M,k,a.nodes,ne,ee,a.customId,Y,J]),re=d(()=>{const e=te[te.length-1];return!j(e)},[te,j]);s(()=>{if("undefined"==typeof window||k)return;if($)return _(!1),void V();const e=K(),n=re();return!1===a.typewriter||!n||e<=F.current?(!1!==a.typewriter&&n||_(!1),void(F.current=e)):(F.current=e,_(!0),V(),requestAnimationFrame(()=>{U()}),A.current=setTimeout(()=>{_(!1)},3e3),()=>{V()})},[M,a.nodes,a.typewriter,a.content,$,te.length,k,K,re,V,U]);const oe=c([]),ie=function(e,n){if(!n.length)return e;const t=new Array(e.length);let r=e.length===n.length;for(let o=0;o<e.length;o++){const i=o<n.length?n[o]:null;i&&Xr(i,e[o])?t[o]=i:(t[o]=e[o],r=!1)}return r?n:t}(te,oe.current);oe.current=ie,s(()=>{var e;if(k)return void v.reset("");const n=null!=(e=a.content)?e:"";if(!C)return v.reset(n),void(N&&v.finish({flush:!0}));const t=v.getSnapshot().source;n?n===t||(n.startsWith(t)?v.enqueue(n.slice(t.length)):v.reset(n)):v.reset(""),N&&v.finish()},[k,a.content,N,C]),s(()=>{var e,n;if("undefined"==typeof window)return;if(a.renderCodeBlocksAsPre)return;if(!ie.some(e=>{var n;return"code_block"===(null==e?void 0:e.type)&&"mermaid"!==D(String(null!=(n=null==e?void 0:e.language)?n:""))}))return;const t=null!=(e=window.requestIdleCallback)?e:(e,n)=>{var t;return window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),null!=(t=null==n?void 0:n.timeout)?t:600)},r=null!=(n=window.cancelIdleCallback)?n:e=>window.clearTimeout(e),o=t(()=>{Ue()},{timeout:900});return()=>r(o)},[ie,a.renderCodeBlocksAsPre]),s(()=>{if("undefined"==typeof window)return;if(a.renderCodeBlocksAsPre)return;const e=a.isDark?a.codeBlockDarkTheme:a.codeBlockLightTheme,n="string"==typeof e?e:"object"==typeof e&&e&&"name"in e?String(e.name):null;n&&h.current!==n&&(h.current=n,function(e){if(null==e)return;const n=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&e&&"name"in e)return String(e.name);if("object"==typeof e){const n=sn.get(e);if(n)return n;try{const n=JSON.stringify(e);if(n)return sn.set(e,n),n}catch{}const t="__theme_"+ ++dn;return sn.set(e,t),t}return String(e)}(e);n&&ln!==n&&(on=e,ln=n,an&&rn(on,an).then(()=>un()).catch(()=>{}))}(e))},[a.codeBlockDarkTheme,a.codeBlockLightTheme,a.isDark,a.renderCodeBlocksAsPre]);const le=o(()=>null!=a.indexKey?String(a.indexKey):"markdown-renderer",[a.indexKey]),ae=o(()=>({..."boolean"==typeof a.showTooltips?{showTooltips:a.showTooltips}:{},...a.codeBlockProps||{}}),[a.codeBlockProps,a.showTooltips]),ce=o(()=>({...a.mermaidProps||{}}),[a.mermaidProps]),se=o(()=>({...a.d2Props||{}}),[a.d2Props]),de=o(()=>({...a.infographicProps||{}}),[a.infographicProps]),ue=o(()=>{var e;return{customId:a.customId,isDark:a.isDark,indexKey:le,typewriter:a.typewriter,fade:a.fade,textStreamState:f.current,streamRenderVersion:p.current,customComponents:Z,customHtmlTags:J,htmlPolicy:null!=(e=a.htmlPolicy)?e:"safe",showTooltips:a.showTooltips,renderCodeBlocksAsPre:a.renderCodeBlocksAsPre,codeBlockStream:a.codeBlockStream,codeBlockProps:ae,mermaidProps:ce,d2Props:se,infographicProps:de,codeBlockThemes:{themes:a.themes,darkTheme:a.codeBlockDarkTheme,lightTheme:a.codeBlockLightTheme,langs:a.langs,monacoOptions:a.codeBlockMonacoOptions,minWidth:a.codeBlockMinWidth,maxWidth:a.codeBlockMaxWidth},events:{onCopy:a.onCopy,onHandleArtifactClick:a.onHandleArtifactClick}}},[a.customId,a.isDark,le,a.typewriter,a.fade,a.showTooltips,a.htmlPolicy,a.renderCodeBlocksAsPre,a.codeBlockStream,J,ae,ce,se,de,a.themes,a.codeBlockDarkTheme,a.codeBlockLightTheme,a.langs,a.codeBlockMonacoOptions,a.codeBlockMinWidth,a.codeBlockMaxWidth,a.onCopy,a.onHandleArtifactClick,Z]);ue.streamRenderVersion=p.current,ue.textStreamState=f.current;const me=c(null);return me.current||(me.current={textStreamState:f.current,getStreamRenderVersion:()=>p.current}),/* @__PURE__ */n(ye.Provider,{value:me.current,children:/* @__PURE__ */n(we.Provider,{value:C,children:/* @__PURE__ */n(Me,{getRoot:()=>m.current,enabled:!1!==a.viewportPriority,children:/* @__PURE__ */n(qr,{props:a,parsedNodes:ie,renderCtx:ue,indexPrefix:le,containerRef:m,showTypewriterCursor:R,typewriterCursorRef:P})})})})};function Zr(e){var t,r,o,i,l,a;const{node:c,ctx:s,renderNode:d,indexKey:u,children:m}=e;/* @__PURE__ */
|
|
188
|
-
return n("blockquote",{className:"blockquote-node",dir:"auto",cite:c.cite,children:null!=m?m:s&&d?/* @__PURE__ */n(Yr,{nodes:c.children||[],indexKey:`blockquote-${String(null!=u?u:"blockquote")}`,customId:s.customId,isDark:s.isDark,typewriter:s.typewriter,viewportPriority:!0,codeBlockStream:s.codeBlockStream,renderCodeBlocksAsPre:s.renderCodeBlocksAsPre,codeBlockProps:s.codeBlockProps,themes:null==(t=s.codeBlockThemes)?void 0:t.themes,codeBlockDarkTheme:null==(r=s.codeBlockThemes)?void 0:r.darkTheme,codeBlockLightTheme:null==(o=s.codeBlockThemes)?void 0:o.lightTheme,codeBlockMonacoOptions:null==(i=s.codeBlockThemes)?void 0:i.monacoOptions,codeBlockMinWidth:null==(l=s.codeBlockThemes)?void 0:l.minWidth,codeBlockMaxWidth:null==(a=s.codeBlockThemes)?void 0:a.maxWidth,htmlPolicy:s.htmlPolicy,showTooltips:s.showTooltips,onCopy:s.events.onCopy,onHandleArtifactClick:s.events.onHandleArtifactClick}):null})}function Gr(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Jr(r){const l={loading:!0,stream:!0,darkTheme:"vitesse-dark",lightTheme:"vitesse-light",isDark:!1,isShowPreview:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0,...r},a=o(()=>{var e;return String(null!=(e=l.node.language)?e:"")},[l.node.language]),u=o(()=>D(a),[a]),[m,h]=i(0);s(()=>$(()=>{h(e=>e+1)}),[]);const f=o(()=>{const e=_[u]||u;return e?e.charAt(0).toUpperCase()+e.slice(1):"Text"},[u]),p=o(()=>R(u),[u,m]),{t:g}=Ee(),v=o(()=>!!l.isShowPreview&&("html"===u||"svg"===u),[u,l.isShowPreview]),w=o(()=>{const e={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t=n(l.minWidth),r=n(l.maxWidth);return t&&(e.minWidth=t),r&&(e.maxWidth=r),e},[l.maxWidth,l.minWidth]),[y,x]=i(!1),[k,b]=i(!1),[C,M]=i(!1),[N,B]=i(()=>l.node.code?`<pre class="shiki shiki-fallback"><code>${Gr(l.node.code)}</code></pre>`:""),[S,T]=i(!1),[L,E]=i(14),[P,A]=i(L),H=o(()=>!1!==l.showTooltips,[l.showTooltips]),I=ae(l.themes,l.langs),W=c(null);W.current&&W.current.key===I||(W.current={key:I,themes:l.themes,langs:l.langs});const F=c(null),O=c(null),j=c(null),z=c(null),K=c(null),V=c(""),X=c(""),U=c(0),q=c(null),Y=c(null),Z=c(null),G=c(!1),J=c(!1),Q=c(null),ee=(c(!1),c(/* @__PURE__ */new Set)),ne=c(/* @__PURE__ */new Set),te=c(""),re=c(0),oe=c(I),ie=c(0),de=c(!0),ue=c(null),me=Ne(),[he,fe]=i(()=>"undefined"==typeof window),pe=d(()=>l.isDark?l.darkTheme:l.lightTheme,[l.darkTheme,l.isDark,l.lightTheme]),ge=d(e=>{null==e||e.disconnect(),e&&z.current!==e||(z.current=null)},[]),ve=d(()=>{j.current&&(j.current.innerHTML="")},[]),we=d(e=>{if(q.current=null,ge(),!e)return ve(),X.current="",B(""),void T(!1);B(`<pre class="shiki shiki-fallback"><code>${Gr(e)}</code></pre>`),T(!1)},[ve,ge]),ye=d(()=>{ge(),B(""),T(!0)},[ge]),xe=d(e=>{X.current=e,ye()},[ye]),ke=d(()=>{var e;const n=j.current;return!!n&&(n.childNodes.length>0||Boolean(null==(e=n.textContent)?void 0:e.trim().length))},[]),be=d((e=!0)=>{const n=K.current;ge(),K.current=null,V.current="",X.current="",q.current=null,ee.current.clear();try{null==n||n.dispose()}catch(t){}finally{ve(),e&&T(!1)}},[ve,ge]),Ce=d(()=>(ie.current+=1,ie.current),[]),Me=d(e=>de.current&&ie.current===e,[]),Be=d((e,n)=>{ge();const t=j.current;if(!t||"undefined"==typeof MutationObserver)return;q.current=null;const r=new MutationObserver(()=>{U.current+=1;const t=q.current;if(t)return Me(e)?void(U.current!==n&&ke()&&(q.current=null,ge(r),xe(t))):(q.current=null,void ge(r))});z.current=r,r.observe(t,{childList:!0,subtree:!0,characterData:!0,attributes:!0})},[ge,ke,Me,xe]),Se=d(async(e,n,t,r)=>{var o;if(q.current=t,await Promise.resolve(),!Me(e))return;const i=ke(),l=U.current!==n,a=void 0!==r&&(null==(o=j.current)?void 0:o.innerHTML)!==r;i&&(!X.current||l||a||X.current===t)&&(q.current=null,ge(),xe(t))},[ge,ke,Me,xe]),Te=d(async()=>{if(!Y.current&&!G.current)return Z.current||(Z.current=(async()=>{try{const e=await import("stream-markdown"),n=e.createShikiStreamRenderer;if("function"!=typeof n)throw new TypeError("stream-markdown.createShikiStreamRenderer is not available");Y.current=n;const t=e.registerHighlight;Q.current="function"==typeof t?t:null,G.current=!1,J.current=!1}catch(e){G.current=!0}finally{Z.current=null}})()),Z.current},[]),Le=d(async e=>{const n=e.key;if(oe.current!==n)return"stale";if(!Q.current)return"ready";if(te.current===n)return"ready";const t=++re.current;try{await ce(Q.current,e.registerOptions,n)}catch{return t!==re.current||oe.current!==n?"stale":"failed"}return t!==re.current||oe.current!==n?"stale":(te.current=n,"ready")},[]),De=d(async e=>{const n=await Le(e);return"failed"!==n?n:oe.current!==e.key?"stale":Le(e)},[Le]),$e=d(e=>{var n;const t={hasRegisterHighlight:Boolean(Q.current),hasCreateRenderer:Boolean(Y.current)},r=se(null==e?void 0:e.themes,null==e?void 0:e.langs,t),o=(null==(n=r.rendererOptions.langs)?void 0:n.length)&&ne.current.has(r.key)?se(null==e?void 0:e.themes,void 0,t):r;return r.ignoredLangs,{key:o.key,registerOptions:o.registerOptions,rendererOptions:o.rendererOptions}},[]),Pe=d(async(e,n,t)=>{const r=K.current;if(!r||!Me(t))return;const o=function(e){return le(e)||"plaintext"}(n),i=async n=>{const r=K.current;if(r&&Me(t)){n&&"plaintext"!==o&&ee.current.add(o);try{return await r.updateCode(e,"plaintext"),Me(t)?"plaintext":void 0}catch{return}}};if("plaintext"!==o&&ee.current.has(o))return i();try{return await r.updateCode(e,o),Me(t)?o:void 0}catch(l){if(!Me(t)||"plaintext"===o)return;return i(l)}},[Me]),Re=d(async()=>{var e,n;const t=Ce(),r=l.node.code,o=l.node.language,i=W.current;if(!he)return void we(r);if(await Te(),!Me(t))return;let a=$e(i),c=a.key;oe.current=c;let s=Boolean(K.current&&V.current!==c);s&&we(r);let d=await De(a);if("failed"===d&&(null==(e=a.rendererOptions.langs)?void 0:e.length)&&(ne.current.add(a.key),a=$e({themes:null==i?void 0:i.themes,langs:void 0}),c=a.key,oe.current=c,d=await De(a)),!Me(t)||"stale"===d)return;if(s=Boolean(K.current&&V.current!==c),"failed"===d)return void(s&&K.current&&ke()?ye():we(r));if(s&&be(),!O.current||!j.current)return void we(r);if(!K.current&&Y.current&&(K.current=Y.current(j.current,{theme:pe(),themes:a.rendererOptions.themes,langs:a.rendererOptions.langs}),V.current=c,T(!0)),!K.current)return void we(r);if(!1===l.stream&&l.loading)return void we(r);we(r);const u=U.current,m=null==(n=j.current)?void 0:n.innerHTML;Be(t,u);const h=await Pe(r,o,t);Me(t)&&(h?await Se(t,u,function(e,n,t){return`${null!=e?e:""}\0${n}\0${t}`}(c,h,r),m):(q.current=null,ge()))},[Ce,l.node.code,l.node.language,l.stream,l.loading,I,he,Te,$e,De,be,ye,pe,ke,we,Be,Pe,Se,ge,Me]);s(()=>{const e=F.current;if(!e)return;let n=!0;const t=me(e,{rootMargin:"400px"});return ue.current=t,t.isVisible()&&fe(!0),t.whenVisible.then(()=>{n&&fe(!0)}),()=>{n=!1,t.destroy(),ue.current=null}},[me]),s(()=>{Re().catch(()=>{de.current&&j.current&&we(l.node.code)})},[Re,l.node.code,we]),s(()=>(de.current=!0,()=>{de.current=!1,ie.current+=1,be(!1)}),[be]),s(()=>{K.current&&he&&K.current.setTheme(pe())},[pe,he]),s(()=>{H||Fe(!0)},[H]);const _e=d((e,n)=>{if(!H)return;const t=e.currentTarget;t&&!t.disabled&&("clientX"in e&&(e.clientX,e.clientY),We(t,n,"top",!1,0,l.isDark))},[l.isDark,H]),Ae=d(()=>{H&&Fe()},[H]),He=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(l.node.code),x(!0),null==(e=l.onCopy)||e.call(l,l.node.code),setTimeout(()=>x(!1),1e3)}catch{}},[l]),Ie=d(()=>{var e;if(!v)return;const n="html"===u?"text/html":"image/svg+xml",t="html"===u?"HTML Preview":"SVG Preview";null==(e=l.onPreviewCode)||e.call(l,{type:n,content:l.node.code,title:t})},[u,v,l]),Oe=o(()=>({fontSize:`${P}px`}),[P]);return s(()=>{E(14),A(14)},[]),/* @__PURE__ */e("div",{ref:F,className:["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",l.isDark?"border-gray-700/30 bg-gray-900 is-dark":"border-gray-200 bg-white"].join(" "),style:w,children:[l.showHeader&&/* @__PURE__ */e("div",{className:"code-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5",style:{color:"var(--vscode-editor-foreground)",backgroundColor:"var(--vscode-editor-background)"},children:[
|
|
189
|
-
/* @__PURE__ */e("div",{className:"flex items-center space-x-2",children:[
|
|
190
|
-
/* @__PURE__ */n("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:p}}),
|
|
191
|
-
/* @__PURE__ */n("span",{className:"text-sm font-medium font-mono",children:f})]}),
|
|
192
|
-
/* @__PURE__ */e("div",{className:"flex items-center space-x-2",children:[l.showCollapseButton&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":C,onClick:()=>M(e=>!e),onMouseEnter:e=>_e(e,C?g("common.expand")||"Expand":g("common.collapse")||"Collapse"),onFocus:e=>_e(e,C?g("common.expand")||"Expand":g("common.collapse")||"Collapse"),onMouseLeave:Ae,onBlur:Ae,children:/* @__PURE__ */n("svg",{style:{rotate:C?"0deg":"90deg"},xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),l.showFontSizeButtons&&l.enableFontSizeControl&&/* @__PURE__ */e(t,{children:[
|
|
193
|
-
/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:P<=10,onClick:()=>A(e=>Math.max(10,e-1)),onMouseEnter:e=>_e(e,g("common.decrease")||"Decrease"),onFocus:e=>_e(e,g("common.decrease")||"Decrease"),onMouseLeave:Ae,onBlur:Ae,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14"})})}),
|
|
194
|
-
/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:P===L,onClick:()=>A(L),onMouseEnter:e=>_e(e,g("common.reset")||"Reset"),onFocus:e=>_e(e,g("common.reset")||"Reset"),onMouseLeave:Ae,onBlur:Ae,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
195
|
-
/* @__PURE__ */n("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),
|
|
196
|
-
/* @__PURE__ */n("path",{d:"M3 3v5h5"})]})})}),
|
|
197
|
-
/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:P>=36,onClick:()=>A(e=>Math.min(36,e+1)),onMouseEnter:e=>_e(e,g("common.increase")||"Increase"),onFocus:e=>_e(e,g("common.increase")||"Increase"),onMouseLeave:Ae,onBlur:Ae,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14m-7-7v14"})})})]}),l.showCopyButton&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":y?g("common.copied")||"Copied":g("common.copy")||"Copy",onClick:He,onMouseEnter:e=>_e(e,y?g("common.copied")||"Copied":g("common.copy")||"Copy"),onFocus:e=>_e(e,y?g("common.copied")||"Copied":g("common.copy")||"Copy"),onMouseLeave:Ae,onBlur:Ae,children:/* @__PURE__ */n("svg",y?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
198
|
-
/* @__PURE__ */n("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
|
|
199
|
-
/* @__PURE__ */n("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),l.showExpandButton&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":k,onClick:e=>{b(e=>!e),_e(e,k?g("common.expand")||"Expand":g("common.collapse")||"Collapse")},onMouseEnter:e=>_e(e,k?g("common.collapse")||"Collapse":g("common.expand")||"Expand"),onFocus:e=>_e(e,k?g("common.collapse")||"Collapse":g("common.expand")||"Expand"),onMouseLeave:Ae,onBlur:Ae,children:/* @__PURE__ */n("svg",k?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})}),v&&l.showPreviewButton&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":g("common.preview")||"Preview",onClick:Ie,onMouseEnter:e=>_e(e,g("common.preview")||"Preview"),onFocus:e=>_e(e,g("common.preview")||"Preview"),onMouseLeave:Ae,onBlur:Ae,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
|
|
200
|
-
/* @__PURE__ */n("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"}),
|
|
201
|
-
/* @__PURE__ */n("circle",{cx:"12",cy:"12",r:"3"})]})})})]})]}),!C&&(!!l.stream||!l.loading)&&/* @__PURE__ */e("div",{ref:O,className:"code-block-content",style:{...Oe,maxHeight:k?"none":"500px",overflowY:k?"visible":"auto",overflowX:"auto"},children:[
|
|
202
|
-
/* @__PURE__ */n("div",{ref:j,className:"code-block-render"}),!S&&N&&/* @__PURE__ */n("div",{className:"code-fallback-plain",dangerouslySetInnerHTML:{__html:N}})]}),!l.stream&&l.loading&&/* @__PURE__ */n("div",{className:"code-loading-placeholder",children:/* @__PURE__ */e("div",{className:"loading-skeleton",children:[
|
|
203
|
-
/* @__PURE__ */n("div",{className:"skeleton-line"}),
|
|
204
|
-
/* @__PURE__ */n("div",{className:"skeleton-line"}),
|
|
205
|
-
/* @__PURE__ */n("div",{className:"skeleton-line short"})]})}),
|
|
206
|
-
/* @__PURE__ */n("span",{className:"sr-only","aria-live":"polite",role:"status",children:y?g("common.copied")||"Copied":""})]})}function Qr(e){var t;const r=c(null),[l,a]=i(!1),[d,u]=i({transform:"translate3d(0px, 0px, 0px)",left:"0px",top:"0px"}),m=o(()=>function(e){if("boolean"==typeof e)return e;if("undefined"!=typeof document)try{if(document.documentElement.classList.contains("dark"))return!0}catch{}if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{return window.matchMedia("(prefers-color-scheme: dark)").matches}catch{}return!1}(e.isDark),[e.isDark]);return s(()=>{if(!e.visible)return void a(!1);if(!e.anchorEl||!r.current)return void a(!0);let n=null,t=!1;const o=async()=>{var n,o;if(!e.anchorEl||!r.current)return;const{x:i,y:l}=await me(e.anchorEl,r.current,{placement:null!=(n=e.placement)?n:"top",middleware:[he(null!=(o=e.offset)?o:8),fe(),pe({padding:8})],strategy:"fixed"});t||u({position:"fixed",left:"0px",top:"0px",transform:`translate3d(${Math.round(i)}px, ${Math.round(l)}px, 0)`})};return o().then(()=>{t||a(!0)}),n=ue(e.anchorEl,r.current,o),()=>{t=!0,null==n||n()}},[e.anchorEl,e.offset,e.placement,e.visible,l]),"undefined"==typeof document?null:e.visible&&l?de(
|
|
207
|
-
/* @__PURE__ */n("div",{id:null!=(t=e.id)?t:void 0,ref:r,style:d,className:["ms-tooltip z-[9999] inline-block text-base py-2 px-3 rounded-md shadow-md whitespace-nowrap pointer-events-none border tooltip-element",m?"bg-gray-900 text-white border-gray-700 is-dark":"bg-white text-gray-900 border-gray-200"].join(" "),role:"tooltip",children:e.content}),document.body):null}export{nr as $,ve as A,Zr as B,Se as C,Kn as D,Xn as E,Lr as F,Qr as G,Gn as H,st as I,lr as J,_t as K,wt as L,tr as M,Yr as N,Et as O,$r as P,or as Q,Pr as R,Rr as S,Ir as T,An as U,Fr as V,$t as W,_n as X,ar as Y,In as Z,Ft as _,Tn as a,Hn as a0,Pt as a1,Ot as a2,zr as a3,Rn as a4,Le as a5,Wt as a6,Rt as a7,At as a8,Lt as a9,Dt as aa,rr as ab,Qt as ac,er as ad,cr as ae,Ee as af,Be as ag,Ht as ah,Vn as b,Un as c,qn as d,Yn as e,Zn as f,Jn as g,Qn as h,et as i,lt as j,ze as k,ft as l,pt as m,gt as n,yt as o,xt as p,Jr as q,Vt as r,Xt as s,xr as t,xn as u,_r as v,Ar as w,Hr as x,vt as y,Wr as z};
|