@lofcz/streamdown 2.14.0 → 2.15.0
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/chunk-6TBP27CO.js +2 -0
- package/dist/chunk-TXJ25TS2.js +51 -0
- package/dist/diagram-O5F65CLC.js +2 -0
- package/dist/highlighted-body-N5O52WFD.js +2 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.js +1 -1
- package/dist/lib/block-keys.d.ts +28 -0
- package/dist/lib/controls.d.ts +2 -2
- package/dist/lib/diagram/adapter.d.ts +11 -0
- package/dist/lib/diagram/context.d.ts +2 -0
- package/dist/lib/diagram/controls.d.ts +4 -0
- package/dist/lib/diagram/download-button.d.ts +15 -0
- package/dist/lib/diagram/fullscreen-button.d.ts +23 -0
- package/dist/lib/diagram/index.d.ts +13 -0
- package/dist/lib/diagram/labels.d.ts +6 -0
- package/dist/lib/diagram/options.d.ts +1 -0
- package/dist/lib/mermaid/download-button.d.ts +1 -1
- package/dist/lib/mermaid/fullscreen-button.d.ts +1 -1
- package/dist/lib/mermaid/index.d.ts +3 -3
- package/dist/lib/plantuml/download-button.d.ts +1 -1
- package/dist/lib/plantuml/fullscreen-button.d.ts +1 -1
- package/dist/lib/plantuml/index.d.ts +3 -3
- package/dist/lib/plugin-context.d.ts +18 -1
- package/dist/lib/plugin-types.d.ts +95 -1
- package/dist/lib/preprocess-custom-tags.d.ts +5 -0
- package/dist/lib/streamdown-context.d.ts +37 -19
- package/dist/lib/tailwind-classes.d.ts +1 -1
- package/dist/lib/tailwind-classes.js +1 -1
- package/dist/lib/translations-context.d.ts +20 -0
- package/dist/openscad-RHDHURT6.js +2 -0
- package/dist/{viewer-A5T7PMUM.js → viewer-URBRVFVJ.js} +1 -1
- package/package.json +3 -3
- package/dist/chunk-EMUDB4GM.js +0 -2
- package/dist/chunk-GG62F4WN.js +0 -50
- package/dist/highlighted-body-R67JZNIT.js +0 -2
- package/dist/mermaid-QZEZ54HM.js +0 -2
- package/dist/openscad-JFLBJUVO.js +0 -2
- package/dist/plantuml-IOCTYIAC.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {createContext,useContext}from'react';var t=(...a)=>twMerge(clsx(a)),S=a=>{if(a!==void 0)return typeof a=="number"?!Number.isFinite(a)||a<=0?void 0:`${a}px`:a},g=(a,n)=>{if(!a||!n)return n;let o=`${a}:`;return n.split(/\s+/).filter(Boolean).map(r=>r.startsWith(o)?r:`${a}:${r}`).join(" ")},v=a=>a?(...n)=>g(a,twMerge(clsx(n))):t,D=(a,n,o)=>{let r=typeof n=="string"&&o.startsWith("text/csv")?"\uFEFF":"",d=typeof n=="string"?new Blob([r+n],{type:o}):n,i=URL.createObjectURL(d),e=document.createElement("a");e.href=i,e.download=a,document.body.appendChild(e),e.click(),document.body.removeChild(e),URL.revokeObjectURL(i);};var u=createContext(t),y=()=>useContext(u);var F={alertNote:"Note",alertTip:"Tip",alertImportant:"Important",alertWarning:"Warning",alertCaution:"Caution",copyCode:"Copy Code",copyDiagram:"Copy diagram",copyModel:"Copy model",downloadFile:"Download file",mermaidChart:"Mermaid chart",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",downloadDiagramAsPuml:"Download diagram as PlantUML",downloadDiagramAsSmi:"Download diagram as SMILES",downloadDiagramAsJson:"Download diagram as JSON",downloadDiagramAsSource:"Download diagram source",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",diagramChart:"Diagram",diagramErrorLabel:"Diagram Error",diagramFormatSource:"Source",diagramLoading:"Loading diagram...",diagramPluginMissing:"Diagram plugin not available. Please add a matching diagram plugin to enable rendering.",diagramRenderFailed:"Failed to render diagram",showCode:"Show Code",mermaidErrorLabel:"Mermaid Error",mermaidPluginMissing:"Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.",mermaidRenderFailed:"Failed to render Mermaid chart",plantumlChart:"PlantUML chart",plantumlErrorLabel:"PlantUML Error",plantumlPluginMissing:"PlantUML plugin not available. Please add the plantuml plugin to enable diagram rendering.",plantumlRenderFailed:"Failed to render PlantUML chart",openscadErrorLabel:"OpenSCAD Error",openscadModel:"OpenSCAD model",openscadLoading:"Loading OpenSCAD engine and rendering model...",openscadPluginMissing:"OpenSCAD plugin not available. Please add the openscad plugin to enable model rendering.",openscadRenderFailed:"Failed to render model",openscadWriting:"Waiting for the model code...",downloadModel:"Download model",downloadModelAsScad:"Download model as SCAD",downloadModelAsStl:"Download model as STL",downloadModelAs3mf:"Download model as 3MF",openscadFormatScad:"SCAD",openscadFormatStl:"STL",openscadFormat3mf:"3MF",plantumlFormatSvg:"SVG",plantumlFormatPng:"PNG",plantumlFormatPuml:"PUML",smilesChart:"Chemical structure",smilesErrorLabel:"SMILES Error",smilesPluginMissing:"SMILES plugin not available. Please add the smiles plugin to enable chemical structure rendering.",smilesRenderFailed:"Failed to render SMILES structure",smilesFormatSmi:"SMI",vegaChart:"Vega chart",vegaErrorLabel:"Vega Error",vegaPluginMissing:"Vega plugin not available. Please add the vega plugin to enable chart rendering.",vegaRenderFailed:"Failed to render Vega chart",vegaFormatSvg:"SVG",vegaFormatPng:"PNG",vegaFormatJson:"JSON",zoomIn:"Zoom in",zoomOut:"Zoom out",resetView:"Reset zoom and pan",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},b=createContext(F),T=()=>useContext(b);export{t as a,S as b,v as c,D as d,u as e,y as f,F as g,b as h,T as i};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {a,f,b,i,c,g,h,e,d}from'./chunk-6TBP27CO.js';import {createContext,memo,useContext,useMemo,lazy,isValidElement,useLayoutEffect,useId,useRef,useEffect,useDeferredValue,useState,createElement,useCallback,Suspense,cloneElement}from'react';import {harden}from'rehype-harden';import Uo from'rehype-raw';import zs,{defaultSchema}from'rehype-sanitize';import vd from'remark-gfm';import kd from'remend';import {visitParents,SKIP as SKIP$1}from'unist-util-visit-parents';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import Oi from'remark-parse';import Hi from'remark-rehype';import {unified}from'unified';import {visit,SKIP}from'unist-util-visit';import {toText}from'hast-util-to-text';import {Lexer}from'marked';var Qs=300,ea="300px",ta=500;function St(e={}){let{immediate:t=false,debounceDelay:n=Qs,rootMargin:o=ea,idleTimeout:r=ta}=e,[s,a]=useState(false),l=useRef(null),i=useRef(null),c=useRef(null),d=useMemo(()=>f=>{let p=Date.now();return window.setTimeout(()=>{f({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-p))});},1)},[]),m=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(f,p)=>window.requestIdleCallback(f,p):d,[d]),u=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?f=>window.cancelIdleCallback(f):f=>{clearTimeout(f);},[]);return useEffect(()=>{if(t){a(true);return}let f=l.current;if(!f)return;i.current&&(clearTimeout(i.current),i.current=null),c.current&&(u(c.current),c.current=null);let p=()=>{i.current&&(clearTimeout(i.current),i.current=null),c.current&&(u(c.current),c.current=null);},h=C=>{c.current=m(k=>{k.timeRemaining()>0||k.didTimeout?(a(true),C.disconnect()):c.current=m(()=>{a(true),C.disconnect();},{timeout:r/2});},{timeout:r});},g=C=>{p(),i.current=window.setTimeout(()=>{var I,L;let k=C.takeRecords();(k.length===0||(L=(I=k.at(-1))==null?void 0:I.isIntersecting)!=null&&L)&&h(C);},n);},b=(C,k)=>{C.isIntersecting?g(k):p();},y=new IntersectionObserver(C=>{for(let k of C)b(k,y);},{rootMargin:o,threshold:0});return y.observe(f),()=>{i.current&&clearTimeout(i.current),c.current&&u(c.current),y.disconnect();}},[t,n,o,r,u,m]),{shouldRender:s,containerRef:l}}var na=320,oa=4,Xn=()=>typeof performance=="undefined"?Date.now():performance.now();function en(e){var s,a;let t=(s=e==null?void 0:e.now)!=null?s:Xn,n=(a=e==null?void 0:e.maxBacklogMs)!=null?a:na,o=0,r=0;return {now:t,beginPass(l){r=Math.min(Math.max(o,l),l+n);},mark(){return r},rewind(l){r=l;},take(l,i,c){if(l<=0)return {baseDelay:0,step:Math.max(0,i)};let d=Math.max(0,i),m=d===0?0:Math.min(d,oa),u=Math.max(r,c),f=c+n,p=u+Math.max(0,l-1)*d,h=d;if(p>f&&l>1)if(u<f){let b=f-u;h=Math.max(m,b/(l-1));}else h=m;let g=Math.max(0,Math.round(u-c));return r=u+l*h,{baseDelay:g,step:h}},commitPass(){o=r;}}}function ra(){return {current:0}}var Jn=/\s/,tn=/^\s+$/,sa=new Set(["pre","svg","math","annotation"]),aa=new Set(["svg","math","annotation"]),Qt=new Set(["img","hr"]),ia=new Set(["ul","ol","li"]),Be=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",nn=(e,t)=>{let n=t?aa:sa;return e.some(o=>Be(o)&&n.has(o.tagName))},la=e=>{for(let t=e.length-1;t>=0;t-=1){let n=e[t];if(Be(n)&&n.tagName==="li")return n}},ca=(e,t,n,o)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate-marker"]=true,e.properties.style=`--sd-marker-duration:${t}ms;--sd-marker-delay:${n}ms;--sd-marker-easing:${o}`;},Yn=e=>{for(let t of e.children)if(Be(t)){if(t.tagName==="input")return t;if(ia.has(t.tagName))continue;let n=Yn(t);if(n)return n}},Qn=(e,t,n,o)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate"]=true;let r=typeof e.properties.style=="string"?`${e.properties.style};`:"";e.properties.style=`${r}--sd-animation:sd-${t.animation};--sd-duration:${n}ms;--sd-easing:${t.easing};--sd-delay:${o}ms`;},da=(e,t,n,o)=>{let r=Yn(e);r&&Qn(r,t,n,o);},eo=e=>{var t;for(let n=e.length-1;n>=0;n-=1){let o=e[n];if(Be(o)){if((t=o.properties)!=null&&t["data-sd-animated"])break;o.properties={...o.properties,"data-sd-animated":true};}}},to=e=>{let t=[],n="",o=false;for(let r of e){let s=Jn.test(r);if(s!==o&&n){if(s){n+=r,o=true;continue}t.push(n),n="";}n+=r,o=s;}return n&&t.push(n),t},no=e=>{let t=[],n="";for(let o of e)Jn.test(o)?t.length>0&&!tn.test(t.at(-1))?t[t.length-1]+=o:n+=o:(n&&(t.push(n),n=""),t.push(o));return n&&(t.length>0?t[t.length-1]+=n:t.push(n)),t},ma=(e,t,n,o,r,s)=>{let a=`--sd-animation:sd-${t};--sd-duration:${r?0:n}ms;--sd-easing:${o}`;return s&&(a+=`;--sd-delay:${Math.round(s)}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:a},children:[{type:"text",value:e}]}},ua=(e,t,n,o)=>{let r=0,s=0;return visitParents(e,a=>a.type==="text"||Be(a)&&Qt.has(a.tagName),(a,l)=>{if(nn(l,n.animateCodeBlocks))return SKIP$1;if(Be(a)&&Qt.has(a.tagName)){o>0&&s<o||(r+=1),s+=1;return}let i=a.value;if(!i.trim()){s+=i.length;return}let c=t.sep==="char"?no(i):to(i);for(let d of c){let m=s;s+=d.length,!tn.test(d)&&(o>0&&m<o||(r+=1));}}),r},pa=(e,t,n,o,r,s)=>{if(nn(t,o.animateCodeBlocks))return;let a=o.prevContentLength,l=r.count;r.count+=1;let i=a>0&&l<a,c=i?0:s.baseDelay+r.newIndex++*s.step;Qn(e,n,i?0:n.duration,c),eo(t);},fa=(e,t,n,o,r,s)=>{var b;let a=t.at(-1);if(!(a&&"children"in a))return;if(nn(t,o.animateCodeBlocks))return SKIP$1;let l=a,i=l.children.indexOf(e);if(i===-1)return;let c=e.value;if(!c.trim()){r.count+=c.length;return}let d=n.sep==="char"?no(c):to(c),m=o.prevContentLength,u=false,f=la(t),p=!!(f&&!((b=f.properties)!=null&&b["data-sd-animate-marker"])),h=false,g=d.map(y=>{let C=r.count;if(r.count+=y.length,tn.test(y))return {type:"text",value:y};let k=m>0&&C<m,S=k?0:s.baseDelay+r.newIndex++*s.step;if(f&&p&&!h){let I=k?0:n.duration;ca(f,I,S,n.easing),da(f,n,I,S),h=true;}return u=true,ma(y,n.animation,n.duration,n.easing,k,S)});return u&&eo(t),l.children.splice(i,1,...g),i+g.length},ga=0;function Tt(e){var s,a,l,i,c;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",duration:(a=e==null?void 0:e.duration)!=null?a:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(c=e==null?void 0:e.stagger)!=null?c:40,timeline:e==null?void 0:e.timeline},n={animateCodeBlocks:false,committedCharCount:0,prevContentLength:0,lastRenderCharCount:0,pendingMark:null},o=ga++,r=()=>d=>{var h;let m={count:0,newIndex:0};n.prevContentLength=n.committedCharCount;let u=t.timeline,f=(h=u==null?void 0:u.now())!=null?h:Xn();u&&(n.pendingMark===null?n.pendingMark=u.mark():u.rewind(n.pendingMark));let p=u?u.take(ua(d,t,n,n.prevContentLength),t.stagger,f):{baseDelay:0,step:t.stagger};visitParents(d,g=>g.type==="text"||Be(g)&&Qt.has(g.tagName),(g,b)=>{if(g.type==="text")return fa(g,b,t,n,m,p);pa(g,b,t,n,m,p);}),n.lastRenderCharCount=m.count,n.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${o}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(d){n.animateCodeBlocks=d;},setPrevContentLength(d){n.committedCharCount=d,n.prevContentLength=d;},getLastRenderCharCount(){return n.lastRenderCharCount},commit(){n.committedCharCount=n.lastRenderCharCount,n.pendingMark=null;}}}Tt();var on=createContext(false),Ye=()=>useContext(on);function oo(e){let t=[],n=[],o=0;return r=>{let s=new Map;for(let i=0;i<t.length;i+=1){let c=t[i],d=n[i];c!==void 0&&d!==void 0&&!s.has(c)&&s.set(c,d);}let a=new Set,l=r.map((i,c)=>{let d=t[c],m=n[c];if(d!==void 0&&m!==void 0&&!a.has(m)&&(d===i||i.startsWith(d)))return a.add(m),m;let u=s.get(i);if(u!==void 0&&!a.has(u))return a.add(u),u;let f=`${e}-${o}`;return o+=1,a.add(f),f});return t=r,n=l,l}}var Qe=({scrollRef:e,ref:t,...n})=>jsx("div",{ref:e,...n});var xa=8,va=e=>e.scrollHeight-e.scrollTop-e.clientHeight<xa,io=e=>{var n,o;let t=(o=(n=e.touches[0])!=null?n:e.changedTouches[0])!=null?o:null;return typeof(t==null?void 0:t.clientY)=="number"?t.clientY:null},Et=({enabled:e,isAnimating:t,content:n})=>{let[o,r]=useState(null),s=useRef(true),a=useRef(0),l=useCallback(c=>{r(d=>d===c?d:c);},[]),i=useCallback(c=>{t&&s.current&&(c.scrollTo({top:c.scrollHeight,behavior:"instant"}),a.current=c.scrollTop);},[t]);return useEffect(()=>{t||(s.current=true);},[t]),useEffect(()=>{if(!(e&&o))return;a.current=o.scrollTop;let c=()=>{s.current=false;},d=g=>{g.deltaY<0&&c();},m=null,u=g=>{m=io(g);},f=g=>{if(m===null)return;let b=io(g);if(b===null)return;let y=b-m;Math.abs(y)<=3||(y>0&&c(),m=b);},p=()=>{m=null;},h=()=>{let g=o.scrollTop<a.current;if(a.current=o.scrollTop,g){c();return}va(o)&&(s.current=true);};return o.addEventListener("wheel",d,{capture:true,passive:true}),o.addEventListener("touchstart",u,{passive:true}),o.addEventListener("touchmove",f,{passive:true}),o.addEventListener("touchend",p,{passive:true}),o.addEventListener("touchcancel",p,{passive:true}),o.addEventListener("scroll",h,{passive:true}),()=>{o.removeEventListener("wheel",d,{capture:true}),o.removeEventListener("touchstart",u),o.removeEventListener("touchmove",f),o.removeEventListener("touchend",p),o.removeEventListener("touchcancel",p),o.removeEventListener("scroll",h);}},[e,o]),useLayoutEffect(()=>{if(!(e&&o)||(i(o),typeof ResizeObserver=="undefined"))return;let c=new ResizeObserver(()=>{i(o);});c.observe(o);for(let d of o.children)c.observe(d);return ()=>{c.disconnect();}},[n,o,e,i]),l};var Sa=a("block"),Ta=a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),Ea=e=>{let t={};for(let n of e.split(";")){let o=n.indexOf(":");if(o>0){let r=n.slice(0,o).trim(),s=n.slice(o+1).trim();r&&s&&(t[r]=s);}}return t},lo=memo(({children:e,result:t,language:n,className:o,maxHeight:r,startLine:s,lineNumbers:a=true,...l})=>{let i=f(),{isAnimating:c,scrollable:d}=useContext(M),m=d!=null?d:Qe,u=b(r),f$1=Et({content:t,enabled:!!u,isAnimating:c}),p=useMemo(()=>i(Ta),[i]),h=useMemo(()=>i(Sa),[i]),g=useMemo(()=>{let b={};return t.bg&&(b["--sdm-bg"]=t.bg),t.fg&&(b["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(b,Ea(t.rootStyle)),b},[t.bg,t.fg,t.rootStyle]);return jsx(m,{className:i(o,u?"overflow-x-auto overflow-y-auto":"overflow-x-auto","rounded-md border border-border bg-background p-4 text-sm"),"data-language":n,"data-streamdown":"code-block-body",scrollRef:f$1,style:u?{maxHeight:u}:void 0,...l,children:jsx("pre",{className:i(o,"bg-[var(--sdm-bg,inherit)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]"),style:g,children:jsx("code",{className:a?i("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&s&&s>1?{counterReset:`line ${s-1}`}:void 0,children:t.tokens.map((b,y)=>jsx("span",{className:a?p:h,children:b.length===0||b.length===1&&b[0].content===""?`
|
|
3
|
+
`:b.map((C,k)=>{let S={},I=!!C.bgColor;if(C.color&&(S["--sdm-c"]=C.color),C.bgColor&&(S["--sdm-tbg"]=C.bgColor),C.htmlStyle)for(let[L,P]of Object.entries(C.htmlStyle))L==="color"?S["--sdm-c"]=P:L==="background-color"?(S["--sdm-tbg"]=P,I=true):S[L]=P;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",I&&"bg-[var(--sdm-tbg)]",I&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:S,...C.htmlAttrs,children:C.content},k)})},y))})})})});var sn=({className:e,language:t,style:n,isIncomplete:o,...r})=>{let s=f();return jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":o||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...r})};var an=createContext({code:""}),Rt=()=>useContext(an);var ln=({language:e})=>{let t=f();return jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var Aa=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
|
+
`;)t--;return e.slice(0,t)},Oa=lazy(()=>import('./highlighted-body-N5O52WFD.js').then(e=>({default:e.HighlightedCodeBlockBody}))),cn=({code:e,language:t,className:n,children:o,isIncomplete:r=false,startLine:s,lineNumbers:a,...l})=>{let i=f(),{codeBlockMaxHeight:c}=useContext(M),d=useMemo(()=>Aa(e),[e]),m=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
|
|
5
|
+
`).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]);return jsx(an.Provider,{value:{code:e},children:jsxs(sn,{dir:"ltr",isIncomplete:r,language:t,children:[jsx(ln,{language:t}),o?jsx("div",{className:i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("div",{className:i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:o})}):null,jsx(Suspense,{fallback:jsx(lo,{className:n,language:t,lineNumbers:a,maxHeight:c,result:m,startLine:s,...l}),children:jsx(Oa,{className:n,code:d,language:t,lineNumbers:a,maxHeight:c,raw:m,startLine:s,...l})})]})})};var uo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),po=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),fo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),go=e=>jsxs("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),bo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),ho=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),yo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),Co=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),wo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),xo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var tt={CheckIcon:uo,CopyIcon:po,DownloadIcon:fo,ExternalLinkIcon:Co,Loader2Icon:go,Maximize2Icon:bo,RotateCcwIcon:ho,XIcon:yo,ZoomInIcon:wo,ZoomOutIcon:xo},ko=createContext(tt),Fa=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let n=Object.keys(e),o=Object.keys(t);return n.length!==o.length?false:n.every(r=>e[r]===t[r])},dn=({icons:e,children:t})=>{let n=useRef(e),o=useRef(e?{...tt,...e}:tt);Fa(n.current,e)||(n.current=e,o.current=e?{...tt,...e}:tt);let r=o.current;return jsx(ko.Provider,{value:r,children:t})},V=()=>useContext(ko);var nt=({onCopy:e,onError:t,timeout:n=2e3,children:o,className:r,code:s,label:a,...l})=>{let i$1=f(),[c,d]=useState(false),m=useRef(0),{code:u}=Rt(),{isAnimating:f$1}=useContext(M),p=i(),h=s!=null?s:u,g=a!=null?a:p.copyCode,b=async()=>{var k;if(typeof window=="undefined"||!((k=navigator==null?void 0:navigator.clipboard)!=null&&k.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{c||(await navigator.clipboard.writeText(h),d(!0),e==null||e(),m.current=window.setTimeout(()=>d(!1),n));}catch(S){t==null||t(S);}};useEffect(()=>()=>{window.clearTimeout(m.current);},[]);let y=V(),C=c?y.CheckIcon:y.CopyIcon;return jsxs(Fragment,{children:[jsx("button",{"aria-label":g,className:i$1("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:f$1,onClick:b,title:g,type:"button",...l,children:o!=null?o:jsx(C,{"aria-hidden":"true",size:14})}),c&&jsx("output",{"aria-live":"polite",className:"sr-only",children:p.copied})]})};var It=e=>typeof e=="object"&&e!==null,Po=(e,t)=>{var n;if(typeof e!="boolean")return t!=="diagrams"&&t in e?e[t]:(n=e.diagrams)==null?void 0:n[t]},ye=(e,t,n)=>{if(typeof e=="boolean")return n;let o=Po(e,t);if(!It(o))return n;let r=o.download;return !It(r)||typeof r.filename!="string"?n:r.filename||n};function Ke(e,t){if(typeof e=="boolean")return {};let n=Po(e,t);if(!It(n))return {};let o=n.copy;return It(o)?{onCopy:typeof o.onCopy=="function"?o.onCopy:void 0,onError:typeof o.onError=="function"?o.onError:void 0}:{}}var So={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",smiles:"smi",smi:"smi",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",vega:"vg.json","vega-lite":"vl.json",vegalite:"vl.json",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",\u6587\u8A00:"wy"},un=({onDownload:e,onError:t,language:n,children:o,className:r,code:s,...a})=>{let l=f(),{code:i$1}=Rt(),{isAnimating:c,controls:d$1}=useContext(M),m=i(),u=V(),f$1=s!=null?s:i$1,p=n&&n in So?So[n]:"txt",h=`${ye(d$1,"code","file")}.${p}`,g="text/plain",b=()=>{try{d(h,f$1,g),e==null||e();}catch(y){t==null||t(y);}};return jsx("button",{"aria-label":m.downloadFile,className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:c,onClick:b,title:m.downloadFile,type:"button",...a,children:o!=null?o:jsx(u.DownloadIcon,{size:14})})};var ot=()=>{let{Loader2Icon:e}=V(),t=f();return jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:jsx(e,{className:t("size-4 animate-spin")})})]})};var Lt=(e,t)=>{var n;return t==="mermaid"?e.mermaid:t==="plantuml"?e.plantuml:t==="vega"?e.vega:t==="smiles"?e.smiles:(n=e.diagrams)==null?void 0:n[t]};var Eo=(e,t)=>{var n;return typeof e=="boolean"?e:t!=="diagrams"&&t in e?e[t]:(n=e.diagrams)==null?void 0:n[t]},Ro=(e,t)=>typeof e=="boolean"?e:Eo(e,t)!==false,Te=(e,t,n)=>{if(typeof e=="boolean")return e;let o=Eo(e,t);return o===false?false:o===true||o===void 0?true:typeof o=="object"&&o!==null?o[n]!==false:true};var Xa=/(<svg\b)/,Mo=/<svg\b[^>]*>/i,Ja=/\bviewBox=(['"])(.*?)\1/i,Ya=/\swidth=(['"]).*?\1/gi,Qa=/\sheight=(['"]).*?\1/gi,Io=/\sstyle=(['"])(.*?)\1/i,Lo=/^<svg/i,ei=/^width\s*:/i,ti=/^height\s*:/i,ni=/^max-width\s*:/i,oi=/[\s,]+/,ri=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(Xa,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),No=e=>{if(typeof DOMParser=="undefined"||typeof XMLSerializer=="undefined")return e;let n=new DOMParser().parseFromString(e,"text/html").querySelector("svg");return n?new XMLSerializer().serializeToString(n):e},fn=e=>{let t=e.match(Mo);if(!t)return null;let o=t[0].match(Ja),r=o==null?void 0:o[2];if(!r)return null;let s=r.trim().split(oi).map(i=>Number.parseFloat(i));if(s.length<4||s.slice(0,4).some(Number.isNaN))return null;let a=s[2],l=s[3];return a>0&&l>0?{height:l,width:a}:null},Do=e=>{let t=e.match(Mo);if(!t)return e;try{let n=t[0],o=fn(e);if(!o)return e;let{width:r,height:s}=o,a=n.replace(Ya,"").replace(Qa,""),l=a.match(Io),i=`width:${r}px;height:${s}px;max-width:none;`;if(l){let c=l[1],m=l[2].split(";").map(f=>f.trim()).filter(Boolean).filter(f=>!(ei.test(f)||ti.test(f)||ni.test(f))).join(";"),u=`${i}${m?`${m};`:""}`;a=a.replace(Io,` style=${c}${u}${c}`);}else a=a.replace(Lo,`<svg style="${i}"`);return a=a.replace(Lo,`<svg width="${r}" height="${s}"`),e.replace(n,a)}catch(n){return e}},Ao=(e,t)=>{var o;let n=(o=void 0)!=null?o:5;return new Promise((r,s)=>{let a=ri(e),l="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let c=document.createElement("canvas"),d=i.width*n,m=i.height*n;c.width=d,c.height=m;let u=c.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(i,0,0,d,m),c.toBlob(f=>{if(!f){s(new Error("Failed to create PNG blob"));return}r(f);},"image/png");},i.onerror=()=>s(new Error("Failed to load SVG image")),i.src=l;})};var si={chart:"diagramChart",error:"diagramErrorLabel",missing:"diagramPluginMissing",failed:"diagramRenderFailed"},ai={mermaid:{chart:"mermaidChart",error:"mermaidErrorLabel",missing:"mermaidPluginMissing",failed:"mermaidRenderFailed"},plantuml:{chart:"plantumlChart",error:"plantumlErrorLabel",missing:"plantumlPluginMissing",failed:"plantumlRenderFailed"},vega:{chart:"vegaChart",error:"vegaErrorLabel",missing:"vegaPluginMissing",failed:"vegaRenderFailed"},smiles:{chart:"smilesChart",error:"smilesErrorLabel",missing:"smilesPluginMissing",failed:"smilesRenderFailed"}},ii={mermaid:"mermaidFormatMmd",plantuml:"plantumlFormatPuml",vega:"vegaFormatJson",smiles:"smilesFormatSmi"},li={mermaid:"downloadDiagramAsMmd",plantuml:"downloadDiagramAsPuml",vega:"downloadDiagramAsJson",smiles:"downloadDiagramAsSmi"},rt=(e,t,n)=>{var r;let o=(r=ai[t])!=null?r:si;return e[o[n]]},Oo=(e,t,n)=>{let o=ii[t];return o?e[o]:n.toUpperCase()||e.diagramFormatSource},gn=(e,t)=>{let n=li[t];return n?e[n]:e.downloadDiagramAsSource},Ho=e=>e==="mermaid"?"Mermaid plugin not available":e==="plantuml"?"PlantUML plugin not available":e==="vega"?"Vega plugin not available":e==="smiles"?"SMILES plugin not available":"Diagram plugin not available";var Mt=(e,t)=>e===void 0&&t===void 0?void 0:{...typeof e=="object"&&e!==null?e:{},language:t};var Nt=({chart:e,children:t,className:n,config:o,language:r,name:s,onDownload:a,onError:l,plugin:i$1,sourceExtension:c})=>{var L;let d$1=f(),[m,u]=useState(false),f$1=useRef(null),{isAnimating:p,controls:h}=useContext(M),g=V(),b=i(),y=(L=c!=null?c:i$1==null?void 0:i$1.sourceExtension)!=null?L:"txt",C=ye(h,s,"diagram"),k=P=>{u(false),a==null||a(P);},S=async P=>{if(!i$1){l==null||l(new Error(Ho(s)));return}let{svg:A}=await i$1.render(e,Mt(o,r));if(!A){l==null||l(new Error("SVG not found. Please wait for the diagram to render."));return}let z=No(A);if(P==="svg"){d(`${C}.svg`,z,"image/svg+xml"),k(P);return}let j=await Ao(z);d(`${C}.png`,j,"image/png"),k(P);},I=async P=>{try{if(P==="source"){d(`${C}.${y}`,e,"text/plain"),k(P);return}await S(P);}catch(A){l==null||l(A);}};return useEffect(()=>{let P=A=>{let z=A.composedPath();f$1.current&&!z.includes(f$1.current)&&u(false);};return document.addEventListener("mousedown",P),()=>{document.removeEventListener("mousedown",P);}},[]),jsxs("div",{className:d$1("relative"),ref:f$1,children:[jsx("button",{"aria-label":b.downloadDiagram,className:d$1("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:p,onClick:()=>u(!m),title:b.downloadDiagram,type:"button",children:t!=null?t:jsx(g.DownloadIcon,{"aria-hidden":"true",size:14})}),m?jsxs("div",{className:d$1("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":b.downloadDiagramAsSvg,className:d$1("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>I("svg"),title:b.downloadDiagramAsSvg,type:"button",children:b.mermaidFormatSvg}),jsx("button",{"aria-label":b.downloadDiagramAsPng,className:d$1("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>I("png"),title:b.downloadDiagramAsPng,type:"button",children:b.mermaidFormatPng}),jsx("button",{"aria-label":gn(b,s),className:d$1("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>I("source"),title:gn(b,s),type:"button",children:Oo(b,s,y)})]}):null]})};var Ee=e=>{let t=typeof e=="function"?e():e;return t!=null?t:document.body};var at=0,me=()=>{at+=1,at===1&&(document.body.style.overflow="hidden");},ue=()=>{at=Math.max(0,at-1),at===0&&(document.body.style.overflow="");};var Fo=({DiagramComponent:e,chart:t,className:n,config:o,language:r,name:s,onExit:a,onFullscreen:l,plugin:i$1,sourceExtension:c,...d})=>{let{Maximize2Icon:m,XIcon:u}=V(),f$1=f(),[p,h]=useState(false),{isAnimating:g,controls:b,portal:y}=useContext(M),C=i(),k=Te(b,s,"panZoom"),S=Te(b,s,"download"),I=()=>{h(!p);};return useEffect(()=>{if(p){me();let L=P=>{P.key==="Escape"&&h(false);};return document.addEventListener("keydown",L),()=>{document.removeEventListener("keydown",L),ue();}}},[p]),useEffect(()=>{p?l==null||l():a&&a();},[p,l,a]),jsxs(Fragment,{children:[jsx("button",{className:f$1("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:g,onClick:I,title:C.viewFullscreen,type:"button",...d,"aria-label":C.viewFullscreen,children:jsx(m,{"aria-hidden":"true",size:14})}),p?createPortal(jsxs("div",{"aria-label":C.viewFullscreen,"aria-modal":"true",className:f$1("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":`${s}-fullscreen`,onClick:I,onKeyDown:L=>{L.key==="Escape"&&I();},role:"dialog",children:[jsxs("div",{className:f$1("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:L=>L.stopPropagation(),onKeyDown:L=>L.stopPropagation(),role:"presentation",children:[S?jsx(Nt,{chart:t,config:o,language:r,name:s,plugin:i$1,sourceExtension:c}):null,jsx("button",{"aria-label":C.exitFullscreen,className:f$1("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:I,title:C.exitFullscreen,type:"button",children:jsx(u,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:f$1("flex size-full items-center justify-center p-4"),onClick:L=>L.stopPropagation(),onKeyDown:L=>L.stopPropagation(),role:"presentation",children:e?jsx(e,{chart:t,className:f$1("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:o,fullscreen:true,language:r,showControls:k}):jsx(Vo,{chart:t,className:f$1("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:o,fallbackName:s,fullscreen:true,language:r,plugin:i$1,showControls:k})})]}),Ee(y)):null]})};var yi=["github-light","github-dark"],Ci={enabled:true},wi={codeBlockMaxHeight:400,shikiTheme:yi,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,openscad:void 0,plantuml:void 0,smiles:void 0,vega:void 0,diagrams:void 0,linkSafety:Ci,portal:void 0,tableMaxHeight:300},M=createContext(wi);var Pi=/\.[^/.]+$/,jo=(e,t)=>{if(typeof e=="boolean")return e;let n=e.image;return n===false?false:n===true||n===void 0?true:n[t]!==false},zo=({node:e,className:t,src:n,alt:o,onLoad:r,onError:s,onClick:a,...l})=>{let{DownloadIcon:i$1,XIcon:c}=V(),d$1=f(),m=useRef(null),[u,f$1]=useState(false),[p,h]=useState(false),[g,b]=useState(false),{controls:y}=useContext(M),C=i(),k=jo(y,"download"),S=jo(y,"fullscreen"),I=l.width!=null||l.height!=null,L=k&&(u||I)&&!p,P=p&&!I,A=S&&!!n&&!p&&u;useEffect(()=>{let T=m.current;if(T!=null&&T.complete){let R=T.naturalWidth>0;f$1(R),h(!R);}},[]),useEffect(()=>{if(!g)return;me();let T=R=>{R.key==="Escape"&&b(false);};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T),ue();}},[g]);let z=useCallback(T=>{f$1(true),h(false),r==null||r(T);},[r]),j=useCallback(T=>{f$1(false),h(true),s==null||s(T);},[s]),E=useCallback(()=>{A&&b(true);},[A]),K=useCallback(()=>{b(false);},[]),oe=useCallback(T=>{a==null||a(T),!T.defaultPrevented&&E();},[a,E]),Q=async T=>{if(T.stopPropagation(),!!n)try{let F=await(await fetch(n)).blob(),G=new URL(n,window.location.origin).pathname.split("/").pop()||"",be=G.split(".").pop(),ke=G.includes(".")&&be!==void 0&&be.length<=4,ie="";if(ke)ie=G;else {let re=F.type,ne="png";re.includes("jpeg")||re.includes("jpg")?ne="jpg":re.includes("png")?ne="png":re.includes("svg")?ne="svg":re.includes("gif")?ne="gif":re.includes("webp")&&(ne="webp"),ie=`${(o||G||"image").replace(Pi,"")}.${ne}`;}d(ie,F,F.type);}catch(R){window.open(n,"_blank");}};return n?n==="streamdown:incomplete-image"?jsx("div",{className:d$1("group relative my-4 inline-block"),"data-incomplete":"true","data-streamdown":"image-wrapper",children:jsx("div",{className:d$1("h-24 w-48 animate-pulse rounded-lg bg-muted"),"data-streamdown":"image-placeholder"})}):jsxs(Fragment,{children:[jsxs("div",{className:d$1("group/image not-prose relative my-2 block max-w-full"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:o,className:d$1("m-0 block h-auto max-w-full rounded-lg",A&&"cursor-zoom-in",P&&"hidden",t),"data-streamdown":"image",onClick:oe,onError:j,onLoad:z,ref:m,src:n,...l}),P&&jsx("span",{className:d$1("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:C.imageNotAvailable}),L&&jsx("button",{"aria-label":C.downloadImage,className:d$1("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 focus-visible:opacity-100 group-hover/image:opacity-100"),onClick:Q,title:C.downloadImage,type:"button",children:jsx(i$1,{size:14})})]}),g?createPortal(jsxs("div",{className:d$1("fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4"),"data-streamdown":"image-lightbox",onClick:K,onKeyDown:T=>{T.key==="Escape"&&K();},role:"button",tabIndex:0,children:[jsx("button",{"aria-label":C.exitFullscreen,className:d$1("absolute top-4 right-4 z-10 rounded-md p-2 text-white/80 transition-colors hover:bg-white/10 hover:text-white"),onClick:K,title:C.exitFullscreen,type:"button",children:jsx(c,{size:20})}),jsx("div",{onClick:T=>T.stopPropagation(),onKeyDown:T=>T.stopPropagation(),role:"presentation",children:jsx("img",{alt:o,className:d$1("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:n})})]}),document.body):null]}):null};var Zo=({url:e,isOpen:t,onClose:n,onConfirm:o})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=V(),i$1=f(),[c,d]=useState(false),m=i(),{portal:u}=useContext(M),f$1=useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(g){}},[e]),p=useCallback(()=>{o(),n();},[o,n]);if(useEffect(()=>{if(t){me();let g=b=>{b.key==="Escape"&&n();};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),ue();}}},[t,n]),!t||typeof document=="undefined")return null;let h=jsx("div",{className:i$1("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:n,onKeyDown:g=>{g.key==="Escape"&&n();},role:"button",tabIndex:0,children:jsxs("div",{className:i$1("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:[jsx("button",{"aria-label":m.close,className:i$1("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:n,title:m.close,type:"button",children:jsx(l,{size:16})}),jsxs("div",{className:i$1("flex flex-col gap-2"),children:[jsxs("div",{className:i$1("flex items-center gap-2 font-semibold text-lg"),children:[jsx(a,{size:20}),jsx("span",{children:m.openExternalLink})]}),jsx("p",{className:i$1("text-muted-foreground text-sm"),children:m.externalLinkWarning})]}),jsx("div",{className:i$1("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:i$1("flex gap-2"),children:[jsx("button",{className:i$1("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:f$1,type:"button",children:c?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:m.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:m.copyLink})]})}),jsxs("button",{className:i$1("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:p,type:"button",children:[jsx(a,{size:14}),jsx("span",{children:m.openLink})]})]})]})});return createPortal(h,Ee(u))};var qo=()=>e=>{visit(e,"html",(n,o,r)=>{!r||typeof o!="number"||(r.children[o]={type:"text",value:n.value});});};var Go=[],Xo={allowDangerousHtml:true},Dt=new WeakMap,wn=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(o||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return "";let u="";for(let f=0;f<m.length;f+=1){let p=m[f];if(f>0&&(u+=","),Array.isArray(p)){let[h,g]=p;if(typeof h=="function"){let b=Dt.get(h);b||(b=h.name,Dt.set(h,b)),u+=b;}else u+=String(h);u+=":",u+=JSON.stringify(g);}else if(typeof p=="function"){let h=Dt.get(p);h||(h=p.name,Dt.set(p,h)),u+=h;}else u+=String(p);}return u},l=a(o),i=a(r),c=s?JSON.stringify(s):"",d=`${i}::${l}::${c}`;return this.keyCache.set(t,d),d}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(o,n);}clear(){this.cache.clear();}},Jo=new wn,lt=e=>{let t=Vi(e),n=e.children||"",o=t.runSync(t.parse(n),n);return Ki(o,e)},Vi=e=>{let t=Jo.get(e);if(t)return t;let n=$i(e);return Jo.set(e,n),n},Fi=e=>e.some(t=>Array.isArray(t)?t[0]===Uo:t===Uo),$i=e=>{let t=e.rehypePlugins||Go,n=e.remarkPlugins||Go,o=Fi(t)?n:[...n,qo],r=e.remarkRehypeOptions?{...Xo,...e.remarkRehypeOptions}:Xo;return unified().use(Oi).use(o).use(Hi,r).use(t)},Yo=e=>e,ji=(e,t,n,o)=>{n?e.children.splice(t,1):e.children[t]={type:"text",value:o};},zi=(e,t)=>{var n;for(let o in urlAttributes)if(Object.hasOwn(urlAttributes,o)&&Object.hasOwn(e.properties,o)){let r=e.properties[o],s=urlAttributes[o];(s===null||s.includes(e.tagName))&&(e.properties[o]=(n=t(String(r||""),o,e))!=null?n:void 0);}},Wi=(e,t,n,o,r,s)=>{let a=false;return o?a=!o.includes(e.tagName):r&&(a=r.includes(e.tagName)),!a&&s&&typeof t=="number"&&(a=!s(e,t,n)),a},Ki=(e,t)=>{let{allowElement:n,allowedElements:o,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:l}=t;if(n||o||r||s||l){let c=l||Yo;visit(e,(d,m,u)=>{if(d.type==="raw"&&u&&typeof m=="number")return ji(u,m,s,d.value),m;if(d.type==="element"&&(zi(d,c),Wi(d,m,u,o,r,n)&&u&&typeof m=="number"))return a&&d.children?u.children.splice(m,1,...d.children):u.children.splice(m,1),m});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var Qo=/[(){}[\]]/,Zi=/[\s;]/,qi=/^[\w-]+$/,Ui=/:::[\w-]+\s*$/,Gi=/^[/\\]/,Xi=/[/\\]$/,Ji=/("[^"]*")/,Yi=[["((","))"],["))","(("],["{{","}}"],["[","]"],["(",")"],[")","("]],ct=e=>`"${e.replace(/"/g,"#quot;")}"`,Qi=e=>e.length>=2&&e.startsWith('"')&&e.endsWith('"'),el=e=>{var o,r,s,a;let t=e.split(`
|
|
6
|
+
`),n=0;if(((o=t[n])==null?void 0:o.trim())==="---"){for(n+=1;n<t.length&&((r=t[n])==null?void 0:r.trim())!=="---";)n+=1;n+=1;}for(;n<t.length;){let l=(a=(s=t[n])==null?void 0:s.trim())!=null?a:"";if(l&&!l.startsWith("%%")){let i=l.split(Zi,1)[0];return i==="mindmap"?"mindmap":i==="flowchart"||i==="graph"?"flowchart":null}n+=1;}return null},tl=e=>{for(let[t,n]of Yi){let o=e.indexOf(t);if(o===-1||!e.endsWith(n))continue;let r=e.slice(0,o);if(r&&!qi.test(r))continue;let s=e.slice(o+t.length,e.length-n.length);if(!(s.includes(n)&&n!==t))return {id:r,open:t,close:n,inner:s}}return null},nl=e=>{let t=e.length-e.trimStart().length,n=e.slice(0,t),o=e.trim();if(!o||o.startsWith("%%")||o.startsWith("::icon"))return e;let r=tl(o);if(r)return !Qi(r.inner)&&(Qo.test(r.inner)||r.inner.includes('"'))?`${n}${r.id}${r.open}${ct(r.inner)}${r.close}`:e;if(Qo.test(o)){let s=o.replace(Ui,"").trimEnd();return `${n}[${ct(s)}]`}return e},ol=e=>{let t=e.split(`
|
|
7
|
+
`),n=false;return t.map(o=>n?nl(o):(o.trim()&&(n=true),o)).join(`
|
|
8
|
+
`)},rl=e=>e.startsWith("(")&&e.endsWith(")")||Gi.test(e)||Xi.test(e),xn=(e,t)=>e.split(Ji).map((n,o)=>o%2===0?t(n):n).join(""),sl=e=>{if(e.trim().startsWith("%%"))return e;let t=xn(e,n=>n.replace(/\[([^[\]"]*[(){}][^[\]"]*)\]/g,(o,r)=>rl(r)?o:`[${ct(r)}]`));return t=xn(t,n=>n.replace(/\{([^{}"]*[()[\]][^{}"]*)\}/g,(o,r)=>`{${ct(r)}}`)),t=xn(t,n=>n.replace(/\|([^|"]*[(){}[\]][^|"]*)\|/g,(o,r)=>`|${ct(r)}|`)),t},al=e=>e.split(`
|
|
9
|
+
`).map(sl).join(`
|
|
10
|
+
`),er=e=>{let t=el(e);if(!t)return null;let n=t==="mindmap"?ol(e):al(e);return n===e?null:n};var il=()=>{if(typeof document=="undefined")return false;let e=document.documentElement;return e.classList.contains("dark")||e.dataset.theme==="dark"||e.dataset.colorMode==="dark"},ll=(e,t)=>Array.isArray(t)?t.includes(e):t===e,cl=e=>"getMermaid"in e&&typeof e.getMermaid=="function",dl=e=>"getPlantUml"in e&&typeof e.getPlantUml=="function",ml=e=>"getVega"in e&&typeof e.getVega=="function",ul=e=>"getSmiles"in e&&typeof e.getSmiles=="function";var pl=e=>{let t=e.split("").reduce((n,o)=>(n<<5)-n+o.charCodeAt(0)|0,0);return `mermaid-${Math.abs(t)}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`},fl=async(e,t,n)=>{try{return await e.render(t,n)}catch(o){let r=er(n);if(!r)throw o;try{return await e.render(`${t}-autofix`,r)}catch(s){throw o}}},gl=e=>{var t,n;return cl(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:"mmd",render:async(o,r)=>{let s=e.getMermaid(r);return await fl(s,pl(o),o)}}:dl(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:"puml",render:async(o,r)=>{var l;let s=r,a=(l=s==null?void 0:s.dark)!=null?l:il();return await e.getPlantUml(s).render(o,{...s,dark:a})}}:ml(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:(t=e.sourceExtension)!=null?t:"json",render:(o,r)=>e.getVega(r).render(o,r)}:ul(e)?{name:e.name,type:"diagram",language:e.language,sourceExtension:(n=e.sourceExtension)!=null?n:"smi",render:(o,r)=>e.getSmiles(r).render(o,r)}:e},tr=e=>{var n;if(!e)return [];let t=[];return e.mermaid&&t.push(e.mermaid),e.plantuml&&t.push(e.plantuml),e.vega&&t.push(e.vega),e.smiles&&t.push(e.smiles),[...t,...(n=e.diagrams)!=null?n:[]].map(gl)},nr=(e,t)=>{var n;return (n=e.find(o=>ll(t,o.language)))!=null?n:null};var At=createContext(null),Ot=()=>useContext(At),hp=()=>{var t;let e=Ot();return (t=e==null?void 0:e.code)!=null?t:null};var Cl=()=>{let e=Ot();return useMemo(()=>tr(e),[e])},or=e=>{let t=Cl();return nr(t,e)},Ze=()=>{var t;let e=Ot();return (t=e==null?void 0:e.openscad)!=null?t:null};var rr=e=>{var n;let t=Ot();return t!=null&&t.renderers&&e&&(n=t.renderers.find(o=>Array.isArray(o.language)?o.language.includes(e):o.language===e))!=null?n:null};var ar={"3mf":"model/3mf",stl:"model/stl"},Ht=({children:e,className:t,code:n,config:o,onDownload:r,onError:s})=>{let a=f(),[l,i$1]=useState(false),[c,d$1]=useState(false),m=useRef(null),{controls:u,isAnimating:f$1}=useContext(M),p=V(),h=Ze(),g=i(),b=ye(u,"openscad","model"),y=async C=>{try{if(C==="scad"){d(`${b}.scad`,n,"text/plain"),i$1(!1),r==null||r(C);return}if(!h){s==null||s(new Error("OpenSCAD plugin not available"));return}d$1(!0);let k=h.getOpenScad(o),{data:S}=await k.render(n,{...o,format:C}),I=S.buffer.slice(S.byteOffset,S.byteOffset+S.byteLength);d(`${b}.${C}`,new Blob([I],{type:ar[C]}),ar[C]),r==null||r(C),i$1(!1);}catch(k){s==null||s(k);}finally{d$1(false);}};return useEffect(()=>{let C=k=>{let S=k.composedPath();m.current&&!S.includes(m.current)&&i$1(false);};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C);}},[]),jsxs("div",{className:a("relative"),ref:m,children:[jsx("button",{"aria-label":g.downloadModel,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:f$1||c,onClick:()=>i$1(!l),title:g.downloadModel,type:"button",children:e!=null?e:jsx(p.DownloadIcon,{"aria-hidden":"true",size:14})}),l?jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":g.downloadModelAsScad,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("scad"),title:g.downloadModelAsScad,type:"button",children:g.openscadFormatScad}),jsx("button",{"aria-label":g.downloadModelAsStl,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("stl"),title:g.downloadModelAsStl,type:"button",children:g.openscadFormatStl}),jsx("button",{"aria-label":g.downloadModelAs3mf,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("3mf"),title:g.downloadModelAs3mf,type:"button",children:g.openscadFormat3mf})]}):null]})};var El=lazy(()=>import('./viewer-URBRVFVJ.js').then(e=>({default:e.OpenScadViewer}))),lr=({className:e,code:t,config:n,fullscreen:o=false})=>{let r=f(),s=i(),[a,l]=useState(null),[i$1,c]=useState(false),[d,m]=useState(null),[u,f$1]=useState(null),[p,h]=useState(0),{openscad:g}=useContext(M),b=Ze(),y=g==null?void 0:g.errorComponent,C=Ye(),{shouldRender:k,containerRef:S}=St({immediate:o});if(useEffect(()=>{if(!k||C)return;if(!b){l(s.openscadPluginMissing);return}(async()=>{try{l(null),c(!0);let A=await b.getOpenScad(n).render(t,n);m(A),f$1(A);}catch(P){if(!(u||d)){let A=P instanceof Error?P.message:s.openscadRenderFailed;l(A);}}finally{c(false);}})();},[t,n,p,k,C,b,s]),!(k||d||u))return jsx("div",{className:r("my-4 min-h-[200px]",e),ref:S});if(C&&!d&&!u)return jsx("div",{className:r("my-4 flex justify-center p-4",e),ref:S,children:jsxs("div",{className:r("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:r("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:r("text-sm"),children:s.openscadWriting})]})});if(i$1&&!d&&!u)return jsx("div",{className:r("my-4 flex justify-center p-4",e),ref:S,children:jsxs("div",{className:r("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:r("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:r("text-sm"),children:s.openscadLoading})]})});if(a&&!d&&!u){let L=()=>h(P=>P+1);return y?jsx("div",{ref:S,children:jsx(y,{code:t,error:a,retry:L})}):jsxs("div",{className:r("rounded-md bg-red-50 p-4",e),ref:S,children:[jsxs("p",{className:r("font-mono text-red-700 text-sm"),children:[s.openscadErrorLabel,": ",a]}),jsxs("details",{className:r("mt-2"),children:[jsx("summary",{className:r("cursor-pointer text-red-600 text-xs"),children:s.showCode}),jsx("pre",{className:r("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:t})]})]})}let I=d!=null?d:u;return jsx("div",{className:r("size-full",e),"data-streamdown":"openscad",ref:S,children:jsx(Suspense,{fallback:jsx("div",{className:r("flex h-full items-center justify-center"),children:jsx("div",{className:r("h-4 w-4 animate-spin rounded-full border-current border-b-2 text-muted-foreground")})}),children:I?jsx(El,{className:e,data:I.data,format:I.format,fullscreen:o}):null})})};var dr=({code:e,config:t,onFullscreen:n,onExit:o,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=V(),i$1=f(),[c,d]=useState(false),{isAnimating:m,controls:u,portal:f$1}=useContext(M),p=i(),h=(()=>{if(typeof u=="boolean")return u;let b=u.openscad;return b===false?false:b===true||b===void 0?true:b.download!==false})(),g=()=>{d(!c);};return useEffect(()=>{if(c){me();let b=y=>{y.key==="Escape"&&d(false);};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),ue();}}},[c]),useEffect(()=>{c?n==null||n():o&&o();},[c,n,o]),jsxs(Fragment,{children:[jsx("button",{className:i$1("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:g,title:p.viewFullscreen,type:"button",...s,"aria-label":p.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),c?createPortal(jsxs("div",{"aria-label":p.viewFullscreen,"aria-modal":"true",className:i$1("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"openscad-fullscreen",onClick:g,onKeyDown:b=>{b.key==="Escape"&&g();},role:"dialog",children:[jsxs("div",{className:i$1("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:[h?jsx(Ht,{code:e,config:t}):null,jsx("button",{"aria-label":p.exitFullscreen,className:i$1("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:g,title:p.exitFullscreen,type:"button",children:jsx(l,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:i$1("flex size-full items-center justify-center p-4"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:jsx(lr,{className:i$1("size-full"),code:e,config:t,fullscreen:true})})]}),Ee(f$1)):null]})};var kn=e=>e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(kn).join(""):isValidElement(e)?kn(e.props.children):"",mr=(e,t,n)=>n!=null?n:(t?toText(t):kn(e)).replace(/\s+/g," ").trim()||void 0;function Pn(e){var n;if(e.nodeType===Node.TEXT_NODE)return (n=e.textContent)!=null?n:"";if(e.nodeType!==Node.ELEMENT_NODE)return "";let t=e;return t.tagName==="BR"?`
|
|
11
|
+
`:Array.from(t.childNodes).map(Pn).join("")}var qe=e=>{let t=[],n=[],o=e.querySelectorAll("thead th");for(let s of o)t.push(Pn(s).trim());let r=e.querySelectorAll("tbody tr");for(let s of r){let a=[],l=s.querySelectorAll("td");for(let i of l)a.push(Pn(i).trim());n.push(a);}return {headers:t,rows:n}},pt=e=>{var n;if(typeof e!="object")return ",";let t=e.table;return typeof t!="object"?",":(n=t.csvSeparator)!=null?n:","},$e=(e,t=",")=>{let n;t==="auto"?Intl.NumberFormat().format(1.1).includes(",")?n=";":n=",":n=t;let{headers:o,rows:r}=e,s=c=>{let d=false;for(let m of c)if(m===n||m==='"'||m===`
|
|
12
|
+
`||m==="\r"){d=true;break}return d?`"${c.replace(/"/g,'""')}"`:c},a=o.length>0?r.length+1:r.length,l=new Array(a),i=0;o.length>0&&(l[i]=o.map(s).join(n),i+=1);for(let c of r)l[i]=c.map(s).join(n),i+=1;return l.join(`
|
|
13
|
+
`)},Sn=e=>{let{headers:t,rows:n}=e,o=l=>{let i=false;for(let d of l)if(d===" "||d===`
|
|
14
|
+
`||d==="\r"){i=true;break}if(!i)return l;let c=[];for(let d of l)d===" "?c.push("\\t"):d===`
|
|
15
|
+
`?c.push("\\n"):d==="\r"?c.push("\\r"):c.push(d);return c.join("")},r=t.length>0?n.length+1:n.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(o).join(" "),a+=1);for(let l of n)s[a]=l.map(o).join(" "),a+=1;return s.join(`
|
|
16
|
+
`)},Bt=e=>{let t=false;for(let o of e)if(o==="\\"||o==="|"||o===`
|
|
17
|
+
`){t=true;break}if(!t)return e;let n=[];for(let o of e)o==="\\"?n.push("\\\\"):o==="|"?n.push("\\|"):o===`
|
|
18
|
+
`?n.push("<br>"):n.push(o);return n.join("")},Ue=e=>{let{headers:t,rows:n}=e;if(t.length===0)return "";let o=new Array(n.length+2),r=0,s=t.map(l=>Bt(l));o[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let l=0;l<t.length;l+=1)a[l]="---";o[r]=`| ${a.join(" | ")} |`,r+=1;for(let l of n)if(l.length<t.length){let i=new Array(t.length);for(let c=0;c<t.length;c+=1)i[c]=c<l.length?Bt(l[c]):"";o[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(c=>Bt(c));o[r]=`| ${i.join(" | ")} |`,r+=1;}return o.join(`
|
|
19
|
+
`)};var gt=({children:e,className:t,onCopy:n,onError:o,timeout:r=2e3})=>{let s=f(),[a,l]=useState(false),[i$1,c]=useState(false),d=useRef(null),m=useRef(0),{isAnimating:u,controls:f$1}=useContext(M),p=i(),h=pt(f$1),g=Ke(f$1,"table"),b=n!=null?n:g.onCopy,y=o!=null?o:g.onError,C=async I=>{var L,P;if(typeof window=="undefined"||!((L=navigator==null?void 0:navigator.clipboard)!=null&&L.write)){y==null||y(new Error("Clipboard API not available"));return}try{let A=(P=d.current)==null?void 0:P.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),z=A==null?void 0:A.querySelector("table");if(!z){y==null||y(new Error("Table not found"));return}let j=qe(z),E="";I==="csv"?E=$e(j,h):I==="tsv"?E=Sn(j):E=Ue(j);let K=new ClipboardItem({"text/plain":new Blob([E],{type:"text/plain"}),"text/html":new Blob([z.outerHTML],{type:"text/html"})});await navigator.clipboard.write([K]),c(!0),l(!1),b==null||b(I),m.current=window.setTimeout(()=>c(!1),r);}catch(A){y==null||y(A);}};useEffect(()=>{let I=L=>{let P=L.composedPath();d.current&&!P.includes(d.current)&&l(false);};return document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I),window.clearTimeout(m.current);}},[]);let k=V(),S=i$1?k.CheckIcon:k.CopyIcon;return jsxs("div",{className:s("relative"),ref:d,children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>l(!a),title:p.copyTable,type:"button",children:e!=null?e:jsx(S,{height:14,width:14})}),a?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>C("md"),title:p.copyTableAsMarkdown,type:"button",children:p.tableFormatMarkdown}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>C("csv"),title:p.copyTableAsCsv,type:"button",children:p.tableFormatCsv}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>C("tsv"),title:p.copyTableAsTsv,type:"button",children:p.tableFormatTsv})]}):null]})};var Vl=({children:e,className:t,onDownload:n,onError:o,format:r="csv",filename:s})=>{let a=f(),{isAnimating:l,controls:i$1}=useContext(M),c=i(),d$1=V(),m=pt(i$1),u=f=>{try{let h=f.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),g=h==null?void 0:h.querySelector("table");if(!g){o==null||o(new Error("Table not found"));return}let b=qe(g),y="",C="",k="";switch(r){case "csv":y=$e(b,m),C="text/csv",k="csv";break;case "markdown":y=Ue(b),C="text/markdown",k="md";break;default:y=$e(b,m),C="text/csv",k="csv";}d(`${s||ye(i$1,"table","table")}.${k}`,y,C),n==null||n();}catch(p){o==null||o(p);}};return jsx("button",{"aria-label":r==="csv"?c.downloadTableAsCsv:c.downloadTableAsMarkdown,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:u,title:r==="csv"?c.downloadTableAsCsv:c.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d$1.DownloadIcon,{size:14})})},bt=({children:e,className:t,onDownload:n,onError:o})=>{let r=f(),[s,a]=useState(false),l=useRef(null),{isAnimating:i$1,controls:c}=useContext(M),d$1=i(),m=V(),u=pt(c),f$1=p=>{var h;try{let g=(h=l.current)==null?void 0:h.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),b=g==null?void 0:g.querySelector("table");if(!b){o==null||o(new Error("Table not found"));return}let y=qe(b),C=p==="csv"?$e(y,u):Ue(y),k=p==="csv"?"csv":"md",S=`${ye(c,"table","table")}.${k}`;d(S,C,p==="csv"?"text/csv":"text/markdown"),a(!1),n==null||n(p);}catch(g){o==null||o(g);}};return useEffect(()=>{let p=h=>{let g=h.composedPath();l.current&&!g.includes(l.current)&&a(false);};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p);}},[]),jsxs("div",{className:r("relative"),ref:l,children:[jsx("button",{"aria-label":d$1.downloadTable,className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i$1,onClick:()=>a(!s),title:d$1.downloadTable,type:"button",children:e!=null?e:jsx(m.DownloadIcon,{size:14})}),s?jsxs("div",{className:r("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":d$1.downloadTableAsCsv,className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("csv"),title:d$1.downloadTableAsCsv,type:"button",children:d$1.tableFormatCsv}),jsx("button",{"aria-label":d$1.downloadTableAsMarkdown,className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("markdown"),title:d$1.downloadTableAsMarkdown,type:"button",children:d$1.tableFormatMarkdown})]}):null]})};var hr=({children:e,className:t,showCopy:n=true,showDownload:o=true})=>{let{Maximize2Icon:r,XIcon:s}=V(),a=f(),[l,i$1]=useState(false),{isAnimating:c,portal:d}=useContext(M),m=i(),u=()=>{i$1(true);},f$1=()=>{i$1(false);};return useEffect(()=>{if(l){me();let p=h=>{h.key==="Escape"&&i$1(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),ue();}}},[l]),jsxs(Fragment,{children:[jsx("button",{"aria-label":m.viewFullscreen,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:u,title:m.viewFullscreen,type:"button",children:jsx(r,{size:14})}),l?createPortal(jsx("div",{"aria-label":m.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:f$1,onKeyDown:p=>{p.key==="Escape"&&f$1();},role:"dialog",children:jsxs("div",{className:a("flex h-full flex-col"),onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:[jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[n?jsx(gt,{}):null,o?jsx(bt,{}):null,jsx("button",{"aria-label":m.exitFullscreen,className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:f$1,title:m.exitFullscreen,type:"button",children:jsx(s,{size:20})})]}),jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:a("w-full table-fixed border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),Ee(d)):null]})};var Cr=({children:e,className:t,maxHeight:n,showControls:o,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...l})=>{let i=f(),{isAnimating:c,scrollable:d}=useContext(M),m=d!=null?d:Qe,u=b(n),f$1=Et({content:e,enabled:!!u,isAnimating:c}),p=o&&r,h=o&&s,g=o&&a,b$1=p||h||g;return jsxs("div",{className:i("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[b$1?jsxs("div",{className:i("flex items-center justify-end gap-1"),children:[p?jsx(gt,{}):null,h?jsx(bt,{}):null,g?jsx(hr,{showCopy:p,showDownload:h,children:e}):null]}):null,jsx(m,{className:i("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),scrollRef:f$1,style:u?{maxHeight:u}:void 0,children:jsx("table",{className:i("w-full table-fixed divide-y divide-border",t),"data-streamdown":"table",...l,children:e})})]})};var Gl=/startLine=(\d+)/,Xl=/\bnoLineNumbers\b/,Jl=lazy(()=>import('./diagram-O5F65CLC.js').then(e=>({default:e.Diagram}))),Yl=lazy(()=>import('./openscad-RHDHURT6.js').then(e=>({default:e.OpenScad}))),Ql=/language-([^\s]+)/,fe=e=>e.props,ec="node";function _(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return false;let o=e,r=t;for(let s of n)if(s!==ec&&!Object.is(o[s],r[s]))return false;return true}function tc(e,t){var n,o;return ((n=e==null?void 0:e.properties)==null?void 0:n.metastring)===((o=t==null?void 0:t.properties)==null?void 0:o.metastring)}function nc(e){if(typeof e=="string")return e;if(isValidElement(e)){let t=fe(e).children;if(typeof t=="string")return t}}var oc=(e,t)=>Array.isArray(t)?t.includes(e):t===e,rc=(e,t)=>!!(t&&oc(e,t.language)),Mn=(e,t)=>typeof e=="boolean"?e:e[t]!==false,In=(e,t)=>{if(typeof e=="boolean")return e;let n=e.table;return n===false?false:n===true||n===void 0?true:n[t]!==false},wr=(e,t)=>{if(typeof e=="boolean")return e;let n=e.code;return n===false?false:n===true||n===void 0?true:n[t]!==false},Ln=(e,t)=>{if(typeof e=="boolean")return e;let n=e.openscad;return n===false?false:n===true||n===void 0?true:n[t]!==false},yt=createContext({depth:0,ulDepth:0,isUnordered:false}),sc={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},Nn=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{depth:s,ulDepth:a}=useContext(yt),l=useMemo(()=>({depth:s+1,ulDepth:a,isUnordered:false}),[s,a]);return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"ordered-list",...o,children:jsx(yt.Provider,{value:l,children:e})})},(e,t)=>_(e,t));Nn.displayName="MarkdownOl";var Sr=memo(({children:e,className:t,node:n,...o})=>{var h;let r=f(),{depth:s,ulDepth:a,isUnordered:l}=useContext(yt),{listStyle:i}=useContext(M),c=sc[i],d=l&&a>0?c[(a-1)%c.length]:void 0,m=Array.isArray(e)?e.filter(g=>g!==`
|
|
20
|
+
`&&g!==""):[e],u=m[0],f$1=isValidElement(u)?(h=fe(u).node)==null?void 0:h.tagName:void 0,p=m.length===1&&isValidElement(u)&&(u.type==="p"||f$1==="p")?fe(u).children:e;return t!=null&&t.includes("task-list-item")?jsx("li",{className:r("my-1 flex list-none items-center gap-2 [&>input]:m-0 [&>p]:inline",t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...o,children:p}):jsx("li",{className:r("py-1 [&>p]:inline",d,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...o,children:p})},(e,t)=>_(e,t));Sr.displayName="MarkdownLi";var Tr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{depth:s,ulDepth:a}=useContext(yt),l=useMemo(()=>({depth:s+1,ulDepth:a+1,isUnordered:true}),[s,a]);return jsx("ul",{className:r("list-inside whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"unordered-list",...o,children:jsx(yt.Provider,{value:l,children:e})})},(e,t)=>_(e,t));Tr.displayName="MarkdownUl";var Er=memo(({className:e,node:t,...n})=>{let o=f();return jsx("hr",{className:o("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n})},(e,t)=>_(e,t));Er.displayName="MarkdownHr";var Rr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...o,children:e})},(e,t)=>_(e,t));Rr.displayName="MarkdownStrong";var ac=({children:e,className:t,href:n,node:o,...r})=>{let s=f(),{linkSafety:a}=useContext(M),[l,i]=useState(false),c=n==="streamdown:incomplete-link",d=useCallback(async p=>{if(!(!(a!=null&&a.enabled&&n)||c)){if(p.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(n)){window.open(n,"_blank","noreferrer");return}i(true);}},[a,n,c]),m=useCallback(()=>{n&&window.open(n,"_blank","noreferrer");},[n]),u=useCallback(()=>{i(false);},[]),f$1={url:n!=null?n:"",isOpen:l,onClose:u,onConfirm:m};return a!=null&&a.enabled&&n?jsxs(Fragment,{children:[jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",onClick:d,type:"button",children:e}),a.renderModal?a.renderModal(f$1):jsx(Zo,{...f$1})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...r,children:e})},Ir=memo(ac,(e,t)=>_(e,t));Ir.displayName="MarkdownA";var Lr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e})},(e,t)=>_(e,t));Lr.displayName="MarkdownH1";var Mr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e})},(e,t)=>_(e,t));Mr.displayName="MarkdownH2";var Nr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e})},(e,t)=>_(e,t));Nr.displayName="MarkdownH3";var Dr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e})},(e,t)=>_(e,t));Dr.displayName="MarkdownH4";var Ar=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e})},(e,t)=>_(e,t));Ar.displayName="MarkdownH5";var Or=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e})},(e,t)=>_(e,t));Or.displayName="MarkdownH6";var Hr=memo(({children:e,className:t,node:n,...o})=>{let{controls:r,tableMaxHeight:s}=useContext(M),a=Mn(r,"table"),l=In(r,"copy"),i=In(r,"download"),c=In(r,"fullscreen");return jsx(Cr,{className:t,maxHeight:s,showControls:a,showCopy:l,showDownload:i,showFullscreen:c,...o,children:e})},(e,t)=>_(e,t));Hr.displayName="MarkdownTable";var Br=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e})},(e,t)=>_(e,t));Br.displayName="MarkdownThead";var _r=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...o,children:e})},(e,t)=>_(e,t));_r.displayName="MarkdownTbody";var Vr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...o,children:e})},(e,t)=>_(e,t));Vr.displayName="MarkdownTr";var Fr=memo(({children:e,className:t,node:n,title:o,...r})=>{let s=f(),a=mr(e,n,o);return jsx("th",{className:s("min-w-0 overflow-hidden px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...r,title:a,children:jsx("span",{className:s("wrap-anywhere line-clamp-2"),children:e})})},(e,t)=>_(e,t));Fr.displayName="MarkdownTh";var $r=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("td",{className:r("wrap-anywhere min-w-0 px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e})},(e,t)=>_(e,t));$r.displayName="MarkdownTd";var jr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e})},(e,t)=>_(e,t));jr.displayName="MarkdownBlockquote";var zr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...o,children:e})},(e,t)=>_(e,t));zr.displayName="MarkdownSup";var ic=()=>({}),lc=e=>{try{let t=atob(e),n=Uint8Array.from(t,o=>o.charCodeAt(0));return new TextDecoder().decode(n)}catch(t){return ""}},Wr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),{calloutIcon:s,calloutStyle:a,components:l,remarkPlugins:i,rehypePlugins:c}=useContext(M),d=o,m=d["data-callout-title"],u=d["data-callout-color"],f$1=d["data-callout-icon"],p=d["data-callout-body"],h=p?lc(p):"",g=(a!=null?a:ic)(u),b=f$1&&s?s(f$1):null;return jsxs("div",{className:r("my-4 rounded-md border-l-4 px-4 py-3 [&>p:last-child]:mb-0",t),"data-streamdown":"callout",style:g,...o,children:[m!==void 0?jsxs("p",{className:"mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",children:[b,m]}):null,h.trim().length>0?jsx(lt,{components:l,rehypePlugins:c,remarkPlugins:i,children:h}):null]})},(e,t)=>_(e,t));Wr.displayName="MarkdownCallout";var xr={"markdown-alert-note":"border-l-blue-500 bg-blue-500/5 [&_.markdown-alert-title]:text-blue-600 dark:[&_.markdown-alert-title]:text-blue-400","markdown-alert-tip":"border-l-green-600 bg-green-600/5 [&_.markdown-alert-title]:text-green-700 dark:[&_.markdown-alert-title]:text-green-400","markdown-alert-important":"border-l-purple-600 bg-purple-600/5 [&_.markdown-alert-title]:text-purple-700 dark:[&_.markdown-alert-title]:text-purple-400","markdown-alert-warning":"border-l-amber-600 bg-amber-600/5 [&_.markdown-alert-title]:text-amber-700 dark:[&_.markdown-alert-title]:text-amber-400","markdown-alert-caution":"border-l-red-600 bg-red-600/5 [&_.markdown-alert-title]:text-red-700 dark:[&_.markdown-alert-title]:text-red-400"},Kr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),s=t==null?void 0:t.includes("markdown-alert");if(t==null?void 0:t.includes("sdm-callout"))return jsx(Wr,{className:t,node:n,...o,children:e});if(s){let l=Object.keys(xr).find(i=>t==null?void 0:t.includes(i));return jsx("div",{className:r("my-4 rounded-r-md border-muted-foreground/30 border-l-4 bg-muted/40 px-4 py-3 [&>p:last-child]:mb-0",l?xr[l]:null,t),...o,children:e})}return jsx("div",{className:r(t),...o,children:e})},(e,t)=>_(e,t));Kr.displayName="MarkdownDiv";var Zr=memo(({children:e,className:t,node:n,...o})=>{let r=f();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...o,children:e})},(e,t)=>_(e,t));Zr.displayName="MarkdownSub";var qr=memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let s=i=>{if(!isValidElement(i))return false;let c=fe(i).children,d=Array.isArray(c)?c:[c],m=false,u=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(m=true);else if(isValidElement(f))if(fe(f)["data-footnote-backref"]!==void 0)u=true;else {let p=fe(f).children,h=Array.isArray(p)?p:[p];for(let g of h){if(typeof g=="string"&&g.trim()!==""){m=true;break}if(isValidElement(g)&&fe(g)["data-footnote-backref"]===void 0){m=true;break}}}}return u&&!m},a=Array.isArray(e)?e.map(i=>{if(!isValidElement(i))return i;if(i.type===Nn){let c=fe(i).children,m=(Array.isArray(c)?c:[c]).filter(u=>!s(u));return m.length===0?null:{...i,props:{...fe(i),children:m}}}return i}):e;return (Array.isArray(a)?a.some(i=>i!==null):a!==null)?jsx("section",{className:t,...o,children:a}):null}return jsx("section",{className:t,...o,children:e})},(e,t)=>_(e,t));qr.displayName="MarkdownSection";var cc=({node:e,className:t,children:n,...o})=>{var oe,Q,Z;let r=f(),s=!("data-block"in o),a=useContext(M),{openscad:l,controls:i$1,lineNumbers:c}=a,d=t==null?void 0:t.match(Ql),m=(oe=d==null?void 0:d.at(1))!=null?oe:"",u=or(m),f$1=Ze(),p=Ye(),h=i(),g=rr(m);if(s)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:n});let b=(Q=e==null?void 0:e.properties)==null?void 0:Q.metastring,y=typeof b=="string"?b:void 0,C=y==null?void 0:y.match(Gl),k=C?Number.parseInt(C[1],10):void 0,S=k!==void 0&&k>=1?k:void 0,L=!(y?Xl.test(y):false)&&c!==false,P=(Z=nc(n))!=null?Z:"";if(g){let T=g.component;return jsx(Suspense,{fallback:jsx(ot,{}),children:jsx(T,{code:P,isIncomplete:p,language:m,meta:y})})}if(u){let T=u.name,R=Lt(a,T),F=Te(i$1,T,"download"),W=Te(i$1,T,"copy"),G=Te(i$1,T,"fullscreen"),be=Te(i$1,T,"panZoom"),ke=Ro(i$1,T)&&(F||W||G);return jsx(Suspense,{fallback:jsx(ot,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":p||void 0,"data-streamdown":`${T}-block`,children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:m})}),ke?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":`${T}-block-actions`,children:[F?jsx(Nt,{chart:P,config:R==null?void 0:R.config,language:m,name:T,plugin:u,sourceExtension:u.sourceExtension}):null,W?jsx(nt,{code:P,label:h.copyDiagram,...Ke(i$1,T)}):null,G?jsx(Fo,{chart:P,config:R==null?void 0:R.config,language:m,name:T,plugin:u,sourceExtension:u.sourceExtension}):null]})}):null,jsx("div",{className:r("overflow-hidden rounded-md border border-border bg-background"),children:jsx(Jl,{chart:P,config:R==null?void 0:R.config,fallbackName:T,language:m,plugin:u,showControls:be})})]})})}if(rc(m,f$1)){let T=Mn(i$1,"openscad"),R=Ln(i$1,"download"),F=Ln(i$1,"copy"),W=Ln(i$1,"fullscreen"),G=T&&(R||F||W);return jsx(Suspense,{fallback:jsx(ot,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":p||void 0,"data-streamdown":"openscad-block",children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:m})}),G?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"openscad-block-actions",children:[R?jsx(Ht,{code:P,config:l==null?void 0:l.config}):null,F?jsx(nt,{code:P,label:h.copyModel,...Ke(i$1,"openscad")}):null,W?jsx(dr,{code:P,config:l==null?void 0:l.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(Yl,{code:P,config:l==null?void 0:l.config})})]})})}let A=Mn(i$1,"code"),z=wr(i$1,"download"),j=wr(i$1,"copy"),{"data-block":E,...K}=o;return jsx(cn,{className:t,code:P,isIncomplete:p,language:m,lineNumbers:L,startLine:S,...K,children:A?jsxs(Fragment,{children:[z?jsx(un,{code:P,language:m}):null,j?jsx(nt,{...Ke(i$1,"code")}):null]}):null})},Ur=memo(cc,(e,t)=>_(e,t)&&tc(e.node,t.node));Ur.displayName="MarkdownCode";var Gr=memo(zo,(e,t)=>_(e,t));Gr.displayName="MarkdownImg";var vr={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},Xr=memo(({children:e,className:t,node:n,...o})=>{let r=f(),s=i(),a=o["data-alert-type"],l=a&&a in vr?vr[a]:void 0,i$1=l?s[l]:void 0,c=e;return i$1&&(c=[...(Array.isArray(e)?e:[e]).filter(u=>!(typeof u=="string"&&u.trim().length>0)),i$1]),jsx("p",{className:r("mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",t),...o,children:c})},(e,t)=>_(e,t));Xr.displayName="MarkdownAlertTitle";var Jr=memo(({children:e,className:t,node:n,...o})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(Xr,{className:t,node:n,...o,children:e});let s=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");if(s.length===1&&isValidElement(s[0])){let a=fe(s[0]).node,l=a==null?void 0:a.tagName;if(l==="img")return jsx(Fragment,{children:e});if(l==="code"&&"data-block"in s[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...o,children:e})},(e,t)=>_(e,t));Jr.displayName="MarkdownParagraph";var Yr={ol:Nn,li:Sr,ul:Tr,hr:Er,strong:Rr,a:Ir,h1:Lr,h2:Mr,h3:Nr,h4:Dr,h5:Ar,h6:Or,table:Hr,thead:Br,tbody:_r,tr:Vr,th:Fr,td:$r,blockquote:jr,code:Ur,div:Kr,img:Gr,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:zr,sub:Zr,p:Jr,section:qr};var dc=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,mc=/\p{L}/u;function Ct(e){let t=e.replace(/(```|~~~)[\s\S]*?\1/g,"").replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,""),n,o=0,r=0;for(let s of t){if(dc.test(s)){n!=null||(n="rtl"),r+=1;continue}mc.test(s)&&(n!=null||(n="ltr"),o+=1);}return r>o?"rtl":o>r?"ltr":n!=null?n:"ltr"}var uc=/^[ \t]{0,3}(`{3,}|~{3,})/;var Qr=e=>{let t=e.split(`
|
|
21
|
+
`),n=null,o=0;for(let r of t){let s=uc.exec(r);if(n===null){if(s){let a=s[1];n=a[0],o=a.length;}}else if(s){let a=s[1],l=a[0],i=a.length;l===n&&i>=o&&(n=null,o=0);}}return n!==null};var fc=/\[\^[\w-]{1,200}\](?!:)/,gc=/\[\^[\w-]{1,200}\]:/,bc=/<([A-Za-z][\w:-]*)[\s>/]/,hc=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),es=new Map,ts=new Map,rs=e=>{let t=e.toLowerCase(),n=es.get(t);if(n)return n;let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return es.set(t,o),o},yc=e=>{let t=e.toLowerCase(),n=ts.get(t);if(n)return n;let o=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return ts.set(t,o),o},ns=(e,t)=>{if(hc.has(t.toLowerCase()))return 0;let n=e.match(rs(t));if(!n)return 0;let o=0;for(let r of n)r.trimEnd().endsWith("/>")||(o+=1);return o},os=(e,t)=>{let n=e.match(yc(t));return n?n.length:0},Cc=(e,t)=>{let n=e.match(rs(t));return !!n&&n.every(o=>o.trimEnd().endsWith("/>"))},wc=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]==="$"&&e[n+1]==="$"&&(t+=1,n+=1);return t},ss=e=>fc.test(e)||gc.test(e),xc=/\r\n|\r/g,vc=e=>new Lexer({gfm:true}).blockTokens(e),kc=`
|
|
22
|
+
|
|
23
|
+
`,Pc=e=>{var t;for(let n=e.length-3;n>=0;n-=1)if((t=e.at(n))!=null&&t.endsWith(kc))return n+1;return 0},Sc=e=>` ${e}`.slice(1),Dn=(e,t)=>({source:e,blocks:t(e),verifiedCount:0,verifiedLength:0}),Tc=(e,t,n)=>{var l,i,c,d;let o=Pc(e.blocks);if(o===0)return null;let r=(l=e.verifiedCount)!=null?l:0,s=(i=e.verifiedLength)!=null?i:0;if(r>o){r=o,s=0;for(let m=0;m<r;m+=1)s+=(d=(c=e.blocks.at(m))==null?void 0:c.length)!=null?d:0;}for(;r<o;){let m=e.blocks.at(r);if(m===void 0||!t.startsWith(m,s))return null;s+=m.length,r+=1;}let a=n(t.slice(s)).map(Sc);return {source:t,blocks:e.blocks.slice(0,o).concat(a),verifiedCount:r,verifiedLength:s}},wt=e=>{if(ss(e))return [e];let t=e.includes("\r")?e.replace(xc,`
|
|
24
|
+
`):e,n=vc(t),o=[],r=[],s=false;for(let a of n){let l=a.raw,i=o.length;if(r.length>0){o[i-1]+=l;let c=r.at(-1),d=ns(l,c),m=os(l,c);for(let u=0;u<d;u+=1)r.push(c);for(let u=0;u<m;u+=1)r.length>0&&r.at(-1)===c&&r.pop();continue}if(a.type==="html"&&a.block){let c=l.match(bc);if(c){let d=c[1],m=ns(l,d),u=os(l,d);m>u&&!Cc(l,d)&&r.push(d);}}if(a.type==="space"&&i>0){o[i-1]+=l;continue}if(i>0&&!s){let c=o[i-1];if(wc(c)%2===1){o[i-1]=c+l;continue}}o.push(l),a.type!=="space"&&(s=a.type==="code");}return o},An=(e,t,n=wt)=>{var o;return t!=null&&t.source&&e.startsWith(t.source)?e===t.source?t:n===wt&&ss(e)?Dn(e,n):(o=Tc(t,e,n))!=null?o:Dn(e,n):Dn(e,n)};var Ec=/^ {0,3}(`{3,}|~{3,})/,Rc=/^\n[ \t]*\n/,is=(e,t,n)=>{let o=t;for(;o<n&&e[o]==="`";)o+=1;return o},Ic=(e,t,n,o)=>{let r=t;for(;r<n;){let s=e[r];if(s==="`"){let a=is(e,r,n);if(a-r===o)return r;r=a;continue}if(s===`
|
|
25
|
+
`&&Rc.test(e.slice(r,r+64)))return -1;r+=1;}return -1},as=(e,t,n,o)=>{let r=t;for(;r<n;){if(e[r]!=="`"){r+=1;continue}let s=is(e,r,n),a=s-r,l=Ic(e,s,n,a);if(l===-1){r=s;continue}o.push([r,l+a]),r=l+a;}},Lc=e=>{let t=[],n=e.length,o=null,r=0,s=0;for(;s<n;){let a=e.indexOf(`
|
|
26
|
+
`,s),l=a===-1?n:a,i=e.slice(s,l),c=Ec.exec(i);if(o){let d=c==null?void 0:c[1];d&&d[0]===o.char&&d.length>=o.length&&i.slice(c[0].length).trim()===""&&(t.push([o.start,l]),o=null,r=l);}else if(c){let d=c[1],m=i.slice(c[0].length);d[0]==="`"&&m.includes("`")||(as(e,r,s,t),o={char:d[0],length:d.length,start:s});}s=l+1;}return o?t.push([o.start,n]):as(e,r,n,t),t},Mc=(e,t)=>{let n=0,o=e.length-1;for(;n<=o;){let r=Math.floor((n+o)/2),[s,a]=e[r];if(t<s)o=r-1;else if(t>=a)n=r+1;else return true}return false},Vt=e=>{let t=null;return n=>(t===null&&(t=Lc(e)),Mc(t,n))},ls=(e,t,n)=>{let o=Vt(e);return e.replace(t,(r,...s)=>{let a=s.findIndex(i=>typeof i=="number"),l=s[a];return o(l)?r:n(r,...s.slice(0,a))})},Ft=(e,t,n)=>{let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),r=new RegExp(`</${t}\\s*>`,"gi"),s=Vt(e),a="",l=0,i=o.exec(e);for(;i;){if(s(i.index)){i=o.exec(e);continue}let c=i.index+i[0].length;r.lastIndex=c;let d=r.exec(e);for(;d&&s(d.index);)d=r.exec(e);if(!d)break;a+=e.slice(l,i.index)+n(i[0],e.slice(c,d.index),d[0]),l=d.index+d[0].length,o.lastIndex=l,i=o.exec(e);}return l===0?e:a+e.slice(l)};var Nc=/^\n*/,Dc=/\n*$/,On=/\n\n/g,Ac=(e,t,n)=>{if(!t.includes(`
|
|
27
|
+
`))return e+t+n;let r=t.replace(On,`
|
|
28
|
+
<!---->
|
|
29
|
+
`).replace(Nc,`
|
|
30
|
+
|
|
31
|
+
`).replace(Dc,`
|
|
32
|
+
|
|
33
|
+
`);return `${e}${r}${n}
|
|
34
|
+
|
|
35
|
+
`},Oc=(e,t)=>{let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),o=new RegExp(`</${t}\\s*>`,"gi"),r=Vt(e),s=c=>{o.lastIndex=c;let d=o.exec(e);for(;d&&r(d.index);)d=o.exec(e);return d!==null},a="",l=0,i=n.exec(e);for(;i;){let c=i[0],d=i.index+c.length;if(r(i.index)){i=n.exec(e);continue}if(s(d)){i=n.exec(e);continue}let m=e.slice(d);if(a+=e.slice(l,i.index),m.length===0){a+=c,l=d,i=n.exec(e);continue}if(m.startsWith(`
|
|
36
|
+
|
|
37
|
+
`)){let p=m.slice(2).replace(On,`
|
|
38
|
+
<!---->
|
|
39
|
+
`);a+=`${c}
|
|
40
|
+
|
|
41
|
+
${p}`,l=e.length;break}if(!m.startsWith(`
|
|
42
|
+
`)){a+=c,l=d,i=n.exec(e);continue}let u=m.slice(1);if(u.trim().length===0){a+=c,l=d,i=n.exec(e);continue}let f=u.replace(On,`
|
|
43
|
+
<!---->
|
|
44
|
+
`);a+=`${c}
|
|
45
|
+
|
|
46
|
+
${f}`,l=e.length;break}return l===0?e:a+e.slice(l)},Hn=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t){let r=new RegExp(`<${o}(?=[\\s>/])((?:"[^"]*"|'[^']*'|[^"'>])*)\\/>`,"gi");n=ls(n,r,(s,a)=>`<${o}${a}></${o}>`);}return n},cs=(e,t)=>{if(!t.length)return e;let n=Hn(e,t);for(let o of t)n=Ft(n,o,Ac),n=Oc(n,o);return n};var Hc=/([\\`*_~[\]|])/g,Bc=e=>e.replace(Hc,"\\$1"),ds=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t)n=Ft(n,o,(r,s,a)=>{let l=Bc(s).replace(/\n\n/g," ");return r+l+a});return n};var Vc=new Set(["blockquote","dd","dt","figcaption","h1","h2","h3","h4","h5","h6","li","p","td","th"]),ms=new Set(["code","kbd","pre","samp","var"]);function us(e){return e.children.map(t=>t.type==="text"?t.value:t.type==="element"&&!ms.has(t.tagName)?us(t):"").join("")}function ps(){return e=>{visit(e,"element",t=>{if(ms.has(t.tagName)){(t.properties)!=null||(t.properties={}),t.properties.dir="ltr";return}Vc.has(t.tagName)&&((t.properties)!=null||(t.properties={}),typeof t.properties.dir!="string"&&(t.properties.dir=Ct(us(t))));});}}var fs=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(o=>o.toLowerCase()));visit(t,"element",o=>{var s;if(!n.has(o.tagName.toLowerCase()))return;let r=o.children.filter(a=>a.type==="element").map(a=>{var l;return {tag:a.tagName,props:(l=a.properties)!=null?l:{},text:toText(a).trim()}});o.properties=(s=o.properties)!=null?s:{},o.properties["data-content"]=JSON.stringify(r),o.children=[];});};var gs=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(gs).join(""):"",bs=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(o=>o.toLowerCase()));visit(t,"element",o=>{if(n.has(o.tagName.toLowerCase())){let r=gs(o);o.children=r?[{type:"text",value:r}]:[];}});};var qc=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),Uc=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),Gc=e=>{let t=unified().use(Oi).use(Hi,{allowDangerousHtml:true}),n=t.parse(e);return t.runSync(n).children},hs=(e,t=[])=>n=>{if(!e||e.length===0)return;let o=new Set(e.map(s=>s.toLowerCase())),r=new Set((t!=null?t:[]).map(s=>s.toLowerCase()));visit(n,"element",s=>{let a=s.tagName.toLowerCase();if(!o.has(a)||r.has(a)||!qc(s))return;let l=Uc(s);if(!l.includes(`
|
|
47
|
+
`))return;let i=Gc(l);s.children=i;});};var ys=()=>e=>{visit(e,"code",t=>{var n,o;t.meta&&(t.data=(n=t.data)!=null?n:{},t.data.hProperties={...(o=t.data.hProperties)!=null?o:{},metastring:t.meta});});};var Cs=/^>>>[ \t]?(.*)$/,Jc=/^<<<\s*$/,Yc=/^>+\s*$/,Qc=/^<+\s*$/,ed=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,td=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,nd=/^[a-z0-9-]+$/,od=e=>{let t=ed.exec(e);if(!(t!=null&&t.groups))return {};let{iconParen:n,iconBrace:o,title:r,color:s}=t.groups,a=n!=null?n:o;return {icon:a&&nd.test(a)?a:void 0,title:r!==void 0&&r.length>0?r:void 0,color:s&&td.test(s)?s:void 0}},Bn=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),rd=e=>{let t=new TextEncoder().encode(e),n="";for(let o of t)n+=String.fromCharCode(o);return btoa(n)},sd=(e,t)=>{var c;let n=Cs.exec(e[t]),o=(c=n==null?void 0:n[1])!=null?c:"",r=od(o),s=[],a=t+1;for(;a<e.length;a+=1){let d=e[a];if(Jc.test(d)){a+=1;break}if(Yc.test(d)||Qc.test(d)){a+=1;break}s.push(d);}let l=s.join(`
|
|
48
|
+
`).trim();return {replacement:`<div ${['class="sdm-callout"',r.title!==void 0?`data-callout-title="${Bn(r.title)}"`:"",r.color!==void 0?`data-callout-color="${Bn(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${Bn(r.icon)}"`:"",`data-callout-body="${rd(l)}"`].filter(Boolean).join(" ")}></div>`,next:a}},ws=e=>{if(!e.includes(">>>"))return e;let t=e.split(`
|
|
49
|
+
`),n=[],o=0,r=false;for(;o<t.length;)if(Cs.test(t[o])){let s=sd(t,o);n.push(s.replacement),o=s.next,r=true;}else n.push(t[o]),o+=1;return r?n.join(`
|
|
50
|
+
`):e},xs=()=>()=>{};var id=/^([a-zA-Z][a-zA-Z\d+\-.]*:)/,ld=e=>new Set(e.map(t=>t.trim().toLowerCase()).filter(t=>t.length>0).map(t=>t.endsWith(":")?t:`${t}:`));function cd(e,t){if(e.children.length!==1)return false;let[n]=e.children;if(n.type!=="text")return false;let o=id.exec(e.url);if(!o)return false;let r=o[1].toLowerCase();return t.has(r)?r==="mailto:"?e.url===`mailto:${n.value}`:e.url===n.value||e.url===`${r}//${n.value}`:false}var vs=(e=[])=>{let t=ld(e);return n=>{t.size!==0&&visit(n,"link",(o,r,s)=>{if(!(!s||r===void 0)&&cd(o,t))return s.children.splice(r,1,...o.children),r});}};var ud={NOTE:{icon:"info",kind:"note",title:"Note",iconPaths:[{d:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]},TIP:{icon:"light-bulb",kind:"tip",title:"Tip",iconPaths:[{d:"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"}]},IMPORTANT:{icon:"report",kind:"important",title:"Important",iconPaths:[{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}]},WARNING:{icon:"alert",kind:"warning",title:"Warning",iconPaths:[{d:"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",fillRule:"evenodd"}]},CAUTION:{icon:"stop",kind:"caution",title:"Caution",iconPaths:[{d:"M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25a.749.749 0 0 1-.53.22H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]}},pd=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,ks=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let n="";for(let o of t)n+=ks(o);return n},fd=e=>{let t=e.iconPaths.map(n=>`<path d="${n.d}"${n.fillRule?` fill-rule="${n.fillRule}"`:""}></path>`).join("");return {type:"paragraph",children:[{type:"html",value:`<svg class="octicon octicon-${e.icon}" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true">${t}</svg>`},{type:"text",value:e.title}],data:{hName:"p",hProperties:{className:["markdown-alert-title"],"data-alert-type":e.kind}}}},gd=e=>{var m,u;let t=e.children[0];if(!t||t.type!=="paragraph")return;let n=t.children[0];if(!n||n.type!=="text")return;let o=ks(n).trimStart(),r=o.match(pd);if(!r)return;let s=ud[r[1].toUpperCase()],a=o.slice(r[0].length),l=t.children.slice(1);if(a.trim().length===0&&l.length===0&&e.children.length===1)return;let i=[fd(s)],c=[];a.length>0&&c.push({type:"text",value:a});let d=l;return ((m=d[0])==null?void 0:m.type)==="break"&&(d=d.slice(1)),c.push(...d),c.length>0&&c.some(f=>f.type!=="text"||f.value.trim().length>0)&&i.push({type:"paragraph",children:c}),i.push(...e.children.slice(1)),e.data=(u=e.data)!=null?u:{},e.data.hName="div",e.data.hProperties={className:["markdown-alert",`markdown-alert-${s.kind}`]},e.children=i,SKIP},Ps=()=>e=>{visit(e,"blockquote",gd);};var Pd=/^[ \t]*<[\w!/?-]/,Sd=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,Td=e=>typeof e!="string"||e.length===0||!Pd.test(e)?e:e.replace(Sd,"$1"),Rs,Is,Ls,Ms,Ns,Ds,As,Os,Hs,Bs,_s,Vs,Fs,$t={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(Is=(Rs=defaultSchema.protocols)==null?void 0:Rs.href)!=null?Is:[],"tel","streamdown"],src:[...(Ms=(Ls=defaultSchema.protocols)==null?void 0:Ls.src)!=null?Ms:[],"streamdown"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(Ds=(Ns=defaultSchema.attributes)==null?void 0:Ns.div)!=null?Ds:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(Os=(As=defaultSchema.attributes)==null?void 0:As.p)!=null?Os:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(Bs=(Hs=defaultSchema.attributes)==null?void 0:Hs.svg)!=null?Bs:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(Vs=(_s=defaultSchema.attributes)==null?void 0:_s.path)!=null?Vs:[],"d","fillRule"]},tagNames:[...(Fs=defaultSchema.tagNames)!=null?Fs:[],"svg","path"]},_n={raw:Uo,sanitize:[zs,$t],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Ed={gfm:[vd,{}],githubAlerts:Ps,containerAlerts:xs,codeMeta:ys},Ts=Object.values(_n),Rd=Object.values(Ed),Es=new WeakMap;function Id(e){var r;let t=Es.get(e);if(t)return t;let n={...$t,tagNames:[...(r=$t.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...$t.attributes,...e}},o=[_n.raw,[zs,n],_n.harden];return Es.set(e,o),o}var Ld={block:" \u258B",circle:" \u25CF"},Md=["github-light","github-dark"],Nd={enabled:true},Ws=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:o,isIncomplete:r,dir:s,animatePlugin:a,...l})=>{useLayoutEffect(()=>{a==null||a.commit();}),a==null||a.setAnimateCodeBlocks(r);let i=typeof e=="string"&&n?Td(e):e,c=jsx(lt,{...l,children:i});return jsx(on.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:c}):c})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return false;if(e.components!==t.components){let n=Object.keys(e.components||{}),o=Object.keys(t.components||{});if(n.length!==o.length||n.some(r=>{var s,a;return ((s=e.components)==null?void 0:s[r])!==((a=t.components)==null?void 0:a[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins||!!e.animatePlugin!=!!t.animatePlugin)});Ws.displayName="Block";var Dd=memo(({children:e$1,mode:t="streaming",dir:n,parseIncompleteMarkdown:o=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=Ts,remarkPlugins:l=Rd,className:i,shikiTheme:c$1,mermaid:d,openscad:m,plantuml:u,smiles:f,vega:p,diagrams:h$1,codeBlockMaxHeight:g$1=400,controls:b=true,isAnimating:y=false,scrollable:C,tableMaxHeight:k=300,animated:S,BlockComponent:I=Ws,parseMarkdownIntoBlocksFn:L=wt,caret:P,listStyle:A="hierarchical",calloutIcon:z,calloutStyle:j,plugins:E,remend:K,linkSafety:oe=Nd,portal:Q,lineNumbers:Z=true,allowedTags:T,literalTagContent:R,dataOnlyTags:F,disableAutolinkProtocols:W,translations:G,icons:be,prefix:ke,onAnimationStart:ie,onAnimationEnd:re,...ne})=>{let Pe=useId(),ze=useMemo(()=>c(ke),[ke]),N=useRef(null),$=useRef(ie),le=useRef(re);$.current=ie,le.current=re,useEffect(()=>{var D,X,q;if(t==="static")return;let w=N.current;if(N.current=y,w===null){y&&((D=$.current)==null||D.call($));return}y&&!w?(X=$.current)==null||X.call($):!y&&w&&((q=le.current)==null||q.call(le));},[y,t]);let ce=useMemo(()=>T?Object.keys(T):[],[T]),Se=useMemo(()=>{if(!(F!=null&&F.length||R!=null&&R.length))return ce;let w=new Set([...F!=null?F:[],...R!=null?R:[]].map(D=>D.toLowerCase()));return ce.filter(D=>!w.has(D.toLowerCase()))},[ce,F,R]),$n=useRef(null),Wt=useMemo(()=>{if(typeof e$1!="string")return "";let w=e$1;return R&&R.length>0&&(w=ds(w,R)),ce.length>0&&(w=Hn(w,ce)),Se.length>0&&(w=cs(w,Se)),w=ws(w),w},[ce,e$1,Se,R]),de=useMemo(()=>{let w=t==="streaming"?$n.current:null,D=An(Wt,w,L);if($n.current=t==="streaming"?D:null,!(t==="streaming"&&o)||D.blocks.length===0)return D.blocks;let X=D.blocks.length-1,q=D.blocks[X],he=kd(q,K);if(he===q)return D.blocks;let He=D.blocks.slice();return He[X]=he,He},[Wt,L,t,o,K]),We=useMemo(()=>S===true?"true":S?JSON.stringify(S):"",[S]),se=useRef(null),Je=useRef([]),Ne=useRef([]),jn=useRef(null),Kt=useRef("");if(We){if(Kt.current!==We){Kt.current=We;let w=We!=="true"?S.maxBacklogMs:void 0;se.current=en({maxBacklogMs:w}),Je.current=[],Ne.current=[];}else se.current||(se.current=en());y&&se.current&&se.current.beginPass(se.current.now());}else se.current=null,Je.current=[],Ne.current=[],Kt.current="";useLayoutEffect(()=>{var w;y&&((w=se.current)==null||w.commitPass());});let De=useDeferredValue(de),Ae=useMemo(()=>{if(t!=="streaming"||se.current||De===de||De.length===0)return de;let w=De.length,D=de.length;if(D===0)return De;if(w!==D)return de;for(let q=0;q<w-1;q+=1)if(De[q]!==de[q])return de;let X=De.slice();return X[w-1]=de[D-1],X},[de,De,t]),Zt=useMemo(()=>n==="auto"?Ae.map(Ct):void 0,[Ae,n]),[zn]=useState(()=>oo(Pe)),qs=useMemo(()=>zn(Ae),[Ae,zn]),Us=useMemo(()=>G?JSON.stringify(G):"",[G]),Wn=useMemo(()=>({...g,...G}),[Us]),vt=useMemo(()=>{let{inlineCode:w,...D}=s!=null?s:{},X={...Yr,...D};if(w){let q=X.code;X.code=he=>"data-block"in he?q?createElement(q,he):null:createElement(w,he);}return X},[s]),kt=useMemo(()=>{let w=[];return E!=null&&E.cjk&&(w=[...w,...E.cjk.remarkPluginsBefore]),w=[...w,...l],W&&W.length>0&&(w=[...w,[vs,W]]),E!=null&&E.cjk&&(w=[...w,...E.cjk.remarkPluginsAfter]),E!=null&&E.math&&(w=[...w,E.math.remarkPlugin]),w},[l,E==null?void 0:E.math,E==null?void 0:E.cjk,W]),Oe=useMemo(()=>{let w=a;return T&&Object.keys(T).length>0&&a===Ts&&(w=Id(T)),Se.length>0&&(w=[...w,[hs,Se,R!=null?R:[]]]),R&&R.length>0&&(w=[...w,[bs,R]]),F&&F.length>0&&(w=[...w,[fs,F]]),E!=null&&E.math&&(w=[...w,E.math.rehypePlugin]),n==="auto"&&t==="static"&&(w=[...w,ps]),w},[a,E==null?void 0:E.math,T,Se,R,F,n,t]),Kn=useMemo(()=>{var w,D;return {calloutIcon:z,calloutStyle:j,codeBlockMaxHeight:g$1,shikiTheme:(D=c$1!=null?c$1:(w=E==null?void 0:E.code)==null?void 0:w.getThemes())!=null?D:Md,controls:b,isAnimating:y,lineNumbers:Z,listStyle:A,mode:t,mermaid:d,openscad:m,plantuml:u,smiles:f,vega:p,diagrams:h$1,linkSafety:oe,portal:Q,scrollable:C,tableMaxHeight:k,components:vt,remarkPlugins:kt,rehypePlugins:Oe}},[z,j,g$1,c$1,b,y,Z,A,t,d,m,u,f,p,h$1,oe,Q,C,E==null?void 0:E.code,k,vt,kt,Oe]),Gs=useMemo(()=>P&&y?{"--streamdown-caret":`"${Ld[P]}"`}:void 0,[P,y]),Xs=w=>{let D=null;if(se.current&&y){if(!Je.current[w]){let q=We&&We!=="true"?S:{},{maxBacklogMs:he,...He}=q;Je.current[w]=Tt({...He,timeline:se.current});}D=Je.current[w];}jn.current!==Oe&&(Ne.current=[],jn.current=Oe),D&&!Ne.current[w]&&(Ne.current[w]=[...Oe,D.rehypePlugin]);let X=D&&Ne.current[w]?Ne.current[w]:Oe;return {blockAnimatePlugin:D,blockRehypePlugins:X}};return t==="static"?jsx(h.Provider,{value:Wn,children:jsx(At.Provider,{value:E!=null?E:null,children:jsx(M.Provider,{value:Kn,children:jsx(dn,{icons:be,children:jsx(e.Provider,{value:ze,children:jsx("div",{className:ze("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:n==="auto"?void 0:n,children:jsx(lt,{components:vt,rehypePlugins:Oe,remarkPlugins:kt,...ne,children:Wt})})})})})})}):jsx(h.Provider,{value:Wn,children:jsx(At.Provider,{value:E!=null?E:null,children:jsx(M.Provider,{value:Kn,children:jsx(dn,{icons:be,children:jsx(e.Provider,{value:ze,children:jsxs("div",{className:ze("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",P?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),"data-streamdown":"container",style:Gs,children:[Ae.length===0&&P&&y&&jsx("span",{}),Ae.map((w,D)=>{var Zn;let X=D===Ae.length-1,q=y&&X&&Qr(w),{blockAnimatePlugin:he,blockRehypePlugins:He}=Xs(D);return jsx(I,{animatePlugin:he,components:vt,content:w,dir:(Zn=Zt==null?void 0:Zt[D])!=null?Zn:n!=="auto"?n:void 0,index:D,isIncomplete:q,rehypePlugins:He,remarkPlugins:kt,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:o,...ne},qs[D])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.calloutIcon===t.calloutIcon&&e.calloutStyle===t.calloutStyle&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&e.dataOnlyTags===t.dataOnlyTags&&e.disableAutolinkProtocols===t.disableAutolinkProtocols&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Dd.displayName="Streamdown";var xt=e=>e>0?e:null,Hd=(e,t)=>{if(e.endsWith("px"))return xt(Number.parseFloat(e));if(e.endsWith("rem")){let n=Number.parseFloat(getComputedStyle(document.documentElement).fontSize||"16");return xt(Number.parseFloat(e)*n)}if(e.endsWith("em")){let n=Number.parseFloat(getComputedStyle(t).fontSize||"16");return xt(Number.parseFloat(e)*n)}if(e.endsWith("vh"))return xt(Number.parseFloat(e)/100*window.innerHeight);if(e.endsWith("%")){let n=t.parentElement;return n&&n.clientHeight>0?xt(Number.parseFloat(e)/100*n.clientHeight):null}return null},Fn=(e,t)=>{let n=t.trim().toLowerCase();return !n||n==="none"||n==="auto"?null:Hd(n,e)},Bd=/^min\(\s*([^,]+)\s*,\s*([^)]+)\s*\)$/i,_d=(e,t)=>{let n=Fn(e,t);if(n!=null)return n;let o=t.trim().match(Bd);if(!o)return null;let r=Fn(e,o[1].trim()),s=Fn(e,o[2].trim());return r==null||s==null?null:Math.min(r,s)},Vd=(e,t,n)=>{let o=t.clientWidth;if(!(o>0))return null;if(n){let d=t.clientHeight;if(!(d>0))return null;let m=Math.min(o/e.width,d/e.height,1);return !(m>0)||Number.isNaN(m)?null:{fitZoom:m,viewportHeight:null}}let r=Math.min(o/e.width,1);if(!(r>0)||Number.isNaN(r))return null;let s=e.height*r,a=null,l=t;for(;l&&a==null;){let d=getComputedStyle(l);a=_d(l,d.maxHeight),l=l.parentElement;}let i=a!=null?Math.min(s,a):s,c=Math.min(r,i/e.height,1);return !(c>0)||Number.isNaN(c)?null:{fitZoom:c,viewportHeight:i}},Zs=({children:e,className:t,contentSize:n,fitKey:o,minZoom:r=.5,maxZoom:s=3,zoomStep:a=.1,showControls:l=true,initialZoom:i$1=1,isAutoFit:c=false,fullscreen:d=false})=>{let{RotateCcwIcon:m,ZoomInIcon:u,ZoomOutIcon:f$1}=V(),p=f(),h=i(),g=useRef(null),b=useRef(null),y=useRef(false),[C,k]=useState(i$1),[S,I]=useState(r),[L,P]=useState(i$1),[A,z]=useState({x:0,y:0}),[j,E]=useState(false),[K,oe]=useState({x:0,y:0}),[Q,Z]=useState({x:0,y:0}),[T,R]=useState(null),F=useCallback(N=>{let $=g.current;if(!$)return;let le=Vd(N,$,d);if(!le)return;let{fitZoom:ce,viewportHeight:Se}=le;R(Se),k(ce),I(Math.min(r,ce)),y.current||(P(ce),z({x:0,y:0}));},[d,r]),W=useCallback(N=>{P($=>Math.max(S,Math.min(s,$+N))),y.current=true;},[S,s]),G=useCallback(()=>{W(a);},[W,a]),be=useCallback(()=>{W(-a);},[W,a]),ke=useCallback(()=>{P(C),z({x:0,y:0}),y.current=false;},[C]),ie=useCallback(N=>{N.preventDefault();let $=N.deltaY>0?-a:a;W($);},[W,a]),re=useCallback(N=>{if(N.button!==0||N.isPrimary===false)return;E(true),y.current=true,oe({x:N.clientX,y:N.clientY}),Z(A);let $=N.currentTarget;$ instanceof HTMLElement&&$.setPointerCapture(N.pointerId);},[A]),ne=useCallback(N=>{if(!j)return;N.preventDefault();let $=N.clientX-K.x,le=N.clientY-K.y;z({x:Q.x+$,y:Q.y+le});},[j,K,Q]),Pe=useCallback(N=>{E(false);let $=N.currentTarget;$ instanceof HTMLElement&&$.releasePointerCapture(N.pointerId);},[]);useEffect(()=>{I(r),c||(k(i$1),P(i$1),R(null));},[i$1,c,r]),useLayoutEffect(()=>{if(!(c&&n))return;F(n);let N=g.current;if(!N||typeof ResizeObserver=="undefined")return;let $=new ResizeObserver(()=>{F(n);});return $.observe(N),()=>{$.disconnect();}},[F,n,c]),useEffect(()=>{c&&(y.current=false);},[o,c]),useEffect(()=>{let N=g.current;if(N)return N.addEventListener("wheel",ie,{passive:false}),()=>{N.removeEventListener("wheel",ie);}},[ie]),useEffect(()=>{let N=b.current;if(N&&j)return document.body.style.userSelect="none",N.addEventListener("pointermove",ne,{passive:false}),N.addEventListener("pointerup",Pe),N.addEventListener("pointercancel",Pe),()=>{document.body.style.userSelect="",N.removeEventListener("pointermove",ne),N.removeEventListener("pointerup",Pe),N.removeEventListener("pointercancel",Pe);}},[j,ne,Pe]);let ze=!d&&c&&T!=null?{height:T}:void 0;return jsxs("div",{className:p("relative flex flex-col",d?"h-full w-full":"min-h-28 w-full",t),ref:g,style:{cursor:j?"grabbing":"grab",...ze},children:[l?jsxs("div",{className:p("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",d?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{"aria-label":h.zoomIn,className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:L>=s,onClick:G,title:h.zoomIn,type:"button",children:jsx(u,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":h.zoomOut,className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:L<=S,onClick:be,title:h.zoomOut,type:"button",children:jsx(f$1,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":h.resetView,className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:ke,title:h.resetView,type:"button",children:jsx(m,{"aria-hidden":"true",size:16})})]}):null,jsx("div",{className:p("flex h-full w-full flex-1 origin-center items-center justify-center transition-transform duration-150 ease-out"),onPointerDown:re,ref:b,role:"application",style:{transform:`translate(${A.x}px, ${A.y}px) scale(${L})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var Vo=({chart:e,className:t,config:n,fallbackName:o,fullscreen:r=false,language:s,plugin:a,showControls:l=true})=>{var K,oe;let i$1=f(),c=i(),d=(oe=(K=a==null?void 0:a.name)!=null?K:o)!=null?oe:"diagram",[m,u]=useState(null),[f$1,p]=useState(false),[h,g]=useState(""),[b,y]=useState(null),[C,k]=useState(""),[S,I]=useState(0),L=useContext(M),P=Lt(L,d),A=P==null?void 0:P.errorComponent,{shouldRender:z,containerRef:j}=St({immediate:r});if(useEffect(()=>{if(!z)return;if(!a){u(rt(c,d,"missing"));return}(async()=>{try{u(null),p(!0);let{svg:Z}=await a.render(e,Mt(n,s)),T=fn(Z),R=r?Z:Do(Z);g(R),y(T),k(R);}catch(Z){C||h||u(Z instanceof Error?Z.message:rt(c,d,"failed"));}finally{p(false);}})();},[e,n,s,S,z,a]),!(z||h||C))return jsx("div",{className:i$1("my-4 min-h-[200px]",t),ref:j});if(f$1&&!h&&!C)return jsx("div",{className:i$1("my-4 flex justify-center p-4",t),ref:j,children:jsxs("div",{className:i$1("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:i$1("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:i$1("text-sm"),children:c.diagramLoading})]})});if(m&&!h&&!C){let Q=()=>I(Z=>Z+1);return A?jsx("div",{ref:j,children:jsx(A,{chart:e,error:m,retry:Q})}):jsxs("div",{className:i$1("rounded-md bg-red-50 p-4",t),ref:j,children:[jsxs("p",{className:i$1("font-mono text-red-700 text-sm"),children:[rt(c,d,"error"),": ",m]}),jsxs("details",{className:i$1("mt-2"),children:[jsx("summary",{className:i$1("cursor-pointer text-red-600 text-xs"),children:c.showCode}),jsx("pre",{className:i$1("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let E=h||C;return jsx("div",{className:i$1(r?"size-full":"max-h-[min(70vh,40rem)] w-full",t),"data-streamdown":d,ref:j,children:jsx(Zs,{className:i$1(r?"size-full overflow-hidden":"max-h-[min(70vh,40rem)] overflow-hidden",t),contentSize:b,fitKey:e,fullscreen:r,isAutoFit:true,maxZoom:3,minZoom:.1,showControls:l,zoomStep:.1,children:jsx("div",{"aria-label":rt(c,d,"chart"),className:i$1("flex justify-center",r?"size-full items-center":null),dangerouslySetInnerHTML:{__html:E},role:"img"})})})};
|
|
51
|
+
export{An as A,Td as B,_n as C,Ed as D,Ws as E,Dd as F,ra as a,Tt as b,Ye as c,Qe as d,lo as e,sn as f,ln as g,hp as h,cn as i,nt as j,un as k,ot as l,Vo as m,M as n,Yo as o,lr as p,qe as q,$e as r,Sn as s,Bt as t,Ue as u,gt as v,Vl as w,bt as x,Ct as y,wt as z};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {n,h,e}from'./chunk-TXJ25TS2.js';import'./chunk-6TBP27CO.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var x=({code:s,language:e$1,maxHeight:h$1,raw:t,className:m,startLine:d,lineNumbers:a,...c})=>{let{shikiTheme:l}=useContext(n),i=h(),[p,o]=useState(t);return useEffect(()=>{if(!i){o(t);return}let g=i.highlight({code:s,language:e$1,themes:l},H=>{o(H);});g&&o(g);},[s,e$1,l,i,t]),jsx(e,{className:m,language:e$1,lineNumbers:a,maxHeight:h$1,result:p,startLine:d,...c})};export{x as HighlightedCodeBlockBody};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type AnimateOptions, type AnimatePlugin } from "./lib/animate";
|
|
|
4
4
|
import { type IconMap } from "./lib/icon-context";
|
|
5
5
|
import { type Options } from "./lib/markdown";
|
|
6
6
|
import type { PluginConfig, ThemeInput } from "./lib/plugin-types";
|
|
7
|
-
import { type CalloutIconResolver, type CalloutStyleResolver, type ControlsConfig, type LinkSafetyConfig, type ListStylePreset, type MermaidOptions, type OpenScadOptions, type PlantUmlOptions, type PortalTarget, type ScrollableComponent } from "./lib/streamdown-context";
|
|
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
9
|
export type { AnimateOptions } from "./lib/animate";
|
|
10
10
|
export { createAnimateCursor, createAnimatePlugin } from "./lib/animate";
|
|
@@ -21,9 +21,9 @@ export type { AllowElement, Components, ExtraProps, UrlTransform, } from "./lib/
|
|
|
21
21
|
export { defaultUrlTransform } from "./lib/markdown";
|
|
22
22
|
export type { IncrementalParseState } from "./lib/parse-blocks";
|
|
23
23
|
export { parseMarkdownIntoBlocks, parseMarkdownIntoBlocksIncremental, } from "./lib/parse-blocks";
|
|
24
|
-
export type { BundledLanguage, BundledTheme, CjkPlugin, CodeHighlighterPlugin, CustomRenderer, CustomRendererProps, DiagramPlugin, HighlightOptions, MathPlugin, PlantUmlConfig, PlantUmlInstance, PlantUmlPlugin, PluginConfig, ThemeInput, ThemeRegistrationAny, } from "./lib/plugin-types";
|
|
24
|
+
export type { BundledLanguage, BundledTheme, CjkPlugin, CodeHighlighterPlugin, CustomRenderer, CustomRendererProps, DiagramPlugin, HighlightOptions, MathPlugin, PlantUmlConfig, PlantUmlInstance, PlantUmlPlugin, PluginConfig, SmilesConfig, SmilesInstance, SmilesPlugin, SvgDiagramPlugin, ThemeInput, ThemeRegistrationAny, VegaConfig, VegaInstance, VegaPlugin, } from "./lib/plugin-types";
|
|
25
25
|
export { DefaultScrollable } from "./lib/scrollable";
|
|
26
|
-
export type { CalloutIconResolver, CalloutStyleResolver, ControlsConfig, CopyControlConfig, DownloadControlConfig, LinkSafetyConfig, LinkSafetyModalProps, MermaidErrorComponentProps, MermaidOptions, OpenScadErrorComponentProps, OpenScadOptions, PlantUmlErrorComponentProps, PlantUmlOptions, PortalTarget, ScrollableComponent, ScrollableProps, StreamdownContextType, TableCopyFormat, } from "./lib/streamdown-context";
|
|
26
|
+
export type { CalloutIconResolver, CalloutStyleResolver, ControlsConfig, CopyControlConfig, DiagramErrorComponentProps, DiagramOptions, DownloadControlConfig, LinkSafetyConfig, LinkSafetyModalProps, MermaidErrorComponentProps, MermaidOptions, OpenScadErrorComponentProps, OpenScadOptions, PlantUmlErrorComponentProps, PlantUmlOptions, PortalTarget, ScrollableComponent, ScrollableProps, SmilesErrorComponentProps, SmilesOptions, StreamdownContextType, TableCopyFormat, VegaErrorComponentProps, VegaOptions, } from "./lib/streamdown-context";
|
|
27
27
|
export { StreamdownContext } from "./lib/streamdown-context";
|
|
28
28
|
export { TableCopyDropdown, type TableCopyDropdownProps, } from "./lib/table/copy-dropdown";
|
|
29
29
|
export { TableDownloadButton, type TableDownloadButtonProps, TableDownloadDropdown, type TableDownloadDropdownProps, } from "./lib/table/download-dropdown";
|
|
@@ -64,6 +64,10 @@ export type StreamdownProps = Options & {
|
|
|
64
64
|
mermaid?: MermaidOptions;
|
|
65
65
|
openscad?: OpenScadOptions;
|
|
66
66
|
plantuml?: PlantUmlOptions;
|
|
67
|
+
smiles?: SmilesOptions;
|
|
68
|
+
vega?: VegaOptions;
|
|
69
|
+
/** Per-engine options for extra SVG diagrams registered via `plugins.diagrams`. */
|
|
70
|
+
diagrams?: Record<string, DiagramOptions>;
|
|
67
71
|
codeBlockMaxHeight?: number | string;
|
|
68
72
|
controls?: ControlsConfig;
|
|
69
73
|
isAnimating?: boolean;
|
|
@@ -181,4 +185,4 @@ export type BlockProps = Options & {
|
|
|
181
185
|
animatePlugin?: AnimatePlugin | null;
|
|
182
186
|
};
|
|
183
187
|
export declare const Block: import("react").MemoExoticComponent<({ content, shouldParseIncompleteMarkdown: _, shouldNormalizeHtmlIndentation, index: __, isIncomplete, dir, animatePlugin: animatePluginProp, ...props }: BlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
184
|
-
export declare const Streamdown: import("react").MemoExoticComponent<({ children, mode, dir, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, normalizeHtmlIndentation: shouldNormalizeHtmlIndentation, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, openscad, plantuml, codeBlockMaxHeight, controls, isAnimating, scrollable, tableMaxHeight, animated, BlockComponent, parseMarkdownIntoBlocksFn, caret, listStyle, calloutIcon, calloutStyle, plugins, remend: remendOptions, linkSafety, portal, lineNumbers, allowedTags, literalTagContent, dataOnlyTags, disableAutolinkProtocols, translations, icons: iconOverrides, prefix, onAnimationStart, onAnimationEnd, ...props }: StreamdownProps) => import("react/jsx-runtime").JSX.Element>;
|
|
188
|
+
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, 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{
|
|
2
|
+
export{E as Block,i as CodeBlock,f as CodeBlockContainer,j as CodeBlockCopyButton,k as CodeBlockDownloadButton,g as CodeBlockHeader,l as CodeBlockSkeleton,d as DefaultScrollable,F as Streamdown,n as StreamdownContext,v as TableCopyDropdown,w as TableDownloadButton,x as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,C as defaultRehypePlugins,D as defaultRemarkPlugins,o as defaultUrlTransform,y as detectTextDirection,t as escapeMarkdownTableCell,q as extractTableDataFromElement,B as normalizeHtmlIndentation,z as parseMarkdownIntoBlocks,A as parseMarkdownIntoBlocksIncremental,r as tableDataToCSV,u as tableDataToMarkdown,s as tableDataToTSV,c as useIsCodeFenceIncomplete}from'./chunk-TXJ25TS2.js';export{g as defaultTranslations,i as useTranslations}from'./chunk-6TBP27CO.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable React keys for streamed markdown blocks.
|
|
3
|
+
*
|
|
4
|
+
* Index-based keys (`${id}-${index}`) keep DOM nodes alive across token
|
|
5
|
+
* appends but BREAK identity when blocks are inserted or removed above:
|
|
6
|
+
* every slot below the edit keeps its key while receiving different
|
|
7
|
+
* content, so React updates those nodes in place and replaces their entire
|
|
8
|
+
* inner subtree. Consumers that track reader position (scroll anchoring,
|
|
9
|
+
* selection, animation state) lose their anchor nodes on every head edit.
|
|
10
|
+
*
|
|
11
|
+
* Pure content-hash keys have the opposite problem: the open trailing block
|
|
12
|
+
* changes with every streamed token, so hashing its content would remount
|
|
13
|
+
* it continuously (and re-run expensive plugins like mermaid/katex).
|
|
14
|
+
*
|
|
15
|
+
* This tracker assigns each block an opaque instance-scoped key at birth
|
|
16
|
+
* and then follows the block by content:
|
|
17
|
+
* - in place, unchanged -> keep the key
|
|
18
|
+
* - in place, streamed append -> keep the key (previous content is a
|
|
19
|
+
* prefix of the new content)
|
|
20
|
+
* - moved (head insert/remove) -> keep the key (identical content is
|
|
21
|
+
* found at its old position)
|
|
22
|
+
* - genuinely new or rewritten -> fresh key (a remount is correct:
|
|
23
|
+
* the content actually changed)
|
|
24
|
+
* Duplicate identical blocks keep distinct keys via a per-render used-set.
|
|
25
|
+
* The mapping is idempotent for the same input, so StrictMode double-renders
|
|
26
|
+
* produce identical keys.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createBlockKeyTracker(prefix: string): (blocks: readonly string[]) => string[];
|
package/dist/lib/controls.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ interface TableCopyCallbacks {
|
|
|
7
7
|
onCopy?: (format: TableCopyFormat) => void;
|
|
8
8
|
onError?: (error: Error) => void;
|
|
9
9
|
}
|
|
10
|
-
export declare const getDownloadFilename: (config: ControlsConfig, type:
|
|
10
|
+
export declare const getDownloadFilename: (config: ControlsConfig, type: string, fallback: string) => string;
|
|
11
11
|
export declare function getCopyCallbacks(config: ControlsConfig, type: "table"): TableCopyCallbacks;
|
|
12
|
-
export declare function getCopyCallbacks(config: ControlsConfig, type:
|
|
12
|
+
export declare function getCopyCallbacks(config: ControlsConfig, type: string): CodeCopyCallbacks;
|
|
13
13
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DiagramPlugin, PlantUmlPlugin, PluginConfig, SmilesPlugin, SvgDiagramPlugin, VegaPlugin } from "../plugin-types";
|
|
2
|
+
export type NamedDiagramPlugin = DiagramPlugin | PlantUmlPlugin | VegaPlugin | SmilesPlugin | SvgDiagramPlugin;
|
|
3
|
+
export declare const matchesPluginLanguage: (language: string, pluginLanguage: string | readonly string[]) => boolean;
|
|
4
|
+
export declare const isMermaidPlugin: (plugin: NamedDiagramPlugin) => plugin is DiagramPlugin;
|
|
5
|
+
export declare const isPlantUmlPlugin: (plugin: NamedDiagramPlugin) => plugin is PlantUmlPlugin;
|
|
6
|
+
export declare const isVegaPlugin: (plugin: NamedDiagramPlugin) => plugin is VegaPlugin;
|
|
7
|
+
export declare const isSmilesPlugin: (plugin: NamedDiagramPlugin) => plugin is SmilesPlugin;
|
|
8
|
+
export declare const isSvgDiagramPlugin: (plugin: NamedDiagramPlugin) => plugin is SvgDiagramPlugin;
|
|
9
|
+
export declare const toSvgDiagramPlugin: (plugin: NamedDiagramPlugin) => SvgDiagramPlugin;
|
|
10
|
+
export declare const collectDiagramPlugins: (config: PluginConfig | null) => SvgDiagramPlugin[];
|
|
11
|
+
export declare const findDiagramPlugin: (plugins: SvgDiagramPlugin[], language: string) => SvgDiagramPlugin | null;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ControlsConfig } from "../streamdown-context";
|
|
2
|
+
export type DiagramControlType = "download" | "copy" | "fullscreen" | "panZoom";
|
|
3
|
+
export declare const shouldShowDiagramControls: (config: ControlsConfig, name: string) => boolean;
|
|
4
|
+
export declare const shouldShowDiagramControl: (config: ControlsConfig, name: string, controlType: DiagramControlType) => boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SvgDiagramPlugin } from "../plugin-types";
|
|
2
|
+
interface DiagramDownloadDropdownProps {
|
|
3
|
+
chart: string;
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
config?: unknown;
|
|
7
|
+
language?: string;
|
|
8
|
+
name: string;
|
|
9
|
+
onDownload?: (format: "png" | "source" | "svg") => void;
|
|
10
|
+
onError?: (error: Error) => void;
|
|
11
|
+
plugin: SvgDiagramPlugin | null;
|
|
12
|
+
sourceExtension?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const DiagramDownloadDropdown: ({ chart, children, className, config, language, name, onDownload, onError, plugin, sourceExtension, }: DiagramDownloadDropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ComponentProps, type ComponentType } from "react";
|
|
2
|
+
import type { SvgDiagramPlugin } from "../plugin-types";
|
|
3
|
+
interface DiagramViewProps {
|
|
4
|
+
chart: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
config?: unknown;
|
|
7
|
+
fullscreen?: boolean;
|
|
8
|
+
language?: string;
|
|
9
|
+
showControls?: boolean;
|
|
10
|
+
}
|
|
11
|
+
type DiagramFullscreenButtonProps = ComponentProps<"button"> & {
|
|
12
|
+
DiagramComponent?: ComponentType<DiagramViewProps>;
|
|
13
|
+
chart: string;
|
|
14
|
+
config?: unknown;
|
|
15
|
+
language?: string;
|
|
16
|
+
name: string;
|
|
17
|
+
onExit?: () => void;
|
|
18
|
+
onFullscreen?: () => void;
|
|
19
|
+
plugin: SvgDiagramPlugin | null;
|
|
20
|
+
sourceExtension?: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const DiagramFullscreenButton: ({ DiagramComponent, chart, className, config, language, name, onExit, onFullscreen, plugin, sourceExtension, ...props }: DiagramFullscreenButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SvgDiagramPlugin } from "../plugin-types";
|
|
2
|
+
interface DiagramProps {
|
|
3
|
+
chart: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
config?: unknown;
|
|
6
|
+
fallbackName?: string;
|
|
7
|
+
fullscreen?: boolean;
|
|
8
|
+
language?: string;
|
|
9
|
+
plugin: SvgDiagramPlugin | null;
|
|
10
|
+
showControls?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const Diagram: ({ chart, className, config, fallbackName, fullscreen, language, plugin, showControls, }: DiagramProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { StreamdownTranslations } from "../translations-context";
|
|
2
|
+
export type DiagramLabelKind = "chart" | "error" | "missing" | "failed";
|
|
3
|
+
export declare const diagramLabel: (t: StreamdownTranslations, name: string, kind: DiagramLabelKind) => string;
|
|
4
|
+
export declare const diagramSourceFormatLabel: (t: StreamdownTranslations, name: string, sourceExtension: string) => string;
|
|
5
|
+
export declare const diagramSourceDownloadLabel: (t: StreamdownTranslations, name: string) => string;
|
|
6
|
+
export declare const diagramPluginMissingMessage: (name: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const buildDiagramRenderOptions: (config: unknown, language?: string) => unknown;
|
|
@@ -7,5 +7,5 @@ interface MermaidDownloadDropdownProps {
|
|
|
7
7
|
onDownload?: (format: "mmd" | "png" | "svg") => void;
|
|
8
8
|
onError?: (error: Error) => void;
|
|
9
9
|
}
|
|
10
|
-
export declare const MermaidDownloadDropdown: ({
|
|
10
|
+
export declare const MermaidDownloadDropdown: ({ onDownload, ...props }: MermaidDownloadDropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { MermaidConfig } from "../plugin-types";
|
|
2
1
|
interface MermaidProps {
|
|
3
2
|
chart: string;
|
|
4
3
|
className?: string;
|
|
5
|
-
config?:
|
|
4
|
+
config?: unknown;
|
|
6
5
|
fullscreen?: boolean;
|
|
6
|
+
language?: string;
|
|
7
7
|
showControls?: boolean;
|
|
8
8
|
}
|
|
9
|
-
export declare const Mermaid: ({ chart, className, config, fullscreen, showControls, }: MermaidProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const Mermaid: ({ chart, className, config, fullscreen, language, showControls, }: MermaidProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export {};
|
|
@@ -7,5 +7,5 @@ interface PlantUmlDownloadDropdownProps {
|
|
|
7
7
|
onDownload?: (format: "puml" | "png" | "svg") => void;
|
|
8
8
|
onError?: (error: Error) => void;
|
|
9
9
|
}
|
|
10
|
-
export declare const PlantUmlDownloadDropdown: ({
|
|
10
|
+
export declare const PlantUmlDownloadDropdown: ({ onDownload, ...props }: PlantUmlDownloadDropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
export {};
|