markstream-react 0.0.56-beta.4 → 0.0.56-beta.5

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,37 +1,37 @@
1
- import{jsxs as e,jsx as n,Fragment as t}from"react/jsx-runtime";import r,{useMemo as o,useState as i,createContext as l,useContext as a,useRef as c,useEffect as s,useCallback as d,useSyncExternalStore as u,useLayoutEffect as m}from"react";import{sanitizeHtmlTokenAttrs as h,normalizeCustomHtmlTagName as f,convertHtmlAttrsToProps as p,tokenAttrsToRecord as g,NON_STRUCTURING_HTML_TAGS as v,isHtmlTagBlocked as w,sanitizeHtmlContent as y,BLOCKED_HTML_TAGS as x,isHtmlTagHardBlocked as k,sanitizeImageSrc as b,sanitizeHtmlAttrs as C,shouldOpenLinkInNewTab as M,toSafeSvgElement as N,getHtmlTagFromContent as B,stripCustomHtmlWrapper as S,shouldRenderUnknownHtmlTagAsText as T,mergeCustomHtmlTags as L,getMarkdown as E,parseMarkdownToStructure as D}from"stream-markdown-parser";import{E as $,v as P,d as A,M as R,H,F,A as W,m as I,r as _,P as O,D as j,L as z,k as V,l as K,N as X,t as q,n as U,w as Y,O as Z,o as G,j as J,I as Q,y as ee,c as ne,g as te,u as re,x as oe,a as ie,h as le,B as ae,q as ce,G as se,i as de,Q as ue,s as me,p as he}from"./codeBlockExtraProps-B08PlQGP.js";import{createSmoothMarkdownStream as fe,normalizeShikiLanguage as pe,getHighlightRegistrationKey as ge,registerHighlightOnce as ve,getRuntimeShikiRegistrationConfig as we}from"markstream-core";import{createPortal as ye}from"react-dom";import{autoUpdate as xe,computePosition as ke,offset as be,flip as Ce,shift as Me}from"@floating-ui/dom";const Ne={note:"ℹ️",info:"ℹ️",tip:"💡",warning:"⚠️",danger:"❗",error:"⛔",caution:"⚠️"};function Be(t){const{node:r,ctx:l,renderNode:a,indexKey:c,isDark:s}=t,d=String(r.kind||"note"),u=o(()=>r.title&&String(r.title).trim().length?String(r.title):d.charAt(0).toUpperCase()+d.slice(1),[d,r.title]),[m,h]=i(()=>{var e;return!!r.collapsible&&!(null==(e=r.open)||e)}),f=o(()=>`admonition-${Math.random().toString(36).slice(2,9)}`,[]);/* @__PURE__ */
1
+ import{jsxs as e,jsx as n,Fragment as t}from"react/jsx-runtime";import r,{useMemo as o,useState as i,createContext as l,useContext as a,useRef as c,useEffect as s,useCallback as d,useSyncExternalStore as u,useLayoutEffect as m}from"react";import{sanitizeHtmlTokenAttrs as h,normalizeCustomHtmlTagName as f,convertHtmlAttrsToProps as p,tokenAttrsToRecord as g,NON_STRUCTURING_HTML_TAGS as v,isHtmlTagBlocked as w,sanitizeHtmlContent as y,BLOCKED_HTML_TAGS as x,isHtmlTagHardBlocked as k,sanitizeImageSrc as b,sanitizeHtmlAttrs as C,shouldOpenLinkInNewTab as M,toSafeSvgElement as N,getHtmlTagFromContent as B,stripCustomHtmlWrapper as S,shouldRenderUnknownHtmlTagAsText as T,mergeCustomHtmlTags as L,getMarkdown as E,parseMarkdownToStructure as $}from"stream-markdown-parser";import{E as D,v as P,d as A,M as R,F as H,A as W,H as F,m as I,r as _,P as O,D as j,L as z,k as V,l as K,N as X,t as q,n as U,w as Y,O as Z,o as G,j as J,I as Q,y as ee,c as ne,g as te,u as re,x as oe,a as ie,h as le,B as ae,q as ce,G as se,i as de,Q as ue,s as me,p as he}from"./codeBlockExtraProps-C-yKuTxD.js";import{createSmoothMarkdownStream as fe,normalizeShikiLanguage as pe,getHighlightRegistrationKey as ge,registerHighlightOnce as ve,getRuntimeShikiRegistrationConfig as we}from"markstream-core";import{createPortal as ye}from"react-dom";import{autoUpdate as xe,computePosition as ke,offset as be,flip as Ce,shift as Me}from"@floating-ui/dom";const Ne={note:"ℹ️",info:"ℹ️",tip:"💡",warning:"⚠️",danger:"❗",error:"⛔",caution:"⚠️"};function Be(t){const{node:r,ctx:l,renderNode:a,indexKey:c,isDark:s}=t,d=String(r.kind||"note"),u=o(()=>r.title&&String(r.title).trim().length?String(r.title):d.charAt(0).toUpperCase()+d.slice(1),[d,r.title]),[m,h]=i(()=>{var e;return!!r.collapsible&&!(null==(e=r.open)||e)}),f=o(()=>`admonition-${Math.random().toString(36).slice(2,9)}`,[]);/* @__PURE__ */
2
2
  return e("div",{className:`admonition admonition-${d}${s?" is-dark":""}`,"data-index-key":c,children:[
3
3
  /* @__PURE__ */e("div",{id:f,className:"admonition-header",children:[Ne[d]&&/* @__PURE__ */n("span",{className:"admonition-icon",children:Ne[d]}),
4
- /* @__PURE__ */n("span",{className:"admonition-title",children:u}),r.collapsible&&/* @__PURE__ */n("button",{type:"button",className:"admonition-toggle","aria-expanded":!m,"aria-controls":`${f}-content`,title:m?"Expand":"Collapse",onClick:()=>h(e=>!e),children:/* @__PURE__ */n("span",{children:m?"▶":"▼"})})]}),!m&&/* @__PURE__ */n("div",{id:`${f}-content`,className:"admonition-content","aria-labelledby":f,children:l&&a?$(r.children,l,String(null!=c?c:f),a):null})]})}const Se=l(!1),Te=l(null);function Le(){return a(Te)}const Ee=l(null);function De(e,n){var t,r;const o="undefined"!=typeof window&&"undefined"!=typeof document,i=o?null!=(t=window.requestIdleCallback)?t:e=>window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),16):null,l=o?null!=(r=window.cancelIdleCallback)?r:e=>window.clearTimeout(e):null;let a=null,c=null;const s=/* @__PURE__ */new Map,d=/* @__PURE__ */new Set;let u=null;const m=()=>{if(!s.size){try{null==a||a.disconnect()}catch{}a=null,c=null,d.size||(()=>{if(null!=u){try{null==l||l(u)}catch{}u=null}})()}},h=e=>{const n=s.get(e);if(n){n.state.current=!0;try{n.resolve()}catch{}try{null==a||a.unobserve(e)}catch{}s.delete(e),d.delete(e),m()}},f=()=>{i&&null==u&&d.size&&(u=i(()=>{u=null;const e=d.values().next().value;e&&(d.delete(e),h(e),d.size&&f())},{timeout:1200}))};return(t,r)=>{var i,l;const u={current:!1};let p,g=!1;const v=new Promise(e=>{p=()=>{g||(g=!0,e())}}),w=()=>{if(s.has(t)){s.delete(t);try{null==a||a.unobserve(t)}catch{}}d.delete(t),m()};if(!o||!n())return u.current=!0,p(),{isVisible:()=>!0,whenVisible:v,destroy:w};const y=((n,t)=>{if(!o)return null;if("undefined"==typeof IntersectionObserver)return null;const r=((n,t)=>{var r;return{root:null!=(r=e())?r:null,rootMargin:n,threshold:t}})(n,t);if(a&&(l=r,(i=c)&&i.root===l.root&&i.rootMargin===l.rootMargin&&i.threshold===l.threshold))return a;var i,l;if(a)try{a.disconnect()}catch{}a=new IntersectionObserver(e=>{for(const n of e)(n.isIntersecting||n.intersectionRatio>0)&&h(n.target)},{root:r.root,rootMargin:r.rootMargin,threshold:r.threshold}),c=r;for(const e of s.keys())a.observe(e);return a})(null!=(i=null==r?void 0:r.rootMargin)?i:"300px",null!=(l=null==r?void 0:r.threshold)?l:0);return y?(s.set(t,{resolve:p,state:u}),y.observe(t),d.add(t),f(),{isVisible:()=>u.current,whenVisible:v,destroy:w}):(u.current=!0,p(),{isVisible:()=>!0,whenVisible:v,destroy:w})}}const $e=De(()=>null,()=>!0);function Pe({getRoot:e,enabled:t=!0,children:r}){const i=c(t);i.current=t;const l=c(e);l.current=e;const a=o(()=>De(()=>{var e,n;return null!=(n=null==(e=l.current)?void 0:e.call(l))?n:null},()=>i.current),[]);/* @__PURE__ */
5
- return n(Ee.Provider,{value:a,children:r})}function Ae(){var e;return null!=(e=a(Ee))?e:$e}function Re(e={}){const n=c(null);n.current||(n.current=fe(e));const t=n.current,[r,l]=i(()=>t.getSnapshot());return s(()=>{const e=t.subscribe(()=>{l(t.getSnapshot())});return t.resume(),l(t.getSnapshot()),()=>{e(),t.pause()}},[t]),o(()=>({...r,enqueue:t.enqueue,finish:t.finish,flush:t.flush,reset:t.reset,pause:t.pause,resume:t.resume,getSnapshot:t.getSnapshot}),[t,r])}function He(e){const{node:t}=e;/* @__PURE__ */
6
- return n("span",{className:"checkbox-node",children:/* @__PURE__ */n("input",{type:"checkbox",checked:Boolean(t.checked),disabled:!0,className:"checkbox-input",readOnly:!0})})}const 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 We(e){Object.assign(Fe,e)}function Ie(){return{t:e=>{var n;return null!=(n=Fe[e])?n:function(e){return(e.split(".").pop()||e).replace(/[_-]/g," ").replace(/([A-Z])/g," $1").replace(/\s+/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}(e)}}}let _e=null,Oe=null,je=null,ze=null,Ve=null,Ke=null;function Xe(){ze&&(clearTimeout(ze),ze=null),Ve&&(clearTimeout(Ve),Ve=null)}async function qe(e){if(!_e||!Oe)return;const{x:n,y:t}=await ke(Oe,_e,{placement:e,middleware:[be(8),Ce(),Me({padding:8})],strategy:"fixed"});_e.style.transform=`translate3d(${Math.round(n)}px, ${Math.round(t)}px, 0)`}function Ue(e,n,t="top",r=!1,o,i){if(!e||"undefined"==typeof document)return;if(_e||"undefined"==typeof document||(_e=document.createElement("div"),_e.className="markstream-react ms-tooltip",_e.setAttribute("role","tooltip"),_e.dataset.visible="false",_e.style.position="fixed",_e.style.left="0px",_e.style.top="0px",_e.style.transform="translate3d(0,0,0)",document.body.appendChild(_e)),!_e)return;Xe();const l=async()=>{if(_e){Oe=e,_e.textContent=n,_e.dataset.placement=t,_e.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",_e.dataset.visible="false",Ke=`tooltip-${Date.now()}-${Math.random().toString(36).slice(2)}`,_e.id=Ke;try{e.setAttribute("aria-describedby",Ke)}catch{}await qe(t),_e.dataset.visible="true",null==je||je(),je=xe(e,_e,()=>{qe(t)})}};r?l():ze=setTimeout(l,80)}function Ye(e=!1){if(!_e)return;Xe();const n=()=>{if(_e){if(_e.dataset.visible="false",Oe&&Ke)try{Oe.removeAttribute("aria-describedby")}catch{}Oe=null,Ke=null,je&&(je(),je=null)}};e?n():Ve=setTimeout(n,120)}const Ze=void 0!==import.meta&&Boolean(!1);let Ge=null;function Je(t){const{t:r}=Ie(),i=o(()=>{const e=t.code||"",n=e.trim().toLowerCase();return n.startsWith("<!doctype")||n.startsWith("<html")||n.startsWith("<body")?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${t.isDark?"#020617":"#ffffff"};\n color: ${t.isDark?"#e5e7eb":"#020617"};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`},[t.code,t.isDark]),l=o(()=>{return e=t.htmlPreviewSandbox,n=t.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!Ze||"undefined"==typeof console||Ge===e)return;const n=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);n.has("allow-scripts")&&n.has("allow-same-origin")&&(Ge=e,console.warn("[markstream-react] htmlPreviewSandbox contains both allow-scripts and allow-same-origin. Use this only for fully trusted content served from an isolated origin."))}(e),e):void 0!==e?"":!0===n?"allow-scripts":"";var e,n},[t.htmlPreviewAllowScripts,t.htmlPreviewSandbox]);return s(()=>{const e=e=>{var n;"Escape"!==e.key&&"Esc"!==e.key||null==(n=t.onClose)||n.call(t)};return"undefined"!=typeof window&&window.addEventListener("keydown",e),()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",e)}},[t]),"undefined"==typeof document?null:ye(
4
+ /* @__PURE__ */n("span",{className:"admonition-title",children:u}),r.collapsible&&/* @__PURE__ */n("button",{type:"button",className:"admonition-toggle","aria-expanded":!m,"aria-controls":`${f}-content`,title:m?"Expand":"Collapse",onClick:()=>h(e=>!e),children:/* @__PURE__ */n("span",{children:m?"▶":"▼"})})]}),!m&&/* @__PURE__ */n("div",{id:`${f}-content`,className:"admonition-content","aria-labelledby":f,children:l&&a?D(r.children,l,String(null!=c?c:f),a):null})]})}const Se=l(!1),Te=l(null);function Le(){return a(Te)}const Ee=l(null);function $e(e,n){var t,r;const o="undefined"!=typeof window&&"undefined"!=typeof document,i=o?null!=(t=window.requestIdleCallback)?t:e=>window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),16):null,l=o?null!=(r=window.cancelIdleCallback)?r:e=>window.clearTimeout(e):null;let a=null,c=null;const s=/* @__PURE__ */new Map,d=/* @__PURE__ */new Set;let u=null;const m=()=>{if(!s.size){try{null==a||a.disconnect()}catch{}a=null,c=null,d.size||(()=>{if(null!=u){try{null==l||l(u)}catch{}u=null}})()}},h=e=>{const n=s.get(e);if(n){n.state.current=!0;try{n.resolve()}catch{}try{null==a||a.unobserve(e)}catch{}s.delete(e),d.delete(e),m()}},f=()=>{i&&null==u&&d.size&&(u=i(()=>{u=null;const e=d.values().next().value;e&&(d.delete(e),h(e),d.size&&f())},{timeout:1200}))};return(t,r)=>{var i,l;const u={current:!1};let p,g=!1;const v=new Promise(e=>{p=()=>{g||(g=!0,e())}}),w=()=>{if(s.has(t)){s.delete(t);try{null==a||a.unobserve(t)}catch{}}d.delete(t),m()};if(!o||!n())return u.current=!0,p(),{isVisible:()=>!0,whenVisible:v,destroy:w};const y=((n,t)=>{if(!o)return null;if("undefined"==typeof IntersectionObserver)return null;const r=((n,t)=>{var r;return{root:null!=(r=e())?r:null,rootMargin:n,threshold:t}})(n,t);if(a&&(l=r,(i=c)&&i.root===l.root&&i.rootMargin===l.rootMargin&&i.threshold===l.threshold))return a;var i,l;if(a)try{a.disconnect()}catch{}a=new IntersectionObserver(e=>{for(const n of e)(n.isIntersecting||n.intersectionRatio>0)&&h(n.target)},{root:r.root,rootMargin:r.rootMargin,threshold:r.threshold}),c=r;for(const e of s.keys())a.observe(e);return a})(null!=(i=null==r?void 0:r.rootMargin)?i:"300px",null!=(l=null==r?void 0:r.threshold)?l:0);return y?(s.set(t,{resolve:p,state:u}),y.observe(t),d.add(t),f(),{isVisible:()=>u.current,whenVisible:v,destroy:w}):(u.current=!0,p(),{isVisible:()=>!0,whenVisible:v,destroy:w})}}const De=$e(()=>null,()=>!0);function Pe({getRoot:e,enabled:t=!0,children:r}){const i=c(t);i.current=t;const l=c(e);l.current=e;const a=o(()=>$e(()=>{var e,n;return null!=(n=null==(e=l.current)?void 0:e.call(l))?n:null},()=>i.current),[]);/* @__PURE__ */
5
+ return n(Ee.Provider,{value:a,children:r})}function Ae(){var e;return null!=(e=a(Ee))?e:De}function Re(e={}){const n=c(null);n.current||(n.current=fe(e));const t=n.current,[r,l]=i(()=>t.getSnapshot());return s(()=>{const e=t.subscribe(()=>{l(t.getSnapshot())});return t.resume(),l(t.getSnapshot()),()=>{e(),t.pause()}},[t]),o(()=>({...r,enqueue:t.enqueue,finish:t.finish,flush:t.flush,reset:t.reset,pause:t.pause,resume:t.resume,getSnapshot:t.getSnapshot}),[t,r])}function He(e){const{node:t}=e;/* @__PURE__ */
6
+ return n("span",{className:"checkbox-node",children:/* @__PURE__ */n("input",{type:"checkbox",checked:Boolean(t.checked),disabled:!0,className:"checkbox-input",readOnly:!0})})}const We={"common.copy":"Copy","common.copied":"Copied","common.decrease":"Decrease","common.reset":"Reset","common.increase":"Increase","common.expand":"Expand","common.collapse":"Collapse","common.preview":"Preview","common.source":"Source","common.export":"Export","common.open":"Open","common.close":"Close","common.zoomIn":"Zoom in","common.zoomOut":"Zoom out","common.resetZoom":"Reset zoom","image.loadError":"Image failed to load","image.loading":"Loading image..."};function Fe(e){Object.assign(We,e)}function Ie(){return{t:e=>{var n;return null!=(n=We[e])?n:function(e){return(e.split(".").pop()||e).replace(/[_-]/g," ").replace(/([A-Z])/g," $1").replace(/\s+/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}(e)}}}let _e=null,Oe=null,je=null,ze=null,Ve=null,Ke=null;function Xe(){ze&&(clearTimeout(ze),ze=null),Ve&&(clearTimeout(Ve),Ve=null)}async function qe(e){if(!_e||!Oe)return;const{x:n,y:t}=await ke(Oe,_e,{placement:e,middleware:[be(8),Ce(),Me({padding:8})],strategy:"fixed"});_e.style.transform=`translate3d(${Math.round(n)}px, ${Math.round(t)}px, 0)`}function Ue(e,n,t="top",r=!1,o,i){if(!e||"undefined"==typeof document)return;if(_e||"undefined"==typeof document||(_e=document.createElement("div"),_e.className="markstream-react ms-tooltip",_e.setAttribute("role","tooltip"),_e.dataset.visible="false",_e.style.position="fixed",_e.style.left="0px",_e.style.top="0px",_e.style.transform="translate3d(0,0,0)",document.body.appendChild(_e)),!_e)return;Xe();const l=async()=>{if(_e){Oe=e,_e.textContent=n,_e.dataset.placement=t,_e.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",_e.dataset.visible="false",Ke=`tooltip-${Date.now()}-${Math.random().toString(36).slice(2)}`,_e.id=Ke;try{e.setAttribute("aria-describedby",Ke)}catch{}await qe(t),_e.dataset.visible="true",null==je||je(),je=xe(e,_e,()=>{qe(t)})}};r?l():ze=setTimeout(l,80)}function Ye(e=!1){if(!_e)return;Xe();const n=()=>{if(_e){if(_e.dataset.visible="false",Oe&&Ke)try{Oe.removeAttribute("aria-describedby")}catch{}Oe=null,Ke=null,je&&(je(),je=null)}};e?n():Ve=setTimeout(n,120)}const Ze=void 0!==import.meta&&Boolean(!1);let Ge=null;function Je(t){const{t:r}=Ie(),i=o(()=>{const e=t.code||"",n=e.trim().toLowerCase();return n.startsWith("<!doctype")||n.startsWith("<html")||n.startsWith("<body")?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${t.isDark?"#020617":"#ffffff"};\n color: ${t.isDark?"#e5e7eb":"#020617"};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`},[t.code,t.isDark]),l=o(()=>{return e=t.htmlPreviewSandbox,n=t.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!Ze||"undefined"==typeof console||Ge===e)return;const n=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);n.has("allow-scripts")&&n.has("allow-same-origin")&&(Ge=e,console.warn("[markstream-react] htmlPreviewSandbox contains both allow-scripts and allow-same-origin. Use this only for fully trusted content served from an isolated origin."))}(e),e):void 0!==e?"":!0===n?"allow-scripts":"";var e,n},[t.htmlPreviewAllowScripts,t.htmlPreviewSandbox]);return s(()=>{const e=e=>{var n;"Escape"!==e.key&&"Esc"!==e.key||null==(n=t.onClose)||n.call(t)};return"undefined"!=typeof window&&window.addEventListener("keydown",e),()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",e)}},[t]),"undefined"==typeof document?null:ye(
7
7
  /* @__PURE__ */n("div",{className:"markstream-react html-preview-frame__backdrop"+(t.isDark?" html-preview-frame__backdrop--dark":""),onClick:()=>{var e;return null==(e=t.onClose)?void 0:e.call(t)},children:/* @__PURE__ */e("div",{className:"html-preview-frame"+(t.isDark?" html-preview-frame--dark":""),onClick:e=>e.stopPropagation(),children:[
8
8
  /* @__PURE__ */e("div",{className:"html-preview-frame__header",children:[
9
9
  /* @__PURE__ */e("div",{className:"html-preview-frame__title",children:[
10
10
  /* @__PURE__ */n("span",{className:"html-preview-frame__dot"}),
11
11
  /* @__PURE__ */n("span",{className:"html-preview-frame__label",children:t.title||`HTML ${r("common.preview")}`})]}),
12
12
  /* @__PURE__ */n("button",{type:"button",className:"html-preview-frame__close"+(t.isDark?" html-preview-frame__close--dark":""),onClick:()=>{var e;return null==(e=t.onClose)?void 0:e.call(t)},children:"×"})]}),
13
- /* @__PURE__ */n("iframe",{className:"html-preview-frame__iframe",sandbox:l,referrerPolicy:"no-referrer",src:"about:blank",srcDoc:i,title:t.title||"Preview"})]})}),document.body)}let Qe=!1;async function en(e){if(Qe)return;Qe=!0;const n=null==globalThis?void 0:globalThis.MonacoEnvironment;(!n||"function"!=typeof n.getWorker&&"function"!=typeof n.getWorkerUrl)&&(null==e?void 0:e.preloadMonacoWorkers)&&await e.preloadMonacoWorkers()}let nn=null,tn=!1;async function rn(){if(nn)return nn;if(tn)return null;try{const e=await import("stream-diffs");if(null==e?void 0:e.useMonaco)return nn=e,await en(nn),nn}catch{}try{const e=await import("stream-monaco");if(null==e?void 0:e.useMonaco)return nn=e,await en(nn),nn}catch{}return tn=!0,null}let on=null,ln=!1,an=null,cn=null,sn=null,dn=null,un=null;const mn=/* @__PURE__ */new WeakMap;let hn=0;function fn(e,n){const t=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&e&&"name"in e)return String(e.name);if("object"==typeof e){const n=mn.get(e);if(n)return n;try{const n=JSON.stringify(e);if(n)return mn.set(e,n),n}catch{}const t="__theme_"+ ++hn;return mn.set(e,t),t}return String(e)}(e);return t?(on!==n&&(on=n),ln||un!==t?!an||dn!==t&&cn!==t?(sn=e,dn=t,an||(ln=!0,an=(async()=>{for(;null!=sn&&null!=dn;){const e=sn,n=dn;if(sn=null,dn=null,un===n)continue;const t=on;if(!t)break;try{cn=n,await Promise.resolve(t(e)),un=n}catch{}}})().finally(()=>{ln=!1,an=null,cn=null}),an)):an:Promise.resolve()):Promise.resolve()}let pn=null,gn=null,vn=null;const wn=/* @__PURE__ */new Set,yn=/* @__PURE__ */new WeakMap;let xn=0;function kn(){for(const e of Array.from(wn))try{e()}catch{}}const bn={isShowPreview:!0,loading:!0,stream:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0},Cn=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});function Mn(e){var n;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const t=e;return{...Cn,...t,enabled:null==(n=t.enabled)||n}}return{...Cn}}function Nn(e,n){var t,r;const o=n?{...n}:{};if(!e)return o;const i=void 0===o.diffHideUnchangedRegions?{...Cn}:Mn(o.diffHideUnchangedRegions),l=void 0===o.hideUnchangedRegions?void 0:Mn(o.hideUnchangedRegions),a=null!=(t=o.diffUnchangedRegionStyle)?t:"line-info";return{maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:4,lineNumbersMinChars:2,glyphMargin:!1,minimap:{enabled:!1},renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,diffHideUnchangedRegions:i,useInlineViewWhenSpaceIsLimited:null!=(r=o.useInlineViewWhenSpaceIsLimited)&&r,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:a,diffHunkActionsOnHover:!1,diffHunkHoverHideDelayMs:160,...o,...void 0===l?{}:{hideUnchangedRegions:l},diffHideUnchangedRegions:i}}function Bn(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function Sn(e){const n=String(null!=e?e:"").match(/\d+(?:\.\d+)?/g);if(!n||n.length<3)return null;const[t,r,o]=n.slice(0,3).map(Number);return.2126*t+.7152*r+.0722*o}function Tn(e){var n,t;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==(t=null==(n=r.match(/^(?:rgba?|hsla?)\(([^)]+)\)/))?void 0:n[1])?void 0:t.split(/[\s,/]+/).filter(Boolean);return 4===(null==l?void 0:l.length)&&0===Number(l[3])}function Ln(r){var l;const a={...bn,...r},{node:u,isDark:m,loading:h,stream:f,isShowPreview:p,enableFontSizeControl:g,darkTheme:v,lightTheme:w,monacoOptions:y,themes:x,minWidth:k,maxWidth:b,showHeader:C,showCopyButton:M,showExpandButton:N,showPreviewButton:B,showCollapseButton:S,showFontSizeButtons:T,showLineNumbers:L,showTooltips:E}=a,D=c(null),$=c(null),j=c(null),z=c(null),V=c(null),K=c(null),X=c(null),q=c(0),U=c(null),Y=c(null),Z=Ae(),G=c(y),J=c(null),Q=c(null),ee=c([]),ne=c(null),te=c(!1),re=c(void 0),[oe,ie]=i(!1),[le,ae]=i(()=>"undefined"==typeof window),[ce,se]=i(!1),[de,ue]=i(!1),[me,he]=i(!1),[fe,pe]=i(()=>u.language||"plaintext"),[ge,ve]=i(()=>P(u.language)),[we,ye]=i(!1),[xe,ke]=i(!1),[be,Ce]=i(!1),[Me,Ne]=i(!1),[Be,Se]=i(0),{t:Te}=Ie();s(()=>{te.current=xe},[xe]);const Le=o(()=>Nn(Boolean(u.diff),y),[y,u.diff]),[Ee,De]=i(()=>{var e;const n=Number(null==(e=Nn(Boolean(u.diff),y))?void 0:e.fontSize);return Number.isFinite(n)&&n>0?n:A}),[$e,Pe]=i(Ee),Re=o(()=>!1!==E,[E]),He=!1!==L,Fe=d(()=>{var e,n;const t=null!=(n=null==(e=G.current)?void 0:e.MAX_HEIGHT)?n:500;if("number"==typeof t&&Number.isFinite(t))return Math.max(80,t);const r=String(t).match(/^(\d+(?:\.\d+)?)/),o=r?Number.parseFloat(r[1]):500;return Number.isFinite(o)?Math.max(80,o):500},[]),We=d(e=>{var n,t,r,o;if(oe)return;const i=D.current,l=j.current;if(!i||!l)return;const a="diff"===K.current?null==(n=l.getDiffEditorView)?void 0:n.call(l):null==(t=l.getEditorView)?void 0:t.call(l);if(!a)return;const c=Fe();try{null==(r=a.updateOptions)||r.call(a,{automaticLayout:e})}catch{}const s="diff"===K.current,d=s?"important":"";e?(i.style.minHeight="0px",i.style.setProperty("max-height","none",d),i.style.overflow="visible"):(i.style.minHeight="0px",i.style.setProperty("max-height",`${Math.ceil(c)}px`,d),i.style.overflow=s?"hidden":"auto");try{const n=()=>{if(s){const e=function(e){if("undefined"==typeof window)return null;try{const n=e.getBoundingClientRect();if(n.width<=0)return null;const t=[".editor.original .view-lines .view-line",".editor.modified .view-lines .view-line",".editor.original .margin-view-overlays .line-numbers",".editor.modified .margin-view-overlays .line-numbers",".editor.original .view-zones > div",".editor.modified .view-zones > div",".editor.original .margin-view-zones > div",".editor.modified .margin-view-zones > div",".editor.original .diff-hidden-lines",".editor.modified .diff-hidden-lines",".stream-monaco-diff-unchanged-bridge"];let r=0;for(const o of Array.from(e.querySelectorAll(t.join(",")))){if(!(o instanceof HTMLElement))continue;const e=window.getComputedStyle(o);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const t=o.getBoundingClientRect();t.height<=0||t.bottom<=n.top||(r=Math.max(r,t.bottom-n.top))}return r>0?Math.ceil(r+4):null}catch{return null}}(i);if(null!=e)return e}if("function"==typeof a.getContentHeight)return a.getContentHeight();if(s&&"function"==typeof a.getModifiedEditor){const e=a.getModifiedEditor();if(e&&"function"==typeof e.getContentHeight)return e.getContentHeight()}},t=Number(n());if(Number.isFinite(t)&&t>0){const n=e?t:Math.min(t,c);i.style.setProperty("height",`${Math.ceil(Math.max(1,n))}px`,d)}null==(o=a.layout)||o.call(a)}catch{}},[Fe,oe]),_e=d(e=>{if(We(e),"undefined"==typeof window||"function"!=typeof window.requestAnimationFrame)return;const n=window.requestAnimationFrame(()=>{We(e),window.requestAnimationFrame(()=>We(e))});return window.setTimeout(()=>We(e),180),()=>window.cancelAnimationFrame(n)},[We]),Oe=d(()=>{var e,n;for(const t of ee.current)try{"function"==typeof t?t():null==(e=null==t?void 0:t.dispose)||e.call(t)}catch{}ee.current=[],null==(n=ne.current)||n.disconnect(),ne.current=null},[]),je=d(()=>{var e,n,t;Oe();const r=j.current,o=D.current;if(!r||!o||"diff"!==K.current)return;const i=()=>_e(te.current),l=(e,n)=>{try{const t=null==e?void 0:e[n];if("function"!=typeof t)return;const r=t.call(e,i);r&&ee.current.push(r)}catch{}},a=null==(e=r.getDiffEditorView)?void 0:e.call(r),c=null==(n=null==a?void 0:a.getOriginalEditor)?void 0:n.call(a),s=null==(t=null==a?void 0:a.getModifiedEditor)?void 0:t.call(a);if(l(a,"onDidUpdateDiff"),l(c,"onDidContentSizeChange"),l(s,"onDidContentSizeChange"),l(c,"onDidLayoutChange"),l(s,"onDidLayoutChange"),"undefined"!=typeof window&&"function"==typeof window.MutationObserver){const e=new window.MutationObserver(e=>{e.some(e=>"childList"===e.type||"attributes"===e.type&&e.target!==o)&&i()});e.observe(o,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),ne.current=e}},[Oe,_e]);s(()=>R(()=>{Se(e=>e+1)}),[]),s(()=>{ve(P(u.language))},[u.language]);const ze=c(u);ze.current=u;const Ve=d(()=>{var e;q.current+=1;try{null==(e=z.current)||e.call(z)}catch{}Oe(),V.current=null,K.current=null,X.current=null,he(!1),ue(!1)},[Oe]),Ke=d(()=>{var e,n,t,r,o,i;const l=D.current,a=$.current;if(!l||!a)return;if(a.style.removeProperty("--vscode-editor-foreground"),a.style.removeProperty("--vscode-editor-background"),a.style.removeProperty("--vscode-editor-selectionBackground"),u.diff)return l.style.removeProperty("--vscode-editor-foreground"),l.style.removeProperty("--vscode-editor-background"),void l.style.removeProperty("--vscode-editor-selectionBackground");const c=null!=(e=l.querySelector(".monaco-editor"))?e:l;try{const e="undefined"!=typeof window&&window.getComputedStyle?window.getComputedStyle(c):null,s=String(null!=(n=null==e?void 0:e.getPropertyValue("--vscode-editor-foreground"))?n:"").trim()||String(null!=(t=null==e?void 0:e.color)?t:"").trim(),d=String(null!=(r=null==e?void 0:e.getPropertyValue("--vscode-editor-background"))?r:"").trim(),m=String(null!=(o=null==e?void 0:e.backgroundColor)?o:"").trim(),h=Tn(d)?Tn(m)?"":m:d,f=String(null!=(i=null==e?void 0:e.getPropertyValue("--vscode-editor-selectionBackground"))?i:"").trim();if(function(e,n,t,r){if(!t)return!1;const o=Sn(e),i=Sn(n);return r?null!=o&&o>170||null!=i&&i<110:null!=o&&o<85||null!=i&&i>190}(h,s,"plaintext"===H(String(u.language||ge||fe||"plaintext")),a.classList.contains("is-dark")))return l.style.removeProperty("--vscode-editor-foreground"),l.style.removeProperty("--vscode-editor-background"),void l.style.removeProperty("--vscode-editor-selectionBackground");s?l.style.setProperty("--vscode-editor-foreground",s):l.style.removeProperty("--vscode-editor-foreground"),h?l.style.setProperty("--vscode-editor-background",h):l.style.removeProperty("--vscode-editor-background"),f?l.style.setProperty("--vscode-editor-selectionBackground",f):l.style.removeProperty("--vscode-editor-selectionBackground")}catch{}},[ge,fe,u.diff,u.language]),Xe=o(()=>m?v:w,[v,m,w]),qe=d(()=>{var e;const n=null==Le?void 0:Le.theme,t=null!=(e=null!=Xe?Xe:n)?e:pn,r=Array.isArray(x)?x:[];if(!r.length||null==t)return t;const o=Bn(t),i=r.map(e=>Bn(e)).filter(e=>!!e);if(!o||i.includes(o))return t;const l=Bn(n);return null!=n&&l&&i.includes(l)?n:r[0]},[Xe,Le,x]),Ze=o(()=>qe(),[qe]),Ge=o(()=>function(e,n){var t;const r=(null!=(t=Bn(e))?t:"").toLowerCase();return r?["dark","night","moon","black","dracula","mocha","frappe","macchiato","palenight","ocean","poimandres","monokai","laserwave","tokyo","slack-dark","rose-pine","github-dark","material-theme","one-dark","catppuccin-mocha","catppuccin-frappe","catppuccin-macchiato"].some(e=>r.includes(e))&&!["light","latte","dawn","lotus"].some(e=>r.includes(e)):n}(Ze,Boolean(m)),[m,Ze]),Qe=o(()=>{if(!u.diff)return Ge?"dark":"light";const e=null==Le?void 0:Le.diffAppearance;return"light"===e||"dark"===e?e:m?"dark":"light"},[m,u.diff,Ge,Le]),en=o(()=>u.diff?"dark"===Qe:Ge,[Qe,u.diff,Ge]),nn=o(()=>{var e;const n=Le,t=F(Le,$e),r=function(e){var n,t;if(!e||"object"!=typeof e)return{top:0,bottom:0};const r=e;return{top:null!=(n=W(r.top))?n:0,bottom:null!=(t=W(r.bottom))?t:0}}(null==n?void 0:n.padding),o=u.diff?0:8,i=Boolean((null==n?void 0:n.padding)&&"object"==typeof n.padding),l=null!=(e=W(null==n?void 0:n.tabSize))?e:4;return{...t,paddingBottom:i?r.bottom:o,paddingTop:i?r.top:o,tabSize:l}},[$e,u.diff,Le]),tn=o(()=>!!u.diff&&!1===(null==Le?void 0:Le.renderSideBySide),[u.diff,Le]),on=o(()=>{var e,n,t;const r=String(u.diff?null!=(n=null!=(e=u.updatedCode)?e:u.code)?n:"":null!=(t=u.code)?t:"");if(!r)return 1;const o=h?r:r.replace(/\r\n$|\n$|\r$/,"");return Math.max(1,o.split(/\r\n|\r|\n/).length)},[h,u.code,u.diff,u.updatedCode]),ln=o(()=>Math.ceil(on*nn.lineHeight+nn.paddingTop+nn.paddingBottom),[on,nn]),an=o(()=>{const e={"--markstream-code-padding-left":"62px","--markstream-pre-diff-line-height":`${nn.lineHeight}px`,"--markstream-pre-line-number-top":`${nn.paddingTop}px`,"--markstream-pre-line-number-width":"36px","--markstream-pre-line-number-gap":"0px",fontSize:`${nn.fontSize}px`,lineHeight:`${nn.lineHeight}px`,paddingBottom:`${nn.paddingBottom}px`,paddingTop:`${nn.paddingTop}px`,tabSize:nn.tabSize};return nn.fontFamily&&(e.fontFamily=nn.fontFamily),e},[nn]),cn=d(()=>{const e={wordWrap:"on",wrappingIndent:"same",...Le||{},themes:x,stream:!1,disableFileHeader:!0,lineNumbers:He,fontSize:nn.fontSize,lineHeight:nn.lineHeight,padding:{top:nn.paddingTop,bottom:nn.paddingBottom},tabSize:nn.tabSize,...nn.fontFamily?{fontFamily:nn.fontFamily}:{},theme:Ze,...u.diff?{diffAppearance:Qe}:{},onThemeChange(){Ke()}},n="string"==typeof e.unsafeCSS?e.unsafeCSS:"";return e.unsafeCSS=`[data-file], [data-diff] { --diffs-min-number-column-width-default: 4ch !important; }\n${n}`.trim(),e},[Qe,He,u.diff,nn,Ze,Le,Ke,x]),sn=d(()=>{const e=cn(),n=J.current;if(!n)return J.current=e,e;for(const t of Object.keys(n))t in e||delete n[t];return Object.assign(n,e),n},[cn]),dn=o(()=>{var e,n,t,r,o,i,l;return JSON.stringify({diffLineStyle:null!=(e=null==Le?void 0:Le.diffLineStyle)?e:"background",diffUnchangedRegionStyle:null!=(n=null==Le?void 0:Le.diffUnchangedRegionStyle)?n:"line-info",diffHideUnchangedRegions:null==(t=null==Le?void 0:Le.diffHideUnchangedRegions)||t,renderSideBySide:null==(r=null==Le?void 0:Le.renderSideBySide)||r,enableSplitViewResizing:null==(o=null==Le?void 0:Le.enableSplitViewResizing)||o,ignoreTrimWhitespace:null==(i=null==Le?void 0:Le.ignoreTrimWhitespace)||i,originalEditable:null!=(l=null==Le?void 0:Le.originalEditable)&&l})},[Le]);s(()=>{G.current=Le,sn()},[Le,sn]),s(()=>()=>{var e,n,t;q.current+=1,null==(e=z.current)||e.call(z),Oe(),z.current=null,V.current=null,K.current=null,X.current=null,U.current=null,null==(t=null==(n=Y.current)?void 0:n.destroy)||t.call(n),Y.current=null},[Oe]),s(()=>{var e,n;if("undefined"==typeof window)return;if(le)return;const t=$.current;if(!t)return;null==(n=null==(e=Y.current)?void 0:e.destroy)||n.call(e);const r=Z(t,{rootMargin:"400px"});return Y.current=r,r.isVisible()&&ae(!0),r.whenVisible.then(()=>ae(!0)),()=>{r.destroy(),Y.current===r&&(Y.current=null)}},[Z,le]),s(()=>{let e=!0;return"undefined"==typeof window?()=>{e=!1}:j.current?(sn(),()=>{e=!1}):((async()=>{try{const t=await rn();if(!e)return;if(!t)return void ie(!0);const r=t.useMonaco,o=t.detectLanguage;if("function"==typeof o&&(U.current=o),"function"!=typeof r)return void ie(!0);const i=r(sn());j.current=i,"function"==typeof(n=i.setTheme)&&(vn=n,null!=pn&&null!=gn&&fn(pn,vn).then(()=>kn()).catch(()=>{})),z.current="function"==typeof i.safeClean?()=>i.safeClean():"function"==typeof i.cleanupEditor?()=>i.cleanupEditor():null,se(!0)}catch{e&&ie(!0)}var n})(),()=>{e=!1})},[sn]),s(()=>{var e;if(!u.language&&!ge&&U.current)try{const n=U.current(String(null!=(e=u.code)?e:""));n&&pe(n)}catch{}},[ge,u.code,u.language]);const un=o(()=>String(u.language||ge||fe||"plaintext"),[ge,fe,u.language]),mn=o(()=>P(un),[un]),hn=o(()=>H(mn),[mn]),yn=o(()=>"plaintext"===hn,[hn]),xn=o(()=>I(mn),[mn,Be]),Cn=o(()=>!!p&&("html"===mn||"svg"===mn),[mn,p]),Mn=o(()=>{const e=mn;return e?_[e]||e.charAt(0).toUpperCase()+e.slice(1):_[""]||"Plain Text"},[mn]),Ln=o(()=>{var e;return function(e,n,t){const r=function(e){const n=function(e){var n,t;const r=null!=(t=null==(n=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:n.trim())?t:"";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(!n)return"";const t=n.split(/\s+/).filter(Boolean);if(!t.length)return"";const r="diff"===t[0]?t.slice(1):t;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||n,caption:r?t?`Diff / ${n}`:n:""}}(String(null!=(e=u.raw)?e:""),Mn,Boolean(u.diff))},[Mn,u.diff,u.raw]),En=Ln.title,Dn=Ln.caption,$n=o(()=>{var e,n,t;return u.diff?null!=(n=null!=(e=u.updatedCode)?e:u.code)?n:"":null!=(t=u.code)?t:""},[u.code,u.diff,u.updatedCode]),Pn=o(()=>{const e=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},n={},t=e(k),r=e(b);return t&&(n.minWidth=t),r&&(n.maxWidth=r),u.diff?(n.color="var(--markstream-diff-shell-fg)",n.borderColor="var(--markstream-diff-shell-border)"):(n.color="var(--vscode-editor-foreground, var(--markstream-code-fallback-fg, var(--code-fg)))",n.backgroundColor="var(--vscode-editor-background, var(--markstream-code-fallback-bg, var(--code-bg)))",n.borderColor="var(--markstream-code-border-color, var(--code-border))"),n},[b,k,u.diff]),An=o(()=>{var e,n,t,r;return u.code.length>0||(null!=(n=null==(e=u.originalCode)?void 0:e.length)?n:0)>0||(null!=(r=null==(t=u.updatedCode)?void 0:t.length)?r:0)>0},[u.code,u.originalCode,u.updatedCode]),Rn=!1===f&&h||!1!==f&&h&&!An;s(()=>{if(oe)return;if(!ce)return;if(!de||!le)return;const e=j.current;sn();const n=()=>{var n;u.diff&&(null==(n=null==e?void 0:e.refreshDiffPresentation)||n.call(e)),Ke(),be||null==("undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>_e(xe)):null)&&_e(xe)};(null==e?void 0:e.setTheme)&&Ze?fn(Ze,e.setTheme).then(n).catch(()=>{}):n()},[be,de,Qe,xe,ce,u.diff,Ze,_e,Ke,sn,oe,le]),s(()=>{var e;if("undefined"!=typeof window)return e=()=>{Ke()},wn.add(e),()=>{wn.delete(e)}},[Ke]);const Hn=d(async()=>{var e,n;if(oe)return null;if(!le)return null;if(be)return null;if(Rn)return null;const t=j.current,r=D.current;if(!t||!r||!t.createEditor)return null;sn();const o=ze.current,i=o.diff?"diff":"single",l=X.current,a="diff"===i?Boolean(null==(e=t.getDiffEditorView)?void 0:e.call(t)):Boolean(null==(n=t.getEditorView)?void 0:n.call(t));if(K.current===i&&l===r&&a)return null;if(V.current)return V.current;q.current+=1;const c=q.current;ue(!0);const s=(async()=>{var e,n,i,l,a,s,d,u,m,h;try{null==(e=z.current)||e.call(z),K.current=null,X.current=null,he(!1);const f=hn;if(o.diff?"function"==typeof t.createDiffEditor?(K.current="diff",await t.createDiffEditor(r,String(null!=(n=o.originalCode)?n:""),String(null!=(i=o.updatedCode)?i:""),f)):(K.current="single",await t.createEditor(r,String(null!=(a=null!=(l=o.updatedCode)?l:o.code)?a:""),f)):(K.current="single",await t.createEditor(r,String(null!=(s=o.code)?s:""),f)),X.current=r,q.current!==c)return;const p=Number(null==(d=G.current)?void 0:d.fontSize);if(Number.isFinite(p)&&p>0){De(p),Pe(p);try{const e="diff"===K.current?null==(u=t.getDiffEditorView)?void 0:u.call(t):null==(m=t.getEditorView)?void 0:m.call(t);null==(h=null==e?void 0:e.updateOptions)||h.call(e,{fontSize:p,automaticLayout:!1})}catch{}}je(),Ke(),xe||be||_e(!1);const g=await async function(e,n){var t;if(n)try{if(!(await n()))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 n=null!=(t=e.querySelector([".monaco-editor",".monaco-diff-editor",".stream-diffs-shell",".stream-monaco-editor","[data-stream-diffs-state]"].join(",")))?t:e.firstElementChild;if(!n)continue;const o=n.getBoundingClientRect();if(o.width>0&&o.height>0)return await r(),!0}return!1}(r,t.whenVisualReady);if(q.current!==c)return;if(!g)return;We(xe),he(!0)}catch{q.current===c&&(re.current=hn,ie(!0))}})(),d=s.finally(()=>{V.current===d&&(V.current=null)});return V.current=d,d},[We,je,be,xe,hn,_e,Rn,Ke,sn,oe,le]);s(()=>{sn();const e=Q.current;if(Q.current=dn,!u.diff)return;if(oe)return;if(!ce||!le||!de)return;if(be||Rn)return;if(e===dn)return;let n=!1;return(async()=>{if(Ve(),!n)try{await Hn()}catch{}})(),()=>{n=!0}},[be,de,Hn,ce,dn,u.diff,Ve,Rn,sn,oe,le]),s(()=>{if(oe){const e=re.current;if(void 0===e||e===hn)return;return re.current=void 0,Ve(),void ie(!1)}ce&&le&&(be||Rn?Ve():Hn())},[be,Hn,hn,ce,Ve,Rn,oe,le]),s(()=>{var e;if(oe)return;if(!ce)return;if(!le)return;if(be)return;if(Rn)return;const n=j.current;if(!n)return;const t=String(null!=(e=u.code)?e:"");(async()=>{var e,r;let o=ge;if(!o&&U.current)try{o=P(U.current(t)),o&&ve(o)}catch{}const i=H(o||mn);if(n.createEditor&&D.current){try{await Promise.resolve(Hn())}catch{}const e=V.current;if(e)try{await e}catch{}}try{u.diff&&n.updateDiff?await Promise.resolve(n.updateDiff(String(null!=(e=u.originalCode)?e:""),String(null!=(r=u.updatedCode)?r:""),i)):n.updateCode&&await Promise.resolve(n.updateCode(t,i))}catch{}_e(xe)})()},[mn,ge,be,de,Hn,xe,ce,u.code,u.diff,u.originalCode,u.updatedCode,_e,Rn,oe,le]),s(()=>{if(oe)return;if(!ce)return;if(!le)return;if(be)return;if(Rn)return;if(!xe&&h)return;const e="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>_e(xe)):null;return null==e&&_e(xe),()=>{null!=e&&"undefined"!=typeof window&&"function"==typeof window.cancelAnimationFrame&&window.cancelAnimationFrame(e)}},[be,xe,h,ce,_e,Rn,oe,le]),s(()=>{var e,n,t;if(!g)return;if(oe)return;const r=j.current;if(r){try{const o="diff"===K.current?null==(e=r.getDiffEditorView)?void 0:e.call(r):null==(n=r.getEditorView)?void 0:n.call(r);null==(t=null==o?void 0:o.updateOptions)||t.call(o,{fontSize:$e})}catch{}_e(xe)}},[g,xe,$e,u.diff,_e,oe]),s(()=>{Re||Ye(!0)},[Re]);const Fn=d((e,n)=>{if(!Re)return;const t=e.currentTarget;t&&!t.disabled&&("clientX"in e&&(e.clientX,e.clientY),Ue(t,n,"top",!1,0,en))},[en,Re]),Wn=d(()=>{Re&&Ye()},[Re]),In=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(String($n)),ye(!0),null==(e=a.onCopy)||e.call(a,String($n)),setTimeout(()=>ye(!1),1e3)}catch{}},[a,$n]),_n=d(()=>{if(!Cn)return;const e="html"===mn?"text/html":"image/svg+xml",n="html"===mn?Te("artifacts.htmlPreviewTitle")||"HTML Preview":Te("artifacts.svgPreviewTitle")||"SVG Preview";"function"!=typeof a.onPreviewCode?"html"===mn&&Ne(e=>!e):a.onPreviewCode({node:u,artifactType:e,artifactTitle:n,id:`temp-${mn}-${Date.now()}`})},[mn,Cn,u,a,Te]);/* @__PURE__ */
14
- return e("div",{ref:$,className:["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",en?"border-gray-700/30":"border-gray-200",h?"is-rendering":"",en?"is-dark":"",u.diff?"is-diff":"",yn?"is-plain-text":""].join(" "),style:Pn,children:[C&&/* @__PURE__ */e("div",{className:"code-block-header",children:[
13
+ /* @__PURE__ */n("iframe",{className:"html-preview-frame__iframe",sandbox:l,referrerPolicy:"no-referrer",src:"about:blank",srcDoc:i,title:t.title||"Preview"})]})}),document.body)}let Qe=!1;async function en(e){if(Qe)return;Qe=!0;const n=null==globalThis?void 0:globalThis.MonacoEnvironment;(!n||"function"!=typeof n.getWorker&&"function"!=typeof n.getWorkerUrl)&&(null==e?void 0:e.preloadMonacoWorkers)&&await e.preloadMonacoWorkers()}let nn=null,tn=!1;async function rn(){if(nn)return nn;if(tn)return null;try{const e=await import("stream-diffs");if(null==e?void 0:e.useMonaco)return nn=e,await en(nn),nn}catch{}try{const e=await import("stream-monaco");if(null==e?void 0:e.useMonaco)return nn=e,await en(nn),nn}catch{}return tn=!0,null}let on=null,ln=!1,an=null,cn=null,sn=null,dn=null,un=null;const mn=/* @__PURE__ */new WeakMap;let hn=0;function fn(e,n){const t=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&e&&"name"in e)return String(e.name);if("object"==typeof e){const n=mn.get(e);if(n)return n;try{const n=JSON.stringify(e);if(n)return mn.set(e,n),n}catch{}const t="__theme_"+ ++hn;return mn.set(e,t),t}return String(e)}(e);return t?(on!==n&&(on=n),ln||un!==t?!an||dn!==t&&cn!==t?(sn=e,dn=t,an||(ln=!0,an=(async()=>{for(;null!=sn&&null!=dn;){const e=sn,n=dn;if(sn=null,dn=null,un===n)continue;const t=on;if(!t)break;try{cn=n,await Promise.resolve(t(e)),un=n}catch{}}})().finally(()=>{ln=!1,an=null,cn=null}),an)):an:Promise.resolve()):Promise.resolve()}let pn=null,gn=null,vn=null;const wn=/* @__PURE__ */new Set,yn=/* @__PURE__ */new WeakMap;let xn=0;function kn(){for(const e of Array.from(wn))try{e()}catch{}}const bn={isShowPreview:!0,loading:!0,stream:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0},Cn=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});async function Mn(e,n){var t;if(n)try{if(!(await n()))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 n=null!=(t=e.querySelector([".monaco-editor",".monaco-diff-editor",".stream-diffs-shell",".stream-monaco-editor","[data-stream-diffs-state]"].join(",")))?t:e.firstElementChild;if(!n)continue;const o=n.getBoundingClientRect();if(o.width>0&&o.height>0)return await r(),!0}return!1}function Nn(e){var n;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const t=e;return{...Cn,...t,enabled:null==(n=t.enabled)||n}}return{...Cn}}function Bn(e,n){var t,r;const o=n?{...n}:{};if(!e)return o;const i=void 0===o.diffHideUnchangedRegions?{...Cn}:Nn(o.diffHideUnchangedRegions),l=void 0===o.hideUnchangedRegions?void 0:Nn(o.hideUnchangedRegions),a=null!=(t=o.diffUnchangedRegionStyle)?t:"line-info";return{maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:4,lineNumbersMinChars:2,glyphMargin:!1,minimap:{enabled:!1},renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,diffHideUnchangedRegions:i,useInlineViewWhenSpaceIsLimited:null!=(r=o.useInlineViewWhenSpaceIsLimited)&&r,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:a,diffHunkActionsOnHover:!1,diffHunkHoverHideDelayMs:160,...o,...void 0===l?{}:{hideUnchangedRegions:l},diffHideUnchangedRegions:i}}function Sn(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function Tn(e){const n=String(null!=e?e:"").match(/\d+(?:\.\d+)?/g);if(!n||n.length<3)return null;const[t,r,o]=n.slice(0,3).map(Number);return.2126*t+.7152*r+.0722*o}function Ln(e){var n,t;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==(t=null==(n=r.match(/^(?:rgba?|hsla?)\(([^)]+)\)/))?void 0:n[1])?void 0:t.split(/[\s,/]+/).filter(Boolean);return 4===(null==l?void 0:l.length)&&0===Number(l[3])}function En(r){var l;const a={...bn,...r},{node:u,isDark:m,loading:h,stream:f,isShowPreview:p,enableFontSizeControl:g,darkTheme:v,lightTheme:w,monacoOptions:y,themes:x,minWidth:k,maxWidth:b,showHeader:C,showCopyButton:M,showExpandButton:N,showPreviewButton:B,showCollapseButton:S,showFontSizeButtons:T,showLineNumbers:L,showTooltips:E}=a,$=c(null),D=c(null),j=c(null),z=c(null),V=c(null),K=c(null),X=c(null),q=c(0),U=c(null),Y=c(null),Z=Ae(),G=c(y),J=c(null),Q=c(null),ee=c([]),ne=c(null),te=c(!1),re=c(void 0),[oe,ie]=i(!1),[le,ae]=i(()=>"undefined"==typeof window),[ce,se]=i(!1),[de,ue]=i(!1),[me,he]=i(!1),[fe,pe]=i(()=>u.language||"plaintext"),[ge,ve]=i(()=>P(u.language)),[we,ye]=i(!1),[xe,ke]=i(!1),[be,Ce]=i(!1),[Me,Ne]=i(!1),[Be,Se]=i(0),{t:Te}=Ie();s(()=>{te.current=xe},[xe]);const Le=o(()=>Bn(Boolean(u.diff),y),[y,u.diff]),[Ee,$e]=i(()=>{var e;const n=Number(null==(e=Bn(Boolean(u.diff),y))?void 0:e.fontSize);return Number.isFinite(n)&&n>0?n:A}),[De,Pe]=i(Ee),Re=o(()=>!1!==E,[E]),He=!1!==L,We=d(()=>{var e,n;const t=null!=(n=null==(e=G.current)?void 0:e.MAX_HEIGHT)?n:500;if("number"==typeof t&&Number.isFinite(t))return Math.max(80,t);const r=String(t).match(/^(\d+(?:\.\d+)?)/),o=r?Number.parseFloat(r[1]):500;return Number.isFinite(o)?Math.max(80,o):500},[]),Fe=d(e=>{var n,t,r,o;if(oe)return;const i=$.current,l=j.current;if(!i||!l)return;const a="diff"===K.current?null==(n=l.getDiffEditorView)?void 0:n.call(l):null==(t=l.getEditorView)?void 0:t.call(l);if(!a)return;const c=We();try{null==(r=a.updateOptions)||r.call(a,{automaticLayout:e})}catch{}const s="diff"===K.current,d=s?"important":"";e?(i.style.minHeight="0px",i.style.setProperty("max-height","none",d),i.style.overflow="visible"):(i.style.minHeight="0px",i.style.setProperty("max-height",`${Math.ceil(c)}px`,d),i.style.overflow=s?"hidden":"auto");try{const n=()=>{if(s){const e=function(e){if("undefined"==typeof window)return null;try{const n=e.getBoundingClientRect();if(n.width<=0)return null;const t=[".editor.original .view-lines .view-line",".editor.modified .view-lines .view-line",".editor.original .margin-view-overlays .line-numbers",".editor.modified .margin-view-overlays .line-numbers",".editor.original .view-zones > div",".editor.modified .view-zones > div",".editor.original .margin-view-zones > div",".editor.modified .margin-view-zones > div",".editor.original .diff-hidden-lines",".editor.modified .diff-hidden-lines",".stream-monaco-diff-unchanged-bridge"];let r=0;for(const o of Array.from(e.querySelectorAll(t.join(",")))){if(!(o instanceof HTMLElement))continue;const e=window.getComputedStyle(o);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const t=o.getBoundingClientRect();t.height<=0||t.bottom<=n.top||(r=Math.max(r,t.bottom-n.top))}return r>0?Math.ceil(r+4):null}catch{return null}}(i);if(null!=e)return e}if("function"==typeof a.getContentHeight)return a.getContentHeight();if(s&&"function"==typeof a.getModifiedEditor){const e=a.getModifiedEditor();if(e&&"function"==typeof e.getContentHeight)return e.getContentHeight()}},t=Number(n());if(Number.isFinite(t)&&t>0){const n=e?t:Math.min(t,c);i.style.setProperty("height",`${Math.ceil(Math.max(1,n))}px`,d)}null==(o=a.layout)||o.call(a)}catch{}},[We,oe]),_e=d(e=>{if(Fe(e),"undefined"==typeof window||"function"!=typeof window.requestAnimationFrame)return;const n=window.requestAnimationFrame(()=>{Fe(e),window.requestAnimationFrame(()=>Fe(e))});return window.setTimeout(()=>Fe(e),180),()=>window.cancelAnimationFrame(n)},[Fe]),Oe=d(()=>{var e,n;for(const t of ee.current)try{"function"==typeof t?t():null==(e=null==t?void 0:t.dispose)||e.call(t)}catch{}ee.current=[],null==(n=ne.current)||n.disconnect(),ne.current=null},[]),je=d(()=>{var e,n,t;Oe();const r=j.current,o=$.current;if(!r||!o||"diff"!==K.current)return;const i=()=>_e(te.current),l=(e,n)=>{try{const t=null==e?void 0:e[n];if("function"!=typeof t)return;const r=t.call(e,i);r&&ee.current.push(r)}catch{}},a=null==(e=r.getDiffEditorView)?void 0:e.call(r),c=null==(n=null==a?void 0:a.getOriginalEditor)?void 0:n.call(a),s=null==(t=null==a?void 0:a.getModifiedEditor)?void 0:t.call(a);if(l(a,"onDidUpdateDiff"),l(c,"onDidContentSizeChange"),l(s,"onDidContentSizeChange"),l(c,"onDidLayoutChange"),l(s,"onDidLayoutChange"),"undefined"!=typeof window&&"function"==typeof window.MutationObserver){const e=new window.MutationObserver(e=>{e.some(e=>"childList"===e.type||"attributes"===e.type&&e.target!==o)&&i()});e.observe(o,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),ne.current=e}},[Oe,_e]);s(()=>R(()=>{Se(e=>e+1)}),[]),s(()=>{ve(P(u.language))},[u.language]);const ze=c(u);ze.current=u;const Ve=d(()=>{var e;q.current+=1;try{null==(e=z.current)||e.call(z)}catch{}Oe(),V.current=null,K.current=null,X.current=null,he(!1),ue(!1)},[Oe]),Ke=o(()=>m?v:w,[v,m,w]),Xe=d(()=>{var e;const n=null==Le?void 0:Le.theme,t=null!=(e=null!=Ke?Ke:n)?e:pn,r=Array.isArray(x)?x:[];if(!r.length||null==t)return t;const o=Sn(t),i=r.map(e=>Sn(e)).filter(e=>!!e);if(!o||i.includes(o))return t;const l=Sn(n);return null!=n&&l&&i.includes(l)?n:r[0]},[Ke,Le,x]),qe=o(()=>Xe(),[Xe]),Ze=o(()=>function(e,n){var t;const r=(null!=(t=Sn(e))?t:"").toLowerCase();return r?["dark","night","moon","black","dracula","mocha","frappe","macchiato","palenight","ocean","poimandres","monokai","laserwave","tokyo","slack-dark","rose-pine","github-dark","material-theme","one-dark","catppuccin-mocha","catppuccin-frappe","catppuccin-macchiato"].some(e=>r.includes(e))&&!["light","latte","dawn","lotus"].some(e=>r.includes(e)):n}(qe,Boolean(m)),[m,qe]),Ge=o(()=>{if(!u.diff)return Ze?"dark":"light";const e=null==Le?void 0:Le.diffAppearance;return"light"===e||"dark"===e?e:m?"dark":"light"},[m,u.diff,Ze,Le]),Qe=o(()=>u.diff?"dark"===Ge:Ze,[Ge,u.diff,Ze]),en=o(()=>{var e;const n=Le,t=H(Le,De),r=function(e){var n,t;if(!e||"object"!=typeof e)return{top:0,bottom:0};const r=e;return{top:null!=(n=W(r.top))?n:0,bottom:null!=(t=W(r.bottom))?t:0}}(null==n?void 0:n.padding),o=u.diff?0:8,i=Boolean((null==n?void 0:n.padding)&&"object"==typeof n.padding),l=null!=(e=W(null==n?void 0:n.tabSize))?e:4;return{...t,paddingBottom:i?r.bottom:o,paddingTop:i?r.top:o,tabSize:l}},[De,u.diff,Le]),nn=o(()=>!!u.diff&&!1===(null==Le?void 0:Le.renderSideBySide),[u.diff,Le]),tn=o(()=>{var e,n,t;const r=String(u.diff?null!=(n=null!=(e=u.updatedCode)?e:u.code)?n:"":null!=(t=u.code)?t:"");if(!r)return 1;const o=h?r:r.replace(/\r\n$|\n$|\r$/,"");return Math.max(1,o.split(/\r\n|\r|\n/).length)},[h,u.code,u.diff,u.updatedCode]),on=o(()=>Math.ceil(tn*en.lineHeight+en.paddingTop+en.paddingBottom),[tn,en]),ln=o(()=>{const e={"--markstream-code-padding-left":"62px","--markstream-pre-diff-line-height":`${en.lineHeight}px`,"--markstream-pre-line-number-top":`${en.paddingTop}px`,"--markstream-pre-line-number-width":"36px","--markstream-pre-line-number-gap":"0px",fontSize:`${en.fontSize}px`,lineHeight:`${en.lineHeight}px`,paddingBottom:`${en.paddingBottom}px`,paddingTop:`${en.paddingTop}px`,tabSize:en.tabSize};return en.fontFamily&&(e.fontFamily=en.fontFamily),e},[en]),an=d(()=>{var e,n,t,r,o,i;const l=$.current,a=D.current;if(!l||!a)return;a.style.removeProperty("--vscode-editor-foreground"),a.style.removeProperty("--vscode-editor-background"),a.style.removeProperty("--vscode-editor-selectionBackground"),l.style.setProperty("--diffs-tab-size",String(en.tabSize));const c=null==Le?void 0:Le.padding;if(c&&"object"==typeof c?l.style.setProperty("--diffs-gap-block",`${en.paddingTop}px`):l.style.removeProperty("--diffs-gap-block"),u.diff)return l.style.removeProperty("--vscode-editor-foreground"),l.style.removeProperty("--vscode-editor-background"),void l.style.removeProperty("--vscode-editor-selectionBackground");const s=null!=(e=l.querySelector(".monaco-editor"))?e:l;try{const e="undefined"!=typeof window&&window.getComputedStyle?window.getComputedStyle(s):null,c=String(null!=(n=null==e?void 0:e.getPropertyValue("--vscode-editor-foreground"))?n:"").trim()||String(null!=(t=null==e?void 0:e.color)?t:"").trim(),d=String(null!=(r=null==e?void 0:e.getPropertyValue("--vscode-editor-background"))?r:"").trim(),m=String(null!=(o=null==e?void 0:e.backgroundColor)?o:"").trim(),h=Ln(d)?Ln(m)?"":m:d,f=String(null!=(i=null==e?void 0:e.getPropertyValue("--vscode-editor-selectionBackground"))?i:"").trim();if(function(e,n,t,r){if(!t)return!1;const o=Tn(e),i=Tn(n);return r?null!=o&&o>170||null!=i&&i<110:null!=o&&o<85||null!=i&&i>190}(h,c,"plaintext"===F(String(u.language||ge||fe||"plaintext")),a.classList.contains("is-dark")))return l.style.removeProperty("--vscode-editor-foreground"),l.style.removeProperty("--vscode-editor-background"),void l.style.removeProperty("--vscode-editor-selectionBackground");c?l.style.setProperty("--vscode-editor-foreground",c):l.style.removeProperty("--vscode-editor-foreground"),h?l.style.setProperty("--vscode-editor-background",h):l.style.removeProperty("--vscode-editor-background"),f?l.style.setProperty("--vscode-editor-selectionBackground",f):l.style.removeProperty("--vscode-editor-selectionBackground")}catch{}},[ge,fe,u.diff,u.language,en,Le]),cn=d(()=>{const e={wordWrap:"on",wrappingIndent:"same",...Le||{},themes:x,stream:!1,disableFileHeader:!0,lineNumbers:He,fontSize:en.fontSize,lineHeight:en.lineHeight,padding:{top:en.paddingTop,bottom:en.paddingBottom},tabSize:en.tabSize,...en.fontFamily?{fontFamily:en.fontFamily}:{},theme:qe,...u.diff?{diffAppearance:Ge}:{},onThemeChange(){an()}},n="string"==typeof e.unsafeCSS?e.unsafeCSS:"";return e.unsafeCSS=`[data-file], [data-diff] { --diffs-min-number-column-width-default: 2ch !important; }\n${n}`.trim(),e},[Ge,He,u.diff,en,qe,Le,an,x]),sn=d(()=>{const e=cn(),n=J.current;if(!n)return J.current=e,e;for(const t of Object.keys(n))t in e||delete n[t];return Object.assign(n,e),n},[cn]),dn=o(()=>{var e,n,t,r,o,i,l;return JSON.stringify({diffLineStyle:null!=(e=null==Le?void 0:Le.diffLineStyle)?e:"background",diffUnchangedRegionStyle:null!=(n=null==Le?void 0:Le.diffUnchangedRegionStyle)?n:"line-info",diffHideUnchangedRegions:null==(t=null==Le?void 0:Le.diffHideUnchangedRegions)||t,renderSideBySide:null==(r=null==Le?void 0:Le.renderSideBySide)||r,enableSplitViewResizing:null==(o=null==Le?void 0:Le.enableSplitViewResizing)||o,ignoreTrimWhitespace:null==(i=null==Le?void 0:Le.ignoreTrimWhitespace)||i,originalEditable:null!=(l=null==Le?void 0:Le.originalEditable)&&l})},[Le]);s(()=>{G.current=Le,sn()},[Le,sn]),s(()=>()=>{var e,n,t;q.current+=1,null==(e=z.current)||e.call(z),Oe(),z.current=null,V.current=null,K.current=null,X.current=null,U.current=null,null==(t=null==(n=Y.current)?void 0:n.destroy)||t.call(n),Y.current=null},[Oe]),s(()=>{var e,n;if("undefined"==typeof window)return;if(le)return;const t=D.current;if(!t)return;null==(n=null==(e=Y.current)?void 0:e.destroy)||n.call(e);const r=Z(t,{rootMargin:"400px"});return Y.current=r,r.isVisible()&&ae(!0),r.whenVisible.then(()=>ae(!0)),()=>{r.destroy(),Y.current===r&&(Y.current=null)}},[Z,le]),s(()=>{let e=!0;return"undefined"==typeof window?()=>{e=!1}:j.current?(sn(),()=>{e=!1}):((async()=>{try{const t=await rn();if(!e)return;if(!t)return void ie(!0);const r=t.useMonaco,o=t.detectLanguage;if("function"==typeof o&&(U.current=o),"function"!=typeof r)return void ie(!0);const i=r(sn());j.current=i,"function"==typeof(n=i.setTheme)&&(vn=n,null!=pn&&null!=gn&&fn(pn,vn).then(()=>kn()).catch(()=>{})),z.current="function"==typeof i.safeClean?()=>i.safeClean():"function"==typeof i.cleanupEditor?()=>i.cleanupEditor():null,se(!0)}catch{e&&ie(!0)}var n})(),()=>{e=!1})},[sn]),s(()=>{var e;if(!u.language&&!ge&&U.current)try{const n=U.current(String(null!=(e=u.code)?e:""));n&&pe(n)}catch{}},[ge,u.code,u.language]);const un=o(()=>String(u.language||ge||fe||"plaintext"),[ge,fe,u.language]),mn=o(()=>P(un),[un]),hn=o(()=>F(mn),[mn]),yn=o(()=>"plaintext"===hn,[hn]),xn=o(()=>I(mn),[mn,Be]),Cn=o(()=>!!p&&("html"===mn||"svg"===mn),[mn,p]),Nn=o(()=>{const e=mn;return e?_[e]||e.charAt(0).toUpperCase()+e.slice(1):_[""]||"Plain Text"},[mn]),En=o(()=>{var e;return function(e,n,t){const r=function(e){const n=function(e){var n,t;const r=null!=(t=null==(n=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:n.trim())?t:"";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(!n)return"";const t=n.split(/\s+/).filter(Boolean);if(!t.length)return"";const r="diff"===t[0]?t.slice(1):t;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||n,caption:r?t?`Diff / ${n}`:n:""}}(String(null!=(e=u.raw)?e:""),Nn,Boolean(u.diff))},[Nn,u.diff,u.raw]),$n=En.title,Dn=En.caption,Pn=o(()=>{var e,n,t;return u.diff?null!=(n=null!=(e=u.updatedCode)?e:u.code)?n:"":null!=(t=u.code)?t:""},[u.code,u.diff,u.updatedCode]),An=o(()=>{const e=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},n={},t=e(k),r=e(b);return t&&(n.minWidth=t),r&&(n.maxWidth=r),u.diff?(n.color="var(--markstream-diff-shell-fg)",n.borderColor="var(--markstream-diff-shell-border)"):(n.color="var(--vscode-editor-foreground, var(--markstream-code-fallback-fg, var(--code-fg)))",n.backgroundColor="var(--vscode-editor-background, var(--markstream-code-fallback-bg, var(--code-bg)))",n.borderColor="var(--markstream-code-border-color, var(--code-border))"),n},[b,k,u.diff]),Rn=o(()=>{var e,n,t,r;return u.code.length>0||(null!=(n=null==(e=u.originalCode)?void 0:e.length)?n:0)>0||(null!=(r=null==(t=u.updatedCode)?void 0:t.length)?r:0)>0},[u.code,u.originalCode,u.updatedCode]),Hn=!1===f&&h||!1!==f&&h&&!Rn;s(()=>{if(oe)return;if(!ce)return;if(!de||!le)return;const e=j.current;sn();const n=()=>{var n;u.diff&&(null==(n=null==e?void 0:e.refreshDiffPresentation)||n.call(e)),an(),be||null==("undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>_e(xe)):null)&&_e(xe)};(null==e?void 0:e.setTheme)&&qe?fn(qe,e.setTheme).then(n).catch(()=>{}):n()},[be,de,Ge,xe,ce,u.diff,qe,_e,an,sn,oe,le]),s(()=>{var e;if("undefined"!=typeof window)return e=()=>{an()},wn.add(e),()=>{wn.delete(e)}},[an]);const Wn=d(async()=>{var e,n;if(oe)return null;if(!le)return null;if(be)return null;if(Hn)return null;const t=j.current,r=$.current;if(!t||!r||!t.createEditor)return null;sn();const o=ze.current,i=o.diff?"diff":"single",l=X.current,a="diff"===i?Boolean(null==(e=t.getDiffEditorView)?void 0:e.call(t)):Boolean(null==(n=t.getEditorView)?void 0:n.call(t));if(K.current===i&&l===r&&a)return null;if(V.current)return V.current;q.current+=1;const c=q.current;ue(!0);const s=(async()=>{var e,n,i,l,a,s,d,u,m,h;try{null==(e=z.current)||e.call(z),K.current=null,X.current=null,he(!1);const f=hn;if(o.diff?"function"==typeof t.createDiffEditor?(K.current="diff",await t.createDiffEditor(r,String(null!=(n=o.originalCode)?n:""),String(null!=(i=o.updatedCode)?i:""),f)):(K.current="single",await t.createEditor(r,String(null!=(a=null!=(l=o.updatedCode)?l:o.code)?a:""),f)):(K.current="single",await t.createEditor(r,String(null!=(s=o.code)?s:""),f)),X.current=r,q.current!==c)return;const p=Number(null==(d=G.current)?void 0:d.fontSize);if(Number.isFinite(p)&&p>0){$e(p),Pe(p);try{const e="diff"===K.current?null==(u=t.getDiffEditorView)?void 0:u.call(t):null==(m=t.getEditorView)?void 0:m.call(t);null==(h=null==e?void 0:e.updateOptions)||h.call(e,{fontSize:p,automaticLayout:!1})}catch{}}je(),an(),xe||be||_e(!1);const g=await Promise.race([Mn(r,t.whenVisualReady),new Promise(e=>{window.setTimeout(()=>e(!0),1500)})]);if(q.current!==c)return;if(!g)return;Fe(xe),he(!0)}catch{q.current===c&&(re.current=hn,ie(!0))}})().finally(()=>{V.current===s&&(V.current=null)});return V.current=s,s},[Fe,je,be,xe,hn,_e,Hn,an,sn,oe,le]);s(()=>{sn();const e=Q.current;if(Q.current=dn,!u.diff)return;if(oe)return;if(!ce||!le||!de)return;if(be||Hn)return;if(e===dn)return;let n=!1;return(async()=>{if(Ve(),!n)try{await Wn()}catch{}})(),()=>{n=!0}},[be,de,Wn,ce,dn,u.diff,Ve,Hn,sn,oe,le]),s(()=>{if(oe){const e=re.current;if(void 0===e||e===hn)return;return re.current=void 0,Ve(),void ie(!1)}ce&&le&&(be||Hn?Ve():Wn())},[be,Wn,hn,ce,Ve,Hn,oe,le]),s(()=>{var e;if(oe)return;if(!ce)return;if(!le)return;if(be)return;if(Hn)return;const n=j.current;if(!n)return;const t=String(null!=(e=u.code)?e:"");(async()=>{var e,r;let o=ge;if(!o&&U.current)try{o=P(U.current(t)),o&&ve(o)}catch{}const i=F(o||mn);if(n.createEditor&&$.current){try{await Promise.resolve(Wn())}catch{}const e=V.current;if(e)try{await e}catch{}}try{u.diff&&n.updateDiff?await Promise.resolve(n.updateDiff(String(null!=(e=u.originalCode)?e:""),String(null!=(r=u.updatedCode)?r:""),i)):n.updateCode&&await Promise.resolve(n.updateCode(t,i))}catch{}_e(xe)})()},[mn,ge,be,de,Wn,xe,ce,u.code,u.diff,u.originalCode,u.updatedCode,_e,Hn,oe,le]),s(()=>{if(oe)return;if(!ce)return;if(!le)return;if(be)return;if(Hn)return;if(!xe&&h)return;const e="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame?window.requestAnimationFrame(()=>_e(xe)):null;return null==e&&_e(xe),()=>{null!=e&&"undefined"!=typeof window&&"function"==typeof window.cancelAnimationFrame&&window.cancelAnimationFrame(e)}},[be,xe,h,ce,_e,Hn,oe,le]),s(()=>{var e,n,t;if(!g)return;if(oe)return;const r=j.current;if(r){try{const o="diff"===K.current?null==(e=r.getDiffEditorView)?void 0:e.call(r):null==(n=r.getEditorView)?void 0:n.call(r);null==(t=null==o?void 0:o.updateOptions)||t.call(o,{fontSize:De})}catch{}_e(xe)}},[g,xe,De,u.diff,_e,oe]),s(()=>{Re||Ye(!0)},[Re]);const Fn=d((e,n)=>{if(!Re)return;const t=e.currentTarget;t&&!t.disabled&&("clientX"in e&&(e.clientX,e.clientY),Ue(t,n,"top",!1,0,Qe))},[Qe,Re]),In=d(()=>{Re&&Ye()},[Re]),_n=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(String(Pn)),ye(!0),null==(e=a.onCopy)||e.call(a,String(Pn)),setTimeout(()=>ye(!1),1e3)}catch{}},[a,Pn]),On=d(()=>{if(!Cn)return;const e="html"===mn?"text/html":"image/svg+xml",n="html"===mn?Te("artifacts.htmlPreviewTitle")||"HTML Preview":Te("artifacts.svgPreviewTitle")||"SVG Preview";"function"!=typeof a.onPreviewCode?"html"===mn&&Ne(e=>!e):a.onPreviewCode({node:u,artifactType:e,artifactTitle:n,id:`temp-${mn}-${Date.now()}`})},[mn,Cn,u,a,Te]);/* @__PURE__ */
14
+ return e("div",{ref:D,className:["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",Qe?"border-gray-700/30":"border-gray-200",h?"is-rendering":"",Qe?"is-dark":"",u.diff?"is-diff":"",yn?"is-plain-text":""].join(" "),style:An,children:[C&&/* @__PURE__ */e("div",{className:"code-block-header",children:[
15
15
  /* @__PURE__ */e("div",{className:"code-header-main",children:[
16
16
  /* @__PURE__ */n("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:xn}}),
17
17
  /* @__PURE__ */e("div",{className:"code-header-copy min-w-0",children:[
18
- /* @__PURE__ */n("div",{className:"code-header-title truncate",children:En}),Dn&&/* @__PURE__ */n("div",{className:"code-header-caption truncate",children:Dn})]})]}),
19
- /* @__PURE__ */e("div",{className:"code-header-actions",children:[S&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-pressed":be,onClick:()=>Ce(e=>!e),onMouseEnter:e=>Fn(e,be?Te("common.expand")||"Expand":Te("common.collapse")||"Collapse"),onFocus:e=>Fn(e,be?Te("common.expand")||"Expand":Te("common.collapse")||"Collapse"),onMouseLeave:Wn,onBlur:Wn,children:/* @__PURE__ */n("svg",{style:{rotate:be?"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:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),T&&g&&/* @__PURE__ */e(t,{children:[
20
- /* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors",disabled:$e<=10,onClick:()=>Pe(e=>Math.max(10,e-1)),onMouseEnter:e=>Fn(e,Te("common.decrease")||"Decrease"),onFocus:e=>Fn(e,Te("common.decrease")||"Decrease"),onMouseLeave:Wn,onBlur:Wn,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14"})})}),
21
- /* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors",disabled:$e===Ee,onClick:()=>Pe(Ee),onMouseEnter:e=>Fn(e,Te("common.reset")||"Reset"),onFocus:e=>Fn(e,Te("common.reset")||"Reset"),onMouseLeave:Wn,onBlur:Wn,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
18
+ /* @__PURE__ */n("div",{className:"code-header-title truncate",children:$n}),Dn&&/* @__PURE__ */n("div",{className:"code-header-caption truncate",children:Dn})]})]}),
19
+ /* @__PURE__ */e("div",{className:"code-header-actions",children:[S&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-pressed":be,onClick:()=>Ce(e=>!e),onMouseEnter:e=>Fn(e,be?Te("common.expand")||"Expand":Te("common.collapse")||"Collapse"),onFocus:e=>Fn(e,be?Te("common.expand")||"Expand":Te("common.collapse")||"Collapse"),onMouseLeave:In,onBlur:In,children:/* @__PURE__ */n("svg",{style:{rotate:be?"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:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),T&&g&&/* @__PURE__ */e(t,{children:[
20
+ /* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors",disabled:De<=10,onClick:()=>Pe(e=>Math.max(10,e-1)),onMouseEnter:e=>Fn(e,Te("common.decrease")||"Decrease"),onFocus:e=>Fn(e,Te("common.decrease")||"Decrease"),onMouseLeave:In,onBlur:In,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14"})})}),
21
+ /* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors",disabled:De===Ee,onClick:()=>Pe(Ee),onMouseEnter:e=>Fn(e,Te("common.reset")||"Reset"),onFocus:e=>Fn(e,Te("common.reset")||"Reset"),onMouseLeave:In,onBlur:In,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
22
22
  /* @__PURE__ */n("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),
23
23
  /* @__PURE__ */n("path",{d:"M3 3v5h5"})]})})}),
24
- /* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors",disabled:$e>=36,onClick:()=>Pe(e=>Math.min(36,e+1)),onMouseEnter:e=>Fn(e,Te("common.increase")||"Increase"),onFocus:e=>Fn(e,Te("common.increase")||"Increase"),onMouseLeave:Wn,onBlur:Wn,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14m-7-7v14"})})})]}),M&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-label":we?Te("common.copied")||"Copied":Te("common.copy")||"Copy",onClick:In,onMouseEnter:e=>Fn(e,we?Te("common.copied")||"Copied":Te("common.copy")||"Copy"),onFocus:e=>Fn(e,we?Te("common.copied")||"Copied":Te("common.copy")||"Copy"),onMouseLeave:Wn,onBlur:Wn,children:/* @__PURE__ */n("svg",we?{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__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
24
+ /* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors",disabled:De>=36,onClick:()=>Pe(e=>Math.min(36,e+1)),onMouseEnter:e=>Fn(e,Te("common.increase")||"Increase"),onFocus:e=>Fn(e,Te("common.increase")||"Increase"),onMouseLeave:In,onBlur:In,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14m-7-7v14"})})})]}),M&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-label":we?Te("common.copied")||"Copied":Te("common.copy")||"Copy",onClick:_n,onMouseEnter:e=>Fn(e,we?Te("common.copied")||"Copied":Te("common.copy")||"Copy"),onFocus:e=>Fn(e,we?Te("common.copied")||"Copied":Te("common.copy")||"Copy"),onMouseLeave:In,onBlur:In,children:/* @__PURE__ */n("svg",we?{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__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
25
25
  /* @__PURE__ */n("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
26
- /* @__PURE__ */n("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),N&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-pressed":xe,onClick:e=>{ke(e=>!e),Fn(e,xe?Te("common.expand")||"Expand":Te("common.collapse")||"Collapse")},onMouseEnter:e=>Fn(e,xe?Te("common.collapse")||"Collapse":Te("common.expand")||"Expand"),onFocus:e=>Fn(e,xe?Te("common.collapse")||"Collapse":Te("common.expand")||"Expand"),onMouseLeave:Wn,onBlur:Wn,children:/* @__PURE__ */n("svg",xe?{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__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})}),Cn&&B&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-label":Te("common.preview")||"Preview",onClick:_n,onMouseEnter:e=>Fn(e,Te("common.preview")||"Preview"),onFocus:e=>Fn(e,Te("common.preview")||"Preview"),onMouseLeave:Wn,onBlur:Wn,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",children:/* @__PURE__ */e("g",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",children:[
26
+ /* @__PURE__ */n("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),N&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-pressed":xe,onClick:e=>{ke(e=>!e),Fn(e,xe?Te("common.expand")||"Expand":Te("common.collapse")||"Collapse")},onMouseEnter:e=>Fn(e,xe?Te("common.collapse")||"Collapse":Te("common.expand")||"Expand"),onFocus:e=>Fn(e,xe?Te("common.collapse")||"Collapse":Te("common.expand")||"Expand"),onMouseLeave:In,onBlur:In,children:/* @__PURE__ */n("svg",xe?{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__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})}),Cn&&B&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-label":Te("common.preview")||"Preview",onClick:On,onMouseEnter:e=>Fn(e,Te("common.preview")||"Preview"),onFocus:e=>Fn(e,Te("common.preview")||"Preview"),onMouseLeave:In,onBlur:In,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",children:/* @__PURE__ */e("g",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",children:[
27
27
  /* @__PURE__ */n("path",{d:"M23.628 7.41c-.12-1.172-.08-3.583-.9-4.233c-1.921-1.51-6.143-1.11-8.815-1.19c-3.481-.15-7.193.14-10.625.24a.34.34 0 0 0 0 .67c3.472-.05 7.074-.29 10.575-.09c2.471.15 6.653-.14 8.254 1.16c.4.33.41 2.732.49 3.582a42 42 0 0 1 .08 9.005a13.8 13.8 0 0 1-.45 3.001c-2.42 1.4-19.69 2.381-20.72.55a21 21 0 0 1-.65-4.632a41.5 41.5 0 0 1 .12-7.964c.08 0 7.334.33 12.586.24c2.331 0 4.682-.13 6.764-.21a.33.33 0 0 0 0-.66c-7.714-.16-12.897-.43-19.31.05c.11-1.38.48-3.922.38-4.002a.3.3 0 0 0-.42 0c-.37.41-.29 1.77-.36 2.251s-.14 1.07-.2 1.6a45 45 0 0 0-.36 8.645a21.8 21.8 0 0 0 .66 5.002c1.46 2.702 17.248 1.461 20.95.43c1.45-.4 1.69-.8 1.871-1.95c.575-3.809.602-7.68.08-11.496"}),
28
28
  /* @__PURE__ */n("path",{d:"M4.528 5.237a.84.84 0 0 0-.21-1c-.77-.41-1.71.39-1 1.1a.83.83 0 0 0 1.21-.1m2.632-.25c.14-.14.19-.84-.2-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.2-.09m2.88 0a.83.83 0 0 0-.21-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.21-.09m-4.29 8.735c0 .08.23 2.471.31 2.561a.371.371 0 0 0 .63-.14c0-.09 0 0 .15-1.72a10 10 0 0 0-.11-2.232a5.3 5.3 0 0 1-.26-1.37a.3.3 0 0 0-.54-.24a6.8 6.8 0 0 0-.2 2.33c-1.281-.38-1.121.13-1.131-.42a15 15 0 0 0-.19-1.93c-.16-.17-.36-.17-.51.14a20 20 0 0 0-.43 3.471c.04.773.18 1.536.42 2.272c.26.4.7.22.7-.1c0-.09-.16-.09 0-1.862c.06-1.18-.23-.3 1.16-.76m5.033-2.552c.32-.07.41-.28.39-.37c0-.55-3.322-.34-3.462-.24s-.2.18-.18.28s0 .11 0 .16a3.8 3.8 0 0 0 1.591.361v.82a15 15 0 0 0-.13 3.132c0 .2-.09.94.17 1.16a.34.34 0 0 0 .48 0c.125-.35.196-.718.21-1.09a8 8 0 0 0 .14-3.232c0-.13.05-.7-.1-.89a8 8 0 0 0 .89-.09m5.544-.181a.69.69 0 0 0-.89-.44a2.8 2.8 0 0 0-1.252 1.001a2.3 2.3 0 0 0-.41-.83a1 1 0 0 0-1.6.27a7 7 0 0 0-.35 2.07c0 .571 0 2.642.06 2.762c.14 1.09 1 .51.63.13a17.6 17.6 0 0 1 .38-3.962c.32-1.18.32.2.39.51s.11 1.081.73 1.081s.48-.93 1.401-1.78q.075 1.345 0 2.69a15 15 0 0 0 0 1.811a.34.34 0 0 0 .68 0q.112-.861.11-1.73a16.7 16.7 0 0 0 .12-3.582m1.441-.201c-.05.16-.3 3.002-.31 3.202a6.3 6.3 0 0 0 .21 1.741c.33 1 1.21 1.07 2.291.82a3.7 3.7 0 0 0 1.14-.23c.21-.22.10-.59-.41-.64q-.817.096-1.64.07c-.44-.07-.34 0-.67-4.442q.015-.185 0-.37a.316.316 0 0 0-.23-.38a.316.316 0 0 0-.38.23"})]})})})]})]}),
29
- /* @__PURE__ */e("div",{className:`code-block-body${be?" code-block-body--collapsed":""}${xe?" code-block-body--expanded":""}`,children:[!be&&(!!f||!h)&&(oe?/* @__PURE__ */n(O,{className:"code-fallback-plain m-0",diffInline:tn,node:u,showLineNumbers:He,style:an}):/* @__PURE__ */e("div",{className:"code-editor-layer",children:[
30
- /* @__PURE__ */n("div",{ref:D,className:"code-editor-container"+(f?"":" code-height-placeholder"),"data-markstream-enhanced":me?"true":"false","data-markstream-host-hidden":me?void 0:"true",style:{"--markstream-editor-initial-height":`${ln}px`,visibility:me?"visible":"hidden"},"aria-hidden":!me}),!me&&/* @__PURE__ */n("div",{className:"code-editor-fallback-surface",children:/* @__PURE__ */n(O,{className:"code-fallback-plain m-0",diffInline:tn,node:u,showLineNumbers:He,style:an})})]})),!f&&h&&/* @__PURE__ */n("div",{className:"code-loading-placeholder",children:/* @__PURE__ */e("div",{className:"loading-skeleton",children:[
29
+ /* @__PURE__ */e("div",{className:`code-block-body${be?" code-block-body--collapsed":""}${xe?" code-block-body--expanded":""}`,children:[!be&&(!!f||!h)&&(oe?/* @__PURE__ */n(O,{className:"code-fallback-plain m-0",diffInline:nn,node:u,showLineNumbers:He,style:ln,monacoOptions:Le}):/* @__PURE__ */e("div",{className:"code-editor-layer",children:[
30
+ /* @__PURE__ */n("div",{ref:$,className:"code-editor-container"+(f?"":" code-height-placeholder"),"data-markstream-enhanced":me?"true":"false","data-markstream-host-hidden":me?void 0:"true",style:{"--markstream-editor-initial-height":`${on}px`,visibility:me?"visible":"hidden"},"aria-hidden":!me}),!me&&/* @__PURE__ */n("div",{className:"code-editor-fallback-surface",children:/* @__PURE__ */n(O,{className:"code-fallback-plain m-0",diffInline:nn,node:u,showLineNumbers:He,style:ln,monacoOptions:Le})})]})),!f&&h&&/* @__PURE__ */n("div",{className:"code-loading-placeholder",children:/* @__PURE__ */e("div",{className:"loading-skeleton",children:[
31
31
  /* @__PURE__ */n("div",{className:"skeleton-line"}),
32
32
  /* @__PURE__ */n("div",{className:"skeleton-line"}),
33
33
  /* @__PURE__ */n("div",{className:"skeleton-line short"})]})})]}),Me&&!a.onPreviewCode&&Cn&&"html"===mn&&/* @__PURE__ */n(Je,{code:String(null!=(l=u.code)?l:""),htmlPreviewAllowScripts:a.htmlPreviewAllowScripts,htmlPreviewSandbox:a.htmlPreviewSandbox,isDark:m,onClose:()=>Ne(!1)}),
34
- /* @__PURE__ */n("span",{className:"sr-only","aria-live":"polite",role:"status",children:we?Te("common.copied")||"Copied":""})]})}function En(e){var n,t,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(n=0;n<o;n++)e[n]&&(t=En(e[n]))&&(r&&(r+=" "),r+=t)}else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function Dn(){for(var e,n,t=0,r="",o=arguments.length;t<o;t++)(e=arguments[t])&&(n=En(e))&&(r&&(r+=" "),r+=n);return r}const $n=()=>import("@terrastruct/d2");let Pn=null,An=$n;function Rn(e){An=e,Pn=null}function Hn(e){Rn(null!=e?e:$n)}function Fn(){Rn(null)}function Wn(){return"function"==typeof An}async function In(){if(Pn)return Pn;const e=An;if(!e)return null;let n;try{n=await e()}catch(t){if(e===$n)throw new Error('Optional dependency "@terrastruct/d2" is not installed. Please install it to enable D2 diagrams.');throw t}return n?(Pn=function(e){var n;if(!e)return e;if(e.D2&&"function"==typeof e.D2)return e.D2;if(e.default&&e.default.D2&&"function"==typeof e.default.D2)return e.default.D2;const t=null!=(n=e.default)?n:e;return"function"==typeof t?t:(null==t?void 0:t.D2)&&"function"==typeof t.D2?t.D2:t}(n),Pn):null}const _n={maxHeight:"500px",loading:!0,progressiveRender:!0,progressiveIntervalMs:700,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showCollapseButton:!0},On={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"},jn=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],zn=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function Vn(e){if(!e)return"";const n=e.trim();return zn.test(n)?n:""}function Kn(r){var l,a;const u={..._n,...r},{t:m}=Ie(),[h,f]=i(!1),[p,g]=i(!1),[v,w]=i(!1),[y,x]=i(!1),[k,b]=i(null),[C,M]=i(""),[N,B]=i(null),[S,T]=i(!1),[L,E]=i(()=>"undefined"==typeof window),D=c(0),$=c(null),P=c(!1),A=c(!1),R=c(0),H=c(null),F=c(!1),W=c(null),I=c(null),_=c(null),O=c(null),j=c(!1),z=c(()=>{}),V=Ae(),K=null!=(a=null==(l=u.node)?void 0:l.code)?a:"",X=v||!y||!C,q=!!C,U=o(()=>{if(u.maxHeight)return{maxHeight:"number"==typeof u.maxHeight?`${u.maxHeight}px`:String(u.maxHeight)}},[u.maxHeight]),Y=o(()=>{if(X&&N)return{minHeight:`${N}px`}},[N,X]);s(()=>{j.current=S},[S]),s(()=>{const e=W.current;if(!e)return;const n=V(e,{rootMargin:"160px"});return I.current=n,n.isVisible()&&E(!0),n.whenVisible.then(()=>E(!0)),()=>{n.destroy(),I.current=null}},[V]);const Z=d(()=>{const e=_.current;if(!e)return;const n=e.getBoundingClientRect().height;n>0&&B(e=>e!==n?n:e)},[]),G=d((e=!1)=>{if(P.current||"undefined"==typeof window)return;if(A.current)return;if(!L)return;if(j.current)return void(F.current=!0);const n=Math.max(120,Number(u.progressiveIntervalMs)||0),t=Date.now()-R.current;if(!e&&t<n)return F.current=!0,void(null==H.current&&(H.current=window.setTimeout(()=>{H.current=null,F.current&&(F.current=!1,G(!0))},Math.max(0,n-t))));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,L]),J=d(async()=>{if($.current)return $.current;const e=await In();if(!e)return null;if("function"==typeof e){const n=new e;return n&&"function"==typeof n.compile?$.current=n:"function"==typeof e.compile&&($.current=e),$.current}return(null==e?void 0:e.D2)&&"function"==typeof e.D2?($.current=new e.D2,$.current):("function"==typeof e.compile&&($.current=e),$.current)},[]),Q=d(async()=>{var e,n,t,r,o;if("undefined"==typeof window||A.current)return;if(!L)return;if(u.loading&&!u.progressiveRender)return;if(!K)return M(""),void b(null);const i=++D.current;T(!0),b(null);try{const l=await J();if(!l)return x(!1),w(!0),M(""),void b("D2 is not available.");if("function"!=typeof l.compile||"function"!=typeof l.render)throw new Error("D2 instance is missing compile/render methods.");x(!0);const a=await l.compile(K);if(i!==D.current)return;const c=null!=(e=null==a?void 0:a.diagram)?e:a,s=null!=(t=null!=(n=null==a?void 0:a.renderOptions)?n:null==a?void 0:a.options)?t:{},d=null!=(r=u.themeId)?r:s.themeID,m=null!=(o=u.darkThemeId)?o:s.darkThemeID,h={...s};if(h.themeID=u.isDark&&null!=m?m:d,h.darkThemeID=null,h.darkThemeOverrides=null,u.isDark){const e=s.themeOverrides&&"object"==typeof s.themeOverrides?s.themeOverrides:null;h.themeOverrides={...On,...e||{}}}const f=await l.render(c,h);if(i!==D.current)return;const p=function(e){return e?"string"==typeof e?e:"string"==typeof e.svg?e.svg:"string"==typeof e.data?e.data:"":""}(f);if(!p)throw new Error("D2 render returned empty output.");const g=function(e){if("undefined"==typeof window||"undefined"==typeof DOMParser)return"";if(!e)return"";const n=e.replace(/["']\s*javascript:/gi,"#").replace(/\bjavascript:/gi,"#").replace(/["']\s*vbscript:/gi,"#").replace(/\bvbscript:/gi,"#").replace(/\bdata:text\/html/gi,"#"),t=(new DOMParser).parseFromString(n,"image/svg+xml").documentElement;if(!t||"svg"!==t.nodeName.toLowerCase())return"";const r=t;return function(e){const n=/* @__PURE__ */new Set(["script"]),t=[e,...Array.from(e.querySelectorAll("*"))];for(const r of t){if(n.has(r.tagName.toLowerCase())){r.remove();continue}const e=Array.from(r.attributes);for(const n of e){const e=n.name;if(/^on/i.test(e))r.removeAttribute(e);else{if("style"===e&&n.value){const t=n.value;if(jn.some(e=>e.test(t))){r.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&n.value){const t=Vn(n.value);if(!t){r.removeAttribute(e);continue}t!==n.value&&r.setAttribute(e,t)}}}}}(r),r.classList.add("markstream-d2-root-svg"),r.outerHTML}(p);M(g||""),u.loading&&w(!1),b(null)}catch(l){if(i!==D.current)return;const e=(null==l?void 0:l.message)?String(l.message):"D2 render failed.";u.loading||b(e),e.includes("@terrastruct/d2")&&(x(!1),w(!0))}finally{i===D.current&&(T(!1),F.current&&(F.current=!1,G()))}},[K,J,u.darkThemeId,u.isDark,u.loading,u.progressiveRender,u.themeId,G,L]);s(()=>{z.current=Q},[Q]);const ee=d(async()=>{var e;try{(null==(e=null==navigator?void 0:navigator.clipboard)?void 0:e.writeText)&&await navigator.clipboard.writeText(K),f(!0),setTimeout(()=>f(!1),1e3)}catch{}},[K]),ne=d(()=>{if(C)try{const e=new Blob([C],{type:"image/svg+xml;charset=utf-8"}),n=URL.createObjectURL(e),t=document.createElement("a");t.href=n,t.download=`d2-diagram-${Date.now()}.svg`,document.body.appendChild(t),t.click(),document.body.removeChild(t),URL.revokeObjectURL(n)}catch(e){console.error("Failed to export SVG:",e)}},[C]),te=d((e,n)=>{var t;(t=e.currentTarget)&&!t.disabled&&Ue(e.currentTarget,n,"top",!1,(e.clientX,e.clientY),u.isDark)},[u.isDark]),re=d(()=>{Ye()},[]);return s(()=>{G()},[K,u.loading,u.isDark,G]),s(()=>{u.loading||G(!0)},[u.loading,G]),s(()=>{const e=requestAnimationFrame(()=>Z());return()=>cancelAnimationFrame(e)},[X,C,K,Z]),s(()=>{A.current=!1,G();const e=requestAnimationFrame(()=>Z());if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{Z()});O.current=e,_.current&&e.observe(_.current)}return()=>{var n;A.current=!0,null!=H.current&&(clearTimeout(H.current),H.current=null),null==(n=O.current)||n.disconnect(),O.current=null,cancelAnimationFrame(e)}},[G,Z]),/* @__PURE__ */e("div",{ref:W,className:Dn("d2-block my-4 rounded-lg border overflow-hidden shadow-sm",u.isDark?"border-gray-700/30 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900"),children:[u.showHeader&&/* @__PURE__ */e("div",{className:"d2-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5",style:{color:"var(--vscode-editor-foreground)",backgroundColor:"var(--vscode-editor-background)"},children:[
34
+ /* @__PURE__ */n("span",{className:"sr-only","aria-live":"polite",role:"status",children:we?Te("common.copied")||"Copied":""})]})}function $n(e){var n,t,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(n=0;n<o;n++)e[n]&&(t=$n(e[n]))&&(r&&(r+=" "),r+=t)}else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function Dn(){for(var e,n,t=0,r="",o=arguments.length;t<o;t++)(e=arguments[t])&&(n=$n(e))&&(r&&(r+=" "),r+=n);return r}const Pn=()=>import("@terrastruct/d2");let An=null,Rn=Pn;function Hn(e){Rn=e,An=null}function Wn(e){Hn(null!=e?e:Pn)}function Fn(){Hn(null)}function In(){return"function"==typeof Rn}async function _n(){if(An)return An;const e=Rn;if(!e)return null;let n;try{n=await e()}catch(t){if(e===Pn)throw new Error('Optional dependency "@terrastruct/d2" is not installed. Please install it to enable D2 diagrams.');throw t}return n?(An=function(e){var n;if(!e)return e;if(e.D2&&"function"==typeof e.D2)return e.D2;if(e.default&&e.default.D2&&"function"==typeof e.default.D2)return e.default.D2;const t=null!=(n=e.default)?n:e;return"function"==typeof t?t:(null==t?void 0:t.D2)&&"function"==typeof t.D2?t.D2:t}(n),An):null}const On={maxHeight:"500px",loading:!0,progressiveRender:!0,progressiveIntervalMs:700,showHeader:!0,showModeToggle:!0,showCopyButton:!0,showExportButton:!0,showCollapseButton:!0},jn={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"},zn=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],Vn=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function Kn(e){if(!e)return"";const n=e.trim();return Vn.test(n)?n:""}function Xn(r){var l,a;const u={...On,...r},{t:m}=Ie(),[h,f]=i(!1),[p,g]=i(!1),[v,w]=i(!1),[y,x]=i(!1),[k,b]=i(null),[C,M]=i(""),[N,B]=i(null),[S,T]=i(!1),[L,E]=i(()=>"undefined"==typeof window),$=c(0),D=c(null),P=c(!1),A=c(!1),R=c(0),H=c(null),W=c(!1),F=c(null),I=c(null),_=c(null),O=c(null),j=c(!1),z=c(()=>{}),V=Ae(),K=null!=(a=null==(l=u.node)?void 0:l.code)?a:"",X=v||!y||!C,q=!!C,U=o(()=>{if(u.maxHeight)return{maxHeight:"number"==typeof u.maxHeight?`${u.maxHeight}px`:String(u.maxHeight)}},[u.maxHeight]),Y=o(()=>{if(X&&N)return{minHeight:`${N}px`}},[N,X]);s(()=>{j.current=S},[S]),s(()=>{const e=F.current;if(!e)return;const n=V(e,{rootMargin:"160px"});return I.current=n,n.isVisible()&&E(!0),n.whenVisible.then(()=>E(!0)),()=>{n.destroy(),I.current=null}},[V]);const Z=d(()=>{const e=_.current;if(!e)return;const n=e.getBoundingClientRect().height;n>0&&B(e=>e!==n?n:e)},[]),G=d((e=!1)=>{if(P.current||"undefined"==typeof window)return;if(A.current)return;if(!L)return;if(j.current)return void(W.current=!0);const n=Math.max(120,Number(u.progressiveIntervalMs)||0),t=Date.now()-R.current;if(!e&&t<n)return W.current=!0,void(null==H.current&&(H.current=window.setTimeout(()=>{H.current=null,W.current&&(W.current=!1,G(!0))},Math.max(0,n-t))));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,L]),J=d(async()=>{if(D.current)return D.current;const e=await _n();if(!e)return null;if("function"==typeof e){const n=new e;return n&&"function"==typeof n.compile?D.current=n:"function"==typeof e.compile&&(D.current=e),D.current}return(null==e?void 0:e.D2)&&"function"==typeof e.D2?(D.current=new e.D2,D.current):("function"==typeof e.compile&&(D.current=e),D.current)},[]),Q=d(async()=>{var e,n,t,r,o;if("undefined"==typeof window||A.current)return;if(!L)return;if(u.loading&&!u.progressiveRender)return;if(!K)return M(""),void b(null);const i=++$.current;T(!0),b(null);try{const l=await J();if(!l)return x(!1),w(!0),M(""),void b("D2 is not available.");if("function"!=typeof l.compile||"function"!=typeof l.render)throw new Error("D2 instance is missing compile/render methods.");x(!0);const a=await l.compile(K);if(i!==$.current)return;const c=null!=(e=null==a?void 0:a.diagram)?e:a,s=null!=(t=null!=(n=null==a?void 0:a.renderOptions)?n:null==a?void 0:a.options)?t:{},d=null!=(r=u.themeId)?r:s.themeID,m=null!=(o=u.darkThemeId)?o:s.darkThemeID,h={...s};if(h.themeID=u.isDark&&null!=m?m:d,h.darkThemeID=null,h.darkThemeOverrides=null,u.isDark){const e=s.themeOverrides&&"object"==typeof s.themeOverrides?s.themeOverrides:null;h.themeOverrides={...jn,...e||{}}}const f=await l.render(c,h);if(i!==$.current)return;const p=function(e){return e?"string"==typeof e?e:"string"==typeof e.svg?e.svg:"string"==typeof e.data?e.data:"":""}(f);if(!p)throw new Error("D2 render returned empty output.");const g=function(e){if("undefined"==typeof window||"undefined"==typeof DOMParser)return"";if(!e)return"";const n=e.replace(/["']\s*javascript:/gi,"#").replace(/\bjavascript:/gi,"#").replace(/["']\s*vbscript:/gi,"#").replace(/\bvbscript:/gi,"#").replace(/\bdata:text\/html/gi,"#"),t=(new DOMParser).parseFromString(n,"image/svg+xml").documentElement;if(!t||"svg"!==t.nodeName.toLowerCase())return"";const r=t;return function(e){const n=/* @__PURE__ */new Set(["script"]),t=[e,...Array.from(e.querySelectorAll("*"))];for(const r of t){if(n.has(r.tagName.toLowerCase())){r.remove();continue}const e=Array.from(r.attributes);for(const n of e){const e=n.name;if(/^on/i.test(e))r.removeAttribute(e);else{if("style"===e&&n.value){const t=n.value;if(zn.some(e=>e.test(t))){r.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&n.value){const t=Kn(n.value);if(!t){r.removeAttribute(e);continue}t!==n.value&&r.setAttribute(e,t)}}}}}(r),r.classList.add("markstream-d2-root-svg"),r.outerHTML}(p);M(g||""),u.loading&&w(!1),b(null)}catch(l){if(i!==$.current)return;const e=(null==l?void 0:l.message)?String(l.message):"D2 render failed.";u.loading||b(e),e.includes("@terrastruct/d2")&&(x(!1),w(!0))}finally{i===$.current&&(T(!1),W.current&&(W.current=!1,G()))}},[K,J,u.darkThemeId,u.isDark,u.loading,u.progressiveRender,u.themeId,G,L]);s(()=>{z.current=Q},[Q]);const ee=d(async()=>{var e;try{(null==(e=null==navigator?void 0:navigator.clipboard)?void 0:e.writeText)&&await navigator.clipboard.writeText(K),f(!0),setTimeout(()=>f(!1),1e3)}catch{}},[K]),ne=d(()=>{if(C)try{const e=new Blob([C],{type:"image/svg+xml;charset=utf-8"}),n=URL.createObjectURL(e),t=document.createElement("a");t.href=n,t.download=`d2-diagram-${Date.now()}.svg`,document.body.appendChild(t),t.click(),document.body.removeChild(t),URL.revokeObjectURL(n)}catch(e){console.error("Failed to export SVG:",e)}},[C]),te=d((e,n)=>{var t;(t=e.currentTarget)&&!t.disabled&&Ue(e.currentTarget,n,"top",!1,(e.clientX,e.clientY),u.isDark)},[u.isDark]),re=d(()=>{Ye()},[]);return s(()=>{G()},[K,u.loading,u.isDark,G]),s(()=>{u.loading||G(!0)},[u.loading,G]),s(()=>{const e=requestAnimationFrame(()=>Z());return()=>cancelAnimationFrame(e)},[X,C,K,Z]),s(()=>{A.current=!1,G();const e=requestAnimationFrame(()=>Z());if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{Z()});O.current=e,_.current&&e.observe(_.current)}return()=>{var n;A.current=!0,null!=H.current&&(clearTimeout(H.current),H.current=null),null==(n=O.current)||n.disconnect(),O.current=null,cancelAnimationFrame(e)}},[G,Z]),/* @__PURE__ */e("div",{ref:F,className:Dn("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__ */n("div",{className:"flex items-center gap-x-2",children:/* @__PURE__ */n("span",{className:"text-sm font-medium font-mono",children:"D2"})}),
36
36
  /* @__PURE__ */e("div",{className:"flex items-center gap-x-2",children:[u.showModeToggle&&/* @__PURE__ */e("div",{className:Dn("flex items-center gap-x-1 rounded-md p-0.5",u.isDark?"bg-gray-700":"bg-gray-100"),children:[
37
37
  /* @__PURE__ */n("button",{type:"button",className:Dn("mode-btn px-2 py-1 text-xs rounded",!v&&"is-active"),onClick:()=>w(!1),onMouseEnter:e=>te(e,m("common.preview")||"Preview"),onFocus:e=>te(e,m("common.preview")||"Preview"),onMouseLeave:re,onBlur:re,children:m("common.preview")||"Preview"}),
@@ -40,33 +40,33 @@ return e("div",{ref:$,className:["code-block-container my-4 rounded-lg border ov
40
40
  /* @__PURE__ */n("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),u.showExportButton&&C&&/* @__PURE__ */n("button",{type:"button",className:"d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-label":m("common.export")||"Export",onClick:ne,onMouseEnter:e=>te(e,m("common.export")||"Export"),onFocus:e=>te(e,m("common.export")||"Export"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 3v12m0-12l-4 4m4-4l4 4M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4"})})}),u.showCollapseButton&&/* @__PURE__ */n("button",{type:"button",className:"d2-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]","aria-pressed":p,onClick:()=>g(e=>!e),onMouseEnter:e=>te(e,p?m("common.expand")||"Expand":m("common.collapse")||"Collapse"),onFocus:e=>te(e,p?m("common.expand")||"Expand":m("common.collapse")||"Collapse"),onMouseLeave:re,onBlur:re,children:/* @__PURE__ */n("svg",{style:{transform:`rotate(${p?0:90}deg)`},xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})})]})]}),!p&&/* @__PURE__ */n("div",{ref:_,className:"d2-block-body",style:Y,children:u.loading&&!q?/* @__PURE__ */e("div",{className:"d2-source px-4 py-4",children:[
41
41
  /* @__PURE__ */n("pre",{className:"d2-code",children:/* @__PURE__ */n("code",{children:K})}),k&&/* @__PURE__ */n("p",{className:"d2-error mt-2 text-xs",children:k})]}):/* @__PURE__ */n(t,{children:/* @__PURE__ */e("div",X?{className:"d2-source px-4 py-4",children:[
42
42
  /* @__PURE__ */n("pre",{className:"d2-code",children:/* @__PURE__ */n("code",{children:K})}),k&&/* @__PURE__ */n("p",{className:"d2-error mt-2 text-xs",children:k})]}:{className:"d2-render",style:U,children:[
43
- /* @__PURE__ */n("div",{className:"d2-svg",dangerouslySetInnerHTML:{__html:C}}),k&&/* @__PURE__ */n("p",{className:"d2-error px-4 pb-3 text-xs",children:k})]})})})]})}function Xn(t){const{node:r,ctx:o,renderNode:i,indexKey:l}=t,a=Array.isArray(r.items)?r.items:[];/* @__PURE__ */
43
+ /* @__PURE__ */n("div",{className:"d2-svg",dangerouslySetInnerHTML:{__html:C}}),k&&/* @__PURE__ */n("p",{className:"d2-error px-4 pb-3 text-xs",children:k})]})})})]})}function qn(t){const{node:r,ctx:o,renderNode:i,indexKey:l}=t,a=Array.isArray(r.items)?r.items:[];/* @__PURE__ */
44
44
  return n("dl",{className:"definition-list","data-index-key":l,children:a.map((t,r)=>/* @__PURE__ */e("div",{className:"mb-4",children:[
45
45
  /* @__PURE__ */n("dt",{className:"definition-term font-semibold",children:o&&i?j(t.term,o,`${String(null!=l?l:"definition")}-term-${r}`,i):null}),
46
- /* @__PURE__ */n("dd",{className:"definition-desc ml-4",children:o&&i?j(t.definition,o,`${String(null!=l?l:"definition")}-desc-${r}`,i):null})]},`${String(null!=l?l:"definition")}-${r}`))})}function qn(e){var t;const{node:r}=e;/* @__PURE__ */
47
- return n("span",{className:"emoji-node",children:null!=(t=r.name)?t:r.markup})}function Un(e){/* @__PURE__ */
48
- return n("em",{className:"emphasis-node",children:e.children})}function Yn(e){const{node:t}=e,r=d(e=>{var n;if(e.preventDefault(),"undefined"==typeof document)return;const r=document.getElementById(`fnref-${String(null!=(n=t.id)?n:"")}`);r&&r.scrollIntoView({behavior:"smooth"})},[t.id]);/* @__PURE__ */
49
- return n("a",{className:"footnote-anchor text-sm hover:underline cursor-pointer",href:`#fnref-${t.id}`,title:`返回引用 ${t.id}`,onClick:r,children:"↩︎"})}function Zn(e){const{node:t,ctx:r,renderNode:o,indexKey:i}=e;/* @__PURE__ */
50
- return n("div",{id:`fnref--${t.id}`,className:"footnote-node flex text-sm leading-relaxed border-t border-[var(--footnote-border,#eaecef)] pt-2",children:/* @__PURE__ */n("div",{className:"flex-1",children:r&&o?$(t.children,r,String(null!=i?i:`footnote-${t.id}`),o):null})})}function Gn(t){const{node:r}=t,i=o(()=>`#fnref--${r.id}`,[r.id]),l=o(()=>({href:i}),[i]),a=d(e=>{if(e.preventDefault(),"undefined"==typeof document)return;const n=document.querySelector(i);n&&n.scrollIntoView({behavior:"smooth"})},[i]);/* @__PURE__ */
51
- return n("sup",{id:`fnref-${r.id}`,className:"footnote-reference",onClick:a,children:/* @__PURE__ */e("span",{...l,title:`查看脚注 ${r.id}`,className:"footnote-link cursor-pointer",children:["[",r.id,"]"]})})}function Jn(e){/* @__PURE__ */
52
- return n("br",{className:"hard-break"})}function Qn(e){const{node:t,ctx:r,renderNode:o,indexKey:i,children:l}=e,a=Math.min(6,Math.max(1,Number(t.level)||1)),c=`h${a}`,s=null==t?void 0:t.attrs,{class:d,className:u,style:m,...h}=null!=s?s:{};/* @__PURE__ */
53
- return n(c,{dir:"auto",className:Dn("heading-node font-semibold",`heading-${a}`,d,u),..."object"==typeof m&&null!=m?{style:m}:{},...h,children:null!=l?l:r&&o?$(t.children,r,String(null!=i?i:`heading-${a}`),o):null})}function et(e){/* @__PURE__ */
54
- return n("mark",{className:"highlight-node",children:e.children})}function nt(l){var a,d,m,x,k,b,C,M;const{node:N,placeholder:B,customId:S}=l,T=null!=(m=null!=(d=l.htmlPolicy)?d:null==(a=l.ctx)?void 0:a.htmlPolicy)?m:"safe",L=Ae(),[E,D]=i(null),P=c(null),[A,R]=i(()=>"undefined"==typeof window),[H,F]=i(N.content),W=Boolean(N.loading),I=u(z,V,V),_=o(()=>{var e,n,t,r,o;return{...null!=(t=null!=(n=l.customComponents)?n:null==(e=l.ctx)?void 0:e.customComponents)?t:K(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,I]),O=o(()=>{var e,n;return{..._,...null!=(n=null==(e=l.ctx)?void 0:e.streamingComponents)?n:{}}},[_,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,!W)return R(!0),void F(N.content);if(!E)return void R(!1);const n=L(E,{rootMargin:"400px"});return P.current=n,n.isVisible()&&R(!0),n.whenVisible.then(()=>R(!0)).catch(()=>{}),()=>{n.destroy(),P.current=null}},[E,W,N.content,L]),s(()=>()=>{var e;null==(e=P.current)||e.destroy(),P.current=null},[]),s(()=>{W&&!A||F(N.content)},[W,N.content,A]);const j=o(()=>{var e;const n=X(h(null!=(e=N.attrs)?e:void 0,T));return n?q(n):void 0},[T,N.attrs]),Z=o(()=>{var e;return String(null!=(e=N.tag)?e:"").trim()},[N.tag]),G=o(()=>f(Z),[Z]),J=o(()=>{var e;const n=X(h(null!=(e=N.attrs)?e:void 0,T,Z));return n?q(n):void 0},[T,N.attrs,Z]),Q=o(()=>{var e;return p(g(h(null!=(e=N.attrs)?e:void 0,T,G)))},[T,N.attrs,G]),ee=o(()=>Array.isArray(N.children)?N.children:[],[N.children]),ne=ee.length>0&&!!Z&&!v.has(Z.toLowerCase())&&!w(Z,T)&&!!l.ctx&&!!l.renderNode,te=o(()=>function(e){const n={...e||{}},t="string"==typeof n.className?n.className.trim():"";return n.className=t?`html-block-node ${t}`:"html-block-node",n}(J),[J]),re=o(()=>{var e;return"escape"!==T&&U(null!=(e=N.content)?e:"",O)},[O,T,N.content]),oe=o(()=>{var e,n,t;return re&&N.content?Y(N.content,_,T,{ctx:l.ctx,keyPrefix:String(null!=(e=l.indexKey)?e:"html-block"),nodeComponents:null==(n=l.ctx)?void 0:n.streamingComponents,propComponents:null==(t=l.ctx)?void 0:t.htmlComponents,renderNode:l.renderNode,sourceNode:N}):null},[_,T,N.autoClosed,N.content,N.loading,l.ctx,l.indexKey,l.renderNode,re]),ie=o(()=>y(null!=H?H:"",T),[T,H]),le=o(()=>{var e;return ne&&l.ctx&&l.renderNode?$(ee,l.ctx,`${String(null!=(e=l.indexKey)?e:"html-block")}-structured`,l.renderNode):null},[ne,l.ctx,l.indexKey,l.renderNode,ee]),ae=G?null==(M=null==(C=l.ctx)?void 0:C.htmlComponents)?void 0:M[G]:void 0,ce=/* @__PURE__ */n("div",{className:"html-block-node__placeholder",children:null!=B?B:/* @__PURE__ */e(t,{children:[
46
+ /* @__PURE__ */n("dd",{className:"definition-desc ml-4",children:o&&i?j(t.definition,o,`${String(null!=l?l:"definition")}-desc-${r}`,i):null})]},`${String(null!=l?l:"definition")}-${r}`))})}function Un(e){var t;const{node:r}=e;/* @__PURE__ */
47
+ return n("span",{className:"emoji-node",children:null!=(t=r.name)?t:r.markup})}function Yn(e){/* @__PURE__ */
48
+ return n("em",{className:"emphasis-node",children:e.children})}function Zn(e){const{node:t}=e,r=d(e=>{var n;if(e.preventDefault(),"undefined"==typeof document)return;const r=document.getElementById(`fnref-${String(null!=(n=t.id)?n:"")}`);r&&r.scrollIntoView({behavior:"smooth"})},[t.id]);/* @__PURE__ */
49
+ return n("a",{className:"footnote-anchor text-sm hover:underline cursor-pointer",href:`#fnref-${t.id}`,title:`返回引用 ${t.id}`,onClick:r,children:"↩︎"})}function Gn(e){const{node:t,ctx:r,renderNode:o,indexKey:i}=e;/* @__PURE__ */
50
+ return n("div",{id:`fnref--${t.id}`,className:"footnote-node flex text-sm leading-relaxed border-t border-[var(--footnote-border,#eaecef)] pt-2",children:/* @__PURE__ */n("div",{className:"flex-1",children:r&&o?D(t.children,r,String(null!=i?i:`footnote-${t.id}`),o):null})})}function Jn(t){const{node:r}=t,i=o(()=>`#fnref--${r.id}`,[r.id]),l=o(()=>({href:i}),[i]),a=d(e=>{if(e.preventDefault(),"undefined"==typeof document)return;const n=document.querySelector(i);n&&n.scrollIntoView({behavior:"smooth"})},[i]);/* @__PURE__ */
51
+ return n("sup",{id:`fnref-${r.id}`,className:"footnote-reference",onClick:a,children:/* @__PURE__ */e("span",{...l,title:`查看脚注 ${r.id}`,className:"footnote-link cursor-pointer",children:["[",r.id,"]"]})})}function Qn(e){/* @__PURE__ */
52
+ return n("br",{className:"hard-break"})}function et(e){const{node:t,ctx:r,renderNode:o,indexKey:i,children:l}=e,a=Math.min(6,Math.max(1,Number(t.level)||1)),c=`h${a}`,s=null==t?void 0:t.attrs,{class:d,className:u,style:m,...h}=null!=s?s:{};/* @__PURE__ */
53
+ return n(c,{dir:"auto",className:Dn("heading-node font-semibold",`heading-${a}`,d,u),..."object"==typeof m&&null!=m?{style:m}:{},...h,children:null!=l?l:r&&o?D(t.children,r,String(null!=i?i:`heading-${a}`),o):null})}function nt(e){/* @__PURE__ */
54
+ return n("mark",{className:"highlight-node",children:e.children})}function tt(l){var a,d,m,x,k,b,C,M;const{node:N,placeholder:B,customId:S}=l,T=null!=(m=null!=(d=l.htmlPolicy)?d:null==(a=l.ctx)?void 0:a.htmlPolicy)?m:"safe",L=Ae(),[E,$]=i(null),P=c(null),[A,R]=i(()=>"undefined"==typeof window),[H,W]=i(N.content),F=Boolean(N.loading),I=u(z,V,V),_=o(()=>{var e,n,t,r,o;return{...null!=(t=null!=(n=l.customComponents)?n:null==(e=l.ctx)?void 0:e.customComponents)?t:K(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,I]),O=o(()=>{var e,n;return{..._,...null!=(n=null==(e=l.ctx)?void 0:e.streamingComponents)?n:{}}},[_,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,!F)return R(!0),void W(N.content);if(!E)return void R(!1);const n=L(E,{rootMargin:"400px"});return P.current=n,n.isVisible()&&R(!0),n.whenVisible.then(()=>R(!0)).catch(()=>{}),()=>{n.destroy(),P.current=null}},[E,F,N.content,L]),s(()=>()=>{var e;null==(e=P.current)||e.destroy(),P.current=null},[]),s(()=>{F&&!A||W(N.content)},[F,N.content,A]);const j=o(()=>{var e;const n=X(h(null!=(e=N.attrs)?e:void 0,T));return n?q(n):void 0},[T,N.attrs]),Z=o(()=>{var e;return String(null!=(e=N.tag)?e:"").trim()},[N.tag]),G=o(()=>f(Z),[Z]),J=o(()=>{var e;const n=X(h(null!=(e=N.attrs)?e:void 0,T,Z));return n?q(n):void 0},[T,N.attrs,Z]),Q=o(()=>{var e;return p(g(h(null!=(e=N.attrs)?e:void 0,T,G)))},[T,N.attrs,G]),ee=o(()=>Array.isArray(N.children)?N.children:[],[N.children]),ne=ee.length>0&&!!Z&&!v.has(Z.toLowerCase())&&!w(Z,T)&&!!l.ctx&&!!l.renderNode,te=o(()=>function(e){const n={...e||{}},t="string"==typeof n.className?n.className.trim():"";return n.className=t?`html-block-node ${t}`:"html-block-node",n}(J),[J]),re=o(()=>{var e;return"escape"!==T&&U(null!=(e=N.content)?e:"",O)},[O,T,N.content]),oe=o(()=>{var e,n,t;return re&&N.content?Y(N.content,_,T,{ctx:l.ctx,keyPrefix:String(null!=(e=l.indexKey)?e:"html-block"),nodeComponents:null==(n=l.ctx)?void 0:n.streamingComponents,propComponents:null==(t=l.ctx)?void 0:t.htmlComponents,renderNode:l.renderNode,sourceNode:N}):null},[_,T,N.autoClosed,N.content,N.loading,l.ctx,l.indexKey,l.renderNode,re]),ie=o(()=>y(null!=H?H:"",T),[T,H]),le=o(()=>{var e;return ne&&l.ctx&&l.renderNode?D(ee,l.ctx,`${String(null!=(e=l.indexKey)?e:"html-block")}-structured`,l.renderNode):null},[ne,l.ctx,l.indexKey,l.renderNode,ee]),ae=G?null==(M=null==(C=l.ctx)?void 0:C.htmlComponents)?void 0:M[G]:void 0,ce=/* @__PURE__ */n("div",{className:"html-block-node__placeholder",children:null!=B?B:/* @__PURE__ */e(t,{children:[
55
55
  /* @__PURE__ */n("span",{className:"html-block-node__placeholder-bar"}),
56
56
  /* @__PURE__ */n("span",{className:"html-block-node__placeholder-bar w-4/5"}),
57
- /* @__PURE__ */n("span",{className:"html-block-node__placeholder-bar w-2/3"})]})});return ne&&ae?r.createElement(ae,Q,le):ne?r.createElement(Z,{...te,ref:D},A?le:ce):/* @__PURE__ */n("div",{ref:D,className:"html-block-node",...j,children:A?re&&oe?/* @__PURE__ */n(t,{children:oe}):/* @__PURE__ */n("div",{dangerouslySetInnerHTML:{__html:ie}}):ce})}const tt=(()=>{try{return Boolean(!1)}catch{}return!1})();function rt(e){tt&&console.warn(e)}function ot(e,n,t=!1){const r=Object.entries(null!=n?n:{}),o=r.length>0?r.map(([e,n])=>""===n?` ${e}`:` ${e}="${n}"`).join(""):"";return t?`<${e}${o} />`:`<${e}${o}>`}function it(e,n){Array.isArray(n)?e.push(...n):null!=n&&e.push(n)}function lt(e,n){var t;for(const r of Z(e)){if("tag_open"!==r.type&&"self_closing"!==r.type)continue;const e=null!=(t=r.tagName)?t:"";if(!G(e,n))continue;const o=n[e]||n[e.toLowerCase()];if("block"===J(o))return!0}return!1}function at(e,n){var t,r;return(null==(t=n.nodeComponents)?void 0:t[e])||(null==(r=n.nodeComponents)?void 0:r[e.toLowerCase()])}function ct(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(ct).join("");if(!r.isValidElement(e))return"";const n=e;if("string"!=typeof n.type)return ct(n.props.children);const t=Object.entries(n.props).filter(([e,n])=>"children"!==e&&"key"!==e&&"ref"!==e&&null!=n&&"boolean"!=typeof n).map(([e,n])=>` ${"className"===e?"class":e}="${String(n)}"`).join("");return`<${n.type}${t}>${ct(n.props.children)}</${n.type}>`}function st(e){return Object.entries(e).map(([e,n])=>[e,""===n?null:n])}function dt(e){var n,t;const r=e.sourceNode,o=!0!==(null==(n=e.ctx)?void 0:n.final)&&(!1===(null==(t=e.ctx)?void 0:t.final)||Boolean(null==r?void 0:r.loading));return{loading:o,autoClosed:o||Boolean(null==r?void 0:r.autoClosed)}}function ut(e,n,t,o,i,l,a,c,s,d){const u=G(e,o),m=Boolean(at(e,a));if(x.has(e.toLowerCase())||!u&&!m&&k(e,l))return null;if(!u&&!m&&w(e,l))return[ot(e,n),...t,`</${e}>`];const h=Q(n,l,e),g=h.key,v=null!=g&&""!==g?g:i;if(m)return function(e,n,t,o,i,l,a,c=dt(i)){const s=f(e),d=null!=l?l:function(e){return e.map(ct).join("")}(t),u={type:s,tag:s,attrs:st(n),content:d,raw:null!=a?a:`${ot(e,n)}${d}</${e}>`,loading:c.loading,autoClosed:c.autoClosed};if(i.ctx&&i.renderNode)return i.renderNode(u,o,i.ctx);const m=at(e,i);return m?r.createElement(m,{key:o,node:u}):null}(e,n,t,String(v),a,c,s,d);if(u){const n=o[e]||o[e.toLowerCase()],i=p(h);return r.createElement(n,{...i,key:v},...t)}return r.createElement(e,{...q(h),key:v},...t)}function mt(e){var o,l,a,d,u,m,v,b;const{node:C,customId:M}=e,N=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 L=r.useMemo(()=>{var n,t,r,o;return{...null!=(t=null==(n=e.ctx)?void 0:n.customComponents)?t:K(M),...null!=(o=null==(r=e.ctx)?void 0:r.htmlComponents)?o:{}}},[M,null==(d=e.ctx)?void 0:d.customComponents,null==(u=e.ctx)?void 0:u.htmlComponents]),E=r.useMemo(()=>{var n,t;return{...L,...null!=(t=null==(n=e.ctx)?void 0:n.streamingComponents)?t:{}}},[L,null==(m=e.ctx)?void 0:m.streamingComponents]),D=r.useMemo(()=>{var e;return y(null!=(e=C.content)?e:"",N)},[N,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]),H=r.useMemo(()=>{var e;return p(g(h(null!=(e=C.attrs)?e:void 0,N,A)))},[N,C.attrs,A]),F=A?null==(b=null==(v=e.ctx)?void 0:v.htmlComponents)?void 0:b[A]:void 0,W=R.length>0&&!!P&&"escape"!==N&&!w(P,N)&&!!e.ctx&&!!e.renderNode&&!!F,I=r.useMemo(()=>{var n;return W&&e.ctx&&e.renderNode?$(R,e.ctx,`${String(null!=(n=e.indexKey)?n:"html-inline")}-structured`,e.renderNode):null},[W,e.ctx,e.indexKey,e.renderNode,R]),_=r.useMemo(()=>{var n,t;const r=C.content;if(!r)return{mode:"html",content:""};if("escape"===N)return{mode:"html",content:r};if(!U(r,E))return{mode:"html",content:r};const o=function(e,n,t="safe",r={}){if(!e)return[];try{const o=function(e,n,t="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,n),u=Boolean(at(s.tagName,r));if(x.has(s.tagName.toLowerCase())||!d&&!u&&k(s.tagName,t))continue;if(!d&&!u&&w(s.tagName,t)){(a.length>0?a[a.length-1].children:c).push(o),a.length>0&&a[a.length-1].sourceParts.push(o);continue}const m=ut(s.tagName,e,[],n,`${l}-${i++}`,t,r,"",o,{loading:!1,autoClosed:!1});it(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,n),i=Boolean(at(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,t),softBlocked:!e&&!o&&!i&&w(s.tagName,t)})}else if("tag_close"===s.type){const e=s.tagName.toLowerCase();let o=-1;for(let n=a.length-1;n>=0;n--)if(a[n].tagName.toLowerCase()===e){o=n;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}:dt(r);m=ut(s.tagName,s.attrs||{},s.children,n,`${l}-${i++}`,t,r,d,u,o)}a.length>0?it(a[a.length-1].children,m):it(c,m),a.length>0&&!s.hardBlocked&&a[a.length-1].sourceParts.push(u),s.tagName.toLowerCase()!==e&&a.length>o&&rt(`Auto-closing unclosed tag: <${s.tagName}>`)}else rt(`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}>`]:ut(e.tagName,e.attrs||{},e.children,n,`${l}-${i++}`,t,r,o,s,dt(r)),it(c,d),a.length>0&&!e.hardBlocked&&a[a.length-1].sourceParts.push(s),rt(`Auto-closing unclosed tag: <${e.tagName}>`)}return c}(Z(e),n,t,r);return o}catch(i){return o=i,tt&&console.error("Failed to parse HTML to React nodes:",o),null}var o}(r,L,N,{ctx:e.ctx,keyPrefix:String(null!=(n=e.indexKey)?n:"html-inline"),nodeComponents:null==(t=e.ctx)?void 0:t.streamingComponents,renderNode:e.renderNode,sourceNode:C});return null===o?{mode:"html",content:r}:{mode:"dynamic",block:lt(r,E),nodes:o}},[L,E,N,C.autoClosed,C.content,C.loading,e.ctx,e.indexKey,e.renderNode]);return s(()=>{if(!S||!B.current||"html"!==_.mode)return;const e=B.current;e.innerHTML="";const n=document.createElement("template");n.innerHTML=D,e.appendChild(n.content.cloneNode(!0))},[_.mode,S,D]),!C.loading||C.autoClosed||W||"dynamic"===_.mode?W?r.createElement(F,H,I):"dynamic"===_.mode?_.block?/* @__PURE__ */n(t,{children:_.nodes}):/* @__PURE__ */n("span",{className:"html-inline-node",style:{display:"inline"},children:_.nodes}):/* @__PURE__ */n("span",{ref:B,className:"html-inline-node",style:{display:"inline"}}):/* @__PURE__ */n("span",{className:"html-inline-node html-inline-node--loading",children:C.content})}const ht={fallbackSrc:"",lazy:!0,usePlaceholder:!0};function ft(e,n,t){return t||e?{src:e,stage:"primary"}:n?{src:n,stage:"fallback"}:{src:"",stage:"failed"}}function pt(r){var o,l,a,c,d,u;const m={...ht,...r},h=b(m.node.src),f=b(m.fallbackSrc),p=ft(h,f,m.node.loading),[g,v]=i(!1),[w,y]=i(!1),[x,k]=i(p.src),[C,M]=i(p.stage),N=x;s(()=>{const e=ft(h,f,m.node.loading);k(e.src),M(e.stage),v(!1),y("failed"===e.stage)},[h,f,m.node.loading]);return!m.node.loading&&"failed"!==C&&N?/* @__PURE__ */n("img",{src:N,alt:String(null!=(l=null!=(o=m.node.alt)?o:m.node.title)?l:""),title:String(null!=(c=null!=(a=m.node.title)?a:m.node.alt)?c:""),className:"image-node__img"+(g?" is-loaded":""),loading:m.lazy?"lazy":"eager",decoding:"async",tabIndex:g?0:-1,"aria-label":null!=(d=m.node.alt)?d:"Preview image",onError:()=>{var e;if("primary"===C&&f&&f!==x)return k(f),M("fallback"),v(!1),void y(!1);M("failed"),y(!0),null==(e=m.onError)||e.call(m,x)},onLoad:()=>{var e;v(!0),y(!1),null==(e=m.onLoad)||e.call(m,N)},onClick:e=>{var n;e.preventDefault(),g&&!w&&(null==(n=m.onClick)||n.call(m,[e,N]))}},"image"):m.node.loading&&!w?/* @__PURE__ */n("span",{className:"image-node__placeholder",children:m.usePlaceholder?/* @__PURE__ */e(t,{children:[
57
+ /* @__PURE__ */n("span",{className:"html-block-node__placeholder-bar w-2/3"})]})});return ne&&ae?r.createElement(ae,Q,le):ne?r.createElement(Z,{...te,ref:$},A?le:ce):/* @__PURE__ */n("div",{ref:$,className:"html-block-node",...j,children:A?re&&oe?/* @__PURE__ */n(t,{children:oe}):/* @__PURE__ */n("div",{dangerouslySetInnerHTML:{__html:ie}}):ce})}const rt=(()=>{try{return Boolean(!1)}catch{}return!1})();function ot(e){rt&&console.warn(e)}function it(e,n,t=!1){const r=Object.entries(null!=n?n:{}),o=r.length>0?r.map(([e,n])=>""===n?` ${e}`:` ${e}="${n}"`).join(""):"";return t?`<${e}${o} />`:`<${e}${o}>`}function lt(e,n){Array.isArray(n)?e.push(...n):null!=n&&e.push(n)}function at(e,n){var t;for(const r of Z(e)){if("tag_open"!==r.type&&"self_closing"!==r.type)continue;const e=null!=(t=r.tagName)?t:"";if(!G(e,n))continue;const o=n[e]||n[e.toLowerCase()];if("block"===J(o))return!0}return!1}function ct(e,n){var t,r;return(null==(t=n.nodeComponents)?void 0:t[e])||(null==(r=n.nodeComponents)?void 0:r[e.toLowerCase()])}function st(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(st).join("");if(!r.isValidElement(e))return"";const n=e;if("string"!=typeof n.type)return st(n.props.children);const t=Object.entries(n.props).filter(([e,n])=>"children"!==e&&"key"!==e&&"ref"!==e&&null!=n&&"boolean"!=typeof n).map(([e,n])=>` ${"className"===e?"class":e}="${String(n)}"`).join("");return`<${n.type}${t}>${st(n.props.children)}</${n.type}>`}function dt(e){return Object.entries(e).map(([e,n])=>[e,""===n?null:n])}function ut(e){var n,t;const r=e.sourceNode,o=!0!==(null==(n=e.ctx)?void 0:n.final)&&(!1===(null==(t=e.ctx)?void 0:t.final)||Boolean(null==r?void 0:r.loading));return{loading:o,autoClosed:o||Boolean(null==r?void 0:r.autoClosed)}}function mt(e,n,t,o,i,l,a,c,s,d){const u=G(e,o),m=Boolean(ct(e,a));if(x.has(e.toLowerCase())||!u&&!m&&k(e,l))return null;if(!u&&!m&&w(e,l))return[it(e,n),...t,`</${e}>`];const h=Q(n,l,e),g=h.key,v=null!=g&&""!==g?g:i;if(m)return function(e,n,t,o,i,l,a,c=ut(i)){const s=f(e),d=null!=l?l:function(e){return e.map(st).join("")}(t),u={type:s,tag:s,attrs:dt(n),content:d,raw:null!=a?a:`${it(e,n)}${d}</${e}>`,loading:c.loading,autoClosed:c.autoClosed};if(i.ctx&&i.renderNode)return i.renderNode(u,o,i.ctx);const m=ct(e,i);return m?r.createElement(m,{key:o,node:u}):null}(e,n,t,String(v),a,c,s,d);if(u){const n=o[e]||o[e.toLowerCase()],i=p(h);return r.createElement(n,{...i,key:v},...t)}return r.createElement(e,{...q(h),key:v},...t)}function ht(e){var o,l,a,d,u,m,v,b;const{node:C,customId:M}=e,N=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 L=r.useMemo(()=>{var n,t,r,o;return{...null!=(t=null==(n=e.ctx)?void 0:n.customComponents)?t:K(M),...null!=(o=null==(r=e.ctx)?void 0:r.htmlComponents)?o:{}}},[M,null==(d=e.ctx)?void 0:d.customComponents,null==(u=e.ctx)?void 0:u.htmlComponents]),E=r.useMemo(()=>{var n,t;return{...L,...null!=(t=null==(n=e.ctx)?void 0:n.streamingComponents)?t:{}}},[L,null==(m=e.ctx)?void 0:m.streamingComponents]),$=r.useMemo(()=>{var e;return y(null!=(e=C.content)?e:"",N)},[N,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]),H=r.useMemo(()=>{var e;return p(g(h(null!=(e=C.attrs)?e:void 0,N,A)))},[N,C.attrs,A]),W=A?null==(b=null==(v=e.ctx)?void 0:v.htmlComponents)?void 0:b[A]:void 0,F=R.length>0&&!!P&&"escape"!==N&&!w(P,N)&&!!e.ctx&&!!e.renderNode&&!!W,I=r.useMemo(()=>{var n;return F&&e.ctx&&e.renderNode?D(R,e.ctx,`${String(null!=(n=e.indexKey)?n:"html-inline")}-structured`,e.renderNode):null},[F,e.ctx,e.indexKey,e.renderNode,R]),_=r.useMemo(()=>{var n,t;const r=C.content;if(!r)return{mode:"html",content:""};if("escape"===N)return{mode:"html",content:r};if(!U(r,E))return{mode:"html",content:r};const o=function(e,n,t="safe",r={}){if(!e)return[];try{const o=function(e,n,t="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=it(s.tagName,e,!0),d=G(s.tagName,n),u=Boolean(ct(s.tagName,r));if(x.has(s.tagName.toLowerCase())||!d&&!u&&k(s.tagName,t))continue;if(!d&&!u&&w(s.tagName,t)){(a.length>0?a[a.length-1].children:c).push(o),a.length>0&&a[a.length-1].sourceParts.push(o);continue}const m=mt(s.tagName,e,[],n,`${l}-${i++}`,t,r,"",o,{loading:!1,autoClosed:!1});lt(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,n),i=Boolean(ct(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,t),softBlocked:!e&&!o&&!i&&w(s.tagName,t)})}else if("tag_close"===s.type){const e=s.tagName.toLowerCase();let o=-1;for(let n=a.length-1;n>=0;n--)if(a[n].tagName.toLowerCase()===e){o=n;break}if(-1!==o)for(;a.length>o;){const s=a.pop(),d=s.sourceParts.join(""),u=`${it(s.tagName,s.attrs||{})}${d}</${s.tagName}>`;let m;if(s.hardBlocked)m=null;else if(s.softBlocked)m=[it(s.tagName,s.attrs||{}),...s.children,`</${s.tagName}>`];else{const o=s.tagName.toLowerCase()===e?{loading:!1,autoClosed:!1}:ut(r);m=mt(s.tagName,s.attrs||{},s.children,n,`${l}-${i++}`,t,r,d,u,o)}a.length>0?lt(a[a.length-1].children,m):lt(c,m),a.length>0&&!s.hardBlocked&&a[a.length-1].sourceParts.push(u),s.tagName.toLowerCase()!==e&&a.length>o&&ot(`Auto-closing unclosed tag: <${s.tagName}>`)}else ot(`Ignoring closing tag with no matching opening tag: </${s.tagName}>`)}for(;a.length>0;){const e=a.pop(),o=e.sourceParts.join(""),s=`${it(e.tagName,e.attrs||{})}${o}`;let d;d=e.hardBlocked?null:e.softBlocked?[it(e.tagName,e.attrs||{}),...e.children,`</${e.tagName}>`]:mt(e.tagName,e.attrs||{},e.children,n,`${l}-${i++}`,t,r,o,s,ut(r)),lt(c,d),a.length>0&&!e.hardBlocked&&a[a.length-1].sourceParts.push(s),ot(`Auto-closing unclosed tag: <${e.tagName}>`)}return c}(Z(e),n,t,r);return o}catch(i){return o=i,rt&&console.error("Failed to parse HTML to React nodes:",o),null}var o}(r,L,N,{ctx:e.ctx,keyPrefix:String(null!=(n=e.indexKey)?n:"html-inline"),nodeComponents:null==(t=e.ctx)?void 0:t.streamingComponents,renderNode:e.renderNode,sourceNode:C});return null===o?{mode:"html",content:r}:{mode:"dynamic",block:at(r,E),nodes:o}},[L,E,N,C.autoClosed,C.content,C.loading,e.ctx,e.indexKey,e.renderNode]);return s(()=>{if(!S||!B.current||"html"!==_.mode)return;const e=B.current;e.innerHTML="";const n=document.createElement("template");n.innerHTML=$,e.appendChild(n.content.cloneNode(!0))},[_.mode,S,$]),!C.loading||C.autoClosed||F||"dynamic"===_.mode?F?r.createElement(W,H,I):"dynamic"===_.mode?_.block?/* @__PURE__ */n(t,{children:_.nodes}):/* @__PURE__ */n("span",{className:"html-inline-node",style:{display:"inline"},children:_.nodes}):/* @__PURE__ */n("span",{ref:B,className:"html-inline-node",style:{display:"inline"}}):/* @__PURE__ */n("span",{className:"html-inline-node html-inline-node--loading",children:C.content})}const ft={fallbackSrc:"",lazy:!0,usePlaceholder:!0};function pt(e,n,t){return t||e?{src:e,stage:"primary"}:n?{src:n,stage:"fallback"}:{src:"",stage:"failed"}}function gt(r){var o,l,a,c,d,u;const m={...ft,...r},h=b(m.node.src),f=b(m.fallbackSrc),p=pt(h,f,m.node.loading),[g,v]=i(!1),[w,y]=i(!1),[x,k]=i(p.src),[C,M]=i(p.stage),N=x;s(()=>{const e=pt(h,f,m.node.loading);k(e.src),M(e.stage),v(!1),y("failed"===e.stage)},[h,f,m.node.loading]);return!m.node.loading&&"failed"!==C&&N?/* @__PURE__ */n("img",{src:N,alt:String(null!=(l=null!=(o=m.node.alt)?o:m.node.title)?l:""),title:String(null!=(c=null!=(a=m.node.title)?a:m.node.alt)?c:""),className:"image-node__img"+(g?" is-loaded":""),loading:m.lazy?"lazy":"eager",decoding:"async",tabIndex:g?0:-1,"aria-label":null!=(d=m.node.alt)?d:"Preview image",onError:()=>{var e;if("primary"===C&&f&&f!==x)return k(f),M("fallback"),v(!1),void y(!1);M("failed"),y(!0),null==(e=m.onError)||e.call(m,x)},onLoad:()=>{var e;v(!0),y(!1),null==(e=m.onLoad)||e.call(m,N)},onClick:e=>{var n;e.preventDefault(),g&&!w&&(null==(n=m.onClick)||n.call(m,[e,N]))}},"image"):m.node.loading&&!w?/* @__PURE__ */n("span",{className:"image-node__placeholder",children:m.usePlaceholder?/* @__PURE__ */e(t,{children:[
58
58
  /* @__PURE__ */n("span",{className:"image-node__spinner","aria-hidden":"true"}),
59
59
  /* @__PURE__ */n("span",{className:"image-node__placeholder-text",children:"Loading image..."})]}):/* @__PURE__ */n("span",{className:"image-node__placeholder-text",children:null!=(u=m.node.raw)?u:"Loading image…"})},"placeholder"):m.node.loading||"failed"!==C?null:/* @__PURE__ */e("span",{className:"image-node__error",children:[
60
60
  /* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24","aria-hidden":"true",children:/* @__PURE__ */n("path",{fill:"currentColor",d:"M2 2h20v10h-2V4H4v9.586l5-5L14.414 14L13 15.414l-4-4l-5 5V20h8v2H2zm13.547 5a1 1 0 1 0 0 2a1 1 0 0 0 0-2m-3 1a3 3 0 1 1 6 0a3 3 0 0 1-6 0m3.625 6.757L19 17.586l2.828-2.829l1.415 1.415L20.414 19l2.829 2.828l-1.415 1.415L19 20.414l-2.828 2.829l-1.415-1.415L17.586 19l-2.829-2.828z"})}),
61
- /* @__PURE__ */n("span",{className:"image-node__placeholder-text",children:"Image failed to load"})]})}let gt=null,vt=null;const wt=/* @__PURE__ */n("svg",{width:"1em",height:"1em",viewBox:"0 0 291 300",fill:"none",className:"w-4 h-4 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",children:/* @__PURE__ */e("g",{children:[
61
+ /* @__PURE__ */n("span",{className:"image-node__placeholder-text",children:"Image failed to load"})]})}let vt=null,wt=null;const yt=/* @__PURE__ */n("svg",{width:"1em",height:"1em",viewBox:"0 0 291 300",fill:"none",className:"w-4 h-4 flex-shrink-0",xmlns:"http://www.w3.org/2000/svg",children:/* @__PURE__ */e("g",{children:[
62
62
  /* @__PURE__ */n("path",{d:"M140.904 239.376C128.83 239.683 119.675 239.299 115.448 243.843C110.902 248.07 111.288 257.227 110.979 269.302C111.118 274.675 111.118 279.478 111.472 283.52C111.662 285.638 111.95 287.547 112.406 289.224C112.411 289.243 112.416 289.259 112.422 289.28C112.462 289.419 112.496 289.558 112.539 289.691C113.168 291.787 114.088 293.491 115.446 294.758C116.662 296.064 118.283 296.963 120.264 297.69C120.36 297.614 120.464 297.646 120.555 297.675C120.56 297.68 120.56 297.68 120.566 297.68C120.848 297.768 121.142 297.846 121.443 297.923C121.454 297.923 121.464 297.928 121.478 297.934C122.875 298.272 124.424 298.507 126.11 298.678C126.326 298.696 126.542 298.718 126.763 298.739C130.79 299.086 135.558 299.088 140.904 299.222C152.974 298.912 162.128 299.302 166.36 294.758C170.904 290.526 170.515 281.371 170.824 269.302C170.515 257.227 170.907 248.07 166.36 243.843C162.131 239.299 152.974 239.683 140.904 239.376Z",fill:"#FF6376"}),
63
63
  /* @__PURE__ */n("path",{d:"M21.2155 128.398C12.6555 128.616 6.16484 128.339 3.16751 131.56C-0.0538222 134.56 0.218178 141.054 -0.000488281 149.608C0.218178 158.168 -0.0538222 164.659 3.16751 167.656C6.16484 170.878 12.6555 170.606 21.2155 170.824C25.0262 170.726 28.4288 170.726 31.2955 170.475C32.7968 170.342 34.1488 170.136 35.3382 169.814C35.3542 169.811 35.3648 169.806 35.3782 169.803C35.4768 169.774 35.5755 169.747 35.6688 169.718C37.1568 169.272 38.3648 168.622 39.2635 167.656C40.1915 166.795 40.8262 165.646 41.2715 164.243C41.2875 164.174 41.3115 164.102 41.3328 164.035C41.3328 164.035 41.3355 164.032 41.3355 164.027C41.3968 163.827 41.4529 163.622 41.5062 163.406C41.5062 163.398 41.5115 163.392 41.5142 163.382C41.7542 162.392 41.9222 161.294 42.0422 160.096C42.0555 159.944 42.0715 159.792 42.0848 159.635C42.3328 156.779 42.3328 153.398 42.4262 149.608C42.2075 141.054 42.4848 134.56 39.2635 131.56C36.2635 128.339 29.7728 128.616 21.2155 128.398Z",fill:"#FFCCCC"}),
64
64
  /* @__PURE__ */n("path",{d:"M81.0595 184.171C70.8568 184.433 63.1208 184.102 59.5475 187.942C55.7075 191.518 56.0328 199.254 55.7742 209.454C56.0328 219.657 55.7075 227.393 59.5475 230.963C63.1208 234.803 70.8568 234.478 81.0595 234.739C85.6008 234.622 89.6595 234.622 93.0728 234.323C94.8648 234.163 96.4755 233.921 97.8942 233.534C97.9102 233.529 97.9235 233.526 97.9422 233.521C98.0568 233.486 98.1742 233.457 98.2888 233.422C100.06 232.889 101.5 232.113 102.569 230.963C103.676 229.937 104.433 228.566 104.964 226.894C104.985 226.811 105.012 226.726 105.036 226.646C105.041 226.643 105.041 226.643 105.041 226.638C105.116 226.401 105.18 226.153 105.244 225.897C105.244 225.889 105.249 225.881 105.254 225.867C105.54 224.689 105.74 223.379 105.881 221.953C105.9 221.771 105.916 221.59 105.934 221.403C106.228 218.001 106.228 213.969 106.342 209.454C106.081 199.254 106.412 191.518 102.572 187.942C98.9955 184.102 91.2568 184.433 81.0595 184.171Z",fill:"#FF939F"}),
65
65
  /* @__PURE__ */n("path",{d:"M260.591 151.87C215.652 151.87 203.02 164.523 203.02 209.462H198.476C198.476 164.523 185.836 151.881 140.895 151.881V147.337C185.836 147.337 198.487 134.705 198.487 89.7659H203.02C203.02 134.705 215.652 147.337 260.591 147.337V151.87ZM286.052 124.158C281.82 119.614 272.66 120.001 260.591 119.689C248.521 119.385 239.361 119.771 235.129 115.227C230.585 110.995 230.983 101.846 230.671 89.7659C230.513 83.7312 230.535 78.4272 230.023 74.1019C229.513 69.7659 228.481 66.4219 226.209 64.3046C221.967 59.7606 212.817 60.1472 200.748 59.8459C188.681 60.1472 179.519 59.7606 175.287 64.3046C170.753 68.5366 171.129 77.6966 170.828 89.7659C170.516 101.835 170.9 110.995 166.356 115.227C162.124 119.771 152.985 119.374 140.905 119.689C138.873 119.739 136.924 119.771 135.071 119.811C119.313 118.697 106.337 112.318 106.337 89.7659C106.212 84.6699 106.233 80.1792 105.807 76.5206C105.367 72.8726 104.492 70.0379 102.575 68.2566C99.0013 64.4112 91.2573 64.7446 81.0653 64.4832C70.86 64.7446 63.1186 64.4112 59.5533 68.2566C55.708 71.8299 56.0306 79.5632 55.7693 89.7659C56.0306 99.9686 55.708 107.702 59.5533 111.278C63.1186 115.113 70.86 114.79 81.0653 115.049C103.617 115.049 109.996 128.035 111.1 143.803C111.068 145.659 111.028 147.587 110.975 149.619C111.121 154.987 111.121 159.79 111.476 163.835C111.663 165.95 111.945 167.857 112.404 169.534C112.412 169.555 112.412 169.566 112.423 169.598C112.465 169.734 112.497 169.867 112.537 170.003C113.164 172.099 114.092 173.809 115.447 175.07C116.665 176.371 118.281 177.278 120.271 177.905C120.364 177.934 120.46 177.955 120.564 177.987C120.855 178.081 121.145 178.153 121.439 178.238C121.46 178.238 121.471 178.238 121.479 178.249C122.876 178.582 124.42 178.822 126.108 178.987C126.327 179.009 126.545 179.03 126.764 179.051C130.788 179.395 135.559 179.395 140.905 179.529C152.975 179.843 162.124 179.457 166.356 184.001C170.9 188.233 170.516 197.371 170.828 209.451C171.129 221.529 170.743 230.681 175.287 234.91C179.519 239.454 188.681 239.07 200.748 239.371C206.127 239.235 210.921 239.235 214.975 238.881C217.079 238.694 218.985 238.403 220.676 237.955C220.695 237.945 220.705 237.934 220.727 237.934C220.873 237.891 220.999 237.859 221.135 237.819C223.228 237.193 224.937 236.265 226.209 234.91C227.511 233.691 228.409 232.065 229.044 230.097C229.065 230.003 229.095 229.899 229.127 229.803V229.793C229.22 229.513 229.295 229.222 229.367 228.918C229.367 228.897 229.377 228.897 229.377 228.878C229.721 227.481 229.951 225.937 230.127 224.249C230.137 224.03 230.169 223.811 230.191 223.593C230.535 219.571 230.535 214.798 230.671 209.451C230.972 197.371 230.585 188.233 235.129 184.001C239.361 179.457 248.511 179.843 260.591 179.529C272.66 179.227 281.82 179.614 286.052 175.07C290.596 170.838 290.209 161.689 290.511 149.619C290.209 137.539 290.596 128.379 286.052 124.158Z",fill:"#FF356A"}),
66
- /* @__PURE__ */n("path",{d:"M112.405 49.848C112.411 49.8694 112.416 49.8827 112.421 49.904C112.461 50.0427 112.499 50.1814 112.539 50.3147C113.171 52.4134 114.088 54.1147 115.448 55.384C116.661 56.6907 118.283 57.5894 120.264 58.2134C120.36 58.24 120.464 58.2694 120.555 58.3014C120.56 58.3067 120.56 58.3067 120.565 58.3067C120.848 58.3947 121.141 58.4694 121.443 58.5467C121.453 58.5467 121.464 58.552 121.48 58.5574C122.875 58.896 124.424 59.1334 126.112 59.3014C126.325 59.3227 126.541 59.3414 126.763 59.3627C130.789 59.712 135.56 59.712 140.904 59.8454C152.973 59.5387 162.128 59.928 166.36 55.384C170.907 51.152 170.515 41.9947 170.824 29.9254C170.517 17.8507 170.907 8.69602 166.363 4.46935C162.131 -0.0746511 152.973 0.309349 140.904 1.52588e-05C128.829 0.309349 119.675 -0.0746511 115.448 4.46935C110.904 8.69602 111.288 17.8507 110.979 29.9254C111.117 35.3014 111.117 40.1014 111.472 44.144C111.661 46.2614 111.949 48.1707 112.405 49.848Z",fill:"#FF6376"})]})}),yt={maxHeight:"500px",loading:!0,showHeader:!0,showCopyButton:!0,showCollapseButton:!0,showModeToggle:!0,showExportButton:!0,showFullscreenButton:!0,showZoomControls:!0};function xt(r){var l;const a={...yt,...r},{t:u}=Ie(),[m,h]=i(!1),[f,p]=i(!1),[g,v]=i(!1),[w,y]=i(!1),[x,k]=i(()=>"undefined"==typeof window),b=a.node.code,C=o(()=>a.maxHeight&&"none"!==a.maxHeight?ee(a.maxHeight):null,[a.maxHeight]),M=o(()=>{var e;return ne(null!=(e=ee(a.estimatedPreviewHeightPx))?e:te(b),void 0,C)},[b,C,a.estimatedPreviewHeightPx]),[N,B]=i(`${M}px`),[S,T]=i(!1),[L,E]=i(1),[D,$]=i({x:0,y:0}),[P,A]=i(!1),R=c(null),H=c(null),F=c(null),W=c(null),I=c(null),_=c({x:0,y:0}),O=c(null),j=Ae(),z=d(e=>{if(!a.maxHeight||"none"===a.maxHeight)return`${Math.max(e,M)}px`;const n=Number.parseFloat(String(a.maxHeight));return Number.isFinite(n)?`${Math.max(Math.min(e,n),M)}px`:`${Math.max(e,M)}px`},[M,a.maxHeight]),V=d(()=>{const e=R.current;if(!e)return;const n=e.scrollHeight;n>0&&B(z(n))},[z]);s(()=>{g||f||B(e=>{const n=ee(e);return null!=n&&n>=M?e:`${M}px`})},[M,f,g]);const K=d(async()=>{var e,n;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(b)),h(!0),null==(n=a.onCopy)||n.call(a,b),setTimeout(()=>h(!1),1e3)}catch{}},[b,a]),X=d(async()=>{var e,n;if(!x)return;if(!R.current)return;const t=R.current;try{const r=await async function(){return vt||gt||(gt=import("@antv/infographic").then(e=>{const n=e&&e.default?e.default:e;let t=n;return"function"==typeof n&&n.prototype&&n.prototype.render?t=n:e.Infographic?t=e.Infographic:n&&n.Infographic&&(t=n.Infographic),vt=t,t}).catch(e=>(console.warn("Failed to load @antv/infographic",e),null)),gt)}();if(!r)return void console.warn("Infographic library failed to load.");O.current&&(null==(n=(e=O.current).destroy)||n.call(e),O.current=null),t.innerHTML="";const o=new r({container:t,width:"100%",height:"100%"});O.current=o,o.render(b),T(!0),setTimeout(()=>{V()},0)}catch(r){console.error("Failed to render infographic:",r),T(!1),t.innerHTML=`<div class="text-red-500 p-4">Failed to render infographic: ${r instanceof Error?r.message:"Unknown error"}</div>`}},[b,V,x]);s(()=>{const e=H.current;if(!e)return;const n=j(e,{rootMargin:"160px"});return F.current=n,n.isVisible()&&k(!0),n.whenVisible.then(()=>k(!0)),()=>{n.destroy(),F.current=null}},[j]),s(()=>{!x||g||f||X()},[b,f,X,g,x]),s(()=>()=>{var e,n;O.current&&(null==(n=(e=O.current).destroy)||n.call(e),O.current=null)},[]);const q=d(()=>{y(!1),W.current&&(W.current.innerHTML=""),I.current=null,document.body.style.overflow=""},[]),U=d(()=>{y(!0),document.body.style.overflow="hidden"},[]);s(()=>{if(!w)return;const e=e=>{"Escape"===e.key&&q()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[w,q]),s(()=>{w&&setTimeout(()=>{if(R.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 n=R.current.cloneNode(!0);n.classList.add("fullscreen"),n.style.height="auto",e.appendChild(n),W.current.appendChild(e),I.current=e,e.style.transform=`translate(${D.x}px, ${D.y}px) scale(${L})`}},0)},[w]),s(()=>{w&&I.current&&(I.current.style.transform=`translate(${D.x}px, ${D.y}px) scale(${L})`)},[w,D,L]);const Y=d(()=>{var e;const n=null==(e=R.current)?void 0:e.querySelector("svg");if(!n)return;const t=(new XMLSerializer).serializeToString(n),r=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=`infographic-${Date.now()}.svg`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)},[]),Z=e=>{A(!0);const n="touches"in e?e.touches[0].clientX:e.clientX,t="touches"in e?e.touches[0].clientY:e.clientY;_.current={x:n-D.x,y:t-D.y}},G=e=>{if(!P)return;const n="touches"in e?e.touches[0].clientX:e.clientX,t="touches"in e?e.touches[0].clientY:e.clientY;$({x:n-_.current.x,y:t-_.current.y})},J=()=>A(!1),Q=a.isDark?"p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200":"p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700",re=g||f;/* @__PURE__ */
66
+ /* @__PURE__ */n("path",{d:"M112.405 49.848C112.411 49.8694 112.416 49.8827 112.421 49.904C112.461 50.0427 112.499 50.1814 112.539 50.3147C113.171 52.4134 114.088 54.1147 115.448 55.384C116.661 56.6907 118.283 57.5894 120.264 58.2134C120.36 58.24 120.464 58.2694 120.555 58.3014C120.56 58.3067 120.56 58.3067 120.565 58.3067C120.848 58.3947 121.141 58.4694 121.443 58.5467C121.453 58.5467 121.464 58.552 121.48 58.5574C122.875 58.896 124.424 59.1334 126.112 59.3014C126.325 59.3227 126.541 59.3414 126.763 59.3627C130.789 59.712 135.56 59.712 140.904 59.8454C152.973 59.5387 162.128 59.928 166.36 55.384C170.907 51.152 170.515 41.9947 170.824 29.9254C170.517 17.8507 170.907 8.69602 166.363 4.46935C162.131 -0.0746511 152.973 0.309349 140.904 1.52588e-05C128.829 0.309349 119.675 -0.0746511 115.448 4.46935C110.904 8.69602 111.288 17.8507 110.979 29.9254C111.117 35.3014 111.117 40.1014 111.472 44.144C111.661 46.2614 111.949 48.1707 112.405 49.848Z",fill:"#FF6376"})]})}),xt={maxHeight:"500px",loading:!0,showHeader:!0,showCopyButton:!0,showCollapseButton:!0,showModeToggle:!0,showExportButton:!0,showFullscreenButton:!0,showZoomControls:!0};function kt(r){var l;const a={...xt,...r},{t:u}=Ie(),[m,h]=i(!1),[f,p]=i(!1),[g,v]=i(!1),[w,y]=i(!1),[x,k]=i(()=>"undefined"==typeof window),b=a.node.code,C=o(()=>a.maxHeight&&"none"!==a.maxHeight?ee(a.maxHeight):null,[a.maxHeight]),M=o(()=>{var e;return ne(null!=(e=ee(a.estimatedPreviewHeightPx))?e:te(b),void 0,C)},[b,C,a.estimatedPreviewHeightPx]),[N,B]=i(`${M}px`),[S,T]=i(!1),[L,E]=i(1),[$,D]=i({x:0,y:0}),[P,A]=i(!1),R=c(null),H=c(null),W=c(null),F=c(null),I=c(null),_=c({x:0,y:0}),O=c(null),j=Ae(),z=d(e=>{if(!a.maxHeight||"none"===a.maxHeight)return`${Math.max(e,M)}px`;const n=Number.parseFloat(String(a.maxHeight));return Number.isFinite(n)?`${Math.max(Math.min(e,n),M)}px`:`${Math.max(e,M)}px`},[M,a.maxHeight]),V=d(()=>{const e=R.current;if(!e)return;const n=e.scrollHeight;n>0&&B(z(n))},[z]);s(()=>{g||f||B(e=>{const n=ee(e);return null!=n&&n>=M?e:`${M}px`})},[M,f,g]);const K=d(async()=>{var e,n;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(b)),h(!0),null==(n=a.onCopy)||n.call(a,b),setTimeout(()=>h(!1),1e3)}catch{}},[b,a]),X=d(async()=>{var e,n;if(!x)return;if(!R.current)return;const t=R.current;try{const r=await async function(){return wt||vt||(vt=import("@antv/infographic").then(e=>{const n=e&&e.default?e.default:e;let t=n;return"function"==typeof n&&n.prototype&&n.prototype.render?t=n:e.Infographic?t=e.Infographic:n&&n.Infographic&&(t=n.Infographic),wt=t,t}).catch(e=>(console.warn("Failed to load @antv/infographic",e),null)),vt)}();if(!r)return void console.warn("Infographic library failed to load.");O.current&&(null==(n=(e=O.current).destroy)||n.call(e),O.current=null),t.innerHTML="";const o=new r({container:t,width:"100%",height:"100%"});O.current=o,o.render(b),T(!0),setTimeout(()=>{V()},0)}catch(r){console.error("Failed to render infographic:",r),T(!1),t.innerHTML=`<div class="text-red-500 p-4">Failed to render infographic: ${r instanceof Error?r.message:"Unknown error"}</div>`}},[b,V,x]);s(()=>{const e=H.current;if(!e)return;const n=j(e,{rootMargin:"160px"});return W.current=n,n.isVisible()&&k(!0),n.whenVisible.then(()=>k(!0)),()=>{n.destroy(),W.current=null}},[j]),s(()=>{!x||g||f||X()},[b,f,X,g,x]),s(()=>()=>{var e,n;O.current&&(null==(n=(e=O.current).destroy)||n.call(e),O.current=null)},[]);const q=d(()=>{y(!1),F.current&&(F.current.innerHTML=""),I.current=null,document.body.style.overflow=""},[]),U=d(()=>{y(!0),document.body.style.overflow="hidden"},[]);s(()=>{if(!w)return;const e=e=>{"Escape"===e.key&&q()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[w,q]),s(()=>{w&&setTimeout(()=>{if(R.current&&F.current){F.current.innerHTML="";const e=document.createElement("div");Object.assign(e.style,{transition:"transform 0.1s ease",transformOrigin:"center center",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"});const n=R.current.cloneNode(!0);n.classList.add("fullscreen"),n.style.height="auto",e.appendChild(n),F.current.appendChild(e),I.current=e,e.style.transform=`translate(${$.x}px, ${$.y}px) scale(${L})`}},0)},[w]),s(()=>{w&&I.current&&(I.current.style.transform=`translate(${$.x}px, ${$.y}px) scale(${L})`)},[w,$,L]);const Y=d(()=>{var e;const n=null==(e=R.current)?void 0:e.querySelector("svg");if(!n)return;const t=(new XMLSerializer).serializeToString(n),r=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=`infographic-${Date.now()}.svg`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)},[]),Z=e=>{A(!0);const n="touches"in e?e.touches[0].clientX:e.clientX,t="touches"in e?e.touches[0].clientY:e.clientY;_.current={x:n-$.x,y:t-$.y}},G=e=>{if(!P)return;const n="touches"in e?e.touches[0].clientX:e.clientX,t="touches"in e?e.touches[0].clientY:e.clientY;D({x:n-_.current.x,y:t-_.current.y})},J=()=>A(!1),Q=a.isDark?"p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200":"p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700",re=g||f;/* @__PURE__ */
67
67
  return e(t,{children:[
68
68
  /* @__PURE__ */e("div",{ref:H,"data-markstream-infographic":"1","data-markstream-mode":g?"source":S?"preview":"pending",className:Dn("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:Dn("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:[wt,
69
+ /* @__PURE__ */e("div",{className:"flex items-center gap-x-2 overflow-hidden",children:[yt,
70
70
  /* @__PURE__ */n("span",{className:Dn("text-sm font-medium font-mono truncate",a.isDark?"text-gray-400":"text-gray-600"),children:"Infographic"})]}),a.showModeToggle&&/* @__PURE__ */e("div",{className:Dn("flex items-center gap-x-1 rounded-md p-0.5",a.isDark?"bg-gray-700":"bg-gray-100"),children:[
71
71
  /* @__PURE__ */n("button",{className:Dn("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:()=>Ye(),children:/* @__PURE__ */e("div",{className:"flex items-center gap-x-1",children:[
72
72
  /* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
@@ -83,47 +83,47 @@ return e(t,{children:[
83
83
  /* @__PURE__ */n("path",{d:"m7 10l5 5l5-5"})]})})}),a.showFullscreenButton&&/* @__PURE__ */n("button",{className:Dn(Q,re&&"opacity-50 cursor-not-allowed"),disabled:re,onClick:U,onMouseEnter:e=>Ue(e.currentTarget,w?u("common.minimize")||"Minimize":u("common.open")||"Open","top",!1,0,a.isDark),onMouseLeave:()=>Ye(),children:/* @__PURE__ */n("svg",w?{xmlns:"http://www.w3.org/2000/svg",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})})]})]}),!f&&/* @__PURE__ */n("div",{children:g?/* @__PURE__ */n("div",{className:Dn("p-4",a.isDark?"bg-gray-900":"bg-gray-50"),children:/* @__PURE__ */n("pre",{className:Dn("text-sm font-mono whitespace-pre-wrap",a.isDark?"text-gray-300":"text-gray-700"),children:b})}):/* @__PURE__ */e("div",{className:"relative",children:[a.showZoomControls&&/* @__PURE__ */n("div",{className:"absolute top-2 right-2 z-10 rounded-lg",children:/* @__PURE__ */e("div",{className:"flex items-center gap-2 backdrop-blur rounded-lg",children:[
84
84
  /* @__PURE__ */n("button",{className:Dn("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.min(L+.1,3)),children:"+"}),
85
85
  /* @__PURE__ */n("button",{className:Dn("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.max(L-.1,.5)),children:"-"}),
86
- /* @__PURE__ */e("button",{className:Dn("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{E(1),$({x:0,y:0})},children:[Math.round(100*L),"%"]})]})}),
87
- /* @__PURE__ */n("div",{className:Dn("infographic-preview min-h-[360px] relative transition-all duration-100 overflow-hidden block",a.isDark?"bg-gray-900":"bg-gray-50"),style:{height:N,maxHeight:null!=(l=a.maxHeight)?l:void 0},onMouseDown:Z,onMouseMove:G,onMouseUp:J,onMouseLeave:J,onTouchStart:Z,onTouchMove:G,onTouchEnd:J,children:/* @__PURE__ */n("div",{className:Dn("absolute inset-0 cursor-grab",P&&"cursor-grabbing"),style:{transform:`translate(${D.x}px, ${D.y}px) scale(${L})`},children:/* @__PURE__ */n("div",{ref:R,className:"w-full text-center flex items-center justify-center min-h-full"})})})]})})]}),w&&"undefined"!=typeof document&&ye(
86
+ /* @__PURE__ */e("button",{className:Dn("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{E(1),D({x:0,y:0})},children:[Math.round(100*L),"%"]})]})}),
87
+ /* @__PURE__ */n("div",{className:Dn("infographic-preview min-h-[360px] relative transition-all duration-100 overflow-hidden block",a.isDark?"bg-gray-900":"bg-gray-50"),style:{height:N,maxHeight:null!=(l=a.maxHeight)?l:void 0},onMouseDown:Z,onMouseMove:G,onMouseUp:J,onMouseLeave:J,onTouchStart:Z,onTouchMove:G,onTouchEnd:J,children:/* @__PURE__ */n("div",{className:Dn("absolute inset-0 cursor-grab",P&&"cursor-grabbing"),style:{transform:`translate(${$.x}px, ${$.y}px) scale(${L})`},children:/* @__PURE__ */n("div",{ref:R,className:"w-full text-center flex items-center justify-center min-h-full"})})})]})})]}),w&&"undefined"!=typeof document&&ye(
88
88
  /* @__PURE__ */n("div",{className:"markstream-react fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:q,role:"dialog","aria-modal":"true",children:/* @__PURE__ */e("div",{className:Dn("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:[
89
89
  /* @__PURE__ */e("div",{className:"absolute top-6 right-6 z-50 flex items-center gap-2",children:[
90
90
  /* @__PURE__ */n("button",{className:Dn("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.min(L+.1,3)),children:"+"}),
91
91
  /* @__PURE__ */n("button",{className:Dn("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>E(Math.max(L-.1,.5)),children:"-"}),
92
- /* @__PURE__ */e("button",{className:Dn("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{E(1),$({x:0,y:0})},children:[Math.round(100*L),"%"]}),
92
+ /* @__PURE__ */e("button",{className:Dn("p-2 text-xs rounded transition-colors",a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),onClick:()=>{E(1),D({x:0,y:0})},children:[Math.round(100*L),"%"]}),
93
93
  /* @__PURE__ */n("button",{className:Dn("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:q,children:"X"})]}),
94
- /* @__PURE__ */n("div",{ref:W,className:Dn("w-full h-full flex items-center justify-center p-4 overflow-hidden",!P&&"cursor-grab",P&&"cursor-grabbing"),onMouseDown:Z,onMouseMove:G,onMouseUp:J,onMouseLeave:J,onTouchStart:Z,onTouchMove:G,onTouchEnd:J})]})}),document.body)]})}function kt(e,n){return e.reduce((e,t)=>{const r=null==n||t.id===n?{...t,fading:!1}:t,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 bt(e){var t,r;const{node:o,children:l,ctx:a,indexKey:d,fade:u}=e,m=String(null!=(t=o.code)?t:""),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=Le(),w=c(m),y=c(1),x=c(void 0);return s(()=>{var e,n;const t=null!=(e=null==v?void 0:v.getStreamRenderVersion())?e:null==a?void 0:a.streamRenderVersion,r=t!==x.current;if(null!=l)return w.current="",g([]),void(x.current=t);const o=null!=(n=null==v?void 0:v.textStreamState)?n:null==a?void 0:a.textStreamState,i=f?null==o?void 0:o.get(f):void 0;let c=w.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(n=>{if(s)return[{id:y.current++,content:c,fading:!1},{id:y.current++,content:e,fading:!0}];const t=n[n.length-1];return(null==t?void 0:t.fading)?[...n.slice(0,-1),{...t,content:t.content+e}]:[...n,{id:y.current++,content:e,fading:!0}]})}else g(m?[{id:y.current++,content:m,fading:!1}]:[]);else r&&g(e=>e.some(e=>e.fading)?kt(e):e);else g(e=>{var n;return 1!==e.length||(null==(n=e[0])?void 0:n.fading)||e[0].content!==m?m?[{id:y.current++,content:m,fading:!1}]:[]:e});w.current=m,x.current=t,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__ */n("code",{className:"inline-code inline text-[85%] px-1 py-0.5 rounded font-mono bg-[hsl(var(--secondary))] whitespace-normal break-words max-w-full",children:l||p.map(e=>/* @__PURE__ */n("span",{className:e.fading?Dn("text-node-stream-delta",e.id%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"):void 0,onAnimationEnd:e.fading?()=>{return n=e.id,void g(e=>e.some(e=>e.id===n&&e.fading)?kt(e,n):e);var n}:void 0,children:e.content},e.id))})}function Ct(e){/* @__PURE__ */
95
- return n("ins",{className:"insert-node",children:e.children})}function Mt(e,n){return e.reduce((e,t)=>{const r=null==n||t.id===n?{...t,fading:!1}:t,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 Nt(e){var t,r;const{node:o,children:l,ctx:a,indexKey:d,fade:u}=e,m=String(null!=(t=o.content)?t:""),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=Le(),w=c(m),y=c(1),x=c(void 0);return s(()=>{var e,n;const t=null!=(e=null==v?void 0:v.getStreamRenderVersion())?e:null==a?void 0:a.streamRenderVersion,r=t!==x.current;if(null!=l)return w.current="",g([]),void(x.current=t);const o=null!=(n=null==v?void 0:v.textStreamState)?n:null==a?void 0:a.textStreamState,i=f?null==o?void 0:o.get(f):void 0;let c=w.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(n=>{if(s)return[{id:y.current++,content:c,fading:!1},{id:y.current++,content:e,fading:!0}];const t=n[n.length-1];return(null==t?void 0:t.fading)?[...n.slice(0,-1),{...t,content:t.content+e}]:[...n,{id:y.current++,content:e,fading:!0}]})}else g(m?[{id:y.current++,content:m,fading:!1}]:[]);else r&&g(e=>e.some(e=>e.fading)?Mt(e):e);else g(e=>{var n;return 1!==e.length||(null==(n=e[0])?void 0:n.fading)||e[0].content!==m?m?[{id:y.current++,content:m,fading:!1}]:[]:e});w.current=m,x.current=t,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__ */n("span",null!=l?{className:Dn("text-node whitespace-pre-wrap break-words",o.center&&"text-node-center"),children:l}:{className:Dn("text-node whitespace-pre-wrap break-words",o.center&&"text-node-center"),children:p.map(e=>/* @__PURE__ */n("span",{className:e.fading?Dn("text-node-stream-delta",e.id%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"):void 0,onAnimationEnd:e.fading?()=>{return n=e.id,void g(e=>e.some(e=>e.id===n&&e.fading)?Mt(e,n):e);var n}:void 0,children:e.content},e.id))})}function Bt(t){var r,i,l;const{node:a,ctx:c,renderNode:s,indexKey:u}=t,m=!1!==t.showTooltip,h=null!=(r=t.isDark)?r:null==c?void 0:c.isDark,f=o(()=>{var e,n,r,o,i,l;const a=void 0!==t.underlineBottom?"number"==typeof t.underlineBottom?`${t.underlineBottom}px`:String(t.underlineBottom):"-3px",c=null!=(e=t.animationOpacity)?e:.35,s=Math.max(.12,Math.min(.5*c,c));return{"--link-color":null!=(n=t.color)?n:"#0366d6","--underline-height":`${null!=(r=t.underlineHeight)?r:2}px`,"--underline-bottom":a,"--underline-opacity":String(c),"--underline-rest-opacity":String(s),"--underline-duration":`${null!=(o=t.animationDuration)?o:1.6}s`,"--underline-timing":null!=(i=t.animationTiming)?i:"ease-in-out","--underline-iteration":"number"==typeof t.animationIteration?String(t.animationIteration):null!=(l=t.animationIteration)?l:"infinite"}},[t.animationDuration,t.animationIteration,t.animationOpacity,t.animationTiming,t.color,t.underlineBottom,t.underlineHeight]),p=o(()=>{var e;return 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=M(p),w=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]),y=d(()=>{m&&Ye()},[m]);return a.loading?/* @__PURE__ */n("span",{className:"link-loading inline-flex items-baseline gap-1.5","aria-hidden":"false",style:f,children:/* @__PURE__ */e("span",{className:"link-text-wrapper relative inline-flex",children:[
96
- /* @__PURE__ */n("span",{className:"leading-[normal] link-text",children:/* @__PURE__ */n(Nt,{node:{type:"text",content:String(null!=(i=a.text)?i:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-loading`,typewriter:t.typewriter})}),
97
- /* @__PURE__ */n("span",{className:"link-loading-indicator","aria-hidden":"true"})]})}):/* @__PURE__ */n("a",{className:"link-node",href:p||void 0,title:m?"":g,"aria-label":`Link: ${g}`,target:v?"_blank":void 0,rel:v?"noopener noreferrer":void 0,style:f,onMouseEnter:w,onMouseLeave:y,children:c&&s?$(a.children,c,String(null!=u?u:"link"),s):/* @__PURE__ */n(Nt,{node:{type:"text",content:String(null!=(l=a.text)?l:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-fallback`,typewriter:t.typewriter})})}function St(e){const{node:t,ctx:r,renderNode:o,value:i,indexKey:l,children:a}=e;/* @__PURE__ */
98
- return n("li",{className:"list-item pl-1.5 my-2",dir:"auto",value:null==i?void 0:i,children:null!=a?a:r&&o?$(t.children,r,String(null!=l?l:"list-item"),o):null})}function Tt(e){var t;const{node:r,ctx:o,renderNode:i,indexKey:l}=e,a=r.ordered?"ol":"ul",c=r.ordered&&r.start?r.start:void 0,s=o&&K(o.customId).list_item||St;/* @__PURE__ */
94
+ /* @__PURE__ */n("div",{ref:F,className:Dn("w-full h-full flex items-center justify-center p-4 overflow-hidden",!P&&"cursor-grab",P&&"cursor-grabbing"),onMouseDown:Z,onMouseMove:G,onMouseUp:J,onMouseLeave:J,onTouchStart:Z,onTouchMove:G,onTouchEnd:J})]})}),document.body)]})}function bt(e,n){return e.reduce((e,t)=>{const r=null==n||t.id===n?{...t,fading:!1}:t,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 Ct(e){var t,r;const{node:o,children:l,ctx:a,indexKey:d,fade:u}=e,m=String(null!=(t=o.code)?t:""),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=Le(),w=c(m),y=c(1),x=c(void 0);return s(()=>{var e,n;const t=null!=(e=null==v?void 0:v.getStreamRenderVersion())?e:null==a?void 0:a.streamRenderVersion,r=t!==x.current;if(null!=l)return w.current="",g([]),void(x.current=t);const o=null!=(n=null==v?void 0:v.textStreamState)?n:null==a?void 0:a.textStreamState,i=f?null==o?void 0:o.get(f):void 0;let c=w.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(n=>{if(s)return[{id:y.current++,content:c,fading:!1},{id:y.current++,content:e,fading:!0}];const t=n[n.length-1];return(null==t?void 0:t.fading)?[...n.slice(0,-1),{...t,content:t.content+e}]:[...n,{id:y.current++,content:e,fading:!0}]})}else g(m?[{id:y.current++,content:m,fading:!1}]:[]);else r&&g(e=>e.some(e=>e.fading)?bt(e):e);else g(e=>{var n;return 1!==e.length||(null==(n=e[0])?void 0:n.fading)||e[0].content!==m?m?[{id:y.current++,content:m,fading:!1}]:[]:e});w.current=m,x.current=t,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__ */n("code",{className:"inline-code inline text-[85%] px-1 py-0.5 rounded font-mono bg-[hsl(var(--secondary))] whitespace-normal break-words max-w-full",children:l||p.map(e=>/* @__PURE__ */n("span",{className:e.fading?Dn("text-node-stream-delta",e.id%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"):void 0,onAnimationEnd:e.fading?()=>{return n=e.id,void g(e=>e.some(e=>e.id===n&&e.fading)?bt(e,n):e);var n}:void 0,children:e.content},e.id))})}function Mt(e){/* @__PURE__ */
95
+ return n("ins",{className:"insert-node",children:e.children})}function Nt(e,n){return e.reduce((e,t)=>{const r=null==n||t.id===n?{...t,fading:!1}:t,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 Bt({content:e}){const t=c(e),r=c(t.current),o=c(null);return s(()=>{const n=o.current;if(n)if(e.startsWith(r.current)){const t=e.slice(r.current.length);t&&n.appendChild(document.createTextNode(t)),r.current=e}else n.textContent=e,r.current=e},[e]),/* @__PURE__ */n("span",{ref:o,children:t.current})}function St(e){var t,r;const{node:o,children:l,ctx:a,indexKey:d,fade:u}=e,m=String(null!=(t=o.content)?t:""),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=Le(),w=c(m),y=c(1),x=c(void 0);return s(()=>{var e,n;const t=null!=(e=null==v?void 0:v.getStreamRenderVersion())?e:null==a?void 0:a.streamRenderVersion,r=t!==x.current;if(null!=l)return w.current="",g([]),void(x.current=t);const o=null!=(n=null==v?void 0:v.textStreamState)?n:null==a?void 0:a.textStreamState,i=f?null==o?void 0:o.get(f):void 0;let c=w.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(n=>{if(s)return[{id:y.current++,content:c,fading:!1},{id:y.current++,content:e,fading:!0}];const t=n[n.length-1];return(null==t?void 0:t.fading)?[...n.slice(0,-1),{...t,content:t.content+e}]:[...n,{id:y.current++,content:e,fading:!0}]})}else g(m?[{id:y.current++,content:m,fading:!1}]:[]);else r&&g(e=>e.some(e=>e.fading)?Nt(e):e);else g(e=>{if(!m)return[];const n=e.reduce((e,n)=>e+n.content,"");return m===n?e:m.startsWith(n)?[...e,{id:y.current++,content:m.slice(n.length),fading:!1}]:[{id:y.current++,content:m,fading:!1}]});w.current=m,x.current=t,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__ */n("span",null!=l?{className:Dn("text-node whitespace-pre-wrap break-words",o.center&&"text-node-center"),children:l}:{className:Dn("text-node whitespace-pre-wrap break-words",o.center&&"text-node-center"),children:p.map(e=>/* @__PURE__ */n("span",{className:e.fading?Dn("text-node-stream-delta",e.id%2==0?"text-node-stream-delta--a":"text-node-stream-delta--b"):void 0,onAnimationEnd:e.fading?()=>{return n=e.id,void g(e=>e.some(e=>e.id===n&&e.fading)?Nt(e,n):e);var n}:void 0,children:e.fading?e.content:/* @__PURE__ */n(Bt,{content:e.content})},e.id))})}function Tt(t){var r,i,l;const{node:a,ctx:c,renderNode:s,indexKey:u}=t,m=!1!==t.showTooltip,h=null!=(r=t.isDark)?r:null==c?void 0:c.isDark,f=o(()=>{var e,n,r,o,i,l;const a=void 0!==t.underlineBottom?"number"==typeof t.underlineBottom?`${t.underlineBottom}px`:String(t.underlineBottom):"-3px",c=null!=(e=t.animationOpacity)?e:.35,s=Math.max(.12,Math.min(.5*c,c));return{"--link-color":null!=(n=t.color)?n:"#0366d6","--underline-height":`${null!=(r=t.underlineHeight)?r:2}px`,"--underline-bottom":a,"--underline-opacity":String(c),"--underline-rest-opacity":String(s),"--underline-duration":`${null!=(o=t.animationDuration)?o:1.6}s`,"--underline-timing":null!=(i=t.animationTiming)?i:"ease-in-out","--underline-iteration":"number"==typeof t.animationIteration?String(t.animationIteration):null!=(l=t.animationIteration)?l:"infinite"}},[t.animationDuration,t.animationIteration,t.animationOpacity,t.animationTiming,t.color,t.underlineBottom,t.underlineHeight]),p=o(()=>{var e;return 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=M(p),w=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]),y=d(()=>{m&&Ye()},[m]);return a.loading?/* @__PURE__ */n("span",{className:"link-loading inline-flex items-baseline gap-1.5","aria-hidden":"false",style:f,children:/* @__PURE__ */e("span",{className:"link-text-wrapper relative inline-flex",children:[
96
+ /* @__PURE__ */n("span",{className:"leading-[normal] link-text",children:/* @__PURE__ */n(St,{node:{type:"text",content:String(null!=(i=a.text)?i:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-loading`,typewriter:t.typewriter})}),
97
+ /* @__PURE__ */n("span",{className:"link-loading-indicator","aria-hidden":"true"})]})}):/* @__PURE__ */n("a",{className:"link-node",href:p||void 0,title:m?"":g,"aria-label":`Link: ${g}`,target:v?"_blank":void 0,rel:v?"noopener noreferrer":void 0,style:f,onMouseEnter:w,onMouseLeave:y,children:c&&s?D(a.children,c,String(null!=u?u:"link"),s):/* @__PURE__ */n(St,{node:{type:"text",content:String(null!=(l=a.text)?l:"")},ctx:c,indexKey:`${String(null!=u?u:"link")}-fallback`,typewriter:t.typewriter})})}function Lt(e){const{node:t,ctx:r,renderNode:o,value:i,indexKey:l,children:a}=e;/* @__PURE__ */
98
+ return n("li",{className:"list-item pl-1.5 my-2",dir:"auto",value:null==i?void 0:i,children:null!=a?a:r&&o?D(t.children,r,String(null!=l?l:"list-item"),o):null})}function Et(e){var t;const{node:r,ctx:o,renderNode:i,indexKey:l}=e,a=r.ordered?"ol":"ul",c=r.ordered&&r.start?r.start:void 0,s=o&&K(o.customId).list_item||Lt;/* @__PURE__ */
99
99
  return n(a,{className:Dn("list-node my-5 pl-[calc(13/8*1em)]",r.ordered?"list-decimal":"list-disc max-lg:my-[calc(4/3*1em)] max-lg:pl-[calc(14/9*1em)]"),start:c,children:null==(t=r.items)?void 0:t.map((e,t)=>{var a;/* @__PURE__ */
100
- return n(s,{node:e,value:r.ordered?(null!=(a=r.start)?a:1)+t:void 0,ctx:o,renderNode:i,indexKey:`${String(null!=l?l:"list")}-${t}`,customId:null==o?void 0:o.customId,isDark:null==o?void 0:o.isDark,typewriter:null==o?void 0:o.typewriter},`${String(null!=l?l:"list")}-${t}`)})})}let Lt=null,Et=null,Dt=!1;const $t=/* @__PURE__ */new Map,Pt=/* @__PURE__ */new Map;let At=5;const Rt=/* @__PURE__ */new Set;function Ht(){if($t.size<At&&Rt.size){const e=Array.from(Rt);Rt.clear();for(const n of e)try{n()}catch{}}}function Ft(e){Lt=e,Et=null,Lt.onmessage=e=>{const{id:n,html:t,error:r}=e.data,o=$t.get(n);if(o)if($t.delete(n),clearTimeout(o.timeoutId),Ht(),r)o.reject(new Error(r));else{const{content:n,displayMode:r}=e.data;if(n){const e=`${r?"d":"i"}:${n}`;if(Pt.set(e,t),Pt.size>200){const e=Pt.keys().next().value;Pt.delete(e)}}o.resolve(t)}},Lt.onerror=e=>{console.error("[katexWorkerClient] Worker error:",e);for(const[n,t]of $t.entries())clearTimeout(t.timeoutId),t.reject(new Error(`Worker error: ${e.message}`));$t.clear(),Ht()}}function Wt(){var e;Lt&&(null==(e=Lt.terminate)||e.call(Lt)),Lt=null,Et=null}function It(e){Dt=!!e,Lt&&Lt.postMessage({type:"init",debug:Dt})}const _t="WORKER_BUSY";async function Ot(e,n=!0,t=2e3,r){performance.now();const o=re(e);if(Et)return Promise.reject(Et);const i=`${n?"d":"i"}:${o}`,l=Pt.get(i);if(l)return Promise.resolve(l);const a=Lt||(Et=new Error("[katexWorkerClient] No worker instance set. Please inject a Worker via setKaTeXWorker()."),Et.name="WORKER_INIT_ERROR",Et.code="WORKER_INIT_ERROR",null);if(!a)return Promise.reject(Et);if($t.size>=At){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=_t,e.busy=!0,e.inFlight=$t.size,e.max=At,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(()=>{$t.delete(l);const e=new Error("Worker render timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT",i(e),Ht()},t),s=()=>{},d=()=>{$t.delete(l),clearTimeout(c),Rt.delete(s);const e=new Error("Aborted");e.name="AbortError",i(e),Ht()};r&&r.addEventListener("abort",d,{once:!0}),$t.set(l,{resolve:n=>{r&&r.removeEventListener("abort",d),e(n)},reject:e=>{r&&r.removeEventListener("abort",d),i(e)},timeoutId:c});try{a.postMessage({id:l,content:o,displayMode:n,debug:Dt})}catch(u){$t.delete(l),clearTimeout(c),r&&r.removeEventListener("abort",d),i(u),Ht()}})}function jt(e,n,t){const r=`${n?"d":"i"}:${re(e)}`;if(Pt.set(r,t),Pt.size>200){const e=Pt.keys().next().value;Pt.delete(e)}}function zt(){Pt.clear()}function Vt(e){At=Math.max(1,Math.floor(e)),Ht()}function Kt(e=1500,n){return $t.size<At?Promise.resolve():new Promise((t,r)=>{if(null==n?void 0:n.aborted){const e=new Error("Aborted");return e.name="AbortError",void r(e)}let o=null;function i(){Rt.delete(l),null!=o&&clearTimeout(o),n&&n.removeEventListener("abort",a)}function l(){i(),t()}function a(){i();const e=new Error("Aborted");e.name="AbortError",r(e)}o=e>0?setTimeout(()=>{i(),r(new Error("Timeout waiting for worker slot"))},e):null,n&&n.addEventListener("abort",a,{once:!0}),Rt.add(l)})}const Xt={timeout:2e3,waitTimeout:1500,backoffMs:30,maxRetries:1};function qt(e){null!=e.timeout&&(Xt.timeout=Math.max(0,Math.floor(e.timeout))),null!=e.waitTimeout&&(Xt.waitTimeout=Math.max(0,Math.floor(e.waitTimeout))),null!=e.backoffMs&&(Xt.backoffMs=Math.max(0,Math.floor(e.backoffMs))),null!=e.maxRetries&&(Xt.maxRetries=Math.max(0,Math.floor(e.maxRetries)))}function Ut(){return{...Xt}}async function Yt(e,n=!0,t={}){var r,o,i,l;const a=null!=(r=t.timeout)?r:Xt.timeout,c=null!=(o=t.waitTimeout)?o:Xt.waitTimeout,s=null!=(i=t.backoffMs)?i:Xt.backoffMs,d=null!=(l=t.maxRetries)?l:Xt.maxRetries,u=Number.isFinite(d)?Math.max(0,Math.min(Math.floor(d),8)):Xt.maxRetries,m=t.signal;let h=0;for(;;){if(null==m?void 0:m.aborted){const e=new Error("Aborted");throw e.name="AbortError",e}try{return await Ot(e,n,a,m)}catch(f){if((null==f?void 0:f.code)!==_t||h>=u)throw f;if(h++,await Kt(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 Zt=null,Gt=!1;async function Jt(){if(Zt)return Zt;if(Gt)return null;try{return Zt=await import("katex"),await import("katex/contrib/mhchem"),Zt}catch{return Gt=!0,null}}function Qt({node:e}){const t=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=t.current;if(!e)return;const n=l(e,{rootMargin:"400px"});return o.current=n,n.isVisible()&&m(!0),n.whenVisible.then(()=>m(!0)),()=>{n.destroy(),o.current=null}},[l]),s(()=>{var n;const t=re(null!=(n=e.content)?n:"");if(!t)return r.current&&(r.current.innerHTML=""),void d(!1);if(!u)return void d(!0);let o=!1;const i=new AbortController,l=++h.current;return Yt(t,!0,{timeout:3e3,waitTimeout:2e3,maxRetries:1,signal:i.signal}).then(e=>{o||l!==h.current||(r.current&&(r.current.innerHTML=e),d(!1))}).catch(async n=>{if(o||l!==h.current)return;if(!r.current)return;const i=(null==n?void 0:n.code)||(null==n?void 0:n.name);if("WORKER_INIT_ERROR"===i||(null==n?void 0:n.fallbackToRenderer)||i===_t||"WORKER_TIMEOUT"===i){const n=await Jt();if(n)try{const i=n.renderToString(t,{throwOnError:e.loading,displayMode:!0});return void(!o&&l===h.current&&r.current&&(r.current.innerHTML=i,d(!1),jt(t,!0,i)))}catch{}}e.loading||(r.current.textContent=e.raw,d(!1))}),()=>{o=!0,i.abort()}},[e.content,e.loading,e.raw,u]),/* @__PURE__ */n("div",{ref:t,className:"math-block text-center overflow-x-auto relative min-h-[40px]",children:/* @__PURE__ */n("div",{ref:r,className:a?"math-rendering":void 0})})}function er({node:t}){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 n=a(e,{rootMargin:"400px"});return l.current=n,n.isVisible()&&h(!0),n.whenVisible.then(()=>h(!0)),()=>{n.destroy(),l.current=null}},[a]),s(()=>{var e;const n=re(null!=(e=t.content)?e:"");if(!n)return o.current&&(o.current.innerHTML=""),void u(!1);if(!m)return void u(!0);let r=!1;const i=new AbortController,l=++f.current,a="$$"===t.markup;return Yt(n,a,{timeout:1500,waitTimeout:0,maxRetries:0,signal:i.signal}).then(e=>{r||l!==f.current||o.current&&(o.current.innerHTML=e,u(!1))}).catch(async e=>{if(r||l!==f.current)return;if(!o.current)return;const i=(null==e?void 0:e.code)||(null==e?void 0:e.name);if("WORKER_INIT_ERROR"===i||(null==e?void 0:e.fallbackToRenderer)||i===_t||"WORKER_TIMEOUT"===i){const e=await Jt();if(e)try{const i=e.renderToString(n,{throwOnError:t.loading,displayMode:a});return void(!r&&l===f.current&&o.current&&(o.current.innerHTML=i,u(!1),jt(n,a,i)))}catch{}}t.loading||(o.current.textContent=t.raw,u(!1))}),()=>{r=!0,i.abort()}},[t.content,t.loading,t.raw,t.markup,m]),/* @__PURE__ */e("span",{ref:r,className:"math-inline-wrapper",children:[
100
+ return n(s,{node:e,value:r.ordered?(null!=(a=r.start)?a:1)+t:void 0,ctx:o,renderNode:i,indexKey:`${String(null!=l?l:"list")}-${t}`,customId:null==o?void 0:o.customId,isDark:null==o?void 0:o.isDark,typewriter:null==o?void 0:o.typewriter},`${String(null!=l?l:"list")}-${t}`)})})}let $t=null,Dt=null,Pt=!1;const At=/* @__PURE__ */new Map,Rt=/* @__PURE__ */new Map;let Ht=5;const Wt=/* @__PURE__ */new Set;function Ft(){if(At.size<Ht&&Wt.size){const e=Array.from(Wt);Wt.clear();for(const n of e)try{n()}catch{}}}function It(e){$t=e,Dt=null,$t.onmessage=e=>{const{id:n,html:t,error:r}=e.data,o=At.get(n);if(o)if(At.delete(n),clearTimeout(o.timeoutId),Ft(),r)o.reject(new Error(r));else{const{content:n,displayMode:r}=e.data;if(n){const e=`${r?"d":"i"}:${n}`;if(Rt.set(e,t),Rt.size>200){const e=Rt.keys().next().value;Rt.delete(e)}}o.resolve(t)}},$t.onerror=e=>{console.error("[katexWorkerClient] Worker error:",e);for(const[n,t]of At.entries())clearTimeout(t.timeoutId),t.reject(new Error(`Worker error: ${e.message}`));At.clear(),Ft()}}function _t(){var e;$t&&(null==(e=$t.terminate)||e.call($t)),$t=null,Dt=null}function Ot(e){Pt=!!e,$t&&$t.postMessage({type:"init",debug:Pt})}const jt="WORKER_BUSY";async function zt(e,n=!0,t=2e3,r){performance.now();const o=re(e);if(Dt)return Promise.reject(Dt);const i=`${n?"d":"i"}:${o}`,l=Rt.get(i);if(l)return Promise.resolve(l);const a=$t||(Dt=new Error("[katexWorkerClient] No worker instance set. Please inject a Worker via setKaTeXWorker()."),Dt.name="WORKER_INIT_ERROR",Dt.code="WORKER_INIT_ERROR",null);if(!a)return Promise.reject(Dt);if(At.size>=Ht){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=jt,e.busy=!0,e.inFlight=At.size,e.max=Ht,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(()=>{At.delete(l);const e=new Error("Worker render timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT",i(e),Ft()},t),s=()=>{},d=()=>{At.delete(l),clearTimeout(c),Wt.delete(s);const e=new Error("Aborted");e.name="AbortError",i(e),Ft()};r&&r.addEventListener("abort",d,{once:!0}),At.set(l,{resolve:n=>{r&&r.removeEventListener("abort",d),e(n)},reject:e=>{r&&r.removeEventListener("abort",d),i(e)},timeoutId:c});try{a.postMessage({id:l,content:o,displayMode:n,debug:Pt})}catch(u){At.delete(l),clearTimeout(c),r&&r.removeEventListener("abort",d),i(u),Ft()}})}function Vt(e,n,t){const r=`${n?"d":"i"}:${re(e)}`;if(Rt.set(r,t),Rt.size>200){const e=Rt.keys().next().value;Rt.delete(e)}}function Kt(){Rt.clear()}function Xt(e){Ht=Math.max(1,Math.floor(e)),Ft()}function qt(e=1500,n){return At.size<Ht?Promise.resolve():new Promise((t,r)=>{if(null==n?void 0:n.aborted){const e=new Error("Aborted");return e.name="AbortError",void r(e)}let o=null;function i(){Wt.delete(l),null!=o&&clearTimeout(o),n&&n.removeEventListener("abort",a)}function l(){i(),t()}function a(){i();const e=new Error("Aborted");e.name="AbortError",r(e)}o=e>0?setTimeout(()=>{i(),r(new Error("Timeout waiting for worker slot"))},e):null,n&&n.addEventListener("abort",a,{once:!0}),Wt.add(l)})}const Ut={timeout:2e3,waitTimeout:1500,backoffMs:30,maxRetries:1};function Yt(e){null!=e.timeout&&(Ut.timeout=Math.max(0,Math.floor(e.timeout))),null!=e.waitTimeout&&(Ut.waitTimeout=Math.max(0,Math.floor(e.waitTimeout))),null!=e.backoffMs&&(Ut.backoffMs=Math.max(0,Math.floor(e.backoffMs))),null!=e.maxRetries&&(Ut.maxRetries=Math.max(0,Math.floor(e.maxRetries)))}function Zt(){return{...Ut}}async function Gt(e,n=!0,t={}){var r,o,i,l;const a=null!=(r=t.timeout)?r:Ut.timeout,c=null!=(o=t.waitTimeout)?o:Ut.waitTimeout,s=null!=(i=t.backoffMs)?i:Ut.backoffMs,d=null!=(l=t.maxRetries)?l:Ut.maxRetries,u=Number.isFinite(d)?Math.max(0,Math.min(Math.floor(d),8)):Ut.maxRetries,m=t.signal;let h=0;for(;;){if(null==m?void 0:m.aborted){const e=new Error("Aborted");throw e.name="AbortError",e}try{return await zt(e,n,a,m)}catch(f){if((null==f?void 0:f.code)!==jt||h>=u)throw f;if(h++,await qt(c,m).catch(()=>{}),null==m?void 0:m.aborted){const e=new Error("Aborted");throw e.name="AbortError",e}s>0&&await new Promise(e=>setTimeout(e,s*h))}}}let Jt=null,Qt=!1;async function er(){if(Jt)return Jt;if(Qt)return null;try{return Jt=await import("katex"),await import("katex/contrib/mhchem"),Jt}catch{return Qt=!0,null}}function nr({node:e}){const t=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=t.current;if(!e)return;const n=l(e,{rootMargin:"400px"});return o.current=n,n.isVisible()&&m(!0),n.whenVisible.then(()=>m(!0)),()=>{n.destroy(),o.current=null}},[l]),s(()=>{var n;const t=re(null!=(n=e.content)?n:"");if(!t)return r.current&&(r.current.innerHTML=""),void d(!1);if(!u)return void d(!0);let o=!1;const i=new AbortController,l=++h.current;return Gt(t,!0,{timeout:3e3,waitTimeout:2e3,maxRetries:1,signal:i.signal}).then(e=>{o||l!==h.current||(r.current&&(r.current.innerHTML=e),d(!1))}).catch(async n=>{if(o||l!==h.current)return;if(!r.current)return;const i=(null==n?void 0:n.code)||(null==n?void 0:n.name);if("WORKER_INIT_ERROR"===i||(null==n?void 0:n.fallbackToRenderer)||i===jt||"WORKER_TIMEOUT"===i){const n=await er();if(n)try{const i=n.renderToString(t,{throwOnError:e.loading,displayMode:!0});return void(!o&&l===h.current&&r.current&&(r.current.innerHTML=i,d(!1),Vt(t,!0,i)))}catch{}}e.loading||(r.current.textContent=e.raw,d(!1))}),()=>{o=!0,i.abort()}},[e.content,e.loading,e.raw,u]),/* @__PURE__ */n("div",{ref:t,className:"math-block text-center overflow-x-auto relative min-h-[40px]",children:/* @__PURE__ */n("div",{ref:r,className:a?"math-rendering":void 0})})}function tr({node:t}){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 n=a(e,{rootMargin:"400px"});return l.current=n,n.isVisible()&&h(!0),n.whenVisible.then(()=>h(!0)),()=>{n.destroy(),l.current=null}},[a]),s(()=>{var e;const n=re(null!=(e=t.content)?e:"");if(!n)return o.current&&(o.current.innerHTML=""),void u(!1);if(!m)return void u(!0);let r=!1;const i=new AbortController,l=++f.current,a="$$"===t.markup;return Gt(n,a,{timeout:1500,waitTimeout:0,maxRetries:0,signal:i.signal}).then(e=>{r||l!==f.current||o.current&&(o.current.innerHTML=e,u(!1))}).catch(async e=>{if(r||l!==f.current)return;if(!o.current)return;const i=(null==e?void 0:e.code)||(null==e?void 0:e.name);if("WORKER_INIT_ERROR"===i||(null==e?void 0:e.fallbackToRenderer)||i===jt||"WORKER_TIMEOUT"===i){const e=await er();if(e)try{const i=e.renderToString(n,{throwOnError:t.loading,displayMode:a});return void(!r&&l===f.current&&o.current&&(o.current.innerHTML=i,u(!1),Vt(n,a,i)))}catch{}}t.loading||(o.current.textContent=t.raw,u(!1))}),()=>{r=!0,i.abort()}},[t.content,t.loading,t.raw,t.markup,m]),/* @__PURE__ */e("span",{ref:r,className:"math-inline-wrapper",children:[
101
101
  /* @__PURE__ */n("span",{ref:o,className:"math-inline"+(d?" math-inline--hidden":"")}),d&&/* @__PURE__ */e("span",{className:"math-inline__loading",role:"status","aria-live":"polite",children:[
102
102
  /* @__PURE__ */n("span",{className:"math-inline__spinner","aria-hidden":"true"}),
103
- /* @__PURE__ */n("span",{className:"sr-only",children:"Loading"})]})]})}function nr(e){try{if("undefined"!=typeof globalThis&&"function"==typeof globalThis.requestAnimationFrame)return globalThis.requestAnimationFrame(e)}catch{}return globalThis.setTimeout(e,0)}let tr=null,rr=null;const or=/* @__PURE__ */new Map;let ir=5,lr=!1;function ar(e){lr=!!e}function cr(e){Number.isFinite(e)&&e>0&&(ir=Math.floor(e))}function sr(){return{inFlight:or.size,max:ir}}const dr="WORKER_BUSY";function ur(e){tr=e,rr=null;const n=e;tr.onmessage=e=>{if(tr!==n)return;const{id:t,ok:r,result:o,error:i}=e.data,l=or.get(t);l&&(!1===r||i?l.reject(new Error(i||"Unknown error")):l.resolve(o))},tr.onerror=e=>{var t,r;if(tr===n)if(0!==or.size){try{lr?console.error("[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e)}catch{}for(const[n,t]of or.entries())t.reject(new Error(`Worker error: ${e.message}`));or.clear()}else null==(t=console.debug)||t.call(console,"[mermaidWorkerClient] Worker error (no pending):",(null==e?void 0:e.message)||e)},tr.onmessageerror=e=>{var t,r;if(tr===n)if(0!==or.size){try{lr?console.error("[mermaidWorkerClient] Worker messageerror:",e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker messageerror:",e)}catch{}for(const[e,n]of or.entries())n.reject(new Error("Worker messageerror"));or.clear()}else null==(t=console.debug)||t.call(console,"[mermaidWorkerClient] Worker messageerror (no pending):",e)}}function mr(){var e;if(tr)try{for(const[e,n]of or.entries())n.reject(new Error("Worker cleared"));or.clear(),null==(e=tr.terminate)||e.call(tr)}catch{}tr=null,rr=null}function hr(e,n,t=1400){if(rr)return Promise.reject(rr);const r=tr||(rr=new Error("[mermaidWorkerClient] No worker instance set. Please inject a Worker via setMermaidWorker()."),rr.name="WORKER_INIT_ERROR",rr.code="WORKER_INIT_ERROR",null);if(!r)return Promise.reject(rr);if(or.size>=ir){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=dr,e.inFlight=or.size,e.max=ir,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),or.delete(l))},d={resolve:e=>{s(),o(e)},reject:e=>{s(),i(e)}};or.set(l,d);try{r.postMessage({id:l,action:e,payload:n})}catch(u){return or.delete(l),void i(u)}c=setTimeout(()=>{const e=new Error("Worker call timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT";const n=or.get(l);null==n||n.reject(e)},t)})}async function fr(e,n,t=1400){return hr("canParse",{code:e,theme:n},t)}async function pr(e,n,t=2400){return hr("findPrefix",{code:e,theme:n},t)}function gr(){var e;null==(e=null==tr?void 0:tr.terminate)||e.call(tr),tr=null,rr=null,or.clear()}let vr=null,wr=!1,yr=null,xr=null;function kr(e,n){var t;if(!e||!n)return;const r=function(e){var n,t;return`${String(null!=(n=null==e?void 0:e.securityLevel)?n:"strict")}|htmlLabels:${!1===(null==(t=null==e?void 0:e.flowchart)?void 0:t.htmlLabels)?"0":"1"}`}(n);if(yr!==r)try{"function"==typeof e.initialize?e.initialize(n):(null==(t=e.mermaidAPI)?void 0:t.initialize)&&e.mermaidAPI.initialize(n),yr=r}catch{}}const br="undefined"!=typeof window?m:s,Cr={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0};function Mr(e){if(e)try{e.replaceChildren()}catch{e.innerHTML=""}}function Nr(e,n,t={}){if(!e)return"";const r=function(e,n){if(!e)return"";const t=N(n);return t?(Mr(e),e.appendChild(t),e.innerHTML):""}(e,n);return r||t.keepPreviousOnFailure||Mr(e),r}function Br(e,n,t){if(t&&(null==e?void 0:e.querySelector("svg")))try{null==n||n(e)}catch{}}const Sr={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 Tr(r){var l,a,u,h,f,p,g,v,w,y;const x={...Sr,...r},{t:k}=Ie(),b=o(()=>I("mermaid"),[]),C=null!=(a=null==(l=x.node)?void 0:l.code)?a:"",M=o(()=>C.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"),[C]),N=null!=(u=x.workerTimeoutMs)?u:Sr.workerTimeoutMs,B=null!=(h=x.parseTimeoutMs)?h:Sr.parseTimeoutMs,S=null!=(f=x.renderTimeoutMs)?f:Sr.renderTimeoutMs,T=null!=(p=x.fullRenderTimeoutMs)?p:Sr.fullRenderTimeoutMs,L=Math.max(0,null!=(g=x.renderDebounceMs)?g:Sr.renderDebounceMs),E=o(()=>x.maxHeight&&"none"!==x.maxHeight?oe(x.maxHeight):null,[x.maxHeight]),D=o(()=>{var e;return ie(null!=(e=oe(x.estimatedPreviewHeightPx))?e:le(M),void 0,E)},[M,E,x.estimatedPreviewHeightPx]),[$,P]=i(!1),[A,R]=i(!1),[H,F]=i(!1),[W,_]=i(!1),[O,j]=i(1),[z,V]=i({x:0,y:0}),[K,X]=i(!1),[q,U]=i(!1),[Y,Z]=i(!1),[G,J]=i(null),[Q,ee]=i(!1),[ne,te]=i(`${D}px`),[re,ae]=i("undefined"==typeof window),ce=c(null),se=c(null),de=c(null),ue=c(null),me=c(null),he=c(null),fe=c(null),pe=c({x:0,y:0}),ge=c(0),ve=c({}),we=c(null),xe=c(""),ke=c(!1),be=c(null),Ce=c(!1),Me=c({zoom:1,translateX:0,translateY:0,containerHeight:ne||"360px"}),Ne=Ae(),Be=Boolean(null!=(w=null==(v=x.node)?void 0:v.loading)?w:x.loading),Se=x.isDark?"dark":"light",Te=Boolean(x.isStrict),Le=!0===x.enableMermaidInteractions,Ee=o(()=>Te?{startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,dompurifyConfig:Cr,flowchart:{htmlLabels:!1}}:{startOnLoad:!1,securityLevel:"loose",suppressErrorRendering:!0},[Te]);s(()=>{Ce.current=Y},[Y]),s(()=>{A||H||te(e=>{const n=oe(e);return null!=n&&n>=D?e:`${D}px`})},[D,H,A]),s(()=>{ve.current={}},[Se,M,Te]),s(()=>{let e=!1;return(async()=>{const n=await async function(e){if(vr)return kr(vr,e),vr;if(xr){const n=await xr;return n&&kr(n,e),n}if(wr)return null;try{wr=!0,xr=(async()=>{try{const n=await import("mermaid"),t=(null==n?void 0:n.default)||n;if(vr=(null==t?void 0:t.default)?t.default:(null==t?void 0:t.mermaidAPI)?t:(null==t?void 0:t.mermaid)?t.mermaid:t,!vr)throw new Error("Mermaid module did not export expected API");return kr(vr,null!=e?e:{startOnLoad:!1,securityLevel:"strict",flowchart:{htmlLabels:!1}}),vr}catch(n){return console.warn("[markstream-react] Failed to load mermaid:",n),null}finally{xr=null}})();const n=await xr;return n&&kr(n,e),n}catch{return null}}(Ee);e||(ce.current=n,P(Boolean(n)),ke.current||R(!n))})(),()=>{e=!0}},[Ee]),s(()=>{const e=se.current;if(!e)return;const n=Ne(e,{rootMargin:"400px"});return be.current=n,n.isVisible()&&ae(!0),n.whenVisible.then(()=>ae(!0)),()=>{n.destroy(),be.current=null}},[Ne]),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 De=d(()=>E,[E]),$e=d(e=>{const n=se.current,t=ue.current;if(!n||!t)return;const r=t.querySelector("svg");if(!r)return;let o=0,i=0;const l=r.getAttribute("viewBox");if(l){const e=l.split(" ");4===e.length&&(o=Number.parseFloat(e[2]),i=Number.parseFloat(e[3]))}if(o&&i||!r.hasAttribute("width")||!r.hasAttribute("height")||(o=Number.parseFloat(r.getAttribute("width")||"0"),i=Number.parseFloat(r.getAttribute("height")||"0")),!o||!i||Number.isNaN(o)||Number.isNaN(i))try{const e=r.getBBox();o=e.width,i=e.height}catch{return}if(!(o>0&&i>0))return;const a=(null!=e?e:n.clientWidth)*(i/o),c=Number.isFinite(a)&&a>0?a:i,s=De(),d=null==s?c:Math.min(c,s);te(`${"none"===x.maxHeight?d:Math.max(d,D)}px`)},[D,x.maxHeight,De]);s(()=>{if(!se.current||"undefined"==typeof ResizeObserver)return;if(A||H)return;const e=new ResizeObserver(e=>{if(!e.length)return;const n=e[0].contentRect.width;nr(()=>$e(n))});return e.observe(se.current),()=>e.disconnect()},[H,A,$e]),s(()=>{A||H||$e()},[H,x.maxHeight,A,$e]),s(()=>()=>{gr()},[]),m(()=>{var e;const n=ve.current[Se];!A&&ue.current&&(null==n?void 0:n.svg)&&(Nr(ue.current,n.svg)&&(we.current=null!=(e=n.bindFunctions)?e:null,Br(ue.current,n.bindFunctions,Le)),nr(()=>$e()))},[Le,A,Se,$e]);const Pe=d(async(e,n,t)=>{var r;if(!ce.current||!ue.current)return!1;U(!0);try{const o=`mermaid-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=Dr(e,n),l=await Rr(()=>ce.current.render(o,i),{timeoutMs:T,signal:t});if(!(null==l?void 0:l.svg))return!1;const a=Nr(ue.current,l.svg);return!!a&&(we.current=null!=(r=l.bindFunctions)?r:null,Br(ue.current,l.bindFunctions,Le),$e(),ve.current[n]={svg:a,bindFunctions:l.bindFunctions},Z(!0),J(null),!0)}catch(o){if(!Be){if("function"==typeof x.onRenderError&&ue.current&&!0===x.onRenderError(o,M,ue.current))return!1;J(o instanceof Error?o.message:String(o))}return!1}finally{U(!1)}},[Le,T,Be,$e]),Re=d(async(e,n,t)=>{var r;if(ce.current&&ue.current){U(!0);try{const o=`mermaid-preview-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=Dr(Ar(e)||e,n),l=await Rr(()=>ce.current.render(o,i),{timeoutMs:S,signal:t});if(null==l?void 0:l.svg){const e=Nr(ue.current,l.svg,{keepPreviousOnFailure:!0});e&&(we.current=null!=(r=l.bindFunctions)?r:null,Br(ue.current,l.bindFunctions,Le)),e&&$e()}}catch{}finally{U(!1)}}},[Le,S,Be,$e]),He=d(async(e,n)=>{if(!e.trim())return Mr(ue.current),Z(!1),void(xe.current="");const t=e.replace(/\s+/g,"");if(t===xe.current&&Ce.current)return;const r=++ge.current;if("gantt"===$r(e)){const i=Ar(e);if(!i.trim())return;try{if(await Er(i,Se,{workerTimeout:N,parseTimeout:B,mermaid:ce.current,signal:n}),(null==n?void 0:n.aborted)||ge.current!==r)return;i===e?await Pe(e,Se,n)&&(xe.current=t):await Re(i,Se,n)}catch(o){if("AbortError"===(null==o?void 0:o.name))return}return}try{if(await Er(e,Se,{workerTimeout:N,parseTimeout:B,mermaid:ce.current,signal:n}),(null==n?void 0:n.aborted)||ge.current!==r)return;return void(await Pe(e,Se,n)&&(xe.current=t))}catch(o){if("AbortError"===(null==o?void 0:o.name))return}try{const t=await async function(e,n,t){try{const r=await pr(e,n,t.workerTimeout);if(r)return r}catch(o){if("AbortError"===(null==o?void 0:o.name))throw o}return Ar(e)}(e,Se,{workerTimeout:N,signal:n});if(!t||(null==n?void 0:n.aborted)||ge.current!==r)return;await Re(t,Se,n)}catch{}},[B,Pe,Re,Se,N]),Fe=d(()=>re&&!A&&!H,[H,A,re]);s(()=>{if(!Fe())return;if(!ce.current)return;const e=new AbortController,n=window.setTimeout(()=>{!e.signal.aborted&&Fe()&&He(M,e.signal)},L);return()=>{e.abort(),window.clearTimeout(n)}},[M,Fe,$,He,L]);const We=d((e,n)=>{e.clientX,e.clientY,Ue(e.currentTarget,n,"top",!1,0,x.isDark)},[x.isDark]),_e=d(async()=>{var e,n;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(M)),_(!0),null==(n=x.onCopy)||n.call(x,M),setTimeout(()=>_(!1),1e3)}catch{}},[M,x]),Oe=d(()=>{var e,n,t;const r=null!=(n=null==(e=ue.current)?void 0:e.querySelector("svg"))?n:null;if(!r)return;const o=Hr(r),i={payload:{type:"export"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(t=x.onExport)||t.call(x,i),i.defaultPrevented||function(e,n){const t=null!=n?n:Hr(e),r=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=`mermaid-${Date.now()}.svg`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}(r,o)},[x]),je=d(()=>{fe.current=null,Mr(he.current)},[]),ze=d(()=>{ee(!1),je()},[je]),Ve=d(()=>{var e,n,t;const r=null!=(n=null==(e=ue.current)?void 0:e.querySelector("svg"))?n:null,o=r?Hr(r):null,i={payload:{type:"open-modal"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(t=x.onOpenModal)||t.call(x,i),i.defaultPrevented||ee(!0)},[x]);s(()=>{if(!Q)return;if("undefined"==typeof window)return;const e=e=>{"Escape"===e.key&&ze()};try{window.addEventListener("keydown",e)}catch{}return()=>{try{window.removeEventListener("keydown",e)}catch{}}},[ze,Q]),br(()=>{var e,n;if(!Q)return;const t=he.current,r=se.current;if(!t||!r)return;const o=`translate(${z.x}px, ${z.y}px) scale(${O})`,i=r.cloneNode(!0);i.classList.add("fullscreen"),i.style.height="100%",i.style.maxHeight="100%";const l=i.querySelector("[data-mermaid-wrapper]");l&&(fe.current=l,l.style.transform=o),Mr(t),t.appendChild(i),Br(t,null!=(n=we.current)?n:null==(e=ve.current[Se])?void 0:e.bindFunctions,Le)},[Le,Q,Se]),s(()=>{Q&&fe.current&&(fe.current.style.transform=`translate(${z.x}px, ${z.y}px) scale(${O})`)},[Q,z.x,z.y,O]);const Ke=A||q||H,Xe=o(()=>x.isDark?"mermaid-action-btn p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200":"mermaid-action-btn p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700",[x.isDark]),qe=d(e=>{var n;const t={payload:{type:"toggle-mode",target:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};if(null==(n=x.onToggleMode)||n.call(x,e,t),!t.defaultPrevented)if(ke.current=!0,"preview"===e){R(!1);const e=Me.current;j(e.zoom),V({x:e.translateX,y:e.translateY}),te(e.containerHeight)}else Me.current={zoom:O,translateX:z.x,translateY:z.y,containerHeight:ne},R(!0)},[M,ne,He,x,Se,z.x,z.y,$e,O]),Ze=d(e=>{if(!1===x.enableWheelZoom)return;if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const n=se.current;if(!n)return;const t=n.getBoundingClientRect(),r=e.clientX-t.left-z.x,o=e.clientY-t.top-z.y,i=.01*-e.deltaY,l=Lr(O+i,.5,3);if(l===O)return;const a=l/O;V({x:z.x-r*(a-1),y:z.y-o*(a-1)}),j(l)},[z,O]),Ge=d((e,n)=>{X(!0),pe.current={x:e-z.x,y:n-z.y}},[z.x,z.y]),Je=d((e,n)=>{K&&V({x:e-pe.current.x,y:n-pe.current.y})},[K]),Qe=d(()=>{X(!1)},[]),en=/* @__PURE__ */e("div",{className:"relative",children:[x.showZoomControls&&/* @__PURE__ */n("div",{className:"absolute top-2 right-2 z-10 rounded-lg",children:/* @__PURE__ */e("div",{className:"flex items-center gap-2 backdrop-blur rounded-lg",children:[
104
- /* @__PURE__ */n("button",{type:"button",className:Dn("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=>We(e,k("common.zoomIn")),onMouseLeave:()=>Ye(),onClick:()=>j(Lr(O+.1,.5,3)),children:"+"}),
105
- /* @__PURE__ */n("button",{type:"button",className:Dn("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=>We(e,k("common.zoomOut")),onMouseLeave:()=>Ye(),onClick:()=>j(Lr(O-.1,.5,3)),children:"−"}),
106
- /* @__PURE__ */e("button",{type:"button",className:Dn("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=>We(e,k("common.resetZoom")),onMouseLeave:()=>Ye(),onClick:()=>{j(1),V({x:0,y:0})},children:[Math.round(100*O),"%"]})]})}),
103
+ /* @__PURE__ */n("span",{className:"sr-only",children:"Loading"})]})]})}function rr(e){try{if("undefined"!=typeof globalThis&&"function"==typeof globalThis.requestAnimationFrame)return globalThis.requestAnimationFrame(e)}catch{}return globalThis.setTimeout(e,0)}let or=null,ir=null;const lr=/* @__PURE__ */new Map;let ar=5,cr=!1;function sr(e){cr=!!e}function dr(e){Number.isFinite(e)&&e>0&&(ar=Math.floor(e))}function ur(){return{inFlight:lr.size,max:ar}}const mr="WORKER_BUSY";function hr(e){or=e,ir=null;const n=e;or.onmessage=e=>{if(or!==n)return;const{id:t,ok:r,result:o,error:i}=e.data,l=lr.get(t);l&&(!1===r||i?l.reject(new Error(i||"Unknown error")):l.resolve(o))},or.onerror=e=>{var t,r;if(or===n)if(0!==lr.size){try{cr?console.error("[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker error:",(null==e?void 0:e.message)||e)}catch{}for(const[n,t]of lr.entries())t.reject(new Error(`Worker error: ${e.message}`));lr.clear()}else null==(t=console.debug)||t.call(console,"[mermaidWorkerClient] Worker error (no pending):",(null==e?void 0:e.message)||e)},or.onmessageerror=e=>{var t,r;if(or===n)if(0!==lr.size){try{cr?console.error("[mermaidWorkerClient] Worker messageerror:",e):null==(r=console.debug)||r.call(console,"[mermaidWorkerClient] Worker messageerror:",e)}catch{}for(const[e,n]of lr.entries())n.reject(new Error("Worker messageerror"));lr.clear()}else null==(t=console.debug)||t.call(console,"[mermaidWorkerClient] Worker messageerror (no pending):",e)}}function fr(){var e;if(or)try{for(const[e,n]of lr.entries())n.reject(new Error("Worker cleared"));lr.clear(),null==(e=or.terminate)||e.call(or)}catch{}or=null,ir=null}function pr(e,n,t=1400){if(ir)return Promise.reject(ir);const r=or||(ir=new Error("[mermaidWorkerClient] No worker instance set. Please inject a Worker via setMermaidWorker()."),ir.name="WORKER_INIT_ERROR",ir.code="WORKER_INIT_ERROR",null);if(!r)return Promise.reject(ir);if(lr.size>=ar){const e=new Error("Worker busy");return e.name="WorkerBusy",e.code=mr,e.inFlight=lr.size,e.max=ar,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),lr.delete(l))},d={resolve:e=>{s(),o(e)},reject:e=>{s(),i(e)}};lr.set(l,d);try{r.postMessage({id:l,action:e,payload:n})}catch(u){return lr.delete(l),void i(u)}c=setTimeout(()=>{const e=new Error("Worker call timed out");e.name="WorkerTimeout",e.code="WORKER_TIMEOUT";const n=lr.get(l);null==n||n.reject(e)},t)})}async function gr(e,n,t=1400){return pr("canParse",{code:e,theme:n},t)}async function vr(e,n,t=2400){return pr("findPrefix",{code:e,theme:n},t)}function wr(){var e;null==(e=null==or?void 0:or.terminate)||e.call(or),or=null,ir=null,lr.clear()}let yr=null,xr=!1,kr=null,br=null;function Cr(e,n){var t;if(!e||!n)return;const r=function(e){var n,t;return`${String(null!=(n=null==e?void 0:e.securityLevel)?n:"strict")}|htmlLabels:${!1===(null==(t=null==e?void 0:e.flowchart)?void 0:t.htmlLabels)?"0":"1"}`}(n);if(kr!==r)try{"function"==typeof e.initialize?e.initialize(n):(null==(t=e.mermaidAPI)?void 0:t.initialize)&&e.mermaidAPI.initialize(n),kr=r}catch{}}const Mr="undefined"!=typeof window?m:s,Nr={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0};function Br(e){if(e)try{e.replaceChildren()}catch{e.innerHTML=""}}function Sr(e,n,t={}){if(!e)return"";const r=function(e,n){if(!e)return"";const t=N(n);return t?(Br(e),e.appendChild(t),e.innerHTML):""}(e,n);return r||t.keepPreviousOnFailure||Br(e),r}function Tr(e,n,t){if(t&&(null==e?void 0:e.querySelector("svg")))try{null==n||n(e)}catch{}}const Lr={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 Er(r){var l,a,u,h,f,p,g,v,w,y;const x={...Lr,...r},{t:k}=Ie(),b=o(()=>I("mermaid"),[]),C=null!=(a=null==(l=x.node)?void 0:l.code)?a:"",M=o(()=>C.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode"),[C]),N=null!=(u=x.workerTimeoutMs)?u:Lr.workerTimeoutMs,B=null!=(h=x.parseTimeoutMs)?h:Lr.parseTimeoutMs,S=null!=(f=x.renderTimeoutMs)?f:Lr.renderTimeoutMs,T=null!=(p=x.fullRenderTimeoutMs)?p:Lr.fullRenderTimeoutMs,L=Math.max(0,null!=(g=x.renderDebounceMs)?g:Lr.renderDebounceMs),E=o(()=>x.maxHeight&&"none"!==x.maxHeight?oe(x.maxHeight):null,[x.maxHeight]),$=o(()=>{var e;return ie(null!=(e=oe(x.estimatedPreviewHeightPx))?e:le(M),void 0,E)},[M,E,x.estimatedPreviewHeightPx]),[D,P]=i(!1),[A,R]=i(!1),[H,W]=i(!1),[F,_]=i(!1),[O,j]=i(1),[z,V]=i({x:0,y:0}),[K,X]=i(!1),[q,U]=i(!1),[Y,Z]=i(!1),[G,J]=i(null),[Q,ee]=i(!1),[ne,te]=i(`${$}px`),[re,ae]=i("undefined"==typeof window),ce=c(null),se=c(null),de=c(null),ue=c(null),me=c(null),he=c(null),fe=c(null),pe=c({x:0,y:0}),ge=c(0),ve=c({}),we=c(null),xe=c(""),ke=c(!1),be=c(null),Ce=c(!1),Me=c({zoom:1,translateX:0,translateY:0,containerHeight:ne||"360px"}),Ne=Ae(),Be=Boolean(null!=(w=null==(v=x.node)?void 0:v.loading)?w:x.loading),Se=x.isDark?"dark":"light",Te=Boolean(x.isStrict),Le=!0===x.enableMermaidInteractions,Ee=o(()=>Te?{startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,dompurifyConfig:Nr,flowchart:{htmlLabels:!1}}:{startOnLoad:!1,securityLevel:"loose",suppressErrorRendering:!0},[Te]);s(()=>{Ce.current=Y},[Y]),s(()=>{A||H||te(e=>{const n=oe(e);return null!=n&&n>=$?e:`${$}px`})},[$,H,A]),s(()=>{ve.current={}},[Se,M,Te]),s(()=>{let e=!1;return(async()=>{const n=await async function(e){if(yr)return Cr(yr,e),yr;if(br){const n=await br;return n&&Cr(n,e),n}if(xr)return null;try{xr=!0,br=(async()=>{try{const n=await import("mermaid"),t=(null==n?void 0:n.default)||n;if(yr=(null==t?void 0:t.default)?t.default:(null==t?void 0:t.mermaidAPI)?t:(null==t?void 0:t.mermaid)?t.mermaid:t,!yr)throw new Error("Mermaid module did not export expected API");return Cr(yr,null!=e?e:{startOnLoad:!1,securityLevel:"strict",flowchart:{htmlLabels:!1}}),yr}catch(n){return console.warn("[markstream-react] Failed to load mermaid:",n),null}finally{br=null}})();const n=await br;return n&&Cr(n,e),n}catch{return null}}(Ee);e||(ce.current=n,P(Boolean(n)),ke.current||R(!n))})(),()=>{e=!0}},[Ee]),s(()=>{const e=se.current;if(!e)return;const n=Ne(e,{rootMargin:"400px"});return be.current=n,n.isVisible()&&ae(!0),n.whenVisible.then(()=>ae(!0)),()=>{n.destroy(),be.current=null}},[Ne]),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 $e=d(()=>E,[E]),De=d(e=>{const n=se.current,t=ue.current;if(!n||!t)return;const r=t.querySelector("svg");if(!r)return;let o=0,i=0;const l=r.getAttribute("viewBox");if(l){const e=l.split(" ");4===e.length&&(o=Number.parseFloat(e[2]),i=Number.parseFloat(e[3]))}if(o&&i||!r.hasAttribute("width")||!r.hasAttribute("height")||(o=Number.parseFloat(r.getAttribute("width")||"0"),i=Number.parseFloat(r.getAttribute("height")||"0")),!o||!i||Number.isNaN(o)||Number.isNaN(i))try{const e=r.getBBox();o=e.width,i=e.height}catch{return}if(!(o>0&&i>0))return;const a=(null!=e?e:n.clientWidth)*(i/o),c=Number.isFinite(a)&&a>0?a:i,s=$e(),d=null==s?c:Math.min(c,s);te(`${"none"===x.maxHeight?d:Math.max(d,$)}px`)},[$,x.maxHeight,$e]);s(()=>{if(!se.current||"undefined"==typeof ResizeObserver)return;if(A||H)return;const e=new ResizeObserver(e=>{if(!e.length)return;const n=e[0].contentRect.width;rr(()=>De(n))});return e.observe(se.current),()=>e.disconnect()},[H,A,De]),s(()=>{A||H||De()},[H,x.maxHeight,A,De]),s(()=>()=>{wr()},[]),m(()=>{var e;const n=ve.current[Se];!A&&ue.current&&(null==n?void 0:n.svg)&&(Sr(ue.current,n.svg)&&(we.current=null!=(e=n.bindFunctions)?e:null,Tr(ue.current,n.bindFunctions,Le)),rr(()=>De()))},[Le,A,Se,De]);const Pe=d(async(e,n,t)=>{var r;if(!ce.current||!ue.current)return!1;U(!0);try{const o=`mermaid-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=Pr(e,n),l=await Wr(()=>ce.current.render(o,i),{timeoutMs:T,signal:t});if(!(null==l?void 0:l.svg))return!1;const a=Sr(ue.current,l.svg);return!!a&&(we.current=null!=(r=l.bindFunctions)?r:null,Tr(ue.current,l.bindFunctions,Le),De(),ve.current[n]={svg:a,bindFunctions:l.bindFunctions},Z(!0),J(null),!0)}catch(o){if(!Be){if("function"==typeof x.onRenderError&&ue.current&&!0===x.onRenderError(o,M,ue.current))return!1;J(o instanceof Error?o.message:String(o))}return!1}finally{U(!1)}},[Le,T,Be,De]),Re=d(async(e,n,t)=>{var r;if(ce.current&&ue.current){U(!0);try{const o=`mermaid-preview-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=Pr(Hr(e)||e,n),l=await Wr(()=>ce.current.render(o,i),{timeoutMs:S,signal:t});if(null==l?void 0:l.svg){const e=Sr(ue.current,l.svg,{keepPreviousOnFailure:!0});e&&(we.current=null!=(r=l.bindFunctions)?r:null,Tr(ue.current,l.bindFunctions,Le)),e&&De()}}catch{}finally{U(!1)}}},[Le,S,Be,De]),He=d(async(e,n)=>{if(!e.trim())return Br(ue.current),Z(!1),void(xe.current="");const t=e.replace(/\s+/g,"");if(t===xe.current&&Ce.current)return;const r=++ge.current;if("gantt"===Ar(e)){const i=Hr(e);if(!i.trim())return;try{if(await Dr(i,Se,{workerTimeout:N,parseTimeout:B,mermaid:ce.current,signal:n}),(null==n?void 0:n.aborted)||ge.current!==r)return;i===e?await Pe(e,Se,n)&&(xe.current=t):await Re(i,Se,n)}catch(o){if("AbortError"===(null==o?void 0:o.name))return}return}try{if(await Dr(e,Se,{workerTimeout:N,parseTimeout:B,mermaid:ce.current,signal:n}),(null==n?void 0:n.aborted)||ge.current!==r)return;return void(await Pe(e,Se,n)&&(xe.current=t))}catch(o){if("AbortError"===(null==o?void 0:o.name))return}try{const t=await async function(e,n,t){try{const r=await vr(e,n,t.workerTimeout);if(r)return r}catch(o){if("AbortError"===(null==o?void 0:o.name))throw o}return Hr(e)}(e,Se,{workerTimeout:N,signal:n});if(!t||(null==n?void 0:n.aborted)||ge.current!==r)return;await Re(t,Se,n)}catch{}},[B,Pe,Re,Se,N]),We=d(()=>re&&!A&&!H,[H,A,re]);s(()=>{if(!We())return;if(!ce.current)return;const e=new AbortController,n=window.setTimeout(()=>{!e.signal.aborted&&We()&&He(M,e.signal)},L);return()=>{e.abort(),window.clearTimeout(n)}},[M,We,D,He,L]);const Fe=d((e,n)=>{e.clientX,e.clientY,Ue(e.currentTarget,n,"top",!1,0,x.isDark)},[x.isDark]),_e=d(async()=>{var e,n;try{await(null==(e=navigator.clipboard)?void 0:e.writeText(M)),_(!0),null==(n=x.onCopy)||n.call(x,M),setTimeout(()=>_(!1),1e3)}catch{}},[M,x]),Oe=d(()=>{var e,n,t;const r=null!=(n=null==(e=ue.current)?void 0:e.querySelector("svg"))?n:null;if(!r)return;const o=Fr(r),i={payload:{type:"export"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(t=x.onExport)||t.call(x,i),i.defaultPrevented||function(e,n){const t=null!=n?n:Fr(e),r=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=`mermaid-${Date.now()}.svg`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}(r,o)},[x]),je=d(()=>{fe.current=null,Br(he.current)},[]),ze=d(()=>{ee(!1),je()},[je]),Ve=d(()=>{var e,n,t;const r=null!=(n=null==(e=ue.current)?void 0:e.querySelector("svg"))?n:null,o=r?Fr(r):null,i={payload:{type:"open-modal"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:r,svgString:o};null==(t=x.onOpenModal)||t.call(x,i),i.defaultPrevented||ee(!0)},[x]);s(()=>{if(!Q)return;if("undefined"==typeof window)return;const e=e=>{"Escape"===e.key&&ze()};try{window.addEventListener("keydown",e)}catch{}return()=>{try{window.removeEventListener("keydown",e)}catch{}}},[ze,Q]),Mr(()=>{var e,n;if(!Q)return;const t=he.current,r=se.current;if(!t||!r)return;const o=`translate(${z.x}px, ${z.y}px) scale(${O})`,i=r.cloneNode(!0);i.classList.add("fullscreen"),i.style.height="100%",i.style.maxHeight="100%";const l=i.querySelector("[data-mermaid-wrapper]");l&&(fe.current=l,l.style.transform=o),Br(t),t.appendChild(i),Tr(t,null!=(n=we.current)?n:null==(e=ve.current[Se])?void 0:e.bindFunctions,Le)},[Le,Q,Se]),s(()=>{Q&&fe.current&&(fe.current.style.transform=`translate(${z.x}px, ${z.y}px) scale(${O})`)},[Q,z.x,z.y,O]);const Ke=A||q||H,Xe=o(()=>x.isDark?"mermaid-action-btn p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200":"mermaid-action-btn p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700",[x.isDark]),qe=d(e=>{var n;const t={payload:{type:"toggle-mode",target:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};if(null==(n=x.onToggleMode)||n.call(x,e,t),!t.defaultPrevented)if(ke.current=!0,"preview"===e){R(!1);const e=Me.current;j(e.zoom),V({x:e.translateX,y:e.translateY}),te(e.containerHeight)}else Me.current={zoom:O,translateX:z.x,translateY:z.y,containerHeight:ne},R(!0)},[M,ne,He,x,Se,z.x,z.y,De,O]),Ze=d(e=>{if(!1===x.enableWheelZoom)return;if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const n=se.current;if(!n)return;const t=n.getBoundingClientRect(),r=e.clientX-t.left-z.x,o=e.clientY-t.top-z.y,i=.01*-e.deltaY,l=$r(O+i,.5,3);if(l===O)return;const a=l/O;V({x:z.x-r*(a-1),y:z.y-o*(a-1)}),j(l)},[z,O]),Ge=d((e,n)=>{X(!0),pe.current={x:e-z.x,y:n-z.y}},[z.x,z.y]),Je=d((e,n)=>{K&&V({x:e-pe.current.x,y:n-pe.current.y})},[K]),Qe=d(()=>{X(!1)},[]),en=/* @__PURE__ */e("div",{className:"relative",children:[x.showZoomControls&&/* @__PURE__ */n("div",{className:"absolute top-2 right-2 z-10 rounded-lg",children:/* @__PURE__ */e("div",{className:"flex items-center gap-2 backdrop-blur rounded-lg",children:[
104
+ /* @__PURE__ */n("button",{type:"button",className:Dn("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=>Fe(e,k("common.zoomIn")),onMouseLeave:()=>Ye(),onClick:()=>j($r(O+.1,.5,3)),children:"+"}),
105
+ /* @__PURE__ */n("button",{type:"button",className:Dn("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=>Fe(e,k("common.zoomOut")),onMouseLeave:()=>Ye(),onClick:()=>j($r(O-.1,.5,3)),children:"−"}),
106
+ /* @__PURE__ */e("button",{type:"button",className:Dn("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=>Fe(e,k("common.resetZoom")),onMouseLeave:()=>Ye(),onClick:()=>{j(1),V({x:0,y:0})},children:[Math.round(100*O),"%"]})]})}),
107
107
  /* @__PURE__ */e("div",{ref:se,className:Dn("min-h-[360px] relative overflow-hidden block transition-[height] duration-150 ease-out",x.isDark?"bg-gray-900":"bg-gray-50"),style:{height:ne,maxHeight:null!=(y=x.maxHeight)?y:void 0},onWheel:Ze,onMouseDown:e=>{0===e.button&&(e.preventDefault(),Ge(e.clientX,e.clientY))},onMouseMove:e=>Je(e.clientX,e.clientY),onMouseUp:Qe,onMouseLeave:Qe,onTouchStart:e=>{const n=e.touches[0];n&&Ge(n.clientX,n.clientY)},onTouchMove:e=>{const n=e.touches[0];n&&Je(n.clientX,n.clientY)},onTouchEnd:Qe,children:[
108
108
  /* @__PURE__ */n("div",{ref:de,"data-mermaid-wrapper":!0,className:Dn("absolute inset-0 cursor-grab",{"cursor-grabbing":K}),style:{transform:`translate(${z.x}px, ${z.y}px) scale(${O})`},children:/* @__PURE__ */n("div",{ref:ue,className:"_mermaid w-full text-center flex items-center justify-center min-h-full"})}),(q||Be)&&/* @__PURE__ */e("div",{className:"mermaid-loading",children:[
109
109
  /* @__PURE__ */n("span",{className:"mermaid-spinner"}),
110
110
  /* @__PURE__ */n("span",{children:"Rendering diagram…"})]})]})]}),nn=x.showHeader&&/* @__PURE__ */e("div",{className:Dn("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
111
  /* @__PURE__ */e("div",{className:"flex items-center space-x-2 overflow-hidden",children:[
112
112
  /* @__PURE__ */n("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:b}}),
113
- /* @__PURE__ */n("span",{className:Dn("text-sm font-medium font-mono truncate",x.isDark?"text-gray-400":"text-gray-600"),children:"Mermaid"})]}),x.showModeToggle&&$&&/* @__PURE__ */e("div",{className:Dn("flex items-center space-x-1 rounded-md p-0.5",x.isDark?"bg-gray-700":"bg-gray-100"),children:[
114
- /* @__PURE__ */n("button",{type:"button",className:Dn("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:()=>qe("preview"),onMouseEnter:e=>We(e,k("common.preview")),onFocus:e=>We(e,k("common.preview")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
113
+ /* @__PURE__ */n("span",{className:Dn("text-sm font-medium font-mono truncate",x.isDark?"text-gray-400":"text-gray-600"),children:"Mermaid"})]}),x.showModeToggle&&D&&/* @__PURE__ */e("div",{className:Dn("flex items-center space-x-1 rounded-md p-0.5",x.isDark?"bg-gray-700":"bg-gray-100"),children:[
114
+ /* @__PURE__ */n("button",{type:"button",className:Dn("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:()=>qe("preview"),onMouseEnter:e=>Fe(e,k("common.preview")),onFocus:e=>Fe(e,k("common.preview")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
115
115
  /* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
116
116
  /* @__PURE__ */n("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),
117
117
  /* @__PURE__ */n("circle",{cx:"12",cy:"12",r:"3"})]})}),
118
118
  /* @__PURE__ */n("span",{children:k("common.preview")})]})}),
119
- /* @__PURE__ */n("button",{type:"button",className:Dn("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:()=>qe("source"),onMouseEnter:e=>We(e,k("common.source")),onFocus:e=>We(e,k("common.source")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
119
+ /* @__PURE__ */n("button",{type:"button",className:Dn("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:()=>qe("source"),onMouseEnter:e=>Fe(e,k("common.source")),onFocus:e=>Fe(e,k("common.source")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[
120
120
  /* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m16 18l6-6l-6-6M8 6l-6 6l6 6"})}),
121
121
  /* @__PURE__ */n("span",{children:k("common.source")})]})})]}),
122
- /* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[x.showCollapseButton&&/* @__PURE__ */n("button",{type:"button",className:Xe,"aria-pressed":H,onClick:()=>F(e=>!e),onMouseEnter:e=>We(e,k(H?"common.expand":"common.collapse")),onFocus:e=>We(e,k(H?"common.expand":"common.collapse")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */n("svg",{style:{rotate:H?"0deg":"90deg"},xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),x.showCopyButton&&/* @__PURE__ */n("button",{type:"button",className:Xe,onClick:_e,onMouseEnter:e=>We(e,k(W?"common.copied":"common.copy")),onFocus:e=>We(e,k(W?"common.copied":"common.copy")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */n("svg",W?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
122
+ /* @__PURE__ */e("div",{className:"flex items-center space-x-1",children:[x.showCollapseButton&&/* @__PURE__ */n("button",{type:"button",className:Xe,"aria-pressed":H,onClick:()=>W(e=>!e),onMouseEnter:e=>Fe(e,k(H?"common.expand":"common.collapse")),onFocus:e=>Fe(e,k(H?"common.expand":"common.collapse")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */n("svg",{style:{rotate:H?"0deg":"90deg"},xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),x.showCopyButton&&/* @__PURE__ */n("button",{type:"button",className:Xe,onClick:_e,onMouseEnter:e=>Fe(e,k(F?"common.copied":"common.copy")),onFocus:e=>Fe(e,k(F?"common.copied":"common.copy")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */n("svg",F?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
123
123
  /* @__PURE__ */n("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
124
- /* @__PURE__ */n("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),x.showExportButton&&$&&/* @__PURE__ */n("button",{type:"button",className:Dn(Xe,Ke?"opacity-50 cursor-not-allowed":""),disabled:Ke,onClick:Oe,onMouseEnter:e=>We(e,k("common.export")),onFocus:e=>We(e,k("common.export")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
124
+ /* @__PURE__ */n("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),x.showExportButton&&D&&/* @__PURE__ */n("button",{type:"button",className:Dn(Xe,Ke?"opacity-50 cursor-not-allowed":""),disabled:Ke,onClick:Oe,onMouseEnter:e=>Fe(e,k("common.export")),onFocus:e=>Fe(e,k("common.export")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
125
125
  /* @__PURE__ */n("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),
126
- /* @__PURE__ */n("path",{d:"m7 10l5 5l5-5"})]})})}),x.showFullscreenButton&&$&&/* @__PURE__ */n("button",{type:"button",className:Dn(Xe,Ke?"opacity-50 cursor-not-allowed":""),disabled:Ke,onClick:Q?ze:Ve,onMouseEnter:e=>We(e,k(Q?"common.minimize":"common.open")),onFocus:e=>We(e,k(Q?"common.minimize":"common.open")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */n("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__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})})]})]}),tn=/* @__PURE__ */e("div",{children:[A?/* @__PURE__ */n("div",{className:Dn("p-4",x.isDark?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-700"),children:/* @__PURE__ */n("pre",{className:"text-sm font-mono whitespace-pre-wrap",children:M})}):en,G&&/* @__PURE__ */n("div",{className:"mermaid-error",children:G})]});/* @__PURE__ */
126
+ /* @__PURE__ */n("path",{d:"m7 10l5 5l5-5"})]})})}),x.showFullscreenButton&&D&&/* @__PURE__ */n("button",{type:"button",className:Dn(Xe,Ke?"opacity-50 cursor-not-allowed":""),disabled:Ke,onClick:Q?ze:Ve,onMouseEnter:e=>Fe(e,k(Q?"common.minimize":"common.open")),onFocus:e=>Fe(e,k(Q?"common.minimize":"common.open")),onMouseLeave:()=>Ye(),onBlur:()=>Ye(),children:/* @__PURE__ */n("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__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"w-3 h-3",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})})]})]}),tn=/* @__PURE__ */e("div",{children:[A?/* @__PURE__ */n("div",{className:Dn("p-4",x.isDark?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-700"),children:/* @__PURE__ */n("pre",{className:"text-sm font-mono whitespace-pre-wrap",children:M})}):en,G&&/* @__PURE__ */n("div",{className:"mermaid-error",children:G})]});/* @__PURE__ */
127
127
  return e(t,{children:[
128
128
  /* @__PURE__ */e("div",{"data-markstream-mermaid":"1","data-markstream-mode":A?"source":Y?"preview":"pending",className:Dn("my-4 rounded-lg border overflow-hidden shadow-sm mermaid-block",x.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":Be}),children:[nn,
129
129
  /* @__PURE__ */n("div",{ref:me,style:{display:H?"none":""},children:tn})]}),Q&&"undefined"!=typeof document&&ye(
@@ -131,75 +131,75 @@ return e(t,{children:[
131
131
  /* @__PURE__ */e("div",{className:"mermaid-modal-header",children:[
132
132
  /* @__PURE__ */n("span",{className:"mermaid-modal-title",children:`Mermaid ${k("common.preview")}`}),
133
133
  /* @__PURE__ */n("button",{type:"button",className:"mermaid-modal-close",onClick:ze,children:k("common.close")})]}),
134
- /* @__PURE__ */n("div",{className:"mermaid-modal-body",children:/* @__PURE__ */n("div",{ref:he,className:"mermaid-modal-content"})})]})}),document.body)]})}function Lr(e,n,t){return Math.min(Math.max(e,n),t)}async function Er(e,n,t){try{if(await fr(e,n,t.workerTimeout))return!0}catch(l){if("AbortError"===(null==l?void 0:l.name))throw l}if(!t.mermaid)throw new Error("Mermaid not available");const r=Dr(e,n),o=t.mermaid;if("function"==typeof o.parse)return await Rr(()=>o.parse(r),{timeoutMs:t.parseTimeout,signal:t.signal}),!0;const i=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;return await Rr(()=>o.render(i,r),{timeoutMs:t.parseTimeout,signal:t.signal}),!0}function Dr(e,n){return e.trimStart().startsWith("%%{")?e:`%%{init: {"theme": "${"dark"===n?"dark":"default"}"}}%%\n${e}`}function $r(e){var n;for(const t of e.split(/\r?\n/)){const e=t.trim();if(!e||e.startsWith("%%"))continue;const r=e.match(/^([A-Z][\w-]*)\b/i);return(null==(n=null==r?void 0:r[1])?void 0:n.toLowerCase())||""}return""}function Pr(e){const n=e.trim();return!(!n||n.startsWith("%%"))&&!/^(?:gantt|title|dateformat|axisformat|tickinterval|excludes|section|todaymarker|topaxis|weekday|weekend|acctitle|accdescr|accdescrmultiline)\b/i.test(n)&&n.includes(":")}function Ar(e){if("gantt"===$r(e))return function(e){var n;const t=e.split(/\r?\n/);for(!/\r?\n$/.test(e)&&t.length>0&&t.pop();t.length>0;){const e=null==(n=t[t.length-1])?void 0:n.trim();if(e&&!e.startsWith("%%")){if(Pr(e))break;t.pop()}else t.pop()}return t.some(Pr)?t.join("\n"):""}(e);const n=e.split("\n");for(;n.length>0;){const e=n[n.length-1].trimEnd();if(""!==e){if(!(/^[-=~>|<\s]+$/.test(e.trim())||/(?:--|==|~~|->|<-|-\||-\)|-x|o-|\|-|\.-)\s*$/.test(e)||/[-|><]$/.test(e)||/(?:graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt)\s*$/i.test(e)))break;n.pop()}else n.pop()}return n.join("\n")}async function Rr(e,n={}){const{timeoutMs:t,signal:r}=n;return(null==r?void 0:r.aborted)?Promise.reject(new DOMException("Aborted","AbortError")):new Promise((n,o)=>{let i=!1,l=null;function a(){i||(i=!0,c(),o(new DOMException("Aborted","AbortError")))}function c(){null!=l&&clearTimeout(l),r&&r.removeEventListener("abort",a)}r&&r.addEventListener("abort",a,{once:!0}),t&&t>0&&(l=setTimeout(()=>{i||(i=!0,c(),o(new Error("Operation timed out")))},t)),e().then(e=>{i||(i=!0,c(),n(e))}).catch(e=>{i||(i=!0,c(),o(e))})})}function Hr(e){return(new XMLSerializer).serializeToString(e)}function Fr(n){const{node:t}=n;/* @__PURE__ */
135
- return e("div",{className:"unknown-node text-sm text-gray-500 italic",children:["Unsupported node type:"," ",String(null==t?void 0:t.type)]})}function Wr(e){var n;return"text"===(null==e?void 0:e.type)&&""===String(null!=(n=null==e?void 0:e.content)?n:"").trim()}function Ir(e,t,o,i){const l=e.filter(e=>!Wr(e)),a=l.length>0&&l.every(e=>"image"===e.type||function(e){var n;const t=function(e){return"link"===(null==e?void 0:e.type)&&Array.isArray(null==e?void 0:e.children)?e.children.filter(e=>!Wr(e)):[]}(e);return 1===t.length&&"image"===(null==(n=t[0])?void 0:n.type)}(e));if(!a||l.length<=1)return $(e,o,i,t);const c=[];for(let n=0;n<e.length;n++){const t=e[n];if(!Wr(t)){c.push(t);continue}const r=c.length>0,o=e.slice(n+1).some(e=>!Wr(e));r&&o&&c.push({...t,content:" ",raw:" "})}return c.map((e,l)=>{var c;return a&&Wr(e)?/* @__PURE__ */n(r.Fragment,{children:String(null!=(c=null==e?void 0:e.content)?c:"")},`${i}-${l}`):t(e,`${i}-${l}`,o)})}function _r(e){var o,i,l,a;const{node:c,ctx:s,renderNode:d,indexKey:u,children:m}=e;if(!s||!d)/* @__PURE__ */
134
+ /* @__PURE__ */n("div",{className:"mermaid-modal-body",children:/* @__PURE__ */n("div",{ref:he,className:"mermaid-modal-content"})})]})}),document.body)]})}function $r(e,n,t){return Math.min(Math.max(e,n),t)}async function Dr(e,n,t){try{if(await gr(e,n,t.workerTimeout))return!0}catch(l){if("AbortError"===(null==l?void 0:l.name))throw l}if(!t.mermaid)throw new Error("Mermaid not available");const r=Pr(e,n),o=t.mermaid;if("function"==typeof o.parse)return await Wr(()=>o.parse(r),{timeoutMs:t.parseTimeout,signal:t.signal}),!0;const i=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;return await Wr(()=>o.render(i,r),{timeoutMs:t.parseTimeout,signal:t.signal}),!0}function Pr(e,n){return e.trimStart().startsWith("%%{")?e:`%%{init: {"theme": "${"dark"===n?"dark":"default"}"}}%%\n${e}`}function Ar(e){var n;for(const t of e.split(/\r?\n/)){const e=t.trim();if(!e||e.startsWith("%%"))continue;const r=e.match(/^([A-Z][\w-]*)\b/i);return(null==(n=null==r?void 0:r[1])?void 0:n.toLowerCase())||""}return""}function Rr(e){const n=e.trim();return!(!n||n.startsWith("%%"))&&!/^(?:gantt|title|dateformat|axisformat|tickinterval|excludes|section|todaymarker|topaxis|weekday|weekend|acctitle|accdescr|accdescrmultiline)\b/i.test(n)&&n.includes(":")}function Hr(e){if("gantt"===Ar(e))return function(e){var n;const t=e.split(/\r?\n/);for(!/\r?\n$/.test(e)&&t.length>0&&t.pop();t.length>0;){const e=null==(n=t[t.length-1])?void 0:n.trim();if(e&&!e.startsWith("%%")){if(Rr(e))break;t.pop()}else t.pop()}return t.some(Rr)?t.join("\n"):""}(e);const n=e.split("\n");for(;n.length>0;){const e=n[n.length-1].trimEnd();if(""!==e){if(!(/^[-=~>|<\s]+$/.test(e.trim())||/(?:--|==|~~|->|<-|-\||-\)|-x|o-|\|-|\.-)\s*$/.test(e)||/[-|><]$/.test(e)||/(?:graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt)\s*$/i.test(e)))break;n.pop()}else n.pop()}return n.join("\n")}async function Wr(e,n={}){const{timeoutMs:t,signal:r}=n;return(null==r?void 0:r.aborted)?Promise.reject(new DOMException("Aborted","AbortError")):new Promise((n,o)=>{let i=!1,l=null;function a(){i||(i=!0,c(),o(new DOMException("Aborted","AbortError")))}function c(){null!=l&&clearTimeout(l),r&&r.removeEventListener("abort",a)}r&&r.addEventListener("abort",a,{once:!0}),t&&t>0&&(l=setTimeout(()=>{i||(i=!0,c(),o(new Error("Operation timed out")))},t)),e().then(e=>{i||(i=!0,c(),n(e))}).catch(e=>{i||(i=!0,c(),o(e))})})}function Fr(e){return(new XMLSerializer).serializeToString(e)}function Ir(n){const{node:t}=n;/* @__PURE__ */
135
+ return e("div",{className:"unknown-node text-sm text-gray-500 italic",children:["Unsupported node type:"," ",String(null==t?void 0:t.type)]})}function _r(e){var n;return"text"===(null==e?void 0:e.type)&&""===String(null!=(n=null==e?void 0:e.content)?n:"").trim()}function Or(e,t,o,i){const l=e.filter(e=>!_r(e)),a=l.length>0&&l.every(e=>"image"===e.type||function(e){var n;const t=function(e){return"link"===(null==e?void 0:e.type)&&Array.isArray(null==e?void 0:e.children)?e.children.filter(e=>!_r(e)):[]}(e);return 1===t.length&&"image"===(null==(n=t[0])?void 0:n.type)}(e));if(!a||l.length<=1)return D(e,o,i,t);const c=[];for(let n=0;n<e.length;n++){const t=e[n];if(!_r(t)){c.push(t);continue}const r=c.length>0,o=e.slice(n+1).some(e=>!_r(e));r&&o&&c.push({...t,content:" ",raw:" "})}return c.map((e,l)=>{var c;return a&&_r(e)?/* @__PURE__ */n(r.Fragment,{children:String(null!=(c=null==e?void 0:e.content)?c:"")},`${i}-${l}`):t(e,`${i}-${l}`,o)})}function jr(e){var o,i,l,a;const{node:c,ctx:s,renderNode:d,indexKey:u,children:m}=e;if(!s||!d)/* @__PURE__ */
136
136
  return n("p",{dir:"auto",className:"paragraph-node",children:m});const h=null!=(o=c.children)?o:[],f={...null!=(i=s.customComponents)?i:K(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(
137
- /* @__PURE__ */n("p",{dir:"auto",className:"paragraph-node",children:Ir(g.slice(),d,s,`${String(null!=u?u:"paragraph")}-${e}`)},`${String(null!=u?u:"paragraph")}-inline-${e}`)),g.length=0};return h.forEach((e,t)=>{var o;const i="escape"!==(null!=(o=s.htmlPolicy)?o:"safe")||"html_inline"!==e.type&&"html_block"!==e.type;ae.has(e.type)||i&&ce(e,f,s.customHtmlTags)?(v(),p.push(
138
- /* @__PURE__ */n(r.Fragment,{children:d(e,`${String(null!=u?u:"paragraph")}-block-${t}`,s)},`${String(null!=u?u:"paragraph")}-block-${t}`))):g.push(e)}),v(),p.length?/* @__PURE__ */n(t,{children:p}):/* @__PURE__ */n("p",{dir:"auto",className:"paragraph-node",children:Ir(h,d,s,String(null!=u?u:"paragraph"))})}function Or(e){const{node:t}=e,r=d(n=>{var r;null==(r=e.onClick)||r.call(e,n,t.id,e.messageId,e.threadId)},[t.id,e]);/* @__PURE__ */
139
- return n("span",{className:"reference-node cursor-pointer bg-[hsl(var(--muted))] text-xs rounded-md px-1.5 mx-0.5 hover:bg-[hsl(var(--secondary))]",role:"button",tabIndex:0,onClick:r,onMouseEnter:n=>{var r;null==(r=e.onMouseEnter)||r.call(e,n,t.id,e.messageId,e.threadId)},onMouseLeave:n=>{var r;null==(r=e.onMouseLeave)||r.call(e,n,t.id,e.messageId,e.threadId)},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||r(e)},children:t.id})}function jr(e){/* @__PURE__ */
140
- return n("s",{className:"strikethrough-node",children:e.children})}function zr(e){/* @__PURE__ */
141
- return n("strong",{className:"strong-node",children:e.children})}function Vr(e){/* @__PURE__ */
142
- return n("sub",{className:"subscript-node",children:e.children})}function Kr(e){/* @__PURE__ */
143
- return n("sup",{className:"superscript-node",children:e.children})}function Xr(t){var o;const{node:i,ctx:l,renderNode:a,indexKey:c}=t,s=Array.isArray(null==(o=null==i?void 0:i.header)?void 0:o.cells)?i.header.cells:[],d=Boolean(null==i?void 0:i.loading),u=Array.isArray(null==i?void 0:i.rows)?i.rows:[],m=r.useRef(null),h=r.useRef(null),f=r.useRef(null),[p,g]=r.useState([]),v=e=>"right"===e?"text-right":"center"===e?"text-center":"text-left",w=()=>{const e=f.current;e&&(window.removeEventListener("pointermove",e.move),window.removeEventListener("pointerup",e.stop),window.removeEventListener("pointercancel",e.stop),f.current=null),h.current=null};return r.useEffect(()=>(w(),g([]),w),[s.length]),/* @__PURE__ */e("div",{className:"table-node-wrapper","data-index-key":c,children:[
137
+ /* @__PURE__ */n("p",{dir:"auto",className:"paragraph-node",children:Or(g.slice(),d,s,`${String(null!=u?u:"paragraph")}-${e}`)},`${String(null!=u?u:"paragraph")}-inline-${e}`)),g.length=0};return h.forEach((e,t)=>{var o;const i="escape"!==(null!=(o=s.htmlPolicy)?o:"safe")||"html_inline"!==e.type&&"html_block"!==e.type;ae.has(e.type)||i&&ce(e,f,s.customHtmlTags)?(v(),p.push(
138
+ /* @__PURE__ */n(r.Fragment,{children:d(e,`${String(null!=u?u:"paragraph")}-block-${t}`,s)},`${String(null!=u?u:"paragraph")}-block-${t}`))):g.push(e)}),v(),p.length?/* @__PURE__ */n(t,{children:p}):/* @__PURE__ */n("p",{dir:"auto",className:"paragraph-node",children:Or(h,d,s,String(null!=u?u:"paragraph"))})}function zr(e){const{node:t}=e,r=d(n=>{var r;null==(r=e.onClick)||r.call(e,n,t.id,e.messageId,e.threadId)},[t.id,e]);/* @__PURE__ */
139
+ return n("span",{className:"reference-node cursor-pointer bg-[hsl(var(--muted))] text-xs rounded-md px-1.5 mx-0.5 hover:bg-[hsl(var(--secondary))]",role:"button",tabIndex:0,onClick:r,onMouseEnter:n=>{var r;null==(r=e.onMouseEnter)||r.call(e,n,t.id,e.messageId,e.threadId)},onMouseLeave:n=>{var r;null==(r=e.onMouseLeave)||r.call(e,n,t.id,e.messageId,e.threadId)},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||r(e)},children:t.id})}function Vr(e){/* @__PURE__ */
140
+ return n("s",{className:"strikethrough-node",children:e.children})}function Kr(e){/* @__PURE__ */
141
+ return n("strong",{className:"strong-node",children:e.children})}function Xr(e){/* @__PURE__ */
142
+ return n("sub",{className:"subscript-node",children:e.children})}function qr(e){/* @__PURE__ */
143
+ return n("sup",{className:"superscript-node",children:e.children})}function Ur(t){var o;const{node:i,ctx:l,renderNode:a,indexKey:c}=t,s=Array.isArray(null==(o=null==i?void 0:i.header)?void 0:o.cells)?i.header.cells:[],d=Boolean(null==i?void 0:i.loading),u=Array.isArray(null==i?void 0:i.rows)?i.rows:[],m=r.useRef(null),h=r.useRef(null),f=r.useRef(null),[p,g]=r.useState([]),v=e=>"right"===e?"text-right":"center"===e?"text-center":"text-left",w=()=>{const e=f.current;e&&(window.removeEventListener("pointermove",e.move),window.removeEventListener("pointerup",e.stop),window.removeEventListener("pointercancel",e.stop),f.current=null),h.current=null};return r.useEffect(()=>(w(),g([]),w),[s.length]),/* @__PURE__ */e("div",{className:"table-node-wrapper","data-index-key":c,children:[
144
144
  /* @__PURE__ */e("table",{ref:m,className:Dn("my-8 text-sm table-node",d&&"table-node--loading"),"aria-busy":d,children:[p.length>0&&/* @__PURE__ */n("colgroup",{children:s.map((e,t)=>/* @__PURE__ */n("col",{style:p[t]>0?{width:`${p[t]}px`}:void 0},`col-${t}`))}),
145
145
  /* @__PURE__ */n("thead",{className:"border-[var(--table-border,#cbd5e1)]",children:/* @__PURE__ */n("tr",{className:"border-b",children:s.map((t,r)=>/* @__PURE__ */e("th",{className:Dn("font-semibold p-[calc(4/7*1em)]",v(t.align)),dir:"auto",children:[l&&a?j(t.children,l,`${String(null!=c?c:"table")}-th-${r}`,a):null,r<s.length-1&&/* @__PURE__ */n("button",{type:"button",className:"table-node__resize-handle","aria-label":`Resize columns ${r+1} and ${r+2}`,onPointerDown:e=>((e,n)=>{if(0!==n.button)return;const t=(()=>{var e;const n=null==(e=m.current)?void 0:e.querySelectorAll("thead th");return Array.from(null!=n?n:[],e=>Math.round(e.getBoundingClientRect().width))})(),r=t[e],o=t[e+1];if(!r||!o)return;n.preventDefault(),w(),h.current={index:e,startX:n.clientX,startWidth:r,nextStartWidth:o,widths:t},g(t);const i=e=>{const n=h.current;if(!n)return;e.preventDefault();const t=n.startWidth+n.nextStartWidth,r=Math.min(48,Math.floor(t/2)),o=Math.max(r,Math.min(t-r,Math.round(n.startWidth+e.clientX-n.startX))),i=[...n.widths];i[n.index]=o,i[n.index+1]=t-o,g(i)},l=()=>{w()};f.current={move:i,stop:l},window.addEventListener("pointermove",i),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l)})(r,e)})]},`header-${r}`))})}),
146
146
  /* @__PURE__ */n("tbody",{children:u.map((e,t)=>{var r;/* @__PURE__ */
147
147
  return n("tr",{className:Dn("border-[var(--table-border,#cbd5e1)]",t<u.length-1&&"border-b"),children:null==(r=e.cells)?void 0:r.map((e,r)=>/* @__PURE__ */n("td",{className:Dn("p-[calc(4/7*1em)]",v(e.align)),dir:"auto",children:l&&a?j(e.children,l,`${String(null!=c?c:"table")}-row-${t}-${r}`,a):null},`cell-${t}-${r}`))},`row-${t}`)})})]}),d&&/* @__PURE__ */e("div",{className:"table-node__loading",role:"status","aria-live":"polite",children:[
148
148
  /* @__PURE__ */n("span",{className:"table-node__spinner","aria-hidden":"true"}),
149
- /* @__PURE__ */n("span",{className:"sr-only",children:"Loading"})]})]})}function qr(){/* @__PURE__ */
150
- return n("hr",{className:"hr-node thematic-break"})}function Ur(e){const{node:t,ctx:i,renderNode:l,indexKey:a}=e,c=`vmr-container vmr-container-${t.name}`,s=o(()=>{if(t.attrs)return Array.isArray(t.attrs)?X(t.attrs):t.attrs},[t.attrs]);/* @__PURE__ */
151
- return n("div",{className:c,...s,children:i&&l&&Array.isArray(t.children)?t.children.map((e,t)=>/* @__PURE__ */n(r.Fragment,{children:l(e,`${String(null!=a?a:"vmr-container")}-${t}`,i)},`${String(null!=a?a:"vmr-container")}-${t}`)):null})}function Yr(e,n,t,o,i={}){var l,a,c,s,d,u;const m=de(o.codeBlockProps),h=o.events.onHandleArtifactClick?e=>{var r,i;const l="image/svg+xml"===e.type?"image/svg+xml":"text/html";null==(i=(r=o.events).onHandleArtifactClick)||i.call(r,{node:null==e.content?n:{...n,code:e.content},artifactType:l,artifactTitle:e.title||("image/svg+xml"===l?"SVG Preview":"HTML Preview"),id:String(t)})}:void 0;return r.createElement(e,{key:t,node:n,loading:Boolean(n.loading),stream:o.codeBlockStream,customId:o.customId,isDark:o.isDark,darkTheme:null==(l=o.codeBlockThemes)?void 0:l.darkTheme,lightTheme:null==(a=o.codeBlockThemes)?void 0:a.lightTheme,themes:null==(c=o.codeBlockThemes)?void 0:c.themes,langs:null==(s=o.codeBlockThemes)?void 0:s.langs,minWidth:null==(d=o.codeBlockThemes)?void 0:d.minWidth,maxWidth:null==(u=o.codeBlockThemes)?void 0:u.maxWidth,onCopy:o.events.onCopy,onPreviewCode:h,...m,...i,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade})}function Zr(e,n,t,o,i={}){return r.createElement(e,{key:t,node:n,isDark:o.isDark,...i})}function Gr(e,t,o){var i,l,a,c,s,d,u,m,v,w,y;const x=null!=(i=o.customComponents)?i:K(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 n=f(e.type),t=f(e.tag);return n&&t&&n===t?n:""}(e),M=C?k[C]:null,N=C&&!M?b[C]:null,L="code_block"===e.type?null:x[e.type];if(M)return r.createElement(M,{key:t,node:e,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade});if(N)return function(e,n,t,o,i){var l,a,c;const s=h(null!=(l=n.attrs)?l:void 0,null!=(a=o.htmlPolicy)?a:"safe",i),d=p(g(s)),u=Array.isArray(n.children)?$(n.children,o,`${String(t)}-html`,Gr):null!=(c=n.content)?c:null;return r.createElement(e,{...d,key:t},u)}(N,e,t,o,C);if(L)return r.createElement(L,{key:t,node:e,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade});if("html_block"===e.type||"html_inline"===e.type){const i={...x,...k},l=se(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 n={...e,type:h,tag:h,content:S(e.content,h)};return r.createElement(i,{key:t,node:n,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade})}const c=String(null!=(w=null!=(v=e.content)?v:e.raw)?w:"");if(!a&&T(c,h))return"html_inline"===e.type?/* @__PURE__ */n(Nt,{node:{type:"text",content:c,raw:c},ctx:o,indexKey:t,typewriter:o.typewriter,fade:o.fade},t):/* @__PURE__ */n(_r,{node:{type:"paragraph",children:[{type:"text",content:c,raw:c}],raw:c},ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t)}}switch(e.type){case"text":/* @__PURE__ */
152
- return n(Nt,{node:e,ctx:o,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"text_special":/* @__PURE__ */
153
- return n(Nt,{node:{type:"text",content:null!=(y=e.content)?y:"",center:e.center},ctx:o,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"paragraph":/* @__PURE__ */
154
- return n(_r,{node:e,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"heading":/* @__PURE__ */
155
- return n(Qn,{node:e,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"blockquote":/* @__PURE__ */
156
- return n(io,{node:e,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"list":/* @__PURE__ */
157
- return n(Tt,{node:e,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"list_item":/* @__PURE__ */
158
- return n(St,{node:e,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"table":/* @__PURE__ */
159
- return n(Xr,{node:e,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"definition_list":/* @__PURE__ */
160
- return n(Xn,{node:e,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"footnote":/* @__PURE__ */
161
- return n(Zn,{node:e,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"footnote_reference":/* @__PURE__ */
162
- return n(Gn,{node:e},t);case"footnote_anchor":/* @__PURE__ */
163
- return n(Yn,{node:e},t);case"admonition":/* @__PURE__ */
164
- return n(Be,{node:e,ctx:o,renderNode:Gr,indexKey:t,isDark:o.isDark,typewriter:o.typewriter,fade:o.fade},t);case"hardbreak":/* @__PURE__ */
165
- return n(Jn,{node:e,typewriter:o.typewriter,fade:o.fade},t);case"link":/* @__PURE__ */
166
- return n(Bt,{node:e,ctx:o,renderNode:Gr,indexKey:t,isDark:o.isDark,showTooltip:"boolean"==typeof o.showTooltips?o.showTooltips:void 0,typewriter:o.typewriter,fade:o.fade},t);case"image":/* @__PURE__ */
167
- return n(pt,{node:e},t);case"inline_code":/* @__PURE__ */
168
- return n(bt,{node:e,ctx:o,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"code_block":return function(e,t,r,o){var i,l,a,c,s,d;const u=function(e){const n=String((null==e?void 0:e.language)||"").trim();if(!n)return"";const[t]=n.split(/\s+/),[r]=t.split(":");return r.toLowerCase()}(e),m=P(u),h=function(e,n){const t=n.trim().toLowerCase();if(!t)return null;for(const r of[t,P(t),pe(t)]){const n=r&&e[r];if(n)return n}return null}(o,u);if("mermaid"===m){const i=function(e,n){var t,r;const o={...n.mermaidProps||{}};return null==oe(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=ie(le(String(null!=(t=null==e?void 0:e.code)?t:"")),void 0,"none"===o.maxHeight?null:null!=(r=oe(o.maxHeight))?r:void 0)),o}(e,r),l=h||o.mermaid;if(l)return Zr(l,e,t,r,i);if(!r.renderCodeBlocksAsPre)/* @__PURE__ */
169
- return n(Tr,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...i},t)}if("infographic"===m){const i=function(e,n){var t,r;const o={...n.infographicProps||{}};return null==ee(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=ne(te(String(null!=(t=null==e?void 0:e.code)?t:"")),void 0,"none"===o.maxHeight?null:null!=(r=ee(o.maxHeight))?r:void 0)),o}(e,r),l=h||o.infographic;return l?Zr(l,e,t,r,i):/* @__PURE__ */n(xt,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...i},t)}if("d2"===m||"d2lang"===m){const i=h||o.d2;return i?Zr(i,e,t,r,r.d2Props||{}):/* @__PURE__ */n(Kn,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...r.d2Props||{}},t)}if(h)return Yr(h,e,t,r);const f=o.code_block;return f?Yr(f,e,t,r):r.renderCodeBlocksAsPre||"mermaid"===m?/* @__PURE__ */n(O,{node:e,monacoOptions:null==(i=r.codeBlockThemes)?void 0:i.monacoOptions,showLineNumbers:!0===(null==(l=r.codeBlockProps)?void 0:l.showLineNumbers)},t):/* @__PURE__ */n(Ln,{node:e,loading:Boolean(e.loading),stream:r.codeBlockStream,monacoOptions:null==(a=r.codeBlockThemes)?void 0:a.monacoOptions,themes:null==(c=r.codeBlockThemes)?void 0:c.themes,minWidth:null==(s=r.codeBlockThemes)?void 0:s.minWidth,maxWidth:null==(d=r.codeBlockThemes)?void 0:d.maxWidth,isDark:r.isDark,onCopy:r.events.onCopy,...de(r.codeBlockProps,{omit:["langs"]})},t)}(e,t,o,x);case"strong":/* @__PURE__ */
170
- return n(zr,{node:e,children:$(e.children,o,`${String(t)}-strong`,Gr)},t);case"emphasis":/* @__PURE__ */
171
- return n(Un,{node:e,children:$(e.children,o,`${String(t)}-em`,Gr)},t);case"strikethrough":/* @__PURE__ */
172
- return n(jr,{node:e,children:$(e.children,o,`${String(t)}-strike`,Gr)},t);case"highlight":/* @__PURE__ */
173
- return n(et,{node:e,children:$(e.children,o,`${String(t)}-highlight`,Gr)},t);case"insert":/* @__PURE__ */
174
- return n(Ct,{node:e,children:$(e.children,o,`${String(t)}-insert`,Gr)},t);case"subscript":/* @__PURE__ */
175
- return n(Vr,{node:e,children:$(e.children,o,`${String(t)}-sub`,Gr)},t);case"superscript":/* @__PURE__ */
176
- return n(Kr,{node:e,children:$(e.children,o,`${String(t)}-sup`,Gr)},t);case"checkbox":case"checkbox_input":/* @__PURE__ */
149
+ /* @__PURE__ */n("span",{className:"sr-only",children:"Loading"})]})]})}function Yr(){/* @__PURE__ */
150
+ return n("hr",{className:"hr-node thematic-break"})}function Zr(e){const{node:t,ctx:i,renderNode:l,indexKey:a}=e,c=`vmr-container vmr-container-${t.name}`,s=o(()=>{if(t.attrs)return Array.isArray(t.attrs)?X(t.attrs):t.attrs},[t.attrs]);/* @__PURE__ */
151
+ return n("div",{className:c,...s,children:i&&l&&Array.isArray(t.children)?t.children.map((e,t)=>/* @__PURE__ */n(r.Fragment,{children:l(e,`${String(null!=a?a:"vmr-container")}-${t}`,i)},`${String(null!=a?a:"vmr-container")}-${t}`)):null})}function Gr(e,n,t,o,i={}){var l,a,c,s,d,u;const m=de(o.codeBlockProps),h=o.events.onHandleArtifactClick?e=>{var r,i;const l="image/svg+xml"===e.type?"image/svg+xml":"text/html";null==(i=(r=o.events).onHandleArtifactClick)||i.call(r,{node:null==e.content?n:{...n,code:e.content},artifactType:l,artifactTitle:e.title||("image/svg+xml"===l?"SVG Preview":"HTML Preview"),id:String(t)})}:void 0;return r.createElement(e,{key:t,node:n,loading:Boolean(n.loading),stream:o.codeBlockStream,customId:o.customId,isDark:o.isDark,darkTheme:null==(l=o.codeBlockThemes)?void 0:l.darkTheme,lightTheme:null==(a=o.codeBlockThemes)?void 0:a.lightTheme,themes:null==(c=o.codeBlockThemes)?void 0:c.themes,langs:null==(s=o.codeBlockThemes)?void 0:s.langs,minWidth:null==(d=o.codeBlockThemes)?void 0:d.minWidth,maxWidth:null==(u=o.codeBlockThemes)?void 0:u.maxWidth,onCopy:o.events.onCopy,onPreviewCode:h,...m,...i,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade})}function Jr(e,n,t,o,i={}){return r.createElement(e,{key:t,node:n,isDark:o.isDark,...i})}function Qr(e,t,o){var i,l,a,c,s,d,u,m,v,w,y;const x=null!=(i=o.customComponents)?i:K(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 n=f(e.type),t=f(e.tag);return n&&t&&n===t?n:""}(e),M=C?k[C]:null,N=C&&!M?b[C]:null,L="code_block"===e.type?null:x[e.type];if(M)return r.createElement(M,{key:t,node:e,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade});if(N)return function(e,n,t,o,i){var l,a,c;const s=h(null!=(l=n.attrs)?l:void 0,null!=(a=o.htmlPolicy)?a:"safe",i),d=p(g(s)),u=Array.isArray(n.children)?D(n.children,o,`${String(t)}-html`,Qr):null!=(c=n.content)?c:null;return r.createElement(e,{...d,key:t},u)}(N,e,t,o,C);if(L)return r.createElement(L,{key:t,node:e,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade});if("html_block"===e.type||"html_inline"===e.type){const i={...x,...k},l=se(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 n={...e,type:h,tag:h,content:S(e.content,h)};return r.createElement(i,{key:t,node:n,customId:o.customId,isDark:o.isDark,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade})}const c=String(null!=(w=null!=(v=e.content)?v:e.raw)?w:"");if(!a&&T(c,h))return"html_inline"===e.type?/* @__PURE__ */n(St,{node:{type:"text",content:c,raw:c},ctx:o,indexKey:t,typewriter:o.typewriter,fade:o.fade},t):/* @__PURE__ */n(jr,{node:{type:"paragraph",children:[{type:"text",content:c,raw:c}],raw:c},ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t)}}switch(e.type){case"text":/* @__PURE__ */
152
+ return n(St,{node:e,ctx:o,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"text_special":/* @__PURE__ */
153
+ return n(St,{node:{type:"text",content:null!=(y=e.content)?y:"",center:e.center},ctx:o,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"paragraph":/* @__PURE__ */
154
+ return n(jr,{node:e,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"heading":/* @__PURE__ */
155
+ return n(et,{node:e,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"blockquote":/* @__PURE__ */
156
+ return n(ao,{node:e,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"list":/* @__PURE__ */
157
+ return n(Et,{node:e,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"list_item":/* @__PURE__ */
158
+ return n(Lt,{node:e,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"table":/* @__PURE__ */
159
+ return n(Ur,{node:e,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"definition_list":/* @__PURE__ */
160
+ return n(qn,{node:e,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"footnote":/* @__PURE__ */
161
+ return n(Gn,{node:e,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"footnote_reference":/* @__PURE__ */
162
+ return n(Jn,{node:e},t);case"footnote_anchor":/* @__PURE__ */
163
+ return n(Zn,{node:e},t);case"admonition":/* @__PURE__ */
164
+ return n(Be,{node:e,ctx:o,renderNode:Qr,indexKey:t,isDark:o.isDark,typewriter:o.typewriter,fade:o.fade},t);case"hardbreak":/* @__PURE__ */
165
+ return n(Qn,{node:e,typewriter:o.typewriter,fade:o.fade},t);case"link":/* @__PURE__ */
166
+ return n(Tt,{node:e,ctx:o,renderNode:Qr,indexKey:t,isDark:o.isDark,showTooltip:"boolean"==typeof o.showTooltips?o.showTooltips:void 0,typewriter:o.typewriter,fade:o.fade},t);case"image":/* @__PURE__ */
167
+ return n(gt,{node:e},t);case"inline_code":/* @__PURE__ */
168
+ return n(Ct,{node:e,ctx:o,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"code_block":return function(e,t,r,o){var i,l,a,c,s,d;const u=function(e){const n=String((null==e?void 0:e.language)||"").trim();if(!n)return"";const[t]=n.split(/\s+/),[r]=t.split(":");return r.toLowerCase()}(e),m=P(u),h=function(e,n){const t=n.trim().toLowerCase();if(!t)return null;for(const r of[t,P(t),pe(t)]){const n=r&&e[r];if(n)return n}return null}(o,u);if("mermaid"===m){const i=function(e,n){var t,r;const o={...n.mermaidProps||{}};return null==oe(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=ie(le(String(null!=(t=null==e?void 0:e.code)?t:"")),void 0,"none"===o.maxHeight?null:null!=(r=oe(o.maxHeight))?r:void 0)),o}(e,r),l=h||o.mermaid;if(l)return Jr(l,e,t,r,i);if(!r.renderCodeBlocksAsPre)/* @__PURE__ */
169
+ return n(Er,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...i},t)}if("infographic"===m){const i=function(e,n){var t,r;const o={...n.infographicProps||{}};return null==ee(o.estimatedPreviewHeightPx)&&(o.estimatedPreviewHeightPx=ne(te(String(null!=(t=null==e?void 0:e.code)?t:"")),void 0,"none"===o.maxHeight?null:null!=(r=ee(o.maxHeight))?r:void 0)),o}(e,r),l=h||o.infographic;return l?Jr(l,e,t,r,i):/* @__PURE__ */n(kt,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...i},t)}if("d2"===m||"d2lang"===m){const i=h||o.d2;return i?Jr(i,e,t,r,r.d2Props||{}):/* @__PURE__ */n(Xn,{node:e,isDark:r.isDark,loading:Boolean(e.loading),...r.d2Props||{}},t)}if(h)return Gr(h,e,t,r);const f=o.code_block;return f?Gr(f,e,t,r):r.renderCodeBlocksAsPre||"mermaid"===m?/* @__PURE__ */n(O,{node:e,monacoOptions:null==(i=r.codeBlockThemes)?void 0:i.monacoOptions,showLineNumbers:!0===(null==(l=r.codeBlockProps)?void 0:l.showLineNumbers)},t):/* @__PURE__ */n(En,{node:e,loading:Boolean(e.loading),stream:r.codeBlockStream,monacoOptions:null==(a=r.codeBlockThemes)?void 0:a.monacoOptions,themes:null==(c=r.codeBlockThemes)?void 0:c.themes,minWidth:null==(s=r.codeBlockThemes)?void 0:s.minWidth,maxWidth:null==(d=r.codeBlockThemes)?void 0:d.maxWidth,isDark:r.isDark,onCopy:r.events.onCopy,...de(r.codeBlockProps,{omit:["langs"]})},t)}(e,t,o,x);case"strong":/* @__PURE__ */
170
+ return n(Kr,{node:e,children:D(e.children,o,`${String(t)}-strong`,Qr)},t);case"emphasis":/* @__PURE__ */
171
+ return n(Yn,{node:e,children:D(e.children,o,`${String(t)}-em`,Qr)},t);case"strikethrough":/* @__PURE__ */
172
+ return n(Vr,{node:e,children:D(e.children,o,`${String(t)}-strike`,Qr)},t);case"highlight":/* @__PURE__ */
173
+ return n(nt,{node:e,children:D(e.children,o,`${String(t)}-highlight`,Qr)},t);case"insert":/* @__PURE__ */
174
+ return n(Mt,{node:e,children:D(e.children,o,`${String(t)}-insert`,Qr)},t);case"subscript":/* @__PURE__ */
175
+ return n(Xr,{node:e,children:D(e.children,o,`${String(t)}-sub`,Qr)},t);case"superscript":/* @__PURE__ */
176
+ return n(qr,{node:e,children:D(e.children,o,`${String(t)}-sup`,Qr)},t);case"checkbox":case"checkbox_input":/* @__PURE__ */
177
177
  return n(He,{node:e,typewriter:o.typewriter,fade:o.fade},t);case"emoji":/* @__PURE__ */
178
- return n(qn,{node:e,typewriter:o.typewriter,fade:o.fade},t);case"thematic_break":/* @__PURE__ */
179
- return n(qr,{},t);case"math_inline":/* @__PURE__ */
180
- return n(er,{node:e},t);case"math_block":/* @__PURE__ */
181
- return n(Qt,{node:e},t);case"reference":/* @__PURE__ */
182
- return n(Or,{node:e,ctx:o,typewriter:o.typewriter,fade:o.fade},t);case"html_block":case"html_inline":return"html_block"===e.type?/* @__PURE__ */n(nt,{node:e,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade,customId:o.customId},t):/* @__PURE__ */n(mt,{node:e,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade,customId:o.customId},t);case"vmr_container":/* @__PURE__ */
183
- return n(Ur,{node:e,ctx:o,renderNode:Gr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"label_open":case"label_close":return null;default:/* @__PURE__ */
184
- return n(Fr,{node:e},t)}}const Jr={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},Qr=E();function eo(e,n){return e.type===n.type&&e.raw===n.raw&&e.loading===n.loading&&e.autoClosed===n.autoClosed&&!!function(e,n){if(e===n)return!0;if(!e||!n||"object"!=typeof e||"object"!=typeof n)return!1;const t=e,r=n;return t.startLine===r.startLine&&t.endLine===r.endLine}(e.sourceMap,n.sourceMap)&&("code_block"!==e.type&&"code_block"!==n.type||e.diff===n.diff)}function no(e){const n=o(()=>me(e),[e]),t=c(n);return function(e,n){const t=Object.keys(e),r=Object.keys(n);return t.length===r.length&&t.every(t=>e[t]===n[t])}(t.current,n)||(t.current=n),t.current}const to=r.memo(({node:e,nodeKey:n,renderCtx:t})=>Gr(e,n,t),(e,n)=>e.node===n.node&&e.renderCtx===n.renderCtx&&e.nodeKey===n.nodeKey),ro=r.memo(({props:t,parsedNodes:r,renderCtx:l,indexPrefix:a,containerRef:u,showTypewriterCursor:m,typewriterCursorRef:h})=>{var f,p,g,v,w,y,x;const k=Ae(),b="undefined"!=typeof window,C="undefined"!=typeof window&&"function"==typeof window.requestIdleCallback,M=Math.max(0,Math.trunc(null!=(f=t.renderBatchSize)?f:80)),N=Math.max(0,Math.trunc(null!=(p=t.initialRenderBatchSize)?p:M||r.length)),B=!1!==t.batchRendering&&M>0&&b,S=Math.max(0,null!=(g=t.liveNodeBuffer)?g:60),T=Math.max(1,null!=(v=t.maxLiveNodes)?v:320),L=(null!=(w=t.maxLiveNodes)?w:0)>0&&r.length>T,E=!1!==t.viewportPriority,D=B&&(null!=(y=t.maxLiveNodes)?y:0)<=0,$=o(()=>{var e;return!1!==t.deferNodesUntilVisible&&!((null!=(e=t.maxLiveNodes)?e:0)<=0)&&!L&&!(r.length>900)&&E},[r.length,t.deferNodesUntilVisible,t.maxLiveNodes,E,L]),[P,A]=i(()=>D?Math.min(r.length,N):r.length),R=c(P);s(()=>{R.current=P},[P]);const H=D?P:r.length,[F,W]=i(0),[I,_]=i({start:0,end:r.length}),O=c(/* @__PURE__ */new Map),[j,z]=i(0),V=c({}),K=c(/* @__PURE__ */new Map),X=c(/* @__PURE__ */new Map),q=c(/* @__PURE__ */new Map),U=c(/* @__PURE__ */new Map),Y=c(/* @__PURE__ */new Set),Z=c(P),G=c(null),J=c(null),Q=c(null),ee=c(!1),ne=c(null),te=c(Math.max(1,M||1)),re=c(r.length),oe=c({key:t.indexKey,total:r.length}),ie=c({batchSize:M,initial:N,delay:null!=(x=t.renderBatchDelay)?x:16,enabled:D}),le=$||L,ae=o(()=>{const e=O.current;if(!e.size)return 32;let n=0;for(const t of e.values())n+=t;return Math.max(16,n/e.size)},[j]),ce=o(()=>{if(!L)return r.map((e,n)=>({node:e,index:n}));const e=r.length,n=Math.max(0,Math.min(I.start,e)),t=Math.max(n,Math.min(I.end,e));return r.slice(n,t).map((e,t)=>({node:e,index:n+t}))},[r,I,L]),se=o(()=>{if(!L)return r.length;const e=Math.max(I.end+S,N),n=Math.min(r.length,e);return Math.max(P,n)},[r.length,L,I.end,S,N,P]);re.current=se;const de=d((e,n)=>{var t;if(e>=n)return 0;const r=O.current;let o=0;for(let i=e;i<n;i++)o+=null!=(t=r.get(i))?t:ae;return o},[ae]),ue=L?de(0,Math.min(I.start,r.length)):0,me=L?de(Math.min(I.end,r.length),r.length):0,he=d(()=>{null!=G.current&&"function"==typeof cancelAnimationFrame&&(cancelAnimationFrame(G.current),G.current=null),null!=J.current&&(window.clearTimeout(J.current),J.current=null),null!=Q.current&&"function"==typeof window.cancelIdleCallback&&(window.cancelIdleCallback(Q.current),Q.current=null),ee.current=!1,ne.current=null},[]),fe=d(e=>{var n;if(!D)return;const r=Math.max(2,null!=(n=t.renderBatchBudgetMs)?n:6),o=Math.max(1,M||1),i=Math.max(1,Math.floor(o/4));e>1.2*r?te.current=Math.max(i,Math.floor(.7*te.current)):e<.5*r&&te.current<o&&(te.current=Math.min(o,Math.ceil(1.2*te.current)))},[D,t.renderBatchBudgetMs,M]),pe=d((e,n={})=>{var r,o;if(!D)return;const i=re.current;if(R.current>=i)return;const l=Math.max(1,e),a=e=>{const n="undefined"!=typeof performance?performance.now():Date.now();A(n=>{const t=Math.min(re.current,n+Math.max(1,e));return R.current=t,t});const t="undefined"!=typeof performance?performance.now():Date.now();fe(t-n)},c=()=>{const e=Math.max(1,Math.round(te.current));pe(e)},s=e=>{var n;G.current=null,J.current=null,Q.current=null,ee.current=!1;const r=ne.current;if(ne.current=null,a(null!=r?r:l),R.current>=re.current)return;if(!e)return void c();const o=Math.max(2,null!=(n=t.renderBatchBudgetMs)?n:6);for(;R.current<re.current&&!(("function"==typeof e.timeRemaining?e.timeRemaining():0)<=.5*o);)a(Math.max(1,Math.round(te.current)));R.current<re.current&&c()};if(!b||n.immediate)return void s();const d=Math.max(0,null!=(r=t.renderBatchDelay)?r:16);if(ne.current=null!=ne.current?Math.max(ne.current,l):l,!ee.current){if(ee.current=!0,C){const e=Math.max(0,null!=(o=t.renderBatchIdleTimeoutMs)?o:120);return void(Q.current=window.requestIdleCallback(e=>s(e),{timeout:e}))}"function"==typeof requestAnimationFrame?G.current=requestAnimationFrame(()=>{0!==d?J.current=window.setTimeout(()=>s(),d):s()}):J.current=window.setTimeout(()=>s(),d)}},[fe,C,D,b,t.renderBatchDelay,t.renderBatchBudgetMs,t.renderBatchIdleTimeoutMs]);s(()=>{var e;const n=t.indexKey,o=r.length,i=oe.current,l=void 0!==n?n!==i.key:o!==i.total;oe.current={key:n,total:o};const a=ie.current,c=null!=(e=t.renderBatchDelay)?e:16,s=a.batchSize!==M||a.initial!==N||a.delay!==c||a.enabled!==D;if(ie.current={batchSize:M,initial:N,delay:c,enabled:D},(l||s||!D)&&he(),(l||s)&&(te.current=Math.max(1,M||1),Y.current.clear()),!o)return R.current=0,void A(0);const d=re.current;if(!D)return R.current=d,void A(d);if(l||s){const e=Math.min(d,N);return R.current=e,A(e),void(e<d&&pe(Math.max(1,N),{immediate:!b}))}const u=Math.min(R.current,d);u!==R.current&&(R.current=u,A(u)),R.current<d&&pe(Math.max(1,M||1))},[he,D,b,r.length,t.indexKey,t.renderBatchDelay,M,N,pe]),s(()=>{if(!L)return void _({start:0,end:r.length});const e=r.length;if(!e)return void _({start:0,end:0});const n=Math.max(0,Math.min(F,e-1));let t=Math.max(0,n-S),o=Math.min(e,n+S+1);const i=o-t;if(i>T){const e=i-T;t+=Math.ceil(e/2),o-=Math.floor(e/2)}else if(i<T){const n=T-i;t=Math.max(0,t-Math.ceil(n/2)),o=Math.min(e,o+Math.floor(n/2))}_({start:t,end:o})},[F,S,T,r.length,L]),s(()=>()=>{he();for(const e of K.current.values())e.destroy();K.current.clear()},[he]);const ge=d(e=>{for(const[n,t]of K.current.entries())n>=e&&(t.destroy(),K.current.delete(n),delete V.current[n],X.current.delete(n),q.current.delete(n),U.current.delete(n))},[]);s(()=>{ge(H)},[ge,H]),s(()=>{const e=r.length;let n=!1;for(const t of Array.from(O.current.keys()))t>=e&&(O.current.delete(t),n=!0);n&&z(e=>e+1);for(const t of Object.keys(V.current))Number(t)>=e&&delete V.current[t];for(const t of Array.from(Y.current))t>=e&&Y.current.delete(t)},[r.length]);const ve=d((e,n)=>{$&&n&&(V.current[e]=!0),n&&L&&W(n=>e>n?e:n)},[$,L]),we=d(e=>{const n=K.current.get(e);n&&(n.destroy(),K.current.delete(e))},[]),ye=d((e,n)=>{const t=X.current;if(n?t.set(e,n):t.delete(e),!le||!n)return we(e),$&&!n&&delete V.current[e],void(n&&ve(e,!0));if(e<N&&!L)return we(e),void ve(e,!0);we(e);const r=k(n,{rootMargin:"400px"});K.current.set(e,r),r.isVisible()&&ve(e,!0),r.whenVisible.then(()=>ve(e,!0)).catch(()=>{})},[$,we,ve,k,N,le,L]),xe=d(e=>{const n=q.current.get(e);if(n)return n;const t=n=>ye(e,n);return q.current.set(e,t),t},[ye]),ke=d((e,n)=>{if(!n)return void(O.current.has(e)&&(O.current.delete(e),z(e=>e+1)));const t=()=>{const t=n.offsetHeight;t&&O.current.get(e)!==t&&(O.current.set(e,t),z(e=>e+1))};"function"==typeof queueMicrotask?queueMicrotask(t):Promise.resolve().then(t)},[]),be=d(e=>{const n=U.current.get(e);if(n)return n;const t=n=>ke(e,n);return U.current.set(e,t),t},[ke]),Ce=d(e=>!(D&&e>=R.current)&&(!$||e<N||!0===V.current[e]),[$,D,N]),Me=d(e=>n=>{if(!e)return;const t=n.target;(null==t?void 0:t.closest("[data-node-index]"))&&e(n)},[]);s(()=>{for(const[e,n]of X.current.entries())n&&ye(e,n)},[ye]),s(()=>{L&&P>Z.current&&W(P-1),Z.current=P},[P,L]);const Ne=L?/* @__PURE__ */n("div",{className:"node-spacer",style:{height:`${ue}px`},"aria-hidden":"true"}):null,Be=L?/* @__PURE__ */n("div",{className:"node-spacer",style:{height:`${me}px`},"aria-hidden":"true"}):null;/* @__PURE__ */
185
- return e("div",{ref:u,className:`markstream-react markdown-renderer${t.isDark?" dark":""}${L?" virtualized":""}`,"data-custom-id":t.customId,onClick:t.onClick,onMouseOver:Me(t.onMouseOver),onMouseOut:Me(t.onMouseOut),children:[Ne,ce.map(({node:e,index:r})=>{var o;const i=Ce(r),c=null!=(o=O.current.get(r))?o:ae,s=!1!==t.fade&&"code_block"!==e.type&&!Y.current.has(r)&&i;return s&&Y.current.add(r),/* @__PURE__ */n("div",{ref:xe(r),className:"node-slot","data-node-index":r,"data-node-type":e.type,children:/* @__PURE__ */n("div",i?{ref:be(r),className:"node-content"+(s?" fade-node typewriter-node":""),children:/* @__PURE__ */n(to,{node:e,nodeKey:`${a}-${r}`,renderCtx:l})}:{className:"node-placeholder",style:{height:`${c}px`}})},`${a}-${r}`)}),Be,m&&/* @__PURE__ */n("span",{ref:h,className:"typewriter-cursor","aria-hidden":"true"})]})},function(e,n){if(e.renderCtx!==n.renderCtx)return!1;if(e.indexPrefix!==n.indexPrefix)return!1;if(e.containerRef!==n.containerRef)return!1;if(e.showTypewriterCursor!==n.showTypewriterCursor)return!1;const t=e.parsedNodes,r=n.parsedNodes;if(t===r)return!0;if(t.length!==r.length)return!1;for(let l=0;l<t.length;l++)if(t[l]!==r[l])return!1;const o=e.props,i=n.props;return o.isDark===i.isDark&&o.typewriter===i.typewriter&&o.fade===i.fade&&o.batchRendering===i.batchRendering&&o.initialRenderBatchSize===i.initialRenderBatchSize&&o.renderBatchSize===i.renderBatchSize&&o.renderBatchDelay===i.renderBatchDelay&&o.renderBatchBudgetMs===i.renderBatchBudgetMs&&o.renderBatchIdleTimeoutMs===i.renderBatchIdleTimeoutMs&&o.deferNodesUntilVisible===i.deferNodesUntilVisible&&o.maxLiveNodes===i.maxLiveNodes&&o.liveNodeBuffer===i.liveNodeBuffer&&o.viewportPriority===i.viewportPriority&&o.indexKey===i.indexKey&&o.onClick===i.onClick&&o.onMouseOver===i.onMouseOver&&o.onMouseOut===i.onMouseOut});function oo(e){var t,l;const a={...Jr,...e},m=c(null),h=c(null),f=c(/* @__PURE__ */new Map),p=c(0),g=c(null),v=Re(a.smoothStreamingOptions),w=r.useContext(Se),y=c(/* @__PURE__ */new Set),[x,k]=i(()=>!0===a.smoothStreaming);s(()=>{k(!0)},[]);const b=Array.isArray(a.nodes)&&a.nodes.length>0,C=o(()=>{var e;return!1!==a.smoothStreaming&&!b&&(!0===a.smoothStreaming||!w)&&(!0===a.smoothStreaming||!0===a.typewriter||(null!=(e=a.maxLiveNodes)?e:0)<=0)},[b,w,a.maxLiveNodes,a.smoothStreaming,a.typewriter]),M=x&&C,N=M?v.visible:null!=(t=a.content)?t:"",B=o(()=>{var e,n;const t=null!=(e=a.parseOptions)?e:{};return null!=(n=a.final)?n:t.final},[a.final,a.parseOptions]),S=null!=(l=a.content)?l:"",T=b||v.source===S,$=o(()=>M&&null!=B?Boolean(B&&T&&v.caughtUp):B,[B,T,v.caughtUp,M]),A=c(null),[R,H]=i(!1),F=c(void 0),W=c(0),I=o(()=>/* @__PURE__ */new Set(["code_block","admonition","table","math_block","html_block","image"]),[]),_=d(e=>{if(!e||"object"!=typeof e)return!1;const n=e.type;return"string"==typeof n&&I.has(n)},[I]),O=d(e=>{var n,t;if(!e||"object"!=typeof e)return 0;const r=e,o=null!=(t=null!=(n=r.raw)?n:r.content)?t:r.code;if("string"==typeof o)return o.length;const i=r.children;if(Array.isArray(i))return i.reduce((e,n)=>e+O(n),0);const l=r.items;return Array.isArray(l)?l.reduce((e,n)=>e+O(n),0):0},[]),j=d(()=>{var e,n;return(null==(e=a.nodes)?void 0:e.length)?a.nodes.reduce((e,n)=>e+O(n),0):(null!=(n=a.content)?n:"").length},[a.nodes,a.content,O]),X=d(()=>{F.current&&(clearTimeout(F.current),F.current=void 0)},[]),q=d(e=>{const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){var n;if(!(null!=(n=e.textContent)?n:"").trim())return NodeFilter.FILTER_REJECT;const t=e.parentElement;return t?t.closest('.typewriter-cursor, .height-estimation-probes, [data-node-type="code_block"], [data-node-type="admonition"], [data-node-type="table"], [data-node-type="math_block"], [data-node-type="html_block"], [data-node-type="image"], script, style')?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});let t=null,r=n.nextNode();for(;r;)t=r,r=n.nextNode();return t},[]),U=d(()=>{var e,n;if("undefined"==typeof window||!R||!m.current||!A.current)return;const t=m.current,r=A.current,o=q(t),i=t.getBoundingClientRect();let l=0,a=0,c=20;if(null==o?void 0:o.textContent){const r=document.createRange(),s=o.textContent.length;r.setStart(o,Math.max(0,s-1)),r.setEnd(o,s);const d="function"==typeof r.getClientRects?r.getClientRects():void 0,u=null!=(n=null==d?void 0:d[d.length-1])?n:null==(e=o.parentElement)?void 0:e.getBoundingClientRect();u&&(l=u.right-i.left+t.scrollLeft,a=u.top-i.top+t.scrollTop,c=u.height||c),r.detach()}r.style.transform=`translate(${Math.max(0,l)}px, ${Math.max(0,a)}px)`,r.style.height=`${c}px`},[R,m,q]);s(()=>{R&&requestAnimationFrame(()=>{U()})},[R,U]),s(()=>()=>{X()},[X]);const Y=b?a.nodes:N;g.current!==Y&&(p.current+=1,g.current=Y);const Z=u(z,V,V),G=o(()=>K(a.customId),[a.customId,Z]),J=no(a.streamingComponents),Q=no(a.htmlComponents);s(()=>{ue(J,Q,y.current)},[Q,J]);const ee=o(()=>a.customId?`renderer-${a.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,[a.customId]),ne=o(()=>{var e,n;const t=null!=(n=(null!=(e=a.parseOptions)?e:{}).customHtmlTags)?n:[];return L(a.customHtmlTags,Array.isArray(t)?t:[],Object.keys(J))},[a.customId,a.customHtmlTags,a.parseOptions,Z,J]),te=o(()=>{const e=ne;return e&&0!==e.length?E(ee,{customHtmlTags:e}):E(ee)},[ee,ne]),re=o(()=>{const e=te;return a.customMarkdownIt?a.customMarkdownIt(e):e},[te,a.customMarkdownIt]),oe=o(()=>{var e;const n=null!=(e=a.parseOptions)?e:{},t=$,r=null!=t,o=ne.length>0;return r||o?{...n,...r?{final:t}:{},...o?{customHtmlTags:ne}:{}}:n},[ne,$,a.parseOptions]),ie=o(()=>{const e=Boolean(a.debugPerformance)&&"undefined"!=typeof console&&"undefined"!=typeof performance,n=e?performance.now():0;let t=[];return b?t=a.nodes.map(e=>({...e})):N&&(t=D(N,null!=re?re:Qr,oe)),e&&console.info("[markstream-react][perf] parse(sync)",{ms:Math.round(performance.now()-n),nodes:t.length,contentLength:N.length}),t},[a.debugPerformance,N,b,a.nodes,oe,re,a.customId,Z,ne]),le=d(()=>{const e=ie[ie.length-1];return!_(e)},[ie,_]);s(()=>{if("undefined"==typeof window||b)return;if($)return H(!1),void X();const e=j(),n=le();return!1===a.typewriter||!n||e<=W.current?(!1!==a.typewriter&&n||H(!1),void(W.current=e)):(W.current=e,H(!0),X(),requestAnimationFrame(()=>{U()}),F.current=setTimeout(()=>{H(!1)},3e3),()=>{X()})},[N,a.nodes,a.typewriter,a.content,$,ie.length,b,j,le,X,U]);const ae=c([]),ce=null==oe?void 0:oe.postTransformNodes,se=c(ce);se.current!==ce&&(ae.current=[],se.current=ce);const de=function(e,n){if(!n.length)return e;const t=new Array(e.length);let r=e.length===n.length;for(let o=0;o<e.length;o++){const i=o<n.length?n[o]:null;i&&eo(i,e[o])?t[o]=i:(t[o]=e[o],r=!1)}return r?n:t}(ie,ae.current);ae.current=de,s(()=>{var e;if(b)return void v.reset("");const n=null!=(e=a.content)?e:"";if(!M)return v.reset(n),void(B&&v.finish({flush:!0}));const t=v.getSnapshot().source;n?n===t||(n.startsWith(t)?v.enqueue(n.slice(t.length)):v.reset(n)):v.reset(""),B&&v.finish()},[b,a.content,B,M]),s(()=>{var e,n;if("undefined"==typeof window)return;if(a.renderCodeBlocksAsPre)return;if(!de.some(e=>{var n;return"code_block"===(null==e?void 0:e.type)&&"mermaid"!==P(String(null!=(n=null==e?void 0:e.language)?n:""))}))return;const t=null!=(e=window.requestIdleCallback)?e:(e,n)=>{var t;return window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),null!=(t=null==n?void 0:n.timeout)?t:600)},r=null!=(n=window.cancelIdleCallback)?n:e=>window.clearTimeout(e),o=t(()=>{rn()},{timeout:900});return()=>r(o)},[de,a.renderCodeBlocksAsPre]),s(()=>{if("undefined"==typeof window)return;if(a.renderCodeBlocksAsPre)return;const e=a.isDark?a.codeBlockDarkTheme:a.codeBlockLightTheme,n="string"==typeof e?e:"object"==typeof e&&e&&"name"in e?String(e.name):null;n&&h.current!==n&&(h.current=n,function(e){if(null==e)return;const n=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&e&&"name"in e)return String(e.name);if("object"==typeof e){const n=yn.get(e);if(n)return n;try{const n=JSON.stringify(e);if(n)return yn.set(e,n),n}catch{}const t="__theme_"+ ++xn;return yn.set(e,t),t}return String(e)}(e);n&&gn!==n&&(pn=e,gn=n,vn&&fn(pn,vn).then(()=>kn()).catch(()=>{}))}(e))},[a.codeBlockDarkTheme,a.codeBlockLightTheme,a.isDark,a.renderCodeBlocksAsPre]);const me=o(()=>null!=a.indexKey?String(a.indexKey):"markdown-renderer",[a.indexKey]),he=o(()=>({..."boolean"==typeof a.showTooltips?{showTooltips:a.showTooltips}:{},...a.codeBlockProps||{}}),[a.codeBlockProps,a.showTooltips]),fe=o(()=>({...a.mermaidProps||{}}),[a.mermaidProps]),pe=o(()=>({...a.d2Props||{}}),[a.d2Props]),ge=o(()=>({...a.infographicProps||{}}),[a.infographicProps]),ve=o(()=>{var e;return{customId:a.customId,isDark:a.isDark,final:$,indexKey:me,typewriter:a.typewriter,fade:a.fade,textStreamState:f.current,streamRenderVersion:p.current,customComponents:G,streamingComponents:J,htmlComponents:Q,customHtmlTags:ne,htmlPolicy:null!=(e=a.htmlPolicy)?e:"safe",showTooltips:a.showTooltips,renderCodeBlocksAsPre:a.renderCodeBlocksAsPre,codeBlockStream:a.codeBlockStream,codeBlockProps:he,mermaidProps:fe,d2Props:pe,infographicProps:ge,codeBlockThemes:{themes:a.themes,darkTheme:a.codeBlockDarkTheme,lightTheme:a.codeBlockLightTheme,langs:a.langs,monacoOptions:a.codeBlockMonacoOptions,minWidth:a.codeBlockMinWidth,maxWidth:a.codeBlockMaxWidth},events:{onCopy:a.onCopy,onHandleArtifactClick:a.onHandleArtifactClick}}},[a.customId,a.isDark,$,me,a.typewriter,a.fade,a.showTooltips,a.htmlPolicy,a.renderCodeBlocksAsPre,a.codeBlockStream,ne,he,fe,pe,ge,a.themes,a.codeBlockDarkTheme,a.codeBlockLightTheme,a.langs,a.codeBlockMonacoOptions,a.codeBlockMinWidth,a.codeBlockMaxWidth,a.onCopy,a.onHandleArtifactClick,G,J,Q]);ve.streamRenderVersion=p.current,ve.textStreamState=f.current;const we=c(null);return we.current||(we.current={textStreamState:f.current,getStreamRenderVersion:()=>p.current}),/* @__PURE__ */n(Te.Provider,{value:we.current,children:/* @__PURE__ */n(Se.Provider,{value:M,children:/* @__PURE__ */n(Pe,{getRoot:()=>m.current,enabled:!1!==a.viewportPriority,children:/* @__PURE__ */n(ro,{props:a,parsedNodes:de,renderCtx:ve,indexPrefix:me,containerRef:m,showTypewriterCursor:R,typewriterCursorRef:A})})})})}function io(e){var t,r,o,i,l,a;const{node:c,ctx:s,renderNode:d,indexKey:u,children:m}=e;/* @__PURE__ */
186
- return n("blockquote",{className:"blockquote-node",dir:"auto",cite:c.cite,children:null!=m?m:s&&d?/* @__PURE__ */n(oo,{nodes:c.children||[],indexKey:`blockquote-${String(null!=u?u:"blockquote")}`,customId:s.customId,isDark:s.isDark,typewriter:s.typewriter,viewportPriority:!0,codeBlockStream:s.codeBlockStream,renderCodeBlocksAsPre:s.renderCodeBlocksAsPre,codeBlockProps:s.codeBlockProps,themes:null==(t=s.codeBlockThemes)?void 0:t.themes,codeBlockDarkTheme:null==(r=s.codeBlockThemes)?void 0:r.darkTheme,codeBlockLightTheme:null==(o=s.codeBlockThemes)?void 0:o.lightTheme,codeBlockMonacoOptions:null==(i=s.codeBlockThemes)?void 0:i.monacoOptions,codeBlockMinWidth:null==(l=s.codeBlockThemes)?void 0:l.minWidth,codeBlockMaxWidth:null==(a=s.codeBlockThemes)?void 0:a.maxWidth,htmlPolicy:s.htmlPolicy,showTooltips:s.showTooltips,onCopy:s.events.onCopy,onHandleArtifactClick:s.events.onHandleArtifactClick}):null})}const lo=he();function ao(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function co(r){const l={loading:!0,stream:!0,darkTheme:"vitesse-dark",lightTheme:"vitesse-light",isDark:!1,isShowPreview:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0,...r},a=o(()=>{var e;return String(null!=(e=l.node.language)?e:"")},[l.node.language]),u=o(()=>P(a),[a]),[m,h]=i(0);s(()=>R(()=>{h(e=>e+1)}),[]);const f=o(()=>{const e=_[u]||u;return e?e.charAt(0).toUpperCase()+e.slice(1):"Text"},[u]),p=o(()=>I(u),[u,m]),{t:g}=Ie(),v=o(()=>!!l.isShowPreview&&("html"===u||"svg"===u),[u,l.isShowPreview]),w=o(()=>{const e={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t=n(l.minWidth),r=n(l.maxWidth);return t&&(e.minWidth=t),r&&(e.maxWidth=r),e},[l.maxWidth,l.minWidth]),[y,x]=i(!1),[k,b]=i(!1),[C,M]=i(!1),[N,B]=i(()=>l.node.code?`<pre class="shiki shiki-fallback"><code>${ao(l.node.code)}</code></pre>`:""),[S,T]=i(!1),[L,E]=i(14),[D,$]=i(L),A=o(()=>!1!==l.showTooltips,[l.showTooltips]),H=ge(l.themes,l.langs),F=c(null);F.current&&F.current.key===H||(F.current={key:H,themes:l.themes,langs:l.langs});const W=c(null),O=c(null),j=c(null),z=c(null),V=c(null),K=c(""),X=c(""),q=c(0),U=c(null),Y=c(null),Z=c(null),G=c(!1),J=c(!1),Q=c(null),ee=c(!1),ne=c(/* @__PURE__ */new Set),te=c(/* @__PURE__ */new Set),re=c(""),oe=c(0),ie=c(H),le=c(0),ae=c(!0),ce=c(null),se=Ae(),[de,ue]=i(()=>"undefined"==typeof window),me=d(()=>l.isDark?l.darkTheme:l.lightTheme,[l.darkTheme,l.isDark,l.lightTheme]),he=d(e=>{null==e||e.disconnect(),e&&z.current!==e||(z.current=null)},[]),fe=d(()=>{j.current&&(j.current.innerHTML="")},[]),ye=d(e=>{if(U.current=null,he(),!e)return fe(),X.current="",B(""),void T(!1);B(`<pre class="shiki shiki-fallback"><code>${ao(e)}</code></pre>`),T(!1)},[fe,he]),xe=d(()=>{he(),B(""),T(!0)},[he]),ke=d(e=>{X.current=e,xe()},[xe]),be=d(()=>{var e;const n=j.current;return!!n&&(n.childNodes.length>0||Boolean(null==(e=n.textContent)?void 0:e.trim().length))},[]),Ce=d((e=!0)=>{const n=V.current;he(),V.current=null,K.current="",X.current="",U.current=null,ne.current.clear();try{null==n||n.dispose()}catch(t){lo&&"undefined"!=typeof console&&console.warn("[MarkdownCodeBlockNode] Failed to dispose Shiki renderer.",t)}finally{fe(),e&&T(!1)}},[fe,he]),Me=d(()=>(le.current+=1,le.current),[]),Ne=d(e=>ae.current&&le.current===e,[]),Be=d((e,n)=>{he();const t=j.current;if(!t||"undefined"==typeof MutationObserver)return;U.current=null;const r=new MutationObserver(()=>{q.current+=1;const t=U.current;if(t)return Ne(e)?void(q.current!==n&&be()&&(U.current=null,he(r),ke(t))):(U.current=null,void he(r))});z.current=r,r.observe(t,{childList:!0,subtree:!0,characterData:!0,attributes:!0})},[he,be,Ne,ke]),Se=d(async(e,n,t,r)=>{var o;if(U.current=t,await Promise.resolve(),!Ne(e))return;const i=be(),l=q.current!==n,a=void 0!==r&&(null==(o=j.current)?void 0:o.innerHTML)!==r;i&&(!X.current||l||a||X.current===t)&&(U.current=null,he(),ke(t))},[he,be,Ne,ke]),Te=d(async()=>{if(!Y.current&&!G.current)return Z.current||(Z.current=(async()=>{try{const e=await import("stream-markdown"),n=e.createShikiStreamRenderer;if("function"!=typeof n)throw new TypeError("stream-markdown.createShikiStreamRenderer is not available");Y.current=n;const t=e.registerHighlight;Q.current="function"==typeof t?t:null,G.current=!1,J.current=!1}catch(e){G.current=!0,lo&&!J.current&&"undefined"!=typeof console&&(J.current=!0,console.warn("[MarkdownCodeBlockNode] stream-markdown not available:",e))}finally{Z.current=null}})()),Z.current},[]),Le=d(async e=>{const n=e.key;if(ie.current!==n)return"stale";if(!Q.current)return"ready";if(re.current===n)return"ready";const t=++oe.current;try{await ve(Q.current,e.registerOptions,n)}catch{return t!==oe.current||ie.current!==n?"stale":"failed"}return t!==oe.current||ie.current!==n?"stale":(re.current=n,"ready")},[]),Ee=d(async e=>{const n=await Le(e);return"failed"!==n?n:ie.current!==e.key?"stale":Le(e)},[Le]),De=d(e=>{var n;const t={hasRegisterHighlight:Boolean(Q.current),hasCreateRenderer:Boolean(Y.current)},r=we(null==e?void 0:e.themes,null==e?void 0:e.langs,t),o=(null==(n=r.rendererOptions.langs)?void 0:n.length)&&te.current.has(r.key)?we(null==e?void 0:e.themes,void 0,t):r;return r.ignoredLangs&&lo&&!ee.current&&"undefined"!=typeof console&&(ee.current=!0,console.warn("[MarkdownCodeBlockNode] `langs` requires stream-markdown >=0.0.15 with registerHighlight(); ignoring `langs` and using stream-markdown default language preload.")),{key:o.key,registerOptions:o.registerOptions,rendererOptions:o.rendererOptions}},[]),$e=d(async(e,n,t)=>{const r=V.current;if(!r||!Ne(t))return;const o=function(e){return pe(e)||"plaintext"}(n),i=async n=>{const r=V.current;if(r&&Ne(t)){n&&"plaintext"!==o&&ne.current.add(o);try{return await r.updateCode(e,"plaintext"),Ne(t)?"plaintext":void 0}catch{return}}};if("plaintext"!==o&&ne.current.has(o))return i();try{return await r.updateCode(e,o),Ne(t)?o:void 0}catch(l){if(!Ne(t)||"plaintext"===o)return;return i(l)}},[Ne]),Pe=d(async()=>{var e,n;const t=Me(),r=l.node.code,o=l.node.language,i=F.current;if(!de)return void ye(r);if(await Te(),!Ne(t))return;let a=De(i),c=a.key;ie.current=c;let s=Boolean(V.current&&K.current!==c);s&&ye(r);let d=await Ee(a);if("failed"===d&&(null==(e=a.rendererOptions.langs)?void 0:e.length)&&(te.current.add(a.key),lo&&"undefined"!=typeof console&&console.warn("[MarkdownCodeBlockNode] Failed to register configured Shiki languages; retrying without `langs`.",{langs:a.rendererOptions.langs}),a=De({themes:null==i?void 0:i.themes,langs:void 0}),c=a.key,ie.current=c,d=await Ee(a)),!Ne(t)||"stale"===d)return;if(s=Boolean(V.current&&K.current!==c),"failed"===d)return void(s&&V.current&&be()?xe():ye(r));if(s&&Ce(),!O.current||!j.current)return void ye(r);if(!V.current&&Y.current&&(V.current=Y.current(j.current,{theme:me(),themes:a.rendererOptions.themes,langs:a.rendererOptions.langs}),K.current=c,T(!0)),!V.current)return void ye(r);if(!1===l.stream&&l.loading)return void ye(r);ye(r);const u=q.current,m=null==(n=j.current)?void 0:n.innerHTML;Be(t,u);const h=await $e(r,o,t);Ne(t)&&(h?await Se(t,u,function(e,n,t){return`${null!=e?e:""}\0${n}\0${t}`}(c,h,r),m):(U.current=null,he()))},[Me,l.node.code,l.node.language,l.stream,l.loading,H,de,Te,De,Ee,Ce,xe,me,be,ye,Be,$e,Se,he,Ne]);s(()=>{const e=W.current;if(!e)return;let n=!0;const t=se(e,{rootMargin:"400px"});return ce.current=t,t.isVisible()&&ue(!0),t.whenVisible.then(()=>{n&&ue(!0)}),()=>{n=!1,t.destroy(),ce.current=null}},[se]),s(()=>{Pe().catch(()=>{ae.current&&j.current&&ye(l.node.code)})},[Pe,l.node.code,ye]),s(()=>(ae.current=!0,()=>{ae.current=!1,le.current+=1,Ce(!1)}),[Ce]),s(()=>{V.current&&de&&V.current.setTheme(me())},[me,de]),s(()=>{A||Ye(!0)},[A]);const Re=d((e,n)=>{if(!A)return;const t=e.currentTarget;t&&!t.disabled&&("clientX"in e&&(e.clientX,e.clientY),Ue(t,n,"top",!1,0,l.isDark))},[l.isDark,A]),He=d(()=>{A&&Ye()},[A]),Fe=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(l.node.code),x(!0),null==(e=l.onCopy)||e.call(l,l.node.code),setTimeout(()=>x(!1),1e3)}catch{}},[l]),We=d(()=>{var e;if(!v)return;const n="html"===u?"text/html":"image/svg+xml",t="html"===u?"HTML Preview":"SVG Preview";null==(e=l.onPreviewCode)||e.call(l,{type:n,content:l.node.code,title:t})},[u,v,l]),_e=o(()=>({fontSize:`${D}px`}),[D]);return s(()=>{E(14),$(14)},[]),/* @__PURE__ */e("div",{ref:W,className:["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",l.isDark?"border-gray-700/30 bg-gray-900 is-dark":"border-gray-200 bg-white"].join(" "),style:w,children:[l.showHeader&&/* @__PURE__ */e("div",{className:"code-block-header",children:[
178
+ return n(Un,{node:e,typewriter:o.typewriter,fade:o.fade},t);case"thematic_break":/* @__PURE__ */
179
+ return n(Yr,{},t);case"math_inline":/* @__PURE__ */
180
+ return n(tr,{node:e},t);case"math_block":/* @__PURE__ */
181
+ return n(nr,{node:e},t);case"reference":/* @__PURE__ */
182
+ return n(zr,{node:e,ctx:o,typewriter:o.typewriter,fade:o.fade},t);case"html_block":case"html_inline":return"html_block"===e.type?/* @__PURE__ */n(tt,{node:e,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade,customId:o.customId},t):/* @__PURE__ */n(ht,{node:e,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade,customId:o.customId},t);case"vmr_container":/* @__PURE__ */
183
+ return n(Zr,{node:e,ctx:o,renderNode:Qr,indexKey:t,typewriter:o.typewriter,fade:o.fade},t);case"label_open":case"label_close":return null;default:/* @__PURE__ */
184
+ return n(Ir,{node:e},t)}}const eo={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},no=E();function to(e,n){return e.type===n.type&&e.raw===n.raw&&e.loading===n.loading&&e.autoClosed===n.autoClosed&&!!function(e,n){if(e===n)return!0;if(!e||!n||"object"!=typeof e||"object"!=typeof n)return!1;const t=e,r=n;return t.startLine===r.startLine&&t.endLine===r.endLine}(e.sourceMap,n.sourceMap)&&("code_block"!==e.type&&"code_block"!==n.type||e.diff===n.diff)}function ro(e){const n=o(()=>me(e),[e]),t=c(n);return function(e,n){const t=Object.keys(e),r=Object.keys(n);return t.length===r.length&&t.every(t=>e[t]===n[t])}(t.current,n)||(t.current=n),t.current}const oo=r.memo(({node:e,nodeKey:n,renderCtx:t})=>Qr(e,n,t),(e,n)=>e.node===n.node&&e.renderCtx===n.renderCtx&&e.nodeKey===n.nodeKey),io=r.memo(({props:t,parsedNodes:r,renderCtx:l,indexPrefix:a,containerRef:u,showTypewriterCursor:m,typewriterCursorRef:h})=>{var f,p,g,v,w,y,x;const k=Ae(),b="undefined"!=typeof window,C="undefined"!=typeof window&&"function"==typeof window.requestIdleCallback,M=Math.max(0,Math.trunc(null!=(f=t.renderBatchSize)?f:80)),N=Math.max(0,Math.trunc(null!=(p=t.initialRenderBatchSize)?p:M||r.length)),B=!1!==t.batchRendering&&M>0&&b,S=Math.max(0,null!=(g=t.liveNodeBuffer)?g:60),T=Math.max(1,null!=(v=t.maxLiveNodes)?v:320),L=(null!=(w=t.maxLiveNodes)?w:0)>0&&r.length>T,E=!1!==t.viewportPriority,$=B&&(null!=(y=t.maxLiveNodes)?y:0)<=0,D=o(()=>{var e;return!1!==t.deferNodesUntilVisible&&!((null!=(e=t.maxLiveNodes)?e:0)<=0)&&!L&&!(r.length>900)&&E},[r.length,t.deferNodesUntilVisible,t.maxLiveNodes,E,L]),[P,A]=i(()=>$?Math.min(r.length,N):r.length),R=c(P);s(()=>{R.current=P},[P]);const H=$?P:r.length,[W,F]=i(0),[I,_]=i({start:0,end:r.length}),O=c(/* @__PURE__ */new Map),[j,z]=i(0),V=c({}),K=c(/* @__PURE__ */new Map),X=c(/* @__PURE__ */new Map),q=c(/* @__PURE__ */new Map),U=c(/* @__PURE__ */new Map),Y=c(/* @__PURE__ */new Set),Z=c(P),G=c(null),J=c(null),Q=c(null),ee=c(!1),ne=c(null),te=c(Math.max(1,M||1)),re=c(r.length),oe=c({key:t.indexKey,total:r.length}),ie=c({batchSize:M,initial:N,delay:null!=(x=t.renderBatchDelay)?x:16,enabled:$}),le=D||L,ae=o(()=>{const e=O.current;if(!e.size)return 32;let n=0;for(const t of e.values())n+=t;return Math.max(16,n/e.size)},[j]),ce=o(()=>{if(!L)return r.map((e,n)=>({node:e,index:n}));const e=r.length,n=Math.max(0,Math.min(I.start,e)),t=Math.max(n,Math.min(I.end,e));return r.slice(n,t).map((e,t)=>({node:e,index:n+t}))},[r,I,L]),se=o(()=>{if(!L)return r.length;const e=Math.max(I.end+S,N),n=Math.min(r.length,e);return Math.max(P,n)},[r.length,L,I.end,S,N,P]);re.current=se;const de=d((e,n)=>{var t;if(e>=n)return 0;const r=O.current;let o=0;for(let i=e;i<n;i++)o+=null!=(t=r.get(i))?t:ae;return o},[ae]),ue=L?de(0,Math.min(I.start,r.length)):0,me=L?de(Math.min(I.end,r.length),r.length):0,he=d(()=>{null!=G.current&&"function"==typeof cancelAnimationFrame&&(cancelAnimationFrame(G.current),G.current=null),null!=J.current&&(window.clearTimeout(J.current),J.current=null),null!=Q.current&&"function"==typeof window.cancelIdleCallback&&(window.cancelIdleCallback(Q.current),Q.current=null),ee.current=!1,ne.current=null},[]),fe=d(e=>{var n;if(!$)return;const r=Math.max(2,null!=(n=t.renderBatchBudgetMs)?n:6),o=Math.max(1,M||1),i=Math.max(1,Math.floor(o/4));e>1.2*r?te.current=Math.max(i,Math.floor(.7*te.current)):e<.5*r&&te.current<o&&(te.current=Math.min(o,Math.ceil(1.2*te.current)))},[$,t.renderBatchBudgetMs,M]),pe=d((e,n={})=>{var r,o;if(!$)return;const i=re.current;if(R.current>=i)return;const l=Math.max(1,e),a=e=>{const n="undefined"!=typeof performance?performance.now():Date.now();A(n=>{const t=Math.min(re.current,n+Math.max(1,e));return R.current=t,t});const t="undefined"!=typeof performance?performance.now():Date.now();fe(t-n)},c=()=>{const e=Math.max(1,Math.round(te.current));pe(e)},s=e=>{var n;G.current=null,J.current=null,Q.current=null,ee.current=!1;const r=ne.current;if(ne.current=null,a(null!=r?r:l),R.current>=re.current)return;if(!e)return void c();const o=Math.max(2,null!=(n=t.renderBatchBudgetMs)?n:6);for(;R.current<re.current&&!(("function"==typeof e.timeRemaining?e.timeRemaining():0)<=.5*o);)a(Math.max(1,Math.round(te.current)));R.current<re.current&&c()};if(!b||n.immediate)return void s();const d=Math.max(0,null!=(r=t.renderBatchDelay)?r:16);if(ne.current=null!=ne.current?Math.max(ne.current,l):l,!ee.current){if(ee.current=!0,C){const e=Math.max(0,null!=(o=t.renderBatchIdleTimeoutMs)?o:120);return void(Q.current=window.requestIdleCallback(e=>s(e),{timeout:e}))}"function"==typeof requestAnimationFrame?G.current=requestAnimationFrame(()=>{0!==d?J.current=window.setTimeout(()=>s(),d):s()}):J.current=window.setTimeout(()=>s(),d)}},[fe,C,$,b,t.renderBatchDelay,t.renderBatchBudgetMs,t.renderBatchIdleTimeoutMs]);s(()=>{var e;const n=t.indexKey,o=r.length,i=oe.current,l=void 0!==n?n!==i.key:o!==i.total;oe.current={key:n,total:o};const a=ie.current,c=null!=(e=t.renderBatchDelay)?e:16,s=a.batchSize!==M||a.initial!==N||a.delay!==c||a.enabled!==$;if(ie.current={batchSize:M,initial:N,delay:c,enabled:$},(l||s||!$)&&he(),(l||s)&&(te.current=Math.max(1,M||1),Y.current.clear()),!o)return R.current=0,void A(0);const d=re.current;if(!$)return R.current=d,void A(d);if(l||s){const e=Math.min(d,N);return R.current=e,A(e),void(e<d&&pe(Math.max(1,N),{immediate:!b}))}const u=Math.min(R.current,d);u!==R.current&&(R.current=u,A(u)),R.current<d&&pe(Math.max(1,M||1))},[he,$,b,r.length,t.indexKey,t.renderBatchDelay,M,N,pe]),s(()=>{if(!L)return void _({start:0,end:r.length});const e=r.length;if(!e)return void _({start:0,end:0});const n=Math.max(0,Math.min(W,e-1));let t=Math.max(0,n-S),o=Math.min(e,n+S+1);const i=o-t;if(i>T){const e=i-T;t+=Math.ceil(e/2),o-=Math.floor(e/2)}else if(i<T){const n=T-i;t=Math.max(0,t-Math.ceil(n/2)),o=Math.min(e,o+Math.floor(n/2))}_({start:t,end:o})},[W,S,T,r.length,L]),s(()=>()=>{he();for(const e of K.current.values())e.destroy();K.current.clear()},[he]);const ge=d(e=>{for(const[n,t]of K.current.entries())n>=e&&(t.destroy(),K.current.delete(n),delete V.current[n],X.current.delete(n),q.current.delete(n),U.current.delete(n))},[]);s(()=>{ge(H)},[ge,H]),s(()=>{const e=r.length;let n=!1;for(const t of Array.from(O.current.keys()))t>=e&&(O.current.delete(t),n=!0);n&&z(e=>e+1);for(const t of Object.keys(V.current))Number(t)>=e&&delete V.current[t];for(const t of Array.from(Y.current))t>=e&&Y.current.delete(t)},[r.length]);const ve=d((e,n)=>{D&&n&&(V.current[e]=!0),n&&L&&F(n=>e>n?e:n)},[D,L]),we=d(e=>{const n=K.current.get(e);n&&(n.destroy(),K.current.delete(e))},[]),ye=d((e,n)=>{const t=X.current;if(n?t.set(e,n):t.delete(e),!le||!n)return we(e),D&&!n&&delete V.current[e],void(n&&ve(e,!0));if(e<N&&!L)return we(e),void ve(e,!0);we(e);const r=k(n,{rootMargin:"400px"});K.current.set(e,r),r.isVisible()&&ve(e,!0),r.whenVisible.then(()=>ve(e,!0)).catch(()=>{})},[D,we,ve,k,N,le,L]),xe=d(e=>{const n=q.current.get(e);if(n)return n;const t=n=>ye(e,n);return q.current.set(e,t),t},[ye]),ke=d((e,n)=>{if(!n)return void(O.current.has(e)&&(O.current.delete(e),z(e=>e+1)));const t=()=>{const t=n.offsetHeight;t&&O.current.get(e)!==t&&(O.current.set(e,t),z(e=>e+1))};"function"==typeof queueMicrotask?queueMicrotask(t):Promise.resolve().then(t)},[]),be=d(e=>{const n=U.current.get(e);if(n)return n;const t=n=>ke(e,n);return U.current.set(e,t),t},[ke]),Ce=d(e=>!($&&e>=R.current)&&(!D||e<N||!0===V.current[e]),[D,$,N]),Me=d(e=>n=>{if(!e)return;const t=n.target;(null==t?void 0:t.closest("[data-node-index]"))&&e(n)},[]);s(()=>{for(const[e,n]of X.current.entries())n&&ye(e,n)},[ye]),s(()=>{L&&P>Z.current&&F(P-1),Z.current=P},[P,L]);const Ne=L?/* @__PURE__ */n("div",{className:"node-spacer",style:{height:`${ue}px`},"aria-hidden":"true"}):null,Be=L?/* @__PURE__ */n("div",{className:"node-spacer",style:{height:`${me}px`},"aria-hidden":"true"}):null;/* @__PURE__ */
185
+ return e("div",{ref:u,className:`markstream-react markdown-renderer${t.isDark?" dark":""}${L?" virtualized":""}`,"data-custom-id":t.customId,onClick:t.onClick,onMouseOver:Me(t.onMouseOver),onMouseOut:Me(t.onMouseOut),children:[Ne,ce.map(({node:e,index:r})=>{var o;const i=Ce(r),c=null!=(o=O.current.get(r))?o:ae,s=!1!==t.fade&&"code_block"!==e.type&&!Y.current.has(r)&&i;return s&&Y.current.add(r),/* @__PURE__ */n("div",{ref:xe(r),className:"node-slot","data-node-index":r,"data-node-type":e.type,children:/* @__PURE__ */n("div",i?{ref:be(r),className:"node-content"+(s?" fade-node typewriter-node":""),children:/* @__PURE__ */n(oo,{node:e,nodeKey:`${a}-${r}`,renderCtx:l})}:{className:"node-placeholder",style:{height:`${c}px`}})},`${a}-${r}`)}),Be,m&&/* @__PURE__ */n("span",{ref:h,className:"typewriter-cursor","aria-hidden":"true"})]})},function(e,n){if(e.renderCtx!==n.renderCtx)return!1;if(e.indexPrefix!==n.indexPrefix)return!1;if(e.containerRef!==n.containerRef)return!1;if(e.showTypewriterCursor!==n.showTypewriterCursor)return!1;const t=e.parsedNodes,r=n.parsedNodes;if(t===r)return!0;if(t.length!==r.length)return!1;for(let l=0;l<t.length;l++)if(t[l]!==r[l])return!1;const o=e.props,i=n.props;return o.isDark===i.isDark&&o.typewriter===i.typewriter&&o.fade===i.fade&&o.batchRendering===i.batchRendering&&o.initialRenderBatchSize===i.initialRenderBatchSize&&o.renderBatchSize===i.renderBatchSize&&o.renderBatchDelay===i.renderBatchDelay&&o.renderBatchBudgetMs===i.renderBatchBudgetMs&&o.renderBatchIdleTimeoutMs===i.renderBatchIdleTimeoutMs&&o.deferNodesUntilVisible===i.deferNodesUntilVisible&&o.maxLiveNodes===i.maxLiveNodes&&o.liveNodeBuffer===i.liveNodeBuffer&&o.viewportPriority===i.viewportPriority&&o.indexKey===i.indexKey&&o.onClick===i.onClick&&o.onMouseOver===i.onMouseOver&&o.onMouseOut===i.onMouseOut});function lo(e){var t,l;const a={...eo,...e},m=c(null),h=c(null),f=c(/* @__PURE__ */new Map),p=c(0),g=c(null),v=Re(a.smoothStreamingOptions),w=r.useContext(Se),y=c(/* @__PURE__ */new Set),[x,k]=i(()=>!0===a.smoothStreaming);s(()=>{k(!0)},[]);const b=Array.isArray(a.nodes)&&a.nodes.length>0,C=o(()=>{var e;return!1!==a.smoothStreaming&&!b&&(!0===a.smoothStreaming||!w)&&(!0===a.smoothStreaming||!0===a.typewriter||(null!=(e=a.maxLiveNodes)?e:0)<=0)},[b,w,a.maxLiveNodes,a.smoothStreaming,a.typewriter]),M=x&&C,N=M?v.visible:null!=(t=a.content)?t:"",B=o(()=>{var e,n;const t=null!=(e=a.parseOptions)?e:{};return null!=(n=a.final)?n:t.final},[a.final,a.parseOptions]),S=null!=(l=a.content)?l:"",T=b||v.source===S,D=o(()=>M&&null!=B?Boolean(B&&T&&v.caughtUp):B,[B,T,v.caughtUp,M]),A=c(null),[R,H]=i(!1),W=c(void 0),F=c(0),I=o(()=>/* @__PURE__ */new Set(["code_block","admonition","table","math_block","html_block","image"]),[]),_=d(e=>{if(!e||"object"!=typeof e)return!1;const n=e.type;return"string"==typeof n&&I.has(n)},[I]),O=d(e=>{var n,t;if(!e||"object"!=typeof e)return 0;const r=e,o=null!=(t=null!=(n=r.raw)?n:r.content)?t:r.code;if("string"==typeof o)return o.length;const i=r.children;if(Array.isArray(i))return i.reduce((e,n)=>e+O(n),0);const l=r.items;return Array.isArray(l)?l.reduce((e,n)=>e+O(n),0):0},[]),j=d(()=>{var e,n;return(null==(e=a.nodes)?void 0:e.length)?a.nodes.reduce((e,n)=>e+O(n),0):(null!=(n=a.content)?n:"").length},[a.nodes,a.content,O]),X=d(()=>{W.current&&(clearTimeout(W.current),W.current=void 0)},[]),q=d(e=>{const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){var n;if(!(null!=(n=e.textContent)?n:"").trim())return NodeFilter.FILTER_REJECT;const t=e.parentElement;return t?t.closest('.typewriter-cursor, .height-estimation-probes, [data-node-type="code_block"], [data-node-type="admonition"], [data-node-type="table"], [data-node-type="math_block"], [data-node-type="html_block"], [data-node-type="image"], script, style')?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});let t=null,r=n.nextNode();for(;r;)t=r,r=n.nextNode();return t},[]),U=d(()=>{var e,n;if("undefined"==typeof window||!R||!m.current||!A.current)return;const t=m.current,r=A.current,o=q(t),i=t.getBoundingClientRect();let l=0,a=0,c=20;if(null==o?void 0:o.textContent){const r=document.createRange(),s=o.textContent.length;r.setStart(o,Math.max(0,s-1)),r.setEnd(o,s);const d="function"==typeof r.getClientRects?r.getClientRects():void 0,u=null!=(n=null==d?void 0:d[d.length-1])?n:null==(e=o.parentElement)?void 0:e.getBoundingClientRect();u&&(l=u.right-i.left+t.scrollLeft,a=u.top-i.top+t.scrollTop,c=u.height||c),r.detach()}r.style.transform=`translate(${Math.max(0,l)}px, ${Math.max(0,a)}px)`,r.style.height=`${c}px`},[R,m,q]);s(()=>{R&&requestAnimationFrame(()=>{U()})},[R,U]),s(()=>()=>{X()},[X]);const Y=b?a.nodes:N;g.current!==Y&&(p.current+=1,g.current=Y);const Z=u(z,V,V),G=o(()=>K(a.customId),[a.customId,Z]),J=ro(a.streamingComponents),Q=ro(a.htmlComponents);s(()=>{ue(J,Q,y.current)},[Q,J]);const ee=o(()=>a.customId?`renderer-${a.customId}`:`renderer-${Date.now()}-${Math.random().toString(36).slice(2)}`,[a.customId]),ne=o(()=>{var e,n;const t=null!=(n=(null!=(e=a.parseOptions)?e:{}).customHtmlTags)?n:[];return L(a.customHtmlTags,Array.isArray(t)?t:[],Object.keys(J))},[a.customId,a.customHtmlTags,a.parseOptions,Z,J]),te=o(()=>{const e=ne;return e&&0!==e.length?E(ee,{customHtmlTags:e}):E(ee)},[ee,ne]),re=o(()=>{const e=te;return a.customMarkdownIt?a.customMarkdownIt(e):e},[te,a.customMarkdownIt]),oe=o(()=>{var e;const n=null!=(e=a.parseOptions)?e:{},t=D,r=null!=t,o=ne.length>0;return r||o?{...n,...r?{final:t}:{},...o?{customHtmlTags:ne}:{}}:n},[ne,D,a.parseOptions]),ie=o(()=>{const e=Boolean(a.debugPerformance)&&"undefined"!=typeof console&&"undefined"!=typeof performance,n=e?performance.now():0;let t=[];return b?t=a.nodes.map(e=>({...e})):N&&(t=$(N,null!=re?re:no,oe)),e&&console.info("[markstream-react][perf] parse(sync)",{ms:Math.round(performance.now()-n),nodes:t.length,contentLength:N.length}),t},[a.debugPerformance,N,b,a.nodes,oe,re,a.customId,Z,ne]),le=d(()=>{const e=ie[ie.length-1];return!_(e)},[ie,_]);s(()=>{if("undefined"==typeof window||b)return;if(D)return H(!1),void X();const e=j(),n=le();return!1===a.typewriter||!n||e<=F.current?(!1!==a.typewriter&&n||H(!1),void(F.current=e)):(F.current=e,H(!0),X(),requestAnimationFrame(()=>{U()}),W.current=setTimeout(()=>{H(!1)},3e3),()=>{X()})},[N,a.nodes,a.typewriter,a.content,D,ie.length,b,j,le,X,U]);const ae=c([]),ce=null==oe?void 0:oe.postTransformNodes,se=c(ce);se.current!==ce&&(ae.current=[],se.current=ce);const de=function(e,n){if(!n.length)return e;const t=new Array(e.length);let r=e.length===n.length;for(let o=0;o<e.length;o++){const i=o<n.length?n[o]:null;i&&to(i,e[o])?t[o]=i:(t[o]=e[o],r=!1)}return r?n:t}(ie,ae.current);ae.current=de,s(()=>{var e;if(b)return void v.reset("");const n=null!=(e=a.content)?e:"";if(!M)return v.reset(n),void(B&&v.finish({flush:!0}));const t=v.getSnapshot().source;n?n===t||(n.startsWith(t)?v.enqueue(n.slice(t.length)):v.reset(n)):v.reset(""),B&&v.finish()},[b,a.content,B,M]),s(()=>{var e,n;if("undefined"==typeof window)return;if(a.renderCodeBlocksAsPre)return;if(!de.some(e=>{var n;return"code_block"===(null==e?void 0:e.type)&&"mermaid"!==P(String(null!=(n=null==e?void 0:e.language)?n:""))}))return;const t=null!=(e=window.requestIdleCallback)?e:(e,n)=>{var t;return window.setTimeout(()=>e({didTimeout:!0,timeRemaining:()=>0}),null!=(t=null==n?void 0:n.timeout)?t:600)},r=null!=(n=window.cancelIdleCallback)?n:e=>window.clearTimeout(e),o=t(()=>{rn()},{timeout:900});return()=>r(o)},[de,a.renderCodeBlocksAsPre]),s(()=>{if("undefined"==typeof window)return;if(a.renderCodeBlocksAsPre)return;const e=a.isDark?a.codeBlockDarkTheme:a.codeBlockLightTheme,n="string"==typeof e?e:"object"==typeof e&&e&&"name"in e?String(e.name):null;n&&h.current!==n&&(h.current=n,function(e){if(null==e)return;const n=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&e&&"name"in e)return String(e.name);if("object"==typeof e){const n=yn.get(e);if(n)return n;try{const n=JSON.stringify(e);if(n)return yn.set(e,n),n}catch{}const t="__theme_"+ ++xn;return yn.set(e,t),t}return String(e)}(e);n&&gn!==n&&(pn=e,gn=n,vn&&fn(pn,vn).then(()=>kn()).catch(()=>{}))}(e))},[a.codeBlockDarkTheme,a.codeBlockLightTheme,a.isDark,a.renderCodeBlocksAsPre]);const me=o(()=>null!=a.indexKey?String(a.indexKey):"markdown-renderer",[a.indexKey]),he=o(()=>({..."boolean"==typeof a.showTooltips?{showTooltips:a.showTooltips}:{},...a.codeBlockProps||{}}),[a.codeBlockProps,a.showTooltips]),fe=o(()=>({...a.mermaidProps||{}}),[a.mermaidProps]),pe=o(()=>({...a.d2Props||{}}),[a.d2Props]),ge=o(()=>({...a.infographicProps||{}}),[a.infographicProps]),ve=o(()=>{var e;return{customId:a.customId,isDark:a.isDark,final:D,indexKey:me,typewriter:a.typewriter,fade:a.fade,textStreamState:f.current,streamRenderVersion:p.current,customComponents:G,streamingComponents:J,htmlComponents:Q,customHtmlTags:ne,htmlPolicy:null!=(e=a.htmlPolicy)?e:"safe",showTooltips:a.showTooltips,renderCodeBlocksAsPre:a.renderCodeBlocksAsPre,codeBlockStream:a.codeBlockStream,codeBlockProps:he,mermaidProps:fe,d2Props:pe,infographicProps:ge,codeBlockThemes:{themes:a.themes,darkTheme:a.codeBlockDarkTheme,lightTheme:a.codeBlockLightTheme,langs:a.langs,monacoOptions:a.codeBlockMonacoOptions,minWidth:a.codeBlockMinWidth,maxWidth:a.codeBlockMaxWidth},events:{onCopy:a.onCopy,onHandleArtifactClick:a.onHandleArtifactClick}}},[a.customId,a.isDark,D,me,a.typewriter,a.fade,a.showTooltips,a.htmlPolicy,a.renderCodeBlocksAsPre,a.codeBlockStream,ne,he,fe,pe,ge,a.themes,a.codeBlockDarkTheme,a.codeBlockLightTheme,a.langs,a.codeBlockMonacoOptions,a.codeBlockMinWidth,a.codeBlockMaxWidth,a.onCopy,a.onHandleArtifactClick,G,J,Q]);ve.streamRenderVersion=p.current,ve.textStreamState=f.current;const we=c(null);return we.current||(we.current={textStreamState:f.current,getStreamRenderVersion:()=>p.current}),/* @__PURE__ */n(Te.Provider,{value:we.current,children:/* @__PURE__ */n(Se.Provider,{value:M,children:/* @__PURE__ */n(Pe,{getRoot:()=>m.current,enabled:!1!==a.viewportPriority,children:/* @__PURE__ */n(io,{props:a,parsedNodes:de,renderCtx:ve,indexPrefix:me,containerRef:m,showTypewriterCursor:R,typewriterCursorRef:A})})})})}function ao(e){var t,r,o,i,l,a;const{node:c,ctx:s,renderNode:d,indexKey:u,children:m}=e;/* @__PURE__ */
186
+ return n("blockquote",{className:"blockquote-node",dir:"auto",cite:c.cite,children:null!=m?m:s&&d?/* @__PURE__ */n(lo,{nodes:c.children||[],indexKey:`blockquote-${String(null!=u?u:"blockquote")}`,customId:s.customId,isDark:s.isDark,typewriter:s.typewriter,viewportPriority:!0,codeBlockStream:s.codeBlockStream,renderCodeBlocksAsPre:s.renderCodeBlocksAsPre,codeBlockProps:s.codeBlockProps,themes:null==(t=s.codeBlockThemes)?void 0:t.themes,codeBlockDarkTheme:null==(r=s.codeBlockThemes)?void 0:r.darkTheme,codeBlockLightTheme:null==(o=s.codeBlockThemes)?void 0:o.lightTheme,codeBlockMonacoOptions:null==(i=s.codeBlockThemes)?void 0:i.monacoOptions,codeBlockMinWidth:null==(l=s.codeBlockThemes)?void 0:l.minWidth,codeBlockMaxWidth:null==(a=s.codeBlockThemes)?void 0:a.maxWidth,htmlPolicy:s.htmlPolicy,showTooltips:s.showTooltips,onCopy:s.events.onCopy,onHandleArtifactClick:s.events.onHandleArtifactClick}):null})}const co=he();function so(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function uo(r){const l={loading:!0,stream:!0,darkTheme:"vitesse-dark",lightTheme:"vitesse-light",isDark:!1,isShowPreview:!0,enableFontSizeControl:!0,showHeader:!0,showCopyButton:!0,showExpandButton:!0,showPreviewButton:!0,showCollapseButton:!0,showFontSizeButtons:!0,...r},a=o(()=>{var e;return String(null!=(e=l.node.language)?e:"")},[l.node.language]),u=o(()=>P(a),[a]),[m,h]=i(0);s(()=>R(()=>{h(e=>e+1)}),[]);const f=o(()=>{const e=_[u]||u;return e?e.charAt(0).toUpperCase()+e.slice(1):"Text"},[u]),p=o(()=>I(u),[u,m]),{t:g}=Ie(),v=o(()=>!!l.isShowPreview&&("html"===u||"svg"===u),[u,l.isShowPreview]),w=o(()=>{const e={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t=n(l.minWidth),r=n(l.maxWidth);return t&&(e.minWidth=t),r&&(e.maxWidth=r),e},[l.maxWidth,l.minWidth]),[y,x]=i(!1),[k,b]=i(!1),[C,M]=i(!1),[N,B]=i(()=>l.node.code?`<pre class="shiki shiki-fallback"><code>${so(l.node.code)}</code></pre>`:""),[S,T]=i(!1),[L,E]=i(14),[$,D]=i(L),A=o(()=>!1!==l.showTooltips,[l.showTooltips]),H=ge(l.themes,l.langs),W=c(null);W.current&&W.current.key===H||(W.current={key:H,themes:l.themes,langs:l.langs});const F=c(null),O=c(null),j=c(null),z=c(null),V=c(null),K=c(""),X=c(""),q=c(0),U=c(null),Y=c(null),Z=c(null),G=c(!1),J=c(!1),Q=c(null),ee=c(!1),ne=c(/* @__PURE__ */new Set),te=c(/* @__PURE__ */new Set),re=c(""),oe=c(0),ie=c(H),le=c(0),ae=c(!0),ce=c(null),se=Ae(),[de,ue]=i(()=>"undefined"==typeof window),me=d(()=>l.isDark?l.darkTheme:l.lightTheme,[l.darkTheme,l.isDark,l.lightTheme]),he=d(e=>{null==e||e.disconnect(),e&&z.current!==e||(z.current=null)},[]),fe=d(()=>{j.current&&(j.current.innerHTML="")},[]),ye=d(e=>{if(U.current=null,he(),!e)return fe(),X.current="",B(""),void T(!1);B(`<pre class="shiki shiki-fallback"><code>${so(e)}</code></pre>`),T(!1)},[fe,he]),xe=d(()=>{he(),B(""),T(!0)},[he]),ke=d(e=>{X.current=e,xe()},[xe]),be=d(()=>{var e;const n=j.current;return!!n&&(n.childNodes.length>0||Boolean(null==(e=n.textContent)?void 0:e.trim().length))},[]),Ce=d((e=!0)=>{const n=V.current;he(),V.current=null,K.current="",X.current="",U.current=null,ne.current.clear();try{null==n||n.dispose()}catch(t){co&&"undefined"!=typeof console&&console.warn("[MarkdownCodeBlockNode] Failed to dispose Shiki renderer.",t)}finally{fe(),e&&T(!1)}},[fe,he]),Me=d(()=>(le.current+=1,le.current),[]),Ne=d(e=>ae.current&&le.current===e,[]),Be=d((e,n)=>{he();const t=j.current;if(!t||"undefined"==typeof MutationObserver)return;U.current=null;const r=new MutationObserver(()=>{q.current+=1;const t=U.current;if(t)return Ne(e)?void(q.current!==n&&be()&&(U.current=null,he(r),ke(t))):(U.current=null,void he(r))});z.current=r,r.observe(t,{childList:!0,subtree:!0,characterData:!0,attributes:!0})},[he,be,Ne,ke]),Se=d(async(e,n,t,r)=>{var o;if(U.current=t,await Promise.resolve(),!Ne(e))return;const i=be(),l=q.current!==n,a=void 0!==r&&(null==(o=j.current)?void 0:o.innerHTML)!==r;i&&(!X.current||l||a||X.current===t)&&(U.current=null,he(),ke(t))},[he,be,Ne,ke]),Te=d(async()=>{if(!Y.current&&!G.current)return Z.current||(Z.current=(async()=>{try{const e=await import("stream-markdown"),n=e.createShikiStreamRenderer;if("function"!=typeof n)throw new TypeError("stream-markdown.createShikiStreamRenderer is not available");Y.current=n;const t=e.registerHighlight;Q.current="function"==typeof t?t:null,G.current=!1,J.current=!1}catch(e){G.current=!0,co&&!J.current&&"undefined"!=typeof console&&(J.current=!0,console.warn("[MarkdownCodeBlockNode] stream-markdown not available:",e))}finally{Z.current=null}})()),Z.current},[]),Le=d(async e=>{const n=e.key;if(ie.current!==n)return"stale";if(!Q.current)return"ready";if(re.current===n)return"ready";const t=++oe.current;try{await ve(Q.current,e.registerOptions,n)}catch{return t!==oe.current||ie.current!==n?"stale":"failed"}return t!==oe.current||ie.current!==n?"stale":(re.current=n,"ready")},[]),Ee=d(async e=>{const n=await Le(e);return"failed"!==n?n:ie.current!==e.key?"stale":Le(e)},[Le]),$e=d(e=>{var n;const t={hasRegisterHighlight:Boolean(Q.current),hasCreateRenderer:Boolean(Y.current)},r=we(null==e?void 0:e.themes,null==e?void 0:e.langs,t),o=(null==(n=r.rendererOptions.langs)?void 0:n.length)&&te.current.has(r.key)?we(null==e?void 0:e.themes,void 0,t):r;return r.ignoredLangs&&co&&!ee.current&&"undefined"!=typeof console&&(ee.current=!0,console.warn("[MarkdownCodeBlockNode] `langs` requires stream-markdown >=0.0.15 with registerHighlight(); ignoring `langs` and using stream-markdown default language preload.")),{key:o.key,registerOptions:o.registerOptions,rendererOptions:o.rendererOptions}},[]),De=d(async(e,n,t)=>{const r=V.current;if(!r||!Ne(t))return;const o=function(e){return pe(e)||"plaintext"}(n),i=async n=>{const r=V.current;if(r&&Ne(t)){n&&"plaintext"!==o&&ne.current.add(o);try{return await r.updateCode(e,"plaintext"),Ne(t)?"plaintext":void 0}catch{return}}};if("plaintext"!==o&&ne.current.has(o))return i();try{return await r.updateCode(e,o),Ne(t)?o:void 0}catch(l){if(!Ne(t)||"plaintext"===o)return;return i(l)}},[Ne]),Pe=d(async()=>{var e,n;const t=Me(),r=l.node.code,o=l.node.language,i=W.current;if(!de)return void ye(r);if(await Te(),!Ne(t))return;let a=$e(i),c=a.key;ie.current=c;let s=Boolean(V.current&&K.current!==c);s&&ye(r);let d=await Ee(a);if("failed"===d&&(null==(e=a.rendererOptions.langs)?void 0:e.length)&&(te.current.add(a.key),co&&"undefined"!=typeof console&&console.warn("[MarkdownCodeBlockNode] Failed to register configured Shiki languages; retrying without `langs`.",{langs:a.rendererOptions.langs}),a=$e({themes:null==i?void 0:i.themes,langs:void 0}),c=a.key,ie.current=c,d=await Ee(a)),!Ne(t)||"stale"===d)return;if(s=Boolean(V.current&&K.current!==c),"failed"===d)return void(s&&V.current&&be()?xe():ye(r));if(s&&Ce(),!O.current||!j.current)return void ye(r);if(!V.current&&Y.current&&(V.current=Y.current(j.current,{theme:me(),themes:a.rendererOptions.themes,langs:a.rendererOptions.langs}),K.current=c,T(!0)),!V.current)return void ye(r);if(!1===l.stream&&l.loading)return void ye(r);ye(r);const u=q.current,m=null==(n=j.current)?void 0:n.innerHTML;Be(t,u);const h=await De(r,o,t);Ne(t)&&(h?await Se(t,u,function(e,n,t){return`${null!=e?e:""}\0${n}\0${t}`}(c,h,r),m):(U.current=null,he()))},[Me,l.node.code,l.node.language,l.stream,l.loading,H,de,Te,$e,Ee,Ce,xe,me,be,ye,Be,De,Se,he,Ne]);s(()=>{const e=F.current;if(!e)return;let n=!0;const t=se(e,{rootMargin:"400px"});return ce.current=t,t.isVisible()&&ue(!0),t.whenVisible.then(()=>{n&&ue(!0)}),()=>{n=!1,t.destroy(),ce.current=null}},[se]),s(()=>{Pe().catch(()=>{ae.current&&j.current&&ye(l.node.code)})},[Pe,l.node.code,ye]),s(()=>(ae.current=!0,()=>{ae.current=!1,le.current+=1,Ce(!1)}),[Ce]),s(()=>{V.current&&de&&V.current.setTheme(me())},[me,de]),s(()=>{A||Ye(!0)},[A]);const Re=d((e,n)=>{if(!A)return;const t=e.currentTarget;t&&!t.disabled&&("clientX"in e&&(e.clientX,e.clientY),Ue(t,n,"top",!1,0,l.isDark))},[l.isDark,A]),He=d(()=>{A&&Ye()},[A]),We=d(async()=>{var e;try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&await navigator.clipboard.writeText(l.node.code),x(!0),null==(e=l.onCopy)||e.call(l,l.node.code),setTimeout(()=>x(!1),1e3)}catch{}},[l]),Fe=d(()=>{var e;if(!v)return;const n="html"===u?"text/html":"image/svg+xml",t="html"===u?"HTML Preview":"SVG Preview";null==(e=l.onPreviewCode)||e.call(l,{type:n,content:l.node.code,title:t})},[u,v,l]),_e=o(()=>({fontSize:`${$}px`}),[$]);return s(()=>{E(14),D(14)},[]),/* @__PURE__ */e("div",{ref:F,className:["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm",l.isDark?"border-gray-700/30 bg-gray-900 is-dark":"border-gray-200 bg-white"].join(" "),style:w,children:[l.showHeader&&/* @__PURE__ */e("div",{className:"code-block-header",children:[
187
187
  /* @__PURE__ */e("div",{className:"code-header-main",children:[
188
188
  /* @__PURE__ */n("span",{className:"icon-slot h-4 w-4 flex-shrink-0",dangerouslySetInnerHTML:{__html:p}}),
189
189
  /* @__PURE__ */n("div",{className:"code-header-copy",children:/* @__PURE__ */n("div",{className:"code-header-title",children:f})})]}),
190
190
  /* @__PURE__ */e("div",{className:"code-header-actions",children:[l.showCollapseButton&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-pressed":C,onClick:()=>M(e=>!e),onMouseEnter:e=>Re(e,C?g("common.expand")||"Expand":g("common.collapse")||"Collapse"),onFocus:e=>Re(e,C?g("common.expand")||"Expand":g("common.collapse")||"Collapse"),onMouseLeave:He,onBlur:He,children:/* @__PURE__ */n("svg",{style:{rotate:C?"0deg":"90deg"},xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 18l6-6l-6-6"})})}),l.showFontSizeButtons&&l.enableFontSizeControl&&/* @__PURE__ */e(t,{children:[
191
- /* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors",disabled:D<=10,onClick:()=>$(e=>Math.max(10,e-1)),onMouseEnter:e=>Re(e,g("common.decrease")||"Decrease"),onFocus:e=>Re(e,g("common.decrease")||"Decrease"),onMouseLeave:He,onBlur:He,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14"})})}),
192
- /* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors",disabled:D===L,onClick:()=>$(L),onMouseEnter:e=>Re(e,g("common.reset")||"Reset"),onFocus:e=>Re(e,g("common.reset")||"Reset"),onMouseLeave:He,onBlur:He,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
191
+ /* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors",disabled:$<=10,onClick:()=>D(e=>Math.max(10,e-1)),onMouseEnter:e=>Re(e,g("common.decrease")||"Decrease"),onFocus:e=>Re(e,g("common.decrease")||"Decrease"),onMouseLeave:He,onBlur:He,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14"})})}),
192
+ /* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors",disabled:$===L,onClick:()=>D(L),onMouseEnter:e=>Re(e,g("common.reset")||"Reset"),onFocus:e=>Re(e,g("common.reset")||"Reset"),onMouseLeave:He,onBlur:He,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
193
193
  /* @__PURE__ */n("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),
194
194
  /* @__PURE__ */n("path",{d:"M3 3v5h5"})]})})}),
195
- /* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors",disabled:D>=36,onClick:()=>$(e=>Math.min(36,e+1)),onMouseEnter:e=>Re(e,g("common.increase")||"Increase"),onFocus:e=>Re(e,g("common.increase")||"Increase"),onMouseLeave:He,onBlur:He,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14m-7-7v14"})})})]}),l.showCopyButton&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-label":y?g("common.copied")||"Copied":g("common.copy")||"Copy",onClick:Fe,onMouseEnter:e=>Re(e,y?g("common.copied")||"Copied":g("common.copy")||"Copy"),onFocus:e=>Re(e,y?g("common.copied")||"Copied":g("common.copy")||"Copy"),onMouseLeave:He,onBlur:He,children:/* @__PURE__ */n("svg",y?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
195
+ /* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors",disabled:$>=36,onClick:()=>D(e=>Math.min(36,e+1)),onMouseEnter:e=>Re(e,g("common.increase")||"Increase"),onFocus:e=>Re(e,g("common.increase")||"Increase"),onMouseLeave:He,onBlur:He,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14m-7-7v14"})})})]}),l.showCopyButton&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-label":y?g("common.copied")||"Copied":g("common.copy")||"Copy",onClick:We,onMouseEnter:e=>Re(e,y?g("common.copied")||"Copied":g("common.copy")||"Copy"),onFocus:e=>Re(e,y?g("common.copied")||"Copied":g("common.copy")||"Copy"),onMouseLeave:He,onBlur:He,children:/* @__PURE__ */n("svg",y?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M20 6L9 17l-5-5"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
196
196
  /* @__PURE__ */n("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),
197
- /* @__PURE__ */n("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),l.showExpandButton&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-pressed":k,onClick:e=>{b(e=>!e),Re(e,k?g("common.expand")||"Expand":g("common.collapse")||"Collapse")},onMouseEnter:e=>Re(e,k?g("common.collapse")||"Collapse":g("common.expand")||"Expand"),onFocus:e=>Re(e,k?g("common.collapse")||"Collapse":g("common.expand")||"Expand"),onMouseLeave:He,onBlur:He,children:/* @__PURE__ */n("svg",k?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})}),v&&l.showPreviewButton&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-label":g("common.preview")||"Preview",onClick:We,onMouseEnter:e=>Re(e,g("common.preview")||"Preview"),onFocus:e=>Re(e,g("common.preview")||"Preview"),onMouseLeave:He,onBlur:He,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
197
+ /* @__PURE__ */n("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})}),l.showExpandButton&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-pressed":k,onClick:e=>{b(e=>!e),Re(e,k?g("common.expand")||"Expand":g("common.collapse")||"Collapse")},onMouseEnter:e=>Re(e,k?g("common.collapse")||"Collapse":g("common.expand")||"Expand"),onFocus:e=>Re(e,k?g("common.collapse")||"Collapse":g("common.expand")||"Expand"),onMouseLeave:He,onBlur:He,children:/* @__PURE__ */n("svg",k?{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"})}:{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */n("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"})})}),v&&l.showPreviewButton&&/* @__PURE__ */n("button",{type:"button",className:"code-action-btn transition-colors","aria-label":g("common.preview")||"Preview",onClick:Fe,onMouseEnter:e=>Re(e,g("common.preview")||"Preview"),onFocus:e=>Re(e,g("common.preview")||"Preview"),onMouseLeave:He,onBlur:He,children:/* @__PURE__ */n("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",className:"action-icon",children:/* @__PURE__ */e("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[
198
198
  /* @__PURE__ */n("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),
199
199
  /* @__PURE__ */n("circle",{cx:"12",cy:"12",r:"3"})]})})})]})]}),!C&&(!!l.stream||!l.loading)&&/* @__PURE__ */e("div",{ref:O,className:"code-block-content",style:{..._e,maxHeight:k?"none":"500px",overflowY:k?"visible":"auto",overflowX:"auto"},children:[
200
200
  /* @__PURE__ */n("div",{ref:j,className:"code-block-render"}),!S&&N&&/* @__PURE__ */n("div",{className:"code-fallback-plain",dangerouslySetInnerHTML:{__html:N}})]}),!l.stream&&l.loading&&/* @__PURE__ */n("div",{className:"code-loading-placeholder",children:/* @__PURE__ */e("div",{className:"loading-skeleton",children:[
201
201
  /* @__PURE__ */n("div",{className:"skeleton-line"}),
202
202
  /* @__PURE__ */n("div",{className:"skeleton-line"}),
203
203
  /* @__PURE__ */n("div",{className:"skeleton-line short"})]})}),
204
- /* @__PURE__ */n("span",{className:"sr-only","aria-live":"polite",role:"status",children:y?g("common.copied")||"Copied":""})]})}function so(e){var t;const r=c(null),[l,a]=i(!1),[d,u]=i({transform:"translate3d(0px, 0px, 0px)",left:"0px",top:"0px"}),m=o(()=>function(e){if("boolean"==typeof e)return e;if("undefined"!=typeof document)try{if(document.documentElement.classList.contains("dark"))return!0}catch{}if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{return window.matchMedia("(prefers-color-scheme: dark)").matches}catch{}return!1}(e.isDark),[e.isDark]);return s(()=>{if(!e.visible)return void a(!1);if(!e.anchorEl||!r.current)return void a(!0);let n=null,t=!1;const o=async()=>{var n,o;if(!e.anchorEl||!r.current)return;const{x:i,y:l}=await ke(e.anchorEl,r.current,{placement:null!=(n=e.placement)?n:"top",middleware:[be(null!=(o=e.offset)?o:8),Ce(),Me({padding:8})],strategy:"fixed"});t||u({position:"fixed",left:"0px",top:"0px",transform:`translate3d(${Math.round(i)}px, ${Math.round(l)}px, 0)`})};return o().then(()=>{t||a(!0)}),n=xe(e.anchorEl,r.current,o),()=>{t=!0,null==n||n()}},[e.anchorEl,e.offset,e.placement,e.visible,l]),"undefined"==typeof document?null:e.visible&&l?ye(
205
- /* @__PURE__ */n("div",{id:null!=(t=e.id)?t: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{Wn as $,Be as A,io as B,He as C,Kn as D,qn as E,Fr as F,fr as G,Jn as H,pt as I,zt as J,Wt as K,Bt as L,dr as M,oo as N,mr as O,_r as P,Fn as Q,Or as R,jr as S,Xr as T,Hn as U,Ur as V,_t as W,pr as X,In as Y,Ut as Z,sr as _,Ln as a,Ot as a0,Yt as a1,Gr as a2,Rn as a3,We as a4,qt as a5,jt as a6,Vt as a7,Ft as a8,It as a9,ur as aa,ar as ab,cr as ac,gr as ad,Ie as ae,Re as af,Kt as ag,Xn as b,Un as c,Yn as d,Zn as e,Gn as f,Qn as g,et as h,nt as i,mt as j,Je as k,xt as l,bt as m,Ct as n,St as o,Tt as p,co as q,Qt as r,er as s,Tr as t,zr as u,Vr as v,Kr as w,Nt as x,qr as y,so as z};
204
+ /* @__PURE__ */n("span",{className:"sr-only","aria-live":"polite",role:"status",children:y?g("common.copied")||"Copied":""})]})}function mo(e){var t;const r=c(null),[l,a]=i(!1),[d,u]=i({transform:"translate3d(0px, 0px, 0px)",left:"0px",top:"0px"}),m=o(()=>function(e){if("boolean"==typeof e)return e;if("undefined"!=typeof document)try{if(document.documentElement.classList.contains("dark"))return!0}catch{}if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{return window.matchMedia("(prefers-color-scheme: dark)").matches}catch{}return!1}(e.isDark),[e.isDark]);return s(()=>{if(!e.visible)return void a(!1);if(!e.anchorEl||!r.current)return void a(!0);let n=null,t=!1;const o=async()=>{var n,o;if(!e.anchorEl||!r.current)return;const{x:i,y:l}=await ke(e.anchorEl,r.current,{placement:null!=(n=e.placement)?n:"top",middleware:[be(null!=(o=e.offset)?o:8),Ce(),Me({padding:8})],strategy:"fixed"});t||u({position:"fixed",left:"0px",top:"0px",transform:`translate3d(${Math.round(i)}px, ${Math.round(l)}px, 0)`})};return o().then(()=>{t||a(!0)}),n=xe(e.anchorEl,r.current,o),()=>{t=!0,null==n||n()}},[e.anchorEl,e.offset,e.placement,e.visible,l]),"undefined"==typeof document?null:e.visible&&l?ye(
205
+ /* @__PURE__ */n("div",{id:null!=(t=e.id)?t: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{In as $,Be as A,ao as B,He as C,Xn as D,Un as E,Ir as F,gr as G,Qn as H,gt as I,Kt as J,_t as K,Tt as L,mr as M,lo as N,fr as O,jr as P,Fn as Q,zr as R,Vr as S,Ur as T,Wn as U,Zr as V,jt as W,vr as X,_n as Y,Zt as Z,ur as _,En as a,zt as a0,Gt as a1,Qr as a2,Hn as a3,Fe as a4,Yt as a5,Vt as a6,Xt as a7,It as a8,Ot as a9,hr as aa,sr as ab,dr as ac,wr as ad,Ie as ae,Re as af,qt as ag,qn as b,Yn as c,Zn as d,Gn as e,Jn as f,et as g,nt as h,tt as i,ht as j,Je as k,kt as l,Ct as m,Mt as n,Lt as o,Et as p,uo as q,nr as r,tr as s,Er as t,Kr as u,Xr as v,qr as w,St as x,Yr as y,mo as z};