@lofcz/streamdown 2.13.2 → 2.14.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-EMUDB4GM.js +2 -0
- package/dist/chunk-GG62F4WN.js +50 -0
- package/dist/highlighted-body-R67JZNIT.js +2 -0
- package/dist/index.d.ts +19 -3
- package/dist/index.js +1 -1
- package/dist/lib/code-block/copy-button.d.ts +4 -2
- package/dist/lib/code-block/download-button.d.ts +1 -1
- package/dist/lib/code-ranges.d.ts +45 -0
- package/dist/lib/controls.d.ts +12 -1
- package/dist/lib/parse-blocks.d.ts +8 -3
- package/dist/lib/preprocess-custom-tags.d.ts +3 -0
- package/dist/lib/remark/disable-autolink-protocols.d.ts +24 -0
- package/dist/lib/streamdown-context.d.ts +10 -5
- package/dist/lib/table/copy-dropdown.d.ts +2 -1
- package/dist/lib/translations-context.d.ts +5 -0
- package/dist/mermaid-QZEZ54HM.js +2 -0
- package/dist/openscad-JFLBJUVO.js +2 -0
- package/dist/plantuml-IOCTYIAC.js +2 -0
- package/dist/viewer-A5T7PMUM.js +2 -0
- package/package.json +3 -3
- package/dist/chunk-JVTSQQFX.js +0 -45
- package/dist/chunk-O747JC4Y.js +0 -2
- package/dist/highlighted-body-75V7K46X.js +0 -2
- package/dist/mermaid-TRQ3QBH6.js +0 -2
- package/dist/openscad-ST5FROOQ.js +0 -2
- package/dist/plantuml-DHKDTGFB.js +0 -2
- package/dist/viewer-XS6MIJ4M.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=(...n)=>twMerge(clsx(n)),D=n=>{if(n!==void 0)return typeof n=="number"?!Number.isFinite(n)||n<=0?void 0:`${n}px`:n},g=(n,a)=>{if(!n||!a)return a;let r=`${n}:`;return a.split(/\s+/).filter(Boolean).map(o=>o.startsWith(r)?o:`${n}:${o}`).join(" ")},S=n=>n?(...a)=>g(n,twMerge(clsx(a))):t,y=(n,a,r)=>{let o=typeof a=="string"&&r.startsWith("text/csv")?"\uFEFF":"",s=typeof a=="string"?new Blob([o+a],{type:r}):a,i=URL.createObjectURL(s),e=document.createElement("a");e.href=i,e.download=n,document.body.appendChild(e),e.click(),document.body.removeChild(e),URL.revokeObjectURL(i);};var c=createContext(t),T=()=>useContext(c);var C={alertNote:"Note",alertTip:"Tip",alertImportant:"Important",alertWarning:"Warning",alertCaution:"Caution",copyCode:"Copy Code",copyDiagram:"Copy diagram",copyModel:"Copy model",downloadFile:"Download file",mermaidChart:"Mermaid chart",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",downloadDiagramAsPuml:"Download diagram as PlantUML",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",diagramLoading:"Loading 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",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(C),x=()=>useContext(b);export{t as a,D as b,S as c,y as d,c as e,T as f,C as g,b as h,x as i};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {a,f,b,i,c,g,h,e,d}from'./chunk-EMUDB4GM.js';import {createContext,memo,useContext,useMemo,lazy,isValidElement,useLayoutEffect,useId,useRef,useEffect,useDeferredValue,cloneElement,createElement,useState,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import Bn from'rehype-raw';import Fs,{defaultSchema}from'rehype-sanitize';import rd from'remark-gfm';import sd 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 dl from'remark-parse';import ml from'remark-rehype';import {unified}from'unified';import {visit,SKIP}from'unist-util-visit';import {toText}from'hast-util-to-text';import {Lexer}from'marked';var Xs=300,Gs="300px",Js=500;function Ze(e={}){let{immediate:t=false,debounceDelay:o=Xs,rootMargin:n=Gs,idleTimeout:r=Js}=e,[s,a]=useState(false),c=useRef(null),l=useRef(null),i=useRef(null),d=useMemo(()=>y=>{let u=Date.now();return window.setTimeout(()=>{y({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-u))});},1)},[]),m=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(y,u)=>window.requestIdleCallback(y,u):d,[d]),p=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?y=>window.cancelIdleCallback(y):y=>{clearTimeout(y);},[]);return useEffect(()=>{if(t){a(true);return}let y=c.current;if(!y)return;l.current&&(clearTimeout(l.current),l.current=null),i.current&&(p(i.current),i.current=null);let u=()=>{l.current&&(clearTimeout(l.current),l.current=null),i.current&&(p(i.current),i.current=null);},b=C=>{i.current=m(k=>{k.timeRemaining()>0||k.didTimeout?(a(true),C.disconnect()):i.current=m(()=>{a(true),C.disconnect();},{timeout:r/2});},{timeout:r});},h=C=>{u(),l.current=window.setTimeout(()=>{var E,R;let k=C.takeRecords();(k.length===0||(R=(E=k.at(-1))==null?void 0:E.isIntersecting)!=null&&R)&&b(C);},o);},f=(C,k)=>{C.isIntersecting?h(k):u();},g=new IntersectionObserver(C=>{for(let k of C)f(k,g);},{rootMargin:n,threshold:0});return g.observe(y),()=>{l.current&&clearTimeout(l.current),i.current&&p(i.current),g.disconnect();}},[t,o,n,r,p,m]),{shouldRender:s,containerRef:c}}var Ys=320,Qs=4,tn=()=>typeof performance=="undefined"?Date.now():performance.now();function mo(e){var s,a;let t=(s=e==null?void 0:e.now)!=null?s:tn,o=(a=e==null?void 0:e.maxBacklogMs)!=null?a:Ys,n=0,r=0;return {now:t,beginPass(c){r=Math.min(Math.max(n,c),c+o);},mark(){return r},rewind(c){r=c;},take(c,l,i){if(c<=0)return {baseDelay:0,step:Math.max(0,l)};let d=Math.max(0,l),m=d===0?0:Math.min(d,Qs),p=Math.max(r,i),y=i+o,u=p+Math.max(0,c-1)*d,b=d;if(u>y&&c>1)if(p<y){let f=y-p;b=Math.max(m,f/(c-1));}else b=m;let h=Math.max(0,Math.round(p-i));return r=p+c*b,{baseDelay:h,step:b}},commitPass(){n=r;}}}function ea(){return {current:0}}var on=/\s/,uo=/^\s+$/,ta=new Set(["pre","svg","math","annotation"]),oa=new Set(["svg","math","annotation"]),co=new Set(["img","hr"]),na=new Set(["ul","ol","li"]),He=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",po=(e,t)=>{let o=t?oa:ta;return e.some(n=>He(n)&&o.has(n.tagName))},ra=e=>{for(let t=e.length-1;t>=0;t-=1){let o=e[t];if(He(o)&&o.tagName==="li")return o}},sa=(e,t,o,n)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate-marker"]=true,e.properties.style=`--sd-marker-duration:${t}ms;--sd-marker-delay:${o}ms;--sd-marker-easing:${n}`;},nn=e=>{for(let t of e.children)if(He(t)){if(t.tagName==="input")return t;if(na.has(t.tagName))continue;let o=nn(t);if(o)return o}},rn=(e,t,o,n)=>{(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:${o}ms;--sd-easing:${t.easing};--sd-delay:${n}ms`;},aa=(e,t,o,n)=>{let r=nn(e);r&&rn(r,t,o,n);},sn=e=>{var t;for(let o=e.length-1;o>=0;o-=1){let n=e[o];if(He(n)){if((t=n.properties)!=null&&t["data-sd-animated"])break;n.properties={...n.properties,"data-sd-animated":true};}}},an=e=>{let t=[],o="",n=false;for(let r of e){let s=on.test(r);if(s!==n&&o){if(s){o+=r,n=true;continue}t.push(o),o="";}o+=r,n=s;}return o&&t.push(o),t},ln=e=>{let t=[],o="";for(let n of e)on.test(n)?t.length>0&&!uo.test(t.at(-1))?t[t.length-1]+=n:o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&(t.length>0?t[t.length-1]+=o:t.push(o)),t},la=(e,t,o,n,r,s)=>{let a=`--sd-animation:sd-${t};--sd-duration:${r?0:o}ms;--sd-easing:${n}`;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}]}},ia=(e,t,o,n)=>{let r=0,s=0;return visitParents(e,a=>a.type==="text"||He(a)&&co.has(a.tagName),(a,c)=>{if(po(c,o.animateCodeBlocks))return SKIP$1;if(He(a)&&co.has(a.tagName)){n>0&&s<n||(r+=1),s+=1;return}let l=a.value;if(!l.trim()){s+=l.length;return}let i=t.sep==="char"?ln(l):an(l);for(let d of i){let m=s;s+=d.length,!uo.test(d)&&(n>0&&m<n||(r+=1));}}),r},ca=(e,t,o,n,r,s)=>{if(po(t,n.animateCodeBlocks))return;let a=n.prevContentLength,c=r.count;r.count+=1;let l=a>0&&c<a,i=l?0:s.baseDelay+r.newIndex++*s.step;rn(e,o,l?0:o.duration,i),sn(t);},da=(e,t,o,n,r,s)=>{var f;let a=t.at(-1);if(!(a&&"children"in a))return;if(po(t,n.animateCodeBlocks))return SKIP$1;let c=a,l=c.children.indexOf(e);if(l===-1)return;let i=e.value;if(!i.trim()){r.count+=i.length;return}let d=o.sep==="char"?ln(i):an(i),m=n.prevContentLength,p=false,y=ra(t),u=!!(y&&!((f=y.properties)!=null&&f["data-sd-animate-marker"])),b=false,h=d.map(g=>{let C=r.count;if(r.count+=g.length,uo.test(g))return {type:"text",value:g};let k=m>0&&C<m,S=k?0:s.baseDelay+r.newIndex++*s.step;if(y&&u&&!b){let E=k?0:o.duration;sa(y,E,S,o.easing),aa(y,o,E,S),b=true;}return p=true,la(g,o.animation,o.duration,o.easing,k,S)});return p&&sn(t),c.children.splice(l,1,...h),l+h.length},ma=0;function Lt(e){var s,a,c,l,i;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:(c=e==null?void 0:e.easing)!=null?c:"ease",sep:(l=e==null?void 0:e.sep)!=null?l:"word",stagger:(i=e==null?void 0:e.stagger)!=null?i:40,timeline:e==null?void 0:e.timeline},o={animateCodeBlocks:false,committedCharCount:0,prevContentLength:0,lastRenderCharCount:0,pendingMark:null},n=ma++,r=()=>d=>{var b;let m={count:0,newIndex:0};o.prevContentLength=o.committedCharCount;let p=t.timeline,y=(b=p==null?void 0:p.now())!=null?b:tn();p&&(o.pendingMark===null?o.pendingMark=p.mark():p.rewind(o.pendingMark));let u=p?p.take(ia(d,t,o,o.prevContentLength),t.stagger,y):{baseDelay:0,step:t.stagger};visitParents(d,h=>h.type==="text"||He(h)&&co.has(h.tagName),(h,f)=>{if(h.type==="text")return da(h,f,t,o,m,u);ca(h,f,t,o,m,u);}),o.lastRenderCharCount=m.count,o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(d){o.animateCodeBlocks=d;},setPrevContentLength(d){o.committedCharCount=d,o.prevContentLength=d;},getLastRenderCharCount(){return o.lastRenderCharCount},commit(){o.committedCharCount=o.lastRenderCharCount,o.pendingMark=null;}}}Lt();var fo=createContext(false),rt=()=>useContext(fo);var st=({scrollRef:e,ref:t,...o})=>jsx("div",{ref:e,...o});var ha=8,ya=e=>e.scrollHeight-e.scrollTop-e.clientHeight<ha,un=e=>{var o,n;let t=(n=(o=e.touches[0])!=null?o:e.changedTouches[0])!=null?n:null;return typeof(t==null?void 0:t.clientY)=="number"?t.clientY:null},At=({enabled:e,isAnimating:t,content:o})=>{let[n,r]=useState(null),s=useRef(true),a=useRef(0),c=useCallback(i=>{r(d=>d===i?d:i);},[]),l=useCallback(i=>{t&&s.current&&(i.scrollTo({top:i.scrollHeight,behavior:"instant"}),a.current=i.scrollTop);},[t]);return useEffect(()=>{t||(s.current=true);},[t]),useEffect(()=>{if(!(e&&n))return;a.current=n.scrollTop;let i=()=>{s.current=false;},d=h=>{h.deltaY<0&&i();},m=null,p=h=>{m=un(h);},y=h=>{if(m===null)return;let f=un(h);if(f===null)return;let g=f-m;Math.abs(g)<=3||(g>0&&i(),m=f);},u=()=>{m=null;},b=()=>{let h=n.scrollTop<a.current;if(a.current=n.scrollTop,h){i();return}ya(n)&&(s.current=true);};return n.addEventListener("wheel",d,{capture:true,passive:true}),n.addEventListener("touchstart",p,{passive:true}),n.addEventListener("touchmove",y,{passive:true}),n.addEventListener("touchend",u,{passive:true}),n.addEventListener("touchcancel",u,{passive:true}),n.addEventListener("scroll",b,{passive:true}),()=>{n.removeEventListener("wheel",d,{capture:true}),n.removeEventListener("touchstart",p),n.removeEventListener("touchmove",y),n.removeEventListener("touchend",u),n.removeEventListener("touchcancel",u),n.removeEventListener("scroll",b);}},[e,n]),useLayoutEffect(()=>{if(!(e&&n)||(l(n),typeof ResizeObserver=="undefined"))return;let i=new ResizeObserver(()=>{l(n);});i.observe(n);for(let d of n.children)i.observe(d);return ()=>{i.disconnect();}},[o,n,e,l]),c};var va=a("block"),xa=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"),ka=e=>{let t={};for(let o of e.split(";")){let n=o.indexOf(":");if(n>0){let r=o.slice(0,n).trim(),s=o.slice(n+1).trim();r&&s&&(t[r]=s);}}return t},pn=memo(({children:e,result:t,language:o,className:n,maxHeight:r,startLine:s,lineNumbers:a=true,...c})=>{let l=f(),{isAnimating:i,scrollable:d}=useContext(T),m=d!=null?d:st,p=b(r),y=At({content:t,enabled:!!p,isAnimating:i}),u=useMemo(()=>l(xa),[l]),b$1=useMemo(()=>l(va),[l]),h=useMemo(()=>{let f={};return t.bg&&(f["--sdm-bg"]=t.bg),t.fg&&(f["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(f,ka(t.rootStyle)),f},[t.bg,t.fg,t.rootStyle]);return jsx(m,{className:l(n,p?"overflow-x-auto overflow-y-auto":"overflow-x-auto","rounded-md border border-border bg-background p-4 text-sm"),"data-language":o,"data-streamdown":"code-block-body",scrollRef:y,style:p?{maxHeight:p}:void 0,...c,children:jsx("pre",{className:l(n,"bg-[var(--sdm-bg,inherit)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]"),style:h,children:jsx("code",{className:a?l("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&s&&s>1?{counterReset:`line ${s-1}`}:void 0,children:t.tokens.map((f,g)=>jsx("span",{className:a?u:b$1,children:f.length===0||f.length===1&&f[0].content===""?`
|
|
3
|
+
`:f.map((C,k)=>{let S={},E=!!C.bgColor;if(C.color&&(S["--sdm-c"]=C.color),C.bgColor&&(S["--sdm-tbg"]=C.bgColor),C.htmlStyle)for(let[R,D]of Object.entries(C.htmlStyle))R==="color"?S["--sdm-c"]=D:R==="background-color"?(S["--sdm-tbg"]=D,E=true):S[R]=D;return jsx("span",{className:l("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",E&&"bg-[var(--sdm-tbg)]",E&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:S,...C.htmlAttrs,children:C.content},k)})},g))})})})});var bo=({className:e,language:t,style:o,isIncomplete:n,...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":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r})};var ho=createContext({code:""}),Dt=()=>useContext(ho);var yo=({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 Ia=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
|
+
`;)t--;return e.slice(0,t)},Na=lazy(()=>import('./highlighted-body-R67JZNIT.js').then(e=>({default:e.HighlightedCodeBlockBody}))),Co=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,lineNumbers:a,...c})=>{let l=f(),{codeBlockMaxHeight:i}=useContext(T),d=useMemo(()=>Ia(e),[e]),m=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
|
|
5
|
+
`).map(p=>[{content:p,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]);return jsx(ho.Provider,{value:{code:e},children:jsxs(bo,{dir:"ltr",isIncomplete:r,language:t,children:[jsx(yo,{language:t}),n?jsx("div",{className:l("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("div",{className:l("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:n})}):null,jsx(Suspense,{fallback:jsx(pn,{className:o,language:t,lineNumbers:a,maxHeight:i,result:m,startLine:s,...c}),children:jsx(Na,{className:o,code:d,language:t,lineNumbers:a,maxHeight:i,raw:m,startLine:s,...c})})]})})};var bn=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"})}),hn=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"})}),yn=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"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"})}),Cn=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"})]}),wn=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"})}),vn=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"})}),xn=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"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"})}),kn=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"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"})}),Pn=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"})}),Sn=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 lt={CheckIcon:bn,CopyIcon:hn,DownloadIcon:yn,ExternalLinkIcon:kn,Loader2Icon:Cn,Maximize2Icon:wn,RotateCcwIcon:vn,XIcon:xn,ZoomInIcon:Pn,ZoomOutIcon:Sn},En=createContext(lt),Oa=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let o=Object.keys(e),n=Object.keys(t);return o.length!==n.length?false:o.every(r=>e[r]===t[r])},wo=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...lt,...e}:lt);Oa(o.current,e)||(o.current=e,n.current=e?{...lt,...e}:lt);let r=n.current;return jsx(En.Provider,{value:r,children:t})},H=()=>useContext(En);var qe=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,label:a,...c})=>{let l=f(),[i$1,d]=useState(false),m=useRef(0),{code:p}=Dt(),{isAnimating:y}=useContext(T),u=i(),b=s!=null?s:p,h=a!=null?a:u.copyCode,f$1=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{i$1||(await navigator.clipboard.writeText(b),d(!0),e==null||e(),m.current=window.setTimeout(()=>d(!1),o));}catch(S){t==null||t(S);}};useEffect(()=>()=>{window.clearTimeout(m.current);},[]);let g=H(),C=i$1?g.CheckIcon:g.CopyIcon;return jsxs(Fragment,{children:[jsx("button",{"aria-label":h,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-copy-button",disabled:y,onClick:f$1,title:h,type:"button",...c,children:n!=null?n:jsx(C,{"aria-hidden":"true",size:14})}),i$1&&jsx("output",{"aria-live":"polite",className:"sr-only",children:u.copied})]})};var pe=(e,t,o)=>{if(typeof e=="boolean")return o;let n=e[t];if(typeof n!="object")return o;let r=n.download;return typeof r!="object"?o:r.filename||o};function Be(e,t){if(typeof e=="boolean")return {};let o=e[t];if(typeof o!="object")return {};let n=o.copy;return typeof n!="object"||n===null?{}:{onCopy:n.onCopy,onError:n.onError}}var Rn={"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",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",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"},xo=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let c=f(),{code:l}=Dt(),{isAnimating:i$1,controls:d$1}=useContext(T),m=i(),p=H(),y=s!=null?s:l,u=o&&o in Rn?Rn[o]:"txt",b=`${pe(d$1,"code","file")}.${u}`,h="text/plain",f$1=()=>{try{d(b,y,h),e==null||e();}catch(g){t==null||t(g);}};return jsx("button",{"aria-label":m.downloadFile,className:c("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:i$1,onClick:f$1,title:m.downloadFile,type:"button",...a,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var Ke=()=>{let{Loader2Icon:e}=H(),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 it=0,de=()=>{it+=1,it===1&&(document.body.style.overflow="hidden");},me=()=>{it=Math.max(0,it-1),it===0&&(document.body.style.overflow="");};var qa=["github-light","github-dark"],Ka={enabled:true},Xa={codeBlockMaxHeight:400,shikiTheme:qa,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,openscad:void 0,plantuml:void 0,linkSafety:Ka,portal:void 0,tableMaxHeight:300},T=createContext(Xa);var Qa=/\.[^/.]+$/,Nn=(e,t)=>{if(typeof e=="boolean")return e;let o=e.image;return o===false?false:o===true||o===void 0?true:o[t]!==false},Ln=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,onClick:a,...c})=>{let{DownloadIcon:l,XIcon:i$1}=H(),d$1=f(),m=useRef(null),[p,y]=useState(false),[u,b]=useState(false),[h,f$1]=useState(false),{controls:g}=useContext(T),C=i(),k=Nn(g,"download"),S=Nn(g,"fullscreen"),E=c.width!=null||c.height!=null,R=k&&(p||E)&&!u,D=u&&!E,P=S&&!!o&&!u&&p;useEffect(()=>{let L=m.current;if(L!=null&&L.complete){let G=L.naturalWidth>0;y(G),b(!G);}},[]),useEffect(()=>{if(!h)return;de();let L=G=>{G.key==="Escape"&&f$1(false);};return document.addEventListener("keydown",L),()=>{document.removeEventListener("keydown",L),me();}},[h]);let M=useCallback(L=>{y(true),b(false),r==null||r(L);},[r]),V=useCallback(L=>{y(false),b(true),s==null||s(L);},[s]),j=useCallback(()=>{P&&f$1(true);},[P]),$=useCallback(()=>{f$1(false);},[]),Z=useCallback(L=>{a==null||a(L),!L.defaultPrevented&&j();},[a,j]),F=async L=>{if(L.stopPropagation(),!!o)try{let q=await(await fetch(o)).blob(),K=new URL(o,window.location.origin).pathname.split("/").pop()||"",Q=K.split(".").pop(),ie=K.includes(".")&&Q!==void 0&&Q.length<=4,ne="";if(ie)ne=K;else {let ae=q.type,le="png";ae.includes("jpeg")||ae.includes("jpg")?le="jpg":ae.includes("png")?le="png":ae.includes("svg")?le="svg":ae.includes("gif")?le="gif":ae.includes("webp")&&(le="webp"),ne=`${(n||K||"image").replace(Qa,"")}.${le}`;}d(ne,q,q.type);}catch(G){window.open(o,"_blank");}};return o?o==="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:n,className:d$1("m-0 block h-auto max-w-full rounded-lg",P&&"cursor-zoom-in",D&&"hidden",t),"data-streamdown":"image",onClick:Z,onError:V,onLoad:M,ref:m,src:o,...c}),D&&jsx("span",{className:d$1("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:C.imageNotAvailable}),R&&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:F,title:C.downloadImage,type:"button",children:jsx(l,{size:14})})]}),h?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:$,onKeyDown:L=>{L.key==="Escape"&&$();},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:$,title:C.exitFullscreen,type:"button",children:jsx(i$1,{size:20})}),jsx("div",{onClick:L=>L.stopPropagation(),onKeyDown:L=>L.stopPropagation(),role:"presentation",children:jsx("img",{alt:n,className:d$1("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:o})})]}),document.body):null]}):null};var he=e=>{let t=typeof e=="function"?e():e;return t!=null?t:document.body};var Hn=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:c}=H(),l=f(),[i$1,d]=useState(false),m=i(),{portal:p}=useContext(T),y=useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(h){}},[e]),u=useCallback(()=>{n(),o();},[n,o]);if(useEffect(()=>{if(t){de();let h=f=>{f.key==="Escape"&&o();};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h),me();}}},[t,o]),!t||typeof document=="undefined")return null;let b=jsx("div",{className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:o,onKeyDown:h=>{h.key==="Escape"&&o();},role:"button",tabIndex:0,children:jsxs("div",{className:l("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:[jsx("button",{"aria-label":m.close,className:l("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:o,title:m.close,type:"button",children:jsx(c,{size:16})}),jsxs("div",{className:l("flex flex-col gap-2"),children:[jsxs("div",{className:l("flex items-center gap-2 font-semibold text-lg"),children:[jsx(a,{size:20}),jsx("span",{children:m.openExternalLink})]}),jsx("p",{className:l("text-muted-foreground text-sm"),children:m.externalLinkWarning})]}),jsx("div",{className:l("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:l("flex gap-2"),children:[jsx("button",{className:l("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:y,type:"button",children:i$1?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:l("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:u,type:"button",children:[jsx(a,{size:14}),jsx("span",{children:m.openLink})]})]})]})});return createPortal(b,he(p))};var On=()=>e=>{visit(e,"html",(o,n,r)=>{!r||typeof n!="number"||(r.children[n]={type:"text",value:o.value});});};var _n=[],Fn={allowDangerousHtml:true},Ht=new WeakMap,Eo=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let o=this.keyCache.get(t);if(o)return o;let n=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return "";let p="";for(let y=0;y<m.length;y+=1){let u=m[y];if(y>0&&(p+=","),Array.isArray(u)){let[b,h]=u;if(typeof b=="function"){let f=Ht.get(b);f||(f=b.name,Ht.set(b,f)),p+=f;}else p+=String(b);p+=":",p+=JSON.stringify(h);}else if(typeof u=="function"){let b=Ht.get(u);b||(b=u.name,Ht.set(u,b)),p+=b;}else p+=String(u);}return p},c=a(n),l=a(r),i=s?JSON.stringify(s):"",d=`${l}::${c}::${i}`;return this.keyCache.set(t,d),d}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(n,o);}clear(){this.cache.clear();}},zn=new Eo,dt=e=>{let t=fl(e),o=e.children||"",n=t.runSync(t.parse(o),o);return wl(n,e)},fl=e=>{let t=zn.get(e);if(t)return t;let o=bl(e);return zn.set(e,o),o},gl=e=>e.some(t=>Array.isArray(t)?t[0]===Bn:t===Bn),bl=e=>{let t=e.rehypePlugins||_n,o=e.remarkPlugins||_n,n=gl(t)?o:[...o,On],r=e.remarkRehypeOptions?{...Fn,...e.remarkRehypeOptions}:Fn;return unified().use(dl).use(n).use(ml,r).use(t)},Vn=e=>e,hl=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},yl=(e,t)=>{var o;for(let n in urlAttributes)if(Object.hasOwn(urlAttributes,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],s=urlAttributes[n];(s===null||s.includes(e.tagName))&&(e.properties[n]=(o=t(String(r||""),n,e))!=null?o:void 0);}},Cl=(e,t,o,n,r,s)=>{let a=false;return n?a=!n.includes(e.tagName):r&&(a=r.includes(e.tagName)),!a&&s&&typeof t=="number"&&(a=!s(e,t,o)),a},wl=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:c}=t;if(o||n||r||s||c){let i=c||Vn;visit(e,(d,m,p)=>{if(d.type==="raw"&&p&&typeof m=="number")return hl(p,m,s,d.value),m;if(d.type==="element"&&(yl(d,i),Cl(d,m,p,n,r,o)&&p&&typeof m=="number"))return a&&d.children?p.children.splice(m,1,...d.children):p.children.splice(m,1),m});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var Ot=createContext(null),mt=()=>useContext(Ot),Mu=()=>{var t;let e=mt();return (t=e==null?void 0:e.code)!=null?t:null},Xe=()=>{var t;let e=mt();return (t=e==null?void 0:e.mermaid)!=null?t:null},Ge=()=>{var t;let e=mt();return (t=e==null?void 0:e.plantuml)!=null?t:null},Je=()=>{var t;let e=mt();return (t=e==null?void 0:e.openscad)!=null?t:null};var $n=e=>{var o;let t=mt();return t!=null&&t.renderers&&e&&(o=t.renderers.find(n=>Array.isArray(n.language)?n.language.includes(e):n.language===e))!=null?o:null};var kl=/(<svg\b)/,Wn=/<svg\b[^>]*>/i,Pl=/\bviewBox=(['"])(.*?)\1/i,Sl=/\swidth=(['"]).*?\1/gi,Tl=/\sheight=(['"]).*?\1/gi,jn=/\sstyle=(['"])(.*?)\1/i,Un=/^<svg/i,El=/^width\s*:/i,Rl=/^height\s*:/i,Ml=/^max-width\s*:/i,Il=/[\s,]+/,Nl=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(kl,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),Bt=e=>{if(typeof DOMParser=="undefined"||typeof XMLSerializer=="undefined")return e;let o=new DOMParser().parseFromString(e,"text/html").querySelector("svg");return o?new XMLSerializer().serializeToString(o):e},ut=e=>{let t=e.match(Wn);if(!t)return null;let n=t[0].match(Pl),r=n==null?void 0:n[2];if(!r)return null;let s=r.trim().split(Il).map(l=>Number.parseFloat(l));if(s.length<4||s.slice(0,4).some(Number.isNaN))return null;let a=s[2],c=s[3];return a>0&&c>0?{height:c,width:a}:null},_t=e=>{let t=e.match(Wn);if(!t)return e;try{let o=t[0],n=ut(e);if(!n)return e;let{width:r,height:s}=n,a=o.replace(Sl,"").replace(Tl,""),c=a.match(jn),l=`width:${r}px;height:${s}px;max-width:none;`;if(c){let i=c[1],m=c[2].split(";").map(y=>y.trim()).filter(Boolean).filter(y=>!(El.test(y)||Rl.test(y)||Ml.test(y))).join(";"),p=`${l}${m?`${m};`:""}`;a=a.replace(jn,` style=${i}${p}${i}`);}else a=a.replace(Un,`<svg style="${l}"`);return a=a.replace(Un,`<svg width="${r}" height="${s}"`),e.replace(o,a)}catch(o){return e}},Ft=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a=Nl(e),c="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a))),l=new Image;l.crossOrigin="anonymous",l.onload=()=>{let i=document.createElement("canvas"),d=l.width*o,m=l.height*o;i.width=d,i.height=m;let p=i.getContext("2d");if(!p){s(new Error("Failed to create 2D canvas context for PNG export"));return}p.drawImage(l,0,0,d,m),i.toBlob(y=>{if(!y){s(new Error("Failed to create PNG blob"));return}r(y);},"image/png");},l.onerror=()=>s(new Error("Failed to load SVG image")),l.src=c;})};var zt=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=f(),[c,l]=useState(false),i$1=useRef(null),{isAnimating:d$1,controls:m}=useContext(T),p=H(),y=Xe(),u=i(),b=pe(m,"mermaid","diagram"),h=async f=>{try{if(f==="mmd"){let R=`${b}.mmd`;d(R,e,"text/plain"),l(!1),n==null||n(f);return}if(!y){s==null||s(new Error("Mermaid plugin not available"));return}let g=y.getMermaid(r),C=e.split("").reduce((R,D)=>(R<<5)-R+D.charCodeAt(0)|0,0),k=`mermaid-${Math.abs(C)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:S}=await g.render(k,e);if(!S){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let E=Bt(S);if(f==="svg"){let R=`${b}.svg`;d(R,E,"image/svg+xml"),l(!1),n==null||n(f);return}if(f==="png"){let R=await Ft(E);d(`${b}.png`,R,"image/png"),n==null||n(f),l(!1);return}}catch(g){s==null||s(g);}};return useEffect(()=>{let f=g=>{let C=g.composedPath();i$1.current&&!C.includes(i$1.current)&&l(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f);}},[]),jsxs("div",{className:a("relative"),ref:i$1,children:[jsx("button",{"aria-label":u.downloadDiagram,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:d$1,onClick:()=>l(!c),title:u.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{"aria-hidden":"true",size:14})}),c?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":u.downloadDiagramAsSvg,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("svg"),title:u.downloadDiagramAsSvg,type:"button",children:u.mermaidFormatSvg}),jsx("button",{"aria-label":u.downloadDiagramAsPng,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("png"),title:u.downloadDiagramAsPng,type:"button",children:u.mermaidFormatPng}),jsx("button",{"aria-label":u.downloadDiagramAsMmd,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("mmd"),title:u.downloadDiagramAsMmd,type:"button",children:u.mermaidFormatMmd})]}):null]})};var Xn=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=H(),l=f(),[i$1,d]=useState(false),{isAnimating:m,controls:p,portal:y}=useContext(T),u=i(),b=(()=>{if(typeof p=="boolean")return p;let g=p.mermaid;return g===false?false:g===true||g===void 0?true:g.panZoom!==false})(),h=(()=>{if(typeof p=="boolean")return p;let g=p.mermaid;return g===false?false:g===true||g===void 0?true:g.download!==false})(),f$1=()=>{d(!i$1);};return useEffect(()=>{if(i$1){de();let g=C=>{C.key==="Escape"&&d(false);};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),me();}}},[i$1]),useEffect(()=>{i$1?o==null||o():n&&n();},[i$1,o,n]),jsxs(Fragment,{children:[jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:f$1,title:u.viewFullscreen,type:"button",...s,"aria-label":u.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i$1?createPortal(jsxs("div",{"aria-label":u.viewFullscreen,"aria-modal":"true",className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"mermaid-fullscreen",onClick:f$1,onKeyDown:g=>{g.key==="Escape"&&f$1();},role:"dialog",children:[jsxs("div",{className:l("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:[h?jsx(zt,{chart:e,config:t}):null,jsx("button",{"aria-label":u.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:f$1,title:u.exitFullscreen,type:"button",children:jsx(c,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:l("flex size-full items-center justify-center p-4"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:jsx(Kn,{chart:e,className:l("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:b})})]}),he(y)):null]})};var Jn={"3mf":"model/3mf",stl:"model/stl"},Vt=({children:e,className:t,code:o,config:n,onDownload:r,onError:s})=>{let a=f(),[c,l]=useState(false),[i$1,d$1]=useState(false),m=useRef(null),{controls:p,isAnimating:y}=useContext(T),u=H(),b=Je(),h=i(),f$1=pe(p,"openscad","model"),g=async C=>{try{if(C==="scad"){d(`${f$1}.scad`,o,"text/plain"),l(!1),r==null||r(C);return}if(!b){s==null||s(new Error("OpenSCAD plugin not available"));return}d$1(!0);let k=b.getOpenScad(n),{data:S}=await k.render(o,{...n,format:C}),E=S.buffer.slice(S.byteOffset,S.byteOffset+S.byteLength);d(`${f$1}.${C}`,new Blob([E],{type:Jn[C]}),Jn[C]),r==null||r(C),l(!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)&&l(false);};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C);}},[]),jsxs("div",{className:a("relative"),ref:m,children:[jsx("button",{"aria-label":h.downloadModel,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:y||i$1,onClick:()=>l(!c),title:h.downloadModel,type:"button",children:e!=null?e:jsx(u.DownloadIcon,{"aria-hidden":"true",size:14})}),c?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":h.downloadModelAsScad,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("scad"),title:h.downloadModelAsScad,type:"button",children:h.openscadFormatScad}),jsx("button",{"aria-label":h.downloadModelAsStl,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("stl"),title:h.downloadModelAsStl,type:"button",children:h.openscadFormatStl}),jsx("button",{"aria-label":h.downloadModelAs3mf,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("3mf"),title:h.downloadModelAs3mf,type:"button",children:h.openscadFormat3mf})]}):null]})};var ql=lazy(()=>import('./viewer-A5T7PMUM.js').then(e=>({default:e.OpenScadViewer}))),Qn=({className:e,code:t,config:o,fullscreen:n=false})=>{let r=f(),s=i(),[a,c]=useState(null),[l,i$1]=useState(false),[d,m]=useState(null),[p,y]=useState(null),[u,b]=useState(0),{openscad:h}=useContext(T),f$1=Je(),g=h==null?void 0:h.errorComponent,C=rt(),{shouldRender:k,containerRef:S}=Ze({immediate:n});if(useEffect(()=>{if(!k||C)return;if(!f$1){c(s.openscadPluginMissing);return}(async()=>{try{c(null),i$1(!0);let P=await f$1.getOpenScad(o).render(t,o);m(P),y(P);}catch(D){if(!(p||d)){let P=D instanceof Error?D.message:s.openscadRenderFailed;c(P);}}finally{i$1(false);}})();},[t,o,u,k,C,f$1,s]),!(k||d||p))return jsx("div",{className:r("my-4 min-h-[200px]",e),ref:S});if(C&&!d&&!p)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(l&&!d&&!p)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&&!p){let R=()=>b(D=>D+1);return g?jsx("div",{ref:S,children:jsx(g,{code:t,error:a,retry:R})}):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 E=d!=null?d:p;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:E?jsx(ql,{className:e,data:E.data,format:E.format,fullscreen:n}):null})})};var tr=({code:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=H(),l=f(),[i$1,d]=useState(false),{isAnimating:m,controls:p,portal:y}=useContext(T),u=i(),b=(()=>{if(typeof p=="boolean")return p;let f=p.openscad;return f===false?false:f===true||f===void 0?true:f.download!==false})(),h=()=>{d(!i$1);};return useEffect(()=>{if(i$1){de();let f=g=>{g.key==="Escape"&&d(false);};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),me();}}},[i$1]),useEffect(()=>{i$1?o==null||o():n&&n();},[i$1,o,n]),jsxs(Fragment,{children:[jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:h,title:u.viewFullscreen,type:"button",...s,"aria-label":u.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i$1?createPortal(jsxs("div",{"aria-label":u.viewFullscreen,"aria-modal":"true",className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"openscad-fullscreen",onClick:h,onKeyDown:f=>{f.key==="Escape"&&h();},role:"dialog",children:[jsxs("div",{className:l("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:f=>f.stopPropagation(),onKeyDown:f=>f.stopPropagation(),role:"presentation",children:[b?jsx(Vt,{code:e,config:t}):null,jsx("button",{"aria-label":u.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:u.exitFullscreen,type:"button",children:jsx(c,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:l("flex size-full items-center justify-center p-4"),onClick:f=>f.stopPropagation(),onKeyDown:f=>f.stopPropagation(),role:"presentation",children:jsx(Qn,{className:l("size-full"),code:e,config:t,fullscreen:true})})]}),he(y)):null]})};var $t=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=f(),[c,l]=useState(false),i$1=useRef(null),{isAnimating:d$1,controls:m}=useContext(T),p=H(),y=Ge(),u=i(),b=pe(m,"plantuml","diagram"),h=async f=>{try{if(f==="puml"){d(`${b}.puml`,e,"text/plain"),l(!1),n==null||n(f);return}if(!y){s==null||s(new Error("PlantUML plugin not available"));return}let g=y.getPlantUml(r),{svg:C}=await g.render(e,r);if(!C){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let k=Bt(C);if(f==="svg"){d(`${b}.svg`,k,"image/svg+xml"),l(!1),n==null||n(f);return}let S=await Ft(k);d(`${b}.png`,S,"image/png"),n==null||n(f),l(!1);}catch(g){s==null||s(g);}};return useEffect(()=>{let f=g=>{let C=g.composedPath();i$1.current&&!C.includes(i$1.current)&&l(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f);}},[]),jsxs("div",{className:a("relative"),ref:i$1,children:[jsx("button",{"aria-label":u.downloadDiagram,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:d$1,onClick:()=>l(!c),title:u.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{"aria-hidden":"true",size:14})}),c?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":u.downloadDiagramAsSvg,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("svg"),title:u.downloadDiagramAsSvg,type:"button",children:u.plantumlFormatSvg}),jsx("button",{"aria-label":u.downloadDiagramAsPng,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("png"),title:u.downloadDiagramAsPng,type:"button",children:u.plantumlFormatPng}),jsx("button",{"aria-label":u.downloadDiagramAsPuml,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("puml"),title:u.downloadDiagramAsPuml,type:"button",children:u.plantumlFormatPuml})]}):null]})};var yt=e=>e>0?e:null,ni=(e,t)=>{if(e.endsWith("px"))return yt(Number.parseFloat(e));if(e.endsWith("rem")){let o=Number.parseFloat(getComputedStyle(document.documentElement).fontSize||"16");return yt(Number.parseFloat(e)*o)}if(e.endsWith("em")){let o=Number.parseFloat(getComputedStyle(t).fontSize||"16");return yt(Number.parseFloat(e)*o)}if(e.endsWith("vh"))return yt(Number.parseFloat(e)/100*window.innerHeight);if(e.endsWith("%")){let o=t.parentElement;return o&&o.clientHeight>0?yt(Number.parseFloat(e)/100*o.clientHeight):null}return null},No=(e,t)=>{let o=t.trim().toLowerCase();return !o||o==="none"||o==="auto"?null:ni(o,e)},ri=/^min\(\s*([^,]+)\s*,\s*([^)]+)\s*\)$/i,si=(e,t)=>{let o=No(e,t);if(o!=null)return o;let n=t.trim().match(ri);if(!n)return null;let r=No(e,n[1].trim()),s=No(e,n[2].trim());return r==null||s==null?null:Math.min(r,s)},ai=(e,t,o)=>{let n=t.clientWidth;if(!(n>0))return null;if(o){let d=t.clientHeight;if(!(d>0))return null;let m=Math.min(n/e.width,d/e.height,1);return !(m>0)||Number.isNaN(m)?null:{fitZoom:m,viewportHeight:null}}let r=Math.min(n/e.width,1);if(!(r>0)||Number.isNaN(r))return null;let s=e.height*r,a=null,c=t;for(;c&&a==null;){let d=getComputedStyle(c);a=si(c,d.maxHeight),c=c.parentElement;}let l=a!=null?Math.min(s,a):s,i=Math.min(r,l/e.height,1);return !(i>0)||Number.isNaN(i)?null:{fitZoom:i,viewportHeight:l}},Ut=({children:e,className:t,contentSize:o,fitKey:n,minZoom:r=.5,maxZoom:s=3,zoomStep:a=.1,showControls:c=true,initialZoom:l=1,isAutoFit:i$1=false,fullscreen:d=false})=>{let{RotateCcwIcon:m,ZoomInIcon:p,ZoomOutIcon:y}=H(),u=f(),b=i(),h=useRef(null),f$1=useRef(null),g=useRef(false),[C,k]=useState(l),[S,E]=useState(r),[R,D]=useState(l),[P,M]=useState({x:0,y:0}),[V,j]=useState(false),[$,Z]=useState({x:0,y:0}),[F,U]=useState({x:0,y:0}),[L,G]=useState(null),q=useCallback(I=>{let z=h.current;if(!z)return;let Te=ai(I,z,d);if(!Te)return;let{fitZoom:Me,viewportHeight:ce}=Te;G(ce),k(Me),E(Math.min(r,Me)),g.current||(D(Me),M({x:0,y:0}));},[d,r]),W=useCallback(I=>{D(z=>Math.max(S,Math.min(s,z+I))),g.current=true;},[S,s]),K=useCallback(()=>{W(a);},[W,a]),Q=useCallback(()=>{W(-a);},[W,a]),ie=useCallback(()=>{D(C),M({x:0,y:0}),g.current=false;},[C]),ne=useCallback(I=>{I.preventDefault();let z=I.deltaY>0?-a:a;W(z);},[W,a]),ae=useCallback(I=>{if(I.button!==0||I.isPrimary===false)return;j(true),g.current=true,Z({x:I.clientX,y:I.clientY}),U(P);let z=I.currentTarget;z instanceof HTMLElement&&z.setPointerCapture(I.pointerId);},[P]),le=useCallback(I=>{if(!V)return;I.preventDefault();let z=I.clientX-$.x,Te=I.clientY-$.y;M({x:F.x+z,y:F.y+Te});},[V,$,F]),re=useCallback(I=>{j(false);let z=I.currentTarget;z instanceof HTMLElement&&z.releasePointerCapture(I.pointerId);},[]);useEffect(()=>{E(r),i$1||(k(l),D(l),G(null));},[l,i$1,r]),useLayoutEffect(()=>{if(!(i$1&&o))return;q(o);let I=h.current;if(!I||typeof ResizeObserver=="undefined")return;let z=new ResizeObserver(()=>{q(o);});return z.observe(I),()=>{z.disconnect();}},[q,o,i$1]),useEffect(()=>{i$1&&(g.current=false);},[n,i$1]),useEffect(()=>{let I=h.current;if(I)return I.addEventListener("wheel",ne,{passive:false}),()=>{I.removeEventListener("wheel",ne);}},[ne]),useEffect(()=>{let I=f$1.current;if(I&&V)return document.body.style.userSelect="none",I.addEventListener("pointermove",le,{passive:false}),I.addEventListener("pointerup",re),I.addEventListener("pointercancel",re),()=>{document.body.style.userSelect="",I.removeEventListener("pointermove",le),I.removeEventListener("pointerup",re),I.removeEventListener("pointercancel",re);}},[V,le,re]);let Ue=!d&&i$1&&L!=null?{height:L}:void 0;return jsxs("div",{className:u("relative flex flex-col",d?"h-full w-full":"min-h-28 w-full",t),ref:h,style:{cursor:V?"grabbing":"grab",...Ue},children:[c?jsxs("div",{className:u("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":b.zoomIn,className:u("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:R>=s,onClick:K,title:b.zoomIn,type:"button",children:jsx(p,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":b.zoomOut,className:u("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:R<=S,onClick:Q,title:b.zoomOut,type:"button",children:jsx(y,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":b.resetView,className:u("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:ie,title:b.resetView,type:"button",children:jsx(m,{"aria-hidden":"true",size:16})})]}):null,jsx("div",{className:u("flex h-full w-full flex-1 origin-center items-center justify-center transition-transform duration-150 ease-out"),onPointerDown:ae,ref:f$1,role:"application",style:{transform:`translate(${P.x}px, ${P.y}px) scale(${R})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var ci=()=>{if(typeof document=="undefined")return false;let e=document.documentElement;return e.classList.contains("dark")||e.dataset.theme==="dark"||e.dataset.colorMode==="dark"},rr=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=f(),a=i(),[c,l]=useState(null),[i$1,d]=useState(false),[m,p]=useState(""),[y,u]=useState(null),[b,h]=useState(""),[f$1,g]=useState(0),{plantuml:C}=useContext(T),k=Ge(),S=C==null?void 0:C.errorComponent,{shouldRender:E,containerRef:R}=Ze({immediate:n});if(useEffect(()=>{if(!E)return;if(!k){l(a.plantumlPluginMissing);return}(async()=>{var M,V,j;try{l(null),d(!0);let $=k.getPlantUml(o),Z=(j=(V=o==null?void 0:o.dark)!=null?V:(M=C==null?void 0:C.config)==null?void 0:M.dark)!=null?j:ci(),{svg:F}=await $.render(e,{dark:Z}),U=ut(F),L=n?F:_t(F);p(L),u(U),h(L);}catch($){if(!(b||m)){let Z=$ instanceof Error?$.message:a.plantumlRenderFailed;l(Z);}}finally{d(false);}})();},[e,o,f$1,E,k]),!(E||m||b))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:R});if(i$1&&!m&&!b)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:R,children:jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:s("text-sm"),children:a.diagramLoading})]})});if(c&&!m&&!b){let P=()=>g(M=>M+1);return S?jsx("div",{ref:R,children:jsx(S,{chart:e,error:c,retry:P})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:R,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:[a.plantumlErrorLabel,": ",c]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:a.showCode}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let D=m||b;return jsx("div",{className:s("size-full",t),"data-streamdown":"plantuml",ref:R,children:jsx(Ut,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),contentSize:y,fitKey:e,fullscreen:n,isAutoFit:true,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":a.plantumlChart,className:s("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:D},role:"img"})})})};var ar=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=H(),l=f(),[i$1,d]=useState(false),{isAnimating:m,controls:p,portal:y}=useContext(T),u=i(),b=(()=>{if(typeof p=="boolean")return p;let g=p.plantuml;return g===false?false:g===true||g===void 0?true:g.panZoom!==false})(),h=(()=>{if(typeof p=="boolean")return p;let g=p.plantuml;return g===false?false:g===true||g===void 0?true:g.download!==false})(),f$1=()=>{d(!i$1);};return useEffect(()=>{if(i$1){de();let g=C=>{C.key==="Escape"&&d(false);};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),me();}}},[i$1]),useEffect(()=>{i$1?o==null||o():n&&n();},[i$1,o,n]),jsxs(Fragment,{children:[jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:f$1,title:u.viewFullscreen,type:"button",...s,"aria-label":u.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i$1?createPortal(jsxs("div",{"aria-label":u.viewFullscreen,"aria-modal":"true",className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"plantuml-fullscreen",onClick:f$1,onKeyDown:g=>{g.key==="Escape"&&f$1();},role:"dialog",children:[jsxs("div",{className:l("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:[h?jsx($t,{chart:e,config:t}):null,jsx("button",{"aria-label":u.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:f$1,title:u.exitFullscreen,type:"button",children:jsx(c,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:l("flex size-full items-center justify-center p-4"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:jsx(rr,{chart:e,className:l("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:b})})]}),he(y)):null]})};var Ao=e=>e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ao).join(""):isValidElement(e)?Ao(e.props.children):"",lr=(e,t,o)=>o!=null?o:(t?toText(t):Ao(e)).replace(/\s+/g," ").trim()||void 0;function Do(e){var o;if(e.nodeType===Node.TEXT_NODE)return (o=e.textContent)!=null?o:"";if(e.nodeType!==Node.ELEMENT_NODE)return "";let t=e;return t.tagName==="BR"?`
|
|
6
|
+
`:Array.from(t.childNodes).map(Do).join("")}var Qe=e=>{let t=[],o=[],n=e.querySelectorAll("thead th");for(let s of n)t.push(Do(s).trim());let r=e.querySelectorAll("tbody tr");for(let s of r){let a=[],c=s.querySelectorAll("td");for(let l of c)a.push(Do(l).trim());o.push(a);}return {headers:t,rows:o}},Ct=e=>{var o;if(typeof e!="object")return ",";let t=e.table;return typeof t!="object"?",":(o=t.csvSeparator)!=null?o:","},je=(e,t=",")=>{let o;t==="auto"?Intl.NumberFormat().format(1.1).includes(",")?o=";":o=",":o=t;let{headers:n,rows:r}=e,s=i=>{let d=false;for(let m of i)if(m===o||m==='"'||m===`
|
|
7
|
+
`||m==="\r"){d=true;break}return d?`"${i.replace(/"/g,'""')}"`:i},a=n.length>0?r.length+1:r.length,c=new Array(a),l=0;n.length>0&&(c[l]=n.map(s).join(o),l+=1);for(let i of r)c[l]=i.map(s).join(o),l+=1;return c.join(`
|
|
8
|
+
`)},Ho=e=>{let{headers:t,rows:o}=e,n=c=>{let l=false;for(let d of c)if(d===" "||d===`
|
|
9
|
+
`||d==="\r"){l=true;break}if(!l)return c;let i=[];for(let d of c)d===" "?i.push("\\t"):d===`
|
|
10
|
+
`?i.push("\\n"):d==="\r"?i.push("\\r"):i.push(d);return i.join("")},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(" "),a+=1);for(let c of o)s[a]=c.map(n).join(" "),a+=1;return s.join(`
|
|
11
|
+
`)},Zt=e=>{let t=false;for(let n of e)if(n==="\\"||n==="|"||n===`
|
|
12
|
+
`){t=true;break}if(!t)return e;let o=[];for(let n of e)n==="\\"?o.push("\\\\"):n==="|"?o.push("\\|"):n===`
|
|
13
|
+
`?o.push("<br>"):o.push(n);return o.join("")},et=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),r=0,s=t.map(c=>Zt(c));n[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let c=0;c<t.length;c+=1)a[c]="---";n[r]=`| ${a.join(" | ")} |`,r+=1;for(let c of o)if(c.length<t.length){let l=new Array(t.length);for(let i=0;i<t.length;i+=1)l[i]=i<c.length?Zt(c[i]):"";n[r]=`| ${l.join(" | ")} |`,r+=1;}else {let l=c.map(i=>Zt(i));n[r]=`| ${l.join(" | ")} |`,r+=1;}return n.join(`
|
|
14
|
+
`)};var vt=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=f(),[a,c]=useState(false),[l,i$1]=useState(false),d=useRef(null),m=useRef(0),{isAnimating:p,controls:y}=useContext(T),u=i(),b=Ct(y),h=Be(y,"table"),f$1=o!=null?o:h.onCopy,g=n!=null?n:h.onError,C=async E=>{var R,D;if(typeof window=="undefined"||!((R=navigator==null?void 0:navigator.clipboard)!=null&&R.write)){g==null||g(new Error("Clipboard API not available"));return}try{let P=(D=d.current)==null?void 0:D.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),M=P==null?void 0:P.querySelector("table");if(!M){g==null||g(new Error("Table not found"));return}let V=Qe(M),j="";E==="csv"?j=je(V,b):E==="tsv"?j=Ho(V):j=et(V);let $=new ClipboardItem({"text/plain":new Blob([j],{type:"text/plain"}),"text/html":new Blob([M.outerHTML],{type:"text/html"})});await navigator.clipboard.write([$]),i$1(!0),c(!1),f$1==null||f$1(E),m.current=window.setTimeout(()=>i$1(!1),r);}catch(P){g==null||g(P);}};useEffect(()=>{let E=R=>{let D=R.composedPath();d.current&&!D.includes(d.current)&&c(false);};return document.addEventListener("mousedown",E),()=>{document.removeEventListener("mousedown",E),window.clearTimeout(m.current);}},[]);let k=H(),S=l?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:p,onClick:()=>c(!a),title:u.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:u.copyTableAsMarkdown,type:"button",children:u.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:u.copyTableAsCsv,type:"button",children:u.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:u.copyTableAsTsv,type:"button",children:u.tableFormatTsv})]}):null]})};var vi=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:s})=>{let a=f(),{isAnimating:c,controls:l}=useContext(T),i$1=i(),d$1=H(),m=Ct(l),p=y=>{try{let b=y.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),h=b==null?void 0:b.querySelector("table");if(!h){n==null||n(new Error("Table not found"));return}let f=Qe(h),g="",C="",k="";switch(r){case "csv":g=je(f,m),C="text/csv",k="csv";break;case "markdown":g=et(f),C="text/markdown",k="md";break;default:g=je(f,m),C="text/csv",k="csv";}d(`${s||pe(l,"table","table")}.${k}`,g,C),o==null||o();}catch(u){n==null||n(u);}};return jsx("button",{"aria-label":r==="csv"?i$1.downloadTableAsCsv:i$1.downloadTableAsMarkdown,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:p,title:r==="csv"?i$1.downloadTableAsCsv:i$1.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d$1.DownloadIcon,{size:14})})},xt=({children:e,className:t,onDownload:o,onError:n})=>{let r=f(),[s,a]=useState(false),c=useRef(null),{isAnimating:l,controls:i$1}=useContext(T),d$1=i(),m=H(),p=Ct(i$1),y=u=>{var b;try{let h=(b=c.current)==null?void 0:b.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=h==null?void 0:h.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let g=Qe(f),C=u==="csv"?je(g,p):et(g),k=u==="csv"?"csv":"md",S=`${pe(i$1,"table","table")}.${k}`;d(S,C,u==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(u);}catch(h){n==null||n(h);}};return useEffect(()=>{let u=b=>{let h=b.composedPath();c.current&&!h.includes(c.current)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[]),jsxs("div",{className:r("relative"),ref:c,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:l,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:()=>y("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:()=>y("markdown"),title:d$1.downloadTableAsMarkdown,type:"button",children:d$1.tableFormatMarkdown})]}):null]})};var pr=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=H(),a=f(),[c,l]=useState(false),{isAnimating:i$1,portal:d}=useContext(T),m=i(),p=()=>{l(true);},y=()=>{l(false);};return useEffect(()=>{if(c){de();let u=b=>{b.key==="Escape"&&l(false);};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u),me();}}},[c]),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:i$1,onClick:p,title:m.viewFullscreen,type:"button",children:jsx(r,{size:14})}),c?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:y,onKeyDown:u=>{u.key==="Escape"&&y();},role:"dialog",children:jsxs("div",{className:a("flex h-full flex-col"),onClick:u=>u.stopPropagation(),onKeyDown:u=>u.stopPropagation(),role:"presentation",children:[jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[o?jsx(vt,{}):null,n?jsx(xt,{}):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:y,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})})]})}),he(d)):null]})};var gr=({children:e,className:t,maxHeight:o,showControls:n,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...c})=>{let l=f(),{isAnimating:i,scrollable:d}=useContext(T),m=d!=null?d:st,p=b(o),y=At({content:e,enabled:!!p,isAnimating:i}),u=n&&r,b$1=n&&s,h=n&&a,f$1=u||b$1||h;return jsxs("div",{className:l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[f$1?jsxs("div",{className:l("flex items-center justify-end gap-1"),children:[u?jsx(vt,{}):null,b$1?jsx(xt,{}):null,h?jsx(pr,{showCopy:u,showDownload:b$1,children:e}):null]}):null,jsx(m,{className:l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),scrollRef:y,style:p?{maxHeight:p}:void 0,children:jsx("table",{className:l("w-full table-fixed divide-y divide-border",t),"data-streamdown":"table",...c,children:e})})]})};var Ni=/startLine=(\d+)/,Li=/\bnoLineNumbers\b/,Ai=lazy(()=>import('./mermaid-QZEZ54HM.js').then(e=>({default:e.Mermaid}))),Di=lazy(()=>import('./plantuml-IOCTYIAC.js').then(e=>({default:e.PlantUml}))),Hi=lazy(()=>import('./openscad-JFLBJUVO.js').then(e=>({default:e.OpenScad}))),Oi=/language-([^\s]+)/,Ce=e=>e.props,Bi="node";function _(e,t){let o=Object.keys(e);if(o.length!==Object.keys(t).length)return false;let n=e,r=t;for(let s of o)if(s!==Bi&&!Object.is(n[s],r[s]))return false;return true}function _i(e,t){var o,n;return ((o=e==null?void 0:e.properties)==null?void 0:o.metastring)===((n=t==null?void 0:t.properties)==null?void 0:n.metastring)}function Fi(e){if(typeof e=="string")return e;if(isValidElement(e)){let t=Ce(e).children;if(typeof t=="string")return t}}var wr=(e,t)=>Array.isArray(t)?t.includes(e):t===e,zi=(e,t)=>!!(t&&wr(e,t.language)),Vi=(e,t)=>!!(t&&wr(e,t.language)),Pt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,_o=(e,t)=>{if(typeof e=="boolean")return e;let o=e.table;return o===false?false:o===true||o===void 0?true:o[t]!==false},br=(e,t)=>{if(typeof e=="boolean")return e;let o=e.code;return o===false?false:o===true||o===void 0?true:o[t]!==false},Kt=(e,t)=>{if(typeof e=="boolean")return e;let o=e.mermaid;return o===false?false:o===true||o===void 0?true:o[t]!==false},Xt=(e,t)=>{if(typeof e=="boolean")return e;let o=e.plantuml;return o===false?false:o===true||o===void 0?true:o[t]!==false},Fo=(e,t)=>{if(typeof e=="boolean")return e;let o=e.openscad;return o===false?false:o===true||o===void 0?true:o[t]!==false},St=createContext({depth:0,ulDepth:0,isUnordered:false}),$i={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},Vo=memo(({children:e,className:t,node:o,...n})=>{let r=f(),{depth:s,ulDepth:a}=useContext(St),c=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",...n,children:jsx(St.Provider,{value:c,children:e})})},(e,t)=>_(e,t));Vo.displayName="MarkdownOl";var vr=memo(({children:e,className:t,node:o,...n})=>{var b;let r=f(),{depth:s,ulDepth:a,isUnordered:c}=useContext(St),{listStyle:l}=useContext(T),i=$i[l],d=c&&a>0?i[(a-1)%i.length]:void 0,m=Array.isArray(e)?e.filter(h=>h!==`
|
|
15
|
+
`&&h!==""):[e],p=m[0],y=isValidElement(p)?(b=Ce(p).node)==null?void 0:b.tagName:void 0,u=m.length===1&&isValidElement(p)&&(p.type==="p"||y==="p")?Ce(p).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",...n,children:u}):jsx("li",{className:r("py-1 [&>p]:inline",d,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...n,children:u})},(e,t)=>_(e,t));vr.displayName="MarkdownLi";var xr=memo(({children:e,className:t,node:o,...n})=>{let r=f(),{depth:s,ulDepth:a}=useContext(St),c=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",...n,children:jsx(St.Provider,{value:c,children:e})})},(e,t)=>_(e,t));xr.displayName="MarkdownUl";var kr=memo(({className:e,node:t,...o})=>{let n=f();return jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>_(e,t));kr.displayName="MarkdownHr";var Pr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>_(e,t));Pr.displayName="MarkdownStrong";var ji=({children:e,className:t,href:o,node:n,...r})=>{let s=f(),{linkSafety:a}=useContext(T),[c,l]=useState(false),i=o==="streamdown:incomplete-link",d=useCallback(async u=>{if(!(!(a!=null&&a.enabled&&o)||i)){if(u.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}l(true);}},[a,o,i]),m=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),p=useCallback(()=>{l(false);},[]),y={url:o!=null?o:"",isOpen:c,onClose:p,onConfirm:m};return a!=null&&a.enabled&&o?jsxs(Fragment,{children:[jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":i,"data-streamdown":"link",onClick:d,type:"button",children:e}),a.renderModal?a.renderModal(y):jsx(Hn,{...y})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":i,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},Sr=memo(ji,(e,t)=>_(e,t));Sr.displayName="MarkdownA";var Tr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>_(e,t));Tr.displayName="MarkdownH1";var Er=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>_(e,t));Er.displayName="MarkdownH2";var Rr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>_(e,t));Rr.displayName="MarkdownH3";var Mr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>_(e,t));Mr.displayName="MarkdownH4";var Ir=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>_(e,t));Ir.displayName="MarkdownH5";var Nr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>_(e,t));Nr.displayName="MarkdownH6";var Lr=memo(({children:e,className:t,node:o,...n})=>{let{controls:r,tableMaxHeight:s}=useContext(T),a=Pt(r,"table"),c=_o(r,"copy"),l=_o(r,"download"),i=_o(r,"fullscreen");return jsx(gr,{className:t,maxHeight:s,showControls:a,showCopy:c,showDownload:l,showFullscreen:i,...n,children:e})},(e,t)=>_(e,t));Lr.displayName="MarkdownTable";var Ar=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>_(e,t));Ar.displayName="MarkdownThead";var Dr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>_(e,t));Dr.displayName="MarkdownTbody";var Hr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>_(e,t));Hr.displayName="MarkdownTr";var Or=memo(({children:e,className:t,node:o,title:n,...r})=>{let s=f(),a=lr(e,o,n);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));Or.displayName="MarkdownTh";var Br=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("td",{className:r("wrap-anywhere min-w-0 px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>_(e,t));Br.displayName="MarkdownTd";var _r=memo(({children:e,className:t,node:o,...n})=>{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",...n,children:e})},(e,t)=>_(e,t));_r.displayName="MarkdownBlockquote";var Fr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>_(e,t));Fr.displayName="MarkdownSup";var Ui=()=>({}),Wi=e=>{try{let t=atob(e),o=Uint8Array.from(t,n=>n.charCodeAt(0));return new TextDecoder().decode(o)}catch(t){return ""}},zr=memo(({children:e,className:t,node:o,...n})=>{let r=f(),{calloutIcon:s,calloutStyle:a,components:c,remarkPlugins:l,rehypePlugins:i}=useContext(T),d=n,m=d["data-callout-title"],p=d["data-callout-color"],y=d["data-callout-icon"],u=d["data-callout-body"],b=u?Wi(u):"",h=(a!=null?a:Ui)(p),f$1=y&&s?s(y):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:h,...n,children:[m!==void 0?jsxs("p",{className:"mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",children:[f$1,m]}):null,b.trim().length>0?jsx(dt,{components:c,rehypePlugins:i,remarkPlugins:l,children:b}):null]})},(e,t)=>_(e,t));zr.displayName="MarkdownCallout";var hr={"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"},Vr=memo(({children:e,className:t,node:o,...n})=>{let r=f(),s=t==null?void 0:t.includes("markdown-alert");if(t==null?void 0:t.includes("sdm-callout"))return jsx(zr,{className:t,node:o,...n,children:e});if(s){let c=Object.keys(hr).find(l=>t==null?void 0:t.includes(l));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",c?hr[c]:null,t),...n,children:e})}return jsx("div",{className:r(t),...n,children:e})},(e,t)=>_(e,t));Vr.displayName="MarkdownDiv";var $r=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>_(e,t));$r.displayName="MarkdownSub";var jr=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=l=>{if(!isValidElement(l))return false;let i=Ce(l).children,d=Array.isArray(i)?i:[i],m=false,p=false;for(let y of d)if(y){if(typeof y=="string")y.trim()!==""&&(m=true);else if(isValidElement(y))if(Ce(y)["data-footnote-backref"]!==void 0)p=true;else {let u=Ce(y).children,b=Array.isArray(u)?u:[u];for(let h of b){if(typeof h=="string"&&h.trim()!==""){m=true;break}if(isValidElement(h)&&Ce(h)["data-footnote-backref"]===void 0){m=true;break}}}}return p&&!m},a=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===Vo){let i=Ce(l).children,m=(Array.isArray(i)?i:[i]).filter(p=>!s(p));return m.length===0?null:{...l,props:{...Ce(l),children:m}}}return l}):e;return (Array.isArray(a)?a.some(l=>l!==null):a!==null)?jsx("section",{className:t,...n,children:a}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>_(e,t));jr.displayName="MarkdownSection";var Zi=({node:e,className:t,children:o,...n})=>{var U,L,G;let r=f(),s=!("data-block"in n),{mermaid:a,plantuml:c,openscad:l,controls:i$1,lineNumbers:d}=useContext(T),m=Xe(),p=Ge(),y=Je(),u=rt(),b=i(),h=t==null?void 0:t.match(Oi),f$1=(U=h==null?void 0:h.at(1))!=null?U:"",g=$n(f$1);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",...n,children:o});let C=(L=e==null?void 0:e.properties)==null?void 0:L.metastring,k=typeof C=="string"?C:void 0,S=k==null?void 0:k.match(Ni),E=S?Number.parseInt(S[1],10):void 0,R=E!==void 0&&E>=1?E:void 0,P=!(k?Li.test(k):false)&&d!==false,M=(G=Fi(o))!=null?G:"";if(g){let q=g.component;return jsx(Suspense,{fallback:jsx(Ke,{}),children:jsx(q,{code:M,isIncomplete:u,language:f$1,meta:k})})}if(f$1==="mermaid"&&m){let q=Pt(i$1,"mermaid"),W=Kt(i$1,"download"),K=Kt(i$1,"copy"),Q=Kt(i$1,"fullscreen"),ie=Kt(i$1,"panZoom"),ne=q&&(W||K||Q);return jsx(Suspense,{fallback:jsx(Ke,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":u||void 0,"data-streamdown":"mermaid-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:"mermaid"})}),ne?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":"mermaid-block-actions",children:[W?jsx(zt,{chart:M,config:a==null?void 0:a.config}):null,K?jsx(qe,{code:M,label:b.copyDiagram,...Be(i$1,"mermaid")}):null,Q?jsx(Xn,{chart:M,config:a==null?void 0:a.config}):null]})}):null,jsx("div",{className:r("overflow-hidden rounded-md border border-border bg-background"),children:jsx(Ai,{chart:M,config:a==null?void 0:a.config,showControls:ie})})]})})}if(zi(f$1,p)){let q=Pt(i$1,"plantuml"),W=Xt(i$1,"download"),K=Xt(i$1,"copy"),Q=Xt(i$1,"fullscreen"),ie=Xt(i$1,"panZoom"),ne=q&&(W||K||Q);return jsx(Suspense,{fallback:jsx(Ke,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":u||void 0,"data-streamdown":"plantuml-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:f$1})}),ne?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":"plantuml-block-actions",children:[W?jsx($t,{chart:M,config:c==null?void 0:c.config}):null,K?jsx(qe,{code:M,label:b.copyDiagram,...Be(i$1,"plantuml")}):null,Q?jsx(ar,{chart:M,config:c==null?void 0:c.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(Di,{chart:M,config:c==null?void 0:c.config,showControls:ie})})]})})}if(Vi(f$1,y)){let q=Pt(i$1,"openscad"),W=Fo(i$1,"download"),K=Fo(i$1,"copy"),Q=Fo(i$1,"fullscreen"),ie=q&&(W||K||Q);return jsx(Suspense,{fallback:jsx(Ke,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":u||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:f$1})}),ie?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:[W?jsx(Vt,{code:M,config:l==null?void 0:l.config}):null,K?jsx(qe,{code:M,label:b.copyModel,...Be(i$1,"openscad")}):null,Q?jsx(tr,{code:M,config:l==null?void 0:l.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(Hi,{code:M,config:l==null?void 0:l.config})})]})})}let V=Pt(i$1,"code"),j=br(i$1,"download"),$=br(i$1,"copy"),{"data-block":Z,...F}=n;return jsx(Co,{className:t,code:M,isIncomplete:u,language:f$1,lineNumbers:P,startLine:R,...F,children:V?jsxs(Fragment,{children:[j?jsx(xo,{code:M,language:f$1}):null,$?jsx(qe,{...Be(i$1,"code")}):null]}):null})},Ur=memo(Zi,(e,t)=>_(e,t)&&_i(e.node,t.node));Ur.displayName="MarkdownCode";var Wr=memo(Ln,(e,t)=>_(e,t));Wr.displayName="MarkdownImg";var yr={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},Zr=memo(({children:e,className:t,node:o,...n})=>{let r=f(),s=i(),a=n["data-alert-type"],c=a&&a in yr?yr[a]:void 0,l=c?s[c]:void 0,i$1=e;return l&&(i$1=[...(Array.isArray(e)?e:[e]).filter(p=>!(typeof p=="string"&&p.trim().length>0)),l]),jsx("p",{className:r("mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",t),...n,children:i$1})},(e,t)=>_(e,t));Zr.displayName="MarkdownAlertTitle";var qr=memo(({children:e,className:t,node:o,...n})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(Zr,{className:t,node:o,...n,children:e});let s=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");if(s.length===1&&isValidElement(s[0])){let a=Ce(s[0]).node,c=a==null?void 0:a.tagName;if(c==="img")return jsx(Fragment,{children:e});if(c==="code"&&"data-block"in s[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...n,children:e})},(e,t)=>_(e,t));qr.displayName="MarkdownParagraph";var Kr={ol:Vo,li:vr,ul:xr,hr:kr,strong:Pr,a:Sr,h1:Tr,h2:Er,h3:Rr,h4:Mr,h5:Ir,h6:Nr,table:Lr,thead:Ar,tbody:Dr,tr:Hr,th:Or,td:Br,blockquote:_r,code:Ur,div:Vr,img:Wr,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:Fr,sub:$r,p:qr,section:jr};var qi=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Ki=/\p{L}/u;function Tt(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,""),o,n=0,r=0;for(let s of t){if(qi.test(s)){o!=null||(o="rtl"),r+=1;continue}Ki.test(s)&&(o!=null||(o="ltr"),n+=1);}return r>n?"rtl":n>r?"ltr":o!=null?o:"ltr"}var Xi=/^[ \t]{0,3}(`{3,}|~{3,})/;var Xr=e=>{let t=e.split(`
|
|
16
|
+
`),o=null,n=0;for(let r of t){let s=Xi.exec(r);if(o===null){if(s){let a=s[1];o=a[0],n=a.length;}}else if(s){let a=s[1],c=a[0],l=a.length;c===o&&l>=n&&(o=null,n=0);}}return o!==null};var Ji=/\[\^[\w-]{1,200}\](?!:)/,Yi=/\[\^[\w-]{1,200}\]:/,Qi=/<([A-Za-z][\w:-]*)[\s>/]/,ec=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Gr=new Map,Jr=new Map,es=e=>{let t=e.toLowerCase(),o=Gr.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Gr.set(t,n),n},tc=e=>{let t=e.toLowerCase(),o=Jr.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return Jr.set(t,n),n},Yr=(e,t)=>{if(ec.has(t.toLowerCase()))return 0;let o=e.match(es(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},Qr=(e,t)=>{let o=e.match(tc(t));return o?o.length:0},oc=(e,t)=>{let o=e.match(es(t));return !!o&&o.every(n=>n.trimEnd().endsWith("/>"))},nc=e=>{let t=0;for(let o=0;o<e.length-1;o+=1)e[o]==="$"&&e[o+1]==="$"&&(t+=1,o+=1);return t},ts=e=>Ji.test(e)||Yi.test(e),rc=/\r\n|\r/g,sc=e=>new Lexer({gfm:true}).blockTokens(e),ac=`
|
|
17
|
+
|
|
18
|
+
`,lc=e=>{var t;for(let o=e.length-3;o>=0;o-=1)if((t=e.at(o))!=null&&t.endsWith(ac))return o+1;return 0},ic=e=>` ${e}`.slice(1),$o=(e,t)=>({source:e,blocks:t(e),verifiedCount:0,verifiedLength:0}),cc=(e,t,o)=>{var c,l,i,d;let n=lc(e.blocks);if(n===0)return null;let r=(c=e.verifiedCount)!=null?c:0,s=(l=e.verifiedLength)!=null?l:0;if(r>n){r=n,s=0;for(let m=0;m<r;m+=1)s+=(d=(i=e.blocks.at(m))==null?void 0:i.length)!=null?d:0;}for(;r<n;){let m=e.blocks.at(r);if(m===void 0||!t.startsWith(m,s))return null;s+=m.length,r+=1;}let a=o(t.slice(s)).map(ic);return {source:t,blocks:e.blocks.slice(0,n).concat(a),verifiedCount:r,verifiedLength:s}},Et=e=>{if(ts(e))return [e];let t=e.includes("\r")?e.replace(rc,`
|
|
19
|
+
`):e,o=sc(t),n=[],r=[],s=false;for(let a of o){let c=a.raw,l=n.length;if(r.length>0){n[l-1]+=c;let i=r.at(-1),d=Yr(c,i),m=Qr(c,i);for(let p=0;p<d;p+=1)r.push(i);for(let p=0;p<m;p+=1)r.length>0&&r.at(-1)===i&&r.pop();continue}if(a.type==="html"&&a.block){let i=c.match(Qi);if(i){let d=i[1],m=Yr(c,d),p=Qr(c,d);m>p&&!oc(c,d)&&r.push(d);}}if(a.type==="space"&&l>0){n[l-1]+=c;continue}if(l>0&&!s){let i=n[l-1];if(nc(i)%2===1){n[l-1]=i+c;continue}}n.push(c),a.type!=="space"&&(s=a.type==="code");}return n},jo=(e,t,o=Et)=>{var n;return t!=null&&t.source&&e.startsWith(t.source)?e===t.source?t:o===Et&&ts(e)?$o(e,o):(n=cc(t,e,o))!=null?n:$o(e,o):$o(e,o)};var dc=/^ {0,3}(`{3,}|~{3,})/,mc=/^\n[ \t]*\n/,ns=(e,t,o)=>{let n=t;for(;n<o&&e[n]==="`";)n+=1;return n},uc=(e,t,o,n)=>{let r=t;for(;r<o;){let s=e[r];if(s==="`"){let a=ns(e,r,o);if(a-r===n)return r;r=a;continue}if(s===`
|
|
20
|
+
`&&mc.test(e.slice(r,r+64)))return -1;r+=1;}return -1},os=(e,t,o,n)=>{let r=t;for(;r<o;){if(e[r]!=="`"){r+=1;continue}let s=ns(e,r,o),a=s-r,c=uc(e,s,o,a);if(c===-1){r=s;continue}n.push([r,c+a]),r=c+a;}},pc=e=>{let t=[],o=e.length,n=null,r=0,s=0;for(;s<o;){let a=e.indexOf(`
|
|
21
|
+
`,s),c=a===-1?o:a,l=e.slice(s,c),i=dc.exec(l);if(n){let d=i==null?void 0:i[1];d&&d[0]===n.char&&d.length>=n.length&&l.slice(i[0].length).trim()===""&&(t.push([n.start,c]),n=null,r=c);}else if(i){let d=i[1],m=l.slice(i[0].length);d[0]==="`"&&m.includes("`")||(os(e,r,s,t),n={char:d[0],length:d.length,start:s});}s=c+1;}return n?t.push([n.start,o]):os(e,r,o,t),t},fc=(e,t)=>{let o=0,n=e.length-1;for(;o<=n;){let r=Math.floor((o+n)/2),[s,a]=e[r];if(t<s)n=r-1;else if(t>=a)o=r+1;else return true}return false},Jt=e=>{let t=null;return o=>(t===null&&(t=pc(e)),fc(t,o))},rs=(e,t,o)=>{let n=Jt(e);return e.replace(t,(r,...s)=>{let a=s.findIndex(l=>typeof l=="number"),c=s[a];return n(c)?r:o(r,...s.slice(0,a))})},Yt=(e,t,o)=>{let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),r=new RegExp(`</${t}\\s*>`,"gi"),s=Jt(e),a="",c=0,l=n.exec(e);for(;l;){if(s(l.index)){l=n.exec(e);continue}let i=l.index+l[0].length;r.lastIndex=i;let d=r.exec(e);for(;d&&s(d.index);)d=r.exec(e);if(!d)break;a+=e.slice(c,l.index)+o(l[0],e.slice(i,d.index),d[0]),c=d.index+d[0].length,n.lastIndex=c,l=n.exec(e);}return c===0?e:a+e.slice(c)};var gc=/^\n*/,bc=/\n*$/,Uo=/\n\n/g,hc=(e,t,o)=>{if(!t.includes(`
|
|
22
|
+
`))return e+t+o;let r=t.replace(Uo,`
|
|
23
|
+
<!---->
|
|
24
|
+
`).replace(gc,`
|
|
25
|
+
|
|
26
|
+
`).replace(bc,`
|
|
27
|
+
|
|
28
|
+
`);return `${e}${r}${o}
|
|
29
|
+
|
|
30
|
+
`},yc=(e,t)=>{let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi"),n=new RegExp(`</${t}\\s*>`,"gi"),r=Jt(e),s=i=>{n.lastIndex=i;let d=n.exec(e);for(;d&&r(d.index);)d=n.exec(e);return d!==null},a="",c=0,l=o.exec(e);for(;l;){let i=l[0],d=l.index+i.length;if(r(l.index)){l=o.exec(e);continue}if(s(d)){l=o.exec(e);continue}let m=e.slice(d);if(a+=e.slice(c,l.index),m.length===0){a+=i,c=d,l=o.exec(e);continue}if(m.startsWith(`
|
|
31
|
+
|
|
32
|
+
`)){let u=m.slice(2).replace(Uo,`
|
|
33
|
+
<!---->
|
|
34
|
+
`);a+=`${i}
|
|
35
|
+
|
|
36
|
+
${u}`,c=e.length;break}if(!m.startsWith(`
|
|
37
|
+
`)){a+=i,c=d,l=o.exec(e);continue}let p=m.slice(1);if(p.trim().length===0){a+=i,c=d,l=o.exec(e);continue}let y=p.replace(Uo,`
|
|
38
|
+
<!---->
|
|
39
|
+
`);a+=`${i}
|
|
40
|
+
|
|
41
|
+
${y}`,c=e.length;break}return c===0?e:a+e.slice(c)},ss=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`<${n}(?=[\\s>/])((?:"[^"]*"|'[^']*'|[^"'>])*)\\/>`,"gi");o=rs(o,r,(s,a)=>`<${n}${a}></${n}>`);}for(let n of t)o=Yt(o,n,hc),o=yc(o,n);return o};var Cc=/([\\`*_~[\]|])/g,wc=e=>e.replace(Cc,"\\$1"),as=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t)o=Yt(o,n,(r,s,a)=>{let c=wc(s).replace(/\n\n/g," ");return r+c+a});return o};var xc=new Set(["blockquote","dd","dt","figcaption","h1","h2","h3","h4","h5","h6","li","p","td","th"]),ls=new Set(["code","kbd","pre","samp","var"]);function is(e){return e.children.map(t=>t.type==="text"?t.value:t.type==="element"&&!ls.has(t.tagName)?is(t):"").join("")}function cs(){return e=>{visit(e,"element",t=>{if(ls.has(t.tagName)){(t.properties)!=null||(t.properties={}),t.properties.dir="ltr";return}xc.has(t.tagName)&&((t.properties)!=null||(t.properties={}),typeof t.properties.dir!="string"&&(t.properties.dir=Tt(is(t))));});}}var ds=e=>t=>{if(!e||e.length===0)return;let o=new Set(e.map(n=>n.toLowerCase()));visit(t,"element",n=>{var s;if(!o.has(n.tagName.toLowerCase()))return;let r=n.children.filter(a=>a.type==="element").map(a=>{var c;return {tag:a.tagName,props:(c=a.properties)!=null?c:{},text:toText(a).trim()}});n.properties=(s=n.properties)!=null?s:{},n.properties["data-content"]=JSON.stringify(r),n.children=[];});};var ms=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(ms).join(""):"",us=e=>t=>{if(!e||e.length===0)return;let o=new Set(e.map(n=>n.toLowerCase()));visit(t,"element",n=>{if(o.has(n.tagName.toLowerCase())){let r=ms(n);n.children=r?[{type:"text",value:r}]:[];}});};var Ic=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),Nc=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),Lc=e=>{let t=unified().use(dl).use(ml,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},ps=(e,t=[])=>o=>{if(!e||e.length===0)return;let n=new Set(e.map(s=>s.toLowerCase())),r=new Set((t!=null?t:[]).map(s=>s.toLowerCase()));visit(o,"element",s=>{let a=s.tagName.toLowerCase();if(!n.has(a)||r.has(a)||!Ic(s))return;let c=Nc(s);if(!c.includes(`
|
|
42
|
+
`))return;let l=Lc(c);s.children=l;});};var fs=()=>e=>{visit(e,"code",t=>{var o,n;t.meta&&(t.data=(o=t.data)!=null?o:{},t.data.hProperties={...(n=t.data.hProperties)!=null?n:{},metastring:t.meta});});};var gs=/^>>>[ \t]?(.*)$/,Dc=/^<<<\s*$/,Hc=/^>+\s*$/,Oc=/^<+\s*$/,Bc=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,_c=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,Fc=/^[a-z0-9-]+$/,zc=e=>{let t=Bc.exec(e);if(!(t!=null&&t.groups))return {};let{iconParen:o,iconBrace:n,title:r,color:s}=t.groups,a=o!=null?o:n;return {icon:a&&Fc.test(a)?a:void 0,title:r!==void 0&&r.length>0?r:void 0,color:s&&_c.test(s)?s:void 0}},Wo=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),Vc=e=>{let t=new TextEncoder().encode(e),o="";for(let n of t)o+=String.fromCharCode(n);return btoa(o)},$c=(e,t)=>{var i;let o=gs.exec(e[t]),n=(i=o==null?void 0:o[1])!=null?i:"",r=zc(n),s=[],a=t+1;for(;a<e.length;a+=1){let d=e[a];if(Dc.test(d)){a+=1;break}if(Hc.test(d)||Oc.test(d)){a+=1;break}s.push(d);}let c=s.join(`
|
|
43
|
+
`).trim();return {replacement:`<div ${['class="sdm-callout"',r.title!==void 0?`data-callout-title="${Wo(r.title)}"`:"",r.color!==void 0?`data-callout-color="${Wo(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${Wo(r.icon)}"`:"",`data-callout-body="${Vc(c)}"`].filter(Boolean).join(" ")}></div>`,next:a}},bs=e=>{if(!e.includes(">>>"))return e;let t=e.split(`
|
|
44
|
+
`),o=[],n=0,r=false;for(;n<t.length;)if(gs.test(t[n])){let s=$c(t,n);o.push(s.replacement),n=s.next,r=true;}else o.push(t[n]),n+=1;return r?o.join(`
|
|
45
|
+
`):e},hs=()=>()=>{};var Uc=/^([a-zA-Z][a-zA-Z\d+\-.]*:)/,Wc=e=>new Set(e.map(t=>t.trim().toLowerCase()).filter(t=>t.length>0).map(t=>t.endsWith(":")?t:`${t}:`));function Zc(e,t){if(e.children.length!==1)return false;let[o]=e.children;if(o.type!=="text")return false;let n=Uc.exec(e.url);if(!n)return false;let r=n[1].toLowerCase();return t.has(r)?r==="mailto:"?e.url===`mailto:${o.value}`:e.url===o.value||e.url===`${r}//${o.value}`:false}var ys=(e=[])=>{let t=Wc(e);return o=>{t.size!==0&&visit(o,"link",(n,r,s)=>{if(!(!s||r===void 0)&&Zc(n,t))return s.children.splice(r,1,...n.children),r});}};var Xc={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"}]}},Gc=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,Cs=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let o="";for(let n of t)o+=Cs(n);return o},Jc=e=>{let t=e.iconPaths.map(o=>`<path d="${o.d}"${o.fillRule?` fill-rule="${o.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}}}},Yc=e=>{var m,p;let t=e.children[0];if(!t||t.type!=="paragraph")return;let o=t.children[0];if(!o||o.type!=="text")return;let n=Cs(o).trimStart(),r=n.match(Gc);if(!r)return;let s=Xc[r[1].toUpperCase()],a=n.slice(r[0].length),c=t.children.slice(1);if(a.trim().length===0&&c.length===0&&e.children.length===1)return;let l=[Jc(s)],i=[];a.length>0&&i.push({type:"text",value:a});let d=c;return ((m=d[0])==null?void 0:m.type)==="break"&&(d=d.slice(1)),i.push(...d),i.length>0&&i.some(y=>y.type!=="text"||y.value.trim().length>0)&&l.push({type:"paragraph",children:i}),l.push(...e.children.slice(1)),e.data=(p=e.data)!=null?p:{},e.data.hName="div",e.data.hProperties={className:["markdown-alert",`markdown-alert-${s.kind}`]},e.children=l,SKIP},ws=()=>e=>{visit(e,"blockquote",Yc);};var ad=/^[ \t]*<[\w!/?-]/,ld=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,id=e=>typeof e!="string"||e.length===0||!ad.test(e)?e:e.replace(ld,"$1"),Ps,Ss,Ts,Es,Rs,Ms,Is,Ns,Ls,As,Ds,Hs,Os,Qt={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(Ss=(Ps=defaultSchema.protocols)==null?void 0:Ps.href)!=null?Ss:[],"tel","streamdown"],src:[...(Es=(Ts=defaultSchema.protocols)==null?void 0:Ts.src)!=null?Es:[],"streamdown"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(Ms=(Rs=defaultSchema.attributes)==null?void 0:Rs.div)!=null?Ms:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(Ns=(Is=defaultSchema.attributes)==null?void 0:Is.p)!=null?Ns:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(As=(Ls=defaultSchema.attributes)==null?void 0:Ls.svg)!=null?As:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(Hs=(Ds=defaultSchema.attributes)==null?void 0:Ds.path)!=null?Hs:[],"d","fillRule"]},tagNames:[...(Os=defaultSchema.tagNames)!=null?Os:[],"svg","path"]},Zo={raw:Bn,sanitize:[Fs,Qt],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},cd={gfm:[rd,{}],githubAlerts:ws,containerAlerts:hs,codeMeta:fs},xs=Object.values(Zo),dd=Object.values(cd),ks=new WeakMap;function md(e){var r;let t=ks.get(e);if(t)return t;let o={...Qt,tagNames:[...(r=Qt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...Qt.attributes,...e}},n=[Zo.raw,[Fs,o],Zo.harden];return ks.set(e,n),n}var ud={block:" \u258B",circle:" \u25CF"},pd=["github-light","github-dark"],fd={enabled:true},zs=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:o,index:n,isIncomplete:r,dir:s,animatePlugin:a,...c})=>{useLayoutEffect(()=>{a==null||a.commit();}),a==null||a.setAnimateCodeBlocks(r);let l=typeof e=="string"&&o?id(e):e,i=jsx(dt,{...c,children:l});return jsx(fo.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:i}):i})},(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 o=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(o.length!==n.length||o.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)});zs.displayName="Block";var gd=memo(({children:e$1,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=xs,remarkPlugins:c$1=dd,className:l,shikiTheme:i,mermaid:d,openscad:m,plantuml:p,codeBlockMaxHeight:y=400,controls:u=true,isAnimating:b=false,scrollable:h$1,tableMaxHeight:f=300,animated:g$1,BlockComponent:C=zs,parseMarkdownIntoBlocksFn:k=Et,caret:S,listStyle:E="hierarchical",calloutIcon:R,calloutStyle:D,plugins:P,remend:M,linkSafety:V=fd,portal:j,lineNumbers:$=true,allowedTags:Z,literalTagContent:F,dataOnlyTags:U,disableAutolinkProtocols:L,translations:G,icons:q,prefix:W,onAnimationStart:K,onAnimationEnd:Q,...ie})=>{let ne=useId(),ae=useMemo(()=>c(W),[W]),le=useRef(null),re=useRef(K),Ue=useRef(Q);re.current=K,Ue.current=Q,useEffect(()=>{var A,ee,J;if(t==="static")return;let x=le.current;if(le.current=b,x===null){b&&((A=re.current)==null||A.call(re));return}b&&!x?(ee=re.current)==null||ee.call(re):!b&&x&&((J=Ue.current)==null||J.call(Ue));},[b,t]);let I=useMemo(()=>Z?Object.keys(Z):[],[Z]),z=useMemo(()=>{if(!(U!=null&&U.length))return I;let x=new Set(U.map(A=>A.toLowerCase()));return I.filter(A=>!x.has(A.toLowerCase()))},[I,U]),Te=useRef(null),Me=useMemo(()=>{if(typeof e$1!="string")return "";let x=e$1;return F&&F.length>0&&(x=as(x,F)),z.length>0&&(x=ss(x,z)),x=bs(x),x},[e$1,z,F]),ce=useMemo(()=>{let x=t==="streaming"?Te.current:null,A=jo(Me,x,k);if(Te.current=t==="streaming"?A:null,!(t==="streaming"&&n)||A.blocks.length===0)return A.blocks;let ee=A.blocks.length-1,J=A.blocks[ee],ve=sd(J,M);if(ve===J)return A.blocks;let De=A.blocks.slice();return De[ee]=ve,De},[Me,k,t,n,M]),We=useMemo(()=>g$1===true?"true":g$1?JSON.stringify(g$1):"",[g$1]),ue=useRef(null),nt=useRef([]),Ie=useRef([]),Ko=useRef(null),to=useRef("");if(We){if(to.current!==We){to.current=We;let x=We!=="true"?g$1.maxBacklogMs:void 0;ue.current=mo({maxBacklogMs:x}),nt.current=[],Ie.current=[];}else ue.current||(ue.current=mo());b&&ue.current&&ue.current.beginPass(ue.current.now());}else ue.current=null,nt.current=[],Ie.current=[],to.current="";useLayoutEffect(()=>{var x;b&&((x=ue.current)==null||x.commitPass());});let Ne=useDeferredValue(ce),Le=useMemo(()=>{if(t!=="streaming"||ue.current||Ne===ce||Ne.length===0)return ce;let x=Ne.length,A=ce.length;if(A===0)return Ne;if(x!==A)return ce;for(let J=0;J<x-1;J+=1)if(Ne[J]!==ce[J])return ce;let ee=Ne.slice();return ee[x-1]=ce[A-1],ee},[ce,Ne,t]),oo=useMemo(()=>o==="auto"?Le.map(Tt):void 0,[Le,o]),js=useMemo(()=>Le.map((x,A)=>`${ne}-${A}`),[Le.length,ne]),Us=useMemo(()=>G?JSON.stringify(G):"",[G]),Xo=useMemo(()=>({...g,...G}),[Us]),Mt=useMemo(()=>{let{inlineCode:x,...A}=s!=null?s:{},ee={...Kr,...A};if(x){let J=ee.code;ee.code=ve=>"data-block"in ve?J?createElement(J,ve):null:createElement(x,ve);}return ee},[s]),It=useMemo(()=>{let x=[];return P!=null&&P.cjk&&(x=[...x,...P.cjk.remarkPluginsBefore]),x=[...x,...c$1],L&&L.length>0&&(x=[...x,[ys,L]]),P!=null&&P.cjk&&(x=[...x,...P.cjk.remarkPluginsAfter]),P!=null&&P.math&&(x=[...x,P.math.remarkPlugin]),x},[c$1,P==null?void 0:P.math,P==null?void 0:P.cjk,L]),Ae=useMemo(()=>{let x=a;return Z&&Object.keys(Z).length>0&&a===xs&&(x=md(Z)),z.length>0&&(x=[...x,[ps,z,F!=null?F:[]]]),F&&F.length>0&&(x=[...x,[us,F]]),U&&U.length>0&&(x=[...x,[ds,U]]),P!=null&&P.math&&(x=[...x,P.math.rehypePlugin]),o==="auto"&&t==="static"&&(x=[...x,cs]),x},[a,P==null?void 0:P.math,Z,z,F,U,o,t]),Go=useMemo(()=>{var x,A;return {calloutIcon:R,calloutStyle:D,codeBlockMaxHeight:y,shikiTheme:(A=i!=null?i:(x=P==null?void 0:P.code)==null?void 0:x.getThemes())!=null?A:pd,controls:u,isAnimating:b,lineNumbers:$,listStyle:E,mode:t,mermaid:d,openscad:m,plantuml:p,linkSafety:V,portal:j,scrollable:h$1,tableMaxHeight:f,components:Mt,remarkPlugins:It,rehypePlugins:Ae}},[R,D,y,i,u,b,$,E,t,d,m,p,V,j,h$1,P==null?void 0:P.code,f,Mt,It,Ae]),Ws=useMemo(()=>S&&b?{"--streamdown-caret":`"${ud[S]}"`}:void 0,[S,b]),Zs=x=>{let A=null;if(ue.current&&b){if(!nt.current[x]){let J=We&&We!=="true"?g$1:{},{maxBacklogMs:ve,...De}=J;nt.current[x]=Lt({...De,timeline:ue.current});}A=nt.current[x];}Ko.current!==Ae&&(Ie.current=[],Ko.current=Ae),A&&!Ie.current[x]&&(Ie.current[x]=[...Ae,A.rehypePlugin]);let ee=A&&Ie.current[x]?Ie.current[x]:Ae;return {blockAnimatePlugin:A,blockRehypePlugins:ee}};return t==="static"?jsx(h.Provider,{value:Xo,children:jsx(Ot.Provider,{value:P!=null?P:null,children:jsx(T.Provider,{value:Go,children:jsx(wo,{icons:q,children:jsx(e.Provider,{value:ae,children:jsx("div",{className:ae("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",l),dir:o==="auto"?void 0:o,children:jsx(dt,{components:Mt,rehypePlugins:Ae,remarkPlugins:It,...ie,children:Me})})})})})})}):jsx(h.Provider,{value:Xo,children:jsx(Ot.Provider,{value:P!=null?P:null,children:jsx(T.Provider,{value:Go,children:jsx(wo,{icons:q,children:jsx(e.Provider,{value:ae,children:jsxs("div",{className:ae("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",S?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,l),"data-streamdown":"container",style:Ws,children:[Le.length===0&&S&&b&&jsx("span",{}),Le.map((x,A)=>{var Jo;let ee=A===Le.length-1,J=b&&ee&&Xr(x),{blockAnimatePlugin:ve,blockRehypePlugins:De}=Zs(A);return jsx(C,{animatePlugin:ve,components:Mt,content:x,dir:(Jo=oo==null?void 0:oo[A])!=null?Jo:o!=="auto"?o:void 0,index:A,isIncomplete:J,rehypePlugins:De,remarkPlugins:It,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...ie},js[A])})]})})})})})})},(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);gd.displayName="Streamdown";var Vs=/[(){}[\]]/,hd=/[\s;]/,yd=/^[\w-]+$/,Cd=/:::[\w-]+\s*$/,wd=/^[/\\]/,vd=/[/\\]$/,xd=/("[^"]*")/,kd=[["((","))"],["))","(("],["{{","}}"],["[","]"],["(",")"],[")","("]],Rt=e=>`"${e.replace(/"/g,"#quot;")}"`,Pd=e=>e.length>=2&&e.startsWith('"')&&e.endsWith('"'),Sd=e=>{var n,r,s,a;let t=e.split(`
|
|
46
|
+
`),o=0;if(((n=t[o])==null?void 0:n.trim())==="---"){for(o+=1;o<t.length&&((r=t[o])==null?void 0:r.trim())!=="---";)o+=1;o+=1;}for(;o<t.length;){let c=(a=(s=t[o])==null?void 0:s.trim())!=null?a:"";if(c&&!c.startsWith("%%")){let l=c.split(hd,1)[0];return l==="mindmap"?"mindmap":l==="flowchart"||l==="graph"?"flowchart":null}o+=1;}return null},Td=e=>{for(let[t,o]of kd){let n=e.indexOf(t);if(n===-1||!e.endsWith(o))continue;let r=e.slice(0,n);if(r&&!yd.test(r))continue;let s=e.slice(n+t.length,e.length-o.length);if(!(s.includes(o)&&o!==t))return {id:r,open:t,close:o,inner:s}}return null},Ed=e=>{let t=e.length-e.trimStart().length,o=e.slice(0,t),n=e.trim();if(!n||n.startsWith("%%")||n.startsWith("::icon"))return e;let r=Td(n);if(r)return !Pd(r.inner)&&(Vs.test(r.inner)||r.inner.includes('"'))?`${o}${r.id}${r.open}${Rt(r.inner)}${r.close}`:e;if(Vs.test(n)){let s=n.replace(Cd,"").trimEnd();return `${o}[${Rt(s)}]`}return e},Rd=e=>{let t=e.split(`
|
|
47
|
+
`),o=false;return t.map(n=>o?Ed(n):(n.trim()&&(o=true),n)).join(`
|
|
48
|
+
`)},Md=e=>e.startsWith("(")&&e.endsWith(")")||wd.test(e)||vd.test(e),qo=(e,t)=>e.split(xd).map((o,n)=>n%2===0?t(o):o).join(""),Id=e=>{if(e.trim().startsWith("%%"))return e;let t=qo(e,o=>o.replace(/\[([^[\]"]*[(){}][^[\]"]*)\]/g,(n,r)=>Md(r)?n:`[${Rt(r)}]`));return t=qo(t,o=>o.replace(/\{([^{}"]*[()[\]][^{}"]*)\}/g,(n,r)=>`{${Rt(r)}}`)),t=qo(t,o=>o.replace(/\|([^|"]*[(){}[\]][^|"]*)\|/g,(n,r)=>`|${Rt(r)}|`)),t},Nd=e=>e.split(`
|
|
49
|
+
`).map(Id).join(`
|
|
50
|
+
`),$s=e=>{let t=Sd(e);if(!t)return null;let o=t==="mindmap"?Rd(e):Nd(e);return o===e?null:o};var Dd=async(e,t,o)=>{try{return await e.render(t,o)}catch(n){let r=$s(o);if(!r)throw n;try{return await e.render(`${t}-autofix`,r)}catch(s){throw n}}},Kn=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=f(),a=i(),[c,l]=useState(null),[i$1,d]=useState(false),[m,p]=useState(""),[y,u]=useState(null),[b,h]=useState(""),[f$1,g]=useState(0),{mermaid:C}=useContext(T),k=Xe(),S=C==null?void 0:C.errorComponent,{shouldRender:E,containerRef:R}=Ze({immediate:n});if(useEffect(()=>{if(!E)return;if(!k){l(a.mermaidPluginMissing);return}(async()=>{try{l(null),d(!0);let M=k.getMermaid(o),V=e.split("").reduce((U,L)=>(U<<5)-U+L.charCodeAt(0)|0,0),j=`mermaid-${Math.abs(V)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:$}=await Dd(M,j,e),Z=ut($),F=n?$:_t($);p(F),u(Z),h(F);}catch(M){if(!(b||m)){let V=M instanceof Error?M.message:a.mermaidRenderFailed;l(V);}}finally{d(false);}})();},[e,o,f$1,E,k]),!(E||m||b))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:R});if(i$1&&!m&&!b)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:R,children:jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:s("text-sm"),children:a.diagramLoading})]})});if(c&&!m&&!b){let P=()=>g(M=>M+1);return S?jsx("div",{ref:R,children:jsx(S,{chart:e,error:c,retry:P})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:R,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:[a.mermaidErrorLabel,": ",c]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:a.showCode}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let D=m||b;return jsx("div",{className:s(n?"size-full":"max-h-[min(70vh,40rem)] w-full",t),"data-streamdown":"mermaid",ref:R,children:jsx(Ut,{className:s(n?"size-full overflow-hidden":"max-h-[min(70vh,40rem)] overflow-hidden",t),contentSize:y,fitKey:e,fullscreen:n,isAutoFit:true,maxZoom:3,minZoom:.1,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":a.mermaidChart,className:s("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:D},role:"img"})})})};export{Et as A,jo as B,id as C,Zo as D,cd as E,zs as F,gd as G,ea as a,Lt as b,rt as c,st as d,pn as e,bo as f,yo as g,Mu as h,Co as i,qe as j,xo as k,Ke as l,T as m,Vn as n,Kn as o,Qn as p,rr as q,Qe as r,je as s,Ho as t,Zt as u,et as v,vt as w,vi as x,xt as y,Tt as z};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {m,h,e}from'./chunk-GG62F4WN.js';import'./chunk-EMUDB4GM.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$1,startLine:d,lineNumbers:a,...c})=>{let{shikiTheme:l}=useContext(m),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$1,language:e$1,lineNumbers:a,maxHeight:h$1,result:p,startLine:d,...c})};export{x as HighlightedCodeBlockBody};
|
package/dist/index.d.ts
CHANGED
|
@@ -23,13 +23,13 @@ export type { IncrementalParseState } from "./lib/parse-blocks";
|
|
|
23
23
|
export { parseMarkdownIntoBlocks, parseMarkdownIntoBlocksIncremental, } from "./lib/parse-blocks";
|
|
24
24
|
export type { BundledLanguage, BundledTheme, CjkPlugin, CodeHighlighterPlugin, CustomRenderer, CustomRendererProps, DiagramPlugin, HighlightOptions, MathPlugin, PlantUmlConfig, PlantUmlInstance, PlantUmlPlugin, PluginConfig, ThemeInput, ThemeRegistrationAny, } from "./lib/plugin-types";
|
|
25
25
|
export { DefaultScrollable } from "./lib/scrollable";
|
|
26
|
-
export type { CalloutIconResolver, CalloutStyleResolver, ControlsConfig, DownloadControlConfig, LinkSafetyConfig, LinkSafetyModalProps, MermaidErrorComponentProps, MermaidOptions, OpenScadErrorComponentProps, OpenScadOptions, PlantUmlErrorComponentProps, PlantUmlOptions, PortalTarget, ScrollableComponent, ScrollableProps, StreamdownContextType, } from "./lib/streamdown-context";
|
|
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";
|
|
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";
|
|
30
30
|
export { type CSVSeparator, escapeMarkdownTableCell, extractTableDataFromElement, type TableData, tableDataToCSV, tableDataToMarkdown, tableDataToTSV, } from "./lib/table/utils";
|
|
31
31
|
export type { StreamdownTranslations } from "./lib/translations-context";
|
|
32
|
-
export { defaultTranslations } from "./lib/translations-context";
|
|
32
|
+
export { defaultTranslations, useTranslations, } from "./lib/translations-context";
|
|
33
33
|
/**
|
|
34
34
|
* Normalizes indentation in HTML blocks to prevent Markdown parsers from
|
|
35
35
|
* treating indented HTML tags as code blocks (4+ spaces = code in Markdown).
|
|
@@ -127,6 +127,22 @@ export type StreamdownProps = Options & {
|
|
|
127
127
|
* ```
|
|
128
128
|
*/
|
|
129
129
|
dataOnlyTags?: string[];
|
|
130
|
+
/**
|
|
131
|
+
* Disable GFM autolinking for specific URL protocols (e.g. bare email
|
|
132
|
+
* addresses become `mailto:` autolinks). Accepts protocol names with or
|
|
133
|
+
* without a trailing colon, case-insensitive (`"mailto"` and `"mailto:"`
|
|
134
|
+
* are equivalent). Only affects literal autolinks created by `remark-gfm`
|
|
135
|
+
* (bare URLs/emails) — explicit markdown links (`[text](url)`) are left
|
|
136
|
+
* as links.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```tsx
|
|
140
|
+
* <Streamdown disableAutolinkProtocols={["mailto"]}>
|
|
141
|
+
* {"Contact us at hello@example.com"}
|
|
142
|
+
* </Streamdown>
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
disableAutolinkProtocols?: string[];
|
|
130
146
|
/** Override UI strings for i18n / custom labels */
|
|
131
147
|
translations?: Partial<StreamdownTranslations>;
|
|
132
148
|
/** Custom icons to override the default icons used in controls */
|
|
@@ -165,4 +181,4 @@ export type BlockProps = Options & {
|
|
|
165
181
|
animatePlugin?: AnimatePlugin | null;
|
|
166
182
|
};
|
|
167
183
|
export declare const Block: import("react").MemoExoticComponent<({ content, shouldParseIncompleteMarkdown: _, shouldNormalizeHtmlIndentation, index: __, isIncomplete, dir, animatePlugin: animatePluginProp, ...props }: BlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
168
|
-
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, translations, icons: iconOverrides, prefix, onAnimationStart, onAnimationEnd, ...props }: StreamdownProps) => 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>;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export{
|
|
2
|
+
export{F as Block,i as CodeBlock,f as CodeBlockContainer,j as CodeBlockCopyButton,k as CodeBlockDownloadButton,g as CodeBlockHeader,l as CodeBlockSkeleton,d as DefaultScrollable,G as Streamdown,m as StreamdownContext,w as TableCopyDropdown,x as TableDownloadButton,y as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,D as defaultRehypePlugins,E as defaultRemarkPlugins,n as defaultUrlTransform,z as detectTextDirection,u as escapeMarkdownTableCell,r as extractTableDataFromElement,C as normalizeHtmlIndentation,A as parseMarkdownIntoBlocks,B as parseMarkdownIntoBlocksIncremental,s as tableDataToCSV,v as tableDataToMarkdown,t as tableDataToTSV,c as useIsCodeFenceIncomplete}from'./chunk-GG62F4WN.js';export{g as defaultTranslations,i as useTranslations}from'./chunk-EMUDB4GM.js';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type ComponentProps } from "react";
|
|
2
|
-
export type CodeBlockCopyButtonProps = ComponentProps<"button"> & {
|
|
2
|
+
export type CodeBlockCopyButtonProps = Omit<ComponentProps<"button">, "onCopy" | "onError"> & {
|
|
3
3
|
onCopy?: () => void;
|
|
4
4
|
onError?: (error: Error) => void;
|
|
5
5
|
timeout?: number;
|
|
6
|
+
/** Override the default `copyCode` tooltip and aria-label. */
|
|
7
|
+
label?: string;
|
|
6
8
|
};
|
|
7
|
-
export declare const CodeBlockCopyButton: ({ onCopy, onError, timeout, children, className, code: propCode, ...props }: CodeBlockCopyButtonProps & {
|
|
9
|
+
export declare const CodeBlockCopyButton: ({ onCopy, onError, timeout, children, className, code: propCode, label, ...props }: CodeBlockCopyButtonProps & {
|
|
8
10
|
code?: string;
|
|
9
11
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ComponentProps } from "react";
|
|
2
|
-
export type CodeBlockDownloadButtonProps = ComponentProps<"button"> & {
|
|
2
|
+
export type CodeBlockDownloadButtonProps = Omit<ComponentProps<"button">, "onError"> & {
|
|
3
3
|
onDownload?: () => void;
|
|
4
4
|
onError?: (error: Error) => void;
|
|
5
5
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locates the code regions of a markdown string — fenced code blocks and
|
|
3
|
+
* inline code spans — so the custom-tag preprocessors can ignore tags that are
|
|
4
|
+
* merely being *shown* rather than used.
|
|
5
|
+
*
|
|
6
|
+
* The preprocessors run on the raw string before the markdown parser, so they
|
|
7
|
+
* cannot rely on the AST to tell `<mention>` (a tag) from `` `<mention>` `` (a
|
|
8
|
+
* code span talking about the tag). Without this, a model explaining its own
|
|
9
|
+
* tag syntax in backticks would have the tag hijacked: the literal-content pass
|
|
10
|
+
* escapes everything up to the next close tag and the whole paragraph collapses
|
|
11
|
+
* into a single raw-text element.
|
|
12
|
+
*
|
|
13
|
+
* Scope: CommonMark fences (```` ``` ```` / `~~~`, up to 3 spaces of indent,
|
|
14
|
+
* closer at least as long as the opener, unclosed fence runs to EOF — which is
|
|
15
|
+
* exactly the streaming case) and inline code spans (a backtick run closed by
|
|
16
|
+
* a run of the same length, within one paragraph). Indented code blocks and
|
|
17
|
+
* fences nested inside blockquotes are not detected.
|
|
18
|
+
*/
|
|
19
|
+
/** Half-open `[start, end)` offsets into the source string. */
|
|
20
|
+
export type CodeRange = readonly [start: number, end: number];
|
|
21
|
+
/**
|
|
22
|
+
* Find all fenced code blocks and inline code spans. Ranges are returned in
|
|
23
|
+
* ascending, non-overlapping order.
|
|
24
|
+
*/
|
|
25
|
+
export declare const findCodeRanges: (markdown: string) => CodeRange[];
|
|
26
|
+
/** True when `index` falls inside one of the (sorted) `ranges`. */
|
|
27
|
+
export declare const isInsideCodeRange: (ranges: readonly CodeRange[], index: number) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Lazily-computed membership test bound to one source string. The scan is
|
|
30
|
+
* skipped entirely when the caller never asks (no tag matched).
|
|
31
|
+
*/
|
|
32
|
+
export declare const createCodeRangeLookup: (markdown: string) => ((index: number) => boolean);
|
|
33
|
+
/**
|
|
34
|
+
* `String#replace` with a global pattern, leaving matches that start inside a
|
|
35
|
+
* code range untouched.
|
|
36
|
+
*/
|
|
37
|
+
export declare const replaceOutsideCode: (markdown: string, pattern: RegExp, replacer: (match: string, ...groups: string[]) => string) => string;
|
|
38
|
+
/**
|
|
39
|
+
* Replace every `<tag …>content</tag>` pair whose open and close tags are both
|
|
40
|
+
* outside code. Open tags inside code are skipped, and a close tag inside code
|
|
41
|
+
* never terminates a pair — so `` `<tag>` `` in prose cannot swallow a real
|
|
42
|
+
* pair that follows it, and a fenced example inside a container tag cannot
|
|
43
|
+
* end the container early. Content is matched lazily (first eligible close).
|
|
44
|
+
*/
|
|
45
|
+
export declare const replaceTagPairsOutsideCode: (markdown: string, tagName: string, replacer: (open: string, content: string, close: string) => string) => string;
|
package/dist/lib/controls.d.ts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
import type { ControlsConfig } from "./streamdown-context";
|
|
1
|
+
import type { ControlsConfig, TableCopyFormat } from "./streamdown-context";
|
|
2
|
+
interface CodeCopyCallbacks {
|
|
3
|
+
onCopy?: () => void;
|
|
4
|
+
onError?: (error: Error) => void;
|
|
5
|
+
}
|
|
6
|
+
interface TableCopyCallbacks {
|
|
7
|
+
onCopy?: (format: TableCopyFormat) => void;
|
|
8
|
+
onError?: (error: Error) => void;
|
|
9
|
+
}
|
|
2
10
|
export declare const getDownloadFilename: (config: ControlsConfig, type: "code" | "table" | "mermaid" | "plantuml" | "openscad", fallback: string) => string;
|
|
11
|
+
export declare function getCopyCallbacks(config: ControlsConfig, type: "table"): TableCopyCallbacks;
|
|
12
|
+
export declare function getCopyCallbacks(config: ControlsConfig, type: "code" | "mermaid" | "plantuml" | "openscad"): CodeCopyCallbacks;
|
|
13
|
+
export {};
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
export declare const parseMarkdownIntoBlocks: (markdown: string) => string[];
|
|
2
1
|
export interface IncrementalParseState {
|
|
3
2
|
blocks: string[];
|
|
4
3
|
/** Tag-preprocessed markdown that produced `blocks` (before last-block remend). */
|
|
5
4
|
source: string;
|
|
5
|
+
/** How many leading blocks have been checked to sit at their expected offsets. */
|
|
6
|
+
verifiedCount?: number;
|
|
7
|
+
verifiedLength?: number;
|
|
6
8
|
}
|
|
9
|
+
export declare const parseMarkdownIntoBlocks: (markdown: string) => string[];
|
|
7
10
|
/**
|
|
8
11
|
* Append-only parse for streaming: keep settled prefix blocks by identity and
|
|
9
|
-
* only re-lex the unfinished tail.
|
|
10
|
-
*
|
|
12
|
+
* only re-lex the unfinished tail. A block is settled only once it ends with a
|
|
13
|
+
* blank line and at least two later blocks exist, so interruptors like `#x` or
|
|
14
|
+
* `2.` cannot change already-reused prefix blocks. Falls back to a full parse
|
|
15
|
+
* when the source is not a pure append, footnotes appear, or raw offsets drift.
|
|
11
16
|
*/
|
|
12
17
|
export declare const parseMarkdownIntoBlocksIncremental: (markdown: string, prev: IncrementalParseState | null | undefined, parseFn?: (value: string) => string[]) => IncrementalParseState;
|
|
@@ -39,5 +39,8 @@
|
|
|
39
39
|
*
|
|
40
40
|
* `parseMarkdownIntoBlocks` re-merges the interrupted open/content/close
|
|
41
41
|
* tokens so streaming still treats the whole custom tag as one block.
|
|
42
|
+
*
|
|
43
|
+
* 6. **Tags inside code** (fenced blocks, inline code spans) are ignored in
|
|
44
|
+
* every pass — they are examples being shown, not markup being used.
|
|
42
45
|
*/
|
|
43
46
|
export declare const preprocessCustomTags: (markdown: string, tagNames: string[]) => string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Root } from "mdast";
|
|
2
|
+
import type { Plugin } from "unified";
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes a list of user-supplied protocol names into a lowercase set of
|
|
5
|
+
* `"scheme:"` strings. Accepts protocols with or without a trailing colon
|
|
6
|
+
* (e.g. `"mailto"` and `"mailto:"` are equivalent) and is case-insensitive.
|
|
7
|
+
*/
|
|
8
|
+
export declare const normalizeAutolinkProtocols: (protocols: string[]) => Set<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Remark plugin that removes GFM autolink-literal links whose protocol
|
|
11
|
+
* matches one of the configured `protocols`, unwrapping them back to plain
|
|
12
|
+
* text. Must run AFTER `remark-gfm` in the plugin pipeline so the autolink
|
|
13
|
+
* nodes exist for it to inspect.
|
|
14
|
+
*
|
|
15
|
+
* Uses the standard unified `[plugin, options]` tuple form (rather than a
|
|
16
|
+
* plugin factory) so Streamdown's internal processor cache — which keys
|
|
17
|
+
* processors by plugin name plus `JSON.stringify(options)` — can tell
|
|
18
|
+
* different `protocols` configurations apart. A factory returning a fresh
|
|
19
|
+
* closure per call would always serialize to the same anonymous-function
|
|
20
|
+
* key and silently reuse a stale cached processor.
|
|
21
|
+
*
|
|
22
|
+
* A no-op (no protocols configured) skips the tree traversal entirely.
|
|
23
|
+
*/
|
|
24
|
+
export declare const remarkDisableAutolinkProtocols: Plugin<[string[]?], Root>;
|
|
@@ -6,32 +6,37 @@ import type { CSVSeparator } from "./table/utils";
|
|
|
6
6
|
export type DownloadControlConfig = boolean | {
|
|
7
7
|
filename: string;
|
|
8
8
|
};
|
|
9
|
+
export type TableCopyFormat = "csv" | "tsv" | "md";
|
|
10
|
+
export type CopyControlConfig<TOnCopy = () => void> = boolean | {
|
|
11
|
+
onCopy?: TOnCopy;
|
|
12
|
+
onError?: (error: Error) => void;
|
|
13
|
+
};
|
|
9
14
|
export type ControlsConfig = boolean | {
|
|
10
15
|
table?: boolean | {
|
|
11
|
-
copy?:
|
|
16
|
+
copy?: CopyControlConfig<(format: TableCopyFormat) => void>;
|
|
12
17
|
csvSeparator?: CSVSeparator;
|
|
13
18
|
download?: DownloadControlConfig;
|
|
14
19
|
fullscreen?: boolean;
|
|
15
20
|
};
|
|
16
21
|
code?: boolean | {
|
|
17
|
-
copy?:
|
|
22
|
+
copy?: CopyControlConfig;
|
|
18
23
|
download?: DownloadControlConfig;
|
|
19
24
|
};
|
|
20
25
|
mermaid?: boolean | {
|
|
21
26
|
download?: DownloadControlConfig;
|
|
22
|
-
copy?:
|
|
27
|
+
copy?: CopyControlConfig;
|
|
23
28
|
fullscreen?: boolean;
|
|
24
29
|
panZoom?: boolean;
|
|
25
30
|
};
|
|
26
31
|
plantuml?: boolean | {
|
|
27
32
|
download?: DownloadControlConfig;
|
|
28
|
-
copy?:
|
|
33
|
+
copy?: CopyControlConfig;
|
|
29
34
|
fullscreen?: boolean;
|
|
30
35
|
panZoom?: boolean;
|
|
31
36
|
};
|
|
32
37
|
openscad?: boolean | {
|
|
33
38
|
download?: DownloadControlConfig;
|
|
34
|
-
copy?:
|
|
39
|
+
copy?: CopyControlConfig;
|
|
35
40
|
fullscreen?: boolean;
|
|
36
41
|
};
|
|
37
42
|
image?: boolean | {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { TableCopyFormat } from "../streamdown-context";
|
|
1
2
|
export interface TableCopyDropdownProps {
|
|
2
3
|
children?: React.ReactNode;
|
|
3
4
|
className?: string;
|
|
4
|
-
onCopy?: (format:
|
|
5
|
+
onCopy?: (format: TableCopyFormat) => void;
|
|
5
6
|
onError?: (error: Error) => void;
|
|
6
7
|
timeout?: number;
|
|
7
8
|
}
|
|
@@ -7,7 +7,9 @@ export interface StreamdownTranslations {
|
|
|
7
7
|
close: string;
|
|
8
8
|
copied: string;
|
|
9
9
|
copyCode: string;
|
|
10
|
+
copyDiagram: string;
|
|
10
11
|
copyLink: string;
|
|
12
|
+
copyModel: string;
|
|
11
13
|
copyTable: string;
|
|
12
14
|
copyTableAsCsv: string;
|
|
13
15
|
copyTableAsMarkdown: string;
|
|
@@ -30,6 +32,7 @@ export interface StreamdownTranslations {
|
|
|
30
32
|
exitFullscreen: string;
|
|
31
33
|
externalLinkWarning: string;
|
|
32
34
|
imageNotAvailable: string;
|
|
35
|
+
mermaidChart: string;
|
|
33
36
|
mermaidErrorLabel: string;
|
|
34
37
|
mermaidFormatMmd: string;
|
|
35
38
|
mermaidFormatPng: string;
|
|
@@ -43,9 +46,11 @@ export interface StreamdownTranslations {
|
|
|
43
46
|
openscadFormatScad: string;
|
|
44
47
|
openscadFormatStl: string;
|
|
45
48
|
openscadLoading: string;
|
|
49
|
+
openscadModel: string;
|
|
46
50
|
openscadPluginMissing: string;
|
|
47
51
|
openscadRenderFailed: string;
|
|
48
52
|
openscadWriting: string;
|
|
53
|
+
plantumlChart: string;
|
|
49
54
|
plantumlErrorLabel: string;
|
|
50
55
|
plantumlFormatPng: string;
|
|
51
56
|
plantumlFormatPuml: string;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {f,i}from'./chunk-EMUDB4GM.js';import {useRef,useEffect}from'react';import {jsx}from'react/jsx-runtime';var z=p=>{p.traverse(i=>{let o=i;if(o.geometry&&o.geometry.dispose(),Array.isArray(o.material))for(let u of o.material)u.dispose();else o.material&&o.material.dispose();});},q=({className:p,data:i$1,format:o,fullscreen:u=false})=>{let P=f(),R=i(),b=useRef(null);return useEffect(()=>{let m=b.current;if(!m)return;let y=false,g=()=>{};return (async()=>{let e=await import('three'),[{STLLoader:j},{ThreeMFLoader:E},{OrbitControls:V}]=await Promise.all([import('three/examples/jsm/loaders/STLLoader.js'),import('three/examples/jsm/loaders/3MFLoader.js'),import('three/examples/jsm/controls/OrbitControls.js')]);if(y)return;let n=new e.WebGLRenderer({alpha:true,antialias:true});n.setPixelRatio(window.devicePixelRatio),m.appendChild(n.domElement);let c=new e.Scene,t=new e.PerspectiveCamera(45,1,.1,2e3),x=new e.Vector3(50,40,60).normalize();t.position.copy(x.clone().multiplyScalar(100));let s=new V(t,n.domElement);s.enableDamping=true,s.dampingFactor=.08;let A=new e.HemisphereLight(16777215,3159357,1.5);c.add(A);let M=new e.DirectionalLight(16777215,2.6);M.position.set(1,1.7,1.2),c.add(M);let v=new e.DirectionalLight(16777215,.7);v.position.set(-1,.5,-1),c.add(v);let r=new e.Group;c.add(r);let C=()=>{for(;r.children.length>0;){let a=r.children[0];r.remove(a),z(a);}let l=i$1.buffer.slice(i$1.byteOffset,i$1.byteOffset+i$1.byteLength);if(o==="3mf"){let a=new E().parse(l);r.add(a);}else {let a=new j().parse(l);a.computeVertexNormals();let F=new e.MeshStandardMaterial({color:9081504,roughness:.55,metalness:.1});r.add(new e.Mesh(a,F));}let d=new e.Box3().setFromObject(r),h=d.getSize(new e.Vector3),w=Math.max(h.x,h.y,h.z)||1,L=d.getCenter(new e.Vector3),T=w*2.2,f=t.position.clone().sub(s.target).normalize();(!Number.isFinite(f.x)||f.lengthSq()===0)&&f.copy(x),s.target.copy(L),t.position.copy(L).add(f.multiplyScalar(T)),t.near=Math.max(w/1e3,.01),t.far=Math.max(w*100,1e3),t.updateProjectionMatrix(),s.update();},O=()=>{let{clientHeight:l,clientWidth:d}=m;d===0||l===0||(t.aspect=d/l,t.updateProjectionMatrix(),n.setSize(d,l));},D=new ResizeObserver(O);D.observe(m),O(),C(),n.setAnimationLoop(()=>{s.update(),n.render(c,t);}),g=()=>{D.disconnect(),n.setAnimationLoop(null),s.dispose(),z(r),c.clear(),n.dispose(),n.domElement.remove();};})().catch(()=>{}),()=>{y=true,g();}},[i$1,o]),jsx("div",{"aria-label":R.openscadModel,className:P(u?"size-full":"h-[400px] w-full",p),"data-streamdown":"openscad-viewer",ref:b,role:"img"})};export{q as OpenScadViewer};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofcz/streamdown",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"typescript": "^7.0.2",
|
|
54
54
|
"vitest": "^4.1.10",
|
|
55
55
|
"@streamdown/cjk": "npm:@lofcz/streamdown-cjk@1.0.3",
|
|
56
|
-
"@streamdown/
|
|
57
|
-
"@streamdown/
|
|
56
|
+
"@streamdown/mermaid": "npm:@lofcz/streamdown-mermaid@1.0.2",
|
|
57
|
+
"@streamdown/math": "npm:@lofcz/streamdown-math@1.0.3"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": "^18.0.0 || ^19.0.0",
|
package/dist/chunk-JVTSQQFX.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {a,f,b,c,e,d}from'./chunk-O747JC4Y.js';import {createContext,memo,useContext,useMemo,lazy,isValidElement,useLayoutEffect,useId,useRef,useEffect,useDeferredValue,cloneElement,createElement,useState,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import In from'rehype-raw';import Rs,{defaultSchema}from'rehype-sanitize';import Hc from'remark-gfm';import Oc 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 ol from'remark-parse';import nl 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 _s=300,Vs="300px",zs=500;function je(e={}){let{immediate:t=false,debounceDelay:o=_s,rootMargin:n=Vs,idleTimeout:r=zs}=e,[s,a]=useState(false),c=useRef(null),l=useRef(null),i=useRef(null),d=useMemo(()=>g=>{let u=Date.now();return window.setTimeout(()=>{g({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-u))});},1)},[]),m=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(g,u)=>window.requestIdleCallback(g,u):d,[d]),p=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?g=>window.cancelIdleCallback(g):g=>{clearTimeout(g);},[]);return useEffect(()=>{if(t){a(true);return}let g=c.current;if(!g)return;l.current&&(clearTimeout(l.current),l.current=null),i.current&&(p(i.current),i.current=null);let u=()=>{l.current&&(clearTimeout(l.current),l.current=null),i.current&&(p(i.current),i.current=null);},b=w=>{i.current=m(P=>{P.timeRemaining()>0||P.didTimeout?(a(true),w.disconnect()):i.current=m(()=>{a(true),w.disconnect();},{timeout:r/2});},{timeout:r});},f=w=>{u(),l.current=window.setTimeout(()=>{var M,E;let P=w.takeRecords();(P.length===0||(E=(M=P.at(-1))==null?void 0:M.isIntersecting)!=null&&E)&&b(w);},o);},h=(w,P)=>{w.isIntersecting?f(P):u();},y=new IntersectionObserver(w=>{for(let P of w)h(P,y);},{rootMargin:n,threshold:0});return y.observe(g),()=>{l.current&&clearTimeout(l.current),i.current&&p(i.current),y.disconnect();}},[t,o,n,r,p,m]),{shouldRender:s,containerRef:c}}var $s=320,js=4,Xo=()=>typeof performance=="undefined"?Date.now():performance.now();function ao(e){var s,a;let t=(s=e==null?void 0:e.now)!=null?s:Xo,o=(a=e==null?void 0:e.maxBacklogMs)!=null?a:$s,n=0,r=0;return {now:t,beginPass(c){r=Math.min(Math.max(n,c),c+o);},mark(){return r},rewind(c){r=c;},take(c,l,i){if(c<=0)return {baseDelay:0,step:Math.max(0,l)};let d=Math.max(0,l),m=d===0?0:Math.min(d,js),p=Math.max(r,i),g=i+o,u=p+Math.max(0,c-1)*d,b=d;if(u>g&&c>1)if(p<g){let h=g-p;b=Math.max(m,h/(c-1));}else b=m;let f=Math.max(0,Math.round(p-i));return r=p+c*b,{baseDelay:f,step:b}},commitPass(){n=r;}}}function Us(){return {current:0}}var Jo=/\s/,lo=/^\s+$/,Ws=new Set(["pre","svg","math","annotation"]),Zs=new Set(["svg","math","annotation"]),so=new Set(["img","hr"]),qs=new Set(["ul","ol","li"]),He=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",io=(e,t)=>{let o=t?Zs:Ws;return e.some(n=>He(n)&&o.has(n.tagName))},Ks=e=>{for(let t=e.length-1;t>=0;t-=1){let o=e[t];if(He(o)&&o.tagName==="li")return o}},Gs=(e,t,o,n)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate-marker"]=true,e.properties.style=`--sd-marker-duration:${t}ms;--sd-marker-delay:${o}ms;--sd-marker-easing:${n}`;},Yo=e=>{for(let t of e.children)if(He(t)){if(t.tagName==="input")return t;if(qs.has(t.tagName))continue;let o=Yo(t);if(o)return o}},Qo=(e,t,o,n)=>{(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:${o}ms;--sd-easing:${t.easing};--sd-delay:${n}ms`;},Xs=(e,t,o,n)=>{let r=Yo(e);r&&Qo(r,t,o,n);},en=e=>{var t;for(let o=e.length-1;o>=0;o-=1){let n=e[o];if(He(n)){if((t=n.properties)!=null&&t["data-sd-animated"])break;n.properties={...n.properties,"data-sd-animated":true};}}},tn=e=>{let t=[],o="",n=false;for(let r of e){let s=Jo.test(r);if(s!==n&&o){if(s){o+=r,n=true;continue}t.push(o),o="";}o+=r,n=s;}return o&&t.push(o),t},on=e=>{let t=[],o="";for(let n of e)Jo.test(n)?t.length>0&&!lo.test(t.at(-1))?t[t.length-1]+=n:o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&(t.length>0?t[t.length-1]+=o:t.push(o)),t},Js=(e,t,o,n,r,s)=>{let a=`--sd-animation:sd-${t};--sd-duration:${r?0:o}ms;--sd-easing:${n}`;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}]}},Ys=(e,t,o,n)=>{let r=0,s=0;return visitParents(e,a=>a.type==="text"||He(a)&&so.has(a.tagName),(a,c)=>{if(io(c,o.animateCodeBlocks))return SKIP$1;if(He(a)&&so.has(a.tagName)){n>0&&s<n||(r+=1),s+=1;return}let l=a.value;if(!l.trim()){s+=l.length;return}let i=t.sep==="char"?on(l):tn(l);for(let d of i){let m=s;s+=d.length,!lo.test(d)&&(n>0&&m<n||(r+=1));}}),r},Qs=(e,t,o,n,r,s)=>{if(io(t,n.animateCodeBlocks))return;let a=n.prevContentLength,c=r.count;r.count+=1;let l=a>0&&c<a,i=l?0:s.baseDelay+r.newIndex++*s.step;Qo(e,o,l?0:o.duration,i),en(t);},ea=(e,t,o,n,r,s)=>{var h;let a=t.at(-1);if(!(a&&"children"in a))return;if(io(t,n.animateCodeBlocks))return SKIP$1;let c=a,l=c.children.indexOf(e);if(l===-1)return;let i=e.value;if(!i.trim()){r.count+=i.length;return}let d=o.sep==="char"?on(i):tn(i),m=n.prevContentLength,p=false,g=Ks(t),u=!!(g&&!((h=g.properties)!=null&&h["data-sd-animate-marker"])),b=false,f=d.map(y=>{let w=r.count;if(r.count+=y.length,lo.test(y))return {type:"text",value:y};let P=m>0&&w<m,S=P?0:s.baseDelay+r.newIndex++*s.step;if(g&&u&&!b){let M=P?0:o.duration;Gs(g,M,S,o.easing),Xs(g,o,M,S),b=true;}return p=true,Js(y,o.animation,o.duration,o.easing,P,S)});return p&&en(t),c.children.splice(l,1,...f),l+f.length},ta=0;function Rt(e){var s,a,c,l,i;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:(c=e==null?void 0:e.easing)!=null?c:"ease",sep:(l=e==null?void 0:e.sep)!=null?l:"word",stagger:(i=e==null?void 0:e.stagger)!=null?i:40,timeline:e==null?void 0:e.timeline},o={animateCodeBlocks:false,committedCharCount:0,prevContentLength:0,lastRenderCharCount:0,pendingMark:null},n=ta++,r=()=>d=>{var b;let m={count:0,newIndex:0};o.prevContentLength=o.committedCharCount;let p=t.timeline,g=(b=p==null?void 0:p.now())!=null?b:Xo();p&&(o.pendingMark===null?o.pendingMark=p.mark():p.rewind(o.pendingMark));let u=p?p.take(Ys(d,t,o,o.prevContentLength),t.stagger,g):{baseDelay:0,step:t.stagger};visitParents(d,f=>f.type==="text"||He(f)&&so.has(f.tagName),(f,h)=>{if(f.type==="text")return ea(f,h,t,o,m,u);Qs(f,h,t,o,m,u);}),o.lastRenderCharCount=m.count,o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(d){o.animateCodeBlocks=d;},setPrevContentLength(d){o.committedCharCount=d,o.prevContentLength=d;},getLastRenderCharCount(){return o.lastRenderCharCount},commit(){o.committedCharCount=o.lastRenderCharCount,o.pendingMark=null;}}}Rt();var co=createContext(false),ot=()=>useContext(co);var nt=({scrollRef:e,ref:t,...o})=>jsx("div",{ref:e,...o});var la=8,ia=e=>e.scrollHeight-e.scrollTop-e.clientHeight<la,an=e=>{var o,n;let t=(n=(o=e.touches[0])!=null?o:e.changedTouches[0])!=null?n:null;return typeof(t==null?void 0:t.clientY)=="number"?t.clientY:null},Lt=({enabled:e,isAnimating:t,content:o})=>{let[n,r]=useState(null),s=useRef(true),a=useRef(0),c=useCallback(i=>{r(d=>d===i?d:i);},[]),l=useCallback(i=>{t&&s.current&&(i.scrollTo({top:i.scrollHeight,behavior:"instant"}),a.current=i.scrollTop);},[t]);return useEffect(()=>{t||(s.current=true);},[t]),useEffect(()=>{if(!(e&&n))return;a.current=n.scrollTop;let i=()=>{s.current=false;},d=f=>{f.deltaY<0&&i();},m=null,p=f=>{m=an(f);},g=f=>{if(m===null)return;let h=an(f);if(h===null)return;let y=h-m;Math.abs(y)<=3||(y>0&&i(),m=h);},u=()=>{m=null;},b=()=>{let f=n.scrollTop<a.current;if(a.current=n.scrollTop,f){i();return}ia(n)&&(s.current=true);};return n.addEventListener("wheel",d,{capture:true,passive:true}),n.addEventListener("touchstart",p,{passive:true}),n.addEventListener("touchmove",g,{passive:true}),n.addEventListener("touchend",u,{passive:true}),n.addEventListener("touchcancel",u,{passive:true}),n.addEventListener("scroll",b,{passive:true}),()=>{n.removeEventListener("wheel",d,{capture:true}),n.removeEventListener("touchstart",p),n.removeEventListener("touchmove",g),n.removeEventListener("touchend",u),n.removeEventListener("touchcancel",u),n.removeEventListener("scroll",b);}},[e,n]),useLayoutEffect(()=>{if(!(e&&n)||(l(n),typeof ResizeObserver=="undefined"))return;let i=new ResizeObserver(()=>{l(n);});i.observe(n);for(let d of n.children)i.observe(d);return ()=>{i.disconnect();}},[o,n,e,l]),c};var ma=a("block"),ua=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"),pa=e=>{let t={};for(let o of e.split(";")){let n=o.indexOf(":");if(n>0){let r=o.slice(0,n).trim(),s=o.slice(n+1).trim();r&&s&&(t[r]=s);}}return t},ln=memo(({children:e,result:t,language:o,className:n,maxHeight:r,startLine:s,lineNumbers:a=true,...c})=>{let l=f(),{isAnimating:i,scrollable:d}=useContext(T),m=d!=null?d:nt,p=b(r),g=Lt({content:t,enabled:!!p,isAnimating:i}),u=useMemo(()=>l(ua),[l]),b$1=useMemo(()=>l(ma),[l]),f$1=useMemo(()=>{let h={};return t.bg&&(h["--sdm-bg"]=t.bg),t.fg&&(h["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(h,pa(t.rootStyle)),h},[t.bg,t.fg,t.rootStyle]);return jsx(m,{className:l(n,p?"overflow-x-auto overflow-y-auto":"overflow-x-auto","rounded-md border border-border bg-background p-4 text-sm"),"data-language":o,"data-streamdown":"code-block-body",scrollRef:g,style:p?{maxHeight:p}:void 0,...c,children:jsx("pre",{className:l(n,"bg-[var(--sdm-bg,inherit)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]"),style:f$1,children:jsx("code",{className:a?l("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&s&&s>1?{counterReset:`line ${s-1}`}:void 0,children:t.tokens.map((h,y)=>jsx("span",{className:a?u:b$1,children:h.length===0||h.length===1&&h[0].content===""?`
|
|
3
|
-
`:h.map((w,P)=>{let S={},M=!!w.bgColor;if(w.color&&(S["--sdm-c"]=w.color),w.bgColor&&(S["--sdm-tbg"]=w.bgColor),w.htmlStyle)for(let[E,A]of Object.entries(w.htmlStyle))E==="color"?S["--sdm-c"]=A:E==="background-color"?(S["--sdm-tbg"]=A,M=true):S[E]=A;return jsx("span",{className:l("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",M&&"bg-[var(--sdm-tbg)]",M&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:S,...w.htmlAttrs,children:w.content},P)})},y))})})})});var uo=({className:e,language:t,style:o,isIncomplete:n,...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":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r})};var po=createContext({code:""}),Nt=()=>useContext(po);var fo=({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 Ca=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
|
-
`;)t--;return e.slice(0,t)},va=lazy(()=>import('./highlighted-body-75V7K46X.js').then(e=>({default:e.HighlightedCodeBlockBody}))),go=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,lineNumbers:a,...c})=>{let l=f(),{codeBlockMaxHeight:i}=useContext(T),d=useMemo(()=>Ca(e),[e]),m=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
|
|
5
|
-
`).map(p=>[{content:p,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]);return jsx(po.Provider,{value:{code:e},children:jsxs(uo,{dir:"ltr",isIncomplete:r,language:t,children:[jsx(fo,{language:t}),n?jsx("div",{className:l("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("div",{className:l("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:n})}):null,jsx(Suspense,{fallback:jsx(ln,{className:o,language:t,lineNumbers:a,maxHeight:i,result:m,startLine:s,...c}),children:jsx(va,{className:o,code:d,language:t,lineNumbers:a,maxHeight:i,raw:m,startLine:s,...c})})]})})};var mn=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"})}),un=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"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"})}),pn=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"})}),fn=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"})]}),gn=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"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"})}),bn=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"})}),hn=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),yn=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),wn=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"})}),Cn=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 st={CheckIcon:mn,CopyIcon:un,DownloadIcon:pn,ExternalLinkIcon:yn,Loader2Icon:fn,Maximize2Icon:gn,RotateCcwIcon:bn,XIcon:hn,ZoomInIcon:wn,ZoomOutIcon:Cn},xn=createContext(st),Ta=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let o=Object.keys(e),n=Object.keys(t);return o.length!==n.length?false:o.every(r=>e[r]===t[r])},bo=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...st,...e}:st);Ta(o.current,e)||(o.current=e,n.current=e?{...st,...e}:st);let r=n.current;return jsx(xn.Provider,{value:r,children:t})},D=()=>useContext(xn);var It={alertNote:"Note",alertTip:"Tip",alertImportant:"Important",alertWarning:"Warning",alertCaution:"Caution",copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",downloadDiagramAsPuml:"Download diagram as PlantUML",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",diagramLoading:"Loading 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",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",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",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"},At=createContext(It),I=()=>useContext(At);var Ue=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let c=f(),[l,i]=useState(false),d=useRef(0),{code:m}=Nt(),{isAnimating:p}=useContext(T),g=I(),u=s!=null?s:m,b=async()=>{var y;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{l||(await navigator.clipboard.writeText(u),i(!0),e==null||e(),d.current=window.setTimeout(()=>i(!1),o));}catch(w){t==null||t(w);}};useEffect(()=>()=>{window.clearTimeout(d.current);},[]);let f$1=D(),h=l?f$1.CheckIcon:f$1.CopyIcon;return jsxs(Fragment,{children:[jsx("button",{"aria-label":g.copyCode,className:c("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:p,onClick:b,title:g.copyCode,type:"button",...a,children:n!=null?n:jsx(h,{"aria-hidden":"true",size:14})}),l&&jsx("output",{"aria-live":"polite",className:"sr-only",children:g.copied})]})};var ue=(e,t,o)=>{if(typeof e=="boolean")return o;let n=e[t];if(typeof n!="object")return o;let r=n.download;return typeof r!="object"?o:r.filename||o};var kn={"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",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",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"},yo=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let c=f(),{code:l}=Nt(),{isAnimating:i,controls:d$1}=useContext(T),m=I(),p=D(),g=s!=null?s:l,u=o&&o in kn?kn[o]:"txt",b=`${ue(d$1,"code","file")}.${u}`,f$1="text/plain",h=()=>{try{d(b,g,f$1),e==null||e();}catch(y){t==null||t(y);}};return jsx("button",{"aria-label":m.downloadFile,className:c("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:i,onClick:h,title:m.downloadFile,type:"button",...a,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var We=()=>{let{Loader2Icon:e}=D(),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 at=0,le=()=>{at+=1,at===1&&(document.body.style.overflow="hidden");},ie=()=>{at=Math.max(0,at-1),at===0&&(document.body.style.overflow="");};var _a=["github-light","github-dark"],Va={enabled:true},za={codeBlockMaxHeight:400,shikiTheme:_a,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,openscad:void 0,plantuml:void 0,linkSafety:Va,portal:void 0,tableMaxHeight:300},T=createContext(za);var Wa=/\.[^/.]+$/,Tn=(e,t)=>{if(typeof e=="boolean")return e;let o=e.image;return o===false?false:o===true||o===void 0?true:o[t]!==false},Mn=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,onClick:a,...c})=>{let{DownloadIcon:l,XIcon:i}=D(),d$1=f(),m=useRef(null),[p,g]=useState(false),[u,b]=useState(false),[f$1,h]=useState(false),{controls:y}=useContext(T),w=I(),P=Tn(y,"download"),S=Tn(y,"fullscreen"),M=c.width!=null||c.height!=null,E=P&&(p||M)&&!u,A=u&&!M,C=S&&!!o&&!u&&p;useEffect(()=>{let L=m.current;if(L!=null&&L.complete){let $=L.naturalWidth>0;g($),b(!$);}},[]),useEffect(()=>{if(!f$1)return;le();let L=$=>{$.key==="Escape"&&h(false);};return document.addEventListener("keydown",L),()=>{document.removeEventListener("keydown",L),ie();}},[f$1]);let _=useCallback(L=>{g(true),b(false),r==null||r(L);},[r]),U=useCallback(L=>{g(false),b(true),s==null||s(L);},[s]),oe=useCallback(()=>{C&&h(true);},[C]),V=useCallback(()=>{h(false);},[]),W=useCallback(L=>{a==null||a(L),!L.defaultPrevented&&oe();},[a,oe]),F=async L=>{if(L.stopPropagation(),!!o)try{let Z=await(await fetch(o)).blob(),K=new URL(o,window.location.origin).pathname.split("/").pop()||"",se=K.split(".").pop(),ge=K.includes(".")&&se!==void 0&&se.length<=4,ae="";if(ge)ae=K;else {let ce=Z.type,G="png";ce.includes("jpeg")||ce.includes("jpg")?G="jpg":ce.includes("png")?G="png":ce.includes("svg")?G="svg":ce.includes("gif")?G="gif":ce.includes("webp")&&(G="webp"),ae=`${(n||K||"image").replace(Wa,"")}.${G}`;}d(ae,Z,Z.type);}catch($){window.open(o,"_blank");}};return o?o==="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:n,className:d$1("m-0 block h-auto max-w-full rounded-lg",C&&"cursor-zoom-in",A&&"hidden",t),"data-streamdown":"image",onClick:W,onError:U,onLoad:_,ref:m,src:o,...c}),A&&jsx("span",{className:d$1("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:w.imageNotAvailable}),E&&jsx("button",{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:F,title:w.downloadImage,type:"button",children:jsx(l,{size:14})})]}),f$1?createPortal(jsxs("div",{className:d$1("fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4"),"data-streamdown":"image-lightbox",onClick:V,onKeyDown:L=>{L.key==="Escape"&&V();},role:"button",tabIndex:0,children:[jsx("button",{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:V,title:w.exitFullscreen,type:"button",children:jsx(i,{size:20})}),jsx("div",{onClick:L=>L.stopPropagation(),onKeyDown:L=>L.stopPropagation(),role:"presentation",children:jsx("img",{alt:n,className:d$1("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:o})})]}),document.body):null]}):null};var he=e=>{let t=typeof e=="function"?e():e;return t!=null?t:document.body};var Ln=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:c}=D(),l=f(),[i,d]=useState(false),m=I(),{portal:p}=useContext(T),g=useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(f){}},[e]),u=useCallback(()=>{n(),o();},[n,o]);if(useEffect(()=>{if(t){le();let f=h=>{h.key==="Escape"&&o();};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),ie();}}},[t,o]),!t||typeof document=="undefined")return null;let b=jsx("div",{className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:o,onKeyDown:f=>{f.key==="Escape"&&o();},role:"button",tabIndex:0,children:jsxs("div",{className:l("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:f=>f.stopPropagation(),onKeyDown:f=>f.stopPropagation(),role:"presentation",children:[jsx("button",{className:l("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:o,title:m.close,type:"button",children:jsx(c,{size:16})}),jsxs("div",{className:l("flex flex-col gap-2"),children:[jsxs("div",{className:l("flex items-center gap-2 font-semibold text-lg"),children:[jsx(a,{size:20}),jsx("span",{children:m.openExternalLink})]}),jsx("p",{className:l("text-muted-foreground text-sm"),children:m.externalLinkWarning})]}),jsx("div",{className:l("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:l("flex gap-2"),children:[jsx("button",{className:l("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:g,type:"button",children:i?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:l("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:u,type:"button",children:[jsx(a,{size:14}),jsx("span",{children:m.openLink})]})]})]})});return createPortal(b,he(p))};var Nn=()=>e=>{visit(e,"html",(o,n,r)=>{!r||typeof n!="number"||(r.children[n]={type:"text",value:o.value});});};var An=[],Dn={allowDangerousHtml:true},Dt=new WeakMap,ko=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let o=this.keyCache.get(t);if(o)return o;let n=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return "";let p="";for(let g=0;g<m.length;g+=1){let u=m[g];if(g>0&&(p+=","),Array.isArray(u)){let[b,f]=u;if(typeof b=="function"){let h=Dt.get(b);h||(h=b.name,Dt.set(b,h)),p+=h;}else p+=String(b);p+=":",p+=JSON.stringify(f);}else if(typeof u=="function"){let b=Dt.get(u);b||(b=u.name,Dt.set(u,b)),p+=b;}else p+=String(u);}return p},c=a(n),l=a(r),i=s?JSON.stringify(s):"",d=`${l}::${c}::${i}`;return this.keyCache.set(t,d),d}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(n,o);}clear(){this.cache.clear();}},Hn=new ko,it=e=>{let t=al(e),o=e.children||"",n=t.runSync(t.parse(o),o);return ul(n,e)},al=e=>{let t=Hn.get(e);if(t)return t;let o=il(e);return Hn.set(e,o),o},ll=e=>e.some(t=>Array.isArray(t)?t[0]===In:t===In),il=e=>{let t=e.rehypePlugins||An,o=e.remarkPlugins||An,n=ll(t)?o:[...o,Nn],r=e.remarkRehypeOptions?{...Dn,...e.remarkRehypeOptions}:Dn;return unified().use(ol).use(n).use(nl,r).use(t)},On=e=>e,cl=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},dl=(e,t)=>{var o;for(let n in urlAttributes)if(Object.hasOwn(urlAttributes,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],s=urlAttributes[n];(s===null||s.includes(e.tagName))&&(e.properties[n]=(o=t(String(r||""),n,e))!=null?o:void 0);}},ml=(e,t,o,n,r,s)=>{let a=false;return n?a=!n.includes(e.tagName):r&&(a=r.includes(e.tagName)),!a&&s&&typeof t=="number"&&(a=!s(e,t,o)),a},ul=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:c}=t;if(o||n||r||s||c){let i=c||On;visit(e,(d,m,p)=>{if(d.type==="raw"&&p&&typeof m=="number")return cl(p,m,s,d.value),m;if(d.type==="element"&&(dl(d,i),ml(d,m,p,n,r,o)&&p&&typeof m=="number"))return a&&d.children?p.children.splice(m,1,...d.children):p.children.splice(m,1),m});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var Ht=createContext(null),ct=()=>useContext(Ht),iu=()=>{var t;let e=ct();return (t=e==null?void 0:e.code)!=null?t:null},Ze=()=>{var t;let e=ct();return (t=e==null?void 0:e.mermaid)!=null?t:null},qe=()=>{var t;let e=ct();return (t=e==null?void 0:e.plantuml)!=null?t:null},Ke=()=>{var t;let e=ct();return (t=e==null?void 0:e.openscad)!=null?t:null};var Bn=e=>{var o;let t=ct();return t!=null&&t.renderers&&e&&(o=t.renderers.find(n=>Array.isArray(n.language)?n.language.includes(e):n.language===e))!=null?o:null};var gl=/(<svg\b)/,Vn=/<svg\b[^>]*>/i,bl=/\bviewBox=(['"])(.*?)\1/i,hl=/\swidth=(['"]).*?\1/gi,yl=/\sheight=(['"]).*?\1/gi,Fn=/\sstyle=(['"])(.*?)\1/i,_n=/^<svg/i,wl=/^width\s*:/i,Cl=/^height\s*:/i,vl=/^max-width\s*:/i,xl=/[\s,]+/,kl=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(gl,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),Ot=e=>{if(typeof DOMParser=="undefined"||typeof XMLSerializer=="undefined")return e;let o=new DOMParser().parseFromString(e,"text/html").querySelector("svg");return o?new XMLSerializer().serializeToString(o):e},dt=e=>{let t=e.match(Vn);if(!t)return null;let n=t[0].match(bl),r=n==null?void 0:n[2];if(!r)return null;let s=r.trim().split(xl).map(l=>Number.parseFloat(l));if(s.length<4||s.slice(0,4).some(Number.isNaN))return null;let a=s[2],c=s[3];return a>0&&c>0?{height:c,width:a}:null},Bt=e=>{let t=e.match(Vn);if(!t)return e;try{let o=t[0],n=dt(e);if(!n)return e;let{width:r,height:s}=n,a=o.replace(hl,"").replace(yl,""),c=a.match(Fn),l=`width:${r}px;height:${s}px;max-width:none;`;if(c){let i=c[1],m=c[2].split(";").map(g=>g.trim()).filter(Boolean).filter(g=>!(wl.test(g)||Cl.test(g)||vl.test(g))).join(";"),p=`${l}${m?`${m};`:""}`;a=a.replace(Fn,` style=${i}${p}${i}`);}else a=a.replace(_n,`<svg style="${l}"`);return a=a.replace(_n,`<svg width="${r}" height="${s}"`),e.replace(o,a)}catch(o){return e}},Ft=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a=kl(e),c="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a))),l=new Image;l.crossOrigin="anonymous",l.onload=()=>{let i=document.createElement("canvas"),d=l.width*o,m=l.height*o;i.width=d,i.height=m;let p=i.getContext("2d");if(!p){s(new Error("Failed to create 2D canvas context for PNG export"));return}p.drawImage(l,0,0,d,m),i.toBlob(g=>{if(!g){s(new Error("Failed to create PNG blob"));return}r(g);},"image/png");},l.onerror=()=>s(new Error("Failed to load SVG image")),l.src=c;})};var _t=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=f(),[c,l]=useState(false),i=useRef(null),{isAnimating:d$1,controls:m}=useContext(T),p=D(),g=Ze(),u=I(),b=ue(m,"mermaid","diagram"),f$1=async h=>{try{if(h==="mmd"){let E=`${b}.mmd`;d(E,e,"text/plain"),l(!1),n==null||n(h);return}if(!g){s==null||s(new Error("Mermaid plugin not available"));return}let y=g.getMermaid(r),w=e.split("").reduce((E,A)=>(E<<5)-E+A.charCodeAt(0)|0,0),P=`mermaid-${Math.abs(w)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:S}=await y.render(P,e);if(!S){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let M=Ot(S);if(h==="svg"){let E=`${b}.svg`;d(E,M,"image/svg+xml"),l(!1),n==null||n(h);return}if(h==="png"){let E=await Ft(M);d(`${b}.png`,E,"image/png"),n==null||n(h),l(!1);return}}catch(y){s==null||s(y);}};return useEffect(()=>{let h=y=>{let w=y.composedPath();i.current&&!w.includes(i.current)&&l(false);};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h);}},[]),jsxs("div",{className:a("relative"),ref:i,children:[jsx("button",{"aria-label":u.downloadDiagram,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:d$1,onClick:()=>l(!c),title:u.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{"aria-hidden":"true",size:14})}),c?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":u.downloadDiagramAsSvg,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("svg"),title:u.downloadDiagramAsSvg,type:"button",children:u.mermaidFormatSvg}),jsx("button",{"aria-label":u.downloadDiagramAsPng,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("png"),title:u.downloadDiagramAsPng,type:"button",children:u.mermaidFormatPng}),jsx("button",{"aria-label":u.downloadDiagramAsMmd,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("mmd"),title:u.downloadDiagramAsMmd,type:"button",children:u.mermaidFormatMmd})]}):null]})};var Un=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=D(),l=f(),[i,d]=useState(false),{isAnimating:m,controls:p,portal:g}=useContext(T),u=I(),b=(()=>{if(typeof p=="boolean")return p;let y=p.mermaid;return y===false?false:y===true||y===void 0?true:y.panZoom!==false})(),f$1=(()=>{if(typeof p=="boolean")return p;let y=p.mermaid;return y===false?false:y===true||y===void 0?true:y.download!==false})(),h=()=>{d(!i);};return useEffect(()=>{if(i){le();let y=w=>{w.key==="Escape"&&d(false);};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y),ie();}}},[i]),useEffect(()=>{i?o==null||o():n&&n();},[i,o,n]),jsxs(Fragment,{children:[jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:h,title:u.viewFullscreen,type:"button",...s,"aria-label":u.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i?createPortal(jsxs("div",{"aria-label":u.viewFullscreen,"aria-modal":"true",className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"mermaid-fullscreen",onClick:h,onKeyDown:y=>{y.key==="Escape"&&h();},role:"dialog",children:[jsxs("div",{className:l("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:y=>y.stopPropagation(),onKeyDown:y=>y.stopPropagation(),role:"presentation",children:[f$1?jsx(_t,{chart:e,config:t}):null,jsx("button",{"aria-label":u.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:u.exitFullscreen,type:"button",children:jsx(c,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:l("flex size-full items-center justify-center p-4"),onClick:y=>y.stopPropagation(),onKeyDown:y=>y.stopPropagation(),role:"presentation",children:jsx(jn,{chart:e,className:l("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:b})})]}),he(g)):null]})};var Zn={"3mf":"model/3mf",stl:"model/stl"},Vt=({children:e,className:t,code:o,config:n,onDownload:r,onError:s})=>{let a=f(),[c,l]=useState(false),[i,d$1]=useState(false),m=useRef(null),{controls:p,isAnimating:g}=useContext(T),u=D(),b=Ke(),f$1=I(),h=ue(p,"openscad","model"),y=async w=>{try{if(w==="scad"){d(`${h}.scad`,o,"text/plain"),l(!1),r==null||r(w);return}if(!b){s==null||s(new Error("OpenSCAD plugin not available"));return}d$1(!0);let P=b.getOpenScad(n),{data:S}=await P.render(o,{...n,format:w}),M=S.buffer.slice(S.byteOffset,S.byteOffset+S.byteLength);d(`${h}.${w}`,new Blob([M],{type:Zn[w]}),Zn[w]),r==null||r(w),l(!1);}catch(P){s==null||s(P);}finally{d$1(false);}};return useEffect(()=>{let w=P=>{let S=P.composedPath();m.current&&!S.includes(m.current)&&l(false);};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w);}},[]),jsxs("div",{className:a("relative"),ref:m,children:[jsx("button",{"aria-label":f$1.downloadModel,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:g||i,onClick:()=>l(!c),title:f$1.downloadModel,type:"button",children:e!=null?e:jsx(u.DownloadIcon,{"aria-hidden":"true",size:14})}),c?jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{"aria-label":f$1.downloadModelAsScad,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("scad"),title:f$1.downloadModelAsScad,type:"button",children:f$1.openscadFormatScad}),jsx("button",{"aria-label":f$1.downloadModelAsStl,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("stl"),title:f$1.downloadModelAsStl,type:"button",children:f$1.openscadFormatStl}),jsx("button",{"aria-label":f$1.downloadModelAs3mf,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>y("3mf"),title:f$1.downloadModelAs3mf,type:"button",children:f$1.openscadFormat3mf})]}):null]})};var _l=lazy(()=>import('./viewer-XS6MIJ4M.js').then(e=>({default:e.OpenScadViewer}))),Kn=({className:e,code:t,config:o,fullscreen:n=false})=>{let r=f(),s=I(),[a,c]=useState(null),[l,i]=useState(false),[d,m]=useState(null),[p,g]=useState(null),[u,b]=useState(0),{openscad:f$1}=useContext(T),h=Ke(),y=f$1==null?void 0:f$1.errorComponent,w=ot(),{shouldRender:P,containerRef:S}=je({immediate:n});if(useEffect(()=>{if(!P||w)return;if(!h){c(s.openscadPluginMissing);return}(async()=>{try{c(null),i(!0);let C=await h.getOpenScad(o).render(t,o);m(C),g(C);}catch(A){if(!(p||d)){let C=A instanceof Error?A.message:s.openscadRenderFailed;c(C);}}finally{i(false);}})();},[t,o,u,P,w,h,s]),!(P||d||p))return jsx("div",{className:r("my-4 min-h-[200px]",e),ref:S});if(w&&!d&&!p)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(l&&!d&&!p)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&&!p){let E=()=>b(A=>A+1);return y?jsx("div",{ref:S,children:jsx(y,{code:t,error:a,retry:E})}):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 M=d!=null?d:p;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:M?jsx(_l,{className:e,data:M.data,format:M.format,fullscreen:n}):null})})};var Xn=({code:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=D(),l=f(),[i,d]=useState(false),{isAnimating:m,controls:p,portal:g}=useContext(T),u=I(),b=(()=>{if(typeof p=="boolean")return p;let h=p.openscad;return h===false?false:h===true||h===void 0?true:h.download!==false})(),f$1=()=>{d(!i);};return useEffect(()=>{if(i){le();let h=y=>{y.key==="Escape"&&d(false);};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h),ie();}}},[i]),useEffect(()=>{i?o==null||o():n&&n();},[i,o,n]),jsxs(Fragment,{children:[jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:f$1,title:u.viewFullscreen,type:"button",...s,"aria-label":u.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i?createPortal(jsxs("div",{"aria-label":u.viewFullscreen,"aria-modal":"true",className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"openscad-fullscreen",onClick:f$1,onKeyDown:h=>{h.key==="Escape"&&f$1();},role:"dialog",children:[jsxs("div",{className:l("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:[b?jsx(Vt,{code:e,config:t}):null,jsx("button",{"aria-label":u.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:f$1,title:u.exitFullscreen,type:"button",children:jsx(c,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:l("flex size-full items-center justify-center p-4"),onClick:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:jsx(Kn,{className:l("size-full"),code:e,config:t,fullscreen:true})})]}),he(g)):null]})};var zt=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=f(),[c,l]=useState(false),i=useRef(null),{isAnimating:d$1,controls:m}=useContext(T),p=D(),g=qe(),u=I(),b=ue(m,"plantuml","diagram"),f$1=async h=>{try{if(h==="puml"){d(`${b}.puml`,e,"text/plain"),l(!1),n==null||n(h);return}if(!g){s==null||s(new Error("PlantUML plugin not available"));return}let y=g.getPlantUml(r),{svg:w}=await y.render(e,r);if(!w){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let P=Ot(w);if(h==="svg"){d(`${b}.svg`,P,"image/svg+xml"),l(!1),n==null||n(h);return}let S=await Ft(P);d(`${b}.png`,S,"image/png"),n==null||n(h),l(!1);}catch(y){s==null||s(y);}};return useEffect(()=>{let h=y=>{let w=y.composedPath();i.current&&!w.includes(i.current)&&l(false);};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h);}},[]),jsxs("div",{className:a("relative"),ref:i,children:[jsx("button",{"aria-label":u.downloadDiagram,className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:d$1,onClick:()=>l(!c),title:u.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{"aria-hidden":"true",size:14})}),c?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":u.downloadDiagramAsSvg,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("svg"),title:u.downloadDiagramAsSvg,type:"button",children:u.plantumlFormatSvg}),jsx("button",{"aria-label":u.downloadDiagramAsPng,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("png"),title:u.downloadDiagramAsPng,type:"button",children:u.plantumlFormatPng}),jsx("button",{"aria-label":u.downloadDiagramAsPuml,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("puml"),title:u.downloadDiagramAsPuml,type:"button",children:u.plantumlFormatPuml})]}):null]})};var bt=e=>e>0?e:null,Gl=(e,t)=>{if(e.endsWith("px"))return bt(Number.parseFloat(e));if(e.endsWith("rem")){let o=Number.parseFloat(getComputedStyle(document.documentElement).fontSize||"16");return bt(Number.parseFloat(e)*o)}if(e.endsWith("em")){let o=Number.parseFloat(getComputedStyle(t).fontSize||"16");return bt(Number.parseFloat(e)*o)}if(e.endsWith("vh"))return bt(Number.parseFloat(e)/100*window.innerHeight);if(e.endsWith("%")){let o=t.parentElement;return o&&o.clientHeight>0?bt(Number.parseFloat(e)/100*o.clientHeight):null}return null},Mo=(e,t)=>{let o=t.trim().toLowerCase();return !o||o==="none"||o==="auto"?null:Gl(o,e)},Xl=/^min\(\s*([^,]+)\s*,\s*([^)]+)\s*\)$/i,Jl=(e,t)=>{let o=Mo(e,t);if(o!=null)return o;let n=t.trim().match(Xl);if(!n)return null;let r=Mo(e,n[1].trim()),s=Mo(e,n[2].trim());return r==null||s==null?null:Math.min(r,s)},Yl=(e,t,o)=>{let n=t.clientWidth;if(!(n>0))return null;if(o){let d=t.clientHeight;if(!(d>0))return null;let m=Math.min(n/e.width,d/e.height,1);return !(m>0)||Number.isNaN(m)?null:{fitZoom:m,viewportHeight:null}}let r=Math.min(n/e.width,1);if(!(r>0)||Number.isNaN(r))return null;let s=e.height*r,a=null,c=t;for(;c&&a==null;){let d=getComputedStyle(c);a=Jl(c,d.maxHeight),c=c.parentElement;}let l=a!=null?Math.min(s,a):s,i=Math.min(r,l/e.height,1);return !(i>0)||Number.isNaN(i)?null:{fitZoom:i,viewportHeight:l}},jt=({children:e,className:t,contentSize:o,fitKey:n,minZoom:r=.5,maxZoom:s=3,zoomStep:a=.1,showControls:c=true,initialZoom:l=1,isAutoFit:i=false,fullscreen:d=false})=>{let{RotateCcwIcon:m,ZoomInIcon:p,ZoomOutIcon:g}=D(),u=f(),b=I(),f$1=useRef(null),h=useRef(null),y=useRef(false),[w,P]=useState(l),[S,M]=useState(r),[E,A]=useState(l),[C,_]=useState({x:0,y:0}),[U,oe]=useState(false),[V,W]=useState({x:0,y:0}),[F,z]=useState({x:0,y:0}),[L,$]=useState(null),Z=useCallback(R=>{let j=f$1.current;if(!j)return;let ve=Yl(R,j,d);if(!ve)return;let{fitZoom:ne,viewportHeight:Me}=ve;$(Me),P(ne),M(Math.min(r,ne)),y.current||(A(ne),_({x:0,y:0}));},[d,r]),q=useCallback(R=>{A(j=>Math.max(S,Math.min(s,j+R))),y.current=true;},[S,s]),K=useCallback(()=>{q(a);},[q,a]),se=useCallback(()=>{q(-a);},[q,a]),ge=useCallback(()=>{A(w),_({x:0,y:0}),y.current=false;},[w]),ae=useCallback(R=>{R.preventDefault();let j=R.deltaY>0?-a:a;q(j);},[q,a]),ce=useCallback(R=>{if(R.button!==0||R.isPrimary===false)return;oe(true),y.current=true,W({x:R.clientX,y:R.clientY}),z(C);let j=R.currentTarget;j instanceof HTMLElement&&j.setPointerCapture(R.pointerId);},[C]),G=useCallback(R=>{if(!U)return;R.preventDefault();let j=R.clientX-V.x,ve=R.clientY-V.y;_({x:F.x+j,y:F.y+ve});},[U,V,F]),de=useCallback(R=>{oe(false);let j=R.currentTarget;j instanceof HTMLElement&&j.releasePointerCapture(R.pointerId);},[]);useEffect(()=>{M(r),i||(P(l),A(l),$(null));},[l,i,r]),useLayoutEffect(()=>{if(!(i&&o))return;Z(o);let R=f$1.current;if(!R||typeof ResizeObserver=="undefined")return;let j=new ResizeObserver(()=>{Z(o);});return j.observe(R),()=>{j.disconnect();}},[Z,o,i]),useEffect(()=>{i&&(y.current=false);},[n,i]),useEffect(()=>{let R=f$1.current;if(R)return R.addEventListener("wheel",ae,{passive:false}),()=>{R.removeEventListener("wheel",ae);}},[ae]),useEffect(()=>{let R=h.current;if(R&&U)return document.body.style.userSelect="none",R.addEventListener("pointermove",G,{passive:false}),R.addEventListener("pointerup",de),R.addEventListener("pointercancel",de),()=>{document.body.style.userSelect="",R.removeEventListener("pointermove",G),R.removeEventListener("pointerup",de),R.removeEventListener("pointercancel",de);}},[U,G,de]);let et=!d&&i&&L!=null?{height:L}:void 0;return jsxs("div",{className:u("relative flex flex-col",d?"h-full w-full":"min-h-28 w-full",t),ref:f$1,style:{cursor:U?"grabbing":"grab",...et},children:[c?jsxs("div",{className:u("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":b.zoomIn,className:u("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:E>=s,onClick:K,title:b.zoomIn,type:"button",children:jsx(p,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":b.zoomOut,className:u("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:E<=S,onClick:se,title:b.zoomOut,type:"button",children:jsx(g,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":b.resetView,className:u("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:ge,title:b.resetView,type:"button",children:jsx(m,{"aria-hidden":"true",size:16})})]}):null,jsx("div",{className:u("flex h-full w-full flex-1 origin-center items-center justify-center transition-transform duration-150 ease-out"),onPointerDown:ce,ref:h,role:"application",style:{transform:`translate(${C.x}px, ${C.y}px) scale(${E})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var ti=()=>{if(typeof document=="undefined")return false;let e=document.documentElement;return e.classList.contains("dark")||e.dataset.theme==="dark"||e.dataset.colorMode==="dark"},Qn=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=f(),a=I(),[c,l]=useState(null),[i,d]=useState(false),[m,p]=useState(""),[g,u]=useState(null),[b,f$1]=useState(""),[h,y]=useState(0),{plantuml:w}=useContext(T),P=qe(),S=w==null?void 0:w.errorComponent,{shouldRender:M,containerRef:E}=je({immediate:n});if(useEffect(()=>{if(!M)return;if(!P){l(a.plantumlPluginMissing);return}(async()=>{var _,U,oe;try{l(null),d(!0);let V=P.getPlantUml(o),W=(oe=(U=o==null?void 0:o.dark)!=null?U:(_=w==null?void 0:w.config)==null?void 0:_.dark)!=null?oe:ti(),{svg:F}=await V.render(e,{dark:W}),z=dt(F),L=n?F:Bt(F);p(L),u(z),f$1(L);}catch(V){if(!(b||m)){let W=V instanceof Error?V.message:a.plantumlRenderFailed;l(W);}}finally{d(false);}})();},[e,o,h,M,P]),!(M||m||b))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:E});if(i&&!m&&!b)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:E,children:jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:s("text-sm"),children:a.diagramLoading})]})});if(c&&!m&&!b){let C=()=>y(_=>_+1);return S?jsx("div",{ref:E,children:jsx(S,{chart:e,error:c,retry:C})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:E,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:[a.plantumlErrorLabel,": ",c]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:a.showCode}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let A=m||b;return jsx("div",{className:s("size-full",t),"data-streamdown":"plantuml",ref:E,children:jsx(jt,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),contentSize:g,fitKey:e,fullscreen:n,isAutoFit:true,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":"PlantUML chart",className:s("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:A},role:"img"})})})};var tr=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=D(),l=f(),[i,d]=useState(false),{isAnimating:m,controls:p,portal:g}=useContext(T),u=I(),b=(()=>{if(typeof p=="boolean")return p;let y=p.plantuml;return y===false?false:y===true||y===void 0?true:y.panZoom!==false})(),f$1=(()=>{if(typeof p=="boolean")return p;let y=p.plantuml;return y===false?false:y===true||y===void 0?true:y.download!==false})(),h=()=>{d(!i);};return useEffect(()=>{if(i){le();let y=w=>{w.key==="Escape"&&d(false);};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y),ie();}}},[i]),useEffect(()=>{i?o==null||o():n&&n();},[i,o,n]),jsxs(Fragment,{children:[jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:h,title:u.viewFullscreen,type:"button",...s,"aria-label":u.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i?createPortal(jsxs("div",{"aria-label":u.viewFullscreen,"aria-modal":"true",className:l("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"plantuml-fullscreen",onClick:h,onKeyDown:y=>{y.key==="Escape"&&h();},role:"dialog",children:[jsxs("div",{className:l("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:y=>y.stopPropagation(),onKeyDown:y=>y.stopPropagation(),role:"presentation",children:[f$1?jsx(zt,{chart:e,config:t}):null,jsx("button",{"aria-label":u.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:u.exitFullscreen,type:"button",children:jsx(c,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:l("flex size-full items-center justify-center p-4"),onClick:y=>y.stopPropagation(),onKeyDown:y=>y.stopPropagation(),role:"presentation",children:jsx(Qn,{chart:e,className:l("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:b})})]}),he(g)):null]})};var Ro=e=>e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ro).join(""):isValidElement(e)?Ro(e.props.children):"",or=(e,t,o)=>o!=null?o:(t?toText(t):Ro(e)).replace(/\s+/g," ").trim()||void 0;function Lo(e){var o;if(e.nodeType===Node.TEXT_NODE)return (o=e.textContent)!=null?o:"";if(e.nodeType!==Node.ELEMENT_NODE)return "";let t=e;return t.tagName==="BR"?`
|
|
6
|
-
`:Array.from(t.childNodes).map(Lo).join("")}var Xe=e=>{let t=[],o=[],n=e.querySelectorAll("thead th");for(let s of n)t.push(Lo(s).trim());let r=e.querySelectorAll("tbody tr");for(let s of r){let a=[],c=s.querySelectorAll("td");for(let l of c)a.push(Lo(l).trim());o.push(a);}return {headers:t,rows:o}},ht=e=>{var o;if(typeof e!="object")return ",";let t=e.table;return typeof t!="object"?",":(o=t.csvSeparator)!=null?o:","},$e=(e,t=",")=>{let o;t==="auto"?Intl.NumberFormat().format(1.1).includes(",")?o=";":o=",":o=t;let{headers:n,rows:r}=e,s=i=>{let d=false;for(let m of i)if(m===o||m==='"'||m===`
|
|
7
|
-
`||m==="\r"){d=true;break}return d?`"${i.replace(/"/g,'""')}"`:i},a=n.length>0?r.length+1:r.length,c=new Array(a),l=0;n.length>0&&(c[l]=n.map(s).join(o),l+=1);for(let i of r)c[l]=i.map(s).join(o),l+=1;return c.join(`
|
|
8
|
-
`)},No=e=>{let{headers:t,rows:o}=e,n=c=>{let l=false;for(let d of c)if(d===" "||d===`
|
|
9
|
-
`||d==="\r"){l=true;break}if(!l)return c;let i=[];for(let d of c)d===" "?i.push("\\t"):d===`
|
|
10
|
-
`?i.push("\\n"):d==="\r"?i.push("\\r"):i.push(d);return i.join("")},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(" "),a+=1);for(let c of o)s[a]=c.map(n).join(" "),a+=1;return s.join(`
|
|
11
|
-
`)},Wt=e=>{let t=false;for(let n of e)if(n==="\\"||n==="|"||n===`
|
|
12
|
-
`){t=true;break}if(!t)return e;let o=[];for(let n of e)n==="\\"?o.push("\\\\"):n==="|"?o.push("\\|"):n===`
|
|
13
|
-
`?o.push("<br>"):o.push(n);return o.join("")},Je=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),r=0,s=t.map(c=>Wt(c));n[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let c=0;c<t.length;c+=1)a[c]="---";n[r]=`| ${a.join(" | ")} |`,r+=1;for(let c of o)if(c.length<t.length){let l=new Array(t.length);for(let i=0;i<t.length;i+=1)l[i]=i<c.length?Wt(c[i]):"";n[r]=`| ${l.join(" | ")} |`,r+=1;}else {let l=c.map(i=>Wt(i));n[r]=`| ${l.join(" | ")} |`,r+=1;}return n.join(`
|
|
14
|
-
`)};var wt=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=f(),[a,c]=useState(false),[l,i]=useState(false),d=useRef(null),m=useRef(0),{isAnimating:p,controls:g}=useContext(T),u=I(),b=ht(g),f$1=async w=>{var P,S;if(typeof window=="undefined"||!((P=navigator==null?void 0:navigator.clipboard)!=null&&P.write)){n==null||n(new Error("Clipboard API not available"));return}try{let M=(S=d.current)==null?void 0:S.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),E=M==null?void 0:M.querySelector("table");if(!E){n==null||n(new Error("Table not found"));return}let A=Xe(E),C="";w==="csv"?C=$e(A,b):w==="tsv"?C=No(A):C=Je(A);let _=new ClipboardItem({"text/plain":new Blob([C],{type:"text/plain"}),"text/html":new Blob([E.outerHTML],{type:"text/html"})});await navigator.clipboard.write([_]),i(!0),c(!1),o==null||o(w),m.current=window.setTimeout(()=>i(!1),r);}catch(M){n==null||n(M);}};useEffect(()=>{let w=P=>{let S=P.composedPath();d.current&&!S.includes(d.current)&&c(false);};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w),window.clearTimeout(m.current);}},[]);let h=D(),y=l?h.CheckIcon:h.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:p,onClick:()=>c(!a),title:u.copyTable,type:"button",children:e!=null?e:jsx(y,{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:()=>f$1("md"),title:u.copyTableAsMarkdown,type:"button",children:u.tableFormatMarkdown}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("csv"),title:u.copyTableAsCsv,type:"button",children:u.tableFormatCsv}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("tsv"),title:u.copyTableAsTsv,type:"button",children:u.tableFormatTsv})]}):null]})};var pi=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:s})=>{let a=f(),{isAnimating:c,controls:l}=useContext(T),i=I(),d$1=D(),m=ht(l),p=g=>{try{let b=g.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=b==null?void 0:b.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let h=Xe(f),y="",w="",P="";switch(r){case "csv":y=$e(h,m),w="text/csv",P="csv";break;case "markdown":y=Je(h),w="text/markdown",P="md";break;default:y=$e(h,m),w="text/csv",P="csv";}d(`${s||ue(l,"table","table")}.${P}`,y,w),o==null||o();}catch(u){n==null||n(u);}};return jsx("button",{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:p,title:r==="csv"?i.downloadTableAsCsv:i.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d$1.DownloadIcon,{size:14})})},Ct=({children:e,className:t,onDownload:o,onError:n})=>{let r=f(),[s,a]=useState(false),c=useRef(null),{isAnimating:l,controls:i}=useContext(T),d$1=I(),m=D(),p=ht(i),g=u=>{var b;try{let f=(b=c.current)==null?void 0:b.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),h=f==null?void 0:f.querySelector("table");if(!h){n==null||n(new Error("Table not found"));return}let y=Xe(h),w=u==="csv"?$e(y,p):Je(y),P=u==="csv"?"csv":"md",S=`${ue(i,"table","table")}.${P}`;d(S,w,u==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(u);}catch(f){n==null||n(f);}};return useEffect(()=>{let u=b=>{let f=b.composedPath();c.current&&!f.includes(c.current)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[]),jsxs("div",{className:r("relative"),ref:c,children:[jsx("button",{className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,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",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("csv"),title:d$1.downloadTableAsCsv,type:"button",children:d$1.tableFormatCsv}),jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("markdown"),title:d$1.downloadTableAsMarkdown,type:"button",children:d$1.tableFormatMarkdown})]}):null]})};var ir=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=D(),a=f(),[c,l]=useState(false),{isAnimating:i,portal:d}=useContext(T),m=I(),p=()=>{l(true);},g=()=>{l(false);};return useEffect(()=>{if(c){le();let u=b=>{b.key==="Escape"&&l(false);};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u),ie();}}},[c]),jsxs(Fragment,{children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:p,title:m.viewFullscreen,type:"button",children:jsx(r,{size:14})}),c?createPortal(jsx("div",{"aria-label":m.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:g,onKeyDown:u=>{u.key==="Escape"&&g();},role:"dialog",children:jsxs("div",{className:a("flex h-full flex-col"),onClick:u=>u.stopPropagation(),onKeyDown:u=>u.stopPropagation(),role:"presentation",children:[jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[o?jsx(wt,{}):null,n?jsx(Ct,{}):null,jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:g,title:m.exitFullscreen,type:"button",children:jsx(s,{size:20})})]}),jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:a("w-full table-fixed border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),he(d)):null]})};var dr=({children:e,className:t,maxHeight:o,showControls:n,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...c})=>{let l=f(),{isAnimating:i,scrollable:d}=useContext(T),m=d!=null?d:nt,p=b(o),g=Lt({content:e,enabled:!!p,isAnimating:i}),u=n&&r,b$1=n&&s,f$1=n&&a,h=u||b$1||f$1;return jsxs("div",{className:l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[h?jsxs("div",{className:l("flex items-center justify-end gap-1"),children:[u?jsx(wt,{}):null,b$1?jsx(Ct,{}):null,f$1?jsx(ir,{showCopy:u,showDownload:b$1,children:e}):null]}):null,jsx(m,{className:l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),scrollRef:g,style:p?{maxHeight:p}:void 0,children:jsx("table",{className:l("w-full table-fixed divide-y divide-border",t),"data-streamdown":"table",...c,children:e})})]})};var ki=/startLine=(\d+)/,Pi=/\bnoLineNumbers\b/,Si=lazy(()=>import('./mermaid-TRQ3QBH6.js').then(e=>({default:e.Mermaid}))),Ti=lazy(()=>import('./plantuml-DHKDTGFB.js').then(e=>({default:e.PlantUml}))),Mi=lazy(()=>import('./openscad-ST5FROOQ.js').then(e=>({default:e.OpenScad}))),Ei=/language-([^\s]+)/,we=e=>e.props,Ri="node";function B(e,t){let o=Object.keys(e);if(o.length!==Object.keys(t).length)return false;let n=e,r=t;for(let s of o)if(s!==Ri&&!Object.is(n[s],r[s]))return false;return true}function Li(e,t){var o,n;return ((o=e==null?void 0:e.properties)==null?void 0:o.metastring)===((n=t==null?void 0:t.properties)==null?void 0:n.metastring)}function Ni(e){if(typeof e=="string")return e;if(isValidElement(e)){let t=we(e).children;if(typeof t=="string")return t}}var gr=(e,t)=>Array.isArray(t)?t.includes(e):t===e,Ii=(e,t)=>!!(t&&gr(e,t.language)),Ai=(e,t)=>!!(t&&gr(e,t.language)),xt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Do=(e,t)=>{if(typeof e=="boolean")return e;let o=e.table;return o===false?false:o===true||o===void 0?true:o[t]!==false},mr=(e,t)=>{if(typeof e=="boolean")return e;let o=e.code;return o===false?false:o===true||o===void 0?true:o[t]!==false},qt=(e,t)=>{if(typeof e=="boolean")return e;let o=e.mermaid;return o===false?false:o===true||o===void 0?true:o[t]!==false},Kt=(e,t)=>{if(typeof e=="boolean")return e;let o=e.plantuml;return o===false?false:o===true||o===void 0?true:o[t]!==false},Ho=(e,t)=>{if(typeof e=="boolean")return e;let o=e.openscad;return o===false?false:o===true||o===void 0?true:o[t]!==false},kt=createContext({depth:0,ulDepth:0,isUnordered:false}),Di={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},Bo=memo(({children:e,className:t,node:o,...n})=>{let r=f(),{depth:s,ulDepth:a}=useContext(kt),c=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",...n,children:jsx(kt.Provider,{value:c,children:e})})},(e,t)=>B(e,t));Bo.displayName="MarkdownOl";var br=memo(({children:e,className:t,node:o,...n})=>{var b;let r=f(),{depth:s,ulDepth:a,isUnordered:c}=useContext(kt),{listStyle:l}=useContext(T),i=Di[l],d=c&&a>0?i[(a-1)%i.length]:void 0,m=Array.isArray(e)?e.filter(f=>f!==`
|
|
15
|
-
`&&f!==""):[e],p=m[0],g=isValidElement(p)?(b=we(p).node)==null?void 0:b.tagName:void 0,u=m.length===1&&isValidElement(p)&&(p.type==="p"||g==="p")?we(p).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",...n,children:u}):jsx("li",{className:r("py-1 [&>p]:inline",d,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...n,children:u})},(e,t)=>B(e,t));br.displayName="MarkdownLi";var hr=memo(({children:e,className:t,node:o,...n})=>{let r=f(),{depth:s,ulDepth:a}=useContext(kt),c=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",...n,children:jsx(kt.Provider,{value:c,children:e})})},(e,t)=>B(e,t));hr.displayName="MarkdownUl";var yr=memo(({className:e,node:t,...o})=>{let n=f();return jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>B(e,t));yr.displayName="MarkdownHr";var wr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>B(e,t));wr.displayName="MarkdownStrong";var Hi=({children:e,className:t,href:o,node:n,...r})=>{let s=f(),{linkSafety:a}=useContext(T),[c,l]=useState(false),i=o==="streamdown:incomplete-link",d=useCallback(async u=>{if(!(!(a!=null&&a.enabled&&o)||i)){if(u.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}l(true);}},[a,o,i]),m=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),p=useCallback(()=>{l(false);},[]),g={url:o!=null?o:"",isOpen:c,onClose:p,onConfirm:m};return a!=null&&a.enabled&&o?jsxs(Fragment,{children:[jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":i,"data-streamdown":"link",onClick:d,type:"button",children:e}),a.renderModal?a.renderModal(g):jsx(Ln,{...g})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":i,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},Cr=memo(Hi,(e,t)=>B(e,t));Cr.displayName="MarkdownA";var vr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>B(e,t));vr.displayName="MarkdownH1";var xr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>B(e,t));xr.displayName="MarkdownH2";var kr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>B(e,t));kr.displayName="MarkdownH3";var Pr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>B(e,t));Pr.displayName="MarkdownH4";var Sr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>B(e,t));Sr.displayName="MarkdownH5";var Tr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>B(e,t));Tr.displayName="MarkdownH6";var Mr=memo(({children:e,className:t,node:o,...n})=>{let{controls:r,tableMaxHeight:s}=useContext(T),a=xt(r,"table"),c=Do(r,"copy"),l=Do(r,"download"),i=Do(r,"fullscreen");return jsx(dr,{className:t,maxHeight:s,showControls:a,showCopy:c,showDownload:l,showFullscreen:i,...n,children:e})},(e,t)=>B(e,t));Mr.displayName="MarkdownTable";var Er=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>B(e,t));Er.displayName="MarkdownThead";var Rr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>B(e,t));Rr.displayName="MarkdownTbody";var Lr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>B(e,t));Lr.displayName="MarkdownTr";var Nr=memo(({children:e,className:t,node:o,title:n,...r})=>{let s=f(),a=or(e,o,n);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)=>B(e,t));Nr.displayName="MarkdownTh";var Ir=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("td",{className:r("wrap-anywhere min-w-0 px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>B(e,t));Ir.displayName="MarkdownTd";var Ar=memo(({children:e,className:t,node:o,...n})=>{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",...n,children:e})},(e,t)=>B(e,t));Ar.displayName="MarkdownBlockquote";var Dr=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>B(e,t));Dr.displayName="MarkdownSup";var Oi=()=>({}),Bi=e=>{try{let t=atob(e),o=Uint8Array.from(t,n=>n.charCodeAt(0));return new TextDecoder().decode(o)}catch(t){return ""}},Hr=memo(({children:e,className:t,node:o,...n})=>{let r=f(),{calloutIcon:s,calloutStyle:a,components:c,remarkPlugins:l,rehypePlugins:i}=useContext(T),d=n,m=d["data-callout-title"],p=d["data-callout-color"],g=d["data-callout-icon"],u=d["data-callout-body"],b=u?Bi(u):"",f$1=(a!=null?a:Oi)(p),h=g&&s?s(g):null;return jsxs("div",{className:r("my-4 rounded-md border-l-4 px-4 py-3 [&>p:last-child]:mb-0",t),"data-streamdown":"callout",style:f$1,...n,children:[m!==void 0?jsxs("p",{className:"mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",children:[h,m]}):null,b.trim().length>0?jsx(it,{components:c,rehypePlugins:i,remarkPlugins:l,children:b}):null]})},(e,t)=>B(e,t));Hr.displayName="MarkdownCallout";var ur={"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"},Or=memo(({children:e,className:t,node:o,...n})=>{let r=f(),s=t==null?void 0:t.includes("markdown-alert");if(t==null?void 0:t.includes("sdm-callout"))return jsx(Hr,{className:t,node:o,...n,children:e});if(s){let c=Object.keys(ur).find(l=>t==null?void 0:t.includes(l));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",c?ur[c]:null,t),...n,children:e})}return jsx("div",{className:r(t),...n,children:e})},(e,t)=>B(e,t));Or.displayName="MarkdownDiv";var Br=memo(({children:e,className:t,node:o,...n})=>{let r=f();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>B(e,t));Br.displayName="MarkdownSub";var Fr=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=l=>{if(!isValidElement(l))return false;let i=we(l).children,d=Array.isArray(i)?i:[i],m=false,p=false;for(let g of d)if(g){if(typeof g=="string")g.trim()!==""&&(m=true);else if(isValidElement(g))if(we(g)["data-footnote-backref"]!==void 0)p=true;else {let u=we(g).children,b=Array.isArray(u)?u:[u];for(let f of b){if(typeof f=="string"&&f.trim()!==""){m=true;break}if(isValidElement(f)&&we(f)["data-footnote-backref"]===void 0){m=true;break}}}}return p&&!m},a=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===Bo){let i=we(l).children,m=(Array.isArray(i)?i:[i]).filter(p=>!s(p));return m.length===0?null:{...l,props:{...we(l),children:m}}}return l}):e;return (Array.isArray(a)?a.some(l=>l!==null):a!==null)?jsx("section",{className:t,...n,children:a}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>B(e,t));Fr.displayName="MarkdownSection";var Fi=({node:e,className:t,children:o,...n})=>{var F,z,L;let r=f(),s=!("data-block"in n),{mermaid:a,plantuml:c,openscad:l,controls:i,lineNumbers:d}=useContext(T),m=Ze(),p=qe(),g=Ke(),u=ot(),b=t==null?void 0:t.match(Ei),f$1=(F=b==null?void 0:b.at(1))!=null?F:"",h=Bn(f$1);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",...n,children:o});let y=(z=e==null?void 0:e.properties)==null?void 0:z.metastring,w=typeof y=="string"?y:void 0,P=w==null?void 0:w.match(ki),S=P?Number.parseInt(P[1],10):void 0,M=S!==void 0&&S>=1?S:void 0,A=!(w?Pi.test(w):false)&&d!==false,C=(L=Ni(o))!=null?L:"";if(h){let $=h.component;return jsx(Suspense,{fallback:jsx(We,{}),children:jsx($,{code:C,isIncomplete:u,language:f$1,meta:w})})}if(f$1==="mermaid"&&m){let $=xt(i,"mermaid"),Z=qt(i,"download"),q=qt(i,"copy"),K=qt(i,"fullscreen"),se=qt(i,"panZoom"),ge=$&&(Z||q||K);return jsx(Suspense,{fallback:jsx(We,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":u||void 0,"data-streamdown":"mermaid-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:"mermaid"})}),ge?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":"mermaid-block-actions",children:[Z?jsx(_t,{chart:C,config:a==null?void 0:a.config}):null,q?jsx(Ue,{code:C}):null,K?jsx(Un,{chart:C,config:a==null?void 0:a.config}):null]})}):null,jsx("div",{className:r("overflow-hidden rounded-md border border-border bg-background"),children:jsx(Si,{chart:C,config:a==null?void 0:a.config,showControls:se})})]})})}if(Ii(f$1,p)){let $=xt(i,"plantuml"),Z=Kt(i,"download"),q=Kt(i,"copy"),K=Kt(i,"fullscreen"),se=Kt(i,"panZoom"),ge=$&&(Z||q||K);return jsx(Suspense,{fallback:jsx(We,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":u||void 0,"data-streamdown":"plantuml-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:f$1})}),ge?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":"plantuml-block-actions",children:[Z?jsx(zt,{chart:C,config:c==null?void 0:c.config}):null,q?jsx(Ue,{code:C}):null,K?jsx(tr,{chart:C,config:c==null?void 0:c.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(Ti,{chart:C,config:c==null?void 0:c.config,showControls:se})})]})})}if(Ai(f$1,g)){let $=xt(i,"openscad"),Z=Ho(i,"download"),q=Ho(i,"copy"),K=Ho(i,"fullscreen"),se=$&&(Z||q||K);return jsx(Suspense,{fallback:jsx(We,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":u||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:f$1})}),se?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:[Z?jsx(Vt,{code:C,config:l==null?void 0:l.config}):null,q?jsx(Ue,{code:C}):null,K?jsx(Xn,{code:C,config:l==null?void 0:l.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(Mi,{code:C,config:l==null?void 0:l.config})})]})})}let _=xt(i,"code"),U=mr(i,"download"),oe=mr(i,"copy"),{"data-block":V,...W}=n;return jsx(go,{className:t,code:C,isIncomplete:u,language:f$1,lineNumbers:A,startLine:M,...W,children:_?jsxs(Fragment,{children:[U?jsx(yo,{code:C,language:f$1}):null,oe?jsx(Ue,{}):null]}):null})},_r=memo(Fi,(e,t)=>B(e,t)&&Li(e.node,t.node));_r.displayName="MarkdownCode";var Vr=memo(Mn,(e,t)=>B(e,t));Vr.displayName="MarkdownImg";var pr={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},zr=memo(({children:e,className:t,node:o,...n})=>{let r=f(),s=I(),a=n["data-alert-type"],c=a&&a in pr?pr[a]:void 0,l=c?s[c]:void 0,i=e;return l&&(i=[...(Array.isArray(e)?e:[e]).filter(p=>!(typeof p=="string"&&p.trim().length>0)),l]),jsx("p",{className:r("mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",t),...n,children:i})},(e,t)=>B(e,t));zr.displayName="MarkdownAlertTitle";var $r=memo(({children:e,className:t,node:o,...n})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(zr,{className:t,node:o,...n,children:e});let s=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");if(s.length===1&&isValidElement(s[0])){let a=we(s[0]).node,c=a==null?void 0:a.tagName;if(c==="img")return jsx(Fragment,{children:e});if(c==="code"&&"data-block"in s[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...n,children:e})},(e,t)=>B(e,t));$r.displayName="MarkdownParagraph";var jr={ol:Bo,li:br,ul:hr,hr:yr,strong:wr,a:Cr,h1:vr,h2:xr,h3:kr,h4:Pr,h5:Sr,h6:Tr,table:Mr,thead:Er,tbody:Rr,tr:Lr,th:Nr,td:Ir,blockquote:Ar,code:_r,div:Or,img:Vr,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:Dr,sub:Br,p:$r,section:Fr};var _i=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Vi=/\p{L}/u;function Pt(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,""),o,n=0,r=0;for(let s of t){if(_i.test(s)){o!=null||(o="rtl"),r+=1;continue}Vi.test(s)&&(o!=null||(o="ltr"),n+=1);}return r>n?"rtl":n>r?"ltr":o!=null?o:"ltr"}var zi=/^[ \t]{0,3}(`{3,}|~{3,})/;var Ur=e=>{let t=e.split(`
|
|
16
|
-
`),o=null,n=0;for(let r of t){let s=zi.exec(r);if(o===null){if(s){let a=s[1];o=a[0],n=a.length;}}else if(s){let a=s[1],c=a[0],l=a.length;c===o&&l>=n&&(o=null,n=0);}}return o!==null};var ji=/\[\^[\w-]{1,200}\](?!:)/,Ui=/\[\^[\w-]{1,200}\]:/,Wi=/<([A-Za-z][\w:-]*)[\s>/]/,Zi=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Wr=new Map,Zr=new Map,Gr=e=>{let t=e.toLowerCase(),o=Wr.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Wr.set(t,n),n},qi=e=>{let t=e.toLowerCase(),o=Zr.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return Zr.set(t,n),n},qr=(e,t)=>{if(Zi.has(t.toLowerCase()))return 0;let o=e.match(Gr(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},Kr=(e,t)=>{let o=e.match(qi(t));return o?o.length:0},Ki=(e,t)=>{let o=e.match(Gr(t));return !!o&&o.every(n=>n.trimEnd().endsWith("/>"))},Gi=e=>{let t=0;for(let o=0;o<e.length-1;o+=1)e[o]==="$"&&e[o+1]==="$"&&(t+=1,o+=1);return t},Xt=e=>{let t=ji.test(e),o=Ui.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),r=[],s=[],a=false;for(let c of n){let l=c.raw,i=r.length;if(s.length>0){r[i-1]+=l;let d=s.at(-1),m=qr(l,d),p=Kr(l,d);for(let g=0;g<m;g+=1)s.push(d);for(let g=0;g<p;g+=1)s.length>0&&s.at(-1)===d&&s.pop();continue}if(c.type==="html"&&c.block){let d=l.match(Wi);if(d){let m=d[1],p=qr(l,m),g=Kr(l,m);p>g&&!Ki(l,m)&&s.push(m);}}if(c.type==="space"&&i>0){r[i-1]+=l;continue}if(i>0&&!a){let d=r[i-1];if(Gi(d)%2===1){r[i-1]=d+l;continue}}r.push(l),c.type!=="space"&&(a=c.type==="code");}return r},Fo=(e,t,o=Xt)=>{if(!(t!=null&&t.source&&e.startsWith(t.source)))return {source:e,blocks:o(e)};if(e===t.source)return t;if(t.blocks.length<=1)return {source:e,blocks:o(e)};let n=t.blocks.slice(0,-1),r=0;for(let l of n)r+=l.length;let s=e.slice(0,r);if(n.join("")!==s)return {source:e,blocks:o(e)};let a=e.slice(r),c=o(a);return {source:e,blocks:[...n,...c]}};var Xi=/^\n*/,Ji=/\n*$/,_o=/\n\n/g,Yi=(e,t,o)=>{if(!t.includes(`
|
|
17
|
-
`))return e+t+o;let r=t.replace(_o,`
|
|
18
|
-
<!---->
|
|
19
|
-
`).replace(Xi,`
|
|
20
|
-
|
|
21
|
-
`).replace(Ji,`
|
|
22
|
-
|
|
23
|
-
`);return `${e}${r}${o}
|
|
24
|
-
|
|
25
|
-
`},Qi=(e,t)=>{let o=new RegExp(`<(${t})(?=[\\s>/])([^>]*)>`,"gi"),n="",r=0,s=o.exec(e);for(;s;){let a=s[0],c=s[1],l=s.index+a.length,i=e.slice(l);if(new RegExp(`</${c}\\s*>`,"i").test(i)){s=o.exec(e);continue}if(n+=e.slice(r,s.index),i.length===0){n+=a,r=l,s=o.exec(e);continue}if(i.startsWith(`
|
|
26
|
-
|
|
27
|
-
`)){let g=i.slice(2).replace(_o,`
|
|
28
|
-
<!---->
|
|
29
|
-
`);n+=`${a}
|
|
30
|
-
|
|
31
|
-
${g}`,r=e.length;break}if(!i.startsWith(`
|
|
32
|
-
`)){n+=a,r=l,s=o.exec(e);continue}let m=i.slice(1);if(m.trim().length===0){n+=a,r=l,s=o.exec(e);continue}let p=m.replace(_o,`
|
|
33
|
-
<!---->
|
|
34
|
-
`);n+=`${a}
|
|
35
|
-
|
|
36
|
-
${p}`,r=e.length;break}return r===0?e:n+e.slice(r)},Xr=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`<${n}(?=[\\s>/])((?:"[^"]*"|'[^']*'|[^"'>])*)\\/>`,"gi");o=o.replace(r,(s,a)=>`<${n}${a}></${n}>`);}for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(s,a,c,l)=>Yi(a,c,l)),o=Qi(o,n);}return o};var ec=/([\\`*_~[\]|])/g,tc=e=>e.replace(ec,"\\$1"),Jr=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(s,a,c,l)=>{let i=tc(c).replace(/\n\n/g," ");return a+i+l});}return o};var nc=new Set(["blockquote","dd","dt","figcaption","h1","h2","h3","h4","h5","h6","li","p","td","th"]),Yr=new Set(["code","kbd","pre","samp","var"]);function Qr(e){return e.children.map(t=>t.type==="text"?t.value:t.type==="element"&&!Yr.has(t.tagName)?Qr(t):"").join("")}function es(){return e=>{visit(e,"element",t=>{if(Yr.has(t.tagName)){(t.properties)!=null||(t.properties={}),t.properties.dir="ltr";return}nc.has(t.tagName)&&((t.properties)!=null||(t.properties={}),typeof t.properties.dir!="string"&&(t.properties.dir=Pt(Qr(t))));});}}var ts=e=>t=>{if(!e||e.length===0)return;let o=new Set(e.map(n=>n.toLowerCase()));visit(t,"element",n=>{var s;if(!o.has(n.tagName.toLowerCase()))return;let r=n.children.filter(a=>a.type==="element").map(a=>{var c;return {tag:a.tagName,props:(c=a.properties)!=null?c:{},text:toText(a).trim()}});n.properties=(s=n.properties)!=null?s:{},n.properties["data-content"]=JSON.stringify(r),n.children=[];});};var os=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(os).join(""):"",ns=e=>t=>{if(!e||e.length===0)return;let o=new Set(e.map(n=>n.toLowerCase()));visit(t,"element",n=>{if(o.has(n.tagName.toLowerCase())){let r=os(n);n.children=r?[{type:"text",value:r}]:[];}});};var mc=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),uc=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),pc=e=>{let t=unified().use(ol).use(nl,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},rs=(e,t=[])=>o=>{if(!e||e.length===0)return;let n=new Set(e.map(s=>s.toLowerCase())),r=new Set((t!=null?t:[]).map(s=>s.toLowerCase()));visit(o,"element",s=>{let a=s.tagName.toLowerCase();if(!n.has(a)||r.has(a)||!mc(s))return;let c=uc(s);if(!c.includes(`
|
|
37
|
-
`))return;let l=pc(c);s.children=l;});};var ss=()=>e=>{visit(e,"code",t=>{var o,n;t.meta&&(t.data=(o=t.data)!=null?o:{},t.data.hProperties={...(n=t.data.hProperties)!=null?n:{},metastring:t.meta});});};var as=/^>>>[ \t]?(.*)$/,gc=/^<<<\s*$/,bc=/^>+\s*$/,hc=/^<+\s*$/,yc=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,wc=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,Cc=/^[a-z0-9-]+$/,vc=e=>{let t=yc.exec(e);if(!(t!=null&&t.groups))return {};let{iconParen:o,iconBrace:n,title:r,color:s}=t.groups,a=o!=null?o:n;return {icon:a&&Cc.test(a)?a:void 0,title:r!==void 0&&r.length>0?r:void 0,color:s&&wc.test(s)?s:void 0}},Vo=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),xc=e=>{let t=new TextEncoder().encode(e),o="";for(let n of t)o+=String.fromCharCode(n);return btoa(o)},kc=(e,t)=>{var i;let o=as.exec(e[t]),n=(i=o==null?void 0:o[1])!=null?i:"",r=vc(n),s=[],a=t+1;for(;a<e.length;a+=1){let d=e[a];if(gc.test(d)){a+=1;break}if(bc.test(d)||hc.test(d)){a+=1;break}s.push(d);}let c=s.join(`
|
|
38
|
-
`).trim();return {replacement:`<div ${['class="sdm-callout"',r.title!==void 0?`data-callout-title="${Vo(r.title)}"`:"",r.color!==void 0?`data-callout-color="${Vo(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${Vo(r.icon)}"`:"",`data-callout-body="${xc(c)}"`].filter(Boolean).join(" ")}></div>`,next:a}},ls=e=>{if(!e.includes(">>>"))return e;let t=e.split(`
|
|
39
|
-
`),o=[],n=0,r=false;for(;n<t.length;)if(as.test(t[n])){let s=kc(t,n);o.push(s.replacement),n=s.next,r=true;}else o.push(t[n]),n+=1;return r?o.join(`
|
|
40
|
-
`):e},is=()=>()=>{};var Tc={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"}]}},Mc=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,cs=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let o="";for(let n of t)o+=cs(n);return o},Ec=e=>{let t=e.iconPaths.map(o=>`<path d="${o.d}"${o.fillRule?` fill-rule="${o.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}}}},Rc=e=>{var m,p;let t=e.children[0];if(!t||t.type!=="paragraph")return;let o=t.children[0];if(!o||o.type!=="text")return;let n=cs(o).trimStart(),r=n.match(Mc);if(!r)return;let s=Tc[r[1].toUpperCase()],a=n.slice(r[0].length),c=t.children.slice(1);if(a.trim().length===0&&c.length===0&&e.children.length===1)return;let l=[Ec(s)],i=[];a.length>0&&i.push({type:"text",value:a});let d=c;return ((m=d[0])==null?void 0:m.type)==="break"&&(d=d.slice(1)),i.push(...d),i.length>0&&i.some(g=>g.type!=="text"||g.value.trim().length>0)&&l.push({type:"paragraph",children:i}),l.push(...e.children.slice(1)),e.data=(p=e.data)!=null?p:{},e.data.hName="div",e.data.hProperties={className:["markdown-alert",`markdown-alert-${s.kind}`]},e.children=l,SKIP},ds=()=>e=>{visit(e,"blockquote",Rc);};var Bc=/^[ \t]*<[\w!/?-]/,Fc=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,_c=e=>typeof e!="string"||e.length===0||!Bc.test(e)?e:e.replace(Fc,"$1"),fs,gs,bs,hs,ys,ws,Cs,vs,xs,ks,Ps,Ss,Ts,Jt={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(gs=(fs=defaultSchema.protocols)==null?void 0:fs.href)!=null?gs:[],"tel","streamdown"],src:[...(hs=(bs=defaultSchema.protocols)==null?void 0:bs.src)!=null?hs:[],"streamdown"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(ws=(ys=defaultSchema.attributes)==null?void 0:ys.div)!=null?ws:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(vs=(Cs=defaultSchema.attributes)==null?void 0:Cs.p)!=null?vs:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(ks=(xs=defaultSchema.attributes)==null?void 0:xs.svg)!=null?ks:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(Ss=(Ps=defaultSchema.attributes)==null?void 0:Ps.path)!=null?Ss:[],"d","fillRule"]},tagNames:[...(Ts=defaultSchema.tagNames)!=null?Ts:[],"svg","path"]},zo={raw:In,sanitize:[Rs,Jt],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Vc={gfm:[Hc,{}],githubAlerts:ds,containerAlerts:is,codeMeta:ss},us=Object.values(zo),zc=Object.values(Vc),ps=new WeakMap;function $c(e){var r;let t=ps.get(e);if(t)return t;let o={...Jt,tagNames:[...(r=Jt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...Jt.attributes,...e}},n=[zo.raw,[Rs,o],zo.harden];return ps.set(e,n),n}var jc={block:" \u258B",circle:" \u25CF"},Uc=["github-light","github-dark"],Wc={enabled:true},Ls=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:o,index:n,isIncomplete:r,dir:s,animatePlugin:a,...c})=>{useLayoutEffect(()=>{a==null||a.commit();}),a==null||a.setAnimateCodeBlocks(r);let l=typeof e=="string"&&o?_c(e):e,i=jsx(it,{...c,children:l});return jsx(co.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:i}):i})},(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 o=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(o.length!==n.length||o.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)});Ls.displayName="Block";var Zc=memo(({children:e$1,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=us,remarkPlugins:c$1=zc,className:l,shikiTheme:i,mermaid:d,openscad:m,plantuml:p,codeBlockMaxHeight:g=400,controls:u=true,isAnimating:b=false,scrollable:f,tableMaxHeight:h=300,animated:y,BlockComponent:w=Ls,parseMarkdownIntoBlocksFn:P=Xt,caret:S,listStyle:M="hierarchical",calloutIcon:E,calloutStyle:A,plugins:C,remend:_,linkSafety:U=Wc,portal:oe,lineNumbers:V=true,allowedTags:W,literalTagContent:F,dataOnlyTags:z,translations:L,icons:$,prefix:Z,onAnimationStart:q,onAnimationEnd:K,...se})=>{let ge=useId(),ae=useMemo(()=>c(Z),[Z]),ce=useRef(null),G=useRef(q),de=useRef(K);G.current=q,de.current=K,useEffect(()=>{var N,Q,J;if(t==="static")return;let k=ce.current;if(ce.current=b,k===null){b&&((N=G.current)==null||N.call(G));return}b&&!k?(Q=G.current)==null||Q.call(G):!b&&k&&((J=de.current)==null||J.call(de));},[b,t]);let et=useMemo(()=>W?Object.keys(W):[],[W]),R=useMemo(()=>{if(!(z!=null&&z.length))return et;let k=new Set(z.map(N=>N.toLowerCase()));return et.filter(N=>!k.has(N.toLowerCase()))},[et,z]),j=useRef(null),ve=useMemo(()=>{if(typeof e$1!="string")return "";let k=e$1;return F&&F.length>0&&(k=Jr(k,F)),R.length>0&&(k=Xr(k,R)),k=ls(k),k},[e$1,R,F]),ne=useMemo(()=>{let k=t==="streaming"?j.current:null,N=Fo(ve,k,P);if(j.current=t==="streaming"?N:null,!(t==="streaming"&&n)||N.blocks.length===0)return N.blocks;let Q=N.blocks.length-1,J=N.blocks[Q],xe=Oc(J,_);if(xe===J)return N.blocks;let De=N.blocks.slice();return De[Q]=xe,De},[ve,P,t,n,_]),Me=useMemo(()=>y===true?"true":y?JSON.stringify(y):"",[y]),me=useRef(null),tt=useRef([]),Le=useRef([]),jo=useRef(null),Qt=useRef("");if(Me){if(Qt.current!==Me){Qt.current=Me;let k=Me!=="true"?y.maxBacklogMs:void 0;me.current=ao({maxBacklogMs:k}),tt.current=[],Le.current=[];}else me.current||(me.current=ao());b&&me.current&&me.current.beginPass(me.current.now());}else me.current=null,tt.current=[],Le.current=[],Qt.current="";useLayoutEffect(()=>{var k;b&&((k=me.current)==null||k.commitPass());});let Ne=useDeferredValue(ne),Ie=useMemo(()=>{if(t!=="streaming"||me.current||Ne===ne||Ne.length===0)return ne;let k=Ne.length,N=ne.length;if(N===0)return Ne;if(k!==N)return ne;for(let J=0;J<k-1;J+=1)if(Ne[J]!==ne[J])return ne;let Q=Ne.slice();return Q[k-1]=ne[N-1],Q},[ne,Ne,t]),eo=useMemo(()=>o==="auto"?Ie.map(Pt):void 0,[Ie,o]),As=useMemo(()=>Ie.map((k,N)=>`${ge}-${N}`),[Ie.length,ge]),Ds=useMemo(()=>L?JSON.stringify(L):"",[L]),Uo=useMemo(()=>({...It,...L}),[Ds]),Tt=useMemo(()=>{let{inlineCode:k,...N}=s!=null?s:{},Q={...jr,...N};if(k){let J=Q.code;Q.code=xe=>"data-block"in xe?J?createElement(J,xe):null:createElement(k,xe);}return Q},[s]),Mt=useMemo(()=>{let k=[];return C!=null&&C.cjk&&(k=[...k,...C.cjk.remarkPluginsBefore]),k=[...k,...c$1],C!=null&&C.cjk&&(k=[...k,...C.cjk.remarkPluginsAfter]),C!=null&&C.math&&(k=[...k,C.math.remarkPlugin]),k},[c$1,C==null?void 0:C.math,C==null?void 0:C.cjk]),Ae=useMemo(()=>{let k=a;return W&&Object.keys(W).length>0&&a===us&&(k=$c(W)),R.length>0&&(k=[...k,[rs,R,F!=null?F:[]]]),F&&F.length>0&&(k=[...k,[ns,F]]),z&&z.length>0&&(k=[...k,[ts,z]]),C!=null&&C.math&&(k=[...k,C.math.rehypePlugin]),o==="auto"&&t==="static"&&(k=[...k,es]),k},[a,C==null?void 0:C.math,W,R,F,z,o,t]),Wo=useMemo(()=>{var k,N;return {calloutIcon:E,calloutStyle:A,codeBlockMaxHeight:g,shikiTheme:(N=i!=null?i:(k=C==null?void 0:C.code)==null?void 0:k.getThemes())!=null?N:Uc,controls:u,isAnimating:b,lineNumbers:V,listStyle:M,mode:t,mermaid:d,openscad:m,plantuml:p,linkSafety:U,portal:oe,scrollable:f,tableMaxHeight:h,components:Tt,remarkPlugins:Mt,rehypePlugins:Ae}},[E,A,g,i,u,b,V,M,t,d,m,p,U,oe,f,C==null?void 0:C.code,h,Tt,Mt,Ae]),Hs=useMemo(()=>S&&b?{"--streamdown-caret":`"${jc[S]}"`}:void 0,[S,b]),Os=k=>{let N=null;if(me.current&&b){if(!tt.current[k]){let J=Me&&Me!=="true"?y:{},{maxBacklogMs:xe,...De}=J;tt.current[k]=Rt({...De,timeline:me.current});}N=tt.current[k];}jo.current!==Ae&&(Le.current=[],jo.current=Ae),N&&!Le.current[k]&&(Le.current[k]=[...Ae,N.rehypePlugin]);let Q=N&&Le.current[k]?Le.current[k]:Ae;return {blockAnimatePlugin:N,blockRehypePlugins:Q}};return t==="static"?jsx(At.Provider,{value:Uo,children:jsx(Ht.Provider,{value:C!=null?C:null,children:jsx(T.Provider,{value:Wo,children:jsx(bo,{icons:$,children:jsx(e.Provider,{value:ae,children:jsx("div",{className:ae("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",l),dir:o==="auto"?void 0:o,children:jsx(it,{components:Tt,rehypePlugins:Ae,remarkPlugins:Mt,...se,children:ve})})})})})})}):jsx(At.Provider,{value:Uo,children:jsx(Ht.Provider,{value:C!=null?C:null,children:jsx(T.Provider,{value:Wo,children:jsx(bo,{icons:$,children:jsx(e.Provider,{value:ae,children:jsxs("div",{className:ae("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",S?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,l),"data-streamdown":"container",style:Hs,children:[Ie.length===0&&S&&b&&jsx("span",{}),Ie.map((k,N)=>{var Zo;let Q=N===Ie.length-1,J=b&&Q&&Ur(k),{blockAnimatePlugin:xe,blockRehypePlugins:De}=Os(N);return jsx(w,{animatePlugin:xe,components:Tt,content:k,dir:(Zo=eo==null?void 0:eo[N])!=null?Zo:o!=="auto"?o:void 0,index:N,isIncomplete:J,rehypePlugins:De,remarkPlugins:Mt,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...se},As[N])})]})})})})})})},(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&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Zc.displayName="Streamdown";var Ns=/[(){}[\]]/,Kc=/[\s;]/,Gc=/^[\w-]+$/,Xc=/:::[\w-]+\s*$/,Jc=/^[/\\]/,Yc=/[/\\]$/,Qc=/("[^"]*")/,ed=[["((","))"],["))","(("],["{{","}}"],["[","]"],["(",")"],[")","("]],St=e=>`"${e.replace(/"/g,"#quot;")}"`,td=e=>e.length>=2&&e.startsWith('"')&&e.endsWith('"'),od=e=>{var n,r,s,a;let t=e.split(`
|
|
41
|
-
`),o=0;if(((n=t[o])==null?void 0:n.trim())==="---"){for(o+=1;o<t.length&&((r=t[o])==null?void 0:r.trim())!=="---";)o+=1;o+=1;}for(;o<t.length;){let c=(a=(s=t[o])==null?void 0:s.trim())!=null?a:"";if(c&&!c.startsWith("%%")){let l=c.split(Kc,1)[0];return l==="mindmap"?"mindmap":l==="flowchart"||l==="graph"?"flowchart":null}o+=1;}return null},nd=e=>{for(let[t,o]of ed){let n=e.indexOf(t);if(n===-1||!e.endsWith(o))continue;let r=e.slice(0,n);if(r&&!Gc.test(r))continue;let s=e.slice(n+t.length,e.length-o.length);if(!(s.includes(o)&&o!==t))return {id:r,open:t,close:o,inner:s}}return null},rd=e=>{let t=e.length-e.trimStart().length,o=e.slice(0,t),n=e.trim();if(!n||n.startsWith("%%")||n.startsWith("::icon"))return e;let r=nd(n);if(r)return !td(r.inner)&&(Ns.test(r.inner)||r.inner.includes('"'))?`${o}${r.id}${r.open}${St(r.inner)}${r.close}`:e;if(Ns.test(n)){let s=n.replace(Xc,"").trimEnd();return `${o}[${St(s)}]`}return e},sd=e=>{let t=e.split(`
|
|
42
|
-
`),o=false;return t.map(n=>o?rd(n):(n.trim()&&(o=true),n)).join(`
|
|
43
|
-
`)},ad=e=>e.startsWith("(")&&e.endsWith(")")||Jc.test(e)||Yc.test(e),$o=(e,t)=>e.split(Qc).map((o,n)=>n%2===0?t(o):o).join(""),ld=e=>{if(e.trim().startsWith("%%"))return e;let t=$o(e,o=>o.replace(/\[([^[\]"]*[(){}][^[\]"]*)\]/g,(n,r)=>ad(r)?n:`[${St(r)}]`));return t=$o(t,o=>o.replace(/\{([^{}"]*[()[\]][^{}"]*)\}/g,(n,r)=>`{${St(r)}}`)),t=$o(t,o=>o.replace(/\|([^|"]*[(){}[\]][^|"]*)\|/g,(n,r)=>`|${St(r)}|`)),t},id=e=>e.split(`
|
|
44
|
-
`).map(ld).join(`
|
|
45
|
-
`),Is=e=>{let t=od(e);if(!t)return null;let o=t==="mindmap"?sd(e):id(e);return o===e?null:o};var md=async(e,t,o)=>{try{return await e.render(t,o)}catch(n){let r=Is(o);if(!r)throw n;try{return await e.render(`${t}-autofix`,r)}catch(s){throw n}}},jn=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=f(),a=I(),[c,l]=useState(null),[i,d]=useState(false),[m,p]=useState(""),[g,u]=useState(null),[b,f$1]=useState(""),[h,y]=useState(0),{mermaid:w}=useContext(T),P=Ze(),S=w==null?void 0:w.errorComponent,{shouldRender:M,containerRef:E}=je({immediate:n});if(useEffect(()=>{if(!M)return;if(!P){l(a.mermaidPluginMissing);return}(async()=>{try{l(null),d(!0);let _=P.getMermaid(o),U=e.split("").reduce((z,L)=>(z<<5)-z+L.charCodeAt(0)|0,0),oe=`mermaid-${Math.abs(U)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:V}=await md(_,oe,e),W=dt(V),F=n?V:Bt(V);p(F),u(W),f$1(F);}catch(_){if(!(b||m)){let U=_ instanceof Error?_.message:a.mermaidRenderFailed;l(U);}}finally{d(false);}})();},[e,o,h,M,P]),!(M||m||b))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:E});if(i&&!m&&!b)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:E,children:jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:s("text-sm"),children:a.diagramLoading})]})});if(c&&!m&&!b){let C=()=>y(_=>_+1);return S?jsx("div",{ref:E,children:jsx(S,{chart:e,error:c,retry:C})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:E,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:[a.mermaidErrorLabel,": ",c]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:a.showCode}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let A=m||b;return jsx("div",{className:s(n?"size-full":"max-h-[min(70vh,40rem)] w-full",t),"data-streamdown":"mermaid",ref:E,children:jsx(jt,{className:s(n?"size-full overflow-hidden":"max-h-[min(70vh,40rem)] overflow-hidden",t),contentSize:g,fitKey:e,fullscreen:n,isAutoFit:true,maxZoom:3,minZoom:.1,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:s("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:A},role:"img"})})})};export{Pt as A,Xt as B,Fo as C,_c as D,zo as E,Vc as F,Ls as G,Zc as H,Us as a,Rt as b,ot as c,nt as d,ln as e,uo as f,fo as g,iu as h,go as i,It as j,Ue as k,yo as l,We as m,T as n,On as o,jn as p,Kn as q,Qn as r,Xe as s,$e as t,No as u,Wt as v,Je as w,wt as x,pi as y,Ct as z};
|
package/dist/chunk-O747JC4Y.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {createContext,useContext}from'react';var s=(...t)=>twMerge(clsx(t)),m=t=>{if(t!==void 0)return typeof t=="number"?!Number.isFinite(t)||t<=0?void 0:`${t}px`:t},l=(t,n)=>{if(!t||!n)return n;let o=`${t}:`;return n.split(/\s+/).filter(Boolean).map(e=>e.startsWith(o)?e:`${t}:${e}`).join(" ")},x=t=>t?(...n)=>l(t,twMerge(clsx(n))):s,F=(t,n,o)=>{let e=typeof n=="string"&&o.startsWith("text/csv")?"\uFEFF":"",p=typeof n=="string"?new Blob([e+n],{type:o}):n,i=URL.createObjectURL(p),r=document.createElement("a");r.href=i,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i);};var C=createContext(s),L=()=>useContext(C);export{s as a,m as b,x as c,F as d,C as e,L as f};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {n,h,e}from'./chunk-JVTSQQFX.js';import'./chunk-O747JC4Y.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/mermaid-TRQ3QBH6.js
DELETED
package/dist/viewer-XS6MIJ4M.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {f}from'./chunk-O747JC4Y.js';import {useRef,useEffect}from'react';import {jsx}from'react/jsx-runtime';var _=p=>{p.traverse(i=>{let o=i;if(o.geometry&&o.geometry.dispose(),Array.isArray(o.material))for(let u of o.material)u.dispose();else o.material&&o.material.dispose();});},G=({className:p,data:i,format:o,fullscreen:u=false})=>{let z=f(),b=useRef(null);return useEffect(()=>{let m=b.current;if(!m)return;let y=false,g=()=>{};return (async()=>{let e=await import('three'),[{STLLoader:P},{ThreeMFLoader:R},{OrbitControls:j}]=await Promise.all([import('three/examples/jsm/loaders/STLLoader.js'),import('three/examples/jsm/loaders/3MFLoader.js'),import('three/examples/jsm/controls/OrbitControls.js')]);if(y)return;let n=new e.WebGLRenderer({alpha:true,antialias:true});n.setPixelRatio(window.devicePixelRatio),m.appendChild(n.domElement);let c=new e.Scene,t=new e.PerspectiveCamera(45,1,.1,2e3),x=new e.Vector3(50,40,60).normalize();t.position.copy(x.clone().multiplyScalar(100));let s=new j(t,n.domElement);s.enableDamping=true,s.dampingFactor=.08;let A=new e.HemisphereLight(16777215,3159357,1.5);c.add(A);let M=new e.DirectionalLight(16777215,2.6);M.position.set(1,1.7,1.2),c.add(M);let v=new e.DirectionalLight(16777215,.7);v.position.set(-1,.5,-1),c.add(v);let r=new e.Group;c.add(r);let E=()=>{for(;r.children.length>0;){let a=r.children[0];r.remove(a),_(a);}let l=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength);if(o==="3mf"){let a=new R().parse(l);r.add(a);}else {let a=new P().parse(l);a.computeVertexNormals();let C=new e.MeshStandardMaterial({color:9081504,roughness:.55,metalness:.1});r.add(new e.Mesh(a,C));}let d=new e.Box3().setFromObject(r),h=d.getSize(new e.Vector3),w=Math.max(h.x,h.y,h.z)||1,S=d.getCenter(new e.Vector3),V=w*2.2,f=t.position.clone().sub(s.target).normalize();(!Number.isFinite(f.x)||f.lengthSq()===0)&&f.copy(x),s.target.copy(S),t.position.copy(S).add(f.multiplyScalar(V)),t.near=Math.max(w/1e3,.01),t.far=Math.max(w*100,1e3),t.updateProjectionMatrix(),s.update();},O=()=>{let{clientHeight:l,clientWidth:d}=m;d===0||l===0||(t.aspect=d/l,t.updateProjectionMatrix(),n.setSize(d,l));},D=new ResizeObserver(O);D.observe(m),O(),E(),n.setAnimationLoop(()=>{s.update(),n.render(c,t);}),g=()=>{D.disconnect(),n.setAnimationLoop(null),s.dispose(),_(r),c.clear(),n.dispose(),n.domElement.remove();};})().catch(()=>{}),()=>{y=true,g();}},[i,o]),jsx("div",{"aria-label":"OpenSCAD model",className:z(u?"size-full":"h-[400px] w-full",p),"data-streamdown":"openscad-viewer",ref:b,role:"img"})};export{G as OpenScadViewer};
|