streamdown 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -2
- package/dist/chunk-LPQFK2AO.js +8 -0
- package/dist/code-block-OCS4YCEC.js +3 -0
- package/dist/index.d.ts +33 -4
- package/dist/index.js +1 -1
- package/dist/mermaid-NOHMQCX5.js +2 -0
- package/package.json +13 -9
- package/styles.css +35 -0
- package/dist/chunk-5FQGJX7Z.js +0 -10
- package/dist/chunk-QX4TVXVA.cjs +0 -10
- package/dist/code-block-37QAKDTI.js +0 -3
- package/dist/code-block-XWNGTFRY.cjs +0 -3
- package/dist/index.cjs +0 -2
- package/dist/index.d.cts +0 -223
- package/dist/mermaid-4DMBBIKO.js +0 -2
- package/dist/mermaid-UQ57JT4G.cjs +0 -2
package/README.md
CHANGED
|
@@ -28,13 +28,33 @@ Streamdown powers the [AI Elements Message](https://ai-sdk.dev/elements/componen
|
|
|
28
28
|
npm i streamdown
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
Then, update your Tailwind `globals.css` to include the following.
|
|
31
|
+
Then, update your Tailwind `globals.css` to include the following so that Tailwind can detect the utility classes used by Streamdown.
|
|
32
32
|
|
|
33
33
|
```css
|
|
34
34
|
@source "../node_modules/streamdown/dist/*.js";
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
The path must be relative from your CSS file to the `node_modules` folder containing `streamdown`. In a standard Next.js project where `globals.css` lives in `app/`, the default path above should work.
|
|
38
|
+
|
|
39
|
+
### Monorepo setup
|
|
40
|
+
|
|
41
|
+
In a monorepo (npm workspaces, Turbo, pnpm, etc.), dependencies are typically hoisted to the root `node_modules`. You need to adjust the relative path to point there:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
monorepo/
|
|
45
|
+
├── node_modules/streamdown/ ← hoisted here
|
|
46
|
+
├── apps/
|
|
47
|
+
│ └── web/
|
|
48
|
+
│ └── app/
|
|
49
|
+
│ └── globals.css ← your CSS file
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```css
|
|
53
|
+
/* apps/web/app/globals.css → 3 levels up to reach root node_modules */
|
|
54
|
+
@source "../../../node_modules/streamdown/dist/*.js";
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Adjust the number of `../` segments based on where your CSS file lives relative to the root `node_modules`.
|
|
38
58
|
|
|
39
59
|
## Usage
|
|
40
60
|
|
|
@@ -48,6 +68,7 @@ import { mermaid } from "@streamdown/mermaid";
|
|
|
48
68
|
import { math } from "@streamdown/math";
|
|
49
69
|
import { cjk } from "@streamdown/cjk";
|
|
50
70
|
import "katex/dist/katex.min.css";
|
|
71
|
+
import "streamdown/styles.css";
|
|
51
72
|
|
|
52
73
|
export default function Chat() {
|
|
53
74
|
const { messages, status } = useChat();
|
|
@@ -61,6 +82,7 @@ export default function Chat() {
|
|
|
61
82
|
part.type === 'text' ? (
|
|
62
83
|
<Streamdown
|
|
63
84
|
key={index}
|
|
85
|
+
animated
|
|
64
86
|
plugins={{ code, mermaid, math, cjk }}
|
|
65
87
|
isAnimating={status === 'streaming'}
|
|
66
88
|
>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {createContext,lazy,memo,useContext,isValidElement,useId,useTransition,useMemo,useState,useEffect,cloneElement,useCallback,Suspense,useRef}from'react';import {harden}from'rehype-harden';import Jt from'rehype-raw';import no,{defaultSchema}from'rehype-sanitize';import _n from'remark-gfm';import Xn from'remend';import {visitParents,SKIP}from'unist-util-visit-parents';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import vn from'remark-parse';import Cn from'remark-rehype';import {unified}from'unified';import {visit}from'unist-util-visit';import {Lexer}from'marked';var fo=300,go="300px",bo=500;function ze(e={}){let{immediate:t=false,debounceDelay:o=fo,rootMargin:n=go,idleTimeout:i=bo}=e,[r,a]=useState(false),c=useRef(null),s=useRef(null),l=useRef(null),d=useMemo(()=>b=>{let f=Date.now();return window.setTimeout(()=>{b({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-f))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(b,f)=>window.requestIdleCallback(b,f):d,[d]),m=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?b=>window.cancelIdleCallback(b):b=>{clearTimeout(b);},[]);return useEffect(()=>{if(t){a(true);return}let b=c.current;if(!b)return;s.current&&(clearTimeout(s.current),s.current=null),l.current&&(m(l.current),l.current=null);let f=()=>{s.current&&(clearTimeout(s.current),s.current=null),l.current&&(m(l.current),l.current=null);},u=P=>{l.current=p(M=>{M.timeRemaining()>0||M.didTimeout?(a(true),P.disconnect()):l.current=p(()=>{a(true),P.disconnect();},{timeout:i/2});},{timeout:i});},y=P=>{f(),s.current=window.setTimeout(()=>{var E,H;let M=P.takeRecords();(M.length===0||(H=(E=M.at(-1))==null?void 0:E.isIntersecting)!=null&&H)&&u(P);},o);},k=(P,M)=>{P.isIntersecting?y(M):f();},C=new IntersectionObserver(P=>{for(let M of P)k(M,C);},{rootMargin:n,threshold:0});return C.observe(b),()=>{s.current&&clearTimeout(s.current),l.current&&m(l.current),C.disconnect();}},[t,o,n,i,m,p]),{shouldRender:r,containerRef:c}}var Ze=/\s/,wo=/^\s+$/,ko=new Set(["code","pre","svg","math","annotation"]),vo=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",Co=e=>e.some(t=>vo(t)&&ko.has(t.tagName)),xo=e=>{let t=[],o="",n=false;for(let i of e){let r=Ze.test(i);r!==n&&o&&(t.push(o),o=""),o+=i,n=r;}return o&&t.push(o),t},Po=e=>{let t=[],o="";for(let n of e)Ze.test(n)?o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&t.push(o),t},Mo=(e,t,o,n)=>({type:"element",tagName:"span",properties:{"data-sd-animate":true,style:`--sd-animation:sd-${t};--sd-duration:${o}ms;--sd-easing:${n}`},children:[{type:"text",value:e}]}),To=(e,t,o)=>{let n=t.at(-1);if(!(n&&"children"in n))return;if(Co(t))return SKIP;let i=n,r=i.children.indexOf(e);if(r===-1)return;let a=e.value;if(!a.trim())return;let s=(o.sep==="char"?Po(a):xo(a)).map(l=>wo.test(l)?{type:"text",value:l}:Mo(l,o.animation,o.duration,o.easing));return i.children.splice(r,1,...s),r+s.length};function Q(e){var n,i,r,a;let t={animation:(n=e==null?void 0:e.animation)!=null?n:"fadeIn",duration:(i=e==null?void 0:e.duration)!=null?i:150,easing:(r=e==null?void 0:e.easing)!=null?r:"ease",sep:(a=e==null?void 0:e.sep)!=null?a:"word"};return {name:"animate",type:"animate",rehypePlugin:()=>c=>{visitParents(c,"text",(s,l)=>To(s,l,t));}}}Q();var J=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"})}),F=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"})}),Z=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"})}),We=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"})]}),$e=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"})}),Ue=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"})}),se=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"})}),xe=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"})}),_e=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"})}),Xe=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 g=(...e)=>twMerge(clsx(e)),B=(e,t,o)=>{let n=typeof t=="string"?new Blob([t],{type:o}):t,i=URL.createObjectURL(n),r=document.createElement("a");r.href=i,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i);};var Io=createContext({code:""}),ae=()=>useContext(Io);var Pe=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:i,code:r,...a})=>{let[c,s]=useState(false),l=useRef(0),{code:d}=ae(),{isAnimating:p}=useContext(L),m=r!=null?r:d,b=async()=>{var u;if(typeof window=="undefined"||!((u=navigator==null?void 0:navigator.clipboard)!=null&&u.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{c||(await navigator.clipboard.writeText(m),s(!0),e==null||e(),l.current=window.setTimeout(()=>s(!1),o));}catch(y){t==null||t(y);}};useEffect(()=>()=>{window.clearTimeout(l.current);},[]);let f=c?J:F;return jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),"data-streamdown":"code-block-copy-button",disabled:p,onClick:b,title:"Copy Code",type:"button",...a,children:n!=null?n:jsx(f,{size:14})})};var Fe={"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"},Ge=({onDownload:e,onError:t,language:o,children:n,className:i,code:r,...a})=>{let{code:c}=ae(),{isAnimating:s}=useContext(L),l=r!=null?r:c,p=`file.${o&&o in Fe?Fe[o]:"txt"}`,m="text/plain",b=()=>{try{B(p,l,m),e==null||e();}catch(f){t==null||t(f);}};return jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),"data-streamdown":"code-block-download-button",disabled:s,onClick:b,title:"Download file",type:"button",...a,children:n!=null?n:jsx(Z,{size:14})})};var Te=()=>jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[jsx("div",{className:"h-[46px] w-full bg-muted/80"}),jsx("div",{className:"flex w-full items-center justify-center p-4",children:jsx(We,{className:"size-4 animate-spin"})})]});var Ao=/\.[^/.]+$/,Ye=({node:e,className:t,src:o,alt:n,...i})=>{let r=async()=>{if(o)try{let c=await(await fetch(o)).blob(),l=new URL(o,window.location.origin).pathname.split("/").pop()||"",d=l.split(".").pop(),p=l.includes(".")&&d!==void 0&&d.length<=4,m="";if(p)m=l;else {let b=c.type,f="png";b.includes("jpeg")||b.includes("jpg")?f="jpg":b.includes("png")?f="png":b.includes("svg")?f="svg":b.includes("gif")?f="gif":b.includes("webp")&&(f="webp"),m=`${(n||l||"image").replace(Ao,"")}.${f}`;}B(m,c,c.type);}catch(a){window.open(o,"_blank");}};return o?jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:g("max-w-full rounded-lg",t),"data-streamdown":"image",src:o,...i}),jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsx("button",{className:g("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 group-hover:opacity-100"),onClick:r,title:"Download image",type:"button",children:jsx(Z,{size:14})})]}):null};var ee=0,Wo=()=>{ee+=1,ee===1&&(document.body.style.overflow="hidden");},$o=()=>{ee=Math.max(0,ee-1),ee===0&&(document.body.style.overflow="");},tt=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let[i,r]=useState(false),a=useCallback(async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3);}catch(s){}},[e]),c=useCallback(()=>{n(),o();},[n,o]);return useEffect(()=>{if(t){Wo();let s=l=>{l.key==="Escape"&&o();};return document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s),$o();}}},[t,o]),t?jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm","data-streamdown":"link-safety-modal",onClick:o,onKeyDown:s=>{s.key==="Escape"&&o();},role:"button",tabIndex:0,children:jsxs("div",{className:"relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg",onClick:s=>s.stopPropagation(),onKeyDown:s=>s.stopPropagation(),role:"presentation",children:[jsx("button",{className:"absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:o,title:"Close",type:"button",children:jsx(se,{size:16})}),jsxs("div",{className:"flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center gap-2 font-semibold text-lg",children:[jsx(xe,{size:20}),jsx("span",{children:"Open external link?"})]}),jsx("p",{className:"text-muted-foreground text-sm",children:"You're about to visit an external website."})]}),jsx("div",{className:g("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:"flex gap-2",children:[jsx("button",{className:"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:a,type:"button",children:i?jsxs(Fragment,{children:[jsx(J,{size:14}),jsx("span",{children:"Copied"})]}):jsxs(Fragment,{children:[jsx(F,{size:14}),jsx("span",{children:"Copy link"})]})}),jsxs("button",{className:"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:c,type:"button",children:[jsx(xe,{size:14}),jsx("span",{children:"Open link"})]})]})]})}):null};var le=createContext(null),ot=()=>useContext(le),Zr=()=>{var t;let e=ot();return (t=e==null?void 0:e.code)!=null?t:null},K=()=>{var t;let e=ot();return (t=e==null?void 0:e.mermaid)!=null?t:null};var nt=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((i,r)=>{let a="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),c=new Image;c.crossOrigin="anonymous",c.onload=()=>{let s=document.createElement("canvas"),l=c.width*o,d=c.height*o;s.width=l,s.height=d;let p=s.getContext("2d");if(!p){r(new Error("Failed to create 2D canvas context for PNG export"));return}p.drawImage(c,0,0,l,d),s.toBlob(m=>{if(!m){r(new Error("Failed to create PNG blob"));return}i(m);},"image/png");},c.onerror=()=>r(new Error("Failed to load SVG image")),c.src=a;})};var st=({chart:e,children:t,className:o,onDownload:n,config:i,onError:r})=>{let[a,c]=useState(false),s=useRef(null),{isAnimating:l}=useContext(L),d=K(),p=async m=>{try{if(m==="mmd"){B("diagram.mmd",e,"text/plain"),c(!1),n==null||n(m);return}if(!d){r==null||r(new Error("Mermaid plugin not available"));return}let b=d.getMermaid(i),f=e.split("").reduce((k,C)=>(k<<5)-k+C.charCodeAt(0)|0,0),u=`mermaid-${Math.abs(f)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:y}=await b.render(u,e);if(!y){r==null||r(new Error("SVG not found. Please wait for the diagram to render."));return}if(m==="svg"){B("diagram.svg",y,"image/svg+xml"),c(!1),n==null||n(m);return}if(m==="png"){let k=await nt(y);B("diagram.png",k,"image/png"),n==null||n(m),c(!1);return}}catch(b){r==null||r(b);}};return useEffect(()=>{let m=b=>{let f=b.composedPath();s.current&&!f.includes(s.current)&&c(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),jsxs("div",{className:"relative",ref:s,children:[jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:l,onClick:()=>c(!a),title:"Download diagram",type:"button",children:t!=null?t:jsx(Z,{size:14})}),a?jsxs("div",{className:"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:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("svg"),title:"Download diagram as SVG",type:"button",children:"SVG"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("png"),title:"Download diagram as PNG",type:"button",children:"PNG"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]}):null]})};var oe=0,Qo=()=>{oe+=1,oe===1&&(document.body.style.overflow="hidden");},en=()=>{oe=Math.max(0,oe-1),oe===0&&(document.body.style.overflow="");},ct=({chart:e,config:t,onFullscreen:o,onExit:n,className:i,...r})=>{let[a,c]=useState(false),{isAnimating:s,controls:l}=useContext(L),d=(()=>{if(typeof l=="boolean")return l;let m=l.mermaid;return m===false?false:m===true||m===void 0?true:m.panZoom!==false})(),p=()=>{c(!a);};return useEffect(()=>{if(a){Qo();let m=b=>{b.key==="Escape"&&c(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),en();}}},[a]),useEffect(()=>{a?o==null||o():n&&n();},[a,o,n]),jsxs(Fragment,{children:[jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),disabled:s,onClick:p,title:"View fullscreen",type:"button",...r,children:jsx($e,{size:14})}),a?jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:p,onKeyDown:m=>{m.key==="Escape"&&p();},role:"button",tabIndex:0,children:[jsx("button",{className:"absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:p,title:"Exit fullscreen",type:"button",children:jsx(se,{size:20})}),jsx("div",{className:"flex size-full items-center justify-center p-4",onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),role:"presentation",children:jsx(lt,{chart:e,className:"size-full [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:true,showControls:d})})]}):null]})};var ce=e=>{var r,a;let t=[],o=[],n=e.querySelectorAll("thead th");for(let c of n)t.push(((r=c.textContent)==null?void 0:r.trim())||"");let i=e.querySelectorAll("tbody tr");for(let c of i){let s=[],l=c.querySelectorAll("td");for(let d of l)s.push(((a=d.textContent)==null?void 0:a.trim())||"");o.push(s);}return {headers:t,rows:o}},de=e=>{let{headers:t,rows:o}=e,n=c=>{let s=false,l=false;for(let d of c){if(d==='"'){s=true,l=true;break}(d===","||d===`
|
|
3
|
+
`)&&(s=true);}return s?l?`"${c.replace(/"/g,'""')}"`:`"${c}"`:c},i=t.length>0?o.length+1:o.length,r=new Array(i),a=0;t.length>0&&(r[a]=t.map(n).join(","),a+=1);for(let c of o)r[a]=c.map(n).join(","),a+=1;return r.join(`
|
|
4
|
+
`)},dt=e=>{let{headers:t,rows:o}=e,n=c=>{let s=false;for(let d of c)if(d===" "||d===`
|
|
5
|
+
`||d==="\r"){s=true;break}if(!s)return c;let l=[];for(let d of c)d===" "?l.push("\\t"):d===`
|
|
6
|
+
`?l.push("\\n"):d==="\r"?l.push("\\r"):l.push(d);return l.join("")},i=t.length>0?o.length+1:o.length,r=new Array(i),a=0;t.length>0&&(r[a]=t.map(n).join(" "),a+=1);for(let c of o)r[a]=c.map(n).join(" "),a+=1;return r.join(`
|
|
7
|
+
`)},Ne=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("")},mt=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),i=0,r=t.map(c=>Ne(c));n[i]=`| ${r.join(" | ")} |`,i+=1;let a=new Array(t.length);for(let c=0;c<t.length;c+=1)a[c]="---";n[i]=`| ${a.join(" | ")} |`,i+=1;for(let c of o)if(c.length<t.length){let s=new Array(t.length);for(let l=0;l<t.length;l+=1)s[l]=l<c.length?Ne(c[l]):"";n[i]=`| ${s.join(" | ")} |`,i+=1;}else {let s=c.map(l=>Ne(l));n[i]=`| ${s.join(" | ")} |`,i+=1;}return n.join(`
|
|
8
|
+
`)};var gt=({children:e,className:t,onCopy:o,onError:n,timeout:i=2e3})=>{let[r,a]=useState(false),[c,s]=useState(false),l=useRef(null),d=useRef(0),{isAnimating:p}=useContext(L),m=async f=>{var u,y;if(typeof window=="undefined"||!((u=navigator==null?void 0:navigator.clipboard)!=null&&u.write)){n==null||n(new Error("Clipboard API not available"));return}try{let k=(y=l.current)==null?void 0:y.closest('[data-streamdown="table-wrapper"]'),C=k==null?void 0:k.querySelector("table");if(!C){n==null||n(new Error("Table not found"));return}let P=ce(C),M=f==="csv"?de(P):dt(P),z=new ClipboardItem({"text/plain":new Blob([M],{type:"text/plain"}),"text/html":new Blob([C.outerHTML],{type:"text/html"})});await navigator.clipboard.write([z]),s(!0),a(!1),o==null||o(f),d.current=window.setTimeout(()=>s(!1),i);}catch(k){n==null||n(k);}};useEffect(()=>{let f=u=>{let y=u.composedPath();l.current&&!y.includes(l.current)&&a(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(d.current);}},[]);let b=c?J:F;return jsxs("div",{className:"relative",ref:l,children:[jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:p,onClick:()=>a(!r),title:"Copy table",type:"button",children:e!=null?e:jsx(b,{size:14})}),r?jsxs("div",{className:"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:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var ht=({children:e,className:t,onDownload:o,onError:n})=>{let[i,r]=useState(false),a=useRef(null),{isAnimating:c}=useContext(L),s=l=>{var d;try{let p=(d=a.current)==null?void 0:d.closest('[data-streamdown="table-wrapper"]'),m=p==null?void 0:p.querySelector("table");if(!m){n==null||n(new Error("Table not found"));return}let b=ce(m),f=l==="csv"?de(b):mt(b);B(`table.${l==="csv"?"csv":"md"}`,f,l==="csv"?"text/csv":"text/markdown"),r(!1),o==null||o(l);}catch(p){n==null||n(p);}};return useEffect(()=>{let l=d=>{let p=d.composedPath();a.current&&!p.includes(a.current)&&r(false);};return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l);}},[]),jsxs("div",{className:"relative",ref:a,children:[jsx("button",{className:g("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:()=>r(!i),title:"Download table",type:"button",children:e!=null?e:jsx(Z,{size:14})}),i?jsxs("div",{className:"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:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>s("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>s("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var wt=({children:e,className:t,showControls:o,...n})=>jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[o?jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsx(gt,{}),jsx(ht,{})]}):null,jsx("div",{className:"overflow-x-auto overscroll-y-auto",children:jsx("table",{className:g("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]});var mn=lazy(()=>import('./code-block-OCS4YCEC.js').then(e=>({default:e.CodeBlock}))),pn=lazy(()=>import('./mermaid-NOHMQCX5.js').then(e=>({default:e.Mermaid}))),un=/language-([^\s]+)/;function he(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,i=e.position.end,r=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)&&(i==null?void 0:i.line)===(r==null?void 0:r.line)&&(i==null?void 0:i.column)===(r==null?void 0:r.column)}function N(e,t){return e.className===t.className&&he(e.node,t.node)}var Re=(e,t)=>typeof e=="boolean"?e:e[t]!==false,fe=(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},Ee=memo(({children:e,className:t,node:o,...n})=>jsx("ol",{className:g("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>N(e,t));Ee.displayName="MarkdownOl";var Ct=memo(({children:e,className:t,node:o,...n})=>jsx("li",{className:g("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&he(e.node,t.node));Ct.displayName="MarkdownLi";var xt=memo(({children:e,className:t,node:o,...n})=>jsx("ul",{className:g("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>N(e,t));xt.displayName="MarkdownUl";var Pt=memo(({className:e,node:t,...o})=>jsx("hr",{className:g("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o}),(e,t)=>N(e,t));Pt.displayName="MarkdownHr";var Mt=memo(({children:e,className:t,node:o,...n})=>jsx("span",{className:g("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>N(e,t));Mt.displayName="MarkdownStrong";var fn=({children:e,className:t,href:o,node:n,...i})=>{let{linkSafety:r}=useContext(L),[a,c]=useState(false),s=o==="streamdown:incomplete-link",l=useCallback(async b=>{if(!(!(r!=null&&r.enabled&&o)||s)){if(b.preventDefault(),r.onLinkCheck&&await r.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}c(true);}},[r,o,s]),d=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),p=useCallback(()=>{c(false);},[]),m={url:o!=null?o:"",isOpen:a,onClose:p,onConfirm:d};return r!=null&&r.enabled&&o?jsxs(Fragment,{children:[jsx("button",{className:g("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":s,"data-streamdown":"link",onClick:l,type:"button",children:e}),r.renderModal?r.renderModal(m):jsx(tt,{...m})]}):jsx("a",{className:g("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":s,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...i,children:e})},Tt=memo(fn,(e,t)=>N(e,t)&&e.href===t.href);Tt.displayName="MarkdownA";var Nt=memo(({children:e,className:t,node:o,...n})=>jsx("h1",{className:g("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>N(e,t));Nt.displayName="MarkdownH1";var Lt=memo(({children:e,className:t,node:o,...n})=>jsx("h2",{className:g("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>N(e,t));Lt.displayName="MarkdownH2";var Rt=memo(({children:e,className:t,node:o,...n})=>jsx("h3",{className:g("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>N(e,t));Rt.displayName="MarkdownH3";var St=memo(({children:e,className:t,node:o,...n})=>jsx("h4",{className:g("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>N(e,t));St.displayName="MarkdownH4";var Et=memo(({children:e,className:t,node:o,...n})=>jsx("h5",{className:g("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>N(e,t));Et.displayName="MarkdownH5";var It=memo(({children:e,className:t,node:o,...n})=>jsx("h6",{className:g("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>N(e,t));It.displayName="MarkdownH6";var Ht=memo(({children:e,className:t,node:o,...n})=>{let{controls:i}=useContext(L),r=Re(i,"table");return jsx(wt,{className:t,showControls:r,...n,children:e})},(e,t)=>N(e,t));Ht.displayName="MarkdownTable";var Dt=memo(({children:e,className:t,node:o,...n})=>jsx("thead",{className:g("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>N(e,t));Dt.displayName="MarkdownThead";var Vt=memo(({children:e,className:t,node:o,...n})=>jsx("tbody",{className:g("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>N(e,t));Vt.displayName="MarkdownTbody";var jt=memo(({children:e,className:t,node:o,...n})=>jsx("tr",{className:g("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>N(e,t));jt.displayName="MarkdownTr";var Bt=memo(({children:e,className:t,node:o,...n})=>jsx("th",{className:g("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>N(e,t));Bt.displayName="MarkdownTh";var Ot=memo(({children:e,className:t,node:o,...n})=>jsx("td",{className:g("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>N(e,t));Ot.displayName="MarkdownTd";var At=memo(({children:e,className:t,node:o,...n})=>jsx("blockquote",{className:g("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>N(e,t));At.displayName="MarkdownBlockquote";var qt=memo(({children:e,className:t,node:o,...n})=>jsx("sup",{className:g("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>N(e,t));qt.displayName="MarkdownSup";var zt=memo(({children:e,className:t,node:o,...n})=>jsx("sub",{className:g("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>N(e,t));zt.displayName="MarkdownSub";var Zt=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let r=s=>{var m,b;if(!isValidElement(s))return false;let l=Array.isArray(s.props.children)?s.props.children:[s.props.children],d=false,p=false;for(let f of l)if(f){if(typeof f=="string")f.trim()!==""&&(d=true);else if(isValidElement(f))if(((m=f.props)==null?void 0:m["data-footnote-backref"])!==void 0)p=true;else {let u=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let y of u){if(typeof y=="string"&&y.trim()!==""){d=true;break}if(isValidElement(y)&&((b=y.props)==null?void 0:b["data-footnote-backref"])===void 0){d=true;break}}}}return p&&!d},a=Array.isArray(e)?e.map(s=>{if(!isValidElement(s))return s;if(s.type===Ee){let d=(Array.isArray(s.props.children)?s.props.children:[s.props.children]).filter(p=>!r(p));return d.length===0?null:{...s,props:{...s.props,children:d}}}return s}):e;return (Array.isArray(a)?a.some(s=>s!==null):a!==null)?jsx("section",{className:t,...n,children:a}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>N(e,t));Zt.displayName="MarkdownSection";var gn=({node:e,className:t,children:o,...n})=>{var m;let i=!("data-block"in n),{mermaid:r,controls:a}=useContext(L),c=K();if(i)return jsx("code",{className:g("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let s=t==null?void 0:t.match(un),l=(m=s==null?void 0:s.at(1))!=null?m:"",d="";if(isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?d=o.props.children:typeof o=="string"&&(d=o),l==="mermaid"&&c){let b=Re(a,"mermaid"),f=fe(a,"download"),u=fe(a,"copy"),y=fe(a,"fullscreen"),k=fe(a,"panZoom"),C=b&&(f||u||y);return jsx(Suspense,{fallback:jsx(Te,{}),children:jsxs("div",{className:g("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[C?jsxs("div",{className:"flex items-center justify-end gap-2",children:[f?jsx(st,{chart:d,config:r==null?void 0:r.config}):null,u?jsx(Pe,{code:d}):null,y?jsx(ct,{chart:d,config:r==null?void 0:r.config}):null]}):null,jsx(pn,{chart:d,config:r==null?void 0:r.config,showControls:k})]})})}let p=Re(a,"code");return jsx(Suspense,{fallback:jsx(Te,{}),children:jsx(mn,{className:g("overflow-x-auto border-border border-t",t),code:d,language:l,children:p?jsxs(Fragment,{children:[jsx(Ge,{code:d,language:l}),jsx(Pe,{})]}):null})})},Wt=memo(gn,(e,t)=>e.className===t.className&&he(e.node,t.node));Wt.displayName="MarkdownCode";var $t=memo(Ye,(e,t)=>e.className===t.className&&he(e.node,t.node));$t.displayName="MarkdownImg";var Ut=memo(({children:e,className:t,node:o,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");if(r.length===1&&isValidElement(r[0])){let a=r[0].props.node,c=a==null?void 0:a.tagName;if(c==="img")return jsx(Fragment,{children:e});if(c==="code"&&"data-block"in r[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...n,children:e})},(e,t)=>N(e,t));Ut.displayName="MarkdownParagraph";var _t={ol:Ee,li:Ct,ul:xt,hr:Pt,strong:Mt,a:Tt,h1:Nt,h2:Lt,h3:Rt,h4:St,h5:Et,h6:It,table:Ht,thead:Dt,tbody:Vt,tr:jt,th:Bt,td:Ot,blockquote:At,code:Wt,img:$t,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:qt,sub:zt,p:Ut,section:Zt};var Xt=()=>e=>{visit(e,"html",(t,o,n)=>{!n||typeof o!="number"||(n.children[o]={type:"text",value:t.value});});};var Ft=[],Kt={allowDangerousHtml:true},ye=new WeakMap,He=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,i=t.remarkPlugins,r=t.remarkRehypeOptions;if(!(n||i||r)){let p="default";return this.keyCache.set(t,p),p}let a=p=>{if(!p||p.length===0)return "";let m="";for(let b=0;b<p.length;b+=1){let f=p[b];if(b>0&&(m+=","),Array.isArray(f)){let[u,y]=f;if(typeof u=="function"){let k=ye.get(u);k||(k=u.name,ye.set(u,k)),m+=k;}else m+=String(u);m+=":",m+=JSON.stringify(y);}else if(typeof f=="function"){let u=ye.get(f);u||(u=f.name,ye.set(f,u)),m+=u;}else m+=String(f);}return m},c=a(n),s=a(i),l=r?JSON.stringify(r):"",d=`${s}::${c}::${l}`;return this.keyCache.set(t,d),d}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let i=this.cache.keys().next().value;i&&this.cache.delete(i);}this.cache.set(n,o);}clear(){this.cache.clear();}},Gt=new He,De=e=>{let t=Mn(e),o=e.children||"";return En(t.runSync(t.parse(o),o),e)},Mn=e=>{let t=Gt.get(e);if(t)return t;let o=Nn(e);return Gt.set(e,o),o},Tn=e=>e.some(t=>Array.isArray(t)?t[0]===Jt:t===Jt),Nn=e=>{let t=e.rehypePlugins||Ft,o=e.remarkPlugins||Ft,n=Tn(t)?o:[...o,Xt],i=e.remarkRehypeOptions?{...Kt,...e.remarkRehypeOptions}:Kt;return unified().use(vn).use(n).use(Cn,i).use(t)},Yt=e=>e,Ln=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},Rn=(e,t)=>{var o;for(let n in urlAttributes)if(Object.hasOwn(urlAttributes,n)&&Object.hasOwn(e.properties,n)){let i=e.properties[n],r=urlAttributes[n];(r===null||r.includes(e.tagName))&&(e.properties[n]=(o=t(String(i||""),n,e))!=null?o:void 0);}},Sn=(e,t,o,n,i,r)=>{let a=false;return n?a=!n.includes(e.tagName):i&&(a=i.includes(e.tagName)),!a&&r&&typeof t=="number"&&(a=!r(e,t,o)),a},En=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:i,skipHtml:r,unwrapDisallowed:a,urlTransform:c}=t;if(o||n||i||r||c){let l=c||Yt;visit(e,(d,p,m)=>{if(d.type==="raw"&&m&&typeof p=="number")return Ln(m,p,r,d.value),p;if(d.type==="element"&&(Rn(d,l),Sn(d,p,m,n,i,o)&&m&&typeof p=="number"))return a&&d.children?m.children.splice(p,1,...d.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 Hn=/\[\^[\w-]{1,200}\](?!:)/,Dn=/\[\^[\w-]{1,200}\]:/,Vn=/<\/(\w+)>/,jn=/<(\w+)[\s>]/,Bn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),On=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},Ve=e=>{let t=Hn.test(e),o=Dn.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),i=[],r=[],a=false;for(let c of n){let s=c.raw,l=i.length;if(r.length>0){if(i[l-1]+=s,c.type==="html"){let d=s.match(Vn);if(d){let p=d[1];r.at(-1)===p&&r.pop();}}continue}if(c.type==="html"&&c.block){let d=s.match(jn);if(d){let p=d[1];s.includes(`</${p}>`)||Bn.has(p.toLowerCase())||r.push(p);}}if(l>0&&!a){let d=i[l-1];if(On(d)%2===1){i[l-1]=d+s;continue}}i.push(s),c.type!=="space"&&(a=c.type==="code");}return i};var eo,to,we={...defaultSchema,protocols:{...defaultSchema.protocols,href:[...(to=(eo=defaultSchema.protocols)==null?void 0:eo.href)!=null?to:[],"tel"]}},Be={raw:Jt,sanitize:[no,we],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Jn={gfm:[_n,{}]},Qt=Object.values(Be),Fn=Object.values(Jn),Kn={block:" \u258B",circle:" \u25CF"},Gn={shikiTheme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0,linkSafety:{enabled:true}},L=createContext(Gn),ro=memo(({content:e,shouldParseIncompleteMarkdown:t,index:o,...n})=>jsx(De,{...n,children:e}),(e,t)=>{if(e.content!==t.content||e.index!==t.index)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(i=>{var r,a;return ((r=e.components)==null?void 0:r[i])!==((a=t.components)==null?void 0:a[i])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});ro.displayName="Block";var Yn=["github-light","github-dark"],Qn=memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:o=true,components:n,rehypePlugins:i=Qt,remarkPlugins:r=Fn,className:a,shikiTheme:c=Yn,mermaid:s,controls:l=true,isAnimating:d=false,animated:p,BlockComponent:m=ro,parseMarkdownIntoBlocksFn:b=Ve,caret:f,plugins:u,remend:y,linkSafety:k={enabled:true},allowedTags:C,...P})=>{let M=useId(),[z,E]=useTransition(),H=useMemo(()=>typeof e!="string"?"":t==="streaming"&&o?Xn(e,y):e,[e,t,o,y]),D=useMemo(()=>b(H),[H,b]),[X,O]=useState(D);useEffect(()=>{t==="streaming"?E(()=>{O(D);}):O(D);},[D,t]);let I=t==="streaming"?X:D,w=useMemo(()=>I.map((T,j)=>`${M}-${j}`),[I.length,M]),R=useMemo(()=>p?p===true?Q():Q(p):null,[p]),Y=useMemo(()=>{var T,j;return {shikiTheme:(j=(T=u==null?void 0:u.code)==null?void 0:T.getThemes())!=null?j:c,controls:l,isAnimating:d,mode:t,mermaid:s,linkSafety:k}},[c,l,d,t,s,k,u==null?void 0:u.code]),Oe=useMemo(()=>({..._t,...n}),[n]),Ae=useMemo(()=>{let T=[];return u!=null&&u.cjk&&(T=[...T,...u.cjk.remarkPluginsBefore]),T=[...T,...r],u!=null&&u.cjk&&(T=[...T,...u.cjk.remarkPluginsAfter]),u!=null&&u.math&&(T=[...T,u.math.remarkPlugin]),T},[r,u==null?void 0:u.math,u==null?void 0:u.cjk]),qe=useMemo(()=>{var j;let T=i;if(C&&Object.keys(C).length>0&&i===Qt){let mo={...we,tagNames:[...(j=we.tagNames)!=null?j:[],...Object.keys(C)],attributes:{...we.attributes,...C}};T=[Be.raw,[no,mo],Be.harden];}return u!=null&&u.math&&(T=[...T,u.math.rehypePlugin]),R&&d&&(T=[...T,R.rehypePlugin]),T},[i,u==null?void 0:u.math,R,d,C]),co=useMemo(()=>f&&d?{"--streamdown-caret":`"${Kn[f]}"`}:void 0,[f,d]);return t==="static"?jsx(le.Provider,{value:u!=null?u:null,children:jsx(L.Provider,{value:Y,children:jsx("div",{className:g("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",a),children:jsx(De,{components:Oe,rehypePlugins:qe,remarkPlugins:Ae,...P,children:e})})})}):jsx(le.Provider,{value:u!=null?u:null,children:jsx(L.Provider,{value:Y,children:jsxs("div",{className:g("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",f?"*:last:after:inline *:last:after:align-baseline *:last:after:content-[var(--streamdown-caret)]":null,a),style:co,children:[I.length===0&&f&&d&&jsx("span",{}),I.map((T,j)=>jsx(m,{components:Oe,content:T,index:j,rehypePlugins:qe,remarkPlugins:Ae,shouldParseIncompleteMarkdown:o,...P},w[j]))]})})})},(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);Qn.displayName="Streamdown";var lo=({children:e,className:t,minZoom:o=.5,maxZoom:n=3,zoomStep:i=.1,showControls:r=true,initialZoom:a=1,fullscreen:c=false})=>{let s=useRef(null),l=useRef(null),[d,p]=useState(a),[m,b]=useState({x:0,y:0}),[f,u]=useState(false),[y,k]=useState({x:0,y:0}),[C,P]=useState({x:0,y:0}),M=useCallback(w=>{p(R=>Math.max(o,Math.min(n,R+w)));},[o,n]),z=useCallback(()=>{M(i);},[M,i]),E=useCallback(()=>{M(-i);},[M,i]),H=useCallback(()=>{p(a),b({x:0,y:0});},[a]),D=useCallback(w=>{w.preventDefault();let R=w.deltaY>0?-i:i;M(R);},[M,i]),X=useCallback(w=>{if(w.button!==0||w.isPrimary===false)return;u(true),k({x:w.clientX,y:w.clientY}),P(m);let R=w.currentTarget;R instanceof HTMLElement&&R.setPointerCapture(w.pointerId);},[m]),O=useCallback(w=>{if(!f)return;w.preventDefault();let R=w.clientX-y.x,Y=w.clientY-y.y;b({x:C.x+R,y:C.y+Y});},[f,y,C]),I=useCallback(w=>{u(false);let R=w.currentTarget;R instanceof HTMLElement&&R.releasePointerCapture(w.pointerId);},[]);return useEffect(()=>{let w=s.current;if(w)return w.addEventListener("wheel",D,{passive:false}),()=>{w.removeEventListener("wheel",D);}},[D]),useEffect(()=>{let w=l.current;if(w&&f)return document.body.style.userSelect="none",w.addEventListener("pointermove",O,{passive:false}),w.addEventListener("pointerup",I),w.addEventListener("pointercancel",I),()=>{document.body.style.userSelect="",w.removeEventListener("pointermove",O),w.removeEventListener("pointerup",I),w.removeEventListener("pointercancel",I);}},[f,O,I]),jsxs("div",{className:g("relative flex flex-col",c?"h-full w-full":"min-h-28 w-full",t),ref:s,style:{cursor:f?"grabbing":"grab"},children:[r?jsxs("div",{className:g("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",c?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:"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:d>=n,onClick:z,title:"Zoom in",type:"button",children:jsx(_e,{size:16})}),jsx("button",{className:"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:d<=o,onClick:E,title:"Zoom out",type:"button",children:jsx(Xe,{size:16})}),jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:H,title:"Reset zoom and pan",type:"button",children:jsx(Ue,{size:16})})]}):null,jsx("div",{className:g("flex-1 origin-center transition-transform duration-150 ease-out",c?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:X,ref:l,role:"application",style:{transform:`translate(${m.x}px, ${m.y}px) scale(${d})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var lt=({chart:e,className:t,config:o,fullscreen:n=false,showControls:i=true})=>{let[r,a]=useState(null),[c,s]=useState(false),[l,d]=useState(""),[p,m]=useState(""),[b,f]=useState(0),{mermaid:u}=useContext(L),y=K(),k=u==null?void 0:u.errorComponent,{shouldRender:C,containerRef:P}=ze({immediate:n});if(useEffect(()=>{if(!C)return;if(!y){a("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{a(null),s(!0);let E=y.getMermaid(o),H=e.split("").reduce((O,I)=>(O<<5)-O+I.charCodeAt(0)|0,0),D=`mermaid-${Math.abs(H)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:X}=await E.render(D,e);d(X),m(X);}catch(E){if(!(p||l)){let H=E instanceof Error?E.message:"Failed to render Mermaid chart";a(H);}}finally{s(false);}})();},[e,o,b,C,y]),!(C||l||p))return jsx("div",{className:g("my-4 min-h-[200px]",t),ref:P});if(c&&!l&&!p)return jsx("div",{className:g("my-4 flex justify-center p-4",t),ref:P,children:jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(r&&!l&&!p){let z=()=>f(E=>E+1);return k?jsx("div",{ref:P,children:jsx(k,{chart:e,error:r,retry:z})}):jsxs("div",{className:g("rounded-lg border border-red-200 bg-red-50 p-4",t),ref:P,children:[jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),jsxs("details",{className:"mt-2",children:[jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let M=l||p;return jsx("div",{className:g("size-full",t),"data-streamdown":"mermaid",ref:P,children:jsx(lo,{className:g(n?"size-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:i,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:g("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:M},role:"img"})})})};export{Q as a,g as b,Io as c,Zr as d,lt as e,Yt as f,Ve as g,Be as h,Jn as i,L as j,ro as k,Qn as l};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {b,j,d,c}from'./chunk-LPQFK2AO.js';import {memo,useMemo,useContext,useState,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';var P=b("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"),R=o=>{let e={};for(let s of o.split(";")){let n=s.indexOf(":");if(n>0){let a=s.slice(0,n).trim(),i=s.slice(n+1).trim();a&&i&&(e[a]=i);}}return e},y=memo(({children:o,result:e,language:s,className:n,...a})=>{let i=useMemo(()=>{let r={};return e.bg&&(r["--sdm-bg"]=e.bg),e.fg&&(r["--sdm-fg"]=e.fg),e.rootStyle&&Object.assign(r,R(e.rootStyle)),r},[e.bg,e.fg,e.rootStyle]);return jsx("pre",{className:b(n,"p-4 text-sm","bg-[var(--sdm-bg,transparent)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,transparent))]"),"data-language":s,"data-streamdown":"code-block-body",style:i,...a,children:jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((r,l)=>jsx("span",{className:P,children:r.map((t,p)=>jsx("span",{className:b("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",t.bgColor&&"bg-[var(--sdm-tbg)]",t.bgColor&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:{...t.color?{"--sdm-c":t.color}:{},...t.bgColor?{"--sdm-tbg":t.bgColor}:{},...t.htmlStyle},...t.htmlAttrs,children:t.content},p))},l))})})},(o,e)=>o.result===e.result&&o.language===e.language&&o.className===e.className);var h=({className:o,language:e,style:s,...n})=>jsx("div",{className:b("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...s},...n});var B=({language:o,children:e})=>jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":o,"data-streamdown":"code-block-header",children:[jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsx("div",{className:"flex items-center gap-2",children:e})]});var I=/\n+$/,Y=({code:o,language:e,className:s,children:n,...a})=>{let{shikiTheme:i}=useContext(j),r=d(),l=useMemo(()=>o.replace(I,""),[o]),t=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:l.split(`
|
|
3
|
+
`).map(m=>[{content:m,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[l]),[p,c$1]=useState(t);return useEffect(()=>{if(!r){c$1(t);return}let m=r.highlight({code:l,language:e,themes:i},S=>{c$1(S);});if(m){c$1(m);return}c$1(t);},[l,e,i,r,t]),jsx(c.Provider,{value:{code:o},children:jsxs(h,{language:e,children:[jsx(B,{language:e,children:n}),jsx(y,{className:s,language:e,result:p,...a})]})})};export{Y as CodeBlock};
|
package/dist/index.d.ts
CHANGED
|
@@ -5,23 +5,47 @@ import { MermaidConfig } from 'mermaid';
|
|
|
5
5
|
import { RemendOptions } from 'remend';
|
|
6
6
|
import { BundledLanguage, BundledTheme } from 'shiki';
|
|
7
7
|
export { BundledLanguage, BundledTheme } from 'shiki';
|
|
8
|
-
import {
|
|
9
|
-
import { Element } from 'hast';
|
|
8
|
+
import { Pluggable, PluggableList } from 'unified';
|
|
9
|
+
import { Element, Parents } from 'hast';
|
|
10
10
|
import { Options as Options$1 } from 'remark-rehype';
|
|
11
11
|
|
|
12
|
+
interface AnimatePlugin {
|
|
13
|
+
name: "animate";
|
|
14
|
+
type: "animate";
|
|
15
|
+
rehypePlugin: Pluggable;
|
|
16
|
+
}
|
|
17
|
+
interface AnimateOptions {
|
|
18
|
+
animation?: "fadeIn" | "blurIn" | "slideUp" | (string & {});
|
|
19
|
+
duration?: number;
|
|
20
|
+
easing?: string;
|
|
21
|
+
sep?: "word" | "char";
|
|
22
|
+
}
|
|
23
|
+
declare function createAnimatePlugin(options?: AnimateOptions): AnimatePlugin;
|
|
24
|
+
|
|
12
25
|
interface ExtraProps {
|
|
13
26
|
node?: Element | undefined;
|
|
14
27
|
}
|
|
28
|
+
type AllowElement = (element: Readonly<Element>, index: number, parent: Readonly<Parents> | undefined) => boolean | null | undefined;
|
|
29
|
+
type UrlTransform = (url: string, key: string, node: Readonly<Element>) => string | null | undefined;
|
|
15
30
|
type Components = {
|
|
16
31
|
[Key in keyof JSX.IntrinsicElements]?: ComponentType<JSX.IntrinsicElements[Key] & ExtraProps> | keyof JSX.IntrinsicElements;
|
|
32
|
+
} & {
|
|
33
|
+
[key: string]: ComponentType<Record<string, unknown> & ExtraProps> | keyof JSX.IntrinsicElements | undefined;
|
|
17
34
|
};
|
|
18
35
|
interface Options {
|
|
36
|
+
allowElement?: AllowElement;
|
|
37
|
+
allowedElements?: readonly string[];
|
|
19
38
|
children?: string;
|
|
20
39
|
components?: Components;
|
|
40
|
+
disallowedElements?: readonly string[];
|
|
21
41
|
rehypePlugins?: PluggableList;
|
|
22
42
|
remarkPlugins?: PluggableList;
|
|
23
43
|
remarkRehypeOptions?: Readonly<Options$1>;
|
|
44
|
+
skipHtml?: boolean;
|
|
45
|
+
unwrapDisallowed?: boolean;
|
|
46
|
+
urlTransform?: UrlTransform;
|
|
24
47
|
}
|
|
48
|
+
declare const defaultUrlTransform: UrlTransform;
|
|
25
49
|
|
|
26
50
|
/**
|
|
27
51
|
* A single token in a highlighted line
|
|
@@ -41,6 +65,7 @@ interface HighlightResult {
|
|
|
41
65
|
tokens: HighlightToken[][];
|
|
42
66
|
fg?: string;
|
|
43
67
|
bg?: string;
|
|
68
|
+
rootStyle?: string | false;
|
|
44
69
|
}
|
|
45
70
|
/**
|
|
46
71
|
* Options for highlighting code
|
|
@@ -182,6 +207,7 @@ interface MermaidOptions {
|
|
|
182
207
|
config?: MermaidConfig;
|
|
183
208
|
errorComponent?: React.ComponentType<MermaidErrorComponentProps>;
|
|
184
209
|
}
|
|
210
|
+
type AllowedTags = Record<string, string[]>;
|
|
185
211
|
type StreamdownProps = Options & {
|
|
186
212
|
mode?: "static" | "streaming";
|
|
187
213
|
BlockComponent?: React.ComponentType<BlockProps>;
|
|
@@ -192,10 +218,13 @@ type StreamdownProps = Options & {
|
|
|
192
218
|
mermaid?: MermaidOptions;
|
|
193
219
|
controls?: ControlsConfig;
|
|
194
220
|
isAnimating?: boolean;
|
|
221
|
+
animated?: boolean | AnimateOptions;
|
|
195
222
|
caret?: keyof typeof carets;
|
|
196
223
|
plugins?: PluginConfig;
|
|
197
224
|
remend?: RemendOptions;
|
|
198
225
|
linkSafety?: LinkSafetyConfig;
|
|
226
|
+
/** Custom tags to allow through sanitization with their permitted attributes */
|
|
227
|
+
allowedTags?: AllowedTags;
|
|
199
228
|
};
|
|
200
229
|
declare const defaultRehypePlugins: Record<string, Pluggable>;
|
|
201
230
|
declare const defaultRemarkPlugins: Record<string, Pluggable>;
|
|
@@ -218,6 +247,6 @@ type BlockProps = Options & {
|
|
|
218
247
|
index: number;
|
|
219
248
|
};
|
|
220
249
|
declare const Block: react.MemoExoticComponent<({ content, shouldParseIncompleteMarkdown: _, index: __, ...props }: BlockProps) => react_jsx_runtime.JSX.Element>;
|
|
221
|
-
declare const Streamdown: react.MemoExoticComponent<({ children, mode, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, controls, isAnimating, BlockComponent, parseMarkdownIntoBlocksFn, caret, plugins, remend: remendOptions, linkSafety, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
|
|
250
|
+
declare const Streamdown: react.MemoExoticComponent<({ children, mode, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, controls, isAnimating, animated, BlockComponent, parseMarkdownIntoBlocksFn, caret, plugins, remend: remendOptions, linkSafety, allowedTags, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
|
|
222
251
|
|
|
223
|
-
export { Block, type CjkPlugin, type CodeHighlighterPlugin, type ControlsConfig, type DiagramPlugin, type HighlightOptions, type LinkSafetyConfig, type LinkSafetyModalProps, type MathPlugin, type MermaidErrorComponentProps, type MermaidOptions, type PluginConfig, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, defaultRehypePlugins, defaultRemarkPlugins, parseMarkdownIntoBlocks };
|
|
252
|
+
export { type AllowElement, type AllowedTags, type AnimateOptions, Block, type CjkPlugin, type CodeHighlighterPlugin, type Components, type ControlsConfig, type DiagramPlugin, type ExtraProps, type HighlightOptions, type LinkSafetyConfig, type LinkSafetyModalProps, type MathPlugin, type MermaidErrorComponentProps, type MermaidOptions, type PluginConfig, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, type UrlTransform, createAnimatePlugin, defaultRehypePlugins, defaultRemarkPlugins, defaultUrlTransform, parseMarkdownIntoBlocks };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export{
|
|
2
|
+
export{k as Block,l as Streamdown,j as StreamdownContext,a as createAnimatePlugin,h as defaultRehypePlugins,i as defaultRemarkPlugins,f as defaultUrlTransform,g as parseMarkdownIntoBlocks}from'./chunk-LPQFK2AO.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "streamdown",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js"
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./styles.css": "./styles.css"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
|
+
"styles.css",
|
|
17
18
|
"README.md"
|
|
18
19
|
],
|
|
19
20
|
"homepage": "https://streamdown.ai",
|
|
@@ -26,7 +27,6 @@
|
|
|
26
27
|
"license": "Apache-2.0",
|
|
27
28
|
"description": "A drop-in replacement for react-markdown, designed for AI-powered streaming.",
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"shiki": "^3.19.0",
|
|
30
30
|
"@testing-library/jest-dom": "^6.9.1",
|
|
31
31
|
"@testing-library/react": "^16.3.0",
|
|
32
32
|
"@types/hast": "^3.0.4",
|
|
@@ -37,11 +37,14 @@
|
|
|
37
37
|
"jsdom": "^27.3.0",
|
|
38
38
|
"mermaid": "^11.12.2",
|
|
39
39
|
"react-markdown": "^10.1.0",
|
|
40
|
+
"rehype-parse": "^9.0.1",
|
|
41
|
+
"rehype-stringify": "^10.0.1",
|
|
42
|
+
"shiki": "^3.19.0",
|
|
40
43
|
"tsup": "^8.5.1",
|
|
41
44
|
"vitest": "^4.0.15",
|
|
42
|
-
"@streamdown/cjk": "1.0.
|
|
43
|
-
"@streamdown/math": "1.0.
|
|
44
|
-
"@streamdown/mermaid": "1.0.
|
|
45
|
+
"@streamdown/cjk": "1.0.2",
|
|
46
|
+
"@streamdown/math": "1.0.2",
|
|
47
|
+
"@streamdown/mermaid": "1.0.2"
|
|
45
48
|
},
|
|
46
49
|
"peerDependencies": {
|
|
47
50
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -60,7 +63,8 @@
|
|
|
60
63
|
"tailwind-merge": "^3.4.0",
|
|
61
64
|
"unified": "^11.0.5",
|
|
62
65
|
"unist-util-visit": "^5.0.0",
|
|
63
|
-
"
|
|
66
|
+
"unist-util-visit-parents": "^6.0.0",
|
|
67
|
+
"remend": "1.2.0"
|
|
64
68
|
},
|
|
65
69
|
"scripts": {
|
|
66
70
|
"build": "tsup",
|
package/styles.css
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@keyframes sd-fadeIn {
|
|
2
|
+
from {
|
|
3
|
+
opacity: 0;
|
|
4
|
+
}
|
|
5
|
+
to {
|
|
6
|
+
opacity: 1;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@keyframes sd-blurIn {
|
|
11
|
+
from {
|
|
12
|
+
opacity: 0;
|
|
13
|
+
filter: blur(4px);
|
|
14
|
+
}
|
|
15
|
+
to {
|
|
16
|
+
opacity: 1;
|
|
17
|
+
filter: blur(0);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@keyframes sd-slideUp {
|
|
22
|
+
from {
|
|
23
|
+
opacity: 0;
|
|
24
|
+
transform: translateY(4px);
|
|
25
|
+
}
|
|
26
|
+
to {
|
|
27
|
+
opacity: 1;
|
|
28
|
+
transform: translateY(0);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[data-sd-animate] {
|
|
33
|
+
animation: var(--sd-animation, sd-fadeIn) var(--sd-duration, 150ms)
|
|
34
|
+
var(--sd-easing, ease) both;
|
|
35
|
+
}
|
package/dist/chunk-5FQGJX7Z.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {createContext,lazy,memo,useContext,isValidElement,useId,useTransition,useMemo,useState,useEffect,useCallback,Suspense,useRef}from'react';import {harden}from'rehype-harden';import pn from'rehype-raw';import un from'rehype-sanitize';import fn from'remark-gfm';import bn from'remend';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import Jo from'remark-parse';import Fo from'remark-rehype';import {unified}from'unified';import {Lexer}from'marked';var Yt=300,Qt="300px",eo=500;function Ve(e={}){let{immediate:t=false,debounceDelay:o=Yt,rootMargin:n=Qt,idleTimeout:d=eo}=e,[s,m]=useState(false),i=useRef(null),r=useRef(null),l=useRef(null),c=useMemo(()=>f=>{let a=Date.now();return window.setTimeout(()=>{f({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-a))});},1)},[]),u=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(f,a)=>window.requestIdleCallback(f,a):c,[c]),p=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?f=>window.cancelIdleCallback(f):f=>{clearTimeout(f);},[]);return useEffect(()=>{if(t){m(true);return}let f=i.current;if(!f)return;r.current&&(clearTimeout(r.current),r.current=null),l.current&&(p(l.current),l.current=null);let a=()=>{r.current&&(clearTimeout(r.current),r.current=null),l.current&&(p(l.current),l.current=null);},h=M=>{l.current=u(P=>{P.timeRemaining()>0||P.didTimeout?(m(true),M.disconnect()):l.current=u(()=>{m(true),M.disconnect();},{timeout:d/2});},{timeout:d});},y=M=>{a(),r.current=window.setTimeout(()=>{var L,D;let P=M.takeRecords();(P.length===0||(D=(L=P.at(-1))==null?void 0:L.isIntersecting)!=null&&D)&&h(M);},o);},k=(M,P)=>{M.isIntersecting?y(P):a();},C=new IntersectionObserver(M=>{for(let P of M)k(P,C);},{rootMargin:n,threshold:0});return C.observe(f),()=>{r.current&&clearTimeout(r.current),l.current&&p(l.current),C.disconnect();}},[t,o,n,d,p,u]),{shouldRender:s,containerRef:i}}var J=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"})}),F=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"})}),z=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"})}),Be=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"})]}),je=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"})}),Oe=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"})}),re=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"})}),ve=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"})}),Ae=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"})}),qe=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"})});var b=(...e)=>twMerge(clsx(e)),B=(e,t,o)=>{let n=typeof t=="string"?new Blob([t],{type:o}):t,d=URL.createObjectURL(n),s=document.createElement("a");s.href=d,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(d);};var ao=createContext({code:""}),se=()=>useContext(ao);var Ce=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:d,code:s,...m})=>{let[i,r]=useState(false),l=useRef(0),{code:c}=se(),{isAnimating:u}=useContext(N),p=s!=null?s:c,f=async()=>{var h;if(typeof window=="undefined"||!((h=navigator==null?void 0:navigator.clipboard)!=null&&h.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(p),r(!0),e==null||e(),l.current=window.setTimeout(()=>r(!1),o));}catch(y){t==null||t(y);}};useEffect(()=>()=>{window.clearTimeout(l.current);},[]);let a=i?J:F;return jsx("button",{className:b("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",d),"data-streamdown":"code-block-copy-button",disabled:u,onClick:f,title:"Copy Code",type:"button",...m,children:n!=null?n:jsx(a,{size:14})})};var $e={"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"},We=({onDownload:e,onError:t,language:o,children:n,className:d,code:s,...m})=>{let{code:i}=se(),{isAnimating:r}=useContext(N),l=s!=null?s:i,u=`file.${o&&o in $e?$e[o]:"txt"}`,p="text/plain",f=()=>{try{B(u,l,p),e==null||e();}catch(a){t==null||t(a);}};return jsx("button",{className:b("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",d),"data-streamdown":"code-block-download-button",disabled:r,onClick:f,title:"Download file",type:"button",...m,children:n!=null?n:jsx(z,{size:14})})};var Pe=()=>jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[jsx("div",{className:"h-[46px] w-full bg-muted/80"}),jsx("div",{className:"flex w-full items-center justify-center p-4",children:jsx(Be,{className:"size-4 animate-spin"})})]});var fo=/\.[^/.]+$/,Xe=({node:e,className:t,src:o,alt:n,...d})=>{let s=async()=>{if(o)try{let i=await(await fetch(o)).blob(),l=new URL(o,window.location.origin).pathname.split("/").pop()||"",c=l.split(".").pop(),u=l.includes(".")&&c!==void 0&&c.length<=4,p="";if(u)p=l;else {let f=i.type,a="png";f.includes("jpeg")||f.includes("jpg")?a="jpg":f.includes("png")?a="png":f.includes("svg")?a="svg":f.includes("gif")?a="gif":f.includes("webp")&&(a="webp"),p=`${(n||l||"image").replace(fo,"")}.${a}`;}B(p,i,i.type);}catch(m){window.open(o,"_blank");}};return o?jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:b("max-w-full rounded-lg",t),"data-streamdown":"image",src:o,...d}),jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsx("button",{className:b("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 group-hover:opacity-100"),onClick:s,title:"Download image",type:"button",children:jsx(z,{size:14})})]}):null};var Q=0,yo=()=>{Q+=1,Q===1&&(document.body.style.overflow="hidden");},wo=()=>{Q=Math.max(0,Q-1),Q===0&&(document.body.style.overflow="");},Fe=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let[d,s]=useState(false),m=useCallback(async()=>{try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3);}catch(r){}},[e]),i=useCallback(()=>{n(),o();},[n,o]);return useEffect(()=>{if(t){yo();let r=l=>{l.key==="Escape"&&o();};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r),wo();}}},[t,o]),t?jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm","data-streamdown":"link-safety-modal",onClick:o,onKeyDown:r=>{r.key==="Escape"&&o();},role:"button",tabIndex:0,children:jsxs("div",{className:"relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg",onClick:r=>r.stopPropagation(),onKeyDown:r=>r.stopPropagation(),role:"presentation",children:[jsx("button",{className:"absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:o,title:"Close",type:"button",children:jsx(re,{size:16})}),jsxs("div",{className:"flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center gap-2 font-semibold text-lg",children:[jsx(ve,{size:20}),jsx("span",{children:"Open external link?"})]}),jsx("p",{className:"text-muted-foreground text-sm",children:"You're about to visit an external website."})]}),jsx("div",{className:b("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:"flex gap-2",children:[jsx("button",{className:"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(J,{size:14}),jsx("span",{children:"Copied"})]}):jsxs(Fragment,{children:[jsx(F,{size:14}),jsx("span",{children:"Copy link"})]})}),jsxs("button",{className:"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:i,type:"button",children:[jsx(ve,{size:14}),jsx("span",{children:"Open link"})]})]})]})}):null};var ie=createContext(null),Ue=()=>useContext(ie),cr=()=>{var t;let e=Ue();return (t=e==null?void 0:e.code)!=null?t:null},U=()=>{var t;let e=Ue();return (t=e==null?void 0:e.mermaid)!=null?t:null};var Ke=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((d,s)=>{let m="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let r=document.createElement("canvas"),l=i.width*o,c=i.height*o;r.width=l,r.height=c;let u=r.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(i,0,0,l,c),r.toBlob(p=>{if(!p){s(new Error("Failed to create PNG blob"));return}d(p);},"image/png");},i.onerror=()=>s(new Error("Failed to load SVG image")),i.src=m;})};var Ye=({chart:e,children:t,className:o,onDownload:n,config:d,onError:s})=>{let[m,i]=useState(false),r=useRef(null),{isAnimating:l}=useContext(N),c=U(),u=async p=>{try{if(p==="mmd"){B("diagram.mmd",e,"text/plain"),i(!1),n==null||n(p);return}if(!c){s==null||s(new Error("Mermaid plugin not available"));return}let f=c.getMermaid(d),a=e.split("").reduce((k,C)=>(k<<5)-k+C.charCodeAt(0)|0,0),h=`mermaid-${Math.abs(a)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:y}=await f.render(h,e);if(!y){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(p==="svg"){B("diagram.svg",y,"image/svg+xml"),i(!1),n==null||n(p);return}if(p==="png"){let k=await Ke(y);B("diagram.png",k,"image/png"),n==null||n(p),i(!1);return}}catch(f){s==null||s(f);}};return useEffect(()=>{let p=f=>{let a=f.composedPath();r.current&&!a.includes(r.current)&&i(false);};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p);}},[]),jsxs("div",{className:"relative",ref:r,children:[jsx("button",{className:b("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:l,onClick:()=>i(!m),title:"Download diagram",type:"button",children:t!=null?t:jsx(z,{size:14})}),m?jsxs("div",{className:"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:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("svg"),title:"Download diagram as SVG",type:"button",children:"SVG"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("png"),title:"Download diagram as PNG",type:"button",children:"PNG"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]}):null]})};var te=0,Lo=()=>{te+=1,te===1&&(document.body.style.overflow="hidden");},So=()=>{te=Math.max(0,te-1),te===0&&(document.body.style.overflow="");},ot=({chart:e,config:t,onFullscreen:o,onExit:n,className:d,...s})=>{let[m,i]=useState(false),{isAnimating:r,controls:l}=useContext(N),c=(()=>{if(typeof l=="boolean")return l;let p=l.mermaid;return p===false?false:p===true||p===void 0?true:p.panZoom!==false})(),u=()=>{i(!m);};return useEffect(()=>{if(m){Lo();let p=f=>{f.key==="Escape"&&i(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),So();}}},[m]),useEffect(()=>{m?o==null||o():n&&n();},[m,o,n]),jsxs(Fragment,{children:[jsx("button",{className:b("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",d),disabled:r,onClick:u,title:"View fullscreen",type:"button",...s,children:jsx(je,{size:14})}),m?jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:u,onKeyDown:p=>{p.key==="Escape"&&u();},role:"button",tabIndex:0,children:[jsx("button",{className:"absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:u,title:"Exit fullscreen",type:"button",children:jsx(re,{size:20})}),jsx("div",{className:"flex size-full items-center justify-center p-4",onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:jsx(tt,{chart:e,className:"size-full [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:true,showControls:c})})]}):null]})};var le=e=>{var s,m;let t=[],o=[],n=e.querySelectorAll("thead th");for(let i of n)t.push(((s=i.textContent)==null?void 0:s.trim())||"");let d=e.querySelectorAll("tbody tr");for(let i of d){let r=[],l=i.querySelectorAll("td");for(let c of l)r.push(((m=c.textContent)==null?void 0:m.trim())||"");o.push(r);}return {headers:t,rows:o}},ce=e=>{let{headers:t,rows:o}=e,n=i=>{let r=false,l=false;for(let c of i){if(c==='"'){r=true,l=true;break}(c===","||c===`
|
|
3
|
-
`)&&(r=true);}return r?l?`"${i.replace(/"/g,'""')}"`:`"${i}"`:i},d=t.length>0?o.length+1:o.length,s=new Array(d),m=0;t.length>0&&(s[m]=t.map(n).join(","),m+=1);for(let i of o)s[m]=i.map(n).join(","),m+=1;return s.join(`
|
|
4
|
-
`)},nt=e=>{let{headers:t,rows:o}=e,n=i=>{let r=false;for(let c of i)if(c===" "||c===`
|
|
5
|
-
`||c==="\r"){r=true;break}if(!r)return i;let l=[];for(let c of i)c===" "?l.push("\\t"):c===`
|
|
6
|
-
`?l.push("\\n"):c==="\r"?l.push("\\r"):l.push(c);return l.join("")},d=t.length>0?o.length+1:o.length,s=new Array(d),m=0;t.length>0&&(s[m]=t.map(n).join(" "),m+=1);for(let i of o)s[m]=i.map(n).join(" "),m+=1;return s.join(`
|
|
7
|
-
`)},Me=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("")},rt=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),d=0,s=t.map(i=>Me(i));n[d]=`| ${s.join(" | ")} |`,d+=1;let m=new Array(t.length);for(let i=0;i<t.length;i+=1)m[i]="---";n[d]=`| ${m.join(" | ")} |`,d+=1;for(let i of o)if(i.length<t.length){let r=new Array(t.length);for(let l=0;l<t.length;l+=1)r[l]=l<i.length?Me(i[l]):"";n[d]=`| ${r.join(" | ")} |`,d+=1;}else {let r=i.map(l=>Me(l));n[d]=`| ${r.join(" | ")} |`,d+=1;}return n.join(`
|
|
8
|
-
`)};var lt=({children:e,className:t,onCopy:o,onError:n,timeout:d=2e3})=>{let[s,m]=useState(false),[i,r]=useState(false),l=useRef(null),c=useRef(0),{isAnimating:u}=useContext(N),p=async a=>{var h,y;if(typeof window=="undefined"||!((h=navigator==null?void 0:navigator.clipboard)!=null&&h.write)){n==null||n(new Error("Clipboard API not available"));return}try{let k=(y=l.current)==null?void 0:y.closest('[data-streamdown="table-wrapper"]'),C=k==null?void 0:k.querySelector("table");if(!C){n==null||n(new Error("Table not found"));return}let M=le(C),P=a==="csv"?ce(M):nt(M),E=new ClipboardItem({"text/plain":new Blob([P],{type:"text/plain"}),"text/html":new Blob([C.outerHTML],{type:"text/html"})});await navigator.clipboard.write([E]),r(!0),m(!1),o==null||o(a),c.current=window.setTimeout(()=>r(!1),d);}catch(k){n==null||n(k);}};useEffect(()=>{let a=h=>{let y=h.composedPath();l.current&&!y.includes(l.current)&&m(false);};return document.addEventListener("mousedown",a),()=>{document.removeEventListener("mousedown",a),window.clearTimeout(c.current);}},[]);let f=i?J:F;return jsxs("div",{className:"relative",ref:l,children:[jsx("button",{className:b("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>m(!s),title:"Copy table",type:"button",children:e!=null?e:jsx(f,{size:14})}),s?jsxs("div",{className:"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:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var dt=({children:e,className:t,onDownload:o,onError:n})=>{let[d,s]=useState(false),m=useRef(null),{isAnimating:i}=useContext(N),r=l=>{var c;try{let u=(c=m.current)==null?void 0:c.closest('[data-streamdown="table-wrapper"]'),p=u==null?void 0:u.querySelector("table");if(!p){n==null||n(new Error("Table not found"));return}let f=le(p),a=l==="csv"?ce(f):rt(f);B(`table.${l==="csv"?"csv":"md"}`,a,l==="csv"?"text/csv":"text/markdown"),s(!1),o==null||o(l);}catch(u){n==null||n(u);}};return useEffect(()=>{let l=c=>{let u=c.composedPath();m.current&&!u.includes(m.current)&&s(false);};return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l);}},[]),jsxs("div",{className:"relative",ref:m,children:[jsx("button",{className:b("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>s(!d),title:"Download table",type:"button",children:e!=null?e:jsx(z,{size:14})}),d?jsxs("div",{className:"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:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>r("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>r("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var pt=({children:e,className:t,showControls:o,...n})=>jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[o?jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsx(lt,{}),jsx(dt,{})]}):null,jsx("div",{className:"overflow-x-auto",children:jsx("table",{className:b("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]});var Oo=lazy(()=>import('./code-block-37QAKDTI.js').then(e=>({default:e.CodeBlock}))),Ao=lazy(()=>import('./mermaid-4DMBBIKO.js').then(e=>({default:e.Mermaid}))),qo=/language-([^\s]+)/;function ge(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,d=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)&&(d==null?void 0:d.line)===(s==null?void 0:s.line)&&(d==null?void 0:d.column)===(s==null?void 0:s.column)}function T(e,t){return e.className===t.className&&ge(e.node,t.node)}var Ne=(e,t)=>typeof e=="boolean"?e:e[t]!==false,ue=(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},Se=memo(({children:e,className:t,node:o,...n})=>jsx("ol",{className:b("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>T(e,t));Se.displayName="MarkdownOl";var bt=memo(({children:e,className:t,node:o,...n})=>jsx("li",{className:b("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&ge(e.node,t.node));bt.displayName="MarkdownLi";var gt=memo(({children:e,className:t,node:o,...n})=>jsx("ul",{className:b("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>T(e,t));gt.displayName="MarkdownUl";var ht=memo(({className:e,node:t,...o})=>jsx("hr",{className:b("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o}),(e,t)=>T(e,t));ht.displayName="MarkdownHr";var yt=memo(({children:e,className:t,node:o,...n})=>jsx("span",{className:b("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>T(e,t));yt.displayName="MarkdownStrong";var zo=({children:e,className:t,href:o,node:n,...d})=>{let{linkSafety:s}=useContext(N),[m,i]=useState(false),r=o==="streamdown:incomplete-link",l=useCallback(async f=>{if(!(!(s!=null&&s.enabled&&o)||r)){if(f.preventDefault(),s.onLinkCheck&&await s.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[s,o,r]),c=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),u=useCallback(()=>{i(false);},[]),p={url:o!=null?o:"",isOpen:m,onClose:u,onConfirm:c};return s!=null&&s.enabled&&o?jsxs(Fragment,{children:[jsx("button",{className:b("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",onClick:l,type:"button",children:e}),s.renderModal?s.renderModal(p):jsx(Fe,{...p})]}):jsx("a",{className:b("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...d,children:e})},wt=memo(zo,(e,t)=>T(e,t)&&e.href===t.href);wt.displayName="MarkdownA";var kt=memo(({children:e,className:t,node:o,...n})=>jsx("h1",{className:b("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>T(e,t));kt.displayName="MarkdownH1";var vt=memo(({children:e,className:t,node:o,...n})=>jsx("h2",{className:b("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>T(e,t));vt.displayName="MarkdownH2";var Ct=memo(({children:e,className:t,node:o,...n})=>jsx("h3",{className:b("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>T(e,t));Ct.displayName="MarkdownH3";var xt=memo(({children:e,className:t,node:o,...n})=>jsx("h4",{className:b("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>T(e,t));xt.displayName="MarkdownH4";var Pt=memo(({children:e,className:t,node:o,...n})=>jsx("h5",{className:b("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>T(e,t));Pt.displayName="MarkdownH5";var Mt=memo(({children:e,className:t,node:o,...n})=>jsx("h6",{className:b("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>T(e,t));Mt.displayName="MarkdownH6";var Tt=memo(({children:e,className:t,node:o,...n})=>{let{controls:d}=useContext(N),s=Ne(d,"table");return jsx(pt,{className:t,showControls:s,...n,children:e})},(e,t)=>T(e,t));Tt.displayName="MarkdownTable";var Nt=memo(({children:e,className:t,node:o,...n})=>jsx("thead",{className:b("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>T(e,t));Nt.displayName="MarkdownThead";var Lt=memo(({children:e,className:t,node:o,...n})=>jsx("tbody",{className:b("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>T(e,t));Lt.displayName="MarkdownTbody";var St=memo(({children:e,className:t,node:o,...n})=>jsx("tr",{className:b("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>T(e,t));St.displayName="MarkdownTr";var Rt=memo(({children:e,className:t,node:o,...n})=>jsx("th",{className:b("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>T(e,t));Rt.displayName="MarkdownTh";var It=memo(({children:e,className:t,node:o,...n})=>jsx("td",{className:b("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>T(e,t));It.displayName="MarkdownTd";var Ht=memo(({children:e,className:t,node:o,...n})=>jsx("blockquote",{className:b("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>T(e,t));Ht.displayName="MarkdownBlockquote";var Et=memo(({children:e,className:t,node:o,...n})=>jsx("sup",{className:b("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>T(e,t));Et.displayName="MarkdownSup";var Dt=memo(({children:e,className:t,node:o,...n})=>jsx("sub",{className:b("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>T(e,t));Dt.displayName="MarkdownSub";var Vt=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=r=>{var p,f;if(!isValidElement(r))return false;let l=Array.isArray(r.props.children)?r.props.children:[r.props.children],c=false,u=false;for(let a of l)if(a){if(typeof a=="string")a.trim()!==""&&(c=true);else if(isValidElement(a))if(((p=a.props)==null?void 0:p["data-footnote-backref"])!==void 0)u=true;else {let h=Array.isArray(a.props.children)?a.props.children:[a.props.children];for(let y of h){if(typeof y=="string"&&y.trim()!==""){c=true;break}if(isValidElement(y)&&((f=y.props)==null?void 0:f["data-footnote-backref"])===void 0){c=true;break}}}}return u&&!c},m=Array.isArray(e)?e.map(r=>{if(!isValidElement(r))return r;if(r.type===Se){let c=(Array.isArray(r.props.children)?r.props.children:[r.props.children]).filter(u=>!s(u));return c.length===0?null:{...r,props:{...r.props,children:c}}}return r}):e;return (Array.isArray(m)?m.some(r=>r!==null):m!==null)?jsx("section",{className:t,...n,children:m}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>T(e,t));Vt.displayName="MarkdownSection";var $o=({node:e,className:t,children:o,...n})=>{var p,f,a;let d=((p=e==null?void 0:e.position)==null?void 0:p.start.line)===((f=e==null?void 0:e.position)==null?void 0:f.end.line),{mermaid:s,controls:m}=useContext(N),i=U();if(d)return jsx("code",{className:b("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let r=t==null?void 0:t.match(qo),l=(a=r==null?void 0:r.at(1))!=null?a:"",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),l==="mermaid"&&i){let h=Ne(m,"mermaid"),y=ue(m,"download"),k=ue(m,"copy"),C=ue(m,"fullscreen"),M=ue(m,"panZoom"),P=h&&(y||k||C);return jsx(Suspense,{fallback:jsx(Pe,{}),children:jsxs("div",{className:b("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[P?jsxs("div",{className:"flex items-center justify-end gap-2",children:[y?jsx(Ye,{chart:c,config:s==null?void 0:s.config}):null,k?jsx(Ce,{code:c}):null,C?jsx(ot,{chart:c,config:s==null?void 0:s.config}):null]}):null,jsx(Ao,{chart:c,config:s==null?void 0:s.config,showControls:M})]})})}let u=Ne(m,"code");return jsx(Suspense,{fallback:jsx(Pe,{}),children:jsx(Oo,{className:b("overflow-x-auto border-border border-t",t),code:c,language:l,children:u?jsxs(Fragment,{children:[jsx(We,{code:c,language:l}),jsx(Ce,{})]}):null})})},Bt=memo($o,(e,t)=>e.className===t.className&&ge(e.node,t.node));Bt.displayName="MarkdownCode";var jt=memo(Xe,(e,t)=>e.className===t.className&&ge(e.node,t.node));jt.displayName="MarkdownImg";var Ot=memo(({children:e,className:t,node:o,...n})=>{var m,i;let s=(Array.isArray(e)?e:[e]).filter(r=>r!=null&&r!=="");if(s.length===1&&isValidElement(s[0])){let r=s[0].props.node,l=r==null?void 0:r.tagName;if(l==="img")return jsx(Fragment,{children:e});if(l==="code"&&((m=r==null?void 0:r.position)==null?void 0:m.start.line)!==((i=r==null?void 0:r.position)==null?void 0:i.end.line))return jsx(Fragment,{children:e})}return jsx("p",{className:t,...n,children:e})},(e,t)=>T(e,t));Ot.displayName="MarkdownParagraph";var At={ol:Se,li:bt,ul:gt,hr:ht,strong:yt,a:wt,h1:kt,h2:vt,h3:Ct,h4:xt,h5:Pt,h6:Mt,table:Tt,thead:Nt,tbody:Lt,tr:St,th:Rt,td:It,blockquote:Ht,code:Bt,img:jt,pre:({children:e})=>e,sup:Et,sub:Dt,p:Ot,section:Vt};var qt=[],zt={allowDangerousHtml:true},he=new WeakMap,Re=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,d=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||d||s)){let u="default";return this.keyCache.set(t,u),u}let m=u=>{if(!u||u.length===0)return "";let p="";for(let f=0;f<u.length;f+=1){let a=u[f];if(f>0&&(p+=","),Array.isArray(a)){let[h,y]=a;if(typeof h=="function"){let k=he.get(h);k||(k=h.name,he.set(h,k)),p+=k;}else p+=String(h);p+=":",p+=JSON.stringify(y);}else if(typeof a=="function"){let h=he.get(a);h||(h=a.name,he.set(a,h)),p+=h;}else p+=String(a);}return p},i=m(n),r=m(d),l=s?JSON.stringify(s):"",c=`${r}::${i}::${l}`;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 d=this.cache.keys().next().value;d&&this.cache.delete(d);}this.cache.set(n,o);}clear(){this.cache.clear();}},$t=new Re,Ie=e=>{let t=Ko(e),o=e.children||"";return Yo(t.runSync(t.parse(o),o),e)},Ko=e=>{let t=$t.get(e);if(t)return t;let o=Go(e);return $t.set(e,o),o},Go=e=>{let t=e.rehypePlugins||qt,o=e.remarkPlugins||qt,n=e.remarkRehypeOptions?{...zt,...e.remarkRehypeOptions}:zt;return unified().use(Jo).use(o).use(Fo,n).use(t)},Yo=(e,t)=>toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true});var en=/\[\^[^\]\s]{1,200}\](?!:)/,tn=/\[\^[^\]\s]{1,200}\]:/,on=/<\/(\w+)>/,nn=/<(\w+)[\s>]/,He=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
9
|
-
`||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},rn=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
10
|
-
`||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},Ee=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},De=e=>{let t=en.test(e),o=tn.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),d=[],s=[];for(let m of n){let i=m.raw,r=d.length;if(s.length>0){if(d[r-1]+=i,m.type==="html"){let c=i.match(on);if(c){let u=c[1];s.at(-1)===u&&s.pop();}}continue}if(m.type==="html"&&m.block){let c=i.match(nn);if(c){let u=c[1];i.includes(`</${u}>`)||s.push(u);}}if(i.trim()==="$$"&&r>0){let c=d[r-1],u=He(c),p=Ee(c);if(u&&p%2===1){d[r-1]=c+i;continue}}if(r>0&&rn(i)){let c=d[r-1],u=He(c),p=Ee(c),f=Ee(i);if(u&&p%2===1&&!He(i)&&f===1){d[r-1]=c+i;continue}}d.push(i);}return d};var gn={raw:pn,sanitize:[un,{}],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},hn={gfm:[fn,{}]},yn=Object.values(gn),wn=Object.values(hn),kn={block:" \u258B",circle:" \u25CF"},vn={shikiTheme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0,linkSafety:{enabled:true}},N=createContext(vn),Wt=memo(({content:e,shouldParseIncompleteMarkdown:t,index:o,...n})=>jsx(Ie,{...n,children:e}),(e,t)=>{if(e.content!==t.content||e.index!==t.index)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(d=>{var s,m;return ((s=e.components)==null?void 0:s[d])!==((m=t.components)==null?void 0:m[d])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Wt.displayName="Block";var Cn=["github-light","github-dark"],xn=memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:o=true,components:n,rehypePlugins:d=yn,remarkPlugins:s=wn,className:m,shikiTheme:i=Cn,mermaid:r,controls:l=true,isAnimating:c=false,BlockComponent:u=Wt,parseMarkdownIntoBlocksFn:p=De,caret:f,plugins:a,remend:h,linkSafety:y={enabled:true},...k})=>{let C=useId(),[M,P]=useTransition(),E=useMemo(()=>typeof e!="string"?"":t==="streaming"&&o?bn(e,h):e,[e,t,o,h]),L=useMemo(()=>p(E),[E,p]),[D,A]=useState(L);useEffect(()=>{t==="streaming"?P(()=>{A(L);}):A(L);},[L,t]);let j=t==="streaming"?D:L,q=useMemo(()=>j.map((S,W)=>`${C}-${W}`),[j.length,C]),V=useMemo(()=>{var S,W;return {shikiTheme:(W=(S=a==null?void 0:a.code)==null?void 0:S.getThemes())!=null?W:i,controls:l,isAnimating:c,mode:t,mermaid:r,linkSafety:y}},[i,l,c,t,r,y,a==null?void 0:a.code]),w=useMemo(()=>({...At,...n}),[n]),R=useMemo(()=>{let S=[];return a!=null&&a.cjk&&(S=[...S,...a.cjk.remarkPluginsBefore]),S=[...S,...s],a!=null&&a.cjk&&(S=[...S,...a.cjk.remarkPluginsAfter]),a!=null&&a.math&&(S=[...S,a.math.remarkPlugin]),S},[s,a==null?void 0:a.math,a==null?void 0:a.cjk]),Y=useMemo(()=>a!=null&&a.math?[...d,a.math.rehypePlugin]:d,[d,a==null?void 0:a.math]),Ut=useMemo(()=>f&&c?{"--streamdown-caret":`"${kn[f]}"`}:void 0,[f,c]);return t==="static"?jsx(ie.Provider,{value:a!=null?a:null,children:jsx(N.Provider,{value:V,children:jsx("div",{className:b("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",m),children:jsx(Ie,{components:w,rehypePlugins:Y,remarkPlugins:R,...k,children:e})})})}):jsx(ie.Provider,{value:a!=null?a:null,children:jsx(N.Provider,{value:V,children:jsxs("div",{className:b("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",f?"*:last:after:inline *:last:after:align-baseline *:last:after:content-(--streamdown-caret)":null,m),style:Ut,children:[j.length===0&&f&&c&&jsx("span",{}),j.map((S,W)=>jsx(u,{components:w,content:S,index:W,rehypePlugins:Y,remarkPlugins:R,shouldParseIncompleteMarkdown:o,...k},q[W]))]})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety);xn.displayName="Streamdown";var Ft=({children:e,className:t,minZoom:o=.5,maxZoom:n=3,zoomStep:d=.1,showControls:s=true,initialZoom:m=1,fullscreen:i=false})=>{let r=useRef(null),l=useRef(null),[c,u]=useState(m),[p,f]=useState({x:0,y:0}),[a,h]=useState(false),[y,k]=useState({x:0,y:0}),[C,M]=useState({x:0,y:0}),P=useCallback(w=>{u(R=>Math.max(o,Math.min(n,R+w)));},[o,n]),E=useCallback(()=>{P(d);},[P,d]),L=useCallback(()=>{P(-d);},[P,d]),D=useCallback(()=>{u(m),f({x:0,y:0});},[m]),A=useCallback(w=>{w.preventDefault();let R=w.deltaY>0?-d:d;P(R);},[P,d]),j=useCallback(w=>{if(w.button!==0||w.isPrimary===false)return;h(true),k({x:w.clientX,y:w.clientY}),M(p);let R=w.currentTarget;R instanceof HTMLElement&&R.setPointerCapture(w.pointerId);},[p]),q=useCallback(w=>{if(!a)return;w.preventDefault();let R=w.clientX-y.x,Y=w.clientY-y.y;f({x:C.x+R,y:C.y+Y});},[a,y,C]),V=useCallback(w=>{h(false);let R=w.currentTarget;R instanceof HTMLElement&&R.releasePointerCapture(w.pointerId);},[]);return useEffect(()=>{let w=r.current;if(w)return w.addEventListener("wheel",A,{passive:false}),()=>{w.removeEventListener("wheel",A);}},[A]),useEffect(()=>{let w=l.current;if(w&&a)return document.body.style.userSelect="none",w.addEventListener("pointermove",q,{passive:false}),w.addEventListener("pointerup",V),w.addEventListener("pointercancel",V),()=>{document.body.style.userSelect="",w.removeEventListener("pointermove",q),w.removeEventListener("pointerup",V),w.removeEventListener("pointercancel",V);}},[a,q,V]),jsxs("div",{className:b("relative flex flex-col",i?"h-full w-full":"min-h-28 w-full",t),ref:r,style:{cursor:a?"grabbing":"grab"},children:[s?jsxs("div",{className:b("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",i?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:"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:c>=n,onClick:E,title:"Zoom in",type:"button",children:jsx(Ae,{size:16})}),jsx("button",{className:"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:c<=o,onClick:L,title:"Zoom out",type:"button",children:jsx(qe,{size:16})}),jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:D,title:"Reset zoom and pan",type:"button",children:jsx(Oe,{size:16})})]}):null,jsx("div",{className:b("flex-1 origin-center transition-transform duration-150 ease-out",i?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:j,ref:l,role:"application",style:{transform:`translate(${p.x}px, ${p.y}px) scale(${c})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var tt=({chart:e,className:t,config:o,fullscreen:n=false,showControls:d=true})=>{let[s,m]=useState(null),[i,r]=useState(false),[l,c]=useState(""),[u,p]=useState(""),[f,a]=useState(0),{mermaid:h}=useContext(N),y=U(),k=h==null?void 0:h.errorComponent,{shouldRender:C,containerRef:M}=Ve({immediate:n});if(useEffect(()=>{if(!C)return;if(!y){m("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{m(null),r(!0);let L=y.getMermaid(o),D=e.split("").reduce((q,V)=>(q<<5)-q+V.charCodeAt(0)|0,0),A=`mermaid-${Math.abs(D)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:j}=await L.render(A,e);c(j),p(j);}catch(L){if(!(u||l)){let D=L instanceof Error?L.message:"Failed to render Mermaid chart";m(D);}}finally{r(false);}})();},[e,o,f,C,y]),!(C||l||u))return jsx("div",{className:b("my-4 min-h-[200px]",t),ref:M});if(i&&!l&&!u)return jsx("div",{className:b("my-4 flex justify-center p-4",t),ref:M,children:jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(s&&!l&&!u){let E=()=>a(L=>L+1);return k?jsx("div",{ref:M,children:jsx(k,{chart:e,error:s,retry:E})}):jsxs("div",{className:b("rounded-lg border border-red-200 bg-red-50 p-4",t),ref:M,children:[jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",s]}),jsxs("details",{className:"mt-2",children:[jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let P=l||u;return jsx("div",{className:b("size-full",t),"data-streamdown":"mermaid",ref:M,children:jsx(Ft,{className:b(n?"size-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:d,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:b("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:P},role:"img"})})})};export{b as a,ao as b,cr as c,tt as d,De as e,gn as f,hn as g,N as h,Wt as i,xn as j};
|
package/dist/chunk-QX4TVXVA.cjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
'use strict';var react=require('react'),rehypeHarden=require('rehype-harden'),pn=require('rehype-raw'),un=require('rehype-sanitize'),fn=require('remark-gfm'),bn=require('remend'),jsxRuntime=require('react/jsx-runtime'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),hastUtilToJsxRuntime=require('hast-util-to-jsx-runtime'),Jo=require('remark-parse'),Fo=require('remark-rehype'),unified=require('unified'),marked=require('marked');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var pn__default=/*#__PURE__*/_interopDefault(pn);var un__default=/*#__PURE__*/_interopDefault(un);var fn__default=/*#__PURE__*/_interopDefault(fn);var bn__default=/*#__PURE__*/_interopDefault(bn);var Jo__default=/*#__PURE__*/_interopDefault(Jo);var Fo__default=/*#__PURE__*/_interopDefault(Fo);var Yt=300,Qt="300px",eo=500;function Ve(e={}){let{immediate:t=false,debounceDelay:o=Yt,rootMargin:n=Qt,idleTimeout:d=eo}=e,[s,m]=react.useState(false),i=react.useRef(null),r=react.useRef(null),l=react.useRef(null),c=react.useMemo(()=>f=>{let a=Date.now();return window.setTimeout(()=>{f({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-a))});},1)},[]),u=react.useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(f,a)=>window.requestIdleCallback(f,a):c,[c]),p=react.useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?f=>window.cancelIdleCallback(f):f=>{clearTimeout(f);},[]);return react.useEffect(()=>{if(t){m(true);return}let f=i.current;if(!f)return;r.current&&(clearTimeout(r.current),r.current=null),l.current&&(p(l.current),l.current=null);let a=()=>{r.current&&(clearTimeout(r.current),r.current=null),l.current&&(p(l.current),l.current=null);},h=M=>{l.current=u(P=>{P.timeRemaining()>0||P.didTimeout?(m(true),M.disconnect()):l.current=u(()=>{m(true),M.disconnect();},{timeout:d/2});},{timeout:d});},y=M=>{a(),r.current=window.setTimeout(()=>{var L,D;let P=M.takeRecords();(P.length===0||(D=(L=P.at(-1))==null?void 0:L.isIntersecting)!=null&&D)&&h(M);},o);},k=(M,P)=>{M.isIntersecting?y(P):a();},C=new IntersectionObserver(M=>{for(let P of M)k(P,C);},{rootMargin:n,threshold:0});return C.observe(f),()=>{r.current&&clearTimeout(r.current),l.current&&p(l.current),C.disconnect();}},[t,o,n,d,p,u]),{shouldRender:s,containerRef:i}}var J=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),F=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),z=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),Be=e=>jsxRuntime.jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsxRuntime.jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),je=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),Oe=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),re=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),ve=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),Ae=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})}),qe=e=>jsxRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsxRuntime.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"})});var b=(...e)=>tailwindMerge.twMerge(clsx.clsx(e)),B=(e,t,o)=>{let n=typeof t=="string"?new Blob([t],{type:o}):t,d=URL.createObjectURL(n),s=document.createElement("a");s.href=d,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(d);};var ao=react.createContext({code:""}),se=()=>react.useContext(ao);var Ce=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:d,code:s,...m})=>{let[i,r]=react.useState(false),l=react.useRef(0),{code:c}=se(),{isAnimating:u}=react.useContext(N),p=s!=null?s:c,f=async()=>{var h;if(typeof window=="undefined"||!((h=navigator==null?void 0:navigator.clipboard)!=null&&h.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(p),r(!0),e==null||e(),l.current=window.setTimeout(()=>r(!1),o));}catch(y){t==null||t(y);}};react.useEffect(()=>()=>{window.clearTimeout(l.current);},[]);let a=i?J:F;return jsxRuntime.jsx("button",{className:b("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",d),"data-streamdown":"code-block-copy-button",disabled:u,onClick:f,title:"Copy Code",type:"button",...m,children:n!=null?n:jsxRuntime.jsx(a,{size:14})})};var $e={"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"},We=({onDownload:e,onError:t,language:o,children:n,className:d,code:s,...m})=>{let{code:i}=se(),{isAnimating:r}=react.useContext(N),l=s!=null?s:i,u=`file.${o&&o in $e?$e[o]:"txt"}`,p="text/plain",f=()=>{try{B(u,l,p),e==null||e();}catch(a){t==null||t(a);}};return jsxRuntime.jsx("button",{className:b("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",d),"data-streamdown":"code-block-download-button",disabled:r,onClick:f,title:"Download file",type:"button",...m,children:n!=null?n:jsxRuntime.jsx(z,{size:14})})};var Pe=()=>jsxRuntime.jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[jsxRuntime.jsx("div",{className:"h-[46px] w-full bg-muted/80"}),jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center p-4",children:jsxRuntime.jsx(Be,{className:"size-4 animate-spin"})})]});var fo=/\.[^/.]+$/,Xe=({node:e,className:t,src:o,alt:n,...d})=>{let s=async()=>{if(o)try{let i=await(await fetch(o)).blob(),l=new URL(o,window.location.origin).pathname.split("/").pop()||"",c=l.split(".").pop(),u=l.includes(".")&&c!==void 0&&c.length<=4,p="";if(u)p=l;else {let f=i.type,a="png";f.includes("jpeg")||f.includes("jpg")?a="jpg":f.includes("png")?a="png":f.includes("svg")?a="svg":f.includes("gif")?a="gif":f.includes("webp")&&(a="webp"),p=`${(n||l||"image").replace(fo,"")}.${a}`;}B(p,i,i.type);}catch(m){window.open(o,"_blank");}};return o?jsxRuntime.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsxRuntime.jsx("img",{alt:n,className:b("max-w-full rounded-lg",t),"data-streamdown":"image",src:o,...d}),jsxRuntime.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsxRuntime.jsx("button",{className:b("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 group-hover:opacity-100"),onClick:s,title:"Download image",type:"button",children:jsxRuntime.jsx(z,{size:14})})]}):null};var Q=0,yo=()=>{Q+=1,Q===1&&(document.body.style.overflow="hidden");},wo=()=>{Q=Math.max(0,Q-1),Q===0&&(document.body.style.overflow="");},Fe=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let[d,s]=react.useState(false),m=react.useCallback(async()=>{try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3);}catch(r){}},[e]),i=react.useCallback(()=>{n(),o();},[n,o]);return react.useEffect(()=>{if(t){yo();let r=l=>{l.key==="Escape"&&o();};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r),wo();}}},[t,o]),t?jsxRuntime.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm","data-streamdown":"link-safety-modal",onClick:o,onKeyDown:r=>{r.key==="Escape"&&o();},role:"button",tabIndex:0,children:jsxRuntime.jsxs("div",{className:"relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg",onClick:r=>r.stopPropagation(),onKeyDown:r=>r.stopPropagation(),role:"presentation",children:[jsxRuntime.jsx("button",{className:"absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:o,title:"Close",type:"button",children:jsxRuntime.jsx(re,{size:16})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 font-semibold text-lg",children:[jsxRuntime.jsx(ve,{size:20}),jsxRuntime.jsx("span",{children:"Open external link?"})]}),jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm",children:"You're about to visit an external website."})]}),jsxRuntime.jsx("div",{className:b("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("button",{className:"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?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(J,{size:14}),jsxRuntime.jsx("span",{children:"Copied"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(F,{size:14}),jsxRuntime.jsx("span",{children:"Copy link"})]})}),jsxRuntime.jsxs("button",{className:"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:i,type:"button",children:[jsxRuntime.jsx(ve,{size:14}),jsxRuntime.jsx("span",{children:"Open link"})]})]})]})}):null};var ie=react.createContext(null),Ue=()=>react.useContext(ie),cr=()=>{var t;let e=Ue();return (t=e==null?void 0:e.code)!=null?t:null},U=()=>{var t;let e=Ue();return (t=e==null?void 0:e.mermaid)!=null?t:null};var Ke=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((d,s)=>{let m="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let r=document.createElement("canvas"),l=i.width*o,c=i.height*o;r.width=l,r.height=c;let u=r.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(i,0,0,l,c),r.toBlob(p=>{if(!p){s(new Error("Failed to create PNG blob"));return}d(p);},"image/png");},i.onerror=()=>s(new Error("Failed to load SVG image")),i.src=m;})};var Ye=({chart:e,children:t,className:o,onDownload:n,config:d,onError:s})=>{let[m,i]=react.useState(false),r=react.useRef(null),{isAnimating:l}=react.useContext(N),c=U(),u=async p=>{try{if(p==="mmd"){B("diagram.mmd",e,"text/plain"),i(!1),n==null||n(p);return}if(!c){s==null||s(new Error("Mermaid plugin not available"));return}let f=c.getMermaid(d),a=e.split("").reduce((k,C)=>(k<<5)-k+C.charCodeAt(0)|0,0),h=`mermaid-${Math.abs(a)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:y}=await f.render(h,e);if(!y){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(p==="svg"){B("diagram.svg",y,"image/svg+xml"),i(!1),n==null||n(p);return}if(p==="png"){let k=await Ke(y);B("diagram.png",k,"image/png"),n==null||n(p),i(!1);return}}catch(f){s==null||s(f);}};return react.useEffect(()=>{let p=f=>{let a=f.composedPath();r.current&&!a.includes(r.current)&&i(false);};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:r,children:[jsxRuntime.jsx("button",{className:b("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:l,onClick:()=>i(!m),title:"Download diagram",type:"button",children:t!=null?t:jsxRuntime.jsx(z,{size:14})}),m?jsxRuntime.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("svg"),title:"Download diagram as SVG",type:"button",children:"SVG"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("png"),title:"Download diagram as PNG",type:"button",children:"PNG"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]}):null]})};var te=0,Lo=()=>{te+=1,te===1&&(document.body.style.overflow="hidden");},So=()=>{te=Math.max(0,te-1),te===0&&(document.body.style.overflow="");},ot=({chart:e,config:t,onFullscreen:o,onExit:n,className:d,...s})=>{let[m,i]=react.useState(false),{isAnimating:r,controls:l}=react.useContext(N),c=(()=>{if(typeof l=="boolean")return l;let p=l.mermaid;return p===false?false:p===true||p===void 0?true:p.panZoom!==false})(),u=()=>{i(!m);};return react.useEffect(()=>{if(m){Lo();let p=f=>{f.key==="Escape"&&i(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),So();}}},[m]),react.useEffect(()=>{m?o==null||o():n&&n();},[m,o,n]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{className:b("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",d),disabled:r,onClick:u,title:"View fullscreen",type:"button",...s,children:jsxRuntime.jsx(je,{size:14})}),m?jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:u,onKeyDown:p=>{p.key==="Escape"&&u();},role:"button",tabIndex:0,children:[jsxRuntime.jsx("button",{className:"absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:u,title:"Exit fullscreen",type:"button",children:jsxRuntime.jsx(re,{size:20})}),jsxRuntime.jsx("div",{className:"flex size-full items-center justify-center p-4",onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:jsxRuntime.jsx(tt,{chart:e,className:"size-full [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:true,showControls:c})})]}):null]})};var le=e=>{var s,m;let t=[],o=[],n=e.querySelectorAll("thead th");for(let i of n)t.push(((s=i.textContent)==null?void 0:s.trim())||"");let d=e.querySelectorAll("tbody tr");for(let i of d){let r=[],l=i.querySelectorAll("td");for(let c of l)r.push(((m=c.textContent)==null?void 0:m.trim())||"");o.push(r);}return {headers:t,rows:o}},ce=e=>{let{headers:t,rows:o}=e,n=i=>{let r=false,l=false;for(let c of i){if(c==='"'){r=true,l=true;break}(c===","||c===`
|
|
3
|
-
`)&&(r=true);}return r?l?`"${i.replace(/"/g,'""')}"`:`"${i}"`:i},d=t.length>0?o.length+1:o.length,s=new Array(d),m=0;t.length>0&&(s[m]=t.map(n).join(","),m+=1);for(let i of o)s[m]=i.map(n).join(","),m+=1;return s.join(`
|
|
4
|
-
`)},nt=e=>{let{headers:t,rows:o}=e,n=i=>{let r=false;for(let c of i)if(c===" "||c===`
|
|
5
|
-
`||c==="\r"){r=true;break}if(!r)return i;let l=[];for(let c of i)c===" "?l.push("\\t"):c===`
|
|
6
|
-
`?l.push("\\n"):c==="\r"?l.push("\\r"):l.push(c);return l.join("")},d=t.length>0?o.length+1:o.length,s=new Array(d),m=0;t.length>0&&(s[m]=t.map(n).join(" "),m+=1);for(let i of o)s[m]=i.map(n).join(" "),m+=1;return s.join(`
|
|
7
|
-
`)},Me=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("")},rt=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),d=0,s=t.map(i=>Me(i));n[d]=`| ${s.join(" | ")} |`,d+=1;let m=new Array(t.length);for(let i=0;i<t.length;i+=1)m[i]="---";n[d]=`| ${m.join(" | ")} |`,d+=1;for(let i of o)if(i.length<t.length){let r=new Array(t.length);for(let l=0;l<t.length;l+=1)r[l]=l<i.length?Me(i[l]):"";n[d]=`| ${r.join(" | ")} |`,d+=1;}else {let r=i.map(l=>Me(l));n[d]=`| ${r.join(" | ")} |`,d+=1;}return n.join(`
|
|
8
|
-
`)};var lt=({children:e,className:t,onCopy:o,onError:n,timeout:d=2e3})=>{let[s,m]=react.useState(false),[i,r]=react.useState(false),l=react.useRef(null),c=react.useRef(0),{isAnimating:u}=react.useContext(N),p=async a=>{var h,y;if(typeof window=="undefined"||!((h=navigator==null?void 0:navigator.clipboard)!=null&&h.write)){n==null||n(new Error("Clipboard API not available"));return}try{let k=(y=l.current)==null?void 0:y.closest('[data-streamdown="table-wrapper"]'),C=k==null?void 0:k.querySelector("table");if(!C){n==null||n(new Error("Table not found"));return}let M=le(C),P=a==="csv"?ce(M):nt(M),E=new ClipboardItem({"text/plain":new Blob([P],{type:"text/plain"}),"text/html":new Blob([C.outerHTML],{type:"text/html"})});await navigator.clipboard.write([E]),r(!0),m(!1),o==null||o(a),c.current=window.setTimeout(()=>r(!1),d);}catch(k){n==null||n(k);}};react.useEffect(()=>{let a=h=>{let y=h.composedPath();l.current&&!y.includes(l.current)&&m(false);};return document.addEventListener("mousedown",a),()=>{document.removeEventListener("mousedown",a),window.clearTimeout(c.current);}},[]);let f=i?J:F;return jsxRuntime.jsxs("div",{className:"relative",ref:l,children:[jsxRuntime.jsx("button",{className:b("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>m(!s),title:"Copy table",type:"button",children:e!=null?e:jsxRuntime.jsx(f,{size:14})}),s?jsxRuntime.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var dt=({children:e,className:t,onDownload:o,onError:n})=>{let[d,s]=react.useState(false),m=react.useRef(null),{isAnimating:i}=react.useContext(N),r=l=>{var c;try{let u=(c=m.current)==null?void 0:c.closest('[data-streamdown="table-wrapper"]'),p=u==null?void 0:u.querySelector("table");if(!p){n==null||n(new Error("Table not found"));return}let f=le(p),a=l==="csv"?ce(f):rt(f);B(`table.${l==="csv"?"csv":"md"}`,a,l==="csv"?"text/csv":"text/markdown"),s(!1),o==null||o(l);}catch(u){n==null||n(u);}};return react.useEffect(()=>{let l=c=>{let u=c.composedPath();m.current&&!u.includes(m.current)&&s(false);};return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:m,children:[jsxRuntime.jsx("button",{className:b("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>s(!d),title:"Download table",type:"button",children:e!=null?e:jsxRuntime.jsx(z,{size:14})}),d?jsxRuntime.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>r("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>r("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var pt=({children:e,className:t,showControls:o,...n})=>jsxRuntime.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[o?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsxRuntime.jsx(lt,{}),jsxRuntime.jsx(dt,{})]}):null,jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsx("table",{className:b("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]});var Oo=react.lazy(()=>import('./code-block-XWNGTFRY.cjs').then(e=>({default:e.CodeBlock}))),Ao=react.lazy(()=>import('./mermaid-UQ57JT4G.cjs').then(e=>({default:e.Mermaid}))),qo=/language-([^\s]+)/;function ge(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,d=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)&&(d==null?void 0:d.line)===(s==null?void 0:s.line)&&(d==null?void 0:d.column)===(s==null?void 0:s.column)}function T(e,t){return e.className===t.className&&ge(e.node,t.node)}var Ne=(e,t)=>typeof e=="boolean"?e:e[t]!==false,ue=(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},Se=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("ol",{className:b("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>T(e,t));Se.displayName="MarkdownOl";var bt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("li",{className:b("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&ge(e.node,t.node));bt.displayName="MarkdownLi";var gt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("ul",{className:b("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>T(e,t));gt.displayName="MarkdownUl";var ht=react.memo(({className:e,node:t,...o})=>jsxRuntime.jsx("hr",{className:b("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o}),(e,t)=>T(e,t));ht.displayName="MarkdownHr";var yt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("span",{className:b("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>T(e,t));yt.displayName="MarkdownStrong";var zo=({children:e,className:t,href:o,node:n,...d})=>{let{linkSafety:s}=react.useContext(N),[m,i]=react.useState(false),r=o==="streamdown:incomplete-link",l=react.useCallback(async f=>{if(!(!(s!=null&&s.enabled&&o)||r)){if(f.preventDefault(),s.onLinkCheck&&await s.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[s,o,r]),c=react.useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),u=react.useCallback(()=>{i(false);},[]),p={url:o!=null?o:"",isOpen:m,onClose:u,onConfirm:c};return s!=null&&s.enabled&&o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{className:b("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",onClick:l,type:"button",children:e}),s.renderModal?s.renderModal(p):jsxRuntime.jsx(Fe,{...p})]}):jsxRuntime.jsx("a",{className:b("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":r,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...d,children:e})},wt=react.memo(zo,(e,t)=>T(e,t)&&e.href===t.href);wt.displayName="MarkdownA";var kt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h1",{className:b("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>T(e,t));kt.displayName="MarkdownH1";var vt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h2",{className:b("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>T(e,t));vt.displayName="MarkdownH2";var Ct=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h3",{className:b("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>T(e,t));Ct.displayName="MarkdownH3";var xt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h4",{className:b("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>T(e,t));xt.displayName="MarkdownH4";var Pt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h5",{className:b("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>T(e,t));Pt.displayName="MarkdownH5";var Mt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("h6",{className:b("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>T(e,t));Mt.displayName="MarkdownH6";var Tt=react.memo(({children:e,className:t,node:o,...n})=>{let{controls:d}=react.useContext(N),s=Ne(d,"table");return jsxRuntime.jsx(pt,{className:t,showControls:s,...n,children:e})},(e,t)=>T(e,t));Tt.displayName="MarkdownTable";var Nt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("thead",{className:b("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>T(e,t));Nt.displayName="MarkdownThead";var Lt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("tbody",{className:b("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>T(e,t));Lt.displayName="MarkdownTbody";var St=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("tr",{className:b("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>T(e,t));St.displayName="MarkdownTr";var Rt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("th",{className:b("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>T(e,t));Rt.displayName="MarkdownTh";var It=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("td",{className:b("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>T(e,t));It.displayName="MarkdownTd";var Ht=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("blockquote",{className:b("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>T(e,t));Ht.displayName="MarkdownBlockquote";var Et=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("sup",{className:b("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>T(e,t));Et.displayName="MarkdownSup";var Dt=react.memo(({children:e,className:t,node:o,...n})=>jsxRuntime.jsx("sub",{className:b("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>T(e,t));Dt.displayName="MarkdownSub";var Vt=react.memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=r=>{var p,f;if(!react.isValidElement(r))return false;let l=Array.isArray(r.props.children)?r.props.children:[r.props.children],c=false,u=false;for(let a of l)if(a){if(typeof a=="string")a.trim()!==""&&(c=true);else if(react.isValidElement(a))if(((p=a.props)==null?void 0:p["data-footnote-backref"])!==void 0)u=true;else {let h=Array.isArray(a.props.children)?a.props.children:[a.props.children];for(let y of h){if(typeof y=="string"&&y.trim()!==""){c=true;break}if(react.isValidElement(y)&&((f=y.props)==null?void 0:f["data-footnote-backref"])===void 0){c=true;break}}}}return u&&!c},m=Array.isArray(e)?e.map(r=>{if(!react.isValidElement(r))return r;if(r.type===Se){let c=(Array.isArray(r.props.children)?r.props.children:[r.props.children]).filter(u=>!s(u));return c.length===0?null:{...r,props:{...r.props,children:c}}}return r}):e;return (Array.isArray(m)?m.some(r=>r!==null):m!==null)?jsxRuntime.jsx("section",{className:t,...n,children:m}):null}return jsxRuntime.jsx("section",{className:t,...n,children:e})},(e,t)=>T(e,t));Vt.displayName="MarkdownSection";var $o=({node:e,className:t,children:o,...n})=>{var p,f,a;let d=((p=e==null?void 0:e.position)==null?void 0:p.start.line)===((f=e==null?void 0:e.position)==null?void 0:f.end.line),{mermaid:s,controls:m}=react.useContext(N),i=U();if(d)return jsxRuntime.jsx("code",{className:b("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let r=t==null?void 0:t.match(qo),l=(a=r==null?void 0:r.at(1))!=null?a:"",c="";if(react.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),l==="mermaid"&&i){let h=Ne(m,"mermaid"),y=ue(m,"download"),k=ue(m,"copy"),C=ue(m,"fullscreen"),M=ue(m,"panZoom"),P=h&&(y||k||C);return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(Pe,{}),children:jsxRuntime.jsxs("div",{className:b("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[P?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2",children:[y?jsxRuntime.jsx(Ye,{chart:c,config:s==null?void 0:s.config}):null,k?jsxRuntime.jsx(Ce,{code:c}):null,C?jsxRuntime.jsx(ot,{chart:c,config:s==null?void 0:s.config}):null]}):null,jsxRuntime.jsx(Ao,{chart:c,config:s==null?void 0:s.config,showControls:M})]})})}let u=Ne(m,"code");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(Pe,{}),children:jsxRuntime.jsx(Oo,{className:b("overflow-x-auto border-border border-t",t),code:c,language:l,children:u?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(We,{code:c,language:l}),jsxRuntime.jsx(Ce,{})]}):null})})},Bt=react.memo($o,(e,t)=>e.className===t.className&&ge(e.node,t.node));Bt.displayName="MarkdownCode";var jt=react.memo(Xe,(e,t)=>e.className===t.className&&ge(e.node,t.node));jt.displayName="MarkdownImg";var Ot=react.memo(({children:e,className:t,node:o,...n})=>{var m,i;let s=(Array.isArray(e)?e:[e]).filter(r=>r!=null&&r!=="");if(s.length===1&&react.isValidElement(s[0])){let r=s[0].props.node,l=r==null?void 0:r.tagName;if(l==="img")return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e});if(l==="code"&&((m=r==null?void 0:r.position)==null?void 0:m.start.line)!==((i=r==null?void 0:r.position)==null?void 0:i.end.line))return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}return jsxRuntime.jsx("p",{className:t,...n,children:e})},(e,t)=>T(e,t));Ot.displayName="MarkdownParagraph";var At={ol:Se,li:bt,ul:gt,hr:ht,strong:yt,a:wt,h1:kt,h2:vt,h3:Ct,h4:xt,h5:Pt,h6:Mt,table:Tt,thead:Nt,tbody:Lt,tr:St,th:Rt,td:It,blockquote:Ht,code:Bt,img:jt,pre:({children:e})=>e,sup:Et,sub:Dt,p:Ot,section:Vt};var qt=[],zt={allowDangerousHtml:true},he=new WeakMap,Re=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,d=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||d||s)){let u="default";return this.keyCache.set(t,u),u}let m=u=>{if(!u||u.length===0)return "";let p="";for(let f=0;f<u.length;f+=1){let a=u[f];if(f>0&&(p+=","),Array.isArray(a)){let[h,y]=a;if(typeof h=="function"){let k=he.get(h);k||(k=h.name,he.set(h,k)),p+=k;}else p+=String(h);p+=":",p+=JSON.stringify(y);}else if(typeof a=="function"){let h=he.get(a);h||(h=a.name,he.set(a,h)),p+=h;}else p+=String(a);}return p},i=m(n),r=m(d),l=s?JSON.stringify(s):"",c=`${r}::${i}::${l}`;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 d=this.cache.keys().next().value;d&&this.cache.delete(d);}this.cache.set(n,o);}clear(){this.cache.clear();}},$t=new Re,Ie=e=>{let t=Ko(e),o=e.children||"";return Yo(t.runSync(t.parse(o),o),e)},Ko=e=>{let t=$t.get(e);if(t)return t;let o=Go(e);return $t.set(e,o),o},Go=e=>{let t=e.rehypePlugins||qt,o=e.remarkPlugins||qt,n=e.remarkRehypeOptions?{...zt,...e.remarkRehypeOptions}:zt;return unified.unified().use(Jo__default.default).use(o).use(Fo__default.default,n).use(t)},Yo=(e,t)=>hastUtilToJsxRuntime.toJsxRuntime(e,{Fragment:jsxRuntime.Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsxRuntime.jsx,jsxs:jsxRuntime.jsxs,passKeys:true,passNode:true});var en=/\[\^[^\]\s]{1,200}\](?!:)/,tn=/\[\^[^\]\s]{1,200}\]:/,on=/<\/(\w+)>/,nn=/<(\w+)[\s>]/,He=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
9
|
-
`||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},rn=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
10
|
-
`||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},Ee=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},De=e=>{let t=en.test(e),o=tn.test(e);if(t||o)return [e];let n=marked.Lexer.lex(e,{gfm:true}),d=[],s=[];for(let m of n){let i=m.raw,r=d.length;if(s.length>0){if(d[r-1]+=i,m.type==="html"){let c=i.match(on);if(c){let u=c[1];s.at(-1)===u&&s.pop();}}continue}if(m.type==="html"&&m.block){let c=i.match(nn);if(c){let u=c[1];i.includes(`</${u}>`)||s.push(u);}}if(i.trim()==="$$"&&r>0){let c=d[r-1],u=He(c),p=Ee(c);if(u&&p%2===1){d[r-1]=c+i;continue}}if(r>0&&rn(i)){let c=d[r-1],u=He(c),p=Ee(c),f=Ee(i);if(u&&p%2===1&&!He(i)&&f===1){d[r-1]=c+i;continue}}d.push(i);}return d};var gn={raw:pn__default.default,sanitize:[un__default.default,{}],harden:[rehypeHarden.harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},hn={gfm:[fn__default.default,{}]},yn=Object.values(gn),wn=Object.values(hn),kn={block:" \u258B",circle:" \u25CF"},vn={shikiTheme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0,linkSafety:{enabled:true}},N=react.createContext(vn),Wt=react.memo(({content:e,shouldParseIncompleteMarkdown:t,index:o,...n})=>jsxRuntime.jsx(Ie,{...n,children:e}),(e,t)=>{if(e.content!==t.content||e.index!==t.index)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(d=>{var s,m;return ((s=e.components)==null?void 0:s[d])!==((m=t.components)==null?void 0:m[d])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Wt.displayName="Block";var Cn=["github-light","github-dark"],xn=react.memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:o=true,components:n,rehypePlugins:d=yn,remarkPlugins:s=wn,className:m,shikiTheme:i=Cn,mermaid:r,controls:l=true,isAnimating:c=false,BlockComponent:u=Wt,parseMarkdownIntoBlocksFn:p=De,caret:f,plugins:a,remend:h,linkSafety:y={enabled:true},...k})=>{let C=react.useId(),[M,P]=react.useTransition(),E=react.useMemo(()=>typeof e!="string"?"":t==="streaming"&&o?bn__default.default(e,h):e,[e,t,o,h]),L=react.useMemo(()=>p(E),[E,p]),[D,A]=react.useState(L);react.useEffect(()=>{t==="streaming"?P(()=>{A(L);}):A(L);},[L,t]);let j=t==="streaming"?D:L,q=react.useMemo(()=>j.map((S,W)=>`${C}-${W}`),[j.length,C]),V=react.useMemo(()=>{var S,W;return {shikiTheme:(W=(S=a==null?void 0:a.code)==null?void 0:S.getThemes())!=null?W:i,controls:l,isAnimating:c,mode:t,mermaid:r,linkSafety:y}},[i,l,c,t,r,y,a==null?void 0:a.code]),w=react.useMemo(()=>({...At,...n}),[n]),R=react.useMemo(()=>{let S=[];return a!=null&&a.cjk&&(S=[...S,...a.cjk.remarkPluginsBefore]),S=[...S,...s],a!=null&&a.cjk&&(S=[...S,...a.cjk.remarkPluginsAfter]),a!=null&&a.math&&(S=[...S,a.math.remarkPlugin]),S},[s,a==null?void 0:a.math,a==null?void 0:a.cjk]),Y=react.useMemo(()=>a!=null&&a.math?[...d,a.math.rehypePlugin]:d,[d,a==null?void 0:a.math]),Ut=react.useMemo(()=>f&&c?{"--streamdown-caret":`"${kn[f]}"`}:void 0,[f,c]);return t==="static"?jsxRuntime.jsx(ie.Provider,{value:a!=null?a:null,children:jsxRuntime.jsx(N.Provider,{value:V,children:jsxRuntime.jsx("div",{className:b("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",m),children:jsxRuntime.jsx(Ie,{components:w,rehypePlugins:Y,remarkPlugins:R,...k,children:e})})})}):jsxRuntime.jsx(ie.Provider,{value:a!=null?a:null,children:jsxRuntime.jsx(N.Provider,{value:V,children:jsxRuntime.jsxs("div",{className:b("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",f?"*:last:after:inline *:last:after:align-baseline *:last:after:content-(--streamdown-caret)":null,m),style:Ut,children:[j.length===0&&f&&c&&jsxRuntime.jsx("span",{}),j.map((S,W)=>jsxRuntime.jsx(u,{components:w,content:S,index:W,rehypePlugins:Y,remarkPlugins:R,shouldParseIncompleteMarkdown:o,...k},q[W]))]})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety);xn.displayName="Streamdown";var Ft=({children:e,className:t,minZoom:o=.5,maxZoom:n=3,zoomStep:d=.1,showControls:s=true,initialZoom:m=1,fullscreen:i=false})=>{let r=react.useRef(null),l=react.useRef(null),[c,u]=react.useState(m),[p,f]=react.useState({x:0,y:0}),[a,h]=react.useState(false),[y,k]=react.useState({x:0,y:0}),[C,M]=react.useState({x:0,y:0}),P=react.useCallback(w=>{u(R=>Math.max(o,Math.min(n,R+w)));},[o,n]),E=react.useCallback(()=>{P(d);},[P,d]),L=react.useCallback(()=>{P(-d);},[P,d]),D=react.useCallback(()=>{u(m),f({x:0,y:0});},[m]),A=react.useCallback(w=>{w.preventDefault();let R=w.deltaY>0?-d:d;P(R);},[P,d]),j=react.useCallback(w=>{if(w.button!==0||w.isPrimary===false)return;h(true),k({x:w.clientX,y:w.clientY}),M(p);let R=w.currentTarget;R instanceof HTMLElement&&R.setPointerCapture(w.pointerId);},[p]),q=react.useCallback(w=>{if(!a)return;w.preventDefault();let R=w.clientX-y.x,Y=w.clientY-y.y;f({x:C.x+R,y:C.y+Y});},[a,y,C]),V=react.useCallback(w=>{h(false);let R=w.currentTarget;R instanceof HTMLElement&&R.releasePointerCapture(w.pointerId);},[]);return react.useEffect(()=>{let w=r.current;if(w)return w.addEventListener("wheel",A,{passive:false}),()=>{w.removeEventListener("wheel",A);}},[A]),react.useEffect(()=>{let w=l.current;if(w&&a)return document.body.style.userSelect="none",w.addEventListener("pointermove",q,{passive:false}),w.addEventListener("pointerup",V),w.addEventListener("pointercancel",V),()=>{document.body.style.userSelect="",w.removeEventListener("pointermove",q),w.removeEventListener("pointerup",V),w.removeEventListener("pointercancel",V);}},[a,q,V]),jsxRuntime.jsxs("div",{className:b("relative flex flex-col",i?"h-full w-full":"min-h-28 w-full",t),ref:r,style:{cursor:a?"grabbing":"grab"},children:[s?jsxRuntime.jsxs("div",{className:b("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",i?"bottom-4 left-4":"bottom-2 left-2"),children:[jsxRuntime.jsx("button",{className:"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:c>=n,onClick:E,title:"Zoom in",type:"button",children:jsxRuntime.jsx(Ae,{size:16})}),jsxRuntime.jsx("button",{className:"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:c<=o,onClick:L,title:"Zoom out",type:"button",children:jsxRuntime.jsx(qe,{size:16})}),jsxRuntime.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:D,title:"Reset zoom and pan",type:"button",children:jsxRuntime.jsx(Oe,{size:16})})]}):null,jsxRuntime.jsx("div",{className:b("flex-1 origin-center transition-transform duration-150 ease-out",i?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:j,ref:l,role:"application",style:{transform:`translate(${p.x}px, ${p.y}px) scale(${c})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var tt=({chart:e,className:t,config:o,fullscreen:n=false,showControls:d=true})=>{let[s,m]=react.useState(null),[i,r]=react.useState(false),[l,c]=react.useState(""),[u,p]=react.useState(""),[f,a]=react.useState(0),{mermaid:h}=react.useContext(N),y=U(),k=h==null?void 0:h.errorComponent,{shouldRender:C,containerRef:M}=Ve({immediate:n});if(react.useEffect(()=>{if(!C)return;if(!y){m("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{m(null),r(!0);let L=y.getMermaid(o),D=e.split("").reduce((q,V)=>(q<<5)-q+V.charCodeAt(0)|0,0),A=`mermaid-${Math.abs(D)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:j}=await L.render(A,e);c(j),p(j);}catch(L){if(!(u||l)){let D=L instanceof Error?L.message:"Failed to render Mermaid chart";m(D);}}finally{r(false);}})();},[e,o,f,C,y]),!(C||l||u))return jsxRuntime.jsx("div",{className:b("my-4 min-h-[200px]",t),ref:M});if(i&&!l&&!u)return jsxRuntime.jsx("div",{className:b("my-4 flex justify-center p-4",t),ref:M,children:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),jsxRuntime.jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(s&&!l&&!u){let E=()=>a(L=>L+1);return k?jsxRuntime.jsx("div",{ref:M,children:jsxRuntime.jsx(k,{chart:e,error:s,retry:E})}):jsxRuntime.jsxs("div",{className:b("rounded-lg border border-red-200 bg-red-50 p-4",t),ref:M,children:[jsxRuntime.jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",s]}),jsxRuntime.jsxs("details",{className:"mt-2",children:[jsxRuntime.jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),jsxRuntime.jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let P=l||u;return jsxRuntime.jsx("div",{className:b("size-full",t),"data-streamdown":"mermaid",ref:M,children:jsxRuntime.jsx(Ft,{className:b(n?"size-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:d,zoomStep:.1,children:jsxRuntime.jsx("div",{"aria-label":"Mermaid chart",className:b("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:P},role:"img"})})})};exports.a=b;exports.b=ao;exports.c=cr;exports.d=tt;exports.e=De;exports.f=gn;exports.g=hn;exports.h=N;exports.i=Wt;exports.j=xn;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {a,h as h$1,c,b}from'./chunk-5FQGJX7Z.js';import {memo,useMemo,useContext,useState,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';var H=a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),k=memo(({children:o,result:e,language:s,className:a$1,...p})=>{let d=useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]);return jsx("pre",{className:a(a$1,"p-4 text-sm dark:bg-(--shiki-dark-bg)!"),"data-language":s,"data-streamdown":"code-block-body",style:d,...p,children:jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((l,r)=>jsx("span",{className:H,children:l.map((t,n)=>jsx("span",{className:"dark:bg-(--shiki-dark-bg)! dark:text-(--shiki-dark)!",style:{color:t.color,backgroundColor:t.bgColor,...t.htmlStyle},...t.htmlAttrs,children:t.content},n))},r))})})},(o,e)=>o.result===e.result&&o.language===e.language&&o.className===e.className);var C=({className:o,language:e,style:s,...a$1})=>jsx("div",{className:a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...s},...a$1});var h=({language:o,children:e})=>jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":o,"data-streamdown":"code-block-header",children:[jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsx("div",{className:"flex items-center gap-2",children:e})]});var W=({code:o,language:e,className:s,children:a,...p})=>{let{shikiTheme:d}=useContext(h$1),l=c(),r=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:o.split(`
|
|
3
|
-
`).map(c=>[{content:c,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[o]),[t,n]=useState(r);return useEffect(()=>{if(!l){n(r);return}let c=l.highlight({code:o,language:e,themes:d},B=>{n(B);});if(c){n(c);return}n(r);},[o,e,d,l,r]),jsx(b.Provider,{value:{code:o},children:jsxs(C,{language:e,children:[jsx(h,{language:e,children:a}),jsx(k,{className:s,language:e,result:t,...p})]})})};export{W as CodeBlock};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
'use strict';var chunkQX4TVXVA_cjs=require('./chunk-QX4TVXVA.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var H=chunkQX4TVXVA_cjs.a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),k=react.memo(({children:o,result:e,language:s,className:a,...p})=>{let d=react.useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]);return jsxRuntime.jsx("pre",{className:chunkQX4TVXVA_cjs.a(a,"p-4 text-sm dark:bg-(--shiki-dark-bg)!"),"data-language":s,"data-streamdown":"code-block-body",style:d,...p,children:jsxRuntime.jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((l,r)=>jsxRuntime.jsx("span",{className:H,children:l.map((t,n)=>jsxRuntime.jsx("span",{className:"dark:bg-(--shiki-dark-bg)! dark:text-(--shiki-dark)!",style:{color:t.color,backgroundColor:t.bgColor,...t.htmlStyle},...t.htmlAttrs,children:t.content},n))},r))})})},(o,e)=>o.result===e.result&&o.language===e.language&&o.className===e.className);var C=({className:o,language:e,style:s,...a})=>jsxRuntime.jsx("div",{className:chunkQX4TVXVA_cjs.a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...s},...a});var h=({language:o,children:e})=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":o,"data-streamdown":"code-block-header",children:[jsxRuntime.jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:e})]});var W=({code:o,language:e,className:s,children:a,...p})=>{let{shikiTheme:d}=react.useContext(chunkQX4TVXVA_cjs.h),l=chunkQX4TVXVA_cjs.c(),r=react.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:o.split(`
|
|
3
|
-
`).map(c=>[{content:c,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[o]),[t,n]=react.useState(r);return react.useEffect(()=>{if(!l){n(r);return}let c=l.highlight({code:o,language:e,themes:d},B=>{n(B);});if(c){n(c);return}n(r);},[o,e,d,l,r]),jsxRuntime.jsx(chunkQX4TVXVA_cjs.b.Provider,{value:{code:o},children:jsxRuntime.jsxs(C,{language:e,children:[jsxRuntime.jsx(h,{language:e,children:a}),jsxRuntime.jsx(k,{className:s,language:e,result:t,...p})]})})};exports.CodeBlock=W;
|
package/dist/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
'use strict';var chunkQX4TVXVA_cjs=require('./chunk-QX4TVXVA.cjs');Object.defineProperty(exports,"Block",{enumerable:true,get:function(){return chunkQX4TVXVA_cjs.i}});Object.defineProperty(exports,"Streamdown",{enumerable:true,get:function(){return chunkQX4TVXVA_cjs.j}});Object.defineProperty(exports,"StreamdownContext",{enumerable:true,get:function(){return chunkQX4TVXVA_cjs.h}});Object.defineProperty(exports,"defaultRehypePlugins",{enumerable:true,get:function(){return chunkQX4TVXVA_cjs.f}});Object.defineProperty(exports,"defaultRemarkPlugins",{enumerable:true,get:function(){return chunkQX4TVXVA_cjs.g}});Object.defineProperty(exports,"parseMarkdownIntoBlocks",{enumerable:true,get:function(){return chunkQX4TVXVA_cjs.e}});
|
package/dist/index.d.cts
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import { JSX, ComponentType } from 'react';
|
|
4
|
-
import { MermaidConfig } from 'mermaid';
|
|
5
|
-
import { RemendOptions } from 'remend';
|
|
6
|
-
import { BundledLanguage, BundledTheme } from 'shiki';
|
|
7
|
-
export { BundledLanguage, BundledTheme } from 'shiki';
|
|
8
|
-
import { PluggableList, Pluggable } from 'unified';
|
|
9
|
-
import { Element } from 'hast';
|
|
10
|
-
import { Options as Options$1 } from 'remark-rehype';
|
|
11
|
-
|
|
12
|
-
interface ExtraProps {
|
|
13
|
-
node?: Element | undefined;
|
|
14
|
-
}
|
|
15
|
-
type Components = {
|
|
16
|
-
[Key in keyof JSX.IntrinsicElements]?: ComponentType<JSX.IntrinsicElements[Key] & ExtraProps> | keyof JSX.IntrinsicElements;
|
|
17
|
-
};
|
|
18
|
-
interface Options {
|
|
19
|
-
children?: string;
|
|
20
|
-
components?: Components;
|
|
21
|
-
rehypePlugins?: PluggableList;
|
|
22
|
-
remarkPlugins?: PluggableList;
|
|
23
|
-
remarkRehypeOptions?: Readonly<Options$1>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* A single token in a highlighted line
|
|
28
|
-
*/
|
|
29
|
-
interface HighlightToken {
|
|
30
|
-
content: string;
|
|
31
|
-
color?: string;
|
|
32
|
-
bgColor?: string;
|
|
33
|
-
htmlStyle?: Record<string, string>;
|
|
34
|
-
htmlAttrs?: Record<string, string>;
|
|
35
|
-
offset?: number;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Result from code highlighting (compatible with shiki's TokensResult)
|
|
39
|
-
*/
|
|
40
|
-
interface HighlightResult {
|
|
41
|
-
tokens: HighlightToken[][];
|
|
42
|
-
fg?: string;
|
|
43
|
-
bg?: string;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Options for highlighting code
|
|
47
|
-
*/
|
|
48
|
-
interface HighlightOptions {
|
|
49
|
-
code: string;
|
|
50
|
-
language: BundledLanguage;
|
|
51
|
-
themes: [string, string];
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Plugin for code syntax highlighting (Shiki)
|
|
55
|
-
*/
|
|
56
|
-
interface CodeHighlighterPlugin {
|
|
57
|
-
name: "shiki";
|
|
58
|
-
type: "code-highlighter";
|
|
59
|
-
/**
|
|
60
|
-
* Highlight code and return tokens
|
|
61
|
-
* Returns null if highlighting not ready yet (async loading)
|
|
62
|
-
* Use callback for async result
|
|
63
|
-
*/
|
|
64
|
-
highlight: (options: HighlightOptions, callback?: (result: HighlightResult) => void) => HighlightResult | null;
|
|
65
|
-
/**
|
|
66
|
-
* Check if language is supported
|
|
67
|
-
*/
|
|
68
|
-
supportsLanguage: (language: BundledLanguage) => boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Get list of supported languages
|
|
71
|
-
*/
|
|
72
|
-
getSupportedLanguages: () => BundledLanguage[];
|
|
73
|
-
/**
|
|
74
|
-
* Get the configured themes
|
|
75
|
-
*/
|
|
76
|
-
getThemes: () => [BundledTheme, BundledTheme];
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Mermaid instance interface
|
|
80
|
-
*/
|
|
81
|
-
interface MermaidInstance {
|
|
82
|
-
initialize: (config: MermaidConfig) => void;
|
|
83
|
-
render: (id: string, source: string) => Promise<{
|
|
84
|
-
svg: string;
|
|
85
|
-
}>;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Plugin for diagram rendering (Mermaid)
|
|
89
|
-
*/
|
|
90
|
-
interface DiagramPlugin {
|
|
91
|
-
name: "mermaid";
|
|
92
|
-
type: "diagram";
|
|
93
|
-
/**
|
|
94
|
-
* Language identifier for code blocks
|
|
95
|
-
*/
|
|
96
|
-
language: string;
|
|
97
|
-
/**
|
|
98
|
-
* Get the mermaid instance (initialized with optional config)
|
|
99
|
-
*/
|
|
100
|
-
getMermaid: (config?: MermaidConfig) => MermaidInstance;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Plugin for math rendering (KaTeX)
|
|
104
|
-
*/
|
|
105
|
-
interface MathPlugin {
|
|
106
|
-
name: "katex";
|
|
107
|
-
type: "math";
|
|
108
|
-
/**
|
|
109
|
-
* Get remark plugin for parsing math syntax
|
|
110
|
-
*/
|
|
111
|
-
remarkPlugin: Pluggable;
|
|
112
|
-
/**
|
|
113
|
-
* Get rehype plugin for rendering math
|
|
114
|
-
*/
|
|
115
|
-
rehypePlugin: Pluggable;
|
|
116
|
-
/**
|
|
117
|
-
* Get CSS styles for math rendering (injected into head)
|
|
118
|
-
*/
|
|
119
|
-
getStyles?: () => string;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Plugin for CJK text handling
|
|
123
|
-
*/
|
|
124
|
-
interface CjkPlugin {
|
|
125
|
-
name: "cjk";
|
|
126
|
-
type: "cjk";
|
|
127
|
-
/**
|
|
128
|
-
* Remark plugins that must run BEFORE remarkGfm
|
|
129
|
-
* (e.g., remark-cjk-friendly which modifies emphasis handling)
|
|
130
|
-
*/
|
|
131
|
-
remarkPluginsBefore: Pluggable[];
|
|
132
|
-
/**
|
|
133
|
-
* Remark plugins that must run AFTER remarkGfm
|
|
134
|
-
* (e.g., autolink boundary splitting, strikethrough enhancements)
|
|
135
|
-
*/
|
|
136
|
-
remarkPluginsAfter: Pluggable[];
|
|
137
|
-
/**
|
|
138
|
-
* @deprecated Use remarkPluginsBefore and remarkPluginsAfter instead
|
|
139
|
-
* All remark plugins (for backwards compatibility)
|
|
140
|
-
*/
|
|
141
|
-
remarkPlugins: Pluggable[];
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Plugin configuration passed to Streamdown
|
|
145
|
-
*/
|
|
146
|
-
interface PluginConfig {
|
|
147
|
-
code?: CodeHighlighterPlugin;
|
|
148
|
-
mermaid?: DiagramPlugin;
|
|
149
|
-
math?: MathPlugin;
|
|
150
|
-
cjk?: CjkPlugin;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
declare const parseMarkdownIntoBlocks: (markdown: string) => string[];
|
|
154
|
-
|
|
155
|
-
type ControlsConfig = boolean | {
|
|
156
|
-
table?: boolean;
|
|
157
|
-
code?: boolean;
|
|
158
|
-
mermaid?: boolean | {
|
|
159
|
-
download?: boolean;
|
|
160
|
-
copy?: boolean;
|
|
161
|
-
fullscreen?: boolean;
|
|
162
|
-
panZoom?: boolean;
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
interface LinkSafetyModalProps {
|
|
166
|
-
url: string;
|
|
167
|
-
isOpen: boolean;
|
|
168
|
-
onClose: () => void;
|
|
169
|
-
onConfirm: () => void;
|
|
170
|
-
}
|
|
171
|
-
interface LinkSafetyConfig {
|
|
172
|
-
enabled: boolean;
|
|
173
|
-
onLinkCheck?: (url: string) => Promise<boolean> | boolean;
|
|
174
|
-
renderModal?: (props: LinkSafetyModalProps) => React.ReactNode;
|
|
175
|
-
}
|
|
176
|
-
interface MermaidErrorComponentProps {
|
|
177
|
-
error: string;
|
|
178
|
-
chart: string;
|
|
179
|
-
retry: () => void;
|
|
180
|
-
}
|
|
181
|
-
interface MermaidOptions {
|
|
182
|
-
config?: MermaidConfig;
|
|
183
|
-
errorComponent?: React.ComponentType<MermaidErrorComponentProps>;
|
|
184
|
-
}
|
|
185
|
-
type StreamdownProps = Options & {
|
|
186
|
-
mode?: "static" | "streaming";
|
|
187
|
-
BlockComponent?: React.ComponentType<BlockProps>;
|
|
188
|
-
parseMarkdownIntoBlocksFn?: (markdown: string) => string[];
|
|
189
|
-
parseIncompleteMarkdown?: boolean;
|
|
190
|
-
className?: string;
|
|
191
|
-
shikiTheme?: [BundledTheme, BundledTheme];
|
|
192
|
-
mermaid?: MermaidOptions;
|
|
193
|
-
controls?: ControlsConfig;
|
|
194
|
-
isAnimating?: boolean;
|
|
195
|
-
caret?: keyof typeof carets;
|
|
196
|
-
plugins?: PluginConfig;
|
|
197
|
-
remend?: RemendOptions;
|
|
198
|
-
linkSafety?: LinkSafetyConfig;
|
|
199
|
-
};
|
|
200
|
-
declare const defaultRehypePlugins: Record<string, Pluggable>;
|
|
201
|
-
declare const defaultRemarkPlugins: Record<string, Pluggable>;
|
|
202
|
-
declare const carets: {
|
|
203
|
-
block: string;
|
|
204
|
-
circle: string;
|
|
205
|
-
};
|
|
206
|
-
interface StreamdownContextType {
|
|
207
|
-
shikiTheme: [BundledTheme, BundledTheme];
|
|
208
|
-
controls: ControlsConfig;
|
|
209
|
-
isAnimating: boolean;
|
|
210
|
-
mode: "static" | "streaming";
|
|
211
|
-
mermaid?: MermaidOptions;
|
|
212
|
-
linkSafety?: LinkSafetyConfig;
|
|
213
|
-
}
|
|
214
|
-
declare const StreamdownContext: react.Context<StreamdownContextType>;
|
|
215
|
-
type BlockProps = Options & {
|
|
216
|
-
content: string;
|
|
217
|
-
shouldParseIncompleteMarkdown: boolean;
|
|
218
|
-
index: number;
|
|
219
|
-
};
|
|
220
|
-
declare const Block: react.MemoExoticComponent<({ content, shouldParseIncompleteMarkdown: _, index: __, ...props }: BlockProps) => react_jsx_runtime.JSX.Element>;
|
|
221
|
-
declare const Streamdown: react.MemoExoticComponent<({ children, mode, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, components, rehypePlugins, remarkPlugins, className, shikiTheme, mermaid, controls, isAnimating, BlockComponent, parseMarkdownIntoBlocksFn, caret, plugins, remend: remendOptions, linkSafety, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
|
|
222
|
-
|
|
223
|
-
export { Block, type CjkPlugin, type CodeHighlighterPlugin, type ControlsConfig, type DiagramPlugin, type HighlightOptions, type LinkSafetyConfig, type LinkSafetyModalProps, type MathPlugin, type MermaidErrorComponentProps, type MermaidOptions, type PluginConfig, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, defaultRehypePlugins, defaultRemarkPlugins, parseMarkdownIntoBlocks };
|
package/dist/mermaid-4DMBBIKO.js
DELETED