@lofcz/streamdown 2.7.4 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
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 +1,2 @@
1
1
  "use client";
2
- import {m,g,d}from'./chunk-BEXMTOTX.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-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};
package/dist/index.d.ts CHANGED
@@ -307,6 +307,12 @@ interface MermaidOptions {
307
307
  config?: MermaidConfig;
308
308
  errorComponent?: React.ComponentType<MermaidErrorComponentProps>;
309
309
  }
310
+ /**
311
+ * Built-in list bullet style presets for nested unordered lists.
312
+ * - `"flat"` — all levels use disc
313
+ * - `"hierarchical"` — disc → circle → square, cycling
314
+ */
315
+ type ListStylePreset = "flat" | "hierarchical";
310
316
  interface StreamdownContextType {
311
317
  /** Max height for code blocks (px number or CSS length). `0` / `Infinity` disables. @default 400 */
312
318
  codeBlockMaxHeight?: number | string;
@@ -315,6 +321,8 @@ interface StreamdownContextType {
315
321
  /** Show line numbers in code blocks. @default true */
316
322
  lineNumbers: boolean;
317
323
  linkSafety?: LinkSafetyConfig;
324
+ /** Bullet style cycling for nested unordered lists. @default "hierarchical" */
325
+ listStyle: ListStylePreset;
318
326
  mermaid?: MermaidOptions;
319
327
  mode: "static" | "streaming";
320
328
  shikiTheme: [ThemeInput, ThemeInput];
@@ -502,6 +510,8 @@ type StreamdownProps = Options & {
502
510
  tableMaxHeight?: number | string;
503
511
  animated?: boolean | AnimateOptions;
504
512
  caret?: keyof typeof carets;
513
+ /** Bullet style cycling for nested unordered lists. @default "hierarchical" */
514
+ listStyle?: ListStylePreset;
505
515
  plugins?: PluginConfig;
506
516
  remend?: RemendOptions;
507
517
  linkSafety?: LinkSafetyConfig;
@@ -542,6 +552,7 @@ declare const carets: {
542
552
  block: string;
543
553
  circle: string;
544
554
  };
555
+
545
556
  type BlockProps = Options & {
546
557
  content: string;
547
558
  shouldParseIncompleteMarkdown: boolean;
@@ -555,6 +566,6 @@ type BlockProps = Options & {
555
566
  animatePlugin?: AnimatePlugin | null;
556
567
  };
557
568
  declare const Block: react.MemoExoticComponent<({ content, shouldParseIncompleteMarkdown: _, shouldNormalizeHtmlIndentation, index: __, isIncomplete, dir, animatePlugin: animatePluginProp, ...props }: BlockProps) => react_jsx_runtime.JSX.Element>;
558
- declare const Streamdown: react.MemoExoticComponent<({ children, mode, dir, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, normalizeHtmlIndentation: shouldNormalizeHtmlIndentation, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, codeBlockMaxHeight, controls, isAnimating, tableMaxHeight, animated, BlockComponent, parseMarkdownIntoBlocksFn, caret, plugins, remend: remendOptions, linkSafety, lineNumbers, allowedTags, literalTagContent, translations, icons: iconOverrides, prefix, onAnimationStart, onAnimationEnd, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
569
+ declare const Streamdown: react.MemoExoticComponent<({ children, mode, dir, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, normalizeHtmlIndentation: shouldNormalizeHtmlIndentation, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, codeBlockMaxHeight, controls, isAnimating, tableMaxHeight, animated, BlockComponent, parseMarkdownIntoBlocksFn, caret, listStyle, plugins, remend: remendOptions, linkSafety, lineNumbers, allowedTags, literalTagContent, translations, icons: iconOverrides, prefix, onAnimationStart, onAnimationEnd, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
559
570
 
560
- export { type AllowElement, type AllowedTags, type AnimateOptions, Block, type BlockProps, type CjkPlugin, CodeBlock, CodeBlockContainer, CodeBlockCopyButton, CodeBlockDownloadButton, CodeBlockHeader, CodeBlockSkeleton, type CodeHighlighterPlugin, type Components, type ControlsConfig, type CustomRenderer, type CustomRendererProps, type DiagramPlugin, type ExtraProps, type HighlightOptions, type IconMap, type IncrementalParseState, type LinkSafetyConfig, type LinkSafetyModalProps, type MathPlugin, type MermaidErrorComponentProps, type MermaidOptions, type PluginConfig, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, type StreamdownTranslations, TableCopyDropdown, type TableCopyDropdownProps, type TableData, TableDownloadButton, type TableDownloadButtonProps, TableDownloadDropdown, type TableDownloadDropdownProps, type ThemeInput, type UrlTransform, createAnimateCursor, createAnimatePlugin, defaultRehypePlugins, defaultRemarkPlugins, defaultTranslations, defaultUrlTransform, detectTextDirection, escapeMarkdownTableCell, extractTableDataFromElement, normalizeHtmlIndentation, parseMarkdownIntoBlocks, parseMarkdownIntoBlocksIncremental, tableDataToCSV, tableDataToMarkdown, tableDataToTSV, useIsCodeFenceIncomplete };
571
+ export { type AllowElement, type AllowedTags, type AnimateOptions, Block, type BlockProps, type CjkPlugin, CodeBlock, CodeBlockContainer, CodeBlockCopyButton, CodeBlockDownloadButton, CodeBlockHeader, CodeBlockSkeleton, type CodeHighlighterPlugin, type Components, type ControlsConfig, type CustomRenderer, type CustomRendererProps, type DiagramPlugin, type ExtraProps, type HighlightOptions, type IconMap, type IncrementalParseState, type LinkSafetyConfig, type LinkSafetyModalProps, type ListStylePreset, type MathPlugin, type MermaidErrorComponentProps, type MermaidOptions, type PluginConfig, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, type StreamdownTranslations, TableCopyDropdown, type TableCopyDropdownProps, type TableData, TableDownloadButton, type TableDownloadButtonProps, TableDownloadDropdown, type TableDownloadDropdownProps, type ThemeInput, type UrlTransform, createAnimateCursor, createAnimatePlugin, defaultRehypePlugins, defaultRemarkPlugins, defaultTranslations, defaultUrlTransform, detectTextDirection, escapeMarkdownTableCell, extractTableDataFromElement, normalizeHtmlIndentation, parseMarkdownIntoBlocks, parseMarkdownIntoBlocksIncremental, tableDataToCSV, tableDataToMarkdown, tableDataToTSV, useIsCodeFenceIncomplete };
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-BEXMTOTX.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-4TCVUZ7E.js';
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export{n as Mermaid}from'./chunk-4TCVUZ7E.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/streamdown",
3
- "version": "2.7.4",
3
+ "version": "2.8.0",
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/cjk": "npm:@lofcz/streamdown-cjk@1.0.3",
53
52
  "@streamdown/math": "npm:@lofcz/streamdown-math@1.0.3",
53
+ "@streamdown/cjk": "npm:@lofcz/streamdown-cjk@1.0.3",
54
54
  "@streamdown/mermaid": "npm:@lofcz/streamdown-mermaid@1.0.2"
55
55
  },
56
56
  "peerDependencies": {
package/styles.css CHANGED
@@ -51,3 +51,54 @@
51
51
  animation: sd-markerIn var(--sd-marker-duration, 150ms)
52
52
  var(--sd-marker-easing, ease) var(--sd-marker-delay, 0ms) both;
53
53
  }
54
+
55
+ @supports (background: color-mix(in oklab, red 10%, transparent)) {
56
+ .markdown-alert-note {
57
+ background-color: color-mix(
58
+ in oklab,
59
+ var(--primary, hsl(221 83% 53%)) 10%,
60
+ transparent
61
+ );
62
+ border-left-color: var(--primary, hsl(221 83% 53%));
63
+ }
64
+
65
+ .markdown-alert-note .markdown-alert-title {
66
+ color: var(--primary, hsl(221 83% 53%));
67
+ }
68
+
69
+ .markdown-alert-tip {
70
+ background-color: color-mix(in oklab, hsl(142 71% 45%) 10%, transparent);
71
+ border-left-color: hsl(142 71% 45%);
72
+ }
73
+
74
+ .markdown-alert-tip .markdown-alert-title {
75
+ color: hsl(142 71% 45%);
76
+ }
77
+
78
+ .markdown-alert-important {
79
+ background-color: color-mix(in oklab, hsl(262 83% 58%) 10%, transparent);
80
+ border-left-color: hsl(262 83% 58%);
81
+ }
82
+
83
+ .markdown-alert-important .markdown-alert-title {
84
+ color: hsl(262 83% 58%);
85
+ }
86
+
87
+ .markdown-alert-warning {
88
+ background-color: color-mix(in oklab, hsl(38 92% 50%) 10%, transparent);
89
+ border-left-color: hsl(38 92% 50%);
90
+ }
91
+
92
+ .markdown-alert-warning .markdown-alert-title {
93
+ color: hsl(38 92% 50%);
94
+ }
95
+
96
+ .markdown-alert-caution {
97
+ background-color: color-mix(in oklab, hsl(0 84% 60%) 10%, transparent);
98
+ border-left-color: hsl(0 84% 60%);
99
+ }
100
+
101
+ .markdown-alert-caution .markdown-alert-title {
102
+ color: hsl(0 84% 60%);
103
+ }
104
+ }
@@ -1,27 +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 Nn from'rehype-raw';import Jn,{defaultSchema}from'rehype-sanitize';import qa from'remark-gfm';import Za 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 da from'remark-parse';import ma from'remark-rehype';import {unified}from'unified';import {visit}from'unist-util-visit';import {Lexer}from'marked';var lr=300,cr="300px",dr=500;function Jt(e={}){let{immediate:t=false,debounceDelay:o=lr,rootMargin:n=cr,idleTimeout:r=dr}=e,[s,a]=useState(false),l=useRef(null),i=useRef(null),d=useRef(null),c=useMemo(()=>m=>{let b=Date.now();return window.setTimeout(()=>{m({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-b))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(m,b)=>window.requestIdleCallback(m,b):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 b=()=>{i.current&&(clearTimeout(i.current),i.current=null),d.current&&(u(d.current),d.current=null);},f=h=>{d.current=p(v=>{v.timeRemaining()>0||v.didTimeout?(a(true),h.disconnect()):d.current=p(()=>{a(true),h.disconnect();},{timeout:r/2});},{timeout:r});},y=h=>{b(),i.current=window.setTimeout(()=>{var I,B;let v=h.takeRecords();(v.length===0||(B=(I=v.at(-1))==null?void 0:I.isIntersecting)!=null&&B)&&f(h);},o);},g=(h,v)=>{h.isIntersecting?y(v):b();},w=new IntersectionObserver(h=>{for(let v of h)g(v,w);},{rootMargin:n,threshold:0});return w.observe(m),()=>{i.current&&clearTimeout(i.current),d.current&&u(d.current),w.disconnect();}},[t,o,n,r,u,p]),{shouldRender:s,containerRef:l}}function pt(){return {current:0}}var Yt=/\s/,Ut=/^\s+$/,pr=new Set(["code","pre","svg","math","annotation"]),fr=new Set(["svg","math","annotation"]),gr=new Set(["img","hr"]),Re=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",Qt=(e,t)=>{let o=t?fr:pr;return e.some(n=>Re(n)&&o.has(n.tagName))},br=e=>{for(let t=e.length-1;t>=0;t--){let o=e[t];if(Re(o)&&o.tagName==="li")return o}},hr=(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}`;},yr=new Set(["ul","ol","li"]),eo=e=>{for(let t of e.children)if(Re(t)){if(t.tagName==="input")return t;if(yr.has(t.tagName))continue;let o=eo(t);if(o)return o}},to=(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`;},wr=(e,t,o,n)=>{let r=eo(e);r&&to(r,t,o,n);},Cr=(e,t,o,n,r)=>{if(Qt(t,n.animateCodeBlocks))return;let s=n.prevContentLength,a=s>0&&r.count<s,l=a?0:(n.startIndex+r.newIndex++)*o.stagger;to(e,o,a?0:o.duration,l);},kr=e=>{let t=[],o="",n=false;for(let r of e){let s=Yt.test(r);s!==n&&o&&(t.push(o),o=""),o+=r,n=s;}return o&&t.push(o),t},xr=e=>{let t=[],o="";for(let n of e)Yt.test(n)?o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&t.push(o),t},vr=(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}]}},Tr=(e,t,o,n,r)=>{var g;let s=t.at(-1);if(!(s&&"children"in s))return;if(Qt(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"?xr(i):kr(i),c=t.some(w=>Re(w)&&w.tagName==="a"),p=d;if(o.sep==="word"&&c){let w=[];for(let h of d)Ut.test(h)&&w.length>0?w[w.length-1]+=h:w.push(h);p=w;}let u=n.prevContentLength,m=br(t),b=!!(m&&!((g=m.properties)!=null&&g["data-sd-animate-marker"])),f=false,y=p.map(w=>{let h=r.count;if(r.count+=w.length,Ut.test(w))return {type:"text",value:w};let v=u>0&&h<u,P=v?0:(n.startIndex+r.newIndex++)*o.stagger;if(m&&b&&!f){let I=v?0:o.duration;hr(m,I,P,o.easing),wr(m,o,I,P),f=true;}return vr(w,o.animation,o.duration,o.easing,v,P)});return a.children.splice(l,1,...y),l+y.length},Pr=0;function Se(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=Pr++,r=()=>c=>{let p={count:0,newIndex:0};t.cursor&&(o.startIndex=t.cursor.current),visitParents(c,u=>u.type==="text"||Re(u)&&gr.has(u.tagName),(u,m)=>{if(u.type==="text")return Tr(u,m,t,o,p);Cr(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}}}Se();var ft=createContext(false),gt=()=>useContext(ft);var Ee=(...e)=>twMerge(clsx(e)),$e=e=>{if(e!==void 0)return typeof e=="number"?!Number.isFinite(e)||e<=0?void 0:`${e}px`:e},Nr=(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(" ")},ro=e=>e?(...t)=>Nr(e,twMerge(clsx(t))):Ee,Q=(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 We=createContext(Ee),C=()=>useContext(We);var Hr=Ee("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"),Ar=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},io=memo(({children:e,result:t,language:o,className:n,maxHeight:r,startLine:s,lineNumbers:a=true,...l})=>{let i=C(),{isAnimating:d}=useContext(M),c=useRef(null),p=useRef(true),u=$e(r);useEffect(()=>{let f=c.current;if(!(f&&u))return;let y=()=>{let g=f.scrollHeight-f.scrollTop-f.clientHeight<8;p.current=g;};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(Hr),[i]),b=useMemo(()=>{let f={};return t.bg&&(f["--sdm-bg"]=t.bg),t.fg&&(f["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(f,Ar(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:b,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((g,w)=>{let h={},v=!!g.bgColor;if(g.color&&(h["--sdm-c"]=g.color),g.bgColor&&(h["--sdm-tbg"]=g.bgColor),g.htmlStyle)for(let[P,I]of Object.entries(g.htmlStyle))P==="color"?h["--sdm-c"]=I:P==="background-color"?(h["--sdm-tbg"]=I,v=true):h[P]=I;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",v&&"bg-[var(--sdm-tbg)]",v&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:h,...g.htmlAttrs,children:g.content},w)})},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 ht=({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 yt=createContext({code:""}),qe=()=>useContext(yt);var wt=({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 Fr=e=>{let t=e.length;for(;t>0&&e[t-1]===`
4
- `;)t--;return e.slice(0,t)},zr=lazy(()=>import('./highlighted-body-CBJEFVPF.js').then(e=>({default:e.HighlightedCodeBlockBody}))),Ct=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,lineNumbers:a,...l})=>{let i=C(),{codeBlockMaxHeight:d}=useContext(M),c=useMemo(()=>Fr(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(yt.Provider,{value:{code:e},children:jsxs(ht,{isIncomplete:r,language:t,children:[jsx(wt,{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(io,{className:o,language:t,lineNumbers:a,maxHeight:d,result:p,startLine:s,...l}),children:jsx(zr,{className:o,code:c,language:t,lineNumbers:a,maxHeight:d,raw:p,startLine:s,...l})})]})})};var mo=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"})}),uo=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"})}),po=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"})}),fo=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"})]}),go=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"})}),bo=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"})}),ho=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"})}),yo=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"})}),wo=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"})}),Co=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 Ae={CheckIcon:mo,CopyIcon:uo,DownloadIcon:po,ExternalLinkIcon:yo,Loader2Icon:fo,Maximize2Icon:go,RotateCcwIcon:bo,XIcon:ho,ZoomInIcon:wo,ZoomOutIcon:Co},xo=createContext(Ae),Kr=(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])},kt=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...Ae,...e}:Ae);Kr(o.current,e)||(o.current=e,n.current=e?{...Ae,...e}:Ae);let r=n.current;return jsx(xo.Provider,{value:r,children:t})},D=()=>useContext(xo);var Ze={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"},Ke=createContext(Ze),V=()=>useContext(Ke);var Xe=({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}=qe(),{isAnimating:u}=useContext(M),m=V(),b=s!=null?s:p,f=async()=>{var w;if(typeof window=="undefined"||!((w=navigator==null?void 0:navigator.clipboard)!=null&&w.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(b),d(!0),e==null||e(),c.current=window.setTimeout(()=>d(!1),o));}catch(h){t==null||t(h);}};useEffect(()=>()=>{window.clearTimeout(c.current);},[]);let y=D(),g=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(g,{size:14})})};var To={"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"},xt=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let l=C(),{code:i}=qe(),{isAnimating:d}=useContext(M),c=V(),p=D(),u=s!=null?s:i,b=`file.${o&&o in To?To[o]:"txt"}`,f="text/plain",y=()=>{try{Q(b,u,f),e==null||e();}catch(g){t==null||t(g);}};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 Ge=()=>{let{Loader2Icon:e}=D(),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 De=0,fe=()=>{De+=1,De===1&&(document.body.style.overflow="hidden");},ge=()=>{De=Math.max(0,De-1),De===0&&(document.body.style.overflow="");};var rs=["github-light","github-dark"],ss={enabled:true},as={codeBlockMaxHeight:400,shikiTheme:rs,controls:true,isAnimating:false,lineNumbers:true,mode:"streaming",mermaid:void 0,linkSafety:ss,tableMaxHeight:300},M=createContext(as);var ds=/\.[^/.]+$/,Mo=(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},No=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,onClick:a,...l})=>{let{DownloadIcon:i,XIcon:d}=D(),c=C(),p=useRef(null),[u,m]=useState(false),[b,f]=useState(false),[y,g]=useState(false),{controls:w}=useContext(M),h=V(),v=Mo(w,"download"),P=Mo(w,"fullscreen"),I=l.width!=null||l.height!=null,B=v&&(u||I)&&!b,H=b&&!I,E=P&&!!o&&!b&&u;useEffect(()=>{let N=p.current;if(N!=null&&N.complete){let z=N.naturalWidth>0;m(z),f(!z);}},[]),useEffect(()=>{if(!y)return;fe();let N=z=>{z.key==="Escape"&&g(false);};return document.addEventListener("keydown",N),()=>{document.removeEventListener("keydown",N),ge();}},[y]);let _=useCallback(N=>{m(true),f(false),r==null||r(N);},[r]),J=useCallback(N=>{m(false),f(true),s==null||s(N);},[s]),j=useCallback(()=>{E&&g(true);},[E]),$=useCallback(()=>{g(false);},[]),U=useCallback(N=>{a==null||a(N),!N.defaultPrevented&&j();},[a,j]),X=async N=>{if(N.stopPropagation(),!!o)try{let te=await(await fetch(o)).blob(),Y=new URL(o,window.location.origin).pathname.split("/").pop()||"",ie=Y.split(".").pop(),me=Y.includes(".")&&ie!==void 0&&ie.length<=4,W="";if(me)W=Y;else {let x=te.type,R="png";x.includes("jpeg")||x.includes("jpg")?R="jpg":x.includes("png")?R="png":x.includes("svg")?R="svg":x.includes("gif")?R="gif":x.includes("webp")&&(R="webp"),W=`${(n||Y||"image").replace(ds,"")}.${R}`;}Q(W,te,te.type);}catch(z){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",E&&"cursor-zoom-in",H&&"hidden",t),"data-streamdown":"image",onClick:U,onError:J,onLoad:_,ref:p,src:o,...l}),H&&jsx("span",{className:c("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:h.imageNotAvailable}),B&&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:X,title:h.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:$,onKeyDown:N=>{N.key==="Escape"&&$();},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:$,title:h.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 So=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=D(),i=C(),[d,c]=useState(false),p=V(),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){fe();let f=y=>{y.key==="Escape"&&o();};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),ge();}}},[t,o]),!t||typeof document=="undefined")return null;let b=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(b,document.body)};var Je=createContext(null),It=()=>useContext(Je),jl=()=>{var t;let e=It();return (t=e==null?void 0:e.code)!=null?t:null},Te=()=>{var t;let e=It();return (t=e==null?void 0:e.mermaid)!=null?t:null};var Eo=e=>{var o;let t=It();return t!=null&&t.renderers&&e&&(o=t.renderers.find(n=>Array.isArray(n.language)?n.language.includes(e):n.language===e))!=null?o:null};var hs=/(<svg\b)/,Do=/<svg\b[^>]*>/i,ys=/\bviewBox=(['"])(.*?)\1/i,ws=/\swidth=(['"]).*?\1/i,Cs=/\sheight=(['"]).*?\1/i,Ho=/\sstyle=(['"])(.*?)\1/i,Ao=/^<svg/i,ks=/^width\s*:/i,xs=/^height\s*:/i,vs=/^max-width\s*:/i,Ts=/[\s,]+/,Ps=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(hs,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),Bo=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},Mt=e=>{let t=e.match(Do);if(!t)return null;let n=t[0].match(ys),r=n==null?void 0:n[2];if(!r)return null;let s=r.trim().split(Ts).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},Oo=e=>{let t=e.match(Do);if(!t)return e;try{let o=t[0],n=Mt(e);if(!n)return e;let{width:r,height:s}=n,a=o.replace(ws,"").replace(Cs,""),l=a.match(Ho),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=>!(ks.test(m)||xs.test(m)||vs.test(m))).join(";"),u=`${i}${p?`${p};`:""}`;a=a.replace(Ho,` style=${d}${u}${d}`);}else a=a.replace(Ao,`<svg style="${i}"`);return a=a.replace(Ao,`<svg width="${r}" height="${s}"`),e.replace(o,a)}catch(o){return e}},Vo=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a=Ps(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 Ue=({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(M),p=D(),u=Te(),m=V(),b=async f=>{try{if(f==="mmd"){Q("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),g=e.split("").reduce((P,I)=>(P<<5)-P+I.charCodeAt(0)|0,0),w=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:h}=await y.render(w,e);if(!h){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let v=Bo(h);if(f==="svg"){Q("diagram.svg",v,"image/svg+xml"),i(!1),n==null||n(f);return}if(f==="png"){let P=await Vo(v);Q("diagram.png",P,"image/png"),n==null||n(f),i(!1);return}}catch(y){s==null||s(y);}};return useEffect(()=>{let f=y=>{let g=y.composedPath();d.current&&!g.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:()=>b("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:()=>b("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:()=>b("mmd"),title:m.downloadDiagramAsMmd,type:"button",children:m.mermaidFormatMmd})]}):null]})};var zo=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=D(),i=C(),[d,c]=useState(false),{isAnimating:p,controls:u}=useContext(M),m=V(),b=(()=>{if(typeof u=="boolean")return u;let g=u.mermaid;return g===false?false:g===true||g===void 0?true:g.panZoom!==false})(),f=(()=>{if(typeof u=="boolean")return u;let g=u.mermaid;return g===false?false:g===true||g===void 0?true:g.download!==false})(),y=()=>{c(!d);};return useEffect(()=>{if(d){fe();let g=w=>{w.key==="Escape"&&c(false);};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),ge();}}},[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:g=>{g.key==="Escape"&&y();},role:"dialog",children:[jsxs("div",{className:i("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:[f?jsx(Ue,{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:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:jsx(Fo,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:b})})]}),document.body):null]})};var Pe=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}},ke=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
- `)},Lt=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
- `)},Ye=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("")},xe=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=>Ye(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?Ye(l[d]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(d=>Ye(d));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
11
- `)};var _e=({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(M),m=V(),b=async g=>{var w,h;if(typeof window=="undefined"||!((w=navigator==null?void 0:navigator.clipboard)!=null&&w.write)){n==null||n(new Error("Clipboard API not available"));return}try{let v=(h=c.current)==null?void 0:h.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),P=v==null?void 0:v.querySelector("table");if(!P){n==null||n(new Error("Table not found"));return}let I=Pe(P),E=({csv:ke,tsv:Lt,md:xe}[g]||xe)(I),_=new ClipboardItem({"text/plain":new Blob([E],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([_]),d(!0),l(!1),o==null||o(g),p.current=window.setTimeout(()=>d(!1),r);}catch(v){n==null||n(v);}};useEffect(()=>{let g=w=>{let h=w.composedPath();c.current&&!h.includes(c.current)&&l(false);};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g),window.clearTimeout(p.current);}},[]);let f=D(),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:()=>b("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:()=>b("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:()=>b("tsv"),title:m.copyTableAsTsv,type:"button",children:m.tableFormatTsv})]}):null]})};var _s=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:s})=>{let a=C(),{isAnimating:l}=useContext(M),i=V(),d=D(),c=p=>{try{let m=p.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),b=m==null?void 0:m.querySelector("table");if(!b){n==null||n(new Error("Table not found"));return}let f=Pe(b),y="",g="",w="";switch(r){case "csv":y=ke(f),g="text/csv",w="csv";break;case "markdown":y=xe(f),g="text/markdown",w="md";break;default:y=ke(f),g="text/csv",w="csv";}Q(`${s||"table"}.${w}`,y,g),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})})},je=({children:e,className:t,onDownload:o,onError:n})=>{let r=C(),[s,a]=useState(false),l=useRef(null),{isAnimating:i}=useContext(M),d=V(),c=D(),p=u=>{var m;try{let b=(m=l.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=b==null?void 0:b.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let y=Pe(f),g=u==="csv"?ke(y):xe(y);Q(`table.${u==="csv"?"csv":"md"}`,g,u==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(u);}catch(b){n==null||n(b);}};return useEffect(()=>{let u=m=>{let b=m.composedPath();l.current&&!b.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 Xo=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=D(),a=C(),[l,i]=useState(false),{isAnimating:d}=useContext(M),c=V(),p=()=>{i(true);},u=()=>{i(false);};return useEffect(()=>{if(l){fe();let m=b=>{b.key==="Escape"&&i(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),ge();}}},[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(_e,{}):null,n?jsx(je,{}):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 Uo=({children:e,className:t,maxHeight:o,showControls:n,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...l})=>{let i=C(),{isAnimating:d}=useContext(M),c=useRef(null),p=useRef(true),u=$e(o);useEffect(()=>{let g=c.current;if(!(g&&u))return;let w=()=>{let h=g.scrollHeight-g.scrollTop-g.clientHeight<8;p.current=h;};return g.addEventListener("scroll",w,{passive:true}),()=>g.removeEventListener("scroll",w)},[u]),useEffect(()=>{let g=c.current;g&&u&&d&&p.current&&g.scrollTo({top:g.scrollHeight,behavior:"instant"});}),useEffect(()=>{d||(p.current=true);},[d]);let m=n&&r,b=n&&s,f=n&&a,y=m||b||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(_e,{}):null,b?jsx(je,{}):null,f?jsx(Xo,{showCopy:m,showDownload:b,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 Gs=/startLine=(\d+)/,Js=/\bnoLineNumbers\b/,Us=lazy(()=>import('./mermaid-FZS7QEIG.js').then(e=>({default:e.Mermaid}))),Ys=/language-([^\s]+)/;function ot(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 O(e,t){return e.className===t.className&&ot(e.node,t.node)}var At=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Ht=(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},Qo=(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},Qe=(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},Bt=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e})},(e,t)=>O(e,t));Bt.displayName="MarkdownOl";var en=memo(({children:e,className:t,node:o,...n})=>{var d;let r=C(),s=Array.isArray(e)?e.filter(c=>c!==`
12
- `&&c!==""):[e],a=s[0],l=isValidElement(a)?(d=a.props.node)==null?void 0:d.tagName:void 0,i=s.length===1&&isValidElement(a)&&(a.type==="p"||l==="p")?a.props.children:e;return jsx("li",{className:r("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:i})},(e,t)=>e.className===t.className&&ot(e.node,t.node));en.displayName="MarkdownLi";var tn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("ul",{className:r("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e})},(e,t)=>O(e,t));tn.displayName="MarkdownUl";var on=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)=>O(e,t));on.displayName="MarkdownHr";var nn=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)=>O(e,t));nn.displayName="MarkdownStrong";var Qs=({children:e,className:t,href:o,node:n,...r})=>{let s=C(),{linkSafety:a}=useContext(M),[l,i]=useState(false),d=o==="streamdown:incomplete-link",c=useCallback(async b=>{if(!(!(a!=null&&a.enabled&&o)||d)){if(b.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(So,{...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})},rn=memo(Qs,(e,t)=>O(e,t)&&e.href===t.href);rn.displayName="MarkdownA";var sn=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)=>O(e,t));sn.displayName="MarkdownH1";var an=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)=>O(e,t));an.displayName="MarkdownH2";var ln=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)=>O(e,t));ln.displayName="MarkdownH3";var cn=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)=>O(e,t));cn.displayName="MarkdownH4";var dn=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)=>O(e,t));dn.displayName="MarkdownH5";var mn=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)=>O(e,t));mn.displayName="MarkdownH6";var un=memo(({children:e,className:t,node:o,...n})=>{let{controls:r,tableMaxHeight:s}=useContext(M),a=At(r,"table"),l=Ht(r,"copy"),i=Ht(r,"download"),d=Ht(r,"fullscreen");return jsx(Uo,{className:t,maxHeight:s,showControls:a,showCopy:l,showDownload:i,showFullscreen:d,...n,children:e})},(e,t)=>O(e,t));un.displayName="MarkdownTable";var pn=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)=>O(e,t));pn.displayName="MarkdownThead";var fn=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)=>O(e,t));fn.displayName="MarkdownTbody";var gn=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)=>O(e,t));gn.displayName="MarkdownTr";var bn=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)=>O(e,t));bn.displayName="MarkdownTh";var hn=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)=>O(e,t));hn.displayName="MarkdownTd";var yn=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)=>O(e,t));yn.displayName="MarkdownBlockquote";var wn=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)=>O(e,t));wn.displayName="MarkdownSup";var Cn=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)=>O(e,t));Cn.displayName="MarkdownSub";var kn=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 b of d)if(b){if(typeof b=="string")b.trim()!==""&&(c=true);else if(isValidElement(b))if(((u=b.props)==null?void 0:u["data-footnote-backref"])!==void 0)p=true;else {let f=Array.isArray(b.props.children)?b.props.children:[b.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===Bt){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)=>O(e,t));kn.displayName="MarkdownSection";var ea=({node:e,className:t,children:o,...n})=>{var H,E;let r=C(),s=!("data-block"in n),{mermaid:a,controls:l,lineNumbers:i}=useContext(M),d=Te(),c=gt(),p=t==null?void 0:t.match(Ys),u=(H=p==null?void 0:p.at(1))!=null?H:"",m=Eo(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 b=(E=e==null?void 0:e.properties)==null?void 0:E.metastring,f=b==null?void 0:b.match(Gs),y=f?Number.parseInt(f[1],10):void 0,g=y!==void 0&&y>=1?y:void 0,h=!(b?Js.test(b):false)&&i!==false,v="";if(isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?v=o.props.children:typeof o=="string"&&(v=o),m){let _=m.component;return jsx(Suspense,{fallback:jsx(Ge,{}),children:jsx(_,{code:v,isIncomplete:c,language:u,meta:b})})}if(u==="mermaid"&&d){let _=At(l,"mermaid"),J=Qe(l,"download"),j=Qe(l,"copy"),$=Qe(l,"fullscreen"),U=Qe(l,"panZoom"),X=_&&(J||j||$);return jsx(Suspense,{fallback:jsx(Ge,{}),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"})}),X?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"mermaid-block-actions",children:[J?jsx(Ue,{chart:v,config:a==null?void 0:a.config}):null,j?jsx(Xe,{code:v}):null,$?jsx(zo,{chart:v,config:a==null?void 0:a.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(Us,{chart:v,config:a==null?void 0:a.config,showControls:U})})]})})}let P=At(l,"code"),I=Qo(l,"download"),B=Qo(l,"copy");return jsx(Ct,{className:t,code:v,isIncomplete:c,language:u,lineNumbers:h,startLine:g,children:P?jsxs(Fragment,{children:[I?jsx(xt,{code:v,language:u}):null,B?jsx(Xe,{}):null]}):null})},xn=memo(ea,(e,t)=>e.className===t.className&&ot(e.node,t.node));xn.displayName="MarkdownCode";var vn=memo(No,(e,t)=>e.className===t.className&&ot(e.node,t.node));vn.displayName="MarkdownImg";var Tn=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)=>O(e,t));Tn.displayName="MarkdownParagraph";var Pn={ol:Bt,li:en,ul:tn,hr:on,strong:nn,a:rn,h1:sn,h2:an,h3:ln,h4:cn,h5:dn,h6:mn,table:un,thead:pn,tbody:fn,tr:gn,th:bn,td:hn,blockquote:yn,code:xn,img:vn,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:wn,sub:Cn,p:Tn,section:kn};var ta=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,oa=/\p{L}/u;function nt(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(ta.test(o))return "rtl";if(oa.test(o))return "ltr"}return "ltr"}var na=/^[ \t]{0,3}(`{3,}|~{3,})/,ra=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,Ot=e=>{let t=e.split(`
13
- `),o=null,n=0;for(let r of t){let s=na.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},In=e=>{let t=e.split(`
14
- `);for(let o of t){let n=o.trim();if(n.length>0&&n.includes("|")&&ra.test(n))return true}return false};var Mn=()=>e=>{visit(e,"html",(t,o,n)=>{!n||typeof o!="number"||(n.children[o]={type:"text",value:t.value});});};var Ln=[],Rn={allowDangerousHtml:true},rt=new WeakMap,_t=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 b=p[m];if(m>0&&(u+=","),Array.isArray(b)){let[f,y]=b;if(typeof f=="function"){let g=rt.get(f);g||(g=f.name,rt.set(f,g)),u+=g;}else u+=String(f);u+=":",u+=JSON.stringify(y);}else if(typeof b=="function"){let f=rt.get(b);f||(f=b.name,rt.set(b,f)),u+=f;}else u+=String(b);}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();}},Sn=new _t,jt=e=>{let t=fa(e),o=e.children||"",n=t.runSync(t.parse(o),o);return Ca(n,e)},fa=e=>{let t=Sn.get(e);if(t)return t;let o=ba(e);return Sn.set(e,o),o},ga=e=>e.some(t=>Array.isArray(t)?t[0]===Nn:t===Nn),ba=e=>{let t=e.rehypePlugins||Ln,o=e.remarkPlugins||Ln,n=ga(t)?o:[...o,Mn],r=e.remarkRehypeOptions?{...Rn,...e.remarkRehypeOptions}:Rn;return unified().use(da).use(n).use(ma,r).use(t)},En=e=>e,ha=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},ya=(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);}},wa=(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},Ca=(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||En;visit(e,(c,p,u)=>{if(c.type==="raw"&&u&&typeof p=="number")return ha(u,p,s,c.value),p;if(c.type==="element"&&(ya(c,d),wa(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 xa=/\[\^[\w-]{1,200}\](?!:)/,va=/\[\^[\w-]{1,200}\]:/;var Ta=/<(\w+)[\s>]/,Pa=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Hn=new Map,An=new Map,On=e=>{let t=e.toLowerCase(),o=Hn.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Hn.set(t,n),n},Ia=e=>{let t=e.toLowerCase(),o=An.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return An.set(t,n),n},Dn=(e,t)=>{if(Pa.has(t.toLowerCase()))return 0;let o=e.match(On(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},Bn=(e,t)=>{let o=e.match(Ia(t));return o?o.length:0},Ma=(e,t)=>{let o=e.match(On(t));return !!o&&o.every(n=>n.trimEnd().endsWith("/>"))},Na=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},st=e=>{let t=xa.test(e),o=va.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=Dn(i,c),u=Bn(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(Ta);if(c){let p=c[1],u=Dn(i,p),m=Bn(i,p);u>m&&!Ma(i,p)&&s.push(p);}}if(d>0&&!a){let c=r[d-1];if(Na(c)%2===1){r[d-1]=c+i;continue}}r.push(i),l.type!=="space"&&(a=l.type==="code");}return r},Ft=(e,t,o=st)=>{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 Vn=(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 La=/([\\`*_~[\]|])/g,Ra=e=>e.replace(La,"\\$1"),_n=(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=Ra(l).replace(/\n\n/g,"&#10;&#10;");return a+d+i});}return o};var jn=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(jn).join(""):"",Fn=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=jn(n);n.children=r?[{type:"text",value:r}]:[];}});};var Ba=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),Oa=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),Va=e=>{let t=unified().use(da).use(ma,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},zn=(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)||!Ba(s))return;let l=Oa(s);if(!l.includes(`
27
- `))return;let i=Va(l);s.children=i;});};var $n=()=>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 Ka=/^[ \t]*<[\w!/?-]/,Xa=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,Ga=e=>typeof e!="string"||e.length===0||!Ka.test(e)?e:e.replace(Xa,"$1"),Kn,Xn,it={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(Xn=(Kn=defaultSchema.protocols)==null?void 0:Kn.href)!=null?Xn:[],"tel"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]]}},zt={raw:Nn,sanitize:[Jn,it],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Ja={gfm:[qa,{}],codeMeta:$n},qn=Object.values(zt),Ua=Object.values(Ja),Zn=new WeakMap;function Ya(e){var r;let t=Zn.get(e);if(t)return t;let o={...it,tagNames:[...(r=it.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...it.attributes,...e}},n=[zt.raw,[Jn,o],zt.harden];return Zn.set(e,n),n}var Qa={block:" \u258B",circle:" \u25CF"},ei=["github-light","github-dark"],ti={enabled:true},Un=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?Ga(e):e,d=jsx(jt,{...l,children:i});return jsx(ft.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)});Un.displayName="Block";var oi=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=qn,remarkPlugins:l=Ua,className:i,shikiTheme:d=ei,mermaid:c,codeBlockMaxHeight:p=400,controls:u=true,isAnimating:m=false,tableMaxHeight:b=300,animated:f,BlockComponent:y=Un,parseMarkdownIntoBlocksFn:g=st,caret:w,plugins:h,remend:v,linkSafety:P=ti,lineNumbers:I=true,allowedTags:B,literalTagContent:H,translations:E,icons:_,prefix:J,onAnimationStart:j,onAnimationEnd:$,...U})=>{var Xt;let X=useId(),se=useMemo(()=>ro(J),[J]),N=useRef(null),z=useRef(j),te=useRef($);z.current=j,te.current=$,useEffect(()=>{var L,G,ne;if(t==="static")return;let k=N.current;if(N.current=m,k===null){m&&((L=z.current)==null||L.call(z));return}m&&!k?(G=z.current)==null||G.call(z):!m&&k&&((ne=te.current)==null||ne.call(te));},[m,t]);let ae=useMemo(()=>B?Object.keys(B):[],[B]),Y=useRef(null),ie=useMemo(()=>{if(typeof e!="string")return "";let k=e;return H&&H.length>0&&(k=_n(k,H)),ae.length>0&&(k=Vn(k,ae)),k},[e,ae,H]),me=useMemo(()=>{let k=t==="streaming"?Y.current:null,L=Ft(ie,k,g);if(Y.current=t==="streaming"?L:null,!(t==="streaming"&&n)||L.blocks.length===0)return L.blocks;let G=L.blocks.length-1,ne=L.blocks[G],pe=Za(ne,v);if(pe===ne)return L.blocks;let Le=L.blocks.slice();return Le[G]=pe,Le},[ie,g,t,n,v]),W=useMemo(()=>f===true?"true":f?JSON.stringify(f):"",[f]),x=useRef(null),R=useRef([]),Z=useRef([]),ue=useRef(null),$t=useRef("");W?($t.current!==W&&($t.current=W,x.current=pt(),R.current=[],Z.current=[]),x.current&&(x.current.current=0)):(x.current=null,R.current=[],Z.current=[]);x.current?(Xt=R.current[0])!=null?Xt:(()=>{var L;let k=Se({...W!=="true"?f:{},cursor:(L=x.current)!=null?L:void 0});return R.current[0]=k,k})():null;let tr=useDeferredValue(me),oe=t==="streaming"&&!x.current?tr:me,ct=useMemo(()=>o==="auto"?oe.map(nt):void 0,[oe,o]),or=useMemo(()=>oe.map((k,L)=>`${X}-${L}`),[oe.length,X]),Wt=useMemo(()=>{var k,L;return {codeBlockMaxHeight:p,shikiTheme:(L=(k=h==null?void 0:h.code)==null?void 0:k.getThemes())!=null?L:d,controls:u,isAnimating:m,lineNumbers:I,mode:t,mermaid:c,linkSafety:P,tableMaxHeight:b}},[p,d,u,m,I,t,c,P,h==null?void 0:h.code,b]),nr=useMemo(()=>E?JSON.stringify(E):"",[E]),qt=useMemo(()=>({...Ze,...E}),[nr]),Zt=useMemo(()=>{let{inlineCode:k,...L}=s!=null?s:{},G={...Pn,...L};if(k){let ne=G.code;G.code=pe=>"data-block"in pe?ne?createElement(ne,pe):null:createElement(k,pe);}return G},[s]),Kt=useMemo(()=>{let k=[];return h!=null&&h.cjk&&(k=[...k,...h.cjk.remarkPluginsBefore]),k=[...k,...l],h!=null&&h.cjk&&(k=[...k,...h.cjk.remarkPluginsAfter]),h!=null&&h.math&&(k=[...k,h.math.remarkPlugin]),k},[l,h==null?void 0:h.math,h==null?void 0:h.cjk]),Ne=useMemo(()=>{let k=a;return B&&Object.keys(B).length>0&&a===qn&&(k=Ya(B)),ae.length>0&&(k=[...k,[zn,ae,H!=null?H:[]]]),H&&H.length>0&&(k=[...k,[Fn,H]]),h!=null&&h.math&&(k=[...k,h.math.rehypePlugin]),k},[a,h==null?void 0:h.math,B,ae,H]),dt=useMemo(()=>{if(!m||oe.length===0)return false;let k=oe.at(-1);return Ot(k)||In(k)},[m,oe]),rr=useMemo(()=>w&&m&&!dt?{"--streamdown-caret":`"${Qa[w]}"`}:void 0,[w,m,dt]),sr=k=>{let L=null;x.current&&m&&(R.current[k]||(R.current[k]=Se({...W!=="true"?f:{},cursor:x.current})),L=R.current[k]),ue.current!==Ne&&(Z.current=[],ue.current=Ne),L&&!Z.current[k]&&(Z.current[k]=[...Ne,L.rehypePlugin]);let G=L&&Z.current[k]?Z.current[k]:Ne;return {blockAnimatePlugin:L,blockRehypePlugins:G}};return t==="static"?jsx(Ke.Provider,{value:qt,children:jsx(Je.Provider,{value:h!=null?h:null,children:jsx(M.Provider,{value:Wt,children:jsx(kt,{icons:_,children:jsx(We.Provider,{value:se,children:jsx("div",{className:se("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:o==="auto"?nt(ie):o,children:jsx(jt,{components:Zt,rehypePlugins:Ne,remarkPlugins:Kt,...U,children:ie})})})})})})}):jsx(Ke.Provider,{value:qt,children:jsx(Je.Provider,{value:h!=null?h:null,children:jsx(M.Provider,{value:Wt,children:jsx(kt,{icons:_,children:jsx(We.Provider,{value:se,children:jsxs("div",{className:se("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",w&&!dt?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),style:rr,children:[oe.length===0&&w&&m&&jsx("span",{}),oe.map((k,L)=>{var Gt;let G=L===oe.length-1,ne=m&&G&&Ot(k),{blockAnimatePlugin:pe,blockRehypePlugins:Le}=sr(L);return jsx(y,{animatePlugin:pe,components:Zt,content:k,dir:(Gt=ct==null?void 0:ct[L])!=null?Gt:o!=="auto"?o:void 0,index:L,isIncomplete:ne,rehypePlugins:Le,remarkPlugins:Kt,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...U},or[L])})]})})})})})})},(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);oi.displayName="Streamdown";var er=({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}=D(),b=C(),f=useRef(null),y=useRef(null),[g,w]=useState(i),[h,v]=useState(r),[P,I]=useState(i),[B,H]=useState({x:0,y:0}),[E,_]=useState(false),[J,j]=useState(false),[$,U]=useState({x:0,y:0}),[X,se]=useState({x:0,y:0}),N=useCallback(x=>{I(R=>Math.max(h,Math.min(s,R+x))),j(true);},[h,s]),z=useCallback(()=>{N(a);},[N,a]),te=useCallback(()=>{N(-a);},[N,a]),ae=useCallback(()=>{I(g),H({x:0,y:0}),j(false);},[g]),Y=useCallback(x=>{x.preventDefault();let R=x.deltaY>0?-a:a;N(R);},[N,a]),ie=useCallback(x=>{if(x.button!==0||x.isPrimary===false)return;_(true),j(true),U({x:x.clientX,y:x.clientY}),se(B);let R=x.currentTarget;R instanceof HTMLElement&&R.setPointerCapture(x.pointerId);},[B]),me=useCallback(x=>{if(!E)return;x.preventDefault();let R=x.clientX-$.x,Z=x.clientY-$.y;H({x:X.x+R,y:X.y+Z});},[E,$,X]),W=useCallback(x=>{_(false);let R=x.currentTarget;R instanceof HTMLElement&&R.releasePointerCapture(x.pointerId);},[]);return useEffect(()=>{v(r),d||(w(i),I(i));},[i,d,r]),useEffect(()=>{if(!(d&&o))return;let x=f.current;if(!x)return;let R=x.clientWidth,Z=x.clientHeight;if(!(R>0&&Z>0))return;let ue=Math.min(R/o.width,Z/o.height,1);!(ue>0)||Number.isNaN(ue)||(w(ue),v(Math.min(r,ue)),J||(I(ue),H({x:0,y:0})));},[o,J,d,r]),useEffect(()=>{d&&j(false);},[d]),useEffect(()=>{let x=f.current;if(x)return x.addEventListener("wheel",Y,{passive:false}),()=>{x.removeEventListener("wheel",Y);}},[Y]),useEffect(()=>{let x=y.current;if(x&&E)return document.body.style.userSelect="none",x.addEventListener("pointermove",me,{passive:false}),x.addEventListener("pointerup",W),x.addEventListener("pointercancel",W),()=>{document.body.style.userSelect="",x.removeEventListener("pointermove",me),x.removeEventListener("pointerup",W),x.removeEventListener("pointercancel",W);}},[E,me,W]),jsxs("div",{className:b("relative flex flex-col",c?"h-full w-full":"min-h-28 w-full",t),ref:f,style:{cursor:E?"grabbing":"grab"},children:[l?jsxs("div",{className:b("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:b("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:P>=s,onClick:z,title:"Zoom in",type:"button",children:jsx(u,{size:16})}),jsx("button",{className:b("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:P<=h,onClick:te,title:"Zoom out",type:"button",children:jsx(m,{size:16})}),jsx("button",{className:b("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:ae,title:"Reset zoom and pan",type:"button",children:jsx(p,{size:16})})]}):null,jsx("div",{className:b("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:ie,ref:y,role:"application",style:{transform:`translate(${B.x}px, ${B.y}px) scale(${P})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var Fo=({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),[b,f]=useState(""),[y,g]=useState(0),{mermaid:w}=useContext(M),h=Te(),v=w==null?void 0:w.errorComponent,{shouldRender:P,containerRef:I}=Jt({immediate:n});if(useEffect(()=>{if(!P)return;if(!h){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),d(!0);let E=h.getMermaid(o),_=e.split("").reduce((X,se)=>(X<<5)-X+se.charCodeAt(0)|0,0),J=`mermaid-${Math.abs(_)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:j}=await E.render(J,e),$=Mt(j),U=n?j:Oo(j);p(U),m($),f(U);}catch(E){if(!(b||c)){let _=E instanceof Error?E.message:"Failed to render Mermaid chart";l(_);}}finally{d(false);}})();},[e,o,y,P,h]),!(P||c||b))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:I});if(i&&!c&&!b)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&&!b){let H=()=>g(E=>E+1);return v?jsx("div",{ref:I,children:jsx(v,{chart:e,error:a,retry:H})}):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 B=c||b;return jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:I,children:jsx(er,{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:B},role:"img"})})})};export{Ga as A,zt as B,Ja as C,Un as D,oi as E,pt as a,Se as b,gt as c,io as d,ht as e,wt as f,jl as g,Ct as h,Ze as i,Xe as j,xt as k,Ge as l,M as m,Fo as n,Pe as o,ke as p,Lt as q,Ye as r,xe as s,_e as t,_s as u,je as v,nt as w,En as x,st as y,Ft as z};
@@ -1,2 +0,0 @@
1
- "use client";
2
- export{n as Mermaid}from'./chunk-BEXMTOTX.js';