@lofcz/streamdown 2.12.0 → 2.13.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.
@@ -0,0 +1,2 @@
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};
@@ -0,0 +1,45 @@
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 Ln 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 Fs=300,Vs="300px",zs=500;function je(e={}){let{immediate:t=false,debounceDelay:o=Fs,rootMargin:n=Vs,idleTimeout:r=zs}=e,[s,a]=useState(false),c=useRef(null),l=useRef(null),i=useRef(null),d=useMemo(()=>b=>{let m=Date.now();return window.setTimeout(()=>{b({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-m))});},1)},[]),u=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(b,m)=>window.requestIdleCallback(b,m):d,[d]),p=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?b=>window.cancelIdleCallback(b):b=>{clearTimeout(b);},[]);return useEffect(()=>{if(t){a(true);return}let b=c.current;if(!b)return;l.current&&(clearTimeout(l.current),l.current=null),i.current&&(p(i.current),i.current=null);let m=()=>{l.current&&(clearTimeout(l.current),l.current=null),i.current&&(p(i.current),i.current=null);},y=w=>{i.current=u(P=>{P.timeRemaining()>0||P.didTimeout?(a(true),w.disconnect()):i.current=u(()=>{a(true),w.disconnect();},{timeout:r/2});},{timeout:r});},f=w=>{m(),l.current=window.setTimeout(()=>{var T,R;let P=w.takeRecords();(P.length===0||(R=(T=P.at(-1))==null?void 0:T.isIntersecting)!=null&&R)&&y(w);},o);},h=(w,P)=>{w.isIntersecting?f(P):m();},g=new IntersectionObserver(w=>{for(let P of w)h(P,g);},{rootMargin:n,threshold:0});return g.observe(b),()=>{l.current&&clearTimeout(l.current),i.current&&p(i.current),g.disconnect();}},[t,o,n,r,p,u]),{shouldRender:s,containerRef:c}}var $s=320,js=4,Xo=()=>typeof performance=="undefined"?Date.now():performance.now();function so(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),u=d===0?0:Math.min(d,js),p=Math.max(r,i),b=i+o,m=p+Math.max(0,c-1)*d,y=d;if(m>b&&c>1)if(p<b){let h=b-p;y=Math.max(u,h/(c-1));}else y=u;let f=Math.max(0,Math.round(p-i));return r=p+c*y,{baseDelay:f,step:y}},commitPass(){n=r;}}}function Us(){return {current:0}}var Jo=/\s/,ao=/^\s+$/,Ws=new Set(["pre","svg","math","annotation"]),Zs=new Set(["svg","math","annotation"]),ro=new Set(["img","hr"]),qs=new Set(["ul","ol","li"]),He=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",lo=(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&&!ao.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)&&ro.has(a.tagName),(a,c)=>{if(lo(c,o.animateCodeBlocks))return SKIP$1;if(He(a)&&ro.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 u=s;s+=d.length,!ao.test(d)&&(n>0&&u<n||(r+=1));}}),r},Qs=(e,t,o,n,r,s)=>{if(lo(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(lo(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),u=n.prevContentLength,p=false,b=Ks(t),m=!!(b&&!((h=b.properties)!=null&&h["data-sd-animate-marker"])),y=false,f=d.map(g=>{let w=r.count;if(r.count+=g.length,ao.test(g))return {type:"text",value:g};let P=u>0&&w<u,S=P?0:s.baseDelay+r.newIndex++*s.step;if(b&&m&&!y){let T=P?0:o.duration;Gs(b,T,S,o.easing),Xs(b,o,T,S),y=true;}return p=true,Js(g,o.animation,o.duration,o.easing,P,S)});return p&&en(t),c.children.splice(l,1,...f),l+f.length},ta=0;function Mt(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 y;let u={count:0,newIndex:0};o.prevContentLength=o.committedCharCount;let p=t.timeline,b=(y=p==null?void 0:p.now())!=null?y:Xo();p&&(o.pendingMark===null?o.pendingMark=p.mark():p.rewind(o.pendingMark));let m=p?p.take(Ys(d,t,o,o.prevContentLength),t.stagger,b):{baseDelay:0,step:t.stagger};visitParents(d,f=>f.type==="text"||He(f)&&ro.has(f.tagName),(f,h)=>{if(f.type==="text")return ea(f,h,t,o,u,m);Qs(f,h,t,o,u,m);}),o.lastRenderCharCount=u.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;}}}Mt();var io=createContext(false),co=()=>useContext(io);var ot=({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},Et=({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();},u=null,p=f=>{u=an(f);},b=f=>{if(u===null)return;let h=an(f);if(h===null)return;let g=h-u;Math.abs(g)<=3||(g>0&&i(),u=h);},m=()=>{u=null;},y=()=>{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",b,{passive:true}),n.addEventListener("touchend",m,{passive:true}),n.addEventListener("touchcancel",m,{passive:true}),n.addEventListener("scroll",y,{passive:true}),()=>{n.removeEventListener("wheel",d,{capture:true}),n.removeEventListener("touchstart",p),n.removeEventListener("touchmove",b),n.removeEventListener("touchend",m),n.removeEventListener("touchcancel",m),n.removeEventListener("scroll",y);}},[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(M),u=d!=null?d:ot,p=b(r),b$1=Et({content:t,enabled:!!p,isAnimating:i}),m=useMemo(()=>l(ua),[l]),y=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(u,{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:b$1,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,g)=>jsx("span",{className:a?m:y,children:h.length===0||h.length===1&&h[0].content===""?`
3
+ `:h.map((w,P)=>{let S={},T=!!w.bgColor;if(w.color&&(S["--sdm-c"]=w.color),w.bgColor&&(S["--sdm-tbg"]=w.bgColor),w.htmlStyle)for(let[R,D]of Object.entries(w.htmlStyle))R==="color"?S["--sdm-c"]=D:R==="background-color"?(S["--sdm-tbg"]=D,T=true):S[R]=D;return jsx("span",{className:l("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",T&&"bg-[var(--sdm-tbg)]",T&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:S,...w.htmlAttrs,children:w.content},P)})},g))})})})});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:""}),Rt=()=>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-SXUW3M4W.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(M),d=useMemo(()=>Ca(e),[e]),u=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:u,startLine:s,...c}),children:jsx(va,{className:o,code:d,language:t,lineNumbers:a,maxHeight:i,raw:u,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 rt={CheckIcon:mn,CopyIcon:un,DownloadIcon:pn,ExternalLinkIcon:yn,Loader2Icon:fn,Maximize2Icon:gn,RotateCcwIcon:bn,XIcon:hn,ZoomInIcon:wn,ZoomOutIcon:Cn},xn=createContext(rt),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?{...rt,...e}:rt);Ta(o.current,e)||(o.current=e,n.current=e?{...rt,...e}:rt);let r=n.current;return jsx(xn.Provider,{value:r,children:t})},L=()=>useContext(xn);var Nt={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",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"},It=createContext(Nt),A=()=>useContext(It);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:u}=Rt(),{isAnimating:p}=useContext(M),b=A(),m=s!=null?s:u,y=async()=>{var g;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{l||(await navigator.clipboard.writeText(m),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=L(),h=l?f$1.CheckIcon:f$1.CopyIcon;return jsxs(Fragment,{children:[jsx("button",{"aria-label":b.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:y,title:b.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:b.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}=Rt(),{isAnimating:i,controls:d$1}=useContext(M),u=A(),p=L(),b=s!=null?s:l,m=o&&o in kn?kn[o]:"txt",y=`${ue(d$1,"code","file")}.${m}`,f$1="text/plain",h=()=>{try{d(y,b,f$1),e==null||e();}catch(g){t==null||t(g);}};return jsx("button",{"aria-label":u.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:u.downloadFile,type:"button",...a,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var We=()=>{let{Loader2Icon:e}=L(),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 st=0,le=()=>{st+=1,st===1&&(document.body.style.overflow="hidden");},ie=()=>{st=Math.max(0,st-1),st===0&&(document.body.style.overflow="");};var Fa=["github-light","github-dark"],Va={enabled:true},za={codeBlockMaxHeight:400,shikiTheme:Fa,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},M=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}=L(),d$1=f(),u=useRef(null),[p,b]=useState(false),[m,y]=useState(false),[f$1,h]=useState(false),{controls:g}=useContext(M),w=A(),P=Tn(g,"download"),S=Tn(g,"fullscreen"),T=c.width!=null||c.height!=null,R=P&&(p||T)&&!m,D=m&&!T,C=S&&!!o&&!m&&p;useEffect(()=>{let I=u.current;if(I!=null&&I.complete){let z=I.naturalWidth>0;b(z),y(!z);}},[]),useEffect(()=>{if(!f$1)return;le();let I=z=>{z.key==="Escape"&&h(false);};return document.addEventListener("keydown",I),()=>{document.removeEventListener("keydown",I),ie();}},[f$1]);let j=useCallback(I=>{b(true),y(false),r==null||r(I);},[r]),X=useCallback(I=>{b(false),y(true),s==null||s(I);},[s]),U=useCallback(()=>{C&&h(true);},[C]),J=useCallback(()=>{h(false);},[]),F=useCallback(I=>{a==null||a(I),!I.defaultPrevented&&U();},[a,U]),_=async I=>{if(I.stopPropagation(),!!o)try{let W=await(await fetch(o)).blob(),q=new URL(o,window.location.origin).pathname.split("/").pop()||"",re=q.split(".").pop(),ge=q.includes(".")&&re!==void 0&&re.length<=4,ae="";if(ge)ae=q;else {let ce=W.type,K="png";ce.includes("jpeg")||ce.includes("jpg")?K="jpg":ce.includes("png")?K="png":ce.includes("svg")?K="svg":ce.includes("gif")?K="gif":ce.includes("webp")&&(K="webp"),ae=`${(n||q||"image").replace(Wa,"")}.${K}`;}d(ae,W,W.type);}catch(z){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",D&&"hidden",t),"data-streamdown":"image",onClick:F,onError:X,onLoad:j,ref:u,src:o,...c}),D&&jsx("span",{className:d$1("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:w.imageNotAvailable}),R&&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:_,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:J,onKeyDown:I=>{I.key==="Escape"&&J();},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:J,title:w.exitFullscreen,type:"button",children:jsx(i,{size:20})}),jsx("div",{onClick:I=>I.stopPropagation(),onKeyDown:I=>I.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 Nn=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:c}=L(),l=f(),[i,d]=useState(false),u=A(),{portal:p}=useContext(M),b=useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(f){}},[e]),m=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 y=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:u.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:u.openExternalLink})]}),jsx("p",{className:l("text-muted-foreground text-sm"),children:u.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:b,type:"button",children:i?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:u.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:u.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:m,type:"button",children:[jsx(a,{size:14}),jsx("span",{children:u.openLink})]})]})]})});return createPortal(y,he(p))};var In=()=>e=>{visit(e,"html",(o,n,r)=>{!r||typeof n!="number"||(r.children[n]={type:"text",value:o.value});});};var An=[],Dn={allowDangerousHtml:true},Lt=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 u="default";return this.keyCache.set(t,u),u}let a=u=>{if(!u||u.length===0)return "";let p="";for(let b=0;b<u.length;b+=1){let m=u[b];if(b>0&&(p+=","),Array.isArray(m)){let[y,f]=m;if(typeof y=="function"){let h=Lt.get(y);h||(h=y.name,Lt.set(y,h)),p+=h;}else p+=String(y);p+=":",p+=JSON.stringify(f);}else if(typeof m=="function"){let y=Lt.get(m);y||(y=m.name,Lt.set(m,y)),p+=y;}else p+=String(m);}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,lt=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]===Ln:t===Ln),il=e=>{let t=e.rehypePlugins||An,o=e.remarkPlugins||An,n=ll(t)?o:[...o,In],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,u,p)=>{if(d.type==="raw"&&p&&typeof u=="number")return cl(p,u,s,d.value),u;if(d.type==="element"&&(dl(d,i),ml(d,u,p,n,r,o)&&p&&typeof u=="number"))return a&&d.children?p.children.splice(u,1,...d.children):p.children.splice(u,1),u});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var At=createContext(null),it=()=>useContext(At),iu=()=>{var t;let e=it();return (t=e==null?void 0:e.code)!=null?t:null},Ze=()=>{var t;let e=it();return (t=e==null?void 0:e.mermaid)!=null?t:null},qe=()=>{var t;let e=it();return (t=e==null?void 0:e.plantuml)!=null?t:null},Ke=()=>{var t;let e=it();return (t=e==null?void 0:e.openscad)!=null?t:null};var Bn=e=>{var o;let t=it();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,_n=/\sstyle=(['"])(.*?)\1/i,Fn=/^<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"'),Dt=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},ct=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},Ht=e=>{let t=e.match(Vn);if(!t)return e;try{let o=t[0],n=ct(e);if(!n)return e;let{width:r,height:s}=n,a=o.replace(hl,"").replace(yl,""),c=a.match(_n),l=`width:${r}px;height:${s}px;max-width:none;`;if(c){let i=c[1],u=c[2].split(";").map(b=>b.trim()).filter(Boolean).filter(b=>!(wl.test(b)||Cl.test(b)||vl.test(b))).join(";"),p=`${l}${u?`${u};`:""}`;a=a.replace(_n,` style=${i}${p}${i}`);}else a=a.replace(Fn,`<svg style="${l}"`);return a=a.replace(Fn,`<svg width="${r}" height="${s}"`),e.replace(o,a)}catch(o){return e}},Ot=(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,u=l.height*o;i.width=d,i.height=u;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,u),i.toBlob(b=>{if(!b){s(new Error("Failed to create PNG blob"));return}r(b);},"image/png");},l.onerror=()=>s(new Error("Failed to load SVG image")),l.src=c;})};var Bt=({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:u}=useContext(M),p=L(),b=Ze(),m=A(),y=ue(u,"mermaid","diagram"),f$1=async h=>{try{if(h==="mmd"){let R=`${y}.mmd`;d(R,e,"text/plain"),l(!1),n==null||n(h);return}if(!b){s==null||s(new Error("Mermaid plugin not available"));return}let g=b.getMermaid(r),w=e.split("").reduce((R,D)=>(R<<5)-R+D.charCodeAt(0)|0,0),P=`mermaid-${Math.abs(w)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:S}=await g.render(P,e);if(!S){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let T=Dt(S);if(h==="svg"){let R=`${y}.svg`;d(R,T,"image/svg+xml"),l(!1),n==null||n(h);return}if(h==="png"){let R=await Ot(T);d(`${y}.png`,R,"image/png"),n==null||n(h),l(!1);return}}catch(g){s==null||s(g);}};return useEffect(()=>{let h=g=>{let w=g.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":m.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:m.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":m.downloadDiagramAsSvg,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("svg"),title:m.downloadDiagramAsSvg,type:"button",children:m.mermaidFormatSvg}),jsx("button",{"aria-label":m.downloadDiagramAsPng,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("png"),title:m.downloadDiagramAsPng,type:"button",children:m.mermaidFormatPng}),jsx("button",{"aria-label":m.downloadDiagramAsMmd,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("mmd"),title:m.downloadDiagramAsMmd,type:"button",children:m.mermaidFormatMmd})]}):null]})};var Un=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=L(),l=f(),[i,d]=useState(false),{isAnimating:u,controls:p,portal:b}=useContext(M),m=A(),y=(()=>{if(typeof p=="boolean")return p;let g=p.mermaid;return g===false?false:g===true||g===void 0?true:g.panZoom!==false})(),f$1=(()=>{if(typeof p=="boolean")return p;let g=p.mermaid;return g===false?false:g===true||g===void 0?true:g.download!==false})(),h=()=>{d(!i);};return useEffect(()=>{if(i){le();let g=w=>{w.key==="Escape"&&d(false);};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),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:u,onClick:h,title:m.viewFullscreen,type:"button",...s,"aria-label":m.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i?createPortal(jsxs("div",{"aria-label":m.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:g=>{g.key==="Escape"&&h();},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:[f$1?jsx(Bt,{chart:e,config:t}):null,jsx("button",{"aria-label":m.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:m.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(jn,{chart:e,className:l("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:y})})]}),he(b)):null]})};var Zn={"3mf":"model/3mf",stl:"model/stl"},_t=({children:e,className:t,code:o,config:n,onDownload:r,onError:s})=>{let a=f(),[c,l]=useState(false),[i,d$1]=useState(false),u=useRef(null),{controls:p,isAnimating:b}=useContext(M),m=L(),y=Ke(),f$1=A(),h=ue(p,"openscad","model"),g=async w=>{try{if(w==="scad"){d(`${h}.scad`,o,"text/plain"),l(!1),r==null||r(w);return}if(!y){s==null||s(new Error("OpenSCAD plugin not available"));return}d$1(!0);let P=y.getOpenScad(n),{data:S}=await P.render(o,{...n,format:w}),T=S.buffer.slice(S.byteOffset,S.byteOffset+S.byteLength);d(`${h}.${w}`,new Blob([T],{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();u.current&&!S.includes(u.current)&&l(false);};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w);}},[]),jsxs("div",{className:a("relative"),ref:u,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:b||i,onClick:()=>l(!c),title:f$1.downloadModel,type:"button",children:e!=null?e:jsx(m.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:()=>g("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:()=>g("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:()=>g("3mf"),title:f$1.downloadModelAs3mf,type:"button",children:f$1.openscadFormat3mf})]}):null]})};var Fl=lazy(()=>import('./viewer-XS6MIJ4M.js').then(e=>({default:e.OpenScadViewer}))),Kn=({className:e,code:t,config:o,fullscreen:n=false})=>{let r=f(),[s,a]=useState(null),[c,l]=useState(false),[i,d]=useState(null),[u,p]=useState(null),[b,m]=useState(0),{openscad:y}=useContext(M),f$1=Ke(),h=y==null?void 0:y.errorComponent,{shouldRender:g,containerRef:w}=je({immediate:n});if(useEffect(()=>{if(!g)return;if(!f$1){a("OpenSCAD plugin not available. Please add the openscad plugin to enable model rendering.");return}(async()=>{try{a(null),l(!0);let R=await f$1.getOpenScad(o).render(t,o);d(R),p(R);}catch(T){if(!(u||i)){let R=T instanceof Error?T.message:"Failed to render model";a(R);}}finally{l(false);}})();},[t,o,b,g,f$1]),!(g||i||u))return jsx("div",{className:r("my-4 min-h-[200px]",e),ref:w});if(c&&!i&&!u)return jsx("div",{className:r("my-4 flex justify-center p-4",e),ref:w,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:"Loading OpenSCAD engine and rendering model..."})]})});if(s&&!i&&!u){let S=()=>m(T=>T+1);return h?jsx("div",{ref:w,children:jsx(h,{code:t,error:s,retry:S})}):jsxs("div",{className:r("rounded-md bg-red-50 p-4",e),ref:w,children:[jsxs("p",{className:r("font-mono text-red-700 text-sm"),children:["OpenSCAD Error: ",s]}),jsxs("details",{className:r("mt-2"),children:[jsx("summary",{className:r("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:r("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:t})]})]})}let P=i!=null?i:u;return jsx("div",{className:r("size-full",e),"data-streamdown":"openscad",ref:w,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:P?jsx(Fl,{className:e,data:P.data,format:P.format,fullscreen:n}):null})})};var Xn=({code:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=L(),l=f(),[i,d]=useState(false),{isAnimating:u,controls:p,portal:b}=useContext(M),m=A(),y=(()=>{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=g=>{g.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:u,onClick:f$1,title:m.viewFullscreen,type:"button",...s,"aria-label":m.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i?createPortal(jsxs("div",{"aria-label":m.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:[y?jsx(_t,{code:e,config:t}):null,jsx("button",{"aria-label":m.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:f$1,title:m.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(b)):null]})};var Vt=({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:u}=useContext(M),p=L(),b=qe(),m=A(),y=ue(u,"plantuml","diagram"),f$1=async h=>{try{if(h==="puml"){d(`${y}.puml`,e,"text/plain"),l(!1),n==null||n(h);return}if(!b){s==null||s(new Error("PlantUML plugin not available"));return}let g=b.getPlantUml(r),{svg:w}=await g.render(e,r);if(!w){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let P=Dt(w);if(h==="svg"){d(`${y}.svg`,P,"image/svg+xml"),l(!1),n==null||n(h);return}let S=await Ot(P);d(`${y}.png`,S,"image/png"),n==null||n(h),l(!1);}catch(g){s==null||s(g);}};return useEffect(()=>{let h=g=>{let w=g.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":m.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:m.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":m.downloadDiagramAsSvg,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("svg"),title:m.downloadDiagramAsSvg,type:"button",children:m.plantumlFormatSvg}),jsx("button",{"aria-label":m.downloadDiagramAsPng,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("png"),title:m.downloadDiagramAsPng,type:"button",children:m.plantumlFormatPng}),jsx("button",{"aria-label":m.downloadDiagramAsPuml,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f$1("puml"),title:m.downloadDiagramAsPuml,type:"button",children:m.plantumlFormatPuml})]}):null]})};var ft=e=>e>0?e:null,Gl=(e,t)=>{if(e.endsWith("px"))return ft(Number.parseFloat(e));if(e.endsWith("rem")){let o=Number.parseFloat(getComputedStyle(document.documentElement).fontSize||"16");return ft(Number.parseFloat(e)*o)}if(e.endsWith("em")){let o=Number.parseFloat(getComputedStyle(t).fontSize||"16");return ft(Number.parseFloat(e)*o)}if(e.endsWith("vh"))return ft(Number.parseFloat(e)/100*window.innerHeight);if(e.endsWith("%")){let o=t.parentElement;return o&&o.clientHeight>0?ft(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 u=Math.min(n/e.width,d/e.height,1);return !(u>0)||Number.isNaN(u)?null:{fitZoom:u,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}},$t=({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:u,ZoomInIcon:p,ZoomOutIcon:b}=L(),m=f(),y=A(),f$1=useRef(null),h=useRef(null),g=useRef(false),[w,P]=useState(l),[S,T]=useState(r),[R,D]=useState(l),[C,j]=useState({x:0,y:0}),[X,U]=useState(false),[J,F]=useState({x:0,y:0}),[_,V]=useState({x:0,y:0}),[I,z]=useState(null),W=useCallback(E=>{let $=f$1.current;if(!$)return;let ve=Yl(E,$,d);if(!ve)return;let{fitZoom:oe,viewportHeight:Me}=ve;z(Me),P(oe),T(Math.min(r,oe)),g.current||(D(oe),j({x:0,y:0}));},[d,r]),Z=useCallback(E=>{D($=>Math.max(S,Math.min(s,$+E))),g.current=true;},[S,s]),q=useCallback(()=>{Z(a);},[Z,a]),re=useCallback(()=>{Z(-a);},[Z,a]),ge=useCallback(()=>{D(w),j({x:0,y:0}),g.current=false;},[w]),ae=useCallback(E=>{E.preventDefault();let $=E.deltaY>0?-a:a;Z($);},[Z,a]),ce=useCallback(E=>{if(E.button!==0||E.isPrimary===false)return;U(true),g.current=true,F({x:E.clientX,y:E.clientY}),V(C);let $=E.currentTarget;$ instanceof HTMLElement&&$.setPointerCapture(E.pointerId);},[C]),K=useCallback(E=>{if(!X)return;E.preventDefault();let $=E.clientX-J.x,ve=E.clientY-J.y;j({x:_.x+$,y:_.y+ve});},[X,J,_]),de=useCallback(E=>{U(false);let $=E.currentTarget;$ instanceof HTMLElement&&$.releasePointerCapture(E.pointerId);},[]);useEffect(()=>{T(r),i||(P(l),D(l),z(null));},[l,i,r]),useLayoutEffect(()=>{if(!(i&&o))return;W(o);let E=f$1.current;if(!E||typeof ResizeObserver=="undefined")return;let $=new ResizeObserver(()=>{W(o);});return $.observe(E),()=>{$.disconnect();}},[W,o,i]),useEffect(()=>{i&&(g.current=false);},[n,i]),useEffect(()=>{let E=f$1.current;if(E)return E.addEventListener("wheel",ae,{passive:false}),()=>{E.removeEventListener("wheel",ae);}},[ae]),useEffect(()=>{let E=h.current;if(E&&X)return document.body.style.userSelect="none",E.addEventListener("pointermove",K,{passive:false}),E.addEventListener("pointerup",de),E.addEventListener("pointercancel",de),()=>{document.body.style.userSelect="",E.removeEventListener("pointermove",K),E.removeEventListener("pointerup",de),E.removeEventListener("pointercancel",de);}},[X,K,de]);let et=!d&&i&&I!=null?{height:I}:void 0;return jsxs("div",{className:m("relative flex flex-col",d?"h-full w-full":"min-h-28 w-full",t),ref:f$1,style:{cursor:X?"grabbing":"grab",...et},children:[c?jsxs("div",{className:m("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":y.zoomIn,className:m("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:y.zoomIn,type:"button",children:jsx(p,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":y.zoomOut,className:m("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:re,title:y.zoomOut,type:"button",children:jsx(b,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":y.resetView,className:m("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:ge,title:y.resetView,type:"button",children:jsx(u,{"aria-hidden":"true",size:16})})]}):null,jsx("div",{className:m("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(${R})`,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,c]=useState(null),[l,i]=useState(false),[d,u]=useState(""),[p,b]=useState(null),[m,y]=useState(""),[f$1,h]=useState(0),{plantuml:g}=useContext(M),w=qe(),P=g==null?void 0:g.errorComponent,{shouldRender:S,containerRef:T}=je({immediate:n});if(useEffect(()=>{if(!S)return;if(!w){c("PlantUML plugin not available. Please add the plantuml plugin to enable diagram rendering.");return}(async()=>{var C,j,X;try{c(null),i(!0);let U=w.getPlantUml(o),J=(X=(j=o==null?void 0:o.dark)!=null?j:(C=g==null?void 0:g.config)==null?void 0:C.dark)!=null?X:ti(),{svg:F}=await U.render(e,{dark:J}),_=ct(F),V=n?F:Ht(F);u(V),b(_),y(V);}catch(U){if(!(m||d)){let J=U instanceof Error?U.message:"Failed to render PlantUML chart";c(J);}}finally{i(false);}})();},[e,o,f$1,S,w]),!(S||d||m))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:T});if(l&&!d&&!m)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:T,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:"Loading diagram..."})]})});if(a&&!d&&!m){let D=()=>h(C=>C+1);return P?jsx("div",{ref:T,children:jsx(P,{chart:e,error:a,retry:D})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:T,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:["PlantUML Error: ",a]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let R=d||m;return jsx("div",{className:s("size-full",t),"data-streamdown":"plantuml",ref:T,children:jsx($t,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),contentSize:p,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:R},role:"img"})})})};var tr=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=L(),l=f(),[i,d]=useState(false),{isAnimating:u,controls:p,portal:b}=useContext(M),m=A(),y=(()=>{if(typeof p=="boolean")return p;let g=p.plantuml;return g===false?false:g===true||g===void 0?true:g.panZoom!==false})(),f$1=(()=>{if(typeof p=="boolean")return p;let g=p.plantuml;return g===false?false:g===true||g===void 0?true:g.download!==false})(),h=()=>{d(!i);};return useEffect(()=>{if(i){le();let g=w=>{w.key==="Escape"&&d(false);};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),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:u,onClick:h,title:m.viewFullscreen,type:"button",...s,"aria-label":m.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i?createPortal(jsxs("div",{"aria-label":m.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:g=>{g.key==="Escape"&&h();},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:[f$1?jsx(Vt,{chart:e,config:t}):null,jsx("button",{"aria-label":m.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:m.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(Qn,{chart:e,className:l("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:y})})]}),he(b)):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 No(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(No).join("")}var Xe=e=>{let t=[],o=[],n=e.querySelectorAll("thead th");for(let s of n)t.push(No(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(No(l).trim());o.push(a);}return {headers:t,rows:o}},gt=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 u of i)if(u===o||u==='"'||u===`
7
+ `||u==="\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
+ `)},Io=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
+ `)},Ut=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=>Ut(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?Ut(c[i]):"";n[r]=`| ${l.join(" | ")} |`,r+=1;}else {let l=c.map(i=>Ut(i));n[r]=`| ${l.join(" | ")} |`,r+=1;}return n.join(`
14
+ `)};var ht=({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),u=useRef(0),{isAnimating:p,controls:b}=useContext(M),m=A(),y=gt(b),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 T=(S=d.current)==null?void 0:S.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),R=T==null?void 0:T.querySelector("table");if(!R){n==null||n(new Error("Table not found"));return}let D=Xe(R),C="";w==="csv"?C=$e(D,y):w==="tsv"?C=Io(D):C=Je(D);let j=new ClipboardItem({"text/plain":new Blob([C],{type:"text/plain"}),"text/html":new Blob([R.outerHTML],{type:"text/html"})});await navigator.clipboard.write([j]),i(!0),c(!1),o==null||o(w),u.current=window.setTimeout(()=>i(!1),r);}catch(T){n==null||n(T);}};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(u.current);}},[]);let h=L(),g=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:m.copyTable,type:"button",children:e!=null?e:jsx(g,{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:m.copyTableAsMarkdown,type:"button",children:m.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:m.copyTableAsCsv,type:"button",children:m.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:m.copyTableAsTsv,type:"button",children:m.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(M),i=A(),d$1=L(),u=gt(l),p=b=>{try{let y=b.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=y==null?void 0:y.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let h=Xe(f),g="",w="",P="";switch(r){case "csv":g=$e(h,u),w="text/csv",P="csv";break;case "markdown":g=Je(h),w="text/markdown",P="md";break;default:g=$e(h,u),w="text/csv",P="csv";}d(`${s||ue(l,"table","table")}.${P}`,g,w),o==null||o();}catch(m){n==null||n(m);}};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})})},yt=({children:e,className:t,onDownload:o,onError:n})=>{let r=f(),[s,a]=useState(false),c=useRef(null),{isAnimating:l,controls:i}=useContext(M),d$1=A(),u=L(),p=gt(i),b=m=>{var y;try{let f=(y=c.current)==null?void 0:y.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 g=Xe(h),w=m==="csv"?$e(g,p):Je(g),P=m==="csv"?"csv":"md",S=`${ue(i,"table","table")}.${P}`;d(S,w,m==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(m);}catch(f){n==null||n(f);}};return useEffect(()=>{let m=y=>{let f=y.composedPath();c.current&&!f.includes(c.current)&&a(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),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(u.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:()=>b("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:()=>b("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}=L(),a=f(),[c,l]=useState(false),{isAnimating:i,portal:d}=useContext(M),u=A(),p=()=>{l(true);},b=()=>{l(false);};return useEffect(()=>{if(c){le();let m=y=>{y.key==="Escape"&&l(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),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:u.viewFullscreen,type:"button",children:jsx(r,{size:14})}),c?createPortal(jsx("div",{"aria-label":u.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:b,onKeyDown:m=>{m.key==="Escape"&&b();},role:"dialog",children:jsxs("div",{className:a("flex h-full flex-col"),onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),role:"presentation",children:[jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[o?jsx(ht,{}):null,n?jsx(yt,{}):null,jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:b,title:u.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(M),u=d!=null?d:ot,p=b(o),b$1=Et({content:e,enabled:!!p,isAnimating:i}),m=n&&r,y=n&&s,f$1=n&&a,h=m||y||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:[m?jsx(ht,{}):null,y?jsx(yt,{}):null,f$1?jsx(ir,{showCopy:m,showDownload:y,children:e}):null]}):null,jsx(u,{className:l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),scrollRef:b$1,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-CQ54J3W7.js').then(e=>({default:e.Mermaid}))),Ti=lazy(()=>import('./plantuml-5PF6IVQ3.js').then(e=>({default:e.PlantUml}))),Mi=lazy(()=>import('./openscad-3VFU4MTZ.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 Ni(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 Ii(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,Li=(e,t)=>!!(t&&gr(e,t.language)),Ai=(e,t)=>!!(t&&gr(e,t.language)),Ct=(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},Zt=(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},qt=(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},vt=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(vt),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(vt.Provider,{value:c,children:e})})},(e,t)=>B(e,t));Bo.displayName="MarkdownOl";var br=memo(({children:e,className:t,node:o,...n})=>{var y;let r=f(),{depth:s,ulDepth:a,isUnordered:c}=useContext(vt),{listStyle:l}=useContext(M),i=Di[l],d=c&&a>0?i[(a-1)%i.length]:void 0,u=Array.isArray(e)?e.filter(f=>f!==`
15
+ `&&f!==""):[e],p=u[0],b=isValidElement(p)?(y=we(p).node)==null?void 0:y.tagName:void 0,m=u.length===1&&isValidElement(p)&&(p.type==="p"||b==="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:m}):jsx("li",{className:r("py-1 [&>p]:inline",d,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...n,children:m})},(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(vt),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(vt.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(M),[c,l]=useState(false),i=o==="streamdown:incomplete-link",d=useCallback(async m=>{if(!(!(a!=null&&a.enabled&&o)||i)){if(m.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}l(true);}},[a,o,i]),u=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),p=useCallback(()=>{l(false);},[]),b={url:o!=null?o:"",isOpen:c,onClose:p,onConfirm:u};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(b):jsx(Nn,{...b})]}):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(M),a=Ct(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 Nr=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));Nr.displayName="MarkdownTr";var Ir=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));Ir.displayName="MarkdownTh";var Lr=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));Lr.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(M),d=n,u=d["data-callout-title"],p=d["data-callout-color"],b=d["data-callout-icon"],m=d["data-callout-body"],y=m?Bi(m):"",f$1=(a!=null?a:Oi)(p),h=b&&s?s(b):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:[u!==void 0?jsxs("p",{className:"mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",children:[h,u]}):null,y.trim().length>0?jsx(lt,{components:c,rehypePlugins:i,remarkPlugins:l,children:y}):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 _r=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],u=false,p=false;for(let b of d)if(b){if(typeof b=="string")b.trim()!==""&&(u=true);else if(isValidElement(b))if(we(b)["data-footnote-backref"]!==void 0)p=true;else {let m=we(b).children,y=Array.isArray(m)?m:[m];for(let f of y){if(typeof f=="string"&&f.trim()!==""){u=true;break}if(isValidElement(f)&&we(f)["data-footnote-backref"]===void 0){u=true;break}}}}return p&&!u},a=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===Bo){let i=we(l).children,u=(Array.isArray(i)?i:[i]).filter(p=>!s(p));return u.length===0?null:{...l,props:{...we(l),children:u}}}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));_r.displayName="MarkdownSection";var _i=({node:e,className:t,children:o,...n})=>{var _,V,I;let r=f(),s=!("data-block"in n),{mermaid:a,plantuml:c,openscad:l,controls:i,lineNumbers:d}=useContext(M),u=Ze(),p=qe(),b=Ke(),m=co(),y=t==null?void 0:t.match(Ei),f$1=(_=y==null?void 0:y.at(1))!=null?_:"",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 g=(V=e==null?void 0:e.properties)==null?void 0:V.metastring,w=typeof g=="string"?g:void 0,P=w==null?void 0:w.match(ki),S=P?Number.parseInt(P[1],10):void 0,T=S!==void 0&&S>=1?S:void 0,D=!(w?Pi.test(w):false)&&d!==false,C=(I=Ii(o))!=null?I:"";if(h){let z=h.component;return jsx(Suspense,{fallback:jsx(We,{}),children:jsx(z,{code:C,isIncomplete:m,language:f$1,meta:w})})}if(f$1==="mermaid"&&u){let z=Ct(i,"mermaid"),W=Zt(i,"download"),Z=Zt(i,"copy"),q=Zt(i,"fullscreen"),re=Zt(i,"panZoom"),ge=z&&(W||Z||q);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":m||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:[W?jsx(Bt,{chart:C,config:a==null?void 0:a.config}):null,Z?jsx(Ue,{code:C}):null,q?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:re})})]})})}if(Li(f$1,p)){let z=Ct(i,"plantuml"),W=qt(i,"download"),Z=qt(i,"copy"),q=qt(i,"fullscreen"),re=qt(i,"panZoom"),ge=z&&(W||Z||q);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":m||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:[W?jsx(Vt,{chart:C,config:c==null?void 0:c.config}):null,Z?jsx(Ue,{code:C}):null,q?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:re})})]})})}if(Ai(f$1,b)){let z=Ct(i,"openscad"),W=Ho(i,"download"),Z=Ho(i,"copy"),q=Ho(i,"fullscreen"),re=z&&(W||Z||q);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":m||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})}),re?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(_t,{code:C,config:l==null?void 0:l.config}):null,Z?jsx(Ue,{code:C}):null,q?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 j=Ct(i,"code"),X=mr(i,"download"),U=mr(i,"copy"),{"data-block":J,...F}=n;return jsx(go,{className:t,code:C,isIncomplete:m,language:f$1,lineNumbers:D,startLine:T,...F,children:j?jsxs(Fragment,{children:[X?jsx(yo,{code:C,language:f$1}):null,U?jsx(Ue,{}):null]}):null})},Fr=memo(_i,(e,t)=>B(e,t)&&Ni(e.node,t.node));Fr.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=A(),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:Nr,th:Ir,td:Lr,blockquote:Ar,code:Fr,div:Or,img:Vr,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:Dr,sub:Br,p:$r,section:_r};var Fi=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Vi=/\p{L}/u;function xt(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(Fi.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},Gt=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),u=qr(l,d),p=Kr(l,d);for(let b=0;b<u;b+=1)s.push(d);for(let b=0;b<p;b+=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 u=d[1],p=qr(l,u),b=Kr(l,u);p>b&&!Ki(l,u)&&s.push(u);}}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},_o=(e,t,o=Gt)=>{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*$/,Fo=/\n\n/g,Yi=(e,t,o)=>{if(!t.includes(`
17
+ `))return e+t+o;let r=t.replace(Fo,`
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 b=i.slice(2).replace(Fo,`
28
+ <!---->
29
+ `);n+=`${a}
30
+
31
+ ${b}`,r=e.length;break}if(!i.startsWith(`
32
+ `)){n+=a,r=l,s=o.exec(e);continue}let u=i.slice(1);if(u.trim().length===0){n+=a,r=l,s=o.exec(e);continue}let p=u.replace(Fo,`
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,"&#10;&#10;");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=xt(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,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),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 u,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 ((u=d[0])==null?void 0:u.type)==="break"&&(d=d.slice(1)),i.push(...d),i.length>0&&i.some(b=>b.type!=="text"||b.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!/?-]/,_c=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,Fc=e=>typeof e!="string"||e.length===0||!Bc.test(e)?e:e.replace(_c,"$1"),fs,gs,bs,hs,ys,ws,Cs,vs,xs,ks,Ps,Ss,Ts,Xt={...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:Ln,sanitize:[Rs,Xt],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={...Xt,tagNames:[...(r=Xt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...Xt.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},Ns=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?Fc(e):e,i=jsx(lt,{...c,children:l});return jsx(io.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)});Ns.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:u,plantuml:p,codeBlockMaxHeight:b=400,controls:m=true,isAnimating:y=false,scrollable:f,tableMaxHeight:h=300,animated:g,BlockComponent:w=Ns,parseMarkdownIntoBlocksFn:P=Gt,caret:S,listStyle:T="hierarchical",calloutIcon:R,calloutStyle:D,plugins:C,remend:j,linkSafety:X=Wc,portal:U,lineNumbers:J=true,allowedTags:F,literalTagContent:_,dataOnlyTags:V,translations:I,icons:z,prefix:W,onAnimationStart:Z,onAnimationEnd:q,...re})=>{let ge=useId(),ae=useMemo(()=>c(W),[W]),ce=useRef(null),K=useRef(Z),de=useRef(q);K.current=Z,de.current=q,useEffect(()=>{var N,ee,Y;if(t==="static")return;let k=ce.current;if(ce.current=y,k===null){y&&((N=K.current)==null||N.call(K));return}y&&!k?(ee=K.current)==null||ee.call(K):!y&&k&&((Y=de.current)==null||Y.call(de));},[y,t]);let et=useMemo(()=>F?Object.keys(F):[],[F]),E=useMemo(()=>{if(!(V!=null&&V.length))return et;let k=new Set(V.map(N=>N.toLowerCase()));return et.filter(N=>!k.has(N.toLowerCase()))},[et,V]),$=useRef(null),ve=useMemo(()=>{if(typeof e$1!="string")return "";let k=e$1;return _&&_.length>0&&(k=Jr(k,_)),E.length>0&&(k=Xr(k,E)),k=ls(k),k},[e$1,E,_]),oe=useMemo(()=>{let k=t==="streaming"?$.current:null,N=_o(ve,k,P);if($.current=t==="streaming"?N:null,!(t==="streaming"&&n)||N.blocks.length===0)return N.blocks;let ee=N.blocks.length-1,Y=N.blocks[ee],xe=Oc(Y,j);if(xe===Y)return N.blocks;let De=N.blocks.slice();return De[ee]=xe,De},[ve,P,t,n,j]),Me=useMemo(()=>g===true?"true":g?JSON.stringify(g):"",[g]),me=useRef(null),tt=useRef([]),Ne=useRef([]),jo=useRef(null),Yt=useRef("");if(Me){if(Yt.current!==Me){Yt.current=Me;let k=Me!=="true"?g.maxBacklogMs:void 0;me.current=so({maxBacklogMs:k}),tt.current=[],Ne.current=[];}else me.current||(me.current=so());y&&me.current&&me.current.beginPass(me.current.now());}else me.current=null,tt.current=[],Ne.current=[],Yt.current="";useLayoutEffect(()=>{var k;y&&((k=me.current)==null||k.commitPass());});let Ie=useDeferredValue(oe),Le=useMemo(()=>{if(t!=="streaming"||me.current||Ie===oe||Ie.length===0)return oe;let k=Ie.length,N=oe.length;if(N===0)return Ie;if(k!==N)return oe;for(let Y=0;Y<k-1;Y+=1)if(Ie[Y]!==oe[Y])return oe;let ee=Ie.slice();return ee[k-1]=oe[N-1],ee},[oe,Ie,t]),Qt=useMemo(()=>o==="auto"?Le.map(xt):void 0,[Le,o]),As=useMemo(()=>Le.map((k,N)=>`${ge}-${N}`),[Le.length,ge]),Ds=useMemo(()=>I?JSON.stringify(I):"",[I]),Uo=useMemo(()=>({...Nt,...I}),[Ds]),Pt=useMemo(()=>{let{inlineCode:k,...N}=s!=null?s:{},ee={...jr,...N};if(k){let Y=ee.code;ee.code=xe=>"data-block"in xe?Y?createElement(Y,xe):null:createElement(k,xe);}return ee},[s]),St=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 F&&Object.keys(F).length>0&&a===us&&(k=$c(F)),E.length>0&&(k=[...k,[rs,E,_!=null?_:[]]]),_&&_.length>0&&(k=[...k,[ns,_]]),V&&V.length>0&&(k=[...k,[ts,V]]),C!=null&&C.math&&(k=[...k,C.math.rehypePlugin]),o==="auto"&&t==="static"&&(k=[...k,es]),k},[a,C==null?void 0:C.math,F,E,_,V,o,t]),Wo=useMemo(()=>{var k,N;return {calloutIcon:R,calloutStyle:D,codeBlockMaxHeight:b,shikiTheme:(N=i!=null?i:(k=C==null?void 0:C.code)==null?void 0:k.getThemes())!=null?N:Uc,controls:m,isAnimating:y,lineNumbers:J,listStyle:T,mode:t,mermaid:d,openscad:u,plantuml:p,linkSafety:X,portal:U,scrollable:f,tableMaxHeight:h,components:Pt,remarkPlugins:St,rehypePlugins:Ae}},[R,D,b,i,m,y,J,T,t,d,u,p,X,U,f,C==null?void 0:C.code,h,Pt,St,Ae]),Hs=useMemo(()=>S&&y?{"--streamdown-caret":`"${jc[S]}"`}:void 0,[S,y]),Os=k=>{let N=null;if(me.current&&y){if(!tt.current[k]){let Y=Me&&Me!=="true"?g:{},{maxBacklogMs:xe,...De}=Y;tt.current[k]=Mt({...De,timeline:me.current});}N=tt.current[k];}jo.current!==Ae&&(Ne.current=[],jo.current=Ae),N&&!Ne.current[k]&&(Ne.current[k]=[...Ae,N.rehypePlugin]);let ee=N&&Ne.current[k]?Ne.current[k]:Ae;return {blockAnimatePlugin:N,blockRehypePlugins:ee}};return t==="static"?jsx(It.Provider,{value:Uo,children:jsx(At.Provider,{value:C!=null?C:null,children:jsx(M.Provider,{value:Wo,children:jsx(bo,{icons:z,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(lt,{components:Pt,rehypePlugins:Ae,remarkPlugins:St,...re,children:ve})})})})})})}):jsx(It.Provider,{value:Uo,children:jsx(At.Provider,{value:C!=null?C:null,children:jsx(M.Provider,{value:Wo,children:jsx(bo,{icons:z,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:[Le.length===0&&S&&y&&jsx("span",{}),Le.map((k,N)=>{var Zo;let ee=N===Le.length-1,Y=y&&ee&&Ur(k),{blockAnimatePlugin:xe,blockRehypePlugins:De}=Os(N);return jsx(w,{animatePlugin:xe,components:Pt,content:k,dir:(Zo=Qt==null?void 0:Qt[N])!=null?Zo:o!=="auto"?o:void 0,index:N,isIncomplete:Y,rehypePlugins:De,remarkPlugins:St,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...re},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 Is=/[(){}[\]]/,Kc=/[\s;]/,Gc=/^[\w-]+$/,Xc=/:::[\w-]+\s*$/,Jc=/^[/\\]/,Yc=/[/\\]$/,Qc=/("[^"]*")/,ed=[["((","))"],["))","(("],["{{","}}"],["[","]"],["(",")"],[")","("]],kt=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)&&(Is.test(r.inner)||r.inner.includes('"'))?`${o}${r.id}${r.open}${kt(r.inner)}${r.close}`:e;if(Is.test(n)){let s=n.replace(Xc,"").trimEnd();return `${o}[${kt(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:`[${kt(r)}]`));return t=$o(t,o=>o.replace(/\{([^{}"]*[()[\]][^{}"]*)\}/g,(n,r)=>`{${kt(r)}}`)),t=$o(t,o=>o.replace(/\|([^|"]*[(){}[\]][^|"]*)\|/g,(n,r)=>`|${kt(r)}|`)),t},id=e=>e.split(`
44
+ `).map(ld).join(`
45
+ `),Ls=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=Ls(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,c]=useState(null),[l,i]=useState(false),[d,u]=useState(""),[p,b]=useState(null),[m,y]=useState(""),[f$1,h]=useState(0),{mermaid:g}=useContext(M),w=Ze(),P=g==null?void 0:g.errorComponent,{shouldRender:S,containerRef:T}=je({immediate:n});if(useEffect(()=>{if(!S)return;if(!w){c("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{c(null),i(!0);let C=w.getMermaid(o),j=e.split("").reduce((_,V)=>(_<<5)-_+V.charCodeAt(0)|0,0),X=`mermaid-${Math.abs(j)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:U}=await md(C,X,e),J=ct(U),F=n?U:Ht(U);u(F),b(J),y(F);}catch(C){if(!(m||d)){let j=C instanceof Error?C.message:"Failed to render Mermaid chart";c(j);}}finally{i(false);}})();},[e,o,f$1,S,w]),!(S||d||m))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:T});if(l&&!d&&!m)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:T,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:"Loading diagram..."})]})});if(a&&!d&&!m){let D=()=>h(C=>C+1);return P?jsx("div",{ref:T,children:jsx(P,{chart:e,error:a,retry:D})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:T,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",a]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let R=d||m;return jsx("div",{className:s(n?"size-full":"max-h-[min(70vh,40rem)] w-full",t),"data-streamdown":"mermaid",ref:T,children:jsx($t,{className:s(n?"size-full overflow-hidden":"max-h-[min(70vh,40rem)] overflow-hidden",t),contentSize:p,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:R},role:"img"})})})};export{xt as A,Gt as B,_o as C,Fc as D,zo as E,Vc as F,Ns as G,Zc as H,Us as a,Mt as b,co as c,ot as d,ln as e,uo as f,fo as g,iu as h,go as i,Nt as j,Ue as k,yo as l,We as m,M as n,On as o,jn as p,Kn as q,Qn as r,Xe as s,$e as t,Io as u,Ut as v,Je as w,ht as x,pi as y,yt as z};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import {n,h,e}from'./chunk-PDMIFGF2.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/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { type AnimateOptions, type AnimatePlugin } from "./lib/animate";
4
4
  import { type IconMap } from "./lib/icon-context";
5
5
  import { type Options } from "./lib/markdown";
6
6
  import type { PluginConfig, ThemeInput } from "./lib/plugin-types";
7
- import { type CalloutIconResolver, type CalloutStyleResolver, type ControlsConfig, type LinkSafetyConfig, type ListStylePreset, type MermaidOptions, type PlantUmlOptions, type PortalTarget, type ScrollableComponent } from "./lib/streamdown-context";
7
+ import { type CalloutIconResolver, type CalloutStyleResolver, type ControlsConfig, type LinkSafetyConfig, type ListStylePreset, type MermaidOptions, type OpenScadOptions, type PlantUmlOptions, type PortalTarget, type ScrollableComponent } from "./lib/streamdown-context";
8
8
  import { type StreamdownTranslations } from "./lib/translations-context";
9
9
  export type { AnimateOptions } from "./lib/animate";
10
10
  export { createAnimateCursor, createAnimatePlugin } from "./lib/animate";
@@ -23,7 +23,7 @@ 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, PlantUmlErrorComponentProps, PlantUmlOptions, PortalTarget, ScrollableComponent, ScrollableProps, StreamdownContextType, } from "./lib/streamdown-context";
26
+ export type { CalloutIconResolver, CalloutStyleResolver, ControlsConfig, DownloadControlConfig, LinkSafetyConfig, LinkSafetyModalProps, MermaidErrorComponentProps, MermaidOptions, OpenScadErrorComponentProps, OpenScadOptions, PlantUmlErrorComponentProps, PlantUmlOptions, PortalTarget, ScrollableComponent, ScrollableProps, StreamdownContextType, } 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";
@@ -62,6 +62,7 @@ export type StreamdownProps = Options & {
62
62
  className?: string;
63
63
  shikiTheme?: [ThemeInput, ThemeInput];
64
64
  mermaid?: MermaidOptions;
65
+ openscad?: OpenScadOptions;
65
66
  plantuml?: PlantUmlOptions;
66
67
  codeBlockMaxHeight?: number | string;
67
68
  controls?: ControlsConfig;
@@ -164,4 +165,4 @@ export type BlockProps = Options & {
164
165
  animatePlugin?: AnimatePlugin | null;
165
166
  };
166
167
  export declare const Block: import("react").MemoExoticComponent<({ content, shouldParseIncompleteMarkdown: _, shouldNormalizeHtmlIndentation, index: __, isIncomplete, dir, animatePlugin: animatePluginProp, ...props }: BlockProps) => import("react/jsx-runtime").JSX.Element>;
167
- export declare const Streamdown: import("react").MemoExoticComponent<({ children, mode, dir, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, normalizeHtmlIndentation: shouldNormalizeHtmlIndentation, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, 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>;
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>;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export{F as Block,i as CodeBlock,f as CodeBlockContainer,k as CodeBlockCopyButton,l as CodeBlockDownloadButton,g as CodeBlockHeader,m as CodeBlockSkeleton,d as DefaultScrollable,G as Streamdown,n as StreamdownContext,w as TableCopyDropdown,x as TableDownloadButton,y as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,D as defaultRehypePlugins,E as defaultRemarkPlugins,j as defaultTranslations,o 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-BD73NLRI.js';
2
+ export{G as Block,i as CodeBlock,f as CodeBlockContainer,k as CodeBlockCopyButton,l as CodeBlockDownloadButton,g as CodeBlockHeader,m as CodeBlockSkeleton,d as DefaultScrollable,H as Streamdown,n as StreamdownContext,x as TableCopyDropdown,y as TableDownloadButton,z as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,E as defaultRehypePlugins,F as defaultRemarkPlugins,j as defaultTranslations,o as defaultUrlTransform,A as detectTextDirection,v as escapeMarkdownTableCell,s as extractTableDataFromElement,D as normalizeHtmlIndentation,B as parseMarkdownIntoBlocks,C as parseMarkdownIntoBlocksIncremental,t as tableDataToCSV,w as tableDataToMarkdown,u as tableDataToTSV,c as useIsCodeFenceIncomplete}from'./chunk-PDMIFGF2.js';import'./chunk-O747JC4Y.js';
@@ -1,2 +1,2 @@
1
1
  import type { ControlsConfig } from "./streamdown-context";
2
- export declare const getDownloadFilename: (config: ControlsConfig, type: "code" | "table" | "mermaid" | "plantuml", fallback: string) => string;
2
+ export declare const getDownloadFilename: (config: ControlsConfig, type: "code" | "table" | "mermaid" | "plantuml" | "openscad", fallback: string) => string;
@@ -15,5 +15,5 @@ interface PanZoomProps {
15
15
  showControls?: boolean;
16
16
  zoomStep?: number;
17
17
  }
18
- export declare const PanZoom: ({ children, className, contentSize, fitKey: _fitKey, minZoom, maxZoom, zoomStep, showControls, initialZoom, isAutoFit, fullscreen, }: PanZoomProps) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const PanZoom: ({ children, className, contentSize, fitKey, minZoom, maxZoom, zoomStep, showControls, initialZoom, isAutoFit, fullscreen, }: PanZoomProps) => import("react/jsx-runtime").JSX.Element;
19
19
  export {};
@@ -0,0 +1,12 @@
1
+ import type { OpenScadConfig, OpenScadExportFormat } from "../plugin-types";
2
+ type DownloadFormat = OpenScadExportFormat | "scad";
3
+ interface OpenScadDownloadDropdownProps {
4
+ children?: React.ReactNode;
5
+ className?: string;
6
+ code: string;
7
+ config?: OpenScadConfig;
8
+ onDownload?: (format: DownloadFormat) => void;
9
+ onError?: (error: Error) => void;
10
+ }
11
+ export declare const OpenScadDownloadDropdown: ({ children, className, code, config, onDownload, onError, }: OpenScadDownloadDropdownProps) => import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,10 @@
1
+ import { type ComponentProps } from "react";
2
+ import type { OpenScadConfig } from "../plugin-types";
3
+ type OpenScadFullscreenButtonProps = ComponentProps<"button"> & {
4
+ code: string;
5
+ config?: OpenScadConfig;
6
+ onFullscreen?: () => void;
7
+ onExit?: () => void;
8
+ };
9
+ export declare const OpenScadFullscreenButton: ({ code, config, onFullscreen, onExit, className, ...props }: OpenScadFullscreenButtonProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { OpenScadConfig } from "../plugin-types";
2
+ interface OpenScadProps {
3
+ className?: string;
4
+ code: string;
5
+ config?: OpenScadConfig;
6
+ fullscreen?: boolean;
7
+ }
8
+ export declare const OpenScad: ({ className, code, config, fullscreen, }: OpenScadProps) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,14 @@
1
+ interface OpenScadViewerProps {
2
+ className?: string;
3
+ data: Uint8Array;
4
+ format: "stl" | "3mf";
5
+ fullscreen?: boolean;
6
+ }
7
+ /**
8
+ * Interactive three.js viewer for rendered OpenSCAD models.
9
+ *
10
+ * This module is only ever loaded through a dynamic import after a render
11
+ * succeeded, so three.js never lands in an eagerly loaded chunk.
12
+ */
13
+ export declare const OpenScadViewer: ({ className, data, format, fullscreen, }: OpenScadViewerProps) => import("react/jsx-runtime").JSX.Element;
14
+ export {};
@@ -19,6 +19,10 @@ export declare const useMermaidPlugin: () => import("./plugin-types").DiagramPlu
19
19
  * Hook to access the PlantUML plugin
20
20
  */
21
21
  export declare const usePlantUmlPlugin: () => import("./plugin-types").PlantUmlPlugin | null;
22
+ /**
23
+ * Hook to access the OpenSCAD plugin
24
+ */
25
+ export declare const useOpenScadPlugin: () => import("./plugin-types").OpenScadPlugin | null;
22
26
  /**
23
27
  * Hook to access the math plugin
24
28
  */
@@ -159,10 +159,40 @@ export interface CjkPlugin {
159
159
  remarkPluginsBefore: Pluggable[];
160
160
  type: "cjk";
161
161
  }
162
+ /**
163
+ * Structural type for OpenSCAD configuration.
164
+ * Avoids a hard dependency on `@lofcz/streamdown-openscad` in the core bundle.
165
+ */
166
+ export interface OpenScadConfig {
167
+ format?: "stl" | "3mf" | "auto";
168
+ }
169
+ export type OpenScadExportFormat = "stl" | "3mf";
170
+ export interface OpenScadRenderResult {
171
+ data: Uint8Array;
172
+ format: OpenScadExportFormat;
173
+ }
174
+ export interface OpenScadInstance {
175
+ render: (source: string, options?: OpenScadConfig) => Promise<OpenScadRenderResult>;
176
+ }
177
+ /**
178
+ * Plugin for 3D model rendering (OpenSCAD)
179
+ */
180
+ export interface OpenScadPlugin {
181
+ /**
182
+ * Get the OpenSCAD instance (initialized with optional config)
183
+ */
184
+ getOpenScad: (config?: OpenScadConfig) => OpenScadInstance;
185
+ /**
186
+ * Language identifiers for code blocks (`openscad`, `scad`)
187
+ */
188
+ language: string | readonly string[];
189
+ name: "openscad";
190
+ type: "model";
191
+ }
162
192
  /**
163
193
  * Union type for all plugins
164
194
  */
165
- export type StreamdownPlugin = CodeHighlighterPlugin | DiagramPlugin | PlantUmlPlugin | MathPlugin | CjkPlugin;
195
+ export type StreamdownPlugin = CodeHighlighterPlugin | DiagramPlugin | PlantUmlPlugin | MathPlugin | CjkPlugin | OpenScadPlugin;
166
196
  export interface CustomRendererProps {
167
197
  code: string;
168
198
  isIncomplete: boolean;
@@ -184,6 +214,7 @@ export interface PluginConfig {
184
214
  code?: CodeHighlighterPlugin;
185
215
  math?: MathPlugin;
186
216
  mermaid?: DiagramPlugin;
217
+ openscad?: OpenScadPlugin;
187
218
  plantuml?: PlantUmlPlugin;
188
219
  renderers?: CustomRenderer[];
189
220
  }
@@ -1,7 +1,7 @@
1
1
  import { type ComponentProps, type ComponentType, type CSSProperties } from "react";
2
2
  import type { PluggableList } from "unified";
3
3
  import type { Components } from "./markdown";
4
- import type { MermaidConfig, PlantUmlConfig, ThemeInput } from "./plugin-types";
4
+ import type { MermaidConfig, OpenScadConfig, PlantUmlConfig, ThemeInput } from "./plugin-types";
5
5
  import type { CSVSeparator } from "./table/utils";
6
6
  export type DownloadControlConfig = boolean | {
7
7
  filename: string;
@@ -29,6 +29,11 @@ export type ControlsConfig = boolean | {
29
29
  fullscreen?: boolean;
30
30
  panZoom?: boolean;
31
31
  };
32
+ openscad?: boolean | {
33
+ download?: DownloadControlConfig;
34
+ copy?: boolean;
35
+ fullscreen?: boolean;
36
+ };
32
37
  image?: boolean | {
33
38
  download?: boolean;
34
39
  fullscreen?: boolean;
@@ -63,6 +68,15 @@ export interface PlantUmlOptions {
63
68
  config?: PlantUmlConfig;
64
69
  errorComponent?: React.ComponentType<PlantUmlErrorComponentProps>;
65
70
  }
71
+ export interface OpenScadErrorComponentProps {
72
+ code: string;
73
+ error: string;
74
+ retry: () => void;
75
+ }
76
+ export interface OpenScadOptions {
77
+ config?: OpenScadConfig;
78
+ errorComponent?: React.ComponentType<OpenScadErrorComponentProps>;
79
+ }
66
80
  /**
67
81
  * Built-in list bullet style presets for nested unordered lists.
68
82
  * - `"flat"` — all levels use disc
@@ -117,6 +131,7 @@ export interface StreamdownContextType {
117
131
  listStyle: ListStylePreset;
118
132
  mermaid?: MermaidOptions;
119
133
  mode: "static" | "streaming";
134
+ openscad?: OpenScadOptions;
120
135
  plantuml?: PlantUmlOptions;
121
136
  /** Overlay portal target for fullscreen and the built-in link safety modal. */
122
137
  portal?: PortalTarget;
@@ -19,6 +19,10 @@ export interface StreamdownTranslations {
19
19
  downloadDiagramAsSvg: string;
20
20
  downloadFile: string;
21
21
  downloadImage: string;
22
+ downloadModel: string;
23
+ downloadModelAs3mf: string;
24
+ downloadModelAsScad: string;
25
+ downloadModelAsStl: string;
22
26
  downloadTable: string;
23
27
  downloadTableAsCsv: string;
24
28
  downloadTableAsMarkdown: string;
@@ -30,6 +34,9 @@ export interface StreamdownTranslations {
30
34
  mermaidFormatSvg: string;
31
35
  openExternalLink: string;
32
36
  openLink: string;
37
+ openscadFormat3mf: string;
38
+ openscadFormatScad: string;
39
+ openscadFormatStl: string;
33
40
  plantumlFormatPng: string;
34
41
  plantumlFormatPuml: string;
35
42
  plantumlFormatSvg: string;
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export{p as Mermaid}from'./chunk-PDMIFGF2.js';import'./chunk-O747JC4Y.js';
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export{q as OpenScad}from'./chunk-PDMIFGF2.js';import'./chunk-O747JC4Y.js';
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export{r as PlantUml}from'./chunk-PDMIFGF2.js';import'./chunk-O747JC4Y.js';
@@ -0,0 +1,2 @@
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/streamdown",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -40,6 +40,7 @@
40
40
  "@types/mdast": "^4.0.4",
41
41
  "@types/react": "^19.2.7",
42
42
  "@types/react-dom": "^19.2.3",
43
+ "@types/three": "^0.170.0",
43
44
  "@types/unist": "^2.0.11",
44
45
  "@vitejs/plugin-react": "^5.1.2",
45
46
  "@vitest/coverage-v8": "^4.1.10",
@@ -52,8 +53,8 @@
52
53
  "typescript": "^7.0.2",
53
54
  "vitest": "^4.1.10",
54
55
  "@streamdown/cjk": "npm:@lofcz/streamdown-cjk@1.0.3",
55
- "@streamdown/math": "npm:@lofcz/streamdown-math@1.0.3",
56
- "@streamdown/mermaid": "npm:@lofcz/streamdown-mermaid@1.0.2"
56
+ "@streamdown/mermaid": "npm:@lofcz/streamdown-mermaid@1.0.2",
57
+ "@streamdown/math": "npm:@lofcz/streamdown-math@1.0.3"
57
58
  },
58
59
  "peerDependencies": {
59
60
  "react": "^18.0.0 || ^19.0.0",
@@ -61,10 +62,11 @@
61
62
  },
62
63
  "dependencies": {
63
64
  "clsx": "^2.1.1",
65
+ "three": "^0.170.0",
64
66
  "hast-util-to-jsx-runtime": "^2.3.6",
65
67
  "hast-util-to-text": "^4.0.2",
66
68
  "html-url-attributes": "^3.0.1",
67
- "marked": "^18.0.9",
69
+ "marked": "^18.0.11",
68
70
  "rehype-harden": "^1.1.8",
69
71
  "rehype-raw": "^7.0.0",
70
72
  "rehype-sanitize": "^6.0.0",
@@ -1,45 +0,0 @@
1
- "use client";
2
- 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 wn from'rehype-raw';import ds,{defaultSchema}from'rehype-sanitize';import tc from'remark-gfm';import oc from'remend';import {visitParents,SKIP as SKIP$1}from'unist-util-visit-parents';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';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 Fa from'remark-parse';import za 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 ws=300,vs="300px",xs=500;function ht(e={}){let{immediate:t=false,debounceDelay:o=ws,rootMargin:n=vs,idleTimeout:r=xs}=e,[s,a]=useState(false),c=useRef(null),l=useRef(null),i=useRef(null),d=useMemo(()=>f=>{let m=Date.now();return window.setTimeout(()=>{f({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-m))});},1)},[]),u=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(f,m)=>window.requestIdleCallback(f,m):d,[d]),p=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?f=>window.cancelIdleCallback(f):f=>{clearTimeout(f);},[]);return useEffect(()=>{if(t){a(true);return}let f=c.current;if(!f)return;l.current&&(clearTimeout(l.current),l.current=null),i.current&&(p(i.current),i.current=null);let m=()=>{l.current&&(clearTimeout(l.current),l.current=null),i.current&&(p(i.current),i.current=null);},y=C=>{i.current=u(P=>{P.timeRemaining()>0||P.didTimeout?(a(true),C.disconnect()):i.current=u(()=>{a(true),C.disconnect();},{timeout:r/2});},{timeout:r});},h=C=>{m(),l.current=window.setTimeout(()=>{var M,S;let P=C.takeRecords();(P.length===0||(S=(M=P.at(-1))==null?void 0:M.isIntersecting)!=null&&S)&&y(C);},o);},b=(C,P)=>{C.isIntersecting?h(P):m();},g=new IntersectionObserver(C=>{for(let P of C)b(P,g);},{rootMargin:n,threshold:0});return g.observe(f),()=>{l.current&&clearTimeout(l.current),i.current&&p(i.current),g.disconnect();}},[t,o,n,r,p,u]),{shouldRender:s,containerRef:c}}var ks=320,Ps=4,Ho=()=>typeof performance=="undefined"?Date.now():performance.now();function Gt(e){var s,a;let t=(s=e==null?void 0:e.now)!=null?s:Ho,o=(a=e==null?void 0:e.maxBacklogMs)!=null?a:ks,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),u=d===0?0:Math.min(d,Ps),p=Math.max(r,i),f=i+o,m=p+Math.max(0,c-1)*d,y=d;if(m>f&&c>1)if(p<f){let b=f-p;y=Math.max(u,b/(c-1));}else y=u;let h=Math.max(0,Math.round(p-i));return r=p+c*y,{baseDelay:h,step:y}},commitPass(){n=r;}}}function Ts(){return {current:0}}var Bo=/\s/,Xt=/^\s+$/,Ss=new Set(["pre","svg","math","annotation"]),Ms=new Set(["svg","math","annotation"]),Kt=new Set(["img","hr"]),Is=new Set(["ul","ol","li"]),Ne=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",Jt=(e,t)=>{let o=t?Ms:Ss;return e.some(n=>Ne(n)&&o.has(n.tagName))},Es=e=>{for(let t=e.length-1;t>=0;t-=1){let o=e[t];if(Ne(o)&&o.tagName==="li")return o}},Rs=(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}`;},Oo=e=>{for(let t of e.children)if(Ne(t)){if(t.tagName==="input")return t;if(Is.has(t.tagName))continue;let o=Oo(t);if(o)return o}},_o=(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`;},Ls=(e,t,o,n)=>{let r=Oo(e);r&&_o(r,t,o,n);},Vo=e=>{var t;for(let o=e.length-1;o>=0;o-=1){let n=e[o];if(Ne(n)){if((t=n.properties)!=null&&t["data-sd-animated"])break;n.properties={...n.properties,"data-sd-animated":true};}}},Fo=e=>{let t=[],o="",n=false;for(let r of e){let s=Bo.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},zo=e=>{let t=[],o="";for(let n of e)Bo.test(n)?t.length>0&&!Xt.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},Ns=(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}]}},As=(e,t,o,n)=>{let r=0,s=0;return visitParents(e,a=>a.type==="text"||Ne(a)&&Kt.has(a.tagName),(a,c)=>{if(Jt(c,o.animateCodeBlocks))return SKIP$1;if(Ne(a)&&Kt.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"?zo(l):Fo(l);for(let d of i){let u=s;s+=d.length,!Xt.test(d)&&(n>0&&u<n||(r+=1));}}),r},Ds=(e,t,o,n,r,s)=>{if(Jt(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;_o(e,o,l?0:o.duration,i),Vo(t);},Hs=(e,t,o,n,r,s)=>{var b;let a=t.at(-1);if(!(a&&"children"in a))return;if(Jt(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"?zo(i):Fo(i),u=n.prevContentLength,p=false,f=Es(t),m=!!(f&&!((b=f.properties)!=null&&b["data-sd-animate-marker"])),y=false,h=d.map(g=>{let C=r.count;if(r.count+=g.length,Xt.test(g))return {type:"text",value:g};let P=u>0&&C<u,E=P?0:s.baseDelay+r.newIndex++*s.step;if(f&&m&&!y){let M=P?0:o.duration;Rs(f,M,E,o.easing),Ls(f,o,M,E),y=true;}return p=true,Ns(g,o.animation,o.duration,o.easing,P,E)});return p&&Vo(t),c.children.splice(l,1,...h),l+h.length},Bs=0;function yt(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=Bs++,r=()=>d=>{var y;let u={count:0,newIndex:0};o.prevContentLength=o.committedCharCount;let p=t.timeline,f=(y=p==null?void 0:p.now())!=null?y:Ho();p&&(o.pendingMark===null?o.pendingMark=p.mark():p.rewind(o.pendingMark));let m=p?p.take(As(d,t,o,o.prevContentLength),t.stagger,f):{baseDelay:0,step:t.stagger};visitParents(d,h=>h.type==="text"||Ne(h)&&Kt.has(h.tagName),(h,b)=>{if(h.type==="text")return Hs(h,b,t,o,u,m);Ds(h,b,t,o,u,m);}),o.lastRenderCharCount=u.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;}}}yt();var Yt=createContext(false),Qt=()=>useContext(Yt);var Fe=(...e)=>twMerge(clsx(e)),Ct=e=>{if(e!==void 0)return typeof e=="number"?!Number.isFinite(e)||e<=0?void 0:`${e}px`:e},Vs=(e,t)=>{if(!e||!t)return t;let o=`${e}:`;return t.split(/\s+/).filter(Boolean).map(n=>n.startsWith(o)?n:`${e}:${n}`).join(" ")},Uo=e=>e?(...t)=>Vs(e,twMerge(clsx(t))):Fe,J=(e,t,o)=>{let n=typeof t=="string"&&o.startsWith("text/csv")?"\uFEFF":"",r=typeof t=="string"?new Blob([n+t],{type:o}):t,s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s);};var wt=createContext(Fe),w=()=>useContext(wt);var Ge=({scrollRef:e,ref:t,...o})=>jsx("div",{ref:e,...o});var Ws=8,Zs=e=>e.scrollHeight-e.scrollTop-e.clientHeight<Ws,Ko=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},vt=({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();},u=null,p=h=>{u=Ko(h);},f=h=>{if(u===null)return;let b=Ko(h);if(b===null)return;let g=b-u;Math.abs(g)<=3||(g>0&&i(),u=b);},m=()=>{u=null;},y=()=>{let h=n.scrollTop<a.current;if(a.current=n.scrollTop,h){i();return}Zs(n)&&(s.current=true);};return n.addEventListener("wheel",d,{capture:true,passive:true}),n.addEventListener("touchstart",p,{passive:true}),n.addEventListener("touchmove",f,{passive:true}),n.addEventListener("touchend",m,{passive:true}),n.addEventListener("touchcancel",m,{passive:true}),n.addEventListener("scroll",y,{passive:true}),()=>{n.removeEventListener("wheel",d,{capture:true}),n.removeEventListener("touchstart",p),n.removeEventListener("touchmove",f),n.removeEventListener("touchend",m),n.removeEventListener("touchcancel",m),n.removeEventListener("scroll",y);}},[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 Gs=Fe("block"),Xs=Fe("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"),Js=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},Go=memo(({children:e,result:t,language:o,className:n,maxHeight:r,startLine:s,lineNumbers:a=true,...c})=>{let l=w(),{isAnimating:i,scrollable:d}=useContext(I),u=d!=null?d:Ge,p=Ct(r),f=vt({content:t,enabled:!!p,isAnimating:i}),m=useMemo(()=>l(Xs),[l]),y=useMemo(()=>l(Gs),[l]),h=useMemo(()=>{let b={};return t.bg&&(b["--sdm-bg"]=t.bg),t.fg&&(b["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(b,Js(t.rootStyle)),b},[t.bg,t.fg,t.rootStyle]);return jsx(u,{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:f,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((b,g)=>jsx("span",{className:a?m:y,children:b.length===0||b.length===1&&b[0].content===""?`
3
- `:b.map((C,P)=>{let E={},M=!!C.bgColor;if(C.color&&(E["--sdm-c"]=C.color),C.bgColor&&(E["--sdm-tbg"]=C.bgColor),C.htmlStyle)for(let[S,v]of Object.entries(C.htmlStyle))S==="color"?E["--sdm-c"]=v:S==="background-color"?(E["--sdm-tbg"]=v,M=true):E[S]=v;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:E,...C.htmlAttrs,children:C.content},P)})},g))})})})});var to=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let s=w();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 oo=createContext({code:""}),xt=()=>useContext(oo);var no=({language:e})=>{let t=w();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 ra=e=>{let t=e.length;for(;t>0&&e[t-1]===`
4
- `;)t--;return e.slice(0,t)},sa=lazy(()=>import('./highlighted-body-ZJQJRCZ7.js').then(e=>({default:e.HighlightedCodeBlockBody}))),ro=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,lineNumbers:a,...c})=>{let l=w(),{codeBlockMaxHeight:i}=useContext(I),d=useMemo(()=>ra(e),[e]),u=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
5
- `).map(p=>[{content:p,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]);return jsx(oo.Provider,{value:{code:e},children:jsxs(to,{dir:"ltr",isIncomplete:r,language:t,children:[jsx(no,{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(Go,{className:o,language:t,lineNumbers:a,maxHeight:i,result:u,startLine:s,...c}),children:jsx(sa,{className:o,code:d,language:t,lineNumbers:a,maxHeight:i,raw:u,startLine:s,...c})})]})})};var Yo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"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"})}),Qo=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"})}),en=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"})}),tn=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"})]}),on=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"})}),nn=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"})}),rn=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"})}),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:"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"})}),an=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"})}),ln=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 Je={CheckIcon:Yo,CopyIcon:Qo,DownloadIcon:en,ExternalLinkIcon:sn,Loader2Icon:tn,Maximize2Icon:on,RotateCcwIcon:nn,XIcon:rn,ZoomInIcon:an,ZoomOutIcon:ln},dn=createContext(Je),da=(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])},so=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...Je,...e}:Je);da(o.current,e)||(o.current=e,n.current=e?{...Je,...e}:Je);let r=n.current;return jsx(dn.Provider,{value:r,children:t})},O=()=>useContext(dn);var kt={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",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"},Pt=createContext(kt),_=()=>useContext(Pt);var Ye=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let c=w(),[l,i]=useState(false),d=useRef(0),{code:u}=xt(),{isAnimating:p}=useContext(I),f=_(),m=s!=null?s:u,y=async()=>{var g;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{l||(await navigator.clipboard.writeText(m),i(!0),e==null||e(),d.current=window.setTimeout(()=>i(!1),o));}catch(C){t==null||t(C);}};useEffect(()=>()=>{window.clearTimeout(d.current);},[]);let h=O(),b=l?h.CheckIcon:h.CopyIcon;return jsxs(Fragment,{children:[jsx("button",{"aria-label":f.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:y,title:f.copyCode,type:"button",...a,children:n!=null?n:jsx(b,{"aria-hidden":"true",size:14})}),l&&jsx("output",{"aria-live":"polite",className:"sr-only",children:f.copied})]})};var ge=(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 mn={"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"},lo=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let c=w(),{code:l}=xt(),{isAnimating:i,controls:d}=useContext(I),u=_(),p=O(),f=s!=null?s:l,m=o&&o in mn?mn[o]:"txt",y=`${ge(d,"code","file")}.${m}`,h="text/plain",b=()=>{try{J(y,f,h),e==null||e();}catch(g){t==null||t(g);}};return jsx("button",{"aria-label":u.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:b,title:u.downloadFile,type:"button",...a,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var Qe=()=>{let{Loader2Icon:e}=O(),t=w();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 et=0,ie=()=>{et+=1,et===1&&(document.body.style.overflow="hidden");},ce=()=>{et=Math.max(0,et-1),et===0&&(document.body.style.overflow="");};var ka=["github-light","github-dark"],Pa={enabled:true},Ta={codeBlockMaxHeight:400,shikiTheme:ka,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,plantuml:void 0,linkSafety:Pa,portal:void 0,tableMaxHeight:300},I=createContext(Ta);var Ea=/\.[^/.]+$/,fn=(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},gn=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,onClick:a,...c})=>{let{DownloadIcon:l,XIcon:i}=O(),d=w(),u=useRef(null),[p,f]=useState(false),[m,y]=useState(false),[h,b]=useState(false),{controls:g}=useContext(I),C=_(),P=fn(g,"download"),E=fn(g,"fullscreen"),M=c.width!=null||c.height!=null,S=P&&(p||M)&&!m,v=m&&!M,N=E&&!!o&&!m&&p;useEffect(()=>{let L=u.current;if(L!=null&&L.complete){let F=L.naturalWidth>0;f(F),y(!F);}},[]),useEffect(()=>{if(!h)return;ie();let L=F=>{F.key==="Escape"&&b(false);};return document.addEventListener("keydown",L),()=>{document.removeEventListener("keydown",L),ce();}},[h]);let z=useCallback(L=>{f(true),y(false),r==null||r(L);},[r]),ee=useCallback(L=>{f(false),y(true),s==null||s(L);},[s]),W=useCallback(()=>{N&&b(true);},[N]),V=useCallback(()=>{b(false);},[]),B=useCallback(L=>{a==null||a(L),!L.defaultPrevented&&W();},[a,W]),$=async L=>{if(L.stopPropagation(),!!o)try{let Y=await(await fetch(o)).blob(),te=new URL(o,window.location.origin).pathname.split("/").pop()||"",pe=te.split(".").pop(),we=te.includes(".")&&pe!==void 0&&pe.length<=4,ae="";if(we)ae=te;else {let U=Y.type,T="png";U.includes("jpeg")||U.includes("jpg")?T="jpg":U.includes("png")?T="png":U.includes("svg")?T="svg":U.includes("gif")?T="gif":U.includes("webp")&&(T="webp"),ae=`${(n||te||"image").replace(Ea,"")}.${T}`;}J(ae,Y,Y.type);}catch(F){window.open(o,"_blank");}};return o?o==="streamdown:incomplete-image"?jsx("div",{className:d("group relative my-4 inline-block"),"data-incomplete":"true","data-streamdown":"image-wrapper",children:jsx("div",{className:d("h-24 w-48 animate-pulse rounded-lg bg-muted"),"data-streamdown":"image-placeholder"})}):jsxs(Fragment,{children:[jsxs("div",{className:d("group/image not-prose relative my-2 block max-w-full"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:d("m-0 block h-auto max-w-full rounded-lg",N&&"cursor-zoom-in",v&&"hidden",t),"data-streamdown":"image",onClick:B,onError:ee,onLoad:z,ref:u,src:o,...c}),v&&jsx("span",{className:d("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:C.imageNotAvailable}),S&&jsx("button",{className:d("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:$,title:C.downloadImage,type:"button",children:jsx(l,{size:14})})]}),h?createPortal(jsxs("div",{className:d("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("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:C.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("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:o})})]}),document.body):null]}):null};var xe=e=>{let t=typeof e=="function"?e():e;return t!=null?t:document.body};var yn=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:c}=O(),l=w(),[i,d]=useState(false),u=_(),{portal:p}=useContext(I),f=useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(h){}},[e]),m=useCallback(()=>{n(),o();},[n,o]);if(useEffect(()=>{if(t){ie();let h=b=>{b.key==="Escape"&&o();};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h),ce();}}},[t,o]),!t||typeof document=="undefined")return null;let y=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",{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:u.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:u.openExternalLink})]}),jsx("p",{className:l("text-muted-foreground text-sm"),children:u.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:f,type:"button",children:i?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:u.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:u.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:m,type:"button",children:[jsx(a,{size:14}),jsx("span",{children:u.openLink})]})]})]})});return createPortal(y,xe(p))};var Cn=()=>e=>{visit(e,"html",(o,n,r)=>{!r||typeof n!="number"||(r.children[n]={type:"text",value:o.value});});};var vn=[],xn={allowDangerousHtml:true},Tt=new WeakMap,po=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 u="default";return this.keyCache.set(t,u),u}let a=u=>{if(!u||u.length===0)return "";let p="";for(let f=0;f<u.length;f+=1){let m=u[f];if(f>0&&(p+=","),Array.isArray(m)){let[y,h]=m;if(typeof y=="function"){let b=Tt.get(y);b||(b=y.name,Tt.set(y,b)),p+=b;}else p+=String(y);p+=":",p+=JSON.stringify(h);}else if(typeof m=="function"){let y=Tt.get(m);y||(y=m.name,Tt.set(m,y)),p+=y;}else p+=String(m);}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();}},kn=new po,ot=e=>{let t=Ua(e),o=e.children||"",n=t.runSync(t.parse(o),o);return Xa(n,e)},Ua=e=>{let t=kn.get(e);if(t)return t;let o=Za(e);return kn.set(e,o),o},Wa=e=>e.some(t=>Array.isArray(t)?t[0]===wn:t===wn),Za=e=>{let t=e.rehypePlugins||vn,o=e.remarkPlugins||vn,n=Wa(t)?o:[...o,Cn],r=e.remarkRehypeOptions?{...xn,...e.remarkRehypeOptions}:xn;return unified().use(Fa).use(n).use(za,r).use(t)},Pn=e=>e,qa=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},Ka=(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);}},Ga=(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},Xa=(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||Pn;visit(e,(d,u,p)=>{if(d.type==="raw"&&p&&typeof u=="number")return qa(p,u,s,d.value),u;if(d.type==="element"&&(Ka(d,i),Ga(d,u,p,n,r,o)&&p&&typeof u=="number"))return a&&d.children?p.children.splice(u,1,...d.children):p.children.splice(u,1),u});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var St=createContext(null),Mt=()=>useContext(St),Dm=()=>{var t;let e=Mt();return (t=e==null?void 0:e.code)!=null?t:null},ze=()=>{var t;let e=Mt();return (t=e==null?void 0:e.mermaid)!=null?t:null},$e=()=>{var t;let e=Mt();return (t=e==null?void 0:e.plantuml)!=null?t:null};var Tn=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 Qa=/(<svg\b)/,In=/<svg\b[^>]*>/i,el=/\bviewBox=(['"])(.*?)\1/i,tl=/\swidth=(['"]).*?\1/i,ol=/\sheight=(['"]).*?\1/i,Sn=/\sstyle=(['"])(.*?)\1/i,Mn=/^<svg/i,nl=/^width\s*:/i,rl=/^height\s*:/i,sl=/^max-width\s*:/i,al=/[\s,]+/,ll=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(Qa,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),It=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},nt=e=>{let t=e.match(In);if(!t)return null;let n=t[0].match(el),r=n==null?void 0:n[2];if(!r)return null;let s=r.trim().split(al).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},Et=e=>{let t=e.match(In);if(!t)return e;try{let o=t[0],n=nt(e);if(!n)return e;let{width:r,height:s}=n,a=o.replace(tl,"").replace(ol,""),c=a.match(Sn),l=`width:${r}px;height:${s}px;max-width:none;`;if(c){let i=c[1],u=c[2].split(";").map(f=>f.trim()).filter(Boolean).filter(f=>!(nl.test(f)||rl.test(f)||sl.test(f))).join(";"),p=`${l}${u?`${u};`:""}`;a=a.replace(Sn,` style=${i}${p}${i}`);}else a=a.replace(Mn,`<svg style="${l}"`);return a=a.replace(Mn,`<svg width="${r}" height="${s}"`),e.replace(o,a)}catch(o){return e}},Rt=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a=ll(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,u=l.height*o;i.width=d,i.height=u;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,u),i.toBlob(f=>{if(!f){s(new Error("Failed to create PNG blob"));return}r(f);},"image/png");},l.onerror=()=>s(new Error("Failed to load SVG image")),l.src=c;})};var Lt=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=w(),[c,l]=useState(false),i=useRef(null),{isAnimating:d,controls:u}=useContext(I),p=O(),f=ze(),m=_(),y=ge(u,"mermaid","diagram"),h=async b=>{try{if(b==="mmd"){let S=`${y}.mmd`;J(S,e,"text/plain"),l(!1),n==null||n(b);return}if(!f){s==null||s(new Error("Mermaid plugin not available"));return}let g=f.getMermaid(r),C=e.split("").reduce((S,v)=>(S<<5)-S+v.charCodeAt(0)|0,0),P=`mermaid-${Math.abs(C)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:E}=await g.render(P,e);if(!E){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let M=It(E);if(b==="svg"){let S=`${y}.svg`;J(S,M,"image/svg+xml"),l(!1),n==null||n(b);return}if(b==="png"){let S=await Rt(M);J(`${y}.png`,S,"image/png"),n==null||n(b),l(!1);return}}catch(g){s==null||s(g);}};return useEffect(()=>{let b=g=>{let C=g.composedPath();i.current&&!C.includes(i.current)&&l(false);};return document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b);}},[]),jsxs("div",{className:a("relative"),ref:i,children:[jsx("button",{"aria-label":m.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,onClick:()=>l(!c),title:m.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":m.downloadDiagramAsSvg,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("svg"),title:m.downloadDiagramAsSvg,type:"button",children:m.mermaidFormatSvg}),jsx("button",{"aria-label":m.downloadDiagramAsPng,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("png"),title:m.downloadDiagramAsPng,type:"button",children:m.mermaidFormatPng}),jsx("button",{"aria-label":m.downloadDiagramAsMmd,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("mmd"),title:m.downloadDiagramAsMmd,type:"button",children:m.mermaidFormatMmd})]}):null]})};var Nn=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=O(),l=w(),[i,d]=useState(false),{isAnimating:u,controls:p,portal:f}=useContext(I),m=_(),y=(()=>{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})(),b=()=>{d(!i);};return useEffect(()=>{if(i){ie();let g=C=>{C.key==="Escape"&&d(false);};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),ce();}}},[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:u,onClick:b,title:m.viewFullscreen,type:"button",...s,"aria-label":m.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i?createPortal(jsxs("div",{"aria-label":m.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:b,onKeyDown:g=>{g.key==="Escape"&&b();},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(Lt,{chart:e,config:t}):null,jsx("button",{"aria-label":m.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:b,title:m.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(Ln,{chart:e,className:l("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:y})})]}),xe(f)):null]})};var Nt=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=w(),[c,l]=useState(false),i=useRef(null),{isAnimating:d,controls:u}=useContext(I),p=O(),f=$e(),m=_(),y=ge(u,"plantuml","diagram"),h=async b=>{try{if(b==="puml"){J(`${y}.puml`,e,"text/plain"),l(!1),n==null||n(b);return}if(!f){s==null||s(new Error("PlantUML plugin not available"));return}let g=f.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 P=It(C);if(b==="svg"){J(`${y}.svg`,P,"image/svg+xml"),l(!1),n==null||n(b);return}let E=await Rt(P);J(`${y}.png`,E,"image/png"),n==null||n(b),l(!1);}catch(g){s==null||s(g);}};return useEffect(()=>{let b=g=>{let C=g.composedPath();i.current&&!C.includes(i.current)&&l(false);};return document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b);}},[]),jsxs("div",{className:a("relative"),ref:i,children:[jsx("button",{"aria-label":m.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,onClick:()=>l(!c),title:m.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":m.downloadDiagramAsSvg,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("svg"),title:m.downloadDiagramAsSvg,type:"button",children:m.plantumlFormatSvg}),jsx("button",{"aria-label":m.downloadDiagramAsPng,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("png"),title:m.downloadDiagramAsPng,type:"button",children:m.plantumlFormatPng}),jsx("button",{"aria-label":m.downloadDiagramAsPuml,className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("puml"),title:m.downloadDiagramAsPuml,type:"button",children:m.plantumlFormatPuml})]}):null]})};var At=({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:u,ZoomInIcon:p,ZoomOutIcon:f}=O(),m=w(),y=_(),h=useRef(null),b=useRef(null),[g,C]=useState(l),[P,E]=useState(r),[M,S]=useState(l),[v,N]=useState({x:0,y:0}),[z,ee]=useState(false),[W,V]=useState(false),[B,$]=useState({x:0,y:0}),[j,L]=useState({x:0,y:0}),F=useCallback(T=>{S(Z=>Math.max(P,Math.min(s,Z+T))),V(true);},[P,s]),Y=useCallback(()=>{F(a);},[F,a]),ue=useCallback(()=>{F(-a);},[F,a]),te=useCallback(()=>{S(g),N({x:0,y:0}),V(false);},[g]),pe=useCallback(T=>{T.preventDefault();let Z=T.deltaY>0?-a:a;F(Z);},[F,a]),we=useCallback(T=>{if(T.button!==0||T.isPrimary===false)return;ee(true),V(true),$({x:T.clientX,y:T.clientY}),L(v);let Z=T.currentTarget;Z instanceof HTMLElement&&Z.setPointerCapture(T.pointerId);},[v]),ae=useCallback(T=>{if(!z)return;T.preventDefault();let Z=T.clientX-B.x,oe=T.clientY-B.y;N({x:j.x+Z,y:j.y+oe});},[z,B,j]),U=useCallback(T=>{ee(false);let Z=T.currentTarget;Z instanceof HTMLElement&&Z.releasePointerCapture(T.pointerId);},[]);return useEffect(()=>{E(r),i||(C(l),S(l));},[l,i,r]),useEffect(()=>{if(!(i&&o))return;let T=h.current;if(!T)return;let Z=T.clientWidth,oe=T.clientHeight;if(!(Z>0&&oe>0))return;let ve=Math.min(Z/o.width,oe/o.height,1);!(ve>0)||Number.isNaN(ve)||(C(ve),E(Math.min(r,ve)),W||(S(ve),N({x:0,y:0})));},[o,W,i,r]),useEffect(()=>{i&&V(false);},[i]),useEffect(()=>{let T=h.current;if(T)return T.addEventListener("wheel",pe,{passive:false}),()=>{T.removeEventListener("wheel",pe);}},[pe]),useEffect(()=>{let T=b.current;if(T&&z)return document.body.style.userSelect="none",T.addEventListener("pointermove",ae,{passive:false}),T.addEventListener("pointerup",U),T.addEventListener("pointercancel",U),()=>{document.body.style.userSelect="",T.removeEventListener("pointermove",ae),T.removeEventListener("pointerup",U),T.removeEventListener("pointercancel",U);}},[z,ae,U]),jsxs("div",{className:m("relative flex flex-col",d?"h-full w-full":"min-h-28 w-full",t),ref:h,style:{cursor:z?"grabbing":"grab"},children:[c?jsxs("div",{className:m("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":y.zoomIn,className:m("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:M>=s,onClick:Y,title:y.zoomIn,type:"button",children:jsx(p,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":y.zoomOut,className:m("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:M<=P,onClick:ue,title:y.zoomOut,type:"button",children:jsx(f,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":y.resetView,className:m("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:te,title:y.resetView,type:"button",children:jsx(u,{"aria-hidden":"true",size:16})})]}):null,jsx("div",{className:m("flex-1 origin-center transition-transform duration-150 ease-out",d?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:we,ref:b,role:"application",style:{transform:`translate(${v.x}px, ${v.y}px) scale(${M})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var xl=()=>{if(typeof document=="undefined")return false;let e=document.documentElement;return e.classList.contains("dark")||e.dataset.theme==="dark"||e.dataset.colorMode==="dark"},Bn=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=w(),[a,c]=useState(null),[l,i]=useState(false),[d,u]=useState(""),[p,f]=useState(null),[m,y]=useState(""),[h,b]=useState(0),{plantuml:g}=useContext(I),C=$e(),P=g==null?void 0:g.errorComponent,{shouldRender:E,containerRef:M}=ht({immediate:n});if(useEffect(()=>{if(!E)return;if(!C){c("PlantUML plugin not available. Please add the plantuml plugin to enable diagram rendering.");return}(async()=>{var N,z,ee;try{c(null),i(!0);let W=C.getPlantUml(o),V=(ee=(z=o==null?void 0:o.dark)!=null?z:(N=g==null?void 0:g.config)==null?void 0:N.dark)!=null?ee:xl(),{svg:B}=await W.render(e,{dark:V}),$=nt(B),j=n?B:Et(B);u(j),f($),y(j);}catch(W){if(!(m||d)){let V=W instanceof Error?W.message:"Failed to render PlantUML chart";c(V);}}finally{i(false);}})();},[e,o,h,E,C]),!(E||d||m))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:M});if(l&&!d&&!m)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:M,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:"Loading diagram..."})]})});if(a&&!d&&!m){let v=()=>b(N=>N+1);return P?jsx("div",{ref:M,children:jsx(P,{chart:e,error:a,retry:v})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:M,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:["PlantUML Error: ",a]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let S=d||m;return jsx("div",{className:s("size-full",t),"data-streamdown":"plantuml",ref:M,children:jsx(At,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),contentSize:p,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:S},role:"img"})})})};var _n=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:c}=O(),l=w(),[i,d]=useState(false),{isAnimating:u,controls:p,portal:f}=useContext(I),m=_(),y=(()=>{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})(),b=()=>{d(!i);};return useEffect(()=>{if(i){ie();let g=C=>{C.key==="Escape"&&d(false);};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),ce();}}},[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:u,onClick:b,title:m.viewFullscreen,type:"button",...s,"aria-label":m.viewFullscreen,children:jsx(a,{"aria-hidden":"true",size:14})}),i?createPortal(jsxs("div",{"aria-label":m.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:b,onKeyDown:g=>{g.key==="Escape"&&b();},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(Nt,{chart:e,config:t}):null,jsx("button",{"aria-label":m.exitFullscreen,className:l("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:b,title:m.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(Bn,{chart:e,className:l("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:y})})]}),xe(f)):null]})};var bo=e=>e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(bo).join(""):isValidElement(e)?bo(e.props.children):"",Vn=(e,t,o)=>o!=null?o:(t?toText(t):bo(e)).replace(/\s+/g," ").trim()||void 0;function ho(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(ho).join("")}var Ue=e=>{let t=[],o=[],n=e.querySelectorAll("thead th");for(let s of n)t.push(ho(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(ho(l).trim());o.push(a);}return {headers:t,rows:o}},lt=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 u of i)if(u===o||u==='"'||u===`
7
- `||u==="\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
- `)},yo=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
- `)},Ht=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("")},We=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=>Ht(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?Ht(c[i]):"";n[r]=`| ${l.join(" | ")} |`,r+=1;}else {let l=c.map(i=>Ht(i));n[r]=`| ${l.join(" | ")} |`,r+=1;}return n.join(`
14
- `)};var ct=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=w(),[a,c]=useState(false),[l,i]=useState(false),d=useRef(null),u=useRef(0),{isAnimating:p,controls:f}=useContext(I),m=_(),y=lt(f),h=async C=>{var P,E;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=(E=d.current)==null?void 0:E.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),S=M==null?void 0:M.querySelector("table");if(!S){n==null||n(new Error("Table not found"));return}let v=Ue(S),N="";C==="csv"?N=_e(v,y):C==="tsv"?N=yo(v):N=We(v);let z=new ClipboardItem({"text/plain":new Blob([N],{type:"text/plain"}),"text/html":new Blob([S.outerHTML],{type:"text/html"})});await navigator.clipboard.write([z]),i(!0),c(!1),o==null||o(C),u.current=window.setTimeout(()=>i(!1),r);}catch(M){n==null||n(M);}};useEffect(()=>{let C=P=>{let E=P.composedPath();d.current&&!E.includes(d.current)&&c(false);};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C),window.clearTimeout(u.current);}},[]);let b=O(),g=l?b.CheckIcon:b.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:m.copyTable,type:"button",children:e!=null?e:jsx(g,{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:()=>h("md"),title:m.copyTableAsMarkdown,type:"button",children:m.tableFormatMarkdown}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("csv"),title:m.copyTableAsCsv,type:"button",children:m.tableFormatCsv}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>h("tsv"),title:m.copyTableAsTsv,type:"button",children:m.tableFormatTsv})]}):null]})};var Dl=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:s})=>{let a=w(),{isAnimating:c,controls:l}=useContext(I),i=_(),d=O(),u=lt(l),p=f=>{try{let y=f.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),h=y==null?void 0:y.querySelector("table");if(!h){n==null||n(new Error("Table not found"));return}let b=Ue(h),g="",C="",P="";switch(r){case "csv":g=_e(b,u),C="text/csv",P="csv";break;case "markdown":g=We(b),C="text/markdown",P="md";break;default:g=_e(b,u),C="text/csv",P="csv";}J(`${s||ge(l,"table","table")}.${P}`,g,C),o==null||o();}catch(m){n==null||n(m);}};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.DownloadIcon,{size:14})})},dt=({children:e,className:t,onDownload:o,onError:n})=>{let r=w(),[s,a]=useState(false),c=useRef(null),{isAnimating:l,controls:i}=useContext(I),d=_(),u=O(),p=lt(i),f=m=>{var y;try{let h=(y=c.current)==null?void 0:y.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),b=h==null?void 0:h.querySelector("table");if(!b){n==null||n(new Error("Table not found"));return}let g=Ue(b),C=m==="csv"?_e(g,p):We(g),P=m==="csv"?"csv":"md",E=`${ge(i,"table","table")}.${P}`;J(E,C,m==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(m);}catch(h){n==null||n(h);}};return useEffect(()=>{let m=y=>{let h=y.composedPath();c.current&&!h.includes(c.current)&&a(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),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.downloadTable,type:"button",children:e!=null?e:jsx(u.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:()=>f("csv"),title:d.downloadTableAsCsv,type:"button",children:d.tableFormatCsv}),jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("markdown"),title:d.downloadTableAsMarkdown,type:"button",children:d.tableFormatMarkdown})]}):null]})};var Wn=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=O(),a=w(),[c,l]=useState(false),{isAnimating:i,portal:d}=useContext(I),u=_(),p=()=>{l(true);},f=()=>{l(false);};return useEffect(()=>{if(c){ie();let m=y=>{y.key==="Escape"&&l(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),ce();}}},[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:u.viewFullscreen,type:"button",children:jsx(r,{size:14})}),c?createPortal(jsx("div",{"aria-label":u.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:f,onKeyDown:m=>{m.key==="Escape"&&f();},role:"dialog",children:jsxs("div",{className:a("flex h-full flex-col"),onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),role:"presentation",children:[jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[o?jsx(ct,{}):null,n?jsx(dt,{}):null,jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:f,title:u.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})})]})}),xe(d)):null]})};var qn=({children:e,className:t,maxHeight:o,showControls:n,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...c})=>{let l=w(),{isAnimating:i,scrollable:d}=useContext(I),u=d!=null?d:Ge,p=Ct(o),f=vt({content:e,enabled:!!p,isAnimating:i}),m=n&&r,y=n&&s,h=n&&a,b=m||y||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:[b?jsxs("div",{className:l("flex items-center justify-end gap-1"),children:[m?jsx(ct,{}):null,y?jsx(dt,{}):null,h?jsx(Wn,{showCopy:m,showDownload:y,children:e}):null]}):null,jsx(u,{className:l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),scrollRef:f,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 Ul=/startLine=(\d+)/,Wl=/\bnoLineNumbers\b/,Zl=lazy(()=>import('./mermaid-KORKP2SN.js').then(e=>({default:e.Mermaid}))),ql=lazy(()=>import('./plantuml-K7PXKDNA.js').then(e=>({default:e.PlantUml}))),Kl=/language-([^\s]+)/,me=e=>e.props,Gl="node";function H(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!==Gl&&!Object.is(n[s],r[s]))return false;return true}function Xl(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 Jl(e){if(typeof e=="string")return e;if(isValidElement(e)){let t=me(e).children;if(typeof t=="string")return t}}var Yl=(e,t)=>Array.isArray(t)?t.includes(e):t===e,Ql=(e,t)=>!!(t&&Yl(e,t.language)),_t=(e,t)=>typeof e=="boolean"?e:e[t]!==false,xo=(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},Kn=(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},Bt=(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},Ot=(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},ut=createContext({depth:0,ulDepth:0,isUnordered:false}),ei={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},ko=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{depth:s,ulDepth:a}=useContext(ut),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(ut.Provider,{value:c,children:e})})},(e,t)=>H(e,t));ko.displayName="MarkdownOl";var Qn=memo(({children:e,className:t,node:o,...n})=>{var y;let r=w(),{depth:s,ulDepth:a,isUnordered:c}=useContext(ut),{listStyle:l}=useContext(I),i=ei[l],d=c&&a>0?i[(a-1)%i.length]:void 0,u=Array.isArray(e)?e.filter(h=>h!==`
15
- `&&h!==""):[e],p=u[0],f=isValidElement(p)?(y=me(p).node)==null?void 0:y.tagName:void 0,m=u.length===1&&isValidElement(p)&&(p.type==="p"||f==="p")?me(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:m}):jsx("li",{className:r("py-1 [&>p]:inline",d,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...n,children:m})},(e,t)=>H(e,t));Qn.displayName="MarkdownLi";var er=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{depth:s,ulDepth:a}=useContext(ut),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(ut.Provider,{value:c,children:e})})},(e,t)=>H(e,t));er.displayName="MarkdownUl";var tr=memo(({className:e,node:t,...o})=>{let n=w();return jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>H(e,t));tr.displayName="MarkdownHr";var or=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>H(e,t));or.displayName="MarkdownStrong";var ti=({children:e,className:t,href:o,node:n,...r})=>{let s=w(),{linkSafety:a}=useContext(I),[c,l]=useState(false),i=o==="streamdown:incomplete-link",d=useCallback(async m=>{if(!(!(a!=null&&a.enabled&&o)||i)){if(m.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}l(true);}},[a,o,i]),u=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),p=useCallback(()=>{l(false);},[]),f={url:o!=null?o:"",isOpen:c,onClose:p,onConfirm:u};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(f):jsx(yn,{...f})]}):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})},nr=memo(ti,(e,t)=>H(e,t));nr.displayName="MarkdownA";var rr=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>H(e,t));rr.displayName="MarkdownH1";var sr=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>H(e,t));sr.displayName="MarkdownH2";var ar=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>H(e,t));ar.displayName="MarkdownH3";var lr=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>H(e,t));lr.displayName="MarkdownH4";var ir=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>H(e,t));ir.displayName="MarkdownH5";var cr=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>H(e,t));cr.displayName="MarkdownH6";var dr=memo(({children:e,className:t,node:o,...n})=>{let{controls:r,tableMaxHeight:s}=useContext(I),a=_t(r,"table"),c=xo(r,"copy"),l=xo(r,"download"),i=xo(r,"fullscreen");return jsx(qn,{className:t,maxHeight:s,showControls:a,showCopy:c,showDownload:l,showFullscreen:i,...n,children:e})},(e,t)=>H(e,t));dr.displayName="MarkdownTable";var mr=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>H(e,t));mr.displayName="MarkdownThead";var ur=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>H(e,t));ur.displayName="MarkdownTbody";var pr=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>H(e,t));pr.displayName="MarkdownTr";var fr=memo(({children:e,className:t,node:o,title:n,...r})=>{let s=w(),a=Vn(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)=>H(e,t));fr.displayName="MarkdownTh";var gr=memo(({children:e,className:t,node:o,...n})=>{let r=w();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)=>H(e,t));gr.displayName="MarkdownTd";var br=memo(({children:e,className:t,node:o,...n})=>{let r=w();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)=>H(e,t));br.displayName="MarkdownBlockquote";var hr=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>H(e,t));hr.displayName="MarkdownSup";var oi=()=>({}),ni=e=>{try{let t=atob(e),o=Uint8Array.from(t,n=>n.charCodeAt(0));return new TextDecoder().decode(o)}catch(t){return ""}},yr=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{calloutIcon:s,calloutStyle:a,components:c,remarkPlugins:l,rehypePlugins:i}=useContext(I),d=n,u=d["data-callout-title"],p=d["data-callout-color"],f=d["data-callout-icon"],m=d["data-callout-body"],y=m?ni(m):"",h=(a!=null?a:oi)(p),b=f&&s?s(f):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:[u!==void 0?jsxs("p",{className:"mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",children:[b,u]}):null,y.trim().length>0?jsx(ot,{components:c,rehypePlugins:i,remarkPlugins:l,children:y}):null]})},(e,t)=>H(e,t));yr.displayName="MarkdownCallout";var Gn={"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"},Cr=memo(({children:e,className:t,node:o,...n})=>{let r=w(),s=t==null?void 0:t.includes("markdown-alert");if(t==null?void 0:t.includes("sdm-callout"))return jsx(yr,{className:t,node:o,...n,children:e});if(s){let c=Object.keys(Gn).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?Gn[c]:null,t),...n,children:e})}return jsx("div",{className:r(t),...n,children:e})},(e,t)=>H(e,t));Cr.displayName="MarkdownDiv";var wr=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>H(e,t));wr.displayName="MarkdownSub";var vr=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=l=>{if(!isValidElement(l))return false;let i=me(l).children,d=Array.isArray(i)?i:[i],u=false,p=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(u=true);else if(isValidElement(f))if(me(f)["data-footnote-backref"]!==void 0)p=true;else {let m=me(f).children,y=Array.isArray(m)?m:[m];for(let h of y){if(typeof h=="string"&&h.trim()!==""){u=true;break}if(isValidElement(h)&&me(h)["data-footnote-backref"]===void 0){u=true;break}}}}return p&&!u},a=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===ko){let i=me(l).children,u=(Array.isArray(i)?i:[i]).filter(p=>!s(p));return u.length===0?null:{...l,props:{...me(l),children:u}}}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)=>H(e,t));vr.displayName="MarkdownSection";var ri=({node:e,className:t,children:o,...n})=>{var V,B,$;let r=w(),s=!("data-block"in n),{mermaid:a,plantuml:c,controls:l,lineNumbers:i}=useContext(I),d=ze(),u=$e(),p=Qt(),f=t==null?void 0:t.match(Kl),m=(V=f==null?void 0:f.at(1))!=null?V:"",y=Tn(m);if(s)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let h=(B=e==null?void 0:e.properties)==null?void 0:B.metastring,b=typeof h=="string"?h:void 0,g=b==null?void 0:b.match(Ul),C=g?Number.parseInt(g[1],10):void 0,P=C!==void 0&&C>=1?C:void 0,M=!(b?Wl.test(b):false)&&i!==false,S=($=Jl(o))!=null?$:"";if(y){let j=y.component;return jsx(Suspense,{fallback:jsx(Qe,{}),children:jsx(j,{code:S,isIncomplete:p,language:m,meta:b})})}if(m==="mermaid"&&d){let j=_t(l,"mermaid"),L=Bt(l,"download"),F=Bt(l,"copy"),Y=Bt(l,"fullscreen"),ue=Bt(l,"panZoom"),te=j&&(L||F||Y);return jsx(Suspense,{fallback:jsx(Qe,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":p||void 0,"data-streamdown":"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"})}),te?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:[L?jsx(Lt,{chart:S,config:a==null?void 0:a.config}):null,F?jsx(Ye,{code:S}):null,Y?jsx(Nn,{chart:S,config:a==null?void 0:a.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(Zl,{chart:S,config:a==null?void 0:a.config,showControls:ue})})]})})}if(Ql(m,u)){let j=_t(l,"plantuml"),L=Ot(l,"download"),F=Ot(l,"copy"),Y=Ot(l,"fullscreen"),ue=Ot(l,"panZoom"),te=j&&(L||F||Y);return jsx(Suspense,{fallback:jsx(Qe,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":p||void 0,"data-streamdown":"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:m})}),te?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:[L?jsx(Nt,{chart:S,config:c==null?void 0:c.config}):null,F?jsx(Ye,{code:S}):null,Y?jsx(_n,{chart:S,config:c==null?void 0:c.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(ql,{chart:S,config:c==null?void 0:c.config,showControls:ue})})]})})}let v=_t(l,"code"),N=Kn(l,"download"),z=Kn(l,"copy"),{"data-block":ee,...W}=n;return jsx(ro,{className:t,code:S,isIncomplete:p,language:m,lineNumbers:M,startLine:P,...W,children:v?jsxs(Fragment,{children:[N?jsx(lo,{code:S,language:m}):null,z?jsx(Ye,{}):null]}):null})},xr=memo(ri,(e,t)=>H(e,t)&&Xl(e.node,t.node));xr.displayName="MarkdownCode";var kr=memo(gn,(e,t)=>H(e,t));kr.displayName="MarkdownImg";var Xn={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},Pr=memo(({children:e,className:t,node:o,...n})=>{let r=w(),s=_(),a=n["data-alert-type"],c=a&&a in Xn?Xn[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)=>H(e,t));Pr.displayName="MarkdownAlertTitle";var Tr=memo(({children:e,className:t,node:o,...n})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(Pr,{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=me(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)=>H(e,t));Tr.displayName="MarkdownParagraph";var Sr={ol:ko,li:Qn,ul:er,hr:tr,strong:or,a:nr,h1:rr,h2:sr,h3:ar,h4:lr,h5:ir,h6:cr,table:dr,thead:mr,tbody:ur,tr:pr,th:fr,td:gr,blockquote:br,code:xr,div:Cr,img:kr,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:hr,sub:wr,p:Tr,section:vr};var si=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,ai=/\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(si.test(s)){o!=null||(o="rtl"),r+=1;continue}ai.test(s)&&(o!=null||(o="ltr"),n+=1);}return r>n?"rtl":n>r?"ltr":o!=null?o:"ltr"}var li=/^[ \t]{0,3}(`{3,}|~{3,})/;var Mr=e=>{let t=e.split(`
16
- `),o=null,n=0;for(let r of t){let s=li.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 ci=/\[\^[\w-]{1,200}\](?!:)/,di=/\[\^[\w-]{1,200}\]:/,mi=/<([A-Za-z][\w:-]*)[\s>/]/,ui=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ir=new Map,Er=new Map,Nr=e=>{let t=e.toLowerCase(),o=Ir.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Ir.set(t,n),n},pi=e=>{let t=e.toLowerCase(),o=Er.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return Er.set(t,n),n},Rr=(e,t)=>{if(ui.has(t.toLowerCase()))return 0;let o=e.match(Nr(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},Lr=(e,t)=>{let o=e.match(pi(t));return o?o.length:0},fi=(e,t)=>{let o=e.match(Nr(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},Ft=e=>{let t=ci.test(e),o=di.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),u=Rr(l,d),p=Lr(l,d);for(let f=0;f<u;f+=1)s.push(d);for(let f=0;f<p;f+=1)s.length>0&&s.at(-1)===d&&s.pop();continue}if(c.type==="html"&&c.block){let d=l.match(mi);if(d){let u=d[1],p=Rr(l,u),f=Lr(l,u);p>f&&!fi(l,u)&&s.push(u);}}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},Po=(e,t,o=Ft)=>{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 bi=/^\n*/,hi=/\n*$/,To=/\n\n/g,yi=(e,t,o)=>{if(!t.includes(`
17
- `))return e+t+o;let r=t.replace(To,`
18
- <!---->
19
- `).replace(bi,`
20
-
21
- `).replace(hi,`
22
-
23
- `);return `${e}${r}${o}
24
-
25
- `},Ci=(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 f=i.slice(2).replace(To,`
28
- <!---->
29
- `);n+=`${a}
30
-
31
- ${f}`,r=e.length;break}if(!i.startsWith(`
32
- `)){n+=a,r=l,s=o.exec(e);continue}let u=i.slice(1);if(u.trim().length===0){n+=a,r=l,s=o.exec(e);continue}let p=u.replace(To,`
33
- <!---->
34
- `);n+=`${a}
35
-
36
- ${p}`,r=e.length;break}return r===0?e:n+e.slice(r)},Ar=(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=Ci(o,n);}return o};var wi=/([\\`*_~[\]|])/g,vi=e=>e.replace(wi,"\\$1"),Dr=(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=vi(c).replace(/\n\n/g,"&#10;&#10;");return a+i+l});}return o};var ki=new Set(["blockquote","dd","dt","figcaption","h1","h2","h3","h4","h5","h6","li","p","td","th"]),Hr=new Set(["code","kbd","pre","samp","var"]);function Br(e){return e.children.map(t=>t.type==="text"?t.value:t.type==="element"&&!Hr.has(t.tagName)?Br(t):"").join("")}function Or(){return e=>{visit(e,"element",t=>{if(Hr.has(t.tagName)){(t.properties)!=null||(t.properties={}),t.properties.dir="ltr";return}ki.has(t.tagName)&&((t.properties)!=null||(t.properties={}),typeof t.properties.dir!="string"&&(t.properties.dir=pt(Br(t))));});}}var _r=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 Vr=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(Vr).join(""):"",Fr=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=Vr(n);n.children=r?[{type:"text",value:r}]:[];}});};var Li=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),Ni=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),Ai=e=>{let t=unified().use(Fa).use(za,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},zr=(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)||!Li(s))return;let c=Ni(s);if(!c.includes(`
37
- `))return;let l=Ai(c);s.children=l;});};var $r=()=>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 jr=/^>>>[ \t]?(.*)$/,Hi=/^<<<\s*$/,Bi=/^>+\s*$/,Oi=/^<+\s*$/,_i=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,Vi=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,Fi=/^[a-z0-9-]+$/,zi=e=>{let t=_i.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&&Fi.test(a)?a:void 0,title:r!==void 0&&r.length>0?r:void 0,color:s&&Vi.test(s)?s:void 0}},So=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),$i=e=>{let t=new TextEncoder().encode(e),o="";for(let n of t)o+=String.fromCharCode(n);return btoa(o)},ji=(e,t)=>{var i;let o=jr.exec(e[t]),n=(i=o==null?void 0:o[1])!=null?i:"",r=zi(n),s=[],a=t+1;for(;a<e.length;a+=1){let d=e[a];if(Hi.test(d)){a+=1;break}if(Bi.test(d)||Oi.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="${So(r.title)}"`:"",r.color!==void 0?`data-callout-color="${So(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${So(r.icon)}"`:"",`data-callout-body="${$i(c)}"`].filter(Boolean).join(" ")}></div>`,next:a}},Ur=e=>{if(!e.includes(">>>"))return e;let t=e.split(`
39
- `),o=[],n=0,r=false;for(;n<t.length;)if(jr.test(t[n])){let s=ji(t,n);o.push(s.replacement),n=s.next,r=true;}else o.push(t[n]),n+=1;return r?o.join(`
40
- `):e},Wr=()=>()=>{};var Zi={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"}]}},qi=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,Zr=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let o="";for(let n of t)o+=Zr(n);return o},Ki=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}}}},Gi=e=>{var u,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=Zr(o).trimStart(),r=n.match(qi);if(!r)return;let s=Zi[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=[Ki(s)],i=[];a.length>0&&i.push({type:"text",value:a});let d=c;return ((u=d[0])==null?void 0:u.type)==="break"&&(d=d.slice(1)),i.push(...d),i.length>0&&i.some(f=>f.type!=="text"||f.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},qr=()=>e=>{visit(e,"blockquote",Gi);};var nc=/^[ \t]*<[\w!/?-]/,rc=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,sc=e=>typeof e!="string"||e.length===0||!nc.test(e)?e:e.replace(rc,"$1"),Jr,Yr,Qr,es,ts,os,ns,rs,ss,as,ls,zt={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(Yr=(Jr=defaultSchema.protocols)==null?void 0:Jr.href)!=null?Yr:[],"tel","streamdown"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(es=(Qr=defaultSchema.attributes)==null?void 0:Qr.div)!=null?es:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(os=(ts=defaultSchema.attributes)==null?void 0:ts.p)!=null?os:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(rs=(ns=defaultSchema.attributes)==null?void 0:ns.svg)!=null?rs:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(as=(ss=defaultSchema.attributes)==null?void 0:ss.path)!=null?as:[],"d","fillRule"]},tagNames:[...(ls=defaultSchema.tagNames)!=null?ls:[],"svg","path"]},Mo={raw:wn,sanitize:[ds,zt],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},ac={gfm:[tc,{}],githubAlerts:qr,containerAlerts:Wr,codeMeta:$r},Gr=Object.values(Mo),lc=Object.values(ac),Xr=new WeakMap;function ic(e){var r;let t=Xr.get(e);if(t)return t;let o={...zt,tagNames:[...(r=zt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...zt.attributes,...e}},n=[Mo.raw,[ds,o],Mo.harden];return Xr.set(e,n),n}var cc={block:" \u258B",circle:" \u25CF"},dc=["github-light","github-dark"],mc={enabled:true},ms=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?sc(e):e,i=jsx(ot,{...c,children:l});return jsx(Yt.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)});ms.displayName="Block";var uc=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=Gr,remarkPlugins:c=lc,className:l,shikiTheme:i,mermaid:d,plantuml:u,codeBlockMaxHeight:p=400,controls:f=true,isAnimating:m=false,scrollable:y,tableMaxHeight:h=300,animated:b,BlockComponent:g=ms,parseMarkdownIntoBlocksFn:C=Ft,caret:P,listStyle:E="hierarchical",calloutIcon:M,calloutStyle:S,plugins:v,remend:N,linkSafety:z=mc,portal:ee,lineNumbers:W=true,allowedTags:V,literalTagContent:B,dataOnlyTags:$,translations:j,icons:L,prefix:F,onAnimationStart:Y,onAnimationEnd:ue,...te})=>{let pe=useId(),we=useMemo(()=>Uo(F),[F]),ae=useRef(null),U=useRef(Y),T=useRef(ue);U.current=Y,T.current=ue,useEffect(()=>{var R,G,q;if(t==="static")return;let x=ae.current;if(ae.current=m,x===null){m&&((R=U.current)==null||R.call(U));return}m&&!x?(G=U.current)==null||G.call(U):!m&&x&&((q=T.current)==null||q.call(T));},[m,t]);let Z=useMemo(()=>V?Object.keys(V):[],[V]),oe=useMemo(()=>{if(!($!=null&&$.length))return Z;let x=new Set($.map(R=>R.toLowerCase()));return Z.filter(R=>!x.has(R.toLowerCase()))},[Z,$]),ve=useRef(null),jt=useMemo(()=>{if(typeof e!="string")return "";let x=e;return B&&B.length>0&&(x=Dr(x,B)),oe.length>0&&(x=Ar(x,oe)),x=Ur(x),x},[e,oe,B]),le=useMemo(()=>{let x=t==="streaming"?ve.current:null,R=Po(jt,x,C);if(ve.current=t==="streaming"?R:null,!(t==="streaming"&&n)||R.blocks.length===0)return R.blocks;let G=R.blocks.length-1,q=R.blocks[G],fe=oc(q,N);if(fe===q)return R.blocks;let Le=R.blocks.slice();return Le[G]=fe,Le},[jt,C,t,n,N]),Ve=useMemo(()=>b===true?"true":b?JSON.stringify(b):"",[b]),ne=useRef(null),Ke=useRef([]),Me=useRef([]),Eo=useRef(null),Ut=useRef("");if(Ve){if(Ut.current!==Ve){Ut.current=Ve;let x=Ve!=="true"?b.maxBacklogMs:void 0;ne.current=Gt({maxBacklogMs:x}),Ke.current=[],Me.current=[];}else ne.current||(ne.current=Gt());m&&ne.current&&ne.current.beginPass(ne.current.now());}else ne.current=null,Ke.current=[],Me.current=[],Ut.current="";useLayoutEffect(()=>{var x;m&&((x=ne.current)==null||x.commitPass());});let Ie=useDeferredValue(le),Ee=useMemo(()=>{if(t!=="streaming"||ne.current||Ie===le||Ie.length===0)return le;let x=Ie.length,R=le.length;if(R===0)return Ie;if(x!==R)return le;for(let q=0;q<x-1;q+=1)if(Ie[q]!==le[q])return le;let G=Ie.slice();return G[x-1]=le[R-1],G},[le,Ie,t]),Wt=useMemo(()=>o==="auto"?Ee.map(pt):void 0,[Ee,o]),fs=useMemo(()=>Ee.map((x,R)=>`${pe}-${R}`),[Ee.length,pe]),gs=useMemo(()=>j?JSON.stringify(j):"",[j]),Ro=useMemo(()=>({...kt,...j}),[gs]),gt=useMemo(()=>{let{inlineCode:x,...R}=s!=null?s:{},G={...Sr,...R};if(x){let q=G.code;G.code=fe=>"data-block"in fe?q?createElement(q,fe):null:createElement(x,fe);}return G},[s]),bt=useMemo(()=>{let x=[];return v!=null&&v.cjk&&(x=[...x,...v.cjk.remarkPluginsBefore]),x=[...x,...c],v!=null&&v.cjk&&(x=[...x,...v.cjk.remarkPluginsAfter]),v!=null&&v.math&&(x=[...x,v.math.remarkPlugin]),x},[c,v==null?void 0:v.math,v==null?void 0:v.cjk]),Re=useMemo(()=>{let x=a;return V&&Object.keys(V).length>0&&a===Gr&&(x=ic(V)),oe.length>0&&(x=[...x,[zr,oe,B!=null?B:[]]]),B&&B.length>0&&(x=[...x,[Fr,B]]),$&&$.length>0&&(x=[...x,[_r,$]]),v!=null&&v.math&&(x=[...x,v.math.rehypePlugin]),o==="auto"&&t==="static"&&(x=[...x,Or]),x},[a,v==null?void 0:v.math,V,oe,B,$,o,t]),Lo=useMemo(()=>{var x,R;return {calloutIcon:M,calloutStyle:S,codeBlockMaxHeight:p,shikiTheme:(R=i!=null?i:(x=v==null?void 0:v.code)==null?void 0:x.getThemes())!=null?R:dc,controls:f,isAnimating:m,lineNumbers:W,listStyle:E,mode:t,mermaid:d,plantuml:u,linkSafety:z,portal:ee,scrollable:y,tableMaxHeight:h,components:gt,remarkPlugins:bt,rehypePlugins:Re}},[M,S,p,i,f,m,W,E,t,d,u,z,ee,y,v==null?void 0:v.code,h,gt,bt,Re]),bs=useMemo(()=>P&&m?{"--streamdown-caret":`"${cc[P]}"`}:void 0,[P,m]),hs=x=>{let R=null;if(ne.current&&m){if(!Ke.current[x]){let q=Ve&&Ve!=="true"?b:{},{maxBacklogMs:fe,...Le}=q;Ke.current[x]=yt({...Le,timeline:ne.current});}R=Ke.current[x];}Eo.current!==Re&&(Me.current=[],Eo.current=Re),R&&!Me.current[x]&&(Me.current[x]=[...Re,R.rehypePlugin]);let G=R&&Me.current[x]?Me.current[x]:Re;return {blockAnimatePlugin:R,blockRehypePlugins:G}};return t==="static"?jsx(Pt.Provider,{value:Ro,children:jsx(St.Provider,{value:v!=null?v:null,children:jsx(I.Provider,{value:Lo,children:jsx(so,{icons:L,children:jsx(wt.Provider,{value:we,children:jsx("div",{className:we("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",l),dir:o==="auto"?void 0:o,children:jsx(ot,{components:gt,rehypePlugins:Re,remarkPlugins:bt,...te,children:jt})})})})})})}):jsx(Pt.Provider,{value:Ro,children:jsx(St.Provider,{value:v!=null?v:null,children:jsx(I.Provider,{value:Lo,children:jsx(so,{icons:L,children:jsx(wt.Provider,{value:we,children:jsxs("div",{className:we("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",P?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,l),"data-streamdown":"container",style:bs,children:[Ee.length===0&&P&&m&&jsx("span",{}),Ee.map((x,R)=>{var No;let G=R===Ee.length-1,q=m&&G&&Mr(x),{blockAnimatePlugin:fe,blockRehypePlugins:Le}=hs(R);return jsx(g,{animatePlugin:fe,components:gt,content:x,dir:(No=Wt==null?void 0:Wt[R])!=null?No:o!=="auto"?o:void 0,index:R,isIncomplete:q,rehypePlugins:Le,remarkPlugins:bt,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...te},fs[R])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.calloutIcon===t.calloutIcon&&e.calloutStyle===t.calloutStyle&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&e.dataOnlyTags===t.dataOnlyTags&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);uc.displayName="Streamdown";var us=/[(){}[\]]/,fc=/[\s;]/,gc=/^[\w-]+$/,bc=/:::[\w-]+\s*$/,hc=/^[/\\]/,yc=/[/\\]$/,Cc=/("[^"]*")/,wc=[["((","))"],["))","(("],["{{","}}"],["[","]"],["(",")"],[")","("]],ft=e=>`"${e.replace(/"/g,"#quot;")}"`,vc=e=>e.length>=2&&e.startsWith('"')&&e.endsWith('"'),xc=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(fc,1)[0];return l==="mindmap"?"mindmap":l==="flowchart"||l==="graph"?"flowchart":null}o+=1;}return null},kc=e=>{for(let[t,o]of wc){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},Pc=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=kc(n);if(r)return !vc(r.inner)&&(us.test(r.inner)||r.inner.includes('"'))?`${o}${r.id}${r.open}${ft(r.inner)}${r.close}`:e;if(us.test(n)){let s=n.replace(bc,"").trimEnd();return `${o}[${ft(s)}]`}return e},Tc=e=>{let t=e.split(`
42
- `),o=false;return t.map(n=>o?Pc(n):(n.trim()&&(o=true),n)).join(`
43
- `)},Sc=e=>e.startsWith("(")&&e.endsWith(")")||hc.test(e)||yc.test(e),Io=(e,t)=>e.split(Cc).map((o,n)=>n%2===0?t(o):o).join(""),Mc=e=>{if(e.trim().startsWith("%%"))return e;let t=Io(e,o=>o.replace(/\[([^[\]"]*[(){}][^[\]"]*)\]/g,(n,r)=>Sc(r)?n:`[${ft(r)}]`));return t=Io(t,o=>o.replace(/\{([^{}"]*[()[\]][^{}"]*)\}/g,(n,r)=>`{${ft(r)}}`)),t=Io(t,o=>o.replace(/\|([^|"]*[(){}[\]][^|"]*)\|/g,(n,r)=>`|${ft(r)}|`)),t},Ic=e=>e.split(`
44
- `).map(Mc).join(`
45
- `),ps=e=>{let t=xc(e);if(!t)return null;let o=t==="mindmap"?Tc(e):Ic(e);return o===e?null:o};var Lc=async(e,t,o)=>{try{return await e.render(t,o)}catch(n){let r=ps(o);if(!r)throw n;try{return await e.render(`${t}-autofix`,r)}catch(s){throw n}}},Ln=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=w(),[a,c]=useState(null),[l,i]=useState(false),[d,u]=useState(""),[p,f]=useState(null),[m,y]=useState(""),[h,b]=useState(0),{mermaid:g}=useContext(I),C=ze(),P=g==null?void 0:g.errorComponent,{shouldRender:E,containerRef:M}=ht({immediate:n});if(useEffect(()=>{if(!E)return;if(!C){c("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{c(null),i(!0);let N=C.getMermaid(o),z=e.split("").reduce(($,j)=>($<<5)-$+j.charCodeAt(0)|0,0),ee=`mermaid-${Math.abs(z)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:W}=await Lc(N,ee,e),V=nt(W),B=n?W:Et(W);u(B),f(V),y(B);}catch(N){if(!(m||d)){let z=N instanceof Error?N.message:"Failed to render Mermaid chart";c(z);}}finally{i(false);}})();},[e,o,h,E,C]),!(E||d||m))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:M});if(l&&!d&&!m)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:M,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:"Loading diagram..."})]})});if(a&&!d&&!m){let v=()=>b(N=>N+1);return P?jsx("div",{ref:M,children:jsx(P,{chart:e,error:a,retry:v})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:M,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",a]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let S=d||m;return jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:M,children:jsx(At,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),contentSize:p,fitKey:e,fullscreen:n,isAutoFit:true,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:s("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:S},role:"img"})})})};export{Ft as A,Po as B,sc as C,Mo as D,ac as E,ms as F,uc as G,Ts as a,yt as b,Qt as c,Ge as d,Go as e,to as f,no as g,Dm as h,ro as i,kt as j,Ye as k,lo as l,Qe as m,I as n,Pn as o,Ln as p,Bn as q,Ue as r,_e as s,yo as t,Ht as u,We as v,ct as w,Dl as x,dt as y,pt as z};
@@ -1,2 +0,0 @@
1
- "use client";
2
- import {n,h,e}from'./chunk-BD73NLRI.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};
@@ -1,2 +0,0 @@
1
- "use client";
2
- export{p as Mermaid}from'./chunk-BD73NLRI.js';
@@ -1,2 +0,0 @@
1
- "use client";
2
- export{q as PlantUml}from'./chunk-BD73NLRI.js';