markstream-react 0.0.46 → 0.0.48

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.
@@ -1,189 +1,189 @@
1
- import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import r,{useMemo as o,useState as i,useContext as l,useRef as a,createContext 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 p,isHtmlTagBlocked as f,sanitizeHtmlContent as g,BLOCKED_HTML_TAGS as w,isHtmlTagHardBlocked as v,convertHtmlAttrsToProps as y,sanitizeHtmlAttrs as x,getHtmlTagFromContent as k,stripCustomHtmlWrapper as b,shouldRenderUnknownHtmlTagAsText as C,mergeCustomHtmlTags as M,getMarkdown as N,parseMarkdownToStructure as B}from"stream-markdown-parser";import{i as L,n as T,f as E,d as S,b as D,l as $,j as P,C as A,D as R,a as H,t as W,q as I,E as _,k as F,F as j,G as O,H as z,y as V,z as K,A as X,h as U,u as q,v as Y,x as Z,B as G,m as J,o as Q}from"./customHtmlTag-BRT4eqd8.js";import{createPortal as ee}from"react-dom";import{autoUpdate as te,computePosition as ne,offset as re,flip as oe,shift as ie}from"@floating-ui/dom";const le={note:"ℹ️",info:"ℹ️",tip:"💡",warning:"⚠️",danger:"❗",error:"⛔",caution:"⚠️"};function ae(n){const{node:r,ctx:l,renderNode:a,indexKey:c,isDark:s}=n,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)}),p=o(()=>`admonition-${Math.random().toString(36).slice(2,9)}`,[]);/* @__PURE__ */
1
+ import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import r,{useMemo as o,useState as i,useContext as l,useRef as a,createContext 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 p,isHtmlTagBlocked as f,sanitizeHtmlContent as g,BLOCKED_HTML_TAGS as w,isHtmlTagHardBlocked as v,convertHtmlAttrsToProps as y,sanitizeHtmlAttrs as x,getHtmlTagFromContent as k,stripCustomHtmlWrapper as b,shouldRenderUnknownHtmlTagAsText as C,mergeCustomHtmlTags as M,getMarkdown as N,parseMarkdownToStructure as B}from"stream-markdown-parser";import{i as L,n as S,f as T,d as E,b as D,l as $,j as P,C as A,D as R,a as H,t as W,q as I,E as _,k as F,F as j,G as O,H as z,y as V,z as K,A as X,h as U,u as q,v as Y,x as Z,B as G,m as J,o as Q}from"./customHtmlTag-BRT4eqd8.js";import{createPortal as ee}from"react-dom";import{autoUpdate as te,computePosition as ne,offset as re,flip as oe,shift as ie}from"@floating-ui/dom";const le={note:"ℹ️",info:"ℹ️",tip:"💡",warning:"⚠️",danger:"❗",error:"⛔",caution:"⚠️"};function ae(n){const{node:r,ctx:l,renderNode:a,indexKey:c,isDark:s}=n,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)}),p=o(()=>`admonition-${Math.random().toString(36).slice(2,9)}`,[]);/* @__PURE__ */
2
2
  return e("div",{className:`admonition admonition-${d}${s?" is-dark":""}`,"data-index-key":c,children:[
3
3
  /* @__PURE__ */e("div",{id:p,className:"admonition-header",children:[le[d]&&/* @__PURE__ */t("span",{className:"admonition-icon",children:le[d]}),
4
4
  /* @__PURE__ */t("span",{className:"admonition-title",children:u}),r.collapsible&&/* @__PURE__ */t("button",{type:"button",className:"admonition-toggle","aria-expanded":!m,"aria-controls":`${p}-content`,title:m?"Expand":"Collapse",onClick:()=>h(e=>!e),children:/* @__PURE__ */t("span",{children:m?"▶":"▼"})})]}),!m&&/* @__PURE__ */t("div",{id:`${p}-content`,className:"admonition-content","aria-labelledby":p,children:l&&a?L(r.children,l,String(null!=c?c:p),a):null})]})}const ce=c(null);function se(e,t){var n,r;const o="undefined"!=typeof window&&"undefined"!=typeof document,i=o?null!=(n=window.requestIdleCallback)?n: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 t=s.get(e);if(t){t.state.current=!0;try{t.resolve()}catch{}try{null==a||a.unobserve(e)}catch{}s.delete(e),d.delete(e),m()}},p=()=>{i&&null==u&&d.size&&(u=i(()=>{u=null;const e=d.values().next().value;e&&(d.delete(e),h(e),d.size&&p())},{timeout:1200}))};return(n,r)=>{var i,l;const u={current:!1};let f,g=!1;const w=new Promise(e=>{f=()=>{g||(g=!0,e())}}),v=()=>{if(s.has(n)){s.delete(n);try{null==a||a.unobserve(n)}catch{}}d.delete(n),m()};if(!o||!t())return u.current=!0,f(),{isVisible:()=>!0,whenVisible:w,destroy:v};const y=((t,n)=>{if(!o)return null;if("undefined"==typeof IntersectionObserver)return null;const r=((t,n)=>{var r;return{root:null!=(r=e())?r:null,rootMargin:t,threshold:n}})(t,n);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 t of e)(t.isIntersecting||t.intersectionRatio>0)&&h(t.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(n,{resolve:f,state:u}),y.observe(n),d.add(n),p(),{isVisible:()=>u.current,whenVisible:w,destroy:v}):(u.current=!0,f(),{isVisible:()=>!0,whenVisible:w,destroy:v})}}const de=se(()=>null,()=>!0);function ue({getRoot:e,enabled:n=!0,children:r}){const i=a(n);i.current=n;const l=a(e);l.current=e;const c=o(()=>se(()=>{var e,t;return null!=(t=null==(e=l.current)?void 0:e.call(l))?t:null},()=>i.current),[]);/* @__PURE__ */
5
5
  return t(ce.Provider,{value:c,children:r})}function me(){var e;return null!=(e=l(ce))?e:de}function he(e){const{node:n}=e;/* @__PURE__ */
6
- return t("span",{className:"checkbox-node",children:/* @__PURE__ */t("input",{type:"checkbox",checked:Boolean(n.checked),disabled:!0,className:"checkbox-input",readOnly:!0})})}const pe={"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 fe(e){Object.assign(pe,e)}function ge(){return{t:e=>{var t;return null!=(t=pe[e])?t: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 we=null,ve=null,ye=null,xe=null,ke=null,be=null;function Ce(){xe&&(clearTimeout(xe),xe=null),ke&&(clearTimeout(ke),ke=null)}async function Me(e){if(!we||!ve)return;const{x:t,y:n}=await ne(ve,we,{placement:e,middleware:[re(8),oe(),ie({padding:8})],strategy:"fixed"});we.style.transform=`translate3d(${Math.round(t)}px, ${Math.round(n)}px, 0)`}function Ne(e,t,n="top",r=!1,o,i){if(!e||"undefined"==typeof document)return;if(we||"undefined"==typeof document||(we=document.createElement("div"),we.className="ms-tooltip",we.setAttribute("role","tooltip"),we.dataset.visible="false",we.style.position="fixed",we.style.left="0px",we.style.top="0px",we.style.transform="translate3d(0,0,0)",document.body.appendChild(we)),!we)return;Ce();const l=async()=>{if(we){ve=e,we.textContent=t,we.dataset.placement=n,we.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",we.dataset.visible="false",be=`tooltip-${Date.now()}-${Math.random().toString(36).slice(2)}`,we.id=be;try{e.setAttribute("aria-describedby",be)}catch{}await Me(n),we.dataset.visible="true",null==ye||ye(),ye=te(e,we,()=>{Me(n)})}};r?l():xe=setTimeout(l,80)}function Be(e=!1){if(!we)return;Ce();const t=()=>{if(we){if(we.dataset.visible="false",ve&&be)try{ve.removeAttribute("aria-describedby")}catch{}ve=null,be=null,ye&&(ye(),ye=null)}};e?t():ke=setTimeout(t,120)}function Le(n){const{t:r}=ge(),i=o(()=>{const e=n.code||"",t=e.trim().toLowerCase();return t.startsWith("<!doctype")||t.startsWith("<html")||t.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: ${n.isDark?"#020617":"#ffffff"};\n color: ${n.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>`},[n.code,n.isDark]);return s(()=>{const e=e=>{var t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=n.onClose)||t.call(n)};return"undefined"!=typeof window&&window.addEventListener("keydown",e),()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",e)}},[n]),"undefined"==typeof document?null:ee(
6
+ return t("span",{className:"checkbox-node",children:/* @__PURE__ */t("input",{type:"checkbox",checked:Boolean(n.checked),disabled:!0,className:"checkbox-input",readOnly:!0})})}const pe={"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 fe(e){Object.assign(pe,e)}function ge(){return{t:e=>{var t;return null!=(t=pe[e])?t: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 we=null,ve=null,ye=null,xe=null,ke=null,be=null;function Ce(){xe&&(clearTimeout(xe),xe=null),ke&&(clearTimeout(ke),ke=null)}async function Me(e){if(!we||!ve)return;const{x:t,y:n}=await ne(ve,we,{placement:e,middleware:[re(8),oe(),ie({padding:8})],strategy:"fixed"});we.style.transform=`translate3d(${Math.round(t)}px, ${Math.round(n)}px, 0)`}function Ne(e,t,n="top",r=!1,o,i){if(!e||"undefined"==typeof document)return;if(we||"undefined"==typeof document||(we=document.createElement("div"),we.className="ms-tooltip",we.setAttribute("role","tooltip"),we.dataset.visible="false",we.style.position="fixed",we.style.left="0px",we.style.top="0px",we.style.transform="translate3d(0,0,0)",document.body.appendChild(we)),!we)return;Ce();const l=async()=>{if(we){ve=e,we.textContent=t,we.dataset.placement=n,we.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",we.dataset.visible="false",be=`tooltip-${Date.now()}-${Math.random().toString(36).slice(2)}`,we.id=be;try{e.setAttribute("aria-describedby",be)}catch{}await Me(n),we.dataset.visible="true",null==ye||ye(),ye=te(e,we,()=>{Me(n)})}};r?l():xe=setTimeout(l,80)}function Be(e=!1){if(!we)return;Ce();const t=()=>{if(we){if(we.dataset.visible="false",ve&&be)try{ve.removeAttribute("aria-describedby")}catch{}ve=null,be=null,ye&&(ye(),ye=null)}};e?t():ke=setTimeout(t,120)}const Le=void 0!==import.meta&&Boolean(!1);let Se=null;function Te(n){const{t:r}=ge(),i=o(()=>{const e=n.code||"",t=e.trim().toLowerCase();return t.startsWith("<!doctype")||t.startsWith("<html")||t.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: ${n.isDark?"#020617":"#ffffff"};\n color: ${n.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>`},[n.code,n.isDark]),l=o(()=>{return e=n.htmlPreviewSandbox,t=n.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!Le||"undefined"==typeof console||Se===e)return;const t=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);t.has("allow-scripts")&&t.has("allow-same-origin")&&(Se=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===t?"allow-scripts":"";var e,t},[n.htmlPreviewAllowScripts,n.htmlPreviewSandbox]);return s(()=>{const e=e=>{var t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=n.onClose)||t.call(n)};return"undefined"!=typeof window&&window.addEventListener("keydown",e),()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",e)}},[n]),"undefined"==typeof document?null:ee(
7
7
  /* @__PURE__ */t("div",{className:"html-preview-frame__backdrop"+(n.isDark?" html-preview-frame__backdrop--dark":""),onClick:()=>{var e;return null==(e=n.onClose)?void 0:e.call(n)},children:/* @__PURE__ */e("div",{className:"html-preview-frame"+(n.isDark?" html-preview-frame--dark":""),onClick:e=>e.stopPropagation(),children:[
8
8
  /* @__PURE__ */e("div",{className:"html-preview-frame__header",children:[
9
9
  /* @__PURE__ */e("div",{className:"html-preview-frame__title",children:[
10
10
  /* @__PURE__ */t("span",{className:"html-preview-frame__dot"}),
11
11
  /* @__PURE__ */t("span",{className:"html-preview-frame__label",children:n.title||`HTML ${r("common.preview")}`})]}),
12
12
  /* @__PURE__ */t("button",{type:"button",className:"html-preview-frame__close"+(n.isDark?" html-preview-frame__close--dark":""),onClick:()=>{var e;return null==(e=n.onClose)?void 0:e.call(n)},children:"×"})]}),
13
- /* @__PURE__ */t("iframe",{className:"html-preview-frame__iframe",sandbox:"allow-scripts allow-same-origin",src:"about:blank",srcDoc:i,title:n.title||"Preview"})]})}),document.body)}let Te=!1,Ee=null,Se=!1;async function De(){if(Ee)return Ee;if(Se)return null;try{return Ee=await import("stream-monaco"),await async function(e){if(Te)return;Te=!0;const t=null==globalThis?void 0:globalThis.MonacoEnvironment;(!t||"function"!=typeof t.getWorker&&"function"!=typeof t.getWorkerUrl)&&(null==e?void 0:e.preloadMonacoWorkers)&&await e.preloadMonacoWorkers()}(Ee),Ee}catch{return Se=!0,null}}let $e=null,Pe=!1,Ae=null,Re=null,He=null,We=null,Ie=null;const _e=/* @__PURE__ */new WeakMap;let Fe=0;function je(e,t){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 t=_e.get(e);if(t)return t;try{const t=JSON.stringify(e);if(t)return _e.set(e,t),t}catch{}const n="__theme_"+ ++Fe;return _e.set(e,n),n}return String(e)}(e);return n?($e!==t&&($e=t),Pe||Ie!==n?!Ae||We!==n&&Re!==n?(He=e,We=n,Ae||(Pe=!0,Ae=(async()=>{for(;null!=He&&null!=We;){const e=He,t=We;if(He=null,We=null,Ie===t)continue;const n=$e;if(!n)break;try{Re=t,await Promise.resolve(n(e)),Ie=t}catch{}}})().finally(()=>{Pe=!1,Ae=null,Re=null}),Ae)):Ae:Promise.resolve()):Promise.resolve()}let Oe=null,ze=null,Ve=null;const Ke=/* @__PURE__ */new Set,Xe=/* @__PURE__ */new WeakMap;let Ue=0;function qe(){for(const e of Array.from(Ke))try{e()}catch{}}function Ye({node:e}){var n;const r=o(()=>function(e){var t;return String(null!=(t=String(null!=e?e:"").split(/\s+/g)[0])?t:"").toLowerCase().replace(/[^\w-]/g,"")||"plaintext"}(null==e?void 0:e.language),[e]),i=r?`Code block: ${r}`:"Code block";/* @__PURE__ */
14
- return t("pre",{className:`language-${r}`,"aria-busy":!0===(null==e?void 0:e.loading),"aria-label":i,"data-language":r,tabIndex:0,children:/* @__PURE__ */t("code",{translate:"no",children:String(null!=(n=null==e?void 0:e.code)?n:"")})})}const Ze={isShowPreview:!0,loading:!0,stream:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0},Ge=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});function Je(e){var t;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const n=e;return{...Ge,...n,enabled:null==(t=n.enabled)||t}}return{...Ge}}function Qe(e,t){var n;const r=t?{...t}:{};if(!e)return r;const o=void 0===r.diffHideUnchangedRegions?{...Ge}:Je(r.diffHideUnchangedRegions),i=void 0===r.hideUnchangedRegions?void 0:Je(r.hideUnchangedRegions),l=null!=(n=r.diffUnchangedRegionStyle)?n:"line-info";return{maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:12,lineNumbersMinChars:2,glyphMargin:!1,fontSize:13,lineHeight:30,renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,padding:{top:10,bottom:"line-info"===l||"line-info-basic"===l||"metadata"===l?22:14},diffHideUnchangedRegions:o,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:l,diffHunkActionsOnHover:!0,diffHunkHoverHideDelayMs:160,...r,...void 0===i?{}:{hideUnchangedRegions:i},diffHideUnchangedRegions:o}}function et(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function tt(e){const t=String(null!=e?e:"").match(/\d+(?:\.\d+)?/g);if(!t||t.length<3)return null;const[n,r,o]=t.slice(0,3).map(Number);return.2126*n+.7152*r+.0722*o}function nt(r){var l;const c={...Ze,...r},{node:u,isDark:m,loading:h,stream:p,isShowPreview:f,enableFontSizeControl:g,darkTheme:w,lightTheme:v,monacoOptions:y,themes:x,minWidth:k,maxWidth:b,showHeader:C,showCopyButton:M,showExpandButton:N,showPreviewButton:B,showCollapseButton:L,showFontSizeButtons:P,showTooltips:A}=c,R=a(null),H=a(null),W=a(null),I=a(null),_=a(null),F=a(null),j=a(null),O=a(0),z=a(null),V=a(null),K=me(),X=a(y),U=a(null),q=a(null),[Y,Z]=i(!1),[G,J]=i(()=>"undefined"==typeof window),[Q,ee]=i(!1),[te,ne]=i(!1),[re,oe]=i(!1),[ie,le]=i(()=>u.language||"plaintext"),[ae,ce]=i(()=>T(u.language)),[se,de]=i(!1),[ue,he]=i(!1),[pe,fe]=i(!1),[we,ve]=i(!1),[ye,xe]=i(0),{t:ke}=ge(),be=o(()=>Qe(Boolean(u.diff),y),[y,u.diff]),[Ce,Me]=i(()=>{var e;const t=Number(null==(e=Qe(Boolean(u.diff),y))?void 0:e.fontSize);return Number.isFinite(t)&&t>0?t:14}),[Te,Ee]=i(Ce),Se=o(()=>!1!==A,[A]),$e=d(()=>{var e,t;const n=null!=(t=null==(e=X.current)?void 0:e.MAX_HEIGHT)?t:500;if("number"==typeof n&&Number.isFinite(n))return Math.max(80,n);const r=String(n).match(/^(\d+(?:\.\d+)?)/),o=r?Number.parseFloat(r[1]):500;return Number.isFinite(o)?Math.max(80,o):500},[]),Pe=d(e=>{var t,n,r,o;if(Y)return;const i=R.current,l=W.current;if(!i||!l)return;const a="diff"===F.current?null==(t=l.getDiffEditorView)?void 0:t.call(l):null==(n=l.getEditorView)?void 0:n.call(l);if(!a)return;const c=$e();try{null==(r=a.updateOptions)||r.call(a,{automaticLayout:e})}catch{}e?(i.style.minHeight="0px",i.style.maxHeight="none",i.style.overflow="visible"):(i.style.minHeight="0px",i.style.maxHeight=`${Math.ceil(c)}px`,i.style.overflow="auto");try{const t=Number((()=>{if("function"==typeof a.getContentHeight)return a.getContentHeight();if("diff"===F.current&&"function"==typeof a.getModifiedEditor){const e=a.getModifiedEditor();if(e&&"function"==typeof e.getContentHeight)return e.getContentHeight()}})());if(Number.isFinite(t)&&t>0){const n=e?t:Math.min(t,c);i.style.height=`${Math.ceil(Math.max(1,n))}px`}null==(o=a.layout)||o.call(a)}catch{}},[$e,Y]);s(()=>E(()=>{xe(e=>e+1)}),[]),s(()=>{ce(T(u.language))},[u.language]);const Ae=a(u);Ae.current=u;const Re=d(()=>{var e;O.current+=1;try{null==(e=I.current)||e.call(I)}catch{}_.current=null,F.current=null,j.current=null,oe(!1),ne(!1)},[]),He=d(()=>{var e,t,n,r,o,i;const l=R.current,a=H.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!=(t=null==e?void 0:e.getPropertyValue("--vscode-editor-foreground"))?t:"").trim()||String(null!=(n=null==e?void 0:e.color)?n:"").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,t,n,r){if(!n)return!1;const o=tt(e),i=tt(t);return r?null!=o&&o>170||null!=i&&i<110:null!=o&&o<85||null!=i&&i>190}(s,l,"plaintext"===S(String(u.language||ae||ie||"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{}},[ae,ie,u.diff,u.language]),We=o(()=>m?w:v,[w,m,v]),Ie=d(()=>{var e;const t=null==be?void 0:be.theme,n=null!=(e=null!=We?We:t)?e:Oe,r=Array.isArray(x)?x:[];if(!r.length||null==n)return n;const o=et(n),i=r.map(e=>et(e)).filter(e=>!!e);if(!o||i.includes(o))return n;const l=et(t);return null!=t&&l&&i.includes(l)?t:r[0]},[We,be,x]),_e=o(()=>Ie(),[Ie]),Fe=o(()=>function(e,t){var n;const r=(null!=(n=et(e))?n:"").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)):t}(_e,Boolean(m)),[m,_e]),Xe=o(()=>{if(!u.diff)return Fe?"dark":"light";const e=null==be?void 0:be.diffAppearance;return"light"===e||"dark"===e?e:m?"dark":"light"},[m,u.diff,Fe,be]),Ue=o(()=>u.diff?"dark"===Xe:Fe,[Xe,u.diff,Fe]),Ge=d(()=>({wordWrap:"on",wrappingIndent:"same",themes:x,...be||{},theme:_e,...u.diff?{diffAppearance:Xe}:{},onThemeChange(){He()}}),[Xe,u.diff,_e,be,He,x]),Je=d(()=>{const e=Ge(),t=U.current;if(!t)return U.current=e,e;for(const n of Object.keys(t))n in e||delete t[n];return Object.assign(t,e),t},[Ge]),nt=o(()=>{var e,t,n,r,o,i,l;return JSON.stringify({diffLineStyle:null!=(e=null==be?void 0:be.diffLineStyle)?e:"background",diffUnchangedRegionStyle:null!=(t=null==be?void 0:be.diffUnchangedRegionStyle)?t:"line-info",diffHideUnchangedRegions:null==(n=null==be?void 0:be.diffHideUnchangedRegions)||n,renderSideBySide:null==(r=null==be?void 0:be.renderSideBySide)||r,enableSplitViewResizing:null==(o=null==be?void 0:be.enableSplitViewResizing)||o,ignoreTrimWhitespace:null==(i=null==be?void 0:be.ignoreTrimWhitespace)||i,originalEditable:null!=(l=null==be?void 0:be.originalEditable)&&l})},[be]);s(()=>{X.current=be,Je()},[be,Je]),s(()=>()=>{var e,t,n;O.current+=1,null==(e=I.current)||e.call(I),I.current=null,_.current=null,F.current=null,j.current=null,z.current=null,null==(n=null==(t=V.current)?void 0:t.destroy)||n.call(t),V.current=null},[]),s(()=>{var e,t;if("undefined"==typeof window)return;if(G)return;const n=H.current;if(!n)return;null==(t=null==(e=V.current)?void 0:e.destroy)||t.call(e);const r=K(n,{rootMargin:"400px"});return V.current=r,r.isVisible()&&J(!0),r.whenVisible.then(()=>J(!0)),()=>{r.destroy(),V.current===r&&(V.current=null)}},[K,G]),s(()=>{let e=!0;return"undefined"==typeof window?()=>{e=!1}:W.current?(Je(),()=>{e=!1}):((async()=>{try{const n=await De();if(!e)return;if(!n)return void Z(!0);const r=n.useMonaco,o=n.detectLanguage;if("function"==typeof o&&(z.current=o),"function"!=typeof r)return void Z(!0);const i=r(Je());W.current=i,"function"==typeof(t=i.setTheme)&&(Ve=t,null!=Oe&&null!=ze&&je(Oe,Ve).then(()=>qe()).catch(()=>{})),I.current="function"==typeof i.safeClean?()=>i.safeClean():"function"==typeof i.cleanupEditor?()=>i.cleanupEditor():null,ee(!0)}catch{e&&Z(!0)}var t})(),()=>{e=!1})},[Je]),s(()=>{var e;if(!u.language&&!ae&&z.current)try{const t=z.current(String(null!=(e=u.code)?e:""));t&&le(t)}catch{}},[ae,u.code,u.language]);const rt=o(()=>String(u.language||ae||ie||"plaintext"),[ae,ie,u.language]),ot=o(()=>T(rt),[rt]),it=o(()=>S(ot),[ot]),lt=o(()=>"plaintext"===it,[it]),at=o(()=>D(ot),[ot,ye]),ct=o(()=>!!f&&("html"===ot||"svg"===ot),[ot,f]),st=o(()=>{const e=ot;return e?$[e]||e.charAt(0).toUpperCase()+e.slice(1):$[""]||"Plain Text"},[ot]),dt=o(()=>{var e,t,n;return u.diff?null!=(t=null!=(e=u.updatedCode)?e:u.code)?t:"":null!=(n=u.code)?n:""},[u.code,u.diff,u.updatedCode]),ut=o(()=>{const e=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t={},n=e(k),r=e(b);return n&&(t.minWidth=n),r&&(t.maxWidth=r),u.diff?(t.color="var(--markstream-diff-shell-fg)",t.borderColor="var(--markstream-diff-shell-border)"):(t.color=`var(--vscode-editor-foreground, ${Ue?"#e5e7eb":"#111827"})`,t.backgroundColor=`var(--vscode-editor-background, ${Ue?"#111827":"#ffffff"})`,t.borderColor=Ue?"rgb(55 65 81 / 0.3)":"rgb(229 231 235)"),t},[b,k,u.diff,Ue]),mt=o(()=>{if(!u.diff)return{color:`var(--vscode-editor-foreground, ${Ue?"#e5e7eb":"#111827"})`,backgroundColor:`var(--vscode-editor-background, ${Ue?"#111827":"#ffffff"})`}},[u.diff,Ue]),ht=!1===p&&h;s(()=>{if(Y)return;if(!Q)return;if(!te||!G)return;const e=W.current;Je();const t=()=>{var t;u.diff&&(null==(t=null==e?void 0:e.refreshDiffPresentation)||t.call(e)),He(),pe||null==("undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>Pe(ue)):null)&&Pe(ue)};(null==e?void 0:e.setTheme)&&_e?je(_e,e.setTheme).then(t).catch(()=>{}):t()},[Pe,pe,te,Xe,ue,Q,u.diff,_e,He,Je,Y,G]),s(()=>{var e;if("undefined"!=typeof window)return e=()=>{He()},Ke.add(e),()=>{Ke.delete(e)}},[He]);const pt=d(async()=>{var e,t;if(Y)return null;if(!G)return null;if(pe)return null;if(ht)return null;const n=W.current,r=R.current;if(!n||!r||!n.createEditor)return null;Je();const o=Ae.current,i=o.diff?"diff":"single",l=j.current,a="diff"===i?Boolean(null==(e=n.getDiffEditorView)?void 0:e.call(n)):Boolean(null==(t=n.getEditorView)?void 0:t.call(n));if(F.current===i&&l===r&&a)return null;if(_.current)return _.current;O.current+=1;const c=O.current;ne(!0);const s=(async()=>{var e,t,i,l,a,s,d,u,m,h;try{null==(e=I.current)||e.call(I),F.current=null,j.current=null,oe(!1);const p=it;if(o.diff?"function"==typeof n.createDiffEditor?(F.current="diff",await n.createDiffEditor(r,String(null!=(t=o.originalCode)?t:""),String(null!=(i=o.updatedCode)?i:""),p)):(F.current="single",await n.createEditor(r,String(null!=(a=null!=(l=o.updatedCode)?l:o.code)?a:""),p)):(F.current="single",await n.createEditor(r,String(null!=(s=o.code)?s:""),p)),j.current=r,O.current!==c)return;const f=Number(null==(d=X.current)?void 0:d.fontSize);if(Number.isFinite(f)&&f>0){Me(f),Ee(f);try{const e="diff"===F.current?null==(u=n.getDiffEditorView)?void 0:u.call(n):null==(m=n.getEditorView)?void 0:m.call(n);null==(h=null==e?void 0:e.updateOptions)||h.call(e,{fontSize:f,automaticLayout:!1})}catch{}}He(),ue||pe||Pe(!1),oe(!0)}catch{O.current===c&&Z(!0)}})().finally(()=>{_.current===s&&(_.current=null)});return _.current=s,s},[Pe,pe,ue,it,ht,He,Je,Y,G]);s(()=>{Je();const e=q.current;if(q.current=nt,!u.diff)return;if(Y)return;if(!Q||!G||!te)return;if(pe||ht)return;if(e===nt)return;let t=!1;return(async()=>{if(Re(),!t)try{await pt()}catch{}})(),()=>{t=!0}},[pe,te,pt,Q,nt,u.diff,Re,ht,Je,Y,G]),s(()=>{Y||Q&&G&&(pe||ht?Re():pt())},[pe,pt,Q,Re,ht,Y,G]),s(()=>{var e;if(Y)return;if(!Q)return;if(!G)return;if(pe)return;if(ht)return;const t=W.current;if(!t)return;const n=String(null!=(e=u.code)?e:"");(async()=>{var e,r;let o=ae;if(!o&&z.current)try{o=T(z.current(n)),o&&ce(o)}catch{}const i=S(o||ot);if(t.createEditor&&R.current){try{await Promise.resolve(pt())}catch{}const e=_.current;if(e)try{await e}catch{}}try{u.diff&&t.updateDiff?await Promise.resolve(t.updateDiff(String(null!=(e=u.originalCode)?e:""),String(null!=(r=u.updatedCode)?r:""),i)):t.updateCode&&await Promise.resolve(t.updateCode(n,i))}catch{}ue&&Pe(!0)})()},[Pe,ot,ae,pe,te,pt,ue,Q,u.code,u.diff,u.originalCode,u.updatedCode,ht,Y,G]),s(()=>{if(Y)return;if(!Q)return;if(!G)return;if(pe)return;if(ht)return;if(!ue&&h)return;const e="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>Pe(ue)):null;return null==e&&Pe(ue),()=>{null!=e&&"undefined"!=typeof window&&"function"==typeof window.cancelAnimationFrame&&window.cancelAnimationFrame(e)}},[Pe,pe,ue,h,Q,ht,Y,G]),s(()=>{var e,t,n;if(!g)return;if(Y)return;const r=W.current;if(r){try{const o="diff"===F.current?null==(e=r.getDiffEditorView)?void 0:e.call(r):null==(t=r.getEditorView)?void 0:t.call(r);null==(n=null==o?void 0:o.updateOptions)||n.call(o,{fontSize:Te})}catch{}Pe(ue)}},[Pe,g,ue,Te,u.diff,Y]),s(()=>{Se||Be(!0)},[Se]);const ft=d((e,t)=>{if(!Se)return;const n=e.currentTarget;n&&!n.disabled&&("clientX"in e&&(e.clientX,e.clientY),Ne(n,t,"top",!1,0,Ue))},[Ue,Se]),gt=d(()=>{Se&&Be()},[Se]),wt=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(String(dt)),de(!0),null==(e=c.onCopy)||e.call(c,String(dt)),setTimeout(()=>de(!1),1e3)}catch{}},[c,dt]),vt=d(()=>{if(!ct)return;const e="html"===ot?"text/html":"image/svg+xml",t="html"===ot?ke("artifacts.htmlPreviewTitle")||"HTML Preview":ke("artifacts.svgPreviewTitle")||"SVG Preview";"function"!=typeof c.onPreviewCode?"html"===ot&&ve(e=>!e):c.onPreviewCode({node:u,artifactType:e,artifactTitle:t,id:`temp-${ot}-${Date.now()}`})},[ot,ct,u,c,ke]);return Y?/* @__PURE__ */t(Ye,{node:u}):/* @__PURE__ */e("div",{ref:H,className:["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",Ue?"border-gray-700/30 bg-gray-900":"border-gray-200 bg-white",h?"is-rendering":"",Ue?"is-dark":"",u.diff?"is-diff":"",lt?"is-plain-text":""].join(" "),style:ut,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:mt,children:[
13
+ /* @__PURE__ */t("iframe",{className:"html-preview-frame__iframe",sandbox:l,referrerPolicy:"no-referrer",src:"about:blank",srcDoc:i,title:n.title||"Preview"})]})}),document.body)}let Ee=!1,De=null,$e=!1;async function Pe(){if(De)return De;if($e)return null;try{return De=await import("stream-monaco"),await async function(e){if(Ee)return;Ee=!0;const t=null==globalThis?void 0:globalThis.MonacoEnvironment;(!t||"function"!=typeof t.getWorker&&"function"!=typeof t.getWorkerUrl)&&(null==e?void 0:e.preloadMonacoWorkers)&&await e.preloadMonacoWorkers()}(De),De}catch{return $e=!0,null}}let Ae=null,Re=!1,He=null,We=null,Ie=null,_e=null,Fe=null;const je=/* @__PURE__ */new WeakMap;let Oe=0;function ze(e,t){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 t=je.get(e);if(t)return t;try{const t=JSON.stringify(e);if(t)return je.set(e,t),t}catch{}const n="__theme_"+ ++Oe;return je.set(e,n),n}return String(e)}(e);return n?(Ae!==t&&(Ae=t),Re||Fe!==n?!He||_e!==n&&We!==n?(Ie=e,_e=n,He||(Re=!0,He=(async()=>{for(;null!=Ie&&null!=_e;){const e=Ie,t=_e;if(Ie=null,_e=null,Fe===t)continue;const n=Ae;if(!n)break;try{We=t,await Promise.resolve(n(e)),Fe=t}catch{}}})().finally(()=>{Re=!1,He=null,We=null}),He)):He:Promise.resolve()):Promise.resolve()}let Ve=null,Ke=null,Xe=null;const Ue=/* @__PURE__ */new Set,qe=/* @__PURE__ */new WeakMap;let Ye=0;function Ze(){for(const e of Array.from(Ue))try{e()}catch{}}function Ge({node:e}){var n;const r=o(()=>function(e){var t;return String(null!=(t=String(null!=e?e:"").split(/\s+/g)[0])?t:"").toLowerCase().replace(/[^\w-]/g,"")||"plaintext"}(null==e?void 0:e.language),[e]),i=r?`Code block: ${r}`:"Code block";/* @__PURE__ */
14
+ return t("pre",{className:`language-${r}`,"aria-busy":!0===(null==e?void 0:e.loading),"aria-label":i,"data-language":r,tabIndex:0,children:/* @__PURE__ */t("code",{translate:"no",children:String(null!=(n=null==e?void 0:e.code)?n:"")})})}const Je={isShowPreview:!0,loading:!0,stream:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0},Qe=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});function et(e){var t;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const n=e;return{...Qe,...n,enabled:null==(t=n.enabled)||t}}return{...Qe}}function tt(e,t){var n;const r=t?{...t}:{};if(!e)return r;const o=void 0===r.diffHideUnchangedRegions?{...Qe}:et(r.diffHideUnchangedRegions),i=void 0===r.hideUnchangedRegions?void 0:et(r.hideUnchangedRegions),l=null!=(n=r.diffUnchangedRegionStyle)?n:"line-info";return{maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:12,lineNumbersMinChars:2,glyphMargin:!1,fontSize:13,lineHeight:30,renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,padding:{top:10,bottom:"line-info"===l||"line-info-basic"===l||"metadata"===l?22:14},diffHideUnchangedRegions:o,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:l,diffHunkActionsOnHover:!0,diffHunkHoverHideDelayMs:160,...r,...void 0===i?{}:{hideUnchangedRegions:i},diffHideUnchangedRegions:o}}function nt(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function rt(e){const t=String(null!=e?e:"").match(/\d+(?:\.\d+)?/g);if(!t||t.length<3)return null;const[n,r,o]=t.slice(0,3).map(Number);return.2126*n+.7152*r+.0722*o}function ot(r){var l;const c={...Je,...r},{node:u,isDark:m,loading:h,stream:p,isShowPreview:f,enableFontSizeControl:g,darkTheme:w,lightTheme:v,monacoOptions:y,themes:x,minWidth:k,maxWidth:b,showHeader:C,showCopyButton:M,showExpandButton:N,showPreviewButton:B,showCollapseButton:L,showFontSizeButtons:P,showTooltips:A}=c,R=a(null),H=a(null),W=a(null),I=a(null),_=a(null),F=a(null),j=a(null),O=a(0),z=a(null),V=a(null),K=me(),X=a(y),U=a(null),q=a(null),[Y,Z]=i(!1),[G,J]=i(()=>"undefined"==typeof window),[Q,ee]=i(!1),[te,ne]=i(!1),[re,oe]=i(!1),[ie,le]=i(()=>u.language||"plaintext"),[ae,ce]=i(()=>S(u.language)),[se,de]=i(!1),[ue,he]=i(!1),[pe,fe]=i(!1),[we,ve]=i(!1),[ye,xe]=i(0),{t:ke}=ge(),be=o(()=>tt(Boolean(u.diff),y),[y,u.diff]),[Ce,Me]=i(()=>{var e;const t=Number(null==(e=tt(Boolean(u.diff),y))?void 0:e.fontSize);return Number.isFinite(t)&&t>0?t:14}),[Le,Se]=i(Ce),Ee=o(()=>!1!==A,[A]),De=d(()=>{var e,t;const n=null!=(t=null==(e=X.current)?void 0:e.MAX_HEIGHT)?t:500;if("number"==typeof n&&Number.isFinite(n))return Math.max(80,n);const r=String(n).match(/^(\d+(?:\.\d+)?)/),o=r?Number.parseFloat(r[1]):500;return Number.isFinite(o)?Math.max(80,o):500},[]),$e=d(e=>{var t,n,r,o;if(Y)return;const i=R.current,l=W.current;if(!i||!l)return;const a="diff"===F.current?null==(t=l.getDiffEditorView)?void 0:t.call(l):null==(n=l.getEditorView)?void 0:n.call(l);if(!a)return;const c=De();try{null==(r=a.updateOptions)||r.call(a,{automaticLayout:e})}catch{}e?(i.style.minHeight="0px",i.style.maxHeight="none",i.style.overflow="visible"):(i.style.minHeight="0px",i.style.maxHeight=`${Math.ceil(c)}px`,i.style.overflow="auto");try{const t=Number((()=>{if("function"==typeof a.getContentHeight)return a.getContentHeight();if("diff"===F.current&&"function"==typeof a.getModifiedEditor){const e=a.getModifiedEditor();if(e&&"function"==typeof e.getContentHeight)return e.getContentHeight()}})());if(Number.isFinite(t)&&t>0){const n=e?t:Math.min(t,c);i.style.height=`${Math.ceil(Math.max(1,n))}px`}null==(o=a.layout)||o.call(a)}catch{}},[De,Y]);s(()=>T(()=>{xe(e=>e+1)}),[]),s(()=>{ce(S(u.language))},[u.language]);const Ae=a(u);Ae.current=u;const Re=d(()=>{var e;O.current+=1;try{null==(e=I.current)||e.call(I)}catch{}_.current=null,F.current=null,j.current=null,oe(!1),ne(!1)},[]),He=d(()=>{var e,t,n,r,o,i;const l=R.current,a=H.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!=(t=null==e?void 0:e.getPropertyValue("--vscode-editor-foreground"))?t:"").trim()||String(null!=(n=null==e?void 0:e.color)?n:"").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,t,n,r){if(!n)return!1;const o=rt(e),i=rt(t);return r?null!=o&&o>170||null!=i&&i<110:null!=o&&o<85||null!=i&&i>190}(s,l,"plaintext"===E(String(u.language||ae||ie||"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{}},[ae,ie,u.diff,u.language]),We=o(()=>m?w:v,[w,m,v]),Ie=d(()=>{var e;const t=null==be?void 0:be.theme,n=null!=(e=null!=We?We:t)?e:Ve,r=Array.isArray(x)?x:[];if(!r.length||null==n)return n;const o=nt(n),i=r.map(e=>nt(e)).filter(e=>!!e);if(!o||i.includes(o))return n;const l=nt(t);return null!=t&&l&&i.includes(l)?t:r[0]},[We,be,x]),_e=o(()=>Ie(),[Ie]),Fe=o(()=>function(e,t){var n;const r=(null!=(n=nt(e))?n:"").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)):t}(_e,Boolean(m)),[m,_e]),je=o(()=>{if(!u.diff)return Fe?"dark":"light";const e=null==be?void 0:be.diffAppearance;return"light"===e||"dark"===e?e:m?"dark":"light"},[m,u.diff,Fe,be]),Oe=o(()=>u.diff?"dark"===je:Fe,[je,u.diff,Fe]),qe=d(()=>({wordWrap:"on",wrappingIndent:"same",themes:x,...be||{},theme:_e,...u.diff?{diffAppearance:je}:{},onThemeChange(){He()}}),[je,u.diff,_e,be,He,x]),Ye=d(()=>{const e=qe(),t=U.current;if(!t)return U.current=e,e;for(const n of Object.keys(t))n in e||delete t[n];return Object.assign(t,e),t},[qe]),Qe=o(()=>{var e,t,n,r,o,i,l;return JSON.stringify({diffLineStyle:null!=(e=null==be?void 0:be.diffLineStyle)?e:"background",diffUnchangedRegionStyle:null!=(t=null==be?void 0:be.diffUnchangedRegionStyle)?t:"line-info",diffHideUnchangedRegions:null==(n=null==be?void 0:be.diffHideUnchangedRegions)||n,renderSideBySide:null==(r=null==be?void 0:be.renderSideBySide)||r,enableSplitViewResizing:null==(o=null==be?void 0:be.enableSplitViewResizing)||o,ignoreTrimWhitespace:null==(i=null==be?void 0:be.ignoreTrimWhitespace)||i,originalEditable:null!=(l=null==be?void 0:be.originalEditable)&&l})},[be]);s(()=>{X.current=be,Ye()},[be,Ye]),s(()=>()=>{var e,t,n;O.current+=1,null==(e=I.current)||e.call(I),I.current=null,_.current=null,F.current=null,j.current=null,z.current=null,null==(n=null==(t=V.current)?void 0:t.destroy)||n.call(t),V.current=null},[]),s(()=>{var e,t;if("undefined"==typeof window)return;if(G)return;const n=H.current;if(!n)return;null==(t=null==(e=V.current)?void 0:e.destroy)||t.call(e);const r=K(n,{rootMargin:"400px"});return V.current=r,r.isVisible()&&J(!0),r.whenVisible.then(()=>J(!0)),()=>{r.destroy(),V.current===r&&(V.current=null)}},[K,G]),s(()=>{let e=!0;return"undefined"==typeof window?()=>{e=!1}:W.current?(Ye(),()=>{e=!1}):((async()=>{try{const n=await Pe();if(!e)return;if(!n)return void Z(!0);const r=n.useMonaco,o=n.detectLanguage;if("function"==typeof o&&(z.current=o),"function"!=typeof r)return void Z(!0);const i=r(Ye());W.current=i,"function"==typeof(t=i.setTheme)&&(Xe=t,null!=Ve&&null!=Ke&&ze(Ve,Xe).then(()=>Ze()).catch(()=>{})),I.current="function"==typeof i.safeClean?()=>i.safeClean():"function"==typeof i.cleanupEditor?()=>i.cleanupEditor():null,ee(!0)}catch{e&&Z(!0)}var t})(),()=>{e=!1})},[Ye]),s(()=>{var e;if(!u.language&&!ae&&z.current)try{const t=z.current(String(null!=(e=u.code)?e:""));t&&le(t)}catch{}},[ae,u.code,u.language]);const et=o(()=>String(u.language||ae||ie||"plaintext"),[ae,ie,u.language]),ot=o(()=>S(et),[et]),it=o(()=>E(ot),[ot]),lt=o(()=>"plaintext"===it,[it]),at=o(()=>D(ot),[ot,ye]),ct=o(()=>!!f&&("html"===ot||"svg"===ot),[ot,f]),st=o(()=>{const e=ot;return e?$[e]||e.charAt(0).toUpperCase()+e.slice(1):$[""]||"Plain Text"},[ot]),dt=o(()=>{var e,t,n;return u.diff?null!=(t=null!=(e=u.updatedCode)?e:u.code)?t:"":null!=(n=u.code)?n:""},[u.code,u.diff,u.updatedCode]),ut=o(()=>{const e=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t={},n=e(k),r=e(b);return n&&(t.minWidth=n),r&&(t.maxWidth=r),u.diff?(t.color="var(--markstream-diff-shell-fg)",t.borderColor="var(--markstream-diff-shell-border)"):(t.color=`var(--vscode-editor-foreground, ${Oe?"#e5e7eb":"#111827"})`,t.backgroundColor=`var(--vscode-editor-background, ${Oe?"#111827":"#ffffff"})`,t.borderColor=Oe?"rgb(55 65 81 / 0.3)":"rgb(229 231 235)"),t},[b,k,u.diff,Oe]),mt=o(()=>{if(!u.diff)return{color:`var(--vscode-editor-foreground, ${Oe?"#e5e7eb":"#111827"})`,backgroundColor:`var(--vscode-editor-background, ${Oe?"#111827":"#ffffff"})`}},[u.diff,Oe]),ht=!1===p&&h;s(()=>{if(Y)return;if(!Q)return;if(!te||!G)return;const e=W.current;Ye();const t=()=>{var t;u.diff&&(null==(t=null==e?void 0:e.refreshDiffPresentation)||t.call(e)),He(),pe||null==("undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>$e(ue)):null)&&$e(ue)};(null==e?void 0:e.setTheme)&&_e?ze(_e,e.setTheme).then(t).catch(()=>{}):t()},[$e,pe,te,je,ue,Q,u.diff,_e,He,Ye,Y,G]),s(()=>{var e;if("undefined"!=typeof window)return e=()=>{He()},Ue.add(e),()=>{Ue.delete(e)}},[He]);const pt=d(async()=>{var e,t;if(Y)return null;if(!G)return null;if(pe)return null;if(ht)return null;const n=W.current,r=R.current;if(!n||!r||!n.createEditor)return null;Ye();const o=Ae.current,i=o.diff?"diff":"single",l=j.current,a="diff"===i?Boolean(null==(e=n.getDiffEditorView)?void 0:e.call(n)):Boolean(null==(t=n.getEditorView)?void 0:t.call(n));if(F.current===i&&l===r&&a)return null;if(_.current)return _.current;O.current+=1;const c=O.current;ne(!0);const s=(async()=>{var e,t,i,l,a,s,d,u,m,h;try{null==(e=I.current)||e.call(I),F.current=null,j.current=null,oe(!1);const p=it;if(o.diff?"function"==typeof n.createDiffEditor?(F.current="diff",await n.createDiffEditor(r,String(null!=(t=o.originalCode)?t:""),String(null!=(i=o.updatedCode)?i:""),p)):(F.current="single",await n.createEditor(r,String(null!=(a=null!=(l=o.updatedCode)?l:o.code)?a:""),p)):(F.current="single",await n.createEditor(r,String(null!=(s=o.code)?s:""),p)),j.current=r,O.current!==c)return;const f=Number(null==(d=X.current)?void 0:d.fontSize);if(Number.isFinite(f)&&f>0){Me(f),Se(f);try{const e="diff"===F.current?null==(u=n.getDiffEditorView)?void 0:u.call(n):null==(m=n.getEditorView)?void 0:m.call(n);null==(h=null==e?void 0:e.updateOptions)||h.call(e,{fontSize:f,automaticLayout:!1})}catch{}}He(),ue||pe||$e(!1),oe(!0)}catch{O.current===c&&Z(!0)}})().finally(()=>{_.current===s&&(_.current=null)});return _.current=s,s},[$e,pe,ue,it,ht,He,Ye,Y,G]);s(()=>{Ye();const e=q.current;if(q.current=Qe,!u.diff)return;if(Y)return;if(!Q||!G||!te)return;if(pe||ht)return;if(e===Qe)return;let t=!1;return(async()=>{if(Re(),!t)try{await pt()}catch{}})(),()=>{t=!0}},[pe,te,pt,Q,Qe,u.diff,Re,ht,Ye,Y,G]),s(()=>{Y||Q&&G&&(pe||ht?Re():pt())},[pe,pt,Q,Re,ht,Y,G]),s(()=>{var e;if(Y)return;if(!Q)return;if(!G)return;if(pe)return;if(ht)return;const t=W.current;if(!t)return;const n=String(null!=(e=u.code)?e:"");(async()=>{var e,r;let o=ae;if(!o&&z.current)try{o=S(z.current(n)),o&&ce(o)}catch{}const i=E(o||ot);if(t.createEditor&&R.current){try{await Promise.resolve(pt())}catch{}const e=_.current;if(e)try{await e}catch{}}try{u.diff&&t.updateDiff?await Promise.resolve(t.updateDiff(String(null!=(e=u.originalCode)?e:""),String(null!=(r=u.updatedCode)?r:""),i)):t.updateCode&&await Promise.resolve(t.updateCode(n,i))}catch{}ue&&$e(!0)})()},[$e,ot,ae,pe,te,pt,ue,Q,u.code,u.diff,u.originalCode,u.updatedCode,ht,Y,G]),s(()=>{if(Y)return;if(!Q)return;if(!G)return;if(pe)return;if(ht)return;if(!ue&&h)return;const e="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>$e(ue)):null;return null==e&&$e(ue),()=>{null!=e&&"undefined"!=typeof window&&"function"==typeof window.cancelAnimationFrame&&window.cancelAnimationFrame(e)}},[$e,pe,ue,h,Q,ht,Y,G]),s(()=>{var e,t,n;if(!g)return;if(Y)return;const r=W.current;if(r){try{const o="diff"===F.current?null==(e=r.getDiffEditorView)?void 0:e.call(r):null==(t=r.getEditorView)?void 0:t.call(r);null==(n=null==o?void 0:o.updateOptions)||n.call(o,{fontSize:Le})}catch{}$e(ue)}},[$e,g,ue,Le,u.diff,Y]),s(()=>{Ee||Be(!0)},[Ee]);const ft=d((e,t)=>{if(!Ee)return;const n=e.currentTarget;n&&!n.disabled&&("clientX"in e&&(e.clientX,e.clientY),Ne(n,t,"top",!1,0,Oe))},[Oe,Ee]),gt=d(()=>{Ee&&Be()},[Ee]),wt=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(String(dt)),de(!0),null==(e=c.onCopy)||e.call(c,String(dt)),setTimeout(()=>de(!1),1e3)}catch{}},[c,dt]),vt=d(()=>{if(!ct)return;const e="html"===ot?"text/html":"image/svg+xml",t="html"===ot?ke("artifacts.htmlPreviewTitle")||"HTML Preview":ke("artifacts.svgPreviewTitle")||"SVG Preview";"function"!=typeof c.onPreviewCode?"html"===ot&&ve(e=>!e):c.onPreviewCode({node:u,artifactType:e,artifactTitle:t,id:`temp-${ot}-${Date.now()}`})},[ot,ct,u,c,ke]);return Y?/* @__PURE__ */t(Ge,{node:u}):/* @__PURE__ */e("div",{ref:H,className:["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",Oe?"border-gray-700/30 bg-gray-900":"border-gray-200 bg-white",h?"is-rendering":"",Oe?"is-dark":"",u.diff?"is-diff":"",lt?"is-plain-text":""].join(" "),style:ut,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:mt,children:[
15
15
  /* @__PURE__ */e("div",{className:"flex items-center space-x-2 flex-1 overflow-hidden",children:[
16
16
  /* @__PURE__ */t("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:at}}),
17
17
  /* @__PURE__ */t("span",{className:"text-sm font-medium font-mono truncate",children:st})]}),
18
18
  /* @__PURE__ */e("div",{className:"flex items-center space-x-2",children:[L&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":pe,onClick:()=>fe(e=>!e),onMouseEnter:e=>ft(e,pe?ke("common.expand")||"Expand":ke("common.collapse")||"Collapse"),onFocus:e=>ft(e,pe?ke("common.expand")||"Expand":ke("common.collapse")||"Collapse"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("svg",{style:{rotate:pe?"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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),P&&g&&/* @__PURE__ */e(n,{children:[
19
- /* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:Te<=10,onClick:()=>Ee(e=>Math.max(10,e-1)),onMouseEnter:e=>ft(e,ke("common.decrease")||"Decrease"),onFocus:e=>ft(e,ke("common.decrease")||"Decrease"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14"})})}),
20
- /* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:Te===Ce,onClick:()=>Ee(Ce),onMouseEnter:e=>ft(e,ke("common.reset")||"Reset"),onFocus:e=>ft(e,ke("common.reset")||"Reset"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("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:[
19
+ /* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:Le<=10,onClick:()=>Se(e=>Math.max(10,e-1)),onMouseEnter:e=>ft(e,ke("common.decrease")||"Decrease"),onFocus:e=>ft(e,ke("common.decrease")||"Decrease"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14"})})}),
20
+ /* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:Le===Ce,onClick:()=>Se(Ce),onMouseEnter:e=>ft(e,ke("common.reset")||"Reset"),onFocus:e=>ft(e,ke("common.reset")||"Reset"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("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:[
21
21
  /* @__PURE__ */t("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),
22
22
  /* @__PURE__ */t("path",{d:"M3 3v5h5"})]})})}),
23
- /* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:Te>=36,onClick:()=>Ee(e=>Math.min(36,e+1)),onMouseEnter:e=>ft(e,ke("common.increase")||"Increase"),onFocus:e=>ft(e,ke("common.increase")||"Increase"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14m-7-7v14"})})})]}),M&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":se?ke("common.copied")||"Copied":ke("common.copy")||"Copy",onClick:wt,onMouseEnter:e=>ft(e,se?ke("common.copied")||"Copied":ke("common.copy")||"Copy"),onFocus:e=>ft(e,se?ke("common.copied")||"Copied":ke("common.copy")||"Copy"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("svg",se?{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__ */t("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:[
23
+ /* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",disabled:Le>=36,onClick:()=>Se(e=>Math.min(36,e+1)),onMouseEnter:e=>ft(e,ke("common.increase")||"Increase"),onFocus:e=>ft(e,ke("common.increase")||"Increase"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14m-7-7v14"})})})]}),M&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":se?ke("common.copied")||"Copied":ke("common.copy")||"Copy",onClick:wt,onMouseEnter:e=>ft(e,se?ke("common.copied")||"Copied":ke("common.copy")||"Copy"),onFocus:e=>ft(e,se?ke("common.copied")||"Copied":ke("common.copy")||"Copy"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("svg",se?{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__ */t("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:[
24
24
  /* @__PURE__ */t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
25
25
  /* @__PURE__ */t("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__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":ue,onClick:e=>{he(e=>!e),ft(e,ue?ke("common.expand")||"Expand":ke("common.collapse")||"Collapse")},onMouseEnter:e=>ft(e,ue?ke("common.collapse")||"Collapse":ke("common.expand")||"Expand"),onFocus:e=>ft(e,ue?ke("common.collapse")||"Collapse":ke("common.expand")||"Expand"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("svg",ue?{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__ */t("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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})}),ct&&B&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":ke("common.preview")||"Preview",onClick:vt,onMouseEnter:e=>ft(e,ke("common.preview")||"Preview"),onFocus:e=>ft(e,ke("common.preview")||"Preview"),onMouseLeave:gt,onBlur:gt,children:/* @__PURE__ */t("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:[
26
26
  /* @__PURE__ */t("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"}),
27
27
  /* @__PURE__ */t("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"})]})})})]})]}),
28
- /* @__PURE__ */e("div",{className:`code-block-body${pe?" code-block-body--collapsed":""}${ue?" code-block-body--expanded":""}`,children:[!pe&&(!!p||!h)&&(Y?/* @__PURE__ */t(Ye,{node:u}):/* @__PURE__ */e("div",{className:"code-editor-layer",children:[
28
+ /* @__PURE__ */e("div",{className:`code-block-body${pe?" code-block-body--collapsed":""}${ue?" code-block-body--expanded":""}`,children:[!pe&&(!!p||!h)&&(Y?/* @__PURE__ */t(Ge,{node:u}):/* @__PURE__ */e("div",{className:"code-editor-layer",children:[
29
29
  /* @__PURE__ */t("div",{ref:R,className:"code-editor-container"+(p?"":" code-height-placeholder"),style:{visibility:re?"visible":"hidden"},"aria-hidden":!re}),!re&&/* @__PURE__ */t("div",{className:"code-editor-fallback-surface",children:/* @__PURE__ */t("pre",{className:"code-fallback-plain m-0","aria-busy":h,"aria-label":`Code block: ${st}`,tabIndex:0,children:/* @__PURE__ */t("code",{translate:"no",children:String(dt)})})})]})),!p&&h&&/* @__PURE__ */t("div",{className:"code-loading-placeholder",children:/* @__PURE__ */e("div",{className:"loading-skeleton",children:[
30
30
  /* @__PURE__ */t("div",{className:"skeleton-line"}),
31
31
  /* @__PURE__ */t("div",{className:"skeleton-line"}),
32
- /* @__PURE__ */t("div",{className:"skeleton-line short"})]})})]}),we&&!c.onPreviewCode&&ct&&"html"===ot&&/* @__PURE__ */t(Le,{code:String(null!=(l=u.code)?l:""),isDark:m,onClose:()=>ve(!1)}),
33
- /* @__PURE__ */t("span",{className:"sr-only","aria-live":"polite",role:"status",children:se?ke("common.copied")||"Copied":""})]})}function rt(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=rt(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function ot(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=rt(e))&&(r&&(r+=" "),r+=t);return r}const it=()=>import("@terrastruct/d2");let lt=null,at=it;function ct(e){at=e,lt=null}function st(e){ct(null!=e?e:it)}function dt(){ct(null)}function ut(){return"function"==typeof at}async function mt(){if(lt)return lt;const e=at;if(!e)return null;let t;try{t=await e()}catch(n){if(e===it)throw new Error('Optional dependency "@terrastruct/d2" is not installed. Please install it to enable D2 diagrams.');throw n}return t?(lt=function(e){var t;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 n=null!=(t=e.default)?t:e;return"function"==typeof n?n:(null==n?void 0:n.D2)&&"function"==typeof n.D2?n.D2:n}(t),lt):null}const ht={maxHeight:"500px",loading:!0,progressiveRender:!0,progressiveIntervalMs:700,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showCollapseButton:!0},pt={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"},ft=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],gt=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function wt(e){if(!e)return"";const t=e.trim();return gt.test(t)?t:""}function vt(r){var l,c;const u={...ht,...r},{t:m}=ge(),[h,p]=i(!1),[f,g]=i(!1),[w,v]=i(!1),[y,x]=i(!1),[k,b]=i(null),[C,M]=i(""),[N,B]=i(null),[L,T]=i(!1),[E,S]=i(()=>"undefined"==typeof window),D=a(0),$=a(null),P=a(!1),A=a(!1),R=a(0),H=a(null),W=a(!1),I=a(null),_=a(null),F=a(null),j=a(null),O=a(!1),z=a(()=>{}),V=me(),K=null!=(c=null==(l=u.node)?void 0:l.code)?c:"",X=w||!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(()=>{O.current=L},[L]),s(()=>{const e=I.current;if(!e)return;const t=V(e,{rootMargin:"160px"});return _.current=t,t.isVisible()&&S(!0),t.whenVisible.then(()=>S(!0)),()=>{t.destroy(),_.current=null}},[V]);const Z=d(()=>{const e=F.current;if(!e)return;const t=e.getBoundingClientRect().height;t>0&&B(e=>e!==t?t:e)},[]),G=d((e=!1)=>{if(P.current||"undefined"==typeof window)return;if(A.current)return;if(!E)return;if(O.current)return void(W.current=!0);const t=Math.max(120,Number(u.progressiveIntervalMs)||0),n=Date.now()-R.current;if(!e&&n<t)return W.current=!0,void(null==H.current&&(H.current=window.setTimeout(()=>{H.current=null,W.current&&(W.current=!1,G(!0))},Math.max(0,t-n))));P.current=!0;const r=()=>{P.current=!1,R.current=Date.now(),z.current()};"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(r):setTimeout(r,0)},[u.progressiveIntervalMs,E]),J=d(async()=>{if($.current)return $.current;const e=await mt();if(!e)return null;if("function"==typeof e){const t=new e;return t&&"function"==typeof t.compile?$.current=t:"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,t,n,r,o;if("undefined"==typeof window||A.current)return;if(!E)return;if(u.loading&&!u.progressiveRender)return;if(!K)return M(""),void b(null);const i=++D.current;T(!0),b(null);try{const l=await J();if(!l)return x(!1),v(!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(K);if(i!==D.current)return;const c=null!=(e=null==a?void 0:a.diagram)?e:a,s=null!=(n=null!=(t=null==a?void 0:a.renderOptions)?t:null==a?void 0:a.options)?n:{},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={...pt,...e||{}}}const p=await l.render(c,h);if(i!==D.current)return;const f=function(e){return e?"string"==typeof e?e:"string"==typeof e.svg?e.svg:"string"==typeof e.data?e.data:"":""}(p);if(!f)throw new Error("D2 render returned empty output.");const g=function(e){if("undefined"==typeof window||"undefined"==typeof DOMParser)return"";if(!e)return"";const t=e.replace(/["']\s*javascript:/gi,"#").replace(/\bjavascript:/gi,"#").replace(/["']\s*vbscript:/gi,"#").replace(/\bvbscript:/gi,"#").replace(/\bdata:text\/html/gi,"#"),n=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!n||"svg"!==n.nodeName.toLowerCase())return"";const r=n;return function(e){const t=/* @__PURE__ */new Set(["script"]),n=[e,...Array.from(e.querySelectorAll("*"))];for(const r of n){if(t.has(r.tagName.toLowerCase())){r.remove();continue}const e=Array.from(r.attributes);for(const t of e){const e=t.name;if(/^on/i.test(e))r.removeAttribute(e);else{if("style"===e&&t.value){const n=t.value;if(ft.some(e=>e.test(n))){r.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&t.value){const n=wt(t.value);if(!n){r.removeAttribute(e);continue}n!==t.value&&r.setAttribute(e,n)}}}}}(r),r.classList.add("markstream-d2-root-svg"),r.outerHTML}(f);M(g||""),u.loading&&v(!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),v(!0))}finally{i===D.current&&(T(!1),W.current&&(W.current=!1,G()))}},[K,J,u.darkThemeId,u.isDark,u.loading,u.progressiveRender,u.themeId,G,E]);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(K),p(!0),setTimeout(()=>p(!1),1e3)}catch{}},[K]),te=d(()=>{if(C)try{const e=new Blob([C],{type:"image/svg+xml;charset=utf-8"}),t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=`d2-diagram-${Date.now()}.svg`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error("Failed to export SVG:",e)}},[C]),ne=d((e,t)=>{var n;(n=e.currentTarget)&&!n.disabled&&Ne(e.currentTarget,t,"top",!1,(e.clientX,e.clientY),u.isDark)},[u.isDark]),re=d(()=>{Be()},[]);return s(()=>{G()},[K,u.loading,u.isDark,G]),s(()=>{u.loading||G(!0)},[u.loading,G]),s(()=>{const e=requestAnimationFrame(()=>Z());return()=>cancelAnimationFrame(e)},[X,C,K,Z]),s(()=>{A.current=!1,G();const e=requestAnimationFrame(()=>Z());if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{Z()});j.current=e,F.current&&e.observe(F.current)}return()=>{var t;A.current=!0,null!=H.current&&(clearTimeout(H.current),H.current=null),null==(t=j.current)||t.disconnect(),j.current=null,cancelAnimationFrame(e)}},[G,Z]),/* @__PURE__ */e("div",{ref:I,className:ot("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:[
32
+ /* @__PURE__ */t("div",{className:"skeleton-line short"})]})})]}),we&&!c.onPreviewCode&&ct&&"html"===ot&&/* @__PURE__ */t(Te,{code:String(null!=(l=u.code)?l:""),htmlPreviewAllowScripts:c.htmlPreviewAllowScripts,htmlPreviewSandbox:c.htmlPreviewSandbox,isDark:m,onClose:()=>ve(!1)}),
33
+ /* @__PURE__ */t("span",{className:"sr-only","aria-live":"polite",role:"status",children:se?ke("common.copied")||"Copied":""})]})}function it(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=it(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function lt(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=it(e))&&(r&&(r+=" "),r+=t);return r}const at=()=>import("@terrastruct/d2");let ct=null,st=at;function dt(e){st=e,ct=null}function ut(e){dt(null!=e?e:at)}function mt(){dt(null)}function ht(){return"function"==typeof st}async function pt(){if(ct)return ct;const e=st;if(!e)return null;let t;try{t=await e()}catch(n){if(e===at)throw new Error('Optional dependency "@terrastruct/d2" is not installed. Please install it to enable D2 diagrams.');throw n}return t?(ct=function(e){var t;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 n=null!=(t=e.default)?t:e;return"function"==typeof n?n:(null==n?void 0:n.D2)&&"function"==typeof n.D2?n.D2:n}(t),ct):null}const ft={maxHeight:"500px",loading:!0,progressiveRender:!0,progressiveIntervalMs:700,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showCollapseButton:!0},gt={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"},wt=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],vt=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function yt(e){if(!e)return"";const t=e.trim();return vt.test(t)?t:""}function xt(r){var l,c;const u={...ft,...r},{t:m}=ge(),[h,p]=i(!1),[f,g]=i(!1),[w,v]=i(!1),[y,x]=i(!1),[k,b]=i(null),[C,M]=i(""),[N,B]=i(null),[L,S]=i(!1),[T,E]=i(()=>"undefined"==typeof window),D=a(0),$=a(null),P=a(!1),A=a(!1),R=a(0),H=a(null),W=a(!1),I=a(null),_=a(null),F=a(null),j=a(null),O=a(!1),z=a(()=>{}),V=me(),K=null!=(c=null==(l=u.node)?void 0:l.code)?c:"",X=w||!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(()=>{O.current=L},[L]),s(()=>{const e=I.current;if(!e)return;const t=V(e,{rootMargin:"160px"});return _.current=t,t.isVisible()&&E(!0),t.whenVisible.then(()=>E(!0)),()=>{t.destroy(),_.current=null}},[V]);const Z=d(()=>{const e=F.current;if(!e)return;const t=e.getBoundingClientRect().height;t>0&&B(e=>e!==t?t:e)},[]),G=d((e=!1)=>{if(P.current||"undefined"==typeof window)return;if(A.current)return;if(!T)return;if(O.current)return void(W.current=!0);const t=Math.max(120,Number(u.progressiveIntervalMs)||0),n=Date.now()-R.current;if(!e&&n<t)return W.current=!0,void(null==H.current&&(H.current=window.setTimeout(()=>{H.current=null,W.current&&(W.current=!1,G(!0))},Math.max(0,t-n))));P.current=!0;const r=()=>{P.current=!1,R.current=Date.now(),z.current()};"undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(r):setTimeout(r,0)},[u.progressiveIntervalMs,T]),J=d(async()=>{if($.current)return $.current;const e=await pt();if(!e)return null;if("function"==typeof e){const t=new e;return t&&"function"==typeof t.compile?$.current=t:"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,t,n,r,o;if("undefined"==typeof window||A.current)return;if(!T)return;if(u.loading&&!u.progressiveRender)return;if(!K)return M(""),void b(null);const i=++D.current;S(!0),b(null);try{const l=await J();if(!l)return x(!1),v(!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(K);if(i!==D.current)return;const c=null!=(e=null==a?void 0:a.diagram)?e:a,s=null!=(n=null!=(t=null==a?void 0:a.renderOptions)?t:null==a?void 0:a.options)?n:{},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={...gt,...e||{}}}const p=await l.render(c,h);if(i!==D.current)return;const f=function(e){return e?"string"==typeof e?e:"string"==typeof e.svg?e.svg:"string"==typeof e.data?e.data:"":""}(p);if(!f)throw new Error("D2 render returned empty output.");const g=function(e){if("undefined"==typeof window||"undefined"==typeof DOMParser)return"";if(!e)return"";const t=e.replace(/["']\s*javascript:/gi,"#").replace(/\bjavascript:/gi,"#").replace(/["']\s*vbscript:/gi,"#").replace(/\bvbscript:/gi,"#").replace(/\bdata:text\/html/gi,"#"),n=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!n||"svg"!==n.nodeName.toLowerCase())return"";const r=n;return function(e){const t=/* @__PURE__ */new Set(["script"]),n=[e,...Array.from(e.querySelectorAll("*"))];for(const r of n){if(t.has(r.tagName.toLowerCase())){r.remove();continue}const e=Array.from(r.attributes);for(const t of e){const e=t.name;if(/^on/i.test(e))r.removeAttribute(e);else{if("style"===e&&t.value){const n=t.value;if(wt.some(e=>e.test(n))){r.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&t.value){const n=yt(t.value);if(!n){r.removeAttribute(e);continue}n!==t.value&&r.setAttribute(e,n)}}}}}(r),r.classList.add("markstream-d2-root-svg"),r.outerHTML}(f);M(g||""),u.loading&&v(!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),v(!0))}finally{i===D.current&&(S(!1),W.current&&(W.current=!1,G()))}},[K,J,u.darkThemeId,u.isDark,u.loading,u.progressiveRender,u.themeId,G,T]);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(K),p(!0),setTimeout(()=>p(!1),1e3)}catch{}},[K]),te=d(()=>{if(C)try{const e=new Blob([C],{type:"image/svg+xml;charset=utf-8"}),t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=`d2-diagram-${Date.now()}.svg`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error("Failed to export SVG:",e)}},[C]),ne=d((e,t)=>{var n;(n=e.currentTarget)&&!n.disabled&&Ne(e.currentTarget,t,"top",!1,(e.clientX,e.clientY),u.isDark)},[u.isDark]),re=d(()=>{Be()},[]);return s(()=>{G()},[K,u.loading,u.isDark,G]),s(()=>{u.loading||G(!0)},[u.loading,G]),s(()=>{const e=requestAnimationFrame(()=>Z());return()=>cancelAnimationFrame(e)},[X,C,K,Z]),s(()=>{A.current=!1,G();const e=requestAnimationFrame(()=>Z());if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{Z()});j.current=e,F.current&&e.observe(F.current)}return()=>{var t;A.current=!0,null!=H.current&&(clearTimeout(H.current),H.current=null),null==(t=j.current)||t.disconnect(),j.current=null,cancelAnimationFrame(e)}},[G,Z]),/* @__PURE__ */e("div",{ref:I,className:lt("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:[
34
34
  /* @__PURE__ */t("div",{className:"flex items-center gap-x-2",children:/* @__PURE__ */t("span",{className:"text-sm font-medium font-mono",children:"D2"})}),
35
- /* @__PURE__ */e("div",{className:"flex items-center gap-x-2",children:[u.showModeToggle&&/* @__PURE__ */e("div",{className:ot("flex items-center gap-x-1 rounded-md p-0.5",u.isDark?"bg-gray-700":"bg-gray-100"),children:[
36
- /* @__PURE__ */t("button",{type:"button",className:ot("mode-btn px-2 py-1 text-xs rounded",!w&&"is-active"),onClick:()=>v(!1),onMouseEnter:e=>ne(e,m("common.preview")||"Preview"),onFocus:e=>ne(e,m("common.preview")||"Preview"),onMouseLeave:re,onBlur:re,children:m("common.preview")||"Preview"}),
37
- /* @__PURE__ */t("button",{type:"button",className:ot("mode-btn px-2 py-1 text-xs rounded",w&&"is-active"),onClick:()=>v(!0),onMouseEnter:e=>ne(e,m("common.source")||"Source"),onFocus:e=>ne(e,m("common.source")||"Source"),onMouseLeave:re,onBlur:re,children:m("common.source")||"Source"})]}),u.showCopyButton&&/* @__PURE__ */t("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=>ne(e,h?m("common.copied")||"Copied":m("common.copy")||"Copy"),onFocus:e=>ne(e,h?m("common.copied")||"Copied":m("common.copy")||"Copy"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */t("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__ */t("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:[
35
+ /* @__PURE__ */e("div",{className:"flex items-center gap-x-2",children:[u.showModeToggle&&/* @__PURE__ */e("div",{className:lt("flex items-center gap-x-1 rounded-md p-0.5",u.isDark?"bg-gray-700":"bg-gray-100"),children:[
36
+ /* @__PURE__ */t("button",{type:"button",className:lt("mode-btn px-2 py-1 text-xs rounded",!w&&"is-active"),onClick:()=>v(!1),onMouseEnter:e=>ne(e,m("common.preview")||"Preview"),onFocus:e=>ne(e,m("common.preview")||"Preview"),onMouseLeave:re,onBlur:re,children:m("common.preview")||"Preview"}),
37
+ /* @__PURE__ */t("button",{type:"button",className:lt("mode-btn px-2 py-1 text-xs rounded",w&&"is-active"),onClick:()=>v(!0),onMouseEnter:e=>ne(e,m("common.source")||"Source"),onFocus:e=>ne(e,m("common.source")||"Source"),onMouseLeave:re,onBlur:re,children:m("common.source")||"Source"})]}),u.showCopyButton&&/* @__PURE__ */t("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=>ne(e,h?m("common.copied")||"Copied":m("common.copy")||"Copy"),onFocus:e=>ne(e,h?m("common.copied")||"Copied":m("common.copy")||"Copy"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */t("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__ */t("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:[
38
38
  /* @__PURE__ */t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
39
39
  /* @__PURE__ */t("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__ */t("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:te,onMouseEnter:e=>ne(e,m("common.export")||"Export"),onFocus:e=>ne(e,m("common.export")||"Export"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */t("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__ */t("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__ */t("button",{type:"button",className:"d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":f,onClick:()=>g(e=>!e),onMouseEnter:e=>ne(e,f?m("common.expand")||"Expand":m("common.collapse")||"Collapse"),onFocus:e=>ne(e,f?m("common.expand")||"Expand":m("common.collapse")||"Collapse"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */t("svg",{style:{transform:`rotate(${f?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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})})]})]}),!f&&/* @__PURE__ */t("div",{ref:F,className:"d2-block-body",style:Y,children:u.loading&&!U?/* @__PURE__ */e("div",{className:"d2-source px-4 py-4",children:[
40
40
  /* @__PURE__ */t("pre",{className:"d2-code",children:/* @__PURE__ */t("code",{children:K})}),k&&/* @__PURE__ */t("p",{className:"d2-error mt-2 text-xs",children:k})]}):/* @__PURE__ */t(n,{children:/* @__PURE__ */e("div",X?{className:"d2-source px-4 py-4",children:[
41
41
  /* @__PURE__ */t("pre",{className:"d2-code",children:/* @__PURE__ */t("code",{children:K})}),k&&/* @__PURE__ */t("p",{className:"d2-error mt-2 text-xs",children:k})]}:{className:"d2-render",style:q,children:[
42
- /* @__PURE__ */t("div",{className:"d2-svg",dangerouslySetInnerHTML:{__html:C}}),k&&/* @__PURE__ */t("p",{className:"d2-error px-4 pb-3 text-xs",children:k})]})})})]})}function yt(n){const{node:r,ctx:o,renderNode:i,indexKey:l}=n,a=Array.isArray(r.items)?r.items:[];/* @__PURE__ */
42
+ /* @__PURE__ */t("div",{className:"d2-svg",dangerouslySetInnerHTML:{__html:C}}),k&&/* @__PURE__ */t("p",{className:"d2-error px-4 pb-3 text-xs",children:k})]})})})]})}function kt(n){const{node:r,ctx:o,renderNode:i,indexKey:l}=n,a=Array.isArray(r.items)?r.items:[];/* @__PURE__ */
43
43
  return t("dl",{className:"definition-list","data-index-key":l,children:a.map((n,r)=>/* @__PURE__ */e("div",{className:"mb-4",children:[
44
44
  /* @__PURE__ */t("dt",{className:"definition-term font-semibold",children:o&&i?P(n.term,o,`${String(null!=l?l:"definition")}-term-${r}`,i):null}),
45
- /* @__PURE__ */t("dd",{className:"definition-desc ml-4",children:o&&i?P(n.definition,o,`${String(null!=l?l:"definition")}-desc-${r}`,i):null})]},`${String(null!=l?l:"definition")}-${r}`))})}function xt(e){var n;const{node:r}=e;/* @__PURE__ */
46
- return t("span",{className:"emoji-node",children:null!=(n=r.name)?n:r.markup})}function kt(e){/* @__PURE__ */
47
- return t("em",{className:"emphasis-node",children:e.children})}function bt(e){const{node:n}=e,r=d(e=>{var t;if(e.preventDefault(),"undefined"==typeof document)return;const r=document.getElementById(`fnref-${String(null!=(t=n.id)?t:"")}`);r&&r.scrollIntoView({behavior:"smooth"})},[n.id]);/* @__PURE__ */
48
- return t("a",{className:"footnote-anchor text-sm text-[#0366d6] hover:underline cursor-pointer",href:`#fnref-${n.id}`,title:`Back to reference ${n.id}`,onClick:r,children:"↩︎"})}function Ct(e){const{node:n,ctx:r,renderNode:o,indexKey:i}=e;/* @__PURE__ */
49
- return t("div",{id:`footnote-${n.id}`,className:"footnote-node flex mt-2 mb-2 text-sm leading-relaxed border-t border-[#eaecef] pt-2",children:/* @__PURE__ */t("div",{className:"flex-1",children:r&&o?L(n.children,r,String(null!=i?i:`footnote-${n.id}`),o):null})})}function Mt(n){const{node:r}=n,i=o(()=>`#footnote-${r.id}`,[r.id]),l=d(e=>{if(e.preventDefault(),"undefined"==typeof document)return;const t=document.querySelector(i);t&&t.scrollIntoView({behavior:"smooth"})},[i]);/* @__PURE__ */
50
- return t("sup",{id:`fnref-${r.id}`,className:"footnote-reference",onClick:l,children:/* @__PURE__ */e("a",{href:i,title:`View footnote ${r.id}`,className:"footnote-link cursor-pointer",children:["[",r.id,"]"]})})}function Nt(e){/* @__PURE__ */
51
- return t("br",{className:"hard-break"})}function Bt(e){const{node:n,ctx:r,renderNode:o,indexKey:i,children:l}=e,a=Math.min(6,Math.max(1,Number(n.level)||1)),c=`h${a}`,s=null==n?void 0:n.attrs,{class:d,className:u,style:m,...h}=null!=s?s:{};/* @__PURE__ */
52
- return t(c,{dir:"auto",className:ot("heading-node font-semibold",`heading-${a}`,d,u),..."object"==typeof m&&null!=m?{style:m}:{},...h,children:null!=l?l:r&&o?L(n.children,r,String(null!=i?i:`heading-${a}`),o):null})}function Lt(e){/* @__PURE__ */
53
- return t("mark",{className:"highlight-node",children:e.children})}function Tt(l){var c,d,m;const{node:w,placeholder:v,customId:y}=l,x=null!=(m=null!=(d=l.htmlPolicy)?d:null==(c=l.ctx)?void 0:c.htmlPolicy)?m:"safe",k=me(),[b,C]=i(null),M=a(null),[N,B]=i(()=>"undefined"==typeof window),[T,E]=i(w.content),S=Boolean(w.loading),D=u(A,R,R),$=o(()=>{var e;return null!=(e=l.customComponents)?e:H(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,!S)return B(!0),void E(w.content);if(!b)return void B(!1);const t=k(b,{rootMargin:"400px"});return M.current=t,t.isVisible()&&B(!0),t.whenVisible.then(()=>B(!0)).catch(()=>{}),()=>{t.destroy(),M.current=null}},[b,S,w.content,k]),s(()=>()=>{var e;null==(e=M.current)||e.destroy(),M.current=null},[]),s(()=>{S&&!N||E(w.content)},[S,w.content,N]);const P=o(()=>{var e;const t=W(h(null!=(e=w.attrs)?e:void 0,x));return t?I(t):void 0},[x,w.attrs]),j=o(()=>{var e;return String(null!=(e=w.tag)?e:"").trim()},[w.tag]),O=o(()=>{var e;const t=W(h(null!=(e=w.attrs)?e:void 0,x,j));return t?I(t):void 0},[x,w.attrs,j]),z=o(()=>Array.isArray(w.children)?w.children:[],[w.children]),V=z.length>0&&!!j&&!p.has(j.toLowerCase())&&!f(j,x)&&!!l.ctx&&!!l.renderNode,K=o(()=>function(e){const t={...e||{}},n="string"==typeof t.className?t.className.trim():"";return t.className=n?`html-block-node ${n}`:"html-block-node",t}(O),[O]),X=o(()=>{var e;return"escape"!==x&&_(null!=(e=w.content)?e:"",$)},[$,x,w.content]),U=o(()=>X&&w.content?F(w.content,$,x):null,[$,x,w.content,X]),q=o(()=>g(null!=T?T:"",x),[x,T]),Y=o(()=>{var e;return V&&l.ctx&&l.renderNode?L(z,l.ctx,`${String(null!=(e=l.indexKey)?e:"html-block")}-structured`,l.renderNode):null},[V,l.ctx,l.indexKey,l.renderNode,z]),Z=/* @__PURE__ */t("div",{className:"html-block-node__placeholder",children:null!=v?v:/* @__PURE__ */e(n,{children:[
45
+ /* @__PURE__ */t("dd",{className:"definition-desc ml-4",children:o&&i?P(n.definition,o,`${String(null!=l?l:"definition")}-desc-${r}`,i):null})]},`${String(null!=l?l:"definition")}-${r}`))})}function bt(e){var n;const{node:r}=e;/* @__PURE__ */
46
+ return t("span",{className:"emoji-node",children:null!=(n=r.name)?n:r.markup})}function Ct(e){/* @__PURE__ */
47
+ return t("em",{className:"emphasis-node",children:e.children})}function Mt(e){const{node:n}=e,r=d(e=>{var t;if(e.preventDefault(),"undefined"==typeof document)return;const r=document.getElementById(`fnref-${String(null!=(t=n.id)?t:"")}`);r&&r.scrollIntoView({behavior:"smooth"})},[n.id]);/* @__PURE__ */
48
+ return t("a",{className:"footnote-anchor text-sm hover:underline cursor-pointer",href:`#fnref-${n.id}`,title:`返回引用 ${n.id}`,onClick:r,children:"↩︎"})}function Nt(e){const{node:n,ctx:r,renderNode:o,indexKey:i}=e;/* @__PURE__ */
49
+ return t("div",{id:`fnref--${n.id}`,className:"footnote-node flex text-sm leading-relaxed border-t border-[var(--footnote-border,#eaecef)] pt-2",children:/* @__PURE__ */t("div",{className:"flex-1",children:r&&o?L(n.children,r,String(null!=i?i:`footnote-${n.id}`),o):null})})}function Bt(n){const{node:r}=n,i=o(()=>`#fnref--${r.id}`,[r.id]),l=o(()=>({href:i}),[i]),a=d(e=>{if(e.preventDefault(),"undefined"==typeof document)return;const t=document.querySelector(i);t&&t.scrollIntoView({behavior:"smooth"})},[i]);/* @__PURE__ */
50
+ return t("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 Lt(e){/* @__PURE__ */
51
+ return t("br",{className:"hard-break"})}function St(e){const{node:n,ctx:r,renderNode:o,indexKey:i,children:l}=e,a=Math.min(6,Math.max(1,Number(n.level)||1)),c=`h${a}`,s=null==n?void 0:n.attrs,{class:d,className:u,style:m,...h}=null!=s?s:{};/* @__PURE__ */
52
+ return t(c,{dir:"auto",className:lt("heading-node font-semibold",`heading-${a}`,d,u),..."object"==typeof m&&null!=m?{style:m}:{},...h,children:null!=l?l:r&&o?L(n.children,r,String(null!=i?i:`heading-${a}`),o):null})}function Tt(e){/* @__PURE__ */
53
+ return t("mark",{className:"highlight-node",children:e.children})}function Et(l){var c,d,m;const{node:w,placeholder:v,customId:y}=l,x=null!=(m=null!=(d=l.htmlPolicy)?d:null==(c=l.ctx)?void 0:c.htmlPolicy)?m:"safe",k=me(),[b,C]=i(null),M=a(null),[N,B]=i(()=>"undefined"==typeof window),[S,T]=i(w.content),E=Boolean(w.loading),D=u(A,R,R),$=o(()=>{var e;return null!=(e=l.customComponents)?e:H(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,!E)return B(!0),void T(w.content);if(!b)return void B(!1);const t=k(b,{rootMargin:"400px"});return M.current=t,t.isVisible()&&B(!0),t.whenVisible.then(()=>B(!0)).catch(()=>{}),()=>{t.destroy(),M.current=null}},[b,E,w.content,k]),s(()=>()=>{var e;null==(e=M.current)||e.destroy(),M.current=null},[]),s(()=>{E&&!N||T(w.content)},[E,w.content,N]);const P=o(()=>{var e;const t=W(h(null!=(e=w.attrs)?e:void 0,x));return t?I(t):void 0},[x,w.attrs]),j=o(()=>{var e;return String(null!=(e=w.tag)?e:"").trim()},[w.tag]),O=o(()=>{var e;const t=W(h(null!=(e=w.attrs)?e:void 0,x,j));return t?I(t):void 0},[x,w.attrs,j]),z=o(()=>Array.isArray(w.children)?w.children:[],[w.children]),V=z.length>0&&!!j&&!p.has(j.toLowerCase())&&!f(j,x)&&!!l.ctx&&!!l.renderNode,K=o(()=>function(e){const t={...e||{}},n="string"==typeof t.className?t.className.trim():"";return t.className=n?`html-block-node ${n}`:"html-block-node",t}(O),[O]),X=o(()=>{var e;return"escape"!==x&&_(null!=(e=w.content)?e:"",$)},[$,x,w.content]),U=o(()=>X&&w.content?F(w.content,$,x):null,[$,x,w.content,X]),q=o(()=>g(null!=S?S:"",x),[x,S]),Y=o(()=>{var e;return V&&l.ctx&&l.renderNode?L(z,l.ctx,`${String(null!=(e=l.indexKey)?e:"html-block")}-structured`,l.renderNode):null},[V,l.ctx,l.indexKey,l.renderNode,z]),Z=/* @__PURE__ */t("div",{className:"html-block-node__placeholder",children:null!=v?v:/* @__PURE__ */e(n,{children:[
54
54
  /* @__PURE__ */t("span",{className:"html-block-node__placeholder-bar"}),
55
55
  /* @__PURE__ */t("span",{className:"html-block-node__placeholder-bar w-4/5"}),
56
- /* @__PURE__ */t("span",{className:"html-block-node__placeholder-bar w-2/3"})]})});return V?r.createElement(j,{...K,ref:C},N?Y:Z):/* @__PURE__ */t("div",{ref:C,className:"html-block-node",...P,children:N?X&&U?/* @__PURE__ */t(n,{children:U}):/* @__PURE__ */t("div",{dangerouslySetInnerHTML:{__html:q}}):Z})}const Et=(()=>{try{return Boolean(!1)}catch{}return!1})();function St(e){Et&&console.warn(e)}function Dt(e,t,n=!1){const r=Object.entries(null!=t?t:{}),o=r.length>0?r.map(([e,t])=>""===t?` ${e}`:` ${e}="${t}"`).join(""):"";return n?`<${e}${o} />`:`<${e}${o}>`}function $t(e,t){Array.isArray(t)?e.push(...t):null!=t&&e.push(t)}function Pt(e,t,n,o,i,l){const a=O(e,o);if(w.has(e.toLowerCase())||!a&&v(e,l))return null;if(!a&&f(e,l))return[Dt(e,t),...n,`</${e}>`];const c=z(t,l,e),s=c.key,d=null!=s&&""!==s?s:i;if(a){const t=o[e]||o[e.toLowerCase()],i=function(e){return y(e)}(c);return r.createElement(t,{...i,key:d},...n)}return r.createElement(e,{...I(c),key:d},...n)}function At(e){var n,o,l;const{node:c,customId:d}=e,u=null!=(l=null!=(o=e.htmlPolicy)?o:null==(n=e.ctx)?void 0:n.htmlPolicy)?l:"safe",m=a(null),[h,p]=i(!1);s(()=>{p(!0)},[]);const y=H(d),x=r.useMemo(()=>{var e;return g(null!=(e=c.content)?e:"",u)},[u,c.content]),k=r.useMemo(()=>{const e=c.content;if(!e)return{mode:"html",content:""};if("escape"===u)return{mode:"html",content:e};if(!_(e,y))return{mode:"html",content:e};const t=function(e,t,n="safe"){if(!e)return[];try{const r=function(e,t,n="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=O(l.tagName,t);if(w.has(l.tagName.toLowerCase())||!e&&v(l.tagName,n))continue;if(!e&&f(l.tagName,n)){(o.length>0?o[o.length-1].children:i).push(Dt(l.tagName,l.attrs||{},!0));continue}const a=Pt(l.tagName,l.attrs||{},[],t,"ms-html-"+r++,n);$t(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=O(l.tagName,t);o.push({tagName:l.tagName,children:[],attrs:l.attrs,customComponent:r,hardBlocked:e||w.has(l.tagName.toLowerCase())||!r&&v(l.tagName,n),softBlocked:!e&&!r&&f(l.tagName,n)})}else if("tag_close"===l.type){const e=l.tagName.toLowerCase();let a=-1;for(let t=o.length-1;t>=0;t--)if(o[t].tagName.toLowerCase()===e){a=t;break}if(-1!==a)for(;o.length>a;){const l=o.pop();let c;c=l.hardBlocked?null:l.softBlocked?[Dt(l.tagName,l.attrs||{}),...l.children,`</${l.tagName}>`]:Pt(l.tagName,l.attrs||{},l.children,t,"ms-html-"+r++,n),o.length>0?$t(o[o.length-1].children,c):$t(i,c),l.tagName.toLowerCase()!==e&&o.length>a&&St(`Auto-closing unclosed tag: <${l.tagName}>`)}else St(`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?[Dt(e.tagName,e.attrs||{}),...e.children,`</${e.tagName}>`]:Pt(e.tagName,e.attrs||{},e.children,t,"ms-html-"+r++,n),$t(i,l),St(`Auto-closing unclosed tag: <${e.tagName}>`)}return i}(j(e),t,n);return r}catch(o){return r=o,Et&&console.error("Failed to parse HTML to React nodes:",r),null}var r}(e,y,u);return null===t?{mode:"html",content:e}:{mode:"dynamic",nodes:t}},[y,u,c.content]);return s(()=>{if(!h||!m.current||"html"!==k.mode)return;const e=m.current;e.innerHTML="";const t=document.createElement("template");t.innerHTML=x,e.appendChild(t.content.cloneNode(!0))},[k.mode,h,x]),c.loading&&!c.autoClosed?/* @__PURE__ */t("span",{className:"html-inline-node html-inline-node--loading",children:c.content}):"dynamic"===k.mode?/* @__PURE__ */t("span",{className:"html-inline-node",style:{display:"inline"},children:k.nodes}):/* @__PURE__ */t("span",{ref:m,className:"html-inline-node",style:{display:"inline"}})}const Rt={fallbackSrc:"",lazy:!0,usePlaceholder:!0};function Ht(r){var o,l,a,c,d,u;const m={...Rt,...r},[h,p]=i(!1),[f,g]=i(!1),[w,v]=i(!1),y=f&&m.fallbackSrc?m.fallbackSrc:m.node.src;s(()=>{p(!1),g(!1)},[y]),s(()=>{v(!1)},[m.node.src]);return m.node.loading||f?f?m.node.loading||m.fallbackSrc?null:/* @__PURE__ */e("span",{className:"image-node__error",children:[
56
+ /* @__PURE__ */t("span",{className:"html-block-node__placeholder-bar w-2/3"})]})});return V?r.createElement(j,{...K,ref:C},N?Y:Z):/* @__PURE__ */t("div",{ref:C,className:"html-block-node",...P,children:N?X&&U?/* @__PURE__ */t(n,{children:U}):/* @__PURE__ */t("div",{dangerouslySetInnerHTML:{__html:q}}):Z})}const Dt=(()=>{try{return Boolean(!1)}catch{}return!1})();function $t(e){Dt&&console.warn(e)}function Pt(e,t,n=!1){const r=Object.entries(null!=t?t:{}),o=r.length>0?r.map(([e,t])=>""===t?` ${e}`:` ${e}="${t}"`).join(""):"";return n?`<${e}${o} />`:`<${e}${o}>`}function At(e,t){Array.isArray(t)?e.push(...t):null!=t&&e.push(t)}function Rt(e,t,n,o,i,l){const a=O(e,o);if(w.has(e.toLowerCase())||!a&&v(e,l))return null;if(!a&&f(e,l))return[Pt(e,t),...n,`</${e}>`];const c=z(t,l,e),s=c.key,d=null!=s&&""!==s?s:i;if(a){const t=o[e]||o[e.toLowerCase()],i=function(e){return y(e)}(c);return r.createElement(t,{...i,key:d},...n)}return r.createElement(e,{...I(c),key:d},...n)}function Ht(e){var n,o,l;const{node:c,customId:d}=e,u=null!=(l=null!=(o=e.htmlPolicy)?o:null==(n=e.ctx)?void 0:n.htmlPolicy)?l:"safe",m=a(null),[h,p]=i(!1);s(()=>{p(!0)},[]);const y=H(d),x=r.useMemo(()=>{var e;return g(null!=(e=c.content)?e:"",u)},[u,c.content]),k=r.useMemo(()=>{const e=c.content;if(!e)return{mode:"html",content:""};if("escape"===u)return{mode:"html",content:e};if(!_(e,y))return{mode:"html",content:e};const t=function(e,t,n="safe"){if(!e)return[];try{const r=function(e,t,n="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=O(l.tagName,t);if(w.has(l.tagName.toLowerCase())||!e&&v(l.tagName,n))continue;if(!e&&f(l.tagName,n)){(o.length>0?o[o.length-1].children:i).push(Pt(l.tagName,l.attrs||{},!0));continue}const a=Rt(l.tagName,l.attrs||{},[],t,"ms-html-"+r++,n);At(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=O(l.tagName,t);o.push({tagName:l.tagName,children:[],attrs:l.attrs,customComponent:r,hardBlocked:e||w.has(l.tagName.toLowerCase())||!r&&v(l.tagName,n),softBlocked:!e&&!r&&f(l.tagName,n)})}else if("tag_close"===l.type){const e=l.tagName.toLowerCase();let a=-1;for(let t=o.length-1;t>=0;t--)if(o[t].tagName.toLowerCase()===e){a=t;break}if(-1!==a)for(;o.length>a;){const l=o.pop();let c;c=l.hardBlocked?null:l.softBlocked?[Pt(l.tagName,l.attrs||{}),...l.children,`</${l.tagName}>`]:Rt(l.tagName,l.attrs||{},l.children,t,"ms-html-"+r++,n),o.length>0?At(o[o.length-1].children,c):At(i,c),l.tagName.toLowerCase()!==e&&o.length>a&&$t(`Auto-closing unclosed tag: <${l.tagName}>`)}else $t(`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?[Pt(e.tagName,e.attrs||{}),...e.children,`</${e.tagName}>`]:Rt(e.tagName,e.attrs||{},e.children,t,"ms-html-"+r++,n),At(i,l),$t(`Auto-closing unclosed tag: <${e.tagName}>`)}return i}(j(e),t,n);return r}catch(o){return r=o,Dt&&console.error("Failed to parse HTML to React nodes:",r),null}var r}(e,y,u);return null===t?{mode:"html",content:e}:{mode:"dynamic",nodes:t}},[y,u,c.content]);return s(()=>{if(!h||!m.current||"html"!==k.mode)return;const e=m.current;e.innerHTML="";const t=document.createElement("template");t.innerHTML=x,e.appendChild(t.content.cloneNode(!0))},[k.mode,h,x]),c.loading&&!c.autoClosed?/* @__PURE__ */t("span",{className:"html-inline-node html-inline-node--loading",children:c.content}):"dynamic"===k.mode?/* @__PURE__ */t("span",{className:"html-inline-node",style:{display:"inline"},children:k.nodes}):/* @__PURE__ */t("span",{ref:m,className:"html-inline-node",style:{display:"inline"}})}const Wt={fallbackSrc:"",lazy:!0,usePlaceholder:!0};function It(r){var o,l,a,c,d,u;const m={...Wt,...r},[h,p]=i(!1),[f,g]=i(!1),[w,v]=i(!1),y=f&&m.fallbackSrc?m.fallbackSrc:m.node.src;s(()=>{p(!1),g(!1)},[y]),s(()=>{v(!1)},[m.node.src]);return m.node.loading||f?f?m.node.loading||m.fallbackSrc?null:/* @__PURE__ */e("span",{className:"image-node__error",children:[
57
57
  /* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24","aria-hidden":"true",children:/* @__PURE__ */t("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"})}),
58
58
  /* @__PURE__ */t("span",{className:"image-node__placeholder-text",children:"Image failed to load"})]}):/* @__PURE__ */t("span",{className:"image-node__placeholder",children:m.usePlaceholder?/* @__PURE__ */e(n,{children:[
59
59
  /* @__PURE__ */t("span",{className:"image-node__spinner","aria-hidden":"true"}),
60
- /* @__PURE__ */t("span",{className:"image-node__placeholder-text",children:"Loading image..."})]}):/* @__PURE__ */t("span",{className:"image-node__placeholder-text",children:null!=(u=m.node.raw)?u:"Loading image…"})},"placeholder"):/* @__PURE__ */t("img",{src:y,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"+(h?" is-loaded":""),loading:m.lazy?"lazy":"eager",decoding:"async",tabIndex:h?0:-1,"aria-label":null!=(d=m.node.alt)?d:"Preview image",onError:()=>{var e;m.fallbackSrc&&!w?(v(!0),g(!0)):(g(!0),null==(e=m.onError)||e.call(m,m.node.src))},onLoad:()=>{var e;p(!0),g(!1),null==(e=m.onLoad)||e.call(m,y)},onClick:e=>{var t;e.preventDefault(),h&&!f&&(null==(t=m.onClick)||t.call(m,[e,y]))}},"image")}let Wt=null,It=null;const _t=/* @__PURE__ */t("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:[
60
+ /* @__PURE__ */t("span",{className:"image-node__placeholder-text",children:"Loading image..."})]}):/* @__PURE__ */t("span",{className:"image-node__placeholder-text",children:null!=(u=m.node.raw)?u:"Loading image…"})},"placeholder"):/* @__PURE__ */t("img",{src:y,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"+(h?" is-loaded":""),loading:m.lazy?"lazy":"eager",decoding:"async",tabIndex:h?0:-1,"aria-label":null!=(d=m.node.alt)?d:"Preview image",onError:()=>{var e;m.fallbackSrc&&!w?(v(!0),g(!0)):(g(!0),null==(e=m.onError)||e.call(m,m.node.src))},onLoad:()=>{var e;p(!0),g(!1),null==(e=m.onLoad)||e.call(m,y)},onClick:e=>{var t;e.preventDefault(),h&&!f&&(null==(t=m.onClick)||t.call(m,[e,y]))}},"image")}let _t=null,Ft=null;const jt=/* @__PURE__ */t("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:[
61
61
  /* @__PURE__ */t("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"}),
62
62
  /* @__PURE__ */t("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"}),
63
63
  /* @__PURE__ */t("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"}),
64
64
  /* @__PURE__ */t("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"}),
65
- /* @__PURE__ */t("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"})]})}),Ft={maxHeight:"500px",loading:!0,showHeader:!0,showCopyButton:!0,showCollapseButton:!0,showModeToggle:!0,showExportButton:!0,showFullscreenButton:!0,showZoomControls:!0};function jt(r){var l;const c={...Ft,...r},{t:u}=ge(),[m,h]=i(!1),[p,f]=i(!1),[g,w]=i(!1),[v,y]=i(!1),[x,k]=i(()=>"undefined"==typeof window),b=c.node.code,C=o(()=>c.maxHeight&&"none"!==c.maxHeight?V(c.maxHeight):null,[c.maxHeight]),M=o(()=>{var e;return K(null!=(e=V(c.estimatedPreviewHeightPx))?e:X(b),void 0,C)},[b,C,c.estimatedPreviewHeightPx]),[N,B]=i(`${M}px`),[L,T]=i(!1),[E,S]=i(1),[D,$]=i({x:0,y:0}),[P,A]=i(!1),R=a(null),H=a(null),W=a(null),I=a(null),_=a(null),F=a({x:0,y:0}),j=a(null),O=me(),z=d(e=>{if(!c.maxHeight||"none"===c.maxHeight)return`${Math.max(e,M)}px`;const t=Number.parseFloat(String(c.maxHeight));return Number.isFinite(t)?`${Math.max(Math.min(e,t),M)}px`:`${Math.max(e,M)}px`},[M,c.maxHeight]),U=d(()=>{const e=R.current;if(!e)return;const t=e.scrollHeight;t>0&&B(z(t))},[z]);s(()=>{g||p||B(e=>{const t=V(e);return null!=t&&t>=M?e:`${M}px`})},[M,p,g]);const q=d(async()=>{var e,t;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(b)),h(!0),null==(t=c.onCopy)||t.call(c,b),setTimeout(()=>h(!1),1e3)}catch{}},[b,c]),Y=d(async()=>{var e,t;if(!x)return;if(!R.current)return;const n=R.current;try{const r=await async function(){return It||Wt||(Wt=import("@antv/infographic").then(e=>{const t=e&&e.default?e.default:e;let n=t;return"function"==typeof t&&t.prototype&&t.prototype.render?n=t:e.Infographic?n=e.Infographic:t&&t.Infographic&&(n=t.Infographic),It=n,n}).catch(e=>(console.warn("Failed to load @antv/infographic",e),null)),Wt)}();if(!r)return void console.warn("Infographic library failed to load.");j.current&&(null==(t=(e=j.current).destroy)||t.call(e),j.current=null),n.innerHTML="";const o=new r({container:n,width:"100%",height:"100%"});j.current=o,o.render(b),T(!0),setTimeout(()=>{U()},0)}catch(r){console.error("Failed to render infographic:",r),T(!1),n.innerHTML=`<div class="text-red-500 p-4">Failed to render infographic: ${r instanceof Error?r.message:"Unknown error"}</div>`}},[b,U,x]);s(()=>{const e=H.current;if(!e)return;const t=O(e,{rootMargin:"160px"});return W.current=t,t.isVisible()&&k(!0),t.whenVisible.then(()=>k(!0)),()=>{t.destroy(),W.current=null}},[O]),s(()=>{!x||g||p||Y()},[b,p,Y,g,x]),s(()=>()=>{var e,t;j.current&&(null==(t=(e=j.current).destroy)||t.call(e),j.current=null)},[]);const Z=d(()=>{y(!1),I.current&&(I.current.innerHTML=""),_.current=null,document.body.style.overflow=""},[]),G=d(()=>{y(!0),document.body.style.overflow="hidden"},[]);s(()=>{if(!v)return;const e=e=>{"Escape"===e.key&&Z()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[v,Z]),s(()=>{v&&setTimeout(()=>{if(R.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 t=R.current.cloneNode(!0);t.classList.add("fullscreen"),t.style.height="auto",e.appendChild(t),I.current.appendChild(e),_.current=e,e.style.transform=`translate(${D.x}px, ${D.y}px) scale(${E})`}},0)},[v]),s(()=>{v&&_.current&&(_.current.style.transform=`translate(${D.x}px, ${D.y}px) scale(${E})`)},[v,D,E]);const J=d(()=>{var e;const t=null==(e=R.current)?void 0:e.querySelector("svg");if(!t)return;const n=(new XMLSerializer).serializeToString(t),r=new Blob([n],{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=>{A(!0);const t="touches"in e?e.touches[0].clientX:e.clientX,n="touches"in e?e.touches[0].clientY:e.clientY;F.current={x:t-D.x,y:n-D.y}},te=e=>{if(!P)return;const t="touches"in e?e.touches[0].clientX:e.clientX,n="touches"in e?e.touches[0].clientY:e.clientY;$({x:t-F.current.x,y:n-F.current.y})},ne=()=>A(!1),re=c.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",oe=g||p;/* @__PURE__ */
65
+ /* @__PURE__ */t("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"})]})}),Ot={maxHeight:"500px",loading:!0,showHeader:!0,showCopyButton:!0,showCollapseButton:!0,showModeToggle:!0,showExportButton:!0,showFullscreenButton:!0,showZoomControls:!0};function zt(r){var l;const c={...Ot,...r},{t:u}=ge(),[m,h]=i(!1),[p,f]=i(!1),[g,w]=i(!1),[v,y]=i(!1),[x,k]=i(()=>"undefined"==typeof window),b=c.node.code,C=o(()=>c.maxHeight&&"none"!==c.maxHeight?V(c.maxHeight):null,[c.maxHeight]),M=o(()=>{var e;return K(null!=(e=V(c.estimatedPreviewHeightPx))?e:X(b),void 0,C)},[b,C,c.estimatedPreviewHeightPx]),[N,B]=i(`${M}px`),[L,S]=i(!1),[T,E]=i(1),[D,$]=i({x:0,y:0}),[P,A]=i(!1),R=a(null),H=a(null),W=a(null),I=a(null),_=a(null),F=a({x:0,y:0}),j=a(null),O=me(),z=d(e=>{if(!c.maxHeight||"none"===c.maxHeight)return`${Math.max(e,M)}px`;const t=Number.parseFloat(String(c.maxHeight));return Number.isFinite(t)?`${Math.max(Math.min(e,t),M)}px`:`${Math.max(e,M)}px`},[M,c.maxHeight]),U=d(()=>{const e=R.current;if(!e)return;const t=e.scrollHeight;t>0&&B(z(t))},[z]);s(()=>{g||p||B(e=>{const t=V(e);return null!=t&&t>=M?e:`${M}px`})},[M,p,g]);const q=d(async()=>{var e,t;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(b)),h(!0),null==(t=c.onCopy)||t.call(c,b),setTimeout(()=>h(!1),1e3)}catch{}},[b,c]),Y=d(async()=>{var e,t;if(!x)return;if(!R.current)return;const n=R.current;try{const r=await async function(){return Ft||_t||(_t=import("@antv/infographic").then(e=>{const t=e&&e.default?e.default:e;let n=t;return"function"==typeof t&&t.prototype&&t.prototype.render?n=t:e.Infographic?n=e.Infographic:t&&t.Infographic&&(n=t.Infographic),Ft=n,n}).catch(e=>(console.warn("Failed to load @antv/infographic",e),null)),_t)}();if(!r)return void console.warn("Infographic library failed to load.");j.current&&(null==(t=(e=j.current).destroy)||t.call(e),j.current=null),n.innerHTML="";const o=new r({container:n,width:"100%",height:"100%"});j.current=o,o.render(b),S(!0),setTimeout(()=>{U()},0)}catch(r){console.error("Failed to render infographic:",r),S(!1),n.innerHTML=`<div class="text-red-500 p-4">Failed to render infographic: ${r instanceof Error?r.message:"Unknown error"}</div>`}},[b,U,x]);s(()=>{const e=H.current;if(!e)return;const t=O(e,{rootMargin:"160px"});return W.current=t,t.isVisible()&&k(!0),t.whenVisible.then(()=>k(!0)),()=>{t.destroy(),W.current=null}},[O]),s(()=>{!x||g||p||Y()},[b,p,Y,g,x]),s(()=>()=>{var e,t;j.current&&(null==(t=(e=j.current).destroy)||t.call(e),j.current=null)},[]);const Z=d(()=>{y(!1),I.current&&(I.current.innerHTML=""),_.current=null,document.body.style.overflow=""},[]),G=d(()=>{y(!0),document.body.style.overflow="hidden"},[]);s(()=>{if(!v)return;const e=e=>{"Escape"===e.key&&Z()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[v,Z]),s(()=>{v&&setTimeout(()=>{if(R.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 t=R.current.cloneNode(!0);t.classList.add("fullscreen"),t.style.height="auto",e.appendChild(t),I.current.appendChild(e),_.current=e,e.style.transform=`translate(${D.x}px, ${D.y}px) scale(${T})`}},0)},[v]),s(()=>{v&&_.current&&(_.current.style.transform=`translate(${D.x}px, ${D.y}px) scale(${T})`)},[v,D,T]);const J=d(()=>{var e;const t=null==(e=R.current)?void 0:e.querySelector("svg");if(!t)return;const n=(new XMLSerializer).serializeToString(t),r=new Blob([n],{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=>{A(!0);const t="touches"in e?e.touches[0].clientX:e.clientX,n="touches"in e?e.touches[0].clientY:e.clientY;F.current={x:t-D.x,y:n-D.y}},te=e=>{if(!P)return;const t="touches"in e?e.touches[0].clientX:e.clientX,n="touches"in e?e.touches[0].clientY:e.clientY;$({x:t-F.current.x,y:n-F.current.y})},ne=()=>A(!1),re=c.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",oe=g||p;/* @__PURE__ */
66
66
  return e(n,{children:[
67
- /* @__PURE__ */e("div",{ref:H,"data-markstream-infographic":"1","data-markstream-mode":g?"source":L?"preview":"pending",className:ot("my-4 rounded-lg border overflow-hidden shadow-sm",c.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":c.loading}),children:[c.showHeader&&/* @__PURE__ */e("div",{className:ot("flex justify-between items-center px-4 py-2.5 border-b",c.isDark?"bg-gray-800 border-gray-700/30":"bg-gray-50 border-gray-200"),children:[
68
- /* @__PURE__ */e("div",{className:"flex items-center gap-x-2 overflow-hidden",children:[_t,
69
- /* @__PURE__ */t("span",{className:ot("text-sm font-medium font-mono truncate",c.isDark?"text-gray-400":"text-gray-600"),children:"Infographic"})]}),c.showModeToggle&&/* @__PURE__ */e("div",{className:ot("flex items-center gap-x-1 rounded-md p-0.5",c.isDark?"bg-gray-700":"bg-gray-100"),children:[
70
- /* @__PURE__ */t("button",{className:ot("px-2.5 py-1 text-xs rounded transition-colors",g?c.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700":c.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm"),onClick:()=>w(!1),onMouseEnter:e=>Ne(e.currentTarget,u("common.preview")||"Preview","top",!1,0,c.isDark),onMouseLeave:()=>Be(),children:/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
67
+ /* @__PURE__ */e("div",{ref:H,"data-markstream-infographic":"1","data-markstream-mode":g?"source":L?"preview":"pending",className:lt("my-4 rounded-lg border overflow-hidden shadow-sm",c.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":c.loading}),children:[c.showHeader&&/* @__PURE__ */e("div",{className:lt("flex justify-between items-center px-4 py-2.5 border-b",c.isDark?"bg-gray-800 border-gray-700/30":"bg-gray-50 border-gray-200"),children:[
68
+ /* @__PURE__ */e("div",{className:"flex items-center gap-x-2 overflow-hidden",children:[jt,
69
+ /* @__PURE__ */t("span",{className:lt("text-sm font-medium font-mono truncate",c.isDark?"text-gray-400":"text-gray-600"),children:"Infographic"})]}),c.showModeToggle&&/* @__PURE__ */e("div",{className:lt("flex items-center gap-x-1 rounded-md p-0.5",c.isDark?"bg-gray-700":"bg-gray-100"),children:[
70
+ /* @__PURE__ */t("button",{className:lt("px-2.5 py-1 text-xs rounded transition-colors",g?c.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700":c.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm"),onClick:()=>w(!1),onMouseEnter:e=>Ne(e.currentTarget,u("common.preview")||"Preview","top",!1,0,c.isDark),onMouseLeave:()=>Be(),children:/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
71
71
  /* @__PURE__ */t("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:[
72
72
  /* @__PURE__ */t("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"}),
73
73
  /* @__PURE__ */t("circle",{cx:"12",cy:"12",r:"3"})]})}),
74
74
  /* @__PURE__ */t("span",{children:u("common.preview")||"Preview"})]})}),
75
- /* @__PURE__ */t("button",{className:ot("px-2.5 py-1 text-xs rounded transition-colors",g?c.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm":c.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),onClick:()=>w(!0),onMouseEnter:e=>Ne(e.currentTarget,u("common.source")||"Source","top",!1,0,c.isDark),onMouseLeave:()=>Be(),children:/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
75
+ /* @__PURE__ */t("button",{className:lt("px-2.5 py-1 text-xs rounded transition-colors",g?c.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm":c.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),onClick:()=>w(!0),onMouseEnter:e=>Ne(e.currentTarget,u("common.source")||"Source","top",!1,0,c.isDark),onMouseLeave:()=>Be(),children:/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
76
76
  /* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m16 18l6-6l-6-6M8 6l-6 6l6 6"})}),
77
77
  /* @__PURE__ */t("span",{children:u("common.source")||"Source"})]})})]}),
78
78
  /* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[c.showCollapseButton&&/* @__PURE__ */t("button",{className:re,onClick:()=>f(!p),onMouseEnter:e=>Ne(e.currentTarget,p?u("common.expand")||"Expand":u("common.collapse")||"Collapse","top",!1,0,c.isDark),onMouseLeave:()=>Be(),children:/* @__PURE__ */t("svg",{style:{rotate:p?"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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),c.showCopyButton&&/* @__PURE__ */t("button",{className:re,onClick:q,onMouseEnter:e=>Ne(e.currentTarget,m?u("common.copied")||"Copied":u("common.copy")||"Copy","top",!1,0,c.isDark),onMouseLeave:()=>Be(),children:/* @__PURE__ */t("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__ */t("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:[
79
79
  /* @__PURE__ */t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
80
- /* @__PURE__ */t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),c.showExportButton&&/* @__PURE__ */t("button",{className:ot(re,oe&&"opacity-50 cursor-not-allowed"),disabled:oe,onClick:J,onMouseEnter:e=>Ne(e.currentTarget,u("common.export")||"Export","top",!1,0,c.isDark),onMouseLeave:()=>Be(),children:/* @__PURE__ */t("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:[
80
+ /* @__PURE__ */t("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),c.showExportButton&&/* @__PURE__ */t("button",{className:lt(re,oe&&"opacity-50 cursor-not-allowed"),disabled:oe,onClick:J,onMouseEnter:e=>Ne(e.currentTarget,u("common.export")||"Export","top",!1,0,c.isDark),onMouseLeave:()=>Be(),children:/* @__PURE__ */t("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:[
81
81
  /* @__PURE__ */t("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),
82
- /* @__PURE__ */t("path",{d:"m7 10l5 5l5-5"})]})})}),c.showFullscreenButton&&/* @__PURE__ */t("button",{className:ot(re,oe&&"opacity-50 cursor-not-allowed"),disabled:oe,onClick:G,onMouseEnter:e=>Ne(e.currentTarget,v?u("common.minimize")||"Minimize":u("common.open")||"Open","top",!1,0,c.isDark),onMouseLeave:()=>Be(),children:/* @__PURE__ */t("svg",v?{xmlns:"http://www.w3.org/2000/svg",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24",children:/* @__PURE__ */t("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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})})]})]}),!p&&/* @__PURE__ */t("div",{children:g?/* @__PURE__ */t("div",{className:ot("p-4",c.isDark?"bg-gray-900":"bg-gray-50"),children:/* @__PURE__ */t("pre",{className:ot("text-sm font-mono whitespace-pre-wrap",c.isDark?"text-gray-300":"text-gray-700"),children:b})}):/* @__PURE__ */e("div",{className:"relative",children:[c.showZoomControls&&/* @__PURE__ */t("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:[
83
- /* @__PURE__ */t("button",{className:ot("p-2 text-xs rounded transition-colors",c.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>S(Math.min(E+.1,3)),children:"+"}),
84
- /* @__PURE__ */t("button",{className:ot("p-2 text-xs rounded transition-colors",c.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>S(Math.max(E-.1,.5)),children:"-"}),
85
- /* @__PURE__ */e("button",{className:ot("p-2 text-xs rounded transition-colors",c.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{S(1),$({x:0,y:0})},children:[Math.round(100*E),"%"]})]})}),
86
- /* @__PURE__ */t("div",{className:ot("infographic-preview min-h-[360px] relative transition-all duration-100 overflow-hidden block",c.isDark?"bg-gray-900":"bg-gray-50"),style:{height:N,maxHeight:null!=(l=c.maxHeight)?l:void 0},onMouseDown:Q,onMouseMove:te,onMouseUp:ne,onMouseLeave:ne,onTouchStart:Q,onTouchMove:te,onTouchEnd:ne,children:/* @__PURE__ */t("div",{className:ot("absolute inset-0 cursor-grab",P&&"cursor-grabbing"),style:{transform:`translate(${D.x}px, ${D.y}px) scale(${E})`},children:/* @__PURE__ */t("div",{ref:R,className:"w-full text-center flex items-center justify-center min-h-full"})})})]})})]}),v&&"undefined"!=typeof document&&ee(
87
- /* @__PURE__ */t("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:ot("dialog-panel relative w-full h-full max-w-full max-h-full rounded shadow-lg overflow-hidden",c.isDark?"bg-gray-900":"bg-white"),onClick:e=>e.stopPropagation(),children:[
82
+ /* @__PURE__ */t("path",{d:"m7 10l5 5l5-5"})]})})}),c.showFullscreenButton&&/* @__PURE__ */t("button",{className:lt(re,oe&&"opacity-50 cursor-not-allowed"),disabled:oe,onClick:G,onMouseEnter:e=>Ne(e.currentTarget,v?u("common.minimize")||"Minimize":u("common.open")||"Open","top",!1,0,c.isDark),onMouseLeave:()=>Be(),children:/* @__PURE__ */t("svg",v?{xmlns:"http://www.w3.org/2000/svg",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24",children:/* @__PURE__ */t("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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})})]})]}),!p&&/* @__PURE__ */t("div",{children:g?/* @__PURE__ */t("div",{className:lt("p-4",c.isDark?"bg-gray-900":"bg-gray-50"),children:/* @__PURE__ */t("pre",{className:lt("text-sm font-mono whitespace-pre-wrap",c.isDark?"text-gray-300":"text-gray-700"),children:b})}):/* @__PURE__ */e("div",{className:"relative",children:[c.showZoomControls&&/* @__PURE__ */t("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:[
83
+ /* @__PURE__ */t("button",{className:lt("p-2 text-xs rounded transition-colors",c.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.min(T+.1,3)),children:"+"}),
84
+ /* @__PURE__ */t("button",{className:lt("p-2 text-xs rounded transition-colors",c.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.max(T-.1,.5)),children:"-"}),
85
+ /* @__PURE__ */e("button",{className:lt("p-2 text-xs rounded transition-colors",c.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*T),"%"]})]})}),
86
+ /* @__PURE__ */t("div",{className:lt("infographic-preview min-h-[360px] relative transition-all duration-100 overflow-hidden block",c.isDark?"bg-gray-900":"bg-gray-50"),style:{height:N,maxHeight:null!=(l=c.maxHeight)?l:void 0},onMouseDown:Q,onMouseMove:te,onMouseUp:ne,onMouseLeave:ne,onTouchStart:Q,onTouchMove:te,onTouchEnd:ne,children:/* @__PURE__ */t("div",{className:lt("absolute inset-0 cursor-grab",P&&"cursor-grabbing"),style:{transform:`translate(${D.x}px, ${D.y}px) scale(${T})`},children:/* @__PURE__ */t("div",{ref:R,className:"w-full text-center flex items-center justify-center min-h-full"})})})]})})]}),v&&"undefined"!=typeof document&&ee(
87
+ /* @__PURE__ */t("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:lt("dialog-panel relative w-full h-full max-w-full max-h-full rounded shadow-lg overflow-hidden",c.isDark?"bg-gray-900":"bg-white"),onClick:e=>e.stopPropagation(),children:[
88
88
  /* @__PURE__ */e("div",{className:"absolute top-6 right-6 z-50 flex items-center gap-2",children:[
89
- /* @__PURE__ */t("button",{className:ot("p-2 text-xs rounded transition-colors",c.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>S(Math.min(E+.1,3)),children:"+"}),
90
- /* @__PURE__ */t("button",{className:ot("p-2 text-xs rounded transition-colors",c.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>S(Math.max(E-.1,.5)),children:"-"}),
91
- /* @__PURE__ */e("button",{className:ot("p-2 text-xs rounded transition-colors",c.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{S(1),$({x:0,y:0})},children:[Math.round(100*E),"%"]}),
92
- /* @__PURE__ */t("button",{className:ot("inline-flex items-center justify-center p-2 rounded transition-colors",c.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:Z,children:"X"})]}),
93
- /* @__PURE__ */t("div",{ref:I,className:ot("w-full h-full flex items-center justify-center p-4 overflow-hidden",!P&&"cursor-grab",P&&"cursor-grabbing"),onMouseDown:Q,onMouseMove:te,onMouseUp:ne,onMouseLeave:ne,onTouchStart:Q,onTouchMove:te,onTouchEnd:ne})]})}),document.body)]})}function Ot({nextContent:e,persistedContent:t,currentState:n,typewriterEnabled:r,streamRenderVersionChanged:o=!1}){const i=`${n.settledContent}${n.streamedDelta}`;return r?n.streamedDelta&&i===e?o?{settledContent:i,streamedDelta:"",appended:!1}:{settledContent:n.settledContent,streamedDelta:n.streamedDelta,appended:!1}:function({nextContent:e,previousContent:t,typewriterEnabled:n}){return n?e===t?{settledContent:e,streamedDelta:"",appended:!1}:t&&e.startsWith(t)&&e.length>t.length?{settledContent:t,streamedDelta:e.slice(t.length),appended:!0}:{settledContent:e,streamedDelta:"",appended:!1}:{settledContent:e,streamedDelta:"",appended:!1}}({nextContent:e,previousContent:null!=t?t:i,typewriterEnabled:r}):{settledContent:e,streamedDelta:"",appended:!1}}function zt(r){var o,l;const{node:c,children:d,ctx:u,indexKey:m,typewriter:h}=r,p=String(null!=(o=c.code)?o:""),f=null==(l=null!=h?h:null==u?void 0:u.typewriter)||l,g=null==m||""===m?"":String(m),[w,v]=i(p),[y,x]=i(""),[k,b]=i(0),C=a({settledContent:p,streamedDelta:""}),M=(e,t)=>{C.current={settledContent:e,streamedDelta:t},v(e),x(t)};return s(()=>{if(null!=d)return void M("","");const e=null==u?void 0:u.textStreamState,t=C.current,n=g?null==e?void 0:e.get(g):void 0,r=Ot({nextContent:p,persistedContent:n,currentState:t,typewriterEnabled:f});M(r.settledContent,r.streamedDelta),r.appended&&b(e=>e+1),g&&(null==e||e.set(g,p))},[d,p,null==u?void 0:u.textStreamState,g,f]),/* @__PURE__ */t("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(n,{children:[w?/* @__PURE__ */t("span",{children:w}):null,y?/* @__PURE__ */t("span",{className:ot("text-node-stream-delta",k%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"),onAnimationEnd:()=>{C.current.streamedDelta&&M((()=>{const{settledContent:e,streamedDelta:t}=C.current;return e+t})(),"")},children:y}):null]})})}function Vt(e){/* @__PURE__ */
94
- return t("ins",{className:"insert-node",children:e.children})}function Kt(n){var r,o;const{node:l,children:c,ctx:d,indexKey:u,typewriter:m}=n,h=String(null!=(r=l.content)?r:""),p=null==(o=null!=m?m:null==d?void 0:d.typewriter)||o,f=null==u||""===u?"":String(u),[g,w]=i(h),[v,y]=i(""),[x,k]=i(0),b=a(null==d?void 0:d.streamRenderVersion),C=a({settledContent:h,streamedDelta:""}),M=(e,t)=>{C.current={settledContent:e,streamedDelta:t},w(e),y(t)};return s(()=>{const e=null==d?void 0:d.streamRenderVersion,t=e!==b.current;if(null!=c)return M("",""),void(b.current=e);const n=null==d?void 0:d.textStreamState,r=C.current,o=f?null==n?void 0:n.get(f):void 0,i=Ot({nextContent:h,persistedContent:o,currentState:r,typewriterEnabled:p,streamRenderVersionChanged:t});M(i.settledContent,i.streamedDelta),i.appended&&k(e=>e+1),f&&(null==n||n.set(f,h)),b.current=e},[c,h,null==d?void 0:d.textStreamState,null==d?void 0:d.streamRenderVersion,f,p]),null!=c?/* @__PURE__ */t("span",{className:ot("text-node whitespace-pre-wrap break-words",l.center&&"text-node-center"),children:c}):/* @__PURE__ */e("span",{className:ot("text-node whitespace-pre-wrap break-words",l.center&&"text-node-center"),children:[g?/* @__PURE__ */t("span",{children:g}):null,v?/* @__PURE__ */t("span",{className:ot("text-node-stream-delta",x%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"),onAnimationEnd:()=>{C.current.streamedDelta&&M((()=>{const{settledContent:e,streamedDelta:t}=C.current;return e+t})(),"")},children:v}):null]})}function Xt(n){var r,i,l;const{node:a,ctx:c,renderNode:s,indexKey:u}=n,m=!1!==n.showTooltip,h=null!=(r=n.isDark)?r:null==c?void 0:c.isDark,p=o(()=>{var e,t,r,o,i,l;const a=void 0!==n.underlineBottom?"number"==typeof n.underlineBottom?`${n.underlineBottom}px`:String(n.underlineBottom):"-3px",c=null!=(e=n.animationOpacity)?e:.35,s=Math.max(.12,Math.min(.5*c,c));return{"--link-color":null!=(t=n.color)?t:"#0366d6","--underline-height":`${null!=(r=n.underlineHeight)?r:2}px`,"--underline-bottom":a,"--underline-opacity":String(c),"--underline-rest-opacity":String(s),"--underline-duration":`${null!=(o=n.animationDuration)?o:1.6}s`,"--underline-timing":null!=(i=n.animationTiming)?i:"ease-in-out","--underline-iteration":"number"==typeof n.animationIteration?String(n.animationIteration):null!=(l=n.animationIteration)?l:"infinite"}},[n.animationDuration,n.animationIteration,n.animationOpacity,n.animationTiming,n.color,n.underlineBottom,n.underlineHeight]),f=o(()=>{var e;return x({href:String(null!=(e=a.href)?e:"")}).href},[a.href]),g="string"==typeof a.title&&a.title.trim().length>0?a.title:String(null!=f?f:""),w=d(e=>{m&&Ne(e.currentTarget,String(a.title||f||a.text||""),"top",!1,(e.clientX,e.clientY),h)},[h,a.text,a.title,f,m]),v=d(()=>{m&&Be()},[m]);return a.loading?/* @__PURE__ */t("span",{className:"link-loading inline-flex items-baseline gap-1.5","aria-hidden":"false",style:p,children:/* @__PURE__ */e("span",{className:"link-text-wrapper relative inline-flex",children:[
95
- /* @__PURE__ */t("span",{className:"leading-[normal] link-text",children:/* @__PURE__ */t(Kt,{node:{type:"text",content:String(null!=(i=a.text)?i:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-loading`,typewriter:n.typewriter})}),
96
- /* @__PURE__ */t("span",{className:"link-loading-indicator","aria-hidden":"true"})]})}):/* @__PURE__ */t("a",{className:"link-node",href:f,title:m?"":g,"aria-label":`Link: ${g}`,target:"_blank",rel:"noopener noreferrer",style:p,onMouseEnter:w,onMouseLeave:v,children:c&&s?L(a.children,c,String(null!=u?u:"link"),s):/* @__PURE__ */t(Kt,{node:{type:"text",content:String(null!=(l=a.text)?l:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-fallback`,typewriter:n.typewriter})})}function Ut(e){const{node:n,ctx:r,renderNode:o,value:i,indexKey:l,children:a}=e;/* @__PURE__ */
97
- return t("li",{className:"list-item pl-1.5 my-2",dir:"auto",value:null==i?void 0:i,children:null!=a?a:r&&o?L(n.children,r,String(null!=l?l:"list-item"),o):null})}function qt(e){var n;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&&H(o.customId).list_item||Ut;/* @__PURE__ */
98
- return t(a,{className:ot("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==(n=r.items)?void 0:n.map((e,n)=>{var a;/* @__PURE__ */
99
- return t(s,{node:e,value:r.ordered?(null!=(a=r.start)?a:1)+n:void 0,ctx:o,renderNode:i,indexKey:`${String(null!=l?l:"list")}-${n}`,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")}-${n}`)})})}let Yt=null,Zt=null,Gt=!1;const Jt=/* @__PURE__ */new Map,Qt=/* @__PURE__ */new Map;let en=5;const tn=/* @__PURE__ */new Set;function nn(){if(Jt.size<en&&tn.size){const e=Array.from(tn);tn.clear();for(const t of e)try{t()}catch{}}}function rn(e){Yt=e,Zt=null,Yt.onmessage=e=>{const{id:t,html:n,error:r}=e.data,o=Jt.get(t);if(o)if(Jt.delete(t),clearTimeout(o.timeoutId),nn(),r)o.reject(new Error(r));else{const{content:t,displayMode:r}=e.data;if(t){const e=`${r?"d":"i"}:${t}`;if(Qt.set(e,n),Qt.size>200){const e=Qt.keys().next().value;Qt.delete(e)}}o.resolve(n)}},Yt.onerror=e=>{console.error("[katexWorkerClient] Worker error:",e);for(const[t,n]of Jt.entries())clearTimeout(n.timeoutId),n.reject(new Error(`Worker error: ${e.message}`));Jt.clear(),nn()}}function on(){var e;Yt&&(null==(e=Yt.terminate)||e.call(Yt)),Yt=null,Zt=null}function ln(e){Gt=!!e,Yt&&Yt.postMessage({type:"init",debug:Gt})}const an="WORKER_BUSY";async function cn(e,t=!0,n=2e3,r){performance.now();const o=U(e);if(Zt)return Promise.reject(Zt);const i=`${t?"d":"i"}:${o}`,l=Qt.get(i);if(l)return Promise.resolve(l);const a=Yt||(Zt=new Error("[katexWorkerClient] No worker instance set. Please inject a Worker via setKaTeXWorker()."),Zt.name="WORKER_INIT_ERROR",Zt.code="WORKER_INIT_ERROR",null);if(!a)return Promise.reject(Zt);if(Jt.size>=en){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=an,e.busy=!0,e.inFlight=Jt.size,e.max=en,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(()=>{Jt.delete(l);const e=new Error("Worker render timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT",i(e),nn()},n),s=()=>{},d=()=>{Jt.delete(l),clearTimeout(c),tn.delete(s);const e=new Error("Aborted");e.name="AbortError",i(e),nn()};r&&r.addEventListener("abort",d,{once:!0}),Jt.set(l,{resolve:t=>{r&&r.removeEventListener("abort",d),e(t)},reject:e=>{r&&r.removeEventListener("abort",d),i(e)},timeoutId:c});try{a.postMessage({id:l,content:o,displayMode:t,debug:Gt})}catch(u){Jt.delete(l),clearTimeout(c),r&&r.removeEventListener("abort",d),i(u),nn()}})}function sn(e,t,n){const r=`${t?"d":"i"}:${U(e)}`;if(Qt.set(r,n),Qt.size>200){const e=Qt.keys().next().value;Qt.delete(e)}}function dn(){Qt.clear()}function un(e){en=Math.max(1,Math.floor(e)),nn()}function mn(e=1500,t){return Jt.size<en?Promise.resolve():new Promise((n,r)=>{if(null==t?void 0:t.aborted){const e=new Error("Aborted");return e.name="AbortError",void r(e)}let o=null;function i(){tn.delete(l),null!=o&&clearTimeout(o),t&&t.removeEventListener("abort",a)}function l(){i(),n()}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,t&&t.addEventListener("abort",a,{once:!0}),tn.add(l)})}const hn={timeout:2e3,waitTimeout:1500,backoffMs:30,maxRetries:1};function pn(e){null!=e.timeout&&(hn.timeout=Math.max(0,Math.floor(e.timeout))),null!=e.waitTimeout&&(hn.waitTimeout=Math.max(0,Math.floor(e.waitTimeout))),null!=e.backoffMs&&(hn.backoffMs=Math.max(0,Math.floor(e.backoffMs))),null!=e.maxRetries&&(hn.maxRetries=Math.max(0,Math.floor(e.maxRetries)))}function fn(){return{...hn}}async function gn(e,t=!0,n={}){var r,o,i,l;const a=null!=(r=n.timeout)?r:hn.timeout,c=null!=(o=n.waitTimeout)?o:hn.waitTimeout,s=null!=(i=n.backoffMs)?i:hn.backoffMs,d=null!=(l=n.maxRetries)?l:hn.maxRetries,u=Number.isFinite(d)?Math.max(0,Math.min(Math.floor(d),8)):hn.maxRetries,m=n.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 cn(e,t,a,m)}catch(p){if((null==p?void 0:p.code)!==an||h>=u)throw p;if(h++,await mn(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 wn=null,vn=!1;async function yn(){if(wn)return wn;if(vn)return null;try{return wn=await import("katex"),await import("katex/contrib/mhchem"),wn}catch{return vn=!0,null}}function xn({node:e}){const n=a(null),r=a(null),o=a(null),l=me(),[c,d]=i(!0),[u,m]=i(()=>"undefined"==typeof window),h=a(0);return s(()=>{const e=n.current;if(!e)return;const t=l(e,{rootMargin:"400px"});return o.current=t,t.isVisible()&&m(!0),t.whenVisible.then(()=>m(!0)),()=>{t.destroy(),o.current=null}},[l]),s(()=>{var t;const n=U(null!=(t=e.content)?t:"");if(!n)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 gn(n,!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 t=>{if(o||l!==h.current)return;if(!r.current)return;const i=(null==t?void 0:t.code)||(null==t?void 0:t.name);if("WORKER_INIT_ERROR"===i||(null==t?void 0:t.fallbackToRenderer)||i===an||"WORKER_TIMEOUT"===i){const t=await yn();if(t)try{const i=t.renderToString(n,{throwOnError:e.loading,displayMode:!0});return void(!o&&l===h.current&&r.current&&(r.current.innerHTML=i,d(!1),sn(n,!0,i)))}catch{}}e.loading||(r.current.textContent=e.raw,d(!1))}),()=>{o=!0,i.abort()}},[e.content,e.loading,e.raw,u]),/* @__PURE__ */t("div",{ref:n,className:"math-block text-center overflow-x-auto relative min-h-[40px]",children:/* @__PURE__ */t("div",{ref:r,className:c?"math-rendering":void 0})})}function kn({node:n}){const r=a(null),o=a(null),l=a(null),c=me(),[d,u]=i(!0),[m,h]=i(()=>"undefined"==typeof window),p=a(0);return s(()=>{const e=r.current;if(!e)return;const t=c(e,{rootMargin:"400px"});return l.current=t,t.isVisible()&&h(!0),t.whenVisible.then(()=>h(!0)),()=>{t.destroy(),l.current=null}},[c]),s(()=>{var e;const t=U(null!=(e=n.content)?e:"");if(!t)return o.current&&(o.current.innerHTML=""),void u(!1);if(!m)return void u(!0);let r=!1;const i=new AbortController,l=++p.current,a="$$"===n.markup;return gn(t,a,{timeout:1500,waitTimeout:0,maxRetries:0,signal:i.signal}).then(e=>{r||l!==p.current||o.current&&(o.current.innerHTML=e,u(!1))}).catch(async e=>{if(r||l!==p.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===an||"WORKER_TIMEOUT"===i){const e=await yn();if(e)try{const i=e.renderToString(t,{throwOnError:n.loading,displayMode:a});return void(!r&&l===p.current&&o.current&&(o.current.innerHTML=i,u(!1),sn(t,a,i)))}catch{}}n.loading||(o.current.textContent=n.raw,u(!1))}),()=>{r=!0,i.abort()}},[n.content,n.loading,n.raw,n.markup,m]),/* @__PURE__ */e("span",{ref:r,className:"math-inline-wrapper",children:[
89
+ /* @__PURE__ */t("button",{className:lt("p-2 text-xs rounded transition-colors",c.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.min(T+.1,3)),children:"+"}),
90
+ /* @__PURE__ */t("button",{className:lt("p-2 text-xs rounded transition-colors",c.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.max(T-.1,.5)),children:"-"}),
91
+ /* @__PURE__ */e("button",{className:lt("p-2 text-xs rounded transition-colors",c.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*T),"%"]}),
92
+ /* @__PURE__ */t("button",{className:lt("inline-flex items-center justify-center p-2 rounded transition-colors",c.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:Z,children:"X"})]}),
93
+ /* @__PURE__ */t("div",{ref:I,className:lt("w-full h-full flex items-center justify-center p-4 overflow-hidden",!P&&"cursor-grab",P&&"cursor-grabbing"),onMouseDown:Q,onMouseMove:te,onMouseUp:ne,onMouseLeave:ne,onTouchStart:Q,onTouchMove:te,onTouchEnd:ne})]})}),document.body)]})}function Vt({nextContent:e,persistedContent:t,currentState:n,typewriterEnabled:r,streamRenderVersionChanged:o=!1}){const i=`${n.settledContent}${n.streamedDelta}`;return r?n.streamedDelta&&i===e?o?{settledContent:i,streamedDelta:"",appended:!1}:{settledContent:n.settledContent,streamedDelta:n.streamedDelta,appended:!1}:function({nextContent:e,previousContent:t,typewriterEnabled:n}){return n?e===t?{settledContent:e,streamedDelta:"",appended:!1}:t&&e.startsWith(t)&&e.length>t.length?{settledContent:t,streamedDelta:e.slice(t.length),appended:!0}:{settledContent:e,streamedDelta:"",appended:!1}:{settledContent:e,streamedDelta:"",appended:!1}}({nextContent:e,previousContent:null!=t?t:i,typewriterEnabled:r}):{settledContent:e,streamedDelta:"",appended:!1}}function Kt(r){var o,l;const{node:c,children:d,ctx:u,indexKey:m,typewriter:h}=r,p=String(null!=(o=c.code)?o:""),f=null==(l=null!=h?h:null==u?void 0:u.typewriter)||l,g=null==m||""===m?"":String(m),[w,v]=i(p),[y,x]=i(""),[k,b]=i(0),C=a({settledContent:p,streamedDelta:""}),M=(e,t)=>{C.current={settledContent:e,streamedDelta:t},v(e),x(t)};return s(()=>{if(null!=d)return void M("","");const e=null==u?void 0:u.textStreamState,t=C.current,n=g?null==e?void 0:e.get(g):void 0,r=Vt({nextContent:p,persistedContent:n,currentState:t,typewriterEnabled:f});M(r.settledContent,r.streamedDelta),r.appended&&b(e=>e+1),g&&(null==e||e.set(g,p))},[d,p,null==u?void 0:u.textStreamState,g,f]),/* @__PURE__ */t("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(n,{children:[w?/* @__PURE__ */t("span",{children:w}):null,y?/* @__PURE__ */t("span",{className:lt("text-node-stream-delta",k%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"),onAnimationEnd:()=>{C.current.streamedDelta&&M((()=>{const{settledContent:e,streamedDelta:t}=C.current;return e+t})(),"")},children:y}):null]})})}function Xt(e){/* @__PURE__ */
94
+ return t("ins",{className:"insert-node",children:e.children})}function Ut(n){var r,o;const{node:l,children:c,ctx:d,indexKey:u,typewriter:m}=n,h=String(null!=(r=l.content)?r:""),p=null==(o=null!=m?m:null==d?void 0:d.typewriter)||o,f=null==u||""===u?"":String(u),[g,w]=i(h),[v,y]=i(""),[x,k]=i(0),b=a(null==d?void 0:d.streamRenderVersion),C=a({settledContent:h,streamedDelta:""}),M=(e,t)=>{C.current={settledContent:e,streamedDelta:t},w(e),y(t)};return s(()=>{const e=null==d?void 0:d.streamRenderVersion,t=e!==b.current;if(null!=c)return M("",""),void(b.current=e);const n=null==d?void 0:d.textStreamState,r=C.current,o=f?null==n?void 0:n.get(f):void 0,i=Vt({nextContent:h,persistedContent:o,currentState:r,typewriterEnabled:p,streamRenderVersionChanged:t});M(i.settledContent,i.streamedDelta),i.appended&&k(e=>e+1),f&&(null==n||n.set(f,h)),b.current=e},[c,h,null==d?void 0:d.textStreamState,null==d?void 0:d.streamRenderVersion,f,p]),null!=c?/* @__PURE__ */t("span",{className:lt("text-node whitespace-pre-wrap break-words",l.center&&"text-node-center"),children:c}):/* @__PURE__ */e("span",{className:lt("text-node whitespace-pre-wrap break-words",l.center&&"text-node-center"),children:[g?/* @__PURE__ */t("span",{children:g}):null,v?/* @__PURE__ */t("span",{className:lt("text-node-stream-delta",x%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"),onAnimationEnd:()=>{C.current.streamedDelta&&M((()=>{const{settledContent:e,streamedDelta:t}=C.current;return e+t})(),"")},children:v}):null]})}function qt(n){var r,i,l;const{node:a,ctx:c,renderNode:s,indexKey:u}=n,m=!1!==n.showTooltip,h=null!=(r=n.isDark)?r:null==c?void 0:c.isDark,p=o(()=>{var e,t,r,o,i,l;const a=void 0!==n.underlineBottom?"number"==typeof n.underlineBottom?`${n.underlineBottom}px`:String(n.underlineBottom):"-3px",c=null!=(e=n.animationOpacity)?e:.35,s=Math.max(.12,Math.min(.5*c,c));return{"--link-color":null!=(t=n.color)?t:"#0366d6","--underline-height":`${null!=(r=n.underlineHeight)?r:2}px`,"--underline-bottom":a,"--underline-opacity":String(c),"--underline-rest-opacity":String(s),"--underline-duration":`${null!=(o=n.animationDuration)?o:1.6}s`,"--underline-timing":null!=(i=n.animationTiming)?i:"ease-in-out","--underline-iteration":"number"==typeof n.animationIteration?String(n.animationIteration):null!=(l=n.animationIteration)?l:"infinite"}},[n.animationDuration,n.animationIteration,n.animationOpacity,n.animationTiming,n.color,n.underlineBottom,n.underlineHeight]),f=o(()=>{var e;return x({href:String(null!=(e=a.href)?e:"")}).href},[a.href]),g="string"==typeof a.title&&a.title.trim().length>0?a.title:String(null!=f?f:""),w=d(e=>{m&&Ne(e.currentTarget,String(a.title||f||a.text||""),"top",!1,(e.clientX,e.clientY),h)},[h,a.text,a.title,f,m]),v=d(()=>{m&&Be()},[m]);return a.loading?/* @__PURE__ */t("span",{className:"link-loading inline-flex items-baseline gap-1.5","aria-hidden":"false",style:p,children:/* @__PURE__ */e("span",{className:"link-text-wrapper relative inline-flex",children:[
95
+ /* @__PURE__ */t("span",{className:"leading-[normal] link-text",children:/* @__PURE__ */t(Ut,{node:{type:"text",content:String(null!=(i=a.text)?i:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-loading`,typewriter:n.typewriter})}),
96
+ /* @__PURE__ */t("span",{className:"link-loading-indicator","aria-hidden":"true"})]})}):/* @__PURE__ */t("a",{className:"link-node",href:f,title:m?"":g,"aria-label":`Link: ${g}`,target:"_blank",rel:"noopener noreferrer",style:p,onMouseEnter:w,onMouseLeave:v,children:c&&s?L(a.children,c,String(null!=u?u:"link"),s):/* @__PURE__ */t(Ut,{node:{type:"text",content:String(null!=(l=a.text)?l:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-fallback`,typewriter:n.typewriter})})}function Yt(e){const{node:n,ctx:r,renderNode:o,value:i,indexKey:l,children:a}=e;/* @__PURE__ */
97
+ return t("li",{className:"list-item pl-1.5 my-2",dir:"auto",value:null==i?void 0:i,children:null!=a?a:r&&o?L(n.children,r,String(null!=l?l:"list-item"),o):null})}function Zt(e){var n;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&&H(o.customId).list_item||Yt;/* @__PURE__ */
98
+ return t(a,{className:lt("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==(n=r.items)?void 0:n.map((e,n)=>{var a;/* @__PURE__ */
99
+ return t(s,{node:e,value:r.ordered?(null!=(a=r.start)?a:1)+n:void 0,ctx:o,renderNode:i,indexKey:`${String(null!=l?l:"list")}-${n}`,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")}-${n}`)})})}let Gt=null,Jt=null,Qt=!1;const en=/* @__PURE__ */new Map,tn=/* @__PURE__ */new Map;let nn=5;const rn=/* @__PURE__ */new Set;function on(){if(en.size<nn&&rn.size){const e=Array.from(rn);rn.clear();for(const t of e)try{t()}catch{}}}function ln(e){Gt=e,Jt=null,Gt.onmessage=e=>{const{id:t,html:n,error:r}=e.data,o=en.get(t);if(o)if(en.delete(t),clearTimeout(o.timeoutId),on(),r)o.reject(new Error(r));else{const{content:t,displayMode:r}=e.data;if(t){const e=`${r?"d":"i"}:${t}`;if(tn.set(e,n),tn.size>200){const e=tn.keys().next().value;tn.delete(e)}}o.resolve(n)}},Gt.onerror=e=>{console.error("[katexWorkerClient] Worker error:",e);for(const[t,n]of en.entries())clearTimeout(n.timeoutId),n.reject(new Error(`Worker error: ${e.message}`));en.clear(),on()}}function an(){var e;Gt&&(null==(e=Gt.terminate)||e.call(Gt)),Gt=null,Jt=null}function cn(e){Qt=!!e,Gt&&Gt.postMessage({type:"init",debug:Qt})}const sn="WORKER_BUSY";async function dn(e,t=!0,n=2e3,r){performance.now();const o=U(e);if(Jt)return Promise.reject(Jt);const i=`${t?"d":"i"}:${o}`,l=tn.get(i);if(l)return Promise.resolve(l);const a=Gt||(Jt=new Error("[katexWorkerClient] No worker instance set. Please inject a Worker via setKaTeXWorker()."),Jt.name="WORKER_INIT_ERROR",Jt.code="WORKER_INIT_ERROR",null);if(!a)return Promise.reject(Jt);if(en.size>=nn){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=sn,e.busy=!0,e.inFlight=en.size,e.max=nn,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(()=>{en.delete(l);const e=new Error("Worker render timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT",i(e),on()},n),s=()=>{},d=()=>{en.delete(l),clearTimeout(c),rn.delete(s);const e=new Error("Aborted");e.name="AbortError",i(e),on()};r&&r.addEventListener("abort",d,{once:!0}),en.set(l,{resolve:t=>{r&&r.removeEventListener("abort",d),e(t)},reject:e=>{r&&r.removeEventListener("abort",d),i(e)},timeoutId:c});try{a.postMessage({id:l,content:o,displayMode:t,debug:Qt})}catch(u){en.delete(l),clearTimeout(c),r&&r.removeEventListener("abort",d),i(u),on()}})}function un(e,t,n){const r=`${t?"d":"i"}:${U(e)}`;if(tn.set(r,n),tn.size>200){const e=tn.keys().next().value;tn.delete(e)}}function mn(){tn.clear()}function hn(e){nn=Math.max(1,Math.floor(e)),on()}function pn(e=1500,t){return en.size<nn?Promise.resolve():new Promise((n,r)=>{if(null==t?void 0:t.aborted){const e=new Error("Aborted");return e.name="AbortError",void r(e)}let o=null;function i(){rn.delete(l),null!=o&&clearTimeout(o),t&&t.removeEventListener("abort",a)}function l(){i(),n()}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,t&&t.addEventListener("abort",a,{once:!0}),rn.add(l)})}const fn={timeout:2e3,waitTimeout:1500,backoffMs:30,maxRetries:1};function gn(e){null!=e.timeout&&(fn.timeout=Math.max(0,Math.floor(e.timeout))),null!=e.waitTimeout&&(fn.waitTimeout=Math.max(0,Math.floor(e.waitTimeout))),null!=e.backoffMs&&(fn.backoffMs=Math.max(0,Math.floor(e.backoffMs))),null!=e.maxRetries&&(fn.maxRetries=Math.max(0,Math.floor(e.maxRetries)))}function wn(){return{...fn}}async function vn(e,t=!0,n={}){var r,o,i,l;const a=null!=(r=n.timeout)?r:fn.timeout,c=null!=(o=n.waitTimeout)?o:fn.waitTimeout,s=null!=(i=n.backoffMs)?i:fn.backoffMs,d=null!=(l=n.maxRetries)?l:fn.maxRetries,u=Number.isFinite(d)?Math.max(0,Math.min(Math.floor(d),8)):fn.maxRetries,m=n.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 dn(e,t,a,m)}catch(p){if((null==p?void 0:p.code)!==sn||h>=u)throw p;if(h++,await pn(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 yn=null,xn=!1;async function kn(){if(yn)return yn;if(xn)return null;try{return yn=await import("katex"),await import("katex/contrib/mhchem"),yn}catch{return xn=!0,null}}function bn({node:e}){const n=a(null),r=a(null),o=a(null),l=me(),[c,d]=i(!0),[u,m]=i(()=>"undefined"==typeof window),h=a(0);return s(()=>{const e=n.current;if(!e)return;const t=l(e,{rootMargin:"400px"});return o.current=t,t.isVisible()&&m(!0),t.whenVisible.then(()=>m(!0)),()=>{t.destroy(),o.current=null}},[l]),s(()=>{var t;const n=U(null!=(t=e.content)?t:"");if(!n)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 vn(n,!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 t=>{if(o||l!==h.current)return;if(!r.current)return;const i=(null==t?void 0:t.code)||(null==t?void 0:t.name);if("WORKER_INIT_ERROR"===i||(null==t?void 0:t.fallbackToRenderer)||i===sn||"WORKER_TIMEOUT"===i){const t=await kn();if(t)try{const i=t.renderToString(n,{throwOnError:e.loading,displayMode:!0});return void(!o&&l===h.current&&r.current&&(r.current.innerHTML=i,d(!1),un(n,!0,i)))}catch{}}e.loading||(r.current.textContent=e.raw,d(!1))}),()=>{o=!0,i.abort()}},[e.content,e.loading,e.raw,u]),/* @__PURE__ */t("div",{ref:n,className:"math-block text-center overflow-x-auto relative min-h-[40px]",children:/* @__PURE__ */t("div",{ref:r,className:c?"math-rendering":void 0})})}function Cn({node:n}){const r=a(null),o=a(null),l=a(null),c=me(),[d,u]=i(!0),[m,h]=i(()=>"undefined"==typeof window),p=a(0);return s(()=>{const e=r.current;if(!e)return;const t=c(e,{rootMargin:"400px"});return l.current=t,t.isVisible()&&h(!0),t.whenVisible.then(()=>h(!0)),()=>{t.destroy(),l.current=null}},[c]),s(()=>{var e;const t=U(null!=(e=n.content)?e:"");if(!t)return o.current&&(o.current.innerHTML=""),void u(!1);if(!m)return void u(!0);let r=!1;const i=new AbortController,l=++p.current,a="$$"===n.markup;return vn(t,a,{timeout:1500,waitTimeout:0,maxRetries:0,signal:i.signal}).then(e=>{r||l!==p.current||o.current&&(o.current.innerHTML=e,u(!1))}).catch(async e=>{if(r||l!==p.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===sn||"WORKER_TIMEOUT"===i){const e=await kn();if(e)try{const i=e.renderToString(t,{throwOnError:n.loading,displayMode:a});return void(!r&&l===p.current&&o.current&&(o.current.innerHTML=i,u(!1),un(t,a,i)))}catch{}}n.loading||(o.current.textContent=n.raw,u(!1))}),()=>{r=!0,i.abort()}},[n.content,n.loading,n.raw,n.markup,m]),/* @__PURE__ */e("span",{ref:r,className:"math-inline-wrapper",children:[
100
100
  /* @__PURE__ */t("span",{ref:o,className:"math-inline"+(d?" math-inline--hidden":"")}),d&&/* @__PURE__ */e("span",{className:"math-inline__loading",role:"status","aria-live":"polite",children:[
101
101
  /* @__PURE__ */t("span",{className:"math-inline__spinner","aria-hidden":"true"}),
102
- /* @__PURE__ */t("span",{className:"sr-only",children:"Loading"})]})]})}function bn(e){try{if("undefined"!=typeof globalThis&&"function"==typeof globalThis.requestAnimationFrame)return globalThis.requestAnimationFrame(e)}catch{}return globalThis.setTimeout(e,0)}let Cn=null,Mn=null;const Nn=/* @__PURE__ */new Map;let Bn=5,Ln=!1;function Tn(e){Ln=!!e}function En(e){Number.isFinite(e)&&e>0&&(Bn=Math.floor(e))}function Sn(){return{inFlight:Nn.size,max:Bn}}const Dn="WORKER_BUSY";function $n(e){Cn=e,Mn=null;const t=e;Cn.onmessage=e=>{if(Cn!==t)return;const{id:n,ok:r,result:o,error:i}=e.data,l=Nn.get(n);l&&(!1===r||i?l.reject(new Error(i||"Unknown error")):l.resolve(o))},Cn.onerror=e=>{var n,r;if(Cn===t)if(0!==Nn.size){try{Ln?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[t,n]of Nn.entries())n.reject(new Error(`Worker error: ${e.message}`));Nn.clear()}else null==(n=console.debug)||n.call(console,"[mermaidWorkerClient] Worker error (no pending):",(null==e?void 0:e.message)||e)},Cn.onmessageerror=e=>{var n,r;if(Cn===t)if(0!==Nn.size){try{Ln?console.error("[mermaidWorkerClient] Worker messageerror:",e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker messageerror:",e)}catch{}for(const[e,t]of Nn.entries())t.reject(new Error("Worker messageerror"));Nn.clear()}else null==(n=console.debug)||n.call(console,"[mermaidWorkerClient] Worker messageerror (no pending):",e)}}function Pn(){var e;if(Cn)try{for(const[e,t]of Nn.entries())t.reject(new Error("Worker cleared"));Nn.clear(),null==(e=Cn.terminate)||e.call(Cn)}catch{}Cn=null,Mn=null}function An(e,t,n=1400){if(Mn)return Promise.reject(Mn);const r=Cn||(Mn=new Error("[mermaidWorkerClient] No worker instance set. Please inject a Worker via setMermaidWorker()."),Mn.name="WORKER_INIT_ERROR",Mn.code="WORKER_INIT_ERROR",null);if(!r)return Promise.reject(Mn);if(Nn.size>=Bn){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=Dn,e.inFlight=Nn.size,e.max=Bn,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),Nn.delete(l))},d={resolve:e=>{s(),o(e)},reject:e=>{s(),i(e)}};Nn.set(l,d);try{r.postMessage({id:l,action:e,payload:t})}catch(u){return Nn.delete(l),void i(u)}c=setTimeout(()=>{const e=new Error("Worker call timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT";const t=Nn.get(l);null==t||t.reject(e)},n)})}async function Rn(e,t,n=1400){return An("canParse",{code:e,theme:t},n)}async function Hn(e,t,n=2400){return An("findPrefix",{code:e,theme:t},n)}function Wn(){var e;null==(e=null==Cn?void 0:Cn.terminate)||e.call(Cn),Cn=null,Mn=null,Nn.clear()}let In=null,_n=!1,Fn=null,jn=null;function On(e,t){var n;if(!e||!t)return;const r=function(e){var t,n;return`${String(null!=(t=null==e?void 0:e.securityLevel)?t:"strict")}|htmlLabels:${!1===(null==(n=null==e?void 0:e.flowchart)?void 0:n.htmlLabels)?"0":"1"}`}(t);if(Fn!==r)try{"function"==typeof e.initialize?e.initialize(t):(null==(n=e.mermaidAPI)?void 0:n.initialize)&&e.mermaidAPI.initialize(t),Fn=r}catch{}}const zn="undefined"!=typeof window?m:s,Vn={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0},Kn=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],Xn=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function Un(e){if(!e)return"";const t=e.trim();return Xn.test(t)?t:""}function qn(e){if(e)try{e.replaceChildren()}catch{e.innerHTML=""}}function Yn(e,t,n){if(!e)return"";if(n)return function(e,t){if(!e)return"";qn(e);const n=function(e){if("undefined"==typeof window||"undefined"==typeof DOMParser)return null;if(!e)return null;const t=e.replace(/["']\s*javascript:/gi,"#").replace(/\bjavascript:/gi,"#").replace(/["']\s*vbscript:/gi,"#").replace(/\bvbscript:/gi,"#").replace(/\bdata:text\/html/gi,"#"),n=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!n||"svg"!==n.nodeName.toLowerCase())return null;const r=n;return function(e){const t=/* @__PURE__ */new Set(["script"]),n=[e,...Array.from(e.querySelectorAll("*"))];for(const r of n){if(t.has(r.tagName.toLowerCase())){r.remove();continue}const e=Array.from(r.attributes);for(const t of e){const e=t.name;if(/^on/i.test(e))r.removeAttribute(e);else{if("style"===e&&t.value){const n=t.value;if(Kn.some(e=>e.test(n))){r.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&t.value){const n=Un(t.value);if(!n){r.removeAttribute(e);continue}n!==t.value&&r.setAttribute(e,n)}}}}}(r),r}(t);return n?(e.appendChild(n),e.innerHTML):""}(e,t);if(qn(e),t)try{e.insertAdjacentHTML("afterbegin",t)}catch{e.innerHTML=t}return e.innerHTML}function Zn(e){if(!e||"undefined"==typeof DOMParser)return!e;const t=(new DOMParser).parseFromString(e,"image/svg+xml").documentElement;if(!t||"svg"!==t.nodeName.toLowerCase())return!0;const n=t.getAttribute("viewBox");if(n){const e=n.trim().split(/[\s,]+/);if(4===e.length){const t=Number.parseFloat(e[2]||""),n=Number.parseFloat(e[3]||"");if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0)return!0}}const r=[t,...Array.from(t.querySelectorAll("*"))];for(const o of r)for(const e of Array.from(o.attributes)){if(/\bNaN\b/i.test(e.value))return!0;if("style"===e.name&&/max-width:\s*0(?:px)?/i.test(e.value))return!0}return!1}const Gn={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};function Jn(r){var l,c,u,h,p,f,g,w,v,y;const x={...Gn,...r},{t:k}=ge(),b=o(()=>D("mermaid"),[]),C=null!=(c=null==(l=x.node)?void 0:l.code)?c:"",M=o(()=>C.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"),[C]),N=null!=(u=x.workerTimeoutMs)?u:Gn.workerTimeoutMs,B=null!=(h=x.parseTimeoutMs)?h:Gn.parseTimeoutMs,L=null!=(p=x.renderTimeoutMs)?p:Gn.renderTimeoutMs,T=null!=(f=x.fullRenderTimeoutMs)?f:Gn.fullRenderTimeoutMs,E=Math.max(0,null!=(g=x.renderDebounceMs)?g:Gn.renderDebounceMs),S=o(()=>x.maxHeight&&"none"!==x.maxHeight?q(x.maxHeight):null,[x.maxHeight]),$=o(()=>{var e;return Y(null!=(e=q(x.estimatedPreviewHeightPx))?e:Z(M),void 0,S)},[M,S,x.estimatedPreviewHeightPx]),[P,A]=i(!1),[R,H]=i(!1),[W,I]=i(!1),[_,F]=i(!1),[j,O]=i(1),[z,V]=i({x:0,y:0}),[K,X]=i(!1),[U,G]=i(!1),[J,Q]=i(!1),[te,ne]=i(null),[re,oe]=i(!1),[ie,le]=i(`${$}px`),[ae,ce]=i("undefined"==typeof window),se=a(null),de=a(null),ue=a(null),he=a(null),pe=a(null),fe=a(null),we=a(null),ve=a({x:0,y:0}),ye=a(0),xe=a({}),ke=a(""),be=a(!1),Ce=a(null),Me=a(!1),Le=a({zoom:1,translateX:0,translateY:0,containerHeight:ie||"360px"}),Te=me(),Ee=Boolean(null!=(v=null==(w=x.node)?void 0:w.loading)?v:x.loading),Se=x.isDark?"dark":"light",De=Boolean(x.isStrict),$e=o(()=>De?{startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,dompurifyConfig:Vn,flowchart:{htmlLabels:!1}}:{startOnLoad:!1,securityLevel:"loose",suppressErrorRendering:!0},[De]);s(()=>{Me.current=J},[J]),s(()=>{R||W||le(e=>{const t=q(e);return null!=t&&t>=$?e:`${$}px`})},[$,W,R]),s(()=>{xe.current={}},[Se,M,De]),s(()=>{let e=!1;return(async()=>{const t=await async function(e){if(In)return On(In,e),In;if(jn){const t=await jn;return t&&On(t,e),t}if(_n)return null;try{_n=!0,jn=(async()=>{try{const t=await import("mermaid"),n=(null==t?void 0:t.default)||t;if(In=(null==n?void 0:n.default)?n.default:(null==n?void 0:n.mermaidAPI)?n:(null==n?void 0:n.mermaid)?n.mermaid:n,!In)throw new Error("Mermaid module did not export expected API");return On(In,null!=e?e:{startOnLoad:!1,securityLevel:"strict",flowchart:{htmlLabels:!1}}),In}catch(t){return console.warn("[markstream-react] Failed to load mermaid:",t),null}finally{jn=null}})();const t=await jn;return t&&On(t,e),t}catch{return null}}($e);e||(se.current=t,A(Boolean(t)),be.current||H(!t))})(),()=>{e=!0}},[$e]),s(()=>{const e=de.current;if(!e)return;const t=Te(e,{rootMargin:"400px"});return Ce.current=t,t.isVisible()&&ce(!0),t.whenVisible.then(()=>ce(!0)),()=>{t.destroy(),Ce.current=null}},[Te]),s(()=>{if("undefined"==typeof document)return;if(!re)return;const e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[re]);const Pe=d(()=>S,[S]),Ae=d(e=>{const t=de.current,n=he.current;if(!t||!n)return;const r=n.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:t.clientWidth)*(i/o),c=Number.isFinite(a)&&a>0?a:i,s=Pe(),d=null==s?c:Math.min(c,s);le(`${"none"===x.maxHeight?d:Math.max(d,$)}px`)},[$,x.maxHeight,Pe]);s(()=>{if(!de.current||"undefined"==typeof ResizeObserver)return;if(R||W)return;const e=new ResizeObserver(e=>{if(!e.length)return;const t=e[0].contentRect.width;bn(()=>Ae(t))});return e.observe(de.current),()=>e.disconnect()},[W,R,Ae]),s(()=>{R||W||Ae()},[W,x.maxHeight,R,Ae]),s(()=>()=>{Wn()},[]),m(()=>{!R&&he.current&&xe.current[Se]&&(Yn(he.current,xe.current[Se],De),bn(()=>Ae()))},[R,De,Se,Ae]);const Re=d(async(e,t,n)=>{var r;if(!se.current||!he.current)return!1;G(!0);try{const o=`mermaid-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=tr(e,t),l=await ir(()=>se.current.render(o,i),{timeoutMs:T,signal:n});if(!(null==l?void 0:l.svg)||Zn(l.svg))return!1;const a=Yn(he.current,l.svg,De);return null==(r=l.bindFunctions)||r.call(l,he.current),Ae(),xe.current[t]=a,Q(!0),ne(null),!0}catch(o){if(!Ee){if("function"==typeof x.onRenderError&&he.current&&!0===x.onRenderError(o,M,he.current))return!1;ne(o instanceof Error?o.message:String(o))}return!1}finally{G(!1)}},[T,Ee,De,Ae]),He=d(async(e,t,n)=>{var r;if(se.current&&he.current){G(!0);try{const o=`mermaid-preview-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=tr(or(e)||e,t),l=await ir(()=>se.current.render(o,i),{timeoutMs:L,signal:n});(null==l?void 0:l.svg)&&!Zn(l.svg)&&(Yn(he.current,l.svg,De),null==(r=l.bindFunctions)||r.call(l,he.current),Ae())}catch{}finally{G(!1)}}},[L,Ee,De,Ae]),We=d(async(e,t)=>{if(!e.trim())return qn(he.current),Q(!1),void(ke.current="");const n=e.replace(/\s+/g,"");if(n===ke.current&&Me.current)return;const r=++ye.current;if("gantt"===nr(e)){const i=or(e);if(!i.trim())return;try{if(await er(i,Se,{workerTimeout:N,parseTimeout:B,mermaid:se.current,signal:t}),(null==t?void 0:t.aborted)||ye.current!==r)return;i===e?await Re(e,Se,t)&&(ke.current=n):await He(i,Se,t)}catch(o){if("AbortError"===(null==o?void 0:o.name))return}return}try{if(await er(e,Se,{workerTimeout:N,parseTimeout:B,mermaid:se.current,signal:t}),(null==t?void 0:t.aborted)||ye.current!==r)return;return void(await Re(e,Se,t)&&(ke.current=n))}catch(o){if("AbortError"===(null==o?void 0:o.name))return}try{const n=await async function(e,t,n){try{const r=await Hn(e,t,n.workerTimeout);if(r)return r}catch(o){if("AbortError"===(null==o?void 0:o.name))throw o}return or(e)}(e,Se,{workerTimeout:N,signal:t});if(!n||(null==t?void 0:t.aborted)||ye.current!==r)return;await He(n,Se,t)}catch{}},[B,Re,He,Se,N]),Ie=d(()=>ae&&!R&&!W,[W,R,ae]);s(()=>{if(!Ie())return;if(!se.current)return;const e=new AbortController,t=window.setTimeout(()=>{!e.signal.aborted&&Ie()&&We(M,e.signal)},E);return()=>{e.abort(),window.clearTimeout(t)}},[M,Ie,P,We,E]);const _e=d((e,t)=>{e.clientX,e.clientY,Ne(e.currentTarget,t,"top",!1,0,x.isDark)},[x.isDark]),Fe=d(async()=>{var e,t;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(M)),F(!0),null==(t=x.onCopy)||t.call(x,M),setTimeout(()=>F(!1),1e3)}catch{}},[M,x]),je=d(()=>{var e,t,n;const r=null!=(t=null==(e=he.current)?void 0:e.querySelector("svg"))?t:null;if(!r)return;const o=lr(r),i={payload:{type:"export"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(n=x.onExport)||n.call(x,i),i.defaultPrevented||function(e,t){const n=null!=t?t:lr(e),r=new Blob([n],{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]),Oe=d(()=>{we.current=null,qn(fe.current)},[]),ze=d(()=>{oe(!1),Oe()},[Oe]),Ve=d(()=>{var e,t,n;const r=null!=(t=null==(e=he.current)?void 0:e.querySelector("svg"))?t:null,o=r?lr(r):null,i={payload:{type:"open-modal"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(n=x.onOpenModal)||n.call(x,i),i.defaultPrevented||oe(!0)},[x]);s(()=>{if(!re)return;if("undefined"==typeof window)return;const e=e=>{"Escape"===e.key&&ze()};try{window.addEventListener("keydown",e)}catch{}return()=>{try{window.removeEventListener("keydown",e)}catch{}}},[ze,re]),zn(()=>{if(!re)return;const e=fe.current,t=de.current;if(!e||!t)return;const n=`translate(${z.x}px, ${z.y}px) scale(${j})`,r=t.cloneNode(!0);r.classList.add("fullscreen"),r.style.height="100%",r.style.maxHeight="100%";const o=r.querySelector("[data-mermaid-wrapper]");o&&(we.current=o,o.style.transform=n),qn(e),e.appendChild(r)},[re]),s(()=>{re&&we.current&&(we.current.style.transform=`translate(${z.x}px, ${z.y}px) scale(${j})`)},[re,z.x,z.y,j]);const Ke=R||U||W,Xe=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]),Ue=d(e=>{var t;const n={payload:{type:"toggle-mode",target:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};if(null==(t=x.onToggleMode)||t.call(x,e,n),!n.defaultPrevented)if(be.current=!0,"preview"===e){H(!1);const e=Le.current;O(e.zoom),V({x:e.translateX,y:e.translateY}),le(e.containerHeight)}else Le.current={zoom:j,translateX:z.x,translateY:z.y,containerHeight:ie},H(!0)},[M,ie,We,x,Se,z.x,z.y,Ae,j]),qe=d(e=>{if(!1===x.enableWheelZoom)return;if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const t=de.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-z.x,o=e.clientY-n.top-z.y,i=.01*-e.deltaY,l=Qn(j+i,.5,3);if(l===j)return;const a=l/j;V({x:z.x-r*(a-1),y:z.y-o*(a-1)}),O(l)},[z,j]),Ye=d((e,t)=>{X(!0),ve.current={x:e-z.x,y:t-z.y}},[z.x,z.y]),Ze=d((e,t)=>{K&&V({x:e-ve.current.x,y:t-ve.current.y})},[K]),Ge=d(()=>{X(!1)},[]),Je=/* @__PURE__ */e("div",{className:"relative",children:[x.showZoomControls&&/* @__PURE__ */t("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:[
103
- /* @__PURE__ */t("button",{type:"button",className:ot("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=>_e(e,k("common.zoomIn")),onMouseLeave:()=>Be(),onClick:()=>O(Qn(j+.1,.5,3)),children:"+"}),
104
- /* @__PURE__ */t("button",{type:"button",className:ot("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=>_e(e,k("common.zoomOut")),onMouseLeave:()=>Be(),onClick:()=>O(Qn(j-.1,.5,3)),children:"−"}),
105
- /* @__PURE__ */e("button",{type:"button",className:ot("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=>_e(e,k("common.resetZoom")),onMouseLeave:()=>Be(),onClick:()=>{O(1),V({x:0,y:0})},children:[Math.round(100*j),"%"]})]})}),
106
- /* @__PURE__ */e("div",{ref:de,className:ot("min-h-[360px] relative overflow-hidden block transition-[height] duration-150 ease-out",x.isDark?"bg-gray-900":"bg-gray-50"),style:{height:ie,maxHeight:null!=(y=x.maxHeight)?y:void 0},onWheel:qe,onMouseDown:e=>{0===e.button&&(e.preventDefault(),Ye(e.clientX,e.clientY))},onMouseMove:e=>Ze(e.clientX,e.clientY),onMouseUp:Ge,onMouseLeave:Ge,onTouchStart:e=>{const t=e.touches[0];t&&Ye(t.clientX,t.clientY)},onTouchMove:e=>{const t=e.touches[0];t&&Ze(t.clientX,t.clientY)},onTouchEnd:Ge,children:[
107
- /* @__PURE__ */t("div",{ref:ue,"data-mermaid-wrapper":!0,className:ot("absolute inset-0 cursor-grab",{"cursor-grabbing":K}),style:{transform:`translate(${z.x}px, ${z.y}px) scale(${j})`},children:/* @__PURE__ */t("div",{ref:he,className:"_mermaid w-full text-center flex items-center justify-center min-h-full"})}),(U||Ee)&&/* @__PURE__ */e("div",{className:"mermaid-loading",children:[
102
+ /* @__PURE__ */t("span",{className:"sr-only",children:"Loading"})]})]})}function Mn(e){try{if("undefined"!=typeof globalThis&&"function"==typeof globalThis.requestAnimationFrame)return globalThis.requestAnimationFrame(e)}catch{}return globalThis.setTimeout(e,0)}let Nn=null,Bn=null;const Ln=/* @__PURE__ */new Map;let Sn=5,Tn=!1;function En(e){Tn=!!e}function Dn(e){Number.isFinite(e)&&e>0&&(Sn=Math.floor(e))}function $n(){return{inFlight:Ln.size,max:Sn}}const Pn="WORKER_BUSY";function An(e){Nn=e,Bn=null;const t=e;Nn.onmessage=e=>{if(Nn!==t)return;const{id:n,ok:r,result:o,error:i}=e.data,l=Ln.get(n);l&&(!1===r||i?l.reject(new Error(i||"Unknown error")):l.resolve(o))},Nn.onerror=e=>{var n,r;if(Nn===t)if(0!==Ln.size){try{Tn?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[t,n]of Ln.entries())n.reject(new Error(`Worker error: ${e.message}`));Ln.clear()}else null==(n=console.debug)||n.call(console,"[mermaidWorkerClient] Worker error (no pending):",(null==e?void 0:e.message)||e)},Nn.onmessageerror=e=>{var n,r;if(Nn===t)if(0!==Ln.size){try{Tn?console.error("[mermaidWorkerClient] Worker messageerror:",e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker messageerror:",e)}catch{}for(const[e,t]of Ln.entries())t.reject(new Error("Worker messageerror"));Ln.clear()}else null==(n=console.debug)||n.call(console,"[mermaidWorkerClient] Worker messageerror (no pending):",e)}}function Rn(){var e;if(Nn)try{for(const[e,t]of Ln.entries())t.reject(new Error("Worker cleared"));Ln.clear(),null==(e=Nn.terminate)||e.call(Nn)}catch{}Nn=null,Bn=null}function Hn(e,t,n=1400){if(Bn)return Promise.reject(Bn);const r=Nn||(Bn=new Error("[mermaidWorkerClient] No worker instance set. Please inject a Worker via setMermaidWorker()."),Bn.name="WORKER_INIT_ERROR",Bn.code="WORKER_INIT_ERROR",null);if(!r)return Promise.reject(Bn);if(Ln.size>=Sn){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=Pn,e.inFlight=Ln.size,e.max=Sn,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),Ln.delete(l))},d={resolve:e=>{s(),o(e)},reject:e=>{s(),i(e)}};Ln.set(l,d);try{r.postMessage({id:l,action:e,payload:t})}catch(u){return Ln.delete(l),void i(u)}c=setTimeout(()=>{const e=new Error("Worker call timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT";const t=Ln.get(l);null==t||t.reject(e)},n)})}async function Wn(e,t,n=1400){return Hn("canParse",{code:e,theme:t},n)}async function In(e,t,n=2400){return Hn("findPrefix",{code:e,theme:t},n)}function _n(){var e;null==(e=null==Nn?void 0:Nn.terminate)||e.call(Nn),Nn=null,Bn=null,Ln.clear()}let Fn=null,jn=!1,On=null,zn=null;function Vn(e,t){var n;if(!e||!t)return;const r=function(e){var t,n;return`${String(null!=(t=null==e?void 0:e.securityLevel)?t:"strict")}|htmlLabels:${!1===(null==(n=null==e?void 0:e.flowchart)?void 0:n.htmlLabels)?"0":"1"}`}(t);if(On!==r)try{"function"==typeof e.initialize?e.initialize(t):(null==(n=e.mermaidAPI)?void 0:n.initialize)&&e.mermaidAPI.initialize(t),On=r}catch{}}const Kn="undefined"!=typeof window?m:s,Xn={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0},Un=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],qn=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function Yn(e){if(!e)return"";const t=e.trim();return qn.test(t)?t:""}function Zn(e){if(e)try{e.replaceChildren()}catch{e.innerHTML=""}}function Gn(e,t,n){if(!e)return"";if(n)return function(e,t){if(!e)return"";Zn(e);const n=function(e){if("undefined"==typeof window||"undefined"==typeof DOMParser)return null;if(!e)return null;const t=e.replace(/["']\s*javascript:/gi,"#").replace(/\bjavascript:/gi,"#").replace(/["']\s*vbscript:/gi,"#").replace(/\bvbscript:/gi,"#").replace(/\bdata:text\/html/gi,"#"),n=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!n||"svg"!==n.nodeName.toLowerCase())return null;const r=n;return function(e){const t=/* @__PURE__ */new Set(["script"]),n=[e,...Array.from(e.querySelectorAll("*"))];for(const r of n){if(t.has(r.tagName.toLowerCase())){r.remove();continue}const e=Array.from(r.attributes);for(const t of e){const e=t.name;if(/^on/i.test(e))r.removeAttribute(e);else{if("style"===e&&t.value){const n=t.value;if(Un.some(e=>e.test(n))){r.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&t.value){const n=Yn(t.value);if(!n){r.removeAttribute(e);continue}n!==t.value&&r.setAttribute(e,n)}}}}}(r),r}(t);return n?(e.appendChild(n),e.innerHTML):""}(e,t);if(Zn(e),t)try{e.insertAdjacentHTML("afterbegin",t)}catch{e.innerHTML=t}return e.innerHTML}function Jn(e){if(!e||"undefined"==typeof DOMParser)return!e;const t=(new DOMParser).parseFromString(e,"image/svg+xml").documentElement;if(!t||"svg"!==t.nodeName.toLowerCase())return!0;const n=t.getAttribute("viewBox");if(n){const e=n.trim().split(/[\s,]+/);if(4===e.length){const t=Number.parseFloat(e[2]||""),n=Number.parseFloat(e[3]||"");if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0)return!0}}const r=[t,...Array.from(t.querySelectorAll("*"))];for(const o of r)for(const e of Array.from(o.attributes)){if(/\bNaN\b/i.test(e.value))return!0;if("style"===e.name&&/max-width:\s*0(?:px)?/i.test(e.value))return!0}return!1}const Qn={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};function er(r){var l,c,u,h,p,f,g,w,v,y;const x={...Qn,...r},{t:k}=ge(),b=o(()=>D("mermaid"),[]),C=null!=(c=null==(l=x.node)?void 0:l.code)?c:"",M=o(()=>C.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"),[C]),N=null!=(u=x.workerTimeoutMs)?u:Qn.workerTimeoutMs,B=null!=(h=x.parseTimeoutMs)?h:Qn.parseTimeoutMs,L=null!=(p=x.renderTimeoutMs)?p:Qn.renderTimeoutMs,S=null!=(f=x.fullRenderTimeoutMs)?f:Qn.fullRenderTimeoutMs,T=Math.max(0,null!=(g=x.renderDebounceMs)?g:Qn.renderDebounceMs),E=o(()=>x.maxHeight&&"none"!==x.maxHeight?q(x.maxHeight):null,[x.maxHeight]),$=o(()=>{var e;return Y(null!=(e=q(x.estimatedPreviewHeightPx))?e:Z(M),void 0,E)},[M,E,x.estimatedPreviewHeightPx]),[P,A]=i(!1),[R,H]=i(!1),[W,I]=i(!1),[_,F]=i(!1),[j,O]=i(1),[z,V]=i({x:0,y:0}),[K,X]=i(!1),[U,G]=i(!1),[J,Q]=i(!1),[te,ne]=i(null),[re,oe]=i(!1),[ie,le]=i(`${$}px`),[ae,ce]=i("undefined"==typeof window),se=a(null),de=a(null),ue=a(null),he=a(null),pe=a(null),fe=a(null),we=a(null),ve=a({x:0,y:0}),ye=a(0),xe=a({}),ke=a(""),be=a(!1),Ce=a(null),Me=a(!1),Le=a({zoom:1,translateX:0,translateY:0,containerHeight:ie||"360px"}),Se=me(),Te=Boolean(null!=(v=null==(w=x.node)?void 0:w.loading)?v:x.loading),Ee=x.isDark?"dark":"light",De=Boolean(x.isStrict),$e=o(()=>De?{startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,dompurifyConfig:Xn,flowchart:{htmlLabels:!1}}:{startOnLoad:!1,securityLevel:"loose",suppressErrorRendering:!0},[De]);s(()=>{Me.current=J},[J]),s(()=>{R||W||le(e=>{const t=q(e);return null!=t&&t>=$?e:`${$}px`})},[$,W,R]),s(()=>{xe.current={}},[Ee,M,De]),s(()=>{let e=!1;return(async()=>{const t=await async function(e){if(Fn)return Vn(Fn,e),Fn;if(zn){const t=await zn;return t&&Vn(t,e),t}if(jn)return null;try{jn=!0,zn=(async()=>{try{const t=await import("mermaid"),n=(null==t?void 0:t.default)||t;if(Fn=(null==n?void 0:n.default)?n.default:(null==n?void 0:n.mermaidAPI)?n:(null==n?void 0:n.mermaid)?n.mermaid:n,!Fn)throw new Error("Mermaid module did not export expected API");return Vn(Fn,null!=e?e:{startOnLoad:!1,securityLevel:"strict",flowchart:{htmlLabels:!1}}),Fn}catch(t){return console.warn("[markstream-react] Failed to load mermaid:",t),null}finally{zn=null}})();const t=await zn;return t&&Vn(t,e),t}catch{return null}}($e);e||(se.current=t,A(Boolean(t)),be.current||H(!t))})(),()=>{e=!0}},[$e]),s(()=>{const e=de.current;if(!e)return;const t=Se(e,{rootMargin:"400px"});return Ce.current=t,t.isVisible()&&ce(!0),t.whenVisible.then(()=>ce(!0)),()=>{t.destroy(),Ce.current=null}},[Se]),s(()=>{if("undefined"==typeof document)return;if(!re)return;const e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[re]);const Pe=d(()=>E,[E]),Ae=d(e=>{const t=de.current,n=he.current;if(!t||!n)return;const r=n.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:t.clientWidth)*(i/o),c=Number.isFinite(a)&&a>0?a:i,s=Pe(),d=null==s?c:Math.min(c,s);le(`${"none"===x.maxHeight?d:Math.max(d,$)}px`)},[$,x.maxHeight,Pe]);s(()=>{if(!de.current||"undefined"==typeof ResizeObserver)return;if(R||W)return;const e=new ResizeObserver(e=>{if(!e.length)return;const t=e[0].contentRect.width;Mn(()=>Ae(t))});return e.observe(de.current),()=>e.disconnect()},[W,R,Ae]),s(()=>{R||W||Ae()},[W,x.maxHeight,R,Ae]),s(()=>()=>{_n()},[]),m(()=>{!R&&he.current&&xe.current[Ee]&&(Gn(he.current,xe.current[Ee],De),Mn(()=>Ae()))},[R,De,Ee,Ae]);const Re=d(async(e,t,n)=>{var r;if(!se.current||!he.current)return!1;G(!0);try{const o=`mermaid-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=rr(e,t),l=await ar(()=>se.current.render(o,i),{timeoutMs:S,signal:n});if(!(null==l?void 0:l.svg)||Jn(l.svg))return!1;const a=Gn(he.current,l.svg,De);return null==(r=l.bindFunctions)||r.call(l,he.current),Ae(),xe.current[t]=a,Q(!0),ne(null),!0}catch(o){if(!Te){if("function"==typeof x.onRenderError&&he.current&&!0===x.onRenderError(o,M,he.current))return!1;ne(o instanceof Error?o.message:String(o))}return!1}finally{G(!1)}},[S,Te,De,Ae]),He=d(async(e,t,n)=>{var r;if(se.current&&he.current){G(!0);try{const o=`mermaid-preview-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=rr(lr(e)||e,t),l=await ar(()=>se.current.render(o,i),{timeoutMs:L,signal:n});(null==l?void 0:l.svg)&&!Jn(l.svg)&&(Gn(he.current,l.svg,De),null==(r=l.bindFunctions)||r.call(l,he.current),Ae())}catch{}finally{G(!1)}}},[L,Te,De,Ae]),We=d(async(e,t)=>{if(!e.trim())return Zn(he.current),Q(!1),void(ke.current="");const n=e.replace(/\s+/g,"");if(n===ke.current&&Me.current)return;const r=++ye.current;if("gantt"===or(e)){const i=lr(e);if(!i.trim())return;try{if(await nr(i,Ee,{workerTimeout:N,parseTimeout:B,mermaid:se.current,signal:t}),(null==t?void 0:t.aborted)||ye.current!==r)return;i===e?await Re(e,Ee,t)&&(ke.current=n):await He(i,Ee,t)}catch(o){if("AbortError"===(null==o?void 0:o.name))return}return}try{if(await nr(e,Ee,{workerTimeout:N,parseTimeout:B,mermaid:se.current,signal:t}),(null==t?void 0:t.aborted)||ye.current!==r)return;return void(await Re(e,Ee,t)&&(ke.current=n))}catch(o){if("AbortError"===(null==o?void 0:o.name))return}try{const n=await async function(e,t,n){try{const r=await In(e,t,n.workerTimeout);if(r)return r}catch(o){if("AbortError"===(null==o?void 0:o.name))throw o}return lr(e)}(e,Ee,{workerTimeout:N,signal:t});if(!n||(null==t?void 0:t.aborted)||ye.current!==r)return;await He(n,Ee,t)}catch{}},[B,Re,He,Ee,N]),Ie=d(()=>ae&&!R&&!W,[W,R,ae]);s(()=>{if(!Ie())return;if(!se.current)return;const e=new AbortController,t=window.setTimeout(()=>{!e.signal.aborted&&Ie()&&We(M,e.signal)},T);return()=>{e.abort(),window.clearTimeout(t)}},[M,Ie,P,We,T]);const _e=d((e,t)=>{e.clientX,e.clientY,Ne(e.currentTarget,t,"top",!1,0,x.isDark)},[x.isDark]),Fe=d(async()=>{var e,t;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(M)),F(!0),null==(t=x.onCopy)||t.call(x,M),setTimeout(()=>F(!1),1e3)}catch{}},[M,x]),je=d(()=>{var e,t,n;const r=null!=(t=null==(e=he.current)?void 0:e.querySelector("svg"))?t:null;if(!r)return;const o=cr(r),i={payload:{type:"export"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(n=x.onExport)||n.call(x,i),i.defaultPrevented||function(e,t){const n=null!=t?t:cr(e),r=new Blob([n],{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]),Oe=d(()=>{we.current=null,Zn(fe.current)},[]),ze=d(()=>{oe(!1),Oe()},[Oe]),Ve=d(()=>{var e,t,n;const r=null!=(t=null==(e=he.current)?void 0:e.querySelector("svg"))?t:null,o=r?cr(r):null,i={payload:{type:"open-modal"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(n=x.onOpenModal)||n.call(x,i),i.defaultPrevented||oe(!0)},[x]);s(()=>{if(!re)return;if("undefined"==typeof window)return;const e=e=>{"Escape"===e.key&&ze()};try{window.addEventListener("keydown",e)}catch{}return()=>{try{window.removeEventListener("keydown",e)}catch{}}},[ze,re]),Kn(()=>{if(!re)return;const e=fe.current,t=de.current;if(!e||!t)return;const n=`translate(${z.x}px, ${z.y}px) scale(${j})`,r=t.cloneNode(!0);r.classList.add("fullscreen"),r.style.height="100%",r.style.maxHeight="100%";const o=r.querySelector("[data-mermaid-wrapper]");o&&(we.current=o,o.style.transform=n),Zn(e),e.appendChild(r)},[re]),s(()=>{re&&we.current&&(we.current.style.transform=`translate(${z.x}px, ${z.y}px) scale(${j})`)},[re,z.x,z.y,j]);const Ke=R||U||W,Xe=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]),Ue=d(e=>{var t;const n={payload:{type:"toggle-mode",target:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};if(null==(t=x.onToggleMode)||t.call(x,e,n),!n.defaultPrevented)if(be.current=!0,"preview"===e){H(!1);const e=Le.current;O(e.zoom),V({x:e.translateX,y:e.translateY}),le(e.containerHeight)}else Le.current={zoom:j,translateX:z.x,translateY:z.y,containerHeight:ie},H(!0)},[M,ie,We,x,Ee,z.x,z.y,Ae,j]),qe=d(e=>{if(!1===x.enableWheelZoom)return;if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const t=de.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-z.x,o=e.clientY-n.top-z.y,i=.01*-e.deltaY,l=tr(j+i,.5,3);if(l===j)return;const a=l/j;V({x:z.x-r*(a-1),y:z.y-o*(a-1)}),O(l)},[z,j]),Ye=d((e,t)=>{X(!0),ve.current={x:e-z.x,y:t-z.y}},[z.x,z.y]),Ze=d((e,t)=>{K&&V({x:e-ve.current.x,y:t-ve.current.y})},[K]),Ge=d(()=>{X(!1)},[]),Je=/* @__PURE__ */e("div",{className:"relative",children:[x.showZoomControls&&/* @__PURE__ */t("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:[
103
+ /* @__PURE__ */t("button",{type:"button",className:lt("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=>_e(e,k("common.zoomIn")),onMouseLeave:()=>Be(),onClick:()=>O(tr(j+.1,.5,3)),children:"+"}),
104
+ /* @__PURE__ */t("button",{type:"button",className:lt("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=>_e(e,k("common.zoomOut")),onMouseLeave:()=>Be(),onClick:()=>O(tr(j-.1,.5,3)),children:"−"}),
105
+ /* @__PURE__ */e("button",{type:"button",className:lt("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=>_e(e,k("common.resetZoom")),onMouseLeave:()=>Be(),onClick:()=>{O(1),V({x:0,y:0})},children:[Math.round(100*j),"%"]})]})}),
106
+ /* @__PURE__ */e("div",{ref:de,className:lt("min-h-[360px] relative overflow-hidden block transition-[height] duration-150 ease-out",x.isDark?"bg-gray-900":"bg-gray-50"),style:{height:ie,maxHeight:null!=(y=x.maxHeight)?y:void 0},onWheel:qe,onMouseDown:e=>{0===e.button&&(e.preventDefault(),Ye(e.clientX,e.clientY))},onMouseMove:e=>Ze(e.clientX,e.clientY),onMouseUp:Ge,onMouseLeave:Ge,onTouchStart:e=>{const t=e.touches[0];t&&Ye(t.clientX,t.clientY)},onTouchMove:e=>{const t=e.touches[0];t&&Ze(t.clientX,t.clientY)},onTouchEnd:Ge,children:[
107
+ /* @__PURE__ */t("div",{ref:ue,"data-mermaid-wrapper":!0,className:lt("absolute inset-0 cursor-grab",{"cursor-grabbing":K}),style:{transform:`translate(${z.x}px, ${z.y}px) scale(${j})`},children:/* @__PURE__ */t("div",{ref:he,className:"_mermaid w-full text-center flex items-center justify-center min-h-full"})}),(U||Te)&&/* @__PURE__ */e("div",{className:"mermaid-loading",children:[
108
108
  /* @__PURE__ */t("span",{className:"mermaid-spinner"}),
109
- /* @__PURE__ */t("span",{children:"Rendering diagram…"})]})]})]}),Qe=x.showHeader&&/* @__PURE__ */e("div",{className:ot("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:[
109
+ /* @__PURE__ */t("span",{children:"Rendering diagram…"})]})]})]}),Qe=x.showHeader&&/* @__PURE__ */e("div",{className:lt("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:[
110
110
  /* @__PURE__ */e("div",{className:"flex items-center space-x-2 overflow-hidden",children:[
111
111
  /* @__PURE__ */t("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:b}}),
112
- /* @__PURE__ */t("span",{className:ot("text-sm font-medium font-mono truncate",x.isDark?"text-gray-400":"text-gray-600"),children:"Mermaid"})]}),x.showModeToggle&&P&&/* @__PURE__ */e("div",{className:ot("flex items-center space-x-1 rounded-md p-0.5",x.isDark?"bg-gray-700":"bg-gray-100"),children:[
113
- /* @__PURE__ */t("button",{type:"button",className:ot("px-2.5 py-1 text-xs rounded transition-colors",R?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:()=>Ue("preview"),onMouseEnter:e=>_e(e,k("common.preview")),onFocus:e=>_e(e,k("common.preview")),onMouseLeave:()=>Be(),onBlur:()=>Be(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
112
+ /* @__PURE__ */t("span",{className:lt("text-sm font-medium font-mono truncate",x.isDark?"text-gray-400":"text-gray-600"),children:"Mermaid"})]}),x.showModeToggle&&P&&/* @__PURE__ */e("div",{className:lt("flex items-center space-x-1 rounded-md p-0.5",x.isDark?"bg-gray-700":"bg-gray-100"),children:[
113
+ /* @__PURE__ */t("button",{type:"button",className:lt("px-2.5 py-1 text-xs rounded transition-colors",R?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:()=>Ue("preview"),onMouseEnter:e=>_e(e,k("common.preview")),onFocus:e=>_e(e,k("common.preview")),onMouseLeave:()=>Be(),onBlur:()=>Be(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
114
114
  /* @__PURE__ */t("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:[
115
115
  /* @__PURE__ */t("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"}),
116
116
  /* @__PURE__ */t("circle",{cx:"12",cy:"12",r:"3"})]})}),
117
117
  /* @__PURE__ */t("span",{children:k("common.preview")})]})}),
118
- /* @__PURE__ */t("button",{type:"button",className:ot("px-2.5 py-1 text-xs rounded transition-colors",R?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:()=>Ue("source"),onMouseEnter:e=>_e(e,k("common.source")),onFocus:e=>_e(e,k("common.source")),onMouseLeave:()=>Be(),onBlur:()=>Be(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
118
+ /* @__PURE__ */t("button",{type:"button",className:lt("px-2.5 py-1 text-xs rounded transition-colors",R?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:()=>Ue("source"),onMouseEnter:e=>_e(e,k("common.source")),onFocus:e=>_e(e,k("common.source")),onMouseLeave:()=>Be(),onBlur:()=>Be(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
119
119
  /* @__PURE__ */t("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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m16 18l6-6l-6-6M8 6l-6 6l6 6"})}),
120
120
  /* @__PURE__ */t("span",{children:k("common.source")})]})})]}),
121
121
  /* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[x.showCollapseButton&&/* @__PURE__ */t("button",{type:"button",className:Xe,"aria-pressed":W,onClick:()=>I(e=>!e),onMouseEnter:e=>_e(e,k(W?"common.expand":"common.collapse")),onFocus:e=>_e(e,k(W?"common.expand":"common.collapse")),onMouseLeave:()=>Be(),onBlur:()=>Be(),children:/* @__PURE__ */t("svg",{style:{rotate:W?"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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),x.showCopyButton&&/* @__PURE__ */t("button",{type:"button",className:Xe,onClick:Fe,onMouseEnter:e=>_e(e,k(_?"common.copied":"common.copy")),onFocus:e=>_e(e,k(_?"common.copied":"common.copy")),onMouseLeave:()=>Be(),onBlur:()=>Be(),children:/* @__PURE__ */t("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__ */t("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:[
122
122
  /* @__PURE__ */t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
123
- /* @__PURE__ */t("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&&P&&/* @__PURE__ */t("button",{type:"button",className:ot(Xe,Ke?"opacity-50 cursor-not-allowed":""),disabled:Ke,onClick:je,onMouseEnter:e=>_e(e,k("common.export")),onFocus:e=>_e(e,k("common.export")),onMouseLeave:()=>Be(),onBlur:()=>Be(),children:/* @__PURE__ */t("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:[
123
+ /* @__PURE__ */t("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&&P&&/* @__PURE__ */t("button",{type:"button",className:lt(Xe,Ke?"opacity-50 cursor-not-allowed":""),disabled:Ke,onClick:je,onMouseEnter:e=>_e(e,k("common.export")),onFocus:e=>_e(e,k("common.export")),onMouseLeave:()=>Be(),onBlur:()=>Be(),children:/* @__PURE__ */t("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:[
124
124
  /* @__PURE__ */t("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),
125
- /* @__PURE__ */t("path",{d:"m7 10l5 5l5-5"})]})})}),x.showFullscreenButton&&P&&/* @__PURE__ */t("button",{type:"button",className:ot(Xe,Ke?"opacity-50 cursor-not-allowed":""),disabled:Ke,onClick:re?ze:Ve,onMouseEnter:e=>_e(e,k(re?"common.minimize":"common.open")),onFocus:e=>_e(e,k(re?"common.minimize":"common.open")),onMouseLeave:()=>Be(),onBlur:()=>Be(),children:/* @__PURE__ */t("svg",re?{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__ */t("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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})})]})]}),et=/* @__PURE__ */e("div",{children:[R?/* @__PURE__ */t("div",{className:ot("p-4",x.isDark?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-700"),children:/* @__PURE__ */t("pre",{className:"text-sm font-mono whitespace-pre-wrap",children:M})}):Je,te&&/* @__PURE__ */t("div",{className:"mermaid-error",children:te})]});/* @__PURE__ */
125
+ /* @__PURE__ */t("path",{d:"m7 10l5 5l5-5"})]})})}),x.showFullscreenButton&&P&&/* @__PURE__ */t("button",{type:"button",className:lt(Xe,Ke?"opacity-50 cursor-not-allowed":""),disabled:Ke,onClick:re?ze:Ve,onMouseEnter:e=>_e(e,k(re?"common.minimize":"common.open")),onFocus:e=>_e(e,k(re?"common.minimize":"common.open")),onMouseLeave:()=>Be(),onBlur:()=>Be(),children:/* @__PURE__ */t("svg",re?{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__ */t("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__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})})]})]}),et=/* @__PURE__ */e("div",{children:[R?/* @__PURE__ */t("div",{className:lt("p-4",x.isDark?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-700"),children:/* @__PURE__ */t("pre",{className:"text-sm font-mono whitespace-pre-wrap",children:M})}):Je,te&&/* @__PURE__ */t("div",{className:"mermaid-error",children:te})]});/* @__PURE__ */
126
126
  return e(n,{children:[
127
- /* @__PURE__ */e("div",{"data-markstream-mermaid":"1","data-markstream-mode":R?"source":J?"preview":"pending",className:ot("my-4 rounded-lg border overflow-hidden shadow-sm mermaid-block",x.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":Ee}),children:[Qe,
127
+ /* @__PURE__ */e("div",{"data-markstream-mermaid":"1","data-markstream-mode":R?"source":J?"preview":"pending",className:lt("my-4 rounded-lg border overflow-hidden shadow-sm mermaid-block",x.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":Te}),children:[Qe,
128
128
  /* @__PURE__ */t("div",{ref:pe,style:{display:W?"none":""},children:et})]}),re&&"undefined"!=typeof document&&ee(
129
- /* @__PURE__ */t("div",{className:"mermaid-modal-overlay",onClick:()=>ze(),children:/* @__PURE__ */e("div",{className:ot("mermaid-modal-panel",{"is-dark":x.isDark}),role:"dialog","aria-modal":"true",onClick:e=>e.stopPropagation(),children:[
129
+ /* @__PURE__ */t("div",{className:"mermaid-modal-overlay",onClick:()=>ze(),children:/* @__PURE__ */e("div",{className:lt("mermaid-modal-panel",{"is-dark":x.isDark}),role:"dialog","aria-modal":"true",onClick:e=>e.stopPropagation(),children:[
130
130
  /* @__PURE__ */e("div",{className:"mermaid-modal-header",children:[
131
131
  /* @__PURE__ */t("span",{className:"mermaid-modal-title",children:`Mermaid ${k("common.preview")}`}),
132
132
  /* @__PURE__ */t("button",{type:"button",className:"mermaid-modal-close",onClick:ze,children:k("common.close")})]}),
133
- /* @__PURE__ */t("div",{className:"mermaid-modal-body",children:/* @__PURE__ */t("div",{ref:fe,className:"mermaid-modal-content"})})]})}),document.body)]})}function Qn(e,t,n){return Math.min(Math.max(e,t),n)}async function er(e,t,n){try{if(await Rn(e,t,n.workerTimeout))return!0}catch(l){if("AbortError"===(null==l?void 0:l.name))throw l}if(!n.mermaid)throw new Error("Mermaid not available");const r=tr(e,t),o=n.mermaid;if("function"==typeof o.parse)return await ir(()=>o.parse(r),{timeoutMs:n.parseTimeout,signal:n.signal}),!0;const i=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;return await ir(()=>o.render(i,r),{timeoutMs:n.parseTimeout,signal:n.signal}),!0}function tr(e,t){return e.trimStart().startsWith("%%{")?e:`%%{init: {"theme": "${"dark"===t?"dark":"default"}"}}%%\n${e}`}function nr(e){var t;for(const n of e.split(/\r?\n/)){const e=n.trim();if(!e||e.startsWith("%%"))continue;const r=e.match(/^([A-Z][\w-]*)\b/i);return(null==(t=null==r?void 0:r[1])?void 0:t.toLowerCase())||""}return""}function rr(e){const t=e.trim();return!(!t||t.startsWith("%%"))&&!/^(?:gantt|title|dateformat|axisformat|tickinterval|excludes|section|todaymarker|topaxis|weekday|weekend|acctitle|accdescr|accdescrmultiline)\b/i.test(t)&&t.includes(":")}function or(e){if("gantt"===nr(e))return function(e){var t;const n=e.split(/\r?\n/);for(!/\r?\n$/.test(e)&&n.length>0&&n.pop();n.length>0;){const e=null==(t=n[n.length-1])?void 0:t.trim();if(e&&!e.startsWith("%%")){if(rr(e))break;n.pop()}else n.pop()}return n.some(rr)?n.join("\n"):""}(e);const t=e.split("\n");for(;t.length>0;){const e=t[t.length-1].trimEnd();if(""!==e){if(!(/^[-=~>|<\s]+$/.test(e.trim())||/(?:--|==|~~|->|<-|-\||-\)|-x|o-|\|-|\.-)\s*$/.test(e)||/[-|><]$/.test(e)||/(?:graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt)\s*$/i.test(e)))break;t.pop()}else t.pop()}return t.join("\n")}async function ir(e,t={}){const{timeoutMs:n,signal:r}=t;return(null==r?void 0:r.aborted)?Promise.reject(new DOMException("Aborted","AbortError")):new Promise((t,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}),n&&n>0&&(l=setTimeout(()=>{i||(i=!0,c(),o(new Error("Operation timed out")))},n)),e().then(e=>{i||(i=!0,c(),t(e))}).catch(e=>{i||(i=!0,c(),o(e))})})}function lr(e){return(new XMLSerializer).serializeToString(e)}function ar(t){const{node:n}=t;/* @__PURE__ */
134
- return e("div",{className:"unknown-node text-sm text-gray-500 italic",children:["Unsupported node type:"," ",String(null==n?void 0:n.type)]})}function cr(e){var t;return"text"===(null==e?void 0:e.type)&&""===String(null!=(t=null==e?void 0:e.content)?t:"").trim()}function sr(e,n,o,i){const l=e.filter(e=>!cr(e)),a=l.length>0&&l.every(e=>"image"===e.type||function(e){var t;const n=function(e){return"link"===(null==e?void 0:e.type)&&Array.isArray(null==e?void 0:e.children)?e.children.filter(e=>!cr(e)):[]}(e);return 1===n.length&&"image"===(null==(t=n[0])?void 0:t.type)}(e));if(!a||l.length<=1)return L(e,o,i,n);const c=[];for(let t=0;t<e.length;t++){const n=e[t];if(!cr(n)){c.push(n);continue}const r=c.length>0,o=e.slice(t+1).some(e=>!cr(e));r&&o&&c.push({...n,content:" ",raw:" "})}return c.map((e,l)=>{var c;return a&&cr(e)?/* @__PURE__ */t(r.Fragment,{children:String(null!=(c=null==e?void 0:e.content)?c:"")},`${i}-${l}`):n(e,`${i}-${l}`,o)})}function dr(e){var o,i;const{node:l,ctx:a,renderNode:c,indexKey:s,children:d}=e;if(!a||!c)/* @__PURE__ */
133
+ /* @__PURE__ */t("div",{className:"mermaid-modal-body",children:/* @__PURE__ */t("div",{ref:fe,className:"mermaid-modal-content"})})]})}),document.body)]})}function tr(e,t,n){return Math.min(Math.max(e,t),n)}async function nr(e,t,n){try{if(await Wn(e,t,n.workerTimeout))return!0}catch(l){if("AbortError"===(null==l?void 0:l.name))throw l}if(!n.mermaid)throw new Error("Mermaid not available");const r=rr(e,t),o=n.mermaid;if("function"==typeof o.parse)return await ar(()=>o.parse(r),{timeoutMs:n.parseTimeout,signal:n.signal}),!0;const i=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;return await ar(()=>o.render(i,r),{timeoutMs:n.parseTimeout,signal:n.signal}),!0}function rr(e,t){return e.trimStart().startsWith("%%{")?e:`%%{init: {"theme": "${"dark"===t?"dark":"default"}"}}%%\n${e}`}function or(e){var t;for(const n of e.split(/\r?\n/)){const e=n.trim();if(!e||e.startsWith("%%"))continue;const r=e.match(/^([A-Z][\w-]*)\b/i);return(null==(t=null==r?void 0:r[1])?void 0:t.toLowerCase())||""}return""}function ir(e){const t=e.trim();return!(!t||t.startsWith("%%"))&&!/^(?:gantt|title|dateformat|axisformat|tickinterval|excludes|section|todaymarker|topaxis|weekday|weekend|acctitle|accdescr|accdescrmultiline)\b/i.test(t)&&t.includes(":")}function lr(e){if("gantt"===or(e))return function(e){var t;const n=e.split(/\r?\n/);for(!/\r?\n$/.test(e)&&n.length>0&&n.pop();n.length>0;){const e=null==(t=n[n.length-1])?void 0:t.trim();if(e&&!e.startsWith("%%")){if(ir(e))break;n.pop()}else n.pop()}return n.some(ir)?n.join("\n"):""}(e);const t=e.split("\n");for(;t.length>0;){const e=t[t.length-1].trimEnd();if(""!==e){if(!(/^[-=~>|<\s]+$/.test(e.trim())||/(?:--|==|~~|->|<-|-\||-\)|-x|o-|\|-|\.-)\s*$/.test(e)||/[-|><]$/.test(e)||/(?:graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt)\s*$/i.test(e)))break;t.pop()}else t.pop()}return t.join("\n")}async function ar(e,t={}){const{timeoutMs:n,signal:r}=t;return(null==r?void 0:r.aborted)?Promise.reject(new DOMException("Aborted","AbortError")):new Promise((t,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}),n&&n>0&&(l=setTimeout(()=>{i||(i=!0,c(),o(new Error("Operation timed out")))},n)),e().then(e=>{i||(i=!0,c(),t(e))}).catch(e=>{i||(i=!0,c(),o(e))})})}function cr(e){return(new XMLSerializer).serializeToString(e)}function sr(t){const{node:n}=t;/* @__PURE__ */
134
+ return e("div",{className:"unknown-node text-sm text-gray-500 italic",children:["Unsupported node type:"," ",String(null==n?void 0:n.type)]})}function dr(e){var t;return"text"===(null==e?void 0:e.type)&&""===String(null!=(t=null==e?void 0:e.content)?t:"").trim()}function ur(e,n,o,i){const l=e.filter(e=>!dr(e)),a=l.length>0&&l.every(e=>"image"===e.type||function(e){var t;const n=function(e){return"link"===(null==e?void 0:e.type)&&Array.isArray(null==e?void 0:e.children)?e.children.filter(e=>!dr(e)):[]}(e);return 1===n.length&&"image"===(null==(t=n[0])?void 0:t.type)}(e));if(!a||l.length<=1)return L(e,o,i,n);const c=[];for(let t=0;t<e.length;t++){const n=e[t];if(!dr(n)){c.push(n);continue}const r=c.length>0,o=e.slice(t+1).some(e=>!dr(e));r&&o&&c.push({...n,content:" ",raw:" "})}return c.map((e,l)=>{var c;return a&&dr(e)?/* @__PURE__ */t(r.Fragment,{children:String(null!=(c=null==e?void 0:e.content)?c:"")},`${i}-${l}`):n(e,`${i}-${l}`,o)})}function mr(e){var o,i;const{node:l,ctx:a,renderNode:c,indexKey:s,children:d}=e;if(!a||!c)/* @__PURE__ */
135
135
  return t("p",{dir:"auto",className:"paragraph-node",children:d});const u=null!=(o=l.children)?o:[],m=null!=(i=a.customComponents)?i:H(a.customId),h=[],p=[],f=()=>{if(!p.length)return;const e=h.length;h.push(
136
- /* @__PURE__ */t("p",{dir:"auto",className:"paragraph-node",children:sr(p.slice(),c,a,`${String(null!=s?s:"paragraph")}-${e}`)},`${String(null!=s?s:"paragraph")}-inline-${e}`)),p.length=0};return u.forEach((e,n)=>{G.has(e.type)||J(e,m,a.customHtmlTags)?(f(),h.push(
137
- /* @__PURE__ */t(r.Fragment,{children:c(e,`${String(null!=s?s:"paragraph")}-block-${n}`,a)},`${String(null!=s?s:"paragraph")}-block-${n}`))):p.push(e)}),f(),h.length?/* @__PURE__ */t(n,{children:h}):/* @__PURE__ */t("p",{dir:"auto",className:"paragraph-node",children:sr(u,c,a,String(null!=s?s:"paragraph"))})}function ur(e){const{node:n}=e,r=d(t=>{var r;null==(r=e.onClick)||r.call(e,t,n.id,e.messageId,e.threadId)},[n.id,e]);/* @__PURE__ */
138
- return t("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:t=>{var r;null==(r=e.onMouseEnter)||r.call(e,t,n.id,e.messageId,e.threadId)},onMouseLeave:t=>{var r;null==(r=e.onMouseLeave)||r.call(e,t,n.id,e.messageId,e.threadId)},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||r(e)},children:n.id})}function mr(e){/* @__PURE__ */
139
- return t("s",{className:"strikethrough-node",children:e.children})}function hr(e){/* @__PURE__ */
140
- return t("strong",{className:"strong-node",children:e.children})}function pr(e){/* @__PURE__ */
141
- return t("sub",{className:"subscript-node",children:e.children})}function fr(e){/* @__PURE__ */
142
- return t("sup",{className:"superscript-node",children:e.children})}function gr(n){var o;const{node:i,ctx:l,renderNode:a,indexKey:c}=n,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),p=r.useRef(null),[f,g]=r.useState([]),w=e=>"right"===e?"text-right":"center"===e?"text-center":"text-left",v=()=>{const e=p.current;e&&(window.removeEventListener("pointermove",e.move),window.removeEventListener("pointerup",e.stop),window.removeEventListener("pointercancel",e.stop),p.current=null),h.current=null};return r.useEffect(()=>(v(),g([]),v),[s.length]),/* @__PURE__ */e("div",{className:"table-node-wrapper","data-index-key":c,children:[
143
- /* @__PURE__ */e("table",{ref:m,className:ot("my-8 text-sm table-node",d&&"table-node--loading"),"aria-busy":d,children:[f.length>0&&/* @__PURE__ */t("colgroup",{children:s.map((e,n)=>/* @__PURE__ */t("col",{style:f[n]>0?{width:`${f[n]}px`}:void 0},`col-${n}`))}),
144
- /* @__PURE__ */t("thead",{className:"border-[var(--table-border,#cbd5e1)]",children:/* @__PURE__ */t("tr",{className:"border-b",children:s.map((n,r)=>/* @__PURE__ */e("th",{className:ot("font-semibold p-[calc(4/7*1em)]",w(n.align)),dir:"auto",children:[l&&a?P(n.children,l,`${String(null!=c?c:"table")}-th-${r}`,a):null,r<s.length-1&&/* @__PURE__ */t("button",{type:"button",className:"table-node__resize-handle","aria-label":`Resize columns ${r+1} and ${r+2}`,onPointerDown:e=>((e,t)=>{if(0!==t.button)return;const n=(()=>{var e;const t=null==(e=m.current)?void 0:e.querySelectorAll("thead th");return Array.from(null!=t?t:[],e=>Math.round(e.getBoundingClientRect().width))})(),r=n[e],o=n[e+1];if(!r||!o)return;t.preventDefault(),v(),h.current={index:e,startX:t.clientX,startWidth:r,nextStartWidth:o,widths:n},g(n);const i=e=>{const t=h.current;if(!t)return;e.preventDefault();const n=t.startWidth+t.nextStartWidth,r=Math.min(48,Math.floor(n/2)),o=Math.max(r,Math.min(n-r,Math.round(t.startWidth+e.clientX-t.startX))),i=[...t.widths];i[t.index]=o,i[t.index+1]=n-o,g(i)},l=()=>{v()};p.current={move:i,stop:l},window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l)})(r,e)})]},`header-${r}`))})}),
136
+ /* @__PURE__ */t("p",{dir:"auto",className:"paragraph-node",children:ur(p.slice(),c,a,`${String(null!=s?s:"paragraph")}-${e}`)},`${String(null!=s?s:"paragraph")}-inline-${e}`)),p.length=0};return u.forEach((e,n)=>{G.has(e.type)||J(e,m,a.customHtmlTags)?(f(),h.push(
137
+ /* @__PURE__ */t(r.Fragment,{children:c(e,`${String(null!=s?s:"paragraph")}-block-${n}`,a)},`${String(null!=s?s:"paragraph")}-block-${n}`))):p.push(e)}),f(),h.length?/* @__PURE__ */t(n,{children:h}):/* @__PURE__ */t("p",{dir:"auto",className:"paragraph-node",children:ur(u,c,a,String(null!=s?s:"paragraph"))})}function hr(e){const{node:n}=e,r=d(t=>{var r;null==(r=e.onClick)||r.call(e,t,n.id,e.messageId,e.threadId)},[n.id,e]);/* @__PURE__ */
138
+ return t("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:t=>{var r;null==(r=e.onMouseEnter)||r.call(e,t,n.id,e.messageId,e.threadId)},onMouseLeave:t=>{var r;null==(r=e.onMouseLeave)||r.call(e,t,n.id,e.messageId,e.threadId)},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||r(e)},children:n.id})}function pr(e){/* @__PURE__ */
139
+ return t("s",{className:"strikethrough-node",children:e.children})}function fr(e){/* @__PURE__ */
140
+ return t("strong",{className:"strong-node",children:e.children})}function gr(e){/* @__PURE__ */
141
+ return t("sub",{className:"subscript-node",children:e.children})}function wr(e){/* @__PURE__ */
142
+ return t("sup",{className:"superscript-node",children:e.children})}function vr(n){var o;const{node:i,ctx:l,renderNode:a,indexKey:c}=n,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),p=r.useRef(null),[f,g]=r.useState([]),w=e=>"right"===e?"text-right":"center"===e?"text-center":"text-left",v=()=>{const e=p.current;e&&(window.removeEventListener("pointermove",e.move),window.removeEventListener("pointerup",e.stop),window.removeEventListener("pointercancel",e.stop),p.current=null),h.current=null};return r.useEffect(()=>(v(),g([]),v),[s.length]),/* @__PURE__ */e("div",{className:"table-node-wrapper","data-index-key":c,children:[
143
+ /* @__PURE__ */e("table",{ref:m,className:lt("my-8 text-sm table-node",d&&"table-node--loading"),"aria-busy":d,children:[f.length>0&&/* @__PURE__ */t("colgroup",{children:s.map((e,n)=>/* @__PURE__ */t("col",{style:f[n]>0?{width:`${f[n]}px`}:void 0},`col-${n}`))}),
144
+ /* @__PURE__ */t("thead",{className:"border-[var(--table-border,#cbd5e1)]",children:/* @__PURE__ */t("tr",{className:"border-b",children:s.map((n,r)=>/* @__PURE__ */e("th",{className:lt("font-semibold p-[calc(4/7*1em)]",w(n.align)),dir:"auto",children:[l&&a?P(n.children,l,`${String(null!=c?c:"table")}-th-${r}`,a):null,r<s.length-1&&/* @__PURE__ */t("button",{type:"button",className:"table-node__resize-handle","aria-label":`Resize columns ${r+1} and ${r+2}`,onPointerDown:e=>((e,t)=>{if(0!==t.button)return;const n=(()=>{var e;const t=null==(e=m.current)?void 0:e.querySelectorAll("thead th");return Array.from(null!=t?t:[],e=>Math.round(e.getBoundingClientRect().width))})(),r=n[e],o=n[e+1];if(!r||!o)return;t.preventDefault(),v(),h.current={index:e,startX:t.clientX,startWidth:r,nextStartWidth:o,widths:n},g(n);const i=e=>{const t=h.current;if(!t)return;e.preventDefault();const n=t.startWidth+t.nextStartWidth,r=Math.min(48,Math.floor(n/2)),o=Math.max(r,Math.min(n-r,Math.round(t.startWidth+e.clientX-t.startX))),i=[...t.widths];i[t.index]=o,i[t.index+1]=n-o,g(i)},l=()=>{v()};p.current={move:i,stop:l},window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l)})(r,e)})]},`header-${r}`))})}),
145
145
  /* @__PURE__ */t("tbody",{children:u.map((e,n)=>{var r;/* @__PURE__ */
146
- return t("tr",{className:ot("border-[var(--table-border,#cbd5e1)]",n<u.length-1&&"border-b"),children:null==(r=e.cells)?void 0:r.map((e,r)=>/* @__PURE__ */t("td",{className:ot("p-[calc(4/7*1em)]",w(e.align)),dir:"auto",children:l&&a?P(e.children,l,`${String(null!=c?c:"table")}-row-${n}-${r}`,a):null},`cell-${n}-${r}`))},`row-${n}`)})})]}),d&&/* @__PURE__ */e("div",{className:"table-node__loading",role:"status","aria-live":"polite",children:[
146
+ return t("tr",{className:lt("border-[var(--table-border,#cbd5e1)]",n<u.length-1&&"border-b"),children:null==(r=e.cells)?void 0:r.map((e,r)=>/* @__PURE__ */t("td",{className:lt("p-[calc(4/7*1em)]",w(e.align)),dir:"auto",children:l&&a?P(e.children,l,`${String(null!=c?c:"table")}-row-${n}-${r}`,a):null},`cell-${n}-${r}`))},`row-${n}`)})})]}),d&&/* @__PURE__ */e("div",{className:"table-node__loading",role:"status","aria-live":"polite",children:[
147
147
  /* @__PURE__ */t("span",{className:"table-node__spinner","aria-hidden":"true"}),
148
- /* @__PURE__ */t("span",{className:"sr-only",children:"Loading"})]})]})}function wr(){/* @__PURE__ */
149
- return t("hr",{className:"hr-node thematic-break"})}function vr(e){const{node:n,ctx:i,renderNode:l,indexKey:a}=e,c=`vmr-container vmr-container-${n.name}`,s=o(()=>{if(n.attrs)return Array.isArray(n.attrs)?W(n.attrs):n.attrs},[n.attrs]);/* @__PURE__ */
150
- return t("div",{className:c,...s,children:i&&l&&Array.isArray(n.children)?n.children.map((e,n)=>/* @__PURE__ */t(r.Fragment,{children:l(e,`${String(null!=a?a:"vmr-container")}-${n}`,i)},`${String(null!=a?a:"vmr-container")}-${n}`)):null})}function yr(e,t,n,o){return r.createElement(e,{key:n,node:t,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter})}function xr(e,n,o){var i,l,a,c,s,d,u,m,h;const p=null!=(i=o.customComponents)?i:H(o.customId),f="code_block"===e.type?null:p[e.type];if(f)return r.createElement(f,{key:n,node:e,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter});if("html_block"===e.type||"html_inline"===e.type){const i=Q(e,p,o.customHtmlTags),h=String(null!=(l=e.tag)?l:"").trim().toLowerCase()||k(e.content),f=null!=(a=null==i?void 0:i.tag)?a:h;if(f){const l=null!=(c=null==i?void 0:i.component)?c:p[f],a=null!=(d=null==i?void 0:i.isWhitelisted)?d:(null!=(s=o.customHtmlTags)?s:[]).some(e=>e.toLowerCase()===f);if(a&&l){const t={...e,type:f,tag:f,content:b(e.content,f)};return r.createElement(l,{key:n,node:t,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter})}const h=String(null!=(m=null!=(u=e.content)?u:e.raw)?m:"");if(!a&&C(h,f))return"html_inline"===e.type?/* @__PURE__ */t(Kt,{node:{type:"text",content:h,raw:h},ctx:o,indexKey:n,typewriter:o.typewriter},n):/* @__PURE__ */t(dr,{node:{type:"paragraph",children:[{type:"text",content:h,raw:h}],raw:h},ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter},n)}}switch(e.type){case"text":/* @__PURE__ */
151
- return t(Kt,{node:e,ctx:o,indexKey:n,typewriter:o.typewriter},n);case"text_special":/* @__PURE__ */
152
- return t(Kt,{node:{type:"text",content:null!=(h=e.content)?h:"",center:e.center},ctx:o,indexKey:n,typewriter:o.typewriter},n);case"paragraph":/* @__PURE__ */
153
- return t(dr,{node:e,ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter},n);case"heading":/* @__PURE__ */
154
- return t(Bt,{node:e,ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter},n);case"blockquote":/* @__PURE__ */
155
- return t(Nr,{node:e,ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter},n);case"list":/* @__PURE__ */
156
- return t(qt,{node:e,ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter},n);case"list_item":/* @__PURE__ */
157
- return t(Ut,{node:e,ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter},n);case"table":/* @__PURE__ */
158
- return t(gr,{node:e,ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter},n);case"definition_list":/* @__PURE__ */
159
- return t(yt,{node:e,ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter},n);case"footnote":/* @__PURE__ */
160
- return t(Ct,{node:e,ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter},n);case"footnote_reference":/* @__PURE__ */
161
- return t(Mt,{node:e},n);case"footnote_anchor":/* @__PURE__ */
162
- return t(bt,{node:e},n);case"admonition":/* @__PURE__ */
163
- return t(ae,{node:e,ctx:o,renderNode:xr,indexKey:n,isDark:o.isDark,typewriter:o.typewriter},n);case"hardbreak":/* @__PURE__ */
164
- return t(Nt,{node:e,typewriter:o.typewriter},n);case"link":/* @__PURE__ */
165
- return t(Xt,{node:e,ctx:o,renderNode:xr,indexKey:n,isDark:o.isDark,showTooltip:"boolean"==typeof o.showTooltips?o.showTooltips:void 0,typewriter:o.typewriter},n);case"image":/* @__PURE__ */
166
- return t(Ht,{node:e},n);case"inline_code":/* @__PURE__ */
167
- return t(zt,{node:e,ctx:o,indexKey:n,typewriter:o.typewriter},n);case"code_block":return function(e,n,o,i){var l,a,c,s;const d=function(e){const t=String((null==e?void 0:e.language)||"").trim();if(!t)return"";const[n]=t.split(/\s+/),[r]=n.split(":");return r.toLowerCase()}(e),u=T(d),m=d?i[d]:null;if("mermaid"===u){const l=function(e,t){var n,r;const o={...t.mermaidProps||{}};return null==q(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=Y(Z(String(null!=(n=null==e?void 0:e.code)?n:"")),void 0,"none"===o.maxHeight?null:null!=(r=q(o.maxHeight))?r:void 0)),o}(e,o),a=m||i.mermaid;if(a)return r.createElement(a,{key:n,node:e,isDark:o.isDark,...l});if(!o.renderCodeBlocksAsPre)/* @__PURE__ */
168
- return t(Jn,{node:e,isDark:o.isDark,loading:Boolean(e.loading),...l},n)}if("infographic"===u){const l=function(e,t){var n,r;const o={...t.infographicProps||{}};return null==V(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=K(X(String(null!=(n=null==e?void 0:e.code)?n:"")),void 0,"none"===o.maxHeight?null:null!=(r=V(o.maxHeight))?r:void 0)),o}(e,o),a=m||i.infographic;return a?r.createElement(a,{key:n,node:e,isDark:o.isDark,...l}):/* @__PURE__ */t(jt,{node:e,isDark:o.isDark,loading:Boolean(e.loading),...l},n)}if("d2"===u||"d2lang"===u){const l=m||i.d2;return l?r.createElement(l,{key:n,node:e,isDark:o.isDark,...o.d2Props||{}}):/* @__PURE__ */t(vt,{node:e,isDark:o.isDark,loading:Boolean(e.loading),...o.d2Props||{}},n)}if(m)return yr(m,e,n,o);const h=i.code_block;return h?yr(h,e,n,o):o.renderCodeBlocksAsPre||"mermaid"===u?/* @__PURE__ */t(Ye,{node:e},n):/* @__PURE__ */t(nt,{node:e,loading:Boolean(e.loading),stream:o.codeBlockStream,monacoOptions:null==(l=o.codeBlockThemes)?void 0:l.monacoOptions,themes:null==(a=o.codeBlockThemes)?void 0:a.themes,minWidth:null==(c=o.codeBlockThemes)?void 0:c.minWidth,maxWidth:null==(s=o.codeBlockThemes)?void 0:s.maxWidth,isDark:o.isDark,onCopy:o.events.onCopy,...o.codeBlockProps||{}},n)}(e,n,o,p);case"strong":/* @__PURE__ */
169
- return t(hr,{node:e,children:L(e.children,o,`${String(n)}-strong`,xr)},n);case"emphasis":/* @__PURE__ */
170
- return t(kt,{node:e,children:L(e.children,o,`${String(n)}-em`,xr)},n);case"strikethrough":/* @__PURE__ */
171
- return t(mr,{node:e,children:L(e.children,o,`${String(n)}-strike`,xr)},n);case"highlight":/* @__PURE__ */
172
- return t(Lt,{node:e,children:L(e.children,o,`${String(n)}-highlight`,xr)},n);case"insert":/* @__PURE__ */
173
- return t(Vt,{node:e,children:L(e.children,o,`${String(n)}-insert`,xr)},n);case"subscript":/* @__PURE__ */
174
- return t(pr,{node:e,children:L(e.children,o,`${String(n)}-sub`,xr)},n);case"superscript":/* @__PURE__ */
175
- return t(fr,{node:e,children:L(e.children,o,`${String(n)}-sup`,xr)},n);case"checkbox":case"checkbox_input":/* @__PURE__ */
148
+ /* @__PURE__ */t("span",{className:"sr-only",children:"Loading"})]})]})}function yr(){/* @__PURE__ */
149
+ return t("hr",{className:"hr-node thematic-break"})}function xr(e){const{node:n,ctx:i,renderNode:l,indexKey:a}=e,c=`vmr-container vmr-container-${n.name}`,s=o(()=>{if(n.attrs)return Array.isArray(n.attrs)?W(n.attrs):n.attrs},[n.attrs]);/* @__PURE__ */
150
+ return t("div",{className:c,...s,children:i&&l&&Array.isArray(n.children)?n.children.map((e,n)=>/* @__PURE__ */t(r.Fragment,{children:l(e,`${String(null!=a?a:"vmr-container")}-${n}`,i)},`${String(null!=a?a:"vmr-container")}-${n}`)):null})}function kr(e,t,n,o){return r.createElement(e,{key:n,node:t,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter})}function br(e,n,o){var i,l,a,c,s,d,u,m,h;const p=null!=(i=o.customComponents)?i:H(o.customId),f="code_block"===e.type?null:p[e.type];if(f)return r.createElement(f,{key:n,node:e,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter});if("html_block"===e.type||"html_inline"===e.type){const i=Q(e,p,o.customHtmlTags),h=String(null!=(l=e.tag)?l:"").trim().toLowerCase()||k(e.content),f=null!=(a=null==i?void 0:i.tag)?a:h;if(f){const l=null!=(c=null==i?void 0:i.component)?c:p[f],a=null!=(d=null==i?void 0:i.isWhitelisted)?d:(null!=(s=o.customHtmlTags)?s:[]).some(e=>e.toLowerCase()===f);if(a&&l){const t={...e,type:f,tag:f,content:b(e.content,f)};return r.createElement(l,{key:n,node:t,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter})}const h=String(null!=(m=null!=(u=e.content)?u:e.raw)?m:"");if(!a&&C(h,f))return"html_inline"===e.type?/* @__PURE__ */t(Ut,{node:{type:"text",content:h,raw:h},ctx:o,indexKey:n,typewriter:o.typewriter},n):/* @__PURE__ */t(mr,{node:{type:"paragraph",children:[{type:"text",content:h,raw:h}],raw:h},ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter},n)}}switch(e.type){case"text":/* @__PURE__ */
151
+ return t(Ut,{node:e,ctx:o,indexKey:n,typewriter:o.typewriter},n);case"text_special":/* @__PURE__ */
152
+ return t(Ut,{node:{type:"text",content:null!=(h=e.content)?h:"",center:e.center},ctx:o,indexKey:n,typewriter:o.typewriter},n);case"paragraph":/* @__PURE__ */
153
+ return t(mr,{node:e,ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter},n);case"heading":/* @__PURE__ */
154
+ return t(St,{node:e,ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter},n);case"blockquote":/* @__PURE__ */
155
+ return t(Lr,{node:e,ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter},n);case"list":/* @__PURE__ */
156
+ return t(Zt,{node:e,ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter},n);case"list_item":/* @__PURE__ */
157
+ return t(Yt,{node:e,ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter},n);case"table":/* @__PURE__ */
158
+ return t(vr,{node:e,ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter},n);case"definition_list":/* @__PURE__ */
159
+ return t(kt,{node:e,ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter},n);case"footnote":/* @__PURE__ */
160
+ return t(Nt,{node:e,ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter},n);case"footnote_reference":/* @__PURE__ */
161
+ return t(Bt,{node:e},n);case"footnote_anchor":/* @__PURE__ */
162
+ return t(Mt,{node:e},n);case"admonition":/* @__PURE__ */
163
+ return t(ae,{node:e,ctx:o,renderNode:br,indexKey:n,isDark:o.isDark,typewriter:o.typewriter},n);case"hardbreak":/* @__PURE__ */
164
+ return t(Lt,{node:e,typewriter:o.typewriter},n);case"link":/* @__PURE__ */
165
+ return t(qt,{node:e,ctx:o,renderNode:br,indexKey:n,isDark:o.isDark,showTooltip:"boolean"==typeof o.showTooltips?o.showTooltips:void 0,typewriter:o.typewriter},n);case"image":/* @__PURE__ */
166
+ return t(It,{node:e},n);case"inline_code":/* @__PURE__ */
167
+ return t(Kt,{node:e,ctx:o,indexKey:n,typewriter:o.typewriter},n);case"code_block":return function(e,n,o,i){var l,a,c,s;const d=function(e){const t=String((null==e?void 0:e.language)||"").trim();if(!t)return"";const[n]=t.split(/\s+/),[r]=n.split(":");return r.toLowerCase()}(e),u=S(d),m=d?i[d]:null;if("mermaid"===u){const l=function(e,t){var n,r;const o={...t.mermaidProps||{}};return null==q(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=Y(Z(String(null!=(n=null==e?void 0:e.code)?n:"")),void 0,"none"===o.maxHeight?null:null!=(r=q(o.maxHeight))?r:void 0)),o}(e,o),a=m||i.mermaid;if(a)return r.createElement(a,{key:n,node:e,isDark:o.isDark,...l});if(!o.renderCodeBlocksAsPre)/* @__PURE__ */
168
+ return t(er,{node:e,isDark:o.isDark,loading:Boolean(e.loading),...l},n)}if("infographic"===u){const l=function(e,t){var n,r;const o={...t.infographicProps||{}};return null==V(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=K(X(String(null!=(n=null==e?void 0:e.code)?n:"")),void 0,"none"===o.maxHeight?null:null!=(r=V(o.maxHeight))?r:void 0)),o}(e,o),a=m||i.infographic;return a?r.createElement(a,{key:n,node:e,isDark:o.isDark,...l}):/* @__PURE__ */t(zt,{node:e,isDark:o.isDark,loading:Boolean(e.loading),...l},n)}if("d2"===u||"d2lang"===u){const l=m||i.d2;return l?r.createElement(l,{key:n,node:e,isDark:o.isDark,...o.d2Props||{}}):/* @__PURE__ */t(xt,{node:e,isDark:o.isDark,loading:Boolean(e.loading),...o.d2Props||{}},n)}if(m)return kr(m,e,n,o);const h=i.code_block;return h?kr(h,e,n,o):o.renderCodeBlocksAsPre||"mermaid"===u?/* @__PURE__ */t(Ge,{node:e},n):/* @__PURE__ */t(ot,{node:e,loading:Boolean(e.loading),stream:o.codeBlockStream,monacoOptions:null==(l=o.codeBlockThemes)?void 0:l.monacoOptions,themes:null==(a=o.codeBlockThemes)?void 0:a.themes,minWidth:null==(c=o.codeBlockThemes)?void 0:c.minWidth,maxWidth:null==(s=o.codeBlockThemes)?void 0:s.maxWidth,isDark:o.isDark,onCopy:o.events.onCopy,...o.codeBlockProps||{}},n)}(e,n,o,p);case"strong":/* @__PURE__ */
169
+ return t(fr,{node:e,children:L(e.children,o,`${String(n)}-strong`,br)},n);case"emphasis":/* @__PURE__ */
170
+ return t(Ct,{node:e,children:L(e.children,o,`${String(n)}-em`,br)},n);case"strikethrough":/* @__PURE__ */
171
+ return t(pr,{node:e,children:L(e.children,o,`${String(n)}-strike`,br)},n);case"highlight":/* @__PURE__ */
172
+ return t(Tt,{node:e,children:L(e.children,o,`${String(n)}-highlight`,br)},n);case"insert":/* @__PURE__ */
173
+ return t(Xt,{node:e,children:L(e.children,o,`${String(n)}-insert`,br)},n);case"subscript":/* @__PURE__ */
174
+ return t(gr,{node:e,children:L(e.children,o,`${String(n)}-sub`,br)},n);case"superscript":/* @__PURE__ */
175
+ return t(wr,{node:e,children:L(e.children,o,`${String(n)}-sup`,br)},n);case"checkbox":case"checkbox_input":/* @__PURE__ */
176
176
  return t(he,{node:e,typewriter:o.typewriter},n);case"emoji":/* @__PURE__ */
177
- return t(xt,{node:e,typewriter:o.typewriter},n);case"thematic_break":/* @__PURE__ */
178
- return t(wr,{},n);case"math_inline":/* @__PURE__ */
179
- return t(kn,{node:e},n);case"math_block":/* @__PURE__ */
180
- return t(xn,{node:e},n);case"reference":/* @__PURE__ */
181
- return t(ur,{node:e,ctx:o,typewriter:o.typewriter},n);case"html_block":case"html_inline":return"html_block"===e.type?/* @__PURE__ */t(Tt,{node:e,ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter,customId:o.customId},n):/* @__PURE__ */t(At,{node:e,ctx:o,typewriter:o.typewriter,customId:o.customId},n);case"vmr_container":/* @__PURE__ */
182
- return t(vr,{node:e,ctx:o,renderNode:xr,indexKey:n,typewriter:o.typewriter},n);case"label_open":case"label_close":return null;default:/* @__PURE__ */
183
- return t(ar,{node:e},n)}}const kr={codeBlockStream:!0,typewriter:!0,batchRendering:!0,initialRenderBatchSize:40,renderBatchSize:80,renderBatchDelay:16,renderBatchBudgetMs:6,renderBatchIdleTimeoutMs:120,deferNodesUntilVisible:!0,maxLiveNodes:320,liveNodeBuffer:60},br=N(),Cr=r.memo(({props:n,parsedNodes:r,renderCtx:l,indexPrefix:c,containerRef:u})=>{var m,h,p,f,g,w,v;const y=me(),x="undefined"!=typeof window,k="undefined"!=typeof window&&"function"==typeof window.requestIdleCallback,b=Math.max(0,Math.trunc(null!=(m=n.renderBatchSize)?m:80)),C=Math.max(0,Math.trunc(null!=(h=n.initialRenderBatchSize)?h:b||r.length)),M=!1!==n.batchRendering&&b>0&&x,N=Math.max(0,null!=(p=n.liveNodeBuffer)?p:60),B=Math.max(1,null!=(f=n.maxLiveNodes)?f:320),L=(null!=(g=n.maxLiveNodes)?g:0)>0&&r.length>B,T=!1!==n.viewportPriority,E=M&&(null!=(w=n.maxLiveNodes)?w:0)<=0,S=o(()=>{var e;return!1!==n.deferNodesUntilVisible&&!((null!=(e=n.maxLiveNodes)?e:0)<=0)&&!L&&!(r.length>900)&&T},[r.length,n.deferNodesUntilVisible,n.maxLiveNodes,T,L]),[D,$]=i(()=>E?Math.min(r.length,C):r.length),P=a(D);s(()=>{P.current=D},[D]);const A=E?D:r.length,[R,H]=i(0),[W,I]=i({start:0,end:r.length}),_=a(/* @__PURE__ */new Map),[F,j]=i(0),O=a({}),z=a(/* @__PURE__ */new Map),V=a(/* @__PURE__ */new Map),K=a(/* @__PURE__ */new Map),X=a(/* @__PURE__ */new Map),U=a(/* @__PURE__ */new Set),q=a(D),Y=a(null),Z=a(null),G=a(null),J=a(!1),Q=a(null),ee=a(Math.max(1,b||1)),te=a(r.length),ne=a({key:n.indexKey,total:r.length}),re=a({batchSize:b,initial:C,delay:null!=(v=n.renderBatchDelay)?v:16,enabled:E}),oe=S||L,ie=o(()=>{const e=_.current;if(!e.size)return 32;let t=0;for(const n of e.values())t+=n;return Math.max(16,t/e.size)},[F]),le=o(()=>{if(!L)return r.map((e,t)=>({node:e,index:t}));const e=r.length,t=Math.max(0,Math.min(W.start,e)),n=Math.max(t,Math.min(W.end,e));return r.slice(t,n).map((e,n)=>({node:e,index:t+n}))},[r,W,L]),ae=o(()=>{if(!L)return r.length;const e=Math.max(W.end+N,C),t=Math.min(r.length,e);return Math.max(D,t)},[r.length,L,W.end,N,C,D]);te.current=ae;const ce=d((e,t)=>{var n;if(e>=t)return 0;const r=_.current;let o=0;for(let i=e;i<t;i++)o+=null!=(n=r.get(i))?n:ie;return o},[ie]),se=L?ce(0,Math.min(W.start,r.length)):0,de=L?ce(Math.min(W.end,r.length),r.length):0,ue=d(()=>{null!=Y.current&&"function"==typeof cancelAnimationFrame&&(cancelAnimationFrame(Y.current),Y.current=null),null!=Z.current&&(window.clearTimeout(Z.current),Z.current=null),null!=G.current&&"function"==typeof window.cancelIdleCallback&&(window.cancelIdleCallback(G.current),G.current=null),J.current=!1,Q.current=null},[]),he=d(e=>{var t;if(!E)return;const r=Math.max(2,null!=(t=n.renderBatchBudgetMs)?t:6),o=Math.max(1,b||1),i=Math.max(1,Math.floor(o/4));e>1.2*r?ee.current=Math.max(i,Math.floor(.7*ee.current)):e<.5*r&&ee.current<o&&(ee.current=Math.min(o,Math.ceil(1.2*ee.current)))},[E,n.renderBatchBudgetMs,b]),pe=d((e,t={})=>{var r,o;if(!E)return;const i=te.current;if(P.current>=i)return;const l=Math.max(1,e),a=e=>{const t="undefined"!=typeof performance?performance.now():Date.now();$(t=>{const n=Math.min(te.current,t+Math.max(1,e));return P.current=n,n});const n="undefined"!=typeof performance?performance.now():Date.now();he(n-t)},c=()=>{const e=Math.max(1,Math.round(ee.current));pe(e)},s=e=>{var t;Y.current=null,Z.current=null,G.current=null,J.current=!1;const r=Q.current;if(Q.current=null,a(null!=r?r:l),P.current>=te.current)return;if(!e)return void c();const o=Math.max(2,null!=(t=n.renderBatchBudgetMs)?t:6);for(;P.current<te.current&&!(("function"==typeof e.timeRemaining?e.timeRemaining():0)<=.5*o);)a(Math.max(1,Math.round(ee.current)));P.current<te.current&&c()};if(!x||t.immediate)return void s();const d=Math.max(0,null!=(r=n.renderBatchDelay)?r:16);if(Q.current=null!=Q.current?Math.max(Q.current,l):l,!J.current){if(J.current=!0,k){const e=Math.max(0,null!=(o=n.renderBatchIdleTimeoutMs)?o:120);return void(G.current=window.requestIdleCallback(e=>s(e),{timeout:e}))}"function"==typeof requestAnimationFrame?Y.current=requestAnimationFrame(()=>{0!==d?Z.current=window.setTimeout(()=>s(),d):s()}):Z.current=window.setTimeout(()=>s(),d)}},[he,k,E,x,n.renderBatchDelay,n.renderBatchBudgetMs,n.renderBatchIdleTimeoutMs]);s(()=>{var e;const t=n.indexKey,o=r.length,i=ne.current,l=void 0!==t?t!==i.key:o!==i.total;ne.current={key:t,total:o};const a=re.current,c=null!=(e=n.renderBatchDelay)?e:16,s=a.batchSize!==b||a.initial!==C||a.delay!==c||a.enabled!==E;if(re.current={batchSize:b,initial:C,delay:c,enabled:E},(l||s||!E)&&ue(),(l||s)&&(ee.current=Math.max(1,b||1),U.current.clear()),!o)return P.current=0,void $(0);const d=te.current;if(!E)return P.current=d,void $(d);if(l||s){const e=Math.min(d,C);return P.current=e,$(e),void(e<d&&pe(Math.max(1,C),{immediate:!x}))}const u=Math.min(P.current,d);u!==P.current&&(P.current=u,$(u)),P.current<d&&pe(Math.max(1,b||1))},[ue,E,x,r.length,n.indexKey,n.renderBatchDelay,b,C,pe]),s(()=>{if(!L)return void I({start:0,end:r.length});const e=r.length;if(!e)return void I({start:0,end:0});const t=Math.max(0,Math.min(R,e-1));let n=Math.max(0,t-N),o=Math.min(e,t+N+1);const i=o-n;if(i>B){const e=i-B;n+=Math.ceil(e/2),o-=Math.floor(e/2)}else if(i<B){const t=B-i;n=Math.max(0,n-Math.ceil(t/2)),o=Math.min(e,o+Math.floor(t/2))}I({start:n,end:o})},[R,N,B,r.length,L]),s(()=>()=>{ue();for(const e of z.current.values())e.destroy();z.current.clear()},[ue]);const fe=d(e=>{for(const[t,n]of z.current.entries())t>=e&&(n.destroy(),z.current.delete(t),delete O.current[t],V.current.delete(t),K.current.delete(t),X.current.delete(t))},[]);s(()=>{fe(A)},[fe,A]),s(()=>{const e=r.length;let t=!1;for(const n of Array.from(_.current.keys()))n>=e&&(_.current.delete(n),t=!0);t&&j(e=>e+1);for(const n of Object.keys(O.current))Number(n)>=e&&delete O.current[n];for(const n of Array.from(U.current))n>=e&&U.current.delete(n)},[r.length]);const ge=d((e,t)=>{S&&t&&(O.current[e]=!0),t&&L&&H(t=>e>t?e:t)},[S,L]),we=d(e=>{const t=z.current.get(e);t&&(t.destroy(),z.current.delete(e))},[]),ve=d((e,t)=>{const n=V.current;if(t?n.set(e,t):n.delete(e),!oe||!t)return we(e),S&&!t&&delete O.current[e],void(t&&ge(e,!0));if(e<C&&!L)return we(e),void ge(e,!0);we(e);const r=y(t,{rootMargin:"400px"});z.current.set(e,r),r.isVisible()&&ge(e,!0),r.whenVisible.then(()=>ge(e,!0)).catch(()=>{})},[S,we,ge,y,C,oe,L]),ye=d(e=>{const t=K.current.get(e);if(t)return t;const n=t=>ve(e,t);return K.current.set(e,n),n},[ve]),xe=d((e,t)=>{if(!t)return void(_.current.has(e)&&(_.current.delete(e),j(e=>e+1)));const n=()=>{const n=t.offsetHeight;n&&_.current.get(e)!==n&&(_.current.set(e,n),j(e=>e+1))};"function"==typeof queueMicrotask?queueMicrotask(n):Promise.resolve().then(n)},[]),ke=d(e=>{const t=X.current.get(e);if(t)return t;const n=t=>xe(e,t);return X.current.set(e,n),n},[xe]),be=d(e=>!(E&&e>=P.current)&&(!S||e<C||!0===O.current[e]),[S,E,C]),Ce=d(e=>t=>{if(!e)return;const n=t.target;(null==n?void 0:n.closest("[data-node-index]"))&&e(t)},[]);s(()=>{for(const[e,t]of V.current.entries())t&&ve(e,t)},[ve]),s(()=>{L&&D>q.current&&H(D-1),q.current=D},[D,L]);const Me=L?/* @__PURE__ */t("div",{className:"node-spacer",style:{height:`${se}px`},"aria-hidden":"true"}):null,Ne=L?/* @__PURE__ */t("div",{className:"node-spacer",style:{height:`${de}px`},"aria-hidden":"true"}):null;/* @__PURE__ */
184
- return e("div",{ref:u,className:`markstream-react markdown-renderer${n.isDark?" dark":""}${L?" virtualized":""}`,"data-custom-id":n.customId,onClick:n.onClick,onMouseOver:Ce(n.onMouseOver),onMouseOut:Ce(n.onMouseOut),children:[Me,le.map(({node:e,index:r})=>{var o;const i=be(r),a=null!=(o=_.current.get(r))?o:ie,s=!1!==n.typewriter&&"code_block"!==e.type&&!U.current.has(r)&&i;return s&&U.current.add(r),/* @__PURE__ */t("div",{ref:ye(r),className:"node-slot","data-node-index":r,"data-node-type":e.type,children:/* @__PURE__ */t("div",i?{ref:ke(r),className:"node-content"+(s?" typewriter-node":""),children:xr(e,`${c}-${r}`,l)}:{className:"node-placeholder",style:{height:`${a}px`}})},`${c}-${r}`)}),Ne]})},function(e,t){if(e.parsedNodes!==t.parsedNodes)return!1;if(e.renderCtx!==t.renderCtx)return!1;if(e.indexPrefix!==t.indexPrefix)return!1;if(e.containerRef!==t.containerRef)return!1;const n=e.props,r=t.props;return n.isDark===r.isDark&&n.typewriter===r.typewriter&&n.batchRendering===r.batchRendering&&n.initialRenderBatchSize===r.initialRenderBatchSize&&n.renderBatchSize===r.renderBatchSize&&n.renderBatchDelay===r.renderBatchDelay&&n.renderBatchBudgetMs===r.renderBatchBudgetMs&&n.renderBatchIdleTimeoutMs===r.renderBatchIdleTimeoutMs&&n.deferNodesUntilVisible===r.deferNodesUntilVisible&&n.maxLiveNodes===r.maxLiveNodes&&n.liveNodeBuffer===r.liveNodeBuffer&&n.viewportPriority===r.viewportPriority&&n.indexKey===r.indexKey&&n.onClick===r.onClick&&n.onMouseOver===r.onMouseOver&&n.onMouseOut===r.onMouseOut}),Mr=e=>{var n,r;const i={...kr,...e},l=a(null),c=a(null),d=a(/* @__PURE__ */new Map),m=a(null),h=a(0);(null==(n=m.current)?void 0:n.content)===i.content&&(null==(r=m.current)?void 0:r.nodes)===i.nodes||(h.current+=1,m.current={content:i.content,nodes:i.nodes});const p=u(A,R,R),f=o(()=>H(i.customId),[i.customId,p]),g=o(()=>i.customId?`renderer-${i.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,[i.customId]),w=o(()=>{var e,t;const n=null!=(t=(null!=(e=i.parseOptions)?e:{}).customHtmlTags)?t:[];return M(i.customHtmlTags,Array.isArray(n)?n:[])},[i.customId,i.customHtmlTags,i.parseOptions,p]),v=o(()=>{const e=w;return e&&0!==e.length?N(g,{customHtmlTags:e}):N(g)},[g,w]),y=o(()=>{const e=v;return i.customMarkdownIt?i.customMarkdownIt(e):e},[v,i.customMarkdownIt]),x=o(()=>{var e,t;const n=null!=(e=i.parseOptions)?e:{},r=null!=(t=i.final)?t:n.final,o=null!=r,l=w.length>0;return o||l?{...n,...o?{final:r}:{},...l?{customHtmlTags:w}:{}}:n},[w,i.final,i.parseOptions]),k=o(()=>{var e,t;const n=Boolean(i.debugPerformance)&&"undefined"!=typeof console&&"undefined"!=typeof performance,r=n?performance.now():0;let o=[];return Array.isArray(i.nodes)&&i.nodes.length?o=i.nodes.map(e=>({...e})):i.content&&(o=B(i.content,null!=y?y:br,x)),n&&console.info("[markstream-react][perf] parse(sync)",{ms:Math.round(performance.now()-r),nodes:o.length,contentLength:null!=(t=null==(e=i.content)?void 0:e.length)?t:0}),o},[i.content,i.debugPerformance,i.nodes,x,y,i.customId,p,w]);s(()=>{var e,t;if("undefined"==typeof window)return;if(i.renderCodeBlocksAsPre)return;if(!k.some(e=>{var t;return"code_block"===(null==e?void 0:e.type)&&"mermaid"!==T(String(null!=(t=null==e?void 0:e.language)?t:""))}))return;const n=null!=(e=window.requestIdleCallback)?e:(e,t)=>{var n;return window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),null!=(n=null==t?void 0:t.timeout)?n:600)},r=null!=(t=window.cancelIdleCallback)?t:e=>window.clearTimeout(e),o=n(()=>{De()},{timeout:900});return()=>r(o)},[k,i.renderCodeBlocksAsPre]),s(()=>{if("undefined"==typeof window)return;if(i.renderCodeBlocksAsPre)return;const e=i.isDark?i.codeBlockDarkTheme:i.codeBlockLightTheme,t="string"==typeof e?e:"object"==typeof e&&e&&"name"in e?String(e.name):null;t&&c.current!==t&&(c.current=t,function(e){if(null==e)return;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 t=Xe.get(e);if(t)return t;try{const t=JSON.stringify(e);if(t)return Xe.set(e,t),t}catch{}const n="__theme_"+ ++Ue;return Xe.set(e,n),n}return String(e)}(e);t&&ze!==t&&(Oe=e,ze=t,Ve&&je(Oe,Ve).then(()=>qe()).catch(()=>{}))}(e))},[i.codeBlockDarkTheme,i.codeBlockLightTheme,i.isDark,i.renderCodeBlocksAsPre]);const b=o(()=>null!=i.indexKey?String(i.indexKey):"markdown-renderer",[i.indexKey]),C=o(()=>({..."boolean"==typeof i.showTooltips?{showTooltips:i.showTooltips}:{},...i.codeBlockProps||{}}),[i.codeBlockProps,i.showTooltips]),L=o(()=>({...i.mermaidProps||{}}),[i.mermaidProps]),E=o(()=>({...i.d2Props||{}}),[i.d2Props]),S=o(()=>({...i.infographicProps||{}}),[i.infographicProps]),D=o(()=>{var e;return{customId:i.customId,isDark:i.isDark,indexKey:b,typewriter:i.typewriter,textStreamState:d.current,streamRenderVersion:h.current,customComponents:f,customHtmlTags:w,htmlPolicy:null!=(e=i.htmlPolicy)?e:"safe",showTooltips:i.showTooltips,renderCodeBlocksAsPre:i.renderCodeBlocksAsPre,codeBlockStream:i.codeBlockStream,codeBlockProps:C,mermaidProps:L,d2Props:E,infographicProps:S,codeBlockThemes:{themes:i.themes,monacoOptions:i.codeBlockMonacoOptions,minWidth:i.codeBlockMinWidth,maxWidth:i.codeBlockMaxWidth},events:{onCopy:i.onCopy,onHandleArtifactClick:i.onHandleArtifactClick}}},[i.customId,i.isDark,b,i.typewriter,i.showTooltips,i.htmlPolicy,i.renderCodeBlocksAsPre,i.codeBlockStream,w,C,L,E,S,i.themes,i.codeBlockMonacoOptions,i.codeBlockMinWidth,i.codeBlockMaxWidth,h.current,i.onCopy,i.onHandleArtifactClick,f]);/* @__PURE__ */
185
- return t(ue,{getRoot:()=>l.current,enabled:!1!==i.viewportPriority,children:/* @__PURE__ */t(Cr,{props:i,parsedNodes:k,renderCtx:D,indexPrefix:b,containerRef:l})})};function Nr(e){var n,r,o,i,l,a;const{node:c,ctx:s,renderNode:d,indexKey:u,children:m}=e;/* @__PURE__ */
186
- return t("blockquote",{className:"blockquote-node",dir:"auto",cite:c.cite,children:null!=m?m:s&&d?/* @__PURE__ */t(Mr,{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==(n=s.codeBlockThemes)?void 0:n.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 Br(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},c=o(()=>{var e;return String(null!=(e=l.node.language)?e:"")},[l.node.language]),u=o(()=>function(e){var t;const[n]=String(null!=e?e:"").split(":");return(null!=(t=null==n?void 0:n.trim().toLowerCase())?t:"")||"plaintext"}(c),[c]),m=o(()=>T(c),[c]),[h,p]=i(0);s(()=>E(()=>{p(e=>e+1)}),[]);const f=o(()=>{const e=$[m]||m;return e?e.charAt(0).toUpperCase()+e.slice(1):"Text"},[m]),g=o(()=>D(m),[m,h]),{t:w}=ge(),v=o(()=>!!l.isShowPreview&&("html"===m||"svg"===m),[m,l.isShowPreview]),y=o(()=>{const e={},t=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},n=t(l.minWidth),r=t(l.maxWidth);return n&&(e.minWidth=n),r&&(e.maxWidth=r),e},[l.maxWidth,l.minWidth]),[x,k]=i(!1),[b,C]=i(!1),[M,N]=i(!1),[B,L]=i(""),[S,P]=i(!1),[A,R]=i(14),[H,W]=i(A),I=o(()=>!1!==l.showTooltips,[l.showTooltips]),_=a(null),F=a(null),j=a(null),O=a(null),z=a(null),V=a(!1),K=a(null),X=me(),[U,q]=i(()=>"undefined"==typeof window),Y=d(()=>l.isDark?l.darkTheme:l.lightTheme,[l.darkTheme,l.isDark,l.lightTheme]),Z=d(e=>{if(!e)return L(""),void P(!1);var t;L(`<pre class="shiki shiki-fallback"><code>${t=e,t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}</code></pre>`),P(!1)},[]),G=d(()=>{L(""),P(!0)},[]),J=d(async()=>{if(!z.current&&!V.current){V.current=!0;try{const e=await import("stream-markdown");z.current=e.createShikiStreamRenderer}catch{}}},[]),Q=d(async()=>{if(U)if(await J(),F.current&&j.current)if(!O.current&&z.current&&(O.current=z.current(j.current,{theme:Y(),themes:l.themes}),P(!0)),O.current)if(!1===l.stream&&l.loading)Z(l.node.code);else{Z(l.node.code);try{await O.current.updateCode(l.node.code,u),G()}catch{}}else Z(l.node.code);else Z(l.node.code);else Z(l.node.code)},[G,J,Y,u,l.loading,l.node.code,l.stream,l.themes,Z,U]);s(()=>{const e=_.current;if(!e)return;const t=X(e,{rootMargin:"400px"});return K.current=t,t.isVisible()&&q(!0),t.whenVisible.then(()=>q(!0)),()=>{t.destroy(),K.current=null}},[X]),s(()=>(Q(),()=>{var e;null==(e=O.current)||e.dispose(),O.current=null}),[Q]),s(()=>{O.current&&U&&O.current.setTheme(Y())},[Y,U]),s(()=>{U?O.current&&(!1===l.stream&&l.loading||(Z(l.node.code),Promise.resolve(O.current.updateCode(l.node.code,u)).then(()=>G()).catch(()=>{}))):Z(l.node.code)},[G,u,l.loading,l.node.code,l.stream,Z,U]),s(()=>{I||Be(!0)},[I]);const ee=d((e,t)=>{if(!I)return;const n=e.currentTarget;n&&!n.disabled&&("clientX"in e&&(e.clientX,e.clientY),Ne(n,t,"top",!1,0,l.isDark))},[l.isDark,I]),te=d(()=>{I&&Be()},[I]),ne=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(l.node.code),k(!0),null==(e=l.onCopy)||e.call(l,l.node.code),setTimeout(()=>k(!1),1e3)}catch{}},[l]),re=d(()=>{var e;if(!v)return;const t="html"===u?"text/html":"image/svg+xml",n="html"===u?"HTML Preview":"SVG Preview";null==(e=l.onPreviewCode)||e.call(l,{type:t,content:l.node.code,title:n})},[v,u,l]),oe=o(()=>({fontSize:`${H}px`}),[H]);return s(()=>{R(14),W(14)},[]),/* @__PURE__ */e("div",{ref:_,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:y,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:[
177
+ return t(bt,{node:e,typewriter:o.typewriter},n);case"thematic_break":/* @__PURE__ */
178
+ return t(yr,{},n);case"math_inline":/* @__PURE__ */
179
+ return t(Cn,{node:e},n);case"math_block":/* @__PURE__ */
180
+ return t(bn,{node:e},n);case"reference":/* @__PURE__ */
181
+ return t(hr,{node:e,ctx:o,typewriter:o.typewriter},n);case"html_block":case"html_inline":return"html_block"===e.type?/* @__PURE__ */t(Et,{node:e,ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter,customId:o.customId},n):/* @__PURE__ */t(Ht,{node:e,ctx:o,typewriter:o.typewriter,customId:o.customId},n);case"vmr_container":/* @__PURE__ */
182
+ return t(xr,{node:e,ctx:o,renderNode:br,indexKey:n,typewriter:o.typewriter},n);case"label_open":case"label_close":return null;default:/* @__PURE__ */
183
+ return t(sr,{node:e},n)}}const Cr={codeBlockStream:!0,typewriter:!0,batchRendering:!0,initialRenderBatchSize:40,renderBatchSize:80,renderBatchDelay:16,renderBatchBudgetMs:6,renderBatchIdleTimeoutMs:120,deferNodesUntilVisible:!0,maxLiveNodes:320,liveNodeBuffer:60},Mr=N(),Nr=r.memo(({props:n,parsedNodes:r,renderCtx:l,indexPrefix:c,containerRef:u})=>{var m,h,p,f,g,w,v;const y=me(),x="undefined"!=typeof window,k="undefined"!=typeof window&&"function"==typeof window.requestIdleCallback,b=Math.max(0,Math.trunc(null!=(m=n.renderBatchSize)?m:80)),C=Math.max(0,Math.trunc(null!=(h=n.initialRenderBatchSize)?h:b||r.length)),M=!1!==n.batchRendering&&b>0&&x,N=Math.max(0,null!=(p=n.liveNodeBuffer)?p:60),B=Math.max(1,null!=(f=n.maxLiveNodes)?f:320),L=(null!=(g=n.maxLiveNodes)?g:0)>0&&r.length>B,S=!1!==n.viewportPriority,T=M&&(null!=(w=n.maxLiveNodes)?w:0)<=0,E=o(()=>{var e;return!1!==n.deferNodesUntilVisible&&!((null!=(e=n.maxLiveNodes)?e:0)<=0)&&!L&&!(r.length>900)&&S},[r.length,n.deferNodesUntilVisible,n.maxLiveNodes,S,L]),[D,$]=i(()=>T?Math.min(r.length,C):r.length),P=a(D);s(()=>{P.current=D},[D]);const A=T?D:r.length,[R,H]=i(0),[W,I]=i({start:0,end:r.length}),_=a(/* @__PURE__ */new Map),[F,j]=i(0),O=a({}),z=a(/* @__PURE__ */new Map),V=a(/* @__PURE__ */new Map),K=a(/* @__PURE__ */new Map),X=a(/* @__PURE__ */new Map),U=a(/* @__PURE__ */new Set),q=a(D),Y=a(null),Z=a(null),G=a(null),J=a(!1),Q=a(null),ee=a(Math.max(1,b||1)),te=a(r.length),ne=a({key:n.indexKey,total:r.length}),re=a({batchSize:b,initial:C,delay:null!=(v=n.renderBatchDelay)?v:16,enabled:T}),oe=E||L,ie=o(()=>{const e=_.current;if(!e.size)return 32;let t=0;for(const n of e.values())t+=n;return Math.max(16,t/e.size)},[F]),le=o(()=>{if(!L)return r.map((e,t)=>({node:e,index:t}));const e=r.length,t=Math.max(0,Math.min(W.start,e)),n=Math.max(t,Math.min(W.end,e));return r.slice(t,n).map((e,n)=>({node:e,index:t+n}))},[r,W,L]),ae=o(()=>{if(!L)return r.length;const e=Math.max(W.end+N,C),t=Math.min(r.length,e);return Math.max(D,t)},[r.length,L,W.end,N,C,D]);te.current=ae;const ce=d((e,t)=>{var n;if(e>=t)return 0;const r=_.current;let o=0;for(let i=e;i<t;i++)o+=null!=(n=r.get(i))?n:ie;return o},[ie]),se=L?ce(0,Math.min(W.start,r.length)):0,de=L?ce(Math.min(W.end,r.length),r.length):0,ue=d(()=>{null!=Y.current&&"function"==typeof cancelAnimationFrame&&(cancelAnimationFrame(Y.current),Y.current=null),null!=Z.current&&(window.clearTimeout(Z.current),Z.current=null),null!=G.current&&"function"==typeof window.cancelIdleCallback&&(window.cancelIdleCallback(G.current),G.current=null),J.current=!1,Q.current=null},[]),he=d(e=>{var t;if(!T)return;const r=Math.max(2,null!=(t=n.renderBatchBudgetMs)?t:6),o=Math.max(1,b||1),i=Math.max(1,Math.floor(o/4));e>1.2*r?ee.current=Math.max(i,Math.floor(.7*ee.current)):e<.5*r&&ee.current<o&&(ee.current=Math.min(o,Math.ceil(1.2*ee.current)))},[T,n.renderBatchBudgetMs,b]),pe=d((e,t={})=>{var r,o;if(!T)return;const i=te.current;if(P.current>=i)return;const l=Math.max(1,e),a=e=>{const t="undefined"!=typeof performance?performance.now():Date.now();$(t=>{const n=Math.min(te.current,t+Math.max(1,e));return P.current=n,n});const n="undefined"!=typeof performance?performance.now():Date.now();he(n-t)},c=()=>{const e=Math.max(1,Math.round(ee.current));pe(e)},s=e=>{var t;Y.current=null,Z.current=null,G.current=null,J.current=!1;const r=Q.current;if(Q.current=null,a(null!=r?r:l),P.current>=te.current)return;if(!e)return void c();const o=Math.max(2,null!=(t=n.renderBatchBudgetMs)?t:6);for(;P.current<te.current&&!(("function"==typeof e.timeRemaining?e.timeRemaining():0)<=.5*o);)a(Math.max(1,Math.round(ee.current)));P.current<te.current&&c()};if(!x||t.immediate)return void s();const d=Math.max(0,null!=(r=n.renderBatchDelay)?r:16);if(Q.current=null!=Q.current?Math.max(Q.current,l):l,!J.current){if(J.current=!0,k){const e=Math.max(0,null!=(o=n.renderBatchIdleTimeoutMs)?o:120);return void(G.current=window.requestIdleCallback(e=>s(e),{timeout:e}))}"function"==typeof requestAnimationFrame?Y.current=requestAnimationFrame(()=>{0!==d?Z.current=window.setTimeout(()=>s(),d):s()}):Z.current=window.setTimeout(()=>s(),d)}},[he,k,T,x,n.renderBatchDelay,n.renderBatchBudgetMs,n.renderBatchIdleTimeoutMs]);s(()=>{var e;const t=n.indexKey,o=r.length,i=ne.current,l=void 0!==t?t!==i.key:o!==i.total;ne.current={key:t,total:o};const a=re.current,c=null!=(e=n.renderBatchDelay)?e:16,s=a.batchSize!==b||a.initial!==C||a.delay!==c||a.enabled!==T;if(re.current={batchSize:b,initial:C,delay:c,enabled:T},(l||s||!T)&&ue(),(l||s)&&(ee.current=Math.max(1,b||1),U.current.clear()),!o)return P.current=0,void $(0);const d=te.current;if(!T)return P.current=d,void $(d);if(l||s){const e=Math.min(d,C);return P.current=e,$(e),void(e<d&&pe(Math.max(1,C),{immediate:!x}))}const u=Math.min(P.current,d);u!==P.current&&(P.current=u,$(u)),P.current<d&&pe(Math.max(1,b||1))},[ue,T,x,r.length,n.indexKey,n.renderBatchDelay,b,C,pe]),s(()=>{if(!L)return void I({start:0,end:r.length});const e=r.length;if(!e)return void I({start:0,end:0});const t=Math.max(0,Math.min(R,e-1));let n=Math.max(0,t-N),o=Math.min(e,t+N+1);const i=o-n;if(i>B){const e=i-B;n+=Math.ceil(e/2),o-=Math.floor(e/2)}else if(i<B){const t=B-i;n=Math.max(0,n-Math.ceil(t/2)),o=Math.min(e,o+Math.floor(t/2))}I({start:n,end:o})},[R,N,B,r.length,L]),s(()=>()=>{ue();for(const e of z.current.values())e.destroy();z.current.clear()},[ue]);const fe=d(e=>{for(const[t,n]of z.current.entries())t>=e&&(n.destroy(),z.current.delete(t),delete O.current[t],V.current.delete(t),K.current.delete(t),X.current.delete(t))},[]);s(()=>{fe(A)},[fe,A]),s(()=>{const e=r.length;let t=!1;for(const n of Array.from(_.current.keys()))n>=e&&(_.current.delete(n),t=!0);t&&j(e=>e+1);for(const n of Object.keys(O.current))Number(n)>=e&&delete O.current[n];for(const n of Array.from(U.current))n>=e&&U.current.delete(n)},[r.length]);const ge=d((e,t)=>{E&&t&&(O.current[e]=!0),t&&L&&H(t=>e>t?e:t)},[E,L]),we=d(e=>{const t=z.current.get(e);t&&(t.destroy(),z.current.delete(e))},[]),ve=d((e,t)=>{const n=V.current;if(t?n.set(e,t):n.delete(e),!oe||!t)return we(e),E&&!t&&delete O.current[e],void(t&&ge(e,!0));if(e<C&&!L)return we(e),void ge(e,!0);we(e);const r=y(t,{rootMargin:"400px"});z.current.set(e,r),r.isVisible()&&ge(e,!0),r.whenVisible.then(()=>ge(e,!0)).catch(()=>{})},[E,we,ge,y,C,oe,L]),ye=d(e=>{const t=K.current.get(e);if(t)return t;const n=t=>ve(e,t);return K.current.set(e,n),n},[ve]),xe=d((e,t)=>{if(!t)return void(_.current.has(e)&&(_.current.delete(e),j(e=>e+1)));const n=()=>{const n=t.offsetHeight;n&&_.current.get(e)!==n&&(_.current.set(e,n),j(e=>e+1))};"function"==typeof queueMicrotask?queueMicrotask(n):Promise.resolve().then(n)},[]),ke=d(e=>{const t=X.current.get(e);if(t)return t;const n=t=>xe(e,t);return X.current.set(e,n),n},[xe]),be=d(e=>!(T&&e>=P.current)&&(!E||e<C||!0===O.current[e]),[E,T,C]),Ce=d(e=>t=>{if(!e)return;const n=t.target;(null==n?void 0:n.closest("[data-node-index]"))&&e(t)},[]);s(()=>{for(const[e,t]of V.current.entries())t&&ve(e,t)},[ve]),s(()=>{L&&D>q.current&&H(D-1),q.current=D},[D,L]);const Me=L?/* @__PURE__ */t("div",{className:"node-spacer",style:{height:`${se}px`},"aria-hidden":"true"}):null,Ne=L?/* @__PURE__ */t("div",{className:"node-spacer",style:{height:`${de}px`},"aria-hidden":"true"}):null;/* @__PURE__ */
184
+ return e("div",{ref:u,className:`markstream-react markdown-renderer${n.isDark?" dark":""}${L?" virtualized":""}`,"data-custom-id":n.customId,onClick:n.onClick,onMouseOver:Ce(n.onMouseOver),onMouseOut:Ce(n.onMouseOut),children:[Me,le.map(({node:e,index:r})=>{var o;const i=be(r),a=null!=(o=_.current.get(r))?o:ie,s=!1!==n.typewriter&&"code_block"!==e.type&&!U.current.has(r)&&i;return s&&U.current.add(r),/* @__PURE__ */t("div",{ref:ye(r),className:"node-slot","data-node-index":r,"data-node-type":e.type,children:/* @__PURE__ */t("div",i?{ref:ke(r),className:"node-content"+(s?" typewriter-node":""),children:br(e,`${c}-${r}`,l)}:{className:"node-placeholder",style:{height:`${a}px`}})},`${c}-${r}`)}),Ne]})},function(e,t){if(e.parsedNodes!==t.parsedNodes)return!1;if(e.renderCtx!==t.renderCtx)return!1;if(e.indexPrefix!==t.indexPrefix)return!1;if(e.containerRef!==t.containerRef)return!1;const n=e.props,r=t.props;return n.isDark===r.isDark&&n.typewriter===r.typewriter&&n.batchRendering===r.batchRendering&&n.initialRenderBatchSize===r.initialRenderBatchSize&&n.renderBatchSize===r.renderBatchSize&&n.renderBatchDelay===r.renderBatchDelay&&n.renderBatchBudgetMs===r.renderBatchBudgetMs&&n.renderBatchIdleTimeoutMs===r.renderBatchIdleTimeoutMs&&n.deferNodesUntilVisible===r.deferNodesUntilVisible&&n.maxLiveNodes===r.maxLiveNodes&&n.liveNodeBuffer===r.liveNodeBuffer&&n.viewportPriority===r.viewportPriority&&n.indexKey===r.indexKey&&n.onClick===r.onClick&&n.onMouseOver===r.onMouseOver&&n.onMouseOut===r.onMouseOut}),Br=e=>{var n,r;const i={...Cr,...e},l=a(null),c=a(null),d=a(/* @__PURE__ */new Map),m=a(null),h=a(0);(null==(n=m.current)?void 0:n.content)===i.content&&(null==(r=m.current)?void 0:r.nodes)===i.nodes||(h.current+=1,m.current={content:i.content,nodes:i.nodes});const p=u(A,R,R),f=o(()=>H(i.customId),[i.customId,p]),g=o(()=>i.customId?`renderer-${i.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,[i.customId]),w=o(()=>{var e,t;const n=null!=(t=(null!=(e=i.parseOptions)?e:{}).customHtmlTags)?t:[];return M(i.customHtmlTags,Array.isArray(n)?n:[])},[i.customId,i.customHtmlTags,i.parseOptions,p]),v=o(()=>{const e=w;return e&&0!==e.length?N(g,{customHtmlTags:e}):N(g)},[g,w]),y=o(()=>{const e=v;return i.customMarkdownIt?i.customMarkdownIt(e):e},[v,i.customMarkdownIt]),x=o(()=>{var e,t;const n=null!=(e=i.parseOptions)?e:{},r=null!=(t=i.final)?t:n.final,o=null!=r,l=w.length>0;return o||l?{...n,...o?{final:r}:{},...l?{customHtmlTags:w}:{}}:n},[w,i.final,i.parseOptions]),k=o(()=>{var e,t;const n=Boolean(i.debugPerformance)&&"undefined"!=typeof console&&"undefined"!=typeof performance,r=n?performance.now():0;let o=[];return Array.isArray(i.nodes)&&i.nodes.length?o=i.nodes.map(e=>({...e})):i.content&&(o=B(i.content,null!=y?y:Mr,x)),n&&console.info("[markstream-react][perf] parse(sync)",{ms:Math.round(performance.now()-r),nodes:o.length,contentLength:null!=(t=null==(e=i.content)?void 0:e.length)?t:0}),o},[i.content,i.debugPerformance,i.nodes,x,y,i.customId,p,w]);s(()=>{var e,t;if("undefined"==typeof window)return;if(i.renderCodeBlocksAsPre)return;if(!k.some(e=>{var t;return"code_block"===(null==e?void 0:e.type)&&"mermaid"!==S(String(null!=(t=null==e?void 0:e.language)?t:""))}))return;const n=null!=(e=window.requestIdleCallback)?e:(e,t)=>{var n;return window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),null!=(n=null==t?void 0:t.timeout)?n:600)},r=null!=(t=window.cancelIdleCallback)?t:e=>window.clearTimeout(e),o=n(()=>{Pe()},{timeout:900});return()=>r(o)},[k,i.renderCodeBlocksAsPre]),s(()=>{if("undefined"==typeof window)return;if(i.renderCodeBlocksAsPre)return;const e=i.isDark?i.codeBlockDarkTheme:i.codeBlockLightTheme,t="string"==typeof e?e:"object"==typeof e&&e&&"name"in e?String(e.name):null;t&&c.current!==t&&(c.current=t,function(e){if(null==e)return;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 t=qe.get(e);if(t)return t;try{const t=JSON.stringify(e);if(t)return qe.set(e,t),t}catch{}const n="__theme_"+ ++Ye;return qe.set(e,n),n}return String(e)}(e);t&&Ke!==t&&(Ve=e,Ke=t,Xe&&ze(Ve,Xe).then(()=>Ze()).catch(()=>{}))}(e))},[i.codeBlockDarkTheme,i.codeBlockLightTheme,i.isDark,i.renderCodeBlocksAsPre]);const b=o(()=>null!=i.indexKey?String(i.indexKey):"markdown-renderer",[i.indexKey]),C=o(()=>({..."boolean"==typeof i.showTooltips?{showTooltips:i.showTooltips}:{},...i.codeBlockProps||{}}),[i.codeBlockProps,i.showTooltips]),L=o(()=>({...i.mermaidProps||{}}),[i.mermaidProps]),T=o(()=>({...i.d2Props||{}}),[i.d2Props]),E=o(()=>({...i.infographicProps||{}}),[i.infographicProps]),D=o(()=>{var e;return{customId:i.customId,isDark:i.isDark,indexKey:b,typewriter:i.typewriter,textStreamState:d.current,streamRenderVersion:h.current,customComponents:f,customHtmlTags:w,htmlPolicy:null!=(e=i.htmlPolicy)?e:"safe",showTooltips:i.showTooltips,renderCodeBlocksAsPre:i.renderCodeBlocksAsPre,codeBlockStream:i.codeBlockStream,codeBlockProps:C,mermaidProps:L,d2Props:T,infographicProps:E,codeBlockThemes:{themes:i.themes,monacoOptions:i.codeBlockMonacoOptions,minWidth:i.codeBlockMinWidth,maxWidth:i.codeBlockMaxWidth},events:{onCopy:i.onCopy,onHandleArtifactClick:i.onHandleArtifactClick}}},[i.customId,i.isDark,b,i.typewriter,i.showTooltips,i.htmlPolicy,i.renderCodeBlocksAsPre,i.codeBlockStream,w,C,L,T,E,i.themes,i.codeBlockMonacoOptions,i.codeBlockMinWidth,i.codeBlockMaxWidth,h.current,i.onCopy,i.onHandleArtifactClick,f]);/* @__PURE__ */
185
+ return t(ue,{getRoot:()=>l.current,enabled:!1!==i.viewportPriority,children:/* @__PURE__ */t(Nr,{props:i,parsedNodes:k,renderCtx:D,indexPrefix:b,containerRef:l})})};function Lr(e){var n,r,o,i,l,a;const{node:c,ctx:s,renderNode:d,indexKey:u,children:m}=e;/* @__PURE__ */
186
+ return t("blockquote",{className:"blockquote-node",dir:"auto",cite:c.cite,children:null!=m?m:s&&d?/* @__PURE__ */t(Br,{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==(n=s.codeBlockThemes)?void 0:n.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 Sr(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},c=o(()=>{var e;return String(null!=(e=l.node.language)?e:"")},[l.node.language]),u=o(()=>function(e){var t;const[n]=String(null!=e?e:"").split(":");return(null!=(t=null==n?void 0:n.trim().toLowerCase())?t:"")||"plaintext"}(c),[c]),m=o(()=>S(c),[c]),[h,p]=i(0);s(()=>T(()=>{p(e=>e+1)}),[]);const f=o(()=>{const e=$[m]||m;return e?e.charAt(0).toUpperCase()+e.slice(1):"Text"},[m]),g=o(()=>D(m),[m,h]),{t:w}=ge(),v=o(()=>!!l.isShowPreview&&("html"===m||"svg"===m),[m,l.isShowPreview]),y=o(()=>{const e={},t=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},n=t(l.minWidth),r=t(l.maxWidth);return n&&(e.minWidth=n),r&&(e.maxWidth=r),e},[l.maxWidth,l.minWidth]),[x,k]=i(!1),[b,C]=i(!1),[M,N]=i(!1),[B,L]=i(""),[E,P]=i(!1),[A,R]=i(14),[H,W]=i(A),I=o(()=>!1!==l.showTooltips,[l.showTooltips]),_=a(null),F=a(null),j=a(null),O=a(null),z=a(null),V=a(!1),K=a(null),X=me(),[U,q]=i(()=>"undefined"==typeof window),Y=d(()=>l.isDark?l.darkTheme:l.lightTheme,[l.darkTheme,l.isDark,l.lightTheme]),Z=d(e=>{if(!e)return L(""),void P(!1);var t;L(`<pre class="shiki shiki-fallback"><code>${t=e,t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}</code></pre>`),P(!1)},[]),G=d(()=>{L(""),P(!0)},[]),J=d(async()=>{if(!z.current&&!V.current){V.current=!0;try{const e=await import("stream-markdown");z.current=e.createShikiStreamRenderer}catch{}}},[]),Q=d(async()=>{if(U)if(await J(),F.current&&j.current)if(!O.current&&z.current&&(O.current=z.current(j.current,{theme:Y(),themes:l.themes}),P(!0)),O.current)if(!1===l.stream&&l.loading)Z(l.node.code);else{Z(l.node.code);try{await O.current.updateCode(l.node.code,u),G()}catch{}}else Z(l.node.code);else Z(l.node.code);else Z(l.node.code)},[G,J,Y,u,l.loading,l.node.code,l.stream,l.themes,Z,U]);s(()=>{const e=_.current;if(!e)return;const t=X(e,{rootMargin:"400px"});return K.current=t,t.isVisible()&&q(!0),t.whenVisible.then(()=>q(!0)),()=>{t.destroy(),K.current=null}},[X]),s(()=>(Q(),()=>{var e;null==(e=O.current)||e.dispose(),O.current=null}),[Q]),s(()=>{O.current&&U&&O.current.setTheme(Y())},[Y,U]),s(()=>{U?O.current&&(!1===l.stream&&l.loading||(Z(l.node.code),Promise.resolve(O.current.updateCode(l.node.code,u)).then(()=>G()).catch(()=>{}))):Z(l.node.code)},[G,u,l.loading,l.node.code,l.stream,Z,U]),s(()=>{I||Be(!0)},[I]);const ee=d((e,t)=>{if(!I)return;const n=e.currentTarget;n&&!n.disabled&&("clientX"in e&&(e.clientX,e.clientY),Ne(n,t,"top",!1,0,l.isDark))},[l.isDark,I]),te=d(()=>{I&&Be()},[I]),ne=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(l.node.code),k(!0),null==(e=l.onCopy)||e.call(l,l.node.code),setTimeout(()=>k(!1),1e3)}catch{}},[l]),re=d(()=>{var e;if(!v)return;const t="html"===u?"text/html":"image/svg+xml",n="html"===u?"HTML Preview":"SVG Preview";null==(e=l.onPreviewCode)||e.call(l,{type:t,content:l.node.code,title:n})},[v,u,l]),oe=o(()=>({fontSize:`${H}px`}),[H]);return s(()=>{R(14),W(14)},[]),/* @__PURE__ */e("div",{ref:_,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:y,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:[
187
187
  /* @__PURE__ */e("div",{className:"flex items-center space-x-2",children:[
188
188
  /* @__PURE__ */t("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:g}}),
189
189
  /* @__PURE__ */t("span",{className:"text-sm font-medium font-mono",children:f})]}),
@@ -197,9 +197,9 @@ return t("blockquote",{className:"blockquote-node",dir:"auto",cite:c.cite,childr
197
197
  /* @__PURE__ */t("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__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":b,onClick:e=>{C(e=>!e),ee(e,b?w("common.expand")||"Expand":w("common.collapse")||"Collapse")},onMouseEnter:e=>ee(e,b?w("common.collapse")||"Collapse":w("common.expand")||"Expand"),onFocus:e=>ee(e,b?w("common.collapse")||"Collapse":w("common.expand")||"Expand"),onMouseLeave:te,onBlur:te,children:/* @__PURE__ */t("svg",b?{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__ */t("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__ */t("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__ */t("button",{type:"button",className:"code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":w("common.preview")||"Preview",onClick:re,onMouseEnter:e=>ee(e,w("common.preview")||"Preview"),onFocus:e=>ee(e,w("common.preview")||"Preview"),onMouseLeave:te,onBlur:te,children:/* @__PURE__ */t("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:[
198
198
  /* @__PURE__ */t("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"}),
199
199
  /* @__PURE__ */t("circle",{cx:"12",cy:"12",r:"3"})]})})})]})]}),!M&&(!!l.stream||!l.loading)&&/* @__PURE__ */e("div",{ref:F,className:"code-block-content",style:{...oe,maxHeight:b?"none":"500px",overflowY:b?"visible":"auto",overflowX:"auto"},children:[
200
- /* @__PURE__ */t("div",{ref:j,className:"code-block-render"}),!S&&B&&/* @__PURE__ */t("div",{className:"code-fallback-plain",dangerouslySetInnerHTML:{__html:B}})]}),!l.stream&&l.loading&&/* @__PURE__ */t("div",{className:"code-loading-placeholder",children:/* @__PURE__ */e("div",{className:"loading-skeleton",children:[
200
+ /* @__PURE__ */t("div",{ref:j,className:"code-block-render"}),!E&&B&&/* @__PURE__ */t("div",{className:"code-fallback-plain",dangerouslySetInnerHTML:{__html:B}})]}),!l.stream&&l.loading&&/* @__PURE__ */t("div",{className:"code-loading-placeholder",children:/* @__PURE__ */e("div",{className:"loading-skeleton",children:[
201
201
  /* @__PURE__ */t("div",{className:"skeleton-line"}),
202
202
  /* @__PURE__ */t("div",{className:"skeleton-line"}),
203
203
  /* @__PURE__ */t("div",{className:"skeleton-line short"})]})}),
204
- /* @__PURE__ */t("span",{className:"sr-only","aria-live":"polite",role:"status",children:x?w("common.copied")||"Copied":""})]})}function Lr(e){var n;const r=a(null),[l,c]=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 c(!1);if(!e.anchorEl||!r.current)return void c(!0);let t=null,n=!1;const o=async()=>{var t,o;if(!e.anchorEl||!r.current)return;const{x:i,y:l}=await ne(e.anchorEl,r.current,{placement:null!=(t=e.placement)?t:"top",middleware:[re(null!=(o=e.offset)?o:8),oe(),ie({padding:8})],strategy:"fixed"});n||u({position:"fixed",left:"0px",top:"0px",transform:`translate3d(${Math.round(i)}px, ${Math.round(l)}px, 0)`})};return o().then(()=>{n||c(!0)}),t=te(e.anchorEl,r.current,o),()=>{n=!0,null==t||t()}},[e.anchorEl,e.offset,e.placement,e.visible,l]),"undefined"==typeof document?null:e.visible&&l?ee(
205
- /* @__PURE__ */t("div",{id:null!=(n=e.id)?n: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{ut as $,ae as A,Nr as B,he as C,vt as D,xt as E,ar as F,Lr as G,Nt as H,Ht as I,Rn as J,dn as K,Xt as L,Dn as M,Mr as N,on as O,dr as P,Pn as Q,ur as R,mr as S,gr as T,dt as U,vr as V,an as W,st as X,Hn as Y,fn as Z,Sn as _,nt as a,cn as a0,gn as a1,xr as a2,ct as a3,fe as a4,pn as a5,sn as a6,un as a7,rn as a8,ln as a9,$n as aa,Tn as ab,En as ac,Wn as ad,ge as ae,mn as af,mt as ag,yt as b,kt as c,bt as d,Ct as e,Mt as f,Bt as g,Lt as h,Tt as i,At as j,Le as k,jt as l,zt as m,Vt as n,Ut as o,qt as p,Br as q,xn as r,kn as s,Jn as t,Ye as u,hr as v,pr as w,fr as x,Kt as y,wr as z};
204
+ /* @__PURE__ */t("span",{className:"sr-only","aria-live":"polite",role:"status",children:x?w("common.copied")||"Copied":""})]})}function Tr(e){var n;const r=a(null),[l,c]=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 c(!1);if(!e.anchorEl||!r.current)return void c(!0);let t=null,n=!1;const o=async()=>{var t,o;if(!e.anchorEl||!r.current)return;const{x:i,y:l}=await ne(e.anchorEl,r.current,{placement:null!=(t=e.placement)?t:"top",middleware:[re(null!=(o=e.offset)?o:8),oe(),ie({padding:8})],strategy:"fixed"});n||u({position:"fixed",left:"0px",top:"0px",transform:`translate3d(${Math.round(i)}px, ${Math.round(l)}px, 0)`})};return o().then(()=>{n||c(!0)}),t=te(e.anchorEl,r.current,o),()=>{n=!0,null==t||t()}},[e.anchorEl,e.offset,e.placement,e.visible,l]),"undefined"==typeof document?null:e.visible&&l?ee(
205
+ /* @__PURE__ */t("div",{id:null!=(n=e.id)?n: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{ht as $,ae as A,Lr as B,he as C,xt as D,bt as E,sr as F,Tr as G,Lt as H,It as I,Wn as J,mn as K,qt as L,Pn as M,Br as N,an as O,mr as P,Rn as Q,hr as R,pr as S,vr as T,mt as U,xr as V,sn as W,ut as X,In as Y,wn as Z,$n as _,ot as a,dn as a0,vn as a1,br as a2,dt as a3,fe as a4,gn as a5,un as a6,hn as a7,ln as a8,cn as a9,An as aa,En as ab,Dn as ac,_n as ad,ge as ae,pn as af,pt as ag,kt as b,Ct as c,Mt as d,Nt as e,Bt as f,St as g,Tt as h,Et as i,Ht as j,Te as k,zt as l,Kt as m,Xt as n,Yt as o,Zt as p,Sr as q,bn as r,Cn as s,er as t,Ge as u,fr as v,gr as w,wr as x,Ut as y,yr as z};