markstream-react 2.0.19 → 2.0.21

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,16 +1,16 @@
1
- import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import r,{useMemo as o,useState as i,createContext as l,useContext as a,useRef as c,useEffect as s,useCallback as d,useLayoutEffect as u,useSyncExternalStore as m}from"react";import{sanitizeHtmlTokenAttrs as h,normalizeCustomHtmlTagName as f,convertHtmlAttrsToProps as p,tokenAttrsToRecord as g,NON_STRUCTURING_HTML_TAGS as v,isHtmlTagBlocked as y,sanitizeHtmlContent as w,BLOCKED_HTML_TAGS as x,isHtmlTagHardBlocked as k,sanitizeImageSrc as b,sanitizeHtmlAttrs as C,shouldOpenLinkInNewTab as N,toSafeSvgElement as M,getHtmlTagFromContent as B,stripCustomHtmlWrapper as S,shouldRenderUnknownHtmlTagAsText as T,mergeCustomHtmlTags as E,getMarkdown as L,parseMarkdownToStructure as D}from"stream-markdown-parser";import{D as $,u as P,d as A,N as R,E as F,z as I,G as _,m as H,q as W,P as O,C as j,L as z,k as K,l as V,O as q,s as U,n as X,v as Z,Q as Y,o as G,j as J,H as Q,x as ee,g as te,c as ne,I as re,t as oe,w as ie,h as le,a as ae,M as ce,B as se,p as de,F as ue,i as me,R as he,r as fe}from"./codeBlockExtraProps-DKls4xQW.js";import{createSmoothMarkdownStream as pe,createPanGesture as ge,normalizeShikiLanguage as ve}from"markstream-core";import{autoUpdate as ye,computePosition as we,offset as xe,flip as ke,shift as be}from"@floating-ui/dom";import{createPortal as Ce}from"react-dom";const Ne={note:"ℹ️",info:"ℹ️",tip:"💡",warning:"⚠️",danger:"❗",error:"⛔",caution:"⚠️"};function Me(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)}),f=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,createContext as l,useContext as a,useRef as c,useEffect as s,useCallback as d,useLayoutEffect as u,useSyncExternalStore as m}from"react";import{sanitizeHtmlTokenAttrs as h,normalizeCustomHtmlTagName as f,convertHtmlAttrsToProps as p,tokenAttrsToRecord as g,NON_STRUCTURING_HTML_TAGS as v,isHtmlTagBlocked as y,sanitizeHtmlContent as w,BLOCKED_HTML_TAGS as x,isHtmlTagHardBlocked as k,sanitizeImageSrc as b,sanitizeHtmlAttrs as C,shouldOpenLinkInNewTab as N,toSafeSvgElement as M,getHtmlTagFromContent as B,stripCustomHtmlWrapper as S,shouldRenderUnknownHtmlTagAsText as T,mergeCustomHtmlTags as E,getMarkdown as L,parseMarkdownToStructure as D}from"stream-markdown-parser";import{D as $,u as P,d as A,N as R,E as F,z as I,G as _,m as H,q as W,P as O,C as j,L as z,k as K,l as V,O as q,s as U,n as X,v as Z,Q as Y,o as G,j as J,H as Q,x as ee,g as te,c as ne,I as re,t as oe,w as ie,h as le,a as ae,M as ce,B as se,p as de,F as ue,i as me,R as he,r as fe}from"./codeBlockExtraProps-DKls4xQW.js";import{createSmoothMarkdownStream as pe,createPanGesture as ge,applyMermaidThemeDirective as ve,normalizeShikiLanguage as ye}from"markstream-core";import{autoUpdate as we,computePosition as xe,offset as ke,flip as be,shift as Ce}from"@floating-ui/dom";import{createPortal as Ne}from"react-dom";const Me={note:"ℹ️",info:"ℹ️",tip:"💡",warning:"⚠️",danger:"❗",error:"⛔",caution:"⚠️"};function Be(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)}),f=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
- /* @__PURE__ */e("div",{id:f,className:"admonition-header",children:[Ne[d]&&/* @__PURE__ */t("span",{className:"admonition-icon",children:Ne[d]}),
4
- /* @__PURE__ */t("span",{className:"admonition-title",children:u}),r.collapsible&&/* @__PURE__ */t("button",{type:"button",className:"admonition-toggle","aria-expanded":!m,"aria-controls":`${f}-content`,title:m?"Expand":"Collapse",onClick:()=>h(e=>!e),children:/* @__PURE__ */t("span",{children:m?"▶":"▼"})})]}),!m&&/* @__PURE__ */t("div",{id:`${f}-content`,className:"admonition-content","aria-labelledby":f,children:l&&a?$(r.children,l,String(null!=c?c:f),a):null})]})}const Be=l(!1),Se=l(null);function Te(){return a(Se)}const Ee=l(null);function Le(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()}},f=()=>{i&&null==u&&d.size&&(u=i(()=>{u=null;const e=d.values().next().value;e&&(d.delete(e),h(e),d.size&&f())},{timeout:1200}))};return(n,r)=>{var i,l;const u={current:!1};let p,g=!1;const v=new Promise(e=>{p=()=>{g||(g=!0,e())}}),y=()=>{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,p(),{isVisible:()=>!0,whenVisible:v,destroy:y};const w=((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 w?(s.set(n,{resolve:p,state:u}),w.observe(n),d.add(n),f(),{isVisible:()=>u.current,whenVisible:v,destroy:y}):(u.current=!0,p(),{isVisible:()=>!0,whenVisible:v,destroy:y})}}const De=Le(()=>null,()=>!0);function $e({getRoot:e,enabled:n=!0,children:r}){const i=c(n);i.current=n;const l=c(e);l.current=e;const a=o(()=>Le(()=>{var e,t;return null!=(t=null==(e=l.current)?void 0:e.call(l))?t:null},()=>i.current),[]);/* @__PURE__ */
5
- return t(Ee.Provider,{value:a,children:r})}function Pe(){var e;return null!=(e=a(Ee))?e:De}function Ae(e={}){const t=c(null);t.current||(t.current=pe(e));const n=t.current,[r,l]=i(()=>n.getSnapshot());return s(()=>{const e=n.subscribe(()=>{l(n.getSnapshot())});return n.resume(),l(n.getSnapshot()),()=>{e(),n.pause()}},[n]),o(()=>({...r,enqueue:n.enqueue,finish:n.finish,flush:n.flush,reset:n.reset,pause:n.pause,resume:n.resume,getSnapshot:n.getSnapshot}),[n,r])}function Re(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 Fe={"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 Ie(e){Object.assign(Fe,e)}function _e(){return{t:e=>{var t;return null!=(t=Fe[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 He=null,We=null,Oe=null,je=null,ze=null,Ke=null;function Ve(){je&&(clearTimeout(je),je=null),ze&&(clearTimeout(ze),ze=null)}async function qe(e){if(!He||!We)return;const{x:t,y:n}=await we(We,He,{placement:e,middleware:[xe(8),ke(),be({padding:8})],strategy:"fixed"});He.style.transform=`translate3d(${Math.round(t)}px, ${Math.round(n)}px, 0)`}function Ue(e,t,n="top",r=!1,o,i){if(!e||"undefined"==typeof document)return;if(He||"undefined"==typeof document||(He=document.createElement("div"),He.className="markstream-react ms-tooltip",He.setAttribute("role","tooltip"),He.dataset.visible="false",He.style.position="fixed",He.style.left="0px",He.style.top="0px",He.style.transform="translate3d(0,0,0)",document.body.appendChild(He)),!He)return;Ve();const l=async()=>{if(He){We=e,He.textContent=t,He.dataset.placement=n,He.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",He.dataset.visible="false",Ke=`tooltip-${Date.now()}-${Math.random().toString(36).slice(2)}`,He.id=Ke;try{e.setAttribute("aria-describedby",Ke)}catch{}await qe(n),He.dataset.visible="true",null==Oe||Oe(),Oe=ye(e,He,()=>{qe(n)})}};r?l():je=setTimeout(l,80)}function Xe(e=!1){if(!He)return;Ve();const t=()=>{if(He){if(He.dataset.visible="false",We&&Ke)try{We.removeAttribute("aria-describedby")}catch{}We=null,Ke=null,Oe&&(Oe(),Oe=null)}};e?t():ze=setTimeout(t,120)}const Ze=void 0!==import.meta&&Boolean(!1);let Ye=null;function Ge(n){const{t:r}=_e(),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(!Ze||"undefined"==typeof console||Ye===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")&&(Ye=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:Ce(
3
+ /* @__PURE__ */e("div",{id:f,className:"admonition-header",children:[Me[d]&&/* @__PURE__ */t("span",{className:"admonition-icon",children:Me[d]}),
4
+ /* @__PURE__ */t("span",{className:"admonition-title",children:u}),r.collapsible&&/* @__PURE__ */t("button",{type:"button",className:"admonition-toggle","aria-expanded":!m,"aria-controls":`${f}-content`,title:m?"Expand":"Collapse",onClick:()=>h(e=>!e),children:/* @__PURE__ */t("span",{children:m?"▶":"▼"})})]}),!m&&/* @__PURE__ */t("div",{id:`${f}-content`,className:"admonition-content","aria-labelledby":f,children:l&&a?$(r.children,l,String(null!=c?c:f),a):null})]})}const Se=l(!1),Te=l(null);function Ee(){return a(Te)}const Le=l(null);function De(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()}},f=()=>{i&&null==u&&d.size&&(u=i(()=>{u=null;const e=d.values().next().value;e&&(d.delete(e),h(e),d.size&&f())},{timeout:1200}))};return(n,r)=>{var i,l;const u={current:!1};let p,g=!1;const v=new Promise(e=>{p=()=>{g||(g=!0,e())}}),y=()=>{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,p(),{isVisible:()=>!0,whenVisible:v,destroy:y};const w=((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 w?(s.set(n,{resolve:p,state:u}),w.observe(n),d.add(n),f(),{isVisible:()=>u.current,whenVisible:v,destroy:y}):(u.current=!0,p(),{isVisible:()=>!0,whenVisible:v,destroy:y})}}const $e=De(()=>null,()=>!0);function Pe({getRoot:e,enabled:n=!0,children:r}){const i=c(n);i.current=n;const l=c(e);l.current=e;const a=o(()=>De(()=>{var e,t;return null!=(t=null==(e=l.current)?void 0:e.call(l))?t:null},()=>i.current),[]);/* @__PURE__ */
5
+ return t(Le.Provider,{value:a,children:r})}function Ae(){var e;return null!=(e=a(Le))?e:$e}function Re(e={}){const t=c(null);t.current||(t.current=pe(e));const n=t.current,[r,l]=i(()=>n.getSnapshot());return s(()=>{const e=n.subscribe(()=>{l(n.getSnapshot())});return n.resume(),l(n.getSnapshot()),()=>{e(),n.pause()}},[n]),o(()=>({...r,enqueue:n.enqueue,finish:n.finish,flush:n.flush,reset:n.reset,pause:n.pause,resume:n.resume,getSnapshot:n.getSnapshot}),[n,r])}function Fe(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 Ie={"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 _e(e){Object.assign(Ie,e)}function He(){return{t:e=>{var t;return null!=(t=Ie[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,Oe=null,je=null,ze=null,Ke=null,Ve=null,qe=0;function Ue(e,t){return!(t!==qe||e!==Oe||!e.isConnected&&(Ye(!0,e),1))}async function Xe(e,t,n){const r=We;if(!r||!Ue(e,n))return!1;const{x:o,y:i}=await xe(e,r,{placement:t,middleware:[ke(8),be(),Ce({padding:8})],strategy:"fixed"});return!!Ue(e,n)&&(r.style.transform=`translate3d(${Math.round(o)}px, ${Math.round(i)}px, 0)`,!0)}function Ze(e,t,n="top",r=!1,o,i){if(!(null==e?void 0:e.isConnected)||"undefined"==typeof document)return;if(We||"undefined"==typeof document||(We=document.createElement("div"),We.className="markstream-react 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;Ye(!0),Oe=e;const l=qe,a=async()=>{if(We&&Ue(e,l)){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",Ve=`tooltip-${Date.now()}-${Math.random().toString(36).slice(2)}`,We.id=Ve;try{e.setAttribute("aria-describedby",Ve)}catch{}await Xe(e,n,l)&&Ue(e,l)&&(We.dataset.visible="true",je=we(e,We,()=>{Xe(e,n,l)}))}};r?a():ze=setTimeout(a,80)}function Ye(e=!1,t){if(void 0!==t&&t!==Oe)return;if(qe+=1,ze&&(clearTimeout(ze),ze=null),Ke&&(clearTimeout(Ke),Ke=null),!We)return;const n=()=>{if(We){if(We.dataset.visible="false",Oe&&Ve&&Oe.getAttribute("aria-describedby")===Ve)try{Oe.removeAttribute("aria-describedby")}catch{}Oe=null,Ve=null,je&&(je(),je=null)}};e?n():Ke=setTimeout(n,120)}const Ge=void 0!==import.meta&&Boolean(!1);let Je=null;function Qe(n){const{t:r}=He(),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(!Ge||"undefined"==typeof console||Je===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")&&(Je=e,console.warn("[markstream-react] htmlPreviewSandbox contains both allow-scripts and allow-same-origin. Use this only for fully trusted content served from an isolated origin."))}(e),e):void 0!==e?"":!0===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:Ne(
7
7
  /* @__PURE__ */t("div",{className:"markstream-react 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:l,referrerPolicy:"no-referrer",src:"about:blank",srcDoc:i,title:n.title||"Preview"})]})}),document.body)}let Je=!1,Qe=null,et=!1,tt=null;async function nt(){if(tt)return tt;if(Qe)return Qe;if(et)return null;tt=(async()=>{try{const e=function(e){var t,n,r;const o="function"==typeof(null==e?void 0:e.createCodeBlockRuntime)||"function"==typeof(null==e?void 0:e.useMonaco)?e:null==e?void 0:e.default,i=null!=(t=null==o?void 0:o.createCodeBlockRuntime)?t:null==o?void 0:o.useMonaco;return"function"!=typeof i?null:{createCodeBlockRuntime:e=>i.call(o,e),detectLanguage:null==(n=null==o?void 0:o.detectLanguage)?void 0:n.bind(o),preloadStreamDiffs:null==(r=null==o?void 0:o.preloadStreamDiffs)?void 0:r.bind(o)}}(await import("stream-diffs/markstream"));if(e)return await async function(e){Je||(Je=!0,(null==e?void 0:e.preloadStreamDiffs)&&await e.preloadStreamDiffs())}(e),Qe=e,Qe}catch{}return et=!0,null})();try{return await tt}finally{tt=null}}const rt="undefined"!=typeof window?u:s,ot={isShowPreview:!0,loading:!0,stream:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0};async function it(e,t){var n;if(t)try{if(!(await t()))return!1}catch{return!1}if("undefined"==typeof window||"function"!=typeof window.requestAnimationFrame)return!1;const r=()=>new Promise(e=>window.requestAnimationFrame(()=>e()));for(let o=0;o<30;o++){await r();const t=null!=(n=e.querySelector([".stream-diffs-shell","[data-stream-diffs-state]"].join(",")))?n:e.firstElementChild;if(!t)continue;const o=t.getBoundingClientRect();if(o.width>0&&o.height>0)return await r(),!0}return!1}function lt(e,t){const n={...t||{}};for(const i of["theme","themes","themeType","language","languages","stream","disableFileHeader","onThemeChange","renderCustomHeader","renderHeaderMetadata","renderHeaderPrefix"])delete n[i];if(!e)return{overflow:"wrap",...n};const r=n.parseDiffOptions&&"object"==typeof n.parseDiffOptions?n.parseDiffOptions:{},o={overflow:"wrap",diffStyle:"split",expandUnchanged:!1,collapsedContextThreshold:5,hunkSeparators:"line-info",parseDiffOptions:{context:2}};return{...o,...n,parseDiffOptions:{...o.parseDiffOptions,...r}}}function at(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 ct(e){var t,n;const r=String(null!=e?e:"").trim().toLowerCase();if(!r||"transparent"===r)return!0;const o=r.match(/^#([0-9a-f]{8})$/);if(o)return 0===Number.parseInt(o[1].slice(6),16);const i=r.match(/^#([0-9a-f]{4})$/);if(i)return 0===Number.parseInt(i[1][3]+i[1][3],16);const l=null==(n=null==(t=r.match(/^(?:rgba?|hsla?)\(([^)]+)\)/))?void 0:t[1])?void 0:n.split(/[\s,/]+/).filter(Boolean);return 4===(null==l?void 0:l.length)&&0===Number(l[3])}function st(r){var l,a;const u={...ot,...r},{node:m,isDark:h,loading:f,stream:p,isShowPreview:g,enableFontSizeControl:v,darkTheme:y,lightTheme:w,codeBlockOptions:x,themes:k,minWidth:b,maxWidth:C,showHeader:N,showCopyButton:M,showExpandButton:B,showPreviewButton:S,showCollapseButton:T,showFontSizeButtons:E,showLineNumbers:L,showTooltips:D}=u,$=c(null),j=c(null),z=c(null),K=c(null),V=c(null),q=c(null),U=c(null),X=c(0),Z=c(null),Y=c(null),G=Pe(),J=c(null),Q=c(null),ee=c(x),te=c(null),ne=c([]),re=c(null),oe=c(!1),ie=c(void 0),[le,ae]=i(!1),[ce,se]=i(()=>"undefined"==typeof window),[de,ue]=i(!1),[me,he]=i(!1),[fe,pe]=i(!1),[ge,ve]=i(()=>m.language||"plaintext"),[ye,we]=i(()=>P(m.language)),[xe,ke]=i(!1),[be,Ce]=i(!1),[Ne,Me]=i(!1),[Be,Se]=i(!1),[Te,Ee]=i(0),{t:Le}=_e();s(()=>{oe.current=be},[be]);const De=o(()=>lt(Boolean(m.diff),x),[x,m.diff]),[$e,Ae]=i(()=>{var e;const t=Number(null==(e=lt(Boolean(m.diff),x))?void 0:e.fontSize);return Number.isFinite(t)&&t>0?t:A}),[Re,Fe]=i($e),Ie=o(()=>!1!==D,[D]),He="boolean"==typeof L?L:!0!==De.disableLineNumbers,We=c(He),Oe=Number(null==(l=ee.current)?void 0:l.fontSize),je=Number(null==x?void 0:x.fontSize),ze=ee.current!==x&&Number.isFinite(Oe)&&Oe>0&&(!Number.isFinite(je)||je<=0),Ke=d(()=>{var e;const t=null!=(e=De.maxHeight)?e:500;return"number"==typeof t&&Number.isFinite(t)?t:500},[De.maxHeight]);rt(()=>{const e=Number(De.fontSize),t=Number.isFinite(e)&&e>0?e:A;Ae(t),Fe(t)},[De.fontSize]);const Ve=d(e=>{var t,n,r;if(le)return;const o=$.current,i=z.current;if(!o||!i)return;const l="diff"===q.current?null==(t=i.getDiffEditorView)?void 0:t.call(i):null==(n=i.getEditorView)?void 0:n.call(i);if(!l)return;const a=Ke(),c="diff"===q.current,s=c?"important":"";e?(o.style.minHeight="0px",o.style.setProperty("max-height","none",s),o.style.overflow="visible"):(o.style.minHeight="0px",o.style.setProperty("max-height",`${Math.ceil(a)}px`,s),o.style.overflow=c?"hidden":"auto");try{const t=Number((()=>{if("function"==typeof l.getContentHeight)return l.getContentHeight();if(c&&"function"==typeof l.getModifiedEditor){const e=l.getModifiedEditor();if(e&&"function"==typeof e.getContentHeight)return e.getContentHeight()}})());if(Number.isFinite(t)&&t>0){const n=e?t:Math.min(t,a);o.style.setProperty("height",`${Math.ceil(Math.max(1,n))}px`,s)}null==(r=l.layout)||r.call(l)}catch{}},[Ke,le]),qe=d(e=>{if(Ve(e),"undefined"==typeof window||"function"!=typeof window.requestAnimationFrame)return;const t=window.requestAnimationFrame(()=>{Ve(e),window.requestAnimationFrame(()=>Ve(e))});return window.setTimeout(()=>Ve(e),180),()=>window.cancelAnimationFrame(t)},[Ve]),Ze=d(()=>{var e,t;for(const n of ne.current)try{"function"==typeof n?n():null==(e=null==n?void 0:n.dispose)||e.call(n)}catch{}ne.current=[],null==(t=re.current)||t.disconnect(),re.current=null},[]),Ye=d(()=>{var e,t,n;Ze();const r=z.current,o=$.current;if(!r||!o||"diff"!==q.current)return;const i=()=>qe(oe.current),l=(e,t)=>{try{const n=null==e?void 0:e[t];if("function"!=typeof n)return;const r=n.call(e,i);r&&ne.current.push(r)}catch{}},a=null==(e=r.getDiffEditorView)?void 0:e.call(r),c=null==(t=null==a?void 0:a.getOriginalEditor)?void 0:t.call(a),s=null==(n=null==a?void 0:a.getModifiedEditor)?void 0:n.call(a);if(l(a,"onDidUpdateDiff"),l(c,"onDidContentSizeChange"),l(s,"onDidContentSizeChange"),l(c,"onDidLayoutChange"),l(s,"onDidLayoutChange"),"undefined"!=typeof window&&"function"==typeof window.MutationObserver){const e=new window.MutationObserver(e=>{e.some(e=>"childList"===e.type||"attributes"===e.type&&e.target!==o)&&i()});e.observe(o,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),re.current=e}},[Ze,qe]);s(()=>R(()=>{Ee(e=>e+1)}),[]),s(()=>{we(P(m.language))},[m.language]);const Je=c(m);Je.current=m;const Qe=d(()=>{var e;X.current+=1;try{null==(e=K.current)||e.call(K)}catch{}Ze(),V.current=null,q.current=null,U.current=null,pe(!1),he(!1)},[Ze]),et=o(()=>{var e,t;return h?null!=(e=null!=y?y:null==k?void 0:k[0])?e:"vitesse-dark":null!=(t=null!=w?w:null==k?void 0:k[1])?t:"vitesse-light"},[y,h,w,k]),tt=d(()=>et,[et]),st=o(()=>tt(),[tt]),dt=o(()=>function(e,t){var n;const r=null!=(n=function(e){return"string"==typeof e?e:null}(e))?n:"",o=r.toLowerCase();return o?["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=>o.includes(e))&&!["light","latte","dawn","lotus"].some(e=>o.includes(e)):t}(st,Boolean(h)),[h,st]),ut=o(()=>m.diff?h?"dark":"light":dt?"dark":"light",[h,m.diff,dt]),mt=o(()=>m.diff?"dark"===ut:dt,[ut,m.diff,dt]),ht=o(()=>{var e;const t=De,n=F(De,ze?A:Re),r=function(e){const t="number"==typeof e&&Number.isFinite(e)&&e>=0?e:0;return{top:t,bottom:t}}(null==t?void 0:t.padding),o=m.diff?0:8,i="number"==typeof(null==t?void 0:t.padding)&&Number.isFinite(t.padding)&&t.padding>=0,l=null!=(e=I(null==t?void 0:t.tabSize))?e:4;return{...n,paddingBottom:i?r.bottom:o,paddingTop:i?r.top:o,tabSize:l}},[ze,Re,m.diff,De]),ft=o(()=>!!m.diff&&"unified"===De.diffStyle,[m.diff,De]),pt=o(()=>{var e,t,n;const r=String(m.diff?null!=(t=null!=(e=m.updatedCode)?e:m.code)?t:"":null!=(n=m.code)?n:"");if(!r)return 1;const o=f?r:r.replace(/\r\n$|\n$|\r$/,"");return Math.max(1,o.split(/\r\n|\r|\n/).length)},[f,m.code,m.diff,m.updatedCode]),gt=o(()=>Math.ceil(pt*ht.lineHeight+ht.paddingTop+ht.paddingBottom),[pt,ht]),vt=o(()=>{const e={"--markstream-code-padding-left":"62px","--markstream-pre-diff-line-height":`${ht.lineHeight}px`,"--markstream-pre-line-number-top":`${ht.paddingTop}px`,"--markstream-pre-line-number-width":"36px","--markstream-pre-line-number-gap":"0px",fontSize:`${ht.fontSize}px`,lineHeight:`${ht.lineHeight}px`,maxHeight:`${Ke()}px`,overflow:"auto",paddingBottom:`${ht.paddingBottom}px`,paddingTop:`${ht.paddingTop}px`,tabSize:ht.tabSize,whiteSpace:"scroll"===De.overflow?"pre":"pre-wrap"};return ht.fontFamily&&(e.fontFamily=ht.fontFamily),e},[Ke,ht,De.overflow]),yt=d(()=>{var e,t,n,r,o;const i=$.current,l=j.current;if(!i||!l)return;if(l.style.removeProperty("--vscode-editor-foreground"),l.style.removeProperty("--vscode-editor-background"),l.style.removeProperty("--vscode-editor-selectionBackground"),i.style.setProperty("--diffs-tab-size",String(ht.tabSize)),"number"==typeof De.padding&&Number.isFinite(De.padding)&&De.padding>=0?i.style.setProperty("--diffs-gap-block",`${ht.paddingTop}px`):i.style.removeProperty("--diffs-gap-block"),m.diff)return i.style.removeProperty("--vscode-editor-foreground"),i.style.removeProperty("--vscode-editor-background"),void i.style.removeProperty("--vscode-editor-selectionBackground");const a=i;try{const c="undefined"!=typeof window&&window.getComputedStyle?window.getComputedStyle(a):null,s=String(null!=(e=null==c?void 0:c.getPropertyValue("--vscode-editor-foreground"))?e:"").trim()||String(null!=(t=null==c?void 0:c.color)?t:"").trim(),d=String(null!=(n=null==c?void 0:c.getPropertyValue("--vscode-editor-background"))?n:"").trim(),u=String(null!=(r=null==c?void 0:c.backgroundColor)?r:"").trim(),h=ct(d)?ct(u)?"":u:d,f=String(null!=(o=null==c?void 0:c.getPropertyValue("--vscode-editor-selectionBackground"))?o:"").trim();if(function(e,t,n,r){if(!n)return!1;const o=at(e),i=at(t);return r?null!=o&&o>170||null!=i&&i<110:null!=o&&o<85||null!=i&&i>190}(h,s,"plaintext"===_(String(m.language||ye||ge||"plaintext")),l.classList.contains("is-dark")))return i.style.removeProperty("--vscode-editor-foreground"),i.style.removeProperty("--vscode-editor-background"),void i.style.removeProperty("--vscode-editor-selectionBackground");s?i.style.setProperty("--vscode-editor-foreground",s):i.style.removeProperty("--vscode-editor-foreground"),h?i.style.setProperty("--vscode-editor-background",h):i.style.removeProperty("--vscode-editor-background"),f?i.style.setProperty("--vscode-editor-selectionBackground",f):i.style.removeProperty("--vscode-editor-selectionBackground")}catch{}},[ye,ge,m.diff,m.language,ht,De]),wt=d(()=>{const e=De.maxHeight,t={...De||{},...null==e?{}:{MAX_HEIGHT:e},themes:k?[...k]:void 0,stream:!1,disableFileHeader:!0,disableLineNumbers:!He,fontSize:ht.fontSize,lineHeight:ht.lineHeight,...ht.fontFamily?{fontFamily:ht.fontFamily}:{},theme:st,themeType:h?"dark":"light",onThemeChange(){yt()}};delete t.maxHeight,delete t.padding,delete t.tabSize;const n="string"==typeof t.unsafeCSS?t.unsafeCSS:"";return t.unsafeCSS=["[data-file], [data-diff] { --diffs-min-number-column-width-default: 2ch !important; }",n].filter(Boolean).join("\n"),t},[He,h,ht,st,De,yt,k]),xt=d(()=>{const e=wt(),t=J.current;if(!t)return J.current=e,e;for(const n of Object.keys(t))n in e||delete t[n];return Object.assign(t,e),t},[wt]),kt=d(e=>{const t=e(xt());return z.current=t,K.current="function"==typeof t.safeClean?()=>t.safeClean():"function"==typeof t.cleanupEditor?()=>t.cleanupEditor():null,t},[xt]),bt=o(()=>{var e;return JSON.stringify({diffStyle:De.diffStyle,expandUnchanged:De.expandUnchanged,collapsedContextThreshold:De.collapsedContextThreshold,hunkSeparators:De.hunkSeparators,lineDiffType:De.lineDiffType,maxLineDiffLength:De.maxLineDiffLength,expansionLineCount:De.expansionLineCount,context:null==(e=De.parseDiffOptions)?void 0:e.context})},[De]);s(()=>{xt()},[De,xt]),s(()=>()=>{var e,t,n;X.current+=1,null==(e=K.current)||e.call(K),Ze(),K.current=null,V.current=null,q.current=null,U.current=null,z.current=null,Q.current=null,Z.current=null,null==(n=null==(t=Y.current)?void 0:t.destroy)||n.call(t),Y.current=null},[Ze]),s(()=>{var e,t;if("undefined"==typeof window)return;if(ce)return;const n=j.current;if(!n)return;null==(t=null==(e=Y.current)?void 0:e.destroy)||t.call(e);const r=G(n,{rootMargin:"400px"});return Y.current=r,r.isVisible()&&se(!0),r.whenVisible.then(()=>se(!0)),()=>{r.destroy(),Y.current===r&&(Y.current=null)}},[G,ce]),s(()=>{let e=!0;return"undefined"==typeof window?()=>{e=!1}:z.current?(xt(),()=>{e=!1}):((async()=>{try{const t=await nt();if(!e)return;if(!t)return void ae(!0);const n=t.createCodeBlockRuntime,r=t.detectLanguage;if("function"==typeof r&&(Z.current=r),"function"!=typeof n)return void ae(!0);Q.current=n,kt(n),ue(!0)}catch{e&&ae(!0)}})(),()=>{e=!1})},[kt,xt]),s(()=>{var e;if(!m.language&&!ye&&Z.current)try{const t=Z.current(String(null!=(e=m.code)?e:""));t&&ve(t)}catch{}},[ye,m.code,m.language]);const Ct=o(()=>String(m.language||ye||ge||"plaintext"),[ye,ge,m.language]),Nt=o(()=>P(Ct),[Ct]),Mt=o(()=>_(Nt),[Nt]),Bt=o(()=>"plaintext"===Mt,[Mt]),St=o(()=>H(Nt),[Nt,Te]),Tt=o(()=>!!g&&("html"===Nt||"svg"===Nt),[Nt,g]),Et=o(()=>{const e=Nt;return e?W[e]||e.charAt(0).toUpperCase()+e.slice(1):W[""]||"Plain Text"},[Nt]),Lt=o(()=>{var e;return function(e,t,n){const r=function(e){const t=function(e){var t,n;const r=null!=(n=null==(t=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:t.trim())?n:"";if(r.length<3)return"";const o=r[0];if("`"!==o&&"~"!==o||r[1]!==o||r[2]!==o)return"";let i=3;for(;r[i]===o;)i+=1;return r.slice(i).trim()}(e);if(!t)return"";const n=t.split(/\s+/).filter(Boolean);if(!n.length)return"";const r="diff"===n[0]?n.slice(1):n;for(const o of r){const e=o.includes(":")?o.slice(o.indexOf(":")+1):o;if(e&&/[./\\-]/.test(e))return e}return""}(e);return{title:r||t,caption:r?n?`Diff / ${t}`:t:""}}(String(null!=(e=m.raw)?e:""),Et,Boolean(m.diff))},[Et,m.diff,m.raw]),Dt=Lt.title,$t=Lt.caption,Pt=o(()=>{var e,t,n;return m.diff?null!=(t=null!=(e=m.updatedCode)?e:m.code)?t:"":null!=(n=m.code)?n:""},[m.code,m.diff,m.updatedCode]),At=o(()=>{const e=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t={},n=e(b),r=e(C);return n&&(t.minWidth=n),r&&(t.maxWidth=r),m.diff?(t.color="var(--markstream-diff-shell-fg)",t.borderColor="var(--markstream-diff-shell-border)"):(t.color="var(--vscode-editor-foreground, var(--markstream-code-fallback-fg, var(--code-fg)))",t.backgroundColor="var(--vscode-editor-background, var(--markstream-code-fallback-bg, var(--code-bg)))",t.borderColor="var(--markstream-code-border-color, var(--code-border))"),t},[C,b,m.diff]),Rt=o(()=>{var e,t,n,r;return m.code.length>0||(null!=(t=null==(e=m.originalCode)?void 0:e.length)?t:0)>0||(null!=(r=null==(n=m.updatedCode)?void 0:n.length)?r:0)>0},[m.code,m.originalCode,m.updatedCode]),Ft=!1===p&&f||!1!==p&&f&&!Rt;s(()=>{if(le)return;if(!de)return;if(!me||!ce)return;const e=z.current;xt();const t=()=>{var t;m.diff&&(null==(t=null==e?void 0:e.refreshDiffPresentation)||t.call(e)),yt(),Ne||null==("undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>qe(be)):null)&&qe(be)};(null==e?void 0:e.setTheme)&&st?Promise.resolve(e.setTheme(st)).then(t).catch(()=>{}):t()},[Ne,me,ut,be,de,m.diff,st,qe,yt,xt,le,ce]);const It=d(async()=>{var e,t;if(le)return null;if(!ce)return null;if(Ne)return null;if(Ft)return null;const n=z.current,r=$.current;if(!n||!r||!n.createEditor)return null;xt();const o=Je.current,i=o.diff?"diff":"single",l=U.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(q.current===i&&l===r&&a)return null;if(V.current)return V.current;X.current+=1;const c=X.current;he(!0);const s=(async()=>{var e,t,i,l,a,s;try{null==(e=K.current)||e.call(K),q.current=null,U.current=null,pe(!1);const d=Mt;if(o.diff?"function"==typeof n.createDiffEditor?(q.current="diff",await n.createDiffEditor(r,String(null!=(t=o.originalCode)?t:""),String(null!=(i=o.updatedCode)?i:""),d)):(q.current="single",await n.createEditor(r,String(null!=(a=null!=(l=o.updatedCode)?l:o.code)?a:""),d)):(q.current="single",await n.createEditor(r,String(null!=(s=o.code)?s:""),d)),U.current=r,X.current!==c)return;Ye(),yt(),be||Ne||qe(!1);const u=await Promise.race([it(r,n.whenVisualReady),new Promise(e=>{window.setTimeout(()=>e(!0),1500)})]);if(X.current!==c)return;if(!u)return;Ve(be),pe(!0)}catch{X.current===c&&(ie.current=Mt,ae(!0))}})().finally(()=>{V.current===s&&(V.current=null)});return V.current=s,s},[Ve,Ye,Ne,be,Mt,qe,Ft,yt,xt,le,ce]);s(()=>{xt();const e=ee.current!==x;ee.current=x;const t=We.current!==He;We.current=He;const n=te.current;if(te.current=bt,le)return;if(!de)return;let r=!1;if(e||t){const e=Q.current;if(e){Qe(),z.current=null,K.current=null;try{kt(e),r=!0}catch{return void ae(!0)}}}const o=Boolean(m.diff&&n!==bt);if(!r&&!o)return;if(!ce||!me&&!r)return;if(Ne||Ft)return;let i=!1;return(async()=>{if(r||Qe(),!i)try{await It()}catch{}})(),()=>{i=!0}},[Ne,x,me,He,It,kt,de,bt,m.diff,Qe,Ft,xt,le,ce]),s(()=>{if(le){const e=ie.current;if(void 0===e||e===Mt)return;return ie.current=void 0,Qe(),void ae(!1)}de&&ce&&(Ne||Ft?Qe():It())},[Ne,It,Mt,de,Qe,Ft,le,ce]),s(()=>{var e;if(le)return;if(!de)return;if(!ce)return;if(Ne)return;if(Ft)return;const t=z.current;if(!t)return;const n=String(null!=(e=m.code)?e:"");(async()=>{var e,r;let o=ye;if(!o&&Z.current)try{o=P(Z.current(n)),o&&we(o)}catch{}const i=_(o||Nt);if(t.createEditor&&$.current){try{await Promise.resolve(It())}catch{}const e=V.current;if(e)try{await e}catch{}}try{m.diff&&t.updateDiff?await Promise.resolve(t.updateDiff(String(null!=(e=m.originalCode)?e:""),String(null!=(r=m.updatedCode)?r:""),i)):t.updateCode&&await Promise.resolve(t.updateCode(n,i))}catch{}const l=$.current;l&&"true"!==l.getAttribute("data-markstream-enhanced")&&await it(l,t.whenVisualReady)&&(Ve(be),pe(!0)),qe(be)})()},[Ve,Nt,ye,Ne,me,It,be,de,m.code,m.diff,m.originalCode,m.updatedCode,qe,Ft,le,ce]),s(()=>{if(le)return;if(!de)return;if(!ce)return;if(Ne)return;if(Ft)return;if(!be&&f)return;const e="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>qe(be)):null;return null==e&&qe(be),()=>{null!=e&&"undefined"!=typeof window&&"function"==typeof window.cancelAnimationFrame&&window.cancelAnimationFrame(e)}},[Ne,be,f,de,qe,Ft,le,ce]),s(()=>{var e,t,n;if(!v)return;if(le)return;const r=z.current;if(r){try{const o="diff"===q.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:Re})}catch{}qe(be)}},[v,be,Re,m.diff,qe,le]),s(()=>{Ie||Xe(!0)},[Ie]);const _t=d((e,t)=>{if(!Ie)return;const n=e.currentTarget;n&&!n.disabled&&("clientX"in e&&(e.clientX,e.clientY),Ue(n,t,"top",!1,0,mt))},[mt,Ie]),Ht=d(()=>{Ie&&Xe()},[Ie]),Wt=d(async()=>{var e;const t=String(Pt);try{u.clipboardWriter?await u.clipboardWriter(t):"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(t),ke(!0),null==(e=u.onCopy)||e.call(u,t),setTimeout(()=>ke(!1),1e3)}catch{}},[u,Pt]),Ot=d(()=>{if(!Tt)return;const e="html"===Nt?"text/html":"image/svg+xml",t="html"===Nt?Le("artifacts.htmlPreviewTitle")||"HTML Preview":Le("artifacts.svgPreviewTitle")||"SVG Preview";"function"!=typeof u.onPreviewCode?"html"===Nt&&Se(e=>!e):u.onPreviewCode({node:m,artifactType:e,artifactTitle:t,id:`temp-${Nt}-${Date.now()}`})},[Nt,Tt,m,u,Le]);/* @__PURE__ */
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 et=!1,tt=null,nt=!1,rt=null;async function ot(){if(rt)return rt;if(tt)return tt;if(nt)return null;rt=(async()=>{try{const e=function(e){var t,n,r;const o="function"==typeof(null==e?void 0:e.createCodeBlockRuntime)||"function"==typeof(null==e?void 0:e.useMonaco)?e:null==e?void 0:e.default,i=null!=(t=null==o?void 0:o.createCodeBlockRuntime)?t:null==o?void 0:o.useMonaco;return"function"!=typeof i?null:{createCodeBlockRuntime:e=>i.call(o,e),detectLanguage:null==(n=null==o?void 0:o.detectLanguage)?void 0:n.bind(o),preloadStreamDiffs:null==(r=null==o?void 0:o.preloadStreamDiffs)?void 0:r.bind(o)}}(await import("stream-diffs/markstream"));if(e)return await async function(e){et||(et=!0,(null==e?void 0:e.preloadStreamDiffs)&&await e.preloadStreamDiffs())}(e),tt=e,tt}catch{}return nt=!0,null})();try{return await rt}finally{rt=null}}const it="undefined"!=typeof window?u:s,lt={isShowPreview:!0,loading:!0,stream:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0};async function at(e,t){var n;if(t)try{if(!(await t()))return!1}catch{return!1}if("undefined"==typeof window||"function"!=typeof window.requestAnimationFrame)return!1;const r=()=>new Promise(e=>window.requestAnimationFrame(()=>e()));for(let o=0;o<30;o++){await r();const t=null!=(n=e.querySelector([".stream-diffs-shell","[data-stream-diffs-state]"].join(",")))?n:e.firstElementChild;if(!t)continue;const o=t.getBoundingClientRect();if(o.width>0&&o.height>0)return await r(),!0}return!1}function ct(e,t){const n={...t||{}};for(const i of["theme","themes","themeType","language","languages","stream","disableFileHeader","onThemeChange","renderCustomHeader","renderHeaderMetadata","renderHeaderPrefix"])delete n[i];if(!e)return{overflow:"wrap",...n};const r=n.parseDiffOptions&&"object"==typeof n.parseDiffOptions?n.parseDiffOptions:{},o={overflow:"wrap",diffStyle:"split",expandUnchanged:!1,collapsedContextThreshold:5,hunkSeparators:"line-info",parseDiffOptions:{context:2}};return{...o,...n,parseDiffOptions:{...o.parseDiffOptions,...r}}}function st(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 dt(e){var t,n;const r=String(null!=e?e:"").trim().toLowerCase();if(!r||"transparent"===r)return!0;const o=r.match(/^#([0-9a-f]{8})$/);if(o)return 0===Number.parseInt(o[1].slice(6),16);const i=r.match(/^#([0-9a-f]{4})$/);if(i)return 0===Number.parseInt(i[1][3]+i[1][3],16);const l=null==(n=null==(t=r.match(/^(?:rgba?|hsla?)\(([^)]+)\)/))?void 0:t[1])?void 0:n.split(/[\s,/]+/).filter(Boolean);return 4===(null==l?void 0:l.length)&&0===Number(l[3])}function ut(r){var l,a;const u={...lt,...r},{node:m,isDark:h,loading:f,stream:p,isShowPreview:g,enableFontSizeControl:v,darkTheme:y,lightTheme:w,codeBlockOptions:x,themes:k,minWidth:b,maxWidth:C,showHeader:N,showCopyButton:M,showExpandButton:B,showPreviewButton:S,showCollapseButton:T,showFontSizeButtons:E,showLineNumbers:L,showTooltips:D}=u,$=c(null),j=c(null),z=c(null),K=c(null),V=c(null),q=c(null),U=c(null),X=c(0),Z=c(null),Y=c(null),G=Ae(),J=c(null),Q=c(null),ee=c(x),te=c(null),ne=c([]),re=c(null),oe=c(!1),ie=c(void 0),[le,ae]=i(!1),[ce,se]=i(()=>"undefined"==typeof window),[de,ue]=i(!1),[me,he]=i(!1),[fe,pe]=i(!1),[ge,ve]=i(()=>m.language||"plaintext"),[ye,we]=i(()=>P(m.language)),[xe,ke]=i(!1),[be,Ce]=i(!1),[Ne,Me]=i(!1),[Be,Se]=i(!1),[Te,Ee]=i(0),{t:Le}=He();s(()=>{oe.current=be},[be]);const De=o(()=>ct(Boolean(m.diff),x),[x,m.diff]),[$e,Pe]=i(()=>{var e;const t=Number(null==(e=ct(Boolean(m.diff),x))?void 0:e.fontSize);return Number.isFinite(t)&&t>0?t:A}),[Re,Fe]=i($e),Ie=o(()=>!1!==D,[D]),_e="boolean"==typeof L?L:!0!==De.disableLineNumbers,We=c(_e),Oe=Number(null==(l=ee.current)?void 0:l.fontSize),je=Number(null==x?void 0:x.fontSize),ze=ee.current!==x&&Number.isFinite(Oe)&&Oe>0&&(!Number.isFinite(je)||je<=0),Ke=d(()=>{var e;const t=null!=(e=De.maxHeight)?e:500;return"number"==typeof t&&Number.isFinite(t)?t:500},[De.maxHeight]);it(()=>{const e=Number(De.fontSize),t=Number.isFinite(e)&&e>0?e:A;Pe(t),Fe(t)},[De.fontSize]);const Ve=d(e=>{var t,n,r;if(le)return;const o=$.current,i=z.current;if(!o||!i)return;const l="diff"===q.current?null==(t=i.getDiffEditorView)?void 0:t.call(i):null==(n=i.getEditorView)?void 0:n.call(i);if(!l)return;const a=Ke(),c="diff"===q.current,s=c?"important":"";e?(o.style.minHeight="0px",o.style.setProperty("max-height","none",s),o.style.overflow="visible"):(o.style.minHeight="0px",o.style.setProperty("max-height",`${Math.ceil(a)}px`,s),o.style.overflow=c?"hidden":"auto");try{const t=Number((()=>{if("function"==typeof l.getContentHeight)return l.getContentHeight();if(c&&"function"==typeof l.getModifiedEditor){const e=l.getModifiedEditor();if(e&&"function"==typeof e.getContentHeight)return e.getContentHeight()}})());if(Number.isFinite(t)&&t>0){const n=e?t:Math.min(t,a);o.style.setProperty("height",`${Math.ceil(Math.max(1,n))}px`,s)}null==(r=l.layout)||r.call(l)}catch{}},[Ke,le]),qe=d(e=>{if(Ve(e),"undefined"==typeof window||"function"!=typeof window.requestAnimationFrame)return;const t=window.requestAnimationFrame(()=>{Ve(e),window.requestAnimationFrame(()=>Ve(e))});return window.setTimeout(()=>Ve(e),180),()=>window.cancelAnimationFrame(t)},[Ve]),Ue=d(()=>{var e,t;for(const n of ne.current)try{"function"==typeof n?n():null==(e=null==n?void 0:n.dispose)||e.call(n)}catch{}ne.current=[],null==(t=re.current)||t.disconnect(),re.current=null},[]),Xe=d(()=>{var e,t,n;Ue();const r=z.current,o=$.current;if(!r||!o||"diff"!==q.current)return;const i=()=>qe(oe.current),l=(e,t)=>{try{const n=null==e?void 0:e[t];if("function"!=typeof n)return;const r=n.call(e,i);r&&ne.current.push(r)}catch{}},a=null==(e=r.getDiffEditorView)?void 0:e.call(r),c=null==(t=null==a?void 0:a.getOriginalEditor)?void 0:t.call(a),s=null==(n=null==a?void 0:a.getModifiedEditor)?void 0:n.call(a);if(l(a,"onDidUpdateDiff"),l(c,"onDidContentSizeChange"),l(s,"onDidContentSizeChange"),l(c,"onDidLayoutChange"),l(s,"onDidLayoutChange"),"undefined"!=typeof window&&"function"==typeof window.MutationObserver){const e=new window.MutationObserver(e=>{e.some(e=>"childList"===e.type||"attributes"===e.type&&e.target!==o)&&i()});e.observe(o,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),re.current=e}},[Ue,qe]);s(()=>R(()=>{Ee(e=>e+1)}),[]),s(()=>{we(P(m.language))},[m.language]);const Ge=c(m);Ge.current=m;const Je=d(()=>{var e;X.current+=1;try{null==(e=K.current)||e.call(K)}catch{}Ue(),V.current=null,q.current=null,U.current=null,pe(!1),he(!1)},[Ue]),et=o(()=>{var e,t;return h?null!=(e=null!=y?y:null==k?void 0:k[0])?e:"vitesse-dark":null!=(t=null!=w?w:null==k?void 0:k[1])?t:"vitesse-light"},[y,h,w,k]),tt=d(()=>et,[et]),nt=o(()=>tt(),[tt]),rt=o(()=>function(e,t){var n;const r=null!=(n=function(e){return"string"==typeof e?e:null}(e))?n:"",o=r.toLowerCase();return o?["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=>o.includes(e))&&!["light","latte","dawn","lotus"].some(e=>o.includes(e)):t}(nt,Boolean(h)),[h,nt]),ut=o(()=>m.diff?h?"dark":"light":rt?"dark":"light",[h,m.diff,rt]),mt=o(()=>m.diff?"dark"===ut:rt,[ut,m.diff,rt]),ht=o(()=>{var e;const t=De,n=F(De,ze?A:Re),r=function(e){const t="number"==typeof e&&Number.isFinite(e)&&e>=0?e:0;return{top:t,bottom:t}}(null==t?void 0:t.padding),o=m.diff?0:8,i="number"==typeof(null==t?void 0:t.padding)&&Number.isFinite(t.padding)&&t.padding>=0,l=null!=(e=I(null==t?void 0:t.tabSize))?e:4;return{...n,paddingBottom:i?r.bottom:o,paddingTop:i?r.top:o,tabSize:l}},[ze,Re,m.diff,De]),ft=o(()=>!!m.diff&&"unified"===De.diffStyle,[m.diff,De]),pt=o(()=>{var e,t,n;const r=String(m.diff?null!=(t=null!=(e=m.updatedCode)?e:m.code)?t:"":null!=(n=m.code)?n:"");if(!r)return 1;const o=f?r:r.replace(/\r\n$|\n$|\r$/,"");return Math.max(1,o.split(/\r\n|\r|\n/).length)},[f,m.code,m.diff,m.updatedCode]),gt=o(()=>Math.ceil(pt*ht.lineHeight+ht.paddingTop+ht.paddingBottom),[pt,ht]),vt=o(()=>{const e={"--markstream-code-padding-left":"62px","--markstream-pre-diff-line-height":`${ht.lineHeight}px`,"--markstream-pre-line-number-top":`${ht.paddingTop}px`,"--markstream-pre-line-number-width":"36px","--markstream-pre-line-number-gap":"0px",fontSize:`${ht.fontSize}px`,lineHeight:`${ht.lineHeight}px`,maxHeight:`${Ke()}px`,overflow:"auto",paddingBottom:`${ht.paddingBottom}px`,paddingTop:`${ht.paddingTop}px`,tabSize:ht.tabSize,whiteSpace:"scroll"===De.overflow?"pre":"pre-wrap"};return ht.fontFamily&&(e.fontFamily=ht.fontFamily),e},[Ke,ht,De.overflow]),yt=d(()=>{var e,t,n,r,o;const i=$.current,l=j.current;if(!i||!l)return;if(l.style.removeProperty("--vscode-editor-foreground"),l.style.removeProperty("--vscode-editor-background"),l.style.removeProperty("--vscode-editor-selectionBackground"),i.style.setProperty("--diffs-tab-size",String(ht.tabSize)),"number"==typeof De.padding&&Number.isFinite(De.padding)&&De.padding>=0?i.style.setProperty("--diffs-gap-block",`${ht.paddingTop}px`):i.style.removeProperty("--diffs-gap-block"),m.diff)return i.style.removeProperty("--vscode-editor-foreground"),i.style.removeProperty("--vscode-editor-background"),void i.style.removeProperty("--vscode-editor-selectionBackground");const a=i;try{const c="undefined"!=typeof window&&window.getComputedStyle?window.getComputedStyle(a):null,s=String(null!=(e=null==c?void 0:c.getPropertyValue("--vscode-editor-foreground"))?e:"").trim()||String(null!=(t=null==c?void 0:c.color)?t:"").trim(),d=String(null!=(n=null==c?void 0:c.getPropertyValue("--vscode-editor-background"))?n:"").trim(),u=String(null!=(r=null==c?void 0:c.backgroundColor)?r:"").trim(),h=dt(d)?dt(u)?"":u:d,f=String(null!=(o=null==c?void 0:c.getPropertyValue("--vscode-editor-selectionBackground"))?o:"").trim();if(function(e,t,n,r){if(!n)return!1;const o=st(e),i=st(t);return r?null!=o&&o>170||null!=i&&i<110:null!=o&&o<85||null!=i&&i>190}(h,s,"plaintext"===_(String(m.language||ye||ge||"plaintext")),l.classList.contains("is-dark")))return i.style.removeProperty("--vscode-editor-foreground"),i.style.removeProperty("--vscode-editor-background"),void i.style.removeProperty("--vscode-editor-selectionBackground");s?i.style.setProperty("--vscode-editor-foreground",s):i.style.removeProperty("--vscode-editor-foreground"),h?i.style.setProperty("--vscode-editor-background",h):i.style.removeProperty("--vscode-editor-background"),f?i.style.setProperty("--vscode-editor-selectionBackground",f):i.style.removeProperty("--vscode-editor-selectionBackground")}catch{}},[ye,ge,m.diff,m.language,ht,De]),wt=d(()=>{const e=De.maxHeight,t={...De||{},...null==e?{}:{MAX_HEIGHT:e},themes:k?[...k]:void 0,stream:!1,disableFileHeader:!0,disableLineNumbers:!_e,fontSize:ht.fontSize,lineHeight:ht.lineHeight,...ht.fontFamily?{fontFamily:ht.fontFamily}:{},theme:nt,themeType:h?"dark":"light",onThemeChange(){yt()}};delete t.maxHeight,delete t.padding,delete t.tabSize;const n="string"==typeof t.unsafeCSS?t.unsafeCSS:"";return t.unsafeCSS=["[data-file], [data-diff] { --diffs-min-number-column-width-default: 2ch !important; }",n].filter(Boolean).join("\n"),t},[_e,h,ht,nt,De,yt,k]),xt=d(()=>{const e=wt(),t=J.current;if(!t)return J.current=e,e;for(const n of Object.keys(t))n in e||delete t[n];return Object.assign(t,e),t},[wt]),kt=d(e=>{const t=e(xt());return z.current=t,K.current="function"==typeof t.safeClean?()=>t.safeClean():"function"==typeof t.cleanupEditor?()=>t.cleanupEditor():null,t},[xt]),bt=o(()=>{var e;return JSON.stringify({diffStyle:De.diffStyle,expandUnchanged:De.expandUnchanged,collapsedContextThreshold:De.collapsedContextThreshold,hunkSeparators:De.hunkSeparators,lineDiffType:De.lineDiffType,maxLineDiffLength:De.maxLineDiffLength,expansionLineCount:De.expansionLineCount,context:null==(e=De.parseDiffOptions)?void 0:e.context})},[De]);s(()=>{xt()},[De,xt]),s(()=>()=>{var e,t,n;X.current+=1,null==(e=K.current)||e.call(K),Ue(),K.current=null,V.current=null,q.current=null,U.current=null,z.current=null,Q.current=null,Z.current=null,null==(n=null==(t=Y.current)?void 0:t.destroy)||n.call(t),Y.current=null},[Ue]),s(()=>{var e,t;if("undefined"==typeof window)return;if(ce)return;const n=j.current;if(!n)return;null==(t=null==(e=Y.current)?void 0:e.destroy)||t.call(e);const r=G(n,{rootMargin:"400px"});return Y.current=r,r.isVisible()&&se(!0),r.whenVisible.then(()=>se(!0)),()=>{r.destroy(),Y.current===r&&(Y.current=null)}},[G,ce]),s(()=>{let e=!0;return"undefined"==typeof window?()=>{e=!1}:z.current?(xt(),()=>{e=!1}):((async()=>{try{const t=await ot();if(!e)return;if(!t)return void ae(!0);const n=t.createCodeBlockRuntime,r=t.detectLanguage;if("function"==typeof r&&(Z.current=r),"function"!=typeof n)return void ae(!0);Q.current=n,kt(n),ue(!0)}catch{e&&ae(!0)}})(),()=>{e=!1})},[kt,xt]),s(()=>{var e;if(!m.language&&!ye&&Z.current)try{const t=Z.current(String(null!=(e=m.code)?e:""));t&&ve(t)}catch{}},[ye,m.code,m.language]);const Ct=o(()=>String(m.language||ye||ge||"plaintext"),[ye,ge,m.language]),Nt=o(()=>P(Ct),[Ct]),Mt=o(()=>_(Nt),[Nt]),Bt=o(()=>"plaintext"===Mt,[Mt]),St=o(()=>H(Nt),[Nt,Te]),Tt=o(()=>!!g&&("html"===Nt||"svg"===Nt),[Nt,g]),Et=o(()=>{const e=Nt;return e?W[e]||e.charAt(0).toUpperCase()+e.slice(1):W[""]||"Plain Text"},[Nt]),Lt=o(()=>{var e;return function(e,t,n){const r=function(e){const t=function(e){var t,n;const r=null!=(n=null==(t=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:t.trim())?n:"";if(r.length<3)return"";const o=r[0];if("`"!==o&&"~"!==o||r[1]!==o||r[2]!==o)return"";let i=3;for(;r[i]===o;)i+=1;return r.slice(i).trim()}(e);if(!t)return"";const n=t.split(/\s+/).filter(Boolean);if(!n.length)return"";const r="diff"===n[0]?n.slice(1):n;for(const o of r){const e=o.includes(":")?o.slice(o.indexOf(":")+1):o;if(e&&/[./\\-]/.test(e))return e}return""}(e);return{title:r||t,caption:r?n?`Diff / ${t}`:t:""}}(String(null!=(e=m.raw)?e:""),Et,Boolean(m.diff))},[Et,m.diff,m.raw]),Dt=Lt.title,$t=Lt.caption,Pt=o(()=>{var e,t,n;return m.diff?null!=(t=null!=(e=m.updatedCode)?e:m.code)?t:"":null!=(n=m.code)?n:""},[m.code,m.diff,m.updatedCode]),At=o(()=>{const e=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t={},n=e(b),r=e(C);return n&&(t.minWidth=n),r&&(t.maxWidth=r),m.diff?(t.color="var(--markstream-diff-shell-fg)",t.borderColor="var(--markstream-diff-shell-border)"):(t.color="var(--vscode-editor-foreground, var(--markstream-code-fallback-fg, var(--code-fg)))",t.backgroundColor="var(--vscode-editor-background, var(--markstream-code-fallback-bg, var(--code-bg)))",t.borderColor="var(--markstream-code-border-color, var(--code-border))"),t},[C,b,m.diff]),Rt=o(()=>{var e,t,n,r;return m.code.length>0||(null!=(t=null==(e=m.originalCode)?void 0:e.length)?t:0)>0||(null!=(r=null==(n=m.updatedCode)?void 0:n.length)?r:0)>0},[m.code,m.originalCode,m.updatedCode]),Ft=!1===p&&f||!1!==p&&f&&!Rt;s(()=>{if(le)return;if(!de)return;if(!me||!ce)return;const e=z.current;xt();const t=()=>{var t;m.diff&&(null==(t=null==e?void 0:e.refreshDiffPresentation)||t.call(e)),yt(),Ne||null==("undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>qe(be)):null)&&qe(be)};(null==e?void 0:e.setTheme)&&nt?Promise.resolve(e.setTheme(nt)).then(t).catch(()=>{}):t()},[Ne,me,ut,be,de,m.diff,nt,qe,yt,xt,le,ce]);const It=d(async()=>{var e,t;if(le)return null;if(!ce)return null;if(Ne)return null;if(Ft)return null;const n=z.current,r=$.current;if(!n||!r||!n.createEditor)return null;xt();const o=Ge.current,i=o.diff?"diff":"single",l=U.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(q.current===i&&l===r&&a)return null;if(V.current)return V.current;X.current+=1;const c=X.current;he(!0);const s=(async()=>{var e,t,i,l,a,s;try{null==(e=K.current)||e.call(K),q.current=null,U.current=null,pe(!1);const d=Mt;if(o.diff?"function"==typeof n.createDiffEditor?(q.current="diff",await n.createDiffEditor(r,String(null!=(t=o.originalCode)?t:""),String(null!=(i=o.updatedCode)?i:""),d)):(q.current="single",await n.createEditor(r,String(null!=(a=null!=(l=o.updatedCode)?l:o.code)?a:""),d)):(q.current="single",await n.createEditor(r,String(null!=(s=o.code)?s:""),d)),U.current=r,X.current!==c)return;Xe(),yt(),be||Ne||qe(!1);const u=await Promise.race([at(r,n.whenVisualReady),new Promise(e=>{window.setTimeout(()=>e(!0),1500)})]);if(X.current!==c)return;if(!u)return;Ve(be),pe(!0)}catch{X.current===c&&(ie.current=Mt,ae(!0))}})().finally(()=>{V.current===s&&(V.current=null)});return V.current=s,s},[Ve,Xe,Ne,be,Mt,qe,Ft,yt,xt,le,ce]);s(()=>{xt();const e=ee.current!==x;ee.current=x;const t=We.current!==_e;We.current=_e;const n=te.current;if(te.current=bt,le)return;if(!de)return;let r=!1;if(e||t){const e=Q.current;if(e){Je(),z.current=null,K.current=null;try{kt(e),r=!0}catch{return void ae(!0)}}}const o=Boolean(m.diff&&n!==bt);if(!r&&!o)return;if(!ce||!me&&!r)return;if(Ne||Ft)return;let i=!1;return(async()=>{if(r||Je(),!i)try{await It()}catch{}})(),()=>{i=!0}},[Ne,x,me,_e,It,kt,de,bt,m.diff,Je,Ft,xt,le,ce]),s(()=>{if(le){const e=ie.current;if(void 0===e||e===Mt)return;return ie.current=void 0,Je(),void ae(!1)}de&&ce&&(Ne||Ft?Je():It())},[Ne,It,Mt,de,Je,Ft,le,ce]),s(()=>{var e;if(le)return;if(!de)return;if(!ce)return;if(Ne)return;if(Ft)return;const t=z.current;if(!t)return;const n=String(null!=(e=m.code)?e:"");(async()=>{var e,r;let o=ye;if(!o&&Z.current)try{o=P(Z.current(n)),o&&we(o)}catch{}const i=_(o||Nt);if(t.createEditor&&$.current){try{await Promise.resolve(It())}catch{}const e=V.current;if(e)try{await e}catch{}}try{m.diff&&t.updateDiff?await Promise.resolve(t.updateDiff(String(null!=(e=m.originalCode)?e:""),String(null!=(r=m.updatedCode)?r:""),i)):t.updateCode&&await Promise.resolve(t.updateCode(n,i))}catch{}const l=$.current;l&&"true"!==l.getAttribute("data-markstream-enhanced")&&await at(l,t.whenVisualReady)&&(Ve(be),pe(!0)),qe(be)})()},[Ve,Nt,ye,Ne,me,It,be,de,m.code,m.diff,m.originalCode,m.updatedCode,qe,Ft,le,ce]),s(()=>{if(le)return;if(!de)return;if(!ce)return;if(Ne)return;if(Ft)return;if(!be&&f)return;const e="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>qe(be)):null;return null==e&&qe(be),()=>{null!=e&&"undefined"!=typeof window&&"function"==typeof window.cancelAnimationFrame&&window.cancelAnimationFrame(e)}},[Ne,be,f,de,qe,Ft,le,ce]),s(()=>{var e,t,n;if(!v)return;if(le)return;const r=z.current;if(r){try{const o="diff"===q.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:Re})}catch{}qe(be)}},[v,be,Re,m.diff,qe,le]),s(()=>{Ie||Ye(!0)},[Ie]);const _t=d((e,t)=>{if(!Ie)return;const n=e.currentTarget;n&&!n.disabled&&("clientX"in e&&(e.clientX,e.clientY),Ze(n,t,"top",!1,0,mt))},[mt,Ie]),Ht=d(()=>{Ie&&Ye()},[Ie]),Wt=d(async()=>{var e;const t=String(Pt);try{u.clipboardWriter?await u.clipboardWriter(t):"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(t),ke(!0),null==(e=u.onCopy)||e.call(u,t),setTimeout(()=>ke(!1),1e3)}catch{}},[u,Pt]),Ot=d(()=>{if(!Tt)return;const e="html"===Nt?"text/html":"image/svg+xml",t="html"===Nt?Le("artifacts.htmlPreviewTitle")||"HTML Preview":Le("artifacts.svgPreviewTitle")||"SVG Preview";"function"!=typeof u.onPreviewCode?"html"===Nt&&Se(e=>!e):u.onPreviewCode({node:m,artifactType:e,artifactTitle:t,id:`temp-${Nt}-${Date.now()}`})},[Nt,Tt,m,u,Le]);/* @__PURE__ */
14
14
  return e("div",{ref:j,className:["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",mt?"border-gray-700/30":"border-gray-200",f?"is-rendering":"",mt?"is-dark":"",m.diff?"is-diff":"",Bt?"is-plain-text":""].join(" "),style:At,children:[N&&/* @__PURE__ */e("div",{className:"code-block-header",children:[
15
15
  /* @__PURE__ */e("div",{className:"code-header-main",children:[
16
16
  /* @__PURE__ */t("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:St}}),
@@ -26,165 +26,165 @@ return e("div",{ref:j,className:["code-block-container my-4 rounded-lg border ov
26
26
  /* @__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"})]})})}),B&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn transition-colors","aria-pressed":be,onClick:e=>{Ce(e=>!e),_t(e,be?Le("common.expand")||"Expand":Le("common.collapse")||"Collapse")},onMouseEnter:e=>_t(e,be?Le("common.collapse")||"Collapse":Le("common.expand")||"Expand"),onFocus:e=>_t(e,be?Le("common.collapse")||"Collapse":Le("common.expand")||"Expand"),onMouseLeave:Ht,onBlur:Ht,children:/* @__PURE__ */t("svg",be?{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:"action-icon",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:"action-icon",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"})})}),Tt&&S&&/* @__PURE__ */t("button",{type:"button",className:"code-action-btn transition-colors","aria-label":Le("common.preview")||"Preview",onClick:Ot,onMouseEnter:e=>_t(e,Le("common.preview")||"Preview"),onFocus:e=>_t(e,Le("common.preview")||"Preview"),onMouseLeave:Ht,onBlur:Ht,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:[
27
27
  /* @__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"}),
28
28
  /* @__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"})]})})})]})]}),
29
- /* @__PURE__ */e("div",{className:`code-block-body${Ne?" code-block-body--collapsed":""}${be?" code-block-body--expanded":""}`,children:[!Ne&&(!!p||!f)&&(le?/* @__PURE__ */t(O,{className:"code-fallback-plain m-0",diffInline:ft,node:m,showLineNumbers:He,style:vt}):/* @__PURE__ */e("div",{className:"code-editor-layer",children:[
30
- /* @__PURE__ */t("div",{ref:$,className:"code-editor-container"+(p?"":" code-height-placeholder"),"data-markstream-enhanced":fe?"true":"false","data-markstream-host-hidden":fe?void 0:"true",style:{"--markstream-editor-initial-height":`${gt}px`,visibility:fe?"visible":"hidden"},"aria-hidden":!fe}),!fe&&/* @__PURE__ */t("div",{className:"code-editor-fallback-surface",children:/* @__PURE__ */t(O,{className:"code-fallback-plain m-0",diffInline:ft,node:m,showLineNumbers:He,style:vt})})]})),!p&&f&&/* @__PURE__ */t("div",{className:"code-loading-placeholder",children:/* @__PURE__ */e("div",{className:"loading-skeleton",children:[
29
+ /* @__PURE__ */e("div",{className:`code-block-body${Ne?" code-block-body--collapsed":""}${be?" code-block-body--expanded":""}`,children:[!Ne&&(!!p||!f)&&(le?/* @__PURE__ */t(O,{className:"code-fallback-plain m-0",diffInline:ft,node:m,showLineNumbers:_e,style:vt}):/* @__PURE__ */e("div",{className:"code-editor-layer",children:[
30
+ /* @__PURE__ */t("div",{ref:$,className:"code-editor-container"+(p?"":" code-height-placeholder"),"data-markstream-enhanced":fe?"true":"false","data-markstream-host-hidden":fe?void 0:"true",style:{"--markstream-editor-initial-height":`${gt}px`,visibility:fe?"visible":"hidden"},"aria-hidden":!fe}),!fe&&/* @__PURE__ */t("div",{className:"code-editor-fallback-surface",children:/* @__PURE__ */t(O,{className:"code-fallback-plain m-0",diffInline:ft,node:m,showLineNumbers:_e,style:vt})})]})),!p&&f&&/* @__PURE__ */t("div",{className:"code-loading-placeholder",children:/* @__PURE__ */e("div",{className:"loading-skeleton",children:[
31
31
  /* @__PURE__ */t("div",{className:"skeleton-line"}),
32
32
  /* @__PURE__ */t("div",{className:"skeleton-line"}),
33
- /* @__PURE__ */t("div",{className:"skeleton-line short"})]})})]}),Be&&!u.onPreviewCode&&Tt&&"html"===Nt&&/* @__PURE__ */t(Ge,{code:String(null!=(a=m.code)?a:""),htmlPreviewAllowScripts:u.htmlPreviewAllowScripts,htmlPreviewSandbox:u.htmlPreviewSandbox,isDark:h,onClose:()=>Se(!1)}),
34
- /* @__PURE__ */t("span",{className:"sr-only","aria-live":"polite",role:"status",children:xe?Le("common.copied")||"Copied":""})]})}function dt(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=dt(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function ut(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=dt(e))&&(r&&(r+=" "),r+=t);return r}let mt=0;const ht=()=>import("@terrastruct/d2");let ft=null,pt=ht;function gt(e){pt=e,ft=null}function vt(e){gt(null!=e?e:ht)}function yt(){gt(null)}function wt(){return"function"==typeof pt}async function xt(){if(ft)return ft;const e=pt;if(!e)return null;let t;try{t=await e()}catch(n){if(e===ht)throw new Error('Optional dependency "@terrastruct/d2" is not installed. Please install it to enable D2 diagrams.');throw n}return t?(ft=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),ft):null}const kt={loading:!0,progressiveRender:!0,progressiveIntervalMs:700,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showCollapseButton:!0},bt={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"},Ct=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],Nt=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function Mt(e){if(!e)return"";const t=e.trim();return Nt.test(t)?t:""}function Bt(r){var l,a;const u={...kt,...r},{t:m}=_e(),[h,f]=i(!1),[p,g]=i(!1),[v,y]=i(!1),[w,x]=i(!1),[k,b]=i(null),[C,N]=i(""),[M,B]=i(null),[S,T]=i(!1),[E,L]=i(()=>"undefined"==typeof window),D=c(0),$=c(null),P=c(!1),A=c(!1),R=c(0),F=c(null),I=c(!1),_=c(null),H=c(null),W=c(null),O=c(null),j=c(!1),z=c(()=>{}),K=Pe(),V=null!=(a=null==(l=u.node)?void 0:l.code)?a:"",q=v||!w||!C,U=!!C,X=o(()=>{if(!u.maxHeight)return;const e="number"==typeof u.maxHeight?`${u.maxHeight}px`:String(u.maxHeight);return{maxHeight:e,"--ms-d2-render-max-height":e}},[u.maxHeight]),Z=o(()=>{if(q&&M)return{minHeight:`${M}px`}},[M,q]);s(()=>{j.current=S},[S]),s(()=>{const e=_.current;if(!e)return;const t=K(e,{rootMargin:"160px"});return H.current=t,t.isVisible()&&L(!0),t.whenVisible.then(()=>L(!0)),()=>{t.destroy(),H.current=null}},[K]);const Y=d(()=>{const e=W.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(j.current)return void(I.current=!0);const t=Math.max(120,Number(u.progressiveIntervalMs)||0),n=Date.now()-R.current;if(!e&&n<t)return I.current=!0,void(null==F.current&&(F.current=window.setTimeout(()=>{F.current=null,I.current&&(I.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 xt();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,i;if("undefined"==typeof window||A.current)return;if(!E)return;if(u.loading&&!u.progressiveRender)return;if(!V)return N(""),void b(null);const l=++D.current;T(!0),b(null);try{const a=await J();if(!a)return x(!1),y(!0),N(""),void b("D2 is not available.");if("function"!=typeof a.compile||"function"!=typeof a.render)throw new Error("D2 instance is missing compile/render methods.");x(!0);const c=await a.compile(V);if(l!==D.current)return;const s=null!=(e=null==c?void 0:c.diagram)?e:c,d=null!=(n=null!=(t=null==c?void 0:c.renderOptions)?t:null==c?void 0:c.options)?n:{},m=null!=(r=u.themeId)?r:d.themeID,h=null!=(o=u.darkThemeId)?o:d.darkThemeID,f={...d};if(f.themeID=u.isDark&&null!=h?h:m,f.darkThemeID=null,f.darkThemeOverrides=null,u.isDark){const e=d.themeOverrides&&"object"==typeof d.themeOverrides?d.themeOverrides:null;f.themeOverrides={...bt,...e||{}}}f.salt=null!=(i=f.salt)?i:function(e="markstream-react-d2"){return mt+=1,`${e}-${mt}`}();const p=await a.render(s,f);if(l!==D.current)return;const g=function(e){return e?"string"==typeof e?e:"string"==typeof e.svg?e.svg:"string"==typeof e.data?e.data:"":""}(p);if(!g)throw new Error("D2 render returned empty output.");const v=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(Ct.some(e=>e.test(n))){r.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&t.value){const n=Mt(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}(g);N(v||""),u.loading&&y(!1),b(null)}catch(a){if(l!==D.current)return;const e=(null==a?void 0:a.message)?String(a.message):"D2 render failed.";u.loading||b(e),e.includes("@terrastruct/d2")&&(x(!1),y(!0))}finally{l===D.current&&(T(!1),I.current&&(I.current=!1,G()))}},[V,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(V),f(!0),setTimeout(()=>f(!1),1e3)}catch{}},[V]),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&&Ue(e.currentTarget,t,"top",!1,(e.clientX,e.clientY),u.isDark)},[u.isDark]),re=d(()=>{Xe()},[]);return s(()=>{G()},[V,u.loading,u.isDark,G]),s(()=>{u.loading||G(!0)},[u.loading,G]),s(()=>{const e=requestAnimationFrame(()=>Y());return()=>cancelAnimationFrame(e)},[q,C,V,Y]),s(()=>{A.current=!1,G();const e=requestAnimationFrame(()=>Y());if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{Y()});O.current=e,W.current&&e.observe(W.current)}return()=>{var t;A.current=!0,null!=F.current&&(clearTimeout(F.current),F.current=null),null==(t=O.current)||t.disconnect(),O.current=null,cancelAnimationFrame(e)}},[G,Y]),/* @__PURE__ */e("div",{ref:_,className:ut("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:[
33
+ /* @__PURE__ */t("div",{className:"skeleton-line short"})]})})]}),Be&&!u.onPreviewCode&&Tt&&"html"===Nt&&/* @__PURE__ */t(Qe,{code:String(null!=(a=m.code)?a:""),htmlPreviewAllowScripts:u.htmlPreviewAllowScripts,htmlPreviewSandbox:u.htmlPreviewSandbox,isDark:h,onClose:()=>Se(!1)}),
34
+ /* @__PURE__ */t("span",{className:"sr-only","aria-live":"polite",role:"status",children:xe?Le("common.copied")||"Copied":""})]})}function mt(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=mt(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function ht(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=mt(e))&&(r&&(r+=" "),r+=t);return r}let ft=0;const pt=()=>import("@terrastruct/d2");let gt=null,vt=pt;function yt(e){vt=e,gt=null}function wt(e){yt(null!=e?e:pt)}function xt(){yt(null)}function kt(){return"function"==typeof vt}async function bt(){if(gt)return gt;const e=vt;if(!e)return null;let t;try{t=await e()}catch(n){if(e===pt)throw new Error('Optional dependency "@terrastruct/d2" is not installed. Please install it to enable D2 diagrams.');throw n}return t?(gt=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),gt):null}const Ct={loading:!0,progressiveRender:!0,progressiveIntervalMs:700,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showCollapseButton:!0},Nt={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"},Mt=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],Bt=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function St(e){if(!e)return"";const t=e.trim();return Bt.test(t)?t:""}function Tt(r){var l,a;const u={...Ct,...r},{t:m}=He(),[h,f]=i(!1),[p,g]=i(!1),[v,y]=i(!1),[w,x]=i(!1),[k,b]=i(null),[C,N]=i(""),[M,B]=i(null),[S,T]=i(!1),[E,L]=i(()=>"undefined"==typeof window),D=c(0),$=c(null),P=c(!1),A=c(!1),R=c(0),F=c(null),I=c(!1),_=c(null),H=c(null),W=c(null),O=c(null),j=c(!1),z=c(()=>{}),K=Ae(),V=null!=(a=null==(l=u.node)?void 0:l.code)?a:"",q=v||!w||!C,U=!!C,X=o(()=>{if(!u.maxHeight)return;const e="number"==typeof u.maxHeight?`${u.maxHeight}px`:String(u.maxHeight);return{maxHeight:e,"--ms-d2-render-max-height":e}},[u.maxHeight]),Z=o(()=>{if(q&&M)return{minHeight:`${M}px`}},[M,q]);s(()=>{j.current=S},[S]),s(()=>{const e=_.current;if(!e)return;const t=K(e,{rootMargin:"160px"});return H.current=t,t.isVisible()&&L(!0),t.whenVisible.then(()=>L(!0)),()=>{t.destroy(),H.current=null}},[K]);const Y=d(()=>{const e=W.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(j.current)return void(I.current=!0);const t=Math.max(120,Number(u.progressiveIntervalMs)||0),n=Date.now()-R.current;if(!e&&n<t)return I.current=!0,void(null==F.current&&(F.current=window.setTimeout(()=>{F.current=null,I.current&&(I.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 bt();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,i;if("undefined"==typeof window||A.current)return;if(!E)return;if(u.loading&&!u.progressiveRender)return;if(!V)return N(""),void b(null);const l=++D.current;T(!0),b(null);try{const a=await J();if(!a)return x(!1),y(!0),N(""),void b("D2 is not available.");if("function"!=typeof a.compile||"function"!=typeof a.render)throw new Error("D2 instance is missing compile/render methods.");x(!0);const c=await a.compile(V);if(l!==D.current)return;const s=null!=(e=null==c?void 0:c.diagram)?e:c,d=null!=(n=null!=(t=null==c?void 0:c.renderOptions)?t:null==c?void 0:c.options)?n:{},m=null!=(r=u.themeId)?r:d.themeID,h=null!=(o=u.darkThemeId)?o:d.darkThemeID,f={...d};if(f.themeID=u.isDark&&null!=h?h:m,f.darkThemeID=null,f.darkThemeOverrides=null,u.isDark){const e=d.themeOverrides&&"object"==typeof d.themeOverrides?d.themeOverrides:null;f.themeOverrides={...Nt,...e||{}}}f.salt=null!=(i=f.salt)?i:function(e="markstream-react-d2"){return ft+=1,`${e}-${ft}`}();const p=await a.render(s,f);if(l!==D.current)return;const g=function(e){return e?"string"==typeof e?e:"string"==typeof e.svg?e.svg:"string"==typeof e.data?e.data:"":""}(p);if(!g)throw new Error("D2 render returned empty output.");const v=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(Mt.some(e=>e.test(n))){r.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&t.value){const n=St(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}(g);N(v||""),u.loading&&y(!1),b(null)}catch(a){if(l!==D.current)return;const e=(null==a?void 0:a.message)?String(a.message):"D2 render failed.";u.loading||b(e),e.includes("@terrastruct/d2")&&(x(!1),y(!0))}finally{l===D.current&&(T(!1),I.current&&(I.current=!1,G()))}},[V,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(V),f(!0),setTimeout(()=>f(!1),1e3)}catch{}},[V]),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&&Ze(e.currentTarget,t,"top",!1,(e.clientX,e.clientY),u.isDark)},[u.isDark]),re=d(()=>{Ye()},[]);return s(()=>{G()},[V,u.loading,u.isDark,G]),s(()=>{u.loading||G(!0)},[u.loading,G]),s(()=>{const e=requestAnimationFrame(()=>Y());return()=>cancelAnimationFrame(e)},[q,C,V,Y]),s(()=>{A.current=!1,G();const e=requestAnimationFrame(()=>Y());if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{Y()});O.current=e,W.current&&e.observe(W.current)}return()=>{var t;A.current=!0,null!=F.current&&(clearTimeout(F.current),F.current=null),null==(t=O.current)||t.disconnect(),O.current=null,cancelAnimationFrame(e)}},[G,Y]),/* @__PURE__ */e("div",{ref:_,className:ht("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:[
35
35
  /* @__PURE__ */t("div",{className:"flex items-center gap-x-2",children:/* @__PURE__ */t("span",{className:"text-sm font-medium font-mono",children:"D2"})}),
36
- /* @__PURE__ */e("div",{className:"flex items-center gap-x-2",children:[u.showModeToggle&&/* @__PURE__ */e("div",{className:ut("flex items-center gap-x-1 rounded-md p-0.5",u.isDark?"bg-gray-700":"bg-gray-100"),children:[
37
- /* @__PURE__ */t("button",{type:"button",className:ut("mode-btn px-2 py-1 text-xs rounded",!v&&"is-active"),onClick:()=>y(!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"}),
38
- /* @__PURE__ */t("button",{type:"button",className:ut("mode-btn px-2 py-1 text-xs rounded",v&&"is-active"),onClick:()=>y(!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:[
36
+ /* @__PURE__ */e("div",{className:"flex items-center gap-x-2",children:[u.showModeToggle&&/* @__PURE__ */e("div",{className:ht("flex items-center gap-x-1 rounded-md p-0.5",u.isDark?"bg-gray-700":"bg-gray-100"),children:[
37
+ /* @__PURE__ */t("button",{type:"button",className:ht("mode-btn px-2 py-1 text-xs rounded",!v&&"is-active"),onClick:()=>y(!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"}),
38
+ /* @__PURE__ */t("button",{type:"button",className:ht("mode-btn px-2 py-1 text-xs rounded",v&&"is-active"),onClick:()=>y(!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:[
39
39
  /* @__PURE__ */t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
40
40
  /* @__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":p,onClick:()=>g(e=>!e),onMouseEnter:e=>ne(e,p?m("common.expand")||"Expand":m("common.collapse")||"Collapse"),onFocus:e=>ne(e,p?m("common.expand")||"Expand":m("common.collapse")||"Collapse"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */t("svg",{style:{transform:`rotate(${p?0:90}deg)`},xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})})]})]}),!p&&/* @__PURE__ */t("div",{ref:W,className:"d2-block-body",style:Z,children:u.loading&&!U?/* @__PURE__ */e("div",{className:"d2-source px-4 py-4",children:[
41
41
  /* @__PURE__ */t("pre",{className:"d2-code",children:/* @__PURE__ */t("code",{children:V})}),k&&/* @__PURE__ */t("p",{className:"d2-error mt-2 text-xs",children:k})]}):/* @__PURE__ */t(n,{children:/* @__PURE__ */e("div",q?{className:"d2-source px-4 py-4",children:[
42
42
  /* @__PURE__ */t("pre",{className:"d2-code",children:/* @__PURE__ */t("code",{children:V})}),k&&/* @__PURE__ */t("p",{className:"d2-error mt-2 text-xs",children:k})]}:{className:"d2-render",style:X,children:[
43
- /* @__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 St(n){const{node:r,ctx:o,renderNode:i,indexKey:l}=n,a=Array.isArray(r.items)?r.items:[];/* @__PURE__ */
43
+ /* @__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 Et(n){const{node:r,ctx:o,renderNode:i,indexKey:l}=n,a=Array.isArray(r.items)?r.items:[];/* @__PURE__ */
44
44
  return t("dl",{className:"definition-list","data-index-key":l,children:a.map((n,r)=>/* @__PURE__ */e("div",{className:"mb-4",children:[
45
45
  /* @__PURE__ */t("dt",{className:"definition-term font-semibold",children:o&&i?j(n.term,o,`${String(null!=l?l:"definition")}-term-${r}`,i):null}),
46
- /* @__PURE__ */t("dd",{className:"definition-desc ml-4",children:o&&i?j(n.definition,o,`${String(null!=l?l:"definition")}-desc-${r}`,i):null})]},`${String(null!=l?l:"definition")}-${r}`))})}function Tt(e){var n;const{node:r}=e;/* @__PURE__ */
47
- return t("span",{className:"emoji-node",children:null!=(n=r.name)?n:r.markup})}function Et(e){/* @__PURE__ */
48
- return t("em",{className:"emphasis-node",children:e.children})}const Lt=".markdown-renderer";function Dt(e,t){var n,r;if("undefined"==typeof document||"undefined"==typeof Element)return null;const o=function(e){return`[id="${e.replace(/["\\]/g,"\\$&")}"]`}(t);let i=e instanceof Element?e.closest(Lt):null;for(;i;){const e=i.querySelector(o);if(e)return e;i=null!=(r=null==(n=i.parentElement)?void 0:n.closest(Lt))?r:null}return document.querySelector(o)}function $t(e){const{node:n}=e,r=d(e=>{var t;if(e.preventDefault(),"undefined"==typeof document)return;const r=Dt(e.currentTarget,`fnref-${String(null!=(t=n.id)?t:"")}`);r&&r.scrollIntoView({behavior:"smooth"})},[n.id]);/* @__PURE__ */
49
- return t("a",{className:"footnote-anchor text-sm hover:underline cursor-pointer",href:`#fnref-${n.id}`,title:`返回引用 ${n.id}`,onClick:r,children:"↩︎"})}function Pt(e){const{node:n,ctx:r,renderNode:o,indexKey:i}=e;/* @__PURE__ */
50
- 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?$(n.children,r,String(null!=i?i:`footnote-${n.id}`),o):null})})}function At(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=Dt(e.currentTarget,`fnref--${r.id}`);t&&t.scrollIntoView({behavior:"smooth"})},[r.id]);/* @__PURE__ */
51
- 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 Rt(e){/* @__PURE__ */
52
- return t("br",{className:"hard-break"})}function Ft(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__ */
53
- return t(c,{dir:"auto",className:ut("heading-node font-semibold",`heading-${a}`,d,u),..."object"==typeof m&&null!=m?{style:m}:{},...h,children:null!=l?l:r&&o?$(n.children,r,String(null!=i?i:`heading-${a}`),o):null})}function It(e){/* @__PURE__ */
54
- return t("mark",{className:"highlight-node",children:e.children})}function _t(l){var a,d,u,x,k,b,C,N;const{node:M,placeholder:B,customId:S}=l,T=null!=(u=null!=(d=l.htmlPolicy)?d:null==(a=l.ctx)?void 0:a.htmlPolicy)?u:"safe",E=Pe(),[L,D]=i(null),P=c(null),[A,R]=i(()=>"undefined"==typeof window),[F,I]=i(M.content),_=Boolean(M.loading),H=m(z,K,K),W=o(()=>{var e,t,n,r,o;return{...null!=(n=null!=(t=l.customComponents)?t:null==(e=l.ctx)?void 0:e.customComponents)?n:V(S),...null!=(o=null==(r=l.ctx)?void 0:r.htmlComponents)?o:{}}},[S,null==(x=l.ctx)?void 0:x.customComponents,null==(k=l.ctx)?void 0:k.htmlComponents,l.customComponents,H]),O=o(()=>{var e,t;return{...W,...null!=(t=null==(e=l.ctx)?void 0:e.streamingComponents)?t:{}}},[W,null==(b=l.ctx)?void 0:b.streamingComponents]);s(()=>{var e;if("undefined"==typeof window)return void R(!0);if(null==(e=P.current)||e.destroy(),P.current=null,!_)return R(!0),void I(M.content);if(!L)return void R(!1);const t=E(L,{rootMargin:"400px"});return P.current=t,t.isVisible()&&R(!0),t.whenVisible.then(()=>R(!0)).catch(()=>{}),()=>{t.destroy(),P.current=null}},[L,_,M.content,E]),s(()=>()=>{var e;null==(e=P.current)||e.destroy(),P.current=null},[]),s(()=>{_&&!A||I(M.content)},[_,M.content,A]);const j=o(()=>{var e;const t=q(h(null!=(e=M.attrs)?e:void 0,T));return t?U(t):void 0},[T,M.attrs]),Y=o(()=>{var e;return String(null!=(e=M.tag)?e:"").trim()},[M.tag]),G=o(()=>f(Y),[Y]),J=o(()=>{var e;const t=q(h(null!=(e=M.attrs)?e:void 0,T,Y));return t?U(t):void 0},[T,M.attrs,Y]),Q=o(()=>{var e;return p(g(h(null!=(e=M.attrs)?e:void 0,T,G)))},[T,M.attrs,G]),ee=o(()=>Array.isArray(M.children)?M.children:[],[M.children]),te=ee.length>0&&!!Y&&!v.has(Y.toLowerCase())&&!y(Y,T)&&!!l.ctx&&!!l.renderNode,ne=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}(J),[J]),re=o(()=>{var e;return"escape"!==T&&X(null!=(e=M.content)?e:"",O)},[O,T,M.content]),oe=o(()=>{var e,t,n;return re&&M.content?Z(M.content,W,T,{ctx:l.ctx,keyPrefix:String(null!=(e=l.indexKey)?e:"html-block"),nodeComponents:null==(t=l.ctx)?void 0:t.streamingComponents,propComponents:null==(n=l.ctx)?void 0:n.htmlComponents,renderNode:l.renderNode,sourceNode:M}):null},[W,T,M.autoClosed,M.content,M.loading,l.ctx,l.indexKey,l.renderNode,re]),ie=o(()=>w(null!=F?F:"",T),[T,F]),le=o(()=>{var e;return te&&l.ctx&&l.renderNode?$(ee,l.ctx,`${String(null!=(e=l.indexKey)?e:"html-block")}-structured`,l.renderNode):null},[te,l.ctx,l.indexKey,l.renderNode,ee]),ae=G?null==(N=null==(C=l.ctx)?void 0:C.htmlComponents)?void 0:N[G]:void 0,ce=/* @__PURE__ */t("div",{className:"html-block-node__placeholder",children:null!=B?B:/* @__PURE__ */e(n,{children:[
46
+ /* @__PURE__ */t("dd",{className:"definition-desc ml-4",children:o&&i?j(n.definition,o,`${String(null!=l?l:"definition")}-desc-${r}`,i):null})]},`${String(null!=l?l:"definition")}-${r}`))})}function Lt(e){var n;const{node:r}=e;/* @__PURE__ */
47
+ return t("span",{className:"emoji-node",children:null!=(n=r.name)?n:r.markup})}function Dt(e){/* @__PURE__ */
48
+ return t("em",{className:"emphasis-node",children:e.children})}const $t=".markdown-renderer";function Pt(e,t){var n,r;if("undefined"==typeof document||"undefined"==typeof Element)return null;const o=function(e){return`[id="${e.replace(/["\\]/g,"\\$&")}"]`}(t);let i=e instanceof Element?e.closest($t):null;for(;i;){const e=i.querySelector(o);if(e)return e;i=null!=(r=null==(n=i.parentElement)?void 0:n.closest($t))?r:null}return document.querySelector(o)}function At(e){const{node:n}=e,r=d(e=>{var t;if(e.preventDefault(),"undefined"==typeof document)return;const r=Pt(e.currentTarget,`fnref-${String(null!=(t=n.id)?t:"")}`);r&&r.scrollIntoView({behavior:"smooth"})},[n.id]);/* @__PURE__ */
49
+ return t("a",{className:"footnote-anchor text-sm hover:underline cursor-pointer",href:`#fnref-${n.id}`,title:`返回引用 ${n.id}`,onClick:r,children:"↩︎"})}function Rt(e){const{node:n,ctx:r,renderNode:o,indexKey:i}=e;/* @__PURE__ */
50
+ 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?$(n.children,r,String(null!=i?i:`footnote-${n.id}`),o):null})})}function Ft(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=Pt(e.currentTarget,`fnref--${r.id}`);t&&t.scrollIntoView({behavior:"smooth"})},[r.id]);/* @__PURE__ */
51
+ 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 It(e){/* @__PURE__ */
52
+ return t("br",{className:"hard-break"})}function _t(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__ */
53
+ return t(c,{dir:"auto",className:ht("heading-node font-semibold",`heading-${a}`,d,u),..."object"==typeof m&&null!=m?{style:m}:{},...h,children:null!=l?l:r&&o?$(n.children,r,String(null!=i?i:`heading-${a}`),o):null})}function Ht(e){/* @__PURE__ */
54
+ return t("mark",{className:"highlight-node",children:e.children})}function Wt(l){var a,d,u,x,k,b,C,N;const{node:M,placeholder:B,customId:S}=l,T=null!=(u=null!=(d=l.htmlPolicy)?d:null==(a=l.ctx)?void 0:a.htmlPolicy)?u:"safe",E=Ae(),[L,D]=i(null),P=c(null),[A,R]=i(()=>"undefined"==typeof window),[F,I]=i(M.content),_=Boolean(M.loading),H=m(z,K,K),W=o(()=>{var e,t,n,r,o;return{...null!=(n=null!=(t=l.customComponents)?t:null==(e=l.ctx)?void 0:e.customComponents)?n:V(S),...null!=(o=null==(r=l.ctx)?void 0:r.htmlComponents)?o:{}}},[S,null==(x=l.ctx)?void 0:x.customComponents,null==(k=l.ctx)?void 0:k.htmlComponents,l.customComponents,H]),O=o(()=>{var e,t;return{...W,...null!=(t=null==(e=l.ctx)?void 0:e.streamingComponents)?t:{}}},[W,null==(b=l.ctx)?void 0:b.streamingComponents]);s(()=>{var e;if("undefined"==typeof window)return void R(!0);if(null==(e=P.current)||e.destroy(),P.current=null,!_)return R(!0),void I(M.content);if(!L)return void R(!1);const t=E(L,{rootMargin:"400px"});return P.current=t,t.isVisible()&&R(!0),t.whenVisible.then(()=>R(!0)).catch(()=>{}),()=>{t.destroy(),P.current=null}},[L,_,M.content,E]),s(()=>()=>{var e;null==(e=P.current)||e.destroy(),P.current=null},[]),s(()=>{_&&!A||I(M.content)},[_,M.content,A]);const j=o(()=>{var e;const t=q(h(null!=(e=M.attrs)?e:void 0,T));return t?U(t):void 0},[T,M.attrs]),Y=o(()=>{var e;return String(null!=(e=M.tag)?e:"").trim()},[M.tag]),G=o(()=>f(Y),[Y]),J=o(()=>{var e;const t=q(h(null!=(e=M.attrs)?e:void 0,T,Y));return t?U(t):void 0},[T,M.attrs,Y]),Q=o(()=>{var e;return p(g(h(null!=(e=M.attrs)?e:void 0,T,G)))},[T,M.attrs,G]),ee=o(()=>Array.isArray(M.children)?M.children:[],[M.children]),te=ee.length>0&&!!Y&&!v.has(Y.toLowerCase())&&!y(Y,T)&&!!l.ctx&&!!l.renderNode,ne=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}(J),[J]),re=o(()=>{var e;return"escape"!==T&&X(null!=(e=M.content)?e:"",O)},[O,T,M.content]),oe=o(()=>{var e,t,n;return re&&M.content?Z(M.content,W,T,{ctx:l.ctx,keyPrefix:String(null!=(e=l.indexKey)?e:"html-block"),nodeComponents:null==(t=l.ctx)?void 0:t.streamingComponents,propComponents:null==(n=l.ctx)?void 0:n.htmlComponents,renderNode:l.renderNode,sourceNode:M}):null},[W,T,M.autoClosed,M.content,M.loading,l.ctx,l.indexKey,l.renderNode,re]),ie=o(()=>w(null!=F?F:"",T),[T,F]),le=o(()=>{var e;return te&&l.ctx&&l.renderNode?$(ee,l.ctx,`${String(null!=(e=l.indexKey)?e:"html-block")}-structured`,l.renderNode):null},[te,l.ctx,l.indexKey,l.renderNode,ee]),ae=G?null==(N=null==(C=l.ctx)?void 0:C.htmlComponents)?void 0:N[G]:void 0,ce=/* @__PURE__ */t("div",{className:"html-block-node__placeholder",children:null!=B?B:/* @__PURE__ */e(n,{children:[
55
55
  /* @__PURE__ */t("span",{className:"html-block-node__placeholder-bar"}),
56
56
  /* @__PURE__ */t("span",{className:"html-block-node__placeholder-bar w-4/5"}),
57
- /* @__PURE__ */t("span",{className:"html-block-node__placeholder-bar w-2/3"})]})});return te&&ae?r.createElement(ae,Q,le):te?r.createElement(Y,{...ne,ref:D},A?le:ce):/* @__PURE__ */t("div",{ref:D,className:"html-block-node",...j,children:A?re&&oe?/* @__PURE__ */t(n,{children:oe}):/* @__PURE__ */t("div",{dangerouslySetInnerHTML:{__html:ie}}):ce})}const Ht=(()=>{try{return Boolean(!1)}catch{}return!1})();function Wt(e){Ht&&console.warn(e)}function Ot(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 jt(e,t){Array.isArray(t)?e.push(...t):null!=t&&e.push(t)}function zt(e,t){var n;for(const r of Y(e)){if("tag_open"!==r.type&&"self_closing"!==r.type)continue;const e=null!=(n=r.tagName)?n:"";if(!G(e,t))continue;const o=t[e]||t[e.toLowerCase()];if("block"===J(o))return!0}return!1}function Kt(e,t){var n,r;return(null==(n=t.nodeComponents)?void 0:n[e])||(null==(r=t.nodeComponents)?void 0:r[e.toLowerCase()])}function Vt(e){if(null==e||"boolean"==typeof e)return"";if("string"==typeof e||"number"==typeof e)return String(e);if(Array.isArray(e))return e.map(Vt).join("");if(!r.isValidElement(e))return"";const t=e;if("string"!=typeof t.type)return Vt(t.props.children);const n=Object.entries(t.props).filter(([e,t])=>"children"!==e&&"key"!==e&&"ref"!==e&&null!=t&&"boolean"!=typeof t).map(([e,t])=>` ${"className"===e?"class":e}="${String(t)}"`).join("");return`<${t.type}${n}>${Vt(t.props.children)}</${t.type}>`}function qt(e){return Object.entries(e).map(([e,t])=>[e,""===t?null:t])}function Ut(e){var t,n;const r=e.sourceNode,o=!0!==(null==(t=e.ctx)?void 0:t.final)&&(!1===(null==(n=e.ctx)?void 0:n.final)||Boolean(null==r?void 0:r.loading));return{loading:o,autoClosed:o||Boolean(null==r?void 0:r.autoClosed)}}function Xt(e,t,n,o,i,l,a,c,s,d){const u=G(e,o),m=Boolean(Kt(e,a));if(x.has(e.toLowerCase())||!u&&!m&&k(e,l))return null;if(!u&&!m&&y(e,l))return[Ot(e,t),...n,`</${e}>`];const h=Q(t,l,e),g=h.key,v=null!=g&&""!==g?g:i;if(m)return function(e,t,n,o,i,l,a,c=Ut(i)){const s=f(e),d=null!=l?l:function(e){return e.map(Vt).join("")}(n),u={type:s,tag:s,attrs:qt(t),content:d,raw:null!=a?a:`${Ot(e,t)}${d}</${e}>`,loading:c.loading,autoClosed:c.autoClosed};if(i.ctx&&i.renderNode)return i.renderNode(u,o,i.ctx);const m=Kt(e,i);return m?r.createElement(m,{key:o,node:u}):null}(e,t,n,String(v),a,c,s,d);if(u){const t=o[e]||o[e.toLowerCase()],i=p(h);return r.createElement(t,{...i,key:v},...n)}return r.createElement(e,{...U(h),key:v},...n)}function Zt(e){var o,l,a,d,u,m,v,b;const{node:C,customId:N}=e,M=null!=(a=null!=(l=e.htmlPolicy)?l:null==(o=e.ctx)?void 0:o.htmlPolicy)?a:"safe",B=c(null),[S,T]=i(!1);s(()=>{T(!0)},[]);const E=r.useMemo(()=>{var t,n,r,o;return{...null!=(n=null==(t=e.ctx)?void 0:t.customComponents)?n:V(N),...null!=(o=null==(r=e.ctx)?void 0:r.htmlComponents)?o:{}}},[N,null==(d=e.ctx)?void 0:d.customComponents,null==(u=e.ctx)?void 0:u.htmlComponents]),L=r.useMemo(()=>{var t,n;return{...E,...null!=(n=null==(t=e.ctx)?void 0:t.streamingComponents)?n:{}}},[E,null==(m=e.ctx)?void 0:m.streamingComponents]),D=r.useMemo(()=>{var e;return w(null!=(e=C.content)?e:"",M)},[M,C.content]),P=r.useMemo(()=>{var e;return String(null!=(e=C.tag)?e:"").trim()},[C.tag]),A=r.useMemo(()=>f(P),[P]),R=r.useMemo(()=>Array.isArray(C.children)?C.children:[],[C.children]),F=r.useMemo(()=>{var e;return p(g(h(null!=(e=C.attrs)?e:void 0,M,A)))},[M,C.attrs,A]),I=A?null==(b=null==(v=e.ctx)?void 0:v.htmlComponents)?void 0:b[A]:void 0,_=R.length>0&&!!P&&"escape"!==M&&!y(P,M)&&!!e.ctx&&!!e.renderNode&&!!I,H=r.useMemo(()=>{var t;return _&&e.ctx&&e.renderNode?$(R,e.ctx,`${String(null!=(t=e.indexKey)?t:"html-inline")}-structured`,e.renderNode):null},[_,e.ctx,e.indexKey,e.renderNode,R]),W=r.useMemo(()=>{var t,n;const r=C.content;if(!r)return{mode:"html",content:""};if("escape"===M)return{mode:"html",content:r};if(!X(r,L))return{mode:"html",content:r};const o=function(e,t,n="safe",r={}){if(!e)return[];try{const o=function(e,t,n="safe",r={}){var o;let i=0;const l=null!=(o=r.keyPrefix)?o:"ms-html",a=[],c=[];for(const s of e)if("text"===s.type){if(a.length>0&&a[a.length-1].hardBlocked)continue;(a.length>0?a[a.length-1].children:c).push(s.content),a.length>0&&a[a.length-1].sourceParts.push(s.content)}else if("self_closing"===s.type){const e=s.attrs||{},o=Ot(s.tagName,e,!0),d=G(s.tagName,t),u=Boolean(Kt(s.tagName,r));if(x.has(s.tagName.toLowerCase())||!d&&!u&&k(s.tagName,n))continue;if(!d&&!u&&y(s.tagName,n)){(a.length>0?a[a.length-1].children:c).push(o),a.length>0&&a[a.length-1].sourceParts.push(o);continue}const m=Xt(s.tagName,e,[],t,`${l}-${i++}`,n,r,"",o,{loading:!1,autoClosed:!1});jt(a.length>0?a[a.length-1].children:c,m),a.length>0&&a[a.length-1].sourceParts.push(o)}else if("tag_open"===s.type){const e=a.length>0&&a[a.length-1].hardBlocked,o=G(s.tagName,t),i=Boolean(Kt(s.tagName,r));a.push({tagName:s.tagName,children:[],attrs:s.attrs,sourceParts:[],customComponent:o||i,hardBlocked:e||x.has(s.tagName.toLowerCase())||!o&&!i&&k(s.tagName,n),softBlocked:!e&&!o&&!i&&y(s.tagName,n)})}else if("tag_close"===s.type){const e=s.tagName.toLowerCase();let o=-1;for(let t=a.length-1;t>=0;t--)if(a[t].tagName.toLowerCase()===e){o=t;break}if(-1!==o)for(;a.length>o;){const s=a.pop(),d=s.sourceParts.join(""),u=`${Ot(s.tagName,s.attrs||{})}${d}</${s.tagName}>`;let m;if(s.hardBlocked)m=null;else if(s.softBlocked)m=[Ot(s.tagName,s.attrs||{}),...s.children,`</${s.tagName}>`];else{const o=s.tagName.toLowerCase()===e?{loading:!1,autoClosed:!1}:Ut(r);m=Xt(s.tagName,s.attrs||{},s.children,t,`${l}-${i++}`,n,r,d,u,o)}a.length>0?jt(a[a.length-1].children,m):jt(c,m),a.length>0&&!s.hardBlocked&&a[a.length-1].sourceParts.push(u),s.tagName.toLowerCase()!==e&&a.length>o&&Wt(`Auto-closing unclosed tag: <${s.tagName}>`)}else Wt(`Ignoring closing tag with no matching opening tag: </${s.tagName}>`)}for(;a.length>0;){const e=a.pop(),o=e.sourceParts.join(""),s=`${Ot(e.tagName,e.attrs||{})}${o}`;let d;d=e.hardBlocked?null:e.softBlocked?[Ot(e.tagName,e.attrs||{}),...e.children,`</${e.tagName}>`]:Xt(e.tagName,e.attrs||{},e.children,t,`${l}-${i++}`,n,r,o,s,Ut(r)),jt(c,d),a.length>0&&!e.hardBlocked&&a[a.length-1].sourceParts.push(s),Wt(`Auto-closing unclosed tag: <${e.tagName}>`)}return c}(Y(e),t,n,r);return o}catch(i){return o=i,Ht&&console.error("Failed to parse HTML to React nodes:",o),null}var o}(r,E,M,{ctx:e.ctx,keyPrefix:String(null!=(t=e.indexKey)?t:"html-inline"),nodeComponents:null==(n=e.ctx)?void 0:n.streamingComponents,renderNode:e.renderNode,sourceNode:C});return null===o?{mode:"html",content:r}:{mode:"dynamic",block:zt(r,L),nodes:o}},[E,L,M,C.autoClosed,C.content,C.loading,e.ctx,e.indexKey,e.renderNode]);return s(()=>{if(!S||!B.current||"html"!==W.mode)return;const e=B.current;e.innerHTML="";const t=document.createElement("template");t.innerHTML=D,e.appendChild(t.content.cloneNode(!0))},[W.mode,S,D]),!C.loading||C.autoClosed||_||"dynamic"===W.mode?_?r.createElement(I,F,H):"dynamic"===W.mode?W.block?/* @__PURE__ */t(n,{children:W.nodes}):/* @__PURE__ */t("span",{className:"html-inline-node",style:{display:"inline"},children:W.nodes}):/* @__PURE__ */t("span",{ref:B,className:"html-inline-node",style:{display:"inline"}}):/* @__PURE__ */t("span",{className:"html-inline-node html-inline-node--loading",children:C.content})}const Yt={fallbackSrc:"",lazy:!0,usePlaceholder:!0};function Gt(e,t,n){return n||e?{src:e,stage:"primary"}:t?{src:t,stage:"fallback"}:{src:"",stage:"failed"}}function Jt(r){var o,l,a,c,d,u;const m={...Yt,...r},h=b(m.node.src),f=b(m.fallbackSrc),p=Gt(h,f,m.node.loading),[g,v]=i(!1),[y,w]=i(!1),[x,k]=i(p.src),[C,N]=i(p.stage),M=x;s(()=>{const e=Gt(h,f,m.node.loading);k(e.src),N(e.stage),v(!1),w("failed"===e.stage)},[h,f,m.node.loading]);return!m.node.loading&&"failed"!==C&&M?/* @__PURE__ */t("img",{src:M,alt:String(null!=(l=null!=(o=m.node.alt)?o:m.node.title)?l:""),title:String(null!=(c=null!=(a=m.node.title)?a:m.node.alt)?c:""),className:"image-node__img"+(g?" is-loaded":""),loading:m.lazy?"lazy":"eager",decoding:"async",tabIndex:g?0:-1,"aria-label":null!=(d=m.node.alt)?d:"Preview image",onError:()=>{var e;if("primary"===C&&f&&f!==x)return k(f),N("fallback"),v(!1),void w(!1);N("failed"),w(!0),null==(e=m.onError)||e.call(m,x)},onLoad:()=>{var e;v(!0),w(!1),null==(e=m.onLoad)||e.call(m,M)},onClick:e=>{var t;e.preventDefault(),g&&!y&&(null==(t=m.onClick)||t.call(m,[e,M]))}},"image"):m.node.loading&&!y?/* @__PURE__ */t("span",{className:"image-node__placeholder",children:m.usePlaceholder?/* @__PURE__ */e(n,{children:[
57
+ /* @__PURE__ */t("span",{className:"html-block-node__placeholder-bar w-2/3"})]})});return te&&ae?r.createElement(ae,Q,le):te?r.createElement(Y,{...ne,ref:D},A?le:ce):/* @__PURE__ */t("div",{ref:D,className:"html-block-node",...j,children:A?re&&oe?/* @__PURE__ */t(n,{children:oe}):/* @__PURE__ */t("div",{dangerouslySetInnerHTML:{__html:ie}}):ce})}const Ot=(()=>{try{return Boolean(!1)}catch{}return!1})();function jt(e){Ot&&console.warn(e)}function zt(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 Kt(e,t){Array.isArray(t)?e.push(...t):null!=t&&e.push(t)}function Vt(e,t){var n;for(const r of Y(e)){if("tag_open"!==r.type&&"self_closing"!==r.type)continue;const e=null!=(n=r.tagName)?n:"";if(!G(e,t))continue;const o=t[e]||t[e.toLowerCase()];if("block"===J(o))return!0}return!1}function qt(e,t){var n,r;return(null==(n=t.nodeComponents)?void 0:n[e])||(null==(r=t.nodeComponents)?void 0:r[e.toLowerCase()])}function Ut(e){if(null==e||"boolean"==typeof e)return"";if("string"==typeof e||"number"==typeof e)return String(e);if(Array.isArray(e))return e.map(Ut).join("");if(!r.isValidElement(e))return"";const t=e;if("string"!=typeof t.type)return Ut(t.props.children);const n=Object.entries(t.props).filter(([e,t])=>"children"!==e&&"key"!==e&&"ref"!==e&&null!=t&&"boolean"!=typeof t).map(([e,t])=>` ${"className"===e?"class":e}="${String(t)}"`).join("");return`<${t.type}${n}>${Ut(t.props.children)}</${t.type}>`}function Xt(e){return Object.entries(e).map(([e,t])=>[e,""===t?null:t])}function Zt(e){var t,n;const r=e.sourceNode,o=!0!==(null==(t=e.ctx)?void 0:t.final)&&(!1===(null==(n=e.ctx)?void 0:n.final)||Boolean(null==r?void 0:r.loading));return{loading:o,autoClosed:o||Boolean(null==r?void 0:r.autoClosed)}}function Yt(e,t,n,o,i,l,a,c,s,d){const u=G(e,o),m=Boolean(qt(e,a));if(x.has(e.toLowerCase())||!u&&!m&&k(e,l))return null;if(!u&&!m&&y(e,l))return[zt(e,t),...n,`</${e}>`];const h=Q(t,l,e),g=h.key,v=null!=g&&""!==g?g:i;if(m)return function(e,t,n,o,i,l,a,c=Zt(i)){const s=f(e),d=null!=l?l:function(e){return e.map(Ut).join("")}(n),u={type:s,tag:s,attrs:Xt(t),content:d,raw:null!=a?a:`${zt(e,t)}${d}</${e}>`,loading:c.loading,autoClosed:c.autoClosed};if(i.ctx&&i.renderNode)return i.renderNode(u,o,i.ctx);const m=qt(e,i);return m?r.createElement(m,{key:o,node:u}):null}(e,t,n,String(v),a,c,s,d);if(u){const t=o[e]||o[e.toLowerCase()],i=p(h);return r.createElement(t,{...i,key:v},...n)}return r.createElement(e,{...U(h),key:v},...n)}function Gt(e){var o,l,a,d,u,m,v,b;const{node:C,customId:N}=e,M=null!=(a=null!=(l=e.htmlPolicy)?l:null==(o=e.ctx)?void 0:o.htmlPolicy)?a:"safe",B=c(null),[S,T]=i(!1);s(()=>{T(!0)},[]);const E=r.useMemo(()=>{var t,n,r,o;return{...null!=(n=null==(t=e.ctx)?void 0:t.customComponents)?n:V(N),...null!=(o=null==(r=e.ctx)?void 0:r.htmlComponents)?o:{}}},[N,null==(d=e.ctx)?void 0:d.customComponents,null==(u=e.ctx)?void 0:u.htmlComponents]),L=r.useMemo(()=>{var t,n;return{...E,...null!=(n=null==(t=e.ctx)?void 0:t.streamingComponents)?n:{}}},[E,null==(m=e.ctx)?void 0:m.streamingComponents]),D=r.useMemo(()=>{var e;return w(null!=(e=C.content)?e:"",M)},[M,C.content]),P=r.useMemo(()=>{var e;return String(null!=(e=C.tag)?e:"").trim()},[C.tag]),A=r.useMemo(()=>f(P),[P]),R=r.useMemo(()=>Array.isArray(C.children)?C.children:[],[C.children]),F=r.useMemo(()=>{var e;return p(g(h(null!=(e=C.attrs)?e:void 0,M,A)))},[M,C.attrs,A]),I=A?null==(b=null==(v=e.ctx)?void 0:v.htmlComponents)?void 0:b[A]:void 0,_=R.length>0&&!!P&&"escape"!==M&&!y(P,M)&&!!e.ctx&&!!e.renderNode&&!!I,H=r.useMemo(()=>{var t;return _&&e.ctx&&e.renderNode?$(R,e.ctx,`${String(null!=(t=e.indexKey)?t:"html-inline")}-structured`,e.renderNode):null},[_,e.ctx,e.indexKey,e.renderNode,R]),W=r.useMemo(()=>{var t,n;const r=C.content;if(!r)return{mode:"html",content:""};if("escape"===M)return{mode:"html",content:r};if(!X(r,L))return{mode:"html",content:r};const o=function(e,t,n="safe",r={}){if(!e)return[];try{const o=function(e,t,n="safe",r={}){var o;let i=0;const l=null!=(o=r.keyPrefix)?o:"ms-html",a=[],c=[];for(const s of e)if("text"===s.type){if(a.length>0&&a[a.length-1].hardBlocked)continue;(a.length>0?a[a.length-1].children:c).push(s.content),a.length>0&&a[a.length-1].sourceParts.push(s.content)}else if("self_closing"===s.type){const e=s.attrs||{},o=zt(s.tagName,e,!0),d=G(s.tagName,t),u=Boolean(qt(s.tagName,r));if(x.has(s.tagName.toLowerCase())||!d&&!u&&k(s.tagName,n))continue;if(!d&&!u&&y(s.tagName,n)){(a.length>0?a[a.length-1].children:c).push(o),a.length>0&&a[a.length-1].sourceParts.push(o);continue}const m=Yt(s.tagName,e,[],t,`${l}-${i++}`,n,r,"",o,{loading:!1,autoClosed:!1});Kt(a.length>0?a[a.length-1].children:c,m),a.length>0&&a[a.length-1].sourceParts.push(o)}else if("tag_open"===s.type){const e=a.length>0&&a[a.length-1].hardBlocked,o=G(s.tagName,t),i=Boolean(qt(s.tagName,r));a.push({tagName:s.tagName,children:[],attrs:s.attrs,sourceParts:[],customComponent:o||i,hardBlocked:e||x.has(s.tagName.toLowerCase())||!o&&!i&&k(s.tagName,n),softBlocked:!e&&!o&&!i&&y(s.tagName,n)})}else if("tag_close"===s.type){const e=s.tagName.toLowerCase();let o=-1;for(let t=a.length-1;t>=0;t--)if(a[t].tagName.toLowerCase()===e){o=t;break}if(-1!==o)for(;a.length>o;){const s=a.pop(),d=s.sourceParts.join(""),u=`${zt(s.tagName,s.attrs||{})}${d}</${s.tagName}>`;let m;if(s.hardBlocked)m=null;else if(s.softBlocked)m=[zt(s.tagName,s.attrs||{}),...s.children,`</${s.tagName}>`];else{const o=s.tagName.toLowerCase()===e?{loading:!1,autoClosed:!1}:Zt(r);m=Yt(s.tagName,s.attrs||{},s.children,t,`${l}-${i++}`,n,r,d,u,o)}a.length>0?Kt(a[a.length-1].children,m):Kt(c,m),a.length>0&&!s.hardBlocked&&a[a.length-1].sourceParts.push(u),s.tagName.toLowerCase()!==e&&a.length>o&&jt(`Auto-closing unclosed tag: <${s.tagName}>`)}else jt(`Ignoring closing tag with no matching opening tag: </${s.tagName}>`)}for(;a.length>0;){const e=a.pop(),o=e.sourceParts.join(""),s=`${zt(e.tagName,e.attrs||{})}${o}`;let d;d=e.hardBlocked?null:e.softBlocked?[zt(e.tagName,e.attrs||{}),...e.children,`</${e.tagName}>`]:Yt(e.tagName,e.attrs||{},e.children,t,`${l}-${i++}`,n,r,o,s,Zt(r)),Kt(c,d),a.length>0&&!e.hardBlocked&&a[a.length-1].sourceParts.push(s),jt(`Auto-closing unclosed tag: <${e.tagName}>`)}return c}(Y(e),t,n,r);return o}catch(i){return o=i,Ot&&console.error("Failed to parse HTML to React nodes:",o),null}var o}(r,E,M,{ctx:e.ctx,keyPrefix:String(null!=(t=e.indexKey)?t:"html-inline"),nodeComponents:null==(n=e.ctx)?void 0:n.streamingComponents,renderNode:e.renderNode,sourceNode:C});return null===o?{mode:"html",content:r}:{mode:"dynamic",block:Vt(r,L),nodes:o}},[E,L,M,C.autoClosed,C.content,C.loading,e.ctx,e.indexKey,e.renderNode]);return s(()=>{if(!S||!B.current||"html"!==W.mode)return;const e=B.current;e.innerHTML="";const t=document.createElement("template");t.innerHTML=D,e.appendChild(t.content.cloneNode(!0))},[W.mode,S,D]),!C.loading||C.autoClosed||_||"dynamic"===W.mode?_?r.createElement(I,F,H):"dynamic"===W.mode?W.block?/* @__PURE__ */t(n,{children:W.nodes}):/* @__PURE__ */t("span",{className:"html-inline-node",style:{display:"inline"},children:W.nodes}):/* @__PURE__ */t("span",{ref:B,className:"html-inline-node",style:{display:"inline"}}):/* @__PURE__ */t("span",{className:"html-inline-node html-inline-node--loading",children:C.content})}const Jt={fallbackSrc:"",lazy:!0,usePlaceholder:!0};function Qt(e,t,n){return n||e?{src:e,stage:"primary"}:t?{src:t,stage:"fallback"}:{src:"",stage:"failed"}}function en(r){var o,l,a,c,d,u;const m={...Jt,...r},h=b(m.node.src),f=b(m.fallbackSrc),p=Qt(h,f,m.node.loading),[g,v]=i(!1),[y,w]=i(!1),[x,k]=i(p.src),[C,N]=i(p.stage),M=x;s(()=>{const e=Qt(h,f,m.node.loading);k(e.src),N(e.stage),v(!1),w("failed"===e.stage)},[h,f,m.node.loading]);return!m.node.loading&&"failed"!==C&&M?/* @__PURE__ */t("img",{src:M,alt:String(null!=(l=null!=(o=m.node.alt)?o:m.node.title)?l:""),title:String(null!=(c=null!=(a=m.node.title)?a:m.node.alt)?c:""),className:"image-node__img"+(g?" is-loaded":""),loading:m.lazy?"lazy":"eager",decoding:"async",tabIndex:g?0:-1,"aria-label":null!=(d=m.node.alt)?d:"Preview image",onError:()=>{var e;if("primary"===C&&f&&f!==x)return k(f),N("fallback"),v(!1),void w(!1);N("failed"),w(!0),null==(e=m.onError)||e.call(m,x)},onLoad:()=>{var e;v(!0),w(!1),null==(e=m.onLoad)||e.call(m,M)},onClick:e=>{var t;e.preventDefault(),g&&!y&&(null==(t=m.onClick)||t.call(m,[e,M]))}},"image"):m.node.loading&&!y?/* @__PURE__ */t("span",{className:"image-node__placeholder",children:m.usePlaceholder?/* @__PURE__ */e(n,{children:[
58
58
  /* @__PURE__ */t("span",{className:"image-node__spinner","aria-hidden":"true"}),
59
59
  /* @__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"):m.node.loading||"failed"!==C?null:/* @__PURE__ */e("span",{className:"image-node__error",children:[
60
60
  /* @__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"})}),
61
- /* @__PURE__ */t("span",{className:"image-node__placeholder-text",children:"Image failed to load"})]})}let Qt=null,en=null;const tn=/* @__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
+ /* @__PURE__ */t("span",{className:"image-node__placeholder-text",children:"Image failed to load"})]})}let tn=null,nn=null;const rn=/* @__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:[
62
62
  /* @__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"}),
63
63
  /* @__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"}),
64
64
  /* @__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"}),
65
65
  /* @__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"}),
66
- /* @__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"})]})}),nn={maxHeight:"500px",loading:!0,showHeader:!0,showCopyButton:!0,showCollapseButton:!0,showModeToggle:!0,showExportButton:!0,showFullscreenButton:!0,showZoomControls:!0};function rn(r){var l;const a={...nn,...r},{t:u}=_e(),[m,h]=i(!1),[f,p]=i(!1),[g,v]=i(!1),[y,w]=i(!1),[x,k]=i(()=>"undefined"==typeof window),b=a.node.code,C=o(()=>a.maxHeight&&"none"!==a.maxHeight?ee(a.maxHeight):null,[a.maxHeight]),N=o(()=>{var e;return null!=(e=ee(a.estimatedPreviewHeightPx))?e:te(b)},[b,a.estimatedPreviewHeightPx]),[M,B]=i(()=>`${ne(N,re,C)}px`),[S,T]=i(!1),[E,L]=i(!1),[D,$]=i(1),[P,A]=i({x:0,y:0}),[R,F]=i(!1),I=c(null),_=c(null),H=c(null),W=c(null),O=c(null),j=c(null),z=c(null),K=c(0),V=c(P);V.current=P;const q=c(D);q.current=D;const U=c(y);U.current=y;const X=c(S);X.current=S;const Z=Pe(),Y=d(()=>{var e;const t=I.current,n=t?getComputedStyle(t).getPropertyValue("--ms-size-diagram-min-height").trim():"";return null!=(e=ee(n))?e:re},[]),G=d(()=>ne(N,Y(),C),[N,C,Y]),J=d(e=>{const t=G();if(!a.maxHeight||"none"===a.maxHeight)return`${Math.max(e,t)}px`;const n=Number.parseFloat(String(a.maxHeight));return Number.isFinite(n)?`${Math.max(Math.min(e,n),t)}px`:`${Math.max(e,t)}px`},[a.maxHeight,G]),Q=d(()=>{const e=I.current;if(!e)return;const t=e.scrollHeight;t>0&&B(J(t))},[J]);s(()=>{g||f||B(e=>{const t=ee(e),n=G();return null!=t&&t>=n?e:`${n}px`})},[f,G,g]);const oe=d(async()=>{var e,t;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(b)),h(!0),null==(t=a.onCopy)||t.call(a,b),setTimeout(()=>h(!1),1e3)}catch{}},[b,a]),ie=d(async()=>{var e,t,n,r,o,i,l,c;if(!x)return;if(!I.current)return;const s=I.current,d=b,u=!1===a.loading,m=++K.current;let h=null,f=null;try{const o=await async function(){return en||Qt||(Qt=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),en=n,n}).catch(e=>(console.warn("Failed to load @antv/infographic",e),null)),Qt)}();if(m!==K.current||s!==I.current)return;if(!o)throw new Error("Infographic library failed to load.");f=Array.from(s.childNodes),h=new o({container:s,width:"100%",height:"100%"});let i="",l=!1;if(null==(e=h.on)||e.call(h,"error",e=>{const t=Array.isArray(e)?e:[e];i=t.map(e=>{var t;return e instanceof Error?e.message:"string"==typeof e?e:String(e&&"object"==typeof e&&"message"in e?null!=(t=e.message)?t:"":null!=e?e:"")}).filter(Boolean).join("; ")}),null==(t=h.on)||t.call(h,"rendered",()=>{l=!0}),h.render(d),i)throw new Error(i);const a=Array.from(s.childNodes),c=a.length>0&&(a.length!==f.length||a.some((e,t)=>e!==(null==f?void 0:f[t])));if(!l&&!c)throw new Error("Infographic render returned empty output.");null==(r=null==(n=z.current)?void 0:n.destroy)||r.call(n),z.current=h,h=null,T(!0),L(!1),setTimeout(()=>{Q()},0)}catch(p){if(m!==K.current||s!==I.current)return;null==(o=null==h?void 0:h.destroy)||o.call(h),h=null,u&&!1===a.loading&&d===b?(console.error("Failed to render infographic:",p),null==(l=null==(i=z.current)?void 0:i.destroy)||l.call(i),z.current=null,T(!1),L(!0),s.innerHTML=`<div class="text-red-500 p-4">Failed to render infographic: ${p instanceof Error?p.message:"Unknown error"}</div>`):f&&s.replaceChildren(...f)}finally{null==(c=null==h?void 0:h.destroy)||c.call(h)}},[b,a.loading,Q,x]);s(()=>{const e=_.current;if(!e)return;const t=Z(e,{rootMargin:"160px"});return H.current=t,t.isVisible()&&k(!0),t.whenVisible.then(()=>k(!0)),()=>{t.destroy(),H.current=null}},[Z]),s(()=>{!x||g||f||ie()},[b,f,ie,g,x]),s(()=>()=>{var e,t;K.current+=1,z.current&&(null==(t=(e=z.current).destroy)||t.call(e),z.current=null)},[]);const le=d(()=>{w(!1),W.current&&(W.current.innerHTML=""),O.current=null,document.body.style.overflow=""},[]),ae=d(()=>{w(!0),document.body.style.overflow="hidden"},[]);s(()=>{if(!y)return;const e=e=>{"Escape"===e.key&&le()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[y,le]),s(()=>{y&&setTimeout(()=>{if(I.current&&W.current){W.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=I.current.cloneNode(!0);t.classList.add("fullscreen"),t.style.height="auto",e.appendChild(t),W.current.appendChild(e),O.current=e,e.style.transform=`translate(${P.x}px, ${P.y}px) scale(${D})`}},0)},[y]),s(()=>{y&&O.current&&(O.current.style.transform=`translate(${P.x}px, ${P.y}px) scale(${D})`)},[y,P,D]);const ce=d(()=>{var e;const t=null==(e=I.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)},[]);j.current||(j.current=ge({getTranslate:()=>V.current,setTranslate:e=>A(e),canStart:e=>!!X.current&&("touch"!==e.pointerType||U.current||q.current>1),onActiveChange:e=>F(e)}));const se=j.current;s(()=>()=>se.stop(),[se]);const de=a.isDark?"p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200":"p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700",ue=g||f,me=y||D>1;/* @__PURE__ */
66
+ /* @__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"})]})}),on={maxHeight:"500px",loading:!0,showHeader:!0,showCopyButton:!0,showCollapseButton:!0,showModeToggle:!0,showExportButton:!0,showFullscreenButton:!0,showZoomControls:!0};function ln(r){var l;const a={...on,...r},{t:u}=He(),[m,h]=i(!1),[f,p]=i(!1),[g,v]=i(!1),[y,w]=i(!1),[x,k]=i(()=>"undefined"==typeof window),b=a.node.code,C=o(()=>a.maxHeight&&"none"!==a.maxHeight?ee(a.maxHeight):null,[a.maxHeight]),N=o(()=>{var e;return null!=(e=ee(a.estimatedPreviewHeightPx))?e:te(b)},[b,a.estimatedPreviewHeightPx]),[M,B]=i(()=>`${ne(N,re,C)}px`),[S,T]=i(!1),[E,L]=i(!1),[D,$]=i(1),[P,A]=i({x:0,y:0}),[R,F]=i(!1),I=c(null),_=c(null),H=c(null),W=c(null),O=c(null),j=c(null),z=c(null),K=c(0),V=c(P);V.current=P;const q=c(D);q.current=D;const U=c(y);U.current=y;const X=c(S);X.current=S;const Z=Ae(),Y=d(()=>{var e;const t=I.current,n=t?getComputedStyle(t).getPropertyValue("--ms-size-diagram-min-height").trim():"";return null!=(e=ee(n))?e:re},[]),G=d(()=>ne(N,Y(),C),[N,C,Y]),J=d(e=>{const t=G();if(!a.maxHeight||"none"===a.maxHeight)return`${Math.max(e,t)}px`;const n=Number.parseFloat(String(a.maxHeight));return Number.isFinite(n)?`${Math.max(Math.min(e,n),t)}px`:`${Math.max(e,t)}px`},[a.maxHeight,G]),Q=d(()=>{const e=I.current;if(!e)return;const t=e.scrollHeight;t>0&&B(J(t))},[J]);s(()=>{g||f||B(e=>{const t=ee(e),n=G();return null!=t&&t>=n?e:`${n}px`})},[f,G,g]);const oe=d(async()=>{var e,t;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(b)),h(!0),null==(t=a.onCopy)||t.call(a,b),setTimeout(()=>h(!1),1e3)}catch{}},[b,a]),ie=d(async()=>{var e,t,n,r,o,i,l,c;if(!x)return;if(!I.current)return;const s=I.current,d=b,u=!1===a.loading,m=++K.current;let h=null,f=null;try{const o=await async function(){return nn||tn||(tn=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),nn=n,n}).catch(e=>(console.warn("Failed to load @antv/infographic",e),null)),tn)}();if(m!==K.current||s!==I.current)return;if(!o)throw new Error("Infographic library failed to load.");f=Array.from(s.childNodes),h=new o({container:s,width:"100%",height:"100%"});let i="",l=!1;if(null==(e=h.on)||e.call(h,"error",e=>{const t=Array.isArray(e)?e:[e];i=t.map(e=>{var t;return e instanceof Error?e.message:"string"==typeof e?e:String(e&&"object"==typeof e&&"message"in e?null!=(t=e.message)?t:"":null!=e?e:"")}).filter(Boolean).join("; ")}),null==(t=h.on)||t.call(h,"rendered",()=>{l=!0}),h.render(d),i)throw new Error(i);const a=Array.from(s.childNodes),c=a.length>0&&(a.length!==f.length||a.some((e,t)=>e!==(null==f?void 0:f[t])));if(!l&&!c)throw new Error("Infographic render returned empty output.");null==(r=null==(n=z.current)?void 0:n.destroy)||r.call(n),z.current=h,h=null,T(!0),L(!1),setTimeout(()=>{Q()},0)}catch(p){if(m!==K.current||s!==I.current)return;null==(o=null==h?void 0:h.destroy)||o.call(h),h=null,u&&!1===a.loading&&d===b?(console.error("Failed to render infographic:",p),null==(l=null==(i=z.current)?void 0:i.destroy)||l.call(i),z.current=null,T(!1),L(!0),s.innerHTML=`<div class="text-red-500 p-4">Failed to render infographic: ${p instanceof Error?p.message:"Unknown error"}</div>`):f&&s.replaceChildren(...f)}finally{null==(c=null==h?void 0:h.destroy)||c.call(h)}},[b,a.loading,Q,x]);s(()=>{const e=_.current;if(!e)return;const t=Z(e,{rootMargin:"160px"});return H.current=t,t.isVisible()&&k(!0),t.whenVisible.then(()=>k(!0)),()=>{t.destroy(),H.current=null}},[Z]),s(()=>{!x||g||f||ie()},[b,f,ie,g,x]),s(()=>()=>{var e,t;K.current+=1,z.current&&(null==(t=(e=z.current).destroy)||t.call(e),z.current=null)},[]);const le=d(()=>{w(!1),W.current&&(W.current.innerHTML=""),O.current=null,document.body.style.overflow=""},[]),ae=d(()=>{w(!0),document.body.style.overflow="hidden"},[]);s(()=>{if(!y)return;const e=e=>{"Escape"===e.key&&le()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[y,le]),s(()=>{y&&setTimeout(()=>{if(I.current&&W.current){W.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=I.current.cloneNode(!0);t.classList.add("fullscreen"),t.style.height="auto",e.appendChild(t),W.current.appendChild(e),O.current=e,e.style.transform=`translate(${P.x}px, ${P.y}px) scale(${D})`}},0)},[y]),s(()=>{y&&O.current&&(O.current.style.transform=`translate(${P.x}px, ${P.y}px) scale(${D})`)},[y,P,D]);const ce=d(()=>{var e;const t=null==(e=I.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)},[]);j.current||(j.current=ge({getTranslate:()=>V.current,setTranslate:e=>A(e),canStart:e=>!!X.current&&("touch"!==e.pointerType||U.current||q.current>1),onActiveChange:e=>F(e)}));const se=j.current;s(()=>()=>se.stop(),[se]);const de=a.isDark?"p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200":"p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700",ue=g||f,me=y||D>1;/* @__PURE__ */
67
67
  return e(n,{children:[
68
- /* @__PURE__ */e("div",{ref:_,"data-markstream-infographic":"1","data-markstream-mode":g?"source":E?"error":S?"preview":"pending",className:ut("my-4 rounded-lg border overflow-hidden shadow-sm",a.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":a.loading}),children:[a.showHeader&&/* @__PURE__ */e("div",{className:ut("flex justify-between items-center px-4 py-2.5 border-b",a.isDark?"bg-gray-800 border-gray-700/30":"bg-gray-50 border-gray-200"),children:[
69
- /* @__PURE__ */e("div",{className:"flex items-center gap-x-2 overflow-hidden",children:[tn,
70
- /* @__PURE__ */t("span",{className:ut("text-sm font-medium font-mono truncate",a.isDark?"text-gray-400":"text-gray-600"),children:"Infographic"})]}),a.showModeToggle&&/* @__PURE__ */e("div",{className:ut("flex items-center gap-x-1 rounded-md p-0.5",a.isDark?"bg-gray-700":"bg-gray-100"),children:[
71
- /* @__PURE__ */t("button",{className:ut("px-2.5 py-1 text-xs rounded transition-colors",g?a.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700":a.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm"),onClick:()=>v(!1),onMouseEnter:e=>Ue(e.currentTarget,u("common.preview")||"Preview","top",!1,0,a.isDark),onMouseLeave:()=>Xe(),children:/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
68
+ /* @__PURE__ */e("div",{ref:_,"data-markstream-infographic":"1","data-markstream-mode":g?"source":E?"error":S?"preview":"pending",className:ht("my-4 rounded-lg border overflow-hidden shadow-sm",a.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":a.loading}),children:[a.showHeader&&/* @__PURE__ */e("div",{className:ht("flex justify-between items-center px-4 py-2.5 border-b",a.isDark?"bg-gray-800 border-gray-700/30":"bg-gray-50 border-gray-200"),children:[
69
+ /* @__PURE__ */e("div",{className:"flex items-center gap-x-2 overflow-hidden",children:[rn,
70
+ /* @__PURE__ */t("span",{className:ht("text-sm font-medium font-mono truncate",a.isDark?"text-gray-400":"text-gray-600"),children:"Infographic"})]}),a.showModeToggle&&/* @__PURE__ */e("div",{className:ht("flex items-center gap-x-1 rounded-md p-0.5",a.isDark?"bg-gray-700":"bg-gray-100"),children:[
71
+ /* @__PURE__ */t("button",{className:ht("px-2.5 py-1 text-xs rounded transition-colors",g?a.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700":a.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm"),onClick:()=>v(!1),onMouseEnter:e=>Ze(e.currentTarget,u("common.preview")||"Preview","top",!1,0,a.isDark),onMouseLeave:()=>Ye(),children:/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
72
72
  /* @__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:[
73
73
  /* @__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"}),
74
74
  /* @__PURE__ */t("circle",{cx:"12",cy:"12",r:"3"})]})}),
75
75
  /* @__PURE__ */t("span",{children:u("common.preview")||"Preview"})]})}),
76
- /* @__PURE__ */t("button",{className:ut("px-2.5 py-1 text-xs rounded transition-colors",g?a.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm":a.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),onClick:()=>v(!0),onMouseEnter:e=>Ue(e.currentTarget,u("common.source")||"Source","top",!1,0,a.isDark),onMouseLeave:()=>Xe(),children:/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
76
+ /* @__PURE__ */t("button",{className:ht("px-2.5 py-1 text-xs rounded transition-colors",g?a.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm":a.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),onClick:()=>v(!0),onMouseEnter:e=>Ze(e.currentTarget,u("common.source")||"Source","top",!1,0,a.isDark),onMouseLeave:()=>Ye(),children:/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
77
77
  /* @__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"})}),
78
78
  /* @__PURE__ */t("span",{children:u("common.source")||"Source"})]})})]}),
79
- /* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[a.showCollapseButton&&/* @__PURE__ */t("button",{className:de,onClick:()=>p(!f),onMouseEnter:e=>Ue(e.currentTarget,f?u("common.expand")||"Expand":u("common.collapse")||"Collapse","top",!1,0,a.isDark),onMouseLeave:()=>Xe(),children:/* @__PURE__ */t("svg",{style:{rotate:f?"0deg":"90deg"},xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),a.showCopyButton&&/* @__PURE__ */t("button",{className:de,onClick:oe,onMouseEnter:e=>Ue(e.currentTarget,m?u("common.copied")||"Copied":u("common.copy")||"Copy","top",!1,0,a.isDark),onMouseLeave:()=>Xe(),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
+ /* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[a.showCollapseButton&&/* @__PURE__ */t("button",{className:de,onClick:()=>p(!f),onMouseEnter:e=>Ze(e.currentTarget,f?u("common.expand")||"Expand":u("common.collapse")||"Collapse","top",!1,0,a.isDark),onMouseLeave:()=>Ye(),children:/* @__PURE__ */t("svg",{style:{rotate:f?"0deg":"90deg"},xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */t("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),a.showCopyButton&&/* @__PURE__ */t("button",{className:de,onClick:oe,onMouseEnter:e=>Ze(e.currentTarget,m?u("common.copied")||"Copied":u("common.copy")||"Copy","top",!1,0,a.isDark),onMouseLeave:()=>Ye(),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:[
80
80
  /* @__PURE__ */t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
81
- /* @__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"})]})})}),a.showExportButton&&/* @__PURE__ */t("button",{className:ut(de,ue&&"opacity-50 cursor-not-allowed"),disabled:ue,onClick:ce,onMouseEnter:e=>Ue(e.currentTarget,u("common.export")||"Export","top",!1,0,a.isDark),onMouseLeave:()=>Xe(),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
+ /* @__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"})]})})}),a.showExportButton&&/* @__PURE__ */t("button",{className:ht(de,ue&&"opacity-50 cursor-not-allowed"),disabled:ue,onClick:ce,onMouseEnter:e=>Ze(e.currentTarget,u("common.export")||"Export","top",!1,0,a.isDark),onMouseLeave:()=>Ye(),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:[
82
82
  /* @__PURE__ */t("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),
83
- /* @__PURE__ */t("path",{d:"m7 10l5 5l5-5"})]})})}),a.showFullscreenButton&&/* @__PURE__ */t("button",{className:ut(de,ue&&"opacity-50 cursor-not-allowed"),disabled:ue,onClick:ae,onMouseEnter:e=>Ue(e.currentTarget,y?u("common.minimize")||"Minimize":u("common.open")||"Open","top",!1,0,a.isDark),onMouseLeave:()=>Xe(),children:/* @__PURE__ */t("svg",y?{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"})})})]})]}),!f&&/* @__PURE__ */t("div",{children:g?/* @__PURE__ */t("div",{className:ut("p-4",a.isDark?"bg-gray-900":"bg-gray-50"),children:/* @__PURE__ */t("pre",{className:ut("text-sm font-mono whitespace-pre-wrap",a.isDark?"text-gray-300":"text-gray-700"),children:b})}):/* @__PURE__ */e("div",{className:"relative",children:[a.showZoomControls&&/* @__PURE__ */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:[
84
- /* @__PURE__ */t("button",{className:ut("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>$(Math.min(D+.1,3)),children:"+"}),
85
- /* @__PURE__ */t("button",{className:ut("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>$(Math.max(D-.1,.5)),children:"-"}),
86
- /* @__PURE__ */e("button",{className:ut("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{$(1),A({x:0,y:0})},children:[Math.round(100*D),"%"]})]})}),
87
- /* @__PURE__ */e("div",{className:ut("infographic-preview relative transition-all duration-100 overflow-hidden block",a.isDark?"bg-gray-900":"bg-gray-50"),style:{height:M,maxHeight:null!=(l=a.maxHeight)?l:void 0,minHeight:"var(--ms-size-diagram-min-height, 360px)",touchAction:me?"none":void 0},onPointerDown:e=>se.start(e.nativeEvent),children:[!S&&!E&&/* @__PURE__ */t("pre",{className:ut("absolute inset-0 overflow-auto p-4 text-left text-sm font-mono whitespace-pre-wrap",a.isDark?"text-gray-300":"text-gray-700"),children:b}),
88
- /* @__PURE__ */t("div",{className:ut("absolute inset-0 cursor-grab",R&&"cursor-grabbing"),style:{transform:`translate(${P.x}px, ${P.y}px) scale(${D})`},children:/* @__PURE__ */t("div",{ref:I,className:"w-full text-center flex items-center justify-center min-h-full"})})]})]})})]}),y&&"undefined"!=typeof document&&Ce(
89
- /* @__PURE__ */t("div",{className:"markstream-react fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:le,role:"dialog","aria-modal":"true",children:/* @__PURE__ */e("div",{className:ut("dialog-panel relative w-full h-full max-w-full max-h-full rounded shadow-lg overflow-hidden",a.isDark?"bg-gray-900":"bg-white"),onClick:e=>e.stopPropagation(),children:[
83
+ /* @__PURE__ */t("path",{d:"m7 10l5 5l5-5"})]})})}),a.showFullscreenButton&&/* @__PURE__ */t("button",{className:ht(de,ue&&"opacity-50 cursor-not-allowed"),disabled:ue,onClick:ae,onMouseEnter:e=>Ze(e.currentTarget,y?u("common.minimize")||"Minimize":u("common.open")||"Open","top",!1,0,a.isDark),onMouseLeave:()=>Ye(),children:/* @__PURE__ */t("svg",y?{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"})})})]})]}),!f&&/* @__PURE__ */t("div",{children:g?/* @__PURE__ */t("div",{className:ht("p-4",a.isDark?"bg-gray-900":"bg-gray-50"),children:/* @__PURE__ */t("pre",{className:ht("text-sm font-mono whitespace-pre-wrap",a.isDark?"text-gray-300":"text-gray-700"),children:b})}):/* @__PURE__ */e("div",{className:"relative",children:[a.showZoomControls&&/* @__PURE__ */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:[
84
+ /* @__PURE__ */t("button",{className:ht("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>$(Math.min(D+.1,3)),children:"+"}),
85
+ /* @__PURE__ */t("button",{className:ht("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>$(Math.max(D-.1,.5)),children:"-"}),
86
+ /* @__PURE__ */e("button",{className:ht("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{$(1),A({x:0,y:0})},children:[Math.round(100*D),"%"]})]})}),
87
+ /* @__PURE__ */e("div",{className:ht("infographic-preview relative transition-all duration-100 overflow-hidden block",a.isDark?"bg-gray-900":"bg-gray-50"),style:{height:M,maxHeight:null!=(l=a.maxHeight)?l:void 0,minHeight:"var(--ms-size-diagram-min-height, 360px)",touchAction:me?"none":void 0},onPointerDown:e=>se.start(e.nativeEvent),children:[!S&&!E&&/* @__PURE__ */t("pre",{className:ht("absolute inset-0 overflow-auto p-4 text-left text-sm font-mono whitespace-pre-wrap",a.isDark?"text-gray-300":"text-gray-700"),children:b}),
88
+ /* @__PURE__ */t("div",{className:ht("absolute inset-0 cursor-grab",R&&"cursor-grabbing"),style:{transform:`translate(${P.x}px, ${P.y}px) scale(${D})`},children:/* @__PURE__ */t("div",{ref:I,className:"w-full text-center flex items-center justify-center min-h-full"})})]})]})})]}),y&&"undefined"!=typeof document&&Ne(
89
+ /* @__PURE__ */t("div",{className:"markstream-react fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:le,role:"dialog","aria-modal":"true",children:/* @__PURE__ */e("div",{className:ht("dialog-panel relative w-full h-full max-w-full max-h-full rounded shadow-lg overflow-hidden",a.isDark?"bg-gray-900":"bg-white"),onClick:e=>e.stopPropagation(),children:[
90
90
  /* @__PURE__ */e("div",{className:"absolute top-6 right-6 z-50 flex items-center gap-2",children:[
91
- /* @__PURE__ */t("button",{className:ut("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>$(Math.min(D+.1,3)),children:"+"}),
92
- /* @__PURE__ */t("button",{className:ut("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>$(Math.max(D-.1,.5)),children:"-"}),
93
- /* @__PURE__ */e("button",{className:ut("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{$(1),A({x:0,y:0})},children:[Math.round(100*D),"%"]}),
94
- /* @__PURE__ */t("button",{className:ut("inline-flex items-center justify-center p-2 rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:le,children:"X"})]}),
95
- /* @__PURE__ */t("div",{ref:W,className:ut("w-full h-full flex items-center justify-center p-4 overflow-hidden",!R&&"cursor-grab",R&&"cursor-grabbing"),style:{touchAction:me?"none":void 0},onPointerDown:e=>se.start(e.nativeEvent)})]})}),document.body)]})}function on(e,t){return e.reduce((e,n)=>{const r=null==t||n.id===t?{...n,fading:!1}:n,o=e[e.length-1];return!o||o.fading||r.fading?e.push(r):e[e.length-1]={...o,content:o.content+r.content},e},[])}function ln(e){var n,r;const{node:o,children:l,ctx:a,indexKey:d,fade:u}=e,m=String(null!=(n=o.code)?n:""),h=null==(r=null!=u?u:null==a?void 0:a.fade)||r,f=null==d||""===d?"":String(d),[p,g]=i(m?[{id:0,content:m,fading:!1}]:[]),v=Te(),y=c(m),w=c(1),x=c(void 0);return s(()=>{var e,t;const n=null!=(e=null==v?void 0:v.getStreamRenderVersion())?e:null==a?void 0:a.streamRenderVersion,r=n!==x.current;if(null!=l)return y.current="",g([]),void(x.current=n);const o=null!=(t=null==v?void 0:v.textStreamState)?t:null==a?void 0:a.textStreamState,i=f?null==o?void 0:o.get(f):void 0;let c=y.current;const s=Boolean(c===m&&i&&m.startsWith(i)&&m.length>i.length);if(s&&(c=i),h)if(m!==c)if(c&&m.startsWith(c)){const e=m.slice(c.length);g(t=>{if(s)return[{id:w.current++,content:c,fading:!1},{id:w.current++,content:e,fading:!0}];const n=t[t.length-1];return(null==n?void 0:n.fading)?[...t.slice(0,-1),{...n,content:n.content+e}]:[...t,{id:w.current++,content:e,fading:!0}]})}else g(m?[{id:w.current++,content:m,fading:!1}]:[]);else r&&g(e=>e.some(e=>e.fading)?on(e):e);else g(e=>{var t;return 1!==e.length||(null==(t=e[0])?void 0:t.fading)||e[0].content!==m?m?[{id:w.current++,content:m,fading:!1}]:[]:e});y.current=m,x.current=n,f&&(null==o||o.set(f,m))},[l,m,v,null==a?void 0:a.textStreamState,null==a?void 0:a.streamRenderVersion,f,h]),/* @__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:l||p.map(e=>/* @__PURE__ */t("span",{className:e.fading?ut("text-node-stream-delta",e.id%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"):void 0,onAnimationEnd:e.fading?()=>{return t=e.id,void g(e=>e.some(e=>e.id===t&&e.fading)?on(e,t):e);var t}:void 0,children:e.content},e.id))})}function an(e){/* @__PURE__ */
96
- return t("ins",{className:"insert-node",children:e.children})}function cn(e,t){return e.reduce((e,n)=>{const r=null==t||n.id===t?{...n,fading:!1}:n,o=e[e.length-1];return!o||o.fading||r.fading?e.push(r):e[e.length-1]={...o,content:o.content+r.content},e},[])}function sn({content:e}){const n=c(e),r=c(n.current),o=c(null);return s(()=>{const t=o.current;if(t)if(e.startsWith(r.current)){const n=e.slice(r.current.length);n&&t.appendChild(document.createTextNode(n)),r.current=e}else t.textContent=e,r.current=e},[e]),/* @__PURE__ */t("span",{ref:o,children:n.current})}function dn(e){var n,r;const{node:o,children:l,ctx:a,indexKey:d,fade:u}=e,m=String(null!=(n=o.content)?n:""),h=null==(r=null!=u?u:null==a?void 0:a.fade)||r,f=null==d||""===d?"":String(d),[p,g]=i(m?[{id:0,content:m,fading:!1}]:[]),v=Te(),y=c(m),w=c(1),x=c(void 0);return s(()=>{var e,t;const n=null!=(e=null==v?void 0:v.getStreamRenderVersion())?e:null==a?void 0:a.streamRenderVersion,r=n!==x.current;if(null!=l)return y.current="",g([]),void(x.current=n);const o=null!=(t=null==v?void 0:v.textStreamState)?t:null==a?void 0:a.textStreamState,i=f?null==o?void 0:o.get(f):void 0;let c=y.current;const s=Boolean(c===m&&i&&m.startsWith(i)&&m.length>i.length);if(s&&(c=i),h)if(m!==c)if(c&&m.startsWith(c)){const e=m.slice(c.length);g(t=>{if(s)return[{id:w.current++,content:c,fading:!1},{id:w.current++,content:e,fading:!0}];const n=t[t.length-1];return(null==n?void 0:n.fading)?[...t.slice(0,-1),{...n,content:n.content+e}]:[...t,{id:w.current++,content:e,fading:!0}]})}else g(m?[{id:w.current++,content:m,fading:!1}]:[]);else r&&g(e=>e.some(e=>e.fading)?cn(e):e);else g(e=>{if(!m)return[];const t=e.reduce((e,t)=>e+t.content,"");return m===t?e:m.startsWith(t)?[...e,{id:w.current++,content:m.slice(t.length),fading:!1}]:[{id:w.current++,content:m,fading:!1}]});y.current=m,x.current=n,f&&(null==o||o.set(f,m))},[l,m,v,null==a?void 0:a.textStreamState,null==a?void 0:a.streamRenderVersion,f,h]),/* @__PURE__ */t("span",null!=l?{className:ut("text-node whitespace-pre-wrap break-words",o.center&&"text-node-center"),children:l}:{className:ut("text-node whitespace-pre-wrap break-words",o.center&&"text-node-center"),children:p.map(e=>/* @__PURE__ */t("span",{className:e.fading?ut("text-node-stream-delta",e.id%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"):void 0,onAnimationEnd:e.fading?()=>{return t=e.id,void g(e=>e.some(e=>e.id===t&&e.fading)?cn(e,t):e);var t}:void 0,children:e.fading?e.content:/* @__PURE__ */t(sn,{content:e.content})},e.id))})}function un(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,f=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]),p=o(()=>{var e;return C({href:String(null!=(e=a.href)?e:"")}).href},[a.href]),g="string"==typeof a.title&&a.title.trim().length>0?a.title:String(null!=p?p:""),v=N(p),y=d(e=>{m&&Ue(e.currentTarget,String(a.title||p||a.text||""),"top",!1,(e.clientX,e.clientY),h)},[h,a.text,a.title,p,m]),w=d(()=>{m&&Xe()},[m]);return a.loading?/* @__PURE__ */t("span",{className:"link-loading inline-flex items-baseline gap-1.5","aria-hidden":"false",style:f,children:/* @__PURE__ */e("span",{className:"link-text-wrapper relative inline-flex",children:[
97
- /* @__PURE__ */t("span",{className:"leading-[normal] link-text",children:/* @__PURE__ */t(dn,{node:{type:"text",content:String(null!=(i=a.text)?i:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-loading`,typewriter:n.typewriter})}),
98
- /* @__PURE__ */t("span",{className:"link-loading-indicator","aria-hidden":"true"})]})}):/* @__PURE__ */t("a",{className:"link-node",href:p||void 0,title:m?"":g,"aria-label":`Link: ${g}`,target:v?"_blank":void 0,rel:v?"noopener noreferrer":void 0,style:f,onMouseEnter:y,onMouseLeave:w,children:c&&s?$(a.children,c,String(null!=u?u:"link"),s):/* @__PURE__ */t(dn,{node:{type:"text",content:String(null!=(l=a.text)?l:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-fallback`,typewriter:n.typewriter})})}function mn(e){const{node:n,ctx:r,renderNode:o,value:i,indexKey:l,children:a}=e;/* @__PURE__ */
99
- 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?$(n.children,r,String(null!=l?l:"list-item"),o):null})}function hn(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&&V(o.customId).list_item||mn;/* @__PURE__ */
100
- return t(a,{className:ut("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__ */
101
- 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 fn=null,pn=null,gn=!1;const vn=/* @__PURE__ */new Map,yn=/* @__PURE__ */new Map;let wn=5;const xn=/* @__PURE__ */new Set;function kn(){if(vn.size<wn&&xn.size){const e=Array.from(xn);xn.clear();for(const t of e)try{t()}catch{}}}function bn(e){fn=e,pn=null,fn.onmessage=e=>{const{id:t,html:n,error:r}=e.data,o=vn.get(t);if(o)if(vn.delete(t),clearTimeout(o.timeoutId),kn(),r)o.reject(new Error(r));else{const{content:t,displayMode:r}=e.data;if(t){const e=`${r?"d":"i"}:${t}`;if(yn.set(e,n),yn.size>200){const e=yn.keys().next().value;yn.delete(e)}}o.resolve(n)}},fn.onerror=e=>{console.error("[katexWorkerClient] Worker error:",e);for(const[t,n]of vn.entries())clearTimeout(n.timeoutId),n.reject(new Error(`Worker error: ${e.message}`));vn.clear(),kn()}}function Cn(){var e;fn&&(null==(e=fn.terminate)||e.call(fn)),fn=null,pn=null}function Nn(e){gn=!!e,fn&&fn.postMessage({type:"init",debug:gn})}const Mn="WORKER_BUSY";async function Bn(e,t=!0,n=2e3,r){performance.now();const o=oe(e);if(pn)return Promise.reject(pn);const i=`${t?"d":"i"}:${o}`,l=yn.get(i);if(l)return Promise.resolve(l);const a=fn||(pn=new Error("[katexWorkerClient] No worker instance set. Please inject a Worker via setKaTeXWorker()."),pn.name="WORKER_INIT_ERROR",pn.code="WORKER_INIT_ERROR",null);if(!a)return Promise.reject(pn);if(vn.size>=wn){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=Mn,e.busy=!0,e.inFlight=vn.size,e.max=wn,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(()=>{vn.delete(l);const e=new Error("Worker render timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT",i(e),kn()},n),s=()=>{},d=()=>{vn.delete(l),clearTimeout(c),xn.delete(s);const e=new Error("Aborted");e.name="AbortError",i(e),kn()};r&&r.addEventListener("abort",d,{once:!0}),vn.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:gn})}catch(u){vn.delete(l),clearTimeout(c),r&&r.removeEventListener("abort",d),i(u),kn()}})}function Sn(e,t,n){const r=`${t?"d":"i"}:${oe(e)}`;if(yn.set(r,n),yn.size>200){const e=yn.keys().next().value;yn.delete(e)}}function Tn(){yn.clear()}function En(e){wn=Math.max(1,Math.floor(e)),kn()}function Ln(e=1500,t){return vn.size<wn?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(){xn.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}),xn.add(l)})}const Dn={timeout:2e3,waitTimeout:1500,backoffMs:30,maxRetries:1};function $n(e){null!=e.timeout&&(Dn.timeout=Math.max(0,Math.floor(e.timeout))),null!=e.waitTimeout&&(Dn.waitTimeout=Math.max(0,Math.floor(e.waitTimeout))),null!=e.backoffMs&&(Dn.backoffMs=Math.max(0,Math.floor(e.backoffMs))),null!=e.maxRetries&&(Dn.maxRetries=Math.max(0,Math.floor(e.maxRetries)))}function Pn(){return{...Dn}}async function An(e,t=!0,n={}){var r,o,i,l;const a=null!=(r=n.timeout)?r:Dn.timeout,c=null!=(o=n.waitTimeout)?o:Dn.waitTimeout,s=null!=(i=n.backoffMs)?i:Dn.backoffMs,d=null!=(l=n.maxRetries)?l:Dn.maxRetries,u=Number.isFinite(d)?Math.max(0,Math.min(Math.floor(d),8)):Dn.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 Bn(e,t,a,m)}catch(f){if((null==f?void 0:f.code)!==Mn||h>=u)throw f;if(h++,await Ln(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 Rn=null,Fn=!1;async function In(){if(Rn)return Rn;if(Fn)return null;try{return Rn=await import("katex"),await import("katex/contrib/mhchem"),Rn}catch{return Fn=!0,null}}function _n({node:e}){const n=c(null),r=c(null),o=c(null),l=Pe(),[a,d]=i(!0),[u,m]=i(()=>"undefined"==typeof window),h=c(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=oe(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 An(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===Mn||"WORKER_TIMEOUT"===i){const t=await In();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:a?"math-rendering":void 0})})}function Hn({node:n}){const r=c(null),o=c(null),l=c(null),a=Pe(),[d,u]=i(!0),[m,h]=i(()=>"undefined"==typeof window),f=c(0);return s(()=>{const e=r.current;if(!e)return;const t=a(e,{rootMargin:"400px"});return l.current=t,t.isVisible()&&h(!0),t.whenVisible.then(()=>h(!0)),()=>{t.destroy(),l.current=null}},[a]),s(()=>{var e;const t=oe(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=++f.current,a="$$"===n.markup;return An(t,a,{timeout:1500,waitTimeout:0,maxRetries:0,signal:i.signal}).then(e=>{r||l!==f.current||o.current&&(o.current.innerHTML=e,u(!1))}).catch(async e=>{if(r||l!==f.current)return;if(!o.current)return;const i=(null==e?void 0:e.code)||(null==e?void 0:e.name);if("WORKER_INIT_ERROR"===i||(null==e?void 0:e.fallbackToRenderer)||i===Mn||"WORKER_TIMEOUT"===i){const e=await In();if(e)try{const i=e.renderToString(t,{throwOnError:n.loading,displayMode:a});return void(!r&&l===f.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:[
91
+ /* @__PURE__ */t("button",{className:ht("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>$(Math.min(D+.1,3)),children:"+"}),
92
+ /* @__PURE__ */t("button",{className:ht("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>$(Math.max(D-.1,.5)),children:"-"}),
93
+ /* @__PURE__ */e("button",{className:ht("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{$(1),A({x:0,y:0})},children:[Math.round(100*D),"%"]}),
94
+ /* @__PURE__ */t("button",{className:ht("inline-flex items-center justify-center p-2 rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:le,children:"X"})]}),
95
+ /* @__PURE__ */t("div",{ref:W,className:ht("w-full h-full flex items-center justify-center p-4 overflow-hidden",!R&&"cursor-grab",R&&"cursor-grabbing"),style:{touchAction:me?"none":void 0},onPointerDown:e=>se.start(e.nativeEvent)})]})}),document.body)]})}function an(e,t){return e.reduce((e,n)=>{const r=null==t||n.id===t?{...n,fading:!1}:n,o=e[e.length-1];return!o||o.fading||r.fading?e.push(r):e[e.length-1]={...o,content:o.content+r.content},e},[])}function cn(e){var n,r;const{node:o,children:l,ctx:a,indexKey:d,fade:u}=e,m=String(null!=(n=o.code)?n:""),h=null==(r=null!=u?u:null==a?void 0:a.fade)||r,f=null==d||""===d?"":String(d),[p,g]=i(m?[{id:0,content:m,fading:!1}]:[]),v=Ee(),y=c(m),w=c(1),x=c(void 0);return s(()=>{var e,t;const n=null!=(e=null==v?void 0:v.getStreamRenderVersion())?e:null==a?void 0:a.streamRenderVersion,r=n!==x.current;if(null!=l)return y.current="",g([]),void(x.current=n);const o=null!=(t=null==v?void 0:v.textStreamState)?t:null==a?void 0:a.textStreamState,i=f?null==o?void 0:o.get(f):void 0;let c=y.current;const s=Boolean(c===m&&i&&m.startsWith(i)&&m.length>i.length);if(s&&(c=i),h)if(m!==c)if(c&&m.startsWith(c)){const e=m.slice(c.length);g(t=>{if(s)return[{id:w.current++,content:c,fading:!1},{id:w.current++,content:e,fading:!0}];const n=t[t.length-1];return(null==n?void 0:n.fading)?[...t.slice(0,-1),{...n,content:n.content+e}]:[...t,{id:w.current++,content:e,fading:!0}]})}else g(m?[{id:w.current++,content:m,fading:!1}]:[]);else r&&g(e=>e.some(e=>e.fading)?an(e):e);else g(e=>{var t;return 1!==e.length||(null==(t=e[0])?void 0:t.fading)||e[0].content!==m?m?[{id:w.current++,content:m,fading:!1}]:[]:e});y.current=m,x.current=n,f&&(null==o||o.set(f,m))},[l,m,v,null==a?void 0:a.textStreamState,null==a?void 0:a.streamRenderVersion,f,h]),/* @__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:l||p.map(e=>/* @__PURE__ */t("span",{className:e.fading?ht("text-node-stream-delta",e.id%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"):void 0,onAnimationEnd:e.fading?()=>{return t=e.id,void g(e=>e.some(e=>e.id===t&&e.fading)?an(e,t):e);var t}:void 0,children:e.content},e.id))})}function sn(e){/* @__PURE__ */
96
+ return t("ins",{className:"insert-node",children:e.children})}function dn(e,t){return e.reduce((e,n)=>{const r=null==t||n.id===t?{...n,fading:!1}:n,o=e[e.length-1];return!o||o.fading||r.fading?e.push(r):e[e.length-1]={...o,content:o.content+r.content},e},[])}function un({content:e}){const n=c(e),r=c(n.current),o=c(null);return s(()=>{const t=o.current;if(t)if(e.startsWith(r.current)){const n=e.slice(r.current.length);n&&t.appendChild(document.createTextNode(n)),r.current=e}else t.textContent=e,r.current=e},[e]),/* @__PURE__ */t("span",{ref:o,children:n.current})}function mn(e){var n,r;const{node:o,children:l,ctx:a,indexKey:d,fade:u}=e,m=String(null!=(n=o.content)?n:""),h=null==(r=null!=u?u:null==a?void 0:a.fade)||r,f=null==d||""===d?"":String(d),[p,g]=i(m?[{id:0,content:m,fading:!1}]:[]),v=Ee(),y=c(m),w=c(1),x=c(void 0);return s(()=>{var e,t;const n=null!=(e=null==v?void 0:v.getStreamRenderVersion())?e:null==a?void 0:a.streamRenderVersion,r=n!==x.current;if(null!=l)return y.current="",g([]),void(x.current=n);const o=null!=(t=null==v?void 0:v.textStreamState)?t:null==a?void 0:a.textStreamState,i=f?null==o?void 0:o.get(f):void 0;let c=y.current;const s=Boolean(c===m&&i&&m.startsWith(i)&&m.length>i.length);if(s&&(c=i),h)if(m!==c)if(c&&m.startsWith(c)){const e=m.slice(c.length);g(t=>{if(s)return[{id:w.current++,content:c,fading:!1},{id:w.current++,content:e,fading:!0}];const n=t[t.length-1];return(null==n?void 0:n.fading)?[...t.slice(0,-1),{...n,content:n.content+e}]:[...t,{id:w.current++,content:e,fading:!0}]})}else g(m?[{id:w.current++,content:m,fading:!1}]:[]);else r&&g(e=>e.some(e=>e.fading)?dn(e):e);else g(e=>{if(!m)return[];const t=e.reduce((e,t)=>e+t.content,"");return m===t?e:m.startsWith(t)?[...e,{id:w.current++,content:m.slice(t.length),fading:!1}]:[{id:w.current++,content:m,fading:!1}]});y.current=m,x.current=n,f&&(null==o||o.set(f,m))},[l,m,v,null==a?void 0:a.textStreamState,null==a?void 0:a.streamRenderVersion,f,h]),/* @__PURE__ */t("span",null!=l?{className:ht("text-node whitespace-pre-wrap break-words",o.center&&"text-node-center"),children:l}:{className:ht("text-node whitespace-pre-wrap break-words",o.center&&"text-node-center"),children:p.map(e=>/* @__PURE__ */t("span",{className:e.fading?ht("text-node-stream-delta",e.id%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"):void 0,onAnimationEnd:e.fading?()=>{return t=e.id,void g(e=>e.some(e=>e.id===t&&e.fading)?dn(e,t):e);var t}:void 0,children:e.fading?e.content:/* @__PURE__ */t(un,{content:e.content})},e.id))})}function hn(n){var r,i,l;const{node:a,ctx:u,renderNode:m,indexKey:h}=n,f=!1!==n.showTooltip,p=null!=(r=n.isDark)?r:null==u?void 0:u.isDark,g=c(null);s(()=>{const e=g.current;return()=>{e&&Ye(!0,e)}},[f,a.loading]);const v=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]),y=o(()=>{var e;return C({href:String(null!=(e=a.href)?e:"")}).href},[a.href]),w="string"==typeof a.title&&a.title.trim().length>0?a.title:String(null!=y?y:""),x=N(y),k=d(e=>{f&&Ze(e.currentTarget,String(a.title||y||a.text||""),"top",!1,(e.clientX,e.clientY),p)},[p,a.text,a.title,y,f]),b=d(e=>{f&&Ye(!1,e.currentTarget)},[f]);return a.loading?/* @__PURE__ */t("span",{className:"link-loading inline-flex items-baseline gap-1.5","aria-hidden":"false",style:v,children:/* @__PURE__ */e("span",{className:"link-text-wrapper relative inline-flex",children:[
97
+ /* @__PURE__ */t("span",{className:"leading-[normal] link-text",children:/* @__PURE__ */t(mn,{node:{type:"text",content:String(null!=(i=a.text)?i:"")},ctx:u,indexKey:`${String(null!=h?h:"link")}-loading`,typewriter:n.typewriter})}),
98
+ /* @__PURE__ */t("span",{className:"link-loading-indicator","aria-hidden":"true"})]})}):/* @__PURE__ */t("a",{ref:g,className:"link-node",href:y||void 0,title:f?"":w,"aria-label":`Link: ${w}`,target:x?"_blank":void 0,rel:x?"noopener noreferrer":void 0,style:v,onMouseEnter:k,onMouseLeave:b,children:u&&m?$(a.children,u,String(null!=h?h:"link"),m):/* @__PURE__ */t(mn,{node:{type:"text",content:String(null!=(l=a.text)?l:"")},ctx:u,indexKey:`${String(null!=h?h:"link")}-fallback`,typewriter:n.typewriter})})}function fn(e){const{node:n,ctx:r,renderNode:o,value:i,indexKey:l,children:a}=e;/* @__PURE__ */
99
+ 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?$(n.children,r,String(null!=l?l:"list-item"),o):null})}function pn(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&&V(o.customId).list_item||fn;/* @__PURE__ */
100
+ return t(a,{className:ht("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__ */
101
+ 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 gn=null,vn=null,yn=!1;const wn=/* @__PURE__ */new Map,xn=/* @__PURE__ */new Map;let kn=5;const bn=/* @__PURE__ */new Set;function Cn(){if(wn.size<kn&&bn.size){const e=Array.from(bn);bn.clear();for(const t of e)try{t()}catch{}}}function Nn(e){gn=e,vn=null,gn.onmessage=e=>{const{id:t,html:n,error:r}=e.data,o=wn.get(t);if(o)if(wn.delete(t),clearTimeout(o.timeoutId),Cn(),r)o.reject(new Error(r));else{const{content:t,displayMode:r}=e.data;if(t){const e=`${r?"d":"i"}:${t}`;if(xn.set(e,n),xn.size>200){const e=xn.keys().next().value;xn.delete(e)}}o.resolve(n)}},gn.onerror=e=>{console.error("[katexWorkerClient] Worker error:",e);for(const[t,n]of wn.entries())clearTimeout(n.timeoutId),n.reject(new Error(`Worker error: ${e.message}`));wn.clear(),Cn()}}function Mn(){var e;gn&&(null==(e=gn.terminate)||e.call(gn)),gn=null,vn=null}function Bn(e){yn=!!e,gn&&gn.postMessage({type:"init",debug:yn})}const Sn="WORKER_BUSY";async function Tn(e,t=!0,n=2e3,r){performance.now();const o=oe(e);if(vn)return Promise.reject(vn);const i=`${t?"d":"i"}:${o}`,l=xn.get(i);if(l)return Promise.resolve(l);const a=gn||(vn=new Error("[katexWorkerClient] No worker instance set. Please inject a Worker via setKaTeXWorker()."),vn.name="WORKER_INIT_ERROR",vn.code="WORKER_INIT_ERROR",null);if(!a)return Promise.reject(vn);if(wn.size>=kn){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=Sn,e.busy=!0,e.inFlight=wn.size,e.max=kn,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(()=>{wn.delete(l);const e=new Error("Worker render timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT",i(e),Cn()},n),s=()=>{},d=()=>{wn.delete(l),clearTimeout(c),bn.delete(s);const e=new Error("Aborted");e.name="AbortError",i(e),Cn()};r&&r.addEventListener("abort",d,{once:!0}),wn.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:yn})}catch(u){wn.delete(l),clearTimeout(c),r&&r.removeEventListener("abort",d),i(u),Cn()}})}function En(e,t,n){const r=`${t?"d":"i"}:${oe(e)}`;if(xn.set(r,n),xn.size>200){const e=xn.keys().next().value;xn.delete(e)}}function Ln(){xn.clear()}function Dn(e){kn=Math.max(1,Math.floor(e)),Cn()}function $n(e=1500,t){return wn.size<kn?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(){bn.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}),bn.add(l)})}const Pn={timeout:2e3,waitTimeout:1500,backoffMs:30,maxRetries:1};function An(e){null!=e.timeout&&(Pn.timeout=Math.max(0,Math.floor(e.timeout))),null!=e.waitTimeout&&(Pn.waitTimeout=Math.max(0,Math.floor(e.waitTimeout))),null!=e.backoffMs&&(Pn.backoffMs=Math.max(0,Math.floor(e.backoffMs))),null!=e.maxRetries&&(Pn.maxRetries=Math.max(0,Math.floor(e.maxRetries)))}function Rn(){return{...Pn}}async function Fn(e,t=!0,n={}){var r,o,i,l;const a=null!=(r=n.timeout)?r:Pn.timeout,c=null!=(o=n.waitTimeout)?o:Pn.waitTimeout,s=null!=(i=n.backoffMs)?i:Pn.backoffMs,d=null!=(l=n.maxRetries)?l:Pn.maxRetries,u=Number.isFinite(d)?Math.max(0,Math.min(Math.floor(d),8)):Pn.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 Tn(e,t,a,m)}catch(f){if((null==f?void 0:f.code)!==Sn||h>=u)throw f;if(h++,await $n(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 In=null,_n=!1;async function Hn(){if(In)return In;if(_n)return null;try{return In=await import("katex"),await import("katex/contrib/mhchem"),In}catch{return _n=!0,null}}function Wn({node:e}){const n=c(null),r=c(null),o=c(null),l=Ae(),[a,d]=i(!0),[u,m]=i(()=>"undefined"==typeof window),h=c(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=oe(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 Fn(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 Hn();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),En(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:a?"math-rendering":void 0})})}function On({node:n}){const r=c(null),o=c(null),l=c(null),a=Ae(),[d,u]=i(!0),[m,h]=i(()=>"undefined"==typeof window),f=c(0);return s(()=>{const e=r.current;if(!e)return;const t=a(e,{rootMargin:"400px"});return l.current=t,t.isVisible()&&h(!0),t.whenVisible.then(()=>h(!0)),()=>{t.destroy(),l.current=null}},[a]),s(()=>{var e;const t=oe(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=++f.current,a="$$"===n.markup;return Fn(t,a,{timeout:1500,waitTimeout:0,maxRetries:0,signal:i.signal}).then(e=>{r||l!==f.current||o.current&&(o.current.innerHTML=e,u(!1))}).catch(async e=>{if(r||l!==f.current)return;if(!o.current)return;const i=(null==e?void 0:e.code)||(null==e?void 0:e.name);if("WORKER_INIT_ERROR"===i||(null==e?void 0:e.fallbackToRenderer)||i===Sn||"WORKER_TIMEOUT"===i){const e=await Hn();if(e)try{const i=e.renderToString(t,{throwOnError:n.loading,displayMode:a});return void(!r&&l===f.current&&o.current&&(o.current.innerHTML=i,u(!1),En(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:[
102
102
  /* @__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:[
103
103
  /* @__PURE__ */t("span",{className:"math-inline__spinner","aria-hidden":"true"}),
104
- /* @__PURE__ */t("span",{className:"sr-only",children:"Loading"})]})]})}function Wn(e){try{if("undefined"!=typeof globalThis&&"function"==typeof globalThis.requestAnimationFrame)return globalThis.requestAnimationFrame(e)}catch{}return globalThis.setTimeout(e,0)}let On=null,jn=null;const zn=/* @__PURE__ */new Map;let Kn=5,Vn=!1;function qn(e){Vn=!!e}function Un(e){Number.isFinite(e)&&e>0&&(Kn=Math.floor(e))}function Xn(){return{inFlight:zn.size,max:Kn}}const Zn="WORKER_BUSY";function Yn(e){On=e,jn=null;const t=e;On.onmessage=e=>{if(On!==t)return;const{id:n,ok:r,result:o,error:i}=e.data,l=zn.get(n);l&&(!1===r||i?l.reject(new Error(i||"Unknown error")):l.resolve(o))},On.onerror=e=>{var n,r;if(On===t)if(0!==zn.size){try{Vn?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 zn.entries())n.reject(new Error(`Worker error: ${e.message}`));zn.clear()}else null==(n=console.debug)||n.call(console,"[mermaidWorkerClient] Worker error (no pending):",(null==e?void 0:e.message)||e)},On.onmessageerror=e=>{var n,r;if(On===t)if(0!==zn.size){try{Vn?console.error("[mermaidWorkerClient] Worker messageerror:",e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker messageerror:",e)}catch{}for(const[e,t]of zn.entries())t.reject(new Error("Worker messageerror"));zn.clear()}else null==(n=console.debug)||n.call(console,"[mermaidWorkerClient] Worker messageerror (no pending):",e)}}function Gn(){var e;if(On)try{for(const[e,t]of zn.entries())t.reject(new Error("Worker cleared"));zn.clear(),null==(e=On.terminate)||e.call(On)}catch{}On=null,jn=null}function Jn(e,t,n=1400){if(jn)return Promise.reject(jn);const r=On||(jn=new Error("[mermaidWorkerClient] No worker instance set. Please inject a Worker via setMermaidWorker()."),jn.name="WORKER_INIT_ERROR",jn.code="WORKER_INIT_ERROR",null);if(!r)return Promise.reject(jn);if(zn.size>=Kn){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=Zn,e.inFlight=zn.size,e.max=Kn,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),zn.delete(l))},d={resolve:e=>{s(),o(e)},reject:e=>{s(),i(e)}};zn.set(l,d);try{r.postMessage({id:l,action:e,payload:t})}catch(u){return zn.delete(l),void i(u)}c=setTimeout(()=>{const e=new Error("Worker call timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT";const t=zn.get(l);null==t||t.reject(e)},n)})}async function Qn(e,t,n=1400){return Jn("canParse",{code:e,theme:t},n)}async function er(e,t,n=2400){return Jn("findPrefix",{code:e,theme:t},n)}function tr(){var e;null==(e=null==On?void 0:On.terminate)||e.call(On),On=null,jn=null,zn.clear()}let nr=null,rr=!1,or=null,ir=null;function lr(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(or!==r)try{"function"==typeof e.initialize?e.initialize(t):(null==(n=e.mermaidAPI)?void 0:n.initialize)&&e.mermaidAPI.initialize(t),or=r}catch{}}const ar="undefined"!=typeof window?u:s,cr={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0};function sr(e){if(e)try{e.replaceChildren()}catch{e.innerHTML=""}}function dr(e,t,n={}){if(!e)return"";const r=function(e,t){if(!e)return"";const n=M(t);return n?(sr(e),e.appendChild(n),e.innerHTML):""}(e,t);return r||n.keepPreviousOnFailure||sr(e),r}function ur(e,t,n){if(n&&(null==e?void 0:e.querySelector("svg")))try{null==t||t(e)}catch{}}const mr={maxHeight:"500px",loading:!0,workerTimeoutMs:1400,parseTimeoutMs:1800,renderTimeoutMs:2500,fullRenderTimeoutMs:4e3,renderDebounceMs:300,contentStableDelayMs:500,previewPollDelayMs:800,previewPollMaxDelayMs:4e3,previewPollMaxAttempts:12,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showFullscreenButton:!0,showCollapseButton:!0,showZoomControls:!0,enableWheelZoom:!1,isStrict:!0,enableMermaidInteractions:!1};function hr(r){var l,a,m,h,f,p,g,v,y,w;const x={...mr,...r},{t:k}=_e(),b=o(()=>H("mermaid"),[]),C=null!=(a=null==(l=x.node)?void 0:l.code)?a:"",N=o(()=>C.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"),[C]),M=null!=(m=x.workerTimeoutMs)?m:mr.workerTimeoutMs,B=null!=(h=x.parseTimeoutMs)?h:mr.parseTimeoutMs,S=null!=(f=x.renderTimeoutMs)?f:mr.renderTimeoutMs,T=null!=(p=x.fullRenderTimeoutMs)?p:mr.fullRenderTimeoutMs,E=Math.max(0,null!=(g=x.renderDebounceMs)?g:mr.renderDebounceMs),L=o(()=>x.maxHeight&&"none"!==x.maxHeight?ie(x.maxHeight):null,[x.maxHeight]),D=o(()=>{var e;return null!=(e=ie(x.estimatedPreviewHeightPx))?e:le(N)},[N,x.estimatedPreviewHeightPx]),[$,P]=i(!1),[A,R]=i(!1),[F,I]=i(!1),[_,W]=i(!1),[O,j]=i(1),[z,K]=i({x:0,y:0}),[V,q]=i(!1),[U,X]=i(!1),[Z,Y]=i(!1),[G,J]=i(null),[Q,ee]=i(!1),[te,ne]=i(()=>`${ae(D,ce,L)}px`),[re,oe]=i("undefined"==typeof window),se=c(null),de=c(null),ue=c(null),me=c(null),he=c(null),fe=c(null),pe=c(null),ve=c(null),ye=c(0),we=c({}),xe=c(null),ke=c(""),be=c(!1),Ne=c(null),Me=c(!1),Be=c({zoom:1,translateX:0,translateY:0,containerHeight:te||"360px"}),Se=c(z);Se.current=z;const Te=c(O);Te.current=O;const Ee=c(Q);Ee.current=Q;const Le=Pe(),De=Boolean(null!=(y=null==(v=x.node)?void 0:v.loading)?y:x.loading),$e=x.isDark?"dark":"light",Ae=Boolean(x.isStrict),Re=!0===x.enableMermaidInteractions,Fe=o(()=>Ae?{startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,dompurifyConfig:cr,flowchart:{htmlLabels:!1}}:{startOnLoad:!1,securityLevel:"loose",suppressErrorRendering:!0},[Ae]);s(()=>{Me.current=Z},[Z]);const Ie=d(()=>{var e;const t=de.current,n=t?getComputedStyle(t).getPropertyValue("--ms-size-diagram-min-height").trim():"";return null!=(e=ie(n))?e:ce},[]),He=d(()=>ae(D,Ie(),L),[D,L,Ie]);s(()=>{A||F||ne(e=>{const t=ie(e),n=He();return null!=t&&t>=n?e:`${n}px`})},[F,He,A]),s(()=>{we.current={}},[$e,N,Ae]),s(()=>{let e=!1;return(async()=>{const t=await async function(e){if(nr)return lr(nr,e),nr;if(ir){const t=await ir;return t&&lr(t,e),t}if(rr)return null;try{rr=!0,ir=(async()=>{try{const t=await import("mermaid"),n=(null==t?void 0:t.default)||t;if(nr=(null==n?void 0:n.default)?n.default:(null==n?void 0:n.mermaidAPI)?n:(null==n?void 0:n.mermaid)?n.mermaid:n,!nr)throw new Error("Mermaid module did not export expected API");return lr(nr,null!=e?e:{startOnLoad:!1,securityLevel:"strict",flowchart:{htmlLabels:!1}}),nr}catch(t){return console.warn("[markstream-react] Failed to load mermaid:",t),null}finally{ir=null}})();const t=await ir;return t&&lr(t,e),t}catch{return null}}(Fe);e||(se.current=t,P(Boolean(t)),be.current||R(!t))})(),()=>{e=!0}},[Fe]),s(()=>{const e=de.current;if(!e)return;const t=Le(e,{rootMargin:"400px"});return Ne.current=t,t.isVisible()&&oe(!0),t.whenVisible.then(()=>oe(!0)),()=>{t.destroy(),Ne.current=null}},[Le]),s(()=>{if("undefined"==typeof document)return;if(!Q)return;const e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[Q]);const We=d(()=>L,[L]),Oe=d(e=>{const t=de.current,n=me.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=We(),d=null==s?c:Math.min(c,s),u=He();ne(`${"none"===x.maxHeight?d:Math.max(d,u)}px`)},[x.maxHeight,He,We]);s(()=>{if(!de.current||"undefined"==typeof ResizeObserver)return;if(A||F)return;const e=new ResizeObserver(e=>{if(!e.length)return;const t=e[0].contentRect.width;Wn(()=>Oe(t))});return e.observe(de.current),()=>e.disconnect()},[F,A,Oe]),s(()=>{A||F||Oe()},[F,x.maxHeight,A,Oe]),s(()=>()=>{tr()},[]),u(()=>{var e;const t=we.current[$e];!A&&me.current&&(null==t?void 0:t.svg)&&(dr(me.current,t.svg)&&(xe.current=null!=(e=t.bindFunctions)?e:null,ur(me.current,t.bindFunctions,Re)),Wn(()=>Oe()))},[Re,A,$e,Oe]);const je=d(async(e,t,n)=>{var r;if(!se.current||!me.current)return!1;X(!0);try{const o=`mermaid-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=gr(e,t),l=await xr(()=>se.current.render(o,i),{timeoutMs:T,signal:n});if(!(null==l?void 0:l.svg))return!1;const a=dr(me.current,l.svg);return!!a&&(xe.current=null!=(r=l.bindFunctions)?r:null,ur(me.current,l.bindFunctions,Re),Oe(),we.current[t]={svg:a,bindFunctions:l.bindFunctions},Y(!0),J(null),!0)}catch(o){if(!De){if("function"==typeof x.onRenderError&&me.current&&!0===x.onRenderError(o,N,me.current))return!1;J(o instanceof Error?o.message:String(o))}return!1}finally{X(!1)}},[Re,T,De,Oe]),ze=d(async(e,t,n)=>{var r;if(se.current&&me.current){X(!0);try{const o=`mermaid-preview-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=gr(wr(e)||e,t),l=await xr(()=>se.current.render(o,i),{timeoutMs:S,signal:n});if(null==l?void 0:l.svg){const e=dr(me.current,l.svg,{keepPreviousOnFailure:!0});e&&(xe.current=null!=(r=l.bindFunctions)?r:null,ur(me.current,l.bindFunctions,Re)),e&&Oe()}}catch{}finally{X(!1)}}},[Re,S,De,Oe]),Ke=d(async(e,t)=>{if(!e.trim())return sr(me.current),Y(!1),void(ke.current="");const n=e.replace(/\s+/g,"");if(n===ke.current&&Me.current)return;const r=++ye.current;if("gantt"===vr(e)){const i=wr(e);if(!i.trim())return;try{if(await pr(i,$e,{workerTimeout:M,parseTimeout:B,mermaid:se.current,signal:t}),(null==t?void 0:t.aborted)||ye.current!==r)return;i===e?await je(e,$e,t)&&(ke.current=n):await ze(i,$e,t)}catch(o){if("AbortError"===(null==o?void 0:o.name))return}return}try{if(await pr(e,$e,{workerTimeout:M,parseTimeout:B,mermaid:se.current,signal:t}),(null==t?void 0:t.aborted)||ye.current!==r)return;return void(await je(e,$e,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 er(e,t,n.workerTimeout);if(r)return r}catch(o){if("AbortError"===(null==o?void 0:o.name))throw o}return wr(e)}(e,$e,{workerTimeout:M,signal:t});if(!n||(null==t?void 0:t.aborted)||ye.current!==r)return;await ze(n,$e,t)}catch{}},[B,je,ze,$e,M]),Ve=d(()=>re&&!A&&!F,[F,A,re]);s(()=>{if(!Ve())return;if(!se.current)return;const e=new AbortController,t=window.setTimeout(()=>{!e.signal.aborted&&Ve()&&Ke(N,e.signal)},E);return()=>{e.abort(),window.clearTimeout(t)}},[N,Ve,$,Ke,E]);const qe=d((e,t)=>{e.clientX,e.clientY,Ue(e.currentTarget,t,"top",!1,0,x.isDark)},[x.isDark]),Ze=d(async()=>{var e,t;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(N)),W(!0),null==(t=x.onCopy)||t.call(x,N),setTimeout(()=>W(!1),1e3)}catch{}},[N,x]),Ye=d(()=>{var e,t,n;const r=null!=(t=null==(e=me.current)?void 0:e.querySelector("svg"))?t:null;if(!r)return;const o=kr(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:kr(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]),Ge=d(()=>{pe.current=null,sr(fe.current)},[]),Je=d(()=>{ee(!1),Ge()},[Ge]),Qe=d(()=>{var e,t,n;const r=null!=(t=null==(e=me.current)?void 0:e.querySelector("svg"))?t:null,o=r?kr(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||ee(!0)},[x]);s(()=>{if(!Q)return;if("undefined"==typeof window)return;const e=e=>{"Escape"===e.key&&Je()};try{window.addEventListener("keydown",e)}catch{}return()=>{try{window.removeEventListener("keydown",e)}catch{}}},[Je,Q]),ar(()=>{var e,t;if(!Q)return;const n=fe.current,r=de.current;if(!n||!r)return;const o=`translate(${z.x}px, ${z.y}px) scale(${O})`,i=r.cloneNode(!0);i.classList.add("fullscreen"),i.style.height="100%",i.style.maxHeight="100%";const l=i.querySelector("[data-mermaid-wrapper]");l&&(pe.current=l,l.style.transform=o),sr(n),n.appendChild(i),ur(n,null!=(t=xe.current)?t:null==(e=we.current[$e])?void 0:e.bindFunctions,Re)},[Re,Q,$e]),s(()=>{Q&&pe.current&&(pe.current.style.transform=`translate(${z.x}px, ${z.y}px) scale(${O})`)},[Q,z.x,z.y,O]);const et=A||U||F,tt=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]),nt=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){R(!1);const e=Be.current;j(e.zoom),K({x:e.translateX,y:e.translateY}),ne(e.containerHeight)}else Be.current={zoom:O,translateX:z.x,translateY:z.y,containerHeight:te},R(!0)},[N,te,Ke,x,$e,z.x,z.y,Oe,O]),rt=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=fr(O+i,.5,3);if(l===O)return;const a=l/O;K({x:z.x-r*(a-1),y:z.y-o*(a-1)}),j(l)},[z,O]);ve.current||(ve.current=ge({getTranslate:()=>Se.current,setTranslate:e=>K(e),canStart:e=>{var t;return!!(null==(t=me.current)?void 0:t.querySelector("svg"))&&("touch"!==e.pointerType||Ee.current||Te.current>1)},onActiveChange:e=>q(e)}));const ot=ve.current;s(()=>()=>ot.stop(),[ot]);const it=Q||O>1,lt=/* @__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:[
105
- /* @__PURE__ */t("button",{type:"button",className:ut("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=>qe(e,k("common.zoomIn")),onMouseLeave:()=>Xe(),onClick:()=>j(fr(O+.1,.5,3)),children:"+"}),
106
- /* @__PURE__ */t("button",{type:"button",className:ut("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=>qe(e,k("common.zoomOut")),onMouseLeave:()=>Xe(),onClick:()=>j(fr(O-.1,.5,3)),children:"−"}),
107
- /* @__PURE__ */e("button",{type:"button",className:ut("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=>qe(e,k("common.resetZoom")),onMouseLeave:()=>Xe(),onClick:()=>{j(1),K({x:0,y:0})},children:[Math.round(100*O),"%"]})]})}),
108
- /* @__PURE__ */e("div",{ref:de,className:ut("relative overflow-hidden block transition-[height] duration-150 ease-out",x.isDark?"bg-gray-900":"bg-gray-50"),style:{height:te,maxHeight:null!=(w=x.maxHeight)?w:void 0,minHeight:"var(--ms-size-diagram-min-height, 360px)",touchAction:it?"none":void 0},onWheel:rt,onPointerDown:e=>ot.start(e.nativeEvent),children:[
109
- /* @__PURE__ */t("div",{ref:ue,"data-mermaid-wrapper":!0,className:ut("absolute inset-0 cursor-grab",{"cursor-grabbing":V}),style:{transform:`translate(${z.x}px, ${z.y}px) scale(${O})`},children:/* @__PURE__ */t("div",{ref:me,className:"_mermaid w-full text-center flex items-center justify-center min-h-full"})}),(U||De)&&/* @__PURE__ */e("div",{className:"mermaid-loading",children:[
104
+ /* @__PURE__ */t("span",{className:"sr-only",children:"Loading"})]})]})}function jn(e){try{if("undefined"!=typeof globalThis&&"function"==typeof globalThis.requestAnimationFrame)return globalThis.requestAnimationFrame(e)}catch{}return globalThis.setTimeout(e,0)}let zn=null,Kn=null;const Vn=/* @__PURE__ */new Map;let qn=5,Un=!1;function Xn(e){Un=!!e}function Zn(e){Number.isFinite(e)&&e>0&&(qn=Math.floor(e))}function Yn(){return{inFlight:Vn.size,max:qn}}const Gn="WORKER_BUSY";function Jn(e){zn=e,Kn=null;const t=e;zn.onmessage=e=>{if(zn!==t)return;const{id:n,ok:r,result:o,error:i}=e.data,l=Vn.get(n);l&&(!1===r||i?l.reject(new Error(i||"Unknown error")):l.resolve(o))},zn.onerror=e=>{var n,r;if(zn===t)if(0!==Vn.size){try{Un?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 Vn.entries())n.reject(new Error(`Worker error: ${e.message}`));Vn.clear()}else null==(n=console.debug)||n.call(console,"[mermaidWorkerClient] Worker error (no pending):",(null==e?void 0:e.message)||e)},zn.onmessageerror=e=>{var n,r;if(zn===t)if(0!==Vn.size){try{Un?console.error("[mermaidWorkerClient] Worker messageerror:",e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker messageerror:",e)}catch{}for(const[e,t]of Vn.entries())t.reject(new Error("Worker messageerror"));Vn.clear()}else null==(n=console.debug)||n.call(console,"[mermaidWorkerClient] Worker messageerror (no pending):",e)}}function Qn(){var e;if(zn)try{for(const[e,t]of Vn.entries())t.reject(new Error("Worker cleared"));Vn.clear(),null==(e=zn.terminate)||e.call(zn)}catch{}zn=null,Kn=null}function er(e,t,n=1400){if(Kn)return Promise.reject(Kn);const r=zn||(Kn=new Error("[mermaidWorkerClient] No worker instance set. Please inject a Worker via setMermaidWorker()."),Kn.name="WORKER_INIT_ERROR",Kn.code="WORKER_INIT_ERROR",null);if(!r)return Promise.reject(Kn);if(Vn.size>=qn){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=Gn,e.inFlight=Vn.size,e.max=qn,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),Vn.delete(l))},d={resolve:e=>{s(),o(e)},reject:e=>{s(),i(e)}};Vn.set(l,d);try{r.postMessage({id:l,action:e,payload:t})}catch(u){return Vn.delete(l),void i(u)}c=setTimeout(()=>{const e=new Error("Worker call timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT";const t=Vn.get(l);null==t||t.reject(e)},n)})}async function tr(e,t,n=1400){return er("canParse",{code:e,theme:t},n)}async function nr(e,t,n=2400){return er("findPrefix",{code:e,theme:t},n)}function rr(){var e;null==(e=null==zn?void 0:zn.terminate)||e.call(zn),zn=null,Kn=null,Vn.clear()}let or=null,ir=!1,lr=null,ar=null;function cr(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(lr!==r)try{"function"==typeof e.initialize?e.initialize(t):(null==(n=e.mermaidAPI)?void 0:n.initialize)&&e.mermaidAPI.initialize(t),lr=r}catch{}}const sr="undefined"!=typeof window?u:s,dr={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0};function ur(e){if(e)try{e.replaceChildren()}catch{e.innerHTML=""}}function mr(e,t,n={}){if(!e)return"";const r=function(e,t){if(!e)return"";const n=M(t);return n?(ur(e),e.appendChild(n),e.innerHTML):""}(e,t);return r||n.keepPreviousOnFailure||ur(e),r}function hr(e,t,n){if(n&&(null==e?void 0:e.querySelector("svg")))try{null==t||t(e)}catch{}}const fr={maxHeight:"500px",loading:!0,workerTimeoutMs:1400,parseTimeoutMs:1800,renderTimeoutMs:2500,fullRenderTimeoutMs:4e3,renderDebounceMs:300,contentStableDelayMs:500,previewPollDelayMs:800,previewPollMaxDelayMs:4e3,previewPollMaxAttempts:12,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showFullscreenButton:!0,showCollapseButton:!0,showZoomControls:!0,enableWheelZoom:!1,isStrict:!0,enableMermaidInteractions:!1};function pr(r){var l,a,m,h,f,p,g,v,y,w;const x={...fr,...r},{t:k}=He(),b=o(()=>H("mermaid"),[]),C=null!=(a=null==(l=x.node)?void 0:l.code)?a:"",N=o(()=>C.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"),[C]),M=null!=(m=x.workerTimeoutMs)?m:fr.workerTimeoutMs,B=null!=(h=x.parseTimeoutMs)?h:fr.parseTimeoutMs,S=null!=(f=x.renderTimeoutMs)?f:fr.renderTimeoutMs,T=null!=(p=x.fullRenderTimeoutMs)?p:fr.fullRenderTimeoutMs,E=Math.max(0,null!=(g=x.renderDebounceMs)?g:fr.renderDebounceMs),L=o(()=>x.maxHeight&&"none"!==x.maxHeight?ie(x.maxHeight):null,[x.maxHeight]),D=o(()=>{var e;return null!=(e=ie(x.estimatedPreviewHeightPx))?e:le(N)},[N,x.estimatedPreviewHeightPx]),[$,P]=i(!1),[A,R]=i(!1),[F,I]=i(!1),[_,W]=i(!1),[O,j]=i(1),[z,K]=i({x:0,y:0}),[V,q]=i(!1),[U,X]=i(!1),[Z,Y]=i(!1),[G,J]=i(null),[Q,ee]=i(!1),[te,ne]=i(()=>`${ae(D,ce,L)}px`),[re,oe]=i("undefined"==typeof window),se=c(null),de=c(null),ue=c(null),me=c(null),he=c(null),fe=c(null),pe=c(null),ve=c(null),ye=c(0),we=c({}),xe=c(null),ke=c(""),be=c(!1),Ce=c(null),Me=c(!1),Be=c({zoom:1,translateX:0,translateY:0,containerHeight:te||"360px"}),Se=c(z);Se.current=z;const Te=c(O);Te.current=O;const Ee=c(Q);Ee.current=Q;const Le=Ae(),De=Boolean(null!=(y=null==(v=x.node)?void 0:v.loading)?y:x.loading),$e=x.isDark?"dark":"light",Pe=Boolean(x.isStrict),Re=!0===x.enableMermaidInteractions,Fe=o(()=>Pe?{startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,dompurifyConfig:dr,flowchart:{htmlLabels:!1}}:{startOnLoad:!1,securityLevel:"loose",suppressErrorRendering:!0},[Pe]);s(()=>{Me.current=Z},[Z]);const Ie=d(()=>{var e;const t=de.current,n=t?getComputedStyle(t).getPropertyValue("--ms-size-diagram-min-height").trim():"";return null!=(e=ie(n))?e:ce},[]),_e=d(()=>ae(D,Ie(),L),[D,L,Ie]);s(()=>{A||F||ne(e=>{const t=ie(e),n=_e();return null!=t&&t>=n?e:`${n}px`})},[F,_e,A]),s(()=>{we.current={}},[$e,N,Pe]),s(()=>{let e=!1;return(async()=>{const t=await async function(e){if(or)return cr(or,e),or;if(ar){const t=await ar;return t&&cr(t,e),t}if(ir)return null;try{ir=!0,ar=(async()=>{try{const t=await import("mermaid"),n=(null==t?void 0:t.default)||t;if(or=(null==n?void 0:n.default)?n.default:(null==n?void 0:n.mermaidAPI)?n:(null==n?void 0:n.mermaid)?n.mermaid:n,!or)throw new Error("Mermaid module did not export expected API");return cr(or,null!=e?e:{startOnLoad:!1,securityLevel:"strict",flowchart:{htmlLabels:!1}}),or}catch(t){return console.warn("[markstream-react] Failed to load mermaid:",t),null}finally{ar=null}})();const t=await ar;return t&&cr(t,e),t}catch{return null}}(Fe);e||(se.current=t,P(Boolean(t)),be.current||R(!t))})(),()=>{e=!0}},[Fe]),s(()=>{const e=de.current;if(!e)return;const t=Le(e,{rootMargin:"400px"});return Ce.current=t,t.isVisible()&&oe(!0),t.whenVisible.then(()=>oe(!0)),()=>{t.destroy(),Ce.current=null}},[Le]),s(()=>{if("undefined"==typeof document)return;if(!Q)return;const e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[Q]);const We=d(()=>L,[L]),Oe=d(e=>{const t=de.current,n=me.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=We(),d=null==s?c:Math.min(c,s),u=_e();ne(`${"none"===x.maxHeight?d:Math.max(d,u)}px`)},[x.maxHeight,_e,We]);s(()=>{if(!de.current||"undefined"==typeof ResizeObserver)return;if(A||F)return;const e=new ResizeObserver(e=>{if(!e.length)return;const t=e[0].contentRect.width;jn(()=>Oe(t))});return e.observe(de.current),()=>e.disconnect()},[F,A,Oe]),s(()=>{A||F||Oe()},[F,x.maxHeight,A,Oe]),s(()=>()=>{rr()},[]),u(()=>{var e;const t=we.current[$e];!A&&me.current&&(null==t?void 0:t.svg)&&(mr(me.current,t.svg)&&(xe.current=null!=(e=t.bindFunctions)?e:null,hr(me.current,t.bindFunctions,Re)),jn(()=>Oe()))},[Re,A,$e,Oe]);const je=d(async(e,t,n)=>{var r;if(!se.current||!me.current)return!1;X(!0);try{const o=`mermaid-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=yr(e,t),l=await br(()=>se.current.render(o,i),{timeoutMs:T,signal:n});if(!(null==l?void 0:l.svg))return!1;const a=mr(me.current,l.svg);return!!a&&(xe.current=null!=(r=l.bindFunctions)?r:null,hr(me.current,l.bindFunctions,Re),Oe(),we.current[t]={svg:a,bindFunctions:l.bindFunctions},Y(!0),J(null),!0)}catch(o){if(!De){if("function"==typeof x.onRenderError&&me.current&&!0===x.onRenderError(o,N,me.current))return!1;J(o instanceof Error?o.message:String(o))}return!1}finally{X(!1)}},[Re,T,De,Oe]),ze=d(async(e,t,n)=>{var r;if(se.current&&me.current){X(!0);try{const o=`mermaid-preview-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=yr(kr(e)||e,t),l=await br(()=>se.current.render(o,i),{timeoutMs:S,signal:n});if(null==l?void 0:l.svg){const e=mr(me.current,l.svg,{keepPreviousOnFailure:!0});e&&(xe.current=null!=(r=l.bindFunctions)?r:null,hr(me.current,l.bindFunctions,Re)),e&&Oe()}}catch{}finally{X(!1)}}},[Re,S,De,Oe]),Ke=d(async(e,t)=>{if(!e.trim())return ur(me.current),Y(!1),void(ke.current="");const n=e.replace(/\s+/g,"");if(n===ke.current&&Me.current)return;const r=++ye.current;if("gantt"===wr(e)){const i=kr(e);if(!i.trim())return;try{if(await vr(i,$e,{workerTimeout:M,parseTimeout:B,mermaid:se.current,signal:t}),(null==t?void 0:t.aborted)||ye.current!==r)return;i===e?await je(e,$e,t)&&(ke.current=n):await ze(i,$e,t)}catch(o){if("AbortError"===(null==o?void 0:o.name))return}return}try{if(await vr(e,$e,{workerTimeout:M,parseTimeout:B,mermaid:se.current,signal:t}),(null==t?void 0:t.aborted)||ye.current!==r)return;return void(await je(e,$e,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 nr(e,t,n.workerTimeout);if(r)return r}catch(o){if("AbortError"===(null==o?void 0:o.name))throw o}return kr(e)}(e,$e,{workerTimeout:M,signal:t});if(!n||(null==t?void 0:t.aborted)||ye.current!==r)return;await ze(n,$e,t)}catch{}},[B,je,ze,$e,M]),Ve=d(()=>re&&!A&&!F,[F,A,re]);s(()=>{if(!Ve())return;if(!se.current)return;const e=new AbortController,t=window.setTimeout(()=>{!e.signal.aborted&&Ve()&&Ke(N,e.signal)},E);return()=>{e.abort(),window.clearTimeout(t)}},[N,Ve,$,Ke,E]);const qe=d((e,t)=>{e.clientX,e.clientY,Ze(e.currentTarget,t,"top",!1,0,x.isDark)},[x.isDark]),Ue=d(async()=>{var e,t;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(N)),W(!0),null==(t=x.onCopy)||t.call(x,N),setTimeout(()=>W(!1),1e3)}catch{}},[N,x]),Xe=d(()=>{var e,t,n;const r=null!=(t=null==(e=me.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]),Ge=d(()=>{pe.current=null,ur(fe.current)},[]),Je=d(()=>{ee(!1),Ge()},[Ge]),Qe=d(()=>{var e,t,n;const r=null!=(t=null==(e=me.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||ee(!0)},[x]);s(()=>{if(!Q)return;if("undefined"==typeof window)return;const e=e=>{"Escape"===e.key&&Je()};try{window.addEventListener("keydown",e)}catch{}return()=>{try{window.removeEventListener("keydown",e)}catch{}}},[Je,Q]),sr(()=>{var e,t;if(!Q)return;const n=fe.current,r=de.current;if(!n||!r)return;const o=`translate(${z.x}px, ${z.y}px) scale(${O})`,i=r.cloneNode(!0);i.classList.add("fullscreen"),i.style.height="100%",i.style.maxHeight="100%";const l=i.querySelector("[data-mermaid-wrapper]");l&&(pe.current=l,l.style.transform=o),ur(n),n.appendChild(i),hr(n,null!=(t=xe.current)?t:null==(e=we.current[$e])?void 0:e.bindFunctions,Re)},[Re,Q,$e]),s(()=>{Q&&pe.current&&(pe.current.style.transform=`translate(${z.x}px, ${z.y}px) scale(${O})`)},[Q,z.x,z.y,O]);const et=A||U||F,tt=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]),nt=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){R(!1);const e=Be.current;j(e.zoom),K({x:e.translateX,y:e.translateY}),ne(e.containerHeight)}else Be.current={zoom:O,translateX:z.x,translateY:z.y,containerHeight:te},R(!0)},[N,te,Ke,x,$e,z.x,z.y,Oe,O]),rt=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=gr(O+i,.5,3);if(l===O)return;const a=l/O;K({x:z.x-r*(a-1),y:z.y-o*(a-1)}),j(l)},[z,O]);ve.current||(ve.current=ge({getTranslate:()=>Se.current,setTranslate:e=>K(e),canStart:e=>{var t;return!!(null==(t=me.current)?void 0:t.querySelector("svg"))&&("touch"!==e.pointerType||Ee.current||Te.current>1)},onActiveChange:e=>q(e)}));const ot=ve.current;s(()=>()=>ot.stop(),[ot]);const it=Q||O>1,lt=/* @__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:[
105
+ /* @__PURE__ */t("button",{type:"button",className:ht("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=>qe(e,k("common.zoomIn")),onMouseLeave:()=>Ye(),onClick:()=>j(gr(O+.1,.5,3)),children:"+"}),
106
+ /* @__PURE__ */t("button",{type:"button",className:ht("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=>qe(e,k("common.zoomOut")),onMouseLeave:()=>Ye(),onClick:()=>j(gr(O-.1,.5,3)),children:"−"}),
107
+ /* @__PURE__ */e("button",{type:"button",className:ht("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=>qe(e,k("common.resetZoom")),onMouseLeave:()=>Ye(),onClick:()=>{j(1),K({x:0,y:0})},children:[Math.round(100*O),"%"]})]})}),
108
+ /* @__PURE__ */e("div",{ref:de,className:ht("relative overflow-hidden block transition-[height] duration-150 ease-out",x.isDark?"bg-gray-900":"bg-gray-50"),style:{height:te,maxHeight:null!=(w=x.maxHeight)?w:void 0,minHeight:"var(--ms-size-diagram-min-height, 360px)",touchAction:it?"none":void 0},onWheel:rt,onPointerDown:e=>ot.start(e.nativeEvent),children:[
109
+ /* @__PURE__ */t("div",{ref:ue,"data-mermaid-wrapper":!0,className:ht("absolute inset-0 cursor-grab",{"cursor-grabbing":V}),style:{transform:`translate(${z.x}px, ${z.y}px) scale(${O})`},children:/* @__PURE__ */t("div",{ref:me,className:"_mermaid w-full text-center flex items-center justify-center min-h-full"})}),(U||De)&&/* @__PURE__ */e("div",{className:"mermaid-loading",children:[
110
110
  /* @__PURE__ */t("span",{className:"mermaid-spinner"}),
111
- /* @__PURE__ */t("span",{children:"Rendering diagram…"})]})]})]}),at=x.showHeader&&/* @__PURE__ */e("div",{className:ut("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:[
111
+ /* @__PURE__ */t("span",{children:"Rendering diagram…"})]})]})]}),at=x.showHeader&&/* @__PURE__ */e("div",{className:ht("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:[
112
112
  /* @__PURE__ */e("div",{className:"flex items-center space-x-2 overflow-hidden",children:[
113
113
  /* @__PURE__ */t("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:b}}),
114
- /* @__PURE__ */t("span",{className:ut("text-sm font-medium font-mono truncate",x.isDark?"text-gray-400":"text-gray-600"),children:"Mermaid"})]}),x.showModeToggle&&$&&/* @__PURE__ */e("div",{className:ut("flex items-center space-x-1 rounded-md p-0.5",x.isDark?"bg-gray-700":"bg-gray-100"),children:[
115
- /* @__PURE__ */t("button",{type:"button",className:ut("px-2.5 py-1 text-xs rounded transition-colors",A?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:()=>nt("preview"),onMouseEnter:e=>qe(e,k("common.preview")),onFocus:e=>qe(e,k("common.preview")),onMouseLeave:()=>Xe(),onBlur:()=>Xe(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
114
+ /* @__PURE__ */t("span",{className:ht("text-sm font-medium font-mono truncate",x.isDark?"text-gray-400":"text-gray-600"),children:"Mermaid"})]}),x.showModeToggle&&$&&/* @__PURE__ */e("div",{className:ht("flex items-center space-x-1 rounded-md p-0.5",x.isDark?"bg-gray-700":"bg-gray-100"),children:[
115
+ /* @__PURE__ */t("button",{type:"button",className:ht("px-2.5 py-1 text-xs rounded transition-colors",A?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:()=>nt("preview"),onMouseEnter:e=>qe(e,k("common.preview")),onFocus:e=>qe(e,k("common.preview")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
116
116
  /* @__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:[
117
117
  /* @__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"}),
118
118
  /* @__PURE__ */t("circle",{cx:"12",cy:"12",r:"3"})]})}),
119
119
  /* @__PURE__ */t("span",{children:k("common.preview")})]})}),
120
- /* @__PURE__ */t("button",{type:"button",className:ut("px-2.5 py-1 text-xs rounded transition-colors",A?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:()=>nt("source"),onMouseEnter:e=>qe(e,k("common.source")),onFocus:e=>qe(e,k("common.source")),onMouseLeave:()=>Xe(),onBlur:()=>Xe(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
120
+ /* @__PURE__ */t("button",{type:"button",className:ht("px-2.5 py-1 text-xs rounded transition-colors",A?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:()=>nt("source"),onMouseEnter:e=>qe(e,k("common.source")),onFocus:e=>qe(e,k("common.source")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
121
121
  /* @__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"})}),
122
122
  /* @__PURE__ */t("span",{children:k("common.source")})]})})]}),
123
- /* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[x.showCollapseButton&&/* @__PURE__ */t("button",{type:"button",className:tt,"aria-pressed":F,onClick:()=>I(e=>!e),onMouseEnter:e=>qe(e,k(F?"common.expand":"common.collapse")),onFocus:e=>qe(e,k(F?"common.expand":"common.collapse")),onMouseLeave:()=>Xe(),onBlur:()=>Xe(),children:/* @__PURE__ */t("svg",{style:{rotate:F?"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:tt,onClick:Ze,onMouseEnter:e=>qe(e,k(_?"common.copied":"common.copy")),onFocus:e=>qe(e,k(_?"common.copied":"common.copy")),onMouseLeave:()=>Xe(),onBlur:()=>Xe(),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:[
123
+ /* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[x.showCollapseButton&&/* @__PURE__ */t("button",{type:"button",className:tt,"aria-pressed":F,onClick:()=>I(e=>!e),onMouseEnter:e=>qe(e,k(F?"common.expand":"common.collapse")),onFocus:e=>qe(e,k(F?"common.expand":"common.collapse")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */t("svg",{style:{rotate:F?"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:tt,onClick:Ue,onMouseEnter:e=>qe(e,k(_?"common.copied":"common.copy")),onFocus:e=>qe(e,k(_?"common.copied":"common.copy")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),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:[
124
124
  /* @__PURE__ */t("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
125
- /* @__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&&$&&/* @__PURE__ */t("button",{type:"button",className:ut(tt,et?"opacity-50 cursor-not-allowed":""),disabled:et,onClick:Ye,onMouseEnter:e=>qe(e,k("common.export")),onFocus:e=>qe(e,k("common.export")),onMouseLeave:()=>Xe(),onBlur:()=>Xe(),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:[
125
+ /* @__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&&$&&/* @__PURE__ */t("button",{type:"button",className:ht(tt,et?"opacity-50 cursor-not-allowed":""),disabled:et,onClick:Xe,onMouseEnter:e=>qe(e,k("common.export")),onFocus:e=>qe(e,k("common.export")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),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:[
126
126
  /* @__PURE__ */t("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),
127
- /* @__PURE__ */t("path",{d:"m7 10l5 5l5-5"})]})})}),x.showFullscreenButton&&$&&/* @__PURE__ */t("button",{type:"button",className:ut(tt,et?"opacity-50 cursor-not-allowed":""),disabled:et,onClick:Q?Je:Qe,onMouseEnter:e=>qe(e,k(Q?"common.minimize":"common.open")),onFocus:e=>qe(e,k(Q?"common.minimize":"common.open")),onMouseLeave:()=>Xe(),onBlur:()=>Xe(),children:/* @__PURE__ */t("svg",Q?{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=/* @__PURE__ */e("div",{children:[A?/* @__PURE__ */t("div",{className:ut("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:N})}):lt,G&&/* @__PURE__ */t("div",{className:"mermaid-error",children:G})]});/* @__PURE__ */
127
+ /* @__PURE__ */t("path",{d:"m7 10l5 5l5-5"})]})})}),x.showFullscreenButton&&$&&/* @__PURE__ */t("button",{type:"button",className:ht(tt,et?"opacity-50 cursor-not-allowed":""),disabled:et,onClick:Q?Je:Qe,onMouseEnter:e=>qe(e,k(Q?"common.minimize":"common.open")),onFocus:e=>qe(e,k(Q?"common.minimize":"common.open")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */t("svg",Q?{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=/* @__PURE__ */e("div",{children:[A?/* @__PURE__ */t("div",{className:ht("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:N})}):lt,G&&/* @__PURE__ */t("div",{className:"mermaid-error",children:G})]});/* @__PURE__ */
128
128
  return e(n,{children:[
129
- /* @__PURE__ */e("div",{"data-markstream-mermaid":"1","data-markstream-mode":A?"source":Z?"preview":"pending",className:ut("my-4 rounded-lg border overflow-hidden shadow-sm mermaid-block",x.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":De}),children:[at,
130
- /* @__PURE__ */t("div",{ref:he,style:{display:F?"none":""},children:ct})]}),Q&&"undefined"!=typeof document&&Ce(
131
- /* @__PURE__ */t("div",{className:"markstream-react mermaid-modal-overlay",onClick:()=>Je(),children:/* @__PURE__ */e("div",{className:ut("mermaid-modal-panel",{"is-dark":x.isDark}),role:"dialog","aria-modal":"true",onClick:e=>e.stopPropagation(),children:[
129
+ /* @__PURE__ */e("div",{"data-markstream-mermaid":"1","data-markstream-mode":A?"source":Z?"preview":"pending",className:ht("my-4 rounded-lg border overflow-hidden shadow-sm mermaid-block",x.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":De}),children:[at,
130
+ /* @__PURE__ */t("div",{ref:he,style:{display:F?"none":""},children:ct})]}),Q&&"undefined"!=typeof document&&Ne(
131
+ /* @__PURE__ */t("div",{className:"markstream-react mermaid-modal-overlay",onClick:()=>Je(),children:/* @__PURE__ */e("div",{className:ht("mermaid-modal-panel",{"is-dark":x.isDark}),role:"dialog","aria-modal":"true",onClick:e=>e.stopPropagation(),children:[
132
132
  /* @__PURE__ */e("div",{className:"mermaid-modal-header",children:[
133
133
  /* @__PURE__ */t("span",{className:"mermaid-modal-title",children:`Mermaid ${k("common.preview")}`}),
134
134
  /* @__PURE__ */t("button",{type:"button",className:"mermaid-modal-close",onClick:Je,children:k("common.close")})]}),
135
- /* @__PURE__ */t("div",{className:"mermaid-modal-body",children:/* @__PURE__ */t("div",{ref:fe,className:"mermaid-modal-content"})})]})}),document.body)]})}function fr(e,t,n){return Math.min(Math.max(e,t),n)}async function pr(e,t,n){try{if(await Qn(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=gr(e,t),o=n.mermaid;if("function"==typeof o.parse)return await xr(()=>o.parse(r),{timeoutMs:n.parseTimeout,signal:n.signal}),!0;const i=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;return await xr(()=>o.render(i,r),{timeoutMs:n.parseTimeout,signal:n.signal}),!0}function gr(e,t){return e.trimStart().startsWith("%%{")?e:`%%{init: {"theme": "${"dark"===t?"dark":"default"}"}}%%\n${e}`}function vr(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 yr(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 wr(e){if("gantt"===vr(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(yr(e))break;n.pop()}else n.pop()}return n.some(yr)?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 xr(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 kr(e){return(new XMLSerializer).serializeToString(e)}function br(t){const{node:n}=t;/* @__PURE__ */
136
- 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 Nr(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 $(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 Mr(e){var o,i,l,a;const{node:c,ctx:s,renderNode:d,indexKey:u,children:m}=e;if(!s||!d)/* @__PURE__ */
135
+ /* @__PURE__ */t("div",{className:"mermaid-modal-body",children:/* @__PURE__ */t("div",{ref:fe,className:"mermaid-modal-content"})})]})}),document.body)]})}function gr(e,t,n){return Math.min(Math.max(e,t),n)}async function vr(e,t,n){try{if(await tr(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=yr(e,t),o=n.mermaid;if("function"==typeof o.parse)return await br(()=>o.parse(r),{timeoutMs:n.parseTimeout,signal:n.signal}),!0;const i=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;return await br(()=>o.render(i,r),{timeoutMs:n.parseTimeout,signal:n.signal}),!0}function yr(e,t){return ve(e,`%%{init: {"theme": "${"dark"===t?"dark":"default"}"}}%%\n`)}function wr(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 xr(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 kr(e){if("gantt"===wr(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(xr(e))break;n.pop()}else n.pop()}return n.some(xr)?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 br(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 Nr(t){const{node:n}=t;/* @__PURE__ */
136
+ return e("div",{className:"unknown-node text-sm text-gray-500 italic",children:["Unsupported node type:"," ",String(null==n?void 0:n.type)]})}function Mr(e){var t;return"text"===(null==e?void 0:e.type)&&""===String(null!=(t=null==e?void 0:e.content)?t:"").trim()}function Br(e,n,o,i){const l=e.filter(e=>!Mr(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=>!Mr(e)):[]}(e);return 1===n.length&&"image"===(null==(t=n[0])?void 0:t.type)}(e));if(!a||l.length<=1)return $(e,o,i,n);const c=[];for(let t=0;t<e.length;t++){const n=e[t];if(!Mr(n)){c.push(n);continue}const r=c.length>0,o=e.slice(t+1).some(e=>!Mr(e));r&&o&&c.push({...n,content:" ",raw:" "})}return c.map((e,l)=>{var c;return a&&Mr(e)?/* @__PURE__ */t(r.Fragment,{children:String(null!=(c=null==e?void 0:e.content)?c:"")},`${i}-${l}`):n(e,`${i}-${l}`,o)})}function Sr(e){var o,i,l,a;const{node:c,ctx:s,renderNode:d,indexKey:u,children:m}=e;if(!s||!d)/* @__PURE__ */
137
137
  return t("p",{dir:"auto",className:"paragraph-node",children:m});const h=null!=(o=c.children)?o:[],f={...null!=(i=s.customComponents)?i:V(s.customId),...null!=(l=s.htmlComponents)?l:{},...null!=(a=s.streamingComponents)?a:{}},p=[],g=[],v=()=>{if(!g.length)return;const e=p.length;p.push(
138
- /* @__PURE__ */t("p",{dir:"auto",className:"paragraph-node",children:Nr(g.slice(),d,s,`${String(null!=u?u:"paragraph")}-${e}`)},`${String(null!=u?u:"paragraph")}-inline-${e}`)),g.length=0};return h.forEach((e,n)=>{var o;const i="escape"!==(null!=(o=s.htmlPolicy)?o:"safe")||"html_inline"!==e.type&&"html_block"!==e.type;se.has(e.type)||i&&de(e,f,s.customHtmlTags)?(v(),p.push(
139
- /* @__PURE__ */t(r.Fragment,{children:d(e,`${String(null!=u?u:"paragraph")}-block-${n}`,s)},`${String(null!=u?u:"paragraph")}-block-${n}`))):g.push(e)}),v(),p.length?/* @__PURE__ */t(n,{children:p}):/* @__PURE__ */t("p",{dir:"auto",className:"paragraph-node",children:Nr(h,d,s,String(null!=u?u:"paragraph"))})}function Br(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__ */
140
- 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 Sr(e){/* @__PURE__ */
141
- return t("s",{className:"strikethrough-node",children:e.children})}function Tr(e){/* @__PURE__ */
142
- return t("strong",{className:"strong-node",children:e.children})}function Er(e){/* @__PURE__ */
143
- return t("sub",{className:"subscript-node",children:e.children})}function Lr(e){/* @__PURE__ */
144
- return t("sup",{className:"superscript-node",children:e.children})}function Dr(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),f=r.useRef(null),[p,g]=r.useState([]),v=e=>"right"===e?"text-right":"center"===e?"text-center":"text-left",y=()=>{const e=f.current;e&&(window.removeEventListener("pointermove",e.move),window.removeEventListener("pointerup",e.stop),window.removeEventListener("pointercancel",e.stop),f.current=null),h.current=null};return r.useEffect(()=>(y(),g([]),y),[s.length]),/* @__PURE__ */e("div",{className:"table-node-wrapper","data-index-key":c,children:[
145
- /* @__PURE__ */e("table",{ref:m,className:ut("my-8 text-sm table-node",d&&"table-node--loading"),"aria-busy":d,children:[p.length>0&&/* @__PURE__ */t("colgroup",{children:s.map((e,n)=>/* @__PURE__ */t("col",{style:p[n]>0?{width:`${p[n]}px`}:void 0},`col-${n}`))}),
146
- /* @__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:ut("font-semibold p-[calc(4/7*1em)]",v(n.align)),dir:"auto",children:[l&&a?j(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(),y(),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=()=>{y()};f.current={move:i,stop:l},window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l)})(r,e)})]},`header-${r}`))})}),
138
+ /* @__PURE__ */t("p",{dir:"auto",className:"paragraph-node",children:Br(g.slice(),d,s,`${String(null!=u?u:"paragraph")}-${e}`)},`${String(null!=u?u:"paragraph")}-inline-${e}`)),g.length=0};return h.forEach((e,n)=>{var o;const i="escape"!==(null!=(o=s.htmlPolicy)?o:"safe")||"html_inline"!==e.type&&"html_block"!==e.type;se.has(e.type)||i&&de(e,f,s.customHtmlTags)?(v(),p.push(
139
+ /* @__PURE__ */t(r.Fragment,{children:d(e,`${String(null!=u?u:"paragraph")}-block-${n}`,s)},`${String(null!=u?u:"paragraph")}-block-${n}`))):g.push(e)}),v(),p.length?/* @__PURE__ */t(n,{children:p}):/* @__PURE__ */t("p",{dir:"auto",className:"paragraph-node",children:Br(h,d,s,String(null!=u?u:"paragraph"))})}function Tr(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__ */
140
+ 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 Er(e){/* @__PURE__ */
141
+ return t("s",{className:"strikethrough-node",children:e.children})}function Lr(e){/* @__PURE__ */
142
+ return t("strong",{className:"strong-node",children:e.children})}function Dr(e){/* @__PURE__ */
143
+ return t("sub",{className:"subscript-node",children:e.children})}function $r(e){/* @__PURE__ */
144
+ return t("sup",{className:"superscript-node",children:e.children})}function Pr(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),f=r.useRef(null),[p,g]=r.useState([]),v=e=>"right"===e?"text-right":"center"===e?"text-center":"text-left",y=()=>{const e=f.current;e&&(window.removeEventListener("pointermove",e.move),window.removeEventListener("pointerup",e.stop),window.removeEventListener("pointercancel",e.stop),f.current=null),h.current=null};return r.useEffect(()=>(y(),g([]),y),[s.length]),/* @__PURE__ */e("div",{className:"table-node-wrapper","data-index-key":c,children:[
145
+ /* @__PURE__ */e("table",{ref:m,className:ht("my-8 text-sm table-node",d&&"table-node--loading"),"aria-busy":d,children:[p.length>0&&/* @__PURE__ */t("colgroup",{children:s.map((e,n)=>/* @__PURE__ */t("col",{style:p[n]>0?{width:`${p[n]}px`}:void 0},`col-${n}`))}),
146
+ /* @__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:ht("font-semibold p-[calc(4/7*1em)]",v(n.align)),dir:"auto",children:[l&&a?j(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(),y(),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=()=>{y()};f.current={move:i,stop:l},window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l)})(r,e)})]},`header-${r}`))})}),
147
147
  /* @__PURE__ */t("tbody",{children:u.map((e,n)=>{var r;/* @__PURE__ */
148
- return t("tr",{className:ut("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:ut("p-[calc(4/7*1em)]",v(e.align)),dir:"auto",children:l&&a?j(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:[
148
+ return t("tr",{className:ht("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:ht("p-[calc(4/7*1em)]",v(e.align)),dir:"auto",children:l&&a?j(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:[
149
149
  /* @__PURE__ */t("span",{className:"table-node__spinner","aria-hidden":"true"}),
150
- /* @__PURE__ */t("span",{className:"sr-only",children:"Loading"})]})]})}function $r(){/* @__PURE__ */
151
- return t("hr",{className:"hr-node thematic-break"})}function Pr(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)?q(n.attrs):n.attrs},[n.attrs]);/* @__PURE__ */
152
- 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 Ar(e,t,n,o,i={}){var l,a,c,s,d;const u=me(o.codeBlockProps),m=o.events.onHandleArtifactClick?e=>{var r,i;const l="image/svg+xml"===e.type?"image/svg+xml":"text/html";null==(i=(r=o.events).onHandleArtifactClick)||i.call(r,{node:null==e.content?t:{...t,code:e.content},artifactType:l,artifactTitle:e.title||("image/svg+xml"===l?"SVG Preview":"HTML Preview"),id:String(n)})}:void 0;return r.createElement(e,{key:n,node:t,loading:Boolean(t.loading),stream:o.codeBlockStream,customId:o.customId,isDark:o.isDark,darkTheme:null==(l=o.codeBlockThemes)?void 0:l.darkTheme,lightTheme:null==(a=o.codeBlockThemes)?void 0:a.lightTheme,themes:null==(c=o.codeBlockThemes)?void 0:c.themes,minWidth:null==(s=o.codeBlockThemes)?void 0:s.minWidth,maxWidth:null==(d=o.codeBlockThemes)?void 0:d.maxWidth,onCopy:o.events.onCopy,onPreviewCode:m,...u,codeBlockOptions:o.codeBlockOptions,...i,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade})}function Rr(e,t,n,o,i={}){return r.createElement(e,{key:n,node:t,isDark:o.isDark,...i})}function Fr(e,n,o){var i,l,a,c,s,d,u,m,v,y,w;const x=null!=(i=o.customComponents)?i:V(o.customId),k=null!=(l=o.streamingComponents)?l:{},b=null!=(a=o.htmlComponents)?a:{},C=function(e){if("html_block"===e.type||"html_inline"===e.type)return"";const t=f(e.type),n=f(e.tag);return t&&n&&t===n?t:""}(e),N=C?k[C]:null,M=C&&!N?b[C]:null,E="code_block"===e.type?null:x[e.type];if(N)return r.createElement(N,{key:n,node:e,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade});if(M)return function(e,t,n,o,i){var l,a,c;const s=h(null!=(l=t.attrs)?l:void 0,null!=(a=o.htmlPolicy)?a:"safe",i),d=p(g(s)),u=Array.isArray(t.children)?$(t.children,o,`${String(n)}-html`,Fr):null!=(c=t.content)?c:null;return r.createElement(e,{...d,key:n},u)}(M,e,n,o,C);if(E)return r.createElement(E,{key:n,node:e,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade});if("html_block"===e.type||"html_inline"===e.type){const i={...x,...k},l=ue(e,i,o.customHtmlTags),a=String(null!=(c=e.tag)?c:"").trim().toLowerCase()||B(e.content),h=null!=(s=null==l?void 0:l.tag)?s:a;if(h){const i=null!=(d=null==l?void 0:l.component)?d:x[h],a=null!=(m=null==l?void 0:l.isWhitelisted)?m:(null!=(u=o.customHtmlTags)?u:[]).some(e=>e.toLowerCase()===h);if(a&&i){const t={...e,type:h,tag:h,content:S(e.content,h)};return r.createElement(i,{key:n,node:t,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade})}const c=String(null!=(y=null!=(v=e.content)?v:e.raw)?y:"");if(!a&&T(c,h))return"html_inline"===e.type?/* @__PURE__ */t(dn,{node:{type:"text",content:c,raw:c},ctx:o,indexKey:n,typewriter:o.typewriter,fade:o.fade},n):/* @__PURE__ */t(Mr,{node:{type:"paragraph",children:[{type:"text",content:c,raw:c}],raw:c},ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n)}}switch(e.type){case"text":/* @__PURE__ */
153
- return t(dn,{node:e,ctx:o,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"text_special":/* @__PURE__ */
154
- return t(dn,{node:{type:"text",content:null!=(w=e.content)?w:"",center:e.center},ctx:o,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"paragraph":/* @__PURE__ */
155
- return t(Mr,{node:e,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"heading":/* @__PURE__ */
156
- return t(Ft,{node:e,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"blockquote":/* @__PURE__ */
157
- return t(Kr,{node:e,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"list":/* @__PURE__ */
158
- return t(hn,{node:e,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"list_item":/* @__PURE__ */
159
- return t(mn,{node:e,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"table":/* @__PURE__ */
160
- return t(Dr,{node:e,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"definition_list":/* @__PURE__ */
161
- return t(St,{node:e,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"footnote":/* @__PURE__ */
162
- return t(Pt,{node:e,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"footnote_reference":/* @__PURE__ */
163
- return t(At,{node:e},n);case"footnote_anchor":/* @__PURE__ */
164
- return t($t,{node:e},n);case"admonition":/* @__PURE__ */
165
- return t(Me,{node:e,ctx:o,renderNode:Fr,indexKey:n,isDark:o.isDark,typewriter:o.typewriter,fade:o.fade},n);case"hardbreak":/* @__PURE__ */
166
- return t(Rt,{node:e,typewriter:o.typewriter,fade:o.fade},n);case"link":/* @__PURE__ */
167
- return t(un,{node:e,ctx:o,renderNode:Fr,indexKey:n,isDark:o.isDark,showTooltip:"boolean"==typeof o.showTooltips?o.showTooltips:void 0,typewriter:o.typewriter,fade:o.fade},n);case"image":/* @__PURE__ */
168
- return t(Jt,{node:e},n);case"inline_code":/* @__PURE__ */
169
- return t(ln,{node:e,ctx:o,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"code_block":return function(e,n,r,o){var i,l,a,c,s,d,u,m;const h=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),f=P(h),p=function(e,t){const n=t.trim().toLowerCase();if(!n)return null;for(const r of[n,P(n),ve(n)]){const t=r&&e[r];if(t)return t}return null}(o,h);if("mermaid"===f){const i=function(e,t){var n,r;const o={...t.mermaidProps||{}};return null==ie(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=ae(le(String(null!=(n=null==e?void 0:e.code)?n:"")),void 0,"none"===o.maxHeight?null:null!=(r=ie(o.maxHeight))?r:void 0)),o}(e,r),l=p||o.mermaid;if(l)return Rr(l,e,n,r,i);if(!r.renderCodeBlocksAsPre)/* @__PURE__ */
170
- return t(hr,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...i},n)}if("infographic"===f){const i=function(e,t){var n,r;const o={...t.infographicProps||{}};return null==ee(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=ne(te(String(null!=(n=null==e?void 0:e.code)?n:"")),void 0,"none"===o.maxHeight?null:null!=(r=ee(o.maxHeight))?r:void 0)),o}(e,r),l=p||o.infographic;return l?Rr(l,e,n,r,i):/* @__PURE__ */t(rn,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...i},n)}if("d2"===f||"d2lang"===f){const i=p||o.d2;return i?Rr(i,e,n,r,r.d2Props||{}):/* @__PURE__ */t(Bt,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...r.d2Props||{}},n)}if(p)return Ar(p,e,n,r);const g=o.code_block;if(g)return Ar(g,e,n,r);if(r.renderCodeBlocksAsPre||"mermaid"===f){const o=null==(i=r.codeBlockProps)?void 0:i.showLineNumbers,c=null==(l=r.codeBlockOptions)?void 0:l.disableLineNumbers,s=null==(a=r.codeBlockOptions)?void 0:a.overflow;/* @__PURE__ */
150
+ /* @__PURE__ */t("span",{className:"sr-only",children:"Loading"})]})]})}function Ar(){/* @__PURE__ */
151
+ return t("hr",{className:"hr-node thematic-break"})}function Rr(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)?q(n.attrs):n.attrs},[n.attrs]);/* @__PURE__ */
152
+ 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 Fr(e,t,n,o,i={}){var l,a,c,s,d;const u=me(o.codeBlockProps),m=o.events.onHandleArtifactClick?e=>{var r,i;const l="image/svg+xml"===e.type?"image/svg+xml":"text/html";null==(i=(r=o.events).onHandleArtifactClick)||i.call(r,{node:null==e.content?t:{...t,code:e.content},artifactType:l,artifactTitle:e.title||("image/svg+xml"===l?"SVG Preview":"HTML Preview"),id:String(n)})}:void 0;return r.createElement(e,{key:n,node:t,loading:Boolean(t.loading),stream:o.codeBlockStream,customId:o.customId,isDark:o.isDark,darkTheme:null==(l=o.codeBlockThemes)?void 0:l.darkTheme,lightTheme:null==(a=o.codeBlockThemes)?void 0:a.lightTheme,themes:null==(c=o.codeBlockThemes)?void 0:c.themes,minWidth:null==(s=o.codeBlockThemes)?void 0:s.minWidth,maxWidth:null==(d=o.codeBlockThemes)?void 0:d.maxWidth,onCopy:o.events.onCopy,onPreviewCode:m,...u,codeBlockOptions:o.codeBlockOptions,...i,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade})}function Ir(e,t,n,o,i={}){return r.createElement(e,{key:n,node:t,isDark:o.isDark,...i})}function _r(e,n,o){var i,l,a,c,s,d,u,m,v,y,w;const x=null!=(i=o.customComponents)?i:V(o.customId),k=null!=(l=o.streamingComponents)?l:{},b=null!=(a=o.htmlComponents)?a:{},C=function(e){if("html_block"===e.type||"html_inline"===e.type)return"";const t=f(e.type),n=f(e.tag);return t&&n&&t===n?t:""}(e),N=C?k[C]:null,M=C&&!N?b[C]:null,E="code_block"===e.type?null:x[e.type];if(N)return r.createElement(N,{key:n,node:e,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade});if(M)return function(e,t,n,o,i){var l,a,c;const s=h(null!=(l=t.attrs)?l:void 0,null!=(a=o.htmlPolicy)?a:"safe",i),d=p(g(s)),u=Array.isArray(t.children)?$(t.children,o,`${String(n)}-html`,_r):null!=(c=t.content)?c:null;return r.createElement(e,{...d,key:n},u)}(M,e,n,o,C);if(E)return r.createElement(E,{key:n,node:e,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade});if("html_block"===e.type||"html_inline"===e.type){const i={...x,...k},l=ue(e,i,o.customHtmlTags),a=String(null!=(c=e.tag)?c:"").trim().toLowerCase()||B(e.content),h=null!=(s=null==l?void 0:l.tag)?s:a;if(h){const i=null!=(d=null==l?void 0:l.component)?d:x[h],a=null!=(m=null==l?void 0:l.isWhitelisted)?m:(null!=(u=o.customHtmlTags)?u:[]).some(e=>e.toLowerCase()===h);if(a&&i){const t={...e,type:h,tag:h,content:S(e.content,h)};return r.createElement(i,{key:n,node:t,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade})}const c=String(null!=(y=null!=(v=e.content)?v:e.raw)?y:"");if(!a&&T(c,h))return"html_inline"===e.type?/* @__PURE__ */t(mn,{node:{type:"text",content:c,raw:c},ctx:o,indexKey:n,typewriter:o.typewriter,fade:o.fade},n):/* @__PURE__ */t(Sr,{node:{type:"paragraph",children:[{type:"text",content:c,raw:c}],raw:c},ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade},n)}}switch(e.type){case"text":/* @__PURE__ */
153
+ return t(mn,{node:e,ctx:o,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"text_special":/* @__PURE__ */
154
+ return t(mn,{node:{type:"text",content:null!=(w=e.content)?w:"",center:e.center},ctx:o,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"paragraph":/* @__PURE__ */
155
+ return t(Sr,{node:e,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"heading":/* @__PURE__ */
156
+ return t(_t,{node:e,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"blockquote":/* @__PURE__ */
157
+ return t(qr,{node:e,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"list":/* @__PURE__ */
158
+ return t(pn,{node:e,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"list_item":/* @__PURE__ */
159
+ return t(fn,{node:e,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"table":/* @__PURE__ */
160
+ return t(Pr,{node:e,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"definition_list":/* @__PURE__ */
161
+ return t(Et,{node:e,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"footnote":/* @__PURE__ */
162
+ return t(Rt,{node:e,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"footnote_reference":/* @__PURE__ */
163
+ return t(Ft,{node:e},n);case"footnote_anchor":/* @__PURE__ */
164
+ return t(At,{node:e},n);case"admonition":/* @__PURE__ */
165
+ return t(Be,{node:e,ctx:o,renderNode:_r,indexKey:n,isDark:o.isDark,typewriter:o.typewriter,fade:o.fade},n);case"hardbreak":/* @__PURE__ */
166
+ return t(It,{node:e,typewriter:o.typewriter,fade:o.fade},n);case"link":/* @__PURE__ */
167
+ return t(hn,{node:e,ctx:o,renderNode:_r,indexKey:n,isDark:o.isDark,showTooltip:"boolean"==typeof o.showTooltips?o.showTooltips:void 0,typewriter:o.typewriter,fade:o.fade},n);case"image":/* @__PURE__ */
168
+ return t(en,{node:e},n);case"inline_code":/* @__PURE__ */
169
+ return t(cn,{node:e,ctx:o,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"code_block":return function(e,n,r,o){var i,l,a,c,s,d,u,m;const h=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),f=P(h),p=function(e,t){const n=t.trim().toLowerCase();if(!n)return null;for(const r of[n,P(n),ye(n)]){const t=r&&e[r];if(t)return t}return null}(o,h);if("mermaid"===f){const i=function(e,t){var n,r;const o={...t.mermaidProps||{}};return null==ie(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=ae(le(String(null!=(n=null==e?void 0:e.code)?n:"")),void 0,"none"===o.maxHeight?null:null!=(r=ie(o.maxHeight))?r:void 0)),o}(e,r),l=p||o.mermaid;if(l)return Ir(l,e,n,r,i);if(!r.renderCodeBlocksAsPre)/* @__PURE__ */
170
+ return t(pr,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...i},n)}if("infographic"===f){const i=function(e,t){var n,r;const o={...t.infographicProps||{}};return null==ee(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=ne(te(String(null!=(n=null==e?void 0:e.code)?n:"")),void 0,"none"===o.maxHeight?null:null!=(r=ee(o.maxHeight))?r:void 0)),o}(e,r),l=p||o.infographic;return l?Ir(l,e,n,r,i):/* @__PURE__ */t(ln,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...i},n)}if("d2"===f||"d2lang"===f){const i=p||o.d2;return i?Ir(i,e,n,r,r.d2Props||{}):/* @__PURE__ */t(Tt,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...r.d2Props||{}},n)}if(p)return Fr(p,e,n,r);const g=o.code_block;if(g)return Fr(g,e,n,r);if(r.renderCodeBlocksAsPre||"mermaid"===f){const o=null==(i=r.codeBlockProps)?void 0:i.showLineNumbers,c=null==(l=r.codeBlockOptions)?void 0:l.disableLineNumbers,s=null==(a=r.codeBlockOptions)?void 0:a.overflow;/* @__PURE__ */
171
171
  return t(O,{node:e,style:s?{whiteSpace:"scroll"===s?"pre":"pre-wrap"}:void 0,showLineNumbers:"boolean"==typeof o?o:"boolean"==typeof c&&!c},n)}/* @__PURE__ */
172
- return t(st,{node:e,loading:Boolean(e.loading),stream:r.codeBlockStream,themes:null==(c=r.codeBlockThemes)?void 0:c.themes,darkTheme:null==(s=r.codeBlockThemes)?void 0:s.darkTheme,lightTheme:null==(d=r.codeBlockThemes)?void 0:d.lightTheme,minWidth:null==(u=r.codeBlockThemes)?void 0:u.minWidth,maxWidth:null==(m=r.codeBlockThemes)?void 0:m.maxWidth,isDark:r.isDark,onCopy:r.events.onCopy,...me(r.codeBlockProps),codeBlockOptions:r.codeBlockOptions},n)}(e,n,o,x);case"strong":/* @__PURE__ */
173
- return t(Tr,{node:e,children:$(e.children,o,`${String(n)}-strong`,Fr)},n);case"emphasis":/* @__PURE__ */
174
- return t(Et,{node:e,children:$(e.children,o,`${String(n)}-em`,Fr)},n);case"strikethrough":/* @__PURE__ */
175
- return t(Sr,{node:e,children:$(e.children,o,`${String(n)}-strike`,Fr)},n);case"highlight":/* @__PURE__ */
176
- return t(It,{node:e,children:$(e.children,o,`${String(n)}-highlight`,Fr)},n);case"insert":/* @__PURE__ */
177
- return t(an,{node:e,children:$(e.children,o,`${String(n)}-insert`,Fr)},n);case"subscript":/* @__PURE__ */
178
- return t(Er,{node:e,children:$(e.children,o,`${String(n)}-sub`,Fr)},n);case"superscript":/* @__PURE__ */
179
- return t(Lr,{node:e,children:$(e.children,o,`${String(n)}-sup`,Fr)},n);case"checkbox":case"checkbox_input":/* @__PURE__ */
180
- return t(Re,{node:e,typewriter:o.typewriter,fade:o.fade},n);case"emoji":/* @__PURE__ */
181
- return t(Tt,{node:e,typewriter:o.typewriter,fade:o.fade},n);case"thematic_break":/* @__PURE__ */
182
- return t($r,{},n);case"math_inline":/* @__PURE__ */
183
- return t(Hn,{node:e},n);case"math_block":/* @__PURE__ */
184
- return t(_n,{node:e},n);case"reference":/* @__PURE__ */
185
- return t(Br,{node:e,ctx:o,typewriter:o.typewriter,fade:o.fade},n);case"html_block":case"html_inline":return"html_block"===e.type?/* @__PURE__ */t(_t,{node:e,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade,customId:o.customId},n):/* @__PURE__ */t(Zt,{node:e,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade,customId:o.customId},n);case"vmr_container":/* @__PURE__ */
186
- return t(Pr,{node:e,ctx:o,renderNode:Fr,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"label_open":case"label_close":return null;default:/* @__PURE__ */
187
- return t(br,{node:e},n)}}const Ir={codeBlockStream:!0,typewriter:!1,fade:!0,smoothStreaming:"auto",batchRendering:!0,initialRenderBatchSize:40,renderBatchSize:80,renderBatchDelay:16,renderBatchBudgetMs:6,renderBatchIdleTimeoutMs:120,deferNodesUntilVisible:!0,maxLiveNodes:320,liveNodeBuffer:60},_r=L();function Hr(e,t){return e.type===t.type&&e.raw===t.raw&&e.loading===t.loading&&e.autoClosed===t.autoClosed&&!!function(e,t){if(e===t)return!0;if(!e||!t||"object"!=typeof e||"object"!=typeof t)return!1;const n=e,r=t;return n.startLine===r.startLine&&n.endLine===r.endLine}(e.sourceMap,t.sourceMap)&&("code_block"!==e.type&&"code_block"!==t.type||e.diff===t.diff)}function Wr(e){const t=o(()=>fe(e),[e]),n=c(t);return function(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])}(n.current,t)||(n.current=t),n.current}const Or=r.memo(({node:e,nodeKey:t,renderCtx:n})=>Fr(e,t,n),(e,t)=>e.node===t.node&&e.renderCtx===t.renderCtx&&e.nodeKey===t.nodeKey),jr=r.memo(({props:n,parsedNodes:r,renderCtx:l,indexPrefix:a,containerRef:u,showTypewriterCursor:m,typewriterCursorRef:h})=>{var f,p,g,v,y,w,x;const k=Pe(),b="undefined"!=typeof window,C="undefined"!=typeof window&&"function"==typeof window.requestIdleCallback,N=Math.max(0,Math.trunc(null!=(f=n.renderBatchSize)?f:80)),M=Math.max(0,Math.trunc(null!=(p=n.initialRenderBatchSize)?p:N||r.length)),B=!1!==n.batchRendering&&N>0&&b,S=Math.max(0,null!=(g=n.liveNodeBuffer)?g:60),T=Math.max(1,null!=(v=n.maxLiveNodes)?v:320),E=(null!=(y=n.maxLiveNodes)?y:0)>0&&r.length>T,L=!1!==n.viewportPriority,D=B&&(null!=(w=n.maxLiveNodes)?w:0)<=0,$=o(()=>{var e;return!1!==n.deferNodesUntilVisible&&!((null!=(e=n.maxLiveNodes)?e:0)<=0)&&!E&&!(r.length>900)&&L},[r.length,n.deferNodesUntilVisible,n.maxLiveNodes,L,E]),[P,A]=i(()=>D?Math.min(r.length,M):r.length),R=c(P);s(()=>{R.current=P},[P]);const F=D?P:r.length,[I,_]=i(0),[H,W]=i({start:0,end:r.length}),O=c(/* @__PURE__ */new Map),[j,z]=i(0),K=c({}),V=c(/* @__PURE__ */new Map),q=c(/* @__PURE__ */new Map),U=c(/* @__PURE__ */new Map),X=c(/* @__PURE__ */new Map),Z=c(/* @__PURE__ */new Set),Y=c(P),G=c(null),J=c(null),Q=c(null),ee=c(!1),te=c(null),ne=c(Math.max(1,N||1)),re=c(r.length),oe=c({key:n.indexKey,total:r.length}),ie=c(r),le=c({batchSize:N,initial:M,delay:null!=(x=n.renderBatchDelay)?x:16,enabled:D}),ae=$||E,ce=o(()=>{const e=O.current;if(!e.size)return 32;let t=0;for(const n of e.values())t+=n;return Math.max(16,t/e.size)},[j]),se=o(()=>{if(!E)return r.map((e,t)=>({node:e,index:t}));const e=r.length,t=Math.max(0,Math.min(H.start,e)),n=Math.max(t,Math.min(H.end,e));return r.slice(t,n).map((e,n)=>({node:e,index:t+n}))},[r,H,E]),de=o(()=>{if(!E)return r.length;const e=Math.max(H.end+S,M),t=Math.min(r.length,e);return Math.max(P,t)},[r.length,E,H.end,S,M,P]);re.current=de;const ue=d((e,t)=>{var n;if(e>=t)return 0;const r=O.current;let o=0;for(let i=e;i<t;i++)o+=null!=(n=r.get(i))?n:ce;return o},[ce]),me=E?ue(0,Math.min(H.start,r.length)):0,he=E?ue(Math.min(H.end,r.length),r.length):0,fe=d(()=>{null!=G.current&&"function"==typeof cancelAnimationFrame&&(cancelAnimationFrame(G.current),G.current=null),null!=J.current&&(window.clearTimeout(J.current),J.current=null),null!=Q.current&&"function"==typeof window.cancelIdleCallback&&(window.cancelIdleCallback(Q.current),Q.current=null),ee.current=!1,te.current=null},[]),pe=d(e=>{var t;if(!D)return;const r=Math.max(2,null!=(t=n.renderBatchBudgetMs)?t:6),o=Math.max(1,N||1),i=Math.max(1,Math.floor(o/4));e>1.2*r?ne.current=Math.max(i,Math.floor(.7*ne.current)):e<.5*r&&ne.current<o&&(ne.current=Math.min(o,Math.ceil(1.2*ne.current)))},[D,n.renderBatchBudgetMs,N]),ge=d((e,t={})=>{var r,o;if(!D)return;const i=re.current;if(R.current>=i)return;const l=Math.max(1,e),a=e=>{const t="undefined"!=typeof performance?performance.now():Date.now();A(t=>{const n=Math.min(re.current,t+Math.max(1,e));return R.current=n,n});const n="undefined"!=typeof performance?performance.now():Date.now();pe(n-t)},c=()=>{const e=Math.max(1,Math.round(ne.current));ge(e)},s=e=>{var t;G.current=null,J.current=null,Q.current=null,ee.current=!1;const r=te.current;if(te.current=null,a(null!=r?r:l),R.current>=re.current)return;if(!e)return void c();const o=Math.max(2,null!=(t=n.renderBatchBudgetMs)?t:6);for(;R.current<re.current&&!(("function"==typeof e.timeRemaining?e.timeRemaining():0)<=.5*o);)a(Math.max(1,Math.round(ne.current)));R.current<re.current&&c()};if(!b||t.immediate)return void s();const d=Math.max(0,null!=(r=n.renderBatchDelay)?r:16);if(te.current=null!=te.current?Math.max(te.current,l):l,!ee.current){if(ee.current=!0,C){const e=Math.max(0,null!=(o=n.renderBatchIdleTimeoutMs)?o:120);return void(Q.current=window.requestIdleCallback(e=>s(e),{timeout:e}))}"function"==typeof requestAnimationFrame?G.current=requestAnimationFrame(()=>{0!==d?J.current=window.setTimeout(()=>s(),d):s()}):J.current=window.setTimeout(()=>s(),d)}},[pe,C,D,b,n.renderBatchDelay,n.renderBatchBudgetMs,n.renderBatchIdleTimeoutMs]);s(()=>{var e;const t=n.indexKey,o=r.length,i=oe.current,l=void 0!==t?t!==i.key:o!==i.total,a=ie.current,c=Math.min(a.length,r.length);let s=0;for(;s<c&&a[s]===r[s];)s+=1;oe.current={key:t,total:o};const d=le.current,u=null!=(e=n.renderBatchDelay)?e:16,m=d.batchSize!==N||d.initial!==M||d.delay!==u||d.enabled!==D;if(le.current={batchSize:N,initial:M,delay:u,enabled:D},(l||m||!D)&&fe(),(l||m)&&(ne.current=Math.max(1,N||1)),t!==i.key)Z.current.clear();else if(l)for(const n of Z.current)n>=s&&Z.current.delete(n);if(!o)return R.current=0,void A(0);const h=re.current;if(!D)return R.current=h,void A(h);if(l||m){const e=Math.min(h,M);return R.current=e,A(e),void(e<h&&ge(Math.max(1,M),{immediate:!b}))}const f=Math.min(R.current,h);f!==R.current&&(R.current=f,A(f)),R.current<h&&ge(Math.max(1,N||1))},[fe,D,b,r.length,n.indexKey,n.renderBatchDelay,N,M,ge]),s(()=>{ie.current=r},[r]),s(()=>{if(!E)return void W({start:0,end:r.length});const e=r.length;if(!e)return void W({start:0,end:0});const t=Math.max(0,Math.min(I,e-1));let n=Math.max(0,t-S),o=Math.min(e,t+S+1);const i=o-n;if(i>T){const e=i-T;n+=Math.ceil(e/2),o-=Math.floor(e/2)}else if(i<T){const t=T-i;n=Math.max(0,n-Math.ceil(t/2)),o=Math.min(e,o+Math.floor(t/2))}W({start:n,end:o})},[I,S,T,r.length,E]),s(()=>()=>{fe();for(const e of V.current.values())e.destroy();V.current.clear()},[fe]);const ve=d(e=>{for(const[t,n]of V.current.entries())t>=e&&(n.destroy(),V.current.delete(t),delete K.current[t],q.current.delete(t),U.current.delete(t),X.current.delete(t))},[]);s(()=>{ve(F)},[ve,F]),s(()=>{const e=r.length;let t=!1;for(const n of Array.from(O.current.keys()))n>=e&&(O.current.delete(n),t=!0);t&&z(e=>e+1);for(const n of Object.keys(K.current))Number(n)>=e&&delete K.current[n];for(const n of Array.from(Z.current))n>=e&&Z.current.delete(n)},[r.length]);const ye=d((e,t)=>{$&&t&&(K.current[e]=!0),t&&E&&_(t=>e>t?e:t)},[$,E]),we=d(e=>{const t=V.current.get(e);t&&(t.destroy(),V.current.delete(e))},[]),xe=d((e,t)=>{const n=q.current;if(t?n.set(e,t):n.delete(e),!ae||!t)return we(e),$&&!t&&delete K.current[e],void(t&&ye(e,!0));if(e<M&&!E)return we(e),void ye(e,!0);we(e);const r=k(t,{rootMargin:"400px"});V.current.set(e,r),r.isVisible()&&ye(e,!0),r.whenVisible.then(()=>ye(e,!0)).catch(()=>{})},[$,we,ye,k,M,ae,E]),ke=d(e=>{const t=U.current.get(e);if(t)return t;const n=t=>xe(e,t);return U.current.set(e,n),n},[xe]),be=d((e,t)=>{if(!t)return void(O.current.has(e)&&(O.current.delete(e),z(e=>e+1)));const n=()=>{const n=t.offsetHeight;n&&O.current.get(e)!==n&&(O.current.set(e,n),z(e=>e+1))};"function"==typeof queueMicrotask?queueMicrotask(n):Promise.resolve().then(n)},[]),Ce=d(e=>{const t=X.current.get(e);if(t)return t;const n=t=>be(e,t);return X.current.set(e,n),n},[be]),Ne=d(e=>!(D&&e>=R.current)&&(!$||e<M||!0===K.current[e]),[$,D,M]),Me=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 q.current.entries())t&&xe(e,t)},[xe]),s(()=>{E&&P>Y.current&&_(P-1),Y.current=P},[P,E]);const Be=E?/* @__PURE__ */t("div",{className:"node-spacer",style:{height:`${me}px`},"aria-hidden":"true"}):null,Se=E?/* @__PURE__ */t("div",{className:"node-spacer",style:{height:`${he}px`},"aria-hidden":"true"}):null;/* @__PURE__ */
188
- return e("div",{ref:u,className:`markstream-react markdown-renderer${n.isDark?" dark":""}${E?" virtualized":""}`,"data-custom-id":n.customId,onClick:n.onClick,onMouseOver:Me(n.onMouseOver),onMouseOut:Me(n.onMouseOut),children:[Be,se.map(({node:e,index:r})=>{var o;const i=Ne(r),c=null!=(o=O.current.get(r))?o:ce,s=!1!==n.fade&&"code_block"!==e.type&&!Z.current.has(r)&&i;return s&&Z.current.add(r),/* @__PURE__ */t("div",{ref:ke(r),className:"node-slot","data-node-index":r,"data-node-type":e.type,children:/* @__PURE__ */t("div",i?{ref:Ce(r),className:"node-content"+(s?" fade-node typewriter-node":""),children:/* @__PURE__ */t(Or,{node:e,nodeKey:`${a}-${r}`,renderCtx:l})}:{className:"node-placeholder",style:{height:`${c}px`}})},`${a}-${r}`)}),Se,m&&/* @__PURE__ */t("span",{ref:h,className:"typewriter-cursor","aria-hidden":"true"})]})},function(e,t){if(e.renderCtx!==t.renderCtx)return!1;if(e.indexPrefix!==t.indexPrefix)return!1;if(e.containerRef!==t.containerRef)return!1;if(e.showTypewriterCursor!==t.showTypewriterCursor)return!1;const n=e.parsedNodes,r=t.parsedNodes;if(n===r)return!0;if(n.length!==r.length)return!1;for(let l=0;l<n.length;l++)if(n[l]!==r[l])return!1;const o=e.props,i=t.props;return o.isDark===i.isDark&&o.typewriter===i.typewriter&&o.fade===i.fade&&o.batchRendering===i.batchRendering&&o.initialRenderBatchSize===i.initialRenderBatchSize&&o.renderBatchSize===i.renderBatchSize&&o.renderBatchDelay===i.renderBatchDelay&&o.renderBatchBudgetMs===i.renderBatchBudgetMs&&o.renderBatchIdleTimeoutMs===i.renderBatchIdleTimeoutMs&&o.deferNodesUntilVisible===i.deferNodesUntilVisible&&o.maxLiveNodes===i.maxLiveNodes&&o.liveNodeBuffer===i.liveNodeBuffer&&o.viewportPriority===i.viewportPriority&&o.indexKey===i.indexKey&&o.onClick===i.onClick&&o.onMouseOver===i.onMouseOver&&o.onMouseOut===i.onMouseOut});function zr(e){var n,l;const a={...Ir,...e},u=c(null),h=c(/* @__PURE__ */new Map),f=c(0),p=c(null),g=Ae(a.smoothStreamingOptions),v=r.useContext(Be),y=c(/* @__PURE__ */new Set),[w,x]=i(()=>!0===a.smoothStreaming);s(()=>{x(!0)},[]);const k=Array.isArray(a.nodes)&&a.nodes.length>0,b=o(()=>{var e;return!1!==a.smoothStreaming&&!k&&(!0===a.smoothStreaming||!v)&&(!0===a.smoothStreaming||!0===a.typewriter||(null!=(e=a.maxLiveNodes)?e:0)<=0)},[k,v,a.maxLiveNodes,a.smoothStreaming,a.typewriter]),C=w&&b,N=C?g.visible:null!=(n=a.content)?n:"",M=o(()=>{var e,t;const n=null!=(e=a.parseOptions)?e:{};return null!=(t=a.final)?t:n.final},[a.final,a.parseOptions]),B=null!=(l=a.content)?l:"",S=k||g.source===B,T=o(()=>C&&null!=M?Boolean(M&&S&&g.caughtUp):M,[M,S,g.caughtUp,C]),$=c(null),[A,R]=i(!1),F=c(void 0),I=c(0),_=o(()=>/* @__PURE__ */new Set(["code_block","admonition","table","math_block","html_block","image"]),[]),H=d(e=>{if(!e||"object"!=typeof e)return!1;const t=e.type;return"string"==typeof t&&_.has(t)},[_]),W=d(e=>{var t,n;if(!e||"object"!=typeof e)return 0;const r=e,o=null!=(n=null!=(t=r.raw)?t:r.content)?n:r.code;if("string"==typeof o)return o.length;const i=r.children;if(Array.isArray(i))return i.reduce((e,t)=>e+W(t),0);const l=r.items;return Array.isArray(l)?l.reduce((e,t)=>e+W(t),0):0},[]),O=d(()=>{var e,t;return(null==(e=a.nodes)?void 0:e.length)?a.nodes.reduce((e,t)=>e+W(t),0):(null!=(t=a.content)?t:"").length},[a.nodes,a.content,W]),j=d(()=>{F.current&&(clearTimeout(F.current),F.current=void 0)},[]),q=d(e=>{const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){var t;if(!(null!=(t=e.textContent)?t:"").trim())return NodeFilter.FILTER_REJECT;const n=e.parentElement;return n?n.closest('.typewriter-cursor, .height-estimation-probes, [data-node-type="code_block"], [data-node-type="admonition"], [data-node-type="table"], [data-node-type="math_block"], [data-node-type="html_block"], [data-node-type="image"], script, style')?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});let n=null,r=t.nextNode();for(;r;)n=r,r=t.nextNode();return n},[]),U=d(()=>{var e,t;if("undefined"==typeof window||!A||!u.current||!$.current)return;const n=u.current,r=$.current,o=q(n),i=n.getBoundingClientRect();let l=0,a=0,c=20;if(null==o?void 0:o.textContent){const r=document.createRange(),s=o.textContent.length;r.setStart(o,Math.max(0,s-1)),r.setEnd(o,s);const d="function"==typeof r.getClientRects?r.getClientRects():void 0,u=null!=(t=null==d?void 0:d[d.length-1])?t:null==(e=o.parentElement)?void 0:e.getBoundingClientRect();u&&(l=u.right-i.left+n.scrollLeft,a=u.top-i.top+n.scrollTop,c=u.height||c),r.detach()}r.style.transform=`translate(${Math.max(0,l)}px, ${Math.max(0,a)}px)`,r.style.height=`${c}px`},[A,u,q]);s(()=>{A&&requestAnimationFrame(()=>{U()})},[A,U]),s(()=>()=>{j()},[j]);const X=k?a.nodes:N;p.current!==X&&(f.current+=1,p.current=X);const Z=m(z,K,K),Y=o(()=>V(a.customId),[a.customId,Z]),G=Wr(a.streamingComponents),J=Wr(a.htmlComponents);s(()=>{he(G,J,y.current)},[J,G]);const Q=o(()=>a.customId?`renderer-${a.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,[a.customId]),ee=o(()=>{var e,t;const n=null!=(t=(null!=(e=a.parseOptions)?e:{}).customHtmlTags)?t:[];return E(a.customHtmlTags,Array.isArray(n)?n:[],Object.keys(G))},[a.customId,a.customHtmlTags,a.parseOptions,Z,G]),te=o(()=>{const e=ee;return e&&0!==e.length?L(Q,{customHtmlTags:e}):L(Q)},[Q,ee]),ne=o(()=>{const e=te;return a.customMarkdownIt?a.customMarkdownIt(e):e},[te,a.customMarkdownIt]),re=o(()=>{var e;const t=null!=(e=a.parseOptions)?e:{},n=T,r=null!=n,o=ee.length>0;return r||o?{...t,...r?{final:n}:{},...o?{customHtmlTags:ee}:{}}:t},[ee,T,a.parseOptions]),oe=o(()=>{const e=Boolean(a.debugPerformance)&&"undefined"!=typeof console&&"undefined"!=typeof performance,t=e?performance.now():0;let n=[];return k?n=a.nodes.map(e=>({...e})):N&&(n=D(N,null!=ne?ne:_r,re)),e&&console.info("[markstream-react][perf] parse(sync)",{ms:Math.round(performance.now()-t),nodes:n.length,contentLength:N.length}),n},[a.debugPerformance,N,k,a.nodes,re,ne,a.customId,Z,ee]),ie=d(()=>{const e=oe[oe.length-1];return!H(e)},[oe,H]);s(()=>{if("undefined"==typeof window||k)return;if(T)return R(!1),void j();const e=O(),t=ie();return!1===a.typewriter||!t||e<=I.current?(!1!==a.typewriter&&t||R(!1),void(I.current=e)):(I.current=e,R(!0),j(),requestAnimationFrame(()=>{U()}),F.current=setTimeout(()=>{R(!1)},3e3),()=>{j()})},[N,a.nodes,a.typewriter,a.content,T,oe.length,k,O,ie,j,U]);const le=c([]),ae=null==re?void 0:re.postTransformNodes,ce=c(ae);ce.current!==ae&&(le.current=[],ce.current=ae);const se=function(e,t){if(!t.length)return e;const n=new Array(e.length);let r=e.length===t.length;for(let o=0;o<e.length;o++){const i=o<t.length?t[o]:null;i&&Hr(i,e[o])?n[o]=i:(n[o]=e[o],r=!1)}return r?t:n}(oe,le.current);le.current=se,s(()=>{var e;if(k)return void g.reset("");const t=null!=(e=a.content)?e:"";if(!C)return g.reset(t),void(M&&g.finish({flush:!0}));const n=g.getSnapshot().source;t?t===n||(t.startsWith(n)?g.enqueue(t.slice(n.length)):g.reset(t)):g.reset(""),M&&g.finish()},[k,a.content,M,C]),s(()=>{var e,t;if("undefined"==typeof window)return;if(a.renderCodeBlocksAsPre)return;if(!se.some(e=>{var t;return"code_block"===(null==e?void 0:e.type)&&"mermaid"!==P(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(()=>{nt()},{timeout:900});return()=>r(o)},[se,a.renderCodeBlocksAsPre]);const de=o(()=>null!=a.indexKey?String(a.indexKey):"markdown-renderer",[a.indexKey]),ue=o(()=>({..."boolean"==typeof a.showTooltips?{showTooltips:a.showTooltips}:{},...a.codeBlockProps||{}}),[a.codeBlockProps,a.showTooltips]),me=o(()=>({...a.mermaidProps||{}}),[a.mermaidProps]),fe=o(()=>({...a.d2Props||{}}),[a.d2Props]),pe=o(()=>({...a.infographicProps||{}}),[a.infographicProps]),ge=o(()=>{var e;return{customId:a.customId,isDark:a.isDark,final:T,indexKey:de,typewriter:a.typewriter,fade:a.fade,textStreamState:h.current,streamRenderVersion:f.current,customComponents:Y,streamingComponents:G,htmlComponents:J,customHtmlTags:ee,htmlPolicy:null!=(e=a.htmlPolicy)?e:"safe",showTooltips:a.showTooltips,renderCodeBlocksAsPre:a.renderCodeBlocksAsPre,codeBlockStream:a.codeBlockStream,codeBlockOptions:a.codeBlockOptions,codeBlockProps:ue,mermaidProps:me,d2Props:fe,infographicProps:pe,codeBlockThemes:{themes:a.themes,darkTheme:a.codeBlockDarkTheme,lightTheme:a.codeBlockLightTheme,minWidth:a.codeBlockMinWidth,maxWidth:a.codeBlockMaxWidth},events:{onCopy:a.onCopy,onHandleArtifactClick:a.onHandleArtifactClick}}},[a.customId,a.isDark,T,de,a.typewriter,a.fade,a.showTooltips,a.htmlPolicy,a.renderCodeBlocksAsPre,a.codeBlockStream,a.codeBlockOptions,ee,ue,me,fe,pe,a.themes,a.codeBlockDarkTheme,a.codeBlockLightTheme,a.codeBlockMinWidth,a.codeBlockMaxWidth,a.onCopy,a.onHandleArtifactClick,Y,G,J]);ge.streamRenderVersion=f.current,ge.textStreamState=h.current;const ve=c(null);return ve.current||(ve.current={textStreamState:h.current,getStreamRenderVersion:()=>f.current}),/* @__PURE__ */t(Se.Provider,{value:ve.current,children:/* @__PURE__ */t(Be.Provider,{value:C,children:/* @__PURE__ */t($e,{getRoot:()=>u.current,enabled:!1!==a.viewportPriority,children:/* @__PURE__ */t(jr,{props:a,parsedNodes:se,renderCtx:ge,indexPrefix:de,containerRef:u,showTypewriterCursor:A,typewriterCursorRef:$})})})})}function Kr(e){var n,r,o,i,l;const{node:a,ctx:c,renderNode:s,indexKey:d,children:u}=e;/* @__PURE__ */
189
- return t("blockquote",{className:"blockquote-node",dir:"auto",cite:a.cite,children:null!=u?u:c&&s?/* @__PURE__ */t(zr,{nodes:a.children||[],indexKey:`blockquote-${String(null!=d?d:"blockquote")}`,customId:c.customId,isDark:c.isDark,typewriter:c.typewriter,viewportPriority:!0,codeBlockStream:c.codeBlockStream,renderCodeBlocksAsPre:c.renderCodeBlocksAsPre,codeBlockOptions:c.codeBlockOptions,codeBlockProps:c.codeBlockProps,themes:null==(n=c.codeBlockThemes)?void 0:n.themes,codeBlockDarkTheme:null==(r=c.codeBlockThemes)?void 0:r.darkTheme,codeBlockLightTheme:null==(o=c.codeBlockThemes)?void 0:o.lightTheme,codeBlockMinWidth:null==(i=c.codeBlockThemes)?void 0:i.minWidth,codeBlockMaxWidth:null==(l=c.codeBlockThemes)?void 0:l.maxWidth,htmlPolicy:c.htmlPolicy,showTooltips:c.showTooltips,onCopy:c.events.onCopy,onHandleArtifactClick:c.events.onHandleArtifactClick}):null})}function Vr(e){var n;const r=c(null),[l,a]=i(!1),[d,u]=i({transform:"translate3d(0px, 0px, 0px)",left:"0px",top:"0px"}),m=o(()=>function(e){if("boolean"==typeof e)return e;if("undefined"!=typeof document)try{if(document.documentElement.classList.contains("dark"))return!0}catch{}if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{return window.matchMedia("(prefers-color-scheme: dark)").matches}catch{}return!1}(e.isDark),[e.isDark]);return s(()=>{if(!e.visible)return void a(!1);if(!e.anchorEl||!r.current)return void a(!0);let t=null,n=!1;const o=async()=>{var t,o;if(!e.anchorEl||!r.current)return;const{x:i,y:l}=await we(e.anchorEl,r.current,{placement:null!=(t=e.placement)?t:"top",middleware:[xe(null!=(o=e.offset)?o:8),ke(),be({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||a(!0)}),t=ye(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?Ce(
190
- /* @__PURE__ */t("div",{id:null!=(n=e.id)?n:void 0,ref:r,style:d,className:["markstream-react 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{Bn as $,Me as A,Kr as B,Re as C,Bt as D,Tt as E,br as F,Tn as G,Rt as H,Jt as I,Cn as J,Gn as K,un as L,Zn as M,zr as N,yt as O,Mr as P,vt as Q,Br as R,Sr as S,Dr as T,er as U,Pr as V,Mn as W,xt as X,Pn as Y,Xn as Z,wt as _,st as a,An as a0,Fr as a1,gt as a2,Ie as a3,$n as a4,Sn as a5,En as a6,bn as a7,Nn as a8,Yn as a9,qn as aa,Un as ab,tr as ac,_e as ad,Ae as ae,Ln as af,St as b,Et as c,$t as d,Pt as e,At as f,Ft as g,It as h,_t as i,Zt as j,Ge as k,rn as l,ln as m,an as n,mn as o,hn as p,_n as q,Hn as r,hr as s,Tr as t,Er as u,Lr as v,dn as w,$r as x,Vr as y,Qn as z};
172
+ return t(ut,{node:e,loading:Boolean(e.loading),stream:r.codeBlockStream,themes:null==(c=r.codeBlockThemes)?void 0:c.themes,darkTheme:null==(s=r.codeBlockThemes)?void 0:s.darkTheme,lightTheme:null==(d=r.codeBlockThemes)?void 0:d.lightTheme,minWidth:null==(u=r.codeBlockThemes)?void 0:u.minWidth,maxWidth:null==(m=r.codeBlockThemes)?void 0:m.maxWidth,isDark:r.isDark,onCopy:r.events.onCopy,...me(r.codeBlockProps),codeBlockOptions:r.codeBlockOptions},n)}(e,n,o,x);case"strong":/* @__PURE__ */
173
+ return t(Lr,{node:e,children:$(e.children,o,`${String(n)}-strong`,_r)},n);case"emphasis":/* @__PURE__ */
174
+ return t(Dt,{node:e,children:$(e.children,o,`${String(n)}-em`,_r)},n);case"strikethrough":/* @__PURE__ */
175
+ return t(Er,{node:e,children:$(e.children,o,`${String(n)}-strike`,_r)},n);case"highlight":/* @__PURE__ */
176
+ return t(Ht,{node:e,children:$(e.children,o,`${String(n)}-highlight`,_r)},n);case"insert":/* @__PURE__ */
177
+ return t(sn,{node:e,children:$(e.children,o,`${String(n)}-insert`,_r)},n);case"subscript":/* @__PURE__ */
178
+ return t(Dr,{node:e,children:$(e.children,o,`${String(n)}-sub`,_r)},n);case"superscript":/* @__PURE__ */
179
+ return t($r,{node:e,children:$(e.children,o,`${String(n)}-sup`,_r)},n);case"checkbox":case"checkbox_input":/* @__PURE__ */
180
+ return t(Fe,{node:e,typewriter:o.typewriter,fade:o.fade},n);case"emoji":/* @__PURE__ */
181
+ return t(Lt,{node:e,typewriter:o.typewriter,fade:o.fade},n);case"thematic_break":/* @__PURE__ */
182
+ return t(Ar,{},n);case"math_inline":/* @__PURE__ */
183
+ return t(On,{node:e},n);case"math_block":/* @__PURE__ */
184
+ return t(Wn,{node:e},n);case"reference":/* @__PURE__ */
185
+ return t(Tr,{node:e,ctx:o,typewriter:o.typewriter,fade:o.fade},n);case"html_block":case"html_inline":return"html_block"===e.type?/* @__PURE__ */t(Wt,{node:e,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade,customId:o.customId},n):/* @__PURE__ */t(Gt,{node:e,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade,customId:o.customId},n);case"vmr_container":/* @__PURE__ */
186
+ return t(Rr,{node:e,ctx:o,renderNode:_r,indexKey:n,typewriter:o.typewriter,fade:o.fade},n);case"label_open":case"label_close":return null;default:/* @__PURE__ */
187
+ return t(Nr,{node:e},n)}}const Hr={codeBlockStream:!0,typewriter:!1,fade:!0,smoothStreaming:"auto",batchRendering:!0,initialRenderBatchSize:40,renderBatchSize:80,renderBatchDelay:16,renderBatchBudgetMs:6,renderBatchIdleTimeoutMs:120,deferNodesUntilVisible:!0,maxLiveNodes:320,liveNodeBuffer:60},Wr=L();function Or(e,t){return e.type===t.type&&e.raw===t.raw&&e.loading===t.loading&&e.autoClosed===t.autoClosed&&!!function(e,t){if(e===t)return!0;if(!e||!t||"object"!=typeof e||"object"!=typeof t)return!1;const n=e,r=t;return n.startLine===r.startLine&&n.endLine===r.endLine}(e.sourceMap,t.sourceMap)&&("code_block"!==e.type&&"code_block"!==t.type||e.diff===t.diff)}function jr(e){const t=o(()=>fe(e),[e]),n=c(t);return function(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])}(n.current,t)||(n.current=t),n.current}const zr=r.memo(({node:e,nodeKey:t,renderCtx:n})=>_r(e,t,n),(e,t)=>e.node===t.node&&e.renderCtx===t.renderCtx&&e.nodeKey===t.nodeKey),Kr=r.memo(({props:n,parsedNodes:r,renderCtx:l,indexPrefix:a,containerRef:u,showTypewriterCursor:m,typewriterCursorRef:h})=>{var f,p,g,v,y,w,x;const k=Ae(),b="undefined"!=typeof window,C="undefined"!=typeof window&&"function"==typeof window.requestIdleCallback,N=Math.max(0,Math.trunc(null!=(f=n.renderBatchSize)?f:80)),M=Math.max(0,Math.trunc(null!=(p=n.initialRenderBatchSize)?p:N||r.length)),B=!1!==n.batchRendering&&N>0&&b,S=Math.max(0,null!=(g=n.liveNodeBuffer)?g:60),T=Math.max(1,null!=(v=n.maxLiveNodes)?v:320),E=(null!=(y=n.maxLiveNodes)?y:0)>0&&r.length>T,L=!1!==n.viewportPriority,D=B&&(null!=(w=n.maxLiveNodes)?w:0)<=0,$=o(()=>{var e;return!1!==n.deferNodesUntilVisible&&!((null!=(e=n.maxLiveNodes)?e:0)<=0)&&!E&&!(r.length>900)&&L},[r.length,n.deferNodesUntilVisible,n.maxLiveNodes,L,E]),[P,A]=i(()=>D?Math.min(r.length,M):r.length),R=c(P);s(()=>{R.current=P},[P]);const F=D?P:r.length,[I,_]=i(0),[H,W]=i({start:0,end:r.length}),O=c(/* @__PURE__ */new Map),[j,z]=i(0),K=c({}),V=c(/* @__PURE__ */new Map),q=c(/* @__PURE__ */new Map),U=c(/* @__PURE__ */new Map),X=c(/* @__PURE__ */new Map),Z=c(/* @__PURE__ */new Set),Y=c(P),G=c(null),J=c(null),Q=c(null),ee=c(!1),te=c(null),ne=c(Math.max(1,N||1)),re=c(r.length),oe=c({key:n.indexKey,total:r.length}),ie=c(r),le=c({batchSize:N,initial:M,delay:null!=(x=n.renderBatchDelay)?x:16,enabled:D}),ae=$||E,ce=o(()=>{const e=O.current;if(!e.size)return 32;let t=0;for(const n of e.values())t+=n;return Math.max(16,t/e.size)},[j]),se=o(()=>{if(!E)return r.map((e,t)=>({node:e,index:t}));const e=r.length,t=Math.max(0,Math.min(H.start,e)),n=Math.max(t,Math.min(H.end,e));return r.slice(t,n).map((e,n)=>({node:e,index:t+n}))},[r,H,E]),de=o(()=>{if(!E)return r.length;const e=Math.max(H.end+S,M),t=Math.min(r.length,e);return Math.max(P,t)},[r.length,E,H.end,S,M,P]);re.current=de;const ue=d((e,t)=>{var n;if(e>=t)return 0;const r=O.current;let o=0;for(let i=e;i<t;i++)o+=null!=(n=r.get(i))?n:ce;return o},[ce]),me=E?ue(0,Math.min(H.start,r.length)):0,he=E?ue(Math.min(H.end,r.length),r.length):0,fe=d(()=>{null!=G.current&&"function"==typeof cancelAnimationFrame&&(cancelAnimationFrame(G.current),G.current=null),null!=J.current&&(window.clearTimeout(J.current),J.current=null),null!=Q.current&&"function"==typeof window.cancelIdleCallback&&(window.cancelIdleCallback(Q.current),Q.current=null),ee.current=!1,te.current=null},[]),pe=d(e=>{var t;if(!D)return;const r=Math.max(2,null!=(t=n.renderBatchBudgetMs)?t:6),o=Math.max(1,N||1),i=Math.max(1,Math.floor(o/4));e>1.2*r?ne.current=Math.max(i,Math.floor(.7*ne.current)):e<.5*r&&ne.current<o&&(ne.current=Math.min(o,Math.ceil(1.2*ne.current)))},[D,n.renderBatchBudgetMs,N]),ge=d((e,t={})=>{var r,o;if(!D)return;const i=re.current;if(R.current>=i)return;const l=Math.max(1,e),a=e=>{const t="undefined"!=typeof performance?performance.now():Date.now();A(t=>{const n=Math.min(re.current,t+Math.max(1,e));return R.current=n,n});const n="undefined"!=typeof performance?performance.now():Date.now();pe(n-t)},c=()=>{const e=Math.max(1,Math.round(ne.current));ge(e)},s=e=>{var t;G.current=null,J.current=null,Q.current=null,ee.current=!1;const r=te.current;if(te.current=null,a(null!=r?r:l),R.current>=re.current)return;if(!e)return void c();const o=Math.max(2,null!=(t=n.renderBatchBudgetMs)?t:6);for(;R.current<re.current&&!(("function"==typeof e.timeRemaining?e.timeRemaining():0)<=.5*o);)a(Math.max(1,Math.round(ne.current)));R.current<re.current&&c()};if(!b||t.immediate)return void s();const d=Math.max(0,null!=(r=n.renderBatchDelay)?r:16);if(te.current=null!=te.current?Math.max(te.current,l):l,!ee.current){if(ee.current=!0,C){const e=Math.max(0,null!=(o=n.renderBatchIdleTimeoutMs)?o:120);return void(Q.current=window.requestIdleCallback(e=>s(e),{timeout:e}))}"function"==typeof requestAnimationFrame?G.current=requestAnimationFrame(()=>{0!==d?J.current=window.setTimeout(()=>s(),d):s()}):J.current=window.setTimeout(()=>s(),d)}},[pe,C,D,b,n.renderBatchDelay,n.renderBatchBudgetMs,n.renderBatchIdleTimeoutMs]);s(()=>{var e;const t=n.indexKey,o=r.length,i=oe.current,l=void 0!==t?t!==i.key:o!==i.total,a=ie.current,c=Math.min(a.length,r.length);let s=0;for(;s<c&&a[s]===r[s];)s+=1;oe.current={key:t,total:o};const d=le.current,u=null!=(e=n.renderBatchDelay)?e:16,m=d.batchSize!==N||d.initial!==M||d.delay!==u||d.enabled!==D;if(le.current={batchSize:N,initial:M,delay:u,enabled:D},(l||m||!D)&&fe(),(l||m)&&(ne.current=Math.max(1,N||1)),t!==i.key)Z.current.clear();else if(l)for(const n of Z.current)n>=s&&Z.current.delete(n);if(!o)return R.current=0,void A(0);const h=re.current;if(!D)return R.current=h,void A(h);if(l||m){const e=Math.min(h,M);return R.current=e,A(e),void(e<h&&ge(Math.max(1,M),{immediate:!b}))}const f=Math.min(R.current,h);f!==R.current&&(R.current=f,A(f)),R.current<h&&ge(Math.max(1,N||1))},[fe,D,b,r.length,n.indexKey,n.renderBatchDelay,N,M,ge]),s(()=>{ie.current=r},[r]),s(()=>{if(!E)return void W({start:0,end:r.length});const e=r.length;if(!e)return void W({start:0,end:0});const t=Math.max(0,Math.min(I,e-1));let n=Math.max(0,t-S),o=Math.min(e,t+S+1);const i=o-n;if(i>T){const e=i-T;n+=Math.ceil(e/2),o-=Math.floor(e/2)}else if(i<T){const t=T-i;n=Math.max(0,n-Math.ceil(t/2)),o=Math.min(e,o+Math.floor(t/2))}W({start:n,end:o})},[I,S,T,r.length,E]),s(()=>()=>{fe();for(const e of V.current.values())e.destroy();V.current.clear()},[fe]);const ve=d(e=>{for(const[t,n]of V.current.entries())t>=e&&(n.destroy(),V.current.delete(t),delete K.current[t],q.current.delete(t),U.current.delete(t),X.current.delete(t))},[]);s(()=>{ve(F)},[ve,F]),s(()=>{const e=r.length;let t=!1;for(const n of Array.from(O.current.keys()))n>=e&&(O.current.delete(n),t=!0);t&&z(e=>e+1);for(const n of Object.keys(K.current))Number(n)>=e&&delete K.current[n];for(const n of Array.from(Z.current))n>=e&&Z.current.delete(n)},[r.length]);const ye=d((e,t)=>{$&&t&&(K.current[e]=!0),t&&E&&_(t=>e>t?e:t)},[$,E]),we=d(e=>{const t=V.current.get(e);t&&(t.destroy(),V.current.delete(e))},[]),xe=d((e,t)=>{const n=q.current;if(t?n.set(e,t):n.delete(e),!ae||!t)return we(e),$&&!t&&delete K.current[e],void(t&&ye(e,!0));if(e<M&&!E)return we(e),void ye(e,!0);we(e);const r=k(t,{rootMargin:"400px"});V.current.set(e,r),r.isVisible()&&ye(e,!0),r.whenVisible.then(()=>ye(e,!0)).catch(()=>{})},[$,we,ye,k,M,ae,E]),ke=d(e=>{const t=U.current.get(e);if(t)return t;const n=t=>xe(e,t);return U.current.set(e,n),n},[xe]),be=d((e,t)=>{if(!t)return void(O.current.has(e)&&(O.current.delete(e),z(e=>e+1)));const n=()=>{const n=t.offsetHeight;n&&O.current.get(e)!==n&&(O.current.set(e,n),z(e=>e+1))};"function"==typeof queueMicrotask?queueMicrotask(n):Promise.resolve().then(n)},[]),Ce=d(e=>{const t=X.current.get(e);if(t)return t;const n=t=>be(e,t);return X.current.set(e,n),n},[be]),Ne=d(e=>!(D&&e>=R.current)&&(!$||e<M||!0===K.current[e]),[$,D,M]),Me=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 q.current.entries())t&&xe(e,t)},[xe]),s(()=>{E&&P>Y.current&&_(P-1),Y.current=P},[P,E]);const Be=E?/* @__PURE__ */t("div",{className:"node-spacer",style:{height:`${me}px`},"aria-hidden":"true"}):null,Se=E?/* @__PURE__ */t("div",{className:"node-spacer",style:{height:`${he}px`},"aria-hidden":"true"}):null;/* @__PURE__ */
188
+ return e("div",{ref:u,className:`markstream-react markdown-renderer${n.isDark?" dark":""}${E?" virtualized":""}`,"data-custom-id":n.customId,onClick:n.onClick,onMouseOver:Me(n.onMouseOver),onMouseOut:Me(n.onMouseOut),children:[Be,se.map(({node:e,index:r})=>{var o;const i=Ne(r),c=null!=(o=O.current.get(r))?o:ce,s=!1!==n.fade&&"code_block"!==e.type&&!Z.current.has(r)&&i;return s&&Z.current.add(r),/* @__PURE__ */t("div",{ref:ke(r),className:"node-slot","data-node-index":r,"data-node-type":e.type,children:/* @__PURE__ */t("div",i?{ref:Ce(r),className:"node-content"+(s?" fade-node typewriter-node":""),children:/* @__PURE__ */t(zr,{node:e,nodeKey:`${a}-${r}`,renderCtx:l})}:{className:"node-placeholder",style:{height:`${c}px`}})},`${a}-${r}`)}),Se,m&&/* @__PURE__ */t("span",{ref:h,className:"typewriter-cursor","aria-hidden":"true"})]})},function(e,t){if(e.renderCtx!==t.renderCtx)return!1;if(e.indexPrefix!==t.indexPrefix)return!1;if(e.containerRef!==t.containerRef)return!1;if(e.showTypewriterCursor!==t.showTypewriterCursor)return!1;const n=e.parsedNodes,r=t.parsedNodes;if(n===r)return!0;if(n.length!==r.length)return!1;for(let l=0;l<n.length;l++)if(n[l]!==r[l])return!1;const o=e.props,i=t.props;return o.isDark===i.isDark&&o.typewriter===i.typewriter&&o.fade===i.fade&&o.batchRendering===i.batchRendering&&o.initialRenderBatchSize===i.initialRenderBatchSize&&o.renderBatchSize===i.renderBatchSize&&o.renderBatchDelay===i.renderBatchDelay&&o.renderBatchBudgetMs===i.renderBatchBudgetMs&&o.renderBatchIdleTimeoutMs===i.renderBatchIdleTimeoutMs&&o.deferNodesUntilVisible===i.deferNodesUntilVisible&&o.maxLiveNodes===i.maxLiveNodes&&o.liveNodeBuffer===i.liveNodeBuffer&&o.viewportPriority===i.viewportPriority&&o.indexKey===i.indexKey&&o.onClick===i.onClick&&o.onMouseOver===i.onMouseOver&&o.onMouseOut===i.onMouseOut});function Vr(e){var n,l;const a={...Hr,...e},u=c(null),h=c(/* @__PURE__ */new Map),f=c(0),p=c(null),g=Re(a.smoothStreamingOptions),v=r.useContext(Se),y=c(/* @__PURE__ */new Set),[w,x]=i(()=>!0===a.smoothStreaming);s(()=>{x(!0)},[]);const k=Array.isArray(a.nodes)&&a.nodes.length>0,b=o(()=>{var e;return!1!==a.smoothStreaming&&!k&&(!0===a.smoothStreaming||!v)&&(!0===a.smoothStreaming||!0===a.typewriter||(null!=(e=a.maxLiveNodes)?e:0)<=0)},[k,v,a.maxLiveNodes,a.smoothStreaming,a.typewriter]),C=w&&b,N=C?g.visible:null!=(n=a.content)?n:"",M=o(()=>{var e,t;const n=null!=(e=a.parseOptions)?e:{};return null!=(t=a.final)?t:n.final},[a.final,a.parseOptions]),B=null!=(l=a.content)?l:"",S=k||g.source===B,T=o(()=>C&&null!=M?Boolean(M&&S&&g.caughtUp):M,[M,S,g.caughtUp,C]),$=c(null),[A,R]=i(!1),F=c(void 0),I=c(0),_=o(()=>/* @__PURE__ */new Set(["code_block","admonition","table","math_block","html_block","image"]),[]),H=d(e=>{if(!e||"object"!=typeof e)return!1;const t=e.type;return"string"==typeof t&&_.has(t)},[_]),W=d(e=>{var t,n;if(!e||"object"!=typeof e)return 0;const r=e,o=null!=(n=null!=(t=r.raw)?t:r.content)?n:r.code;if("string"==typeof o)return o.length;const i=r.children;if(Array.isArray(i))return i.reduce((e,t)=>e+W(t),0);const l=r.items;return Array.isArray(l)?l.reduce((e,t)=>e+W(t),0):0},[]),O=d(()=>{var e,t;return(null==(e=a.nodes)?void 0:e.length)?a.nodes.reduce((e,t)=>e+W(t),0):(null!=(t=a.content)?t:"").length},[a.nodes,a.content,W]),j=d(()=>{F.current&&(clearTimeout(F.current),F.current=void 0)},[]),q=d(e=>{const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){var t;if(!(null!=(t=e.textContent)?t:"").trim())return NodeFilter.FILTER_REJECT;const n=e.parentElement;return n?n.closest('.typewriter-cursor, .height-estimation-probes, [data-node-type="code_block"], [data-node-type="admonition"], [data-node-type="table"], [data-node-type="math_block"], [data-node-type="html_block"], [data-node-type="image"], script, style')?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});let n=null,r=t.nextNode();for(;r;)n=r,r=t.nextNode();return n},[]),U=d(()=>{var e,t;if("undefined"==typeof window||!A||!u.current||!$.current)return;const n=u.current,r=$.current,o=q(n),i=n.getBoundingClientRect();let l=0,a=0,c=20;if(null==o?void 0:o.textContent){const r=document.createRange(),s=o.textContent.length;r.setStart(o,Math.max(0,s-1)),r.setEnd(o,s);const d="function"==typeof r.getClientRects?r.getClientRects():void 0,u=null!=(t=null==d?void 0:d[d.length-1])?t:null==(e=o.parentElement)?void 0:e.getBoundingClientRect();u&&(l=u.right-i.left+n.scrollLeft,a=u.top-i.top+n.scrollTop,c=u.height||c),r.detach()}r.style.transform=`translate(${Math.max(0,l)}px, ${Math.max(0,a)}px)`,r.style.height=`${c}px`},[A,u,q]);s(()=>{A&&requestAnimationFrame(()=>{U()})},[A,U]),s(()=>()=>{j()},[j]);const X=k?a.nodes:N;p.current!==X&&(f.current+=1,p.current=X);const Z=m(z,K,K),Y=o(()=>V(a.customId),[a.customId,Z]),G=jr(a.streamingComponents),J=jr(a.htmlComponents);s(()=>{he(G,J,y.current)},[J,G]);const Q=o(()=>a.customId?`renderer-${a.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,[a.customId]),ee=o(()=>{var e,t;const n=null!=(t=(null!=(e=a.parseOptions)?e:{}).customHtmlTags)?t:[];return E(a.customHtmlTags,Array.isArray(n)?n:[],Object.keys(G))},[a.customId,a.customHtmlTags,a.parseOptions,Z,G]),te=o(()=>{const e=ee;return e&&0!==e.length?L(Q,{customHtmlTags:e}):L(Q)},[Q,ee]),ne=o(()=>{const e=te;return a.customMarkdownIt?a.customMarkdownIt(e):e},[te,a.customMarkdownIt]),re=o(()=>{var e;const t=null!=(e=a.parseOptions)?e:{},n=T,r=null!=n,o=ee.length>0;return r||o?{...t,...r?{final:n}:{},...o?{customHtmlTags:ee}:{}}:t},[ee,T,a.parseOptions]),oe=o(()=>{const e=Boolean(a.debugPerformance)&&"undefined"!=typeof console&&"undefined"!=typeof performance,t=e?performance.now():0;let n=[];return k?n=a.nodes.map(e=>({...e})):N&&(n=D(N,null!=ne?ne:Wr,re)),e&&console.info("[markstream-react][perf] parse(sync)",{ms:Math.round(performance.now()-t),nodes:n.length,contentLength:N.length}),n},[a.debugPerformance,N,k,a.nodes,re,ne,a.customId,Z,ee]),ie=d(()=>{const e=oe[oe.length-1];return!H(e)},[oe,H]);s(()=>{if("undefined"==typeof window||k)return;if(T)return R(!1),void j();const e=O(),t=ie();return!1===a.typewriter||!t||e<=I.current?(!1!==a.typewriter&&t||R(!1),void(I.current=e)):(I.current=e,R(!0),j(),requestAnimationFrame(()=>{U()}),F.current=setTimeout(()=>{R(!1)},3e3),()=>{j()})},[N,a.nodes,a.typewriter,a.content,T,oe.length,k,O,ie,j,U]);const le=c([]),ae=null==re?void 0:re.postTransformNodes,ce=c(ae);ce.current!==ae&&(le.current=[],ce.current=ae);const se=function(e,t){if(!t.length)return e;const n=new Array(e.length);let r=e.length===t.length;for(let o=0;o<e.length;o++){const i=o<t.length?t[o]:null;i&&Or(i,e[o])?n[o]=i:(n[o]=e[o],r=!1)}return r?t:n}(oe,le.current);le.current=se,s(()=>{var e;if(k)return void g.reset("");const t=null!=(e=a.content)?e:"";if(!C)return g.reset(t),void(M&&g.finish({flush:!0}));const n=g.getSnapshot().source;t?t===n||(t.startsWith(n)?g.enqueue(t.slice(n.length)):g.reset(t)):g.reset(""),M&&g.finish()},[k,a.content,M,C]),s(()=>{var e,t;if("undefined"==typeof window)return;if(a.renderCodeBlocksAsPre)return;if(!se.some(e=>{var t;return"code_block"===(null==e?void 0:e.type)&&"mermaid"!==P(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(()=>{ot()},{timeout:900});return()=>r(o)},[se,a.renderCodeBlocksAsPre]);const de=o(()=>null!=a.indexKey?String(a.indexKey):"markdown-renderer",[a.indexKey]),ue=o(()=>({..."boolean"==typeof a.showTooltips?{showTooltips:a.showTooltips}:{},...a.codeBlockProps||{}}),[a.codeBlockProps,a.showTooltips]),me=o(()=>({...a.mermaidProps||{}}),[a.mermaidProps]),fe=o(()=>({...a.d2Props||{}}),[a.d2Props]),pe=o(()=>({...a.infographicProps||{}}),[a.infographicProps]),ge=o(()=>{var e;return{customId:a.customId,isDark:a.isDark,final:T,indexKey:de,typewriter:a.typewriter,fade:a.fade,textStreamState:h.current,streamRenderVersion:f.current,customComponents:Y,streamingComponents:G,htmlComponents:J,customHtmlTags:ee,htmlPolicy:null!=(e=a.htmlPolicy)?e:"safe",showTooltips:a.showTooltips,renderCodeBlocksAsPre:a.renderCodeBlocksAsPre,codeBlockStream:a.codeBlockStream,codeBlockOptions:a.codeBlockOptions,codeBlockProps:ue,mermaidProps:me,d2Props:fe,infographicProps:pe,codeBlockThemes:{themes:a.themes,darkTheme:a.codeBlockDarkTheme,lightTheme:a.codeBlockLightTheme,minWidth:a.codeBlockMinWidth,maxWidth:a.codeBlockMaxWidth},events:{onCopy:a.onCopy,onHandleArtifactClick:a.onHandleArtifactClick}}},[a.customId,a.isDark,T,de,a.typewriter,a.fade,a.showTooltips,a.htmlPolicy,a.renderCodeBlocksAsPre,a.codeBlockStream,a.codeBlockOptions,ee,ue,me,fe,pe,a.themes,a.codeBlockDarkTheme,a.codeBlockLightTheme,a.codeBlockMinWidth,a.codeBlockMaxWidth,a.onCopy,a.onHandleArtifactClick,Y,G,J]);ge.streamRenderVersion=f.current,ge.textStreamState=h.current;const ve=c(null);return ve.current||(ve.current={textStreamState:h.current,getStreamRenderVersion:()=>f.current}),/* @__PURE__ */t(Te.Provider,{value:ve.current,children:/* @__PURE__ */t(Se.Provider,{value:C,children:/* @__PURE__ */t(Pe,{getRoot:()=>u.current,enabled:!1!==a.viewportPriority,children:/* @__PURE__ */t(Kr,{props:a,parsedNodes:se,renderCtx:ge,indexPrefix:de,containerRef:u,showTypewriterCursor:A,typewriterCursorRef:$})})})})}function qr(e){var n,r,o,i,l;const{node:a,ctx:c,renderNode:s,indexKey:d,children:u}=e;/* @__PURE__ */
189
+ return t("blockquote",{className:"blockquote-node",dir:"auto",cite:a.cite,children:null!=u?u:c&&s?/* @__PURE__ */t(Vr,{nodes:a.children||[],indexKey:`blockquote-${String(null!=d?d:"blockquote")}`,customId:c.customId,isDark:c.isDark,typewriter:c.typewriter,viewportPriority:!0,codeBlockStream:c.codeBlockStream,renderCodeBlocksAsPre:c.renderCodeBlocksAsPre,codeBlockOptions:c.codeBlockOptions,codeBlockProps:c.codeBlockProps,themes:null==(n=c.codeBlockThemes)?void 0:n.themes,codeBlockDarkTheme:null==(r=c.codeBlockThemes)?void 0:r.darkTheme,codeBlockLightTheme:null==(o=c.codeBlockThemes)?void 0:o.lightTheme,codeBlockMinWidth:null==(i=c.codeBlockThemes)?void 0:i.minWidth,codeBlockMaxWidth:null==(l=c.codeBlockThemes)?void 0:l.maxWidth,htmlPolicy:c.htmlPolicy,showTooltips:c.showTooltips,onCopy:c.events.onCopy,onHandleArtifactClick:c.events.onHandleArtifactClick}):null})}function Ur(e){var n;const r=c(null),[l,a]=i(!1),[d,u]=i({transform:"translate3d(0px, 0px, 0px)",left:"0px",top:"0px"}),m=o(()=>function(e){if("boolean"==typeof e)return e;if("undefined"!=typeof document)try{if(document.documentElement.classList.contains("dark"))return!0}catch{}if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{return window.matchMedia("(prefers-color-scheme: dark)").matches}catch{}return!1}(e.isDark),[e.isDark]);return s(()=>{if(!e.visible)return void a(!1);if(!e.anchorEl||!r.current)return void a(!0);let t=null,n=!1;const o=async()=>{var t,o;if(!e.anchorEl||!r.current)return;const{x:i,y:l}=await xe(e.anchorEl,r.current,{placement:null!=(t=e.placement)?t:"top",middleware:[ke(null!=(o=e.offset)?o:8),be(),Ce({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||a(!0)}),t=we(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?Ne(
190
+ /* @__PURE__ */t("div",{id:null!=(n=e.id)?n:void 0,ref:r,style:d,className:["markstream-react 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{Tn as $,Be as A,qr as B,Fe as C,Tt as D,Lt as E,Nr as F,Ln as G,It as H,en as I,Mn as J,Qn as K,hn as L,Gn as M,Vr as N,xt as O,Sr as P,wt as Q,Tr as R,Er as S,Pr as T,nr as U,Rr as V,Sn as W,bt as X,Rn as Y,Yn as Z,kt as _,ut as a,Fn as a0,_r as a1,yt as a2,_e as a3,An as a4,En as a5,Dn as a6,Nn as a7,Bn as a8,Jn as a9,Xn as aa,Zn as ab,rr as ac,He as ad,Re as ae,$n as af,Et as b,Dt as c,At as d,Rt as e,Ft as f,_t as g,Ht as h,Wt as i,Gt as j,Qe as k,ln as l,cn as m,sn as n,fn as o,pn as p,Wn as q,On as r,pr as s,Lr as t,Dr as u,$r as v,mn as w,Ar as x,Ur as y,tr as z};