@lofcz/streamdown 2.6.0 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/dist/chunk-Y3ZNCRKE.js +27 -0
- package/dist/highlighted-body-FVL6SNMJ.js +2 -0
- package/dist/index.d.ts +66 -3
- package/dist/index.js +1 -1
- package/dist/lib/tailwind-classes.d.ts +26 -0
- package/dist/lib/tailwind-classes.js +1 -0
- package/dist/mermaid-R4VHL52U.js +2 -0
- package/package.json +8 -5
- package/styles.css +18 -0
- package/dist/chunk-XMZ7XVWH.js +0 -23
- package/dist/highlighted-body-T7AKFYQP.js +0 -2
- package/dist/mermaid-OOFVDMCH.js +0 -2
package/README.md
CHANGED
|
@@ -103,6 +103,47 @@ If you are already using shadcn/ui, these variables are set up automatically. If
|
|
|
103
103
|
|
|
104
104
|
You can also use the shadcn/ui [theme generator](https://ui.shadcn.com/themes) to create a custom palette and copy the generated CSS variables directly into your project.
|
|
105
105
|
|
|
106
|
+
### Tailwind v4 prefix
|
|
107
|
+
|
|
108
|
+
If you use Tailwind v4's `prefix()` option (e.g. `prefix(tw)`), Tailwind's
|
|
109
|
+
scanner cannot match unprefixed class names from Streamdown's dist files to the
|
|
110
|
+
prefixed utilities it generates. Use Tailwind's `@source inline()` directive
|
|
111
|
+
to supply the correct prefixed class list instead.
|
|
112
|
+
|
|
113
|
+
Streamdown exports a `getSourceInline` helper that generates the directive for
|
|
114
|
+
you. Run it once with a small build script and paste (or write) the output into
|
|
115
|
+
your CSS file:
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
// scripts/gen-streamdown-source.js
|
|
119
|
+
import { getSourceInline } from "streamdown/tailwind";
|
|
120
|
+
// Also import helpers from installed plugins, e.g.:
|
|
121
|
+
// import { getSourceInline as codeSource } from "@streamdown/code/tailwind";
|
|
122
|
+
|
|
123
|
+
process.stdout.write(getSourceInline("tw") + "
|
|
124
|
+
");
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
node scripts/gen-streamdown-source.js >> app/globals.css
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Or copy the generated line directly into your CSS:
|
|
132
|
+
|
|
133
|
+
```css
|
|
134
|
+
@import "tailwindcss" prefix(tw);
|
|
135
|
+
|
|
136
|
+
/* Replace 'tw' with your actual prefix: */
|
|
137
|
+
@source inline("tw:{absolute,animate-spin,appearance-none,...}");
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
You can also import the raw class array and build your own tooling:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { STREAMDOWN_CLASSES } from "streamdown/tailwind";
|
|
144
|
+
// string[] of every Tailwind class used by streamdown
|
|
145
|
+
```
|
|
146
|
+
|
|
106
147
|
## Usage
|
|
107
148
|
|
|
108
149
|
Here's how you can use Streamdown in your React application with the AI SDK:
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {createContext,memo,useContext,useRef,useEffect,useMemo,lazy,isValidElement,useId,useDeferredValue,cloneElement,createElement,useState,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import Nn from'rehype-raw';import Un,{defaultSchema}from'rehype-sanitize';import Za from'remark-gfm';import Ka 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 ma from'remark-parse';import ua from'remark-rehype';import {unified}from'unified';import {visit}from'unist-util-visit';import {Lexer}from'marked';var cr=300,dr="300px",mr=500;function Jt(e={}){let{immediate:t=false,debounceDelay:o=cr,rootMargin:n=dr,idleTimeout:r=mr}=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+$/,fr=new Set(["code","pre","svg","math","annotation"]),gr=new Set(["svg","math","annotation"]),br=new Set(["img","hr"]),Re=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",Qt=(e,t)=>{let o=t?gr:fr;return e.some(n=>Re(n)&&o.has(n.tagName))},hr=e=>{for(let t=e.length-1;t>=0;t--){let o=e[t];if(Re(o)&&o.tagName==="li")return o}},yr=(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}`;},wr=new Set(["ul","ol","li"]),eo=e=>{for(let t of e.children)if(Re(t)){if(t.tagName==="input")return t;if(wr.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`;},Cr=(e,t,o,n)=>{let r=eo(e);r&&to(r,t,o,n);},kr=(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);},xr=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},vr=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},Tr=(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}]}},Pr=(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"?vr(i):xr(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=hr(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;yr(m,I,P,o.easing),Cr(m,o,I,P),f=true;}return Tr(w,o.animation,o.duration,o.easing,v,P)});return a.children.splice(l,1,...y),l+y.length},Ir=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=Ir++,r=()=>c=>{let p={count:0,newIndex:0};t.cursor&&(o.startIndex=t.cursor.current),visitParents(c,u=>u.type==="text"||Re(u)&&br.has(u.tagName),(u,m)=>{if(u.type==="text")return Pr(u,m,t,o,p);kr(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)),We=e=>{if(e!==void 0)return typeof e=="number"?!Number.isFinite(e)||e<=0?void 0:`${e}px`:e},Lr=(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)=>Lr(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 qe=createContext(Ee),C=()=>useContext(qe);var Ar=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"),Dr=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=We(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(Ar),[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,Dr(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:""}),Ze=()=>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 zr=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
|
+
`;)t--;return e.slice(0,t)},$r=lazy(()=>import('./highlighted-body-FVL6SNMJ.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(()=>zr(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($r,{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),Xr=(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);Xr(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 Ke={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"},Xe=createContext(Ke),V=()=>useContext(Xe);var Ge=({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}=Ze(),{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}=Ze(),{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 Je=()=>{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 ss=["github-light","github-dark"],as={enabled:true},is={codeBlockMaxHeight:400,shikiTheme:ss,controls:true,isAnimating:false,lineNumbers:true,mode:"streaming",mermaid:void 0,linkSafety:as,tableMaxHeight:300},M=createContext(is);var ms=/\.[^/.]+$/,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 j=useCallback(N=>{m(true),f(false),r==null||r(N);},[r]),J=useCallback(N=>{m(false),f(true),s==null||s(N);},[s]),_=useCallback(()=>{E&&g(true);},[E]),$=useCallback(()=>{g(false);},[]),U=useCallback(N=>{a==null||a(N),!N.defaultPrevented&&_();},[a,_]),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(ms,"")}.${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:j,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 Ue=createContext(null),It=()=>useContext(Ue),Fl=()=>{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 ys=/(<svg\b)/,Do=/<svg\b[^>]*>/i,ws=/\bviewBox=(['"])(.*?)\1/i,Cs=/\swidth=(['"]).*?\1/i,ks=/\sheight=(['"]).*?\1/i,Ho=/\sstyle=(['"])(.*?)\1/i,Ao=/^<svg/i,xs=/^width\s*:/i,vs=/^height\s*:/i,Ts=/^max-width\s*:/i,Ps=/[\s,]+/,Is=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(ys,'$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(ws),r=n==null?void 0:n[2];if(!r)return null;let s=r.trim().split(Ps).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(Cs,"").replace(ks,""),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=>!(xs.test(m)||vs.test(m)||Ts.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=Is(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 Ye=({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(Ye,{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
|
+
`)},Qe=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=>Qe(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?Qe(l[d]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(d=>Qe(d));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
|
|
11
|
+
`)};var je=({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),j=new ClipboardItem({"text/plain":new Blob([E],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([j]),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})})},_e=({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(je,{}):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 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=We(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(je,{}):null,b?jsx(_e,{}):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 Js=/startLine=(\d+)/,Us=/\bnoLineNumbers\b/,Ys=lazy(()=>import('./mermaid-R4VHL52U.js').then(e=>({default:e.Mermaid}))),Qs=/language-([^\s]+)/;function nt(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&&nt(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},et=(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&&nt(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 ea=({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(ea,(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 ta=({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(Qs),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(Js),y=f?Number.parseInt(f[1],10):void 0,g=y!==void 0&&y>=1?y:void 0,h=!(b?Us.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 j=m.component;return jsx(Suspense,{fallback:jsx(Je,{}),children:jsx(j,{code:v,isIncomplete:c,language:u,meta:b})})}if(u==="mermaid"&&d){let j=At(l,"mermaid"),J=et(l,"download"),_=et(l,"copy"),$=et(l,"fullscreen"),U=et(l,"panZoom"),X=j&&(J||_||$);return jsx(Suspense,{fallback:jsx(Je,{}),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(Ye,{chart:v,config:a==null?void 0:a.config}):null,_?jsx(Ge,{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(Ys,{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(Ge,{}):null]}):null})},xn=memo(ta,(e,t)=>e.className===t.className&&nt(e.node,t.node));xn.displayName="MarkdownCode";var vn=memo(No,(e,t)=>e.className===t.className&&nt(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 oa=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,na=/\p{L}/u;function rt(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(oa.test(o))return "rtl";if(na.test(o))return "ltr"}return "ltr"}var ra=/^[ \t]{0,3}(`{3,}|~{3,})/,sa=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,Ot=e=>{let t=e.split(`
|
|
13
|
+
`),o=null,n=0;for(let r of t){let s=ra.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("|")&&sa.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},st=new WeakMap,jt=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=st.get(f);g||(g=f.name,st.set(f,g)),u+=g;}else u+=String(f);u+=":",u+=JSON.stringify(y);}else if(typeof b=="function"){let f=st.get(b);f||(f=b.name,st.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 jt,_t=e=>{let t=ga(e),o=e.children||"",n=t.runSync(t.parse(o),o);return ka(n,e)},ga=e=>{let t=Sn.get(e);if(t)return t;let o=ha(e);return Sn.set(e,o),o},ba=e=>e.some(t=>Array.isArray(t)?t[0]===Nn:t===Nn),ha=e=>{let t=e.rehypePlugins||Ln,o=e.remarkPlugins||Ln,n=ba(t)?o:[...o,Mn],r=e.remarkRehypeOptions?{...Rn,...e.remarkRehypeOptions}:Rn;return unified().use(ma).use(n).use(ua,r).use(t)},En=e=>e,ya=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},wa=(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);}},Ca=(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},ka=(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 ya(u,p,s,c.value),p;if(c.type==="element"&&(wa(c,d),Ca(c,p,u,n,r,o)&&u&&typeof p=="number"))return a&&c.children?u.children.splice(p,1,...c.children):u.children.splice(p,1),p});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var va=/\[\^[\w-]{1,200}\](?!:)/,Ta=/\[\^[\w-]{1,200}\]:/;var Pa=/<(\w+)[\s>]/,Ia=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Hn=new Map,An=new Map,Ma=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},Na=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(Ia.has(t.toLowerCase()))return 0;let o=e.match(Ma(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(Na(t));return o?o.length:0},La=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},at=e=>{let t=va.test(e),o=Ta.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(Pa);if(c){let p=c[1],u=Dn(i,p),m=Bn(i,p);u>m&&s.push(p);}}if(d>0&&!a){let c=r[d-1];if(La(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=at)=>{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 On=(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=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 Ra=/([\\`*_~[\]|])/g,Sa=e=>e.replace(Ra,"\\$1"),Vn=(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=Sa(l).replace(/\n\n/g," ");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(""):"",_n=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 Oa=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),Va=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),ja=e=>{let t=unified().use(ma).use(ua,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},Fn=(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)||!Oa(s))return;let l=Va(s);if(!l.includes(`
|
|
27
|
+
`))return;let i=ja(l);s.children=i;});};var zn=()=>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 Xa=/^[ \t]*<[\w!/?-]/,Ga=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,Ja=e=>typeof e!="string"||e.length===0||!Xa.test(e)?e:e.replace(Ga,"$1"),Zn,Kn,Xn,Gn,it={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(Kn=(Zn=defaultSchema.protocols)==null?void 0:Zn.href)!=null?Kn:[],"tel"]},attributes:{...defaultSchema.attributes,code:[...(Gn=(Xn=defaultSchema.attributes)==null?void 0:Xn.code)!=null?Gn:[],"metastring"]}},zt={raw:Nn,sanitize:[Un,it],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Ua={gfm:[Za,{}],codeMeta:zn},Wn=Object.values(zt),Ya=Object.values(Ua),qn=new WeakMap;function Qa(e){var r;let t=qn.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,[Un,o],zt.harden];return qn.set(e,n),n}var ei={block:" \u258B",circle:" \u25CF"},ti=["github-light","github-dark"],oi={enabled:true},Yn=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?Ja(e):e,d=jsx(_t,{...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)});Yn.displayName="Block";var ni=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=Wn,remarkPlugins:l=Ya,className:i,shikiTheme:d=ti,mermaid:c,codeBlockMaxHeight:p=400,controls:u=true,isAnimating:m=false,tableMaxHeight:b=300,animated:f,BlockComponent:y=Yn,parseMarkdownIntoBlocksFn:g=at,caret:w,plugins:h,remend:v,linkSafety:P=oi,lineNumbers:I=true,allowedTags:B,literalTagContent:H,translations:E,icons:j,prefix:J,onAnimationStart:_,onAnimationEnd:$,...U})=>{var Xt;let X=useId(),se=useMemo(()=>ro(J),[J]),N=useRef(null),z=useRef(_),te=useRef($);z.current=_,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=Vn(k,H)),ae.length>0&&(k=On(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=Ka(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 or=useDeferredValue(me),oe=t==="streaming"&&!x.current?or:me,ct=useMemo(()=>o==="auto"?oe.map(rt):void 0,[oe,o]),nr=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]),rr=useMemo(()=>E?JSON.stringify(E):"",[E]),qt=useMemo(()=>({...Ke,...E}),[rr]),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===Wn&&(k=Qa(B)),ae.length>0&&(k=[...k,[Fn,ae,H!=null?H:[]]]),H&&H.length>0&&(k=[...k,[_n,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]),sr=useMemo(()=>w&&m&&!dt?{"--streamdown-caret":`"${ei[w]}"`}:void 0,[w,m,dt]),ar=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(Xe.Provider,{value:qt,children:jsx(Ue.Provider,{value:h!=null?h:null,children:jsx(M.Provider,{value:Wt,children:jsx(kt,{icons:j,children:jsx(qe.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"?rt(ie):o,children:jsx(_t,{components:Zt,rehypePlugins:Ne,remarkPlugins:Kt,...U,children:ie})})})})})})}):jsx(Xe.Provider,{value:qt,children:jsx(Ue.Provider,{value:h!=null?h:null,children:jsx(M.Provider,{value:Wt,children:jsx(kt,{icons:j,children:jsx(qe.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:sr,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}=ar(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},nr[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);ni.displayName="Streamdown";var tr=({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,j]=useState(false),[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))),_(true);},[h,s]),z=useCallback(()=>{N(a);},[N,a]),te=useCallback(()=>{N(-a);},[N,a]),ae=useCallback(()=>{I(g),H({x:0,y:0}),_(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;j(true),_(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=>{j(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&&_(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),j=e.split("").reduce((X,se)=>(X<<5)-X+se.charCodeAt(0)|0,0),J=`mermaid-${Math.abs(j)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:_}=await E.render(J,e),$=Mt(_),U=n?_:Oo(_);p(U),m($),f(U);}catch(E){if(!(b||c)){let j=E instanceof Error?E.message:"Failed to render Mermaid chart";l(j);}}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(tr,{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{Ja as A,zt as B,Ua as C,Yn as D,ni as E,pt as a,Se as b,gt as c,io as d,ht as e,wt as f,Fl as g,Ct as h,Ke as i,Ge as j,xt as k,Je as l,M as m,Fo as n,Pe as o,ke as p,Lt as q,Qe as r,xe as s,je as t,_s as u,_e as v,rt as w,En as x,at as y,Ft as z};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {m,g,d}from'./chunk-Y3ZNCRKE.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
|
@@ -5,10 +5,20 @@ import { RemendOptions } from 'remend';
|
|
|
5
5
|
import { Pluggable, PluggableList } from 'unified';
|
|
6
6
|
import { Element, Parents } from 'hast';
|
|
7
7
|
import { Options as Options$1 } from 'remark-rehype';
|
|
8
|
-
import { MermaidConfig } from 'mermaid';
|
|
9
8
|
import { BundledTheme, ThemeRegistrationAny, BundledLanguage } from 'shiki';
|
|
10
9
|
export { BundledLanguage, BundledTheme, ThemeRegistrationAny } from 'shiki';
|
|
11
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Shared cursor used to chain stagger delays across sibling blocks in a
|
|
13
|
+
* single render pass. Create one instance per Streamdown component and
|
|
14
|
+
* reset `cursor.current = 0` before each React render so that block 0
|
|
15
|
+
* starts at index 0 and each subsequent block continues from where the
|
|
16
|
+
* previous one left off.
|
|
17
|
+
*/
|
|
18
|
+
interface AnimateCursor {
|
|
19
|
+
current: number;
|
|
20
|
+
}
|
|
21
|
+
declare function createAnimateCursor(): AnimateCursor;
|
|
12
22
|
interface AnimatePlugin {
|
|
13
23
|
/**
|
|
14
24
|
* Returns the total HAST text node character count from the last
|
|
@@ -16,18 +26,46 @@ interface AnimatePlugin {
|
|
|
16
26
|
* setPrevContentLength on the next render.
|
|
17
27
|
*/
|
|
18
28
|
getLastRenderCharCount: () => number;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the number of newly-animated words from the last rehype run,
|
|
31
|
+
* then resets to 0. Pass this value to setStartIndex() on the next
|
|
32
|
+
* sibling block so its stagger delays chain after ours.
|
|
33
|
+
*/
|
|
34
|
+
getLastRenderNewWordCount: () => number;
|
|
19
35
|
name: "animate";
|
|
20
36
|
rehypePlugin: Pluggable;
|
|
37
|
+
/**
|
|
38
|
+
* Enable or disable animation inside code/pre blocks.
|
|
39
|
+
* When true, code block content will be animated incrementally
|
|
40
|
+
* during streaming (useful for incomplete/unclosed code fences).
|
|
41
|
+
*/
|
|
42
|
+
setAnimateCodeBlocks: (enabled: boolean) => void;
|
|
21
43
|
/**
|
|
22
44
|
* Set the number of HAST text characters from a previous render.
|
|
23
45
|
* Characters up to this count will get duration=0ms, preventing
|
|
24
46
|
* re-animation of already-visible content during streaming updates.
|
|
25
47
|
*/
|
|
26
48
|
setPrevContentLength: (length: number) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Set the animation word index to start from. Used when no shared
|
|
51
|
+
* cursor is provided. Use the value returned by
|
|
52
|
+
* getLastRenderNewWordCount() from the previous sibling block to
|
|
53
|
+
* ensure that a new block's stagger delays begin after the previous
|
|
54
|
+
* block's animation is still completing, preventing concurrent reveals.
|
|
55
|
+
*/
|
|
56
|
+
setStartIndex: (index: number) => void;
|
|
27
57
|
type: "animate";
|
|
28
58
|
}
|
|
29
59
|
interface AnimateOptions {
|
|
30
60
|
animation?: "fadeIn" | "blurIn" | "slideUp" | (string & {});
|
|
61
|
+
/**
|
|
62
|
+
* Shared cursor for automatic cross-block stagger chaining. When
|
|
63
|
+
* provided the plugin reads `cursor.current` as the start index and
|
|
64
|
+
* increments it by the number of newly animated words after each run,
|
|
65
|
+
* so sibling blocks automatically pick up where the previous one left
|
|
66
|
+
* off without any manual `setStartIndex` calls.
|
|
67
|
+
*/
|
|
68
|
+
cursor?: AnimateCursor;
|
|
31
69
|
duration?: number;
|
|
32
70
|
easing?: string;
|
|
33
71
|
sep?: "word" | "char";
|
|
@@ -77,6 +115,14 @@ interface Options {
|
|
|
77
115
|
}
|
|
78
116
|
declare const defaultUrlTransform: UrlTransform;
|
|
79
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Structural type for Mermaid configuration.
|
|
120
|
+
* Avoids a hard dependency on the "mermaid" package in the core bundle.
|
|
121
|
+
* Users who need full type safety can import MermaidConfig from "mermaid"
|
|
122
|
+
* directly — it is structurally compatible with this type.
|
|
123
|
+
*/
|
|
124
|
+
type MermaidConfig = Record<string, any>;
|
|
125
|
+
|
|
80
126
|
type ThemeInput = BundledTheme | ThemeRegistrationAny;
|
|
81
127
|
/**
|
|
82
128
|
* A single token in a highlighted line
|
|
@@ -262,6 +308,8 @@ interface MermaidOptions {
|
|
|
262
308
|
errorComponent?: React.ComponentType<MermaidErrorComponentProps>;
|
|
263
309
|
}
|
|
264
310
|
interface StreamdownContextType {
|
|
311
|
+
/** Max height for code blocks (px number or CSS length). `0` / `Infinity` disables. @default 400 */
|
|
312
|
+
codeBlockMaxHeight?: number | string;
|
|
265
313
|
controls: ControlsConfig;
|
|
266
314
|
isAnimating: boolean;
|
|
267
315
|
/** Show line numbers in code blocks. @default true */
|
|
@@ -270,6 +318,8 @@ interface StreamdownContextType {
|
|
|
270
318
|
mermaid?: MermaidOptions;
|
|
271
319
|
mode: "static" | "streaming";
|
|
272
320
|
shikiTheme: [ThemeInput, ThemeInput];
|
|
321
|
+
/** Max height for tables (px number or CSS length). `0` / `Infinity` disables. @default 300 */
|
|
322
|
+
tableMaxHeight?: number | string;
|
|
273
323
|
}
|
|
274
324
|
declare const StreamdownContext: react.Context<StreamdownContextType>;
|
|
275
325
|
|
|
@@ -374,6 +424,17 @@ declare const CodeBlockSkeleton: () => react_jsx_runtime.JSX.Element;
|
|
|
374
424
|
declare function detectTextDirection(text: string): "ltr" | "rtl";
|
|
375
425
|
|
|
376
426
|
declare const parseMarkdownIntoBlocks: (markdown: string) => string[];
|
|
427
|
+
interface IncrementalParseState {
|
|
428
|
+
blocks: string[];
|
|
429
|
+
/** Tag-preprocessed markdown that produced `blocks` (before last-block remend). */
|
|
430
|
+
source: string;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Append-only parse for streaming: keep settled prefix blocks by identity and
|
|
434
|
+
* only re-lex the unfinished tail. Falls back to a full parse when the source
|
|
435
|
+
* is not a pure append (edits, rewinds, or structural shifts).
|
|
436
|
+
*/
|
|
437
|
+
declare const parseMarkdownIntoBlocksIncremental: (markdown: string, prev: IncrementalParseState | null | undefined, parseFn?: (value: string) => string[]) => IncrementalParseState;
|
|
377
438
|
|
|
378
439
|
interface TableCopyDropdownProps {
|
|
379
440
|
children?: React.ReactNode;
|
|
@@ -435,8 +496,10 @@ type StreamdownProps = Options & {
|
|
|
435
496
|
className?: string;
|
|
436
497
|
shikiTheme?: [ThemeInput, ThemeInput];
|
|
437
498
|
mermaid?: MermaidOptions;
|
|
499
|
+
codeBlockMaxHeight?: number | string;
|
|
438
500
|
controls?: ControlsConfig;
|
|
439
501
|
isAnimating?: boolean;
|
|
502
|
+
tableMaxHeight?: number | string;
|
|
440
503
|
animated?: boolean | AnimateOptions;
|
|
441
504
|
caret?: keyof typeof carets;
|
|
442
505
|
plugins?: PluginConfig;
|
|
@@ -492,6 +555,6 @@ type BlockProps = Options & {
|
|
|
492
555
|
animatePlugin?: AnimatePlugin | null;
|
|
493
556
|
};
|
|
494
557
|
declare const Block: react.MemoExoticComponent<({ content, shouldParseIncompleteMarkdown: _, shouldNormalizeHtmlIndentation, index: __, isIncomplete, dir, animatePlugin: animatePluginProp, ...props }: BlockProps) => react_jsx_runtime.JSX.Element>;
|
|
495
|
-
declare const Streamdown: react.MemoExoticComponent<({ children, mode, dir, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, normalizeHtmlIndentation: shouldNormalizeHtmlIndentation, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, controls, isAnimating, animated, BlockComponent, parseMarkdownIntoBlocksFn, caret, plugins, remend: remendOptions, linkSafety, lineNumbers, allowedTags, literalTagContent, translations, icons: iconOverrides, prefix, onAnimationStart, onAnimationEnd, ...props }: StreamdownProps) => 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>;
|
|
496
559
|
|
|
497
|
-
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 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, createAnimatePlugin, defaultRehypePlugins, defaultRemarkPlugins, defaultTranslations, defaultUrlTransform, detectTextDirection, escapeMarkdownTableCell, extractTableDataFromElement, normalizeHtmlIndentation, parseMarkdownIntoBlocks, tableDataToCSV, tableDataToMarkdown, tableDataToTSV, useIsCodeFenceIncomplete };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export{
|
|
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-Y3ZNCRKE.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Complete list of Tailwind CSS utility classes used by streamdown and its
|
|
3
|
+
* official plugins (@streamdown/code, @streamdown/math, @streamdown/mermaid,
|
|
4
|
+
* @streamdown/cjk).
|
|
5
|
+
*
|
|
6
|
+
* Use this list to configure Tailwind v4's `@source inline()` directive when
|
|
7
|
+
* you need a custom prefix. See the README for details.
|
|
8
|
+
*/
|
|
9
|
+
declare const STREAMDOWN_CLASSES: readonly string[];
|
|
10
|
+
/**
|
|
11
|
+
* Generates a Tailwind v4 `@source inline()` directive containing all
|
|
12
|
+
* streamdown classes, optionally prefixed.
|
|
13
|
+
*
|
|
14
|
+
* @param prefix - Tailwind v4 prefix string (e.g. `"tw"` for `prefix(tw)`).
|
|
15
|
+
* Omit or pass `undefined` when you are not using a prefix.
|
|
16
|
+
* @returns A ready-to-paste CSS `@source inline(...)` rule string.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // In a postcss.config.js build script, write this string to a CSS file:
|
|
20
|
+
* import { getSourceInline } from 'streamdown/tailwind';
|
|
21
|
+
* console.log(getSourceInline('tw'));
|
|
22
|
+
* // → @source inline("tw:{absolute,animate-spin,...}");
|
|
23
|
+
*/
|
|
24
|
+
declare function getSourceInline(prefix?: string): string;
|
|
25
|
+
|
|
26
|
+
export { STREAMDOWN_CLASSES, getSourceInline };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=["-mt-10","[&>p]:inline","[&_svg]:h-auto","[&_svg]:w-auto","[counter-increment:line_0]","[counter-reset:line]","[li_&]:pl-6","absolute","animate-spin","appearance-none","backdrop-blur-sm","before:[counter-increment:line]","before:content-[counter(line)]","before:font-mono","before:inline-block","before:mr-4","before:select-none","before:text-[13px]","before:text-muted-foreground/50","before:text-right","before:w-6","bg-[var(--sdm-bg,inherit]","bg-[var(--sdm-tbg)]","bg-background","bg-background/50","bg-background/80","bg-background/90","bg-background/95","bg-black/10","bg-muted","bg-muted/40","bg-muted/80","bg-primary","bg-red-100","bg-red-50","bg-sidebar","bg-sidebar/80","block","border","border-b","border-b-2","border-border","border-collapse","border-current","border-l-4","border-muted-foreground/30","border-red-200","border-sidebar","border-t","bottom-2","bottom-4","break-all","cursor-pointer","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]","disabled:cursor-not-allowed","disabled:opacity-50","divide-border","divide-y","duration-150","duration-200","ease-out","fixed","flex","flex-1","flex-col","font-medium","font-mono","font-semibold","gap-1","gap-2","gap-4","group","group-hover:block","group-hover:opacity-100","h-4","h-8","h-[46px]","h-auto","h-full","hidden","hover:bg-background","hover:bg-muted","hover:bg-muted/40","hover:bg-primary/90","hover:text-foreground","inline-block","inset-0","italic","items-center","justify-between","justify-center","justify-end","left-2","left-4","list-decimal","list-disc","list-inside","lowercase","max-h-32","max-w-full","max-w-md","mb-2","min-h-28","min-h-[200px]","min-w-[120px]","ml-1","mt-1","mt-2","mt-6","mx-4","my-4","my-6","opacity-0","origin-center","overflow-hidden","overflow-x-auto","overflow-y-auto","overscroll-y-auto","p-1","p-1.5","p-2","p-3","p-4","p-6","pl-4","pointer-events-auto","pointer-events-none","px-1.5","px-3","px-4","py-0.5","py-1","py-2","relative","right-0","right-2","right-4","rounded","rounded-full","rounded-lg","rounded-md","rounded-xl","shadow-lg","shadow-sm","shrink-0","size-4","size-full","space-x-2","space-y-2","space-y-4","sticky","table-fixed","supports-[backdrop-filter]:backdrop-blur","supports-[backdrop-filter]:backdrop-blur-sm","supports-[backdrop-filter]:bg-background/70","supports-[backdrop-filter]:bg-sidebar/70","text-2xl","text-3xl","text-[var(--sdm-c,inherit)]","text-base","text-left","text-lg","text-muted-foreground","text-primary","text-primary-foreground","text-red-600","text-red-700","text-red-800","text-sm","text-xl","text-xs","top-2","top-4","top-full","transition-all","transition-colors","transition-transform","w-4","w-8","w-full","whitespace-normal","whitespace-nowrap","wrap-anywhere","z-10","z-50"];function n(e){let r=[...t];return `@source inline("${e?`${e}:{${r.join(",")}}`:`{${r.join(",")}}`}");`}export{t as STREAMDOWN_CLASSES,n as getSourceInline};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofcz/streamdown",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./styles.css": "./styles.css"
|
|
13
|
+
"./styles.css": "./styles.css",
|
|
14
|
+
"./tailwind": {
|
|
15
|
+
"types": "./dist/tailwind-classes.d.ts",
|
|
16
|
+
"import": "./dist/tailwind-classes.js"
|
|
17
|
+
}
|
|
14
18
|
},
|
|
15
19
|
"files": [
|
|
16
20
|
"dist",
|
|
@@ -46,8 +50,8 @@
|
|
|
46
50
|
"tsup": "^8.5.1",
|
|
47
51
|
"vitest": "^4.0.15",
|
|
48
52
|
"@streamdown/cjk": "npm:@lofcz/streamdown-cjk@1.0.3",
|
|
49
|
-
"@streamdown/
|
|
50
|
-
"@streamdown/
|
|
53
|
+
"@streamdown/mermaid": "npm:@lofcz/streamdown-mermaid@1.0.2",
|
|
54
|
+
"@streamdown/math": "npm:@lofcz/streamdown-math@1.0.2"
|
|
51
55
|
},
|
|
52
56
|
"peerDependencies": {
|
|
53
57
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -67,7 +71,6 @@
|
|
|
67
71
|
"remend": "npm:@lofcz/remend@^1.3.0",
|
|
68
72
|
"tailwind-merge": "^3.4.0",
|
|
69
73
|
"unified": "^11.0.5",
|
|
70
|
-
"mermaid": "^11.12.2",
|
|
71
74
|
"unist-util-visit": "^5.0.0",
|
|
72
75
|
"unist-util-visit-parents": "^6.0.0"
|
|
73
76
|
},
|
package/styles.css
CHANGED
|
@@ -33,3 +33,21 @@
|
|
|
33
33
|
animation: var(--sd-animation, sd-fadeIn) var(--sd-duration, 150ms)
|
|
34
34
|
var(--sd-easing, ease) var(--sd-delay, 0ms) both;
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* List markers (the disc/decimal glyph) are painted by the browser's
|
|
39
|
+
* ::marker pseudo-element, which the animate plugin can't wrap in a
|
|
40
|
+
* span. ::marker also doesn't honor opacity/transform animations, so we
|
|
41
|
+
* fade it in via color (which it does support) instead, synced to the
|
|
42
|
+
* timing the plugin stamps from the item's first word.
|
|
43
|
+
*/
|
|
44
|
+
@keyframes sd-markerIn {
|
|
45
|
+
from {
|
|
46
|
+
color: transparent;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
[data-sd-animate-marker]::marker {
|
|
51
|
+
animation: sd-markerIn var(--sd-marker-duration, 150ms)
|
|
52
|
+
var(--sd-marker-easing, ease) var(--sd-marker-delay, 0ms) both;
|
|
53
|
+
}
|
package/dist/chunk-XMZ7XVWH.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {createContext,memo,useContext,useMemo,lazy,isValidElement,useId,useTransition,useRef,useEffect,useState,cloneElement,createElement,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import on from'rehype-raw';import Pn,{defaultSchema}from'rehype-sanitize';import Js from'remark-gfm';import Us 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 ks from'remark-parse';import xs from'remark-rehype';import {unified}from'unified';import {visit}from'unist-util-visit';import {Lexer}from'marked';var An=300,On="300px",Vn=500;function Dt(e={}){let{immediate:t=false,debounceDelay:o=An,rootMargin:n=On,idleTimeout:r=Vn}=e,[s,a]=useState(false),l=useRef(null),i=useRef(null),d=useRef(null),c=useMemo(()=>u=>{let f=Date.now();return window.setTimeout(()=>{u({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-f))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(u,f)=>window.requestIdleCallback(u,f):c,[c]),m=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?u=>window.cancelIdleCallback(u):u=>{clearTimeout(u);},[]);return useEffect(()=>{if(t){a(true);return}let u=l.current;if(!u)return;i.current&&(clearTimeout(i.current),i.current=null),d.current&&(m(d.current),d.current=null);let f=()=>{i.current&&(clearTimeout(i.current),i.current=null),d.current&&(m(d.current),d.current=null);},h=v=>{d.current=p(C=>{C.timeRemaining()>0||C.didTimeout?(a(true),v.disconnect()):d.current=p(()=>{a(true),v.disconnect();},{timeout:r/2});},{timeout:r});},b=v=>{f(),i.current=window.setTimeout(()=>{var N,E;let C=v.takeRecords();(C.length===0||(E=(N=C.at(-1))==null?void 0:N.isIntersecting)!=null&&E)&&h(v);},o);},g=(v,C)=>{v.isIntersecting?b(C):f();},T=new IntersectionObserver(v=>{for(let C of v)g(C,T);},{rootMargin:n,threshold:0});return T.observe(u),()=>{i.current&&clearTimeout(i.current),d.current&&m(d.current),T.disconnect();}},[t,o,n,r,m,p]),{shouldRender:s,containerRef:l}}var Bt=/\s/,zn=/^\s+$/,_n=new Set(["code","pre","svg","math","annotation"]),qn=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",$n=e=>e.some(t=>qn(t)&&_n.has(t.tagName)),Wn=e=>{let t=[],o="",n=false;for(let r of e){let s=Bt.test(r);s!==n&&o&&(t.push(o),o=""),o+=r,n=s;}return o&&t.push(o),t},Zn=e=>{let t=[],o="";for(let n of e)Bt.test(n)?o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&t.push(o),t},Xn=(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}]}},Kn=(e,t,o,n,r)=>{let s=t.at(-1);if(!(s&&"children"in s))return;if($n(t))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"?Zn(i):Wn(i),c=n.prevContentLength,p=d.map(m=>{let u=r.count;if(r.count+=m.length,zn.test(m))return {type:"text",value:m};let f=c>0&&u<c,h=f?0:r.newIndex++*o.stagger;return Xn(m,o.animation,o.duration,o.easing,f,h)});return a.children.splice(l,1,...p),l+p.length},Jn=0;function xe(e){var s,a,l,i,d;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",duration:(a=e==null?void 0:e.duration)!=null?a:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(d=e==null?void 0:e.stagger)!=null?d:40},o={prevContentLength:0,lastRenderCharCount:0},n=Jn++,r=()=>c=>{let p={count:0,newIndex:0};visitParents(c,"text",(m,u)=>Kn(m,u,t,o,p)),o.lastRenderCharCount=p.count,o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setPrevContentLength(c){o.prevContentLength=c;},getLastRenderCharCount(){let c=o.lastRenderCharCount;return o.lastRenderCharCount=0,c}}}xe();var nt=createContext(false),rt=()=>useContext(nt);var ve=(...e)=>twMerge(clsx(e)),Yn=(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(" ")},Vt=e=>e?(...t)=>Yn(e,twMerge(clsx(t))):ve,K=(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 Oe=createContext(ve),w=()=>useContext(Oe);var or=ve("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"),nr=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},Ft=memo(({children:e,result:t,language:o,className:n,startLine:r,lineNumbers:s=true,...a})=>{let l=w(),i=useMemo(()=>l(or),[l]),d=useMemo(()=>{let c={};return t.bg&&(c["--sdm-bg"]=t.bg),t.fg&&(c["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(c,nr(t.rootStyle)),c},[t.bg,t.fg,t.rootStyle]);return jsx("div",{className:l(n,"overflow-x-auto rounded-md border border-border bg-background p-4 text-sm"),"data-language":o,"data-streamdown":"code-block-body",...a,children:jsx("pre",{className:l(n,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:d,children:jsx("code",{className:s?l("[counter-increment:line_0] [counter-reset:line]"):void 0,style:s&&r&&r>1?{counterReset:`line ${r-1}`}:void 0,children:t.tokens.map((c,p)=>jsx("span",{className:s?i:void 0,children:c.length===0||c.length===1&&c[0].content===""?`
|
|
3
|
-
`:c.map((m,u)=>{let f={},h=!!m.bgColor;if(m.color&&(f["--sdm-c"]=m.color),m.bgColor&&(f["--sdm-tbg"]=m.bgColor),m.htmlStyle)for(let[b,g]of Object.entries(m.htmlStyle))b==="color"?f["--sdm-c"]=g:b==="background-color"?(f["--sdm-tbg"]=g,h=true):f[b]=g;return jsx("span",{className:l("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:f,...m.htmlAttrs,children:m.content},u)})},p))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers);var st=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let s=w();return jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r})};var at=createContext({code:""}),Ve=()=>useContext(at);var it=({language:e})=>{let t=w();return jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var cr=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
|
-
`;)t--;return e.slice(0,t)},dr=lazy(()=>import('./highlighted-body-T7AKFYQP.js').then(e=>({default:e.HighlightedCodeBlockBody}))),lt=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,lineNumbers:a,...l})=>{let i=w(),d=useMemo(()=>cr(e),[e]),c=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
|
|
5
|
-
`).map(p=>[{content:p,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]);return jsx(at.Provider,{value:{code:e},children:jsxs(st,{isIncomplete:r,language:t,children:[jsx(it,{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(Ft,{className:o,language:t,lineNumbers:a,result:c,startLine:s,...l}),children:jsx(dr,{className:o,code:d,language:t,lineNumbers:a,raw:c,startLine:s,...l})})]})})};var qt=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"})}),$t=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"})}),Wt=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"})}),Zt=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"})]}),Xt=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"})}),Kt=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"})}),Jt=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"})}),Ut=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"})}),Gt=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"})}),Yt=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 Pe={CheckIcon:qt,CopyIcon:$t,DownloadIcon:Wt,ExternalLinkIcon:Ut,Loader2Icon:Zt,Maximize2Icon:Xt,RotateCcwIcon:Kt,XIcon:Jt,ZoomInIcon:Gt,ZoomOutIcon:Yt},eo=createContext(Pe),gr=(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])},ct=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...Pe,...e}:Pe);gr(o.current,e)||(o.current=e,n.current=e?{...Pe,...e}:Pe);let r=n.current;return jsx(eo.Provider,{value:r,children:t})},S=()=>useContext(eo);var je={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"},Fe=createContext(je),B=()=>useContext(Fe);var ze=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let l=w(),[i,d]=useState(false),c=useRef(0),{code:p}=Ve(),{isAnimating:m}=useContext(M),u=B(),f=s!=null?s:p,h=async()=>{var T;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(f),d(!0),e==null||e(),c.current=window.setTimeout(()=>d(!1),o));}catch(v){t==null||t(v);}};useEffect(()=>()=>{window.clearTimeout(c.current);},[]);let b=S(),g=i?b.CheckIcon:b.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:m,onClick:h,title:u.copyCode,type:"button",...a,children:n!=null?n:jsx(g,{size:14})})};var oo={"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"},dt=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let l=w(),{code:i}=Ve(),{isAnimating:d}=useContext(M),c=B(),p=S(),m=s!=null?s:i,f=`file.${o&&o in oo?oo[o]:"txt"}`,h="text/plain",b=()=>{try{K(f,m,h),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:b,title:c.downloadFile,type:"button",...a,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var _e=()=>{let{Loader2Icon:e}=S(),t=w();return jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:jsx(e,{className:t("size-4 animate-spin")})})]})};var Me=0,te=()=>{Me+=1,Me===1&&(document.body.style.overflow="hidden");},oe=()=>{Me=Math.max(0,Me-1),Me===0&&(document.body.style.overflow="");};var Mr=["github-light","github-dark"],Ir={enabled:true},Nr={shikiTheme:Mr,controls:true,isAnimating:false,lineNumbers:true,mode:"streaming",mermaid:void 0,linkSafety:Ir},M=createContext(Nr);var Er=/\.[^/.]+$/,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},ao=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,onClick:a,...l})=>{let{DownloadIcon:i,XIcon:d}=S(),c=w(),p=useRef(null),[m,u]=useState(false),[f,h]=useState(false),[b,g]=useState(false),{controls:T}=useContext(M),v=B(),C=so(T,"download"),I=so(T,"fullscreen"),N=l.width!=null||l.height!=null,E=C&&(m||N)&&!f,D=f&&!N,F=I&&!!o&&!f&&m;useEffect(()=>{let y=p.current;if(y!=null&&y.complete){let H=y.naturalWidth>0;u(H),h(!H);}},[]),useEffect(()=>{if(!b)return;te();let y=H=>{H.key==="Escape"&&g(false);};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y),oe();}},[b]);let z=useCallback(y=>{u(true),h(false),r==null||r(y);},[r]),W=useCallback(y=>{u(false),h(true),s==null||s(y);},[s]),_=useCallback(()=>{F&&g(true);},[F]),Z=useCallback(()=>{g(false);},[]),Q=useCallback(y=>{a==null||a(y),!y.defaultPrevented&&_();},[a,_]),X=async y=>{if(y.stopPropagation(),!!o)try{let q=await(await fetch(o)).blob(),ee=new URL(o,window.location.origin).pathname.split("/").pop()||"",se=ee.split(".").pop(),ae=ee.includes(".")&&se!==void 0&&se.length<=4,Ce="";if(ae)Ce=ee;else {let G=q.type,A="png";G.includes("jpeg")||G.includes("jpg")?A="jpg":G.includes("png")?A="png":G.includes("svg")?A="svg":G.includes("gif")?A="gif":G.includes("webp")&&(A="webp"),Ce=`${(n||ee||"image").replace(Er,"")}.${A}`;}K(Ce,q,q.type);}catch(H){window.open(o,"_blank");}};return o?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",F&&"cursor-zoom-in",D&&"hidden",t),"data-streamdown":"image",onClick:Q,onError:W,onLoad:z,ref:p,src:o,...l}),D&&jsx("span",{className:c("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:v.imageNotAvailable}),E&&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:v.downloadImage,type:"button",children:jsx(i,{size:14})})]}),b?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:Z,onKeyDown:y=>{y.key==="Escape"&&Z();},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:Z,title:v.exitFullscreen,type:"button",children:jsx(d,{size:20})}),jsx("div",{onClick:y=>y.stopPropagation(),onKeyDown:y=>y.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 co=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=S(),i=w(),[d,c]=useState(false),p=B(),m=useCallback(async()=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3);}catch(f){}},[e]),u=useCallback(()=>{n(),o();},[n,o]);return useEffect(()=>{if(t){te();let f=h=>{h.key==="Escape"&&o();};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),oe();}}},[t,o]),t?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:m,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:u,type:"button",children:[jsx(a,{size:14}),jsx("span",{children:p.openLink})]})]})]})}):null};var qe=createContext(null),ft=()=>useContext(qe),Fi=()=>{var t;let e=ft();return (t=e==null?void 0:e.code)!=null?t:null},ge=()=>{var t;let e=ft();return (t=e==null?void 0:e.mermaid)!=null?t:null};var mo=e=>{var o;let t=ft();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 uo=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),l=new Image;l.crossOrigin="anonymous",l.onload=()=>{let i=document.createElement("canvas"),d=l.width*o,c=l.height*o;i.width=d,i.height=c;let p=i.getContext("2d");if(!p){s(new Error("Failed to create 2D canvas context for PNG export"));return}p.drawImage(l,0,0,d,c),i.toBlob(m=>{if(!m){s(new Error("Failed to create PNG blob"));return}r(m);},"image/png");},l.onerror=()=>s(new Error("Failed to load SVG image")),l.src=a;})};var fo=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=w(),[l,i]=useState(false),d=useRef(null),{isAnimating:c}=useContext(M),p=S(),m=ge(),u=B(),f=async h=>{try{if(h==="mmd"){K("diagram.mmd",e,"text/plain"),i(!1),n==null||n(h);return}if(!m){s==null||s(new Error("Mermaid plugin not available"));return}let b=m.getMermaid(r),g=e.split("").reduce((C,I)=>(C<<5)-C+I.charCodeAt(0)|0,0),T=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:v}=await b.render(T,e);if(!v){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(h==="svg"){K("diagram.svg",v,"image/svg+xml"),i(!1),n==null||n(h);return}if(h==="png"){let C=await uo(v);K("diagram.png",C,"image/png"),n==null||n(h),i(!1);return}}catch(b){s==null||s(b);}};return useEffect(()=>{let h=b=>{let g=b.composedPath();d.current&&!g.includes(d.current)&&i(false);};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h);}},[]),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:u.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:()=>f("svg"),title:u.downloadDiagramAsSvg,type:"button",children:u.mermaidFormatSvg}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("png"),title:u.downloadDiagramAsPng,type:"button",children:u.mermaidFormatPng}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("mmd"),title:u.downloadDiagramAsMmd,type:"button",children:u.mermaidFormatMmd})]}):null]})};var yo=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=S(),i=w(),[d,c]=useState(false),{isAnimating:p,controls:m}=useContext(M),u=B(),f=(()=>{if(typeof m=="boolean")return m;let b=m.mermaid;return b===false?false:b===true||b===void 0?true:b.panZoom!==false})(),h=()=>{c(!d);};return useEffect(()=>{if(d){te();let b=g=>{g.key==="Escape"&&c(false);};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),oe();}}},[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:h,title:u.viewFullscreen,type:"button",...s,children:jsx(a,{size:14})}),d?createPortal(jsxs("div",{className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),onClick:h,onKeyDown:b=>{b.key==="Escape"&&h();},role:"button",tabIndex:0,children:[jsx("button",{className:i("absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:u.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(ho,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:f})})]}),document.body):null]})};var he=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}},de=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
|
-
`)},gt=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
|
-
`)},$e=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("")},me=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=>$e(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?$e(l[d]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(d=>$e(d));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
|
|
11
|
-
`)};var Se=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=w(),[a,l]=useState(false),[i,d]=useState(false),c=useRef(null),p=useRef(0),{isAnimating:m}=useContext(M),u=B(),f=async g=>{var T,v;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.write)){n==null||n(new Error("Clipboard API not available"));return}try{let C=(v=c.current)==null?void 0:v.closest('[data-streamdown="table-wrapper"]'),I=C==null?void 0:C.querySelector("table");if(!I){n==null||n(new Error("Table not found"));return}let N=he(I),F=({csv:de,tsv:gt,md:me}[g]||me)(N),z=new ClipboardItem({"text/plain":new Blob([F],{type:"text/plain"}),"text/html":new Blob([I.outerHTML],{type:"text/html"})});await navigator.clipboard.write([z]),d(!0),l(!1),o==null||o(g),p.current=window.setTimeout(()=>d(!1),r);}catch(C){n==null||n(C);}};useEffect(()=>{let g=T=>{let v=T.composedPath();c.current&&!v.includes(c.current)&&l(false);};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g),window.clearTimeout(p.current);}},[]);let h=S(),b=i?h.CheckIcon:h.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:m,onClick:()=>l(!a),title:u.copyTable,type:"button",children:e!=null?e:jsx(b,{height:14,width:14})}),a?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("md"),title:u.copyTableAsMarkdown,type:"button",children:u.tableFormatMarkdown}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("csv"),title:u.copyTableAsCsv,type:"button",children:u.tableFormatCsv}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("tsv"),title:u.copyTableAsTsv,type:"button",children:u.tableFormatTsv})]}):null]})};var Gr=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:s})=>{let a=w(),{isAnimating:l}=useContext(M),i=B(),d=S(),c=p=>{try{let u=p.currentTarget.closest('[data-streamdown="table-wrapper"]'),f=u==null?void 0:u.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let h=he(f),b="",g="",T="";switch(r){case "csv":b=de(h),g="text/csv",T="csv";break;case "markdown":b=me(h),g="text/markdown",T="md";break;default:b=de(h),g="text/csv",T="csv";}K(`${s||"table"}.${T}`,b,g),o==null||o();}catch(m){n==null||n(m);}};return jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:c,title:r==="csv"?i.downloadTableAsCsv:i.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d.DownloadIcon,{size:14})})},Re=({children:e,className:t,onDownload:o,onError:n})=>{let r=w(),[s,a]=useState(false),l=useRef(null),{isAnimating:i}=useContext(M),d=B(),c=S(),p=m=>{var u;try{let f=(u=l.current)==null?void 0:u.closest('[data-streamdown="table-wrapper"]'),h=f==null?void 0:f.querySelector("table");if(!h){n==null||n(new Error("Table not found"));return}let b=he(h),g=m==="csv"?de(b):me(b);K(`table.${m==="csv"?"csv":"md"}`,g,m==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(m);}catch(f){n==null||n(f);}};return useEffect(()=>{let m=u=>{let f=u.composedPath();l.current&&!f.includes(l.current)&&a(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),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 To=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=S(),a=w(),[l,i]=useState(false),{isAnimating:d}=useContext(M),c=B(),p=()=>{i(true);},m=()=>{i(false);};return useEffect(()=>{if(l){te();let u=f=>{f.key==="Escape"&&i(false);};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u),oe();}}},[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:m,onKeyDown:u=>{u.key==="Escape"&&m();},role:"dialog",children:jsxs("div",{className:a("flex h-full flex-col"),onClick:u=>u.stopPropagation(),onKeyDown:u=>u.stopPropagation(),role:"presentation",children:[jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[o?jsx(Se,{}):null,n?jsx(Re,{}):null,jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:m,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 border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})};var Mo=({children:e,className:t,showControls:o,showCopy:n=true,showDownload:r=true,showFullscreen:s=true,...a})=>{let l=w(),i=o&&n,d=o&&r,c=o&&s,p=i||d||c;return jsxs("div",{className:l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[p?jsxs("div",{className:l("flex items-center justify-end gap-1"),children:[i?jsx(Se,{}):null,d?jsx(Re,{}):null,c?jsx(To,{showCopy:i,showDownload:d,children:e}):null]}):null,jsx("div",{className:l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),children:jsx("table",{className:l("w-full divide-y divide-border",t),"data-streamdown":"table",...a,children:e})})]})};var as=/startLine=(\d+)/,is=/\bnoLineNumbers\b/,ls=lazy(()=>import('./mermaid-OOFVDMCH.js').then(e=>({default:e.Mermaid}))),cs=/language-([^\s]+)/;function Ke(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)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function R(e,t){return e.className===t.className&&Ke(e.node,t.node)}var wt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,yt=(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},No=(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},We=(e,t)=>{if(typeof e=="boolean")return e;let o=e.mermaid;return o===false?false:o===true||o===void 0?true:o[t]!==false},kt=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e})},(e,t)=>R(e,t));kt.displayName="MarkdownOl";var Lo=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("li",{className:r("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e})},(e,t)=>e.className===t.className&&Ke(e.node,t.node));Lo.displayName="MarkdownLi";var So=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("ul",{className:r("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e})},(e,t)=>R(e,t));So.displayName="MarkdownUl";var Ro=memo(({className:e,node:t,...o})=>{let n=w();return jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>R(e,t));Ro.displayName="MarkdownHr";var Eo=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>R(e,t));Eo.displayName="MarkdownStrong";var ds=({children:e,className:t,href:o,node:n,...r})=>{let s=w(),{linkSafety:a}=useContext(M),[l,i]=useState(false),d=o==="streamdown:incomplete-link",c=useCallback(async f=>{if(!(!(a!=null&&a.enabled&&o)||d)){if(f.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]),m=useCallback(()=>{i(false);},[]),u={url:o!=null?o:"",isOpen:l,onClose:m,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(u):jsx(co,{...u})]}):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})},Ho=memo(ds,(e,t)=>R(e,t)&&e.href===t.href);Ho.displayName="MarkdownA";var Do=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>R(e,t));Do.displayName="MarkdownH1";var Bo=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>R(e,t));Bo.displayName="MarkdownH2";var Ao=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>R(e,t));Ao.displayName="MarkdownH3";var Oo=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>R(e,t));Oo.displayName="MarkdownH4";var Vo=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>R(e,t));Vo.displayName="MarkdownH5";var jo=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>R(e,t));jo.displayName="MarkdownH6";var Fo=memo(({children:e,className:t,node:o,...n})=>{let{controls:r}=useContext(M),s=wt(r,"table"),a=yt(r,"copy"),l=yt(r,"download"),i=yt(r,"fullscreen");return jsx(Mo,{className:t,showControls:s,showCopy:a,showDownload:l,showFullscreen:i,...n,children:e})},(e,t)=>R(e,t));Fo.displayName="MarkdownTable";var zo=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>R(e,t));zo.displayName="MarkdownThead";var _o=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>R(e,t));_o.displayName="MarkdownTbody";var qo=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>R(e,t));qo.displayName="MarkdownTr";var $o=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("th",{className:r("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>R(e,t));$o.displayName="MarkdownTh";var Wo=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>R(e,t));Wo.displayName="MarkdownTd";var Zo=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e})},(e,t)=>R(e,t));Zo.displayName="MarkdownBlockquote";var Xo=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>R(e,t));Xo.displayName="MarkdownSup";var Ko=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>R(e,t));Ko.displayName="MarkdownSub";var Jo=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=i=>{var m,u;if(!isValidElement(i))return false;let d=Array.isArray(i.props.children)?i.props.children:[i.props.children],c=false,p=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(c=true);else if(isValidElement(f))if(((m=f.props)==null?void 0:m["data-footnote-backref"])!==void 0)p=true;else {let h=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let b of h){if(typeof b=="string"&&b.trim()!==""){c=true;break}if(isValidElement(b)&&((u=b.props)==null?void 0:u["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===kt){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)=>R(e,t));Jo.displayName="MarkdownSection";var ms=({node:e,className:t,children:o,...n})=>{var D,F;let r=w(),s=!("data-block"in n),{mermaid:a,controls:l,lineNumbers:i}=useContext(M),d=ge(),c=rt(),p=t==null?void 0:t.match(cs),m=(D=p==null?void 0:p.at(1))!=null?D:"",u=mo(m);if(s)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let f=(F=e==null?void 0:e.properties)==null?void 0:F.metastring,h=f==null?void 0:f.match(as),b=h?Number.parseInt(h[1],10):void 0,g=b!==void 0&&b>=1?b:void 0,v=!(f?is.test(f):false)&&i!==false,C="";if(isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?C=o.props.children:typeof o=="string"&&(C=o),u){let z=u.component;return jsx(Suspense,{fallback:jsx(_e,{}),children:jsx(z,{code:C,isIncomplete:c,language:m,meta:f})})}if(m==="mermaid"&&d){let z=wt(l,"mermaid"),W=We(l,"download"),_=We(l,"copy"),Z=We(l,"fullscreen"),Q=We(l,"panZoom"),X=z&&(W||_||Z);return jsx(Suspense,{fallback:jsx(_e,{}),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:[W?jsx(fo,{chart:C,config:a==null?void 0:a.config}):null,_?jsx(ze,{code:C}):null,Z?jsx(yo,{chart:C,config:a==null?void 0:a.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(ls,{chart:C,config:a==null?void 0:a.config,showControls:Q})})]})})}let I=wt(l,"code"),N=No(l,"download"),E=No(l,"copy");return jsx(lt,{className:t,code:C,isIncomplete:c,language:m,lineNumbers:v,startLine:g,children:I?jsxs(Fragment,{children:[N?jsx(dt,{code:C,language:m}):null,E?jsx(ze,{}):null]}):null})},Uo=memo(ms,(e,t)=>e.className===t.className&&Ke(e.node,t.node));Uo.displayName="MarkdownCode";var Go=memo(ao,(e,t)=>e.className===t.className&&Ke(e.node,t.node));Go.displayName="MarkdownImg";var Yo=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)=>R(e,t));Yo.displayName="MarkdownParagraph";var Qo={ol:kt,li:Lo,ul:So,hr:Ro,strong:Eo,a:Ho,h1:Do,h2:Bo,h3:Ao,h4:Oo,h5:Vo,h6:jo,table:Fo,thead:zo,tbody:_o,tr:qo,th:$o,td:Wo,blockquote:Zo,code:Uo,img:Go,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:Xo,sub:Ko,p:Yo,section:Jo};var us=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,ps=/\p{L}/u;function Je(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(us.test(o))return "rtl";if(ps.test(o))return "ltr"}return "ltr"}var fs=/^[ \t]{0,3}(`{3,}|~{3,})/,gs=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,xt=e=>{let t=e.split(`
|
|
12
|
-
`),o=null,n=0;for(let r of t){let s=fs.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},en=e=>{let t=e.split(`
|
|
13
|
-
`);for(let o of t){let n=o.trim();if(n.length>0&&n.includes("|")&&gs.test(n))return true}return false};var tn=()=>e=>{visit(e,"html",(t,o,n)=>{!n||typeof o!="number"||(n.children[o]={type:"text",value:t.value});});};var nn=[],rn={allowDangerousHtml:true},Ue=new WeakMap,Tt=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 m="";for(let u=0;u<p.length;u+=1){let f=p[u];if(u>0&&(m+=","),Array.isArray(f)){let[h,b]=f;if(typeof h=="function"){let g=Ue.get(h);g||(g=h.name,Ue.set(h,g)),m+=g;}else m+=String(h);m+=":",m+=JSON.stringify(b);}else if(typeof f=="function"){let h=Ue.get(f);h||(h=f.name,Ue.set(f,h)),m+=h;}else m+=String(f);}return m},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 Tt,Pt=e=>{let t=Ps(e),o=e.children||"",n=t.runSync(t.parse(o),o);return Rs(n,e)},Ps=e=>{let t=sn.get(e);if(t)return t;let o=Is(e);return sn.set(e,o),o},Ms=e=>e.some(t=>Array.isArray(t)?t[0]===on:t===on),Is=e=>{let t=e.rehypePlugins||nn,o=e.remarkPlugins||nn,n=Ms(t)?o:[...o,tn],r=e.remarkRehypeOptions?{...rn,...e.remarkRehypeOptions}:rn;return unified().use(ks).use(n).use(xs,r).use(t)},an=e=>e,Ns=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},Ls=(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);}},Ss=(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},Rs=(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||an;visit(e,(c,p,m)=>{if(c.type==="raw"&&m&&typeof p=="number")return Ns(m,p,s,c.value),p;if(c.type==="element"&&(Ls(c,d),Ss(c,p,m,n,r,o)&&m&&typeof p=="number"))return a&&c.children?m.children.splice(p,1,...c.children):m.children.splice(p,1),p});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var Hs=/\[\^[\w-]{1,200}\](?!:)/,Ds=/\[\^[\w-]{1,200}\]:/;var Bs=/<(\w+)[\s>]/,As=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ln=new Map,cn=new Map,Os=e=>{let t=e.toLowerCase(),o=ln.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return ln.set(t,n),n},Vs=e=>{let t=e.toLowerCase(),o=cn.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return cn.set(t,n),n},dn=(e,t)=>{if(As.has(t.toLowerCase()))return 0;let o=e.match(Os(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},mn=(e,t)=>{let o=e.match(Vs(t));return o?o.length:0},js=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},Mt=e=>{let t=Hs.test(e),o=Ds.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),m=mn(i,c);for(let u=0;u<p;u+=1)s.push(c);for(let u=0;u<m;u+=1)s.length>0&&s.at(-1)===c&&s.pop();continue}if(l.type==="html"&&l.block){let c=i.match(Bs);if(c){let p=c[1],m=dn(i,p),u=mn(i,p);m>u&&s.push(p);}}if(d>0&&!a){let c=r[d-1];if(js(c)%2===1){r[d-1]=c+i;continue}}r.push(i),l.type!=="space"&&(a=l.type==="code");}return r};var un=(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)=>{if(!l.includes(`
|
|
14
|
-
|
|
15
|
-
`))return a+l+i;let d=l.replace(/\n\n/g,`
|
|
16
|
-
<!---->
|
|
17
|
-
`),c=(d.startsWith(`
|
|
18
|
-
`)?"":`
|
|
19
|
-
`)+d+(d.endsWith(`
|
|
20
|
-
`)?"":`
|
|
21
|
-
`);return `${a}${c}${i}
|
|
22
|
-
|
|
23
|
-
`});}return o};var Fs=/([\\`*_~[\]|])/g,zs=e=>e.replace(Fs,"\\$1"),pn=(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=zs(l).replace(/\n\n/g," ");return a+d+i});}return o};var fn=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(fn).join(""):"",gn=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=fn(n);n.children=r?[{type:"text",value:r}]:[];}});};var bn=()=>e=>{visit(e,"code",t=>{var o,n;t.meta&&(t.data=(o=t.data)!=null?o:{},t.data.hProperties={...(n=t.data.hProperties)!=null?n:{},metastring:t.meta});});};var Gs=/^[ \t]*<[\w!/?-]/,Ys=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,Qs=e=>typeof e!="string"||e.length===0||!Gs.test(e)?e:e.replace(Ys,"$1"),Cn,kn,xn,vn,Ge={...defaultSchema,protocols:{...defaultSchema.protocols,href:[...(kn=(Cn=defaultSchema.protocols)==null?void 0:Cn.href)!=null?kn:[],"tel"]},attributes:{...defaultSchema.attributes,code:[...(vn=(xn=defaultSchema.attributes)==null?void 0:xn.code)!=null?vn:[],"metastring"]}},Nt={raw:on,sanitize:[Pn,Ge],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},ea={gfm:[Js,{}],codeMeta:bn},wn=Object.values(Nt),ta=Object.values(ea),oa={block:" \u258B",circle:" \u25CF"},na=["github-light","github-dark"],ra={enabled:true},Mn=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);}let i=typeof e=="string"&&o?Qs(e):e,d=jsx(Pt,{...l,children:i});return jsx(nt.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)});Mn.displayName="Block";var sa=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=wn,remarkPlugins:l=ta,className:i,shikiTheme:d=na,mermaid:c,controls:p=true,isAnimating:m=false,animated:u,BlockComponent:f=Mn,parseMarkdownIntoBlocksFn:h=Mt,caret:b,plugins:g,remend:T,linkSafety:v=ra,lineNumbers:C=true,allowedTags:I,literalTagContent:N,translations:E,icons:D,prefix:F,onAnimationStart:z,onAnimationEnd:W,..._})=>{let Z=useId(),[Q,X]=useTransition(),y=useMemo(()=>Vt(F),[F]),H=useRef(null),q=useRef(z),we=useRef(W);q.current=z,we.current=W,useEffect(()=>{var O,U,ie;if(t==="static")return;let x=H.current;if(H.current=m,x===null){m&&((O=q.current)==null||O.call(q));return}m&&!x?(U=q.current)==null||U.call(q):!m&&x&&((ie=we.current)==null||ie.call(we));},[m,t]);let ee=useMemo(()=>I?Object.keys(I):[],[I]),se=useMemo(()=>{if(typeof e!="string")return "";let x=t==="streaming"&&n?Us(e,T):e;return N&&N.length>0&&(x=pn(x,N)),ee.length>0&&(x=un(x,ee)),x},[e,t,n,T,ee,N]),ae=useMemo(()=>h(se),[se,h]),[Ce,G]=useState(ae);useEffect(()=>{t==="streaming"&&!ke?X(()=>{G(ae);}):G(ae);},[ae,t]);let A=t==="streaming"?Ce:ae,Ae=useMemo(()=>o==="auto"?A.map(Je):void 0,[A,o]),Rn=useMemo(()=>A.map((x,O)=>`${Z}-${O}`),[A.length,Z]),Qe=useMemo(()=>u===true?"true":u?JSON.stringify(u):"",[u]),ke=useMemo(()=>Qe?Qe==="true"?xe():xe(u):null,[Qe]),Lt=useMemo(()=>{var x,O;return {shikiTheme:(O=(x=g==null?void 0:g.code)==null?void 0:x.getThemes())!=null?O:d,controls:p,isAnimating:m,lineNumbers:C,mode:t,mermaid:c,linkSafety:v}},[d,p,m,C,t,c,v,g==null?void 0:g.code]),En=useMemo(()=>E?JSON.stringify(E):"",[E]),St=useMemo(()=>({...je,...E}),[En]),Rt=useMemo(()=>{let{inlineCode:x,...O}=s!=null?s:{},U={...Qo,...O};if(x){let ie=U.code;U.code=fe=>"data-block"in fe?ie?createElement(ie,fe):null:createElement(x,fe);}return U},[s]),Et=useMemo(()=>{let x=[];return g!=null&&g.cjk&&(x=[...x,...g.cjk.remarkPluginsBefore]),x=[...x,...l],g!=null&&g.cjk&&(x=[...x,...g.cjk.remarkPluginsAfter]),g!=null&&g.math&&(x=[...x,g.math.remarkPlugin]),x},[l,g==null?void 0:g.math,g==null?void 0:g.cjk]),Ht=useMemo(()=>{var O;let x=a;if(I&&Object.keys(I).length>0&&a===wn){let U={...Ge,tagNames:[...(O=Ge.tagNames)!=null?O:[],...Object.keys(I)],attributes:{...Ge.attributes,...I}};x=[Nt.raw,[Pn,U],Nt.harden];}return N&&N.length>0&&(x=[...x,[gn,N]]),g!=null&&g.math&&(x=[...x,g.math.rehypePlugin]),ke&&m&&(x=[...x,ke.rehypePlugin]),x},[a,g==null?void 0:g.math,ke,m,I,N]),et=useMemo(()=>{if(!m||A.length===0)return false;let x=A.at(-1);return xt(x)||en(x)},[m,A]),Hn=useMemo(()=>b&&m&&!et?{"--streamdown-caret":`"${oa[b]}"`}:void 0,[b,m,et]);return t==="static"?jsx(Fe.Provider,{value:St,children:jsx(qe.Provider,{value:g!=null?g:null,children:jsx(M.Provider,{value:Lt,children:jsx(ct,{icons:D,children:jsx(Oe.Provider,{value:y,children:jsx("div",{className:y("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:o==="auto"?Je(se):o,children:jsx(Pt,{components:Rt,rehypePlugins:Ht,remarkPlugins:Et,..._,children:se})})})})})})}):jsx(Fe.Provider,{value:St,children:jsx(qe.Provider,{value:g!=null?g:null,children:jsx(M.Provider,{value:Lt,children:jsx(ct,{icons:D,children:jsx(Oe.Provider,{value:y,children:jsxs("div",{className:y("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",b&&!et?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),style:Hn,children:[A.length===0&&b&&m&&jsx("span",{}),A.map((x,O)=>{var fe;let U=O===A.length-1,ie=m&&U&&xt(x);return jsx(f,{animatePlugin:ke,components:Rt,content:x,dir:(fe=Ae==null?void 0:Ae[O])!=null?fe:o!=="auto"?o:void 0,index:O,isIncomplete:ie,rehypePlugins:Ht,remarkPlugins:Et,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,..._},Rn[O])})]})})})})})})},(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);sa.displayName="Streamdown";var Sn=({children:e,className:t,minZoom:o=.5,maxZoom:n=3,zoomStep:r=.1,showControls:s=true,initialZoom:a=1,fullscreen:l=false})=>{let{RotateCcwIcon:i,ZoomInIcon:d,ZoomOutIcon:c}=S(),p=w(),m=useRef(null),u=useRef(null),[f,h]=useState(a),[b,g]=useState({x:0,y:0}),[T,v]=useState(false),[C,I]=useState({x:0,y:0}),[N,E]=useState({x:0,y:0}),D=useCallback(y=>{h(H=>Math.max(o,Math.min(n,H+y)));},[o,n]),F=useCallback(()=>{D(r);},[D,r]),z=useCallback(()=>{D(-r);},[D,r]),W=useCallback(()=>{h(a),g({x:0,y:0});},[a]),_=useCallback(y=>{y.preventDefault();let H=y.deltaY>0?-r:r;D(H);},[D,r]),Z=useCallback(y=>{if(y.button!==0||y.isPrimary===false)return;v(true),I({x:y.clientX,y:y.clientY}),E(b);let H=y.currentTarget;H instanceof HTMLElement&&H.setPointerCapture(y.pointerId);},[b]),Q=useCallback(y=>{if(!T)return;y.preventDefault();let H=y.clientX-C.x,q=y.clientY-C.y;g({x:N.x+H,y:N.y+q});},[T,C,N]),X=useCallback(y=>{v(false);let H=y.currentTarget;H instanceof HTMLElement&&H.releasePointerCapture(y.pointerId);},[]);return useEffect(()=>{let y=m.current;if(y)return y.addEventListener("wheel",_,{passive:false}),()=>{y.removeEventListener("wheel",_);}},[_]),useEffect(()=>{let y=u.current;if(y&&T)return document.body.style.userSelect="none",y.addEventListener("pointermove",Q,{passive:false}),y.addEventListener("pointerup",X),y.addEventListener("pointercancel",X),()=>{document.body.style.userSelect="",y.removeEventListener("pointermove",Q),y.removeEventListener("pointerup",X),y.removeEventListener("pointercancel",X);}},[T,Q,X]),jsxs("div",{className:p("relative flex flex-col",l?"h-full w-full":"min-h-28 w-full",t),ref:m,style:{cursor:T?"grabbing":"grab"},children:[s?jsxs("div",{className:p("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",l?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:f>=n,onClick:F,title:"Zoom in",type:"button",children:jsx(d,{size:16})}),jsx("button",{className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:f<=o,onClick:z,title:"Zoom out",type:"button",children:jsx(c,{size:16})}),jsx("button",{className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:W,title:"Reset zoom and pan",type:"button",children:jsx(i,{size:16})})]}):null,jsx("div",{className:p("flex-1 origin-center transition-transform duration-150 ease-out",l?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:Z,ref:u,role:"application",style:{transform:`translate(${b.x}px, ${b.y}px) scale(${f})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var ho=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=w(),[a,l]=useState(null),[i,d]=useState(false),[c,p]=useState(""),[m,u]=useState(""),[f,h]=useState(0),{mermaid:b}=useContext(M),g=ge(),T=b==null?void 0:b.errorComponent,{shouldRender:v,containerRef:C}=Dt({immediate:n});if(useEffect(()=>{if(!v)return;if(!g){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),d(!0);let E=g.getMermaid(o),D=e.split("").reduce((W,_)=>(W<<5)-W+_.charCodeAt(0)|0,0),F=`mermaid-${Math.abs(D)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:z}=await E.render(F,e);p(z),u(z);}catch(E){if(!(m||c)){let D=E instanceof Error?E.message:"Failed to render Mermaid chart";l(D);}}finally{d(false);}})();},[e,o,f,v,g]),!(v||c||m))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:C});if(i&&!c&&!m)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:C,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&&!m){let N=()=>h(E=>E+1);return T?jsx("div",{ref:C,children:jsx(T,{chart:e,error:a,retry:N})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:C,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 I=c||m;return jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:C,children:jsx(Sn,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),fullscreen:n,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:I},role:"img"})})})};export{ea as A,Mn as B,sa as C,xe as a,rt as b,Ft as c,st as d,it as e,Fi as f,lt as g,je as h,ze as i,dt as j,_e as k,M as l,ho as m,he as n,de as o,gt as p,$e as q,me as r,Se as s,Gr as t,Re as u,Je as v,an as w,Mt as x,Qs as y,Nt as z};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {l,f,c}from'./chunk-XMZ7XVWH.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var R=({code:s,language:e,raw:t,className:h,startLine:d,lineNumbers:m,...p})=>{let{shikiTheme:l$1}=useContext(l),o=f(),[a,i]=useState(t);return useEffect(()=>{if(!o){i(t);return}let r=o.highlight({code:s,language:e,themes:l$1},c=>{i(c);});r&&i(r);},[s,e,l$1,o,t]),jsx(c,{className:h,language:e,lineNumbers:m,result:a,startLine:d,...p})};export{R as HighlightedCodeBlockBody};
|
package/dist/mermaid-OOFVDMCH.js
DELETED