@lofcz/streamdown 2.16.0 → 2.16.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.
- package/dist/{block-NMJXQ35A.js → block-7TI5JYN4.js} +1 -1
- package/dist/chunk-XGSGO2TP.js +51 -0
- package/dist/{highlighted-body-FUSBPRQ5.js → highlighted-body-CQKXWK4Z.js} +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.js +1 -1
- package/dist/lib/animate.d.ts +24 -8
- package/dist/lib/use-animation-drain.d.ts +4 -0
- package/dist/lib/use-smooth-stream.d.ts +45 -0
- package/dist/openscad-M2KFPRPJ.js +2 -0
- package/package.json +2 -2
- package/dist/chunk-MFO3W3BR.js +0 -51
- package/dist/openscad-PAJE3A4O.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {r,k,m,j,l,p,q as q$1,s,c,u}from'./chunk-MFO3W3BR.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})})]})};
|
|
2
|
+
import {r,k,m,j,l,p,q as q$1,s,c,u}from'./chunk-XGSGO2TP.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
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 wo from'rehype-raw';import Ss,{defaultSchema}from'rehype-sanitize';import Qc from'remark-gfm';import ed from'remend';import {visitParents,SKIP}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 Ya from'remark-parse';import Qa from'remark-rehype';import {unified}from'unified';import {visit,SKIP as SKIP$1}from'unist-util-visit';import {toText}from'hast-util-to-text';import {Lexer}from'marked';var Os=300,Hs="300px",Bs=500;function Nn(e={}){let{immediate:t=false,debounceDelay:n=Os,rootMargin:o=Hs,idleTimeout:r=Bs}=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);},b=y=>{c.current=m(v=>{v.timeRemaining()>0||v.didTimeout?(a(true),y.disconnect()):c.current=m(()=>{a(true),y.disconnect();},{timeout:r/2});},{timeout:r});},g=y=>{p(),i.current=window.setTimeout(()=>{var R,_;let v=y.takeRecords();(v.length===0||(_=(R=v.at(-1))==null?void 0:R.isIntersecting)!=null&&_)&&b(y);},n);},h=(y,v)=>{y.isIntersecting?g(v):p();},x=new IntersectionObserver(y=>{for(let v of y)h(v,x);},{rootMargin:o,threshold:0});return x.observe(f),()=>{i.current&&clearTimeout(i.current),c.current&&u(c.current),x.disconnect();}},[t,n,o,r,u,m]),{shouldRender:s,containerRef:l}}var _s=320,Vs=4,Hn=()=>typeof performance=="undefined"?Date.now():performance.now();function zt(e){var a,l;let t=(a=e==null?void 0:e.now)!=null?a:Hn,n=(l=e==null?void 0:e.maxBacklogMs)!=null?l:_s,o=0,r=0,s=t();return {now:t,passNow:()=>s,beginPass(i){s=i,r=Math.min(Math.max(o,i),i+n);},mark(){return r},rewind(i){r=i;},take(i,c,d){if(i<=0)return {baseDelay:0,step:Math.max(0,c)};let m=Math.max(0,c),u=m===0?0:Math.min(m,Vs),f=Math.max(r,d),p=d+n,b=f+Math.max(0,i-1)*m,g=m;if(b>p&&i>1)if(f<p){let x=p-f;g=Math.max(u,x/(i-1));}else g=u;let h=Math.max(0,Math.round(f-d));return r=f+i*g,{baseDelay:h,step:g}},commitPass(){o=r;}}}function js(){return {current:0}}var Bn=/\s/,ht=/^\s+$/,$s=new Set(["pre","svg","math","annotation","table"]),Fs=new Set(["img","hr","pre"]),$e=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",Wt=e=>e.some(t=>$e(t)&&$s.has(t.tagName)),zs=e=>{for(let t=e.length-1;t>=0;t-=1){let n=e.at(t);if($e(n)&&n.tagName==="li")return n}},Ws=(e,t,n,o)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate-marker"]=true;let r=typeof e.properties.style=="string"?`${e.properties.style};`:"";e.properties.style=`${r}--sd-marker-duration:${t}ms;--sd-marker-delay:${Math.round(n)}ms;--sd-marker-easing:${o}`;},qs=new Set(["ul","ol","li"]),_n=e=>{for(let t of e.children)if($e(t)){if(t.tagName==="input")return t;if(qs.has(t.tagName))continue;let n=_n(t);if(n)return n}},Vn=(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:${Math.round(o)}ms`;},Us=(e,t,n,o)=>{let r=_n(e);r&&Vn(r,t,n,o);},Ks=(e,t,n,o,r,s)=>{if(Wt(t))return;let a=r.count;r.count+=1;let l=Fn(a,n,o,r,s);Vn(e,n,l.duration,l.delay);},Zs=e=>{var t;for(let n=e.length-1;n>=0;n-=1){let o=e[n];if($e(o)){if((t=o.properties)!=null&&t["data-sd-animated"])break;o.properties={...o.properties,"data-sd-animated":true};}}},jn=e=>{let t=[],n="",o=false;for(let r of e){let s=Bn.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},$n=e=>{let t=[],n="";for(let o of e)Bn.test(o)?t.length>0&&!ht.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},Xs=(e,t,n,o,r,s)=>{let a=`--sd-animation:sd-${t};--sd-duration:${n}ms;--sd-easing:${o}`;r&&(a+=`;--sd-delay:${Math.round(r)}ms`);let l={"data-sd-animate":true,style:a};for(let[i,c]of Object.entries(s!=null?s:{}))i.startsWith("data-")&&(l[i]=c);return {type:"element",tagName:"span",properties:l,children:[{type:"text",value:e}]}},Gs=(e,t)=>{let n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},$t=(e,t)=>!(e>0&&t<e),Fn=(e,t,n,o,r)=>{let s=n.committedAnimations.get(e);if($t(n.prevContentLength,e)){let a=t.scatter>0?t.scatter*Gs(t.seed,e):0,l=Math.round(r.baseDelay+o.newIndex++*r.step+a);s={delay:l,endsAt:n.now+l+t.duration};}return !s||s.endsAt<=n.now?{duration:0,delay:0}:(n.pendingAnimations.set(e,s),{duration:t.duration,delay:s.delay})},zn=e=>!e.position&&ht.test(e.value),Ft=e=>$e(e)&&Fs.has(e.tagName),Js=(e,t,n)=>{let o=0,r=0;return visitParents(e,s=>s.type==="text"||Ft(s),(s,a)=>{if(Wt(a))return SKIP;if(Ft(s)){$t(n,r)&&(o+=1),r+=1;return}if(zn(s))return;let l=s.value;if(!l.trim()){r+=l.length;return}let i=t.sep==="char"?$n(l):jn(l);for(let c of i){let d=r;r+=c.length,!ht.test(c)&&$t(n,d)&&(o+=1);}}),o},Ys=(e,t,n,o,r,s)=>{var g;let a=t.at(-1);if(!(a&&"children"in a))return;if(Wt(t))return SKIP;let l=a,i=l.children.indexOf(e);if(i===-1||zn(e))return;let c=e.value;if(!c.trim()){r.count+=c.length;return}let d=n.sep==="char"?$n(c):jn(c),m=false,u=zs(t),f=!!(u&&!((g=u.properties)!=null&&g["data-sd-animate-marker"])),p=false,b=d.map(h=>{let x=r.count;if(r.count+=h.length,ht.test(h))return {type:"text",value:h};let y=Fn(x,n,o,r,s);return m=true,u&&f&&!p&&(Ws(u,y.duration,y.delay,n.easing),Us(u,n,y.duration,y.delay),p=true),Xs(h,n.animation,y.duration,n.easing,y.delay,n.decorate&&y.duration>0?n.decorate(h.trimEnd(),n.seed*100003+x):void 0)});return m&&Zs(t),l.children.splice(i,1,...b),i+b.length},Qs=0;function bt(e){var l,i,c,d,m,u,f;let t=Qs++,n=(l=e==null?void 0:e.animation)!=null?l:"fadeIn",o=typeof n=="string"?void 0:n,r={animation:typeof n=="string"?n:n.name,decorate:o==null?void 0:o.decorate,duration:(c=(i=e==null?void 0:e.duration)!=null?i:o==null?void 0:o.duration)!=null?c:150,easing:(d=e==null?void 0:e.easing)!=null?d:"ease",scatter:(m=o==null?void 0:o.scatter)!=null?m:0,seed:t,sep:(u=e==null?void 0:e.sep)!=null?u:"word",stagger:(f=e==null?void 0:e.stagger)!=null?f:40,timeline:e==null?void 0:e.timeline},s={committedAnimations:new Map,committedCharCount:0,prevContentLength:0,lastRenderCharCount:0,pendingMark:null,now:0,pendingAnimations:new Map},a=()=>p=>{var y;let b={count:0,newIndex:0};s.prevContentLength=s.committedCharCount,s.pendingAnimations=new Map;let g=r.timeline,h=(y=g==null?void 0:g.passNow())!=null?y:Hn();s.now=h,g&&(s.pendingMark===null?s.pendingMark=g.mark():g.rewind(s.pendingMark));let x=g?g.take(Js(p,r,s.prevContentLength),r.stagger,h):{baseDelay:0,step:r.stagger};visitParents(p,v=>v.type==="text"||Ft(v),(v,S)=>{if(v.type==="text")return Ys(v,S,r,s,b,x);Ks(v,S,r,s,b,x);}),s.lastRenderCharCount=b.count,s.prevContentLength=0;};return Object.defineProperty(a,"name",{value:`rehypeAnimate$${t}`}),{name:"animate",type:"animate",rehypePlugin:a,setPrevContentLength(p){s.committedCharCount=p,s.prevContentLength=p,s.committedAnimations.clear();},getLastRenderCharCount(){return s.lastRenderCharCount},commit(){s.committedCharCount=s.lastRenderCharCount,s.committedAnimations=s.pendingAnimations,s.pendingMark=null;}}}bt();var qt=createContext(false),Fe=()=>useContext(qt);function Wn(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 ze=({scrollRef:e,ref:t,...n})=>jsx("div",{ref:e,...n});var sa=8,aa=e=>e.scrollHeight-e.scrollTop-e.clientHeight<sa,Zn=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},yt=({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=Zn(g);},f=g=>{if(m===null)return;let h=Zn(g);if(h===null)return;let x=h-m;Math.abs(x)<=3||(x>0&&c(),m=h);},p=()=>{m=null;},b=()=>{let g=o.scrollTop<a.current;if(a.current=o.scrollTop,g){c();return}aa(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",b,{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",b);}},[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 ca=a("block"),da=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"),ma=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},Xn=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:ze,u=b(r),f$1=yt({content:t,enabled:!!u,isAnimating:c}),p=useMemo(()=>i(da),[i]),b$1=useMemo(()=>i(ca),[i]),g=useMemo(()=>{let h={};return t.bg&&(h["--sdm-bg"]=t.bg),t.fg&&(h["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(h,ma(t.rootStyle)),h},[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((h,x)=>jsx("span",{className:a?p:b$1,children:h.length===0||h.length===1&&h[0].content===""?`
|
|
3
|
+
`:h.map((y,v)=>{let S={},R=!!y.bgColor;if(y.color&&(S["--sdm-c"]=y.color),y.bgColor&&(S["--sdm-tbg"]=y.bgColor),y.htmlStyle)for(let[_,I]of Object.entries(y.htmlStyle))_==="color"?S["--sdm-c"]=I:_==="background-color"?(S["--sdm-tbg"]=I,R=true):S[_]=I;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",R&&"bg-[var(--sdm-tbg)]",R&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:S,...y.htmlAttrs,children:y.content},v)})},x))})})})});var Kt=({className:e,language:t,style:n,isIncomplete:o,...r})=>{let s=f();return jsx("div",{className:s("relative 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 Zt=createContext({code:""}),Ct=()=>useContext(Zt);var Xt=({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 ya=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
|
+
`;)t--;return e.slice(0,t)},Ca=lazy(()=>import('./highlighted-body-CQKXWK4Z.js').then(e=>({default:e.HighlightedCodeBlockBody}))),Gt=({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(()=>ya(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(Zt.Provider,{value:{code:e},children:jsxs(Kt,{dir:"ltr",isIncomplete:r,language:t,children:[jsx(Xt,{language:t}),o?jsx("div",{className:i("pointer-events-none absolute top-2 right-2 z-10 flex items-center"),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(Xn,{className:n,language:t,lineNumbers:a,maxHeight:c,result:m,startLine:s,...l}),children:jsx(Ca,{className:n,code:d,language:t,lineNumbers:a,maxHeight:c,raw:m,startLine:s,...l})})]})})};var 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:"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"})}),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:"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"})}),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:"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"})}),to=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"})]}),no=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"})}),oo=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"})}),ro=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"})}),so=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"})}),ao=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"})}),io=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 qe={CheckIcon:Yn,CopyIcon:Qn,DownloadIcon:eo,ExternalLinkIcon:so,Loader2Icon:to,Maximize2Icon:no,RotateCcwIcon:oo,XIcon:ro,ZoomInIcon:ao,ZoomOutIcon:io},co=createContext(qe),Pa=(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])},Jt=({icons:e,children:t})=>{let n=useRef(e),o=useRef(e?{...qe,...e}:qe);Pa(n.current,e)||(n.current=e,o.current=e?{...qe,...e}:qe);let r=o.current;return jsx(co.Provider,{value:r,children:t})},B=()=>useContext(co);var xt=({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}=Ct(),{isAnimating:f$1}=useContext(T),p=i(),b=s!=null?s:u,g=a!=null?a:p.copyCode,h=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(b),d(!0),e==null||e(),m.current=window.setTimeout(()=>d(!1),n));}catch(S){t==null||t(S);}};useEffect(()=>()=>{window.clearTimeout(m.current);},[]);let x=B(),y=c?x.CheckIcon:x.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:h,title:g,type:"button",...l,children:o!=null?o:jsx(y,{"aria-hidden":"true",size:14})}),c&&jsx("output",{"aria-live":"polite",className:"sr-only",children:p.copied})]})};var wt=e=>typeof e=="object"&&e!==null,mo=(e,t)=>{var n;if(typeof e!="boolean")return t!=="diagrams"&&t in e?e[t]:(n=e.diagrams)==null?void 0:n[t]},Te=(e,t,n)=>{if(typeof e=="boolean")return n;let o=mo(e,t);if(!wt(o))return n;let r=o.download;return !wt(r)||typeof r.filename!="string"?n:r.filename||n};function Ue(e,t){if(typeof e=="boolean")return {};let n=mo(e,t);if(!wt(n))return {};let o=n.copy;return wt(o)?{onCopy:typeof o.onCopy=="function"?o.onCopy:void 0,onError:typeof o.onError=="function"?o.onError:void 0}:{}}var uo={"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"},Qt=({onDownload:e,onError:t,language:n,children:o,className:r,code:s,...a})=>{let l=f(),{code:i$1}=Ct(),{isAnimating:c,controls:d$1}=useContext(T),m=i(),u=B(),f$1=s!=null?s:i$1,p=n&&n in uo?uo[n]:"txt",b=`${Te(d$1,"code","file")}.${p}`,g="text/plain",h=()=>{try{d(b,f$1,g),e==null||e();}catch(x){t==null||t(x);}};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:h,title:m.downloadFile,type:"button",...a,children:o!=null?o:jsx(u.DownloadIcon,{size:14})})};var Ke=()=>{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 Ze=0,fe=()=>{Ze+=1,Ze===1&&(document.body.style.overflow="hidden");},ge=()=>{Ze=Math.max(0,Ze-1),Ze===0&&(document.body.style.overflow="");};var Oa=["github-light","github-dark"],Ha={enabled:true},Ba={codeBlockMaxHeight:400,shikiTheme:Oa,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:Ha,portal:void 0,tableMaxHeight:300},T=createContext(Ba);var $a=/\.[^/.]+$/,go=(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},ho=({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,f$1]=useState(false),[p,b]=useState(false),[g,h]=useState(false),{controls:x}=useContext(T),y=i(),v=go(x,"download"),S=go(x,"fullscreen"),R=l.width!=null||l.height!=null,_=v&&(u||R)&&!p,I=p&&!R,O=S&&!!n&&!p&&u;useEffect(()=>{let M=m.current;if(M!=null&&M.complete){let V=M.naturalWidth>0;f$1(V),b(!V);}},[]),useEffect(()=>{if(!g)return;fe();let M=V=>{V.key==="Escape"&&h(false);};return document.addEventListener("keydown",M),()=>{document.removeEventListener("keydown",M),ge();}},[g]);let ee=useCallback(M=>{f$1(true),b(false),r==null||r(M);},[r]),te=useCallback(M=>{f$1(false),b(true),s==null||s(M);},[s]),Q=useCallback(()=>{O&&h(true);},[O]),P=useCallback(()=>{h(false);},[]),be=useCallback(M=>{a==null||a(M),!M.defaultPrevented&&Q();},[a,Q]),ye=async M=>{if(M.stopPropagation(),!!n)try{let G=await(await fetch(n)).blob(),$=new URL(n,window.location.origin).pathname.split("/").pop()||"",Ce=$.split(".").pop(),Le=$.includes(".")&&Ce!==void 0&&Ce.length<=4,Ae="";if(Le)Ae=$;else {let le=G.type,ce="png";le.includes("jpeg")||le.includes("jpg")?ce="jpg":le.includes("png")?ce="png":le.includes("svg")?ce="svg":le.includes("gif")?ce="gif":le.includes("webp")&&(ce="webp"),Ae=`${(o||$||"image").replace($a,"")}.${ce}`;}d(Ae,G,G.type);}catch(V){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",O&&"cursor-zoom-in",I&&"hidden",t),"data-streamdown":"image",onClick:be,onError:te,onLoad:ee,ref:m,src:n,...l}),I&&jsx("span",{className:d$1("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:y.imageNotAvailable}),_&&jsx("button",{"aria-label":y.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:ye,title:y.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:P,onKeyDown:M=>{M.key==="Escape"&&P();},role:"button",tabIndex:0,children:[jsx("button",{"aria-label":y.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:P,title:y.exitFullscreen,type:"button",children:jsx(c,{size:20})}),jsx("div",{onClick:M=>M.stopPropagation(),onKeyDown:M=>M.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 Oe=e=>{let t=typeof e=="function"?e():e;return t!=null?t:document.body};var Co=({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),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){fe();let g=h=>{h.key==="Escape"&&n();};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),ge();}}},[t,n]),!t||typeof document=="undefined")return null;let b=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(b,Oe(u))};var xo=()=>e=>{visit(e,"html",(n,o,r)=>{!r||typeof o!="number"||(r.children[o]={type:"text",value:n.value});});};var ko=[],vo={allowDangerousHtml:true},kt=new WeakMap,rn=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[b,g]=p;if(typeof b=="function"){let h=kt.get(b);h||(h=b.name,kt.set(b,h)),u+=h;}else u+=String(b);u+=":",u+=JSON.stringify(g);}else if(typeof p=="function"){let b=kt.get(p);b||(b=p.name,kt.set(p,b)),u+=b;}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();}},Po=new rn,Ge=e=>{let t=ni(e),n=e.children||"",o=t.runSync(t.parse(n),n);return li(o,e)},ni=e=>{let t=Po.get(e);if(t)return t;let n=ri(e);return Po.set(e,n),n},oi=e=>e.some(t=>Array.isArray(t)?t[0]===wo:t===wo),ri=e=>{let t=e.rehypePlugins||ko,n=e.remarkPlugins||ko,o=oi(t)?n:[...n,xo],r=e.remarkRehypeOptions?{...vo,...e.remarkRehypeOptions}:vo;return unified().use(Ya).use(o).use(Qa,r).use(t)},So=e=>e,si=(e,t,n,o)=>{n?e.children.splice(t,1):e.children[t]={type:"text",value:o};},ai=(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);}},ii=(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},li=(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||So;visit(e,(d,m,u)=>{if(d.type==="raw"&&u&&typeof m=="number")return si(u,m,s,d.value),m;if(d.type==="element"&&(ai(d,c),ii(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 To=/[(){}[\]]/,ci=/[\s;]/,di=/^[\w-]+$/,mi=/:::[\w-]+\s*$/,ui=/^[/\\]/,pi=/[/\\]$/,fi=/("[^"]*")/,gi=[["((","))"],["))","(("],["{{","}}"],["[","]"],["(",")"],[")","("]],Je=e=>`"${e.replace(/"/g,"#quot;")}"`,hi=e=>e.length>=2&&e.startsWith('"')&&e.endsWith('"'),bi=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(ci,1)[0];return i==="mindmap"?"mindmap":i==="flowchart"||i==="graph"?"flowchart":null}n+=1;}return null},yi=e=>{for(let[t,n]of gi){let o=e.indexOf(t);if(o===-1||!e.endsWith(n))continue;let r=e.slice(0,o);if(r&&!di.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},Ci=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=yi(o);if(r)return !hi(r.inner)&&(To.test(r.inner)||r.inner.includes('"'))?`${n}${r.id}${r.open}${Je(r.inner)}${r.close}`:e;if(To.test(o)){let s=o.replace(mi,"").trimEnd();return `${n}[${Je(s)}]`}return e},xi=e=>{let t=e.split(`
|
|
7
|
+
`),n=false;return t.map(o=>n?Ci(o):(o.trim()&&(n=true),o)).join(`
|
|
8
|
+
`)},wi=e=>e.startsWith("(")&&e.endsWith(")")||ui.test(e)||pi.test(e),sn=(e,t)=>e.split(fi).map((n,o)=>o%2===0?t(n):n).join(""),ki=e=>{if(e.trim().startsWith("%%"))return e;let t=sn(e,n=>n.replace(/\[([^[\]"]*[(){}][^[\]"]*)\]/g,(o,r)=>wi(r)?o:`[${Je(r)}]`));return t=sn(t,n=>n.replace(/\{([^{}"]*[()[\]][^{}"]*)\}/g,(o,r)=>`{${Je(r)}}`)),t=sn(t,n=>n.replace(/\|([^|"]*[(){}[\]][^|"]*)\|/g,(o,r)=>`|${Je(r)}|`)),t},vi=e=>e.split(`
|
|
9
|
+
`).map(ki).join(`
|
|
10
|
+
`),Eo=e=>{let t=bi(e);if(!t)return null;let n=t==="mindmap"?xi(e):vi(e);return n===e?null:n};var Pi=()=>{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,Ti=e=>"getMermaid"in e&&typeof e.getMermaid=="function",Ei=e=>"getPlantUml"in e&&typeof e.getPlantUml=="function",Ri=e=>"getVega"in e&&typeof e.getVega=="function",Ii=e=>"getSmiles"in e&&typeof e.getSmiles=="function";var Mi=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)}`},Li=async(e,t,n)=>{try{return await e.render(t,n)}catch(o){let r=Eo(n);if(!r)throw o;try{return await e.render(`${t}-autofix`,r)}catch(s){throw o}}},Ai=e=>{var t,n;return Ti(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:"mmd",render:async(o,r)=>{let s=e.getMermaid(r);return await Li(s,Mi(o),o)}}:Ei(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:Pi();return await e.getPlantUml(s).render(o,{...s,dark:a})}}:Ri(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)}:Ii(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},Ro=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(Ai)},Io=(e,t)=>{var n;return (n=e.find(o=>Si(t,o.language)))!=null?n:null};var vt=createContext(null),Pt=()=>useContext(vt),yu=()=>{var t;let e=Pt();return (t=e==null?void 0:e.code)!=null?t:null};var Hi=()=>{let e=Pt();return useMemo(()=>Ro(e),[e])},Mo=e=>{let t=Hi();return Io(t,e)},He=()=>{var t;let e=Pt();return (t=e==null?void 0:e.openscad)!=null?t:null};var Lo=e=>{var n;let t=Pt();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 No={"3mf":"model/3mf",stl:"model/stl"},St=({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(T),p=B(),b=He(),g=i(),h=Te(u,"openscad","model"),x=async y=>{try{if(y==="scad"){d(`${h}.scad`,n,"text/plain"),i$1(!1),r==null||r(y);return}if(!b){s==null||s(new Error("OpenSCAD plugin not available"));return}d$1(!0);let v=b.getOpenScad(o),{data:S}=await v.render(n,{...o,format:y}),R=S.buffer.slice(S.byteOffset,S.byteOffset+S.byteLength);d(`${h}.${y}`,new Blob([R],{type:No[y]}),No[y]),r==null||r(y),i$1(!1);}catch(v){s==null||s(v);}finally{d$1(false);}};return useEffect(()=>{let y=v=>{let S=v.composedPath();m.current&&!S.includes(m.current)&&i$1(false);};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y);}},[]),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:()=>x("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:()=>x("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:()=>x("3mf"),title:g.downloadModelAs3mf,type:"button",children:g.openscadFormat3mf})]}):null]})};var Bo=({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:f$1}=useContext(T),p=i(),b=(()=>{if(typeof u=="boolean")return u;let h=u.openscad;return h===false?false:h===true||h===void 0?true:h.download!==false})(),g=()=>{d(!c);};return useEffect(()=>{if(c){fe();let h=x=>{x.key==="Escape"&&d(false);};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h),ge();}}},[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:h=>{h.key==="Escape"&&g();},role:"dialog",children:[jsxs("div",{className:i$1("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:[b?jsx(St,{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:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:jsx(Ho,{className:i$1("size-full"),code:e,config:t,fullscreen:true})})]}),Oe(f$1)):null]})};var ln=e=>e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(ln).join(""):isValidElement(e)?ln(e.props.children):"",_o=(e,t,n)=>n!=null?n:(t?toText(t):ln(e)).replace(/\s+/g," ").trim()||void 0;function cn(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(cn).join("")}var Be=e=>{let t=[],n=[],o=e.querySelectorAll("thead th");for(let s of o)t.push(cn(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(cn(i).trim());n.push(a);}return {headers:t,rows:n}},Qe=e=>{var n;if(typeof e!="object")return ",";let t=e.table;return typeof t!="object"?",":(n=t.csvSeparator)!=null?n:","},Ie=(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
|
+
`)},dn=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
|
+
`)},Tt=e=>{let t=false;for(let o of e)if(o==="\\"||o==="|"||o===`
|
|
17
|
+
`||o==="&"||o==="<"||o===">"){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>"):o==="&"?n.push("&"):o==="<"?n.push("<"):o===">"?n.push(">"):n.push(o);return n.join("")},_e=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=>Tt(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?Tt(l[c]):"";o[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(c=>Tt(c));o[r]=`| ${i.join(" | ")} |`,r+=1;}return o.join(`
|
|
19
|
+
`)};var tt=({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(T),p=i(),b=Qe(f$1),g=Ue(f$1,"table"),h=n!=null?n:g.onCopy,x=o!=null?o:g.onError,y=async R=>{var _,I;if(typeof window=="undefined"||!((_=navigator==null?void 0:navigator.clipboard)!=null&&_.write)){x==null||x(new Error("Clipboard API not available"));return}try{let O=(I=d.current)==null?void 0:I.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),ee=O==null?void 0:O.querySelector("table");if(!ee){x==null||x(new Error("Table not found"));return}let te=Be(ee),Q="";R==="csv"?Q=Ie(te,b):R==="tsv"?Q=dn(te):Q=_e(te);let P=new ClipboardItem({"text/plain":new Blob([Q],{type:"text/plain"}),"text/html":new Blob([ee.outerHTML],{type:"text/html"})});await navigator.clipboard.write([P]),c(!0),l(!1),h==null||h(R),m.current=window.setTimeout(()=>c(!1),r);}catch(O){x==null||x(O);}};useEffect(()=>{let R=_=>{let I=_.composedPath();d.current&&!I.includes(d.current)&&l(false);};return document.addEventListener("mousedown",R),()=>{document.removeEventListener("mousedown",R),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:()=>y("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:()=>y("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:()=>y("tsv"),title:p.copyTableAsTsv,type:"button",children:p.tableFormatTsv})]}):null]})};var Ji=({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=Qe(i$1),u=f=>{try{let b=f.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),g=b==null?void 0:b.querySelector("table");if(!g){o==null||o(new Error("Table not found"));return}let h=Be(g),x="",y="",v="";switch(r){case "csv":x=Ie(h,m),y="text/csv",v="csv";break;case "markdown":x=_e(h),y="text/markdown",v="md";break;default:x=Ie(h,m),y="text/csv",v="csv";}d(`${s||Te(i$1,"table","table")}.${v}`,x,y),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})})},nt=({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=Qe(c),f$1=p=>{var b;try{let g=(b=l.current)==null?void 0:b.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),h=g==null?void 0:g.querySelector("table");if(!h){o==null||o(new Error("Table not found"));return}let x=Be(h),y=p==="csv"?Ie(x,u):_e(x),v=p==="csv"?"csv":"md",S=`${Te(c,"table","table")}.${v}`;d(S,y,p==="csv"?"text/csv":"text/markdown"),a(!1),n==null||n(p);}catch(g){o==null||o(g);}};return useEffect(()=>{let p=b=>{let g=b.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 Wo=({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);},f$1=()=>{i$1(false);};return useEffect(()=>{if(l){fe();let p=b=>{b.key==="Escape"&&i$1(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),ge();}}},[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(tt,{}):null,o?jsx(nt,{}):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})})]})}),Oe(d)):null]})};var Uo=({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:ze,u=b(n),f$1=yt({content:e,enabled:!!u,isAnimating:c}),p=o&&r,b$1=o&&s,g=o&&a,h=p||b$1||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:[h?jsxs("div",{className:i("flex items-center justify-end gap-1"),children:[p?jsx(tt,{}):null,b$1?jsx(nt,{}):null,g?jsx(Wo,{showCopy:p,showDownload:b$1,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 il=/startLine=(\d+)/,ll=/\bnoLineNumbers\b/,cl=lazy(()=>import('./block-7TI5JYN4.js').then(e=>({default:e.DiagramCodeBlock}))),dl=lazy(()=>import('./openscad-M2KFPRPJ.js').then(e=>({default:e.OpenScad}))),ml=/language-([^\s]+)/,ae=e=>e.props,ul="node";function N(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!==ul&&!Object.is(o[s],r[s]))return false;return true}function pl(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 fl(e){if(typeof e=="string")return e;if(isValidElement(e)){let t=ae(e).children;if(typeof t=="string")return t}}var gl=(e,t)=>Array.isArray(t)?t.includes(e):t===e,hl=(e,t)=>!!(t&&gl(e,t.language)),hn=(e,t)=>typeof e=="boolean"?e:e[t]!==false,fn=(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},Ko=(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},gn=(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},rt=createContext({depth:0,ulDepth:0,isUnordered:false}),bl={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},bn=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{depth:s,ulDepth:a}=useContext(rt),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(rt.Provider,{value:l,children:e})})},(e,t)=>N(e,t));bn.displayName="MarkdownOl";var Yo=memo(({children:e,className:t,node:n,...o})=>{var b;let r=f(),{depth:s,ulDepth:a,isUnordered:l}=useContext(rt),{listStyle:i}=useContext(T),c=bl[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)?(b=ae(u).node)==null?void 0:b.tagName:void 0,p=m.length===1&&isValidElement(u)&&(u.type==="p"||f$1==="p")?ae(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)=>N(e,t));Yo.displayName="MarkdownLi";var Qo=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{depth:s,ulDepth:a}=useContext(rt),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(rt.Provider,{value:l,children:e})})},(e,t)=>N(e,t));Qo.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)=>N(e,t));er.displayName="MarkdownHr";var tr=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)=>N(e,t));tr.displayName="MarkdownStrong";var yl=({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);},[]),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(Co,{...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})},nr=memo(yl,(e,t)=>N(e,t));nr.displayName="MarkdownA";var or=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)=>N(e,t));or.displayName="MarkdownH1";var rr=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)=>N(e,t));rr.displayName="MarkdownH2";var sr=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)=>N(e,t));sr.displayName="MarkdownH3";var ar=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)=>N(e,t));ar.displayName="MarkdownH4";var ir=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)=>N(e,t));ir.displayName="MarkdownH5";var lr=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)=>N(e,t));lr.displayName="MarkdownH6";var cr=memo(({children:e,className:t,node:n,...o})=>{let{controls:r,tableMaxHeight:s}=useContext(T),a=hn(r,"table"),l=fn(r,"copy"),i=fn(r,"download"),c=fn(r,"fullscreen");return jsx(Uo,{className:t,maxHeight:s,showControls:a,showCopy:l,showDownload:i,showFullscreen:c,...o,children:e})},(e,t)=>N(e,t));cr.displayName="MarkdownTable";var dr=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)=>N(e,t));dr.displayName="MarkdownThead";var mr=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)=>N(e,t));mr.displayName="MarkdownTbody";var ur=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)=>N(e,t));ur.displayName="MarkdownTr";var pr=memo(({children:e,className:t,node:n,title:o,...r})=>{let s=f(),a=_o(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)=>N(e,t));pr.displayName="MarkdownTh";var fr=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)=>N(e,t));fr.displayName="MarkdownTd";var gr=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)=>N(e,t));gr.displayName="MarkdownBlockquote";var hr=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)=>N(e,t));hr.displayName="MarkdownSup";var Cl=()=>({}),xl=e=>{try{let t=atob(e),n=Uint8Array.from(t,o=>o.charCodeAt(0));return new TextDecoder().decode(n)}catch(t){return ""}},br=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"],f$1=d["data-callout-icon"],p=d["data-callout-body"],b=p?xl(p):"",g=(a!=null?a:Cl)(u),h=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:[h,m]}):null,b.trim().length>0?jsx(Ge,{components:l,rehypePlugins:c,remarkPlugins:i,children:b}):null]})},(e,t)=>N(e,t));br.displayName="MarkdownCallout";var Zo={"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"},yr=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(br,{className:t,node:n,...o,children:e});if(s){let l=Object.keys(Zo).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?Zo[l]:null,t),...o,children:e})}return jsx("div",{className:r(t),...o,children:e})},(e,t)=>N(e,t));yr.displayName="MarkdownDiv";var Cr=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)=>N(e,t));Cr.displayName="MarkdownSub";var xr=memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let s=i=>{if(!isValidElement(i))return false;let c=ae(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(ae(f)["data-footnote-backref"]!==void 0)u=true;else {let p=ae(f).children,b=Array.isArray(p)?p:[p];for(let g of b){if(typeof g=="string"&&g.trim()!==""){m=true;break}if(isValidElement(g)&&ae(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===bn){let c=ae(i).children,m=(Array.isArray(c)?c:[c]).filter(u=>!s(u));return m.length===0?null:{...i,props:{...ae(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)=>N(e,t));xr.displayName="MarkdownSection";var wl=({node:e,className:t,children:n,...o})=>{var be,ye,Me;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(ml),m=(be=d==null?void 0:d.at(1))!=null?be:"",u=Mo(m),f$1=He(),p=Fe(),b=i(),g=Lo(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 h=(ye=e==null?void 0:e.properties)==null?void 0:ye.metastring,x=typeof h=="string"?h:void 0,y=x==null?void 0:x.match(il),v=y?Number.parseInt(y[1],10):void 0,S=v!==void 0&&v>=1?v:void 0,_=!(x?ll.test(x):false)&&c!==false,I=(Me=fl(n))!=null?Me:"";if(g){let M=g.component;return jsx(Suspense,{fallback:jsx(Ke,{}),children:jsx(M,{code:I,isIncomplete:p,language:m,meta:x})})}if(u)return jsx(Suspense,{fallback:jsx(Ke,{}),children:jsx(cl,{className:t,code:I,isBlockIncomplete:p,language:m,plugin:u})});if(hl(m,f$1)){let M=hn(i$1,"openscad"),V=gn(i$1,"download"),G=gn(i$1,"copy"),H=gn(i$1,"fullscreen"),$=M&&(V||G||H);return jsx(Suspense,{fallback:jsx(Ke,{}),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})}),$?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:[V?jsx(St,{code:I,config:l==null?void 0:l.config}):null,G?jsx(xt,{code:I,label:b.copyModel,...Ue(i$1,"openscad")}):null,H?jsx(Bo,{code:I,config:l==null?void 0:l.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(dl,{code:I,config:l==null?void 0:l.config})})]})})}let O=hn(i$1,"code"),ee=Ko(i$1,"download"),te=Ko(i$1,"copy"),{"data-block":Q,...P}=o;return jsx(Gt,{className:t,code:I,isIncomplete:p,language:m,lineNumbers:_,startLine:S,...P,children:O?jsxs(Fragment,{children:[ee?jsx(Qt,{code:I,language:m}):null,te?jsx(xt,{...Ue(i$1,"code")}):null]}):null})},wr=memo(wl,(e,t)=>N(e,t)&&pl(e.node,t.node));wr.displayName="MarkdownCode";var kr=memo(ho,(e,t)=>N(e,t));kr.displayName="MarkdownImg";var Xo={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},vr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),s=i(),a=o["data-alert-type"],l=a&&a in Xo?Xo[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)=>N(e,t));vr.displayName="MarkdownAlertTitle";var Pr=memo(({children:e,className:t,node:n,...o})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(vr,{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=ae(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)=>N(e,t));Pr.displayName="MarkdownParagraph";var Sr={ol:bn,li:Yo,ul:Qo,hr:er,strong:tr,a:nr,h1:or,h2:rr,h3:sr,h4:ar,h5:ir,h6:lr,table:cr,thead:dr,tbody:mr,tr:ur,th:pr,td:fr,blockquote:gr,code:wr,div:yr,img:kr,pre:({children:e,node:t,...n})=>jsx("div",{...n,children:isValidElement(e)?cloneElement(e,{"data-block":"true"}):e}),sup:hr,sub:Cr,p:Pr,section:xr};var kl=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,vl=/\p{L}/u;function st(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(kl.test(s)){n!=null||(n="rtl"),r+=1;continue}vl.test(s)&&(n!=null||(n="ltr"),o+=1);}return r>o?"rtl":o>r?"ltr":n!=null?n:"ltr"}var Pl=/^[ \t]{0,3}(`{3,}|~{3,})/;var Tr=e=>{let t=e.split(`
|
|
21
|
+
`),n=null,o=0;for(let r of t){let s=Pl.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 Tl=/\[\^[\w-]{1,200}\](?!:)/,El=/\[\^[\w-]{1,200}\]:/,Rl=/<([A-Za-z][\w:-]*)[\s>/]/,Il=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Er=new Map,Rr=new Map,Lr=e=>{let t=e.toLowerCase(),n=Er.get(t);if(n)return n;let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Er.set(t,o),o},Ml=e=>{let t=e.toLowerCase(),n=Rr.get(t);if(n)return n;let o=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return Rr.set(t,o),o},Ir=(e,t)=>{if(Il.has(t.toLowerCase()))return 0;let n=e.match(Lr(t));if(!n)return 0;let o=0;for(let r of n)r.trimEnd().endsWith("/>")||(o+=1);return o},Mr=(e,t)=>{let n=e.match(Ml(t));return n?n.length:0},Ll=(e,t)=>{let n=e.match(Lr(t));return !!n&&n.every(o=>o.trimEnd().endsWith("/>"))},Al=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},Ar=e=>Tl.test(e)||El.test(e),Nl=/\r\n|\r/g,Dl=e=>new Lexer({gfm:true}).blockTokens(e),Ol=`
|
|
22
|
+
|
|
23
|
+
`,Hl=e=>{var t;for(let n=e.length-3;n>=0;n-=1)if((t=e.at(n))!=null&&t.endsWith(Ol))return n+1;return 0},Bl=e=>` ${e}`.slice(1),yn=(e,t)=>({source:e,blocks:t(e),verifiedCount:0,verifiedLength:0}),_l=(e,t,n)=>{var l,i,c,d;let o=Hl(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(Bl);return {source:t,blocks:e.blocks.slice(0,o).concat(a),verifiedCount:r,verifiedLength:s}},at=e=>{if(Ar(e))return [e];let t=e.includes("\r")?e.replace(Nl,`
|
|
24
|
+
`):e,n=Dl(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=Ir(l,c),m=Mr(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(Rl);if(c){let d=c[1],m=Ir(l,d),u=Mr(l,d);m>u&&!Ll(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(Al(c)%2===1){o[i-1]=c+l;continue}}o.push(l),a.type!=="space"&&(s=a.type==="code");}return o},Cn=(e,t,n=at)=>{var o;return t!=null&&t.source&&e.startsWith(t.source)?e===t.source?t:n===at&&Ar(e)?yn(e,n):(o=_l(t,e,n))!=null?o:yn(e,n):yn(e,n)};var Vl=/^ {0,3}(`{3,}|~{3,})/,jl=/^\n[ \t]*\n/,Dr=(e,t,n)=>{let o=t;for(;o<n&&e[o]==="`";)o+=1;return o},$l=(e,t,n,o)=>{let r=t;for(;r<n;){let s=e[r];if(s==="`"){let a=Dr(e,r,n);if(a-r===o)return r;r=a;continue}if(s===`
|
|
25
|
+
`&&jl.test(e.slice(r,r+64)))return -1;r+=1;}return -1},Nr=(e,t,n,o)=>{let r=t;for(;r<n;){if(e[r]!=="`"){r+=1;continue}let s=Dr(e,r,n),a=s-r,l=$l(e,s,n,a);if(l===-1){r=s;continue}o.push([r,l+a]),r=l+a;}},Fl=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=Vl.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("`")||(Nr(e,r,s,t),o={char:d[0],length:d.length,start:s});}s=l+1;}return o?t.push([o.start,n]):Nr(e,r,n,t),t},zl=(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},Rt=e=>{let t=null;return n=>(t===null&&(t=Fl(e)),zl(t,n))},Or=(e,t,n)=>{let o=Rt(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))})},It=(e,t,n)=>{let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),r=new RegExp(`</${t}\\s*>`,"gi"),s=Rt(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 Wl=/^\n*/,ql=/\n*$/,xn=/\n\n/g,Ul=(e,t,n)=>{if(!t.includes(`
|
|
27
|
+
`))return e+t+n;let r=t.replace(xn,`
|
|
28
|
+
<!---->
|
|
29
|
+
`).replace(Wl,`
|
|
30
|
+
|
|
31
|
+
`).replace(ql,`
|
|
32
|
+
|
|
33
|
+
`);return `${e}${r}${n}
|
|
34
|
+
|
|
35
|
+
`},Kl=(e,t)=>{let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),o=new RegExp(`</${t}\\s*>`,"gi"),r=Rt(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(xn,`
|
|
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(xn,`
|
|
43
|
+
<!---->
|
|
44
|
+
`);a+=`${c}
|
|
45
|
+
|
|
46
|
+
${f}`,l=e.length;break}return l===0?e:a+e.slice(l)},wn=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t){let r=new RegExp(`<${o}(?=[\\s>/])((?:"[^"]*"|'[^']*'|[^"'>])*)\\/>`,"gi");n=Or(n,r,(s,a)=>`<${o}${a}></${o}>`);}return n},Hr=(e,t)=>{if(!t.length)return e;let n=wn(e,t);for(let o of t)n=It(n,o,Ul),n=Kl(n,o);return n};var Zl=/([\\`*_~[\]|])/g,Xl=e=>e.replace(Zl,"\\$1"),Br=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t)n=It(n,o,(r,s,a)=>{let l=Xl(s).replace(/\n\n/g," ");return r+l+a});return n};var Jl=new Set(["blockquote","dd","dt","figcaption","h1","h2","h3","h4","h5","h6","li","p","td","th"]),_r=new Set(["code","kbd","pre","samp","var"]);function Vr(e){return e.children.map(t=>t.type==="text"?t.value:t.type==="element"&&!_r.has(t.tagName)?Vr(t):"").join("")}function jr(){return e=>{visit(e,"element",t=>{if(_r.has(t.tagName)){(t.properties)!=null||(t.properties={}),t.properties.dir="ltr";return}Jl.has(t.tagName)&&((t.properties)!=null||(t.properties={}),typeof t.properties.dir!="string"&&(t.properties.dir=st(Vr(t))));});}}var $r=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 Fr=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(Fr).join(""):"",zr=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=Fr(o);o.children=r?[{type:"text",value:r}]:[];}});};var sc=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),ac=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),ic=e=>{let t=unified().use(Ya).use(Qa,{allowDangerousHtml:true}),n=t.parse(e);return t.runSync(n).children},Wr=(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)||!sc(s))return;let l=ac(s);if(!l.includes(`
|
|
47
|
+
`))return;let i=ic(l);s.children=i;});};var qr=()=>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 Ur=/^>>>[ \t]?(.*)$/,cc=/^<<<\s*$/,dc=/^>+\s*$/,mc=/^<+\s*$/,uc=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,pc=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,fc=/^[a-z0-9-]+$/,gc=e=>{let t=uc.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&&fc.test(a)?a:void 0,title:r!==void 0&&r.length>0?r:void 0,color:s&&pc.test(s)?s:void 0}},kn=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),hc=e=>{let t=new TextEncoder().encode(e),n="";for(let o of t)n+=String.fromCharCode(o);return btoa(n)},bc=(e,t)=>{var c;let n=Ur.exec(e[t]),o=(c=n==null?void 0:n[1])!=null?c:"",r=gc(o),s=[],a=t+1;for(;a<e.length;a+=1){let d=e[a];if(cc.test(d)){a+=1;break}if(dc.test(d)||mc.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="${kn(r.title)}"`:"",r.color!==void 0?`data-callout-color="${kn(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${kn(r.icon)}"`:"",`data-callout-body="${hc(l)}"`].filter(Boolean).join(" ")}></div>`,next:a}},Kr=e=>{if(!e.includes(">>>"))return e;let t=e.split(`
|
|
49
|
+
`),n=[],o=0,r=false;for(;o<t.length;)if(Ur.test(t[o])){let s=bc(t,o);n.push(s.replacement),o=s.next,r=true;}else n.push(t[o]),o+=1;return r?n.join(`
|
|
50
|
+
`):e},Zr=()=>()=>{};var Cc=/^([a-zA-Z][a-zA-Z\d+\-.]*:)/,xc=e=>new Set(e.map(t=>t.trim().toLowerCase()).filter(t=>t.length>0).map(t=>t.endsWith(":")?t:`${t}:`));function wc(e,t){if(e.children.length!==1)return false;let[n]=e.children;if(n.type!=="text")return false;let o=Cc.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 Xr=(e=[])=>{let t=xc(e);return n=>{t.size!==0&&visit(n,"link",(o,r,s)=>{if(!(!s||r===void 0)&&wc(o,t))return s.children.splice(r,1,...o.children),r});}};var Pc={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,Gr=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let n="";for(let o of t)n+=Gr(o);return n},Tc=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}}}},Ec=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=Gr(n).trimStart(),r=o.match(Sc);if(!r)return;let s=Pc[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=[Tc(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$1},Jr=()=>e=>{visit(e,"blockquote",Ec);};var Ic=(e,t)=>{var r,s;if(!(t.ordered&&t.children.length===1))return false;let n=(r=e.position)==null?void 0:r.start.line,o=(s=t.position)==null?void 0:s.start.line;return n!==void 0&&n===o},Mc=(e,t,n)=>{var s,a,l;let o=(s=t.position)==null?void 0:s.start.offset,r=(a=n==null?void 0:n.position)==null?void 0:a.start.offset;return o!==void 0&&r!==void 0&&r>o?e.slice(o,r).trimEnd():`${(l=t.start)!=null?l:1}.`},Lc=(e,t,n)=>{let o=t.children[0],[r,...s]=o.children,a=Mc(n,t,r),l;if((r==null?void 0:r.type)==="paragraph"){let[i,...c]=r.children,d={...r,children:(i==null?void 0:i.type)==="text"?[{...i,value:`${a} ${i.value}`},...c]:[{type:"text",value:`${a} `},...r.children]};t.position&&r.position&&(d.position={start:t.position.start,end:r.position.end}),l=[d,...s];}else {let i={type:"paragraph",children:[{type:"text",value:a}]};t.position&&(i.position={start:t.position.start,end:t.position.start}),l=[i,...o.children];}e.children=[...l,...e.children.slice(1)],o.spread&&(e.spread=true);},Yr=()=>(e,t)=>{let n=typeof(t==null?void 0:t.value)=="string"?t.value:"";visit(e,"listItem",o=>{let r=o.children[0];(r==null?void 0:r.type)==="list"&&Ic(o,r)&&Lc(o,r,n);});};function Qr(e,t,n,o){let r=useRef(null),[s,a]=useState(false),l=!!t&&n!=="static";return useLayoutEffect(()=>{var d,m,u;if(!l||e){a(l&&e);return}let i=((u=(m=(d=r.current)==null?void 0:d.getAnimations)==null?void 0:m.call(d,{subtree:true}))!=null?u:[]).filter(f=>{var p;return "animationName"in f&&String(f.animationName).startsWith("sd-")&&f.playState!=="finished"&&f.playState!=="idle"&&Number.isFinite((p=f.effect)==null?void 0:p.getComputedTiming().endTime)});if(i.length===0){a(false);return}let c=false;return Promise.allSettled(i.map(f=>f.finished)).then(()=>{c||a(false);}),()=>{c=true;}},[e,l,t,o]),{containerRef:r,animateText:l&&(e||s)}}var Bc=120,_c=16,Vc=1e3,jc=.5,$c=.15,Fc=250,ts=32,zc=/[\s\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,ns=e=>zc.test(e),Wc=e=>e>=55296&&e<=56319,os=(e,t,n)=>{let o=Math.min(Math.floor(t),e.length),r=Math.min(e.length,o+ts);for(;o<r&&!ns(e.charAt(o));)o+=1;if(!n&&o===e.length){let s=Math.max(0,o-ts);for(;o>s&&!ns(e.charAt(o-1));)o-=1;}return o>0&&o<e.length&&Wc(e.charCodeAt(o-1))&&(o-=1),o},qc=e=>{let t=e,n=e.length,o=e.length,r=0,s=0,a=null,l=null,i=false,c=e,d=f=>{f>o&&(o=f,c=t.slice(0,o));},m=f=>{let p=l===null?0:Math.max(0,f-l);l=f,n=Math.min(t.length,n+r*p),d(os(t,n,!i));},u=f=>{if(a!==null){let p=Math.min(Vc,Math.max(_c,f-a)),b=p>s?jc:$c;s=s===0?p:s+b*(p-s);}a=f;};return {advance:m,flush(){n=t.length,r=0,d(t.length);},get isRevealing(){return o<os(t,t.length,!i)},update(f,p,b){m(b),i=p,f!==t&&(f.startsWith(t)?(u(b),t=f):(t=f,n=f.length,o=f.length,c=f,s=0,a=null));let g=t.length-n;r=g/(s||Bc),i||(r=Math.max(r,g/Fc));},get visible(){return c}}},rs=()=>typeof performance=="undefined"?Date.now():performance.now(),Uc=()=>typeof document!="undefined"&&document.visibilityState==="hidden",ss=({children:e,isAnimating:t,mode:n,smooth:o})=>{let r=typeof e=="string"?e:"",s=useRef(null),[a,l]=useState(r),[i,c]=useState(o);o!==i&&(c(o),l(r));let d=o?r:"",m=o&&t;useEffect(()=>{if(!o){s.current=null;return}(s.current)!=null||(s.current=qc(d));let p=s.current;p.update(d,m,rs()),Uc()&&p.flush();let b=0,g=()=>{p.advance(rs()),l(p.visible),p.isRevealing&&(b=requestAnimationFrame(g));};return g(),()=>cancelAnimationFrame(b)},[d,m,o]);let u=o&&r.startsWith(a)?a:r,f=u.length<r.length;return {isAnimating:t||f,mode:f?"streaming":n,text:u}};var is=/^[a-z]/,td=/^[ \t]*<[\w!/?-]/,nd=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,od=e=>typeof e!="string"||e.length===0||!td.test(e)?e:e.replace(nd,"$1"),ds,ms,us,ps,fs,gs,hs,bs,ys,Cs,xs,ws,ks,Mt={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(ms=(ds=defaultSchema.protocols)==null?void 0:ds.href)!=null?ms:[],"tel","streamdown"],src:[...(ps=(us=defaultSchema.protocols)==null?void 0:us.src)!=null?ps:[],"streamdown"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(gs=(fs=defaultSchema.attributes)==null?void 0:fs.div)!=null?gs:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(bs=(hs=defaultSchema.attributes)==null?void 0:hs.p)!=null?bs:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(Cs=(ys=defaultSchema.attributes)==null?void 0:ys.svg)!=null?Cs:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(ws=(xs=defaultSchema.attributes)==null?void 0:xs.path)!=null?ws:[],"d","fillRule"]},tagNames:[...(ks=defaultSchema.tagNames)!=null?ks:[],"svg","path"]},vn={raw:wo,sanitize:[Ss,Mt],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},rd={gfm:[Qc,{}],githubAlerts:Jr,containerAlerts:Zr,codeMeta:qr,inlineOrderedMarker:Yr},ls=Object.values(vn),sd=Object.values(rd),cs=new WeakMap;function ad(e){var r;let t=cs.get(e);if(t)return t;let n={...Mt,tagNames:[...(r=Mt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...Mt.attributes,...e}},o=[vn.raw,[Ss,n],vn.harden];return cs.set(e,o),o}var id={block:" \u258B",circle:" \u25CF"},ld=["github-light","github-dark"],cd={enabled:true},dd=(e,t)=>{if(!e)return "";let n=e===true?"true":JSON.stringify(e);return t?`${n}:smooth`:n},md=(e,t)=>{var r;let{maxBacklogMs:n,...o}=typeof e=="object"?e:{};return {...o,stagger:(r=o.stagger)!=null?r:t?0:void 0}},Ts=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:o,isIncomplete:r,dir:s,animatePlugin:a,...l})=>{useLayoutEffect(()=>{a==null||a.commit();});let i=typeof e=="string"&&n?od(e):e,c=jsx(Ge,{...l,children:i});return jsx(qt.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)});Ts.displayName="Block";var ud=memo(({children:e$1,mode:t="streaming",dir:n,parseIncompleteMarkdown:o=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=ls,remarkPlugins:l=sd,className:i,shikiTheme:c$1,mermaid:d,openscad:m,plantuml:u,smiles:f,vega:p,diagrams:b,codeBlockMaxHeight:g$1=400,controls:h$1=true,isAnimating:x=false,scrollable:y,tableMaxHeight:v=300,animated:S,smooth:R=false,BlockComponent:_=Ts,parseMarkdownIntoBlocksFn:I=at,caret:O,listStyle:ee="hierarchical",calloutIcon:te,calloutStyle:Q,plugins:P,remend:be,linkSafety:ye=cd,portal:Me,lineNumbers:M=true,allowedTags:V,fallbackComponent:G,literalTagContent:H,dataOnlyTags:$,disableAutolinkProtocols:Ce,translations:Le,icons:Ae,prefix:le,onAnimationStart:ce,onAnimationEnd:Lt,...Pn})=>{let Es=useId(),{text:Sn,isAnimating:J,mode:K}=ss({children:e$1,isAnimating:x,mode:t,smooth:R}),ct=useMemo(()=>c(le),[le]),Tn=useRef(null),xe=useRef(ce),dt=useRef(Lt);xe.current=ce,dt.current=Lt,useEffect(()=>{var E,j,F;if(K==="static")return;let C=Tn.current;if(Tn.current=J,C===null){J&&((E=xe.current)==null||E.call(xe));return}J&&!C?(j=xe.current)==null||j.call(xe):!J&&C&&((F=dt.current)==null||F.call(dt));},[J,K]);let Ne=useMemo(()=>V?Object.keys(V):[],[V]),De=useMemo(()=>{if(!($!=null&&$.length||H!=null&&H.length))return Ne;let C=new Set([...$!=null?$:[],...H!=null?H:[]].map(E=>E.toLowerCase()));return Ne.filter(E=>!C.has(E.toLowerCase()))},[Ne,$,H]),En=useRef(null),At=useMemo(()=>{if(typeof e$1!="string")return "";let C=Sn;return H&&H.length>0&&(C=Br(C,H)),Ne.length>0&&(C=wn(C,Ne)),De.length>0&&(C=Hr(C,De)),C=Kr(C),C},[Ne,e$1,De,H,Sn]),ne=useMemo(()=>{let C=K==="streaming"?En.current:null,E=Cn(At,C,I);if(En.current=K==="streaming"?E:null,!(K==="streaming"&&o)||E.blocks.length===0)return E.blocks;let j=E.blocks.length-1,F=E.blocks[j],W=ed(F,be);if(W===F)return E.blocks;let Z=E.blocks.slice();return Z[j]=W,Z},[At,I,K,o,be]),mt=useMemo(()=>dd(S,R),[S,R]),{containerRef:Rs,animateText:Nt}=Qr(J,mt,K,e$1),Y=useRef(null),we=useRef([]),de=useRef([]),Rn=useRef(null),ut=useRef("");if(mt){if(ut.current!==mt){ut.current=mt;let C=typeof S=="object"?S.maxBacklogMs:void 0;Y.current=zt({maxBacklogMs:C}),we.current=[],de.current=[];}else Y.current||(Y.current=zt());Nt&&Y.current&&Y.current.beginPass(Y.current.now());}else Y.current=null,we.current=[],de.current=[],ut.current="";let ke=useDeferredValue(ne),oe=useMemo(()=>{if(K!=="streaming"||Y.current||ke===ne||ke.length===0)return ne;let C=ke.length,E=ne.length;if(E===0)return ke;if(C!==E)return ne;for(let F=0;F<C-1;F+=1)if(ke[F]!==ne[F])return ne;let j=ke.slice();return j[C-1]=ne[E-1],j},[ne,ke,K]);useLayoutEffect(()=>{var C;if(we.current.length=Math.min(we.current.length,oe.length),de.current.length=Math.min(de.current.length,oe.length),oe.length===0){Y.current=null,ut.current="";return}Nt&&((C=Y.current)==null||C.commitPass());});let Dt=useMemo(()=>n==="auto"?oe.map(st):void 0,[oe,n]),[In]=useState(()=>Wn(Es)),Is=useMemo(()=>In(oe),[oe,In]),Ms=useMemo(()=>Le?JSON.stringify(Le):"",[Le]),Mn=useMemo(()=>({...g,...Le}),[Ms]),pt=useMemo(()=>{let{inlineCode:C,...E}=s!=null?s:{},j={...Sr,...E};if(C){let F=j.code;j.code=W=>"data-block"in W?F?createElement(F,W):null:createElement(C,W);}if(G){if(V)for(let W of Object.keys(V))Object.hasOwn(j,W)||(j[W]=G);let F={configurable:true,enumerable:false,value:G,writable:false};return new Proxy(j,{getOwnPropertyDescriptor(W,Z){let Pe=Object.getOwnPropertyDescriptor(W,Z);if(Pe)return Pe;if(typeof Z=="string"&&is.test(Z))return F},get(W,Z,Pe){return typeof Z=="string"&&is.test(Z)&&!Object.hasOwn(W,Z)?G:Reflect.get(W,Z,Pe)}})}return j},[s,G,V]),ft=useMemo(()=>{let C=[];return P!=null&&P.cjk&&(C=[...C,...P.cjk.remarkPluginsBefore]),C=[...C,...l],Ce&&Ce.length>0&&(C=[...C,[Xr,Ce]]),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,Ce]),ve=useMemo(()=>{let C=a;return V&&Object.keys(V).length>0&&a===ls&&(C=ad(V)),De.length>0&&(C=[...C,[Wr,De,H!=null?H:[]]]),H&&H.length>0&&(C=[...C,[zr,H]]),$&&$.length>0&&(C=[...C,[$r,$]]),P!=null&&P.math&&(C=[...C,P.math.rehypePlugin]),n==="auto"&&K==="static"&&(C=[...C,jr]),C},[a,P==null?void 0:P.math,V,De,H,$,n,K]),Ln=useMemo(()=>{var C,E;return {calloutIcon:te,calloutStyle:Q,codeBlockMaxHeight:g$1,shikiTheme:(E=c$1!=null?c$1:(C=P==null?void 0:P.code)==null?void 0:C.getThemes())!=null?E:ld,controls:h$1,isAnimating:J,lineNumbers:M,listStyle:ee,mode:K,mermaid:d,openscad:m,plantuml:u,smiles:f,vega:p,diagrams:b,linkSafety:ye,portal:Me,scrollable:y,tableMaxHeight:v,components:pt,remarkPlugins:ft,rehypePlugins:ve}},[te,Q,g$1,c$1,h$1,J,M,ee,K,d,m,u,f,p,b,ye,Me,y,P==null?void 0:P.code,v,pt,ft,ve]),Ls=useMemo(()=>O&&J?{"--streamdown-caret":`"${id[O]}"`}:void 0,[O,J]),As=C=>{let E=null;Y.current&&Nt&&(we.current[C]||(we.current[C]=bt({...md(S,R),timeline:Y.current})),E=we.current[C]),Rn.current!==ve&&(de.current=[],Rn.current=ve),E&&!de.current[C]&&(de.current[C]=[...ve,E.rehypePlugin]);let j=E&&de.current[C]?de.current[C]:ve;return {blockAnimatePlugin:E,blockRehypePlugins:j}};return K==="static"?jsx(h.Provider,{value:Mn,children:jsx(vt.Provider,{value:P!=null?P:null,children:jsx(T.Provider,{value:Ln,children:jsx(Jt,{icons:Ae,children:jsx(e.Provider,{value:ct,children:jsx("div",{className:ct("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:n==="auto"?void 0:n,children:jsx(Ge,{components:pt,rehypePlugins:ve,remarkPlugins:ft,...Pn,children:At})})})})})})}):jsx(h.Provider,{value:Mn,children:jsx(vt.Provider,{value:P!=null?P:null,children:jsx(T.Provider,{value:Ln,children:jsx(Jt,{icons:Ae,children:jsx(e.Provider,{value:ct,children:jsxs("div",{className:ct("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",O?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),"data-streamdown":"container",ref:Rs,style:Ls,children:[oe.length===0&&O&&J&&jsx("span",{}),oe.map((C,E)=>{var Pe;let j=E===oe.length-1,F=J&&j&&Tr(C),{blockAnimatePlugin:W,blockRehypePlugins:Z}=As(E);return jsx(_,{animatePlugin:W,components:pt,content:C,dir:(Pe=Dt==null?void 0:Dt[E])!=null?Pe:n!=="auto"?n:void 0,index:E,isIncomplete:F,rehypePlugins:Z,remarkPlugins:ft,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:o,...Pn},Is[E])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.smooth===t.smooth&&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&&e.fallbackComponent===t.fallbackComponent);ud.displayName="Streamdown";var yd=lazy(()=>import('./viewer-SB7OV4V7.js').then(e=>({default:e.OpenScadViewer}))),Ho=({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,b]=useState(0),{openscad:g}=useContext(T),h=He(),x=g==null?void 0:g.errorComponent,y=Fe(),{shouldRender:v,containerRef:S}=Nn({immediate:o});if(useEffect(()=>{if(!v||y)return;if(!h){l(s.openscadPluginMissing);return}(async()=>{try{l(null),c(!0);let O=await h.getOpenScad(n).render(t,n);m(O),f$1(O);}catch(I){if(!(u||d)){let O=I instanceof Error?I.message:s.openscadRenderFailed;l(O);}}finally{c(false);}})();},[t,n,p,v,y,h,s]),!(v||d||u))return jsx("div",{className:r("my-4 min-h-[200px]",e),ref:S});if(y&&!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 _=()=>b(I=>I+1);return x?jsx("div",{ref:S,children:jsx(x,{code:t,error:a,retry:_})}):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 R=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:R?jsx(yd,{className:e,data:R.data,format:R.format,fullscreen:o}):null})})};
|
|
51
|
+
export{_e as A,tt as B,Ji as C,nt as D,st as E,at as F,Cn as G,od as H,vn as I,rd as J,Ts as K,ud as L,js as a,bt as b,Fe as c,ze as d,Xn as e,Kt as f,Xt as g,yu as h,Gt as i,B as j,xt as k,Te as l,Ue as m,Qt as n,Ke as o,fe as p,ge as q,T as r,Oe as s,So as t,Nn as u,Ho as v,Be as w,Ie as x,dn as y,Tt as z};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {r,h,e}from'./chunk-
|
|
2
|
+
import {r,h,e}from'./chunk-XGSGO2TP.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.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type ExtraProps, type Options } from "./lib/markdown";
|
|
|
6
6
|
import type { PluginConfig, ThemeInput } from "./lib/plugin-types";
|
|
7
7
|
import { type CalloutIconResolver, type CalloutStyleResolver, type ControlsConfig, type DiagramOptions, type LinkSafetyConfig, type ListStylePreset, type MermaidOptions, type OpenScadOptions, type PlantUmlOptions, type PortalTarget, type ScrollableComponent, type SmilesOptions, type VegaOptions } from "./lib/streamdown-context";
|
|
8
8
|
import { type StreamdownTranslations } from "./lib/translations-context";
|
|
9
|
-
export type { AnimateOptions } from "./lib/animate";
|
|
9
|
+
export type { AnimateOptions, AnimationEffect } from "./lib/animate";
|
|
10
10
|
export { createAnimateCursor, createAnimatePlugin } from "./lib/animate";
|
|
11
11
|
export { useIsCodeFenceIncomplete } from "./lib/block-incomplete-context";
|
|
12
12
|
export { CodeBlock } from "./lib/code-block";
|
|
@@ -75,6 +75,16 @@ export type StreamdownProps = Options & {
|
|
|
75
75
|
scrollable?: ScrollableComponent;
|
|
76
76
|
tableMaxHeight?: number | string;
|
|
77
77
|
animated?: boolean | AnimateOptions;
|
|
78
|
+
/**
|
|
79
|
+
* Pace bursty streams. Text that arrives in large chunks is revealed a word
|
|
80
|
+
* at a time at the rate it has been arriving, instead of all at once.
|
|
81
|
+
* Adds roughly one chunk interval of display latency. Uses `isAnimating`
|
|
82
|
+
* to know when the stream ends. Until the held-back text is shown,
|
|
83
|
+
* Streamdown stays in streaming mode (caret, animation, incomplete-Markdown
|
|
84
|
+
* handling) even if `mode` is `"static"`, and `onAnimationEnd` waits for
|
|
85
|
+
* it. @default false
|
|
86
|
+
*/
|
|
87
|
+
smooth?: boolean;
|
|
78
88
|
caret?: keyof typeof carets;
|
|
79
89
|
/** Bullet style cycling for nested unordered lists. @default "hierarchical" */
|
|
80
90
|
listStyle?: ListStylePreset;
|
|
@@ -210,4 +220,4 @@ export type BlockProps = Options & {
|
|
|
210
220
|
animatePlugin?: AnimatePlugin | null;
|
|
211
221
|
};
|
|
212
222
|
export declare const Block: import("react").MemoExoticComponent<({ content, shouldParseIncompleteMarkdown: _, shouldNormalizeHtmlIndentation, index: __, isIncomplete, dir, animatePlugin: animatePluginProp, ...props }: BlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
213
|
-
export declare const Streamdown: import("react").MemoExoticComponent<({ children, mode, dir, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, normalizeHtmlIndentation: shouldNormalizeHtmlIndentation, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, openscad, plantuml, smiles, vega, diagrams, codeBlockMaxHeight, controls, isAnimating, scrollable, tableMaxHeight, animated, BlockComponent, parseMarkdownIntoBlocksFn, caret, listStyle, calloutIcon, calloutStyle, plugins, remend: remendOptions, linkSafety, portal, lineNumbers, allowedTags, fallbackComponent, literalTagContent, dataOnlyTags, disableAutolinkProtocols, translations, icons: iconOverrides, prefix, onAnimationStart, onAnimationEnd, ...props }: StreamdownProps) => import("react/jsx-runtime").JSX.Element>;
|
|
223
|
+
export declare const Streamdown: import("react").MemoExoticComponent<({ children, mode: modeProp, dir, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, normalizeHtmlIndentation: shouldNormalizeHtmlIndentation, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, openscad, plantuml, smiles, vega, diagrams, codeBlockMaxHeight, controls, isAnimating: isAnimatingProp, scrollable, tableMaxHeight, animated, smooth, BlockComponent, parseMarkdownIntoBlocksFn, caret, listStyle, calloutIcon, calloutStyle, plugins, remend: remendOptions, linkSafety, portal, lineNumbers, allowedTags, fallbackComponent, literalTagContent, dataOnlyTags, disableAutolinkProtocols, translations, icons: iconOverrides, prefix, onAnimationStart, onAnimationEnd, ...props }: StreamdownProps) => import("react/jsx-runtime").JSX.Element>;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
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-
|
|
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-XGSGO2TP.js';export{g as defaultTranslations,i as useTranslations}from'./chunk-GKDS2YGT.js';
|
package/dist/lib/animate.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface AnimateTimeline {
|
|
|
40
40
|
/** Snapshot of the working cursor (passNextStartAt). */
|
|
41
41
|
mark: () => number;
|
|
42
42
|
now: () => number;
|
|
43
|
+
passNow: () => number;
|
|
43
44
|
/** Restore the working cursor to a prior mark. */
|
|
44
45
|
rewind: (mark: number) => void;
|
|
45
46
|
take: (wordCount: number, stagger: number, now: number) => ScheduleSlot;
|
|
@@ -61,7 +62,7 @@ export declare function createAnimateCursor(): AnimateCursor;
|
|
|
61
62
|
export interface AnimatePlugin {
|
|
62
63
|
/**
|
|
63
64
|
* Commit the last rehype char count so the *next* rehype run treats that
|
|
64
|
-
* many characters as already-
|
|
65
|
+
* many characters as already-scheduled. Also clears the StrictMode rewind
|
|
65
66
|
* mark so the next commit starts clean. Called from Block's useLayoutEffect.
|
|
66
67
|
*/
|
|
67
68
|
commit: () => void;
|
|
@@ -69,12 +70,6 @@ export interface AnimatePlugin {
|
|
|
69
70
|
getLastRenderCharCount: () => number;
|
|
70
71
|
name: "animate";
|
|
71
72
|
rehypePlugin: Pluggable;
|
|
72
|
-
/**
|
|
73
|
-
* Enable or disable animation inside code/pre blocks.
|
|
74
|
-
* When true, code block content will be animated incrementally
|
|
75
|
-
* during streaming (useful for incomplete/unclosed code fences).
|
|
76
|
-
*/
|
|
77
|
-
setAnimateCodeBlocks: (enabled: boolean) => void;
|
|
78
73
|
/**
|
|
79
74
|
* Manually set how many HAST characters count as already-rendered.
|
|
80
75
|
* Prefer `commit()` in React; this is for tests / custom hosts.
|
|
@@ -82,8 +77,29 @@ export interface AnimatePlugin {
|
|
|
82
77
|
setPrevContentLength: (length: number) => void;
|
|
83
78
|
type: "animate";
|
|
84
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* An animation packaged with the per-word behavior its keyframes need, such
|
|
82
|
+
* as the ones in `@streamdown/effects`. Pass it as `animated.animation`.
|
|
83
|
+
*/
|
|
84
|
+
export interface AnimationEffect {
|
|
85
|
+
/**
|
|
86
|
+
* Extra attributes for each word while it animates, such as text for
|
|
87
|
+
* styles to draw. Must return the same attributes for the same arguments:
|
|
88
|
+
* words are re-rendered while they animate.
|
|
89
|
+
*/
|
|
90
|
+
decorate?: (text: string, seed: number) => Record<`data-${string}`, string>;
|
|
91
|
+
/** Default duration in ms. `animated.duration` overrides it. */
|
|
92
|
+
duration?: number;
|
|
93
|
+
/** `@keyframes` name without the `sd-` prefix. */
|
|
94
|
+
name: string;
|
|
95
|
+
/**
|
|
96
|
+
* Maximum extra delay in ms per word, hashed from its position, so words
|
|
97
|
+
* resolve in scattered order instead of left to right.
|
|
98
|
+
*/
|
|
99
|
+
scatter?: number;
|
|
100
|
+
}
|
|
85
101
|
export interface AnimateOptions {
|
|
86
|
-
animation?: "fadeIn" | "blurIn" | "slideUp" | (string & {});
|
|
102
|
+
animation?: "fadeIn" | "blurIn" | "slideUp" | (string & {}) | AnimationEffect;
|
|
87
103
|
duration?: number;
|
|
88
104
|
easing?: string;
|
|
89
105
|
/**
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visible length for a reveal head at `head`. Extends forward to the end of
|
|
3
|
+
* the word the head is in, so words appear whole. While streaming, holds
|
|
4
|
+
* back a trailing word the producer may still be extending.
|
|
5
|
+
*/
|
|
6
|
+
export declare const snapToWord: (text: string, head: number, final: boolean) => number;
|
|
7
|
+
export interface TextPacer {
|
|
8
|
+
/** Move the reveal head forward to `now`. */
|
|
9
|
+
advance: (now: number) => void;
|
|
10
|
+
/** Show everything immediately. */
|
|
11
|
+
flush: () => void;
|
|
12
|
+
/** True while there is text the pacer can still reveal. */
|
|
13
|
+
readonly isRevealing: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Feed the latest full text. Appends are paced; any other change (reset,
|
|
16
|
+
* edit, a diffusion model's full-text frame) is shown immediately.
|
|
17
|
+
*/
|
|
18
|
+
update: (text: string, streaming: boolean, now: number) => void;
|
|
19
|
+
readonly visible: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Jitter buffer for bursty streams. Each arrival re-targets the reveal rate
|
|
23
|
+
* so the current backlog finishes around when the next chunk is expected.
|
|
24
|
+
* `initial` is treated as already shown.
|
|
25
|
+
*/
|
|
26
|
+
export declare const createTextPacer: (initial: string) => TextPacer;
|
|
27
|
+
export interface SmoothStreamOptions {
|
|
28
|
+
children: unknown;
|
|
29
|
+
/** Whether more text may still arrive. */
|
|
30
|
+
isAnimating: boolean;
|
|
31
|
+
mode: "static" | "streaming";
|
|
32
|
+
smooth: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface SmoothStream {
|
|
35
|
+
isAnimating: boolean;
|
|
36
|
+
mode: "static" | "streaming";
|
|
37
|
+
text: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Paces string `children` for display when `smooth` is on. Appends are
|
|
41
|
+
* revealed over time; any other change renders as-is. While held-back text
|
|
42
|
+
* is still being shown, reports streaming state even if the stream has
|
|
43
|
+
* ended, so caret, animation and `onAnimationEnd` wait for it.
|
|
44
|
+
*/
|
|
45
|
+
export declare const useSmoothStream: ({ children, isAnimating, mode, smooth, }: SmoothStreamOptions) => SmoothStream;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofcz/streamdown",
|
|
3
|
-
"version": "2.16.
|
|
3
|
+
"version": "2.16.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"tsup": "^8.5.1",
|
|
53
53
|
"typescript": "^7.0.2",
|
|
54
54
|
"vitest": "^4.1.10",
|
|
55
|
-
"@streamdown/cjk": "npm:@lofcz/streamdown-cjk@1.0.
|
|
55
|
+
"@streamdown/cjk": "npm:@lofcz/streamdown-cjk@1.0.4",
|
|
56
56
|
"@streamdown/math": "npm:@lofcz/streamdown-math@1.0.3",
|
|
57
57
|
"@streamdown/mermaid": "npm:@lofcz/streamdown-mermaid@1.0.2"
|
|
58
58
|
},
|
package/dist/chunk-MFO3W3BR.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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 ms,{defaultSchema}from'rehype-sanitize';import wc from'remark-gfm';import kc 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 Oa from'remark-parse';import Ha 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 xs=300,ws="300px",ks=500;function En(e={}){let{immediate:t=false,debounceDelay:n=xs,rootMargin:o=ws,idleTimeout:r=ks}=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);},b=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)&&b(x);},n);},h=(x,v)=>{x.isIntersecting?f(v):p();},y=new IntersectionObserver(x=>{for(let v of x)h(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 vs=320,Ps=4,Ln=()=>typeof performance=="undefined"?Date.now():performance.now();function Vt(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:vs,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,Ps),u=Math.max(r,c),g=c+n,p=u+Math.max(0,l-1)*d,b=d;if(p>g&&l>1)if(u<g){let h=g-u;b=Math.max(m,h/(l-1));}else b=m;let f=Math.max(0,Math.round(u-c));return r=u+l*b,{baseDelay:f,step:b}},commitPass(){o=r;}}}function Ss(){return {current:0}}var Mn=/\s/,_t=/^\s+$/,Ts=new Set(["pre","svg","math","annotation"]),Es=new Set(["svg","math","annotation"]),Bt=new Set(["img","hr"]),Rs=new Set(["ul","ol","li"]),ke=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",jt=(e,t)=>{let n=t?Es:Ts;return e.some(o=>ke(o)&&n.has(o.tagName))},Is=e=>{for(let t=e.length-1;t>=0;t-=1){let n=e[t];if(ke(n)&&n.tagName==="li")return n}},Ls=(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(ke(t)){if(t.tagName==="input")return t;if(Rs.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`;},Ms=(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(ke(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&&!_t.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},Ns=(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}]}},As=(e,t,n,o)=>{let r=0,s=0;return visitParents(e,a=>a.type==="text"||ke(a)&&Bt.has(a.tagName),(a,l)=>{if(jt(l,n.animateCodeBlocks))return SKIP$1;if(ke(a)&&Bt.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,!_t.test(d)&&(o>0&&m<o||(r+=1));}}),r},Ds=(e,t,n,o,r,s)=>{if(jt(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);},Os=(e,t,n,o,r,s)=>{var h;let a=t.at(-1);if(!(a&&"children"in a))return;if(jt(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=Is(t),p=!!(g&&!((h=g.properties)!=null&&h["data-sd-animate-marker"])),b=false,f=d.map(y=>{let x=r.count;if(r.count+=y.length,_t.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&&!b){let L=v?0:n.duration;Ls(g,L,S,n.easing),Ms(g,n,L,S),b=true;}return u=true,Ns(y,n.animation,n.duration,n.easing,v,S)});return u&&Dn(t),l.children.splice(i,1,...f),i+f.length},Hs=0;function pt(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=Hs++,r=()=>d=>{var b;let m={count:0,newIndex:0};n.prevContentLength=n.committedCharCount;let u=t.timeline,g=(b=u==null?void 0:u.now())!=null?b:Ln();u&&(n.pendingMark===null?n.pendingMark=u.mark():u.rewind(n.pendingMark));let p=u?u.take(As(d,t,n,n.prevContentLength),t.stagger,g):{baseDelay:0,step:t.stagger};visitParents(d,f=>f.type==="text"||ke(f)&&Bt.has(f.tagName),(f,h)=>{if(f.type==="text")return Os(f,h,t,n,m,p);Ds(f,h,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;}}}pt();var $t=createContext(false),je=()=>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 $e=({scrollRef:e,ref:t,...n})=>jsx("div",{ref:e,...n});var Fs=8,zs=e=>e.scrollHeight-e.scrollTop-e.clientHeight<Fs,$n=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},ft=({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=$n(f);},g=f=>{if(m===null)return;let h=$n(f);if(h===null)return;let y=h-m;Math.abs(y)<=3||(y>0&&c(),m=h);},p=()=>{m=null;},b=()=>{let f=o.scrollTop<a.current;if(a.current=o.scrollTop,f){c();return}zs(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",b,{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",b);}},[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 Ks=a("block"),Us=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"),Zs=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},Fn=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(E),m=d!=null?d:$e,u=b(r),g=ft({content:t,enabled:!!u,isAnimating:c}),p=useMemo(()=>i(Us),[i]),b$1=useMemo(()=>i(Ks),[i]),f$1=useMemo(()=>{let h={};return t.bg&&(h["--sdm-bg"]=t.bg),t.fg&&(h["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(h,Zs(t.rootStyle)),h},[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((h,y)=>jsx("span",{className:a?p:b$1,children:h.length===0||h.length===1&&h[0].content===""?`
|
|
3
|
-
`:h.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 zt=({className:e,language:t,style:n,isIncomplete:o,...r})=>{let s=f();return jsx("div",{className:s("relative 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 Wt=createContext({code:""}),gt=()=>useContext(Wt);var qt=({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 ta=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
|
-
`;)t--;return e.slice(0,t)},na=lazy(()=>import('./highlighted-body-FUSBPRQ5.js').then(e=>({default:e.HighlightedCodeBlockBody}))),Kt=({code:e,language:t,className:n,children:o,isIncomplete:r=false,startLine:s,lineNumbers:a,...l})=>{let i=f(),{codeBlockMaxHeight:c}=useContext(E),d=useMemo(()=>ta(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(Wt.Provider,{value:{code:e},children:jsxs(zt,{dir:"ltr",isIncomplete:r,language:t,children:[jsx(qt,{language:t}),o?jsx("div",{className:i("pointer-events-none absolute top-2 right-2 z-10 flex items-center"),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(Fn,{className:n,language:t,lineNumbers:a,maxHeight:c,result:m,startLine:s,...l}),children:jsx(na,{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 ze={CheckIcon:qn,CopyIcon:Kn,DownloadIcon:Un,ExternalLinkIcon:Yn,Loader2Icon:Zn,Maximize2Icon:Xn,RotateCcwIcon:Jn,XIcon:Gn,ZoomInIcon:Qn,ZoomOutIcon:eo},no=createContext(ze),ia=(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])},Ut=({icons:e,children:t})=>{let n=useRef(e),o=useRef(e?{...ze,...e}:ze);ia(n.current,e)||(n.current=e,o.current=e?{...ze,...e}:ze);let r=o.current;return jsx(no.Provider,{value:r,children:t})},B=()=>useContext(no);var ht=({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}=gt(),{isAnimating:g}=useContext(E),p=i(),b=s!=null?s:u,f$1=a!=null?a:p.copyCode,h=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(b),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:h,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]},Pe=(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 We(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"},Xt=({onDownload:e,onError:t,language:n,children:o,className:r,code:s,...a})=>{let l=f(),{code:i$1}=gt(),{isAnimating:c,controls:d$1}=useContext(E),m=i(),u=B(),g=s!=null?s:i$1,p=n&&n in ro?ro[n]:"txt",b=`${Pe(d$1,"code","file")}.${p}`,f$1="text/plain",h=()=>{try{d(b,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:h,title:m.downloadFile,type:"button",...a,children:o!=null?o:jsx(u.DownloadIcon,{size:14})})};var qe=()=>{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 Ke=0,de=()=>{Ke+=1,Ke===1&&(document.body.style.overflow="hidden");},me=()=>{Ke=Math.max(0,Ke-1),Ke===0&&(document.body.style.overflow="");};var ya=["github-light","github-dark"],Ca={enabled:true},xa={codeBlockMaxHeight:400,shikiTheme:ya,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:Ca,portal:void 0,tableMaxHeight:300},E=createContext(xa);var Pa=/\.[^/.]+$/,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,b]=useState(false),[f$1,h]=useState(false),{controls:y}=useContext(E),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 T=m.current;if(T!=null&&T.complete){let K=T.naturalWidth>0;g(K),b(!K);}},[]),useEffect(()=>{if(!f$1)return;de();let T=K=>{K.key==="Escape"&&h(false);};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T),me();}},[f$1]);let G=useCallback(T=>{g(true),b(false),r==null||r(T);},[r]),Y=useCallback(T=>{g(false),b(true),s==null||s(T);},[s]),P=useCallback(()=>{V&&h(true);},[V]),Q=useCallback(()=>{h(false);},[]),pe=useCallback(T=>{a==null||a(T),!T.defaultPrevented&&P();},[a,P]),fe=async T=>{if(T.stopPropagation(),!!n)try{let D=await(await fetch(n)).blob(),X=new URL(n,window.location.origin).pathname.split("/").pop()||"",ge=X.split(".").pop(),it=X.includes(".")&&ge!==void 0&&ge.length<=4,Ie="";if(it)Ie=X;else {let se=D.type,ae="png";se.includes("jpeg")||se.includes("jpg")?ae="jpg":se.includes("png")?ae="png":se.includes("svg")?ae="svg":se.includes("gif")?ae="gif":se.includes("webp")&&(ae="webp"),Ie=`${(o||X||"image").replace(Pa,"")}.${ae}`;}d(Ie,D,D.type);}catch(K){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:pe,onError:Y,onLoad:G,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:fe,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:Q,onKeyDown:T=>{T.key==="Escape"&&Q();},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:Q,title:x.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 Ae=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(E),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){de();let f=h=>{h.key==="Escape"&&n();};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),me();}}},[t,n]),!t||typeof document=="undefined")return null;let b=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(b,Ae(u))};var po=()=>e=>{visit(e,"html",(n,o,r)=>{!r||typeof o!="number"||(r.children[o]={type:"text",value:n.value});});};var go=[],ho={allowDangerousHtml:true},yt=new WeakMap,en=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[b,f]=p;if(typeof b=="function"){let h=yt.get(b);h||(h=b.name,yt.set(b,h)),u+=h;}else u+=String(b);u+=":",u+=JSON.stringify(f);}else if(typeof p=="function"){let b=yt.get(p);b||(b=p.name,yt.set(p,b)),u+=b;}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();}},bo=new en,Ze=e=>{let t=_a(e),n=e.children||"",o=t.runSync(t.parse(n),n);return qa(o,e)},_a=e=>{let t=bo.get(e);if(t)return t;let n=$a(e);return bo.set(e,n),n},ja=e=>e.some(t=>Array.isArray(t)?t[0]===fo:t===fo),$a=e=>{let t=e.rehypePlugins||go,n=e.remarkPlugins||go,o=ja(t)?n:[...n,po],r=e.remarkRehypeOptions?{...ho,...e.remarkRehypeOptions}:ho;return unified().use(Oa).use(o).use(Ha,r).use(t)},yo=e=>e,Fa=(e,t,n,o)=>{n?e.children.splice(t,1):e.children[t]={type:"text",value:o};},za=(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);}},Wa=(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},qa=(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 Fa(u,m,s,d.value),m;if(d.type==="element"&&(za(d,c),Wa(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=/[(){}[\]]/,Ka=/[\s;]/,Ua=/^[\w-]+$/,Za=/:::[\w-]+\s*$/,Xa=/^[/\\]/,Ja=/[/\\]$/,Ga=/("[^"]*")/,Ya=[["((","))"],["))","(("],["{{","}}"],["[","]"],["(",")"],[")","("]],Xe=e=>`"${e.replace(/"/g,"#quot;")}"`,Qa=e=>e.length>=2&&e.startsWith('"')&&e.endsWith('"'),ei=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(Ka,1)[0];return i==="mindmap"?"mindmap":i==="flowchart"||i==="graph"?"flowchart":null}n+=1;}return null},ti=e=>{for(let[t,n]of Ya){let o=e.indexOf(t);if(o===-1||!e.endsWith(n))continue;let r=e.slice(0,o);if(r&&!Ua.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},ni=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=ti(o);if(r)return !Qa(r.inner)&&(Co.test(r.inner)||r.inner.includes('"'))?`${n}${r.id}${r.open}${Xe(r.inner)}${r.close}`:e;if(Co.test(o)){let s=o.replace(Za,"").trimEnd();return `${n}[${Xe(s)}]`}return e},oi=e=>{let t=e.split(`
|
|
7
|
-
`),n=false;return t.map(o=>n?ni(o):(o.trim()&&(n=true),o)).join(`
|
|
8
|
-
`)},ri=e=>e.startsWith("(")&&e.endsWith(")")||Xa.test(e)||Ja.test(e),tn=(e,t)=>e.split(Ga).map((n,o)=>o%2===0?t(n):n).join(""),si=e=>{if(e.trim().startsWith("%%"))return e;let t=tn(e,n=>n.replace(/\[([^[\]"]*[(){}][^[\]"]*)\]/g,(o,r)=>ri(r)?o:`[${Xe(r)}]`));return t=tn(t,n=>n.replace(/\{([^{}"]*[()[\]][^{}"]*)\}/g,(o,r)=>`{${Xe(r)}}`)),t=tn(t,n=>n.replace(/\|([^|"]*[(){}[\]][^|"]*)\|/g,(o,r)=>`|${Xe(r)}|`)),t},ai=e=>e.split(`
|
|
9
|
-
`).map(si).join(`
|
|
10
|
-
`),xo=e=>{let t=ei(e);if(!t)return null;let n=t==="mindmap"?oi(e):ai(e);return n===e?null:n};var ii=()=>{if(typeof document=="undefined")return false;let e=document.documentElement;return e.classList.contains("dark")||e.dataset.theme==="dark"||e.dataset.colorMode==="dark"},li=(e,t)=>Array.isArray(t)?t.includes(e):t===e,ci=e=>"getMermaid"in e&&typeof e.getMermaid=="function",di=e=>"getPlantUml"in e&&typeof e.getPlantUml=="function",mi=e=>"getVega"in e&&typeof e.getVega=="function",ui=e=>"getSmiles"in e&&typeof e.getSmiles=="function";var pi=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)}`},fi=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}}},gi=e=>{var t,n;return ci(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:"mmd",render:async(o,r)=>{let s=e.getMermaid(r);return await fi(s,pi(o),o)}}:di(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:ii();return await e.getPlantUml(s).render(o,{...s,dark:a})}}:mi(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)}:ui(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(gi)},ko=(e,t)=>{var n;return (n=e.find(o=>li(t,o.language)))!=null?n:null};var Ct=createContext(null),xt=()=>useContext(Ct),Vm=()=>{var t;let e=xt();return (t=e==null?void 0:e.code)!=null?t:null};var Ci=()=>{let e=xt();return useMemo(()=>wo(e),[e])},vo=e=>{let t=Ci();return ko(t,e)},De=()=>{var t;let e=xt();return (t=e==null?void 0:e.openscad)!=null?t:null};var Po=e=>{var n;let t=xt();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"},wt=({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(E),p=B(),b=De(),f$1=i(),h=Pe(u,"openscad","model"),y=async x=>{try{if(x==="scad"){d(`${h}.scad`,n,"text/plain"),i$1(!1),r==null||r(x);return}if(!b){s==null||s(new Error("OpenSCAD plugin not available"));return}d$1(!0);let v=b.getOpenScad(o),{data:S}=await v.render(n,{...o,format:x}),L=S.buffer.slice(S.byteOffset,S.byteOffset+S.byteLength);d(`${h}.${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(E),p=i(),b=(()=>{if(typeof u=="boolean")return u;let h=u.openscad;return h===false?false:h===true||h===void 0?true:h.download!==false})(),f$1=()=>{d(!c);};return useEffect(()=>{if(c){de();let h=y=>{y.key==="Escape"&&d(false);};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h),me();}}},[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:h=>{h.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:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:[b?jsx(wt,{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:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:jsx(Io,{className:i$1("size-full"),code:e,config:t,fullscreen:true})})]}),Ae(g)):null]})};var on=e=>e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(on).join(""):isValidElement(e)?on(e.props.children):"",Mo=(e,t,n)=>n!=null?n:(t?toText(t):on(e)).replace(/\s+/g," ").trim()||void 0;function rn(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(rn).join("")}var Oe=e=>{let t=[],n=[],o=e.querySelectorAll("thead th");for(let s of o)t.push(rn(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(rn(i).trim());n.push(a);}return {headers:t,rows:n}},Ge=e=>{var n;if(typeof e!="object")return ",";let t=e.table;return typeof t!="object"?",":(n=t.csvSeparator)!=null?n:","},Ee=(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
|
-
`)},kt=e=>{let t=false;for(let o of e)if(o==="\\"||o==="|"||o===`
|
|
17
|
-
`||o==="&"||o==="<"||o===">"){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>"):o==="&"?n.push("&"):o==="<"?n.push("<"):o===">"?n.push(">"):n.push(o);return n.join("")},He=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=>kt(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?kt(l[c]):"";o[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(c=>kt(c));o[r]=`| ${i.join(" | ")} |`,r+=1;}return o.join(`
|
|
19
|
-
`)};var Qe=({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(E),p=i(),b=Ge(g),f$1=We(g,"table"),h=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"]'),G=V==null?void 0:V.querySelector("table");if(!G){y==null||y(new Error("Table not found"));return}let Y=Oe(G),P="";L==="csv"?P=Ee(Y,b):L==="tsv"?P=sn(Y):P=He(Y);let Q=new ClipboardItem({"text/plain":new Blob([P],{type:"text/plain"}),"text/html":new Blob([G.outerHTML],{type:"text/html"})});await navigator.clipboard.write([Q]),c(!0),l(!1),h==null||h(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 Di=({children:e,className:t,onDownload:n,onError:o,format:r="csv",filename:s})=>{let a=f(),{isAnimating:l,controls:i$1}=useContext(E),c=i(),d$1=B(),m=Ge(i$1),u=g=>{try{let b=g.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=b==null?void 0:b.querySelector("table");if(!f){o==null||o(new Error("Table not found"));return}let h=Oe(f),y="",x="",v="";switch(r){case "csv":y=Ee(h,m),x="text/csv",v="csv";break;case "markdown":y=He(h),x="text/markdown",v="md";break;default:y=Ee(h,m),x="text/csv",v="csv";}d(`${s||Pe(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})})},et=({children:e,className:t,onDownload:n,onError:o})=>{let r=f(),[s,a]=useState(false),l=useRef(null),{isAnimating:i$1,controls:c}=useContext(E),d$1=i(),m=B(),u=Ge(c),g=p=>{var b;try{let f=(b=l.current)==null?void 0:b.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),h=f==null?void 0:f.querySelector("table");if(!h){o==null||o(new Error("Table not found"));return}let y=Oe(h),x=p==="csv"?Ee(y,u):He(y),v=p==="csv"?"csv":"md",S=`${Pe(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=b=>{let f=b.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(E),m=i(),u=()=>{i$1(true);},g=()=>{i$1(false);};return useEffect(()=>{if(l){de();let p=b=>{b.key==="Escape"&&i$1(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),me();}}},[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(Qe,{}):null,o?jsx(et,{}):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})})]})}),Ae(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(E),m=d!=null?d:$e,u=b(n),g=ft({content:e,enabled:!!u,isAnimating:c}),p=o&&r,b$1=o&&s,f$1=o&&a,h=p||b$1||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:[h?jsxs("div",{className:i("flex items-center justify-end gap-1"),children:[p?jsx(Qe,{}):null,b$1?jsx(et,{}):null,f$1?jsx(Bo,{showCopy:p,showDownload:b$1,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 Wi=/startLine=(\d+)/,qi=/\bnoLineNumbers\b/,Ki=lazy(()=>import('./block-NMJXQ35A.js').then(e=>({default:e.DiagramCodeBlock}))),Ui=lazy(()=>import('./openscad-PAJE3A4O.js').then(e=>({default:e.OpenScad}))),Zi=/language-([^\s]+)/,oe=e=>e.props,Xi="node";function A(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!==Xi&&!Object.is(o[s],r[s]))return false;return true}function Ji(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 Gi(e){if(typeof e=="string")return e;if(isValidElement(e)){let t=oe(e).children;if(typeof t=="string")return t}}var Yi=(e,t)=>Array.isArray(t)?t.includes(e):t===e,Qi=(e,t)=>!!(t&&Yi(e,t.language)),un=(e,t)=>typeof e=="boolean"?e:e[t]!==false,dn=(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},mn=(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},nt=createContext({depth:0,ulDepth:0,isUnordered:false}),el={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},pn=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{depth:s,ulDepth:a}=useContext(nt),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(nt.Provider,{value:l,children:e})})},(e,t)=>A(e,t));pn.displayName="MarkdownOl";var qo=memo(({children:e,className:t,node:n,...o})=>{var b;let r=f(),{depth:s,ulDepth:a,isUnordered:l}=useContext(nt),{listStyle:i}=useContext(E),c=el[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)?(b=oe(u).node)==null?void 0:b.tagName:void 0,p=m.length===1&&isValidElement(u)&&(u.type==="p"||g==="p")?oe(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)=>A(e,t));qo.displayName="MarkdownLi";var Ko=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{depth:s,ulDepth:a}=useContext(nt),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(nt.Provider,{value:l,children:e})})},(e,t)=>A(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)=>A(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)=>A(e,t));Zo.displayName="MarkdownStrong";var tl=({children:e,className:t,href:n,node:o,...r})=>{let s=f(),{linkSafety:a}=useContext(E),[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(tl,(e,t)=>A(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)=>A(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)=>A(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)=>A(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)=>A(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)=>A(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)=>A(e,t));tr.displayName="MarkdownH6";var nr=memo(({children:e,className:t,node:n,...o})=>{let{controls:r,tableMaxHeight:s}=useContext(E),a=un(r,"table"),l=dn(r,"copy"),i=dn(r,"download"),c=dn(r,"fullscreen");return jsx(_o,{className:t,maxHeight:s,showControls:a,showCopy:l,showDownload:i,showFullscreen:c,...o,children:e})},(e,t)=>A(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)=>A(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)=>A(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)=>A(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)=>A(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)=>A(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)=>A(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)=>A(e,t));cr.displayName="MarkdownSup";var nl=()=>({}),ol=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(E),d=o,m=d["data-callout-title"],u=d["data-callout-color"],g=d["data-callout-icon"],p=d["data-callout-body"],b=p?ol(p):"",f$1=(a!=null?a:nl)(u),h=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:[h,m]}):null,b.trim().length>0?jsx(Ze,{components:l,rehypePlugins:c,remarkPlugins:i,children:b}):null]})},(e,t)=>A(e,t));dr.displayName="MarkdownCallout";var $o={"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($o).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?$o[l]:null,t),...o,children:e})}return jsx("div",{className:r(t),...o,children:e})},(e,t)=>A(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)=>A(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=oe(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(oe(g)["data-footnote-backref"]!==void 0)u=true;else {let p=oe(g).children,b=Array.isArray(p)?p:[p];for(let f of b){if(typeof f=="string"&&f.trim()!==""){m=true;break}if(isValidElement(f)&&oe(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===pn){let c=oe(i).children,m=(Array.isArray(c)?c:[c]).filter(u=>!s(u));return m.length===0?null:{...i,props:{...oe(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)=>A(e,t));pr.displayName="MarkdownSection";var rl=({node:e,className:t,children:n,...o})=>{var pe,fe,Re;let r=f(),s=!("data-block"in o),a=useContext(E),{openscad:l,controls:i$1,lineNumbers:c}=a,d=t==null?void 0:t.match(Zi),m=(pe=d==null?void 0:d.at(1))!=null?pe:"",u=vo(m),g=De(),p=je(),b=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 h=(fe=e==null?void 0:e.properties)==null?void 0:fe.metastring,y=typeof h=="string"?h:void 0,x=y==null?void 0:y.match(Wi),v=x?Number.parseInt(x[1],10):void 0,S=v!==void 0&&v>=1?v:void 0,H=!(y?qi.test(y):false)&&c!==false,I=(Re=Gi(n))!=null?Re:"";if(f$1){let T=f$1.component;return jsx(Suspense,{fallback:jsx(qe,{}),children:jsx(T,{code:I,isIncomplete:p,language:m,meta:y})})}if(u)return jsx(Suspense,{fallback:jsx(qe,{}),children:jsx(Ki,{className:t,code:I,isBlockIncomplete:p,language:m,plugin:u})});if(Qi(m,g)){let T=un(i$1,"openscad"),K=mn(i$1,"download"),D=mn(i$1,"copy"),U=mn(i$1,"fullscreen"),X=T&&(K||D||U);return jsx(Suspense,{fallback:jsx(qe,{}),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})}),X?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:[K?jsx(wt,{code:I,config:l==null?void 0:l.config}):null,D?jsx(ht,{code:I,label:b.copyModel,...We(i$1,"openscad")}):null,U?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(Ui,{code:I,config:l==null?void 0:l.config})})]})})}let V=un(i$1,"code"),G=jo(i$1,"download"),Y=jo(i$1,"copy"),{"data-block":P,...Q}=o;return jsx(Kt,{className:t,code:I,isIncomplete:p,language:m,lineNumbers:H,startLine:S,...Q,children:V?jsxs(Fragment,{children:[G?jsx(Xt,{code:I,language:m}):null,Y?jsx(ht,{...We(i$1,"code")}):null]}):null})},fr=memo(rl,(e,t)=>A(e,t)&&Ji(e.node,t.node));fr.displayName="MarkdownCode";var gr=memo(lo,(e,t)=>A(e,t));gr.displayName="MarkdownImg";var Fo={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},hr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),s=i(),a=o["data-alert-type"],l=a&&a in Fo?Fo[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)=>A(e,t));hr.displayName="MarkdownAlertTitle";var br=memo(({children:e,className:t,node:n,...o})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(hr,{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=oe(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)=>A(e,t));br.displayName="MarkdownParagraph";var yr={ol:pn,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:br,section:pr};var sl=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,al=/\p{L}/u;function ot(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(sl.test(s)){n!=null||(n="rtl"),r+=1;continue}al.test(s)&&(n!=null||(n="ltr"),o+=1);}return r>o?"rtl":o>r?"ltr":n!=null?n:"ltr"}var il=/^[ \t]{0,3}(`{3,}|~{3,})/;var Cr=e=>{let t=e.split(`
|
|
21
|
-
`),n=null,o=0;for(let r of t){let s=il.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 cl=/\[\^[\w-]{1,200}\](?!:)/,dl=/\[\^[\w-]{1,200}\]:/,ml=/<([A-Za-z][\w:-]*)[\s>/]/,ul=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},pl=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(ul.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(pl(t));return n?n.length:0},fl=(e,t)=>{let n=e.match(Pr(t));return !!n&&n.every(o=>o.trimEnd().endsWith("/>"))},gl=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=>cl.test(e)||dl.test(e),hl=/\r\n|\r/g,bl=e=>new Lexer({gfm:true}).blockTokens(e),yl=`
|
|
22
|
-
|
|
23
|
-
`,Cl=e=>{var t;for(let n=e.length-3;n>=0;n-=1)if((t=e.at(n))!=null&&t.endsWith(yl))return n+1;return 0},xl=e=>` ${e}`.slice(1),fn=(e,t)=>({source:e,blocks:t(e),verifiedCount:0,verifiedLength:0}),wl=(e,t,n)=>{var l,i,c,d;let o=Cl(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(xl);return {source:t,blocks:e.blocks.slice(0,o).concat(a),verifiedCount:r,verifiedLength:s}},rt=e=>{if(Sr(e))return [e];let t=e.includes("\r")?e.replace(hl,`
|
|
24
|
-
`):e,n=bl(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(ml);if(c){let d=c[1],m=kr(l,d),u=vr(l,d);m>u&&!fl(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(gl(c)%2===1){o[i-1]=c+l;continue}}o.push(l),a.type!=="space"&&(s=a.type==="code");}return o},gn=(e,t,n=rt)=>{var o;return t!=null&&t.source&&e.startsWith(t.source)?e===t.source?t:n===rt&&Sr(e)?fn(e,n):(o=wl(t,e,n))!=null?o:fn(e,n):fn(e,n)};var kl=/^ {0,3}(`{3,}|~{3,})/,vl=/^\n[ \t]*\n/,Er=(e,t,n)=>{let o=t;for(;o<n&&e[o]==="`";)o+=1;return o},Pl=(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
|
-
`&&vl.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=Pl(e,s,n,a);if(l===-1){r=s;continue}o.push([r,l+a]),r=l+a;}},Sl=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=kl.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},Tl=(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},Pt=e=>{let t=null;return n=>(t===null&&(t=Sl(e)),Tl(t,n))},Rr=(e,t,n)=>{let o=Pt(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))})},St=(e,t,n)=>{let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),r=new RegExp(`</${t}\\s*>`,"gi"),s=Pt(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 El=/^\n*/,Rl=/\n*$/,hn=/\n\n/g,Il=(e,t,n)=>{if(!t.includes(`
|
|
27
|
-
`))return e+t+n;let r=t.replace(hn,`
|
|
28
|
-
<!---->
|
|
29
|
-
`).replace(El,`
|
|
30
|
-
|
|
31
|
-
`).replace(Rl,`
|
|
32
|
-
|
|
33
|
-
`);return `${e}${r}${n}
|
|
34
|
-
|
|
35
|
-
`},Ll=(e,t)=>{let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),o=new RegExp(`</${t}\\s*>`,"gi"),r=Pt(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(hn,`
|
|
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(hn,`
|
|
43
|
-
<!---->
|
|
44
|
-
`);a+=`${c}
|
|
45
|
-
|
|
46
|
-
${g}`,l=e.length;break}return l===0?e:a+e.slice(l)},bn=(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=bn(e,t);for(let o of t)n=St(n,o,Il),n=Ll(n,o);return n};var Ml=/([\\`*_~[\]|])/g,Nl=e=>e.replace(Ml,"\\$1"),Lr=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t)n=St(n,o,(r,s,a)=>{let l=Nl(s).replace(/\n\n/g," ");return r+l+a});return n};var Dl=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}Dl.has(t.tagName)&&((t.properties)!=null||(t.properties={}),typeof t.properties.dir!="string"&&(t.properties.dir=ot(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 Fl=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),zl=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),Wl=e=>{let t=unified().use(Oa).use(Ha,{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)||!Fl(s))return;let l=zl(s);if(!l.includes(`
|
|
47
|
-
`))return;let i=Wl(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]?(.*)$/,Kl=/^<<<\s*$/,Ul=/^>+\s*$/,Zl=/^<+\s*$/,Xl=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,Jl=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,Gl=/^[a-z0-9-]+$/,Yl=e=>{let t=Xl.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&&Gl.test(a)?a:void 0,title:r!==void 0&&r.length>0?r:void 0,color:s&&Jl.test(s)?s:void 0}},yn=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),Ql=e=>{let t=new TextEncoder().encode(e),n="";for(let o of t)n+=String.fromCharCode(o);return btoa(n)},ec=(e,t)=>{var c;let n=_r.exec(e[t]),o=(c=n==null?void 0:n[1])!=null?c:"",r=Yl(o),s=[],a=t+1;for(;a<e.length;a+=1){let d=e[a];if(Kl.test(d)){a+=1;break}if(Ul.test(d)||Zl.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="${yn(r.title)}"`:"",r.color!==void 0?`data-callout-color="${yn(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${yn(r.icon)}"`:"",`data-callout-body="${Ql(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=ec(t,o);n.push(s.replacement),o=s.next,r=true;}else n.push(t[o]),o+=1;return r?n.join(`
|
|
50
|
-
`):e},$r=()=>()=>{};var nc=/^([a-zA-Z][a-zA-Z\d+\-.]*:)/,oc=e=>new Set(e.map(t=>t.trim().toLowerCase()).filter(t=>t.length>0).map(t=>t.endsWith(":")?t:`${t}:`));function rc(e,t){if(e.children.length!==1)return false;let[n]=e.children;if(n.type!=="text")return false;let o=nc.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 Fr=(e=[])=>{let t=oc(e);return n=>{t.size!==0&&visit(n,"link",(o,r,s)=>{if(!(!s||r===void 0)&&rc(o,t))return s.children.splice(r,1,...o.children),r});}};var ic={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"}]}},lc=/^\[!(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},cc=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}}}},dc=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(lc);if(!r)return;let s=ic[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=[cc(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",dc);};var uc=(e,t)=>{var r,s;if(!(t.ordered&&t.children.length===1))return false;let n=(r=e.position)==null?void 0:r.start.line,o=(s=t.position)==null?void 0:s.start.line;return n!==void 0&&n===o},pc=(e,t,n)=>{var s,a,l;let o=(s=t.position)==null?void 0:s.start.offset,r=(a=n==null?void 0:n.position)==null?void 0:a.start.offset;return o!==void 0&&r!==void 0&&r>o?e.slice(o,r).trimEnd():`${(l=t.start)!=null?l:1}.`},fc=(e,t,n)=>{let o=t.children[0],[r,...s]=o.children,a=pc(n,t,r),l;if((r==null?void 0:r.type)==="paragraph"){let[i,...c]=r.children,d={...r,children:(i==null?void 0:i.type)==="text"?[{...i,value:`${a} ${i.value}`},...c]:[{type:"text",value:`${a} `},...r.children]};t.position&&r.position&&(d.position={start:t.position.start,end:r.position.end}),l=[d,...s];}else {let i={type:"paragraph",children:[{type:"text",value:a}]};t.position&&(i.position={start:t.position.start,end:t.position.start}),l=[i,...o.children];}e.children=[...l,...e.children.slice(1)],o.spread&&(e.spread=true);},qr=()=>(e,t)=>{let n=typeof(t==null?void 0:t.value)=="string"?t.value:"";visit(e,"listItem",o=>{let r=o.children[0];(r==null?void 0:r.type)==="list"&&uc(o,r)&&fc(o,r,n);});};var Ur=/^[a-z]/,vc=/^[ \t]*<[\w!/?-]/,Pc=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,Sc=e=>typeof e!="string"||e.length===0||!vc.test(e)?e:e.replace(Pc,"$1"),Jr,Gr,Yr,Qr,es,ts,ns,os,rs,ss,as,is,ls,Tt={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(Gr=(Jr=defaultSchema.protocols)==null?void 0:Jr.href)!=null?Gr:[],"tel","streamdown"],src:[...(Qr=(Yr=defaultSchema.protocols)==null?void 0:Yr.src)!=null?Qr:[],"streamdown"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(ts=(es=defaultSchema.attributes)==null?void 0:es.div)!=null?ts:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(os=(ns=defaultSchema.attributes)==null?void 0:ns.p)!=null?os:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(ss=(rs=defaultSchema.attributes)==null?void 0:rs.svg)!=null?ss:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(is=(as=defaultSchema.attributes)==null?void 0:as.path)!=null?is:[],"d","fillRule"]},tagNames:[...(ls=defaultSchema.tagNames)!=null?ls:[],"svg","path"]},Cn={raw:fo,sanitize:[ms,Tt],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Tc={gfm:[wc,{}],githubAlerts:Wr,containerAlerts:$r,codeMeta:Vr,inlineOrderedMarker:qr},Zr=Object.values(Cn),Ec=Object.values(Tc),Xr=new WeakMap;function Rc(e){var r;let t=Xr.get(e);if(t)return t;let n={...Tt,tagNames:[...(r=Tt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...Tt.attributes,...e}},o=[Cn.raw,[ms,n],Cn.harden];return Xr.set(e,o),o}var Ic={block:" \u258B",circle:" \u25CF"},Lc=["github-light","github-dark"],Mc={enabled:true},us=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?Sc(e):e,c=jsx(Ze,{...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)});us.displayName="Block";var Nc=memo(({children:e$1,mode:t="streaming",dir:n,parseIncompleteMarkdown:o=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=Zr,remarkPlugins:l=Ec,className:i,shikiTheme:c$1,mermaid:d,openscad:m,plantuml:u,smiles:g$1,vega:p,diagrams:b,codeBlockMaxHeight:f=400,controls:h$1=true,isAnimating:y=false,scrollable:x,tableMaxHeight:v=300,animated:S,BlockComponent:L=us,parseMarkdownIntoBlocksFn:H=rt,caret:I,listStyle:V="hierarchical",calloutIcon:G,calloutStyle:Y,plugins:P,remend:Q,linkSafety:pe=Mc,portal:fe,lineNumbers:Re=true,allowedTags:T,fallbackComponent:K,literalTagContent:D,dataOnlyTags:U,disableAutolinkProtocols:X,translations:ge,icons:it,prefix:Ie,onAnimationStart:se,onAnimationEnd:ae,...Et})=>{let ps=useId(),lt=useMemo(()=>c(Ie),[Ie]),xn=useRef(null),he=useRef(se),ct=useRef(ae);he.current=se,ct.current=ae,useEffect(()=>{var R,_,j;if(t==="static")return;let C=xn.current;if(xn.current=y,C===null){y&&((R=he.current)==null||R.call(he));return}y&&!C?(_=he.current)==null||_.call(he):!y&&C&&((j=ct.current)==null||j.call(ct));},[y,t]);let Le=useMemo(()=>T?Object.keys(T):[],[T]),Me=useMemo(()=>{if(!(U!=null&&U.length||D!=null&&D.length))return Le;let C=new Set([...U!=null?U:[],...D!=null?D:[]].map(R=>R.toLowerCase()));return Le.filter(R=>!C.has(R.toLowerCase()))},[Le,U,D]),wn=useRef(null),Rt=useMemo(()=>{if(typeof e$1!="string")return "";let C=e$1;return D&&D.length>0&&(C=Lr(C,D)),Le.length>0&&(C=bn(C,Le)),Me.length>0&&(C=Ir(C,Me)),C=jr(C),C},[Le,e$1,Me,D]),ee=useMemo(()=>{let C=t==="streaming"?wn.current:null,R=gn(Rt,C,H);if(wn.current=t==="streaming"?R:null,!(t==="streaming"&&o)||R.blocks.length===0)return R.blocks;let _=R.blocks.length-1,j=R.blocks[_],$=kc(j,Q);if($===j)return R.blocks;let z=R.blocks.slice();return z[_]=$,z},[Rt,H,t,o,Q]),Ne=useMemo(()=>S===true?"true":S?JSON.stringify(S):"",[S]),J=useRef(null),_e=useRef([]),be=useRef([]),kn=useRef(null),It=useRef("");if(Ne){if(It.current!==Ne){It.current=Ne;let C=Ne!=="true"?S.maxBacklogMs:void 0;J.current=Vt({maxBacklogMs:C}),_e.current=[],be.current=[];}else J.current||(J.current=Vt());y&&J.current&&J.current.beginPass(J.current.now());}else J.current=null,_e.current=[],be.current=[],It.current="";useLayoutEffect(()=>{var C;y&&((C=J.current)==null||C.commitPass());});let ye=useDeferredValue(ee),Ce=useMemo(()=>{if(t!=="streaming"||J.current||ye===ee||ye.length===0)return ee;let C=ye.length,R=ee.length;if(R===0)return ye;if(C!==R)return ee;for(let j=0;j<C-1;j+=1)if(ye[j]!==ee[j])return ee;let _=ye.slice();return _[C-1]=ee[R-1],_},[ee,ye,t]),Lt=useMemo(()=>n==="auto"?Ce.map(ot):void 0,[Ce,n]),[vn]=useState(()=>Bn(ps)),fs=useMemo(()=>vn(Ce),[Ce,vn]),gs=useMemo(()=>ge?JSON.stringify(ge):"",[ge]),Pn=useMemo(()=>({...g,...ge}),[gs]),dt=useMemo(()=>{let{inlineCode:C,...R}=s!=null?s:{},_={...yr,...R};if(C){let j=_.code;_.code=$=>"data-block"in $?j?createElement(j,$):null:createElement(C,$);}if(K){if(T)for(let $ of Object.keys(T))Object.hasOwn(_,$)||(_[$]=K);let j={configurable:true,enumerable:false,value:K,writable:false};return new Proxy(_,{getOwnPropertyDescriptor($,z){let we=Object.getOwnPropertyDescriptor($,z);if(we)return we;if(typeof z=="string"&&Ur.test(z))return j},get($,z,we){return typeof z=="string"&&Ur.test(z)&&!Object.hasOwn($,z)?K:Reflect.get($,z,we)}})}return _},[s,K,T]),mt=useMemo(()=>{let C=[];return P!=null&&P.cjk&&(C=[...C,...P.cjk.remarkPluginsBefore]),C=[...C,...l],X&&X.length>0&&(C=[...C,[Fr,X]]),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,X]),xe=useMemo(()=>{let C=a;return T&&Object.keys(T).length>0&&a===Zr&&(C=Rc(T)),Me.length>0&&(C=[...C,[Br,Me,D!=null?D:[]]]),D&&D.length>0&&(C=[...C,[Hr,D]]),U&&U.length>0&&(C=[...C,[Dr,U]]),P!=null&&P.math&&(C=[...C,P.math.rehypePlugin]),n==="auto"&&t==="static"&&(C=[...C,Ar]),C},[a,P==null?void 0:P.math,T,Me,D,U,n,t]),Sn=useMemo(()=>{var C,R;return {calloutIcon:G,calloutStyle:Y,codeBlockMaxHeight:f,shikiTheme:(R=c$1!=null?c$1:(C=P==null?void 0:P.code)==null?void 0:C.getThemes())!=null?R:Lc,controls:h$1,isAnimating:y,lineNumbers:Re,listStyle:V,mode:t,mermaid:d,openscad:m,plantuml:u,smiles:g$1,vega:p,diagrams:b,linkSafety:pe,portal:fe,scrollable:x,tableMaxHeight:v,components:dt,remarkPlugins:mt,rehypePlugins:xe}},[G,Y,f,c$1,h$1,y,Re,V,t,d,m,u,g$1,p,b,pe,fe,x,P==null?void 0:P.code,v,dt,mt,xe]),hs=useMemo(()=>I&&y?{"--streamdown-caret":`"${Ic[I]}"`}:void 0,[I,y]),bs=C=>{let R=null;if(J.current&&y){if(!_e.current[C]){let j=Ne&&Ne!=="true"?S:{},{maxBacklogMs:$,...z}=j;_e.current[C]=pt({...z,timeline:J.current});}R=_e.current[C];}kn.current!==xe&&(be.current=[],kn.current=xe),R&&!be.current[C]&&(be.current[C]=[...xe,R.rehypePlugin]);let _=R&&be.current[C]?be.current[C]:xe;return {blockAnimatePlugin:R,blockRehypePlugins:_}};return t==="static"?jsx(h.Provider,{value:Pn,children:jsx(Ct.Provider,{value:P!=null?P:null,children:jsx(E.Provider,{value:Sn,children:jsx(Ut,{icons:it,children:jsx(e.Provider,{value:lt,children:jsx("div",{className:lt("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:n==="auto"?void 0:n,children:jsx(Ze,{components:dt,rehypePlugins:xe,remarkPlugins:mt,...Et,children:Rt})})})})})})}):jsx(h.Provider,{value:Pn,children:jsx(Ct.Provider,{value:P!=null?P:null,children:jsx(E.Provider,{value:Sn,children:jsx(Ut,{icons:it,children:jsx(e.Provider,{value:lt,children:jsxs("div",{className:lt("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:hs,children:[Ce.length===0&&I&&y&&jsx("span",{}),Ce.map((C,R)=>{var we;let _=R===Ce.length-1,j=y&&_&&Cr(C),{blockAnimatePlugin:$,blockRehypePlugins:z}=bs(R);return jsx(L,{animatePlugin:$,components:dt,content:C,dir:(we=Lt==null?void 0:Lt[R])!=null?we:n!=="auto"?n:void 0,index:R,isIncomplete:j,rehypePlugins:z,remarkPlugins:mt,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:o,...Et},fs[R])})]})})})})})})},(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&&e.fallbackComponent===t.fallbackComponent);Nc.displayName="Streamdown";var Vc=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,b]=useState(0),{openscad:f$1}=useContext(E),h=De(),y=f$1==null?void 0:f$1.errorComponent,x=je(),{shouldRender:v,containerRef:S}=En({immediate:o});if(useEffect(()=>{if(!v||x)return;if(!h){l(s.openscadPluginMissing);return}(async()=>{try{l(null),c(!0);let V=await h.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,h,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=()=>b(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(Vc,{className:e,data:L.data,format:L.format,fullscreen:o}):null})})};
|
|
51
|
-
export{He as A,Qe as B,Di as C,et as D,ot as E,rt as F,gn as G,Sc as H,Cn as I,Tc as J,us as K,Nc as L,Ss as a,pt as b,je as c,$e as d,Fn as e,zt as f,qt as g,Vm as h,Kt as i,B as j,ht as k,Pe as l,We as m,Xt as n,qe as o,de as p,me as q,E as r,Ae as s,yo as t,En as u,Io as v,Oe as w,Ee as x,sn as y,kt as z};
|