@lofcz/streamdown 2.15.0 → 2.15.1

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.
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ import {r,k,m,j,l,p,q as q$1,s,c,u}from'./chunk-BSY33EDM.js';import {f,i,d}from'./chunk-GKDS2YGT.js';import {useContext,useState,useRef,useEffect,useCallback,useLayoutEffect}from'react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';var Je=/\s+/;function Ne(e){var n;return ((n=e.trim().split(Je,1).at(0))!=null?n:"").includes(">")}function Pe(e){if(!e||typeof e!="object"||!("compactDrawing"in e))return;let t=e.compactDrawing;return typeof t=="boolean"?t:void 0}function Ee(e,t){return {...typeof e=="object"&&e!==null?e:{},compactDrawing:t}}var Te=({compact:e,onToggle:t})=>{let n=f(),s=i(),{isAnimating:a}=useContext(r),i$1=e?s.smilesShowStructures:s.smilesShowCompact;return jsx("button",{"aria-label":i$1,"aria-pressed":e,className:n("cursor-pointer px-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",e&&"text-foreground"),disabled:a,onClick:t,title:i$1,type:"button",children:jsx("span",{className:n("font-mono text-[10px] leading-none"),children:"CH\u2083"})})};var q=e=>e>0?e:null,tt=(e,t)=>{if(e.endsWith("px"))return q(Number.parseFloat(e));if(e.endsWith("rem")){let n=Number.parseFloat(getComputedStyle(document.documentElement).fontSize||"16");return q(Number.parseFloat(e)*n)}if(e.endsWith("em")){let n=Number.parseFloat(getComputedStyle(t).fontSize||"16");return q(Number.parseFloat(e)*n)}if(e.endsWith("vh"))return q(Number.parseFloat(e)/100*window.innerHeight);if(e.endsWith("%")){let n=t.parentElement;return n&&n.clientHeight>0?q(Number.parseFloat(e)/100*n.clientHeight):null}return null},ge=(e,t)=>{let n=t.trim().toLowerCase();return !n||n==="none"||n==="auto"?null:tt(n,e)},nt=/^min\(\s*([^,]+)\s*,\s*([^)]+)\s*\)$/i,ot=(e,t)=>{let n=ge(e,t);if(n!=null)return n;let s=t.trim().match(nt);if(!s)return null;let a=ge(e,s[1].trim()),i=ge(e,s[2].trim());return a==null||i==null?null:Math.min(a,i)},rt=(e,t,n)=>{let s=t.clientWidth;if(!(s>0))return null;if(n){let m=t.clientHeight;if(!(m>0))return null;let p=Math.min(s/e.width,m/e.height,1);return !(p>0)||Number.isNaN(p)?null:{fitZoom:p,viewportHeight:null}}let a=Math.min(s/e.width,1);if(!(a>0)||Number.isNaN(a))return null;let i=e.height*a,l=null,u=t;for(;u&&l==null;){let m=getComputedStyle(u);l=ot(u,m.maxHeight),u=u.parentElement;}let o=l!=null?Math.min(i,l):i,r=Math.min(a,o/e.height,1);return !(r>0)||Number.isNaN(r)?null:{fitZoom:r,viewportHeight:o}},Re=({children:e,className:t,contentSize:n,fitKey:s,minZoom:a=.5,maxZoom:i$1=3,zoomStep:l=.1,showControls:u=true,initialZoom:o=1,isAutoFit:r=false,fullscreen:m=false})=>{let{RotateCcwIcon:p,ZoomInIcon:x,ZoomOutIcon:d}=j(),v=f(),h=i(),S=useRef(null),f$1=useRef(null),D=useRef(false),[w,N]=useState(o),[R,C]=useState(a),[b,g]=useState(o),[P,k]=useState({x:0,y:0}),[M,Z]=useState(false),[F,le]=useState({x:0,y:0}),[G,te]=useState({x:0,y:0}),[K,_]=useState(null),U=useCallback(c=>{let y=S.current;if(!y)return;let Y=rt(c,y,m);if(!Y)return;let{fitZoom:ce,viewportHeight:qe}=Y;_(qe),N(ce),C(Math.min(a,ce)),D.current||(g(ce),k({x:0,y:0}));},[m,a]),z=useCallback(c=>{g(y=>Math.max(R,Math.min(i$1,y+c))),D.current=true;},[R,i$1]),Xe=useCallback(()=>{z(l);},[z,l]),Ke=useCallback(()=>{z(-l);},[z,l]),Ue=useCallback(()=>{g(w),k({x:0,y:0}),D.current=false;},[w]),me=useCallback(c=>{c.preventDefault();let y=c.deltaY>0?-l:l;z(y);},[z,l]),je=useCallback(c=>{if(c.button!==0||c.isPrimary===false)return;Z(true),D.current=true,le({x:c.clientX,y:c.clientY}),te(P);let y=c.currentTarget;y instanceof HTMLElement&&y.setPointerCapture(c.pointerId);},[P]),ue=useCallback(c=>{if(!M)return;c.preventDefault();let y=c.clientX-F.x,Y=c.clientY-F.y;k({x:G.x+y,y:G.y+Y});},[M,F,G]),j$1=useCallback(c=>{Z(false);let y=c.currentTarget;y instanceof HTMLElement&&y.releasePointerCapture(c.pointerId);},[]);useEffect(()=>{C(a),r||(N(o),g(o),_(null));},[o,r,a]),useLayoutEffect(()=>{if(!(r&&n))return;U(n);let c=S.current;if(!c||typeof ResizeObserver=="undefined")return;let y=new ResizeObserver(()=>{U(n);});return y.observe(c),()=>{y.disconnect();}},[U,n,r]),useEffect(()=>{r&&(D.current=false);},[s,r]),useEffect(()=>{let c=S.current;if(c)return c.addEventListener("wheel",me,{passive:false}),()=>{c.removeEventListener("wheel",me);}},[me]),useEffect(()=>{let c=f$1.current;if(c&&M)return document.body.style.userSelect="none",c.addEventListener("pointermove",ue,{passive:false}),c.addEventListener("pointerup",j$1),c.addEventListener("pointercancel",j$1),()=>{document.body.style.userSelect="",c.removeEventListener("pointermove",ue),c.removeEventListener("pointerup",j$1),c.removeEventListener("pointercancel",j$1);}},[M,ue,j$1]);let Ye=!m&&r&&K!=null?{height:K}:void 0;return jsxs("div",{className:v("relative flex flex-col",m?"h-full w-full":"min-h-28 w-full",t),ref:S,style:{cursor:M?"grabbing":"grab",...Ye},children:[u?jsxs("div",{className:v("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",m?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{"aria-label":h.zoomIn,className:v("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:b>=i$1,onClick:Xe,title:h.zoomIn,type:"button",children:jsx(x,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":h.zoomOut,className:v("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:b<=R,onClick:Ke,title:h.zoomOut,type:"button",children:jsx(d,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":h.resetView,className:v("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:Ue,title:h.resetView,type:"button",children:jsx(p,{"aria-hidden":"true",size:16})})]}):null,jsx("div",{className:v("flex h-full w-full flex-1 origin-center items-center justify-center transition-transform duration-150 ease-out"),onPointerDown:je,ref:f$1,role:"application",style:{transform:`translate(${P.x}px, ${P.y}px) scale(${b})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var st=/(<svg\b)/,Fe=/<svg\b[^>]*>/i,at=/\bviewBox=(['"])(.*?)\1/i,it=/\swidth=(['"]).*?\1/gi,lt=/\sheight=(['"]).*?\1/gi,Me=/\sstyle=(['"])(.*?)\1/i,_e=/^<svg/i,mt=/^width\s*:/i,ut=/^height\s*:/i,ct=/^max-width\s*:/i,dt=/[\s,]+/,gt=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(st,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),Ie=e=>{if(typeof DOMParser=="undefined"||typeof XMLSerializer=="undefined")return e;let n=new DOMParser().parseFromString(e,"text/html").querySelector("svg");return n?new XMLSerializer().serializeToString(n):e},pe=e=>{let t=e.match(Fe);if(!t)return null;let s=t[0].match(at),a=s==null?void 0:s[2];if(!a)return null;let i=a.trim().split(dt).map(o=>Number.parseFloat(o));if(i.length<4||i.slice(0,4).some(Number.isNaN))return null;let l=i[2],u=i[3];return l>0&&u>0?{height:u,width:l}:null},ze=e=>{let t=e.match(Fe);if(!t)return e;try{let n=t[0],s=pe(e);if(!s)return e;let{width:a,height:i}=s,l=n.replace(it,"").replace(lt,""),u=l.match(Me),o=`width:${a}px;height:${i}px;max-width:none;`;if(u){let r=u[1],p=u[2].split(";").map(d=>d.trim()).filter(Boolean).filter(d=>!(mt.test(d)||ut.test(d)||ct.test(d))).join(";"),x=`${o}${p?`${p};`:""}`;l=l.replace(Me,` style=${r}${x}${r}`);}else l=l.replace(_e,`<svg style="${o}"`);return l=l.replace(_e,`<svg width="${a}" height="${i}"`),e.replace(n,l)}catch(n){return e}},He=(e,t)=>{var s;let n=(s=void 0)!=null?s:5;return new Promise((a,i)=>{let l=gt(e),u="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(l))),o=new Image;o.crossOrigin="anonymous",o.onload=()=>{let r=document.createElement("canvas"),m=o.width*n,p=o.height*n;r.width=m,r.height=p;let x=r.getContext("2d");if(!x){i(new Error("Failed to create 2D canvas context for PNG export"));return}x.drawImage(o,0,0,m,p),r.toBlob(d=>{if(!d){i(new Error("Failed to create PNG blob"));return}a(d);},"image/png");},o.onerror=()=>i(new Error("Failed to load SVG image")),o.src=u;})};var re=(e,t)=>{var n;return t==="mermaid"?e.mermaid:t==="plantuml"?e.plantuml:t==="vega"?e.vega:t==="smiles"?e.smiles:(n=e.diagrams)==null?void 0:n[t]};var pt={chart:"diagramChart",error:"diagramErrorLabel",missing:"diagramPluginMissing",failed:"diagramRenderFailed"},ft={mermaid:{chart:"mermaidChart",error:"mermaidErrorLabel",missing:"mermaidPluginMissing",failed:"mermaidRenderFailed"},plantuml:{chart:"plantumlChart",error:"plantumlErrorLabel",missing:"plantumlPluginMissing",failed:"plantumlRenderFailed"},vega:{chart:"vegaChart",error:"vegaErrorLabel",missing:"vegaPluginMissing",failed:"vegaRenderFailed"},smiles:{chart:"smilesChart",error:"smilesErrorLabel",missing:"smilesPluginMissing",failed:"smilesRenderFailed"}},bt={mermaid:"mermaidFormatMmd",plantuml:"plantumlFormatPuml",vega:"vegaFormatJson",smiles:"smilesFormatSmi"},ht={mermaid:"downloadDiagramAsMmd",plantuml:"downloadDiagramAsPuml",vega:"downloadDiagramAsJson",smiles:"downloadDiagramAsSmi"},J=(e,t,n)=>{var a;let s=(a=ft[t])!=null?a:pt;return e[s[n]]},Oe=(e,t,n)=>{let s=bt[t];return s?e[s]:n.toUpperCase()||e.diagramFormatSource},fe=(e,t)=>{let n=ht[t];return n?e[n]:e.downloadDiagramAsSource},Ae=e=>e==="mermaid"?"Mermaid plugin not available":e==="plantuml"?"PlantUML plugin not available":e==="vega"?"Vega plugin not available":e==="smiles"?"SMILES plugin not available":"Diagram plugin not available";var se=(e,t)=>e===void 0&&t===void 0?void 0:{...typeof e=="object"&&e!==null?e:{},language:t};var xt=new Set(["vega","smiles"]),ae=({chart:e,className:t,config:n,fallbackName:s,fullscreen:a=false,language:i$1,plugin:l,showControls:u$1=true})=>{var G,te;let o=f(),r$1=i(),m=(te=(G=l==null?void 0:l.name)!=null?G:s)!=null?te:"diagram",[p,x]=useState(null),[d,v]=useState(false),[h,S]=useState(""),[f$1,D]=useState(null),[w,N]=useState(""),[R,C]=useState(0),b=useContext(r),g=re(b,m),P=g==null?void 0:g.errorComponent,k=c(),M=xt.has(m),{shouldRender:Z,containerRef:F}=u({immediate:a});if(useEffect(()=>{if(!Z||M&&k)return;if(!l){x(J(r$1,m,"missing"));return}(async()=>{try{x(null),v(!0);let{svg:_}=await l.render(e,se(n,i$1)),U=pe(_),z=a?_:ze(_);S(z),D(U),N(z);}catch(_){w||h||x(_ instanceof Error?_.message:J(r$1,m,"failed"));}finally{v(false);}})();},[e,n,i$1,R,Z,l,k,M]),!(Z||h||w))return jsx("div",{className:o("my-4 min-h-[200px]",t),ref:F});if(M&&k&&!h&&!w)return jsx("div",{className:o("my-4 flex justify-center p-4",t),ref:F,children:jsxs("div",{className:o("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:o("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:o("text-sm"),children:r$1.diagramWriting})]})});if(d&&!h&&!w)return jsx("div",{className:o("my-4 flex justify-center p-4",t),ref:F,children:jsxs("div",{className:o("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:o("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:o("text-sm"),children:r$1.diagramLoading})]})});if(p&&!h&&!w){let K=()=>C(_=>_+1);return P?jsx("div",{ref:F,children:jsx(P,{chart:e,error:p,retry:K})}):jsxs("div",{className:o("rounded-md bg-red-50 p-4",t),ref:F,children:[jsxs("p",{className:o("font-mono text-red-700 text-sm"),children:[J(r$1,m,"error"),": ",p]}),jsxs("details",{className:o("mt-2"),children:[jsx("summary",{className:o("cursor-pointer text-red-600 text-xs"),children:r$1.showCode}),jsx("pre",{className:o("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let le=h||w;return jsx("div",{className:o(a?"size-full":"max-h-[min(70vh,40rem)] w-full",t),"data-streamdown":m,ref:F,children:jsx(Re,{className:o(a?"size-full overflow-hidden":"max-h-[min(70vh,40rem)] overflow-hidden",t),contentSize:f$1,fitKey:e,fullscreen:a,isAutoFit:true,maxZoom:3,minZoom:.1,showControls:u$1,zoomStep:.1,children:jsx("div",{"aria-label":J(r$1,m,"chart"),className:o("flex justify-center",a?"size-full items-center":null),dangerouslySetInnerHTML:{__html:le},role:"img"})})})};var Be=(e,t)=>{var n;return typeof e=="boolean"?e:t!=="diagrams"&&t in e?e[t]:(n=e.diagrams)==null?void 0:n[t]},Ve=(e,t)=>typeof e=="boolean"?e:Be(e,t)!==false,O=(e,t,n)=>{if(typeof e=="boolean")return e;let s=Be(e,t);return s===false?false:s===true||s===void 0?true:typeof s=="object"&&s!==null?s[n]!==false:true};var ie=({chart:e,children:t,className:n,config:s,language:a,name:i$1,onDownload:l$1,onError:u,plugin:o,sourceExtension:r$1})=>{var b;let m=f(),[p,x]=useState(false),d$1=useRef(null),{isAnimating:v,controls:h}=useContext(r),S=j(),f$1=i(),D=(b=r$1!=null?r$1:o==null?void 0:o.sourceExtension)!=null?b:"txt",w=l(h,i$1,"diagram"),N=g=>{x(false),l$1==null||l$1(g);},R=async g=>{if(!o){u==null||u(new Error(Ae(i$1)));return}let{svg:P}=await o.render(e,se(s,a));if(!P){u==null||u(new Error("SVG not found. Please wait for the diagram to render."));return}let k=Ie(P);if(g==="svg"){d(`${w}.svg`,k,"image/svg+xml"),N(g);return}let M=await He(k);d(`${w}.png`,M,"image/png"),N(g);},C=async g=>{try{if(g==="source"){d(`${w}.${D}`,e,"text/plain"),N(g);return}await R(g);}catch(P){u==null||u(P);}};return useEffect(()=>{let g=P=>{let k=P.composedPath();d$1.current&&!k.includes(d$1.current)&&x(false);};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g);}},[]),jsxs("div",{className:m("relative"),ref:d$1,children:[jsx("button",{"aria-label":f$1.downloadDiagram,className:m("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:v,onClick:()=>x(!p),title:f$1.downloadDiagram,type:"button",children:t!=null?t:jsx(S.DownloadIcon,{"aria-hidden":"true",size:14})}),p?jsxs("div",{className:m("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":f$1.downloadDiagramAsSvg,className:m("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>C("svg"),title:f$1.downloadDiagramAsSvg,type:"button",children:f$1.mermaidFormatSvg}),jsx("button",{"aria-label":f$1.downloadDiagramAsPng,className:m("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>C("png"),title:f$1.downloadDiagramAsPng,type:"button",children:f$1.mermaidFormatPng}),jsx("button",{"aria-label":fe(f$1,i$1),className:m("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>C("source"),title:fe(f$1,i$1),type:"button",children:Oe(f$1,i$1,D)})]}):null]})};var Ge=({DiagramComponent:e,chart:t,className:n,config:s$1,language:a,name:i$1,onExit:l,onFullscreen:u,plugin:o,sourceExtension:r$1,...m})=>{let{Maximize2Icon:p$1,XIcon:x}=j(),d=f(),[v,h]=useState(false),{isAnimating:S,controls:f$1,portal:D}=useContext(r),w=i(),N=O(f$1,i$1,"panZoom"),R=O(f$1,i$1,"download"),C=()=>{h(!v);};return useEffect(()=>{if(v){p();let b=g=>{g.key==="Escape"&&h(false);};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),q$1();}}},[v]),useEffect(()=>{v?u==null||u():l&&l();},[v,u,l]),jsxs(Fragment,{children:[jsx("button",{className:d("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:S,onClick:C,title:w.viewFullscreen,type:"button",...m,"aria-label":w.viewFullscreen,children:jsx(p$1,{"aria-hidden":"true",size:14})}),v?createPortal(jsxs("div",{"aria-label":w.viewFullscreen,"aria-modal":"true",className:d("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":`${i$1}-fullscreen`,onClick:C,onKeyDown:b=>{b.key==="Escape"&&C();},role:"dialog",children:[jsxs("div",{className:d("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:[R?jsx(ie,{chart:t,config:s$1,language:a,name:i$1,plugin:o,sourceExtension:r$1}):null,jsx("button",{"aria-label":w.exitFullscreen,className:d("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:C,title:w.exitFullscreen,type:"button",children:jsx(x,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:d("flex size-full items-center justify-center p-4"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:e?jsx(e,{chart:t,className:d("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:s$1,fullscreen:true,language:a,showControls:N}):jsx(ae,{chart:t,className:d("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:s$1,fallbackName:i$1,fullscreen:true,language:a,plugin:o,showControls:N})})]}),s(D)):null]})};var Kn=({className:e,code:t,isBlockIncomplete:n,language:s,plugin:a})=>{var g;let i$1=f(),l=i(),u=useContext(r),{controls:o}=u,r$1=a.name,m$1=re(u,r$1),p=r$1==="smiles",x=Pe(m$1==null?void 0:m$1.config),[d,v]=useState({code:t}),h=d.code===t?d.override:void 0,S=(g=h!=null?h:x)!=null?g:Ne(t),f$1=p?Ee(m$1==null?void 0:m$1.config,S):m$1==null?void 0:m$1.config,D=O(o,r$1,"download"),w=O(o,r$1,"copy"),N=O(o,r$1,"fullscreen"),R=O(o,r$1,"panZoom"),C=p&&O(o,r$1,"compact"),b=Ve(o,r$1)&&(D||w||N||C);return jsxs("div",{className:i$1("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-streamdown":`${r$1}-block`,children:[jsx("div",{className:i$1("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:i$1("ml-1 font-mono lowercase"),children:s})}),b?jsx("div",{className:i$1("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:i$1("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":`${r$1}-block-actions`,children:[C?jsx(Te,{compact:S,onToggle:()=>v({code:t,override:!S})}):null,D?jsx(ie,{chart:t,config:f$1,language:s,name:r$1,plugin:a,sourceExtension:a.sourceExtension}):null,w?jsx(k,{code:t,label:l.copyDiagram,...m(o,r$1)}):null,N?jsx(Ge,{chart:t,config:f$1,language:s,name:r$1,plugin:a,sourceExtension:a.sourceExtension}):null]})}):null,jsx("div",{className:i$1("overflow-hidden rounded-md border border-border bg-background"),children:jsx(ae,{chart:t,config:f$1,fallbackName:r$1,language:s,plugin:a,showControls:R})})]})};
3
+ export{Kn as DiagramCodeBlock};
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import {a,f,b,i,c,g,h,e,d}from'./chunk-GKDS2YGT.js';import {createContext,memo,useContext,useMemo,lazy,isValidElement,useLayoutEffect,useId,useRef,useEffect,useDeferredValue,useState,createElement,useCallback,Suspense,cloneElement}from'react';import {harden}from'rehype-harden';import fo from'rehype-raw';import cs,{defaultSchema}from'rehype-sanitize';import fc from'remark-gfm';import gc from'remend';import {visitParents,SKIP as SKIP$1}from'unist-util-visit-parents';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import Na from'remark-parse';import Aa from'remark-rehype';import {unified}from'unified';import {visit,SKIP}from'unist-util-visit';import {toText}from'hast-util-to-text';import {Lexer}from'marked';var hs=300,ys="300px",Cs=500;function En(e={}){let{immediate:t=false,debounceDelay:n=hs,rootMargin:o=ys,idleTimeout:r=Cs}=e,[s,a]=useState(false),l=useRef(null),i=useRef(null),c=useRef(null),d=useMemo(()=>g=>{let p=Date.now();return window.setTimeout(()=>{g({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-p))});},1)},[]),m=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(g,p)=>window.requestIdleCallback(g,p):d,[d]),u=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?g=>window.cancelIdleCallback(g):g=>{clearTimeout(g);},[]);return useEffect(()=>{if(t){a(true);return}let g=l.current;if(!g)return;i.current&&(clearTimeout(i.current),i.current=null),c.current&&(u(c.current),c.current=null);let p=()=>{i.current&&(clearTimeout(i.current),i.current=null),c.current&&(u(c.current),c.current=null);},h=x=>{c.current=m(v=>{v.timeRemaining()>0||v.didTimeout?(a(true),x.disconnect()):c.current=m(()=>{a(true),x.disconnect();},{timeout:r/2});},{timeout:r});},f=x=>{p(),i.current=window.setTimeout(()=>{var L,H;let v=x.takeRecords();(v.length===0||(H=(L=v.at(-1))==null?void 0:L.isIntersecting)!=null&&H)&&h(x);},n);},b=(x,v)=>{x.isIntersecting?f(v):p();},y=new IntersectionObserver(x=>{for(let v of x)b(v,y);},{rootMargin:o,threshold:0});return y.observe(g),()=>{i.current&&clearTimeout(i.current),c.current&&u(c.current),y.disconnect();}},[t,n,o,r,u,m]),{shouldRender:s,containerRef:l}}var xs=320,ws=4,Ln=()=>typeof performance=="undefined"?Date.now():performance.now();function Ht(e){var s,a;let t=(s=e==null?void 0:e.now)!=null?s:Ln,n=(a=e==null?void 0:e.maxBacklogMs)!=null?a:xs,o=0,r=0;return {now:t,beginPass(l){r=Math.min(Math.max(o,l),l+n);},mark(){return r},rewind(l){r=l;},take(l,i,c){if(l<=0)return {baseDelay:0,step:Math.max(0,i)};let d=Math.max(0,i),m=d===0?0:Math.min(d,ws),u=Math.max(r,c),g=c+n,p=u+Math.max(0,l-1)*d,h=d;if(p>g&&l>1)if(u<g){let b=g-u;h=Math.max(m,b/(l-1));}else h=m;let f=Math.max(0,Math.round(u-c));return r=u+l*h,{baseDelay:f,step:h}},commitPass(){o=r;}}}function ks(){return {current:0}}var Mn=/\s/,Bt=/^\s+$/,vs=new Set(["pre","svg","math","annotation"]),Ps=new Set(["svg","math","annotation"]),Ot=new Set(["img","hr"]),Ss=new Set(["ul","ol","li"]),xe=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",Vt=(e,t)=>{let n=t?Ps:vs;return e.some(o=>xe(o)&&n.has(o.tagName))},Ts=e=>{for(let t=e.length-1;t>=0;t-=1){let n=e[t];if(xe(n)&&n.tagName==="li")return n}},Es=(e,t,n,o)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate-marker"]=true,e.properties.style=`--sd-marker-duration:${t}ms;--sd-marker-delay:${n}ms;--sd-marker-easing:${o}`;},Nn=e=>{for(let t of e.children)if(xe(t)){if(t.tagName==="input")return t;if(Ss.has(t.tagName))continue;let n=Nn(t);if(n)return n}},An=(e,t,n,o)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate"]=true;let r=typeof e.properties.style=="string"?`${e.properties.style};`:"";e.properties.style=`${r}--sd-animation:sd-${t.animation};--sd-duration:${n}ms;--sd-easing:${t.easing};--sd-delay:${o}ms`;},Rs=(e,t,n,o)=>{let r=Nn(e);r&&An(r,t,n,o);},Dn=e=>{var t;for(let n=e.length-1;n>=0;n-=1){let o=e[n];if(xe(o)){if((t=o.properties)!=null&&t["data-sd-animated"])break;o.properties={...o.properties,"data-sd-animated":true};}}},On=e=>{let t=[],n="",o=false;for(let r of e){let s=Mn.test(r);if(s!==o&&n){if(s){n+=r,o=true;continue}t.push(n),n="";}n+=r,o=s;}return n&&t.push(n),t},Hn=e=>{let t=[],n="";for(let o of e)Mn.test(o)?t.length>0&&!Bt.test(t.at(-1))?t[t.length-1]+=o:n+=o:(n&&(t.push(n),n=""),t.push(o));return n&&(t.length>0?t[t.length-1]+=n:t.push(n)),t},Is=(e,t,n,o,r,s)=>{let a=`--sd-animation:sd-${t};--sd-duration:${r?0:n}ms;--sd-easing:${o}`;return s&&(a+=`;--sd-delay:${Math.round(s)}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:a},children:[{type:"text",value:e}]}},Ls=(e,t,n,o)=>{let r=0,s=0;return visitParents(e,a=>a.type==="text"||xe(a)&&Ot.has(a.tagName),(a,l)=>{if(Vt(l,n.animateCodeBlocks))return SKIP$1;if(xe(a)&&Ot.has(a.tagName)){o>0&&s<o||(r+=1),s+=1;return}let i=a.value;if(!i.trim()){s+=i.length;return}let c=t.sep==="char"?Hn(i):On(i);for(let d of c){let m=s;s+=d.length,!Bt.test(d)&&(o>0&&m<o||(r+=1));}}),r},Ms=(e,t,n,o,r,s)=>{if(Vt(t,o.animateCodeBlocks))return;let a=o.prevContentLength,l=r.count;r.count+=1;let i=a>0&&l<a,c=i?0:s.baseDelay+r.newIndex++*s.step;An(e,n,i?0:n.duration,c),Dn(t);},Ns=(e,t,n,o,r,s)=>{var b;let a=t.at(-1);if(!(a&&"children"in a))return;if(Vt(t,o.animateCodeBlocks))return SKIP$1;let l=a,i=l.children.indexOf(e);if(i===-1)return;let c=e.value;if(!c.trim()){r.count+=c.length;return}let d=n.sep==="char"?Hn(c):On(c),m=o.prevContentLength,u=false,g=Ts(t),p=!!(g&&!((b=g.properties)!=null&&b["data-sd-animate-marker"])),h=false,f=d.map(y=>{let x=r.count;if(r.count+=y.length,Bt.test(y))return {type:"text",value:y};let v=m>0&&x<m,S=v?0:s.baseDelay+r.newIndex++*s.step;if(g&&p&&!h){let L=v?0:n.duration;Es(g,L,S,n.easing),Rs(g,n,L,S),h=true;}return u=true,Is(y,n.animation,n.duration,n.easing,v,S)});return u&&Dn(t),l.children.splice(i,1,...f),i+f.length},As=0;function ut(e){var s,a,l,i,c;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",duration:(a=e==null?void 0:e.duration)!=null?a:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(c=e==null?void 0:e.stagger)!=null?c:40,timeline:e==null?void 0:e.timeline},n={animateCodeBlocks:false,committedCharCount:0,prevContentLength:0,lastRenderCharCount:0,pendingMark:null},o=As++,r=()=>d=>{var h;let m={count:0,newIndex:0};n.prevContentLength=n.committedCharCount;let u=t.timeline,g=(h=u==null?void 0:u.now())!=null?h:Ln();u&&(n.pendingMark===null?n.pendingMark=u.mark():u.rewind(n.pendingMark));let p=u?u.take(Ls(d,t,n,n.prevContentLength),t.stagger,g):{baseDelay:0,step:t.stagger};visitParents(d,f=>f.type==="text"||xe(f)&&Ot.has(f.tagName),(f,b)=>{if(f.type==="text")return Ns(f,b,t,n,m,p);Ms(f,b,t,n,m,p);}),n.lastRenderCharCount=m.count,n.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${o}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(d){n.animateCodeBlocks=d;},setPrevContentLength(d){n.committedCharCount=d,n.prevContentLength=d;},getLastRenderCharCount(){return n.lastRenderCharCount},commit(){n.committedCharCount=n.lastRenderCharCount,n.pendingMark=null;}}}ut();var _t=createContext(false),_e=()=>useContext(_t);function Bn(e){let t=[],n=[],o=0;return r=>{let s=new Map;for(let i=0;i<t.length;i+=1){let c=t[i],d=n[i];c!==void 0&&d!==void 0&&!s.has(c)&&s.set(c,d);}let a=new Set,l=r.map((i,c)=>{let d=t[c],m=n[c];if(d!==void 0&&m!==void 0&&!a.has(m)&&(d===i||i.startsWith(d)))return a.add(m),m;let u=s.get(i);if(u!==void 0&&!a.has(u))return a.add(u),u;let g=`${e}-${o}`;return o+=1,a.add(g),g});return t=r,n=l,l}}var je=({scrollRef:e,ref:t,...n})=>jsx("div",{ref:e,...n});var _s=8,js=e=>e.scrollHeight-e.scrollTop-e.clientHeight<_s,Fn=e=>{var n,o;let t=(o=(n=e.touches[0])!=null?n:e.changedTouches[0])!=null?o:null;return typeof(t==null?void 0:t.clientY)=="number"?t.clientY:null},pt=({enabled:e,isAnimating:t,content:n})=>{let[o,r]=useState(null),s=useRef(true),a=useRef(0),l=useCallback(c=>{r(d=>d===c?d:c);},[]),i=useCallback(c=>{t&&s.current&&(c.scrollTo({top:c.scrollHeight,behavior:"instant"}),a.current=c.scrollTop);},[t]);return useEffect(()=>{t||(s.current=true);},[t]),useEffect(()=>{if(!(e&&o))return;a.current=o.scrollTop;let c=()=>{s.current=false;},d=f=>{f.deltaY<0&&c();},m=null,u=f=>{m=Fn(f);},g=f=>{if(m===null)return;let b=Fn(f);if(b===null)return;let y=b-m;Math.abs(y)<=3||(y>0&&c(),m=b);},p=()=>{m=null;},h=()=>{let f=o.scrollTop<a.current;if(a.current=o.scrollTop,f){c();return}js(o)&&(s.current=true);};return o.addEventListener("wheel",d,{capture:true,passive:true}),o.addEventListener("touchstart",u,{passive:true}),o.addEventListener("touchmove",g,{passive:true}),o.addEventListener("touchend",p,{passive:true}),o.addEventListener("touchcancel",p,{passive:true}),o.addEventListener("scroll",h,{passive:true}),()=>{o.removeEventListener("wheel",d,{capture:true}),o.removeEventListener("touchstart",u),o.removeEventListener("touchmove",g),o.removeEventListener("touchend",p),o.removeEventListener("touchcancel",p),o.removeEventListener("scroll",h);}},[e,o]),useLayoutEffect(()=>{if(!(e&&o)||(i(o),typeof ResizeObserver=="undefined"))return;let c=new ResizeObserver(()=>{i(o);});c.observe(o);for(let d of o.children)c.observe(d);return ()=>{c.disconnect();}},[n,o,e,i]),l};var zs=a("block"),Ws=a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),qs=e=>{let t={};for(let n of e.split(";")){let o=n.indexOf(":");if(o>0){let r=n.slice(0,o).trim(),s=n.slice(o+1).trim();r&&s&&(t[r]=s);}}return t},$n=memo(({children:e,result:t,language:n,className:o,maxHeight:r,startLine:s,lineNumbers:a=true,...l})=>{let i=f(),{isAnimating:c,scrollable:d}=useContext(T),m=d!=null?d:je,u=b(r),g=pt({content:t,enabled:!!u,isAnimating:c}),p=useMemo(()=>i(Ws),[i]),h=useMemo(()=>i(zs),[i]),f$1=useMemo(()=>{let b={};return t.bg&&(b["--sdm-bg"]=t.bg),t.fg&&(b["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(b,qs(t.rootStyle)),b},[t.bg,t.fg,t.rootStyle]);return jsx(m,{className:i(o,u?"overflow-x-auto overflow-y-auto":"overflow-x-auto","rounded-md border border-border bg-background p-4 text-sm"),"data-language":n,"data-streamdown":"code-block-body",scrollRef:g,style:u?{maxHeight:u}:void 0,...l,children:jsx("pre",{className:i(o,"bg-[var(--sdm-bg,inherit)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]"),style:f$1,children:jsx("code",{className:a?i("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&s&&s>1?{counterReset:`line ${s-1}`}:void 0,children:t.tokens.map((b,y)=>jsx("span",{className:a?p:h,children:b.length===0||b.length===1&&b[0].content===""?`
3
+ `:b.map((x,v)=>{let S={},L=!!x.bgColor;if(x.color&&(S["--sdm-c"]=x.color),x.bgColor&&(S["--sdm-tbg"]=x.bgColor),x.htmlStyle)for(let[H,I]of Object.entries(x.htmlStyle))H==="color"?S["--sdm-c"]=I:H==="background-color"?(S["--sdm-tbg"]=I,L=true):S[H]=I;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",L&&"bg-[var(--sdm-tbg)]",L&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:S,...x.htmlAttrs,children:x.content},v)})},y))})})})});var Ft=({className:e,language:t,style:n,isIncomplete:o,...r})=>{let s=f();return jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":o||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...r})};var $t=createContext({code:""}),ft=()=>useContext($t);var zt=({language:e})=>{let t=f();return jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var Ys=e=>{let t=e.length;for(;t>0&&e[t-1]===`
4
+ `;)t--;return e.slice(0,t)},Qs=lazy(()=>import('./highlighted-body-M2KTRTZG.js').then(e=>({default:e.HighlightedCodeBlockBody}))),Wt=({code:e,language:t,className:n,children:o,isIncomplete:r=false,startLine:s,lineNumbers:a,...l})=>{let i=f(),{codeBlockMaxHeight:c}=useContext(T),d=useMemo(()=>Ys(e),[e]),m=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
5
+ `).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]);return jsx($t.Provider,{value:{code:e},children:jsxs(Ft,{dir:"ltr",isIncomplete:r,language:t,children:[jsx(zt,{language:t}),o?jsx("div",{className:i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("div",{className:i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:o})}):null,jsx(Suspense,{fallback:jsx($n,{className:n,language:t,lineNumbers:a,maxHeight:c,result:m,startLine:s,...l}),children:jsx(Qs,{className:n,code:d,language:t,lineNumbers:a,maxHeight:c,raw:m,startLine:s,...l})})]})})};var qn=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),Kn=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),Un=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),Zn=e=>jsxs("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),Xn=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),Jn=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),Gn=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),Yn=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),Qn=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),eo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var $e={CheckIcon:qn,CopyIcon:Kn,DownloadIcon:Un,ExternalLinkIcon:Yn,Loader2Icon:Zn,Maximize2Icon:Xn,RotateCcwIcon:Jn,XIcon:Gn,ZoomInIcon:Qn,ZoomOutIcon:eo},no=createContext($e),ra=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let n=Object.keys(e),o=Object.keys(t);return n.length!==o.length?false:n.every(r=>e[r]===t[r])},qt=({icons:e,children:t})=>{let n=useRef(e),o=useRef(e?{...$e,...e}:$e);ra(n.current,e)||(n.current=e,o.current=e?{...$e,...e}:$e);let r=o.current;return jsx(no.Provider,{value:r,children:t})},B=()=>useContext(no);var gt=({onCopy:e,onError:t,timeout:n=2e3,children:o,className:r,code:s,label:a,...l})=>{let i$1=f(),[c,d]=useState(false),m=useRef(0),{code:u}=ft(),{isAnimating:g}=useContext(T),p=i(),h=s!=null?s:u,f$1=a!=null?a:p.copyCode,b=async()=>{var v;if(typeof window=="undefined"||!((v=navigator==null?void 0:navigator.clipboard)!=null&&v.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{c||(await navigator.clipboard.writeText(h),d(!0),e==null||e(),m.current=window.setTimeout(()=>d(!1),n));}catch(S){t==null||t(S);}};useEffect(()=>()=>{window.clearTimeout(m.current);},[]);let y=B(),x=c?y.CheckIcon:y.CopyIcon;return jsxs(Fragment,{children:[jsx("button",{"aria-label":f$1,className:i$1("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:g,onClick:b,title:f$1,type:"button",...l,children:o!=null?o:jsx(x,{"aria-hidden":"true",size:14})}),c&&jsx("output",{"aria-live":"polite",className:"sr-only",children:p.copied})]})};var bt=e=>typeof e=="object"&&e!==null,oo=(e,t)=>{var n;if(typeof e!="boolean")return t!=="diagrams"&&t in e?e[t]:(n=e.diagrams)==null?void 0:n[t]},ke=(e,t,n)=>{if(typeof e=="boolean")return n;let o=oo(e,t);if(!bt(o))return n;let r=o.download;return !bt(r)||typeof r.filename!="string"?n:r.filename||n};function ze(e,t){if(typeof e=="boolean")return {};let n=oo(e,t);if(!bt(n))return {};let o=n.copy;return bt(o)?{onCopy:typeof o.onCopy=="function"?o.onCopy:void 0,onError:typeof o.onError=="function"?o.onError:void 0}:{}}var ro={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",smiles:"smi",smi:"smi",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",vega:"vg.json","vega-lite":"vl.json",vegalite:"vl.json",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",\u6587\u8A00:"wy"},Ut=({onDownload:e,onError:t,language:n,children:o,className:r,code:s,...a})=>{let l=f(),{code:i$1}=ft(),{isAnimating:c,controls:d$1}=useContext(T),m=i(),u=B(),g=s!=null?s:i$1,p=n&&n in ro?ro[n]:"txt",h=`${ke(d$1,"code","file")}.${p}`,f$1="text/plain",b=()=>{try{d(h,g,f$1),e==null||e();}catch(y){t==null||t(y);}};return jsx("button",{"aria-label":m.downloadFile,className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:c,onClick:b,title:m.downloadFile,type:"button",...a,children:o!=null?o:jsx(u.DownloadIcon,{size:14})})};var We=()=>{let{Loader2Icon:e}=B(),t=f();return jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:jsx(e,{className:t("size-4 animate-spin")})})]})};var qe=0,ce=()=>{qe+=1,qe===1&&(document.body.style.overflow="hidden");},de=()=>{qe=Math.max(0,qe-1),qe===0&&(document.body.style.overflow="");};var ga=["github-light","github-dark"],ba={enabled:true},ha={codeBlockMaxHeight:400,shikiTheme:ga,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,openscad:void 0,plantuml:void 0,smiles:void 0,vega:void 0,diagrams:void 0,linkSafety:ba,portal:void 0,tableMaxHeight:300},T=createContext(ha);var wa=/\.[^/.]+$/,io=(e,t)=>{if(typeof e=="boolean")return e;let n=e.image;return n===false?false:n===true||n===void 0?true:n[t]!==false},lo=({node:e,className:t,src:n,alt:o,onLoad:r,onError:s,onClick:a,...l})=>{let{DownloadIcon:i$1,XIcon:c}=B(),d$1=f(),m=useRef(null),[u,g]=useState(false),[p,h]=useState(false),[f$1,b]=useState(false),{controls:y}=useContext(T),x=i(),v=io(y,"download"),S=io(y,"fullscreen"),L=l.width!=null||l.height!=null,H=v&&(u||L)&&!p,I=p&&!L,V=S&&!!n&&!p&&u;useEffect(()=>{let R=m.current;if(R!=null&&R.complete){let M=R.naturalWidth>0;g(M),h(!M);}},[]),useEffect(()=>{if(!f$1)return;ce();let R=M=>{M.key==="Escape"&&b(false);};return document.addEventListener("keydown",R),()=>{document.removeEventListener("keydown",R),de();}},[f$1]);let Z=useCallback(R=>{g(true),h(false),r==null||r(R);},[r]),X=useCallback(R=>{g(false),h(true),s==null||s(R);},[s]),P=useCallback(()=>{V&&b(true);},[V]),J=useCallback(()=>{b(false);},[]),ue=useCallback(R=>{a==null||a(R),!R.defaultPrevented&&P();},[a,P]),pe=async R=>{if(R.stopPropagation(),!!n)try{let _=await(await fetch(n)).blob(),K=new URL(n,window.location.origin).pathname.split("/").pop()||"",Be=K.split(".").pop(),at=K.includes(".")&&Be!==void 0&&Be.length<=4,Ee="";if(at)Ee=K;else {let ne=_.type,oe="png";ne.includes("jpeg")||ne.includes("jpg")?oe="jpg":ne.includes("png")?oe="png":ne.includes("svg")?oe="svg":ne.includes("gif")?oe="gif":ne.includes("webp")&&(oe="webp"),Ee=`${(o||K||"image").replace(wa,"")}.${oe}`;}d(Ee,_,_.type);}catch(M){window.open(n,"_blank");}};return n?n==="streamdown:incomplete-image"?jsx("div",{className:d$1("group relative my-4 inline-block"),"data-incomplete":"true","data-streamdown":"image-wrapper",children:jsx("div",{className:d$1("h-24 w-48 animate-pulse rounded-lg bg-muted"),"data-streamdown":"image-placeholder"})}):jsxs(Fragment,{children:[jsxs("div",{className:d$1("group/image not-prose relative my-2 block max-w-full"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:o,className:d$1("m-0 block h-auto max-w-full rounded-lg",V&&"cursor-zoom-in",I&&"hidden",t),"data-streamdown":"image",onClick:ue,onError:X,onLoad:Z,ref:m,src:n,...l}),I&&jsx("span",{className:d$1("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:x.imageNotAvailable}),H&&jsx("button",{"aria-label":x.downloadImage,className:d$1("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 focus-visible:opacity-100 group-hover/image:opacity-100"),onClick:pe,title:x.downloadImage,type:"button",children:jsx(i$1,{size:14})})]}),f$1?createPortal(jsxs("div",{className:d$1("fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4"),"data-streamdown":"image-lightbox",onClick:J,onKeyDown:R=>{R.key==="Escape"&&J();},role:"button",tabIndex:0,children:[jsx("button",{"aria-label":x.exitFullscreen,className:d$1("absolute top-4 right-4 z-10 rounded-md p-2 text-white/80 transition-colors hover:bg-white/10 hover:text-white"),onClick:J,title:x.exitFullscreen,type:"button",children:jsx(c,{size:20})}),jsx("div",{onClick:R=>R.stopPropagation(),onKeyDown:R=>R.stopPropagation(),role:"presentation",children:jsx("img",{alt:o,className:d$1("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:n})})]}),document.body):null]}):null};var Me=e=>{let t=typeof e=="function"?e():e;return t!=null?t:document.body};var uo=({url:e,isOpen:t,onClose:n,onConfirm:o})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=B(),i$1=f(),[c,d]=useState(false),m=i(),{portal:u}=useContext(T),g=useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(f){}},[e]),p=useCallback(()=>{o(),n();},[o,n]);if(useEffect(()=>{if(t){ce();let f=b=>{b.key==="Escape"&&n();};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),de();}}},[t,n]),!t||typeof document=="undefined")return null;let h=jsx("div",{className:i$1("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:n,onKeyDown:f=>{f.key==="Escape"&&n();},role:"button",tabIndex:0,children:jsxs("div",{className:i$1("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:f=>f.stopPropagation(),onKeyDown:f=>f.stopPropagation(),role:"presentation",children:[jsx("button",{"aria-label":m.close,className:i$1("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:n,title:m.close,type:"button",children:jsx(l,{size:16})}),jsxs("div",{className:i$1("flex flex-col gap-2"),children:[jsxs("div",{className:i$1("flex items-center gap-2 font-semibold text-lg"),children:[jsx(a,{size:20}),jsx("span",{children:m.openExternalLink})]}),jsx("p",{className:i$1("text-muted-foreground text-sm"),children:m.externalLinkWarning})]}),jsx("div",{className:i$1("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:i$1("flex gap-2"),children:[jsx("button",{className:i$1("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:g,type:"button",children:c?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:m.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:m.copyLink})]})}),jsxs("button",{className:i$1("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:p,type:"button",children:[jsx(a,{size:14}),jsx("span",{children:m.openLink})]})]})]})});return createPortal(h,Me(u))};var po=()=>e=>{visit(e,"html",(n,o,r)=>{!r||typeof o!="number"||(r.children[o]={type:"text",value:n.value});});};var go=[],bo={allowDangerousHtml:true},ht=new WeakMap,Yt=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(o||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return "";let u="";for(let g=0;g<m.length;g+=1){let p=m[g];if(g>0&&(u+=","),Array.isArray(p)){let[h,f]=p;if(typeof h=="function"){let b=ht.get(h);b||(b=h.name,ht.set(h,b)),u+=b;}else u+=String(h);u+=":",u+=JSON.stringify(f);}else if(typeof p=="function"){let h=ht.get(p);h||(h=p.name,ht.set(p,h)),u+=h;}else u+=String(p);}return u},l=a(o),i=a(r),c=s?JSON.stringify(s):"",d=`${i}::${l}::${c}`;return this.keyCache.set(t,d),d}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(o,n);}clear(){this.cache.clear();}},ho=new Yt,Ue=e=>{let t=Ha(e),n=e.children||"",o=t.runSync(t.parse(n),n);return $a(o,e)},Ha=e=>{let t=ho.get(e);if(t)return t;let n=Va(e);return ho.set(e,n),n},Ba=e=>e.some(t=>Array.isArray(t)?t[0]===fo:t===fo),Va=e=>{let t=e.rehypePlugins||go,n=e.remarkPlugins||go,o=Ba(t)?n:[...n,po],r=e.remarkRehypeOptions?{...bo,...e.remarkRehypeOptions}:bo;return unified().use(Na).use(o).use(Aa,r).use(t)},yo=e=>e,_a=(e,t,n,o)=>{n?e.children.splice(t,1):e.children[t]={type:"text",value:o};},ja=(e,t)=>{var n;for(let o in urlAttributes)if(Object.hasOwn(urlAttributes,o)&&Object.hasOwn(e.properties,o)){let r=e.properties[o],s=urlAttributes[o];(s===null||s.includes(e.tagName))&&(e.properties[o]=(n=t(String(r||""),o,e))!=null?n:void 0);}},Fa=(e,t,n,o,r,s)=>{let a=false;return o?a=!o.includes(e.tagName):r&&(a=r.includes(e.tagName)),!a&&s&&typeof t=="number"&&(a=!s(e,t,n)),a},$a=(e,t)=>{let{allowElement:n,allowedElements:o,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:l}=t;if(n||o||r||s||l){let c=l||yo;visit(e,(d,m,u)=>{if(d.type==="raw"&&u&&typeof m=="number")return _a(u,m,s,d.value),m;if(d.type==="element"&&(ja(d,c),Fa(d,m,u,o,r,n)&&u&&typeof m=="number"))return a&&d.children?u.children.splice(m,1,...d.children):u.children.splice(m,1),m});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var Co=/[(){}[\]]/,za=/[\s;]/,Wa=/^[\w-]+$/,qa=/:::[\w-]+\s*$/,Ka=/^[/\\]/,Ua=/[/\\]$/,Za=/("[^"]*")/,Xa=[["((","))"],["))","(("],["{{","}}"],["[","]"],["(",")"],[")","("]],Ze=e=>`"${e.replace(/"/g,"#quot;")}"`,Ja=e=>e.length>=2&&e.startsWith('"')&&e.endsWith('"'),Ga=e=>{var o,r,s,a;let t=e.split(`
6
+ `),n=0;if(((o=t[n])==null?void 0:o.trim())==="---"){for(n+=1;n<t.length&&((r=t[n])==null?void 0:r.trim())!=="---";)n+=1;n+=1;}for(;n<t.length;){let l=(a=(s=t[n])==null?void 0:s.trim())!=null?a:"";if(l&&!l.startsWith("%%")){let i=l.split(za,1)[0];return i==="mindmap"?"mindmap":i==="flowchart"||i==="graph"?"flowchart":null}n+=1;}return null},Ya=e=>{for(let[t,n]of Xa){let o=e.indexOf(t);if(o===-1||!e.endsWith(n))continue;let r=e.slice(0,o);if(r&&!Wa.test(r))continue;let s=e.slice(o+t.length,e.length-n.length);if(!(s.includes(n)&&n!==t))return {id:r,open:t,close:n,inner:s}}return null},Qa=e=>{let t=e.length-e.trimStart().length,n=e.slice(0,t),o=e.trim();if(!o||o.startsWith("%%")||o.startsWith("::icon"))return e;let r=Ya(o);if(r)return !Ja(r.inner)&&(Co.test(r.inner)||r.inner.includes('"'))?`${n}${r.id}${r.open}${Ze(r.inner)}${r.close}`:e;if(Co.test(o)){let s=o.replace(qa,"").trimEnd();return `${n}[${Ze(s)}]`}return e},ei=e=>{let t=e.split(`
7
+ `),n=false;return t.map(o=>n?Qa(o):(o.trim()&&(n=true),o)).join(`
8
+ `)},ti=e=>e.startsWith("(")&&e.endsWith(")")||Ka.test(e)||Ua.test(e),Qt=(e,t)=>e.split(Za).map((n,o)=>o%2===0?t(n):n).join(""),ni=e=>{if(e.trim().startsWith("%%"))return e;let t=Qt(e,n=>n.replace(/\[([^[\]"]*[(){}][^[\]"]*)\]/g,(o,r)=>ti(r)?o:`[${Ze(r)}]`));return t=Qt(t,n=>n.replace(/\{([^{}"]*[()[\]][^{}"]*)\}/g,(o,r)=>`{${Ze(r)}}`)),t=Qt(t,n=>n.replace(/\|([^|"]*[(){}[\]][^|"]*)\|/g,(o,r)=>`|${Ze(r)}|`)),t},oi=e=>e.split(`
9
+ `).map(ni).join(`
10
+ `),xo=e=>{let t=Ga(e);if(!t)return null;let n=t==="mindmap"?ei(e):oi(e);return n===e?null:n};var ri=()=>{if(typeof document=="undefined")return false;let e=document.documentElement;return e.classList.contains("dark")||e.dataset.theme==="dark"||e.dataset.colorMode==="dark"},si=(e,t)=>Array.isArray(t)?t.includes(e):t===e,ai=e=>"getMermaid"in e&&typeof e.getMermaid=="function",ii=e=>"getPlantUml"in e&&typeof e.getPlantUml=="function",li=e=>"getVega"in e&&typeof e.getVega=="function",ci=e=>"getSmiles"in e&&typeof e.getSmiles=="function";var di=e=>{let t=e.split("").reduce((n,o)=>(n<<5)-n+o.charCodeAt(0)|0,0);return `mermaid-${Math.abs(t)}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`},mi=async(e,t,n)=>{try{return await e.render(t,n)}catch(o){let r=xo(n);if(!r)throw o;try{return await e.render(`${t}-autofix`,r)}catch(s){throw o}}},ui=e=>{var t,n;return ai(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:"mmd",render:async(o,r)=>{let s=e.getMermaid(r);return await mi(s,di(o),o)}}:ii(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:"puml",render:async(o,r)=>{var l;let s=r,a=(l=s==null?void 0:s.dark)!=null?l:ri();return await e.getPlantUml(s).render(o,{...s,dark:a})}}:li(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:(t=e.sourceExtension)!=null?t:"json",render:(o,r)=>e.getVega(r).render(o,r)}:ci(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:(n=e.sourceExtension)!=null?n:"smi",render:(o,r)=>e.getSmiles(r).render(o,r)}:e},wo=e=>{var n;if(!e)return [];let t=[];return e.mermaid&&t.push(e.mermaid),e.plantuml&&t.push(e.plantuml),e.vega&&t.push(e.vega),e.smiles&&t.push(e.smiles),[...t,...(n=e.diagrams)!=null?n:[]].map(ui)},ko=(e,t)=>{var n;return (n=e.find(o=>si(t,o.language)))!=null?n:null};var yt=createContext(null),Ct=()=>useContext(yt),Mm=()=>{var t;let e=Ct();return (t=e==null?void 0:e.code)!=null?t:null};var bi=()=>{let e=Ct();return useMemo(()=>wo(e),[e])},vo=e=>{let t=bi();return ko(t,e)},Ne=()=>{var t;let e=Ct();return (t=e==null?void 0:e.openscad)!=null?t:null};var Po=e=>{var n;let t=Ct();return t!=null&&t.renderers&&e&&(n=t.renderers.find(o=>Array.isArray(o.language)?o.language.includes(e):o.language===e))!=null?n:null};var To={"3mf":"model/3mf",stl:"model/stl"},xt=({children:e,className:t,code:n,config:o,onDownload:r,onError:s})=>{let a=f(),[l,i$1]=useState(false),[c,d$1]=useState(false),m=useRef(null),{controls:u,isAnimating:g}=useContext(T),p=B(),h=Ne(),f$1=i(),b=ke(u,"openscad","model"),y=async x=>{try{if(x==="scad"){d(`${b}.scad`,n,"text/plain"),i$1(!1),r==null||r(x);return}if(!h){s==null||s(new Error("OpenSCAD plugin not available"));return}d$1(!0);let v=h.getOpenScad(o),{data:S}=await v.render(n,{...o,format:x}),L=S.buffer.slice(S.byteOffset,S.byteOffset+S.byteLength);d(`${b}.${x}`,new Blob([L],{type:To[x]}),To[x]),r==null||r(x),i$1(!1);}catch(v){s==null||s(v);}finally{d$1(false);}};return useEffect(()=>{let x=v=>{let S=v.composedPath();m.current&&!S.includes(m.current)&&i$1(false);};return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x);}},[]),jsxs("div",{className:a("relative"),ref:m,children:[jsx("button",{"aria-label":f$1.downloadModel,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:g||c,onClick:()=>i$1(!l),title:f$1.downloadModel,type:"button",children:e!=null?e:jsx(p.DownloadIcon,{"aria-hidden":"true",size:14})}),l?jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":f$1.downloadModelAsScad,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("scad"),title:f$1.downloadModelAsScad,type:"button",children:f$1.openscadFormatScad}),jsx("button",{"aria-label":f$1.downloadModelAsStl,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("stl"),title:f$1.downloadModelAsStl,type:"button",children:f$1.openscadFormatStl}),jsx("button",{"aria-label":f$1.downloadModelAs3mf,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("3mf"),title:f$1.downloadModelAs3mf,type:"button",children:f$1.openscadFormat3mf})]}):null]})};var Lo=({code:e,config:t,onFullscreen:n,onExit:o,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=B(),i$1=f(),[c,d]=useState(false),{isAnimating:m,controls:u,portal:g}=useContext(T),p=i(),h=(()=>{if(typeof u=="boolean")return u;let b=u.openscad;return b===false?false:b===true||b===void 0?true:b.download!==false})(),f$1=()=>{d(!c);};return useEffect(()=>{if(c){ce();let b=y=>{y.key==="Escape"&&d(false);};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),de();}}},[c]),useEffect(()=>{c?n==null||n():o&&o();},[c,n,o]),jsxs(Fragment,{children:[jsx("button",{className:i$1("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:f$1,title:p.viewFullscreen,type:"button",...s,"aria-label":p.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),c?createPortal(jsxs("div",{"aria-label":p.viewFullscreen,"aria-modal":"true",className:i$1("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"openscad-fullscreen",onClick:f$1,onKeyDown:b=>{b.key==="Escape"&&f$1();},role:"dialog",children:[jsxs("div",{className:i$1("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:[h?jsx(xt,{code:e,config:t}):null,jsx("button",{"aria-label":p.exitFullscreen,className:i$1("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:f$1,title:p.exitFullscreen,type:"button",children:jsx(l,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:i$1("flex size-full items-center justify-center p-4"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:jsx(Io,{className:i$1("size-full"),code:e,config:t,fullscreen:true})})]}),Me(g)):null]})};var tn=e=>e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(tn).join(""):isValidElement(e)?tn(e.props.children):"",Mo=(e,t,n)=>n!=null?n:(t?toText(t):tn(e)).replace(/\s+/g," ").trim()||void 0;function nn(e){var n;if(e.nodeType===Node.TEXT_NODE)return (n=e.textContent)!=null?n:"";if(e.nodeType!==Node.ELEMENT_NODE)return "";let t=e;return t.tagName==="BR"?`
11
+ `:Array.from(t.childNodes).map(nn).join("")}var Ae=e=>{let t=[],n=[],o=e.querySelectorAll("thead th");for(let s of o)t.push(nn(s).trim());let r=e.querySelectorAll("tbody tr");for(let s of r){let a=[],l=s.querySelectorAll("td");for(let i of l)a.push(nn(i).trim());n.push(a);}return {headers:t,rows:n}},Je=e=>{var n;if(typeof e!="object")return ",";let t=e.table;return typeof t!="object"?",":(n=t.csvSeparator)!=null?n:","},Se=(e,t=",")=>{let n;t==="auto"?Intl.NumberFormat().format(1.1).includes(",")?n=";":n=",":n=t;let{headers:o,rows:r}=e,s=c=>{let d=false;for(let m of c)if(m===n||m==='"'||m===`
12
+ `||m==="\r"){d=true;break}return d?`"${c.replace(/"/g,'""')}"`:c},a=o.length>0?r.length+1:r.length,l=new Array(a),i=0;o.length>0&&(l[i]=o.map(s).join(n),i+=1);for(let c of r)l[i]=c.map(s).join(n),i+=1;return l.join(`
13
+ `)},on=e=>{let{headers:t,rows:n}=e,o=l=>{let i=false;for(let d of l)if(d===" "||d===`
14
+ `||d==="\r"){i=true;break}if(!i)return l;let c=[];for(let d of l)d===" "?c.push("\\t"):d===`
15
+ `?c.push("\\n"):d==="\r"?c.push("\\r"):c.push(d);return c.join("")},r=t.length>0?n.length+1:n.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(o).join(" "),a+=1);for(let l of n)s[a]=l.map(o).join(" "),a+=1;return s.join(`
16
+ `)},wt=e=>{let t=false;for(let o of e)if(o==="\\"||o==="|"||o===`
17
+ `){t=true;break}if(!t)return e;let n=[];for(let o of e)o==="\\"?n.push("\\\\"):o==="|"?n.push("\\|"):o===`
18
+ `?n.push("<br>"):n.push(o);return n.join("")},De=e=>{let{headers:t,rows:n}=e;if(t.length===0)return "";let o=new Array(n.length+2),r=0,s=t.map(l=>wt(l));o[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let l=0;l<t.length;l+=1)a[l]="---";o[r]=`| ${a.join(" | ")} |`,r+=1;for(let l of n)if(l.length<t.length){let i=new Array(t.length);for(let c=0;c<t.length;c+=1)i[c]=c<l.length?wt(l[c]):"";o[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(c=>wt(c));o[r]=`| ${i.join(" | ")} |`,r+=1;}return o.join(`
19
+ `)};var Ye=({children:e,className:t,onCopy:n,onError:o,timeout:r=2e3})=>{let s=f(),[a,l]=useState(false),[i$1,c]=useState(false),d=useRef(null),m=useRef(0),{isAnimating:u,controls:g}=useContext(T),p=i(),h=Je(g),f$1=ze(g,"table"),b=n!=null?n:f$1.onCopy,y=o!=null?o:f$1.onError,x=async L=>{var H,I;if(typeof window=="undefined"||!((H=navigator==null?void 0:navigator.clipboard)!=null&&H.write)){y==null||y(new Error("Clipboard API not available"));return}try{let V=(I=d.current)==null?void 0:I.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),Z=V==null?void 0:V.querySelector("table");if(!Z){y==null||y(new Error("Table not found"));return}let X=Ae(Z),P="";L==="csv"?P=Se(X,h):L==="tsv"?P=on(X):P=De(X);let J=new ClipboardItem({"text/plain":new Blob([P],{type:"text/plain"}),"text/html":new Blob([Z.outerHTML],{type:"text/html"})});await navigator.clipboard.write([J]),c(!0),l(!1),b==null||b(L),m.current=window.setTimeout(()=>c(!1),r);}catch(V){y==null||y(V);}};useEffect(()=>{let L=H=>{let I=H.composedPath();d.current&&!I.includes(d.current)&&l(false);};return document.addEventListener("mousedown",L),()=>{document.removeEventListener("mousedown",L),window.clearTimeout(m.current);}},[]);let v=B(),S=i$1?v.CheckIcon:v.CopyIcon;return jsxs("div",{className:s("relative"),ref:d,children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>l(!a),title:p.copyTable,type:"button",children:e!=null?e:jsx(S,{height:14,width:14})}),a?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>x("md"),title:p.copyTableAsMarkdown,type:"button",children:p.tableFormatMarkdown}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>x("csv"),title:p.copyTableAsCsv,type:"button",children:p.tableFormatCsv}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>x("tsv"),title:p.copyTableAsTsv,type:"button",children:p.tableFormatTsv})]}):null]})};var Mi=({children:e,className:t,onDownload:n,onError:o,format:r="csv",filename:s})=>{let a=f(),{isAnimating:l,controls:i$1}=useContext(T),c=i(),d$1=B(),m=Je(i$1),u=g=>{try{let h=g.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=h==null?void 0:h.querySelector("table");if(!f){o==null||o(new Error("Table not found"));return}let b=Ae(f),y="",x="",v="";switch(r){case "csv":y=Se(b,m),x="text/csv",v="csv";break;case "markdown":y=De(b),x="text/markdown",v="md";break;default:y=Se(b,m),x="text/csv",v="csv";}d(`${s||ke(i$1,"table","table")}.${v}`,y,x),n==null||n();}catch(p){o==null||o(p);}};return jsx("button",{"aria-label":r==="csv"?c.downloadTableAsCsv:c.downloadTableAsMarkdown,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:u,title:r==="csv"?c.downloadTableAsCsv:c.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d$1.DownloadIcon,{size:14})})},Qe=({children:e,className:t,onDownload:n,onError:o})=>{let r=f(),[s,a]=useState(false),l=useRef(null),{isAnimating:i$1,controls:c}=useContext(T),d$1=i(),m=B(),u=Je(c),g=p=>{var h;try{let f=(h=l.current)==null?void 0:h.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),b=f==null?void 0:f.querySelector("table");if(!b){o==null||o(new Error("Table not found"));return}let y=Ae(b),x=p==="csv"?Se(y,u):De(y),v=p==="csv"?"csv":"md",S=`${ke(c,"table","table")}.${v}`;d(S,x,p==="csv"?"text/csv":"text/markdown"),a(!1),n==null||n(p);}catch(f){o==null||o(f);}};return useEffect(()=>{let p=h=>{let f=h.composedPath();l.current&&!f.includes(l.current)&&a(false);};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p);}},[]),jsxs("div",{className:r("relative"),ref:l,children:[jsx("button",{"aria-label":d$1.downloadTable,className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i$1,onClick:()=>a(!s),title:d$1.downloadTable,type:"button",children:e!=null?e:jsx(m.DownloadIcon,{size:14})}),s?jsxs("div",{className:r("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":d$1.downloadTableAsCsv,className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("csv"),title:d$1.downloadTableAsCsv,type:"button",children:d$1.tableFormatCsv}),jsx("button",{"aria-label":d$1.downloadTableAsMarkdown,className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("markdown"),title:d$1.downloadTableAsMarkdown,type:"button",children:d$1.tableFormatMarkdown})]}):null]})};var Bo=({children:e,className:t,showCopy:n=true,showDownload:o=true})=>{let{Maximize2Icon:r,XIcon:s}=B(),a=f(),[l,i$1]=useState(false),{isAnimating:c,portal:d}=useContext(T),m=i(),u=()=>{i$1(true);},g=()=>{i$1(false);};return useEffect(()=>{if(l){ce();let p=h=>{h.key==="Escape"&&i$1(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),de();}}},[l]),jsxs(Fragment,{children:[jsx("button",{"aria-label":m.viewFullscreen,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:u,title:m.viewFullscreen,type:"button",children:jsx(r,{size:14})}),l?createPortal(jsx("div",{"aria-label":m.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:g,onKeyDown:p=>{p.key==="Escape"&&g();},role:"dialog",children:jsxs("div",{className:a("flex h-full flex-col"),onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:[jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[n?jsx(Ye,{}):null,o?jsx(Qe,{}):null,jsx("button",{"aria-label":m.exitFullscreen,className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:g,title:m.exitFullscreen,type:"button",children:jsx(s,{size:20})})]}),jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:a("w-full table-fixed border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),Me(d)):null]})};var _o=({children:e,className:t,maxHeight:n,showControls:o,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...l})=>{let i=f(),{isAnimating:c,scrollable:d}=useContext(T),m=d!=null?d:je,u=b(n),g=pt({content:e,enabled:!!u,isAnimating:c}),p=o&&r,h=o&&s,f$1=o&&a,b$1=p||h||f$1;return jsxs("div",{className:i("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[b$1?jsxs("div",{className:i("flex items-center justify-end gap-1"),children:[p?jsx(Ye,{}):null,h?jsx(Qe,{}):null,f$1?jsx(Bo,{showCopy:p,showDownload:h,children:e}):null]}):null,jsx(m,{className:i("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),scrollRef:g,style:u?{maxHeight:u}:void 0,children:jsx("table",{className:i("w-full table-fixed divide-y divide-border",t),"data-streamdown":"table",...l,children:e})})]})};var Fi=/startLine=(\d+)/,$i=/\bnoLineNumbers\b/,zi=lazy(()=>import('./block-KAMYR4TF.js').then(e=>({default:e.DiagramCodeBlock}))),Wi=lazy(()=>import('./openscad-VI3FNOEN.js').then(e=>({default:e.OpenScad}))),qi=/language-([^\s]+)/,ee=e=>e.props,Ki="node";function D(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return false;let o=e,r=t;for(let s of n)if(s!==Ki&&!Object.is(o[s],r[s]))return false;return true}function Ui(e,t){var n,o;return ((n=e==null?void 0:e.properties)==null?void 0:n.metastring)===((o=t==null?void 0:t.properties)==null?void 0:o.metastring)}function Zi(e){if(typeof e=="string")return e;if(isValidElement(e)){let t=ee(e).children;if(typeof t=="string")return t}}var Xi=(e,t)=>Array.isArray(t)?t.includes(e):t===e,Ji=(e,t)=>!!(t&&Xi(e,t.language)),dn=(e,t)=>typeof e=="boolean"?e:e[t]!==false,ln=(e,t)=>{if(typeof e=="boolean")return e;let n=e.table;return n===false?false:n===true||n===void 0?true:n[t]!==false},jo=(e,t)=>{if(typeof e=="boolean")return e;let n=e.code;return n===false?false:n===true||n===void 0?true:n[t]!==false},cn=(e,t)=>{if(typeof e=="boolean")return e;let n=e.openscad;return n===false?false:n===true||n===void 0?true:n[t]!==false},tt=createContext({depth:0,ulDepth:0,isUnordered:false}),Gi={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},mn=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{depth:s,ulDepth:a}=useContext(tt),l=useMemo(()=>({depth:s+1,ulDepth:a,isUnordered:false}),[s,a]);return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"ordered-list",...o,children:jsx(tt.Provider,{value:l,children:e})})},(e,t)=>D(e,t));mn.displayName="MarkdownOl";var qo=memo(({children:e,className:t,node:n,...o})=>{var h;let r=f(),{depth:s,ulDepth:a,isUnordered:l}=useContext(tt),{listStyle:i}=useContext(T),c=Gi[i],d=l&&a>0?c[(a-1)%c.length]:void 0,m=Array.isArray(e)?e.filter(f=>f!==`
20
+ `&&f!==""):[e],u=m[0],g=isValidElement(u)?(h=ee(u).node)==null?void 0:h.tagName:void 0,p=m.length===1&&isValidElement(u)&&(u.type==="p"||g==="p")?ee(u).children:e;return t!=null&&t.includes("task-list-item")?jsx("li",{className:r("my-1 flex list-none items-center gap-2 [&>input]:m-0 [&>p]:inline",t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...o,children:p}):jsx("li",{className:r("py-1 [&>p]:inline",d,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...o,children:p})},(e,t)=>D(e,t));qo.displayName="MarkdownLi";var Ko=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{depth:s,ulDepth:a}=useContext(tt),l=useMemo(()=>({depth:s+1,ulDepth:a+1,isUnordered:true}),[s,a]);return jsx("ul",{className:r("list-inside whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"unordered-list",...o,children:jsx(tt.Provider,{value:l,children:e})})},(e,t)=>D(e,t));Ko.displayName="MarkdownUl";var Uo=memo(({className:e,node:t,...n})=>{let o=f();return jsx("hr",{className:o("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n})},(e,t)=>D(e,t));Uo.displayName="MarkdownHr";var Zo=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...o,children:e})},(e,t)=>D(e,t));Zo.displayName="MarkdownStrong";var Yi=({children:e,className:t,href:n,node:o,...r})=>{let s=f(),{linkSafety:a}=useContext(T),[l,i]=useState(false),c=n==="streamdown:incomplete-link",d=useCallback(async p=>{if(!(!(a!=null&&a.enabled&&n)||c)){if(p.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(n)){window.open(n,"_blank","noreferrer");return}i(true);}},[a,n,c]),m=useCallback(()=>{n&&window.open(n,"_blank","noreferrer");},[n]),u=useCallback(()=>{i(false);},[]),g={url:n!=null?n:"",isOpen:l,onClose:u,onConfirm:m};return a!=null&&a.enabled&&n?jsxs(Fragment,{children:[jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",onClick:d,type:"button",children:e}),a.renderModal?a.renderModal(g):jsx(uo,{...g})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...r,children:e})},Xo=memo(Yi,(e,t)=>D(e,t));Xo.displayName="MarkdownA";var Jo=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e})},(e,t)=>D(e,t));Jo.displayName="MarkdownH1";var Go=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e})},(e,t)=>D(e,t));Go.displayName="MarkdownH2";var Yo=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e})},(e,t)=>D(e,t));Yo.displayName="MarkdownH3";var Qo=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e})},(e,t)=>D(e,t));Qo.displayName="MarkdownH4";var er=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e})},(e,t)=>D(e,t));er.displayName="MarkdownH5";var tr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e})},(e,t)=>D(e,t));tr.displayName="MarkdownH6";var nr=memo(({children:e,className:t,node:n,...o})=>{let{controls:r,tableMaxHeight:s}=useContext(T),a=dn(r,"table"),l=ln(r,"copy"),i=ln(r,"download"),c=ln(r,"fullscreen");return jsx(_o,{className:t,maxHeight:s,showControls:a,showCopy:l,showDownload:i,showFullscreen:c,...o,children:e})},(e,t)=>D(e,t));nr.displayName="MarkdownTable";var or=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e})},(e,t)=>D(e,t));or.displayName="MarkdownThead";var rr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...o,children:e})},(e,t)=>D(e,t));rr.displayName="MarkdownTbody";var sr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...o,children:e})},(e,t)=>D(e,t));sr.displayName="MarkdownTr";var ar=memo(({children:e,className:t,node:n,title:o,...r})=>{let s=f(),a=Mo(e,n,o);return jsx("th",{className:s("min-w-0 overflow-hidden px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...r,title:a,children:jsx("span",{className:s("wrap-anywhere line-clamp-2"),children:e})})},(e,t)=>D(e,t));ar.displayName="MarkdownTh";var ir=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("td",{className:r("wrap-anywhere min-w-0 px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e})},(e,t)=>D(e,t));ir.displayName="MarkdownTd";var lr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e})},(e,t)=>D(e,t));lr.displayName="MarkdownBlockquote";var cr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...o,children:e})},(e,t)=>D(e,t));cr.displayName="MarkdownSup";var Qi=()=>({}),el=e=>{try{let t=atob(e),n=Uint8Array.from(t,o=>o.charCodeAt(0));return new TextDecoder().decode(n)}catch(t){return ""}},dr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{calloutIcon:s,calloutStyle:a,components:l,remarkPlugins:i,rehypePlugins:c}=useContext(T),d=o,m=d["data-callout-title"],u=d["data-callout-color"],g=d["data-callout-icon"],p=d["data-callout-body"],h=p?el(p):"",f$1=(a!=null?a:Qi)(u),b=g&&s?s(g):null;return jsxs("div",{className:r("my-4 rounded-md border-l-4 px-4 py-3 [&>p:last-child]:mb-0",t),"data-streamdown":"callout",style:f$1,...o,children:[m!==void 0?jsxs("p",{className:"mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",children:[b,m]}):null,h.trim().length>0?jsx(Ue,{components:l,rehypePlugins:c,remarkPlugins:i,children:h}):null]})},(e,t)=>D(e,t));dr.displayName="MarkdownCallout";var Fo={"markdown-alert-note":"border-l-blue-500 bg-blue-500/5 [&_.markdown-alert-title]:text-blue-600 dark:[&_.markdown-alert-title]:text-blue-400","markdown-alert-tip":"border-l-green-600 bg-green-600/5 [&_.markdown-alert-title]:text-green-700 dark:[&_.markdown-alert-title]:text-green-400","markdown-alert-important":"border-l-purple-600 bg-purple-600/5 [&_.markdown-alert-title]:text-purple-700 dark:[&_.markdown-alert-title]:text-purple-400","markdown-alert-warning":"border-l-amber-600 bg-amber-600/5 [&_.markdown-alert-title]:text-amber-700 dark:[&_.markdown-alert-title]:text-amber-400","markdown-alert-caution":"border-l-red-600 bg-red-600/5 [&_.markdown-alert-title]:text-red-700 dark:[&_.markdown-alert-title]:text-red-400"},mr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),s=t==null?void 0:t.includes("markdown-alert");if(t==null?void 0:t.includes("sdm-callout"))return jsx(dr,{className:t,node:n,...o,children:e});if(s){let l=Object.keys(Fo).find(i=>t==null?void 0:t.includes(i));return jsx("div",{className:r("my-4 rounded-r-md border-muted-foreground/30 border-l-4 bg-muted/40 px-4 py-3 [&>p:last-child]:mb-0",l?Fo[l]:null,t),...o,children:e})}return jsx("div",{className:r(t),...o,children:e})},(e,t)=>D(e,t));mr.displayName="MarkdownDiv";var ur=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...o,children:e})},(e,t)=>D(e,t));ur.displayName="MarkdownSub";var pr=memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let s=i=>{if(!isValidElement(i))return false;let c=ee(i).children,d=Array.isArray(c)?c:[c],m=false,u=false;for(let g of d)if(g){if(typeof g=="string")g.trim()!==""&&(m=true);else if(isValidElement(g))if(ee(g)["data-footnote-backref"]!==void 0)u=true;else {let p=ee(g).children,h=Array.isArray(p)?p:[p];for(let f of h){if(typeof f=="string"&&f.trim()!==""){m=true;break}if(isValidElement(f)&&ee(f)["data-footnote-backref"]===void 0){m=true;break}}}}return u&&!m},a=Array.isArray(e)?e.map(i=>{if(!isValidElement(i))return i;if(i.type===mn){let c=ee(i).children,m=(Array.isArray(c)?c:[c]).filter(u=>!s(u));return m.length===0?null:{...i,props:{...ee(i),children:m}}}return i}):e;return (Array.isArray(a)?a.some(i=>i!==null):a!==null)?jsx("section",{className:t,...o,children:a}):null}return jsx("section",{className:t,...o,children:e})},(e,t)=>D(e,t));pr.displayName="MarkdownSection";var tl=({node:e,className:t,children:n,...o})=>{var ue,pe,Te;let r=f(),s=!("data-block"in o),a=useContext(T),{openscad:l,controls:i$1,lineNumbers:c}=a,d=t==null?void 0:t.match(qi),m=(ue=d==null?void 0:d.at(1))!=null?ue:"",u=vo(m),g=Ne(),p=_e(),h=i(),f$1=Po(m);if(s)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:n});let b=(pe=e==null?void 0:e.properties)==null?void 0:pe.metastring,y=typeof b=="string"?b:void 0,x=y==null?void 0:y.match(Fi),v=x?Number.parseInt(x[1],10):void 0,S=v!==void 0&&v>=1?v:void 0,H=!(y?$i.test(y):false)&&c!==false,I=(Te=Zi(n))!=null?Te:"";if(f$1){let R=f$1.component;return jsx(Suspense,{fallback:jsx(We,{}),children:jsx(R,{code:I,isIncomplete:p,language:m,meta:y})})}if(u)return jsx(Suspense,{fallback:jsx(We,{}),children:jsx(zi,{className:t,code:I,isBlockIncomplete:p,language:m,plugin:u})});if(Ji(m,g)){let R=dn(i$1,"openscad"),M=cn(i$1,"download"),_=cn(i$1,"copy"),le=cn(i$1,"fullscreen"),K=R&&(M||_||le);return jsx(Suspense,{fallback:jsx(We,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":p||void 0,"data-streamdown":"openscad-block",children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:m})}),K?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"openscad-block-actions",children:[M?jsx(xt,{code:I,config:l==null?void 0:l.config}):null,_?jsx(gt,{code:I,label:h.copyModel,...ze(i$1,"openscad")}):null,le?jsx(Lo,{code:I,config:l==null?void 0:l.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(Wi,{code:I,config:l==null?void 0:l.config})})]})})}let V=dn(i$1,"code"),Z=jo(i$1,"download"),X=jo(i$1,"copy"),{"data-block":P,...J}=o;return jsx(Wt,{className:t,code:I,isIncomplete:p,language:m,lineNumbers:H,startLine:S,...J,children:V?jsxs(Fragment,{children:[Z?jsx(Ut,{code:I,language:m}):null,X?jsx(gt,{...ze(i$1,"code")}):null]}):null})},fr=memo(tl,(e,t)=>D(e,t)&&Ui(e.node,t.node));fr.displayName="MarkdownCode";var gr=memo(lo,(e,t)=>D(e,t));gr.displayName="MarkdownImg";var $o={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},br=memo(({children:e,className:t,node:n,...o})=>{let r=f(),s=i(),a=o["data-alert-type"],l=a&&a in $o?$o[a]:void 0,i$1=l?s[l]:void 0,c=e;return i$1&&(c=[...(Array.isArray(e)?e:[e]).filter(u=>!(typeof u=="string"&&u.trim().length>0)),i$1]),jsx("p",{className:r("mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",t),...o,children:c})},(e,t)=>D(e,t));br.displayName="MarkdownAlertTitle";var hr=memo(({children:e,className:t,node:n,...o})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(br,{className:t,node:n,...o,children:e});let s=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");if(s.length===1&&isValidElement(s[0])){let a=ee(s[0]).node,l=a==null?void 0:a.tagName;if(l==="img")return jsx(Fragment,{children:e});if(l==="code"&&"data-block"in s[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...o,children:e})},(e,t)=>D(e,t));hr.displayName="MarkdownParagraph";var yr={ol:mn,li:qo,ul:Ko,hr:Uo,strong:Zo,a:Xo,h1:Jo,h2:Go,h3:Yo,h4:Qo,h5:er,h6:tr,table:nr,thead:or,tbody:rr,tr:sr,th:ar,td:ir,blockquote:lr,code:fr,div:mr,img:gr,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:cr,sub:ur,p:hr,section:pr};var nl=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,ol=/\p{L}/u;function nt(e){let t=e.replace(/(```|~~~)[\s\S]*?\1/g,"").replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,""),n,o=0,r=0;for(let s of t){if(nl.test(s)){n!=null||(n="rtl"),r+=1;continue}ol.test(s)&&(n!=null||(n="ltr"),o+=1);}return r>o?"rtl":o>r?"ltr":n!=null?n:"ltr"}var rl=/^[ \t]{0,3}(`{3,}|~{3,})/;var Cr=e=>{let t=e.split(`
21
+ `),n=null,o=0;for(let r of t){let s=rl.exec(r);if(n===null){if(s){let a=s[1];n=a[0],o=a.length;}}else if(s){let a=s[1],l=a[0],i=a.length;l===n&&i>=o&&(n=null,o=0);}}return n!==null};var al=/\[\^[\w-]{1,200}\](?!:)/,il=/\[\^[\w-]{1,200}\]:/,ll=/<([A-Za-z][\w:-]*)[\s>/]/,cl=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),xr=new Map,wr=new Map,Pr=e=>{let t=e.toLowerCase(),n=xr.get(t);if(n)return n;let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return xr.set(t,o),o},dl=e=>{let t=e.toLowerCase(),n=wr.get(t);if(n)return n;let o=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return wr.set(t,o),o},kr=(e,t)=>{if(cl.has(t.toLowerCase()))return 0;let n=e.match(Pr(t));if(!n)return 0;let o=0;for(let r of n)r.trimEnd().endsWith("/>")||(o+=1);return o},vr=(e,t)=>{let n=e.match(dl(t));return n?n.length:0},ml=(e,t)=>{let n=e.match(Pr(t));return !!n&&n.every(o=>o.trimEnd().endsWith("/>"))},ul=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]==="$"&&e[n+1]==="$"&&(t+=1,n+=1);return t},Sr=e=>al.test(e)||il.test(e),pl=/\r\n|\r/g,fl=e=>new Lexer({gfm:true}).blockTokens(e),gl=`
22
+
23
+ `,bl=e=>{var t;for(let n=e.length-3;n>=0;n-=1)if((t=e.at(n))!=null&&t.endsWith(gl))return n+1;return 0},hl=e=>` ${e}`.slice(1),un=(e,t)=>({source:e,blocks:t(e),verifiedCount:0,verifiedLength:0}),yl=(e,t,n)=>{var l,i,c,d;let o=bl(e.blocks);if(o===0)return null;let r=(l=e.verifiedCount)!=null?l:0,s=(i=e.verifiedLength)!=null?i:0;if(r>o){r=o,s=0;for(let m=0;m<r;m+=1)s+=(d=(c=e.blocks.at(m))==null?void 0:c.length)!=null?d:0;}for(;r<o;){let m=e.blocks.at(r);if(m===void 0||!t.startsWith(m,s))return null;s+=m.length,r+=1;}let a=n(t.slice(s)).map(hl);return {source:t,blocks:e.blocks.slice(0,o).concat(a),verifiedCount:r,verifiedLength:s}},ot=e=>{if(Sr(e))return [e];let t=e.includes("\r")?e.replace(pl,`
24
+ `):e,n=fl(t),o=[],r=[],s=false;for(let a of n){let l=a.raw,i=o.length;if(r.length>0){o[i-1]+=l;let c=r.at(-1),d=kr(l,c),m=vr(l,c);for(let u=0;u<d;u+=1)r.push(c);for(let u=0;u<m;u+=1)r.length>0&&r.at(-1)===c&&r.pop();continue}if(a.type==="html"&&a.block){let c=l.match(ll);if(c){let d=c[1],m=kr(l,d),u=vr(l,d);m>u&&!ml(l,d)&&r.push(d);}}if(a.type==="space"&&i>0){o[i-1]+=l;continue}if(i>0&&!s){let c=o[i-1];if(ul(c)%2===1){o[i-1]=c+l;continue}}o.push(l),a.type!=="space"&&(s=a.type==="code");}return o},pn=(e,t,n=ot)=>{var o;return t!=null&&t.source&&e.startsWith(t.source)?e===t.source?t:n===ot&&Sr(e)?un(e,n):(o=yl(t,e,n))!=null?o:un(e,n):un(e,n)};var Cl=/^ {0,3}(`{3,}|~{3,})/,xl=/^\n[ \t]*\n/,Er=(e,t,n)=>{let o=t;for(;o<n&&e[o]==="`";)o+=1;return o},wl=(e,t,n,o)=>{let r=t;for(;r<n;){let s=e[r];if(s==="`"){let a=Er(e,r,n);if(a-r===o)return r;r=a;continue}if(s===`
25
+ `&&xl.test(e.slice(r,r+64)))return -1;r+=1;}return -1},Tr=(e,t,n,o)=>{let r=t;for(;r<n;){if(e[r]!=="`"){r+=1;continue}let s=Er(e,r,n),a=s-r,l=wl(e,s,n,a);if(l===-1){r=s;continue}o.push([r,l+a]),r=l+a;}},kl=e=>{let t=[],n=e.length,o=null,r=0,s=0;for(;s<n;){let a=e.indexOf(`
26
+ `,s),l=a===-1?n:a,i=e.slice(s,l),c=Cl.exec(i);if(o){let d=c==null?void 0:c[1];d&&d[0]===o.char&&d.length>=o.length&&i.slice(c[0].length).trim()===""&&(t.push([o.start,l]),o=null,r=l);}else if(c){let d=c[1],m=i.slice(c[0].length);d[0]==="`"&&m.includes("`")||(Tr(e,r,s,t),o={char:d[0],length:d.length,start:s});}s=l+1;}return o?t.push([o.start,n]):Tr(e,r,n,t),t},vl=(e,t)=>{let n=0,o=e.length-1;for(;n<=o;){let r=Math.floor((n+o)/2),[s,a]=e[r];if(t<s)o=r-1;else if(t>=a)n=r+1;else return true}return false},vt=e=>{let t=null;return n=>(t===null&&(t=kl(e)),vl(t,n))},Rr=(e,t,n)=>{let o=vt(e);return e.replace(t,(r,...s)=>{let a=s.findIndex(i=>typeof i=="number"),l=s[a];return o(l)?r:n(r,...s.slice(0,a))})},Pt=(e,t,n)=>{let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),r=new RegExp(`</${t}\\s*>`,"gi"),s=vt(e),a="",l=0,i=o.exec(e);for(;i;){if(s(i.index)){i=o.exec(e);continue}let c=i.index+i[0].length;r.lastIndex=c;let d=r.exec(e);for(;d&&s(d.index);)d=r.exec(e);if(!d)break;a+=e.slice(l,i.index)+n(i[0],e.slice(c,d.index),d[0]),l=d.index+d[0].length,o.lastIndex=l,i=o.exec(e);}return l===0?e:a+e.slice(l)};var Pl=/^\n*/,Sl=/\n*$/,fn=/\n\n/g,Tl=(e,t,n)=>{if(!t.includes(`
27
+ `))return e+t+n;let r=t.replace(fn,`
28
+ <!---->
29
+ `).replace(Pl,`
30
+
31
+ `).replace(Sl,`
32
+
33
+ `);return `${e}${r}${n}
34
+
35
+ `},El=(e,t)=>{let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),o=new RegExp(`</${t}\\s*>`,"gi"),r=vt(e),s=c=>{o.lastIndex=c;let d=o.exec(e);for(;d&&r(d.index);)d=o.exec(e);return d!==null},a="",l=0,i=n.exec(e);for(;i;){let c=i[0],d=i.index+c.length;if(r(i.index)){i=n.exec(e);continue}if(s(d)){i=n.exec(e);continue}let m=e.slice(d);if(a+=e.slice(l,i.index),m.length===0){a+=c,l=d,i=n.exec(e);continue}if(m.startsWith(`
36
+
37
+ `)){let p=m.slice(2).replace(fn,`
38
+ <!---->
39
+ `);a+=`${c}
40
+
41
+ ${p}`,l=e.length;break}if(!m.startsWith(`
42
+ `)){a+=c,l=d,i=n.exec(e);continue}let u=m.slice(1);if(u.trim().length===0){a+=c,l=d,i=n.exec(e);continue}let g=u.replace(fn,`
43
+ <!---->
44
+ `);a+=`${c}
45
+
46
+ ${g}`,l=e.length;break}return l===0?e:a+e.slice(l)},gn=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t){let r=new RegExp(`<${o}(?=[\\s>/])((?:"[^"]*"|'[^']*'|[^"'>])*)\\/>`,"gi");n=Rr(n,r,(s,a)=>`<${o}${a}></${o}>`);}return n},Ir=(e,t)=>{if(!t.length)return e;let n=gn(e,t);for(let o of t)n=Pt(n,o,Tl),n=El(n,o);return n};var Rl=/([\\`*_~[\]|])/g,Il=e=>e.replace(Rl,"\\$1"),Lr=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t)n=Pt(n,o,(r,s,a)=>{let l=Il(s).replace(/\n\n/g,"&#10;&#10;");return r+l+a});return n};var Ml=new Set(["blockquote","dd","dt","figcaption","h1","h2","h3","h4","h5","h6","li","p","td","th"]),Mr=new Set(["code","kbd","pre","samp","var"]);function Nr(e){return e.children.map(t=>t.type==="text"?t.value:t.type==="element"&&!Mr.has(t.tagName)?Nr(t):"").join("")}function Ar(){return e=>{visit(e,"element",t=>{if(Mr.has(t.tagName)){(t.properties)!=null||(t.properties={}),t.properties.dir="ltr";return}Ml.has(t.tagName)&&((t.properties)!=null||(t.properties={}),typeof t.properties.dir!="string"&&(t.properties.dir=nt(Nr(t))));});}}var Dr=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(o=>o.toLowerCase()));visit(t,"element",o=>{var s;if(!n.has(o.tagName.toLowerCase()))return;let r=o.children.filter(a=>a.type==="element").map(a=>{var l;return {tag:a.tagName,props:(l=a.properties)!=null?l:{},text:toText(a).trim()}});o.properties=(s=o.properties)!=null?s:{},o.properties["data-content"]=JSON.stringify(r),o.children=[];});};var Or=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(Or).join(""):"",Hr=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(o=>o.toLowerCase()));visit(t,"element",o=>{if(n.has(o.tagName.toLowerCase())){let r=Or(o);o.children=r?[{type:"text",value:r}]:[];}});};var _l=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),jl=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),Fl=e=>{let t=unified().use(Na).use(Aa,{allowDangerousHtml:true}),n=t.parse(e);return t.runSync(n).children},Br=(e,t=[])=>n=>{if(!e||e.length===0)return;let o=new Set(e.map(s=>s.toLowerCase())),r=new Set((t!=null?t:[]).map(s=>s.toLowerCase()));visit(n,"element",s=>{let a=s.tagName.toLowerCase();if(!o.has(a)||r.has(a)||!_l(s))return;let l=jl(s);if(!l.includes(`
47
+ `))return;let i=Fl(l);s.children=i;});};var Vr=()=>e=>{visit(e,"code",t=>{var n,o;t.meta&&(t.data=(n=t.data)!=null?n:{},t.data.hProperties={...(o=t.data.hProperties)!=null?o:{},metastring:t.meta});});};var _r=/^>>>[ \t]?(.*)$/,zl=/^<<<\s*$/,Wl=/^>+\s*$/,ql=/^<+\s*$/,Kl=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,Ul=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,Zl=/^[a-z0-9-]+$/,Xl=e=>{let t=Kl.exec(e);if(!(t!=null&&t.groups))return {};let{iconParen:n,iconBrace:o,title:r,color:s}=t.groups,a=n!=null?n:o;return {icon:a&&Zl.test(a)?a:void 0,title:r!==void 0&&r.length>0?r:void 0,color:s&&Ul.test(s)?s:void 0}},bn=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Jl=e=>{let t=new TextEncoder().encode(e),n="";for(let o of t)n+=String.fromCharCode(o);return btoa(n)},Gl=(e,t)=>{var c;let n=_r.exec(e[t]),o=(c=n==null?void 0:n[1])!=null?c:"",r=Xl(o),s=[],a=t+1;for(;a<e.length;a+=1){let d=e[a];if(zl.test(d)){a+=1;break}if(Wl.test(d)||ql.test(d)){a+=1;break}s.push(d);}let l=s.join(`
48
+ `).trim();return {replacement:`<div ${['class="sdm-callout"',r.title!==void 0?`data-callout-title="${bn(r.title)}"`:"",r.color!==void 0?`data-callout-color="${bn(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${bn(r.icon)}"`:"",`data-callout-body="${Jl(l)}"`].filter(Boolean).join(" ")}></div>`,next:a}},jr=e=>{if(!e.includes(">>>"))return e;let t=e.split(`
49
+ `),n=[],o=0,r=false;for(;o<t.length;)if(_r.test(t[o])){let s=Gl(t,o);n.push(s.replacement),o=s.next,r=true;}else n.push(t[o]),o+=1;return r?n.join(`
50
+ `):e},Fr=()=>()=>{};var Ql=/^([a-zA-Z][a-zA-Z\d+\-.]*:)/,ec=e=>new Set(e.map(t=>t.trim().toLowerCase()).filter(t=>t.length>0).map(t=>t.endsWith(":")?t:`${t}:`));function tc(e,t){if(e.children.length!==1)return false;let[n]=e.children;if(n.type!=="text")return false;let o=Ql.exec(e.url);if(!o)return false;let r=o[1].toLowerCase();return t.has(r)?r==="mailto:"?e.url===`mailto:${n.value}`:e.url===n.value||e.url===`${r}//${n.value}`:false}var $r=(e=[])=>{let t=ec(e);return n=>{t.size!==0&&visit(n,"link",(o,r,s)=>{if(!(!s||r===void 0)&&tc(o,t))return s.children.splice(r,1,...o.children),r});}};var rc={NOTE:{icon:"info",kind:"note",title:"Note",iconPaths:[{d:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]},TIP:{icon:"light-bulb",kind:"tip",title:"Tip",iconPaths:[{d:"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"}]},IMPORTANT:{icon:"report",kind:"important",title:"Important",iconPaths:[{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}]},WARNING:{icon:"alert",kind:"warning",title:"Warning",iconPaths:[{d:"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",fillRule:"evenodd"}]},CAUTION:{icon:"stop",kind:"caution",title:"Caution",iconPaths:[{d:"M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25a.749.749 0 0 1-.53.22H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]}},sc=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,zr=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let n="";for(let o of t)n+=zr(o);return n},ac=e=>{let t=e.iconPaths.map(n=>`<path d="${n.d}"${n.fillRule?` fill-rule="${n.fillRule}"`:""}></path>`).join("");return {type:"paragraph",children:[{type:"html",value:`<svg class="octicon octicon-${e.icon}" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true">${t}</svg>`},{type:"text",value:e.title}],data:{hName:"p",hProperties:{className:["markdown-alert-title"],"data-alert-type":e.kind}}}},ic=e=>{var m,u;let t=e.children[0];if(!t||t.type!=="paragraph")return;let n=t.children[0];if(!n||n.type!=="text")return;let o=zr(n).trimStart(),r=o.match(sc);if(!r)return;let s=rc[r[1].toUpperCase()],a=o.slice(r[0].length),l=t.children.slice(1);if(a.trim().length===0&&l.length===0&&e.children.length===1)return;let i=[ac(s)],c=[];a.length>0&&c.push({type:"text",value:a});let d=l;return ((m=d[0])==null?void 0:m.type)==="break"&&(d=d.slice(1)),c.push(...d),c.length>0&&c.some(g=>g.type!=="text"||g.value.trim().length>0)&&i.push({type:"paragraph",children:c}),i.push(...e.children.slice(1)),e.data=(u=e.data)!=null?u:{},e.data.hName="div",e.data.hProperties={className:["markdown-alert",`markdown-alert-${s.kind}`]},e.children=i,SKIP},Wr=()=>e=>{visit(e,"blockquote",ic);};var bc=/^[ \t]*<[\w!/?-]/,hc=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,yc=e=>typeof e!="string"||e.length===0||!bc.test(e)?e:e.replace(hc,"$1"),Zr,Xr,Jr,Gr,Yr,Qr,es,ts,ns,os,rs,ss,as,St={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(Xr=(Zr=defaultSchema.protocols)==null?void 0:Zr.href)!=null?Xr:[],"tel","streamdown"],src:[...(Gr=(Jr=defaultSchema.protocols)==null?void 0:Jr.src)!=null?Gr:[],"streamdown"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(Qr=(Yr=defaultSchema.attributes)==null?void 0:Yr.div)!=null?Qr:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(ts=(es=defaultSchema.attributes)==null?void 0:es.p)!=null?ts:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(os=(ns=defaultSchema.attributes)==null?void 0:ns.svg)!=null?os:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(ss=(rs=defaultSchema.attributes)==null?void 0:rs.path)!=null?ss:[],"d","fillRule"]},tagNames:[...(as=defaultSchema.tagNames)!=null?as:[],"svg","path"]},hn={raw:fo,sanitize:[cs,St],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Cc={gfm:[fc,{}],githubAlerts:Wr,containerAlerts:Fr,codeMeta:Vr},Kr=Object.values(hn),xc=Object.values(Cc),Ur=new WeakMap;function wc(e){var r;let t=Ur.get(e);if(t)return t;let n={...St,tagNames:[...(r=St.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...St.attributes,...e}},o=[hn.raw,[cs,n],hn.harden];return Ur.set(e,o),o}var kc={block:" \u258B",circle:" \u25CF"},vc=["github-light","github-dark"],Pc={enabled:true},ds=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:o,isIncomplete:r,dir:s,animatePlugin:a,...l})=>{useLayoutEffect(()=>{a==null||a.commit();}),a==null||a.setAnimateCodeBlocks(r);let i=typeof e=="string"&&n?yc(e):e,c=jsx(Ue,{...l,children:i});return jsx(_t.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:c}):c})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return false;if(e.components!==t.components){let n=Object.keys(e.components||{}),o=Object.keys(t.components||{});if(n.length!==o.length||n.some(r=>{var s,a;return ((s=e.components)==null?void 0:s[r])!==((a=t.components)==null?void 0:a[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins||!!e.animatePlugin!=!!t.animatePlugin)});ds.displayName="Block";var Sc=memo(({children:e$1,mode:t="streaming",dir:n,parseIncompleteMarkdown:o=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=Kr,remarkPlugins:l=xc,className:i,shikiTheme:c$1,mermaid:d,openscad:m,plantuml:u,smiles:g$1,vega:p,diagrams:h$1,codeBlockMaxHeight:f=400,controls:b=true,isAnimating:y=false,scrollable:x,tableMaxHeight:v=300,animated:S,BlockComponent:L=ds,parseMarkdownIntoBlocksFn:H=ot,caret:I,listStyle:V="hierarchical",calloutIcon:Z,calloutStyle:X,plugins:P,remend:J,linkSafety:ue=Pc,portal:pe,lineNumbers:Te=true,allowedTags:R,literalTagContent:M,dataOnlyTags:_,disableAutolinkProtocols:le,translations:K,icons:Be,prefix:at,onAnimationStart:Ee,onAnimationEnd:ne,...oe})=>{let yn=useId(),it=useMemo(()=>c(at),[at]),Cn=useRef(null),fe=useRef(Ee),lt=useRef(ne);fe.current=Ee,lt.current=ne,useEffect(()=>{var E,$,j;if(t==="static")return;let C=Cn.current;if(Cn.current=y,C===null){y&&((E=fe.current)==null||E.call(fe));return}y&&!C?($=fe.current)==null||$.call(fe):!y&&C&&((j=lt.current)==null||j.call(lt));},[y,t]);let Re=useMemo(()=>R?Object.keys(R):[],[R]),Ie=useMemo(()=>{if(!(_!=null&&_.length||M!=null&&M.length))return Re;let C=new Set([..._!=null?_:[],...M!=null?M:[]].map(E=>E.toLowerCase()));return Re.filter(E=>!C.has(E.toLowerCase()))},[Re,_,M]),xn=useRef(null),Tt=useMemo(()=>{if(typeof e$1!="string")return "";let C=e$1;return M&&M.length>0&&(C=Lr(C,M)),Re.length>0&&(C=gn(C,Re)),Ie.length>0&&(C=Ir(C,Ie)),C=jr(C),C},[Re,e$1,Ie,M]),G=useMemo(()=>{let C=t==="streaming"?xn.current:null,E=pn(Tt,C,H);if(xn.current=t==="streaming"?E:null,!(t==="streaming"&&o)||E.blocks.length===0)return E.blocks;let $=E.blocks.length-1,j=E.blocks[$],re=gc(j,J);if(re===j)return E.blocks;let Ce=E.blocks.slice();return Ce[$]=re,Ce},[Tt,H,t,o,J]),Le=useMemo(()=>S===true?"true":S?JSON.stringify(S):"",[S]),U=useRef(null),Ve=useRef([]),ge=useRef([]),wn=useRef(null),Et=useRef("");if(Le){if(Et.current!==Le){Et.current=Le;let C=Le!=="true"?S.maxBacklogMs:void 0;U.current=Ht({maxBacklogMs:C}),Ve.current=[],ge.current=[];}else U.current||(U.current=Ht());y&&U.current&&U.current.beginPass(U.current.now());}else U.current=null,Ve.current=[],ge.current=[],Et.current="";useLayoutEffect(()=>{var C;y&&((C=U.current)==null||C.commitPass());});let be=useDeferredValue(G),he=useMemo(()=>{if(t!=="streaming"||U.current||be===G||be.length===0)return G;let C=be.length,E=G.length;if(E===0)return be;if(C!==E)return G;for(let j=0;j<C-1;j+=1)if(be[j]!==G[j])return G;let $=be.slice();return $[C-1]=G[E-1],$},[G,be,t]),Rt=useMemo(()=>n==="auto"?he.map(nt):void 0,[he,n]),[kn]=useState(()=>Bn(yn)),ms=useMemo(()=>kn(he),[he,kn]),us=useMemo(()=>K?JSON.stringify(K):"",[K]),vn=useMemo(()=>({...g,...K}),[us]),ct=useMemo(()=>{let{inlineCode:C,...E}=s!=null?s:{},$={...yr,...E};if(C){let j=$.code;$.code=re=>"data-block"in re?j?createElement(j,re):null:createElement(C,re);}return $},[s]),dt=useMemo(()=>{let C=[];return P!=null&&P.cjk&&(C=[...C,...P.cjk.remarkPluginsBefore]),C=[...C,...l],le&&le.length>0&&(C=[...C,[$r,le]]),P!=null&&P.cjk&&(C=[...C,...P.cjk.remarkPluginsAfter]),P!=null&&P.math&&(C=[...C,P.math.remarkPlugin]),C},[l,P==null?void 0:P.math,P==null?void 0:P.cjk,le]),ye=useMemo(()=>{let C=a;return R&&Object.keys(R).length>0&&a===Kr&&(C=wc(R)),Ie.length>0&&(C=[...C,[Br,Ie,M!=null?M:[]]]),M&&M.length>0&&(C=[...C,[Hr,M]]),_&&_.length>0&&(C=[...C,[Dr,_]]),P!=null&&P.math&&(C=[...C,P.math.rehypePlugin]),n==="auto"&&t==="static"&&(C=[...C,Ar]),C},[a,P==null?void 0:P.math,R,Ie,M,_,n,t]),Pn=useMemo(()=>{var C,E;return {calloutIcon:Z,calloutStyle:X,codeBlockMaxHeight:f,shikiTheme:(E=c$1!=null?c$1:(C=P==null?void 0:P.code)==null?void 0:C.getThemes())!=null?E:vc,controls:b,isAnimating:y,lineNumbers:Te,listStyle:V,mode:t,mermaid:d,openscad:m,plantuml:u,smiles:g$1,vega:p,diagrams:h$1,linkSafety:ue,portal:pe,scrollable:x,tableMaxHeight:v,components:ct,remarkPlugins:dt,rehypePlugins:ye}},[Z,X,f,c$1,b,y,Te,V,t,d,m,u,g$1,p,h$1,ue,pe,x,P==null?void 0:P.code,v,ct,dt,ye]),ps=useMemo(()=>I&&y?{"--streamdown-caret":`"${kc[I]}"`}:void 0,[I,y]),fs=C=>{let E=null;if(U.current&&y){if(!Ve.current[C]){let j=Le&&Le!=="true"?S:{},{maxBacklogMs:re,...Ce}=j;Ve.current[C]=ut({...Ce,timeline:U.current});}E=Ve.current[C];}wn.current!==ye&&(ge.current=[],wn.current=ye),E&&!ge.current[C]&&(ge.current[C]=[...ye,E.rehypePlugin]);let $=E&&ge.current[C]?ge.current[C]:ye;return {blockAnimatePlugin:E,blockRehypePlugins:$}};return t==="static"?jsx(h.Provider,{value:vn,children:jsx(yt.Provider,{value:P!=null?P:null,children:jsx(T.Provider,{value:Pn,children:jsx(qt,{icons:Be,children:jsx(e.Provider,{value:it,children:jsx("div",{className:it("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:n==="auto"?void 0:n,children:jsx(Ue,{components:ct,rehypePlugins:ye,remarkPlugins:dt,...oe,children:Tt})})})})})})}):jsx(h.Provider,{value:vn,children:jsx(yt.Provider,{value:P!=null?P:null,children:jsx(T.Provider,{value:Pn,children:jsx(qt,{icons:Be,children:jsx(e.Provider,{value:it,children:jsxs("div",{className:it("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",I?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),"data-streamdown":"container",style:ps,children:[he.length===0&&I&&y&&jsx("span",{}),he.map((C,E)=>{var Sn;let $=E===he.length-1,j=y&&$&&Cr(C),{blockAnimatePlugin:re,blockRehypePlugins:Ce}=fs(E);return jsx(L,{animatePlugin:re,components:ct,content:C,dir:(Sn=Rt==null?void 0:Rt[E])!=null?Sn:n!=="auto"?n:void 0,index:E,isIncomplete:j,rehypePlugins:Ce,remarkPlugins:dt,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:o,...oe},ms[E])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.calloutIcon===t.calloutIcon&&e.calloutStyle===t.calloutStyle&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&e.dataOnlyTags===t.dataOnlyTags&&e.disableAutolinkProtocols===t.disableAutolinkProtocols&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Sc.displayName="Streamdown";var Mc=lazy(()=>import('./viewer-SB7OV4V7.js').then(e=>({default:e.OpenScadViewer}))),Io=({className:e,code:t,config:n,fullscreen:o=false})=>{let r=f(),s=i(),[a,l]=useState(null),[i$1,c]=useState(false),[d,m]=useState(null),[u,g]=useState(null),[p,h]=useState(0),{openscad:f$1}=useContext(T),b=Ne(),y=f$1==null?void 0:f$1.errorComponent,x=_e(),{shouldRender:v,containerRef:S}=En({immediate:o});if(useEffect(()=>{if(!v||x)return;if(!b){l(s.openscadPluginMissing);return}(async()=>{try{l(null),c(!0);let V=await b.getOpenScad(n).render(t,n);m(V),g(V);}catch(I){if(!(u||d)){let V=I instanceof Error?I.message:s.openscadRenderFailed;l(V);}}finally{c(false);}})();},[t,n,p,v,x,b,s]),!(v||d||u))return jsx("div",{className:r("my-4 min-h-[200px]",e),ref:S});if(x&&!d&&!u)return jsx("div",{className:r("my-4 flex justify-center p-4",e),ref:S,children:jsxs("div",{className:r("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:r("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:r("text-sm"),children:s.openscadWriting})]})});if(i$1&&!d&&!u)return jsx("div",{className:r("my-4 flex justify-center p-4",e),ref:S,children:jsxs("div",{className:r("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:r("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:r("text-sm"),children:s.openscadLoading})]})});if(a&&!d&&!u){let H=()=>h(I=>I+1);return y?jsx("div",{ref:S,children:jsx(y,{code:t,error:a,retry:H})}):jsxs("div",{className:r("rounded-md bg-red-50 p-4",e),ref:S,children:[jsxs("p",{className:r("font-mono text-red-700 text-sm"),children:[s.openscadErrorLabel,": ",a]}),jsxs("details",{className:r("mt-2"),children:[jsx("summary",{className:r("cursor-pointer text-red-600 text-xs"),children:s.showCode}),jsx("pre",{className:r("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:t})]})]})}let L=d!=null?d:u;return jsx("div",{className:r("size-full",e),"data-streamdown":"openscad",ref:S,children:jsx(Suspense,{fallback:jsx("div",{className:r("flex h-full items-center justify-center"),children:jsx("div",{className:r("h-4 w-4 animate-spin rounded-full border-current border-b-2 text-muted-foreground")})}),children:L?jsx(Mc,{className:e,data:L.data,format:L.format,fullscreen:o}):null})})};
51
+ export{De as A,Ye as B,Mi as C,Qe as D,nt as E,ot as F,pn as G,yc as H,hn as I,Cc as J,ds as K,Sc as L,ks as a,ut as b,_e as c,je as d,$n as e,Ft as f,zt as g,Mm as h,Wt as i,B as j,gt as k,ke as l,ze as m,Ut as n,We as o,ce as p,de as q,T as r,Me as s,yo as t,En as u,Io as v,Ae as w,Se as x,on as y,wt as z};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {createContext,useContext}from'react';var t=(...a)=>twMerge(clsx(a)),M=a=>{if(a!==void 0)return typeof a=="number"?!Number.isFinite(a)||a<=0?void 0:`${a}px`:a},g=(a,n)=>{if(!a||!n)return n;let o=`${a}:`;return n.split(/\s+/).filter(Boolean).map(r=>r.startsWith(o)?r:`${a}:${r}`).join(" ")},v=a=>a?(...n)=>g(a,twMerge(clsx(n))):t,D=(a,n,o)=>{let r=typeof n=="string"&&o.startsWith("text/csv")?"\uFEFF":"",d=typeof n=="string"?new Blob([r+n],{type:o}):n,i=URL.createObjectURL(d),e=document.createElement("a");e.href=i,e.download=a,document.body.appendChild(e),e.click(),document.body.removeChild(e),URL.revokeObjectURL(i);};var u=createContext(t),A=()=>useContext(u);var C={alertNote:"Note",alertTip:"Tip",alertImportant:"Important",alertWarning:"Warning",alertCaution:"Caution",copyCode:"Copy Code",copyDiagram:"Copy diagram",copyModel:"Copy model",downloadFile:"Download file",mermaidChart:"Mermaid chart",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",downloadDiagramAsPuml:"Download diagram as PlantUML",downloadDiagramAsSmi:"Download diagram as SMILES",downloadDiagramAsJson:"Download diagram as JSON",downloadDiagramAsSource:"Download diagram source",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",diagramChart:"Diagram",diagramErrorLabel:"Diagram Error",diagramFormatSource:"Source",diagramLoading:"Loading diagram...",diagramWriting:"Waiting for the diagram...",diagramPluginMissing:"Diagram plugin not available. Please add a matching diagram plugin to enable rendering.",diagramRenderFailed:"Failed to render diagram",showCode:"Show Code",mermaidErrorLabel:"Mermaid Error",mermaidPluginMissing:"Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.",mermaidRenderFailed:"Failed to render Mermaid chart",plantumlChart:"PlantUML chart",plantumlErrorLabel:"PlantUML Error",plantumlPluginMissing:"PlantUML plugin not available. Please add the plantuml plugin to enable diagram rendering.",plantumlRenderFailed:"Failed to render PlantUML chart",openscadErrorLabel:"OpenSCAD Error",openscadModel:"OpenSCAD model",openscadLoading:"Loading OpenSCAD engine and rendering model...",openscadPluginMissing:"OpenSCAD plugin not available. Please add the openscad plugin to enable model rendering.",openscadRenderFailed:"Failed to render model",openscadWriting:"Waiting for the model code...",downloadModel:"Download model",downloadModelAsScad:"Download model as SCAD",downloadModelAsStl:"Download model as STL",downloadModelAs3mf:"Download model as 3MF",openscadFormatScad:"SCAD",openscadFormatStl:"STL",openscadFormat3mf:"3MF",plantumlFormatSvg:"SVG",plantumlFormatPng:"PNG",plantumlFormatPuml:"PUML",smilesChart:"Chemical structure",smilesErrorLabel:"SMILES Error",smilesPluginMissing:"SMILES plugin not available. Please add the smiles plugin to enable chemical structure rendering.",smilesRenderFailed:"Failed to render SMILES structure",smilesFormatSmi:"SMI",smilesShowCompact:"Show compact notation",smilesShowStructures:"Show structures",vegaChart:"Vega chart",vegaErrorLabel:"Vega Error",vegaPluginMissing:"Vega plugin not available. Please add the vega plugin to enable chart rendering.",vegaRenderFailed:"Failed to render Vega chart",vegaFormatSvg:"SVG",vegaFormatPng:"PNG",vegaFormatJson:"JSON",zoomIn:"Zoom in",zoomOut:"Zoom out",resetView:"Reset zoom and pan",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},F=createContext(C),T=()=>useContext(F);export{t as a,M as b,v as c,D as d,u as e,A as f,C as g,F as h,T as i};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import {n,h,e}from'./chunk-TXJ25TS2.js';import'./chunk-6TBP27CO.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var x=({code:s,language:e$1,maxHeight:h$1,raw:t,className:m,startLine:d,lineNumbers:a,...c})=>{let{shikiTheme:l}=useContext(n),i=h(),[p,o]=useState(t);return useEffect(()=>{if(!i){o(t);return}let g=i.highlight({code:s,language:e$1,themes:l},H=>{o(H);});g&&o(g);},[s,e$1,l,i,t]),jsx(e,{className:m,language:e$1,lineNumbers:a,maxHeight:h$1,result:p,startLine:d,...c})};export{x as HighlightedCodeBlockBody};
2
+ import {r,h,e}from'./chunk-BSY33EDM.js';import'./chunk-GKDS2YGT.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var x=({code:s,language:e$1,maxHeight:h$1,raw:t,className:m,startLine:d,lineNumbers:a,...c})=>{let{shikiTheme:l}=useContext(r),i=h(),[p,o]=useState(t);return useEffect(()=>{if(!i){o(t);return}let g=i.highlight({code:s,language:e$1,themes:l},H=>{o(H);});g&&o(g);},[s,e$1,l,i,t]),jsx(e,{className:m,language:e$1,lineNumbers:a,maxHeight:h$1,result:p,startLine:d,...c})};export{x as HighlightedCodeBlockBody};
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export{E as Block,i as CodeBlock,f as CodeBlockContainer,j as CodeBlockCopyButton,k as CodeBlockDownloadButton,g as CodeBlockHeader,l as CodeBlockSkeleton,d as DefaultScrollable,F as Streamdown,n as StreamdownContext,v as TableCopyDropdown,w as TableDownloadButton,x as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,C as defaultRehypePlugins,D as defaultRemarkPlugins,o as defaultUrlTransform,y as detectTextDirection,t as escapeMarkdownTableCell,q as extractTableDataFromElement,B as normalizeHtmlIndentation,z as parseMarkdownIntoBlocks,A as parseMarkdownIntoBlocksIncremental,r as tableDataToCSV,u as tableDataToMarkdown,s as tableDataToTSV,c as useIsCodeFenceIncomplete}from'./chunk-TXJ25TS2.js';export{g as defaultTranslations,i as useTranslations}from'./chunk-6TBP27CO.js';
2
+ export{K as Block,i as CodeBlock,f as CodeBlockContainer,k as CodeBlockCopyButton,n as CodeBlockDownloadButton,g as CodeBlockHeader,o as CodeBlockSkeleton,d as DefaultScrollable,L as Streamdown,r as StreamdownContext,B as TableCopyDropdown,C as TableDownloadButton,D as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,I as defaultRehypePlugins,J as defaultRemarkPlugins,t as defaultUrlTransform,E as detectTextDirection,z as escapeMarkdownTableCell,w as extractTableDataFromElement,H as normalizeHtmlIndentation,F as parseMarkdownIntoBlocks,G as parseMarkdownIntoBlocksIncremental,x as tableDataToCSV,A as tableDataToMarkdown,y as tableDataToTSV,c as useIsCodeFenceIncomplete}from'./chunk-BSY33EDM.js';export{g as defaultTranslations,i as useTranslations}from'./chunk-GKDS2YGT.js';
@@ -0,0 +1,10 @@
1
+ import type { SvgDiagramPlugin } from "../plugin-types";
2
+ interface DiagramCodeBlockProps {
3
+ className?: string;
4
+ code: string;
5
+ isBlockIncomplete?: boolean;
6
+ language: string;
7
+ plugin: SvgDiagramPlugin;
8
+ }
9
+ export declare const DiagramCodeBlock: ({ className, code, isBlockIncomplete, language, plugin, }: DiagramCodeBlockProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -1,4 +1,4 @@
1
1
  import type { ControlsConfig } from "../streamdown-context";
2
- export type DiagramControlType = "download" | "copy" | "fullscreen" | "panZoom";
2
+ export type DiagramControlType = "download" | "copy" | "compact" | "fullscreen" | "panZoom";
3
3
  export declare const shouldShowDiagramControls: (config: ControlsConfig, name: string) => boolean;
4
4
  export declare const shouldShowDiagramControl: (config: ControlsConfig, name: string, controlType: DiagramControlType) => boolean;
@@ -250,6 +250,7 @@ export interface OpenScadPlugin {
250
250
  * Avoids a hard dependency on `smiles-drawer` in the core bundle.
251
251
  */
252
252
  export interface SmilesConfig {
253
+ compactDrawing?: boolean;
253
254
  elementColors?: boolean;
254
255
  height?: number;
255
256
  theme?: "light" | "dark" | "oldschool" | "auto";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Same default as `@streamdown/smiles` `resolveCompactDrawing` when the
3
+ * option is omitted: reaction SMILES start compact, molecules start skeletal.
4
+ * Kept here so core UI does not import the plugin package.
5
+ */
6
+ export declare function defaultSmilesCompactDrawing(source: string): boolean;
7
+ export declare function readConfiguredCompactDrawing(config: unknown): boolean | undefined;
8
+ export declare function withSmilesCompactDrawing(config: unknown, compactDrawing: boolean): unknown;
@@ -0,0 +1,6 @@
1
+ interface SmilesNotationToggleProps {
2
+ compact: boolean;
3
+ onToggle: () => void;
4
+ }
5
+ export declare const SmilesNotationToggle: ({ compact, onToggle, }: SmilesNotationToggleProps) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -14,6 +14,8 @@ export type CopyControlConfig<TOnCopy = () => void> = boolean | {
14
14
  export type DiagramControls = boolean | {
15
15
  download?: DownloadControlConfig;
16
16
  copy?: CopyControlConfig;
17
+ /** SMILES only: skeletal structures vs compact CH₃ / COOH notation. */
18
+ compact?: boolean;
17
19
  fullscreen?: boolean;
18
20
  panZoom?: boolean;
19
21
  };
@@ -20,6 +20,7 @@ export interface StreamdownTranslations {
20
20
  diagramLoading: string;
21
21
  diagramPluginMissing: string;
22
22
  diagramRenderFailed: string;
23
+ diagramWriting: string;
23
24
  downloadDiagram: string;
24
25
  downloadDiagramAsJson: string;
25
26
  downloadDiagramAsMmd: string;
@@ -72,6 +73,8 @@ export interface StreamdownTranslations {
72
73
  smilesFormatSmi: string;
73
74
  smilesPluginMissing: string;
74
75
  smilesRenderFailed: string;
76
+ smilesShowCompact: string;
77
+ smilesShowStructures: string;
75
78
  tableFormatCsv: string;
76
79
  tableFormatMarkdown: string;
77
80
  tableFormatTsv: string;
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export{v as OpenScad}from'./chunk-BSY33EDM.js';import'./chunk-GKDS2YGT.js';
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import {f,i}from'./chunk-6TBP27CO.js';import {useRef,useEffect}from'react';import {jsx}from'react/jsx-runtime';var z=p=>{p.traverse(i=>{let o=i;if(o.geometry&&o.geometry.dispose(),Array.isArray(o.material))for(let u of o.material)u.dispose();else o.material&&o.material.dispose();});},q=({className:p,data:i$1,format:o,fullscreen:u=false})=>{let P=f(),R=i(),b=useRef(null);return useEffect(()=>{let m=b.current;if(!m)return;let y=false,g=()=>{};return (async()=>{let e=await import('three'),[{STLLoader:j},{ThreeMFLoader:E},{OrbitControls:V}]=await Promise.all([import('three/examples/jsm/loaders/STLLoader.js'),import('three/examples/jsm/loaders/3MFLoader.js'),import('three/examples/jsm/controls/OrbitControls.js')]);if(y)return;let n=new e.WebGLRenderer({alpha:true,antialias:true});n.setPixelRatio(window.devicePixelRatio),m.appendChild(n.domElement);let c=new e.Scene,t=new e.PerspectiveCamera(45,1,.1,2e3),x=new e.Vector3(50,40,60).normalize();t.position.copy(x.clone().multiplyScalar(100));let s=new V(t,n.domElement);s.enableDamping=true,s.dampingFactor=.08;let A=new e.HemisphereLight(16777215,3159357,1.5);c.add(A);let M=new e.DirectionalLight(16777215,2.6);M.position.set(1,1.7,1.2),c.add(M);let v=new e.DirectionalLight(16777215,.7);v.position.set(-1,.5,-1),c.add(v);let r=new e.Group;c.add(r);let C=()=>{for(;r.children.length>0;){let a=r.children[0];r.remove(a),z(a);}let l=i$1.buffer.slice(i$1.byteOffset,i$1.byteOffset+i$1.byteLength);if(o==="3mf"){let a=new E().parse(l);r.add(a);}else {let a=new j().parse(l);a.computeVertexNormals();let F=new e.MeshStandardMaterial({color:9081504,roughness:.55,metalness:.1});r.add(new e.Mesh(a,F));}let d=new e.Box3().setFromObject(r),h=d.getSize(new e.Vector3),w=Math.max(h.x,h.y,h.z)||1,L=d.getCenter(new e.Vector3),T=w*2.2,f=t.position.clone().sub(s.target).normalize();(!Number.isFinite(f.x)||f.lengthSq()===0)&&f.copy(x),s.target.copy(L),t.position.copy(L).add(f.multiplyScalar(T)),t.near=Math.max(w/1e3,.01),t.far=Math.max(w*100,1e3),t.updateProjectionMatrix(),s.update();},O=()=>{let{clientHeight:l,clientWidth:d}=m;d===0||l===0||(t.aspect=d/l,t.updateProjectionMatrix(),n.setSize(d,l));},D=new ResizeObserver(O);D.observe(m),O(),C(),n.setAnimationLoop(()=>{s.update(),n.render(c,t);}),g=()=>{D.disconnect(),n.setAnimationLoop(null),s.dispose(),z(r),c.clear(),n.dispose(),n.domElement.remove();};})().catch(()=>{}),()=>{y=true,g();}},[i$1,o]),jsx("div",{"aria-label":R.openscadModel,className:P(u?"size-full":"h-[400px] w-full",p),"data-streamdown":"openscad-viewer",ref:b,role:"img"})};export{q as OpenScadViewer};
2
+ import {f,i}from'./chunk-GKDS2YGT.js';import {useRef,useEffect}from'react';import {jsx}from'react/jsx-runtime';var z=p=>{p.traverse(i=>{let o=i;if(o.geometry&&o.geometry.dispose(),Array.isArray(o.material))for(let u of o.material)u.dispose();else o.material&&o.material.dispose();});},q=({className:p,data:i$1,format:o,fullscreen:u=false})=>{let P=f(),R=i(),b=useRef(null);return useEffect(()=>{let m=b.current;if(!m)return;let y=false,g=()=>{};return (async()=>{let e=await import('three'),[{STLLoader:j},{ThreeMFLoader:E},{OrbitControls:V}]=await Promise.all([import('three/examples/jsm/loaders/STLLoader.js'),import('three/examples/jsm/loaders/3MFLoader.js'),import('three/examples/jsm/controls/OrbitControls.js')]);if(y)return;let n=new e.WebGLRenderer({alpha:true,antialias:true});n.setPixelRatio(window.devicePixelRatio),m.appendChild(n.domElement);let c=new e.Scene,t=new e.PerspectiveCamera(45,1,.1,2e3),x=new e.Vector3(50,40,60).normalize();t.position.copy(x.clone().multiplyScalar(100));let s=new V(t,n.domElement);s.enableDamping=true,s.dampingFactor=.08;let A=new e.HemisphereLight(16777215,3159357,1.5);c.add(A);let M=new e.DirectionalLight(16777215,2.6);M.position.set(1,1.7,1.2),c.add(M);let v=new e.DirectionalLight(16777215,.7);v.position.set(-1,.5,-1),c.add(v);let r=new e.Group;c.add(r);let C=()=>{for(;r.children.length>0;){let a=r.children[0];r.remove(a),z(a);}let l=i$1.buffer.slice(i$1.byteOffset,i$1.byteOffset+i$1.byteLength);if(o==="3mf"){let a=new E().parse(l);r.add(a);}else {let a=new j().parse(l);a.computeVertexNormals();let F=new e.MeshStandardMaterial({color:9081504,roughness:.55,metalness:.1});r.add(new e.Mesh(a,F));}let d=new e.Box3().setFromObject(r),h=d.getSize(new e.Vector3),w=Math.max(h.x,h.y,h.z)||1,L=d.getCenter(new e.Vector3),T=w*2.2,f=t.position.clone().sub(s.target).normalize();(!Number.isFinite(f.x)||f.lengthSq()===0)&&f.copy(x),s.target.copy(L),t.position.copy(L).add(f.multiplyScalar(T)),t.near=Math.max(w/1e3,.01),t.far=Math.max(w*100,1e3),t.updateProjectionMatrix(),s.update();},O=()=>{let{clientHeight:l,clientWidth:d}=m;d===0||l===0||(t.aspect=d/l,t.updateProjectionMatrix(),n.setSize(d,l));},D=new ResizeObserver(O);D.observe(m),O(),C(),n.setAnimationLoop(()=>{s.update(),n.render(c,t);}),g=()=>{D.disconnect(),n.setAnimationLoop(null),s.dispose(),z(r),c.clear(),n.dispose(),n.domElement.remove();};})().catch(()=>{}),()=>{y=true,g();}},[i$1,o]),jsx("div",{"aria-label":R.openscadModel,className:P(u?"size-full":"h-[400px] w-full",p),"data-streamdown":"openscad-viewer",ref:b,role:"img"})};export{q as OpenScadViewer};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/streamdown",
3
- "version": "2.15.0",
3
+ "version": "2.15.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,2 +0,0 @@
1
- "use client";
2
- import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {createContext,useContext}from'react';var t=(...a)=>twMerge(clsx(a)),S=a=>{if(a!==void 0)return typeof a=="number"?!Number.isFinite(a)||a<=0?void 0:`${a}px`:a},g=(a,n)=>{if(!a||!n)return n;let o=`${a}:`;return n.split(/\s+/).filter(Boolean).map(r=>r.startsWith(o)?r:`${a}:${r}`).join(" ")},v=a=>a?(...n)=>g(a,twMerge(clsx(n))):t,D=(a,n,o)=>{let r=typeof n=="string"&&o.startsWith("text/csv")?"\uFEFF":"",d=typeof n=="string"?new Blob([r+n],{type:o}):n,i=URL.createObjectURL(d),e=document.createElement("a");e.href=i,e.download=a,document.body.appendChild(e),e.click(),document.body.removeChild(e),URL.revokeObjectURL(i);};var u=createContext(t),y=()=>useContext(u);var F={alertNote:"Note",alertTip:"Tip",alertImportant:"Important",alertWarning:"Warning",alertCaution:"Caution",copyCode:"Copy Code",copyDiagram:"Copy diagram",copyModel:"Copy model",downloadFile:"Download file",mermaidChart:"Mermaid chart",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",downloadDiagramAsPuml:"Download diagram as PlantUML",downloadDiagramAsSmi:"Download diagram as SMILES",downloadDiagramAsJson:"Download diagram as JSON",downloadDiagramAsSource:"Download diagram source",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",diagramChart:"Diagram",diagramErrorLabel:"Diagram Error",diagramFormatSource:"Source",diagramLoading:"Loading diagram...",diagramPluginMissing:"Diagram plugin not available. Please add a matching diagram plugin to enable rendering.",diagramRenderFailed:"Failed to render diagram",showCode:"Show Code",mermaidErrorLabel:"Mermaid Error",mermaidPluginMissing:"Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.",mermaidRenderFailed:"Failed to render Mermaid chart",plantumlChart:"PlantUML chart",plantumlErrorLabel:"PlantUML Error",plantumlPluginMissing:"PlantUML plugin not available. Please add the plantuml plugin to enable diagram rendering.",plantumlRenderFailed:"Failed to render PlantUML chart",openscadErrorLabel:"OpenSCAD Error",openscadModel:"OpenSCAD model",openscadLoading:"Loading OpenSCAD engine and rendering model...",openscadPluginMissing:"OpenSCAD plugin not available. Please add the openscad plugin to enable model rendering.",openscadRenderFailed:"Failed to render model",openscadWriting:"Waiting for the model code...",downloadModel:"Download model",downloadModelAsScad:"Download model as SCAD",downloadModelAsStl:"Download model as STL",downloadModelAs3mf:"Download model as 3MF",openscadFormatScad:"SCAD",openscadFormatStl:"STL",openscadFormat3mf:"3MF",plantumlFormatSvg:"SVG",plantumlFormatPng:"PNG",plantumlFormatPuml:"PUML",smilesChart:"Chemical structure",smilesErrorLabel:"SMILES Error",smilesPluginMissing:"SMILES plugin not available. Please add the smiles plugin to enable chemical structure rendering.",smilesRenderFailed:"Failed to render SMILES structure",smilesFormatSmi:"SMI",vegaChart:"Vega chart",vegaErrorLabel:"Vega Error",vegaPluginMissing:"Vega plugin not available. Please add the vega plugin to enable chart rendering.",vegaRenderFailed:"Failed to render Vega chart",vegaFormatSvg:"SVG",vegaFormatPng:"PNG",vegaFormatJson:"JSON",zoomIn:"Zoom in",zoomOut:"Zoom out",resetView:"Reset zoom and pan",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},b=createContext(F),T=()=>useContext(b);export{t as a,S as b,v as c,D as d,u as e,y as f,F as g,b as h,T as i};
@@ -1,51 +0,0 @@
1
- "use client";
2
- import {a,f,b,i,c,g,h,e,d}from'./chunk-6TBP27CO.js';import {createContext,memo,useContext,useMemo,lazy,isValidElement,useLayoutEffect,useId,useRef,useEffect,useDeferredValue,useState,createElement,useCallback,Suspense,cloneElement}from'react';import {harden}from'rehype-harden';import Uo from'rehype-raw';import zs,{defaultSchema}from'rehype-sanitize';import vd from'remark-gfm';import kd from'remend';import {visitParents,SKIP as SKIP$1}from'unist-util-visit-parents';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import Oi from'remark-parse';import Hi from'remark-rehype';import {unified}from'unified';import {visit,SKIP}from'unist-util-visit';import {toText}from'hast-util-to-text';import {Lexer}from'marked';var Qs=300,ea="300px",ta=500;function St(e={}){let{immediate:t=false,debounceDelay:n=Qs,rootMargin:o=ea,idleTimeout:r=ta}=e,[s,a]=useState(false),l=useRef(null),i=useRef(null),c=useRef(null),d=useMemo(()=>f=>{let p=Date.now();return window.setTimeout(()=>{f({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-p))});},1)},[]),m=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(f,p)=>window.requestIdleCallback(f,p):d,[d]),u=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?f=>window.cancelIdleCallback(f):f=>{clearTimeout(f);},[]);return useEffect(()=>{if(t){a(true);return}let f=l.current;if(!f)return;i.current&&(clearTimeout(i.current),i.current=null),c.current&&(u(c.current),c.current=null);let p=()=>{i.current&&(clearTimeout(i.current),i.current=null),c.current&&(u(c.current),c.current=null);},h=C=>{c.current=m(k=>{k.timeRemaining()>0||k.didTimeout?(a(true),C.disconnect()):c.current=m(()=>{a(true),C.disconnect();},{timeout:r/2});},{timeout:r});},g=C=>{p(),i.current=window.setTimeout(()=>{var I,L;let k=C.takeRecords();(k.length===0||(L=(I=k.at(-1))==null?void 0:I.isIntersecting)!=null&&L)&&h(C);},n);},b=(C,k)=>{C.isIntersecting?g(k):p();},y=new IntersectionObserver(C=>{for(let k of C)b(k,y);},{rootMargin:o,threshold:0});return y.observe(f),()=>{i.current&&clearTimeout(i.current),c.current&&u(c.current),y.disconnect();}},[t,n,o,r,u,m]),{shouldRender:s,containerRef:l}}var na=320,oa=4,Xn=()=>typeof performance=="undefined"?Date.now():performance.now();function en(e){var s,a;let t=(s=e==null?void 0:e.now)!=null?s:Xn,n=(a=e==null?void 0:e.maxBacklogMs)!=null?a:na,o=0,r=0;return {now:t,beginPass(l){r=Math.min(Math.max(o,l),l+n);},mark(){return r},rewind(l){r=l;},take(l,i,c){if(l<=0)return {baseDelay:0,step:Math.max(0,i)};let d=Math.max(0,i),m=d===0?0:Math.min(d,oa),u=Math.max(r,c),f=c+n,p=u+Math.max(0,l-1)*d,h=d;if(p>f&&l>1)if(u<f){let b=f-u;h=Math.max(m,b/(l-1));}else h=m;let g=Math.max(0,Math.round(u-c));return r=u+l*h,{baseDelay:g,step:h}},commitPass(){o=r;}}}function ra(){return {current:0}}var Jn=/\s/,tn=/^\s+$/,sa=new Set(["pre","svg","math","annotation"]),aa=new Set(["svg","math","annotation"]),Qt=new Set(["img","hr"]),ia=new Set(["ul","ol","li"]),Be=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",nn=(e,t)=>{let n=t?aa:sa;return e.some(o=>Be(o)&&n.has(o.tagName))},la=e=>{for(let t=e.length-1;t>=0;t-=1){let n=e[t];if(Be(n)&&n.tagName==="li")return n}},ca=(e,t,n,o)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate-marker"]=true,e.properties.style=`--sd-marker-duration:${t}ms;--sd-marker-delay:${n}ms;--sd-marker-easing:${o}`;},Yn=e=>{for(let t of e.children)if(Be(t)){if(t.tagName==="input")return t;if(ia.has(t.tagName))continue;let n=Yn(t);if(n)return n}},Qn=(e,t,n,o)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate"]=true;let r=typeof e.properties.style=="string"?`${e.properties.style};`:"";e.properties.style=`${r}--sd-animation:sd-${t.animation};--sd-duration:${n}ms;--sd-easing:${t.easing};--sd-delay:${o}ms`;},da=(e,t,n,o)=>{let r=Yn(e);r&&Qn(r,t,n,o);},eo=e=>{var t;for(let n=e.length-1;n>=0;n-=1){let o=e[n];if(Be(o)){if((t=o.properties)!=null&&t["data-sd-animated"])break;o.properties={...o.properties,"data-sd-animated":true};}}},to=e=>{let t=[],n="",o=false;for(let r of e){let s=Jn.test(r);if(s!==o&&n){if(s){n+=r,o=true;continue}t.push(n),n="";}n+=r,o=s;}return n&&t.push(n),t},no=e=>{let t=[],n="";for(let o of e)Jn.test(o)?t.length>0&&!tn.test(t.at(-1))?t[t.length-1]+=o:n+=o:(n&&(t.push(n),n=""),t.push(o));return n&&(t.length>0?t[t.length-1]+=n:t.push(n)),t},ma=(e,t,n,o,r,s)=>{let a=`--sd-animation:sd-${t};--sd-duration:${r?0:n}ms;--sd-easing:${o}`;return s&&(a+=`;--sd-delay:${Math.round(s)}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:a},children:[{type:"text",value:e}]}},ua=(e,t,n,o)=>{let r=0,s=0;return visitParents(e,a=>a.type==="text"||Be(a)&&Qt.has(a.tagName),(a,l)=>{if(nn(l,n.animateCodeBlocks))return SKIP$1;if(Be(a)&&Qt.has(a.tagName)){o>0&&s<o||(r+=1),s+=1;return}let i=a.value;if(!i.trim()){s+=i.length;return}let c=t.sep==="char"?no(i):to(i);for(let d of c){let m=s;s+=d.length,!tn.test(d)&&(o>0&&m<o||(r+=1));}}),r},pa=(e,t,n,o,r,s)=>{if(nn(t,o.animateCodeBlocks))return;let a=o.prevContentLength,l=r.count;r.count+=1;let i=a>0&&l<a,c=i?0:s.baseDelay+r.newIndex++*s.step;Qn(e,n,i?0:n.duration,c),eo(t);},fa=(e,t,n,o,r,s)=>{var b;let a=t.at(-1);if(!(a&&"children"in a))return;if(nn(t,o.animateCodeBlocks))return SKIP$1;let l=a,i=l.children.indexOf(e);if(i===-1)return;let c=e.value;if(!c.trim()){r.count+=c.length;return}let d=n.sep==="char"?no(c):to(c),m=o.prevContentLength,u=false,f=la(t),p=!!(f&&!((b=f.properties)!=null&&b["data-sd-animate-marker"])),h=false,g=d.map(y=>{let C=r.count;if(r.count+=y.length,tn.test(y))return {type:"text",value:y};let k=m>0&&C<m,S=k?0:s.baseDelay+r.newIndex++*s.step;if(f&&p&&!h){let I=k?0:n.duration;ca(f,I,S,n.easing),da(f,n,I,S),h=true;}return u=true,ma(y,n.animation,n.duration,n.easing,k,S)});return u&&eo(t),l.children.splice(i,1,...g),i+g.length},ga=0;function Tt(e){var s,a,l,i,c;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",duration:(a=e==null?void 0:e.duration)!=null?a:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(c=e==null?void 0:e.stagger)!=null?c:40,timeline:e==null?void 0:e.timeline},n={animateCodeBlocks:false,committedCharCount:0,prevContentLength:0,lastRenderCharCount:0,pendingMark:null},o=ga++,r=()=>d=>{var h;let m={count:0,newIndex:0};n.prevContentLength=n.committedCharCount;let u=t.timeline,f=(h=u==null?void 0:u.now())!=null?h:Xn();u&&(n.pendingMark===null?n.pendingMark=u.mark():u.rewind(n.pendingMark));let p=u?u.take(ua(d,t,n,n.prevContentLength),t.stagger,f):{baseDelay:0,step:t.stagger};visitParents(d,g=>g.type==="text"||Be(g)&&Qt.has(g.tagName),(g,b)=>{if(g.type==="text")return fa(g,b,t,n,m,p);pa(g,b,t,n,m,p);}),n.lastRenderCharCount=m.count,n.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${o}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(d){n.animateCodeBlocks=d;},setPrevContentLength(d){n.committedCharCount=d,n.prevContentLength=d;},getLastRenderCharCount(){return n.lastRenderCharCount},commit(){n.committedCharCount=n.lastRenderCharCount,n.pendingMark=null;}}}Tt();var on=createContext(false),Ye=()=>useContext(on);function oo(e){let t=[],n=[],o=0;return r=>{let s=new Map;for(let i=0;i<t.length;i+=1){let c=t[i],d=n[i];c!==void 0&&d!==void 0&&!s.has(c)&&s.set(c,d);}let a=new Set,l=r.map((i,c)=>{let d=t[c],m=n[c];if(d!==void 0&&m!==void 0&&!a.has(m)&&(d===i||i.startsWith(d)))return a.add(m),m;let u=s.get(i);if(u!==void 0&&!a.has(u))return a.add(u),u;let f=`${e}-${o}`;return o+=1,a.add(f),f});return t=r,n=l,l}}var Qe=({scrollRef:e,ref:t,...n})=>jsx("div",{ref:e,...n});var xa=8,va=e=>e.scrollHeight-e.scrollTop-e.clientHeight<xa,io=e=>{var n,o;let t=(o=(n=e.touches[0])!=null?n:e.changedTouches[0])!=null?o:null;return typeof(t==null?void 0:t.clientY)=="number"?t.clientY:null},Et=({enabled:e,isAnimating:t,content:n})=>{let[o,r]=useState(null),s=useRef(true),a=useRef(0),l=useCallback(c=>{r(d=>d===c?d:c);},[]),i=useCallback(c=>{t&&s.current&&(c.scrollTo({top:c.scrollHeight,behavior:"instant"}),a.current=c.scrollTop);},[t]);return useEffect(()=>{t||(s.current=true);},[t]),useEffect(()=>{if(!(e&&o))return;a.current=o.scrollTop;let c=()=>{s.current=false;},d=g=>{g.deltaY<0&&c();},m=null,u=g=>{m=io(g);},f=g=>{if(m===null)return;let b=io(g);if(b===null)return;let y=b-m;Math.abs(y)<=3||(y>0&&c(),m=b);},p=()=>{m=null;},h=()=>{let g=o.scrollTop<a.current;if(a.current=o.scrollTop,g){c();return}va(o)&&(s.current=true);};return o.addEventListener("wheel",d,{capture:true,passive:true}),o.addEventListener("touchstart",u,{passive:true}),o.addEventListener("touchmove",f,{passive:true}),o.addEventListener("touchend",p,{passive:true}),o.addEventListener("touchcancel",p,{passive:true}),o.addEventListener("scroll",h,{passive:true}),()=>{o.removeEventListener("wheel",d,{capture:true}),o.removeEventListener("touchstart",u),o.removeEventListener("touchmove",f),o.removeEventListener("touchend",p),o.removeEventListener("touchcancel",p),o.removeEventListener("scroll",h);}},[e,o]),useLayoutEffect(()=>{if(!(e&&o)||(i(o),typeof ResizeObserver=="undefined"))return;let c=new ResizeObserver(()=>{i(o);});c.observe(o);for(let d of o.children)c.observe(d);return ()=>{c.disconnect();}},[n,o,e,i]),l};var Sa=a("block"),Ta=a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),Ea=e=>{let t={};for(let n of e.split(";")){let o=n.indexOf(":");if(o>0){let r=n.slice(0,o).trim(),s=n.slice(o+1).trim();r&&s&&(t[r]=s);}}return t},lo=memo(({children:e,result:t,language:n,className:o,maxHeight:r,startLine:s,lineNumbers:a=true,...l})=>{let i=f(),{isAnimating:c,scrollable:d}=useContext(M),m=d!=null?d:Qe,u=b(r),f$1=Et({content:t,enabled:!!u,isAnimating:c}),p=useMemo(()=>i(Ta),[i]),h=useMemo(()=>i(Sa),[i]),g=useMemo(()=>{let b={};return t.bg&&(b["--sdm-bg"]=t.bg),t.fg&&(b["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(b,Ea(t.rootStyle)),b},[t.bg,t.fg,t.rootStyle]);return jsx(m,{className:i(o,u?"overflow-x-auto overflow-y-auto":"overflow-x-auto","rounded-md border border-border bg-background p-4 text-sm"),"data-language":n,"data-streamdown":"code-block-body",scrollRef:f$1,style:u?{maxHeight:u}:void 0,...l,children:jsx("pre",{className:i(o,"bg-[var(--sdm-bg,inherit)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]"),style:g,children:jsx("code",{className:a?i("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&s&&s>1?{counterReset:`line ${s-1}`}:void 0,children:t.tokens.map((b,y)=>jsx("span",{className:a?p:h,children:b.length===0||b.length===1&&b[0].content===""?`
3
- `:b.map((C,k)=>{let S={},I=!!C.bgColor;if(C.color&&(S["--sdm-c"]=C.color),C.bgColor&&(S["--sdm-tbg"]=C.bgColor),C.htmlStyle)for(let[L,P]of Object.entries(C.htmlStyle))L==="color"?S["--sdm-c"]=P:L==="background-color"?(S["--sdm-tbg"]=P,I=true):S[L]=P;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",I&&"bg-[var(--sdm-tbg)]",I&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:S,...C.htmlAttrs,children:C.content},k)})},y))})})})});var sn=({className:e,language:t,style:n,isIncomplete:o,...r})=>{let s=f();return jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":o||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...r})};var an=createContext({code:""}),Rt=()=>useContext(an);var ln=({language:e})=>{let t=f();return jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var Aa=e=>{let t=e.length;for(;t>0&&e[t-1]===`
4
- `;)t--;return e.slice(0,t)},Oa=lazy(()=>import('./highlighted-body-N5O52WFD.js').then(e=>({default:e.HighlightedCodeBlockBody}))),cn=({code:e,language:t,className:n,children:o,isIncomplete:r=false,startLine:s,lineNumbers:a,...l})=>{let i=f(),{codeBlockMaxHeight:c}=useContext(M),d=useMemo(()=>Aa(e),[e]),m=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
5
- `).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]);return jsx(an.Provider,{value:{code:e},children:jsxs(sn,{dir:"ltr",isIncomplete:r,language:t,children:[jsx(ln,{language:t}),o?jsx("div",{className:i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("div",{className:i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:o})}):null,jsx(Suspense,{fallback:jsx(lo,{className:n,language:t,lineNumbers:a,maxHeight:c,result:m,startLine:s,...l}),children:jsx(Oa,{className:n,code:d,language:t,lineNumbers:a,maxHeight:c,raw:m,startLine:s,...l})})]})})};var uo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),po=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),fo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),go=e=>jsxs("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),bo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),ho=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),yo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),Co=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),wo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),xo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var tt={CheckIcon:uo,CopyIcon:po,DownloadIcon:fo,ExternalLinkIcon:Co,Loader2Icon:go,Maximize2Icon:bo,RotateCcwIcon:ho,XIcon:yo,ZoomInIcon:wo,ZoomOutIcon:xo},ko=createContext(tt),Fa=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let n=Object.keys(e),o=Object.keys(t);return n.length!==o.length?false:n.every(r=>e[r]===t[r])},dn=({icons:e,children:t})=>{let n=useRef(e),o=useRef(e?{...tt,...e}:tt);Fa(n.current,e)||(n.current=e,o.current=e?{...tt,...e}:tt);let r=o.current;return jsx(ko.Provider,{value:r,children:t})},V=()=>useContext(ko);var nt=({onCopy:e,onError:t,timeout:n=2e3,children:o,className:r,code:s,label:a,...l})=>{let i$1=f(),[c,d]=useState(false),m=useRef(0),{code:u}=Rt(),{isAnimating:f$1}=useContext(M),p=i(),h=s!=null?s:u,g=a!=null?a:p.copyCode,b=async()=>{var k;if(typeof window=="undefined"||!((k=navigator==null?void 0:navigator.clipboard)!=null&&k.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{c||(await navigator.clipboard.writeText(h),d(!0),e==null||e(),m.current=window.setTimeout(()=>d(!1),n));}catch(S){t==null||t(S);}};useEffect(()=>()=>{window.clearTimeout(m.current);},[]);let y=V(),C=c?y.CheckIcon:y.CopyIcon;return jsxs(Fragment,{children:[jsx("button",{"aria-label":g,className:i$1("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:f$1,onClick:b,title:g,type:"button",...l,children:o!=null?o:jsx(C,{"aria-hidden":"true",size:14})}),c&&jsx("output",{"aria-live":"polite",className:"sr-only",children:p.copied})]})};var It=e=>typeof e=="object"&&e!==null,Po=(e,t)=>{var n;if(typeof e!="boolean")return t!=="diagrams"&&t in e?e[t]:(n=e.diagrams)==null?void 0:n[t]},ye=(e,t,n)=>{if(typeof e=="boolean")return n;let o=Po(e,t);if(!It(o))return n;let r=o.download;return !It(r)||typeof r.filename!="string"?n:r.filename||n};function Ke(e,t){if(typeof e=="boolean")return {};let n=Po(e,t);if(!It(n))return {};let o=n.copy;return It(o)?{onCopy:typeof o.onCopy=="function"?o.onCopy:void 0,onError:typeof o.onError=="function"?o.onError:void 0}:{}}var So={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",smiles:"smi",smi:"smi",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",vega:"vg.json","vega-lite":"vl.json",vegalite:"vl.json",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",\u6587\u8A00:"wy"},un=({onDownload:e,onError:t,language:n,children:o,className:r,code:s,...a})=>{let l=f(),{code:i$1}=Rt(),{isAnimating:c,controls:d$1}=useContext(M),m=i(),u=V(),f$1=s!=null?s:i$1,p=n&&n in So?So[n]:"txt",h=`${ye(d$1,"code","file")}.${p}`,g="text/plain",b=()=>{try{d(h,f$1,g),e==null||e();}catch(y){t==null||t(y);}};return jsx("button",{"aria-label":m.downloadFile,className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:c,onClick:b,title:m.downloadFile,type:"button",...a,children:o!=null?o:jsx(u.DownloadIcon,{size:14})})};var ot=()=>{let{Loader2Icon:e}=V(),t=f();return jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:jsx(e,{className:t("size-4 animate-spin")})})]})};var Lt=(e,t)=>{var n;return t==="mermaid"?e.mermaid:t==="plantuml"?e.plantuml:t==="vega"?e.vega:t==="smiles"?e.smiles:(n=e.diagrams)==null?void 0:n[t]};var Eo=(e,t)=>{var n;return typeof e=="boolean"?e:t!=="diagrams"&&t in e?e[t]:(n=e.diagrams)==null?void 0:n[t]},Ro=(e,t)=>typeof e=="boolean"?e:Eo(e,t)!==false,Te=(e,t,n)=>{if(typeof e=="boolean")return e;let o=Eo(e,t);return o===false?false:o===true||o===void 0?true:typeof o=="object"&&o!==null?o[n]!==false:true};var Xa=/(<svg\b)/,Mo=/<svg\b[^>]*>/i,Ja=/\bviewBox=(['"])(.*?)\1/i,Ya=/\swidth=(['"]).*?\1/gi,Qa=/\sheight=(['"]).*?\1/gi,Io=/\sstyle=(['"])(.*?)\1/i,Lo=/^<svg/i,ei=/^width\s*:/i,ti=/^height\s*:/i,ni=/^max-width\s*:/i,oi=/[\s,]+/,ri=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(Xa,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),No=e=>{if(typeof DOMParser=="undefined"||typeof XMLSerializer=="undefined")return e;let n=new DOMParser().parseFromString(e,"text/html").querySelector("svg");return n?new XMLSerializer().serializeToString(n):e},fn=e=>{let t=e.match(Mo);if(!t)return null;let o=t[0].match(Ja),r=o==null?void 0:o[2];if(!r)return null;let s=r.trim().split(oi).map(i=>Number.parseFloat(i));if(s.length<4||s.slice(0,4).some(Number.isNaN))return null;let a=s[2],l=s[3];return a>0&&l>0?{height:l,width:a}:null},Do=e=>{let t=e.match(Mo);if(!t)return e;try{let n=t[0],o=fn(e);if(!o)return e;let{width:r,height:s}=o,a=n.replace(Ya,"").replace(Qa,""),l=a.match(Io),i=`width:${r}px;height:${s}px;max-width:none;`;if(l){let c=l[1],m=l[2].split(";").map(f=>f.trim()).filter(Boolean).filter(f=>!(ei.test(f)||ti.test(f)||ni.test(f))).join(";"),u=`${i}${m?`${m};`:""}`;a=a.replace(Io,` style=${c}${u}${c}`);}else a=a.replace(Lo,`<svg style="${i}"`);return a=a.replace(Lo,`<svg width="${r}" height="${s}"`),e.replace(n,a)}catch(n){return e}},Ao=(e,t)=>{var o;let n=(o=void 0)!=null?o:5;return new Promise((r,s)=>{let a=ri(e),l="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let c=document.createElement("canvas"),d=i.width*n,m=i.height*n;c.width=d,c.height=m;let u=c.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(i,0,0,d,m),c.toBlob(f=>{if(!f){s(new Error("Failed to create PNG blob"));return}r(f);},"image/png");},i.onerror=()=>s(new Error("Failed to load SVG image")),i.src=l;})};var si={chart:"diagramChart",error:"diagramErrorLabel",missing:"diagramPluginMissing",failed:"diagramRenderFailed"},ai={mermaid:{chart:"mermaidChart",error:"mermaidErrorLabel",missing:"mermaidPluginMissing",failed:"mermaidRenderFailed"},plantuml:{chart:"plantumlChart",error:"plantumlErrorLabel",missing:"plantumlPluginMissing",failed:"plantumlRenderFailed"},vega:{chart:"vegaChart",error:"vegaErrorLabel",missing:"vegaPluginMissing",failed:"vegaRenderFailed"},smiles:{chart:"smilesChart",error:"smilesErrorLabel",missing:"smilesPluginMissing",failed:"smilesRenderFailed"}},ii={mermaid:"mermaidFormatMmd",plantuml:"plantumlFormatPuml",vega:"vegaFormatJson",smiles:"smilesFormatSmi"},li={mermaid:"downloadDiagramAsMmd",plantuml:"downloadDiagramAsPuml",vega:"downloadDiagramAsJson",smiles:"downloadDiagramAsSmi"},rt=(e,t,n)=>{var r;let o=(r=ai[t])!=null?r:si;return e[o[n]]},Oo=(e,t,n)=>{let o=ii[t];return o?e[o]:n.toUpperCase()||e.diagramFormatSource},gn=(e,t)=>{let n=li[t];return n?e[n]:e.downloadDiagramAsSource},Ho=e=>e==="mermaid"?"Mermaid plugin not available":e==="plantuml"?"PlantUML plugin not available":e==="vega"?"Vega plugin not available":e==="smiles"?"SMILES plugin not available":"Diagram plugin not available";var Mt=(e,t)=>e===void 0&&t===void 0?void 0:{...typeof e=="object"&&e!==null?e:{},language:t};var Nt=({chart:e,children:t,className:n,config:o,language:r,name:s,onDownload:a,onError:l,plugin:i$1,sourceExtension:c})=>{var L;let d$1=f(),[m,u]=useState(false),f$1=useRef(null),{isAnimating:p,controls:h}=useContext(M),g=V(),b=i(),y=(L=c!=null?c:i$1==null?void 0:i$1.sourceExtension)!=null?L:"txt",C=ye(h,s,"diagram"),k=P=>{u(false),a==null||a(P);},S=async P=>{if(!i$1){l==null||l(new Error(Ho(s)));return}let{svg:A}=await i$1.render(e,Mt(o,r));if(!A){l==null||l(new Error("SVG not found. Please wait for the diagram to render."));return}let z=No(A);if(P==="svg"){d(`${C}.svg`,z,"image/svg+xml"),k(P);return}let j=await Ao(z);d(`${C}.png`,j,"image/png"),k(P);},I=async P=>{try{if(P==="source"){d(`${C}.${y}`,e,"text/plain"),k(P);return}await S(P);}catch(A){l==null||l(A);}};return useEffect(()=>{let P=A=>{let z=A.composedPath();f$1.current&&!z.includes(f$1.current)&&u(false);};return document.addEventListener("mousedown",P),()=>{document.removeEventListener("mousedown",P);}},[]),jsxs("div",{className:d$1("relative"),ref:f$1,children:[jsx("button",{"aria-label":b.downloadDiagram,className:d$1("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:p,onClick:()=>u(!m),title:b.downloadDiagram,type:"button",children:t!=null?t:jsx(g.DownloadIcon,{"aria-hidden":"true",size:14})}),m?jsxs("div",{className:d$1("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":b.downloadDiagramAsSvg,className:d$1("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>I("svg"),title:b.downloadDiagramAsSvg,type:"button",children:b.mermaidFormatSvg}),jsx("button",{"aria-label":b.downloadDiagramAsPng,className:d$1("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>I("png"),title:b.downloadDiagramAsPng,type:"button",children:b.mermaidFormatPng}),jsx("button",{"aria-label":gn(b,s),className:d$1("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>I("source"),title:gn(b,s),type:"button",children:Oo(b,s,y)})]}):null]})};var Ee=e=>{let t=typeof e=="function"?e():e;return t!=null?t:document.body};var at=0,me=()=>{at+=1,at===1&&(document.body.style.overflow="hidden");},ue=()=>{at=Math.max(0,at-1),at===0&&(document.body.style.overflow="");};var Fo=({DiagramComponent:e,chart:t,className:n,config:o,language:r,name:s,onExit:a,onFullscreen:l,plugin:i$1,sourceExtension:c,...d})=>{let{Maximize2Icon:m,XIcon:u}=V(),f$1=f(),[p,h]=useState(false),{isAnimating:g,controls:b,portal:y}=useContext(M),C=i(),k=Te(b,s,"panZoom"),S=Te(b,s,"download"),I=()=>{h(!p);};return useEffect(()=>{if(p){me();let L=P=>{P.key==="Escape"&&h(false);};return document.addEventListener("keydown",L),()=>{document.removeEventListener("keydown",L),ue();}}},[p]),useEffect(()=>{p?l==null||l():a&&a();},[p,l,a]),jsxs(Fragment,{children:[jsx("button",{className:f$1("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:g,onClick:I,title:C.viewFullscreen,type:"button",...d,"aria-label":C.viewFullscreen,children:jsx(m,{"aria-hidden":"true",size:14})}),p?createPortal(jsxs("div",{"aria-label":C.viewFullscreen,"aria-modal":"true",className:f$1("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":`${s}-fullscreen`,onClick:I,onKeyDown:L=>{L.key==="Escape"&&I();},role:"dialog",children:[jsxs("div",{className:f$1("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:L=>L.stopPropagation(),onKeyDown:L=>L.stopPropagation(),role:"presentation",children:[S?jsx(Nt,{chart:t,config:o,language:r,name:s,plugin:i$1,sourceExtension:c}):null,jsx("button",{"aria-label":C.exitFullscreen,className:f$1("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:I,title:C.exitFullscreen,type:"button",children:jsx(u,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:f$1("flex size-full items-center justify-center p-4"),onClick:L=>L.stopPropagation(),onKeyDown:L=>L.stopPropagation(),role:"presentation",children:e?jsx(e,{chart:t,className:f$1("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:o,fullscreen:true,language:r,showControls:k}):jsx(Vo,{chart:t,className:f$1("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:o,fallbackName:s,fullscreen:true,language:r,plugin:i$1,showControls:k})})]}),Ee(y)):null]})};var yi=["github-light","github-dark"],Ci={enabled:true},wi={codeBlockMaxHeight:400,shikiTheme:yi,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,openscad:void 0,plantuml:void 0,smiles:void 0,vega:void 0,diagrams:void 0,linkSafety:Ci,portal:void 0,tableMaxHeight:300},M=createContext(wi);var Pi=/\.[^/.]+$/,jo=(e,t)=>{if(typeof e=="boolean")return e;let n=e.image;return n===false?false:n===true||n===void 0?true:n[t]!==false},zo=({node:e,className:t,src:n,alt:o,onLoad:r,onError:s,onClick:a,...l})=>{let{DownloadIcon:i$1,XIcon:c}=V(),d$1=f(),m=useRef(null),[u,f$1]=useState(false),[p,h]=useState(false),[g,b]=useState(false),{controls:y}=useContext(M),C=i(),k=jo(y,"download"),S=jo(y,"fullscreen"),I=l.width!=null||l.height!=null,L=k&&(u||I)&&!p,P=p&&!I,A=S&&!!n&&!p&&u;useEffect(()=>{let T=m.current;if(T!=null&&T.complete){let R=T.naturalWidth>0;f$1(R),h(!R);}},[]),useEffect(()=>{if(!g)return;me();let T=R=>{R.key==="Escape"&&b(false);};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T),ue();}},[g]);let z=useCallback(T=>{f$1(true),h(false),r==null||r(T);},[r]),j=useCallback(T=>{f$1(false),h(true),s==null||s(T);},[s]),E=useCallback(()=>{A&&b(true);},[A]),K=useCallback(()=>{b(false);},[]),oe=useCallback(T=>{a==null||a(T),!T.defaultPrevented&&E();},[a,E]),Q=async T=>{if(T.stopPropagation(),!!n)try{let F=await(await fetch(n)).blob(),G=new URL(n,window.location.origin).pathname.split("/").pop()||"",be=G.split(".").pop(),ke=G.includes(".")&&be!==void 0&&be.length<=4,ie="";if(ke)ie=G;else {let re=F.type,ne="png";re.includes("jpeg")||re.includes("jpg")?ne="jpg":re.includes("png")?ne="png":re.includes("svg")?ne="svg":re.includes("gif")?ne="gif":re.includes("webp")&&(ne="webp"),ie=`${(o||G||"image").replace(Pi,"")}.${ne}`;}d(ie,F,F.type);}catch(R){window.open(n,"_blank");}};return n?n==="streamdown:incomplete-image"?jsx("div",{className:d$1("group relative my-4 inline-block"),"data-incomplete":"true","data-streamdown":"image-wrapper",children:jsx("div",{className:d$1("h-24 w-48 animate-pulse rounded-lg bg-muted"),"data-streamdown":"image-placeholder"})}):jsxs(Fragment,{children:[jsxs("div",{className:d$1("group/image not-prose relative my-2 block max-w-full"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:o,className:d$1("m-0 block h-auto max-w-full rounded-lg",A&&"cursor-zoom-in",P&&"hidden",t),"data-streamdown":"image",onClick:oe,onError:j,onLoad:z,ref:m,src:n,...l}),P&&jsx("span",{className:d$1("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:C.imageNotAvailable}),L&&jsx("button",{"aria-label":C.downloadImage,className:d$1("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 focus-visible:opacity-100 group-hover/image:opacity-100"),onClick:Q,title:C.downloadImage,type:"button",children:jsx(i$1,{size:14})})]}),g?createPortal(jsxs("div",{className:d$1("fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4"),"data-streamdown":"image-lightbox",onClick:K,onKeyDown:T=>{T.key==="Escape"&&K();},role:"button",tabIndex:0,children:[jsx("button",{"aria-label":C.exitFullscreen,className:d$1("absolute top-4 right-4 z-10 rounded-md p-2 text-white/80 transition-colors hover:bg-white/10 hover:text-white"),onClick:K,title:C.exitFullscreen,type:"button",children:jsx(c,{size:20})}),jsx("div",{onClick:T=>T.stopPropagation(),onKeyDown:T=>T.stopPropagation(),role:"presentation",children:jsx("img",{alt:o,className:d$1("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:n})})]}),document.body):null]}):null};var Zo=({url:e,isOpen:t,onClose:n,onConfirm:o})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=V(),i$1=f(),[c,d]=useState(false),m=i(),{portal:u}=useContext(M),f$1=useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(g){}},[e]),p=useCallback(()=>{o(),n();},[o,n]);if(useEffect(()=>{if(t){me();let g=b=>{b.key==="Escape"&&n();};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),ue();}}},[t,n]),!t||typeof document=="undefined")return null;let h=jsx("div",{className:i$1("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:n,onKeyDown:g=>{g.key==="Escape"&&n();},role:"button",tabIndex:0,children:jsxs("div",{className:i$1("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:[jsx("button",{"aria-label":m.close,className:i$1("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:n,title:m.close,type:"button",children:jsx(l,{size:16})}),jsxs("div",{className:i$1("flex flex-col gap-2"),children:[jsxs("div",{className:i$1("flex items-center gap-2 font-semibold text-lg"),children:[jsx(a,{size:20}),jsx("span",{children:m.openExternalLink})]}),jsx("p",{className:i$1("text-muted-foreground text-sm"),children:m.externalLinkWarning})]}),jsx("div",{className:i$1("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:i$1("flex gap-2"),children:[jsx("button",{className:i$1("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:f$1,type:"button",children:c?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:m.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:m.copyLink})]})}),jsxs("button",{className:i$1("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:p,type:"button",children:[jsx(a,{size:14}),jsx("span",{children:m.openLink})]})]})]})});return createPortal(h,Ee(u))};var qo=()=>e=>{visit(e,"html",(n,o,r)=>{!r||typeof o!="number"||(r.children[o]={type:"text",value:n.value});});};var Go=[],Xo={allowDangerousHtml:true},Dt=new WeakMap,wn=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(o||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return "";let u="";for(let f=0;f<m.length;f+=1){let p=m[f];if(f>0&&(u+=","),Array.isArray(p)){let[h,g]=p;if(typeof h=="function"){let b=Dt.get(h);b||(b=h.name,Dt.set(h,b)),u+=b;}else u+=String(h);u+=":",u+=JSON.stringify(g);}else if(typeof p=="function"){let h=Dt.get(p);h||(h=p.name,Dt.set(p,h)),u+=h;}else u+=String(p);}return u},l=a(o),i=a(r),c=s?JSON.stringify(s):"",d=`${i}::${l}::${c}`;return this.keyCache.set(t,d),d}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(o,n);}clear(){this.cache.clear();}},Jo=new wn,lt=e=>{let t=Vi(e),n=e.children||"",o=t.runSync(t.parse(n),n);return Ki(o,e)},Vi=e=>{let t=Jo.get(e);if(t)return t;let n=$i(e);return Jo.set(e,n),n},Fi=e=>e.some(t=>Array.isArray(t)?t[0]===Uo:t===Uo),$i=e=>{let t=e.rehypePlugins||Go,n=e.remarkPlugins||Go,o=Fi(t)?n:[...n,qo],r=e.remarkRehypeOptions?{...Xo,...e.remarkRehypeOptions}:Xo;return unified().use(Oi).use(o).use(Hi,r).use(t)},Yo=e=>e,ji=(e,t,n,o)=>{n?e.children.splice(t,1):e.children[t]={type:"text",value:o};},zi=(e,t)=>{var n;for(let o in urlAttributes)if(Object.hasOwn(urlAttributes,o)&&Object.hasOwn(e.properties,o)){let r=e.properties[o],s=urlAttributes[o];(s===null||s.includes(e.tagName))&&(e.properties[o]=(n=t(String(r||""),o,e))!=null?n:void 0);}},Wi=(e,t,n,o,r,s)=>{let a=false;return o?a=!o.includes(e.tagName):r&&(a=r.includes(e.tagName)),!a&&s&&typeof t=="number"&&(a=!s(e,t,n)),a},Ki=(e,t)=>{let{allowElement:n,allowedElements:o,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:l}=t;if(n||o||r||s||l){let c=l||Yo;visit(e,(d,m,u)=>{if(d.type==="raw"&&u&&typeof m=="number")return ji(u,m,s,d.value),m;if(d.type==="element"&&(zi(d,c),Wi(d,m,u,o,r,n)&&u&&typeof m=="number"))return a&&d.children?u.children.splice(m,1,...d.children):u.children.splice(m,1),m});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var Qo=/[(){}[\]]/,Zi=/[\s;]/,qi=/^[\w-]+$/,Ui=/:::[\w-]+\s*$/,Gi=/^[/\\]/,Xi=/[/\\]$/,Ji=/("[^"]*")/,Yi=[["((","))"],["))","(("],["{{","}}"],["[","]"],["(",")"],[")","("]],ct=e=>`"${e.replace(/"/g,"#quot;")}"`,Qi=e=>e.length>=2&&e.startsWith('"')&&e.endsWith('"'),el=e=>{var o,r,s,a;let t=e.split(`
6
- `),n=0;if(((o=t[n])==null?void 0:o.trim())==="---"){for(n+=1;n<t.length&&((r=t[n])==null?void 0:r.trim())!=="---";)n+=1;n+=1;}for(;n<t.length;){let l=(a=(s=t[n])==null?void 0:s.trim())!=null?a:"";if(l&&!l.startsWith("%%")){let i=l.split(Zi,1)[0];return i==="mindmap"?"mindmap":i==="flowchart"||i==="graph"?"flowchart":null}n+=1;}return null},tl=e=>{for(let[t,n]of Yi){let o=e.indexOf(t);if(o===-1||!e.endsWith(n))continue;let r=e.slice(0,o);if(r&&!qi.test(r))continue;let s=e.slice(o+t.length,e.length-n.length);if(!(s.includes(n)&&n!==t))return {id:r,open:t,close:n,inner:s}}return null},nl=e=>{let t=e.length-e.trimStart().length,n=e.slice(0,t),o=e.trim();if(!o||o.startsWith("%%")||o.startsWith("::icon"))return e;let r=tl(o);if(r)return !Qi(r.inner)&&(Qo.test(r.inner)||r.inner.includes('"'))?`${n}${r.id}${r.open}${ct(r.inner)}${r.close}`:e;if(Qo.test(o)){let s=o.replace(Ui,"").trimEnd();return `${n}[${ct(s)}]`}return e},ol=e=>{let t=e.split(`
7
- `),n=false;return t.map(o=>n?nl(o):(o.trim()&&(n=true),o)).join(`
8
- `)},rl=e=>e.startsWith("(")&&e.endsWith(")")||Gi.test(e)||Xi.test(e),xn=(e,t)=>e.split(Ji).map((n,o)=>o%2===0?t(n):n).join(""),sl=e=>{if(e.trim().startsWith("%%"))return e;let t=xn(e,n=>n.replace(/\[([^[\]"]*[(){}][^[\]"]*)\]/g,(o,r)=>rl(r)?o:`[${ct(r)}]`));return t=xn(t,n=>n.replace(/\{([^{}"]*[()[\]][^{}"]*)\}/g,(o,r)=>`{${ct(r)}}`)),t=xn(t,n=>n.replace(/\|([^|"]*[(){}[\]][^|"]*)\|/g,(o,r)=>`|${ct(r)}|`)),t},al=e=>e.split(`
9
- `).map(sl).join(`
10
- `),er=e=>{let t=el(e);if(!t)return null;let n=t==="mindmap"?ol(e):al(e);return n===e?null:n};var il=()=>{if(typeof document=="undefined")return false;let e=document.documentElement;return e.classList.contains("dark")||e.dataset.theme==="dark"||e.dataset.colorMode==="dark"},ll=(e,t)=>Array.isArray(t)?t.includes(e):t===e,cl=e=>"getMermaid"in e&&typeof e.getMermaid=="function",dl=e=>"getPlantUml"in e&&typeof e.getPlantUml=="function",ml=e=>"getVega"in e&&typeof e.getVega=="function",ul=e=>"getSmiles"in e&&typeof e.getSmiles=="function";var pl=e=>{let t=e.split("").reduce((n,o)=>(n<<5)-n+o.charCodeAt(0)|0,0);return `mermaid-${Math.abs(t)}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`},fl=async(e,t,n)=>{try{return await e.render(t,n)}catch(o){let r=er(n);if(!r)throw o;try{return await e.render(`${t}-autofix`,r)}catch(s){throw o}}},gl=e=>{var t,n;return cl(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:"mmd",render:async(o,r)=>{let s=e.getMermaid(r);return await fl(s,pl(o),o)}}:dl(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:"puml",render:async(o,r)=>{var l;let s=r,a=(l=s==null?void 0:s.dark)!=null?l:il();return await e.getPlantUml(s).render(o,{...s,dark:a})}}:ml(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:(t=e.sourceExtension)!=null?t:"json",render:(o,r)=>e.getVega(r).render(o,r)}:ul(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:(n=e.sourceExtension)!=null?n:"smi",render:(o,r)=>e.getSmiles(r).render(o,r)}:e},tr=e=>{var n;if(!e)return [];let t=[];return e.mermaid&&t.push(e.mermaid),e.plantuml&&t.push(e.plantuml),e.vega&&t.push(e.vega),e.smiles&&t.push(e.smiles),[...t,...(n=e.diagrams)!=null?n:[]].map(gl)},nr=(e,t)=>{var n;return (n=e.find(o=>ll(t,o.language)))!=null?n:null};var At=createContext(null),Ot=()=>useContext(At),hp=()=>{var t;let e=Ot();return (t=e==null?void 0:e.code)!=null?t:null};var Cl=()=>{let e=Ot();return useMemo(()=>tr(e),[e])},or=e=>{let t=Cl();return nr(t,e)},Ze=()=>{var t;let e=Ot();return (t=e==null?void 0:e.openscad)!=null?t:null};var rr=e=>{var n;let t=Ot();return t!=null&&t.renderers&&e&&(n=t.renderers.find(o=>Array.isArray(o.language)?o.language.includes(e):o.language===e))!=null?n:null};var ar={"3mf":"model/3mf",stl:"model/stl"},Ht=({children:e,className:t,code:n,config:o,onDownload:r,onError:s})=>{let a=f(),[l,i$1]=useState(false),[c,d$1]=useState(false),m=useRef(null),{controls:u,isAnimating:f$1}=useContext(M),p=V(),h=Ze(),g=i(),b=ye(u,"openscad","model"),y=async C=>{try{if(C==="scad"){d(`${b}.scad`,n,"text/plain"),i$1(!1),r==null||r(C);return}if(!h){s==null||s(new Error("OpenSCAD plugin not available"));return}d$1(!0);let k=h.getOpenScad(o),{data:S}=await k.render(n,{...o,format:C}),I=S.buffer.slice(S.byteOffset,S.byteOffset+S.byteLength);d(`${b}.${C}`,new Blob([I],{type:ar[C]}),ar[C]),r==null||r(C),i$1(!1);}catch(k){s==null||s(k);}finally{d$1(false);}};return useEffect(()=>{let C=k=>{let S=k.composedPath();m.current&&!S.includes(m.current)&&i$1(false);};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C);}},[]),jsxs("div",{className:a("relative"),ref:m,children:[jsx("button",{"aria-label":g.downloadModel,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:f$1||c,onClick:()=>i$1(!l),title:g.downloadModel,type:"button",children:e!=null?e:jsx(p.DownloadIcon,{"aria-hidden":"true",size:14})}),l?jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":g.downloadModelAsScad,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("scad"),title:g.downloadModelAsScad,type:"button",children:g.openscadFormatScad}),jsx("button",{"aria-label":g.downloadModelAsStl,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("stl"),title:g.downloadModelAsStl,type:"button",children:g.openscadFormatStl}),jsx("button",{"aria-label":g.downloadModelAs3mf,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("3mf"),title:g.downloadModelAs3mf,type:"button",children:g.openscadFormat3mf})]}):null]})};var El=lazy(()=>import('./viewer-URBRVFVJ.js').then(e=>({default:e.OpenScadViewer}))),lr=({className:e,code:t,config:n,fullscreen:o=false})=>{let r=f(),s=i(),[a,l]=useState(null),[i$1,c]=useState(false),[d,m]=useState(null),[u,f$1]=useState(null),[p,h]=useState(0),{openscad:g}=useContext(M),b=Ze(),y=g==null?void 0:g.errorComponent,C=Ye(),{shouldRender:k,containerRef:S}=St({immediate:o});if(useEffect(()=>{if(!k||C)return;if(!b){l(s.openscadPluginMissing);return}(async()=>{try{l(null),c(!0);let A=await b.getOpenScad(n).render(t,n);m(A),f$1(A);}catch(P){if(!(u||d)){let A=P instanceof Error?P.message:s.openscadRenderFailed;l(A);}}finally{c(false);}})();},[t,n,p,k,C,b,s]),!(k||d||u))return jsx("div",{className:r("my-4 min-h-[200px]",e),ref:S});if(C&&!d&&!u)return jsx("div",{className:r("my-4 flex justify-center p-4",e),ref:S,children:jsxs("div",{className:r("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:r("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:r("text-sm"),children:s.openscadWriting})]})});if(i$1&&!d&&!u)return jsx("div",{className:r("my-4 flex justify-center p-4",e),ref:S,children:jsxs("div",{className:r("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:r("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:r("text-sm"),children:s.openscadLoading})]})});if(a&&!d&&!u){let L=()=>h(P=>P+1);return y?jsx("div",{ref:S,children:jsx(y,{code:t,error:a,retry:L})}):jsxs("div",{className:r("rounded-md bg-red-50 p-4",e),ref:S,children:[jsxs("p",{className:r("font-mono text-red-700 text-sm"),children:[s.openscadErrorLabel,": ",a]}),jsxs("details",{className:r("mt-2"),children:[jsx("summary",{className:r("cursor-pointer text-red-600 text-xs"),children:s.showCode}),jsx("pre",{className:r("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:t})]})]})}let I=d!=null?d:u;return jsx("div",{className:r("size-full",e),"data-streamdown":"openscad",ref:S,children:jsx(Suspense,{fallback:jsx("div",{className:r("flex h-full items-center justify-center"),children:jsx("div",{className:r("h-4 w-4 animate-spin rounded-full border-current border-b-2 text-muted-foreground")})}),children:I?jsx(El,{className:e,data:I.data,format:I.format,fullscreen:o}):null})})};var dr=({code:e,config:t,onFullscreen:n,onExit:o,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=V(),i$1=f(),[c,d]=useState(false),{isAnimating:m,controls:u,portal:f$1}=useContext(M),p=i(),h=(()=>{if(typeof u=="boolean")return u;let b=u.openscad;return b===false?false:b===true||b===void 0?true:b.download!==false})(),g=()=>{d(!c);};return useEffect(()=>{if(c){me();let b=y=>{y.key==="Escape"&&d(false);};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),ue();}}},[c]),useEffect(()=>{c?n==null||n():o&&o();},[c,n,o]),jsxs(Fragment,{children:[jsx("button",{className:i$1("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:g,title:p.viewFullscreen,type:"button",...s,"aria-label":p.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),c?createPortal(jsxs("div",{"aria-label":p.viewFullscreen,"aria-modal":"true",className:i$1("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"openscad-fullscreen",onClick:g,onKeyDown:b=>{b.key==="Escape"&&g();},role:"dialog",children:[jsxs("div",{className:i$1("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:[h?jsx(Ht,{code:e,config:t}):null,jsx("button",{"aria-label":p.exitFullscreen,className:i$1("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:g,title:p.exitFullscreen,type:"button",children:jsx(l,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:i$1("flex size-full items-center justify-center p-4"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:jsx(lr,{className:i$1("size-full"),code:e,config:t,fullscreen:true})})]}),Ee(f$1)):null]})};var kn=e=>e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(kn).join(""):isValidElement(e)?kn(e.props.children):"",mr=(e,t,n)=>n!=null?n:(t?toText(t):kn(e)).replace(/\s+/g," ").trim()||void 0;function Pn(e){var n;if(e.nodeType===Node.TEXT_NODE)return (n=e.textContent)!=null?n:"";if(e.nodeType!==Node.ELEMENT_NODE)return "";let t=e;return t.tagName==="BR"?`
11
- `:Array.from(t.childNodes).map(Pn).join("")}var qe=e=>{let t=[],n=[],o=e.querySelectorAll("thead th");for(let s of o)t.push(Pn(s).trim());let r=e.querySelectorAll("tbody tr");for(let s of r){let a=[],l=s.querySelectorAll("td");for(let i of l)a.push(Pn(i).trim());n.push(a);}return {headers:t,rows:n}},pt=e=>{var n;if(typeof e!="object")return ",";let t=e.table;return typeof t!="object"?",":(n=t.csvSeparator)!=null?n:","},$e=(e,t=",")=>{let n;t==="auto"?Intl.NumberFormat().format(1.1).includes(",")?n=";":n=",":n=t;let{headers:o,rows:r}=e,s=c=>{let d=false;for(let m of c)if(m===n||m==='"'||m===`
12
- `||m==="\r"){d=true;break}return d?`"${c.replace(/"/g,'""')}"`:c},a=o.length>0?r.length+1:r.length,l=new Array(a),i=0;o.length>0&&(l[i]=o.map(s).join(n),i+=1);for(let c of r)l[i]=c.map(s).join(n),i+=1;return l.join(`
13
- `)},Sn=e=>{let{headers:t,rows:n}=e,o=l=>{let i=false;for(let d of l)if(d===" "||d===`
14
- `||d==="\r"){i=true;break}if(!i)return l;let c=[];for(let d of l)d===" "?c.push("\\t"):d===`
15
- `?c.push("\\n"):d==="\r"?c.push("\\r"):c.push(d);return c.join("")},r=t.length>0?n.length+1:n.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(o).join(" "),a+=1);for(let l of n)s[a]=l.map(o).join(" "),a+=1;return s.join(`
16
- `)},Bt=e=>{let t=false;for(let o of e)if(o==="\\"||o==="|"||o===`
17
- `){t=true;break}if(!t)return e;let n=[];for(let o of e)o==="\\"?n.push("\\\\"):o==="|"?n.push("\\|"):o===`
18
- `?n.push("<br>"):n.push(o);return n.join("")},Ue=e=>{let{headers:t,rows:n}=e;if(t.length===0)return "";let o=new Array(n.length+2),r=0,s=t.map(l=>Bt(l));o[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let l=0;l<t.length;l+=1)a[l]="---";o[r]=`| ${a.join(" | ")} |`,r+=1;for(let l of n)if(l.length<t.length){let i=new Array(t.length);for(let c=0;c<t.length;c+=1)i[c]=c<l.length?Bt(l[c]):"";o[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(c=>Bt(c));o[r]=`| ${i.join(" | ")} |`,r+=1;}return o.join(`
19
- `)};var gt=({children:e,className:t,onCopy:n,onError:o,timeout:r=2e3})=>{let s=f(),[a,l]=useState(false),[i$1,c]=useState(false),d=useRef(null),m=useRef(0),{isAnimating:u,controls:f$1}=useContext(M),p=i(),h=pt(f$1),g=Ke(f$1,"table"),b=n!=null?n:g.onCopy,y=o!=null?o:g.onError,C=async I=>{var L,P;if(typeof window=="undefined"||!((L=navigator==null?void 0:navigator.clipboard)!=null&&L.write)){y==null||y(new Error("Clipboard API not available"));return}try{let A=(P=d.current)==null?void 0:P.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),z=A==null?void 0:A.querySelector("table");if(!z){y==null||y(new Error("Table not found"));return}let j=qe(z),E="";I==="csv"?E=$e(j,h):I==="tsv"?E=Sn(j):E=Ue(j);let K=new ClipboardItem({"text/plain":new Blob([E],{type:"text/plain"}),"text/html":new Blob([z.outerHTML],{type:"text/html"})});await navigator.clipboard.write([K]),c(!0),l(!1),b==null||b(I),m.current=window.setTimeout(()=>c(!1),r);}catch(A){y==null||y(A);}};useEffect(()=>{let I=L=>{let P=L.composedPath();d.current&&!P.includes(d.current)&&l(false);};return document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I),window.clearTimeout(m.current);}},[]);let k=V(),S=i$1?k.CheckIcon:k.CopyIcon;return jsxs("div",{className:s("relative"),ref:d,children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>l(!a),title:p.copyTable,type:"button",children:e!=null?e:jsx(S,{height:14,width:14})}),a?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>C("md"),title:p.copyTableAsMarkdown,type:"button",children:p.tableFormatMarkdown}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>C("csv"),title:p.copyTableAsCsv,type:"button",children:p.tableFormatCsv}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>C("tsv"),title:p.copyTableAsTsv,type:"button",children:p.tableFormatTsv})]}):null]})};var Vl=({children:e,className:t,onDownload:n,onError:o,format:r="csv",filename:s})=>{let a=f(),{isAnimating:l,controls:i$1}=useContext(M),c=i(),d$1=V(),m=pt(i$1),u=f=>{try{let h=f.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),g=h==null?void 0:h.querySelector("table");if(!g){o==null||o(new Error("Table not found"));return}let b=qe(g),y="",C="",k="";switch(r){case "csv":y=$e(b,m),C="text/csv",k="csv";break;case "markdown":y=Ue(b),C="text/markdown",k="md";break;default:y=$e(b,m),C="text/csv",k="csv";}d(`${s||ye(i$1,"table","table")}.${k}`,y,C),n==null||n();}catch(p){o==null||o(p);}};return jsx("button",{"aria-label":r==="csv"?c.downloadTableAsCsv:c.downloadTableAsMarkdown,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:u,title:r==="csv"?c.downloadTableAsCsv:c.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d$1.DownloadIcon,{size:14})})},bt=({children:e,className:t,onDownload:n,onError:o})=>{let r=f(),[s,a]=useState(false),l=useRef(null),{isAnimating:i$1,controls:c}=useContext(M),d$1=i(),m=V(),u=pt(c),f$1=p=>{var h;try{let g=(h=l.current)==null?void 0:h.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),b=g==null?void 0:g.querySelector("table");if(!b){o==null||o(new Error("Table not found"));return}let y=qe(b),C=p==="csv"?$e(y,u):Ue(y),k=p==="csv"?"csv":"md",S=`${ye(c,"table","table")}.${k}`;d(S,C,p==="csv"?"text/csv":"text/markdown"),a(!1),n==null||n(p);}catch(g){o==null||o(g);}};return useEffect(()=>{let p=h=>{let g=h.composedPath();l.current&&!g.includes(l.current)&&a(false);};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p);}},[]),jsxs("div",{className:r("relative"),ref:l,children:[jsx("button",{"aria-label":d$1.downloadTable,className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i$1,onClick:()=>a(!s),title:d$1.downloadTable,type:"button",children:e!=null?e:jsx(m.DownloadIcon,{size:14})}),s?jsxs("div",{className:r("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":d$1.downloadTableAsCsv,className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("csv"),title:d$1.downloadTableAsCsv,type:"button",children:d$1.tableFormatCsv}),jsx("button",{"aria-label":d$1.downloadTableAsMarkdown,className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("markdown"),title:d$1.downloadTableAsMarkdown,type:"button",children:d$1.tableFormatMarkdown})]}):null]})};var hr=({children:e,className:t,showCopy:n=true,showDownload:o=true})=>{let{Maximize2Icon:r,XIcon:s}=V(),a=f(),[l,i$1]=useState(false),{isAnimating:c,portal:d}=useContext(M),m=i(),u=()=>{i$1(true);},f$1=()=>{i$1(false);};return useEffect(()=>{if(l){me();let p=h=>{h.key==="Escape"&&i$1(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),ue();}}},[l]),jsxs(Fragment,{children:[jsx("button",{"aria-label":m.viewFullscreen,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:u,title:m.viewFullscreen,type:"button",children:jsx(r,{size:14})}),l?createPortal(jsx("div",{"aria-label":m.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:f$1,onKeyDown:p=>{p.key==="Escape"&&f$1();},role:"dialog",children:jsxs("div",{className:a("flex h-full flex-col"),onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:[jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[n?jsx(gt,{}):null,o?jsx(bt,{}):null,jsx("button",{"aria-label":m.exitFullscreen,className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:f$1,title:m.exitFullscreen,type:"button",children:jsx(s,{size:20})})]}),jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:a("w-full table-fixed border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),Ee(d)):null]})};var Cr=({children:e,className:t,maxHeight:n,showControls:o,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...l})=>{let i=f(),{isAnimating:c,scrollable:d}=useContext(M),m=d!=null?d:Qe,u=b(n),f$1=Et({content:e,enabled:!!u,isAnimating:c}),p=o&&r,h=o&&s,g=o&&a,b$1=p||h||g;return jsxs("div",{className:i("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[b$1?jsxs("div",{className:i("flex items-center justify-end gap-1"),children:[p?jsx(gt,{}):null,h?jsx(bt,{}):null,g?jsx(hr,{showCopy:p,showDownload:h,children:e}):null]}):null,jsx(m,{className:i("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),scrollRef:f$1,style:u?{maxHeight:u}:void 0,children:jsx("table",{className:i("w-full table-fixed divide-y divide-border",t),"data-streamdown":"table",...l,children:e})})]})};var Gl=/startLine=(\d+)/,Xl=/\bnoLineNumbers\b/,Jl=lazy(()=>import('./diagram-O5F65CLC.js').then(e=>({default:e.Diagram}))),Yl=lazy(()=>import('./openscad-RHDHURT6.js').then(e=>({default:e.OpenScad}))),Ql=/language-([^\s]+)/,fe=e=>e.props,ec="node";function _(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return false;let o=e,r=t;for(let s of n)if(s!==ec&&!Object.is(o[s],r[s]))return false;return true}function tc(e,t){var n,o;return ((n=e==null?void 0:e.properties)==null?void 0:n.metastring)===((o=t==null?void 0:t.properties)==null?void 0:o.metastring)}function nc(e){if(typeof e=="string")return e;if(isValidElement(e)){let t=fe(e).children;if(typeof t=="string")return t}}var oc=(e,t)=>Array.isArray(t)?t.includes(e):t===e,rc=(e,t)=>!!(t&&oc(e,t.language)),Mn=(e,t)=>typeof e=="boolean"?e:e[t]!==false,In=(e,t)=>{if(typeof e=="boolean")return e;let n=e.table;return n===false?false:n===true||n===void 0?true:n[t]!==false},wr=(e,t)=>{if(typeof e=="boolean")return e;let n=e.code;return n===false?false:n===true||n===void 0?true:n[t]!==false},Ln=(e,t)=>{if(typeof e=="boolean")return e;let n=e.openscad;return n===false?false:n===true||n===void 0?true:n[t]!==false},yt=createContext({depth:0,ulDepth:0,isUnordered:false}),sc={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},Nn=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{depth:s,ulDepth:a}=useContext(yt),l=useMemo(()=>({depth:s+1,ulDepth:a,isUnordered:false}),[s,a]);return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"ordered-list",...o,children:jsx(yt.Provider,{value:l,children:e})})},(e,t)=>_(e,t));Nn.displayName="MarkdownOl";var Sr=memo(({children:e,className:t,node:n,...o})=>{var h;let r=f(),{depth:s,ulDepth:a,isUnordered:l}=useContext(yt),{listStyle:i}=useContext(M),c=sc[i],d=l&&a>0?c[(a-1)%c.length]:void 0,m=Array.isArray(e)?e.filter(g=>g!==`
20
- `&&g!==""):[e],u=m[0],f$1=isValidElement(u)?(h=fe(u).node)==null?void 0:h.tagName:void 0,p=m.length===1&&isValidElement(u)&&(u.type==="p"||f$1==="p")?fe(u).children:e;return t!=null&&t.includes("task-list-item")?jsx("li",{className:r("my-1 flex list-none items-center gap-2 [&>input]:m-0 [&>p]:inline",t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...o,children:p}):jsx("li",{className:r("py-1 [&>p]:inline",d,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...o,children:p})},(e,t)=>_(e,t));Sr.displayName="MarkdownLi";var Tr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{depth:s,ulDepth:a}=useContext(yt),l=useMemo(()=>({depth:s+1,ulDepth:a+1,isUnordered:true}),[s,a]);return jsx("ul",{className:r("list-inside whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"unordered-list",...o,children:jsx(yt.Provider,{value:l,children:e})})},(e,t)=>_(e,t));Tr.displayName="MarkdownUl";var Er=memo(({className:e,node:t,...n})=>{let o=f();return jsx("hr",{className:o("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n})},(e,t)=>_(e,t));Er.displayName="MarkdownHr";var Rr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...o,children:e})},(e,t)=>_(e,t));Rr.displayName="MarkdownStrong";var ac=({children:e,className:t,href:n,node:o,...r})=>{let s=f(),{linkSafety:a}=useContext(M),[l,i]=useState(false),c=n==="streamdown:incomplete-link",d=useCallback(async p=>{if(!(!(a!=null&&a.enabled&&n)||c)){if(p.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(n)){window.open(n,"_blank","noreferrer");return}i(true);}},[a,n,c]),m=useCallback(()=>{n&&window.open(n,"_blank","noreferrer");},[n]),u=useCallback(()=>{i(false);},[]),f$1={url:n!=null?n:"",isOpen:l,onClose:u,onConfirm:m};return a!=null&&a.enabled&&n?jsxs(Fragment,{children:[jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",onClick:d,type:"button",children:e}),a.renderModal?a.renderModal(f$1):jsx(Zo,{...f$1})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...r,children:e})},Ir=memo(ac,(e,t)=>_(e,t));Ir.displayName="MarkdownA";var Lr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e})},(e,t)=>_(e,t));Lr.displayName="MarkdownH1";var Mr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e})},(e,t)=>_(e,t));Mr.displayName="MarkdownH2";var Nr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e})},(e,t)=>_(e,t));Nr.displayName="MarkdownH3";var Dr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e})},(e,t)=>_(e,t));Dr.displayName="MarkdownH4";var Ar=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e})},(e,t)=>_(e,t));Ar.displayName="MarkdownH5";var Or=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e})},(e,t)=>_(e,t));Or.displayName="MarkdownH6";var Hr=memo(({children:e,className:t,node:n,...o})=>{let{controls:r,tableMaxHeight:s}=useContext(M),a=Mn(r,"table"),l=In(r,"copy"),i=In(r,"download"),c=In(r,"fullscreen");return jsx(Cr,{className:t,maxHeight:s,showControls:a,showCopy:l,showDownload:i,showFullscreen:c,...o,children:e})},(e,t)=>_(e,t));Hr.displayName="MarkdownTable";var Br=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e})},(e,t)=>_(e,t));Br.displayName="MarkdownThead";var _r=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...o,children:e})},(e,t)=>_(e,t));_r.displayName="MarkdownTbody";var Vr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...o,children:e})},(e,t)=>_(e,t));Vr.displayName="MarkdownTr";var Fr=memo(({children:e,className:t,node:n,title:o,...r})=>{let s=f(),a=mr(e,n,o);return jsx("th",{className:s("min-w-0 overflow-hidden px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...r,title:a,children:jsx("span",{className:s("wrap-anywhere line-clamp-2"),children:e})})},(e,t)=>_(e,t));Fr.displayName="MarkdownTh";var $r=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("td",{className:r("wrap-anywhere min-w-0 px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e})},(e,t)=>_(e,t));$r.displayName="MarkdownTd";var jr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e})},(e,t)=>_(e,t));jr.displayName="MarkdownBlockquote";var zr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...o,children:e})},(e,t)=>_(e,t));zr.displayName="MarkdownSup";var ic=()=>({}),lc=e=>{try{let t=atob(e),n=Uint8Array.from(t,o=>o.charCodeAt(0));return new TextDecoder().decode(n)}catch(t){return ""}},Wr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{calloutIcon:s,calloutStyle:a,components:l,remarkPlugins:i,rehypePlugins:c}=useContext(M),d=o,m=d["data-callout-title"],u=d["data-callout-color"],f$1=d["data-callout-icon"],p=d["data-callout-body"],h=p?lc(p):"",g=(a!=null?a:ic)(u),b=f$1&&s?s(f$1):null;return jsxs("div",{className:r("my-4 rounded-md border-l-4 px-4 py-3 [&>p:last-child]:mb-0",t),"data-streamdown":"callout",style:g,...o,children:[m!==void 0?jsxs("p",{className:"mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",children:[b,m]}):null,h.trim().length>0?jsx(lt,{components:l,rehypePlugins:c,remarkPlugins:i,children:h}):null]})},(e,t)=>_(e,t));Wr.displayName="MarkdownCallout";var xr={"markdown-alert-note":"border-l-blue-500 bg-blue-500/5 [&_.markdown-alert-title]:text-blue-600 dark:[&_.markdown-alert-title]:text-blue-400","markdown-alert-tip":"border-l-green-600 bg-green-600/5 [&_.markdown-alert-title]:text-green-700 dark:[&_.markdown-alert-title]:text-green-400","markdown-alert-important":"border-l-purple-600 bg-purple-600/5 [&_.markdown-alert-title]:text-purple-700 dark:[&_.markdown-alert-title]:text-purple-400","markdown-alert-warning":"border-l-amber-600 bg-amber-600/5 [&_.markdown-alert-title]:text-amber-700 dark:[&_.markdown-alert-title]:text-amber-400","markdown-alert-caution":"border-l-red-600 bg-red-600/5 [&_.markdown-alert-title]:text-red-700 dark:[&_.markdown-alert-title]:text-red-400"},Kr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),s=t==null?void 0:t.includes("markdown-alert");if(t==null?void 0:t.includes("sdm-callout"))return jsx(Wr,{className:t,node:n,...o,children:e});if(s){let l=Object.keys(xr).find(i=>t==null?void 0:t.includes(i));return jsx("div",{className:r("my-4 rounded-r-md border-muted-foreground/30 border-l-4 bg-muted/40 px-4 py-3 [&>p:last-child]:mb-0",l?xr[l]:null,t),...o,children:e})}return jsx("div",{className:r(t),...o,children:e})},(e,t)=>_(e,t));Kr.displayName="MarkdownDiv";var Zr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...o,children:e})},(e,t)=>_(e,t));Zr.displayName="MarkdownSub";var qr=memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let s=i=>{if(!isValidElement(i))return false;let c=fe(i).children,d=Array.isArray(c)?c:[c],m=false,u=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(m=true);else if(isValidElement(f))if(fe(f)["data-footnote-backref"]!==void 0)u=true;else {let p=fe(f).children,h=Array.isArray(p)?p:[p];for(let g of h){if(typeof g=="string"&&g.trim()!==""){m=true;break}if(isValidElement(g)&&fe(g)["data-footnote-backref"]===void 0){m=true;break}}}}return u&&!m},a=Array.isArray(e)?e.map(i=>{if(!isValidElement(i))return i;if(i.type===Nn){let c=fe(i).children,m=(Array.isArray(c)?c:[c]).filter(u=>!s(u));return m.length===0?null:{...i,props:{...fe(i),children:m}}}return i}):e;return (Array.isArray(a)?a.some(i=>i!==null):a!==null)?jsx("section",{className:t,...o,children:a}):null}return jsx("section",{className:t,...o,children:e})},(e,t)=>_(e,t));qr.displayName="MarkdownSection";var cc=({node:e,className:t,children:n,...o})=>{var oe,Q,Z;let r=f(),s=!("data-block"in o),a=useContext(M),{openscad:l,controls:i$1,lineNumbers:c}=a,d=t==null?void 0:t.match(Ql),m=(oe=d==null?void 0:d.at(1))!=null?oe:"",u=or(m),f$1=Ze(),p=Ye(),h=i(),g=rr(m);if(s)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:n});let b=(Q=e==null?void 0:e.properties)==null?void 0:Q.metastring,y=typeof b=="string"?b:void 0,C=y==null?void 0:y.match(Gl),k=C?Number.parseInt(C[1],10):void 0,S=k!==void 0&&k>=1?k:void 0,L=!(y?Xl.test(y):false)&&c!==false,P=(Z=nc(n))!=null?Z:"";if(g){let T=g.component;return jsx(Suspense,{fallback:jsx(ot,{}),children:jsx(T,{code:P,isIncomplete:p,language:m,meta:y})})}if(u){let T=u.name,R=Lt(a,T),F=Te(i$1,T,"download"),W=Te(i$1,T,"copy"),G=Te(i$1,T,"fullscreen"),be=Te(i$1,T,"panZoom"),ke=Ro(i$1,T)&&(F||W||G);return jsx(Suspense,{fallback:jsx(ot,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":p||void 0,"data-streamdown":`${T}-block`,children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:m})}),ke?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":`${T}-block-actions`,children:[F?jsx(Nt,{chart:P,config:R==null?void 0:R.config,language:m,name:T,plugin:u,sourceExtension:u.sourceExtension}):null,W?jsx(nt,{code:P,label:h.copyDiagram,...Ke(i$1,T)}):null,G?jsx(Fo,{chart:P,config:R==null?void 0:R.config,language:m,name:T,plugin:u,sourceExtension:u.sourceExtension}):null]})}):null,jsx("div",{className:r("overflow-hidden rounded-md border border-border bg-background"),children:jsx(Jl,{chart:P,config:R==null?void 0:R.config,fallbackName:T,language:m,plugin:u,showControls:be})})]})})}if(rc(m,f$1)){let T=Mn(i$1,"openscad"),R=Ln(i$1,"download"),F=Ln(i$1,"copy"),W=Ln(i$1,"fullscreen"),G=T&&(R||F||W);return jsx(Suspense,{fallback:jsx(ot,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":p||void 0,"data-streamdown":"openscad-block",children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:m})}),G?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"openscad-block-actions",children:[R?jsx(Ht,{code:P,config:l==null?void 0:l.config}):null,F?jsx(nt,{code:P,label:h.copyModel,...Ke(i$1,"openscad")}):null,W?jsx(dr,{code:P,config:l==null?void 0:l.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(Yl,{code:P,config:l==null?void 0:l.config})})]})})}let A=Mn(i$1,"code"),z=wr(i$1,"download"),j=wr(i$1,"copy"),{"data-block":E,...K}=o;return jsx(cn,{className:t,code:P,isIncomplete:p,language:m,lineNumbers:L,startLine:S,...K,children:A?jsxs(Fragment,{children:[z?jsx(un,{code:P,language:m}):null,j?jsx(nt,{...Ke(i$1,"code")}):null]}):null})},Ur=memo(cc,(e,t)=>_(e,t)&&tc(e.node,t.node));Ur.displayName="MarkdownCode";var Gr=memo(zo,(e,t)=>_(e,t));Gr.displayName="MarkdownImg";var vr={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},Xr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),s=i(),a=o["data-alert-type"],l=a&&a in vr?vr[a]:void 0,i$1=l?s[l]:void 0,c=e;return i$1&&(c=[...(Array.isArray(e)?e:[e]).filter(u=>!(typeof u=="string"&&u.trim().length>0)),i$1]),jsx("p",{className:r("mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",t),...o,children:c})},(e,t)=>_(e,t));Xr.displayName="MarkdownAlertTitle";var Jr=memo(({children:e,className:t,node:n,...o})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(Xr,{className:t,node:n,...o,children:e});let s=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");if(s.length===1&&isValidElement(s[0])){let a=fe(s[0]).node,l=a==null?void 0:a.tagName;if(l==="img")return jsx(Fragment,{children:e});if(l==="code"&&"data-block"in s[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...o,children:e})},(e,t)=>_(e,t));Jr.displayName="MarkdownParagraph";var Yr={ol:Nn,li:Sr,ul:Tr,hr:Er,strong:Rr,a:Ir,h1:Lr,h2:Mr,h3:Nr,h4:Dr,h5:Ar,h6:Or,table:Hr,thead:Br,tbody:_r,tr:Vr,th:Fr,td:$r,blockquote:jr,code:Ur,div:Kr,img:Gr,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:zr,sub:Zr,p:Jr,section:qr};var dc=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,mc=/\p{L}/u;function Ct(e){let t=e.replace(/(```|~~~)[\s\S]*?\1/g,"").replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,""),n,o=0,r=0;for(let s of t){if(dc.test(s)){n!=null||(n="rtl"),r+=1;continue}mc.test(s)&&(n!=null||(n="ltr"),o+=1);}return r>o?"rtl":o>r?"ltr":n!=null?n:"ltr"}var uc=/^[ \t]{0,3}(`{3,}|~{3,})/;var Qr=e=>{let t=e.split(`
21
- `),n=null,o=0;for(let r of t){let s=uc.exec(r);if(n===null){if(s){let a=s[1];n=a[0],o=a.length;}}else if(s){let a=s[1],l=a[0],i=a.length;l===n&&i>=o&&(n=null,o=0);}}return n!==null};var fc=/\[\^[\w-]{1,200}\](?!:)/,gc=/\[\^[\w-]{1,200}\]:/,bc=/<([A-Za-z][\w:-]*)[\s>/]/,hc=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),es=new Map,ts=new Map,rs=e=>{let t=e.toLowerCase(),n=es.get(t);if(n)return n;let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return es.set(t,o),o},yc=e=>{let t=e.toLowerCase(),n=ts.get(t);if(n)return n;let o=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return ts.set(t,o),o},ns=(e,t)=>{if(hc.has(t.toLowerCase()))return 0;let n=e.match(rs(t));if(!n)return 0;let o=0;for(let r of n)r.trimEnd().endsWith("/>")||(o+=1);return o},os=(e,t)=>{let n=e.match(yc(t));return n?n.length:0},Cc=(e,t)=>{let n=e.match(rs(t));return !!n&&n.every(o=>o.trimEnd().endsWith("/>"))},wc=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]==="$"&&e[n+1]==="$"&&(t+=1,n+=1);return t},ss=e=>fc.test(e)||gc.test(e),xc=/\r\n|\r/g,vc=e=>new Lexer({gfm:true}).blockTokens(e),kc=`
22
-
23
- `,Pc=e=>{var t;for(let n=e.length-3;n>=0;n-=1)if((t=e.at(n))!=null&&t.endsWith(kc))return n+1;return 0},Sc=e=>` ${e}`.slice(1),Dn=(e,t)=>({source:e,blocks:t(e),verifiedCount:0,verifiedLength:0}),Tc=(e,t,n)=>{var l,i,c,d;let o=Pc(e.blocks);if(o===0)return null;let r=(l=e.verifiedCount)!=null?l:0,s=(i=e.verifiedLength)!=null?i:0;if(r>o){r=o,s=0;for(let m=0;m<r;m+=1)s+=(d=(c=e.blocks.at(m))==null?void 0:c.length)!=null?d:0;}for(;r<o;){let m=e.blocks.at(r);if(m===void 0||!t.startsWith(m,s))return null;s+=m.length,r+=1;}let a=n(t.slice(s)).map(Sc);return {source:t,blocks:e.blocks.slice(0,o).concat(a),verifiedCount:r,verifiedLength:s}},wt=e=>{if(ss(e))return [e];let t=e.includes("\r")?e.replace(xc,`
24
- `):e,n=vc(t),o=[],r=[],s=false;for(let a of n){let l=a.raw,i=o.length;if(r.length>0){o[i-1]+=l;let c=r.at(-1),d=ns(l,c),m=os(l,c);for(let u=0;u<d;u+=1)r.push(c);for(let u=0;u<m;u+=1)r.length>0&&r.at(-1)===c&&r.pop();continue}if(a.type==="html"&&a.block){let c=l.match(bc);if(c){let d=c[1],m=ns(l,d),u=os(l,d);m>u&&!Cc(l,d)&&r.push(d);}}if(a.type==="space"&&i>0){o[i-1]+=l;continue}if(i>0&&!s){let c=o[i-1];if(wc(c)%2===1){o[i-1]=c+l;continue}}o.push(l),a.type!=="space"&&(s=a.type==="code");}return o},An=(e,t,n=wt)=>{var o;return t!=null&&t.source&&e.startsWith(t.source)?e===t.source?t:n===wt&&ss(e)?Dn(e,n):(o=Tc(t,e,n))!=null?o:Dn(e,n):Dn(e,n)};var Ec=/^ {0,3}(`{3,}|~{3,})/,Rc=/^\n[ \t]*\n/,is=(e,t,n)=>{let o=t;for(;o<n&&e[o]==="`";)o+=1;return o},Ic=(e,t,n,o)=>{let r=t;for(;r<n;){let s=e[r];if(s==="`"){let a=is(e,r,n);if(a-r===o)return r;r=a;continue}if(s===`
25
- `&&Rc.test(e.slice(r,r+64)))return -1;r+=1;}return -1},as=(e,t,n,o)=>{let r=t;for(;r<n;){if(e[r]!=="`"){r+=1;continue}let s=is(e,r,n),a=s-r,l=Ic(e,s,n,a);if(l===-1){r=s;continue}o.push([r,l+a]),r=l+a;}},Lc=e=>{let t=[],n=e.length,o=null,r=0,s=0;for(;s<n;){let a=e.indexOf(`
26
- `,s),l=a===-1?n:a,i=e.slice(s,l),c=Ec.exec(i);if(o){let d=c==null?void 0:c[1];d&&d[0]===o.char&&d.length>=o.length&&i.slice(c[0].length).trim()===""&&(t.push([o.start,l]),o=null,r=l);}else if(c){let d=c[1],m=i.slice(c[0].length);d[0]==="`"&&m.includes("`")||(as(e,r,s,t),o={char:d[0],length:d.length,start:s});}s=l+1;}return o?t.push([o.start,n]):as(e,r,n,t),t},Mc=(e,t)=>{let n=0,o=e.length-1;for(;n<=o;){let r=Math.floor((n+o)/2),[s,a]=e[r];if(t<s)o=r-1;else if(t>=a)n=r+1;else return true}return false},Vt=e=>{let t=null;return n=>(t===null&&(t=Lc(e)),Mc(t,n))},ls=(e,t,n)=>{let o=Vt(e);return e.replace(t,(r,...s)=>{let a=s.findIndex(i=>typeof i=="number"),l=s[a];return o(l)?r:n(r,...s.slice(0,a))})},Ft=(e,t,n)=>{let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),r=new RegExp(`</${t}\\s*>`,"gi"),s=Vt(e),a="",l=0,i=o.exec(e);for(;i;){if(s(i.index)){i=o.exec(e);continue}let c=i.index+i[0].length;r.lastIndex=c;let d=r.exec(e);for(;d&&s(d.index);)d=r.exec(e);if(!d)break;a+=e.slice(l,i.index)+n(i[0],e.slice(c,d.index),d[0]),l=d.index+d[0].length,o.lastIndex=l,i=o.exec(e);}return l===0?e:a+e.slice(l)};var Nc=/^\n*/,Dc=/\n*$/,On=/\n\n/g,Ac=(e,t,n)=>{if(!t.includes(`
27
- `))return e+t+n;let r=t.replace(On,`
28
- <!---->
29
- `).replace(Nc,`
30
-
31
- `).replace(Dc,`
32
-
33
- `);return `${e}${r}${n}
34
-
35
- `},Oc=(e,t)=>{let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),o=new RegExp(`</${t}\\s*>`,"gi"),r=Vt(e),s=c=>{o.lastIndex=c;let d=o.exec(e);for(;d&&r(d.index);)d=o.exec(e);return d!==null},a="",l=0,i=n.exec(e);for(;i;){let c=i[0],d=i.index+c.length;if(r(i.index)){i=n.exec(e);continue}if(s(d)){i=n.exec(e);continue}let m=e.slice(d);if(a+=e.slice(l,i.index),m.length===0){a+=c,l=d,i=n.exec(e);continue}if(m.startsWith(`
36
-
37
- `)){let p=m.slice(2).replace(On,`
38
- <!---->
39
- `);a+=`${c}
40
-
41
- ${p}`,l=e.length;break}if(!m.startsWith(`
42
- `)){a+=c,l=d,i=n.exec(e);continue}let u=m.slice(1);if(u.trim().length===0){a+=c,l=d,i=n.exec(e);continue}let f=u.replace(On,`
43
- <!---->
44
- `);a+=`${c}
45
-
46
- ${f}`,l=e.length;break}return l===0?e:a+e.slice(l)},Hn=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t){let r=new RegExp(`<${o}(?=[\\s>/])((?:"[^"]*"|'[^']*'|[^"'>])*)\\/>`,"gi");n=ls(n,r,(s,a)=>`<${o}${a}></${o}>`);}return n},cs=(e,t)=>{if(!t.length)return e;let n=Hn(e,t);for(let o of t)n=Ft(n,o,Ac),n=Oc(n,o);return n};var Hc=/([\\`*_~[\]|])/g,Bc=e=>e.replace(Hc,"\\$1"),ds=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t)n=Ft(n,o,(r,s,a)=>{let l=Bc(s).replace(/\n\n/g,"&#10;&#10;");return r+l+a});return n};var Vc=new Set(["blockquote","dd","dt","figcaption","h1","h2","h3","h4","h5","h6","li","p","td","th"]),ms=new Set(["code","kbd","pre","samp","var"]);function us(e){return e.children.map(t=>t.type==="text"?t.value:t.type==="element"&&!ms.has(t.tagName)?us(t):"").join("")}function ps(){return e=>{visit(e,"element",t=>{if(ms.has(t.tagName)){(t.properties)!=null||(t.properties={}),t.properties.dir="ltr";return}Vc.has(t.tagName)&&((t.properties)!=null||(t.properties={}),typeof t.properties.dir!="string"&&(t.properties.dir=Ct(us(t))));});}}var fs=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(o=>o.toLowerCase()));visit(t,"element",o=>{var s;if(!n.has(o.tagName.toLowerCase()))return;let r=o.children.filter(a=>a.type==="element").map(a=>{var l;return {tag:a.tagName,props:(l=a.properties)!=null?l:{},text:toText(a).trim()}});o.properties=(s=o.properties)!=null?s:{},o.properties["data-content"]=JSON.stringify(r),o.children=[];});};var gs=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(gs).join(""):"",bs=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(o=>o.toLowerCase()));visit(t,"element",o=>{if(n.has(o.tagName.toLowerCase())){let r=gs(o);o.children=r?[{type:"text",value:r}]:[];}});};var qc=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),Uc=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),Gc=e=>{let t=unified().use(Oi).use(Hi,{allowDangerousHtml:true}),n=t.parse(e);return t.runSync(n).children},hs=(e,t=[])=>n=>{if(!e||e.length===0)return;let o=new Set(e.map(s=>s.toLowerCase())),r=new Set((t!=null?t:[]).map(s=>s.toLowerCase()));visit(n,"element",s=>{let a=s.tagName.toLowerCase();if(!o.has(a)||r.has(a)||!qc(s))return;let l=Uc(s);if(!l.includes(`
47
- `))return;let i=Gc(l);s.children=i;});};var ys=()=>e=>{visit(e,"code",t=>{var n,o;t.meta&&(t.data=(n=t.data)!=null?n:{},t.data.hProperties={...(o=t.data.hProperties)!=null?o:{},metastring:t.meta});});};var Cs=/^>>>[ \t]?(.*)$/,Jc=/^<<<\s*$/,Yc=/^>+\s*$/,Qc=/^<+\s*$/,ed=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,td=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,nd=/^[a-z0-9-]+$/,od=e=>{let t=ed.exec(e);if(!(t!=null&&t.groups))return {};let{iconParen:n,iconBrace:o,title:r,color:s}=t.groups,a=n!=null?n:o;return {icon:a&&nd.test(a)?a:void 0,title:r!==void 0&&r.length>0?r:void 0,color:s&&td.test(s)?s:void 0}},Bn=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),rd=e=>{let t=new TextEncoder().encode(e),n="";for(let o of t)n+=String.fromCharCode(o);return btoa(n)},sd=(e,t)=>{var c;let n=Cs.exec(e[t]),o=(c=n==null?void 0:n[1])!=null?c:"",r=od(o),s=[],a=t+1;for(;a<e.length;a+=1){let d=e[a];if(Jc.test(d)){a+=1;break}if(Yc.test(d)||Qc.test(d)){a+=1;break}s.push(d);}let l=s.join(`
48
- `).trim();return {replacement:`<div ${['class="sdm-callout"',r.title!==void 0?`data-callout-title="${Bn(r.title)}"`:"",r.color!==void 0?`data-callout-color="${Bn(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${Bn(r.icon)}"`:"",`data-callout-body="${rd(l)}"`].filter(Boolean).join(" ")}></div>`,next:a}},ws=e=>{if(!e.includes(">>>"))return e;let t=e.split(`
49
- `),n=[],o=0,r=false;for(;o<t.length;)if(Cs.test(t[o])){let s=sd(t,o);n.push(s.replacement),o=s.next,r=true;}else n.push(t[o]),o+=1;return r?n.join(`
50
- `):e},xs=()=>()=>{};var id=/^([a-zA-Z][a-zA-Z\d+\-.]*:)/,ld=e=>new Set(e.map(t=>t.trim().toLowerCase()).filter(t=>t.length>0).map(t=>t.endsWith(":")?t:`${t}:`));function cd(e,t){if(e.children.length!==1)return false;let[n]=e.children;if(n.type!=="text")return false;let o=id.exec(e.url);if(!o)return false;let r=o[1].toLowerCase();return t.has(r)?r==="mailto:"?e.url===`mailto:${n.value}`:e.url===n.value||e.url===`${r}//${n.value}`:false}var vs=(e=[])=>{let t=ld(e);return n=>{t.size!==0&&visit(n,"link",(o,r,s)=>{if(!(!s||r===void 0)&&cd(o,t))return s.children.splice(r,1,...o.children),r});}};var ud={NOTE:{icon:"info",kind:"note",title:"Note",iconPaths:[{d:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]},TIP:{icon:"light-bulb",kind:"tip",title:"Tip",iconPaths:[{d:"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"}]},IMPORTANT:{icon:"report",kind:"important",title:"Important",iconPaths:[{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}]},WARNING:{icon:"alert",kind:"warning",title:"Warning",iconPaths:[{d:"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",fillRule:"evenodd"}]},CAUTION:{icon:"stop",kind:"caution",title:"Caution",iconPaths:[{d:"M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25a.749.749 0 0 1-.53.22H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]}},pd=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,ks=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let n="";for(let o of t)n+=ks(o);return n},fd=e=>{let t=e.iconPaths.map(n=>`<path d="${n.d}"${n.fillRule?` fill-rule="${n.fillRule}"`:""}></path>`).join("");return {type:"paragraph",children:[{type:"html",value:`<svg class="octicon octicon-${e.icon}" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true">${t}</svg>`},{type:"text",value:e.title}],data:{hName:"p",hProperties:{className:["markdown-alert-title"],"data-alert-type":e.kind}}}},gd=e=>{var m,u;let t=e.children[0];if(!t||t.type!=="paragraph")return;let n=t.children[0];if(!n||n.type!=="text")return;let o=ks(n).trimStart(),r=o.match(pd);if(!r)return;let s=ud[r[1].toUpperCase()],a=o.slice(r[0].length),l=t.children.slice(1);if(a.trim().length===0&&l.length===0&&e.children.length===1)return;let i=[fd(s)],c=[];a.length>0&&c.push({type:"text",value:a});let d=l;return ((m=d[0])==null?void 0:m.type)==="break"&&(d=d.slice(1)),c.push(...d),c.length>0&&c.some(f=>f.type!=="text"||f.value.trim().length>0)&&i.push({type:"paragraph",children:c}),i.push(...e.children.slice(1)),e.data=(u=e.data)!=null?u:{},e.data.hName="div",e.data.hProperties={className:["markdown-alert",`markdown-alert-${s.kind}`]},e.children=i,SKIP},Ps=()=>e=>{visit(e,"blockquote",gd);};var Pd=/^[ \t]*<[\w!/?-]/,Sd=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,Td=e=>typeof e!="string"||e.length===0||!Pd.test(e)?e:e.replace(Sd,"$1"),Rs,Is,Ls,Ms,Ns,Ds,As,Os,Hs,Bs,_s,Vs,Fs,$t={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(Is=(Rs=defaultSchema.protocols)==null?void 0:Rs.href)!=null?Is:[],"tel","streamdown"],src:[...(Ms=(Ls=defaultSchema.protocols)==null?void 0:Ls.src)!=null?Ms:[],"streamdown"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(Ds=(Ns=defaultSchema.attributes)==null?void 0:Ns.div)!=null?Ds:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(Os=(As=defaultSchema.attributes)==null?void 0:As.p)!=null?Os:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(Bs=(Hs=defaultSchema.attributes)==null?void 0:Hs.svg)!=null?Bs:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(Vs=(_s=defaultSchema.attributes)==null?void 0:_s.path)!=null?Vs:[],"d","fillRule"]},tagNames:[...(Fs=defaultSchema.tagNames)!=null?Fs:[],"svg","path"]},_n={raw:Uo,sanitize:[zs,$t],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Ed={gfm:[vd,{}],githubAlerts:Ps,containerAlerts:xs,codeMeta:ys},Ts=Object.values(_n),Rd=Object.values(Ed),Es=new WeakMap;function Id(e){var r;let t=Es.get(e);if(t)return t;let n={...$t,tagNames:[...(r=$t.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...$t.attributes,...e}},o=[_n.raw,[zs,n],_n.harden];return Es.set(e,o),o}var Ld={block:" \u258B",circle:" \u25CF"},Md=["github-light","github-dark"],Nd={enabled:true},Ws=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:o,isIncomplete:r,dir:s,animatePlugin:a,...l})=>{useLayoutEffect(()=>{a==null||a.commit();}),a==null||a.setAnimateCodeBlocks(r);let i=typeof e=="string"&&n?Td(e):e,c=jsx(lt,{...l,children:i});return jsx(on.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:c}):c})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return false;if(e.components!==t.components){let n=Object.keys(e.components||{}),o=Object.keys(t.components||{});if(n.length!==o.length||n.some(r=>{var s,a;return ((s=e.components)==null?void 0:s[r])!==((a=t.components)==null?void 0:a[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins||!!e.animatePlugin!=!!t.animatePlugin)});Ws.displayName="Block";var Dd=memo(({children:e$1,mode:t="streaming",dir:n,parseIncompleteMarkdown:o=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=Ts,remarkPlugins:l=Rd,className:i,shikiTheme:c$1,mermaid:d,openscad:m,plantuml:u,smiles:f,vega:p,diagrams:h$1,codeBlockMaxHeight:g$1=400,controls:b=true,isAnimating:y=false,scrollable:C,tableMaxHeight:k=300,animated:S,BlockComponent:I=Ws,parseMarkdownIntoBlocksFn:L=wt,caret:P,listStyle:A="hierarchical",calloutIcon:z,calloutStyle:j,plugins:E,remend:K,linkSafety:oe=Nd,portal:Q,lineNumbers:Z=true,allowedTags:T,literalTagContent:R,dataOnlyTags:F,disableAutolinkProtocols:W,translations:G,icons:be,prefix:ke,onAnimationStart:ie,onAnimationEnd:re,...ne})=>{let Pe=useId(),ze=useMemo(()=>c(ke),[ke]),N=useRef(null),$=useRef(ie),le=useRef(re);$.current=ie,le.current=re,useEffect(()=>{var D,X,q;if(t==="static")return;let w=N.current;if(N.current=y,w===null){y&&((D=$.current)==null||D.call($));return}y&&!w?(X=$.current)==null||X.call($):!y&&w&&((q=le.current)==null||q.call(le));},[y,t]);let ce=useMemo(()=>T?Object.keys(T):[],[T]),Se=useMemo(()=>{if(!(F!=null&&F.length||R!=null&&R.length))return ce;let w=new Set([...F!=null?F:[],...R!=null?R:[]].map(D=>D.toLowerCase()));return ce.filter(D=>!w.has(D.toLowerCase()))},[ce,F,R]),$n=useRef(null),Wt=useMemo(()=>{if(typeof e$1!="string")return "";let w=e$1;return R&&R.length>0&&(w=ds(w,R)),ce.length>0&&(w=Hn(w,ce)),Se.length>0&&(w=cs(w,Se)),w=ws(w),w},[ce,e$1,Se,R]),de=useMemo(()=>{let w=t==="streaming"?$n.current:null,D=An(Wt,w,L);if($n.current=t==="streaming"?D:null,!(t==="streaming"&&o)||D.blocks.length===0)return D.blocks;let X=D.blocks.length-1,q=D.blocks[X],he=kd(q,K);if(he===q)return D.blocks;let He=D.blocks.slice();return He[X]=he,He},[Wt,L,t,o,K]),We=useMemo(()=>S===true?"true":S?JSON.stringify(S):"",[S]),se=useRef(null),Je=useRef([]),Ne=useRef([]),jn=useRef(null),Kt=useRef("");if(We){if(Kt.current!==We){Kt.current=We;let w=We!=="true"?S.maxBacklogMs:void 0;se.current=en({maxBacklogMs:w}),Je.current=[],Ne.current=[];}else se.current||(se.current=en());y&&se.current&&se.current.beginPass(se.current.now());}else se.current=null,Je.current=[],Ne.current=[],Kt.current="";useLayoutEffect(()=>{var w;y&&((w=se.current)==null||w.commitPass());});let De=useDeferredValue(de),Ae=useMemo(()=>{if(t!=="streaming"||se.current||De===de||De.length===0)return de;let w=De.length,D=de.length;if(D===0)return De;if(w!==D)return de;for(let q=0;q<w-1;q+=1)if(De[q]!==de[q])return de;let X=De.slice();return X[w-1]=de[D-1],X},[de,De,t]),Zt=useMemo(()=>n==="auto"?Ae.map(Ct):void 0,[Ae,n]),[zn]=useState(()=>oo(Pe)),qs=useMemo(()=>zn(Ae),[Ae,zn]),Us=useMemo(()=>G?JSON.stringify(G):"",[G]),Wn=useMemo(()=>({...g,...G}),[Us]),vt=useMemo(()=>{let{inlineCode:w,...D}=s!=null?s:{},X={...Yr,...D};if(w){let q=X.code;X.code=he=>"data-block"in he?q?createElement(q,he):null:createElement(w,he);}return X},[s]),kt=useMemo(()=>{let w=[];return E!=null&&E.cjk&&(w=[...w,...E.cjk.remarkPluginsBefore]),w=[...w,...l],W&&W.length>0&&(w=[...w,[vs,W]]),E!=null&&E.cjk&&(w=[...w,...E.cjk.remarkPluginsAfter]),E!=null&&E.math&&(w=[...w,E.math.remarkPlugin]),w},[l,E==null?void 0:E.math,E==null?void 0:E.cjk,W]),Oe=useMemo(()=>{let w=a;return T&&Object.keys(T).length>0&&a===Ts&&(w=Id(T)),Se.length>0&&(w=[...w,[hs,Se,R!=null?R:[]]]),R&&R.length>0&&(w=[...w,[bs,R]]),F&&F.length>0&&(w=[...w,[fs,F]]),E!=null&&E.math&&(w=[...w,E.math.rehypePlugin]),n==="auto"&&t==="static"&&(w=[...w,ps]),w},[a,E==null?void 0:E.math,T,Se,R,F,n,t]),Kn=useMemo(()=>{var w,D;return {calloutIcon:z,calloutStyle:j,codeBlockMaxHeight:g$1,shikiTheme:(D=c$1!=null?c$1:(w=E==null?void 0:E.code)==null?void 0:w.getThemes())!=null?D:Md,controls:b,isAnimating:y,lineNumbers:Z,listStyle:A,mode:t,mermaid:d,openscad:m,plantuml:u,smiles:f,vega:p,diagrams:h$1,linkSafety:oe,portal:Q,scrollable:C,tableMaxHeight:k,components:vt,remarkPlugins:kt,rehypePlugins:Oe}},[z,j,g$1,c$1,b,y,Z,A,t,d,m,u,f,p,h$1,oe,Q,C,E==null?void 0:E.code,k,vt,kt,Oe]),Gs=useMemo(()=>P&&y?{"--streamdown-caret":`"${Ld[P]}"`}:void 0,[P,y]),Xs=w=>{let D=null;if(se.current&&y){if(!Je.current[w]){let q=We&&We!=="true"?S:{},{maxBacklogMs:he,...He}=q;Je.current[w]=Tt({...He,timeline:se.current});}D=Je.current[w];}jn.current!==Oe&&(Ne.current=[],jn.current=Oe),D&&!Ne.current[w]&&(Ne.current[w]=[...Oe,D.rehypePlugin]);let X=D&&Ne.current[w]?Ne.current[w]:Oe;return {blockAnimatePlugin:D,blockRehypePlugins:X}};return t==="static"?jsx(h.Provider,{value:Wn,children:jsx(At.Provider,{value:E!=null?E:null,children:jsx(M.Provider,{value:Kn,children:jsx(dn,{icons:be,children:jsx(e.Provider,{value:ze,children:jsx("div",{className:ze("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:n==="auto"?void 0:n,children:jsx(lt,{components:vt,rehypePlugins:Oe,remarkPlugins:kt,...ne,children:Wt})})})})})})}):jsx(h.Provider,{value:Wn,children:jsx(At.Provider,{value:E!=null?E:null,children:jsx(M.Provider,{value:Kn,children:jsx(dn,{icons:be,children:jsx(e.Provider,{value:ze,children:jsxs("div",{className:ze("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",P?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),"data-streamdown":"container",style:Gs,children:[Ae.length===0&&P&&y&&jsx("span",{}),Ae.map((w,D)=>{var Zn;let X=D===Ae.length-1,q=y&&X&&Qr(w),{blockAnimatePlugin:he,blockRehypePlugins:He}=Xs(D);return jsx(I,{animatePlugin:he,components:vt,content:w,dir:(Zn=Zt==null?void 0:Zt[D])!=null?Zn:n!=="auto"?n:void 0,index:D,isIncomplete:q,rehypePlugins:He,remarkPlugins:kt,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:o,...ne},qs[D])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.calloutIcon===t.calloutIcon&&e.calloutStyle===t.calloutStyle&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&e.dataOnlyTags===t.dataOnlyTags&&e.disableAutolinkProtocols===t.disableAutolinkProtocols&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Dd.displayName="Streamdown";var xt=e=>e>0?e:null,Hd=(e,t)=>{if(e.endsWith("px"))return xt(Number.parseFloat(e));if(e.endsWith("rem")){let n=Number.parseFloat(getComputedStyle(document.documentElement).fontSize||"16");return xt(Number.parseFloat(e)*n)}if(e.endsWith("em")){let n=Number.parseFloat(getComputedStyle(t).fontSize||"16");return xt(Number.parseFloat(e)*n)}if(e.endsWith("vh"))return xt(Number.parseFloat(e)/100*window.innerHeight);if(e.endsWith("%")){let n=t.parentElement;return n&&n.clientHeight>0?xt(Number.parseFloat(e)/100*n.clientHeight):null}return null},Fn=(e,t)=>{let n=t.trim().toLowerCase();return !n||n==="none"||n==="auto"?null:Hd(n,e)},Bd=/^min\(\s*([^,]+)\s*,\s*([^)]+)\s*\)$/i,_d=(e,t)=>{let n=Fn(e,t);if(n!=null)return n;let o=t.trim().match(Bd);if(!o)return null;let r=Fn(e,o[1].trim()),s=Fn(e,o[2].trim());return r==null||s==null?null:Math.min(r,s)},Vd=(e,t,n)=>{let o=t.clientWidth;if(!(o>0))return null;if(n){let d=t.clientHeight;if(!(d>0))return null;let m=Math.min(o/e.width,d/e.height,1);return !(m>0)||Number.isNaN(m)?null:{fitZoom:m,viewportHeight:null}}let r=Math.min(o/e.width,1);if(!(r>0)||Number.isNaN(r))return null;let s=e.height*r,a=null,l=t;for(;l&&a==null;){let d=getComputedStyle(l);a=_d(l,d.maxHeight),l=l.parentElement;}let i=a!=null?Math.min(s,a):s,c=Math.min(r,i/e.height,1);return !(c>0)||Number.isNaN(c)?null:{fitZoom:c,viewportHeight:i}},Zs=({children:e,className:t,contentSize:n,fitKey:o,minZoom:r=.5,maxZoom:s=3,zoomStep:a=.1,showControls:l=true,initialZoom:i$1=1,isAutoFit:c=false,fullscreen:d=false})=>{let{RotateCcwIcon:m,ZoomInIcon:u,ZoomOutIcon:f$1}=V(),p=f(),h=i(),g=useRef(null),b=useRef(null),y=useRef(false),[C,k]=useState(i$1),[S,I]=useState(r),[L,P]=useState(i$1),[A,z]=useState({x:0,y:0}),[j,E]=useState(false),[K,oe]=useState({x:0,y:0}),[Q,Z]=useState({x:0,y:0}),[T,R]=useState(null),F=useCallback(N=>{let $=g.current;if(!$)return;let le=Vd(N,$,d);if(!le)return;let{fitZoom:ce,viewportHeight:Se}=le;R(Se),k(ce),I(Math.min(r,ce)),y.current||(P(ce),z({x:0,y:0}));},[d,r]),W=useCallback(N=>{P($=>Math.max(S,Math.min(s,$+N))),y.current=true;},[S,s]),G=useCallback(()=>{W(a);},[W,a]),be=useCallback(()=>{W(-a);},[W,a]),ke=useCallback(()=>{P(C),z({x:0,y:0}),y.current=false;},[C]),ie=useCallback(N=>{N.preventDefault();let $=N.deltaY>0?-a:a;W($);},[W,a]),re=useCallback(N=>{if(N.button!==0||N.isPrimary===false)return;E(true),y.current=true,oe({x:N.clientX,y:N.clientY}),Z(A);let $=N.currentTarget;$ instanceof HTMLElement&&$.setPointerCapture(N.pointerId);},[A]),ne=useCallback(N=>{if(!j)return;N.preventDefault();let $=N.clientX-K.x,le=N.clientY-K.y;z({x:Q.x+$,y:Q.y+le});},[j,K,Q]),Pe=useCallback(N=>{E(false);let $=N.currentTarget;$ instanceof HTMLElement&&$.releasePointerCapture(N.pointerId);},[]);useEffect(()=>{I(r),c||(k(i$1),P(i$1),R(null));},[i$1,c,r]),useLayoutEffect(()=>{if(!(c&&n))return;F(n);let N=g.current;if(!N||typeof ResizeObserver=="undefined")return;let $=new ResizeObserver(()=>{F(n);});return $.observe(N),()=>{$.disconnect();}},[F,n,c]),useEffect(()=>{c&&(y.current=false);},[o,c]),useEffect(()=>{let N=g.current;if(N)return N.addEventListener("wheel",ie,{passive:false}),()=>{N.removeEventListener("wheel",ie);}},[ie]),useEffect(()=>{let N=b.current;if(N&&j)return document.body.style.userSelect="none",N.addEventListener("pointermove",ne,{passive:false}),N.addEventListener("pointerup",Pe),N.addEventListener("pointercancel",Pe),()=>{document.body.style.userSelect="",N.removeEventListener("pointermove",ne),N.removeEventListener("pointerup",Pe),N.removeEventListener("pointercancel",Pe);}},[j,ne,Pe]);let ze=!d&&c&&T!=null?{height:T}:void 0;return jsxs("div",{className:p("relative flex flex-col",d?"h-full w-full":"min-h-28 w-full",t),ref:g,style:{cursor:j?"grabbing":"grab",...ze},children:[l?jsxs("div",{className:p("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",d?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{"aria-label":h.zoomIn,className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:L>=s,onClick:G,title:h.zoomIn,type:"button",children:jsx(u,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":h.zoomOut,className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:L<=S,onClick:be,title:h.zoomOut,type:"button",children:jsx(f$1,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":h.resetView,className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:ke,title:h.resetView,type:"button",children:jsx(m,{"aria-hidden":"true",size:16})})]}):null,jsx("div",{className:p("flex h-full w-full flex-1 origin-center items-center justify-center transition-transform duration-150 ease-out"),onPointerDown:re,ref:b,role:"application",style:{transform:`translate(${A.x}px, ${A.y}px) scale(${L})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var Vo=({chart:e,className:t,config:n,fallbackName:o,fullscreen:r=false,language:s,plugin:a,showControls:l=true})=>{var K,oe;let i$1=f(),c=i(),d=(oe=(K=a==null?void 0:a.name)!=null?K:o)!=null?oe:"diagram",[m,u]=useState(null),[f$1,p]=useState(false),[h,g]=useState(""),[b,y]=useState(null),[C,k]=useState(""),[S,I]=useState(0),L=useContext(M),P=Lt(L,d),A=P==null?void 0:P.errorComponent,{shouldRender:z,containerRef:j}=St({immediate:r});if(useEffect(()=>{if(!z)return;if(!a){u(rt(c,d,"missing"));return}(async()=>{try{u(null),p(!0);let{svg:Z}=await a.render(e,Mt(n,s)),T=fn(Z),R=r?Z:Do(Z);g(R),y(T),k(R);}catch(Z){C||h||u(Z instanceof Error?Z.message:rt(c,d,"failed"));}finally{p(false);}})();},[e,n,s,S,z,a]),!(z||h||C))return jsx("div",{className:i$1("my-4 min-h-[200px]",t),ref:j});if(f$1&&!h&&!C)return jsx("div",{className:i$1("my-4 flex justify-center p-4",t),ref:j,children:jsxs("div",{className:i$1("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:i$1("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:i$1("text-sm"),children:c.diagramLoading})]})});if(m&&!h&&!C){let Q=()=>I(Z=>Z+1);return A?jsx("div",{ref:j,children:jsx(A,{chart:e,error:m,retry:Q})}):jsxs("div",{className:i$1("rounded-md bg-red-50 p-4",t),ref:j,children:[jsxs("p",{className:i$1("font-mono text-red-700 text-sm"),children:[rt(c,d,"error"),": ",m]}),jsxs("details",{className:i$1("mt-2"),children:[jsx("summary",{className:i$1("cursor-pointer text-red-600 text-xs"),children:c.showCode}),jsx("pre",{className:i$1("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let E=h||C;return jsx("div",{className:i$1(r?"size-full":"max-h-[min(70vh,40rem)] w-full",t),"data-streamdown":d,ref:j,children:jsx(Zs,{className:i$1(r?"size-full overflow-hidden":"max-h-[min(70vh,40rem)] overflow-hidden",t),contentSize:b,fitKey:e,fullscreen:r,isAutoFit:true,maxZoom:3,minZoom:.1,showControls:l,zoomStep:.1,children:jsx("div",{"aria-label":rt(c,d,"chart"),className:i$1("flex justify-center",r?"size-full items-center":null),dangerouslySetInnerHTML:{__html:E},role:"img"})})})};
51
- export{An as A,Td as B,_n as C,Ed as D,Ws as E,Dd as F,ra as a,Tt as b,Ye as c,Qe as d,lo as e,sn as f,ln as g,hp as h,cn as i,nt as j,un as k,ot as l,Vo as m,M as n,Yo as o,lr as p,qe as q,$e as r,Sn as s,Bt as t,Ue as u,gt as v,Vl as w,bt as x,Ct as y,wt as z};
@@ -1,2 +0,0 @@
1
- "use client";
2
- export{m as Diagram}from'./chunk-TXJ25TS2.js';import'./chunk-6TBP27CO.js';
@@ -1,2 +0,0 @@
1
- "use client";
2
- export{p as OpenScad}from'./chunk-TXJ25TS2.js';import'./chunk-6TBP27CO.js';