@lofcz/streamdown 2.8.0 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import {createContext,memo,useContext,useRef,useEffect,useMemo,lazy,isValidElement,useId,useDeferredValue,cloneElement,createElement,useState,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import Hn from'rehype-raw';import dr,{defaultSchema}from'rehype-sanitize';import ui from'remark-gfm';import pi from'remend';import {visitParents,SKIP}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 Ta from'remark-parse';import Ma from'remark-rehype';import {unified}from'unified';import {visit,SKIP as SKIP$1}from'unist-util-visit';import {Lexer}from'marked';var kr=300,xr="300px",vr=500;function Qt(e={}){let{immediate:t=false,debounceDelay:o=kr,rootMargin:n=xr,idleTimeout:r=vr}=e,[s,a]=useState(false),l=useRef(null),i=useRef(null),d=useRef(null),c=useMemo(()=>m=>{let g=Date.now();return window.setTimeout(()=>{m({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-g))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(m,g)=>window.requestIdleCallback(m,g):c,[c]),u=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?m=>window.cancelIdleCallback(m):m=>{clearTimeout(m);},[]);return useEffect(()=>{if(t){a(true);return}let m=l.current;if(!m)return;i.current&&(clearTimeout(i.current),i.current=null),d.current&&(u(d.current),d.current=null);let g=()=>{i.current&&(clearTimeout(i.current),i.current=null),d.current&&(u(d.current),d.current=null);},f=x=>{d.current=p(b=>{b.timeRemaining()>0||b.didTimeout?(a(true),x.disconnect()):d.current=p(()=>{a(true),x.disconnect();},{timeout:r/2});},{timeout:r});},y=x=>{g(),i.current=window.setTimeout(()=>{var I,j;let b=x.takeRecords();(b.length===0||(j=(I=b.at(-1))==null?void 0:I.isIntersecting)!=null&&j)&&f(x);},o);},h=(x,b)=>{x.isIntersecting?y(b):g();},k=new IntersectionObserver(x=>{for(let b of x)h(b,k);},{rootMargin:n,threshold:0});return k.observe(m),()=>{i.current&&clearTimeout(i.current),d.current&&u(d.current),k.disconnect();}},[t,o,n,r,u,p]),{shouldRender:s,containerRef:l}}function ht(){return {current:0}}var to=/\s/,eo=/^\s+$/,Mr=new Set(["code","pre","svg","math","annotation"]),Ir=new Set(["svg","math","annotation"]),Nr=new Set(["img","hr"]),He=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",oo=(e,t)=>{let o=t?Ir:Mr;return e.some(n=>He(n)&&o.has(n.tagName))},Lr=e=>{for(let t=e.length-1;t>=0;t--){let o=e[t];if(He(o)&&o.tagName==="li")return o}},Sr=(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}`;},Rr=new Set(["ul","ol","li"]),no=e=>{for(let t of e.children)if(He(t)){if(t.tagName==="input")return t;if(Rr.has(t.tagName))continue;let o=no(t);if(o)return o}},ro=(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`;},Er=(e,t,o,n)=>{let r=no(e);r&&ro(r,t,o,n);},Hr=(e,t,o,n,r)=>{if(oo(t,n.animateCodeBlocks))return;let s=n.prevContentLength,a=s>0&&r.count<s,l=a?0:(n.startIndex+r.newIndex++)*o.stagger;ro(e,o,a?0:o.duration,l);},Ar=e=>{let t=[],o="",n=false;for(let r of e){let s=to.test(r);s!==n&&o&&(t.push(o),o=""),o+=r,n=s;}return o&&t.push(o),t},Dr=e=>{let t=[],o="";for(let n of e)to.test(n)?o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&t.push(o),t},Br=(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:${s}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:a},children:[{type:"text",value:e}]}},Vr=(e,t,o,n,r)=>{var h;let s=t.at(-1);if(!(s&&"children"in s))return;if(oo(t,n.animateCodeBlocks))return SKIP;let a=s,l=a.children.indexOf(e);if(l===-1)return;let i=e.value;if(!i.trim()){r.count+=i.length;return}let d=o.sep==="char"?Dr(i):Ar(i),c=t.some(k=>He(k)&&k.tagName==="a"),p=d;if(o.sep==="word"&&c){let k=[];for(let x of d)eo.test(x)&&k.length>0?k[k.length-1]+=x:k.push(x);p=k;}let u=n.prevContentLength,m=Lr(t),g=!!(m&&!((h=m.properties)!=null&&h["data-sd-animate-marker"])),f=false,y=p.map(k=>{let x=r.count;if(r.count+=k.length,eo.test(k))return {type:"text",value:k};let b=u>0&&x<u,M=b?0:(n.startIndex+r.newIndex++)*o.stagger;if(m&&g&&!f){let I=b?0:o.duration;Sr(m,I,M,o.easing),Er(m,o,I,M),f=true;}return Br(k,o.animation,o.duration,o.easing,b,M)});return a.children.splice(l,1,...y),l+y.length},Or=0;function Ae(e){var s,a,l,i,d;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",cursor:e==null?void 0:e.cursor,duration:(a=e==null?void 0:e.duration)!=null?a:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(d=e==null?void 0:e.stagger)!=null?d:40},o={animateCodeBlocks:false,prevContentLength:0,lastRenderCharCount:0,lastRenderNewWordCount:0,startIndex:0},n=Or++,r=()=>c=>{let p={count:0,newIndex:0};t.cursor&&(o.startIndex=t.cursor.current),visitParents(c,u=>u.type==="text"||He(u)&&Nr.has(u.tagName),(u,m)=>{if(u.type==="text")return Vr(u,m,t,o,p);Hr(u,m,t,o,p);}),o.lastRenderCharCount=p.count,o.lastRenderNewWordCount=p.newIndex,t.cursor&&(t.cursor.current+=p.newIndex),o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(c){o.animateCodeBlocks=c;},setPrevContentLength(c){o.prevContentLength=c;},setStartIndex(c){o.startIndex=c;},getLastRenderCharCount(){let c=o.lastRenderCharCount;return o.lastRenderCharCount=0,c},getLastRenderNewWordCount(){let c=o.lastRenderNewWordCount;return o.lastRenderNewWordCount=0,c}}}Ae();var bt=createContext(false),yt=()=>useContext(bt);var De=(...e)=>twMerge(clsx(e)),Ke=e=>{if(e!==void 0)return typeof e=="number"?!Number.isFinite(e)||e<=0?void 0:`${e}px`:e},Fr=(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(" ")},io=e=>e?(...t)=>Fr(e,twMerge(clsx(t))):De,oe=(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 Xe=createContext(De),w=()=>useContext(Xe);var Zr=De("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"),Kr=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},mo=memo(({children:e,result:t,language:o,className:n,maxHeight:r,startLine:s,lineNumbers:a=true,...l})=>{let i=w(),{isAnimating:d}=useContext(L),c=useRef(null),p=useRef(true),u=Ke(r);useEffect(()=>{let f=c.current;if(!(f&&u))return;let y=()=>{let h=f.scrollHeight-f.scrollTop-f.clientHeight<8;p.current=h;};return f.addEventListener("scroll",y,{passive:true}),()=>f.removeEventListener("scroll",y)},[u]),useEffect(()=>{let f=c.current;f&&u&&d&&p.current&&f.scrollTo({top:f.scrollHeight,behavior:"instant"});},[d,u]),useEffect(()=>{d||(p.current=true);},[d]);let m=useMemo(()=>i(Zr),[i]),g=useMemo(()=>{let f={};return t.bg&&(f["--sdm-bg"]=t.bg),t.fg&&(f["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(f,Kr(t.rootStyle)),f},[t.bg,t.fg,t.rootStyle]);return jsx("div",{className:i(n,u?"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",ref:c,style:u?{maxHeight:u}:void 0,...l,children:jsx("pre",{className:i(n,"bg-[var(--sdm-bg,inherit)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]"),style:g,children:jsx("code",{className:a?i("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&s&&s>1?{counterReset:`line ${s-1}`}:void 0,children:t.tokens.map((f,y)=>jsx("span",{className:a?m:void 0,children:f.length===0||f.length===1&&f[0].content===""?`
3
+ `:f.map((h,k)=>{let x={},b=!!h.bgColor;if(h.color&&(x["--sdm-c"]=h.color),h.bgColor&&(x["--sdm-tbg"]=h.bgColor),h.htmlStyle)for(let[M,I]of Object.entries(h.htmlStyle))M==="color"?x["--sdm-c"]=I:M==="background-color"?(x["--sdm-tbg"]=I,b=true):x[M]=I;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",b&&"bg-[var(--sdm-tbg)]",b&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:x,...h.htmlAttrs,children:h.content},k)})},y))})})})},(e,t)=>e.maxHeight===t.maxHeight&&e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers);var Ct=({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 kt=createContext({code:""}),Ge=()=>useContext(kt);var xt=({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 es=e=>{let t=e.length;for(;t>0&&e[t-1]===`
4
+ `;)t--;return e.slice(0,t)},ts=lazy(()=>import('./highlighted-body-MXNYJID6.js').then(e=>({default:e.HighlightedCodeBlockBody}))),vt=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,lineNumbers:a,...l})=>{let i=w(),{codeBlockMaxHeight:d}=useContext(L),c=useMemo(()=>es(e),[e]),p=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:c.split(`
5
+ `).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[c]);return jsx(kt.Provider,{value:{code:e},children:jsxs(Ct,{isIncomplete:r,language:t,children:[jsx(xt,{language:t}),n?jsx("div",{className:i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("div",{className:i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:n})}):null,jsx(Suspense,{fallback:jsx(mo,{className:o,language:t,lineNumbers:a,maxHeight:d,result:p,startLine:s,...l}),children:jsx(ts,{className:o,code:c,language:t,lineNumbers:a,maxHeight:d,raw:p,startLine:s,...l})})]})})};var fo=e=>jsx("svg",{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"})}),go=e=>jsx("svg",{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"})}),ho=e=>jsx("svg",{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"})}),bo=e=>jsxs("svg",{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"})]}),yo=e=>jsx("svg",{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"})}),wo=e=>jsx("svg",{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"})}),Co=e=>jsx("svg",{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"})}),ko=e=>jsx("svg",{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"})}),xo=e=>jsx("svg",{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"})}),vo=e=>jsx("svg",{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 Ve={CheckIcon:fo,CopyIcon:go,DownloadIcon:ho,ExternalLinkIcon:ko,Loader2Icon:bo,Maximize2Icon:yo,RotateCcwIcon:wo,XIcon:Co,ZoomInIcon:xo,ZoomOutIcon:vo},To=createContext(Ve),as=(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])},Pt=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...Ve,...e}:Ve);as(o.current,e)||(o.current=e,n.current=e?{...Ve,...e}:Ve);let r=n.current;return jsx(To.Provider,{value:r,children:t})},A=()=>useContext(To);var Ue={copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",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"},Je=createContext(Ue),_=()=>useContext(Je);var Ye=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let l=w(),[i,d]=useState(false),c=useRef(0),{code:p}=Ge(),{isAnimating:u}=useContext(L),m=_(),g=s!=null?s:p,f=async()=>{var k;if(typeof window=="undefined"||!((k=navigator==null?void 0:navigator.clipboard)!=null&&k.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(g),d(!0),e==null||e(),c.current=window.setTimeout(()=>d(!1),o));}catch(x){t==null||t(x);}};useEffect(()=>()=>{window.clearTimeout(c.current);},[]);let y=A(),h=i?y.CheckIcon:y.CopyIcon;return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:u,onClick:f,title:m.copyCode,type:"button",...a,children:n!=null?n:jsx(h,{size:14})})};var Io={"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"},Tt=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let l=w(),{code:i}=Ge(),{isAnimating:d}=useContext(L),c=_(),p=A(),u=s!=null?s:i,g=`file.${o&&o in Io?Io[o]:"txt"}`,f="text/plain",y=()=>{try{oe(g,u,f),e==null||e();}catch(h){t==null||t(h);}};return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:d,onClick:y,title:c.downloadFile,type:"button",...a,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var Qe=()=>{let{Loader2Icon:e}=A(),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 Oe=0,me=()=>{Oe+=1,Oe===1&&(document.body.style.overflow="hidden");},ue=()=>{Oe=Math.max(0,Oe-1),Oe===0&&(document.body.style.overflow="");};var bs=["github-light","github-dark"],ys={enabled:true},ws={codeBlockMaxHeight:400,shikiTheme:bs,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,linkSafety:ys,tableMaxHeight:300},L=createContext(ws);var vs=/\.[^/.]+$/,So=(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},Ro=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,onClick:a,...l})=>{let{DownloadIcon:i,XIcon:d}=A(),c=w(),p=useRef(null),[u,m]=useState(false),[g,f]=useState(false),[y,h]=useState(false),{controls:k}=useContext(L),x=_(),b=So(k,"download"),M=So(k,"fullscreen"),I=l.width!=null||l.height!=null,j=b&&(u||I)&&!g,B=g&&!I,S=M&&!!o&&!g&&u;useEffect(()=>{let N=p.current;if(N!=null&&N.complete){let te=N.naturalWidth>0;m(te),f(!te);}},[]),useEffect(()=>{if(!y)return;me();let N=te=>{te.key==="Escape"&&h(false);};return document.addEventListener("keydown",N),()=>{document.removeEventListener("keydown",N),ue();}},[y]);let O=useCallback(N=>{m(true),f(false),r==null||r(N);},[r]),Q=useCallback(N=>{m(false),f(true),s==null||s(N);},[s]),F=useCallback(()=>{S&&h(true);},[S]),q=useCallback(()=>{h(false);},[]),ee=useCallback(N=>{a==null||a(N),!N.defaultPrevented&&F();},[a,F]),U=async N=>{if(N.stopPropagation(),!!o)try{let J=await(await fetch(o)).blob(),Z=new URL(o,window.location.origin).pathname.split("/").pop()||"",ye=Z.split(".").pop(),re=Z.includes(".")&&ye!==void 0&&ye.length<=4,V="";if(re)V=Z;else {let P=J.type,R="png";P.includes("jpeg")||P.includes("jpg")?R="jpg":P.includes("png")?R="png":P.includes("svg")?R="svg":P.includes("gif")?R="gif":P.includes("webp")&&(R="webp"),V=`${(n||Z||"image").replace(vs,"")}.${R}`;}oe(V,J,J.type);}catch(te){window.open(o,"_blank");}};return o?o==="streamdown:incomplete-image"?jsx("div",{className:c("group relative my-4 inline-block"),"data-incomplete":"true","data-streamdown":"image-wrapper",children:jsx("div",{className:c("h-24 w-48 animate-pulse rounded-lg bg-muted"),"data-streamdown":"image-placeholder"})}):jsxs(Fragment,{children:[jsxs("div",{className:c("group/image not-prose relative my-2 block max-w-full"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:c("m-0 block h-auto max-w-full rounded-lg",S&&"cursor-zoom-in",B&&"hidden",t),"data-streamdown":"image",onClick:ee,onError:Q,onLoad:O,ref:p,src:o,...l}),B&&jsx("span",{className:c("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:x.imageNotAvailable}),j&&jsx("button",{className:c("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:U,title:x.downloadImage,type:"button",children:jsx(i,{size:14})})]}),y?createPortal(jsxs("div",{className:c("fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4"),"data-streamdown":"image-lightbox",onClick:q,onKeyDown:N=>{N.key==="Escape"&&q();},role:"button",tabIndex:0,children:[jsx("button",{className:c("absolute top-4 right-4 z-10 rounded-md p-2 text-white/80 transition-colors hover:bg-white/10 hover:text-white"),onClick:q,title:x.exitFullscreen,type:"button",children:jsx(d,{size:20})}),jsx("div",{onClick:N=>N.stopPropagation(),onKeyDown:N=>N.stopPropagation(),role:"presentation",children:jsx("img",{alt:n,className:c("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:o})})]}),document.body):null]}):null};var Ao=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=A(),i=w(),[d,c]=useState(false),p=_(),u=useCallback(async()=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3);}catch(f){}},[e]),m=useCallback(()=>{n(),o();},[n,o]);if(useEffect(()=>{if(t){me();let f=y=>{y.key==="Escape"&&o();};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),ue();}}},[t,o]),!t||typeof document=="undefined")return null;let g=jsx("div",{className:i("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:i("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:i("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:o,title:p.close,type:"button",children:jsx(l,{size:16})}),jsxs("div",{className:i("flex flex-col gap-2"),children:[jsxs("div",{className:i("flex items-center gap-2 font-semibold text-lg"),children:[jsx(a,{size:20}),jsx("span",{children:p.openExternalLink})]}),jsx("p",{className:i("text-muted-foreground text-sm"),children:p.externalLinkWarning})]}),jsx("div",{className:i("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:i("flex gap-2"),children:[jsx("button",{className:i("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:u,type:"button",children:d?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:p.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:p.copyLink})]})}),jsxs("button",{className:i("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:p.openLink})]})]})]})});return createPortal(g,document.body)};var et=createContext(null),Lt=()=>useContext(et),ic=()=>{var t;let e=Lt();return (t=e==null?void 0:e.code)!=null?t:null},Ie=()=>{var t;let e=Lt();return (t=e==null?void 0:e.mermaid)!=null?t:null};var Do=e=>{var o;let t=Lt();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 Ss=/(<svg\b)/,Oo=/<svg\b[^>]*>/i,Rs=/\bviewBox=(['"])(.*?)\1/i,Es=/\swidth=(['"]).*?\1/i,Hs=/\sheight=(['"]).*?\1/i,Bo=/\sstyle=(['"])(.*?)\1/i,Vo=/^<svg/i,As=/^width\s*:/i,Ds=/^height\s*:/i,Bs=/^max-width\s*:/i,Vs=/[\s,]+/,Os=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(Ss,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),_o=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},St=e=>{let t=e.match(Oo);if(!t)return null;let n=t[0].match(Rs),r=n==null?void 0:n[2];if(!r)return null;let s=r.trim().split(Vs).map(i=>Number.parseFloat(i));if(s.length<4||s.slice(0,4).some(Number.isNaN))return null;let a=s[2],l=s[3];return a>0&&l>0?{height:l,width:a}:null},jo=e=>{let t=e.match(Oo);if(!t)return e;try{let o=t[0],n=St(e);if(!n)return e;let{width:r,height:s}=n,a=o.replace(Es,"").replace(Hs,""),l=a.match(Bo),i=`width:${r}px;height:${s}px;max-width:none;`;if(l){let d=l[1],p=l[2].split(";").map(m=>m.trim()).filter(Boolean).filter(m=>!(As.test(m)||Ds.test(m)||Bs.test(m))).join(";"),u=`${i}${p?`${p};`:""}`;a=a.replace(Bo,` style=${d}${u}${d}`);}else a=a.replace(Vo,`<svg style="${i}"`);return a=a.replace(Vo,`<svg width="${r}" height="${s}"`),e.replace(o,a)}catch(o){return e}},Fo=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a=Os(e),l="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let d=document.createElement("canvas"),c=i.width*o,p=i.height*o;d.width=c,d.height=p;let u=d.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(i,0,0,c,p),d.toBlob(m=>{if(!m){s(new Error("Failed to create PNG blob"));return}r(m);},"image/png");},i.onerror=()=>s(new Error("Failed to load SVG image")),i.src=l;})};var tt=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=w(),[l,i]=useState(false),d=useRef(null),{isAnimating:c}=useContext(L),p=A(),u=Ie(),m=_(),g=async f=>{try{if(f==="mmd"){oe("diagram.mmd",e,"text/plain"),i(!1),n==null||n(f);return}if(!u){s==null||s(new Error("Mermaid plugin not available"));return}let y=u.getMermaid(r),h=e.split("").reduce((M,I)=>(M<<5)-M+I.charCodeAt(0)|0,0),k=`mermaid-${Math.abs(h)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:x}=await y.render(k,e);if(!x){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let b=_o(x);if(f==="svg"){oe("diagram.svg",b,"image/svg+xml"),i(!1),n==null||n(f);return}if(f==="png"){let M=await Fo(b);oe("diagram.png",M,"image/png"),n==null||n(f),i(!1);return}}catch(y){s==null||s(y);}};return useEffect(()=>{let f=y=>{let h=y.composedPath();d.current&&!h.includes(d.current)&&i(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f);}},[]),jsxs("div",{className:a("relative"),ref:d,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:c,onClick:()=>i(!l),title:m.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{size:14})}),l?jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("svg"),title:m.downloadDiagramAsSvg,type:"button",children:m.mermaidFormatSvg}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("png"),title:m.downloadDiagramAsPng,type:"button",children:m.mermaidFormatPng}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("mmd"),title:m.downloadDiagramAsMmd,type:"button",children:m.mermaidFormatMmd})]}):null]})};var qo=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=A(),i=w(),[d,c]=useState(false),{isAnimating:p,controls:u}=useContext(L),m=_(),g=(()=>{if(typeof u=="boolean")return u;let h=u.mermaid;return h===false?false:h===true||h===void 0?true:h.panZoom!==false})(),f=(()=>{if(typeof u=="boolean")return u;let h=u.mermaid;return h===false?false:h===true||h===void 0?true:h.download!==false})(),y=()=>{c(!d);};return useEffect(()=>{if(d){me();let h=k=>{k.key==="Escape"&&c(false);};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h),ue();}}},[d]),useEffect(()=>{d?o==null||o():n&&n();},[d,o,n]),jsxs(Fragment,{children:[jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:p,onClick:y,title:m.viewFullscreen,type:"button",...s,children:jsx(a,{size:14})}),d?createPortal(jsxs("div",{"aria-label":m.viewFullscreen,"aria-modal":"true",className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"mermaid-fullscreen",onClick:y,onKeyDown:h=>{h.key==="Escape"&&y();},role:"dialog",children:[jsxs("div",{className:i("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:[f?jsx(tt,{chart:e,config:t}):null,jsx("button",{className:i("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:y,title:m.exitFullscreen,type:"button",children:jsx(l,{size:20})})]}),jsx("div",{className:i("flex size-full items-center justify-center p-4"),onClick:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:jsx(Wo,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:g})})]}),document.body):null]})};var Ne=e=>{var s,a;let t=[],o=[],n=e.querySelectorAll("thead th");for(let l of n)t.push(((s=l.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let l of r){let i=[],d=l.querySelectorAll("td");for(let c of d)i.push(((a=c.textContent)==null?void 0:a.trim())||"");o.push(i);}return {headers:t,rows:o}},ve=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false,d=false;for(let c of l){if(c==='"'){i=true,d=true;break}(c===","||c===`
6
+ `)&&(i=true);}return i?d?`"${l.replace(/"/g,'""')}"`:`"${l}"`:l},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 l of o)s[a]=l.map(n).join(","),a+=1;return s.join(`
7
+ `)},Et=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false;for(let c of l)if(c===" "||c===`
8
+ `||c==="\r"){i=true;break}if(!i)return l;let d=[];for(let c of l)c===" "?d.push("\\t"):c===`
9
+ `?d.push("\\n"):c==="\r"?d.push("\\r"):d.push(c);return d.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 l of o)s[a]=l.map(n).join(" "),a+=1;return s.join(`
10
+ `)},ot=e=>{let t=false;for(let n of e)if(n==="\\"||n==="|"){t=true;break}if(!t)return e;let o=[];for(let n of e)n==="\\"?o.push("\\\\"):n==="|"?o.push("\\|"):o.push(n);return o.join("")},Pe=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),r=0,s=t.map(l=>ot(l));n[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let l=0;l<t.length;l+=1)a[l]="---";n[r]=`| ${a.join(" | ")} |`,r+=1;for(let l of o)if(l.length<t.length){let i=new Array(t.length);for(let d=0;d<t.length;d+=1)i[d]=d<l.length?ot(l[d]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(d=>ot(d));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
11
+ `)};var ze=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=w(),[a,l]=useState(false),[i,d]=useState(false),c=useRef(null),p=useRef(0),{isAnimating:u}=useContext(L),m=_(),g=async h=>{var k,x;if(typeof window=="undefined"||!((k=navigator==null?void 0:navigator.clipboard)!=null&&k.write)){n==null||n(new Error("Clipboard API not available"));return}try{let b=(x=c.current)==null?void 0:x.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),M=b==null?void 0:b.querySelector("table");if(!M){n==null||n(new Error("Table not found"));return}let I=Ne(M),S=({csv:ve,tsv:Et,md:Pe}[h]||Pe)(I),O=new ClipboardItem({"text/plain":new Blob([S],{type:"text/plain"}),"text/html":new Blob([M.outerHTML],{type:"text/html"})});await navigator.clipboard.write([O]),d(!0),l(!1),o==null||o(h),p.current=window.setTimeout(()=>d(!1),r);}catch(b){n==null||n(b);}};useEffect(()=>{let h=k=>{let x=k.composedPath();c.current&&!x.includes(c.current)&&l(false);};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h),window.clearTimeout(p.current);}},[]);let f=A(),y=i?f.CheckIcon:f.CopyIcon;return jsxs("div",{className:s("relative"),ref:c,children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>l(!a),title:m.copyTable,type:"button",children:e!=null?e:jsx(y,{height:14,width:14})}),a?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("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:()=>g("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:()=>g("tsv"),title:m.copyTableAsTsv,type:"button",children:m.tableFormatTsv})]}):null]})};var Ys=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:s})=>{let a=w(),{isAnimating:l}=useContext(L),i=_(),d=A(),c=p=>{try{let m=p.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),g=m==null?void 0:m.querySelector("table");if(!g){n==null||n(new Error("Table not found"));return}let f=Ne(g),y="",h="",k="";switch(r){case "csv":y=ve(f),h="text/csv",k="csv";break;case "markdown":y=Pe(f),h="text/markdown",k="md";break;default:y=ve(f),h="text/csv",k="csv";}oe(`${s||"table"}.${k}`,y,h),o==null||o();}catch(u){n==null||n(u);}};return jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:c,title:r==="csv"?i.downloadTableAsCsv:i.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d.DownloadIcon,{size:14})})},$e=({children:e,className:t,onDownload:o,onError:n})=>{let r=w(),[s,a]=useState(false),l=useRef(null),{isAnimating:i}=useContext(L),d=_(),c=A(),p=u=>{var m;try{let g=(m=l.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=g==null?void 0:g.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let y=Ne(f),h=u==="csv"?ve(y):Pe(y);oe(`table.${u==="csv"?"csv":"md"}`,h,u==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(u);}catch(g){n==null||n(g);}};return useEffect(()=>{let u=m=>{let g=m.composedPath();l.current&&!g.includes(l.current)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[]),jsxs("div",{className:r("relative"),ref:l,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:i,onClick:()=>a(!s),title:d.downloadTable,type:"button",children:e!=null?e:jsx(c.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:()=>p("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:()=>p("markdown"),title:d.downloadTableAsMarkdown,type:"button",children:d.tableFormatMarkdown})]}):null]})};var Jo=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=A(),a=w(),[l,i]=useState(false),{isAnimating:d}=useContext(L),c=_(),p=()=>{i(true);},u=()=>{i(false);};return useEffect(()=>{if(l){me();let m=g=>{g.key==="Escape"&&i(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),ue();}}},[l]),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:d,onClick:p,title:c.viewFullscreen,type:"button",children:jsx(r,{size:14})}),l?createPortal(jsx("div",{"aria-label":c.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:u,onKeyDown:m=>{m.key==="Escape"&&u();},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(ze,{}):null,n?jsx($e,{}):null,jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:u,title:c.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})})]})}),document.body):null]})};var en=({children:e,className:t,maxHeight:o,showControls:n,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...l})=>{let i=w(),{isAnimating:d}=useContext(L),c=useRef(null),p=useRef(true),u=Ke(o);useEffect(()=>{let h=c.current;if(!(h&&u))return;let k=()=>{let x=h.scrollHeight-h.scrollTop-h.clientHeight<8;p.current=x;};return h.addEventListener("scroll",k,{passive:true}),()=>h.removeEventListener("scroll",k)},[u]),useEffect(()=>{let h=c.current;h&&u&&d&&p.current&&h.scrollTo({top:h.scrollHeight,behavior:"instant"});}),useEffect(()=>{d||(p.current=true);},[d]);let m=n&&r,g=n&&s,f=n&&a,y=m||g||f;return jsxs("div",{className:i("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[y?jsxs("div",{className:i("flex items-center justify-end gap-1"),children:[m?jsx(ze,{}):null,g?jsx($e,{}):null,f?jsx(Jo,{showCopy:m,showDownload:g,children:e}):null]}):null,jsx("div",{className:i("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),ref:c,style:u?{maxHeight:u}:void 0,children:jsx("table",{className:i("w-full table-fixed divide-y divide-border",t),"data-streamdown":"table",...l,children:e})})]})};var ca=/startLine=(\d+)/,da=/\bnoLineNumbers\b/,ma=lazy(()=>import('./mermaid-4TLAMNZ2.js').then(e=>({default:e.Mermaid}))),ua=/language-([^\s]+)/;function at(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let o=e.position.start,n=t.position.start,r=e.position.end,s=t.position.end;return (o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(o==null?void 0:o.offset)===(n==null?void 0:n.offset)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)&&(r==null?void 0:r.offset)===(s==null?void 0:s.offset)}function D(e,t){return e.className===t.className&&at(e.node,t.node)}var Vt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Bt=(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},on=(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},nt=(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},qe=createContext({depth:0,ulDepth:0,isUnordered:false}),pa={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},Ot=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{depth:s,ulDepth:a}=useContext(qe),l=useMemo(()=>({depth:s+1,ulDepth:a,isUnordered:false}),[s,a]);return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"ordered-list",...n,children:jsx(qe.Provider,{value:l,children:e})})},(e,t)=>D(e,t));Ot.displayName="MarkdownOl";var rn=memo(({children:e,className:t,node:o,...n})=>{var f;let r=w(),{depth:s,ulDepth:a,isUnordered:l}=useContext(qe),{listStyle:i}=useContext(L),d=pa[i],c=l&&a>0?d[(a-1)%d.length]:void 0,p=Array.isArray(e)?e.filter(y=>y!==`
12
+ `&&y!==""):[e],u=p[0],m=isValidElement(u)?(f=u.props.node)==null?void 0:f.tagName:void 0,g=p.length===1&&isValidElement(u)&&(u.type==="p"||m==="p")?u.props.children:e;return jsx("li",{className:r("py-1 [&>p]:inline",c,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...n,children:g})},(e,t)=>e.className===t.className&&at(e.node,t.node));rn.displayName="MarkdownLi";var sn=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{depth:s,ulDepth:a}=useContext(qe),l=useMemo(()=>({depth:s+1,ulDepth:a+1,isUnordered:true}),[s,a]);return jsx("ul",{className:r("list-inside whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"unordered-list",...n,children:jsx(qe.Provider,{value:l,children:e})})},(e,t)=>D(e,t));sn.displayName="MarkdownUl";var an=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)=>D(e,t));an.displayName="MarkdownHr";var ln=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)=>D(e,t));ln.displayName="MarkdownStrong";var fa=({children:e,className:t,href:o,node:n,...r})=>{let s=w(),{linkSafety:a}=useContext(L),[l,i]=useState(false),d=o==="streamdown:incomplete-link",c=useCallback(async g=>{if(!(!(a!=null&&a.enabled&&o)||d)){if(g.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[a,o,d]),p=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),u=useCallback(()=>{i(false);},[]),m={url:o!=null?o:"",isOpen:l,onClose:u,onConfirm:p};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":d,"data-streamdown":"link",onClick:c,type:"button",children:e}),a.renderModal?a.renderModal(m):jsx(Ao,{...m})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":d,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},cn=memo(fa,(e,t)=>D(e,t)&&e.href===t.href);cn.displayName="MarkdownA";var dn=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)=>D(e,t));dn.displayName="MarkdownH1";var mn=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)=>D(e,t));mn.displayName="MarkdownH2";var un=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)=>D(e,t));un.displayName="MarkdownH3";var pn=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)=>D(e,t));pn.displayName="MarkdownH4";var fn=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)=>D(e,t));fn.displayName="MarkdownH5";var gn=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)=>D(e,t));gn.displayName="MarkdownH6";var hn=memo(({children:e,className:t,node:o,...n})=>{let{controls:r,tableMaxHeight:s}=useContext(L),a=Vt(r,"table"),l=Bt(r,"copy"),i=Bt(r,"download"),d=Bt(r,"fullscreen");return jsx(en,{className:t,maxHeight:s,showControls:a,showCopy:l,showDownload:i,showFullscreen:d,...n,children:e})},(e,t)=>D(e,t));hn.displayName="MarkdownTable";var bn=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)=>D(e,t));bn.displayName="MarkdownThead";var yn=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)=>D(e,t));yn.displayName="MarkdownTbody";var wn=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)=>D(e,t));wn.displayName="MarkdownTr";var Cn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("th",{className:r("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>D(e,t));Cn.displayName="MarkdownTh";var kn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>D(e,t));kn.displayName="MarkdownTd";var xn=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)=>D(e,t));xn.displayName="MarkdownBlockquote";var vn=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)=>D(e,t));vn.displayName="MarkdownSup";var Pn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return (t==null?void 0:t.includes("markdown-alert"))?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",t),...n,children:e}):jsx("div",{className:r(t),...n,children:e})},(e,t)=>D(e,t));Pn.displayName="MarkdownDiv";var Tn=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)=>D(e,t));Tn.displayName="MarkdownSub";var Mn=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=i=>{var u,m;if(!isValidElement(i))return false;let d=Array.isArray(i.props.children)?i.props.children:[i.props.children],c=false,p=false;for(let g of d)if(g){if(typeof g=="string")g.trim()!==""&&(c=true);else if(isValidElement(g))if(((u=g.props)==null?void 0:u["data-footnote-backref"])!==void 0)p=true;else {let f=Array.isArray(g.props.children)?g.props.children:[g.props.children];for(let y of f){if(typeof y=="string"&&y.trim()!==""){c=true;break}if(isValidElement(y)&&((m=y.props)==null?void 0:m["data-footnote-backref"])===void 0){c=true;break}}}}return p&&!c},a=Array.isArray(e)?e.map(i=>{if(!isValidElement(i))return i;if(i.type===Ot){let c=(Array.isArray(i.props.children)?i.props.children:[i.props.children]).filter(p=>!s(p));return c.length===0?null:{...i,props:{...i.props,children:c}}}return i}):e;return (Array.isArray(a)?a.some(i=>i!==null):a!==null)?jsx("section",{className:t,...n,children:a}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>D(e,t));Mn.displayName="MarkdownSection";var ga=({node:e,className:t,children:o,...n})=>{var B,S;let r=w(),s=!("data-block"in n),{mermaid:a,controls:l,lineNumbers:i}=useContext(L),d=Ie(),c=yt(),p=t==null?void 0:t.match(ua),u=(B=p==null?void 0:p.at(1))!=null?B:"",m=Do(u);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=(S=e==null?void 0:e.properties)==null?void 0:S.metastring,f=g==null?void 0:g.match(ca),y=f?Number.parseInt(f[1],10):void 0,h=y!==void 0&&y>=1?y:void 0,x=!(g?da.test(g):false)&&i!==false,b="";if(isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?b=o.props.children:typeof o=="string"&&(b=o),m){let O=m.component;return jsx(Suspense,{fallback:jsx(Qe,{}),children:jsx(O,{code:b,isIncomplete:c,language:u,meta:g})})}if(u==="mermaid"&&d){let O=Vt(l,"mermaid"),Q=nt(l,"download"),F=nt(l,"copy"),q=nt(l,"fullscreen"),ee=nt(l,"panZoom"),U=O&&(Q||F||q);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-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"})}),U?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:[Q?jsx(tt,{chart:b,config:a==null?void 0:a.config}):null,F?jsx(Ye,{code:b}):null,q?jsx(qo,{chart:b,config:a==null?void 0:a.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(ma,{chart:b,config:a==null?void 0:a.config,showControls:ee})})]})})}let M=Vt(l,"code"),I=on(l,"download"),j=on(l,"copy");return jsx(vt,{className:t,code:b,isIncomplete:c,language:u,lineNumbers:x,startLine:h,children:M?jsxs(Fragment,{children:[I?jsx(Tt,{code:b,language:u}):null,j?jsx(Ye,{}):null]}):null})},In=memo(ga,(e,t)=>e.className===t.className&&at(e.node,t.node));In.displayName="MarkdownCode";var Nn=memo(Ro,(e,t)=>e.className===t.className&&at(e.node,t.node));Nn.displayName="MarkdownImg";var Ln=memo(({children:e,className:t,node:o,...n})=>{let r=w();if(t!=null&&t.includes("markdown-alert-title"))return jsx("p",{className:r("mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",t),...n,children:e});let a=(Array.isArray(e)?e:[e]).filter(l=>l!=null&&l!=="");if(a.length===1&&isValidElement(a[0])){let l=a[0].props.node,i=l==null?void 0:l.tagName;if(i==="img")return jsx(Fragment,{children:e});if(i==="code"&&"data-block"in a[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...n,children:e})},(e,t)=>D(e,t));Ln.displayName="MarkdownParagraph";var Sn={ol:Ot,li:rn,ul:sn,hr:an,strong:ln,a:cn,h1:dn,h2:mn,h3:un,h4:pn,h5:fn,h6:gn,table:hn,thead:bn,tbody:yn,tr:wn,th:Cn,td:kn,blockquote:xn,code:In,div:Pn,img:Nn,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:vn,sub:Tn,p:Ln,section:Mn};var ha=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,ba=/\p{L}/u;function it(e){let t=e.replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,"");for(let o of t){if(ha.test(o))return "rtl";if(ba.test(o))return "ltr"}return "ltr"}var ya=/^[ \t]{0,3}(`{3,}|~{3,})/,wa=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,_t=e=>{let t=e.split(`
13
+ `),o=null,n=0;for(let r of t){let s=ya.exec(r);if(o===null){if(s){let a=s[1];o=a[0],n=a.length;}}else if(s){let a=s[1],l=a[0],i=a.length;l===o&&i>=n&&(o=null,n=0);}}return o!==null},Rn=e=>{let t=e.split(`
14
+ `);for(let o of t){let n=o.trim();if(n.length>0&&n.includes("|")&&wa.test(n))return true}return false};var En=()=>e=>{visit(e,"html",(t,o,n)=>{!n||typeof o!="number"||(n.children[o]={type:"text",value:t.value});});};var An=[],Dn={allowDangerousHtml:true},lt=new WeakMap,Ft=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 p="default";return this.keyCache.set(t,p),p}let a=p=>{if(!p||p.length===0)return "";let u="";for(let m=0;m<p.length;m+=1){let g=p[m];if(m>0&&(u+=","),Array.isArray(g)){let[f,y]=g;if(typeof f=="function"){let h=lt.get(f);h||(h=f.name,lt.set(f,h)),u+=h;}else u+=String(f);u+=":",u+=JSON.stringify(y);}else if(typeof g=="function"){let f=lt.get(g);f||(f=g.name,lt.set(g,f)),u+=f;}else u+=String(g);}return u},l=a(n),i=a(r),d=s?JSON.stringify(s):"",c=`${i}::${l}::${d}`;return this.keyCache.set(t,c),c}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();}},Bn=new Ft,zt=e=>{let t=La(e),o=e.children||"",n=t.runSync(t.parse(o),o);return Da(n,e)},La=e=>{let t=Bn.get(e);if(t)return t;let o=Ra(e);return Bn.set(e,o),o},Sa=e=>e.some(t=>Array.isArray(t)?t[0]===Hn:t===Hn),Ra=e=>{let t=e.rehypePlugins||An,o=e.remarkPlugins||An,n=Sa(t)?o:[...o,En],r=e.remarkRehypeOptions?{...Dn,...e.remarkRehypeOptions}:Dn;return unified().use(Ta).use(n).use(Ma,r).use(t)},Vn=e=>e,Ea=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},Ha=(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);}},Aa=(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},Da=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:l}=t;if(o||n||r||s||l){let d=l||Vn;visit(e,(c,p,u)=>{if(c.type==="raw"&&u&&typeof p=="number")return Ea(u,p,s,c.value),p;if(c.type==="element"&&(Ha(c,d),Aa(c,p,u,n,r,o)&&u&&typeof p=="number"))return a&&c.children?u.children.splice(p,1,...c.children):u.children.splice(p,1),p});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var Va=/\[\^[\w-]{1,200}\](?!:)/,Oa=/\[\^[\w-]{1,200}\]:/;var _a=/<(\w+)[\s>]/,ja=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),On=new Map,_n=new Map,zn=e=>{let t=e.toLowerCase(),o=On.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return On.set(t,n),n},Fa=e=>{let t=e.toLowerCase(),o=_n.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return _n.set(t,n),n},jn=(e,t)=>{if(ja.has(t.toLowerCase()))return 0;let o=e.match(zn(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},Fn=(e,t)=>{let o=e.match(Fa(t));return o?o.length:0},za=(e,t)=>{let o=e.match(zn(t));return !!o&&o.every(n=>n.trimEnd().endsWith("/>"))},$a=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},ct=e=>{let t=Va.test(e),o=Oa.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),r=[],s=[],a=false;for(let l of n){let i=l.raw,d=r.length;if(s.length>0){r[d-1]+=i;let c=s.at(-1),p=jn(i,c),u=Fn(i,c);for(let m=0;m<p;m+=1)s.push(c);for(let m=0;m<u;m+=1)s.length>0&&s.at(-1)===c&&s.pop();continue}if(l.type==="html"&&l.block){let c=i.match(_a);if(c){let p=c[1],u=jn(i,p),m=Fn(i,p);u>m&&!za(i,p)&&s.push(p);}}if(d>0&&!a){let c=r[d-1];if($a(c)%2===1){r[d-1]=c+i;continue}}r.push(i),l.type!=="space"&&(a=l.type==="code");}return r},$t=(e,t,o=ct)=>{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 i of n)r+=i.length;let s=e.slice(0,r);if(n.join("")!==s)return {source:e,blocks:o(e)};let a=e.slice(r),l=o(a);return {source:e,blocks:[...n,...l]}};var $n=(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,l,i)=>{let d=l.includes(`
15
+
16
+ `),c=!l.startsWith(`
17
+ `),p=l.includes(`
18
+ `);if(!(d||c&&p))return a+l+i;let u=l.replace(/\n\n/g,`
19
+ <!---->
20
+ `),m=(u.startsWith(`
21
+ `)?"":`
22
+ `)+u+(u.endsWith(`
23
+ `)?"":`
24
+ `);return `${a}${m}${i}
25
+
26
+ `});}return o};var Wa=/([\\`*_~[\]|])/g,qa=e=>e.replace(Wa,"\\$1"),Wn=(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,l,i)=>{let d=qa(l).replace(/\n\n/g,"&#10;&#10;");return a+d+i});}return o};var qn=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(qn).join(""):"",Zn=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=qn(n);n.children=r?[{type:"text",value:r}]:[];}});};var Ja=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),Ya=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),Qa=e=>{let t=unified().use(Ta).use(Ma,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},Kn=(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)||!Ja(s))return;let l=Ya(s);if(!l.includes(`
27
+ `))return;let i=Qa(l);s.children=i;});};var Xn=()=>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 ni={NOTE:{icon:"info",kind:"note",title:"Note",iconPath:"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",iconPath:"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",iconPath:"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",iconPath:"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.575ZM8.75 5.75v2.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"},CAUTION:{icon:"stop",kind:"caution",title:"Caution",iconPath:"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"}},ri=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,Gn=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let o="";for(let n of t)o+=Gn(n);return o},si=e=>({type:"paragraph",children:[{type:"html",value:`<svg class="octicon octicon-${e.icon}" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="${e.iconPath}"></path></svg>`},{type:"text",value:e.title}],data:{hName:"p",hProperties:{className:["markdown-alert-title"]}}}),ai=e=>{var p,u;let t=e.children[0];if(!t||t.type!=="paragraph")return;let o=t.children[0];if(!o||o.type!=="text")return;let n=Gn(o).trimStart(),r=n.match(ri);if(!r)return;let s=ni[r[1].toUpperCase()],a=n.slice(r[0].length),l=t.children.slice(1);if(a.trim().length===0&&l.length===0&&e.children.length===1)return;let i=[si(s)],d=[];a.length>0&&d.push({type:"text",value:a});let c=l;return ((p=c[0])==null?void 0:p.type)==="break"&&(c=c.slice(1)),d.push(...c),d.length>0&&d.some(m=>m.type!=="text"||m.value.trim().length>0)&&i.push({type:"paragraph",children:d}),i.push(...e.children.slice(1)),e.data=(u=e.data)!=null?u:{},e.data.hName="div",e.data.hProperties={className:["markdown-alert",`markdown-alert-${s.kind}`]},e.children=i,SKIP$1},Un=()=>e=>{visit(e,"blockquote",ai);};var fi=/^[ \t]*<[\w!/?-]/,gi=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,hi=e=>typeof e!="string"||e.length===0||!fi.test(e)?e:e.replace(gi,"$1"),er,tr,or,nr,rr,sr,ar,ir,lr,dt={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(tr=(er=defaultSchema.protocols)==null?void 0:er.href)!=null?tr:[],"tel"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(nr=(or=defaultSchema.attributes)==null?void 0:or.div)!=null?nr:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution))$/]],p:[...(sr=(rr=defaultSchema.attributes)==null?void 0:rr.p)!=null?sr:[],["className",/^markdown-alert-title$/]],svg:[...(ir=(ar=defaultSchema.attributes)==null?void 0:ar.svg)!=null?ir:[],"className","viewBox"]},tagNames:[...(lr=defaultSchema.tagNames)!=null?lr:[],"svg","path"]},Wt={raw:Hn,sanitize:[dr,dt],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},bi={gfm:[ui,{}],githubAlerts:Un,codeMeta:Xn},Yn=Object.values(Wt),yi=Object.values(bi),Qn=new WeakMap;function wi(e){var r;let t=Qn.get(e);if(t)return t;let o={...dt,tagNames:[...(r=dt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...dt.attributes,...e}},n=[Wt.raw,[dr,o],Wt.harden];return Qn.set(e,n),n}var Ci={block:" \u258B",circle:" \u25CF"},ki=["github-light","github-dark"],xi={enabled:true},mr=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:o,index:n,isIncomplete:r,dir:s,animatePlugin:a,...l})=>{if(a){let c=a.getLastRenderCharCount();a.setPrevContentLength(c),a.setAnimateCodeBlocks(r);}let i=typeof e=="string"&&o?hi(e):e,d=jsx(zt,{...l,children:i});return jsx(bt.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:d}):d})},(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)});mr.displayName="Block";var vi=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=Yn,remarkPlugins:l=yi,className:i,shikiTheme:d=ki,mermaid:c,codeBlockMaxHeight:p=400,controls:u=true,isAnimating:m=false,tableMaxHeight:g=300,animated:f,BlockComponent:y=mr,parseMarkdownIntoBlocksFn:h=ct,caret:k,listStyle:x="hierarchical",plugins:b,remend:M,linkSafety:I=xi,lineNumbers:j=true,allowedTags:B,literalTagContent:S,translations:O,icons:Q,prefix:F,onAnimationStart:q,onAnimationEnd:ee,...U})=>{var Jt;let he=useId(),N=useMemo(()=>io(F),[F]),te=useRef(null),J=useRef(q),be=useRef(ee);J.current=q,be.current=ee,useEffect(()=>{var T,$,K;if(t==="static")return;let C=te.current;if(te.current=m,C===null){m&&((T=J.current)==null||T.call(J));return}m&&!C?($=J.current)==null||$.call(J):!m&&C&&((K=be.current)==null||K.call(be));},[m,t]);let Z=useMemo(()=>B?Object.keys(B):[],[B]),ye=useRef(null),re=useMemo(()=>{if(typeof e!="string")return "";let C=e;return S&&S.length>0&&(C=Wn(C,S)),Z.length>0&&(C=$n(C,Z)),C},[e,Z,S]),V=useMemo(()=>{let C=t==="streaming"?ye.current:null,T=$t(re,C,h);if(ye.current=t==="streaming"?T:null,!(t==="streaming"&&n)||T.blocks.length===0)return T.blocks;let $=T.blocks.length-1,K=T.blocks[$],de=pi(K,M);if(de===K)return T.blocks;let Ee=T.blocks.slice();return Ee[$]=de,Ee},[re,h,t,n,M]),P=useMemo(()=>f===true?"true":f?JSON.stringify(f):"",[f]),R=useRef(null),X=useRef([]),Y=useRef([]),qt=useRef(null),Zt=useRef("");P?(Zt.current!==P&&(Zt.current=P,R.current=ht(),X.current=[],Y.current=[]),R.current&&(R.current.current=0)):(R.current=null,X.current=[],Y.current=[]);R.current?(Jt=X.current[0])!=null?Jt:(()=>{var T;let C=Ae({...P!=="true"?f:{},cursor:(T=R.current)!=null?T:void 0});return X.current[0]=C,C})():null;let we=useDeferredValue(V),se=useMemo(()=>{if(t!=="streaming"||R.current||we===V||we.length===0)return V;let C=we.length,T=V.length;if(T===0)return we;if(C!==T)return V;for(let K=0;K<C-1;K+=1)if(we[K]!==V[K])return V;let $=we.slice();return $[C-1]=V[T-1],$},[V,we,t]),ut=useMemo(()=>o==="auto"?se.map(it):void 0,[se,o]),gr=useMemo(()=>se.map((C,T)=>`${he}-${T}`),[se.length,he]),Kt=useMemo(()=>{var C,T;return {codeBlockMaxHeight:p,shikiTheme:(T=(C=b==null?void 0:b.code)==null?void 0:C.getThemes())!=null?T:d,controls:u,isAnimating:m,lineNumbers:j,listStyle:x,mode:t,mermaid:c,linkSafety:I,tableMaxHeight:g}},[p,d,u,m,j,x,t,c,I,b==null?void 0:b.code,g]),hr=useMemo(()=>O?JSON.stringify(O):"",[O]),Xt=useMemo(()=>({...Ue,...O}),[hr]),Gt=useMemo(()=>{let{inlineCode:C,...T}=s!=null?s:{},$={...Sn,...T};if(C){let K=$.code;$.code=de=>"data-block"in de?K?createElement(K,de):null:createElement(C,de);}return $},[s]),Ut=useMemo(()=>{let C=[];return b!=null&&b.cjk&&(C=[...C,...b.cjk.remarkPluginsBefore]),C=[...C,...l],b!=null&&b.cjk&&(C=[...C,...b.cjk.remarkPluginsAfter]),b!=null&&b.math&&(C=[...C,b.math.remarkPlugin]),C},[l,b==null?void 0:b.math,b==null?void 0:b.cjk]),Re=useMemo(()=>{let C=a;return B&&Object.keys(B).length>0&&a===Yn&&(C=wi(B)),Z.length>0&&(C=[...C,[Kn,Z,S!=null?S:[]]]),S&&S.length>0&&(C=[...C,[Zn,S]]),b!=null&&b.math&&(C=[...C,b.math.rehypePlugin]),C},[a,b==null?void 0:b.math,B,Z,S]),pt=useMemo(()=>{if(!m||se.length===0)return false;let C=se.at(-1);return _t(C)||Rn(C)},[m,se]),br=useMemo(()=>k&&m&&!pt?{"--streamdown-caret":`"${Ci[k]}"`}:void 0,[k,m,pt]),yr=C=>{let T=null;R.current&&m&&(X.current[C]||(X.current[C]=Ae({...P!=="true"?f:{},cursor:R.current})),T=X.current[C]),qt.current!==Re&&(Y.current=[],qt.current=Re),T&&!Y.current[C]&&(Y.current[C]=[...Re,T.rehypePlugin]);let $=T&&Y.current[C]?Y.current[C]:Re;return {blockAnimatePlugin:T,blockRehypePlugins:$}};return t==="static"?jsx(Je.Provider,{value:Xt,children:jsx(et.Provider,{value:b!=null?b:null,children:jsx(L.Provider,{value:Kt,children:jsx(Pt,{icons:Q,children:jsx(Xe.Provider,{value:N,children:jsx("div",{className:N("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:o==="auto"?it(re):o,children:jsx(zt,{components:Gt,rehypePlugins:Re,remarkPlugins:Ut,...U,children:re})})})})})})}):jsx(Je.Provider,{value:Xt,children:jsx(et.Provider,{value:b!=null?b:null,children:jsx(L.Provider,{value:Kt,children:jsx(Pt,{icons:Q,children:jsx(Xe.Provider,{value:N,children:jsxs("div",{className:N("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",k&&!pt?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),style:br,children:[se.length===0&&k&&m&&jsx("span",{}),se.map((C,T)=>{var Yt;let $=T===se.length-1,K=m&&$&&_t(C),{blockAnimatePlugin:de,blockRehypePlugins:Ee}=yr(T);return jsx(y,{animatePlugin:de,components:Gt,content:C,dir:(Yt=ut==null?void 0:ut[T])!=null?Yt:o!=="auto"?o:void 0,index:T,isIncomplete:K,rehypePlugins:Ee,remarkPlugins:Ut,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...U},gr[T])})]})})})})})})},(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.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);vi.displayName="Streamdown";var fr=({children:e,className:t,contentSize:o,fitKey:n,minZoom:r=.5,maxZoom:s=3,zoomStep:a=.1,showControls:l=true,initialZoom:i=1,isAutoFit:d=false,fullscreen:c=false})=>{let{RotateCcwIcon:p,ZoomInIcon:u,ZoomOutIcon:m}=A(),g=w(),f=useRef(null),y=useRef(null),[h,k]=useState(i),[x,b]=useState(r),[M,I]=useState(i),[j,B]=useState({x:0,y:0}),[S,O]=useState(false),[Q,F]=useState(false),[q,ee]=useState({x:0,y:0}),[U,he]=useState({x:0,y:0}),N=useCallback(P=>{I(R=>Math.max(x,Math.min(s,R+P))),F(true);},[x,s]),te=useCallback(()=>{N(a);},[N,a]),J=useCallback(()=>{N(-a);},[N,a]),be=useCallback(()=>{I(h),B({x:0,y:0}),F(false);},[h]),Z=useCallback(P=>{P.preventDefault();let R=P.deltaY>0?-a:a;N(R);},[N,a]),ye=useCallback(P=>{if(P.button!==0||P.isPrimary===false)return;O(true),F(true),ee({x:P.clientX,y:P.clientY}),he(j);let R=P.currentTarget;R instanceof HTMLElement&&R.setPointerCapture(P.pointerId);},[j]),re=useCallback(P=>{if(!S)return;P.preventDefault();let R=P.clientX-q.x,X=P.clientY-q.y;B({x:U.x+R,y:U.y+X});},[S,q,U]),V=useCallback(P=>{O(false);let R=P.currentTarget;R instanceof HTMLElement&&R.releasePointerCapture(P.pointerId);},[]);return useEffect(()=>{b(r),d||(k(i),I(i));},[i,d,r]),useEffect(()=>{if(!(d&&o))return;let P=f.current;if(!P)return;let R=P.clientWidth,X=P.clientHeight;if(!(R>0&&X>0))return;let Y=Math.min(R/o.width,X/o.height,1);!(Y>0)||Number.isNaN(Y)||(k(Y),b(Math.min(r,Y)),Q||(I(Y),B({x:0,y:0})));},[o,Q,d,r]),useEffect(()=>{d&&F(false);},[d]),useEffect(()=>{let P=f.current;if(P)return P.addEventListener("wheel",Z,{passive:false}),()=>{P.removeEventListener("wheel",Z);}},[Z]),useEffect(()=>{let P=y.current;if(P&&S)return document.body.style.userSelect="none",P.addEventListener("pointermove",re,{passive:false}),P.addEventListener("pointerup",V),P.addEventListener("pointercancel",V),()=>{document.body.style.userSelect="",P.removeEventListener("pointermove",re),P.removeEventListener("pointerup",V),P.removeEventListener("pointercancel",V);}},[S,re,V]),jsxs("div",{className:g("relative flex flex-col",c?"h-full w-full":"min-h-28 w-full",t),ref:f,style:{cursor:S?"grabbing":"grab"},children:[l?jsxs("div",{className:g("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",c?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:g("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:te,title:"Zoom in",type:"button",children:jsx(u,{size:16})}),jsx("button",{className:g("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<=x,onClick:J,title:"Zoom out",type:"button",children:jsx(m,{size:16})}),jsx("button",{className:g("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:be,title:"Reset zoom and pan",type:"button",children:jsx(p,{size:16})})]}):null,jsx("div",{className:g("flex-1 origin-center transition-transform duration-150 ease-out",c?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:ye,ref:y,role:"application",style:{transform:`translate(${j.x}px, ${j.y}px) scale(${M})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var Wo=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=w(),[a,l]=useState(null),[i,d]=useState(false),[c,p]=useState(""),[u,m]=useState(null),[g,f]=useState(""),[y,h]=useState(0),{mermaid:k}=useContext(L),x=Ie(),b=k==null?void 0:k.errorComponent,{shouldRender:M,containerRef:I}=Qt({immediate:n});if(useEffect(()=>{if(!M)return;if(!x){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),d(!0);let S=x.getMermaid(o),O=e.split("").reduce((U,he)=>(U<<5)-U+he.charCodeAt(0)|0,0),Q=`mermaid-${Math.abs(O)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:F}=await S.render(Q,e),q=St(F),ee=n?F:jo(F);p(ee),m(q),f(ee);}catch(S){if(!(g||c)){let O=S instanceof Error?S.message:"Failed to render Mermaid chart";l(O);}}finally{d(false);}})();},[e,o,y,M,x]),!(M||c||g))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:I});if(i&&!c&&!g)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:I,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&&!c&&!g){let B=()=>h(S=>S+1);return b?jsx("div",{ref:I,children:jsx(b,{chart:e,error:a,retry:B})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:I,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 j=c||g;return jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:I,children:jsx(fr,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),contentSize:u,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:j},role:"img"})})})};export{hi as A,Wt as B,bi as C,mr as D,vi as E,ht as a,Ae as b,yt as c,mo as d,Ct as e,xt as f,ic as g,vt as h,Ue as i,Ye as j,Tt as k,Qe as l,L as m,Wo as n,Ne as o,ve as p,Et as q,ot as r,Pe as s,ze as t,Ys as u,$e as v,it as w,Vn as x,ct as y,$t as z};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import {m,g,d}from'./chunk-4TCVUZ7E.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var x=({code:s,language:e,maxHeight:h,raw:t,className:m$1,startLine:d$1,lineNumbers:a,...p})=>{let{shikiTheme:r}=useContext(m),i=g(),[c,o]=useState(t);return useEffect(()=>{if(!i){o(t);return}let l=i.highlight({code:s,language:e,themes:r},H=>{o(H);});l&&o(l);},[s,e,r,i,t]),jsx(d,{className:m$1,language:e,lineNumbers:a,maxHeight:h,result:c,startLine:d$1,...p})};export{x as HighlightedCodeBlockBody};
2
+ import {m,g,d}from'./chunk-FBI6MPO2.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var x=({code:s,language:e,maxHeight:h,raw:t,className:m$1,startLine:d$1,lineNumbers:a,...p})=>{let{shikiTheme:r}=useContext(m),i=g(),[c,o]=useState(t);return useEffect(()=>{if(!i){o(t);return}let l=i.highlight({code:s,language:e,themes:r},H=>{o(H);});l&&o(l);},[s,e,r,i,t]),jsx(d,{className:m$1,language:e,lineNumbers:a,maxHeight:h,result:c,startLine:d$1,...p})};export{x as HighlightedCodeBlockBody};
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export{D as Block,h as CodeBlock,e as CodeBlockContainer,j as CodeBlockCopyButton,k as CodeBlockDownloadButton,f as CodeBlockHeader,l as CodeBlockSkeleton,E as Streamdown,m as StreamdownContext,t as TableCopyDropdown,u as TableDownloadButton,v as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,B as defaultRehypePlugins,C as defaultRemarkPlugins,i as defaultTranslations,x as defaultUrlTransform,w as detectTextDirection,r as escapeMarkdownTableCell,o as extractTableDataFromElement,A as normalizeHtmlIndentation,y as parseMarkdownIntoBlocks,z as parseMarkdownIntoBlocksIncremental,p as tableDataToCSV,s as tableDataToMarkdown,q as tableDataToTSV,c as useIsCodeFenceIncomplete}from'./chunk-4TCVUZ7E.js';
2
+ export{D as Block,h as CodeBlock,e as CodeBlockContainer,j as CodeBlockCopyButton,k as CodeBlockDownloadButton,f as CodeBlockHeader,l as CodeBlockSkeleton,E as Streamdown,m as StreamdownContext,t as TableCopyDropdown,u as TableDownloadButton,v as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,B as defaultRehypePlugins,C as defaultRemarkPlugins,i as defaultTranslations,x as defaultUrlTransform,w as detectTextDirection,r as escapeMarkdownTableCell,o as extractTableDataFromElement,A as normalizeHtmlIndentation,y as parseMarkdownIntoBlocks,z as parseMarkdownIntoBlocksIncremental,p as tableDataToCSV,s as tableDataToMarkdown,q as tableDataToTSV,c as useIsCodeFenceIncomplete}from'./chunk-FBI6MPO2.js';
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export{n as Mermaid}from'./chunk-FBI6MPO2.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/streamdown",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -49,8 +49,8 @@
49
49
  "shiki": "^3.19.0",
50
50
  "tsup": "^8.5.1",
51
51
  "vitest": "^4.0.15",
52
- "@streamdown/math": "npm:@lofcz/streamdown-math@1.0.3",
53
52
  "@streamdown/cjk": "npm:@lofcz/streamdown-cjk@1.0.3",
53
+ "@streamdown/math": "npm:@lofcz/streamdown-math@1.0.3",
54
54
  "@streamdown/mermaid": "npm:@lofcz/streamdown-mermaid@1.0.2"
55
55
  },
56
56
  "peerDependencies": {
package/styles.css CHANGED
@@ -52,6 +52,12 @@
52
52
  var(--sd-marker-easing, ease) var(--sd-marker-delay, 0ms) both;
53
53
  }
54
54
 
55
+ .markdown-alert-title .octicon {
56
+ display: inline-block;
57
+ vertical-align: text-bottom;
58
+ fill: currentColor;
59
+ }
60
+
55
61
  @supports (background: color-mix(in oklab, red 10%, transparent)) {
56
62
  .markdown-alert-note {
57
63
  background-color: color-mix(
@@ -1,28 +0,0 @@
1
- "use client";
2
- import {createContext,memo,useContext,useRef,useEffect,useMemo,lazy,isValidElement,useId,useDeferredValue,cloneElement,createElement,useState,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import Hn from'rehype-raw';import ir,{defaultSchema}from'rehype-sanitize';import di from'remark-gfm';import mi from'remend';import {visitParents,SKIP}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 xa from'remark-parse';import va from'remark-rehype';import {unified}from'unified';import {visit}from'unist-util-visit';import {Lexer}from'marked';var yr=300,wr="300px",Cr=500;function Qt(e={}){let{immediate:t=false,debounceDelay:o=yr,rootMargin:n=wr,idleTimeout:r=Cr}=e,[s,a]=useState(false),l=useRef(null),i=useRef(null),d=useRef(null),c=useMemo(()=>m=>{let g=Date.now();return window.setTimeout(()=>{m({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-g))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(m,g)=>window.requestIdleCallback(m,g):c,[c]),u=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?m=>window.cancelIdleCallback(m):m=>{clearTimeout(m);},[]);return useEffect(()=>{if(t){a(true);return}let m=l.current;if(!m)return;i.current&&(clearTimeout(i.current),i.current=null),d.current&&(u(d.current),d.current=null);let g=()=>{i.current&&(clearTimeout(i.current),i.current=null),d.current&&(u(d.current),d.current=null);},f=x=>{d.current=p(h=>{h.timeRemaining()>0||h.didTimeout?(a(true),x.disconnect()):d.current=p(()=>{a(true),x.disconnect();},{timeout:r/2});},{timeout:r});},y=x=>{g(),i.current=window.setTimeout(()=>{var M,j;let h=x.takeRecords();(h.length===0||(j=(M=h.at(-1))==null?void 0:M.isIntersecting)!=null&&j)&&f(x);},o);},b=(x,h)=>{x.isIntersecting?y(h):g();},k=new IntersectionObserver(x=>{for(let h of x)b(h,k);},{rootMargin:n,threshold:0});return k.observe(m),()=>{i.current&&clearTimeout(i.current),d.current&&u(d.current),k.disconnect();}},[t,o,n,r,u,p]),{shouldRender:s,containerRef:l}}function bt(){return {current:0}}var to=/\s/,eo=/^\s+$/,vr=new Set(["code","pre","svg","math","annotation"]),Tr=new Set(["svg","math","annotation"]),Pr=new Set(["img","hr"]),He=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",oo=(e,t)=>{let o=t?Tr:vr;return e.some(n=>He(n)&&o.has(n.tagName))},Ir=e=>{for(let t=e.length-1;t>=0;t--){let o=e[t];if(He(o)&&o.tagName==="li")return o}},Mr=(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}`;},Nr=new Set(["ul","ol","li"]),no=e=>{for(let t of e.children)if(He(t)){if(t.tagName==="input")return t;if(Nr.has(t.tagName))continue;let o=no(t);if(o)return o}},ro=(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`;},Lr=(e,t,o,n)=>{let r=no(e);r&&ro(r,t,o,n);},Sr=(e,t,o,n,r)=>{if(oo(t,n.animateCodeBlocks))return;let s=n.prevContentLength,a=s>0&&r.count<s,l=a?0:(n.startIndex+r.newIndex++)*o.stagger;ro(e,o,a?0:o.duration,l);},Rr=e=>{let t=[],o="",n=false;for(let r of e){let s=to.test(r);s!==n&&o&&(t.push(o),o=""),o+=r,n=s;}return o&&t.push(o),t},Er=e=>{let t=[],o="";for(let n of e)to.test(n)?o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&t.push(o),t},Hr=(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:${s}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:a},children:[{type:"text",value:e}]}},Ar=(e,t,o,n,r)=>{var b;let s=t.at(-1);if(!(s&&"children"in s))return;if(oo(t,n.animateCodeBlocks))return SKIP;let a=s,l=a.children.indexOf(e);if(l===-1)return;let i=e.value;if(!i.trim()){r.count+=i.length;return}let d=o.sep==="char"?Er(i):Rr(i),c=t.some(k=>He(k)&&k.tagName==="a"),p=d;if(o.sep==="word"&&c){let k=[];for(let x of d)eo.test(x)&&k.length>0?k[k.length-1]+=x:k.push(x);p=k;}let u=n.prevContentLength,m=Ir(t),g=!!(m&&!((b=m.properties)!=null&&b["data-sd-animate-marker"])),f=false,y=p.map(k=>{let x=r.count;if(r.count+=k.length,eo.test(k))return {type:"text",value:k};let h=u>0&&x<u,I=h?0:(n.startIndex+r.newIndex++)*o.stagger;if(m&&g&&!f){let M=h?0:o.duration;Mr(m,M,I,o.easing),Lr(m,o,M,I),f=true;}return Hr(k,o.animation,o.duration,o.easing,h,I)});return a.children.splice(l,1,...y),l+y.length},Dr=0;function Ae(e){var s,a,l,i,d;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",cursor:e==null?void 0:e.cursor,duration:(a=e==null?void 0:e.duration)!=null?a:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(d=e==null?void 0:e.stagger)!=null?d:40},o={animateCodeBlocks:false,prevContentLength:0,lastRenderCharCount:0,lastRenderNewWordCount:0,startIndex:0},n=Dr++,r=()=>c=>{let p={count:0,newIndex:0};t.cursor&&(o.startIndex=t.cursor.current),visitParents(c,u=>u.type==="text"||He(u)&&Pr.has(u.tagName),(u,m)=>{if(u.type==="text")return Ar(u,m,t,o,p);Sr(u,m,t,o,p);}),o.lastRenderCharCount=p.count,o.lastRenderNewWordCount=p.newIndex,t.cursor&&(t.cursor.current+=p.newIndex),o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(c){o.animateCodeBlocks=c;},setPrevContentLength(c){o.prevContentLength=c;},setStartIndex(c){o.startIndex=c;},getLastRenderCharCount(){let c=o.lastRenderCharCount;return o.lastRenderCharCount=0,c},getLastRenderNewWordCount(){let c=o.lastRenderNewWordCount;return o.lastRenderNewWordCount=0,c}}}Ae();var ht=createContext(false),yt=()=>useContext(ht);var De=(...e)=>twMerge(clsx(e)),Ke=e=>{if(e!==void 0)return typeof e=="number"?!Number.isFinite(e)||e<=0?void 0:`${e}px`:e},Vr=(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(" ")},io=e=>e?(...t)=>Vr(e,twMerge(clsx(t))):De,oe=(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 Xe=createContext(De),C=()=>useContext(Xe);var $r=De("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"),Wr=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},mo=memo(({children:e,result:t,language:o,className:n,maxHeight:r,startLine:s,lineNumbers:a=true,...l})=>{let i=C(),{isAnimating:d}=useContext(L),c=useRef(null),p=useRef(true),u=Ke(r);useEffect(()=>{let f=c.current;if(!(f&&u))return;let y=()=>{let b=f.scrollHeight-f.scrollTop-f.clientHeight<8;p.current=b;};return f.addEventListener("scroll",y,{passive:true}),()=>f.removeEventListener("scroll",y)},[u]),useEffect(()=>{let f=c.current;f&&u&&d&&p.current&&f.scrollTo({top:f.scrollHeight,behavior:"instant"});},[d,u]),useEffect(()=>{d||(p.current=true);},[d]);let m=useMemo(()=>i($r),[i]),g=useMemo(()=>{let f={};return t.bg&&(f["--sdm-bg"]=t.bg),t.fg&&(f["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(f,Wr(t.rootStyle)),f},[t.bg,t.fg,t.rootStyle]);return jsx("div",{className:i(n,u?"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",ref:c,style:u?{maxHeight:u}:void 0,...l,children:jsx("pre",{className:i(n,"bg-[var(--sdm-bg,inherit)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]"),style:g,children:jsx("code",{className:a?i("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&s&&s>1?{counterReset:`line ${s-1}`}:void 0,children:t.tokens.map((f,y)=>jsx("span",{className:a?m:void 0,children:f.length===0||f.length===1&&f[0].content===""?`
3
- `:f.map((b,k)=>{let x={},h=!!b.bgColor;if(b.color&&(x["--sdm-c"]=b.color),b.bgColor&&(x["--sdm-tbg"]=b.bgColor),b.htmlStyle)for(let[I,M]of Object.entries(b.htmlStyle))I==="color"?x["--sdm-c"]=M:I==="background-color"?(x["--sdm-tbg"]=M,h=true):x[I]=M;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",h&&"bg-[var(--sdm-tbg)]",h&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:x,...b.htmlAttrs,children:b.content},k)})},y))})})})},(e,t)=>e.maxHeight===t.maxHeight&&e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers);var Ct=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let s=C();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 kt=createContext({code:""}),Ge=()=>useContext(kt);var xt=({language:e})=>{let t=C();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 Jr=e=>{let t=e.length;for(;t>0&&e[t-1]===`
4
- `;)t--;return e.slice(0,t)},Yr=lazy(()=>import('./highlighted-body-OG2RQPEZ.js').then(e=>({default:e.HighlightedCodeBlockBody}))),vt=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,lineNumbers:a,...l})=>{let i=C(),{codeBlockMaxHeight:d}=useContext(L),c=useMemo(()=>Jr(e),[e]),p=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:c.split(`
5
- `).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[c]);return jsx(kt.Provider,{value:{code:e},children:jsxs(Ct,{isIncomplete:r,language:t,children:[jsx(xt,{language:t}),n?jsx("div",{className:i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("div",{className:i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:n})}):null,jsx(Suspense,{fallback:jsx(mo,{className:o,language:t,lineNumbers:a,maxHeight:d,result:p,startLine:s,...l}),children:jsx(Yr,{className:o,code:c,language:t,lineNumbers:a,maxHeight:d,raw:p,startLine:s,...l})})]})})};var fo=e=>jsx("svg",{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"})}),go=e=>jsx("svg",{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"})}),bo=e=>jsx("svg",{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"})}),ho=e=>jsxs("svg",{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"})]}),yo=e=>jsx("svg",{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"})}),wo=e=>jsx("svg",{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"})}),Co=e=>jsx("svg",{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"})}),ko=e=>jsx("svg",{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"})}),xo=e=>jsx("svg",{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"})}),vo=e=>jsx("svg",{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 Oe={CheckIcon:fo,CopyIcon:go,DownloadIcon:bo,ExternalLinkIcon:ko,Loader2Icon:ho,Maximize2Icon:yo,RotateCcwIcon:wo,XIcon:Co,ZoomInIcon:xo,ZoomOutIcon:vo},Po=createContext(Oe),ns=(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])},Tt=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...Oe,...e}:Oe);ns(o.current,e)||(o.current=e,n.current=e?{...Oe,...e}:Oe);let r=n.current;return jsx(Po.Provider,{value:r,children:t})},A=()=>useContext(Po);var Ue={copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",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"},Je=createContext(Ue),_=()=>useContext(Je);var Ye=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let l=C(),[i,d]=useState(false),c=useRef(0),{code:p}=Ge(),{isAnimating:u}=useContext(L),m=_(),g=s!=null?s:p,f=async()=>{var k;if(typeof window=="undefined"||!((k=navigator==null?void 0:navigator.clipboard)!=null&&k.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(g),d(!0),e==null||e(),c.current=window.setTimeout(()=>d(!1),o));}catch(x){t==null||t(x);}};useEffect(()=>()=>{window.clearTimeout(c.current);},[]);let y=A(),b=i?y.CheckIcon:y.CopyIcon;return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:u,onClick:f,title:m.copyCode,type:"button",...a,children:n!=null?n:jsx(b,{size:14})})};var Mo={"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"},Pt=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let l=C(),{code:i}=Ge(),{isAnimating:d}=useContext(L),c=_(),p=A(),u=s!=null?s:i,g=`file.${o&&o in Mo?Mo[o]:"txt"}`,f="text/plain",y=()=>{try{oe(g,u,f),e==null||e();}catch(b){t==null||t(b);}};return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:d,onClick:y,title:c.downloadFile,type:"button",...a,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var Qe=()=>{let{Loader2Icon:e}=A(),t=C();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 Ve=0,me=()=>{Ve+=1,Ve===1&&(document.body.style.overflow="hidden");},ue=()=>{Ve=Math.max(0,Ve-1),Ve===0&&(document.body.style.overflow="");};var fs=["github-light","github-dark"],gs={enabled:true},bs={codeBlockMaxHeight:400,shikiTheme:fs,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,linkSafety:gs,tableMaxHeight:300},L=createContext(bs);var Cs=/\.[^/.]+$/,So=(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},Ro=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,onClick:a,...l})=>{let{DownloadIcon:i,XIcon:d}=A(),c=C(),p=useRef(null),[u,m]=useState(false),[g,f]=useState(false),[y,b]=useState(false),{controls:k}=useContext(L),x=_(),h=So(k,"download"),I=So(k,"fullscreen"),M=l.width!=null||l.height!=null,j=h&&(u||M)&&!g,B=g&&!M,S=I&&!!o&&!g&&u;useEffect(()=>{let N=p.current;if(N!=null&&N.complete){let te=N.naturalWidth>0;m(te),f(!te);}},[]),useEffect(()=>{if(!y)return;me();let N=te=>{te.key==="Escape"&&b(false);};return document.addEventListener("keydown",N),()=>{document.removeEventListener("keydown",N),ue();}},[y]);let V=useCallback(N=>{m(true),f(false),r==null||r(N);},[r]),Q=useCallback(N=>{m(false),f(true),s==null||s(N);},[s]),F=useCallback(()=>{S&&b(true);},[S]),q=useCallback(()=>{b(false);},[]),ee=useCallback(N=>{a==null||a(N),!N.defaultPrevented&&F();},[a,F]),U=async N=>{if(N.stopPropagation(),!!o)try{let J=await(await fetch(o)).blob(),Z=new URL(o,window.location.origin).pathname.split("/").pop()||"",he=Z.split(".").pop(),re=Z.includes(".")&&he!==void 0&&he.length<=4,O="";if(re)O=Z;else {let T=J.type,R="png";T.includes("jpeg")||T.includes("jpg")?R="jpg":T.includes("png")?R="png":T.includes("svg")?R="svg":T.includes("gif")?R="gif":T.includes("webp")&&(R="webp"),O=`${(n||Z||"image").replace(Cs,"")}.${R}`;}oe(O,J,J.type);}catch(te){window.open(o,"_blank");}};return o?o==="streamdown:incomplete-image"?jsx("div",{className:c("group relative my-4 inline-block"),"data-incomplete":"true","data-streamdown":"image-wrapper",children:jsx("div",{className:c("h-24 w-48 animate-pulse rounded-lg bg-muted"),"data-streamdown":"image-placeholder"})}):jsxs(Fragment,{children:[jsxs("div",{className:c("group/image not-prose relative my-2 block max-w-full"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:c("m-0 block h-auto max-w-full rounded-lg",S&&"cursor-zoom-in",B&&"hidden",t),"data-streamdown":"image",onClick:ee,onError:Q,onLoad:V,ref:p,src:o,...l}),B&&jsx("span",{className:c("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:x.imageNotAvailable}),j&&jsx("button",{className:c("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:U,title:x.downloadImage,type:"button",children:jsx(i,{size:14})})]}),y?createPortal(jsxs("div",{className:c("fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4"),"data-streamdown":"image-lightbox",onClick:q,onKeyDown:N=>{N.key==="Escape"&&q();},role:"button",tabIndex:0,children:[jsx("button",{className:c("absolute top-4 right-4 z-10 rounded-md p-2 text-white/80 transition-colors hover:bg-white/10 hover:text-white"),onClick:q,title:x.exitFullscreen,type:"button",children:jsx(d,{size:20})}),jsx("div",{onClick:N=>N.stopPropagation(),onKeyDown:N=>N.stopPropagation(),role:"presentation",children:jsx("img",{alt:n,className:c("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:o})})]}),document.body):null]}):null};var Ao=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=A(),i=C(),[d,c]=useState(false),p=_(),u=useCallback(async()=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3);}catch(f){}},[e]),m=useCallback(()=>{n(),o();},[n,o]);if(useEffect(()=>{if(t){me();let f=y=>{y.key==="Escape"&&o();};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),ue();}}},[t,o]),!t||typeof document=="undefined")return null;let g=jsx("div",{className:i("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:i("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:i("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:o,title:p.close,type:"button",children:jsx(l,{size:16})}),jsxs("div",{className:i("flex flex-col gap-2"),children:[jsxs("div",{className:i("flex items-center gap-2 font-semibold text-lg"),children:[jsx(a,{size:20}),jsx("span",{children:p.openExternalLink})]}),jsx("p",{className:i("text-muted-foreground text-sm"),children:p.externalLinkWarning})]}),jsx("div",{className:i("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:i("flex gap-2"),children:[jsx("button",{className:i("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:u,type:"button",children:d?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:p.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:p.copyLink})]})}),jsxs("button",{className:i("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:p.openLink})]})]})]})});return createPortal(g,document.body)};var et=createContext(null),Lt=()=>useContext(et),sc=()=>{var t;let e=Lt();return (t=e==null?void 0:e.code)!=null?t:null},Ie=()=>{var t;let e=Lt();return (t=e==null?void 0:e.mermaid)!=null?t:null};var Do=e=>{var o;let t=Lt();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 Ms=/(<svg\b)/,Vo=/<svg\b[^>]*>/i,Ns=/\bviewBox=(['"])(.*?)\1/i,Ls=/\swidth=(['"]).*?\1/i,Ss=/\sheight=(['"]).*?\1/i,Bo=/\sstyle=(['"])(.*?)\1/i,Oo=/^<svg/i,Rs=/^width\s*:/i,Es=/^height\s*:/i,Hs=/^max-width\s*:/i,As=/[\s,]+/,Ds=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(Ms,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),_o=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},St=e=>{let t=e.match(Vo);if(!t)return null;let n=t[0].match(Ns),r=n==null?void 0:n[2];if(!r)return null;let s=r.trim().split(As).map(i=>Number.parseFloat(i));if(s.length<4||s.slice(0,4).some(Number.isNaN))return null;let a=s[2],l=s[3];return a>0&&l>0?{height:l,width:a}:null},jo=e=>{let t=e.match(Vo);if(!t)return e;try{let o=t[0],n=St(e);if(!n)return e;let{width:r,height:s}=n,a=o.replace(Ls,"").replace(Ss,""),l=a.match(Bo),i=`width:${r}px;height:${s}px;max-width:none;`;if(l){let d=l[1],p=l[2].split(";").map(m=>m.trim()).filter(Boolean).filter(m=>!(Rs.test(m)||Es.test(m)||Hs.test(m))).join(";"),u=`${i}${p?`${p};`:""}`;a=a.replace(Bo,` style=${d}${u}${d}`);}else a=a.replace(Oo,`<svg style="${i}"`);return a=a.replace(Oo,`<svg width="${r}" height="${s}"`),e.replace(o,a)}catch(o){return e}},Fo=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a=Ds(e),l="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let d=document.createElement("canvas"),c=i.width*o,p=i.height*o;d.width=c,d.height=p;let u=d.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(i,0,0,c,p),d.toBlob(m=>{if(!m){s(new Error("Failed to create PNG blob"));return}r(m);},"image/png");},i.onerror=()=>s(new Error("Failed to load SVG image")),i.src=l;})};var tt=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=C(),[l,i]=useState(false),d=useRef(null),{isAnimating:c}=useContext(L),p=A(),u=Ie(),m=_(),g=async f=>{try{if(f==="mmd"){oe("diagram.mmd",e,"text/plain"),i(!1),n==null||n(f);return}if(!u){s==null||s(new Error("Mermaid plugin not available"));return}let y=u.getMermaid(r),b=e.split("").reduce((I,M)=>(I<<5)-I+M.charCodeAt(0)|0,0),k=`mermaid-${Math.abs(b)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:x}=await y.render(k,e);if(!x){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let h=_o(x);if(f==="svg"){oe("diagram.svg",h,"image/svg+xml"),i(!1),n==null||n(f);return}if(f==="png"){let I=await Fo(h);oe("diagram.png",I,"image/png"),n==null||n(f),i(!1);return}}catch(y){s==null||s(y);}};return useEffect(()=>{let f=y=>{let b=y.composedPath();d.current&&!b.includes(d.current)&&i(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f);}},[]),jsxs("div",{className:a("relative"),ref:d,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:c,onClick:()=>i(!l),title:m.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{size:14})}),l?jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("svg"),title:m.downloadDiagramAsSvg,type:"button",children:m.mermaidFormatSvg}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("png"),title:m.downloadDiagramAsPng,type:"button",children:m.mermaidFormatPng}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("mmd"),title:m.downloadDiagramAsMmd,type:"button",children:m.mermaidFormatMmd})]}):null]})};var qo=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=A(),i=C(),[d,c]=useState(false),{isAnimating:p,controls:u}=useContext(L),m=_(),g=(()=>{if(typeof u=="boolean")return u;let b=u.mermaid;return b===false?false:b===true||b===void 0?true:b.panZoom!==false})(),f=(()=>{if(typeof u=="boolean")return u;let b=u.mermaid;return b===false?false:b===true||b===void 0?true:b.download!==false})(),y=()=>{c(!d);};return useEffect(()=>{if(d){me();let b=k=>{k.key==="Escape"&&c(false);};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),ue();}}},[d]),useEffect(()=>{d?o==null||o():n&&n();},[d,o,n]),jsxs(Fragment,{children:[jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:p,onClick:y,title:m.viewFullscreen,type:"button",...s,children:jsx(a,{size:14})}),d?createPortal(jsxs("div",{"aria-label":m.viewFullscreen,"aria-modal":"true",className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"mermaid-fullscreen",onClick:y,onKeyDown:b=>{b.key==="Escape"&&y();},role:"dialog",children:[jsxs("div",{className:i("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:[f?jsx(tt,{chart:e,config:t}):null,jsx("button",{className:i("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:y,title:m.exitFullscreen,type:"button",children:jsx(l,{size:20})})]}),jsx("div",{className:i("flex size-full items-center justify-center p-4"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:jsx(Wo,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:g})})]}),document.body):null]})};var Me=e=>{var s,a;let t=[],o=[],n=e.querySelectorAll("thead th");for(let l of n)t.push(((s=l.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let l of r){let i=[],d=l.querySelectorAll("td");for(let c of d)i.push(((a=c.textContent)==null?void 0:a.trim())||"");o.push(i);}return {headers:t,rows:o}},xe=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false,d=false;for(let c of l){if(c==='"'){i=true,d=true;break}(c===","||c===`
6
- `)&&(i=true);}return i?d?`"${l.replace(/"/g,'""')}"`:`"${l}"`:l},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 l of o)s[a]=l.map(n).join(","),a+=1;return s.join(`
7
- `)},Et=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false;for(let c of l)if(c===" "||c===`
8
- `||c==="\r"){i=true;break}if(!i)return l;let d=[];for(let c of l)c===" "?d.push("\\t"):c===`
9
- `?d.push("\\n"):c==="\r"?d.push("\\r"):d.push(c);return d.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 l of o)s[a]=l.map(n).join(" "),a+=1;return s.join(`
10
- `)},ot=e=>{let t=false;for(let n of e)if(n==="\\"||n==="|"){t=true;break}if(!t)return e;let o=[];for(let n of e)n==="\\"?o.push("\\\\"):n==="|"?o.push("\\|"):o.push(n);return o.join("")},ve=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),r=0,s=t.map(l=>ot(l));n[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let l=0;l<t.length;l+=1)a[l]="---";n[r]=`| ${a.join(" | ")} |`,r+=1;for(let l of o)if(l.length<t.length){let i=new Array(t.length);for(let d=0;d<t.length;d+=1)i[d]=d<l.length?ot(l[d]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(d=>ot(d));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
11
- `)};var ze=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=C(),[a,l]=useState(false),[i,d]=useState(false),c=useRef(null),p=useRef(0),{isAnimating:u}=useContext(L),m=_(),g=async b=>{var k,x;if(typeof window=="undefined"||!((k=navigator==null?void 0:navigator.clipboard)!=null&&k.write)){n==null||n(new Error("Clipboard API not available"));return}try{let h=(x=c.current)==null?void 0:x.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),I=h==null?void 0:h.querySelector("table");if(!I){n==null||n(new Error("Table not found"));return}let M=Me(I),S=({csv:xe,tsv:Et,md:ve}[b]||ve)(M),V=new ClipboardItem({"text/plain":new Blob([S],{type:"text/plain"}),"text/html":new Blob([I.outerHTML],{type:"text/html"})});await navigator.clipboard.write([V]),d(!0),l(!1),o==null||o(b),p.current=window.setTimeout(()=>d(!1),r);}catch(h){n==null||n(h);}};useEffect(()=>{let b=k=>{let x=k.composedPath();c.current&&!x.includes(c.current)&&l(false);};return document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b),window.clearTimeout(p.current);}},[]);let f=A(),y=i?f.CheckIcon:f.CopyIcon;return jsxs("div",{className:s("relative"),ref:c,children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>l(!a),title:m.copyTable,type:"button",children:e!=null?e:jsx(y,{height:14,width:14})}),a?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("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:()=>g("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:()=>g("tsv"),title:m.copyTableAsTsv,type:"button",children:m.tableFormatTsv})]}):null]})};var Gs=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:s})=>{let a=C(),{isAnimating:l}=useContext(L),i=_(),d=A(),c=p=>{try{let m=p.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),g=m==null?void 0:m.querySelector("table");if(!g){n==null||n(new Error("Table not found"));return}let f=Me(g),y="",b="",k="";switch(r){case "csv":y=xe(f),b="text/csv",k="csv";break;case "markdown":y=ve(f),b="text/markdown",k="md";break;default:y=xe(f),b="text/csv",k="csv";}oe(`${s||"table"}.${k}`,y,b),o==null||o();}catch(u){n==null||n(u);}};return jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:c,title:r==="csv"?i.downloadTableAsCsv:i.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d.DownloadIcon,{size:14})})},$e=({children:e,className:t,onDownload:o,onError:n})=>{let r=C(),[s,a]=useState(false),l=useRef(null),{isAnimating:i}=useContext(L),d=_(),c=A(),p=u=>{var m;try{let g=(m=l.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=g==null?void 0:g.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let y=Me(f),b=u==="csv"?xe(y):ve(y);oe(`table.${u==="csv"?"csv":"md"}`,b,u==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(u);}catch(g){n==null||n(g);}};return useEffect(()=>{let u=m=>{let g=m.composedPath();l.current&&!g.includes(l.current)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[]),jsxs("div",{className:r("relative"),ref:l,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:i,onClick:()=>a(!s),title:d.downloadTable,type:"button",children:e!=null?e:jsx(c.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:()=>p("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:()=>p("markdown"),title:d.downloadTableAsMarkdown,type:"button",children:d.tableFormatMarkdown})]}):null]})};var Jo=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=A(),a=C(),[l,i]=useState(false),{isAnimating:d}=useContext(L),c=_(),p=()=>{i(true);},u=()=>{i(false);};return useEffect(()=>{if(l){me();let m=g=>{g.key==="Escape"&&i(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),ue();}}},[l]),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:d,onClick:p,title:c.viewFullscreen,type:"button",children:jsx(r,{size:14})}),l?createPortal(jsx("div",{"aria-label":c.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:u,onKeyDown:m=>{m.key==="Escape"&&u();},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(ze,{}):null,n?jsx($e,{}):null,jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:u,title:c.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})})]})}),document.body):null]})};var en=({children:e,className:t,maxHeight:o,showControls:n,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...l})=>{let i=C(),{isAnimating:d}=useContext(L),c=useRef(null),p=useRef(true),u=Ke(o);useEffect(()=>{let b=c.current;if(!(b&&u))return;let k=()=>{let x=b.scrollHeight-b.scrollTop-b.clientHeight<8;p.current=x;};return b.addEventListener("scroll",k,{passive:true}),()=>b.removeEventListener("scroll",k)},[u]),useEffect(()=>{let b=c.current;b&&u&&d&&p.current&&b.scrollTo({top:b.scrollHeight,behavior:"instant"});}),useEffect(()=>{d||(p.current=true);},[d]);let m=n&&r,g=n&&s,f=n&&a,y=m||g||f;return jsxs("div",{className:i("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[y?jsxs("div",{className:i("flex items-center justify-end gap-1"),children:[m?jsx(ze,{}):null,g?jsx($e,{}):null,f?jsx(Jo,{showCopy:m,showDownload:g,children:e}):null]}):null,jsx("div",{className:i("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),ref:c,style:u?{maxHeight:u}:void 0,children:jsx("table",{className:i("w-full table-fixed divide-y divide-border",t),"data-streamdown":"table",...l,children:e})})]})};var aa=/startLine=(\d+)/,ia=/\bnoLineNumbers\b/,la=lazy(()=>import('./mermaid-C4WZAPX4.js').then(e=>({default:e.Mermaid}))),ca=/language-([^\s]+)/;function at(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let o=e.position.start,n=t.position.start,r=e.position.end,s=t.position.end;return (o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(o==null?void 0:o.offset)===(n==null?void 0:n.offset)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)&&(r==null?void 0:r.offset)===(s==null?void 0:s.offset)}function D(e,t){return e.className===t.className&&at(e.node,t.node)}var Ot=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Bt=(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},on=(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},nt=(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},qe=createContext({depth:0,ulDepth:0,isUnordered:false}),da={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},Vt=memo(({children:e,className:t,node:o,...n})=>{let r=C(),{depth:s,ulDepth:a}=useContext(qe),l=useMemo(()=>({depth:s+1,ulDepth:a,isUnordered:false}),[s,a]);return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"ordered-list",...n,children:jsx(qe.Provider,{value:l,children:e})})},(e,t)=>D(e,t));Vt.displayName="MarkdownOl";var rn=memo(({children:e,className:t,node:o,...n})=>{var f;let r=C(),{depth:s,ulDepth:a,isUnordered:l}=useContext(qe),{listStyle:i}=useContext(L),d=da[i],c=l&&a>0?d[(a-1)%d.length]:void 0,p=Array.isArray(e)?e.filter(y=>y!==`
12
- `&&y!==""):[e],u=p[0],m=isValidElement(u)?(f=u.props.node)==null?void 0:f.tagName:void 0,g=p.length===1&&isValidElement(u)&&(u.type==="p"||m==="p")?u.props.children:e;return jsx("li",{className:r("py-1 [&>p]:inline",c,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...n,children:g})},(e,t)=>e.className===t.className&&at(e.node,t.node));rn.displayName="MarkdownLi";var sn=memo(({children:e,className:t,node:o,...n})=>{let r=C(),{depth:s,ulDepth:a}=useContext(qe),l=useMemo(()=>({depth:s+1,ulDepth:a+1,isUnordered:true}),[s,a]);return jsx("ul",{className:r("list-inside whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"unordered-list",...n,children:jsx(qe.Provider,{value:l,children:e})})},(e,t)=>D(e,t));sn.displayName="MarkdownUl";var an=memo(({className:e,node:t,...o})=>{let n=C();return jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>D(e,t));an.displayName="MarkdownHr";var ln=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>D(e,t));ln.displayName="MarkdownStrong";var ma=({children:e,className:t,href:o,node:n,...r})=>{let s=C(),{linkSafety:a}=useContext(L),[l,i]=useState(false),d=o==="streamdown:incomplete-link",c=useCallback(async g=>{if(!(!(a!=null&&a.enabled&&o)||d)){if(g.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[a,o,d]),p=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),u=useCallback(()=>{i(false);},[]),m={url:o!=null?o:"",isOpen:l,onClose:u,onConfirm:p};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":d,"data-streamdown":"link",onClick:c,type:"button",children:e}),a.renderModal?a.renderModal(m):jsx(Ao,{...m})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":d,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},cn=memo(ma,(e,t)=>D(e,t)&&e.href===t.href);cn.displayName="MarkdownA";var dn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>D(e,t));dn.displayName="MarkdownH1";var mn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>D(e,t));mn.displayName="MarkdownH2";var un=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>D(e,t));un.displayName="MarkdownH3";var pn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>D(e,t));pn.displayName="MarkdownH4";var fn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>D(e,t));fn.displayName="MarkdownH5";var gn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>D(e,t));gn.displayName="MarkdownH6";var bn=memo(({children:e,className:t,node:o,...n})=>{let{controls:r,tableMaxHeight:s}=useContext(L),a=Ot(r,"table"),l=Bt(r,"copy"),i=Bt(r,"download"),d=Bt(r,"fullscreen");return jsx(en,{className:t,maxHeight:s,showControls:a,showCopy:l,showDownload:i,showFullscreen:d,...n,children:e})},(e,t)=>D(e,t));bn.displayName="MarkdownTable";var hn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>D(e,t));hn.displayName="MarkdownThead";var yn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>D(e,t));yn.displayName="MarkdownTbody";var wn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>D(e,t));wn.displayName="MarkdownTr";var Cn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("th",{className:r("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>D(e,t));Cn.displayName="MarkdownTh";var kn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>D(e,t));kn.displayName="MarkdownTd";var xn=memo(({children:e,className:t,node:o,...n})=>{let r=C();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)=>D(e,t));xn.displayName="MarkdownBlockquote";var vn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>D(e,t));vn.displayName="MarkdownSup";var Tn=memo(({children:e,className:t,node:o,...n})=>{let r=C(),s=t==null?void 0:t.includes("markdown-alert");return (t==null?void 0:t.includes("markdown-alert-title"))?jsx("div",{className:r("mb-2 font-semibold",t),...n,children:e}):s?jsx("div",{className:r("my-4 rounded-r-md border-muted-foreground/30 border-l-4 bg-muted/40 p-4 [&>p]:my-0",t),...n,children:e}):jsx("div",{className:r(t),...n,children:e})},(e,t)=>D(e,t));Tn.displayName="MarkdownDiv";var Pn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>D(e,t));Pn.displayName="MarkdownSub";var In=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=i=>{var u,m;if(!isValidElement(i))return false;let d=Array.isArray(i.props.children)?i.props.children:[i.props.children],c=false,p=false;for(let g of d)if(g){if(typeof g=="string")g.trim()!==""&&(c=true);else if(isValidElement(g))if(((u=g.props)==null?void 0:u["data-footnote-backref"])!==void 0)p=true;else {let f=Array.isArray(g.props.children)?g.props.children:[g.props.children];for(let y of f){if(typeof y=="string"&&y.trim()!==""){c=true;break}if(isValidElement(y)&&((m=y.props)==null?void 0:m["data-footnote-backref"])===void 0){c=true;break}}}}return p&&!c},a=Array.isArray(e)?e.map(i=>{if(!isValidElement(i))return i;if(i.type===Vt){let c=(Array.isArray(i.props.children)?i.props.children:[i.props.children]).filter(p=>!s(p));return c.length===0?null:{...i,props:{...i.props,children:c}}}return i}):e;return (Array.isArray(a)?a.some(i=>i!==null):a!==null)?jsx("section",{className:t,...n,children:a}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>D(e,t));In.displayName="MarkdownSection";var ua=({node:e,className:t,children:o,...n})=>{var B,S;let r=C(),s=!("data-block"in n),{mermaid:a,controls:l,lineNumbers:i}=useContext(L),d=Ie(),c=yt(),p=t==null?void 0:t.match(ca),u=(B=p==null?void 0:p.at(1))!=null?B:"",m=Do(u);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=(S=e==null?void 0:e.properties)==null?void 0:S.metastring,f=g==null?void 0:g.match(aa),y=f?Number.parseInt(f[1],10):void 0,b=y!==void 0&&y>=1?y:void 0,x=!(g?ia.test(g):false)&&i!==false,h="";if(isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?h=o.props.children:typeof o=="string"&&(h=o),m){let V=m.component;return jsx(Suspense,{fallback:jsx(Qe,{}),children:jsx(V,{code:h,isIncomplete:c,language:u,meta:g})})}if(u==="mermaid"&&d){let V=Ot(l,"mermaid"),Q=nt(l,"download"),F=nt(l,"copy"),q=nt(l,"fullscreen"),ee=nt(l,"panZoom"),U=V&&(Q||F||q);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-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"})}),U?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:[Q?jsx(tt,{chart:h,config:a==null?void 0:a.config}):null,F?jsx(Ye,{code:h}):null,q?jsx(qo,{chart:h,config:a==null?void 0:a.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(la,{chart:h,config:a==null?void 0:a.config,showControls:ee})})]})})}let I=Ot(l,"code"),M=on(l,"download"),j=on(l,"copy");return jsx(vt,{className:t,code:h,isIncomplete:c,language:u,lineNumbers:x,startLine:b,children:I?jsxs(Fragment,{children:[M?jsx(Pt,{code:h,language:u}):null,j?jsx(Ye,{}):null]}):null})},Mn=memo(ua,(e,t)=>e.className===t.className&&at(e.node,t.node));Mn.displayName="MarkdownCode";var Nn=memo(Ro,(e,t)=>e.className===t.className&&at(e.node,t.node));Nn.displayName="MarkdownImg";var Ln=memo(({children:e,node:t,...o})=>{let r=(Array.isArray(e)?e:[e]).filter(s=>s!=null&&s!=="");if(r.length===1&&isValidElement(r[0])){let s=r[0].props.node,a=s==null?void 0:s.tagName;if(a==="img")return jsx(Fragment,{children:e});if(a==="code"&&"data-block"in r[0].props)return jsx(Fragment,{children:e})}return jsx("p",{...o,children:e})},(e,t)=>D(e,t));Ln.displayName="MarkdownParagraph";var Sn={ol:Vt,li:rn,ul:sn,hr:an,strong:ln,a:cn,h1:dn,h2:mn,h3:un,h4:pn,h5:fn,h6:gn,table:bn,thead:hn,tbody:yn,tr:wn,th:Cn,td:kn,blockquote:xn,code:Mn,div:Tn,img:Nn,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:vn,sub:Pn,p:Ln,section:In};var pa=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,fa=/\p{L}/u;function it(e){let t=e.replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,"");for(let o of t){if(pa.test(o))return "rtl";if(fa.test(o))return "ltr"}return "ltr"}var ga=/^[ \t]{0,3}(`{3,}|~{3,})/,ba=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,_t=e=>{let t=e.split(`
13
- `),o=null,n=0;for(let r of t){let s=ga.exec(r);if(o===null){if(s){let a=s[1];o=a[0],n=a.length;}}else if(s){let a=s[1],l=a[0],i=a.length;l===o&&i>=n&&(o=null,n=0);}}return o!==null},Rn=e=>{let t=e.split(`
14
- `);for(let o of t){let n=o.trim();if(n.length>0&&n.includes("|")&&ba.test(n))return true}return false};var En=()=>e=>{visit(e,"html",(t,o,n)=>{!n||typeof o!="number"||(n.children[o]={type:"text",value:t.value});});};var An=[],Dn={allowDangerousHtml:true},lt=new WeakMap,Ft=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 p="default";return this.keyCache.set(t,p),p}let a=p=>{if(!p||p.length===0)return "";let u="";for(let m=0;m<p.length;m+=1){let g=p[m];if(m>0&&(u+=","),Array.isArray(g)){let[f,y]=g;if(typeof f=="function"){let b=lt.get(f);b||(b=f.name,lt.set(f,b)),u+=b;}else u+=String(f);u+=":",u+=JSON.stringify(y);}else if(typeof g=="function"){let f=lt.get(g);f||(f=g.name,lt.set(g,f)),u+=f;}else u+=String(g);}return u},l=a(n),i=a(r),d=s?JSON.stringify(s):"",c=`${i}::${l}::${d}`;return this.keyCache.set(t,c),c}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();}},Bn=new Ft,zt=e=>{let t=Ia(e),o=e.children||"",n=t.runSync(t.parse(o),o);return Ea(n,e)},Ia=e=>{let t=Bn.get(e);if(t)return t;let o=Na(e);return Bn.set(e,o),o},Ma=e=>e.some(t=>Array.isArray(t)?t[0]===Hn:t===Hn),Na=e=>{let t=e.rehypePlugins||An,o=e.remarkPlugins||An,n=Ma(t)?o:[...o,En],r=e.remarkRehypeOptions?{...Dn,...e.remarkRehypeOptions}:Dn;return unified().use(xa).use(n).use(va,r).use(t)},On=e=>e,La=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},Sa=(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);}},Ra=(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},Ea=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:l}=t;if(o||n||r||s||l){let d=l||On;visit(e,(c,p,u)=>{if(c.type==="raw"&&u&&typeof p=="number")return La(u,p,s,c.value),p;if(c.type==="element"&&(Sa(c,d),Ra(c,p,u,n,r,o)&&u&&typeof p=="number"))return a&&c.children?u.children.splice(p,1,...c.children):u.children.splice(p,1),p});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var Aa=/\[\^[\w-]{1,200}\](?!:)/,Da=/\[\^[\w-]{1,200}\]:/;var Ba=/<(\w+)[\s>]/,Oa=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Vn=new Map,_n=new Map,zn=e=>{let t=e.toLowerCase(),o=Vn.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Vn.set(t,n),n},Va=e=>{let t=e.toLowerCase(),o=_n.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return _n.set(t,n),n},jn=(e,t)=>{if(Oa.has(t.toLowerCase()))return 0;let o=e.match(zn(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},Fn=(e,t)=>{let o=e.match(Va(t));return o?o.length:0},_a=(e,t)=>{let o=e.match(zn(t));return !!o&&o.every(n=>n.trimEnd().endsWith("/>"))},ja=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},ct=e=>{let t=Aa.test(e),o=Da.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),r=[],s=[],a=false;for(let l of n){let i=l.raw,d=r.length;if(s.length>0){r[d-1]+=i;let c=s.at(-1),p=jn(i,c),u=Fn(i,c);for(let m=0;m<p;m+=1)s.push(c);for(let m=0;m<u;m+=1)s.length>0&&s.at(-1)===c&&s.pop();continue}if(l.type==="html"&&l.block){let c=i.match(Ba);if(c){let p=c[1],u=jn(i,p),m=Fn(i,p);u>m&&!_a(i,p)&&s.push(p);}}if(d>0&&!a){let c=r[d-1];if(ja(c)%2===1){r[d-1]=c+i;continue}}r.push(i),l.type!=="space"&&(a=l.type==="code");}return r},$t=(e,t,o=ct)=>{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 i of n)r+=i.length;let s=e.slice(0,r);if(n.join("")!==s)return {source:e,blocks:o(e)};let a=e.slice(r),l=o(a);return {source:e,blocks:[...n,...l]}};var $n=(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,l,i)=>{let d=l.includes(`
15
-
16
- `),c=!l.startsWith(`
17
- `),p=l.includes(`
18
- `);if(!(d||c&&p))return a+l+i;let u=l.replace(/\n\n/g,`
19
- <!---->
20
- `),m=(u.startsWith(`
21
- `)?"":`
22
- `)+u+(u.endsWith(`
23
- `)?"":`
24
- `);return `${a}${m}${i}
25
-
26
- `});}return o};var Fa=/([\\`*_~[\]|])/g,za=e=>e.replace(Fa,"\\$1"),Wn=(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,l,i)=>{let d=za(l).replace(/\n\n/g,"&#10;&#10;");return a+d+i});}return o};var qn=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(qn).join(""):"",Zn=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=qn(n);n.children=r?[{type:"text",value:r}]:[];}});};var Xa=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),Ga=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),Ua=e=>{let t=unified().use(xa).use(va,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},Kn=(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)||!Xa(s))return;let l=Ga(s);if(!l.includes(`
27
- `))return;let i=Ua(l);s.children=i;});};var Xn=()=>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 Qa={CAUTION:"caution",IMPORTANT:"important",NOTE:"note",TIP:"tip",WARNING:"warning"},ei=/^\[!(note|tip|important|warning|caution)\](?:\s+([^\n]+))?(?:\n|$)/i,ti=/^\s+/,oi=/^ /,Gn=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let o="";for(let n of t)o+=Gn(n);return o},ni=(e,t)=>{if(e.type!=="text")return null;let o=e.value.trimStart().indexOf("]")+1,n=e.value.length-e.value.trimStart().length,r=e.value.slice(n+o);return t.length>0?r=r.slice(t.length).replace(ti,""):r=r.replace(oi,""),r.startsWith(`
28
- `)?r.slice(1):r.trim().length===0?null:r},ri=e=>{var d,c;let t=e.children[0];if(!t||t.type!=="paragraph")return;let o=t.children[0];if(!o)return;let r=Gn(o).trimStart().match(ei);if(!r)return;let s=Qa[r[1].toUpperCase()],a=((d=r[2])==null?void 0:d.trim())||"",l=ni(o,a),i=[{type:"paragraph",children:[{type:"text",value:a||s}],data:{hName:"div",hProperties:{className:["markdown-alert-title"]}}}];l!==null&&l.length>0&&i.push({type:"paragraph",children:[{type:"text",value:l}]}),t.children.length>1&&i.push(...t.children.slice(1)),i.push(...e.children.slice(1)),e.data=(c=e.data)!=null?c:{},e.data.hName="div",e.data.hProperties={className:["markdown-alert",`markdown-alert-${s}`],"data-streamdown":"alert","data-alert-type":s},e.children=i;},Un=()=>e=>{visit(e,"blockquote",ri);};var ui=/^[ \t]*<[\w!/?-]/,pi=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,fi=e=>typeof e!="string"||e.length===0||!ui.test(e)?e:e.replace(pi,"$1"),er,tr,or,nr,rr,sr,dt={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(tr=(er=defaultSchema.protocols)==null?void 0:er.href)!=null?tr:[],"tel"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(nr=(or=defaultSchema.attributes)==null?void 0:or.div)!=null?nr:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution))$/],"data-streamdown","data-alert-type"],p:[...(sr=(rr=defaultSchema.attributes)==null?void 0:rr.p)!=null?sr:[],["className",/^markdown-alert-title$/]]}},Wt={raw:Hn,sanitize:[ir,dt],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},gi={gfm:[di,{}],githubAlerts:Un,codeMeta:Xn},Yn=Object.values(Wt),bi=Object.values(gi),Qn=new WeakMap;function hi(e){var r;let t=Qn.get(e);if(t)return t;let o={...dt,tagNames:[...(r=dt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...dt.attributes,...e}},n=[Wt.raw,[ir,o],Wt.harden];return Qn.set(e,n),n}var yi={block:" \u258B",circle:" \u25CF"},wi=["github-light","github-dark"],Ci={enabled:true},lr=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:o,index:n,isIncomplete:r,dir:s,animatePlugin:a,...l})=>{if(a){let c=a.getLastRenderCharCount();a.setPrevContentLength(c),a.setAnimateCodeBlocks(r);}let i=typeof e=="string"&&o?fi(e):e,d=jsx(zt,{...l,children:i});return jsx(ht.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:d}):d})},(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)});lr.displayName="Block";var ki=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=Yn,remarkPlugins:l=bi,className:i,shikiTheme:d=wi,mermaid:c,codeBlockMaxHeight:p=400,controls:u=true,isAnimating:m=false,tableMaxHeight:g=300,animated:f,BlockComponent:y=lr,parseMarkdownIntoBlocksFn:b=ct,caret:k,listStyle:x="hierarchical",plugins:h,remend:I,linkSafety:M=Ci,lineNumbers:j=true,allowedTags:B,literalTagContent:S,translations:V,icons:Q,prefix:F,onAnimationStart:q,onAnimationEnd:ee,...U})=>{var Jt;let ge=useId(),N=useMemo(()=>io(F),[F]),te=useRef(null),J=useRef(q),be=useRef(ee);J.current=q,be.current=ee,useEffect(()=>{var P,$,K;if(t==="static")return;let w=te.current;if(te.current=m,w===null){m&&((P=J.current)==null||P.call(J));return}m&&!w?($=J.current)==null||$.call(J):!m&&w&&((K=be.current)==null||K.call(be));},[m,t]);let Z=useMemo(()=>B?Object.keys(B):[],[B]),he=useRef(null),re=useMemo(()=>{if(typeof e!="string")return "";let w=e;return S&&S.length>0&&(w=Wn(w,S)),Z.length>0&&(w=$n(w,Z)),w},[e,Z,S]),O=useMemo(()=>{let w=t==="streaming"?he.current:null,P=$t(re,w,b);if(he.current=t==="streaming"?P:null,!(t==="streaming"&&n)||P.blocks.length===0)return P.blocks;let $=P.blocks.length-1,K=P.blocks[$],de=mi(K,I);if(de===K)return P.blocks;let Ee=P.blocks.slice();return Ee[$]=de,Ee},[re,b,t,n,I]),T=useMemo(()=>f===true?"true":f?JSON.stringify(f):"",[f]),R=useRef(null),X=useRef([]),Y=useRef([]),qt=useRef(null),Zt=useRef("");T?(Zt.current!==T&&(Zt.current=T,R.current=bt(),X.current=[],Y.current=[]),R.current&&(R.current.current=0)):(R.current=null,X.current=[],Y.current=[]);R.current?(Jt=X.current[0])!=null?Jt:(()=>{var P;let w=Ae({...T!=="true"?f:{},cursor:(P=R.current)!=null?P:void 0});return X.current[0]=w,w})():null;let ye=useDeferredValue(O),se=useMemo(()=>{if(t!=="streaming"||R.current||ye===O||ye.length===0)return O;let w=ye.length,P=O.length;if(P===0)return ye;if(w!==P)return O;for(let K=0;K<w-1;K+=1)if(ye[K]!==O[K])return O;let $=ye.slice();return $[w-1]=O[P-1],$},[O,ye,t]),ut=useMemo(()=>o==="auto"?se.map(it):void 0,[se,o]),ur=useMemo(()=>se.map((w,P)=>`${ge}-${P}`),[se.length,ge]),Kt=useMemo(()=>{var w,P;return {codeBlockMaxHeight:p,shikiTheme:(P=(w=h==null?void 0:h.code)==null?void 0:w.getThemes())!=null?P:d,controls:u,isAnimating:m,lineNumbers:j,listStyle:x,mode:t,mermaid:c,linkSafety:M,tableMaxHeight:g}},[p,d,u,m,j,x,t,c,M,h==null?void 0:h.code,g]),pr=useMemo(()=>V?JSON.stringify(V):"",[V]),Xt=useMemo(()=>({...Ue,...V}),[pr]),Gt=useMemo(()=>{let{inlineCode:w,...P}=s!=null?s:{},$={...Sn,...P};if(w){let K=$.code;$.code=de=>"data-block"in de?K?createElement(K,de):null:createElement(w,de);}return $},[s]),Ut=useMemo(()=>{let w=[];return h!=null&&h.cjk&&(w=[...w,...h.cjk.remarkPluginsBefore]),w=[...w,...l],h!=null&&h.cjk&&(w=[...w,...h.cjk.remarkPluginsAfter]),h!=null&&h.math&&(w=[...w,h.math.remarkPlugin]),w},[l,h==null?void 0:h.math,h==null?void 0:h.cjk]),Re=useMemo(()=>{let w=a;return B&&Object.keys(B).length>0&&a===Yn&&(w=hi(B)),Z.length>0&&(w=[...w,[Kn,Z,S!=null?S:[]]]),S&&S.length>0&&(w=[...w,[Zn,S]]),h!=null&&h.math&&(w=[...w,h.math.rehypePlugin]),w},[a,h==null?void 0:h.math,B,Z,S]),pt=useMemo(()=>{if(!m||se.length===0)return false;let w=se.at(-1);return _t(w)||Rn(w)},[m,se]),fr=useMemo(()=>k&&m&&!pt?{"--streamdown-caret":`"${yi[k]}"`}:void 0,[k,m,pt]),gr=w=>{let P=null;R.current&&m&&(X.current[w]||(X.current[w]=Ae({...T!=="true"?f:{},cursor:R.current})),P=X.current[w]),qt.current!==Re&&(Y.current=[],qt.current=Re),P&&!Y.current[w]&&(Y.current[w]=[...Re,P.rehypePlugin]);let $=P&&Y.current[w]?Y.current[w]:Re;return {blockAnimatePlugin:P,blockRehypePlugins:$}};return t==="static"?jsx(Je.Provider,{value:Xt,children:jsx(et.Provider,{value:h!=null?h:null,children:jsx(L.Provider,{value:Kt,children:jsx(Tt,{icons:Q,children:jsx(Xe.Provider,{value:N,children:jsx("div",{className:N("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:o==="auto"?it(re):o,children:jsx(zt,{components:Gt,rehypePlugins:Re,remarkPlugins:Ut,...U,children:re})})})})})})}):jsx(Je.Provider,{value:Xt,children:jsx(et.Provider,{value:h!=null?h:null,children:jsx(L.Provider,{value:Kt,children:jsx(Tt,{icons:Q,children:jsx(Xe.Provider,{value:N,children:jsxs("div",{className:N("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",k&&!pt?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),style:fr,children:[se.length===0&&k&&m&&jsx("span",{}),se.map((w,P)=>{var Yt;let $=P===se.length-1,K=m&&$&&_t(w),{blockAnimatePlugin:de,blockRehypePlugins:Ee}=gr(P);return jsx(y,{animatePlugin:de,components:Gt,content:w,dir:(Yt=ut==null?void 0:ut[P])!=null?Yt:o!=="auto"?o:void 0,index:P,isIncomplete:K,rehypePlugins:Ee,remarkPlugins:Ut,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...U},ur[P])})]})})})})})})},(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.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);ki.displayName="Streamdown";var mr=({children:e,className:t,contentSize:o,fitKey:n,minZoom:r=.5,maxZoom:s=3,zoomStep:a=.1,showControls:l=true,initialZoom:i=1,isAutoFit:d=false,fullscreen:c=false})=>{let{RotateCcwIcon:p,ZoomInIcon:u,ZoomOutIcon:m}=A(),g=C(),f=useRef(null),y=useRef(null),[b,k]=useState(i),[x,h]=useState(r),[I,M]=useState(i),[j,B]=useState({x:0,y:0}),[S,V]=useState(false),[Q,F]=useState(false),[q,ee]=useState({x:0,y:0}),[U,ge]=useState({x:0,y:0}),N=useCallback(T=>{M(R=>Math.max(x,Math.min(s,R+T))),F(true);},[x,s]),te=useCallback(()=>{N(a);},[N,a]),J=useCallback(()=>{N(-a);},[N,a]),be=useCallback(()=>{M(b),B({x:0,y:0}),F(false);},[b]),Z=useCallback(T=>{T.preventDefault();let R=T.deltaY>0?-a:a;N(R);},[N,a]),he=useCallback(T=>{if(T.button!==0||T.isPrimary===false)return;V(true),F(true),ee({x:T.clientX,y:T.clientY}),ge(j);let R=T.currentTarget;R instanceof HTMLElement&&R.setPointerCapture(T.pointerId);},[j]),re=useCallback(T=>{if(!S)return;T.preventDefault();let R=T.clientX-q.x,X=T.clientY-q.y;B({x:U.x+R,y:U.y+X});},[S,q,U]),O=useCallback(T=>{V(false);let R=T.currentTarget;R instanceof HTMLElement&&R.releasePointerCapture(T.pointerId);},[]);return useEffect(()=>{h(r),d||(k(i),M(i));},[i,d,r]),useEffect(()=>{if(!(d&&o))return;let T=f.current;if(!T)return;let R=T.clientWidth,X=T.clientHeight;if(!(R>0&&X>0))return;let Y=Math.min(R/o.width,X/o.height,1);!(Y>0)||Number.isNaN(Y)||(k(Y),h(Math.min(r,Y)),Q||(M(Y),B({x:0,y:0})));},[o,Q,d,r]),useEffect(()=>{d&&F(false);},[d]),useEffect(()=>{let T=f.current;if(T)return T.addEventListener("wheel",Z,{passive:false}),()=>{T.removeEventListener("wheel",Z);}},[Z]),useEffect(()=>{let T=y.current;if(T&&S)return document.body.style.userSelect="none",T.addEventListener("pointermove",re,{passive:false}),T.addEventListener("pointerup",O),T.addEventListener("pointercancel",O),()=>{document.body.style.userSelect="",T.removeEventListener("pointermove",re),T.removeEventListener("pointerup",O),T.removeEventListener("pointercancel",O);}},[S,re,O]),jsxs("div",{className:g("relative flex flex-col",c?"h-full w-full":"min-h-28 w-full",t),ref:f,style:{cursor:S?"grabbing":"grab"},children:[l?jsxs("div",{className:g("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",c?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:g("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:I>=s,onClick:te,title:"Zoom in",type:"button",children:jsx(u,{size:16})}),jsx("button",{className:g("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:I<=x,onClick:J,title:"Zoom out",type:"button",children:jsx(m,{size:16})}),jsx("button",{className:g("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:be,title:"Reset zoom and pan",type:"button",children:jsx(p,{size:16})})]}):null,jsx("div",{className:g("flex-1 origin-center transition-transform duration-150 ease-out",c?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:he,ref:y,role:"application",style:{transform:`translate(${j.x}px, ${j.y}px) scale(${I})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var Wo=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=C(),[a,l]=useState(null),[i,d]=useState(false),[c,p]=useState(""),[u,m]=useState(null),[g,f]=useState(""),[y,b]=useState(0),{mermaid:k}=useContext(L),x=Ie(),h=k==null?void 0:k.errorComponent,{shouldRender:I,containerRef:M}=Qt({immediate:n});if(useEffect(()=>{if(!I)return;if(!x){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),d(!0);let S=x.getMermaid(o),V=e.split("").reduce((U,ge)=>(U<<5)-U+ge.charCodeAt(0)|0,0),Q=`mermaid-${Math.abs(V)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:F}=await S.render(Q,e),q=St(F),ee=n?F:jo(F);p(ee),m(q),f(ee);}catch(S){if(!(g||c)){let V=S instanceof Error?S.message:"Failed to render Mermaid chart";l(V);}}finally{d(false);}})();},[e,o,y,I,x]),!(I||c||g))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:M});if(i&&!c&&!g)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&&!c&&!g){let B=()=>b(S=>S+1);return h?jsx("div",{ref:M,children:jsx(h,{chart:e,error:a,retry:B})}):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 j=c||g;return jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:M,children:jsx(mr,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),contentSize:u,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:j},role:"img"})})})};export{fi as A,Wt as B,gi as C,lr as D,ki as E,bt as a,Ae as b,yt as c,mo as d,Ct as e,xt as f,sc as g,vt as h,Ue as i,Ye as j,Pt as k,Qe as l,L as m,Wo as n,Me as o,xe as p,Et as q,ot as r,ve as s,ze as t,Gs as u,$e as v,it as w,On as x,ct as y,$t as z};
@@ -1,2 +0,0 @@
1
- "use client";
2
- export{n as Mermaid}from'./chunk-4TCVUZ7E.js';