streamdown 1.6.0 → 1.6.2

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 CHANGED
@@ -51,16 +51,3 @@ export default function Page() {
51
51
  ```
52
52
 
53
53
  For more info, see the [documentation](https://streamdown.ai/docs).
54
-
55
- ## Browser Support
56
-
57
- Streamdown requires browsers that support [RegExp lookbehind assertions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion). This means:
58
-
59
- - **Safari 16.5+** (iOS 16.5+, macOS Ventura 13.4+)
60
- - Chrome 62+
61
- - Edge 79+
62
- - Firefox 78+
63
-
64
- The lookbehind assertion requirement comes from dependencies (particularly Shiki for syntax highlighting and mdast-util-gfm-autolink-literal). Older browsers will crash when attempting to parse these regular expressions.
65
-
66
- If you need to support older browsers, particularly iOS Safari < 16.5, you may need to implement conditional loading or provide a fallback rendering solution.
@@ -0,0 +1,21 @@
1
+ import {createContext,lazy,memo,useContext,isValidElement,useMemo,useId,useTransition,useState,useEffect,Suspense,useRef,useCallback}from'react';import {harden}from'rehype-harden';import Ue from'rehype-katex';import gr from'rehype-raw';import br from'remark-cjk-friendly';import yr from'remark-cjk-friendly-gfm-strikethrough';import wr from'remark-gfm';import We from'remark-math';import Rn from'lucide-react/dist/esm/icons/check';import jn from'lucide-react/dist/esm/icons/copy';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import zn from'lucide-react/dist/esm/icons/download';import _n from'lucide-react/dist/esm/icons/loader-2';import Yn from'lucide-react/dist/esm/icons/maximize-2';import Qn from'lucide-react/dist/esm/icons/x';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import Io from'remark-parse';import So from'remark-rehype';import E from'path';import nn from'process';import {fileURLToPath}from'url';import {Lexer}from'marked';import Nr from'lucide-react/dist/esm/icons/rotate-ccw';import Ir from'lucide-react/dist/esm/icons/zoom-in';import Sr from'lucide-react/dist/esm/icons/zoom-out';var vn=Object.create;var Ve=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var Mn=Object.getOwnPropertyNames;var xn=Object.getPrototypeOf,Pn=Object.prototype.hasOwnProperty;var Tn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Nn=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Mn(t))!Pn.call(e,r)&&r!==n&&Ve(e,r,{get:()=>t[r],enumerable:!(o=Cn(t,r))||o.enumerable});return e};var In=(e,t,n)=>(n=e!=null?vn(xn(e)):{},Nn(Ve(n,"default",{value:e,enumerable:true}),e));var Yt=Tn((ni,Gt)=>{var de=Object.prototype.hasOwnProperty,Zt=Object.prototype.toString,Ut=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,Vt=function(t){return typeof Array.isArray=="function"?Array.isArray(t):Zt.call(t)==="[object Array]"},Xt=function(t){if(!t||Zt.call(t)!=="[object Object]")return false;var n=de.call(t,"constructor"),o=t.constructor&&t.constructor.prototype&&de.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!o)return false;var r;for(r in t);return typeof r=="undefined"||de.call(t,r)},Jt=function(t,n){Ut&&n.name==="__proto__"?Ut(t,n.name,{enumerable:true,configurable:true,value:n.newValue,writable:true}):t[n.name]=n.newValue;},Kt=function(t,n){if(n==="__proto__")if(de.call(t,n)){if(Wt)return Wt(t,n).value}else return;return t[n]};Gt.exports=function e(){var t,n,o,r,s,a,i=arguments[0],l=1,c=arguments.length,d=false;for(typeof i=="boolean"&&(d=i,i=arguments[1]||{},l=2),(i==null||typeof i!="object"&&typeof i!="function")&&(i={});l<c;++l)if(t=arguments[l],t!=null)for(n in t)o=Kt(i,n),r=Kt(t,n),i!==r&&(d&&r&&(Xt(r)||(s=Vt(r)))?(s?(s=false,a=o&&Vt(o)?o:[]):a=o&&Xt(o)?o:{},Jt(i,{name:n,newValue:e(d,a,r)})):typeof r!="undefined"&&Jt(i,{name:n,newValue:r}));return i};});var f=(...e)=>twMerge(clsx(e)),A=(e,t,n)=>{let o=typeof t=="string"?new Blob([t],{type:n}):t,r=URL.createObjectURL(o),s=document.createElement("a");s.href=r,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r);};var Ln=createContext({code:""}),te=()=>useContext(Ln);var be=({onCopy:e,onError:t,timeout:n=2e3,children:o,className:r,code:s,...a})=>{let[i,l]=useState(false),c=useRef(0),{code:d}=te(),{isAnimating:m}=useContext(M),p=s!=null?s:d,h=async()=>{var g;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(p),l(!0),e==null||e(),c.current=window.setTimeout(()=>l(!1),n));}catch(w){t==null||t(w);}};useEffect(()=>()=>{window.clearTimeout(c.current);},[]);let u=i?Rn:jn;return jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:h,type:"button",...a,children:o!=null?o:jsx(u,{size:14})})};var Je={"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"},Ze=({onDownload:e,onError:t,language:n,children:o,className:r,code:s,...a})=>{let{code:i}=te(),{isAnimating:l}=useContext(M),c=s!=null?s:i,m=`file.${n&&n in Je?Je[n]:"txt"}`,p="text/plain",h=()=>{try{A(m,c,p),e==null||e();}catch(u){t==null||t(u);}};return jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:l,onClick:h,title:"Download file",type:"button",...a,children:o!=null?o:jsx(zn,{size:14})})};var we=()=>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(_n,{className:"size-4 animate-spin"})})]});var Wn=/\.[^/.]+$/,Ge=({node:e,className:t,src:n,alt:o,...r})=>{let s=async()=>{if(n)try{let i=await(await fetch(n)).blob(),c=new URL(n,window.location.origin).pathname.split("/").pop()||"",d=c.split(".").pop(),m=c.includes(".")&&d!==void 0&&d.length<=4,p="";if(m)p=c;else {let h=i.type,u="png";h.includes("jpeg")||h.includes("jpg")?u="jpg":h.includes("png")?u="png":h.includes("svg")?u="svg":h.includes("gif")?u="gif":h.includes("webp")&&(u="webp"),p=`${(o||c||"image").replace(Wn,"")}.${u}`;}A(p,i,i.type);}catch(a){console.error("Failed to download image:",a);}};return n?jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsx("img",{alt:o,className:f("max-w-full rounded-lg",t),"data-streamdown":"image",src:n,...r}),jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsx("button",{className:f("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(zn,{size:14})})]}):null};var oe=async e=>{let n={...{startOnLoad:false,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:true},...e},r=(await import('mermaid')).default;return r.initialize(n),r},Ye=(e,t)=>{var o;let n=(o=void 0)!=null?o:5;return new Promise((r,s)=>{let a="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let l=document.createElement("canvas"),c=i.width*n,d=i.height*n;l.width=c,l.height=d;let m=l.getContext("2d");if(!m){s(new Error("Failed to create 2D canvas context for PNG export"));return}m.drawImage(i,0,0,c,d),l.toBlob(p=>{if(!p){s(new Error("Failed to create PNG blob"));return}r(p);},"image/png");},i.onerror=()=>s(new Error("Failed to load SVG image")),i.src=a;})};var et=({chart:e,children:t,className:n,onDownload:o,config:r,onError:s})=>{let[a,i]=useState(false),l=useRef(null),{isAnimating:c}=useContext(M),d=async m=>{try{if(m==="mmd"){A("diagram.mmd",e,"text/plain"),i(!1),o==null||o(m);return}let p=await oe(r),h=e.split("").reduce((w,k)=>(w<<5)-w+k.charCodeAt(0)|0,0),u=`mermaid-${Math.abs(h)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:g}=await p.render(u,e);if(!g){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(m==="svg"){A("diagram.svg",g,"image/svg+xml"),i(!1),o==null||o(m);return}if(m==="png"){let w=await Ye(g);A("diagram.png",w,"image/png"),o==null||o(m),i(!1);return}}catch(p){s==null||s(p);}};return useEffect(()=>{let m=p=>{l.current&&!l.current.contains(p.target)&&i(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),jsxs("div",{className:"relative",ref:l,children:[jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:c,onClick:()=>i(!a),title:"Download diagram",type:"button",children:t!=null?t:jsx(zn,{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:()=>d("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:()=>d("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:()=>d("mmd"),type:"button",children:"MMD"})]})]})};var J=0,no=()=>{J+=1,J===1&&(document.body.style.overflow="hidden");},oo=()=>{J=Math.max(0,J-1),J===0&&(document.body.style.overflow="");},rt=({chart:e,config:t,onFullscreen:n,onExit:o,className:r,...s})=>{let[a,i]=useState(false),{isAnimating:l}=useContext(M),c=()=>{i(!a);};return useEffect(()=>{if(a){no();let d=m=>{m.key==="Escape"&&i(false);};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),oo();}}},[a]),useEffect(()=>{a?n==null||n():o&&o();},[a,n,o]),jsxs(Fragment,{children:[jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:l,onClick:c,title:"View fullscreen",type:"button",...s,children:jsx(Yn,{size:14})}),a&&jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:c,onKeyDown:d=>{d.key==="Escape"&&c();},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:c,title:"Exit fullscreen",type:"button",children:jsx(Qn,{size:20})}),jsx("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:d=>d.stopPropagation(),onKeyDown:d=>d.stopPropagation(),role:"presentation",children:jsx(ot,{chart:e,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:true})})]})]})};var re=e=>{var s,a;let t=[],n=[],o=e.querySelectorAll("thead th");for(let i of o)t.push(((s=i.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let i of r){let l=[],c=i.querySelectorAll("td");for(let d of c)l.push(((a=d.textContent)==null?void 0:a.trim())||"");n.push(l);}return {headers:t,rows:n}},se=e=>{let{headers:t,rows:n}=e,o=i=>{let l=false,c=false;for(let d=0;d<i.length;d+=1){let m=i[d];if(m==='"'){l=true,c=true;break}(m===","||m===`
2
+ `)&&(l=true);}return l?c?`"${i.replace(/"/g,'""')}"`:`"${i}"`:i},r=t.length>0?n.length+1:n.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(o).join(","),a+=1);for(let i of n)s[a]=i.map(o).join(","),a+=1;return s.join(`
3
+ `)},st=e=>{let{headers:t,rows:n}=e,o=i=>{let l=false;for(let d=0;d<i.length;d+=1){let m=i[d];if(m===" "||m===`
4
+ `||m==="\r"){l=true;break}}if(!l)return i;let c=[];for(let d=0;d<i.length;d+=1){let m=i[d];m===" "?c.push("\\t"):m===`
5
+ `?c.push("\\n"):m==="\r"?c.push("\\r"):c.push(m);}return c.join("")},r=t.length>0?n.length+1:n.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(o).join(" "),a+=1);for(let i of n)s[a]=i.map(o).join(" "),a+=1;return s.join(`
6
+ `)},ke=e=>{let t=false;for(let o=0;o<e.length;o+=1){let r=e[o];if(r==="\\"||r==="|"){t=true;break}}if(!t)return e;let n=[];for(let o=0;o<e.length;o+=1){let r=e[o];r==="\\"?n.push("\\\\"):r==="|"?n.push("\\|"):n.push(r);}return n.join("")},it=e=>{let{headers:t,rows:n}=e;if(t.length===0)return "";let o=new Array(n.length+2),r=0,s=t.map(i=>ke(i));o[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let i=0;i<t.length;i+=1)a[i]="---";o[r]=`| ${a.join(" | ")} |`,r+=1;for(let i of n)if(i.length<t.length){let l=new Array(t.length);for(let c=0;c<t.length;c+=1)l[c]=c<i.length?ke(i[c]):"";o[r]=`| ${l.join(" | ")} |`,r+=1;}else {let l=i.map(c=>ke(c));o[r]=`| ${l.join(" | ")} |`,r+=1;}return o.join(`
7
+ `)};var dt=({children:e,className:t,onCopy:n,onError:o,timeout:r=2e3})=>{let[s,a]=useState(false),[i,l]=useState(false),c=useRef(null),d=useRef(0),{isAnimating:m}=useContext(M),p=async u=>{var g,w;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.write)){o==null||o(new Error("Clipboard API not available"));return}try{let k=(w=c.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),P=k==null?void 0:k.querySelector("table");if(!P){o==null||o(new Error("Table not found"));return}let N=re(P),T=u==="csv"?se(N):st(N),L=new ClipboardItem({"text/plain":new Blob([T],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([L]),l(!0),a(!1),n==null||n(u),d.current=window.setTimeout(()=>l(!1),r);}catch(k){o==null||o(k);}};useEffect(()=>{let u=g=>{c.current&&!c.current.contains(g.target)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u),window.clearTimeout(d.current);}},[]);let h=i?Rn:jn;return jsxs("div",{className:"relative",ref:c,children:[jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>a(!s),title:"Copy table",type:"button",children:e!=null?e:jsx(h,{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"),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"),type:"button",children:"TSV"})]})]})};var pt=({children:e,className:t,onDownload:n,onError:o})=>{let[r,s]=useState(false),a=useRef(null),{isAnimating:i}=useContext(M),l=c=>{var d;try{let m=(d=a.current)==null?void 0:d.closest('[data-streamdown="table-wrapper"]'),p=m==null?void 0:m.querySelector("table");if(!p){o==null||o(new Error("Table not found"));return}let h=re(p),u=c==="csv"?se(h):it(h);A(`table.${c==="csv"?"csv":"md"}`,u,c==="csv"?"text/csv":"text/markdown"),s(!1),n==null||n(c);}catch(m){o==null||o(m);}};return useEffect(()=>{let c=d=>{a.current&&!a.current.contains(d.target)&&s(false);};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c);}},[]),jsxs("div",{className:"relative",ref:a,children:[jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>s(!r),title:"Download table",type:"button",children:e!=null?e:jsx(zn,{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:()=>l("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:()=>l("markdown"),type:"button",children:"Markdown"})]})]})};var ft=({children:e,className:t,showControls:n,...o})=>jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[n&&jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsx(dt,{}),jsx(pt,{})]}),jsx("div",{className:"overflow-x-auto",children:jsx("table",{className:f("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var ho=lazy(()=>import('./code-block-O5G73IWQ.js').then(e=>({default:e.CodeBlock}))),go=lazy(()=>import('./mermaid-V6KZCINT.js').then(e=>({default:e.Mermaid}))),bo=/language-([^\s]+)/;function ce(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 n=e.position.start,o=t.position.start,r=e.position.end,s=t.position.end;return (n==null?void 0:n.line)===(o==null?void 0:o.line)&&(n==null?void 0:n.column)===(o==null?void 0:o.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function C(e,t){return e.className===t.className&&ce(e.node,t.node)}var Me=(e,t)=>typeof e=="boolean"?e:e[t]!==false,ve=(e,t)=>{if(typeof e=="boolean")return e;let n=e.mermaid;return n===false?false:n===true||n===void 0?true:n[t]!==false},xe=memo(({children:e,className:t,node:n,...o})=>jsx("ol",{className:f("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>C(e,t));xe.displayName="MarkdownOl";var yt=memo(({children:e,className:t,node:n,...o})=>jsx("li",{className:f("py-1",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&ce(e.node,t.node));yt.displayName="MarkdownLi";var wt=memo(({children:e,className:t,node:n,...o})=>jsx("ul",{className:f("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>C(e,t));wt.displayName="MarkdownUl";var kt=memo(({className:e,node:t,...n})=>jsx("hr",{className:f("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>C(e,t));kt.displayName="MarkdownHr";var vt=memo(({children:e,className:t,node:n,...o})=>jsx("span",{className:f("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>C(e,t));vt.displayName="MarkdownStrong";var Ct=memo(({children:e,className:t,href:n,node:o,...r})=>{let s=n==="streamdown:incomplete-link";return jsx("a",{className:f("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":s,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...r,children:e})},(e,t)=>C(e,t)&&e.href===t.href);Ct.displayName="MarkdownA";var Mt=memo(({children:e,className:t,node:n,...o})=>jsx("h1",{className:f("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>C(e,t));Mt.displayName="MarkdownH1";var xt=memo(({children:e,className:t,node:n,...o})=>jsx("h2",{className:f("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>C(e,t));xt.displayName="MarkdownH2";var Pt=memo(({children:e,className:t,node:n,...o})=>jsx("h3",{className:f("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>C(e,t));Pt.displayName="MarkdownH3";var Tt=memo(({children:e,className:t,node:n,...o})=>jsx("h4",{className:f("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>C(e,t));Tt.displayName="MarkdownH4";var Nt=memo(({children:e,className:t,node:n,...o})=>jsx("h5",{className:f("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>C(e,t));Nt.displayName="MarkdownH5";var It=memo(({children:e,className:t,node:n,...o})=>jsx("h6",{className:f("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>C(e,t));It.displayName="MarkdownH6";var St=memo(({children:e,className:t,node:n,...o})=>{let{controls:r}=useContext(M),s=Me(r,"table");return jsx(ft,{className:t,"data-streamdown":"table-wrapper",showControls:s,...o,children:e})},(e,t)=>C(e,t));St.displayName="MarkdownTable";var Et=memo(({children:e,className:t,node:n,...o})=>jsx("thead",{className:f("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>C(e,t));Et.displayName="MarkdownThead";var At=memo(({children:e,className:t,node:n,...o})=>jsx("tbody",{className:f("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>C(e,t));At.displayName="MarkdownTbody";var Bt=memo(({children:e,className:t,node:n,...o})=>jsx("tr",{className:f("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>C(e,t));Bt.displayName="MarkdownTr";var Lt=memo(({children:e,className:t,node:n,...o})=>jsx("th",{className:f("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>C(e,t));Lt.displayName="MarkdownTh";var Rt=memo(({children:e,className:t,node:n,...o})=>jsx("td",{className:f("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>C(e,t));Rt.displayName="MarkdownTd";var jt=memo(({children:e,className:t,node:n,...o})=>jsx("blockquote",{className:f("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>C(e,t));jt.displayName="MarkdownBlockquote";var Dt=memo(({children:e,className:t,node:n,...o})=>jsx("sup",{className:f("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>C(e,t));Dt.displayName="MarkdownSup";var $t=memo(({children:e,className:t,node:n,...o})=>jsx("sub",{className:f("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>C(e,t));$t.displayName="MarkdownSub";var Ot=memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let s=l=>{var p,h;if(!isValidElement(l))return false;let c=Array.isArray(l.props.children)?l.props.children:[l.props.children],d=false,m=false;for(let u of c)if(u){if(typeof u=="string")u.trim()!==""&&(d=true);else if(isValidElement(u))if(((p=u.props)==null?void 0:p["data-footnote-backref"])!==void 0)m=true;else {let g=Array.isArray(u.props.children)?u.props.children:[u.props.children];for(let w of g){if(typeof w=="string"&&w.trim()!==""){d=true;break}if(isValidElement(w)&&((h=w.props)==null?void 0:h["data-footnote-backref"])===void 0){d=true;break}}}}return m&&!d},a=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===xe){let d=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!s(m));return d.length===0?null:{...l,props:{...l.props,children:d}}}return l}):e;return (Array.isArray(a)?a.some(l=>l!==null):a!==null)?jsx("section",{className:t,...o,children:a}):null}return jsx("section",{className:t,...o,children:e})},(e,t)=>C(e,t));Ot.displayName="MarkdownSection";var yo=({node:e,className:t,children:n,...o})=>{var m,p,h;let r=((m=e==null?void 0:e.position)==null?void 0:m.start.line)===((p=e==null?void 0:e.position)==null?void 0:p.end.line),{mermaid:s,controls:a}=useContext(M);if(r)return jsx("code",{className:f("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:n});let i=t==null?void 0:t.match(bo),l=(h=i==null?void 0:i.at(1))!=null?h:"",c="";if(isValidElement(n)&&n.props&&typeof n.props=="object"&&"children"in n.props&&typeof n.props.children=="string"?c=n.props.children:typeof n=="string"&&(c=n),l==="mermaid"){let u=Me(a,"mermaid"),g=ve(a,"download"),w=ve(a,"copy"),k=ve(a,"fullscreen");return jsxs("div",{className:f("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[u&&(g||w||k)&&jsxs("div",{className:"flex items-center justify-end gap-2",children:[g&&jsx(et,{chart:c,config:s==null?void 0:s.config}),w&&jsx(be,{code:c}),k&&jsx(rt,{chart:c,config:s==null?void 0:s.config})]}),jsx(Suspense,{fallback:jsx(we,{}),children:jsx(go,{chart:c,config:s==null?void 0:s.config})})]})}let d=Me(a,"code");return jsx(Suspense,{fallback:jsx(we,{}),children:jsx(ho,{className:f("overflow-x-auto border-border border-t",t),code:c,"data-language":l,"data-streamdown":"code-block",language:l,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:d&&jsxs(Fragment,{children:[jsx(Ze,{code:c,language:l}),jsx(be,{})]})})})},Ht=memo(yo,(e,t)=>e.className===t.className&&ce(e.node,t.node));Ht.displayName="MarkdownCode";var zt=memo(Ge,(e,t)=>e.className===t.className&&ce(e.node,t.node));zt.displayName="MarkdownImg";var qt=memo(({children:e,className:t,node:n,...o})=>{var a;let s=(Array.isArray(e)?e:[e]).filter(i=>i!=null&&i!=="");return s.length===1&&isValidElement(s[0])&&((a=s[0].props.node)==null?void 0:a.tagName)==="img"?jsx(Fragment,{children:e}):jsx("p",{className:t,...o,children:e})},(e,t)=>C(e,t));qt.displayName="MarkdownParagraph";var _t={ol:xe,li:yt,ul:wt,hr:kt,strong:vt,a:Ct,h1:Mt,h2:xt,h3:Pt,h4:Tt,h5:Nt,h6:It,table:St,thead:Et,tbody:At,tr:Bt,th:Lt,td:Rt,blockquote:jt,code:Ht,img:zt,pre:({children:e})=>e,sup:Dt,sub:$t,p:qt,section:Ot};function Pe(e){if(e)throw e}var ue=In(Yt());function K(e){if(typeof e!="object"||e===null)return false;let t=Object.getPrototypeOf(e);return (t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Te(){let e=[],t={run:n,use:o};return t;function n(...r){let s=-1,a=r.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);i(null,...r);function i(l,...c){let d=e[++s],m=-1;if(l){a(l);return}for(;++m<r.length;)(c[m]===null||c[m]===void 0)&&(c[m]=r[m]);r=c,d?Qt(d,i)(...c):a(null,...c);}}function o(r){if(typeof r!="function")throw new TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),t}}function Qt(e,t){let n;return o;function o(...a){let i=e.length>a.length,l;i&&a.push(r);try{l=e.apply(this,a);}catch(c){let d=c;if(i&&n)throw d;return r(d)}i||(l&&l.then&&typeof l.then=="function"?l.then(s,r):l instanceof Error?r(l):s(l));}function r(a,...i){n||(n=true,t(a,...i));}function s(a){r(null,a);}}function Ie(e){return !e||typeof e!="object"?"":"position"in e||"type"in e?en(e.position):"start"in e||"end"in e?en(e):"line"in e||"column"in e?Ne(e):""}function Ne(e){return tn(e&&e.line)+":"+tn(e&&e.column)}function en(e){return Ne(e&&e.start)+"-"+Ne(e&&e.end)}function tn(e){return e&&typeof e=="number"?e:1}var x=class extends Error{constructor(t,n,o){super(),typeof n=="string"&&(o=n,n=void 0);let r="",s={},a=false;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?r=t:!s.cause&&t&&(a=true,r=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof o=="string"){let l=o.indexOf(":");l===-1?s.ruleId=o:(s.source=o.slice(0,l),s.ruleId=o.slice(l+1));}if(!s.place&&s.ancestors&&s.ancestors){let l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position);}let i=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=i?i.line:void 0,this.name=Ie(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0;}};x.prototype.file="";x.prototype.name="";x.prototype.reason="";x.prototype.message="";x.prototype.stack="";x.prototype.column=void 0;x.prototype.line=void 0;x.prototype.ancestors=void 0;x.prototype.cause=void 0;x.prototype.fatal=void 0;x.prototype.place=void 0;x.prototype.ruleId=void 0;x.prototype.source=void 0;function me(e){return !!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}var Se=["history","path","basename","stem","extname","dirname"],Z=class{constructor(t){let n;t?me(t)?n={path:t}:typeof t=="string"||wo(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":nn.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let o=-1;for(;++o<Se.length;){let s=Se[o];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s]);}let r;for(r in n)Se.includes(r)||(this[r]=n[r]);}get basename(){return typeof this.path=="string"?E.basename(this.path):void 0}set basename(t){Ae(t,"basename"),Ee(t,"basename"),this.path=E.join(this.dirname||"",t);}get dirname(){return typeof this.path=="string"?E.dirname(this.path):void 0}set dirname(t){rn(this.basename,"dirname"),this.path=E.join(t||"",this.basename);}get extname(){return typeof this.path=="string"?E.extname(this.path):void 0}set extname(t){if(Ee(t,"extname"),rn(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=E.join(this.dirname,this.stem+(t||""));}get path(){return this.history[this.history.length-1]}set path(t){me(t)&&(t=fileURLToPath(t)),Ae(t,"path"),this.path!==t&&this.history.push(t);}get stem(){return typeof this.path=="string"?E.basename(this.path,this.extname):void 0}set stem(t){Ae(t,"stem"),Ee(t,"stem"),this.path=E.join(this.dirname||"",t+(this.extname||""));}fail(t,n,o){let r=this.message(t,n,o);throw r.fatal=true,r}info(t,n,o){let r=this.message(t,n,o);return r.fatal=void 0,r}message(t,n,o){let r=new x(t,n,o);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=false,this.messages.push(r),r}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}};function Ee(e,t){if(e&&e.includes(E.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+E.sep+"`")}function Ae(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function rn(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function wo(e){return !!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var sn=(function(e){let o=this.constructor.prototype,r=o[e],s=function(){return r.apply(s,arguments)};return Object.setPrototypeOf(s,o),s});var ko={}.hasOwnProperty,je=class e extends sn{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Te();}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let o=this.attachers[n];t.use(...o);}return t.data((0, ue.default)(true,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Re("data",this.frozen),this.namespace[t]=n,this):ko.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Re("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...o]=this.attachers[this.freezeIndex];if(o[0]===false)continue;o[0]===true&&(o[0]=void 0);let r=n.call(t,...o);typeof r=="function"&&this.transformers.use(r);}return this.frozen=true,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=pe(t),o=this.parser||this.Parser;return Be("parse",o),o(String(n),n)}process(t,n){let o=this;return this.freeze(),Be("process",this.parser||this.Parser),Le("process",this.compiler||this.Compiler),n?r(void 0,n):new Promise(r);function r(s,a){let i=pe(t),l=o.parse(i);o.run(l,i,function(d,m,p){if(d||!m||!p)return c(d);let h=m,u=o.stringify(h,p);Co(u)?p.value=u:p.result=u,c(d,p);});function c(d,m){d||!m?a(d):s?s(m):n(void 0,m);}}}processSync(t){let n=false,o;return this.freeze(),Be("processSync",this.parser||this.Parser),Le("processSync",this.compiler||this.Compiler),this.process(t,r),ln("processSync","process",n),o;function r(s,a){n=true,Pe(s),o=a;}}run(t,n,o){an(t),this.freeze();let r=this.transformers;return !o&&typeof n=="function"&&(o=n,n=void 0),o?s(void 0,o):new Promise(s);function s(a,i){let l=pe(n);r.run(t,l,c);function c(d,m,p){let h=m||t;d?i(d):a?a(h):o(void 0,h,p);}}}runSync(t,n){let o=false,r;return this.run(t,n,s),ln("runSync","run",o),r;function s(a,i){Pe(a),r=i,o=true;}}stringify(t,n){this.freeze();let o=pe(n),r=this.compiler||this.Compiler;return Le("stringify",r),an(t),r(t,o)}use(t,...n){let o=this.attachers,r=this.namespace;if(Re("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?i(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[d,...m]=c;l(d,m);}else a(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function a(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(c.plugins),c.settings&&(r.settings=(0, ue.default)(true,r.settings,c.settings));}function i(c){let d=-1;if(c!=null)if(Array.isArray(c))for(;++d<c.length;){let m=c[d];s(m);}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,d){let m=-1,p=-1;for(;++m<o.length;)if(o[m][0]===c){p=m;break}if(p===-1)o.push([c,...d]);else if(d.length>0){let[h,...u]=d,g=o[p][1];K(g)&&K(h)&&(h=(0, ue.default)(true,g,h)),o[p]=[c,h,...u];}}}},De=new je().freeze();function Be(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Le(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Re(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function an(e){if(!K(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function ln(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function pe(e){return vo(e)?e:new Z(e)}function vo(e){return !!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Co(e){return typeof e=="string"||Mo(e)}function Mo(e){return !!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var cn=[],dn={allowDangerousHtml:true},fe=new WeakMap,$e=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(o||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return "";let p="";for(let h=0;h<m.length;h+=1){let u=m[h];if(h>0&&(p+=","),Array.isArray(u)){let[g,w]=u;if(typeof g=="function"){let k=fe.get(g);k||(k=g.name,fe.set(g,k)),p+=k;}else p+=String(g);p+=":",p+=JSON.stringify(w);}else if(typeof u=="function"){let g=fe.get(u);g||(g=u.name,fe.set(u,g)),p+=g;}else p+=String(u);}return p},i=a(o),l=a(r),c=s?JSON.stringify(s):"",d=`${l}::${i}::${c}`;return this.keyCache.set(t,d),d}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(o,n);}clear(){this.cache.clear();}},mn=new $e,Oe=e=>{let t=Eo(e),n=e.children||"";return Bo(t.runSync(t.parse(n),n),e)},Eo=e=>{let t=mn.get(e);if(t)return t;let n=Ao(e);return mn.set(e,n),n},Ao=e=>{let t=e.rehypePlugins||cn,n=e.remarkPlugins||cn,o=e.remarkRehypeOptions?{...dn,...e.remarkRehypeOptions}:dn;return De().use(Io).use(n).use(So,o).use(t)},Bo=(e,t)=>toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true});var Ro=/\[\^[^\]\s]{1,200}\](?!:)/,jo=/\[\^[^\]\s]{1,200}\]:/,Do=/<\/(\w+)>/,$o=/<(\w+)[\s>]/,He=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
8
+ `||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},Oo=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
9
+ `||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},ze=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]==="$"&&e[n+1]==="$"&&(t+=1,n+=1);return t},qe=e=>{let t=Ro.test(e),n=jo.test(e);if(t||n)return [e];let o=Lexer.lex(e,{gfm:true}),r=[],s=[];for(let a of o){let i=a.raw,l=r.length;if(s.length>0){if(r[l-1]+=i,a.type==="html"){let d=i.match(Do);if(d){let m=d[1];s.at(-1)===m&&s.pop();}}continue}if(a.type==="html"&&a.block){let d=i.match($o);if(d){let m=d[1];i.includes(`</${m}>`)||s.push(m);}}if(i.trim()==="$$"&&l>0){let d=r[l-1],m=He(d),p=ze(d);if(m&&p%2===1){r[l-1]=d+i;continue}}if(l>0&&Oo(i)){let d=r[l-1],m=He(d),p=ze(d),h=ze(i);if(m&&p%2===1&&!He(i)&&h===1){r[l-1]=d+i;continue}}r.push(i);}return r};var Ho=/(\*\*)([^*]*?)$/,zo=/(__)([^_]*?)$/,qo=/(\*\*\*)([^*]*?)$/,_o=/(\*)([^*]*?)$/,Fo=/(_)([^_]*?)$/,Uo=/(`)([^`]*?)$/,Wo=/(~~)([^~]*?)$/,q=/^[\s_~*`]*$/,pn=/^[\s]*[-*+][\s]+$/,Vo=/[\p{L}\p{N}_]/u,Xo=/^```[^`\n]*```?$/,Jo=/^\*{4,}$/,j=e=>{if(!e)return false;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?true:Vo.test(e)},he=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
10
+ `)};var Ko=(e,t)=>{let n=1;for(let o=t-1;o>=0;o-=1)if(e[o]==="]")n+=1;else if(e[o]==="["&&(n-=1,n===0))return o;return -1},Zo=(e,t)=>{let n=1;for(let o=t+1;o<e.length;o+=1)if(e[o]==="[")n+=1;else if(e[o]==="]"&&(n-=1,n===0))return o;return -1},_e=(e,t)=>{let n=false,o=false;for(let r=0;r<t;r+=1){if(e.substring(r,r+3)==="```"){o=!o,r+=2;continue}!o&&e[r]==="`"&&(n=!n);}return n||o},Go=e=>{let t=e.lastIndexOf("](");if(t!==-1&&!_e(e,t)&&!e.substring(t+2).includes(")")){let o=Ko(e,t);if(o!==-1&&!_e(e,o)){let r=o>0&&e[o-1]==="!",s=r?o-1:o,a=e.substring(0,s),i=e.substring(o+1,t);return r?a:`${a}[${i}](streamdown:incomplete-link)`}}for(let n=e.length-1;n>=0;n-=1)if(e[n]==="["&&!_e(e,n)){let o=n>0&&e[n-1]==="!",r=o?n-1:n;if(!e.substring(n+1).includes("]")){let i=e.substring(0,r);return o?i:`${e}](streamdown:incomplete-link)`}if(Zo(e,n)===-1){let i=e.substring(0,r);return o?i:`${e}](streamdown:incomplete-link)`}}return e},Yo=e=>{if(he(e))return e;let t=e.match(Ho);if(t){let n=t[2];if(!n||q.test(n))return e;let o=e.lastIndexOf(t[1]),s=e.substring(0,o).lastIndexOf(`
11
+ `),a=s===-1?0:s+1,i=e.substring(a,o);if(pn.test(i)&&n.includes(`
12
+ `))return e;if((e.match(/\*\*/g)||[]).length%2===1)return `${e}**`}return e},Qo=e=>{let t=e.match(zo);if(t){let n=t[2];if(!n||q.test(n))return e;let o=e.lastIndexOf(t[1]),s=e.substring(0,o).lastIndexOf(`
13
+ `),a=s===-1?0:s+1,i=e.substring(a,o);if(pn.test(i)&&n.includes(`
14
+ `))return e;if((e.match(/__/g)||[]).length%2===1)return `${e}__`}return e},er=e=>{let t=0,n=e.length;for(let o=0;o<n;o+=1){if(e[o]!=="*")continue;let r=o>0?e[o-1]:"",s=o<n-1?e[o+1]:"";if(r==="\\"||r==="*"||s==="*"||r&&s&&j(r)&&j(s))continue;let a=0;for(let l=o-1;l>=0;l-=1)if(e[l]===`
15
+ `){a=l+1;break}let i=true;for(let l=a;l<o;l+=1)if(e[l]!==" "&&e[l]!==" "){i=false;break}i&&(s===" "||s===" ")||(t+=1);}return t},tr=e=>{if(he(e))return e;if(e.match(_o)){let n=-1;for(let s=0;s<e.length;s+=1)if(e[s]==="*"&&e[s-1]!=="*"&&e[s+1]!=="*"&&e[s-1]!=="\\"){let a=s>0?e[s-1]:"",i=s<e.length-1?e[s+1]:"";if(a&&i&&j(a)&&j(i))continue;n=s;break}if(n===-1)return e;let o=e.substring(n+1);if(!o||q.test(o))return e;if(er(e)%2===1)return `${e}*`}return e},un=(e,t)=>{let n=false,o=false;for(let r=0;r<e.length&&r<t;r+=1){if(e[r]==="\\"&&e[r+1]==="$"){r+=1;continue}e[r]==="$"&&(e[r+1]==="$"?(o=!o,r+=1,n=false):o||(n=!n));}return n||o},nr=e=>{let t=e.includes("$"),n=0,o=e.length;for(let r=0;r<o;r+=1){if(e[r]!=="_")continue;let s=r>0?e[r-1]:"",a=r<o-1?e[r+1]:"";s!=="\\"&&(t&&un(e,r)||s==="_"||a==="_"||s&&a&&j(s)&&j(a)||(n+=1));}return n},or=e=>{if(he(e))return e;if(e.match(Fo)){let n=-1;for(let s=0;s<e.length;s+=1)if(e[s]==="_"&&e[s-1]!=="_"&&e[s+1]!=="_"&&e[s-1]!=="\\"&&!un(e,s)){let a=s>0?e[s-1]:"",i=s<e.length-1?e[s+1]:"";if(a&&i&&j(a)&&j(i))continue;n=s;break}if(n===-1)return e;let o=e.substring(n+1);if(!o||q.test(o))return e;if(nr(e)%2===1){let s=e.length;for(;s>0&&e[s-1]===`
16
+ `;)s-=1;if(s<e.length){let a=e.slice(0,s),i=e.slice(s);return `${a}_${i}`}return `${e}_`}}return e},rr=(e,t)=>{let n=e.substring(t,t+3)==="```",o=t>0&&e.substring(t-1,t+2)==="```",r=t>1&&e.substring(t-2,t+1)==="```";return n||o||r},sr=e=>{let t=0;for(let n=0;n<e.length;n+=1)e[n]==="`"&&!rr(e,n)&&(t+=1);return t},ir=e=>{if(e.match(Xo)&&!e.includes(`
17
+ `))return e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e;let n=(e.match(/```/g)||[]).length,o=n%2===1;if(n>0&&n%2===0&&e.includes(`
18
+ `)||(e.endsWith("```\n")||e.endsWith("```"))&&n%2===0)return e;let r=e.match(Uo);if(r&&!o){let s=r[2];if(!s||q.test(s))return e;if(sr(e)%2===1)return `${e}\``}return e},ar=e=>{let t=e.match(Wo);if(t){let n=t[2];if(!n||q.test(n))return e;if((e.match(/~~/g)||[]).length%2===1)return `${e}~~`}return e},lr=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let n=e.indexOf("$$");return n!==-1&&e.indexOf(`
19
+ `,n)!==-1&&!e.endsWith(`
20
+ `)?`${e}
21
+ $$`:`${e}$$`},cr=e=>{let t=0,n=0;for(let o=0;o<e.length;o+=1)e[o]==="*"?n+=1:(n>=3&&(t+=Math.floor(n/3)),n=0);return n>=3&&(t+=Math.floor(n/3)),t},dr=e=>{if(he(e)||Jo.test(e))return e;let t=e.match(qo);if(t){let n=t[2];if(!n||q.test(n))return e;if(cr(e)%2===1)return `${e}***`}return e},Fe=e=>{if(!e||typeof e!="string")return e;let t=e,n=Go(t);return n.endsWith("](streamdown:incomplete-link)")?n:(t=n,t=dr(t),t=Yo(t),t=Qo(t),t=tr(t),t=or(t),t=ir(t),t=ar(t),t=lr(t),t)};var kr={harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],defaultOrigin:void 0,allowDataImages:true}],raw:gr,katex:[Ue,{errorColor:"var(--color-muted-foreground)"}]},vr={gfm:[wr,{}],math:[We,{singleDollarTextMath:false}],cjkFriendly:[br,{}],cjkFriendlyGfmStrikethrough:[yr,{}]},Cr=Object.values(kr),Mr=Object.values(vr),xr={shikiTheme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0},M=createContext(xr),gn=memo(({content:e,shouldParseIncompleteMarkdown:t,...n})=>{let o=useMemo(()=>typeof e=="string"&&t?Fe(e.trim()):e,[e,t]);return jsx(Oe,{...n,children:o})},(e,t)=>{if(e.content!==t.content||e.shouldParseIncompleteMarkdown!==t.shouldParseIncompleteMarkdown||e.index!==t.index)return false;if(e.components!==t.components){let n=Object.keys(e.components||{}),o=Object.keys(t.components||{});if(n.length!==o.length||n.some(r=>{var s,a;return ((s=e.components)==null?void 0:s[r])!==((a=t.components)==null?void 0:a[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});gn.displayName="Block";var Pr=["github-light","github-dark"],Tr=memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:n=true,components:o,rehypePlugins:r=Cr,remarkPlugins:s=Mr,className:a,shikiTheme:i=Pr,mermaid:l,controls:c=true,isAnimating:d=false,BlockComponent:m=gn,parseMarkdownIntoBlocksFn:p=qe,...h})=>{let u=useId(),[g,w]=useTransition(),[k,P]=useState([]),N=useMemo(()=>p(typeof e=="string"?e:""),[e,p]);useEffect(()=>{t==="streaming"?w(()=>{P(N);}):P(N);},[N,t]);let T=t==="streaming"?k:N,L=useMemo(()=>T.map((H,B)=>`${u}-${B}`),[T.length,u]),O=useMemo(()=>({shikiTheme:i,controls:c,isAnimating:d,mode:t,mermaid:l}),[i,c,d,t,l]),U=useMemo(()=>({..._t,...o}),[o]);return useEffect(()=>{if(!(Array.isArray(r)&&r.some(S=>Array.isArray(S)?S[0]===Ue:S===Ue)))return;let B=false;if(Array.isArray(s)){let S=s.find(ee=>Array.isArray(ee)?ee[0]===We:ee===We);S&&Array.isArray(S)&&S[1]&&(B=S[1].singleDollarTextMath===true);}let R=typeof e=="string"?e:"",z=R.includes("$$"),y=B&&(/[^$]\$[^$]/.test(R)||/^\$[^$]/.test(R)||/[^$]\$$/.test(R));(z||y)&&import('katex/dist/katex.min.css');},[r,s,e]),t==="static"?jsx(M.Provider,{value:O,children:jsx("div",{className:f("space-y-4",a),children:jsx(Oe,{components:U,rehypePlugins:r,remarkPlugins:s,...h,children:e})})}):jsx(M.Provider,{value:O,children:jsx("div",{className:f("space-y-4",a),children:T.map((H,B)=>jsx(m,{components:U,content:H,index:B,rehypePlugins:r,remarkPlugins:s,shouldParseIncompleteMarkdown:n,...h},L[B]))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode);Tr.displayName="Streamdown";var kn=({children:e,className:t,minZoom:n=.5,maxZoom:o=3,zoomStep:r=.1,showControls:s=true,initialZoom:a=1,fullscreen:i=false})=>{let l=useRef(null),c=useRef(null),[d,m]=useState(a),[p,h]=useState({x:0,y:0}),[u,g]=useState(false),[w,k]=useState({x:0,y:0}),[P,N]=useState({x:0,y:0}),T=useCallback(y=>{m(I=>Math.max(n,Math.min(o,I+y)));},[n,o]),L=useCallback(()=>{T(r);},[T,r]),O=useCallback(()=>{T(-r);},[T,r]),U=useCallback(()=>{m(a),h({x:0,y:0});},[a]),H=useCallback(y=>{y.preventDefault();let I=y.deltaY>0?-r:r;T(I);},[T,r]),B=useCallback(y=>{if(y.button!==0||y.isPrimary===false)return;g(true),k({x:y.clientX,y:y.clientY}),N(p);let I=y.currentTarget;I instanceof HTMLElement&&I.setPointerCapture(y.pointerId);},[p]),R=useCallback(y=>{if(!u)return;y.preventDefault();let I=y.clientX-w.x,S=y.clientY-w.y;h({x:P.x+I,y:P.y+S});},[u,w,P]),z=useCallback(y=>{g(false);let I=y.currentTarget;I instanceof HTMLElement&&I.releasePointerCapture(y.pointerId);},[]);return useEffect(()=>{let y=l.current;if(y)return y.addEventListener("wheel",H,{passive:false}),()=>{y.removeEventListener("wheel",H);}},[H]),useEffect(()=>{let y=c.current;if(y&&u)return document.body.style.userSelect="none",y.addEventListener("pointermove",R,{passive:false}),y.addEventListener("pointerup",z),y.addEventListener("pointercancel",z),()=>{document.body.style.userSelect="",y.removeEventListener("pointermove",R),y.removeEventListener("pointerup",z),y.removeEventListener("pointercancel",z);}},[u,R,z]),jsxs("div",{className:f("relative",i?"h-full w-full":"w-full",t),ref:l,style:{cursor:u?"grabbing":"grab"},children:[s&&jsxs("div",{className:f("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:d>=o,onClick:L,title:"Zoom in",type:"button",children:jsx(Ir,{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<=n,onClick:O,title:"Zoom out",type:"button",children:jsx(Sr,{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:U,title:"Reset zoom and pan",type:"button",children:jsx(Nr,{size:16})})]}),jsx("div",{className:f("origin-center transition-transform duration-150 ease-out",i&&"flex h-full w-full items-center justify-center"),onPointerDown:B,ref:c,role:"application",style:{transform:`translate(${p.x}px, ${p.y}px) scale(${d})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var ot=({chart:e,className:t,config:n,fullscreen:o=false})=>{let[r,s]=useState(null),[a,i]=useState(true),[l,c]=useState(""),[d,m]=useState(""),[p,h]=useState(0),{mermaid:u}=useContext(M),g=u==null?void 0:u.errorComponent;if(useEffect(()=>{(async()=>{try{s(null),i(!0);let P=await oe(n),N=e.split("").reduce((O,U)=>(O<<5)-O+U.charCodeAt(0)|0,0),T=`mermaid-${Math.abs(N)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:L}=await P.render(T,e);c(L),m(L);}catch(P){if(!(d||l)){let N=P instanceof Error?P.message:"Failed to render Mermaid chart";s(N);}}finally{i(false);}})();},[e,n,p]),a&&!l&&!d)return jsx("div",{className:f("my-4 flex justify-center p-4",t),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&&!d){let k=()=>h(P=>P+1);return g?jsx(g,{chart:e,error:r,retry:k}):jsxs("div",{className:f("rounded-lg border border-red-200 bg-red-50 p-4",t),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 w=l||d;return jsx(kn,{className:f(o?"h-full w-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:o,maxZoom:3,minZoom:.5,showControls:true,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:f("flex justify-center",o&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:w},role:"img"})})};export{f as a,Ln as b,ot as c,qe as d,Fe as e,kr as f,vr as g,M as h,gn as i,Tr as j};
@@ -0,0 +1,21 @@
1
+ 'use strict';var react=require('react'),rehypeHarden=require('rehype-harden'),Ue=require('rehype-katex'),gr=require('rehype-raw'),br=require('remark-cjk-friendly'),yr=require('remark-cjk-friendly-gfm-strikethrough'),wr=require('remark-gfm'),We=require('remark-math'),Rn=require('lucide-react/dist/esm/icons/check'),jn=require('lucide-react/dist/esm/icons/copy'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime'),zn=require('lucide-react/dist/esm/icons/download'),_n=require('lucide-react/dist/esm/icons/loader-2'),Yn=require('lucide-react/dist/esm/icons/maximize-2'),Qn=require('lucide-react/dist/esm/icons/x'),hastUtilToJsxRuntime=require('hast-util-to-jsx-runtime'),Io=require('remark-parse'),So=require('remark-rehype'),E=require('path'),nn=require('process'),url=require('url'),marked=require('marked'),Nr=require('lucide-react/dist/esm/icons/rotate-ccw'),Ir=require('lucide-react/dist/esm/icons/zoom-in'),Sr=require('lucide-react/dist/esm/icons/zoom-out');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Ue__default=/*#__PURE__*/_interopDefault(Ue);var gr__default=/*#__PURE__*/_interopDefault(gr);var br__default=/*#__PURE__*/_interopDefault(br);var yr__default=/*#__PURE__*/_interopDefault(yr);var wr__default=/*#__PURE__*/_interopDefault(wr);var We__default=/*#__PURE__*/_interopDefault(We);var Rn__default=/*#__PURE__*/_interopDefault(Rn);var jn__default=/*#__PURE__*/_interopDefault(jn);var zn__default=/*#__PURE__*/_interopDefault(zn);var _n__default=/*#__PURE__*/_interopDefault(_n);var Yn__default=/*#__PURE__*/_interopDefault(Yn);var Qn__default=/*#__PURE__*/_interopDefault(Qn);var Io__default=/*#__PURE__*/_interopDefault(Io);var So__default=/*#__PURE__*/_interopDefault(So);var E__default=/*#__PURE__*/_interopDefault(E);var nn__default=/*#__PURE__*/_interopDefault(nn);var Nr__default=/*#__PURE__*/_interopDefault(Nr);var Ir__default=/*#__PURE__*/_interopDefault(Ir);var Sr__default=/*#__PURE__*/_interopDefault(Sr);var vn=Object.create;var Ve=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var Mn=Object.getOwnPropertyNames;var xn=Object.getPrototypeOf,Pn=Object.prototype.hasOwnProperty;var Tn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Nn=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Mn(t))!Pn.call(e,r)&&r!==n&&Ve(e,r,{get:()=>t[r],enumerable:!(o=Cn(t,r))||o.enumerable});return e};var In=(e,t,n)=>(n=e!=null?vn(xn(e)):{},Nn(Ve(n,"default",{value:e,enumerable:true}),e));var Yt=Tn((ni,Gt)=>{var de=Object.prototype.hasOwnProperty,Zt=Object.prototype.toString,Ut=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,Vt=function(t){return typeof Array.isArray=="function"?Array.isArray(t):Zt.call(t)==="[object Array]"},Xt=function(t){if(!t||Zt.call(t)!=="[object Object]")return false;var n=de.call(t,"constructor"),o=t.constructor&&t.constructor.prototype&&de.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!o)return false;var r;for(r in t);return typeof r=="undefined"||de.call(t,r)},Jt=function(t,n){Ut&&n.name==="__proto__"?Ut(t,n.name,{enumerable:true,configurable:true,value:n.newValue,writable:true}):t[n.name]=n.newValue;},Kt=function(t,n){if(n==="__proto__")if(de.call(t,n)){if(Wt)return Wt(t,n).value}else return;return t[n]};Gt.exports=function e(){var t,n,o,r,s,a,i=arguments[0],l=1,c=arguments.length,d=false;for(typeof i=="boolean"&&(d=i,i=arguments[1]||{},l=2),(i==null||typeof i!="object"&&typeof i!="function")&&(i={});l<c;++l)if(t=arguments[l],t!=null)for(n in t)o=Kt(i,n),r=Kt(t,n),i!==r&&(d&&r&&(Xt(r)||(s=Vt(r)))?(s?(s=false,a=o&&Vt(o)?o:[]):a=o&&Xt(o)?o:{},Jt(i,{name:n,newValue:e(d,a,r)})):typeof r!="undefined"&&Jt(i,{name:n,newValue:r}));return i};});var f=(...e)=>tailwindMerge.twMerge(clsx.clsx(e)),A=(e,t,n)=>{let o=typeof t=="string"?new Blob([t],{type:n}):t,r=URL.createObjectURL(o),s=document.createElement("a");s.href=r,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r);};var Ln=react.createContext({code:""}),te=()=>react.useContext(Ln);var be=({onCopy:e,onError:t,timeout:n=2e3,children:o,className:r,code:s,...a})=>{let[i,l]=react.useState(false),c=react.useRef(0),{code:d}=te(),{isAnimating:m}=react.useContext(M),p=s!=null?s:d,h=async()=>{var g;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(p),l(!0),e==null||e(),c.current=window.setTimeout(()=>l(!1),n));}catch(w){t==null||t(w);}};react.useEffect(()=>()=>{window.clearTimeout(c.current);},[]);let u=i?Rn__default.default:jn__default.default;return jsxRuntime.jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:h,type:"button",...a,children:o!=null?o:jsxRuntime.jsx(u,{size:14})})};var Je={"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"},Ze=({onDownload:e,onError:t,language:n,children:o,className:r,code:s,...a})=>{let{code:i}=te(),{isAnimating:l}=react.useContext(M),c=s!=null?s:i,m=`file.${n&&n in Je?Je[n]:"txt"}`,p="text/plain",h=()=>{try{A(m,c,p),e==null||e();}catch(u){t==null||t(u);}};return jsxRuntime.jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:l,onClick:h,title:"Download file",type:"button",...a,children:o!=null?o:jsxRuntime.jsx(zn__default.default,{size:14})})};var we=()=>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(_n__default.default,{className:"size-4 animate-spin"})})]});var Wn=/\.[^/.]+$/,Ge=({node:e,className:t,src:n,alt:o,...r})=>{let s=async()=>{if(n)try{let i=await(await fetch(n)).blob(),c=new URL(n,window.location.origin).pathname.split("/").pop()||"",d=c.split(".").pop(),m=c.includes(".")&&d!==void 0&&d.length<=4,p="";if(m)p=c;else {let h=i.type,u="png";h.includes("jpeg")||h.includes("jpg")?u="jpg":h.includes("png")?u="png":h.includes("svg")?u="svg":h.includes("gif")?u="gif":h.includes("webp")&&(u="webp"),p=`${(o||c||"image").replace(Wn,"")}.${u}`;}A(p,i,i.type);}catch(a){console.error("Failed to download image:",a);}};return n?jsxRuntime.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsxRuntime.jsx("img",{alt:o,className:f("max-w-full rounded-lg",t),"data-streamdown":"image",src:n,...r}),jsxRuntime.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsxRuntime.jsx("button",{className:f("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(zn__default.default,{size:14})})]}):null};var oe=async e=>{let n={...{startOnLoad:false,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:true},...e},r=(await import('mermaid')).default;return r.initialize(n),r},Ye=(e,t)=>{var o;let n=(o=void 0)!=null?o:5;return new Promise((r,s)=>{let a="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let l=document.createElement("canvas"),c=i.width*n,d=i.height*n;l.width=c,l.height=d;let m=l.getContext("2d");if(!m){s(new Error("Failed to create 2D canvas context for PNG export"));return}m.drawImage(i,0,0,c,d),l.toBlob(p=>{if(!p){s(new Error("Failed to create PNG blob"));return}r(p);},"image/png");},i.onerror=()=>s(new Error("Failed to load SVG image")),i.src=a;})};var et=({chart:e,children:t,className:n,onDownload:o,config:r,onError:s})=>{let[a,i]=react.useState(false),l=react.useRef(null),{isAnimating:c}=react.useContext(M),d=async m=>{try{if(m==="mmd"){A("diagram.mmd",e,"text/plain"),i(!1),o==null||o(m);return}let p=await oe(r),h=e.split("").reduce((w,k)=>(w<<5)-w+k.charCodeAt(0)|0,0),u=`mermaid-${Math.abs(h)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:g}=await p.render(u,e);if(!g){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(m==="svg"){A("diagram.svg",g,"image/svg+xml"),i(!1),o==null||o(m);return}if(m==="png"){let w=await Ye(g);A("diagram.png",w,"image/png"),o==null||o(m),i(!1);return}}catch(p){s==null||s(p);}};return react.useEffect(()=>{let m=p=>{l.current&&!l.current.contains(p.target)&&i(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:l,children:[jsxRuntime.jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:c,onClick:()=>i(!a),title:"Download diagram",type:"button",children:t!=null?t:jsxRuntime.jsx(zn__default.default,{size:14})}),a&&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:()=>d("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:()=>d("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:()=>d("mmd"),type:"button",children:"MMD"})]})]})};var J=0,no=()=>{J+=1,J===1&&(document.body.style.overflow="hidden");},oo=()=>{J=Math.max(0,J-1),J===0&&(document.body.style.overflow="");},rt=({chart:e,config:t,onFullscreen:n,onExit:o,className:r,...s})=>{let[a,i]=react.useState(false),{isAnimating:l}=react.useContext(M),c=()=>{i(!a);};return react.useEffect(()=>{if(a){no();let d=m=>{m.key==="Escape"&&i(false);};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),oo();}}},[a]),react.useEffect(()=>{a?n==null||n():o&&o();},[a,n,o]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:l,onClick:c,title:"View fullscreen",type:"button",...s,children:jsxRuntime.jsx(Yn__default.default,{size:14})}),a&&jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:c,onKeyDown:d=>{d.key==="Escape"&&c();},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:c,title:"Exit fullscreen",type:"button",children:jsxRuntime.jsx(Qn__default.default,{size:20})}),jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:d=>d.stopPropagation(),onKeyDown:d=>d.stopPropagation(),role:"presentation",children:jsxRuntime.jsx(ot,{chart:e,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:true})})]})]})};var re=e=>{var s,a;let t=[],n=[],o=e.querySelectorAll("thead th");for(let i of o)t.push(((s=i.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let i of r){let l=[],c=i.querySelectorAll("td");for(let d of c)l.push(((a=d.textContent)==null?void 0:a.trim())||"");n.push(l);}return {headers:t,rows:n}},se=e=>{let{headers:t,rows:n}=e,o=i=>{let l=false,c=false;for(let d=0;d<i.length;d+=1){let m=i[d];if(m==='"'){l=true,c=true;break}(m===","||m===`
2
+ `)&&(l=true);}return l?c?`"${i.replace(/"/g,'""')}"`:`"${i}"`:i},r=t.length>0?n.length+1:n.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(o).join(","),a+=1);for(let i of n)s[a]=i.map(o).join(","),a+=1;return s.join(`
3
+ `)},st=e=>{let{headers:t,rows:n}=e,o=i=>{let l=false;for(let d=0;d<i.length;d+=1){let m=i[d];if(m===" "||m===`
4
+ `||m==="\r"){l=true;break}}if(!l)return i;let c=[];for(let d=0;d<i.length;d+=1){let m=i[d];m===" "?c.push("\\t"):m===`
5
+ `?c.push("\\n"):m==="\r"?c.push("\\r"):c.push(m);}return c.join("")},r=t.length>0?n.length+1:n.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(o).join(" "),a+=1);for(let i of n)s[a]=i.map(o).join(" "),a+=1;return s.join(`
6
+ `)},ke=e=>{let t=false;for(let o=0;o<e.length;o+=1){let r=e[o];if(r==="\\"||r==="|"){t=true;break}}if(!t)return e;let n=[];for(let o=0;o<e.length;o+=1){let r=e[o];r==="\\"?n.push("\\\\"):r==="|"?n.push("\\|"):n.push(r);}return n.join("")},it=e=>{let{headers:t,rows:n}=e;if(t.length===0)return "";let o=new Array(n.length+2),r=0,s=t.map(i=>ke(i));o[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let i=0;i<t.length;i+=1)a[i]="---";o[r]=`| ${a.join(" | ")} |`,r+=1;for(let i of n)if(i.length<t.length){let l=new Array(t.length);for(let c=0;c<t.length;c+=1)l[c]=c<i.length?ke(i[c]):"";o[r]=`| ${l.join(" | ")} |`,r+=1;}else {let l=i.map(c=>ke(c));o[r]=`| ${l.join(" | ")} |`,r+=1;}return o.join(`
7
+ `)};var dt=({children:e,className:t,onCopy:n,onError:o,timeout:r=2e3})=>{let[s,a]=react.useState(false),[i,l]=react.useState(false),c=react.useRef(null),d=react.useRef(0),{isAnimating:m}=react.useContext(M),p=async u=>{var g,w;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.write)){o==null||o(new Error("Clipboard API not available"));return}try{let k=(w=c.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),P=k==null?void 0:k.querySelector("table");if(!P){o==null||o(new Error("Table not found"));return}let N=re(P),T=u==="csv"?se(N):st(N),L=new ClipboardItem({"text/plain":new Blob([T],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([L]),l(!0),a(!1),n==null||n(u),d.current=window.setTimeout(()=>l(!1),r);}catch(k){o==null||o(k);}};react.useEffect(()=>{let u=g=>{c.current&&!c.current.contains(g.target)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u),window.clearTimeout(d.current);}},[]);let h=i?Rn__default.default:jn__default.default;return jsxRuntime.jsxs("div",{className:"relative",ref:c,children:[jsxRuntime.jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>a(!s),title:"Copy table",type:"button",children:e!=null?e:jsxRuntime.jsx(h,{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"),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"),type:"button",children:"TSV"})]})]})};var pt=({children:e,className:t,onDownload:n,onError:o})=>{let[r,s]=react.useState(false),a=react.useRef(null),{isAnimating:i}=react.useContext(M),l=c=>{var d;try{let m=(d=a.current)==null?void 0:d.closest('[data-streamdown="table-wrapper"]'),p=m==null?void 0:m.querySelector("table");if(!p){o==null||o(new Error("Table not found"));return}let h=re(p),u=c==="csv"?se(h):it(h);A(`table.${c==="csv"?"csv":"md"}`,u,c==="csv"?"text/csv":"text/markdown"),s(!1),n==null||n(c);}catch(m){o==null||o(m);}};return react.useEffect(()=>{let c=d=>{a.current&&!a.current.contains(d.target)&&s(false);};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:a,children:[jsxRuntime.jsx("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>s(!r),title:"Download table",type:"button",children:e!=null?e:jsxRuntime.jsx(zn__default.default,{size:14})}),r&&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:()=>l("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:()=>l("markdown"),type:"button",children:"Markdown"})]})]})};var ft=({children:e,className:t,showControls:n,...o})=>jsxRuntime.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[n&&jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsxRuntime.jsx(dt,{}),jsxRuntime.jsx(pt,{})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsx("table",{className:f("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var ho=react.lazy(()=>import('./code-block-ZXCJA7QC.cjs').then(e=>({default:e.CodeBlock}))),go=react.lazy(()=>import('./mermaid-5BLLS6T5.cjs').then(e=>({default:e.Mermaid}))),bo=/language-([^\s]+)/;function ce(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 n=e.position.start,o=t.position.start,r=e.position.end,s=t.position.end;return (n==null?void 0:n.line)===(o==null?void 0:o.line)&&(n==null?void 0:n.column)===(o==null?void 0:o.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function C(e,t){return e.className===t.className&&ce(e.node,t.node)}var Me=(e,t)=>typeof e=="boolean"?e:e[t]!==false,ve=(e,t)=>{if(typeof e=="boolean")return e;let n=e.mermaid;return n===false?false:n===true||n===void 0?true:n[t]!==false},xe=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("ol",{className:f("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>C(e,t));xe.displayName="MarkdownOl";var yt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("li",{className:f("py-1",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&ce(e.node,t.node));yt.displayName="MarkdownLi";var wt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("ul",{className:f("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>C(e,t));wt.displayName="MarkdownUl";var kt=react.memo(({className:e,node:t,...n})=>jsxRuntime.jsx("hr",{className:f("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>C(e,t));kt.displayName="MarkdownHr";var vt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("span",{className:f("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>C(e,t));vt.displayName="MarkdownStrong";var Ct=react.memo(({children:e,className:t,href:n,node:o,...r})=>{let s=n==="streamdown:incomplete-link";return jsxRuntime.jsx("a",{className:f("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":s,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...r,children:e})},(e,t)=>C(e,t)&&e.href===t.href);Ct.displayName="MarkdownA";var Mt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h1",{className:f("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>C(e,t));Mt.displayName="MarkdownH1";var xt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h2",{className:f("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>C(e,t));xt.displayName="MarkdownH2";var Pt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h3",{className:f("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>C(e,t));Pt.displayName="MarkdownH3";var Tt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h4",{className:f("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>C(e,t));Tt.displayName="MarkdownH4";var Nt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h5",{className:f("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>C(e,t));Nt.displayName="MarkdownH5";var It=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("h6",{className:f("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>C(e,t));It.displayName="MarkdownH6";var St=react.memo(({children:e,className:t,node:n,...o})=>{let{controls:r}=react.useContext(M),s=Me(r,"table");return jsxRuntime.jsx(ft,{className:t,"data-streamdown":"table-wrapper",showControls:s,...o,children:e})},(e,t)=>C(e,t));St.displayName="MarkdownTable";var Et=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("thead",{className:f("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>C(e,t));Et.displayName="MarkdownThead";var At=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("tbody",{className:f("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>C(e,t));At.displayName="MarkdownTbody";var Bt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("tr",{className:f("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>C(e,t));Bt.displayName="MarkdownTr";var Lt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("th",{className:f("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>C(e,t));Lt.displayName="MarkdownTh";var Rt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("td",{className:f("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>C(e,t));Rt.displayName="MarkdownTd";var jt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("blockquote",{className:f("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>C(e,t));jt.displayName="MarkdownBlockquote";var Dt=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("sup",{className:f("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>C(e,t));Dt.displayName="MarkdownSup";var $t=react.memo(({children:e,className:t,node:n,...o})=>jsxRuntime.jsx("sub",{className:f("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>C(e,t));$t.displayName="MarkdownSub";var Ot=react.memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let s=l=>{var p,h;if(!react.isValidElement(l))return false;let c=Array.isArray(l.props.children)?l.props.children:[l.props.children],d=false,m=false;for(let u of c)if(u){if(typeof u=="string")u.trim()!==""&&(d=true);else if(react.isValidElement(u))if(((p=u.props)==null?void 0:p["data-footnote-backref"])!==void 0)m=true;else {let g=Array.isArray(u.props.children)?u.props.children:[u.props.children];for(let w of g){if(typeof w=="string"&&w.trim()!==""){d=true;break}if(react.isValidElement(w)&&((h=w.props)==null?void 0:h["data-footnote-backref"])===void 0){d=true;break}}}}return m&&!d},a=Array.isArray(e)?e.map(l=>{if(!react.isValidElement(l))return l;if(l.type===xe){let d=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!s(m));return d.length===0?null:{...l,props:{...l.props,children:d}}}return l}):e;return (Array.isArray(a)?a.some(l=>l!==null):a!==null)?jsxRuntime.jsx("section",{className:t,...o,children:a}):null}return jsxRuntime.jsx("section",{className:t,...o,children:e})},(e,t)=>C(e,t));Ot.displayName="MarkdownSection";var yo=({node:e,className:t,children:n,...o})=>{var m,p,h;let r=((m=e==null?void 0:e.position)==null?void 0:m.start.line)===((p=e==null?void 0:e.position)==null?void 0:p.end.line),{mermaid:s,controls:a}=react.useContext(M);if(r)return jsxRuntime.jsx("code",{className:f("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:n});let i=t==null?void 0:t.match(bo),l=(h=i==null?void 0:i.at(1))!=null?h:"",c="";if(react.isValidElement(n)&&n.props&&typeof n.props=="object"&&"children"in n.props&&typeof n.props.children=="string"?c=n.props.children:typeof n=="string"&&(c=n),l==="mermaid"){let u=Me(a,"mermaid"),g=ve(a,"download"),w=ve(a,"copy"),k=ve(a,"fullscreen");return jsxRuntime.jsxs("div",{className:f("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[u&&(g||w||k)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2",children:[g&&jsxRuntime.jsx(et,{chart:c,config:s==null?void 0:s.config}),w&&jsxRuntime.jsx(be,{code:c}),k&&jsxRuntime.jsx(rt,{chart:c,config:s==null?void 0:s.config})]}),jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(we,{}),children:jsxRuntime.jsx(go,{chart:c,config:s==null?void 0:s.config})})]})}let d=Me(a,"code");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(we,{}),children:jsxRuntime.jsx(ho,{className:f("overflow-x-auto border-border border-t",t),code:c,"data-language":l,"data-streamdown":"code-block",language:l,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ze,{code:c,language:l}),jsxRuntime.jsx(be,{})]})})})},Ht=react.memo(yo,(e,t)=>e.className===t.className&&ce(e.node,t.node));Ht.displayName="MarkdownCode";var zt=react.memo(Ge,(e,t)=>e.className===t.className&&ce(e.node,t.node));zt.displayName="MarkdownImg";var qt=react.memo(({children:e,className:t,node:n,...o})=>{var a;let s=(Array.isArray(e)?e:[e]).filter(i=>i!=null&&i!=="");return s.length===1&&react.isValidElement(s[0])&&((a=s[0].props.node)==null?void 0:a.tagName)==="img"?jsxRuntime.jsx(jsxRuntime.Fragment,{children:e}):jsxRuntime.jsx("p",{className:t,...o,children:e})},(e,t)=>C(e,t));qt.displayName="MarkdownParagraph";var _t={ol:xe,li:yt,ul:wt,hr:kt,strong:vt,a:Ct,h1:Mt,h2:xt,h3:Pt,h4:Tt,h5:Nt,h6:It,table:St,thead:Et,tbody:At,tr:Bt,th:Lt,td:Rt,blockquote:jt,code:Ht,img:zt,pre:({children:e})=>e,sup:Dt,sub:$t,p:qt,section:Ot};function Pe(e){if(e)throw e}var ue=In(Yt());function K(e){if(typeof e!="object"||e===null)return false;let t=Object.getPrototypeOf(e);return (t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Te(){let e=[],t={run:n,use:o};return t;function n(...r){let s=-1,a=r.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);i(null,...r);function i(l,...c){let d=e[++s],m=-1;if(l){a(l);return}for(;++m<r.length;)(c[m]===null||c[m]===void 0)&&(c[m]=r[m]);r=c,d?Qt(d,i)(...c):a(null,...c);}}function o(r){if(typeof r!="function")throw new TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),t}}function Qt(e,t){let n;return o;function o(...a){let i=e.length>a.length,l;i&&a.push(r);try{l=e.apply(this,a);}catch(c){let d=c;if(i&&n)throw d;return r(d)}i||(l&&l.then&&typeof l.then=="function"?l.then(s,r):l instanceof Error?r(l):s(l));}function r(a,...i){n||(n=true,t(a,...i));}function s(a){r(null,a);}}function Ie(e){return !e||typeof e!="object"?"":"position"in e||"type"in e?en(e.position):"start"in e||"end"in e?en(e):"line"in e||"column"in e?Ne(e):""}function Ne(e){return tn(e&&e.line)+":"+tn(e&&e.column)}function en(e){return Ne(e&&e.start)+"-"+Ne(e&&e.end)}function tn(e){return e&&typeof e=="number"?e:1}var x=class extends Error{constructor(t,n,o){super(),typeof n=="string"&&(o=n,n=void 0);let r="",s={},a=false;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?r=t:!s.cause&&t&&(a=true,r=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof o=="string"){let l=o.indexOf(":");l===-1?s.ruleId=o:(s.source=o.slice(0,l),s.ruleId=o.slice(l+1));}if(!s.place&&s.ancestors&&s.ancestors){let l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position);}let i=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=i?i.line:void 0,this.name=Ie(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0;}};x.prototype.file="";x.prototype.name="";x.prototype.reason="";x.prototype.message="";x.prototype.stack="";x.prototype.column=void 0;x.prototype.line=void 0;x.prototype.ancestors=void 0;x.prototype.cause=void 0;x.prototype.fatal=void 0;x.prototype.place=void 0;x.prototype.ruleId=void 0;x.prototype.source=void 0;function me(e){return !!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}var Se=["history","path","basename","stem","extname","dirname"],Z=class{constructor(t){let n;t?me(t)?n={path:t}:typeof t=="string"||wo(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":nn__default.default.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let o=-1;for(;++o<Se.length;){let s=Se[o];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s]);}let r;for(r in n)Se.includes(r)||(this[r]=n[r]);}get basename(){return typeof this.path=="string"?E__default.default.basename(this.path):void 0}set basename(t){Ae(t,"basename"),Ee(t,"basename"),this.path=E__default.default.join(this.dirname||"",t);}get dirname(){return typeof this.path=="string"?E__default.default.dirname(this.path):void 0}set dirname(t){rn(this.basename,"dirname"),this.path=E__default.default.join(t||"",this.basename);}get extname(){return typeof this.path=="string"?E__default.default.extname(this.path):void 0}set extname(t){if(Ee(t,"extname"),rn(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=E__default.default.join(this.dirname,this.stem+(t||""));}get path(){return this.history[this.history.length-1]}set path(t){me(t)&&(t=url.fileURLToPath(t)),Ae(t,"path"),this.path!==t&&this.history.push(t);}get stem(){return typeof this.path=="string"?E__default.default.basename(this.path,this.extname):void 0}set stem(t){Ae(t,"stem"),Ee(t,"stem"),this.path=E__default.default.join(this.dirname||"",t+(this.extname||""));}fail(t,n,o){let r=this.message(t,n,o);throw r.fatal=true,r}info(t,n,o){let r=this.message(t,n,o);return r.fatal=void 0,r}message(t,n,o){let r=new x(t,n,o);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=false,this.messages.push(r),r}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}};function Ee(e,t){if(e&&e.includes(E__default.default.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+E__default.default.sep+"`")}function Ae(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function rn(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function wo(e){return !!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var sn=(function(e){let o=this.constructor.prototype,r=o[e],s=function(){return r.apply(s,arguments)};return Object.setPrototypeOf(s,o),s});var ko={}.hasOwnProperty,je=class e extends sn{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Te();}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let o=this.attachers[n];t.use(...o);}return t.data((0, ue.default)(true,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Re("data",this.frozen),this.namespace[t]=n,this):ko.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Re("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[n,...o]=this.attachers[this.freezeIndex];if(o[0]===false)continue;o[0]===true&&(o[0]=void 0);let r=n.call(t,...o);typeof r=="function"&&this.transformers.use(r);}return this.frozen=true,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let n=pe(t),o=this.parser||this.Parser;return Be("parse",o),o(String(n),n)}process(t,n){let o=this;return this.freeze(),Be("process",this.parser||this.Parser),Le("process",this.compiler||this.Compiler),n?r(void 0,n):new Promise(r);function r(s,a){let i=pe(t),l=o.parse(i);o.run(l,i,function(d,m,p){if(d||!m||!p)return c(d);let h=m,u=o.stringify(h,p);Co(u)?p.value=u:p.result=u,c(d,p);});function c(d,m){d||!m?a(d):s?s(m):n(void 0,m);}}}processSync(t){let n=false,o;return this.freeze(),Be("processSync",this.parser||this.Parser),Le("processSync",this.compiler||this.Compiler),this.process(t,r),ln("processSync","process",n),o;function r(s,a){n=true,Pe(s),o=a;}}run(t,n,o){an(t),this.freeze();let r=this.transformers;return !o&&typeof n=="function"&&(o=n,n=void 0),o?s(void 0,o):new Promise(s);function s(a,i){let l=pe(n);r.run(t,l,c);function c(d,m,p){let h=m||t;d?i(d):a?a(h):o(void 0,h,p);}}}runSync(t,n){let o=false,r;return this.run(t,n,s),ln("runSync","run",o),r;function s(a,i){Pe(a),r=i,o=true;}}stringify(t,n){this.freeze();let o=pe(n),r=this.compiler||this.Compiler;return Le("stringify",r),an(t),r(t,o)}use(t,...n){let o=this.attachers,r=this.namespace;if(Re("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?i(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[d,...m]=c;l(d,m);}else a(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function a(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(c.plugins),c.settings&&(r.settings=(0, ue.default)(true,r.settings,c.settings));}function i(c){let d=-1;if(c!=null)if(Array.isArray(c))for(;++d<c.length;){let m=c[d];s(m);}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,d){let m=-1,p=-1;for(;++m<o.length;)if(o[m][0]===c){p=m;break}if(p===-1)o.push([c,...d]);else if(d.length>0){let[h,...u]=d,g=o[p][1];K(g)&&K(h)&&(h=(0, ue.default)(true,g,h)),o[p]=[c,h,...u];}}}},De=new je().freeze();function Be(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Le(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Re(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function an(e){if(!K(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function ln(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function pe(e){return vo(e)?e:new Z(e)}function vo(e){return !!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Co(e){return typeof e=="string"||Mo(e)}function Mo(e){return !!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var cn=[],dn={allowDangerousHtml:true},fe=new WeakMap,$e=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(o||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return "";let p="";for(let h=0;h<m.length;h+=1){let u=m[h];if(h>0&&(p+=","),Array.isArray(u)){let[g,w]=u;if(typeof g=="function"){let k=fe.get(g);k||(k=g.name,fe.set(g,k)),p+=k;}else p+=String(g);p+=":",p+=JSON.stringify(w);}else if(typeof u=="function"){let g=fe.get(u);g||(g=u.name,fe.set(u,g)),p+=g;}else p+=String(u);}return p},i=a(o),l=a(r),c=s?JSON.stringify(s):"",d=`${l}::${i}::${c}`;return this.keyCache.set(t,d),d}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(o,n);}clear(){this.cache.clear();}},mn=new $e,Oe=e=>{let t=Eo(e),n=e.children||"";return Bo(t.runSync(t.parse(n),n),e)},Eo=e=>{let t=mn.get(e);if(t)return t;let n=Ao(e);return mn.set(e,n),n},Ao=e=>{let t=e.rehypePlugins||cn,n=e.remarkPlugins||cn,o=e.remarkRehypeOptions?{...dn,...e.remarkRehypeOptions}:dn;return De().use(Io__default.default).use(n).use(So__default.default,o).use(t)},Bo=(e,t)=>hastUtilToJsxRuntime.toJsxRuntime(e,{Fragment:jsxRuntime.Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsxRuntime.jsx,jsxs:jsxRuntime.jsxs,passKeys:true,passNode:true});var Ro=/\[\^[^\]\s]{1,200}\](?!:)/,jo=/\[\^[^\]\s]{1,200}\]:/,Do=/<\/(\w+)>/,$o=/<(\w+)[\s>]/,He=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
8
+ `||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},Oo=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
9
+ `||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},ze=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]==="$"&&e[n+1]==="$"&&(t+=1,n+=1);return t},qe=e=>{let t=Ro.test(e),n=jo.test(e);if(t||n)return [e];let o=marked.Lexer.lex(e,{gfm:true}),r=[],s=[];for(let a of o){let i=a.raw,l=r.length;if(s.length>0){if(r[l-1]+=i,a.type==="html"){let d=i.match(Do);if(d){let m=d[1];s.at(-1)===m&&s.pop();}}continue}if(a.type==="html"&&a.block){let d=i.match($o);if(d){let m=d[1];i.includes(`</${m}>`)||s.push(m);}}if(i.trim()==="$$"&&l>0){let d=r[l-1],m=He(d),p=ze(d);if(m&&p%2===1){r[l-1]=d+i;continue}}if(l>0&&Oo(i)){let d=r[l-1],m=He(d),p=ze(d),h=ze(i);if(m&&p%2===1&&!He(i)&&h===1){r[l-1]=d+i;continue}}r.push(i);}return r};var Ho=/(\*\*)([^*]*?)$/,zo=/(__)([^_]*?)$/,qo=/(\*\*\*)([^*]*?)$/,_o=/(\*)([^*]*?)$/,Fo=/(_)([^_]*?)$/,Uo=/(`)([^`]*?)$/,Wo=/(~~)([^~]*?)$/,q=/^[\s_~*`]*$/,pn=/^[\s]*[-*+][\s]+$/,Vo=/[\p{L}\p{N}_]/u,Xo=/^```[^`\n]*```?$/,Jo=/^\*{4,}$/,j=e=>{if(!e)return false;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?true:Vo.test(e)},he=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
10
+ `)};var Ko=(e,t)=>{let n=1;for(let o=t-1;o>=0;o-=1)if(e[o]==="]")n+=1;else if(e[o]==="["&&(n-=1,n===0))return o;return -1},Zo=(e,t)=>{let n=1;for(let o=t+1;o<e.length;o+=1)if(e[o]==="[")n+=1;else if(e[o]==="]"&&(n-=1,n===0))return o;return -1},_e=(e,t)=>{let n=false,o=false;for(let r=0;r<t;r+=1){if(e.substring(r,r+3)==="```"){o=!o,r+=2;continue}!o&&e[r]==="`"&&(n=!n);}return n||o},Go=e=>{let t=e.lastIndexOf("](");if(t!==-1&&!_e(e,t)&&!e.substring(t+2).includes(")")){let o=Ko(e,t);if(o!==-1&&!_e(e,o)){let r=o>0&&e[o-1]==="!",s=r?o-1:o,a=e.substring(0,s),i=e.substring(o+1,t);return r?a:`${a}[${i}](streamdown:incomplete-link)`}}for(let n=e.length-1;n>=0;n-=1)if(e[n]==="["&&!_e(e,n)){let o=n>0&&e[n-1]==="!",r=o?n-1:n;if(!e.substring(n+1).includes("]")){let i=e.substring(0,r);return o?i:`${e}](streamdown:incomplete-link)`}if(Zo(e,n)===-1){let i=e.substring(0,r);return o?i:`${e}](streamdown:incomplete-link)`}}return e},Yo=e=>{if(he(e))return e;let t=e.match(Ho);if(t){let n=t[2];if(!n||q.test(n))return e;let o=e.lastIndexOf(t[1]),s=e.substring(0,o).lastIndexOf(`
11
+ `),a=s===-1?0:s+1,i=e.substring(a,o);if(pn.test(i)&&n.includes(`
12
+ `))return e;if((e.match(/\*\*/g)||[]).length%2===1)return `${e}**`}return e},Qo=e=>{let t=e.match(zo);if(t){let n=t[2];if(!n||q.test(n))return e;let o=e.lastIndexOf(t[1]),s=e.substring(0,o).lastIndexOf(`
13
+ `),a=s===-1?0:s+1,i=e.substring(a,o);if(pn.test(i)&&n.includes(`
14
+ `))return e;if((e.match(/__/g)||[]).length%2===1)return `${e}__`}return e},er=e=>{let t=0,n=e.length;for(let o=0;o<n;o+=1){if(e[o]!=="*")continue;let r=o>0?e[o-1]:"",s=o<n-1?e[o+1]:"";if(r==="\\"||r==="*"||s==="*"||r&&s&&j(r)&&j(s))continue;let a=0;for(let l=o-1;l>=0;l-=1)if(e[l]===`
15
+ `){a=l+1;break}let i=true;for(let l=a;l<o;l+=1)if(e[l]!==" "&&e[l]!==" "){i=false;break}i&&(s===" "||s===" ")||(t+=1);}return t},tr=e=>{if(he(e))return e;if(e.match(_o)){let n=-1;for(let s=0;s<e.length;s+=1)if(e[s]==="*"&&e[s-1]!=="*"&&e[s+1]!=="*"&&e[s-1]!=="\\"){let a=s>0?e[s-1]:"",i=s<e.length-1?e[s+1]:"";if(a&&i&&j(a)&&j(i))continue;n=s;break}if(n===-1)return e;let o=e.substring(n+1);if(!o||q.test(o))return e;if(er(e)%2===1)return `${e}*`}return e},un=(e,t)=>{let n=false,o=false;for(let r=0;r<e.length&&r<t;r+=1){if(e[r]==="\\"&&e[r+1]==="$"){r+=1;continue}e[r]==="$"&&(e[r+1]==="$"?(o=!o,r+=1,n=false):o||(n=!n));}return n||o},nr=e=>{let t=e.includes("$"),n=0,o=e.length;for(let r=0;r<o;r+=1){if(e[r]!=="_")continue;let s=r>0?e[r-1]:"",a=r<o-1?e[r+1]:"";s!=="\\"&&(t&&un(e,r)||s==="_"||a==="_"||s&&a&&j(s)&&j(a)||(n+=1));}return n},or=e=>{if(he(e))return e;if(e.match(Fo)){let n=-1;for(let s=0;s<e.length;s+=1)if(e[s]==="_"&&e[s-1]!=="_"&&e[s+1]!=="_"&&e[s-1]!=="\\"&&!un(e,s)){let a=s>0?e[s-1]:"",i=s<e.length-1?e[s+1]:"";if(a&&i&&j(a)&&j(i))continue;n=s;break}if(n===-1)return e;let o=e.substring(n+1);if(!o||q.test(o))return e;if(nr(e)%2===1){let s=e.length;for(;s>0&&e[s-1]===`
16
+ `;)s-=1;if(s<e.length){let a=e.slice(0,s),i=e.slice(s);return `${a}_${i}`}return `${e}_`}}return e},rr=(e,t)=>{let n=e.substring(t,t+3)==="```",o=t>0&&e.substring(t-1,t+2)==="```",r=t>1&&e.substring(t-2,t+1)==="```";return n||o||r},sr=e=>{let t=0;for(let n=0;n<e.length;n+=1)e[n]==="`"&&!rr(e,n)&&(t+=1);return t},ir=e=>{if(e.match(Xo)&&!e.includes(`
17
+ `))return e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e;let n=(e.match(/```/g)||[]).length,o=n%2===1;if(n>0&&n%2===0&&e.includes(`
18
+ `)||(e.endsWith("```\n")||e.endsWith("```"))&&n%2===0)return e;let r=e.match(Uo);if(r&&!o){let s=r[2];if(!s||q.test(s))return e;if(sr(e)%2===1)return `${e}\``}return e},ar=e=>{let t=e.match(Wo);if(t){let n=t[2];if(!n||q.test(n))return e;if((e.match(/~~/g)||[]).length%2===1)return `${e}~~`}return e},lr=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let n=e.indexOf("$$");return n!==-1&&e.indexOf(`
19
+ `,n)!==-1&&!e.endsWith(`
20
+ `)?`${e}
21
+ $$`:`${e}$$`},cr=e=>{let t=0,n=0;for(let o=0;o<e.length;o+=1)e[o]==="*"?n+=1:(n>=3&&(t+=Math.floor(n/3)),n=0);return n>=3&&(t+=Math.floor(n/3)),t},dr=e=>{if(he(e)||Jo.test(e))return e;let t=e.match(qo);if(t){let n=t[2];if(!n||q.test(n))return e;if(cr(e)%2===1)return `${e}***`}return e},Fe=e=>{if(!e||typeof e!="string")return e;let t=e,n=Go(t);return n.endsWith("](streamdown:incomplete-link)")?n:(t=n,t=dr(t),t=Yo(t),t=Qo(t),t=tr(t),t=or(t),t=ir(t),t=ar(t),t=lr(t),t)};var kr={harden:[rehypeHarden.harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],defaultOrigin:void 0,allowDataImages:true}],raw:gr__default.default,katex:[Ue__default.default,{errorColor:"var(--color-muted-foreground)"}]},vr={gfm:[wr__default.default,{}],math:[We__default.default,{singleDollarTextMath:false}],cjkFriendly:[br__default.default,{}],cjkFriendlyGfmStrikethrough:[yr__default.default,{}]},Cr=Object.values(kr),Mr=Object.values(vr),xr={shikiTheme:["github-light","github-dark"],controls:true,isAnimating:false,mode:"streaming",mermaid:void 0},M=react.createContext(xr),gn=react.memo(({content:e,shouldParseIncompleteMarkdown:t,...n})=>{let o=react.useMemo(()=>typeof e=="string"&&t?Fe(e.trim()):e,[e,t]);return jsxRuntime.jsx(Oe,{...n,children:o})},(e,t)=>{if(e.content!==t.content||e.shouldParseIncompleteMarkdown!==t.shouldParseIncompleteMarkdown||e.index!==t.index)return false;if(e.components!==t.components){let n=Object.keys(e.components||{}),o=Object.keys(t.components||{});if(n.length!==o.length||n.some(r=>{var s,a;return ((s=e.components)==null?void 0:s[r])!==((a=t.components)==null?void 0:a[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});gn.displayName="Block";var Pr=["github-light","github-dark"],Tr=react.memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:n=true,components:o,rehypePlugins:r=Cr,remarkPlugins:s=Mr,className:a,shikiTheme:i=Pr,mermaid:l,controls:c=true,isAnimating:d=false,BlockComponent:m=gn,parseMarkdownIntoBlocksFn:p=qe,...h})=>{let u=react.useId(),[g,w]=react.useTransition(),[k,P]=react.useState([]),N=react.useMemo(()=>p(typeof e=="string"?e:""),[e,p]);react.useEffect(()=>{t==="streaming"?w(()=>{P(N);}):P(N);},[N,t]);let T=t==="streaming"?k:N,L=react.useMemo(()=>T.map((H,B)=>`${u}-${B}`),[T.length,u]),O=react.useMemo(()=>({shikiTheme:i,controls:c,isAnimating:d,mode:t,mermaid:l}),[i,c,d,t,l]),U=react.useMemo(()=>({..._t,...o}),[o]);return react.useEffect(()=>{if(!(Array.isArray(r)&&r.some(S=>Array.isArray(S)?S[0]===Ue__default.default:S===Ue__default.default)))return;let B=false;if(Array.isArray(s)){let S=s.find(ee=>Array.isArray(ee)?ee[0]===We__default.default:ee===We__default.default);S&&Array.isArray(S)&&S[1]&&(B=S[1].singleDollarTextMath===true);}let R=typeof e=="string"?e:"",z=R.includes("$$"),y=B&&(/[^$]\$[^$]/.test(R)||/^\$[^$]/.test(R)||/[^$]\$$/.test(R));(z||y)&&import('katex/dist/katex.min.css');},[r,s,e]),t==="static"?jsxRuntime.jsx(M.Provider,{value:O,children:jsxRuntime.jsx("div",{className:f("space-y-4",a),children:jsxRuntime.jsx(Oe,{components:U,rehypePlugins:r,remarkPlugins:s,...h,children:e})})}):jsxRuntime.jsx(M.Provider,{value:O,children:jsxRuntime.jsx("div",{className:f("space-y-4",a),children:T.map((H,B)=>jsxRuntime.jsx(m,{components:U,content:H,index:B,rehypePlugins:r,remarkPlugins:s,shouldParseIncompleteMarkdown:n,...h},L[B]))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode);Tr.displayName="Streamdown";var kn=({children:e,className:t,minZoom:n=.5,maxZoom:o=3,zoomStep:r=.1,showControls:s=true,initialZoom:a=1,fullscreen:i=false})=>{let l=react.useRef(null),c=react.useRef(null),[d,m]=react.useState(a),[p,h]=react.useState({x:0,y:0}),[u,g]=react.useState(false),[w,k]=react.useState({x:0,y:0}),[P,N]=react.useState({x:0,y:0}),T=react.useCallback(y=>{m(I=>Math.max(n,Math.min(o,I+y)));},[n,o]),L=react.useCallback(()=>{T(r);},[T,r]),O=react.useCallback(()=>{T(-r);},[T,r]),U=react.useCallback(()=>{m(a),h({x:0,y:0});},[a]),H=react.useCallback(y=>{y.preventDefault();let I=y.deltaY>0?-r:r;T(I);},[T,r]),B=react.useCallback(y=>{if(y.button!==0||y.isPrimary===false)return;g(true),k({x:y.clientX,y:y.clientY}),N(p);let I=y.currentTarget;I instanceof HTMLElement&&I.setPointerCapture(y.pointerId);},[p]),R=react.useCallback(y=>{if(!u)return;y.preventDefault();let I=y.clientX-w.x,S=y.clientY-w.y;h({x:P.x+I,y:P.y+S});},[u,w,P]),z=react.useCallback(y=>{g(false);let I=y.currentTarget;I instanceof HTMLElement&&I.releasePointerCapture(y.pointerId);},[]);return react.useEffect(()=>{let y=l.current;if(y)return y.addEventListener("wheel",H,{passive:false}),()=>{y.removeEventListener("wheel",H);}},[H]),react.useEffect(()=>{let y=c.current;if(y&&u)return document.body.style.userSelect="none",y.addEventListener("pointermove",R,{passive:false}),y.addEventListener("pointerup",z),y.addEventListener("pointercancel",z),()=>{document.body.style.userSelect="",y.removeEventListener("pointermove",R),y.removeEventListener("pointerup",z),y.removeEventListener("pointercancel",z);}},[u,R,z]),jsxRuntime.jsxs("div",{className:f("relative",i?"h-full w-full":"w-full",t),ref:l,style:{cursor:u?"grabbing":"grab"},children:[s&&jsxRuntime.jsxs("div",{className:f("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:d>=o,onClick:L,title:"Zoom in",type:"button",children:jsxRuntime.jsx(Ir__default.default,{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:d<=n,onClick:O,title:"Zoom out",type:"button",children:jsxRuntime.jsx(Sr__default.default,{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:U,title:"Reset zoom and pan",type:"button",children:jsxRuntime.jsx(Nr__default.default,{size:16})})]}),jsxRuntime.jsx("div",{className:f("origin-center transition-transform duration-150 ease-out",i&&"flex h-full w-full items-center justify-center"),onPointerDown:B,ref:c,role:"application",style:{transform:`translate(${p.x}px, ${p.y}px) scale(${d})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var ot=({chart:e,className:t,config:n,fullscreen:o=false})=>{let[r,s]=react.useState(null),[a,i]=react.useState(true),[l,c]=react.useState(""),[d,m]=react.useState(""),[p,h]=react.useState(0),{mermaid:u}=react.useContext(M),g=u==null?void 0:u.errorComponent;if(react.useEffect(()=>{(async()=>{try{s(null),i(!0);let P=await oe(n),N=e.split("").reduce((O,U)=>(O<<5)-O+U.charCodeAt(0)|0,0),T=`mermaid-${Math.abs(N)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:L}=await P.render(T,e);c(L),m(L);}catch(P){if(!(d||l)){let N=P instanceof Error?P.message:"Failed to render Mermaid chart";s(N);}}finally{i(false);}})();},[e,n,p]),a&&!l&&!d)return jsxRuntime.jsx("div",{className:f("my-4 flex justify-center p-4",t),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(r&&!l&&!d){let k=()=>h(P=>P+1);return g?jsxRuntime.jsx(g,{chart:e,error:r,retry:k}):jsxRuntime.jsxs("div",{className:f("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[jsxRuntime.jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),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 w=l||d;return jsxRuntime.jsx(kn,{className:f(o?"h-full w-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:o,maxZoom:3,minZoom:.5,showControls:true,zoomStep:.1,children:jsxRuntime.jsx("div",{"aria-label":"Mermaid chart",className:f("flex justify-center",o&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:w},role:"img"})})};exports.a=f;exports.b=Ln;exports.c=ot;exports.d=qe;exports.e=Fe;exports.f=kr;exports.g=vr;exports.h=M;exports.i=gn;exports.j=Tr;
@@ -0,0 +1,2 @@
1
+ import {a,h as h$1,b as b$1}from'./chunk-2LSFTLAB.js';import {memo,useMemo,useContext,useState,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';import {createHighlighter}from'shiki';import {createJavaScriptRegexEngine}from'shiki/engine/javascript';var H=a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-4","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),y=memo(({children:o,result:e,language:t,className:r,...n})=>{let l=useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]);return jsx("pre",{className:a(r,"p-4 text-sm"),"data-code-block":true,"data-language":t,style:l,...n,children:jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((a,i)=>jsx("span",{className:H,children:a.map((s,u)=>jsx("span",{style:{color:s.color,backgroundColor:s.bgColor,...s.htmlStyle},...s.htmlAttrs,children:s.content},u))},i))})})},(o,e)=>o.result===e.result&&o.language===e.language&&o.className===e.className);var b=({className:o,language:e,style:t,...r})=>jsx("div",{className:a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-code-block-container":true,"data-language":e,style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...t},...r});var x=({language:o,children:e})=>jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-code-block-header":true,"data-language":o,children:[jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsx("div",{className:"flex items-center gap-2",children:e})]});var M=createJavaScriptRegexEngine({forgiving:true}),p=new Map,h=new Map,d=new Map,$=(o,e)=>`${o}-${e[0]}-${e[1]}`,E=(o,e,t)=>{let r=o.slice(0,100),n=o.length>100?o.slice(-100):"";return `${e}:${t[0]}:${t[1]}:${o.length}:${r}:${n}`},A=(o,e)=>{let t=$(o,e);if(p.has(t))return p.get(t);let r=createHighlighter({themes:e,langs:[o],engine:M});return p.set(t,r),r},f=(o,e,t,r)=>{let n=E(o,e,t);return h.has(n)?h.get(n):(r&&(d.has(n)||d.set(n,new Set),d.get(n).add(r)),A(e,t).then(l=>{let a=l.codeToTokens(o,{lang:e,themes:{light:t[0],dark:t[1]}});h.set(n,a);let i=d.get(n);if(i){for(let s of i)s(a);d.delete(n);}}).catch(l=>{console.error("Failed to highlight code:",l),d.delete(n);}),null)};var le=({code:o,language:e,className:t,children:r,preClassName:n,...l})=>{let{shikiTheme:a}=useContext(h$1),i=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:o.split(`
2
+ `).map(g=>[{content:g,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[o]),[s,u]=useState(i);return useEffect(()=>{let g=f(o,e,a);if(g){u(g);return}f(o,e,a,R=>{u(R);});},[o,e,a]),jsx(b$1.Provider,{value:{code:o},children:jsxs(b,{language:e,children:[jsx(x,{language:e,children:r}),jsx(y,{className:t,language:e,result:s,...l})]})})};export{le as CodeBlock};
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkUGPOVMD7_cjs=require('./chunk-UGPOVMD7.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),shiki=require('shiki'),javascript=require('shiki/engine/javascript');var H=chunkUGPOVMD7_cjs.a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-4","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),y=react.memo(({children:o,result:e,language:t,className:r,...n})=>{let l=react.useMemo(()=>({backgroundColor:e.bg,color:e.fg}),[e.bg,e.fg]);return jsxRuntime.jsx("pre",{className:chunkUGPOVMD7_cjs.a(r,"p-4 text-sm"),"data-code-block":true,"data-language":t,style:l,...n,children:jsxRuntime.jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((a,i)=>jsxRuntime.jsx("span",{className:H,children:a.map((s,u)=>jsxRuntime.jsx("span",{style:{color:s.color,backgroundColor:s.bgColor,...s.htmlStyle},...s.htmlAttrs,children:s.content},u))},i))})})},(o,e)=>o.result===e.result&&o.language===e.language&&o.className===e.className);var b=({className:o,language:e,style:t,...r})=>jsxRuntime.jsx("div",{className:chunkUGPOVMD7_cjs.a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-code-block-container":true,"data-language":e,style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...t},...r});var x=({language:o,children:e})=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-code-block-header":true,"data-language":o,children:[jsxRuntime.jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:e})]});var M=javascript.createJavaScriptRegexEngine({forgiving:true}),p=new Map,h=new Map,d=new Map,$=(o,e)=>`${o}-${e[0]}-${e[1]}`,E=(o,e,t)=>{let r=o.slice(0,100),n=o.length>100?o.slice(-100):"";return `${e}:${t[0]}:${t[1]}:${o.length}:${r}:${n}`},A=(o,e)=>{let t=$(o,e);if(p.has(t))return p.get(t);let r=shiki.createHighlighter({themes:e,langs:[o],engine:M});return p.set(t,r),r},f=(o,e,t,r)=>{let n=E(o,e,t);return h.has(n)?h.get(n):(r&&(d.has(n)||d.set(n,new Set),d.get(n).add(r)),A(e,t).then(l=>{let a=l.codeToTokens(o,{lang:e,themes:{light:t[0],dark:t[1]}});h.set(n,a);let i=d.get(n);if(i){for(let s of i)s(a);d.delete(n);}}).catch(l=>{console.error("Failed to highlight code:",l),d.delete(n);}),null)};var le=({code:o,language:e,className:t,children:r,preClassName:n,...l})=>{let{shikiTheme:a}=react.useContext(chunkUGPOVMD7_cjs.h),i=react.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:o.split(`
2
+ `).map(g=>[{content:g,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[o]),[s,u]=react.useState(i);return react.useEffect(()=>{let g=f(o,e,a);if(g){u(g);return}f(o,e,a,R=>{u(R);});},[o,e,a]),jsxRuntime.jsx(chunkUGPOVMD7_cjs.b.Provider,{value:{code:o},children:jsxRuntime.jsxs(b,{language:e,children:[jsxRuntime.jsx(x,{language:e,children:r}),jsxRuntime.jsx(y,{className:t,language:e,result:s,...l})]})})};exports.CodeBlock=le;
package/dist/index.cjs CHANGED
@@ -1,22 +1 @@
1
- "use strict";"use client";var Vo=Object.create;var ue=Object.defineProperty;var Xo=Object.getOwnPropertyDescriptor;var Jo=Object.getOwnPropertyNames;var Ko=Object.getPrototypeOf,Zo=Object.prototype.hasOwnProperty;var Go=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Yo=(e,t)=>{for(var o in t)ue(e,o,{get:t[o],enumerable:!0})},ut=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Jo(t))!Zo.call(e,r)&&r!==o&&ue(e,r,{get:()=>t[r],enumerable:!(n=Xo(t,r))||n.enumerable});return e};var E=(e,t,o)=>(o=e!=null?Vo(Ko(e)):{},ut(t||!e||!e.__esModule?ue(o,"default",{value:e,enumerable:!0}):o,e)),Qo=e=>ut(ue({},"__esModule",{value:!0}),e);var ko=Go((fs,wo)=>{"use strict";var Pe=Object.prototype.hasOwnProperty,yo=Object.prototype.toString,po=Object.defineProperty,uo=Object.getOwnPropertyDescriptor,fo=function(t){return typeof Array.isArray=="function"?Array.isArray(t):yo.call(t)==="[object Array]"},ho=function(t){if(!t||yo.call(t)!=="[object Object]")return!1;var o=Pe.call(t,"constructor"),n=t.constructor&&t.constructor.prototype&&Pe.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!o&&!n)return!1;var r;for(r in t);return typeof r=="undefined"||Pe.call(t,r)},go=function(t,o){po&&o.name==="__proto__"?po(t,o.name,{enumerable:!0,configurable:!0,value:o.newValue,writable:!0}):t[o.name]=o.newValue},bo=function(t,o){if(o==="__proto__")if(Pe.call(t,o)){if(uo)return uo(t,o).value}else return;return t[o]};wo.exports=function e(){var t,o,n,r,s,a,i=arguments[0],l=1,c=arguments.length,d=!1;for(typeof i=="boolean"&&(d=i,i=arguments[1]||{},l=2),(i==null||typeof i!="object"&&typeof i!="function")&&(i={});l<c;++l)if(t=arguments[l],t!=null)for(o in t)n=bo(i,o),r=bo(t,o),i!==r&&(d&&r&&(ho(r)||(s=fo(r)))?(s?(s=!1,a=n&&fo(n)?n:[]):a=n&&ho(n)?n:{},go(i,{name:o,newValue:e(d,a,r)})):typeof r!="undefined"&&go(i,{name:o,newValue:r}));return i}});var er={};Yo(er,{Block:()=>mt,Streamdown:()=>Wo,StreamdownContext:()=>v,defaultRehypePlugins:()=>Fo,defaultRemarkPlugins:()=>Uo,parseIncompleteMarkdown:()=>Le,parseMarkdownIntoBlocks:()=>Be});module.exports=Qo(er);var P=require("react"),Do=require("rehype-harden"),Ae=E(require("rehype-katex"),1),Ho=E(require("rehype-raw"),1),Oo=E(require("remark-cjk-friendly"),1),zo=E(require("remark-cjk-friendly-gfm-strikethrough"),1),qo=E(require("remark-gfm"),1),_o=E(require("remark-math"),1);var y=require("react");var _=require("react");var fe=require("react");var ft=require("clsx"),ht=require("tailwind-merge"),f=(...e)=>(0,ht.twMerge)((0,ft.clsx)(e)),D=(e,t,o)=>{let n=typeof t=="string"?new Blob([t],{type:o}):t,r=URL.createObjectURL(n),s=document.createElement("a");s.href=r,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r)};var le=require("react/jsx-runtime"),en=f("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-4","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),gt=(0,fe.memo)(({children:e,result:t,language:o,className:n,...r})=>{let s=(0,fe.useMemo)(()=>({backgroundColor:t.bg,color:t.fg}),[t.bg,t.fg]);return(0,le.jsx)("pre",{className:f(n,"p-4 text-sm"),"data-code-block":!0,"data-language":o,style:s,...r,children:(0,le.jsx)("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:t.tokens.map((a,i)=>(0,le.jsx)("span",{className:en,children:a.map((l,c)=>(0,le.jsx)("span",{style:{color:l.color,backgroundColor:l.bgColor,...l.htmlStyle},...l.htmlAttrs,children:l.content},c))},i))})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className);var yt=require("react/jsx-runtime"),bt=({className:e,language:t,style:o,...n})=>(0,yt.jsx)("div",{className:f("my-4 w-full overflow-hidden rounded-xl border border-border",e),"data-code-block-container":!0,"data-language":t,style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...n});var he=require("react"),je=(0,he.createContext)({code:""}),ge=()=>(0,he.useContext)(je);var ce=require("react/jsx-runtime"),wt=({language:e,children:t})=>(0,ce.jsxs)("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-code-block-header":!0,"data-language":e,children:[(0,ce.jsx)("span",{className:"ml-1 font-mono lowercase",children:e}),(0,ce.jsx)("div",{className:"flex items-center gap-2",children:t})]});var kt=require("shiki"),Ct=require("shiki/engine/javascript"),tn=(0,Ct.createJavaScriptRegexEngine)({forgiving:!0}),$e=new Map,De=new Map,ne=new Map,on=(e,t)=>`${e}-${t[0]}-${t[1]}`,nn=(e,t,o)=>{let n=e.slice(0,100),r=e.length>100?e.slice(-100):"";return`${t}:${o[0]}:${o[1]}:${e.length}:${n}:${r}`},rn=(e,t)=>{let o=on(e,t);if($e.has(o))return $e.get(o);let n=(0,kt.createHighlighter)({themes:t,langs:[e],engine:tn});return $e.set(o,n),n},He=(e,t,o,n)=>{let r=nn(e,t,o);return De.has(r)?De.get(r):(n&&(ne.has(r)||ne.set(r,new Set),ne.get(r).add(n)),rn(t,o).then(s=>{let a=s.codeToTokens(e,{lang:t,themes:{light:o[0],dark:o[1]}});De.set(r,a);let i=ne.get(r);if(i){for(let l of i)l(a);ne.delete(r)}}).catch(s=>{console.error("Failed to highlight code:",s),ne.delete(r)}),null)};var re=require("react/jsx-runtime"),vt=({code:e,language:t,className:o,children:n,preClassName:r,...s})=>{let{shikiTheme:a}=(0,_.useContext)(v),i=(0,_.useMemo)(()=>({bg:"transparent",fg:"inherit",tokens:e.split(`
2
- `).map(d=>[{content:d,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[e]),[l,c]=(0,_.useState)(i);return(0,_.useEffect)(()=>{let d=He(e,t,a);if(d){c(d);return}He(e,t,a,m=>{c(m)})},[e,t,a]),(0,re.jsx)(je.Provider,{value:{code:e},children:(0,re.jsxs)(bt,{language:t,children:[(0,re.jsx)(wt,{language:t,children:n}),(0,re.jsx)(gt,{className:o,language:t,result:l,...s})]})})};var be=require("lucide-react"),F=require("react");var Oe=require("react/jsx-runtime"),ze=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let[i,l]=(0,F.useState)(!1),c=(0,F.useRef)(0),{code:d}=ge(),{isAnimating:m}=(0,F.useContext)(v),p=s!=null?s:d,h=async()=>{var b;if(typeof window=="undefined"||!((b=navigator==null?void 0:navigator.clipboard)!=null&&b.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(p),l(!0),e==null||e(),c.current=window.setTimeout(()=>l(!1),o))}catch(w){t==null||t(w)}};(0,F.useEffect)(()=>()=>{window.clearTimeout(c.current)},[]);let u=i?be.CheckIcon:be.CopyIcon;return(0,Oe.jsx)("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:h,type:"button",...a,children:n!=null?n:(0,Oe.jsx)(u,{size:14})})};var Tt=require("lucide-react"),Pt=require("react");var qe=require("react/jsx-runtime"),Mt={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",\u6587\u8A00:"wy"},xt=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let{code:i}=ge(),{isAnimating:l}=(0,Pt.useContext)(v),c=s!=null?s:i,m=`file.${o&&o in Mt?Mt[o]:"txt"}`,p="text/plain",h=()=>{try{D(m,c,p),e==null||e()}catch(u){t==null||t(u)}};return(0,qe.jsx)("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:l,onClick:h,title:"Download file",type:"button",...a,children:n!=null?n:(0,qe.jsx)(Tt.DownloadIcon,{size:14})})};var Nt=require("lucide-react");var Y=require("react/jsx-runtime"),sn=/\.[^/.]+$/,It=({node:e,className:t,src:o,alt:n,...r})=>{let s=async()=>{if(o)try{let i=await(await fetch(o)).blob(),c=new URL(o,window.location.origin).pathname.split("/").pop()||"",d=c.split(".").pop(),m=c.includes(".")&&d!==void 0&&d.length<=4,p="";if(m)p=c;else{let h=i.type,u="png";h.includes("jpeg")||h.includes("jpg")?u="jpg":h.includes("png")?u="png":h.includes("svg")?u="svg":h.includes("gif")?u="gif":h.includes("webp")&&(u="webp"),p=`${(n||c||"image").replace(sn,"")}.${u}`}D(p,i,i.type)}catch(a){console.error("Failed to download image:",a)}};return o?(0,Y.jsxs)("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[(0,Y.jsx)("img",{alt:n,className:f("max-w-full rounded-lg",t),"data-streamdown":"image",src:o,...r}),(0,Y.jsx)("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),(0,Y.jsx)("button",{className:f("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:(0,Y.jsx)(Nt.DownloadIcon,{size:14})})]}):null};var H=require("react");var se=require("lucide-react"),T=require("react");var j=require("react/jsx-runtime"),St=({children:e,className:t,minZoom:o=.5,maxZoom:n=3,zoomStep:r=.1,showControls:s=!0,initialZoom:a=1,fullscreen:i=!1})=>{let l=(0,T.useRef)(null),c=(0,T.useRef)(null),[d,m]=(0,T.useState)(a),[p,h]=(0,T.useState)({x:0,y:0}),[u,b]=(0,T.useState)(!1),[w,C]=(0,T.useState)({x:0,y:0}),[N,B]=(0,T.useState)({x:0,y:0}),I=(0,T.useCallback)(k=>{m(R=>Math.max(o,Math.min(n,R+k)))},[o,n]),q=(0,T.useCallback)(()=>{I(r)},[I,r]),G=(0,T.useCallback)(()=>{I(-r)},[I,r]),te=(0,T.useCallback)(()=>{m(a),h({x:0,y:0})},[a]),$=(0,T.useCallback)(k=>{k.preventDefault();let R=k.deltaY>0?-r:r;I(R)},[I,r]),oe=(0,T.useCallback)(k=>{if(k.button!==0||k.isPrimary===!1)return;b(!0),C({x:k.clientX,y:k.clientY}),B(p);let R=k.currentTarget;R instanceof HTMLElement&&R.setPointerCapture(k.pointerId)},[p]),Re=(0,T.useCallback)(k=>{if(!u)return;k.preventDefault();let R=k.clientX-w.x,pt=k.clientY-w.y;h({x:N.x+R,y:N.y+pt})},[u,w,N]),ae=(0,T.useCallback)(k=>{b(!1);let R=k.currentTarget;R instanceof HTMLElement&&R.releasePointerCapture(k.pointerId)},[]);return(0,T.useEffect)(()=>{let k=l.current;if(k)return k.addEventListener("wheel",$,{passive:!1}),()=>{k.removeEventListener("wheel",$)}},[$]),(0,T.useEffect)(()=>{let k=c.current;if(k&&u)return document.body.style.userSelect="none",k.addEventListener("pointermove",Re,{passive:!1}),k.addEventListener("pointerup",ae),k.addEventListener("pointercancel",ae),()=>{document.body.style.userSelect="",k.removeEventListener("pointermove",Re),k.removeEventListener("pointerup",ae),k.removeEventListener("pointercancel",ae)}},[u,Re,ae]),(0,j.jsxs)("div",{className:f("relative",i?"h-full w-full":"w-full",t),ref:l,style:{cursor:u?"grabbing":"grab"},children:[s&&(0,j.jsxs)("div",{className:f("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:[(0,j.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:q,title:"Zoom in",type:"button",children:(0,j.jsx)(se.ZoomInIcon,{size:16})}),(0,j.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:G,title:"Zoom out",type:"button",children:(0,j.jsx)(se.ZoomOutIcon,{size:16})}),(0,j.jsx)("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:te,title:"Reset zoom and pan",type:"button",children:(0,j.jsx)(se.RotateCcwIcon,{size:16})})]}),(0,j.jsx)("div",{className:f("origin-center transition-transform duration-150 ease-out",i&&"flex h-full w-full items-center justify-center"),onPointerDown:oe,ref:c,role:"application",style:{transform:`translate(${p.x}px, ${p.y}px) scale(${d})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var ye=async e=>{let o={...{startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0},...e},r=(await import("mermaid")).default;return r.initialize(o),r},Bt=(e,t)=>{var n;let o=(n=t==null?void 0:t.scale)!=null?n:5;return new Promise((r,s)=>{let a="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let l=document.createElement("canvas"),c=i.width*o,d=i.height*o;l.width=c,l.height=d;let m=l.getContext("2d");if(!m){s(new Error("Failed to create 2D canvas context for PNG export"));return}m.drawImage(i,0,0,c,d),l.toBlob(p=>{if(!p){s(new Error("Failed to create PNG blob"));return}r(p)},"image/png")},i.onerror=()=>s(new Error("Failed to load SVG image")),i.src=a})};var S=require("react/jsx-runtime"),we=({chart:e,className:t,config:o,fullscreen:n=!1})=>{let[r,s]=(0,H.useState)(null),[a,i]=(0,H.useState)(!0),[l,c]=(0,H.useState)(""),[d,m]=(0,H.useState)(""),[p,h]=(0,H.useState)(0),{mermaid:u}=(0,H.useContext)(v),b=u==null?void 0:u.errorComponent;if((0,H.useEffect)(()=>{(async()=>{try{s(null),i(!0);let N=await ye(o),B=e.split("").reduce((G,te)=>(G<<5)-G+te.charCodeAt(0)|0,0),I=`mermaid-${Math.abs(B)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:q}=await N.render(I,e);c(q),m(q)}catch(N){if(!(d||l)){let B=N instanceof Error?N.message:"Failed to render Mermaid chart";s(B)}}finally{i(!1)}})()},[e,o,p]),a&&!l&&!d)return(0,S.jsx)("div",{className:f("my-4 flex justify-center p-4",t),children:(0,S.jsxs)("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[(0,S.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),(0,S.jsx)("span",{className:"text-sm",children:"Loading diagram..."})]})});if(r&&!l&&!d){let C=()=>h(N=>N+1);return b?(0,S.jsx)(b,{chart:e,error:r,retry:C}):(0,S.jsxs)("div",{className:f("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[(0,S.jsxs)("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),(0,S.jsxs)("details",{className:"mt-2",children:[(0,S.jsx)("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),(0,S.jsx)("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let w=l||d;return(0,S.jsx)(St,{className:f(n?"h-full w-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:!0,zoomStep:.1,children:(0,S.jsx)("div",{"aria-label":"Mermaid chart",className:f("flex justify-center",n&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:w},role:"img"})})};var Et=require("lucide-react"),U=require("react");var z=require("react/jsx-runtime"),Lt=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let[a,i]=(0,U.useState)(!1),l=(0,U.useRef)(null),{isAnimating:c}=(0,U.useContext)(v),d=async m=>{try{if(m==="mmd"){D("diagram.mmd",e,"text/plain"),i(!1),n==null||n(m);return}let p=await ye(r),h=e.split("").reduce((w,C)=>(w<<5)-w+C.charCodeAt(0)|0,0),u=`mermaid-${Math.abs(h)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:b}=await p.render(u,e);if(!b){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(m==="svg"){D("diagram.svg",b,"image/svg+xml"),i(!1),n==null||n(m);return}if(m==="png"){let w=await Bt(b);D("diagram.png",w,"image/png"),n==null||n(m),i(!1);return}}catch(p){s==null||s(p)}};return(0,U.useEffect)(()=>{let m=p=>{l.current&&!l.current.contains(p.target)&&i(!1)};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]),(0,z.jsxs)("div",{className:"relative",ref:l,children:[(0,z.jsx)("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:c,onClick:()=>i(!a),title:"Download diagram",type:"button",children:t!=null?t:(0,z.jsx)(Et.DownloadIcon,{size:14})}),a&&(0,z.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:[(0,z.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("svg"),type:"button",children:"SVG"}),(0,z.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("png"),type:"button",children:"PNG"}),(0,z.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("mmd"),type:"button",children:"MMD"})]})]})};var ke=require("lucide-react"),Q=require("react");var L=require("react/jsx-runtime"),de=0,an=()=>{de+=1,de===1&&(document.body.style.overflow="hidden")},ln=()=>{de=Math.max(0,de-1),de===0&&(document.body.style.overflow="")},At=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let[a,i]=(0,Q.useState)(!1),{isAnimating:l}=(0,Q.useContext)(v),c=()=>{i(!a)};return(0,Q.useEffect)(()=>{if(a){an();let d=m=>{m.key==="Escape"&&i(!1)};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),ln()}}},[a]),(0,Q.useEffect)(()=>{a?o==null||o():n&&n()},[a,o,n]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:l,onClick:c,title:"View fullscreen",type:"button",...s,children:(0,L.jsx)(ke.Maximize2Icon,{size:14})}),a&&(0,L.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:c,onKeyDown:d=>{d.key==="Escape"&&c()},role:"button",tabIndex:0,children:[(0,L.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:c,title:"Exit fullscreen",type:"button",children:(0,L.jsx)(ke.XIcon,{size:20})}),(0,L.jsx)("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:d=>d.stopPropagation(),onKeyDown:d=>d.stopPropagation(),role:"presentation",children:(0,L.jsx)(we,{chart:e,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:!0})})]})]})};var Me=require("lucide-react"),O=require("react");var Ce=e=>{var s,a;let t=[],o=[],n=e.querySelectorAll("thead th");for(let i of n)t.push(((s=i.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let i of r){let l=[],c=i.querySelectorAll("td");for(let d of c)l.push(((a=d.textContent)==null?void 0:a.trim())||"");o.push(l)}return{headers:t,rows:o}},ve=e=>{let{headers:t,rows:o}=e,n=i=>{let l=!1,c=!1;for(let d=0;d<i.length;d+=1){let m=i[d];if(m==='"'){l=!0,c=!0;break}(m===","||m===`
3
- `)&&(l=!0)}return l?c?`"${i.replace(/"/g,'""')}"`:`"${i}"`:i},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(","),a+=1);for(let i of o)s[a]=i.map(n).join(","),a+=1;return s.join(`
4
- `)},Rt=e=>{let{headers:t,rows:o}=e,n=i=>{let l=!1;for(let d=0;d<i.length;d+=1){let m=i[d];if(m===" "||m===`
5
- `||m==="\r"){l=!0;break}}if(!l)return i;let c=[];for(let d=0;d<i.length;d+=1){let m=i[d];m===" "?c.push("\\t"):m===`
6
- `?c.push("\\n"):m==="\r"?c.push("\\r"):c.push(m)}return c.join("")},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(" "),a+=1);for(let i of o)s[a]=i.map(n).join(" "),a+=1;return s.join(`
7
- `)},_e=e=>{let t=!1;for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="\\"||r==="|"){t=!0;break}}if(!t)return e;let o=[];for(let n=0;n<e.length;n+=1){let r=e[n];r==="\\"?o.push("\\\\"):r==="|"?o.push("\\|"):o.push(r)}return o.join("")},jt=e=>{let{headers:t,rows:o}=e;if(t.length===0)return"";let n=new Array(o.length+2),r=0,s=t.map(i=>_e(i));n[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let i=0;i<t.length;i+=1)a[i]="---";n[r]=`| ${a.join(" | ")} |`,r+=1;for(let i of o)if(i.length<t.length){let l=new Array(t.length);for(let c=0;c<t.length;c+=1)l[c]=c<i.length?_e(i[c]):"";n[r]=`| ${l.join(" | ")} |`,r+=1}else{let l=i.map(c=>_e(c));n[r]=`| ${l.join(" | ")} |`,r+=1}return n.join(`
8
- `)};var W=require("react/jsx-runtime"),$t=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let[s,a]=(0,O.useState)(!1),[i,l]=(0,O.useState)(!1),c=(0,O.useRef)(null),d=(0,O.useRef)(0),{isAnimating:m}=(0,O.useContext)(v),p=async u=>{var b,w;if(typeof window=="undefined"||!((b=navigator==null?void 0:navigator.clipboard)!=null&&b.write)){n==null||n(new Error("Clipboard API not available"));return}try{let C=(w=c.current)==null?void 0:w.closest('[data-streamdown="table-wrapper"]'),N=C==null?void 0:C.querySelector("table");if(!N){n==null||n(new Error("Table not found"));return}let B=Ce(N),I=u==="csv"?ve(B):Rt(B),q=new ClipboardItem({"text/plain":new Blob([I],{type:"text/plain"}),"text/html":new Blob([N.outerHTML],{type:"text/html"})});await navigator.clipboard.write([q]),l(!0),a(!1),o==null||o(u),d.current=window.setTimeout(()=>l(!1),r)}catch(C){n==null||n(C)}};(0,O.useEffect)(()=>{let u=b=>{c.current&&!c.current.contains(b.target)&&a(!1)};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u),window.clearTimeout(d.current)}},[]);let h=i?Me.CheckIcon:Me.CopyIcon;return(0,W.jsxs)("div",{className:"relative",ref:c,children:[(0,W.jsx)("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>a(!s),title:"Copy table",type:"button",children:e!=null?e:(0,W.jsx)(h,{size:14})}),s&&(0,W.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:[(0,W.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("csv"),type:"button",children:"CSV"}),(0,W.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("tsv"),type:"button",children:"TSV"})]})]})};var Dt=require("lucide-react"),X=require("react");var V=require("react/jsx-runtime");var Ht=({children:e,className:t,onDownload:o,onError:n})=>{let[r,s]=(0,X.useState)(!1),a=(0,X.useRef)(null),{isAnimating:i}=(0,X.useContext)(v),l=c=>{var d;try{let m=(d=a.current)==null?void 0:d.closest('[data-streamdown="table-wrapper"]'),p=m==null?void 0:m.querySelector("table");if(!p){n==null||n(new Error("Table not found"));return}let h=Ce(p),u=c==="csv"?ve(h):jt(h);D(`table.${c==="csv"?"csv":"md"}`,u,c==="csv"?"text/csv":"text/markdown"),s(!1),o==null||o(c)}catch(m){n==null||n(m)}};return(0,X.useEffect)(()=>{let c=d=>{a.current&&!a.current.contains(d.target)&&s(!1)};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[]),(0,V.jsxs)("div",{className:"relative",ref:a,children:[(0,V.jsx)("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>s(!r),title:"Download table",type:"button",children:e!=null?e:(0,V.jsx)(Dt.DownloadIcon,{size:14})}),r&&(0,V.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:[(0,V.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("csv"),type:"button",children:"CSV"}),(0,V.jsx)("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",children:"Markdown"})]})]})};var J=require("react/jsx-runtime"),Ot=({children:e,className:t,showControls:o,...n})=>(0,J.jsxs)("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[o&&(0,J.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,J.jsx)($t,{}),(0,J.jsx)(Ht,{})]}),(0,J.jsx)("div",{className:"overflow-x-auto",children:(0,J.jsx)("table",{className:f("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]});var g=require("react/jsx-runtime"),cn=/language-([^\s]+)/;function Te(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&(t!=null&&t.position)))return!1;let o=e.position.start,n=t.position.start,r=e.position.end,s=t.position.end;return(o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function M(e,t){return e.className===t.className&&Te(e.node,t.node)}var Ue=(e,t)=>typeof e=="boolean"?e:e[t]!==!1,Fe=(e,t)=>{if(typeof e=="boolean")return e;let o=e.mermaid;return o===!1?!1:o===!0||o===void 0?!0:o[t]!==!1},We=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("ol",{className:f("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>M(e,t));We.displayName="MarkdownOl";var zt=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("li",{className:f("py-1",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&Te(e.node,t.node));zt.displayName="MarkdownLi";var qt=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("ul",{className:f("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>M(e,t));qt.displayName="MarkdownUl";var _t=(0,y.memo)(({className:e,node:t,...o})=>(0,g.jsx)("hr",{className:f("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o}),(e,t)=>M(e,t));_t.displayName="MarkdownHr";var Ft=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("span",{className:f("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>M(e,t));Ft.displayName="MarkdownStrong";var Ut=(0,y.memo)(({children:e,className:t,href:o,node:n,...r})=>{let s=o==="streamdown:incomplete-link";return(0,g.jsx)("a",{className:f("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":s,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},(e,t)=>M(e,t)&&e.href===t.href);Ut.displayName="MarkdownA";var Wt=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("h1",{className:f("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>M(e,t));Wt.displayName="MarkdownH1";var Vt=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("h2",{className:f("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>M(e,t));Vt.displayName="MarkdownH2";var Xt=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("h3",{className:f("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>M(e,t));Xt.displayName="MarkdownH3";var Jt=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("h4",{className:f("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>M(e,t));Jt.displayName="MarkdownH4";var Kt=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("h5",{className:f("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>M(e,t));Kt.displayName="MarkdownH5";var Zt=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("h6",{className:f("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>M(e,t));Zt.displayName="MarkdownH6";var Gt=(0,y.memo)(({children:e,className:t,node:o,...n})=>{let{controls:r}=(0,y.useContext)(v),s=Ue(r,"table");return(0,g.jsx)(Ot,{className:t,"data-streamdown":"table-wrapper",showControls:s,...n,children:e})},(e,t)=>M(e,t));Gt.displayName="MarkdownTable";var Yt=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("thead",{className:f("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>M(e,t));Yt.displayName="MarkdownThead";var Qt=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("tbody",{className:f("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>M(e,t));Qt.displayName="MarkdownTbody";var eo=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("tr",{className:f("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>M(e,t));eo.displayName="MarkdownTr";var to=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("th",{className:f("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>M(e,t));to.displayName="MarkdownTh";var oo=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("td",{className:f("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>M(e,t));oo.displayName="MarkdownTd";var no=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("blockquote",{className:f("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>M(e,t));no.displayName="MarkdownBlockquote";var ro=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("sup",{className:f("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>M(e,t));ro.displayName="MarkdownSup";var so=(0,y.memo)(({children:e,className:t,node:o,...n})=>(0,g.jsx)("sub",{className:f("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>M(e,t));so.displayName="MarkdownSub";var io=(0,y.memo)(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=l=>{var p,h;if(!(0,y.isValidElement)(l))return!1;let c=Array.isArray(l.props.children)?l.props.children:[l.props.children],d=!1,m=!1;for(let u of c)if(u){if(typeof u=="string")u.trim()!==""&&(d=!0);else if((0,y.isValidElement)(u))if(((p=u.props)==null?void 0:p["data-footnote-backref"])!==void 0)m=!0;else{let b=Array.isArray(u.props.children)?u.props.children:[u.props.children];for(let w of b){if(typeof w=="string"&&w.trim()!==""){d=!0;break}if((0,y.isValidElement)(w)&&((h=w.props)==null?void 0:h["data-footnote-backref"])===void 0){d=!0;break}}}}return m&&!d},a=Array.isArray(e)?e.map(l=>{if(!(0,y.isValidElement)(l))return l;if(l.type===We){let d=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!s(m));return d.length===0?null:{...l,props:{...l.props,children:d}}}return l}):e;return(Array.isArray(a)?a.some(l=>l!==null):a!==null)?(0,g.jsx)("section",{className:t,...n,children:a}):null}return(0,g.jsx)("section",{className:t,...n,children:e})},(e,t)=>M(e,t));io.displayName="MarkdownSection";var dn=({node:e,className:t,children:o,...n})=>{var m,p,h;let r=((m=e==null?void 0:e.position)==null?void 0:m.start.line)===((p=e==null?void 0:e.position)==null?void 0:p.end.line),{mermaid:s,controls:a}=(0,y.useContext)(v);if(r)return(0,g.jsx)("code",{className:f("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let i=t==null?void 0:t.match(cn),l=(h=i==null?void 0:i.at(1))!=null?h:"",c="";if((0,y.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"){let u=Ue(a,"mermaid"),b=Fe(a,"download"),w=Fe(a,"copy"),C=Fe(a,"fullscreen");return(0,g.jsxs)("div",{className:f("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[u&&(b||w||C)&&(0,g.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[b&&(0,g.jsx)(Lt,{chart:c,config:s==null?void 0:s.config}),w&&(0,g.jsx)(ze,{code:c}),C&&(0,g.jsx)(At,{chart:c,config:s==null?void 0:s.config})]}),(0,g.jsx)(we,{chart:c,config:s==null?void 0:s.config})]})}let d=Ue(a,"code");return(0,g.jsx)(vt,{className:f("overflow-x-auto border-border border-t",t),code:c,"data-language":l,"data-streamdown":"code-block",language:l,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:d&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(xt,{code:c,language:l}),(0,g.jsx)(ze,{})]})})},ao=(0,y.memo)(dn,(e,t)=>e.className===t.className&&Te(e.node,t.node));ao.displayName="MarkdownCode";var lo=(0,y.memo)(It,(e,t)=>e.className===t.className&&Te(e.node,t.node));lo.displayName="MarkdownImg";var co=(0,y.memo)(({children:e,className:t,node:o,...n})=>{var a;let s=(Array.isArray(e)?e:[e]).filter(i=>i!=null&&i!=="");return s.length===1&&(0,y.isValidElement)(s[0])&&((a=s[0].props.node)==null?void 0:a.tagName)==="img"?(0,g.jsx)(g.Fragment,{children:e}):(0,g.jsx)("p",{className:t,...n,children:e})},(e,t)=>M(e,t));co.displayName="MarkdownParagraph";var mo={ol:We,li:zt,ul:qt,hr:_t,strong:Ft,a:Ut,h1:Wt,h2:Vt,h3:Xt,h4:Jt,h5:Kt,h6:Zt,table:Gt,thead:Yt,tbody:Qt,tr:eo,th:to,td:oo,blockquote:no,code:ao,img:lo,pre:({children:e})=>e,sup:ro,sub:so,p:co,section:io};var Eo=require("hast-util-to-jsx-runtime"),ie=require("react/jsx-runtime"),Lo=E(require("remark-parse"),1),Ao=E(require("remark-rehype"),1);function Ve(e){if(e)throw e}var Ie=E(ko(),1);function me(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Xe(){let e=[],t={run:o,use:n};return t;function o(...r){let s=-1,a=r.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);i(null,...r);function i(l,...c){let d=e[++s],m=-1;if(l){a(l);return}for(;++m<r.length;)(c[m]===null||c[m]===void 0)&&(c[m]=r[m]);r=c,d?Co(d,i)(...c):a(null,...c)}}function n(r){if(typeof r!="function")throw new TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),t}}function Co(e,t){let o;return n;function n(...a){let i=e.length>a.length,l;i&&a.push(r);try{l=e.apply(this,a)}catch(c){let d=c;if(i&&o)throw d;return r(d)}i||(l&&l.then&&typeof l.then=="function"?l.then(s,r):l instanceof Error?r(l):s(l))}function r(a,...i){o||(o=!0,t(a,...i))}function s(a){r(null,a)}}function Ke(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?vo(e.position):"start"in e||"end"in e?vo(e):"line"in e||"column"in e?Je(e):""}function Je(e){return Mo(e&&e.line)+":"+Mo(e&&e.column)}function vo(e){return Je(e&&e.start)+"-"+Je(e&&e.end)}function Mo(e){return e&&typeof e=="number"?e:1}var x=class extends Error{constructor(t,o,n){super(),typeof o=="string"&&(n=o,o=void 0);let r="",s={},a=!1;if(o&&("line"in o&&"column"in o?s={place:o}:"start"in o&&"end"in o?s={place:o}:"type"in o?s={ancestors:[o],place:o.position}:s={...o}),typeof t=="string"?r=t:!s.cause&&t&&(a=!0,r=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof n=="string"){let l=n.indexOf(":");l===-1?s.ruleId=n:(s.source=n.slice(0,l),s.ruleId=n.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){let l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}let i=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=i?i.line:void 0,this.name=Ke(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};x.prototype.file="";x.prototype.name="";x.prototype.reason="";x.prototype.message="";x.prototype.stack="";x.prototype.column=void 0;x.prototype.line=void 0;x.prototype.ancestors=void 0;x.prototype.cause=void 0;x.prototype.fatal=void 0;x.prototype.place=void 0;x.prototype.ruleId=void 0;x.prototype.source=void 0;var A=E(require("path"),1);var Ze=E(require("process"),1);var Ge=require("url");function xe(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}var Ye=["history","path","basename","stem","extname","dirname"],pe=class{constructor(t){let o;t?xe(t)?o={path:t}:typeof t=="string"||mn(t)?o={value:t}:o=t:o={},this.cwd="cwd"in o?"":Ze.default.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Ye.length;){let s=Ye[n];s in o&&o[s]!==void 0&&o[s]!==null&&(this[s]=s==="history"?[...o[s]]:o[s])}let r;for(r in o)Ye.includes(r)||(this[r]=o[r])}get basename(){return typeof this.path=="string"?A.default.basename(this.path):void 0}set basename(t){et(t,"basename"),Qe(t,"basename"),this.path=A.default.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?A.default.dirname(this.path):void 0}set dirname(t){To(this.basename,"dirname"),this.path=A.default.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?A.default.extname(this.path):void 0}set extname(t){if(Qe(t,"extname"),To(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=A.default.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){xe(t)&&(t=(0,Ge.fileURLToPath)(t)),et(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?A.default.basename(this.path,this.extname):void 0}set stem(t){et(t,"stem"),Qe(t,"stem"),this.path=A.default.join(this.dirname||"",t+(this.extname||""))}fail(t,o,n){let r=this.message(t,o,n);throw r.fatal=!0,r}info(t,o,n){let r=this.message(t,o,n);return r.fatal=void 0,r}message(t,o,n){let r=new x(t,o,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}};function Qe(e,t){if(e&&e.includes(A.default.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+A.default.sep+"`")}function et(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function To(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function mn(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var Po=(function(e){let n=this.constructor.prototype,r=n[e],s=function(){return r.apply(s,arguments)};return Object.setPrototypeOf(s,n),s});var pn={}.hasOwnProperty,rt=class e extends Po{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Xe()}copy(){let t=new e,o=-1;for(;++o<this.attachers.length;){let n=this.attachers[o];t.use(...n)}return t.data((0,Ie.default)(!0,{},this.namespace)),t}data(t,o){return typeof t=="string"?arguments.length===2?(nt("data",this.frozen),this.namespace[t]=o,this):pn.call(this.namespace,t)&&this.namespace[t]||void 0:t?(nt("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[o,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=o.call(t,...n);typeof r=="function"&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let o=Ne(t),n=this.parser||this.Parser;return tt("parse",n),n(String(o),o)}process(t,o){let n=this;return this.freeze(),tt("process",this.parser||this.Parser),ot("process",this.compiler||this.Compiler),o?r(void 0,o):new Promise(r);function r(s,a){let i=Ne(t),l=n.parse(i);n.run(l,i,function(d,m,p){if(d||!m||!p)return c(d);let h=m,u=n.stringify(h,p);fn(u)?p.value=u:p.result=u,c(d,p)});function c(d,m){d||!m?a(d):s?s(m):o(void 0,m)}}}processSync(t){let o=!1,n;return this.freeze(),tt("processSync",this.parser||this.Parser),ot("processSync",this.compiler||this.Compiler),this.process(t,r),No("processSync","process",o),n;function r(s,a){o=!0,Ve(s),n=a}}run(t,o,n){xo(t),this.freeze();let r=this.transformers;return!n&&typeof o=="function"&&(n=o,o=void 0),n?s(void 0,n):new Promise(s);function s(a,i){let l=Ne(o);r.run(t,l,c);function c(d,m,p){let h=m||t;d?i(d):a?a(h):n(void 0,h,p)}}}runSync(t,o){let n=!1,r;return this.run(t,o,s),No("runSync","run",n),r;function s(a,i){Ve(a),r=i,n=!0}}stringify(t,o){this.freeze();let n=Ne(o),r=this.compiler||this.Compiler;return ot("stringify",r),xo(t),r(t,n)}use(t,...o){let n=this.attachers,r=this.namespace;if(nt("use",this.frozen),t!=null)if(typeof t=="function")l(t,o);else if(typeof t=="object")Array.isArray(t)?i(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[d,...m]=c;l(d,m)}else a(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function a(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(c.plugins),c.settings&&(r.settings=(0,Ie.default)(!0,r.settings,c.settings))}function i(c){let d=-1;if(c!=null)if(Array.isArray(c))for(;++d<c.length;){let m=c[d];s(m)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,d){let m=-1,p=-1;for(;++m<n.length;)if(n[m][0]===c){p=m;break}if(p===-1)n.push([c,...d]);else if(d.length>0){let[h,...u]=d,b=n[p][1];me(b)&&me(h)&&(h=(0,Ie.default)(!0,b,h)),n[p]=[c,h,...u]}}}},st=new rt().freeze();function tt(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ot(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function nt(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function xo(e){if(!me(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function No(e,t,o){if(!o)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Ne(e){return un(e)?e:new pe(e)}function un(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function fn(e){return typeof e=="string"||hn(e)}function hn(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var Io=[],So={allowDangerousHtml:!0},Se=new WeakMap,it=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100}generateCacheKey(t){let o=this.keyCache.get(t);if(o)return o;let n=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return"";let p="";for(let h=0;h<m.length;h+=1){let u=m[h];if(h>0&&(p+=","),Array.isArray(u)){let[b,w]=u;if(typeof b=="function"){let C=Se.get(b);C||(C=b.name,Se.set(b,C)),p+=C}else p+=String(b);p+=":",p+=JSON.stringify(w)}else if(typeof u=="function"){let b=Se.get(u);b||(b=u.name,Se.set(u,b)),p+=b}else p+=String(u)}return p},i=a(n),l=a(r),c=s?JSON.stringify(s):"",d=`${l}::${i}::${c}`;return this.keyCache.set(t,d),d}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r)}this.cache.set(n,o)}clear(){this.cache.clear()}},Bo=new it,at=e=>{let t=gn(e),o=e.children||"";return yn(t.runSync(t.parse(o),o),e)},gn=e=>{let t=Bo.get(e);if(t)return t;let o=bn(e);return Bo.set(e,o),o},bn=e=>{let t=e.rehypePlugins||Io,o=e.remarkPlugins||Io,n=e.remarkRehypeOptions?{...So,...e.remarkRehypeOptions}:So;return st().use(Lo.default).use(o).use(Ao.default,n).use(t)},yn=(e,t)=>(0,Eo.toJsxRuntime)(e,{Fragment:ie.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:ie.jsx,jsxs:ie.jsxs,passKeys:!0,passNode:!0});var Ro=require("marked"),wn=/\[\^[^\]\s]{1,200}\](?!:)/,kn=/\[\^[^\]\s]{1,200}\]:/,Cn=/<\/(\w+)>/,vn=/<(\w+)[\s>]/,lt=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]==="$"},Mn=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]==="$"},ct=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},Be=e=>{let t=wn.test(e),o=kn.test(e);if(t||o)return[e];let n=Ro.Lexer.lex(e,{gfm:!0}),r=[],s=[];for(let a of n){let i=a.raw,l=r.length;if(s.length>0){if(r[l-1]+=i,a.type==="html"){let d=i.match(Cn);if(d){let m=d[1];s.at(-1)===m&&s.pop()}}continue}if(a.type==="html"&&a.block){let d=i.match(vn);if(d){let m=d[1];i.includes(`</${m}>`)||s.push(m)}}if(i.trim()==="$$"&&l>0){let d=r[l-1],m=lt(d),p=ct(d);if(m&&p%2===1){r[l-1]=d+i;continue}}if(l>0&&Mn(i)){let d=r[l-1],m=lt(d),p=ct(d),h=ct(i);if(m&&p%2===1&&!lt(i)&&h===1){r[l-1]=d+i;continue}}r.push(i)}return r};var Tn=/(\*\*)([^*]*?)$/,Pn=/(__)([^_]*?)$/,xn=/(\*\*\*)([^*]*?)$/,Nn=/(\*)([^*]*?)$/,In=/(_)([^_]*?)$/,Sn=/(`)([^`]*?)$/,Bn=/(~~)([^~]*?)$/,ee=/^[\s_~*`]*$/,jo=/^[\s]*[-*+][\s]+$/,En=/[\p{L}\p{N}_]/u,Ln=/^```[^`\n]*```?$/,An=/^\*{4,}$/,K=e=>{if(!e)return!1;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?!0:En.test(e)},Ee=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
11
- `)};var Rn=(e,t)=>{let o=1;for(let n=t-1;n>=0;n-=1)if(e[n]==="]")o+=1;else if(e[n]==="["&&(o-=1,o===0))return n;return-1},jn=(e,t)=>{let o=1;for(let n=t+1;n<e.length;n+=1)if(e[n]==="[")o+=1;else if(e[n]==="]"&&(o-=1,o===0))return n;return-1},dt=(e,t)=>{let o=!1,n=!1;for(let r=0;r<t;r+=1){if(e.substring(r,r+3)==="```"){n=!n,r+=2;continue}!n&&e[r]==="`"&&(o=!o)}return o||n},$n=e=>{let t=e.lastIndexOf("](");if(t!==-1&&!dt(e,t)&&!e.substring(t+2).includes(")")){let n=Rn(e,t);if(n!==-1&&!dt(e,n)){let r=n>0&&e[n-1]==="!",s=r?n-1:n,a=e.substring(0,s),i=e.substring(n+1,t);return r?a:`${a}[${i}](streamdown:incomplete-link)`}}for(let o=e.length-1;o>=0;o-=1)if(e[o]==="["&&!dt(e,o)){let n=o>0&&e[o-1]==="!",r=n?o-1:o;if(!e.substring(o+1).includes("]")){let i=e.substring(0,r);return n?i:`${e}](streamdown:incomplete-link)`}if(jn(e,o)===-1){let i=e.substring(0,r);return n?i:`${e}](streamdown:incomplete-link)`}}return e},Dn=e=>{if(Ee(e))return e;let t=e.match(Tn);if(t){let o=t[2];if(!o||ee.test(o))return e;let n=e.lastIndexOf(t[1]),s=e.substring(0,n).lastIndexOf(`
12
- `),a=s===-1?0:s+1,i=e.substring(a,n);if(jo.test(i)&&o.includes(`
13
- `))return e;if((e.match(/\*\*/g)||[]).length%2===1)return`${e}**`}return e},Hn=e=>{let t=e.match(Pn);if(t){let o=t[2];if(!o||ee.test(o))return e;let n=e.lastIndexOf(t[1]),s=e.substring(0,n).lastIndexOf(`
14
- `),a=s===-1?0:s+1,i=e.substring(a,n);if(jo.test(i)&&o.includes(`
15
- `))return e;if((e.match(/__/g)||[]).length%2===1)return`${e}__`}return e},On=e=>{let t=0,o=e.length;for(let n=0;n<o;n+=1){if(e[n]!=="*")continue;let r=n>0?e[n-1]:"",s=n<o-1?e[n+1]:"";if(r==="\\"||r==="*"||s==="*"||r&&s&&K(r)&&K(s))continue;let a=0;for(let l=n-1;l>=0;l-=1)if(e[l]===`
16
- `){a=l+1;break}let i=!0;for(let l=a;l<n;l+=1)if(e[l]!==" "&&e[l]!==" "){i=!1;break}i&&(s===" "||s===" ")||(t+=1)}return t},zn=e=>{if(Ee(e))return e;if(e.match(Nn)){let o=-1;for(let s=0;s<e.length;s+=1)if(e[s]==="*"&&e[s-1]!=="*"&&e[s+1]!=="*"&&e[s-1]!=="\\"){let a=s>0?e[s-1]:"",i=s<e.length-1?e[s+1]:"";if(a&&i&&K(a)&&K(i))continue;o=s;break}if(o===-1)return e;let n=e.substring(o+1);if(!n||ee.test(n))return e;if(On(e)%2===1)return`${e}*`}return e},$o=(e,t)=>{let o=!1,n=!1;for(let r=0;r<e.length&&r<t;r+=1){if(e[r]==="\\"&&e[r+1]==="$"){r+=1;continue}e[r]==="$"&&(e[r+1]==="$"?(n=!n,r+=1,o=!1):n||(o=!o))}return o||n},qn=e=>{let t=e.includes("$"),o=0,n=e.length;for(let r=0;r<n;r+=1){if(e[r]!=="_")continue;let s=r>0?e[r-1]:"",a=r<n-1?e[r+1]:"";s!=="\\"&&(t&&$o(e,r)||s==="_"||a==="_"||s&&a&&K(s)&&K(a)||(o+=1))}return o},_n=e=>{if(Ee(e))return e;if(e.match(In)){let o=-1;for(let s=0;s<e.length;s+=1)if(e[s]==="_"&&e[s-1]!=="_"&&e[s+1]!=="_"&&e[s-1]!=="\\"&&!$o(e,s)){let a=s>0?e[s-1]:"",i=s<e.length-1?e[s+1]:"";if(a&&i&&K(a)&&K(i))continue;o=s;break}if(o===-1)return e;let n=e.substring(o+1);if(!n||ee.test(n))return e;if(qn(e)%2===1){let s=e.length;for(;s>0&&e[s-1]===`
17
- `;)s-=1;if(s<e.length){let a=e.slice(0,s),i=e.slice(s);return`${a}_${i}`}return`${e}_`}}return e},Fn=(e,t)=>{let o=e.substring(t,t+3)==="```",n=t>0&&e.substring(t-1,t+2)==="```",r=t>1&&e.substring(t-2,t+1)==="```";return o||n||r},Un=e=>{let t=0;for(let o=0;o<e.length;o+=1)e[o]==="`"&&!Fn(e,o)&&(t+=1);return t},Wn=e=>{if(e.match(Ln)&&!e.includes(`
18
- `))return e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e;let o=(e.match(/```/g)||[]).length,n=o%2===1;if(o>0&&o%2===0&&e.includes(`
19
- `)||(e.endsWith("```\n")||e.endsWith("```"))&&o%2===0)return e;let r=e.match(Sn);if(r&&!n){let s=r[2];if(!s||ee.test(s))return e;if(Un(e)%2===1)return`${e}\``}return e},Vn=e=>{let t=e.match(Bn);if(t){let o=t[2];if(!o||ee.test(o))return e;if((e.match(/~~/g)||[]).length%2===1)return`${e}~~`}return e},Xn=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let o=e.indexOf("$$");return o!==-1&&e.indexOf(`
20
- `,o)!==-1&&!e.endsWith(`
21
- `)?`${e}
22
- $$`:`${e}$$`},Jn=e=>{let t=0,o=0;for(let n=0;n<e.length;n+=1)e[n]==="*"?o+=1:(o>=3&&(t+=Math.floor(o/3)),o=0);return o>=3&&(t+=Math.floor(o/3)),t},Kn=e=>{if(Ee(e)||An.test(e))return e;let t=e.match(xn);if(t){let o=t[2];if(!o||ee.test(o))return e;if(Jn(e)%2===1)return`${e}***`}return e},Le=e=>{if(!e||typeof e!="string")return e;let t=e,o=$n(t);return o.endsWith("](streamdown:incomplete-link)")?o:(t=o,t=Kn(t),t=Dn(t),t=Hn(t),t=zn(t),t=_n(t),t=Wn(t),t=Vn(t),t=Xn(t),t)};var Z=require("react/jsx-runtime"),Fo={harden:[Do.harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],defaultOrigin:void 0,allowDataImages:!0}],raw:Ho.default,katex:[Ae.default,{errorColor:"var(--color-muted-foreground)"}]},Uo={gfm:[qo.default,{}],math:[_o.default,{singleDollarTextMath:!1}],cjkFriendly:[Oo.default,{}],cjkFriendlyGfmStrikethrough:[zo.default,{}]},Zn=Object.values(Fo),Gn=Object.values(Uo),Yn={shikiTheme:["github-light","github-dark"],controls:!0,isAnimating:!1,mode:"streaming",mermaid:void 0},v=(0,P.createContext)(Yn),mt=(0,P.memo)(({content:e,shouldParseIncompleteMarkdown:t,...o})=>{let n=(0,P.useMemo)(()=>typeof e=="string"&&t?Le(e.trim()):e,[e,t]);return(0,Z.jsx)(at,{...o,children:n})},(e,t)=>{if(e.content!==t.content||e.shouldParseIncompleteMarkdown!==t.shouldParseIncompleteMarkdown||e.index!==t.index)return!1;if(e.components!==t.components){let o=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(o.length!==n.length||o.some(r=>{var s,a;return((s=e.components)==null?void 0:s[r])!==((a=t.components)==null?void 0:a[r])}))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});mt.displayName="Block";var Qn=["github-light","github-dark"],Wo=(0,P.memo)(({children:e,mode:t="streaming",parseIncompleteMarkdown:o=!0,components:n,rehypePlugins:r=Zn,remarkPlugins:s=Gn,className:a,shikiTheme:i=Qn,mermaid:l,controls:c=!0,isAnimating:d=!1,BlockComponent:m=mt,parseMarkdownIntoBlocksFn:p=Be,...h})=>{let u=(0,P.useId)(),[b,w]=(0,P.useTransition)(),[C,N]=(0,P.useState)([]),B=(0,P.useMemo)(()=>p(typeof e=="string"?e:""),[e,p]);(0,P.useEffect)(()=>{t==="streaming"?w(()=>{N(B)}):N(B)},[B,t]);let I=t==="streaming"?C:B,q=(0,P.useMemo)(()=>I.map(($,oe)=>`${u}-${oe}`),[I.length,u]),G=(0,P.useMemo)(()=>({shikiTheme:i,controls:c,isAnimating:d,mode:t,mermaid:l}),[i,c,d,t,l]),te=(0,P.useMemo)(()=>({...mo,...n}),[n]);return(0,P.useEffect)(()=>{Array.isArray(r)&&r.some($=>Array.isArray($)?$[0]===Ae.default:$===Ae.default)&&import("katex/dist/katex.min.css")},[r]),t==="static"?(0,Z.jsx)(v.Provider,{value:G,children:(0,Z.jsx)("div",{className:f("space-y-4",a),children:(0,Z.jsx)(at,{components:te,rehypePlugins:r,remarkPlugins:s,...h,children:e})})}):(0,Z.jsx)(v.Provider,{value:G,children:(0,Z.jsx)("div",{className:f("space-y-4",a),children:I.map(($,oe)=>(0,Z.jsx)(m,{components:te,content:$,index:oe,rehypePlugins:r,remarkPlugins:s,shouldParseIncompleteMarkdown:o,...h},q[oe]))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode);Wo.displayName="Streamdown";0&&(module.exports={Block,Streamdown,StreamdownContext,defaultRehypePlugins,defaultRemarkPlugins,parseIncompleteMarkdown,parseMarkdownIntoBlocks});
1
+ 'use strict';var chunkUGPOVMD7_cjs=require('./chunk-UGPOVMD7.cjs');Object.defineProperty(exports,"Block",{enumerable:true,get:function(){return chunkUGPOVMD7_cjs.i}});Object.defineProperty(exports,"Streamdown",{enumerable:true,get:function(){return chunkUGPOVMD7_cjs.j}});Object.defineProperty(exports,"StreamdownContext",{enumerable:true,get:function(){return chunkUGPOVMD7_cjs.h}});Object.defineProperty(exports,"defaultRehypePlugins",{enumerable:true,get:function(){return chunkUGPOVMD7_cjs.f}});Object.defineProperty(exports,"defaultRemarkPlugins",{enumerable:true,get:function(){return chunkUGPOVMD7_cjs.g}});Object.defineProperty(exports,"parseIncompleteMarkdown",{enumerable:true,get:function(){return chunkUGPOVMD7_cjs.e}});Object.defineProperty(exports,"parseMarkdownIntoBlocks",{enumerable:true,get:function(){return chunkUGPOVMD7_cjs.d}});
package/dist/index.js CHANGED
@@ -1,22 +1 @@
1
- "use client";var No=Object.create;var Ze=Object.defineProperty;var Io=Object.getOwnPropertyDescriptor;var So=Object.getOwnPropertyNames;var Bo=Object.getPrototypeOf,Eo=Object.prototype.hasOwnProperty;var Lo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ao=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of So(t))!Eo.call(e,r)&&r!==o&&Ze(e,r,{get:()=>t[r],enumerable:!(n=Io(t,r))||n.enumerable});return e};var Ro=(e,t,o)=>(o=e!=null?No(Bo(e)):{},Ao(t||!e||!e.__esModule?Ze(o,"default",{value:e,enumerable:!0}):o,e));var lo=Lo((Ji,ao)=>{"use strict";var me=Object.prototype.hasOwnProperty,io=Object.prototype.toString,eo=Object.defineProperty,to=Object.getOwnPropertyDescriptor,oo=function(t){return typeof Array.isArray=="function"?Array.isArray(t):io.call(t)==="[object Array]"},no=function(t){if(!t||io.call(t)!=="[object Object]")return!1;var o=me.call(t,"constructor"),n=t.constructor&&t.constructor.prototype&&me.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!o&&!n)return!1;var r;for(r in t);return typeof r=="undefined"||me.call(t,r)},ro=function(t,o){eo&&o.name==="__proto__"?eo(t,o.name,{enumerable:!0,configurable:!0,value:o.newValue,writable:!0}):t[o.name]=o.newValue},so=function(t,o){if(o==="__proto__")if(me.call(t,o)){if(to)return to(t,o).value}else return;return t[o]};ao.exports=function e(){var t,o,n,r,s,a,i=arguments[0],l=1,c=arguments.length,d=!1;for(typeof i=="boolean"&&(d=i,i=arguments[1]||{},l=2),(i==null||typeof i!="object"&&typeof i!="function")&&(i={});l<c;++l)if(t=arguments[l],t!=null)for(o in t)n=so(i,o),r=so(t,o),i!==r&&(d&&r&&(no(r)||(s=oo(r)))?(s?(s=!1,a=n&&oo(n)?n:[]):a=n&&no(n)?n:{},ro(i,{name:o,newValue:e(d,a,r)})):typeof r!="undefined"&&ro(i,{name:o,newValue:r}));return i}});import{createContext as Ar,memo as Po,useEffect as To,useId as Rr,useMemo as Y,useState as jr,useTransition as $r}from"react";import{harden as Dr}from"rehype-harden";import Je from"rehype-katex";import Hr from"rehype-raw";import Or from"remark-cjk-friendly";import zr from"remark-cjk-friendly-gfm-strikethrough";import qr from"remark-gfm";import _r from"remark-math";import{isValidElement as U,memo as C,useContext as Nt}from"react";import{useContext as Zo,useEffect as Go,useMemo as Yo,useState as Qo}from"react";import{memo as Do,useMemo as Ho}from"react";import{clsx as jo}from"clsx";import{twMerge as $o}from"tailwind-merge";var f=(...e)=>$o(jo(e)),E=(e,t,o)=>{let n=typeof t=="string"?new Blob([t],{type:o}):t,r=URL.createObjectURL(n),s=document.createElement("a");s.href=r,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r)};import{jsx as Q}from"react/jsx-runtime";var Oo=f("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-4","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),Ge=Do(({children:e,result:t,language:o,className:n,...r})=>{let s=Ho(()=>({backgroundColor:t.bg,color:t.fg}),[t.bg,t.fg]);return Q("pre",{className:f(n,"p-4 text-sm"),"data-code-block":!0,"data-language":o,style:s,...r,children:Q("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:t.tokens.map((a,i)=>Q("span",{className:Oo,children:a.map((l,c)=>Q("span",{style:{color:l.color,backgroundColor:l.bgColor,...l.htmlStyle},...l.htmlAttrs,children:l.content},c))},i))})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className);import{jsx as zo}from"react/jsx-runtime";var Ye=({className:e,language:t,style:o,...n})=>zo("div",{className:f("my-4 w-full overflow-hidden rounded-xl border border-border",e),"data-code-block-container":!0,"data-language":t,style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...n});import{createContext as qo,useContext as _o}from"react";var ye=qo({code:""}),ee=()=>_o(ye);import{jsx as Qe,jsxs as Fo}from"react/jsx-runtime";var et=({language:e,children:t})=>Fo("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-code-block-header":!0,"data-language":e,children:[Qe("span",{className:"ml-1 font-mono lowercase",children:e}),Qe("div",{className:"flex items-center gap-2",children:t})]});import{createHighlighter as Uo}from"shiki";import{createJavaScriptRegexEngine as Wo}from"shiki/engine/javascript";var Vo=Wo({forgiving:!0}),we=new Map,ke=new Map,_=new Map,Xo=(e,t)=>`${e}-${t[0]}-${t[1]}`,Jo=(e,t,o)=>{let n=e.slice(0,100),r=e.length>100?e.slice(-100):"";return`${t}:${o[0]}:${o[1]}:${e.length}:${n}:${r}`},Ko=(e,t)=>{let o=Xo(e,t);if(we.has(o))return we.get(o);let n=Uo({themes:t,langs:[e],engine:Vo});return we.set(o,n),n},Ce=(e,t,o,n)=>{let r=Jo(e,t,o);return ke.has(r)?ke.get(r):(n&&(_.has(r)||_.set(r,new Set),_.get(r).add(n)),Ko(t,o).then(s=>{let a=s.codeToTokens(e,{lang:t,themes:{light:o[0],dark:o[1]}});ke.set(r,a);let i=_.get(r);if(i){for(let l of i)l(a);_.delete(r)}}).catch(s=>{console.error("Failed to highlight code:",s),_.delete(r)}),null)};import{jsx as ve,jsxs as en}from"react/jsx-runtime";var tt=({code:e,language:t,className:o,children:n,preClassName:r,...s})=>{let{shikiTheme:a}=Zo(M),i=Yo(()=>({bg:"transparent",fg:"inherit",tokens:e.split(`
2
- `).map(d=>[{content:d,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[e]),[l,c]=Qo(i);return Go(()=>{let d=Ce(e,t,a);if(d){c(d);return}Ce(e,t,a,m=>{c(m)})},[e,t,a]),ve(ye.Provider,{value:{code:e},children:en(Ye,{language:t,children:[ve(et,{language:t,children:n}),ve(Ge,{className:o,language:t,result:l,...s})]})})};import{CheckIcon as tn,CopyIcon as on}from"lucide-react";import{useContext as nn,useEffect as rn,useRef as sn,useState as an}from"react";import{jsx as ot}from"react/jsx-runtime";var Me=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let[i,l]=an(!1),c=sn(0),{code:d}=ee(),{isAnimating:m}=nn(M),p=s!=null?s:d,h=async()=>{var g;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(p),l(!0),e==null||e(),c.current=window.setTimeout(()=>l(!1),o))}catch(y){t==null||t(y)}};rn(()=>()=>{window.clearTimeout(c.current)},[]);let u=i?tn:on;return ot("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:m,onClick:h,type:"button",...a,children:n!=null?n:ot(u,{size:14})})};import{DownloadIcon as ln}from"lucide-react";import{useContext as cn}from"react";import{jsx as rt}from"react/jsx-runtime";var nt={"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"},st=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let{code:i}=ee(),{isAnimating:l}=cn(M),c=s!=null?s:i,m=`file.${o&&o in nt?nt[o]:"txt"}`,p="text/plain",h=()=>{try{E(m,c,p),e==null||e()}catch(u){t==null||t(u)}};return rt("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:l,onClick:h,title:"Download file",type:"button",...a,children:n!=null?n:rt(ln,{size:14})})};import{DownloadIcon as dn}from"lucide-react";import{jsx as te,jsxs as pn}from"react/jsx-runtime";var mn=/\.[^/.]+$/,it=({node:e,className:t,src:o,alt:n,...r})=>{let s=async()=>{if(o)try{let i=await(await fetch(o)).blob(),c=new URL(o,window.location.origin).pathname.split("/").pop()||"",d=c.split(".").pop(),m=c.includes(".")&&d!==void 0&&d.length<=4,p="";if(m)p=c;else{let h=i.type,u="png";h.includes("jpeg")||h.includes("jpg")?u="jpg":h.includes("png")?u="png":h.includes("svg")?u="svg":h.includes("gif")?u="gif":h.includes("webp")&&(u="webp"),p=`${(n||c||"image").replace(mn,"")}.${u}`}E(p,i,i.type)}catch(a){console.error("Failed to download image:",a)}};return o?pn("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[te("img",{alt:n,className:f("max-w-full rounded-lg",t),"data-streamdown":"image",src:o,...r}),te("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),te("button",{className:f("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:te(dn,{size:14})})]}):null};import{useContext as gn,useEffect as bn,useState as X}from"react";import{RotateCcwIcon as un,ZoomInIcon as fn,ZoomOutIcon as hn}from"lucide-react";import{useCallback as A,useEffect as at,useRef as lt,useState as V}from"react";import{jsx as D,jsxs as ct}from"react/jsx-runtime";var dt=({children:e,className:t,minZoom:o=.5,maxZoom:n=3,zoomStep:r=.1,showControls:s=!0,initialZoom:a=1,fullscreen:i=!1})=>{let l=lt(null),c=lt(null),[d,m]=V(a),[p,h]=V({x:0,y:0}),[u,g]=V(!1),[y,k]=V({x:0,y:0}),[P,N]=V({x:0,y:0}),x=A(w=>{m(I=>Math.max(o,Math.min(n,I+w)))},[o,n]),L=A(()=>{x(r)},[x,r]),$=A(()=>{x(-r)},[x,r]),z=A(()=>{m(a),h({x:0,y:0})},[a]),B=A(w=>{w.preventDefault();let I=w.deltaY>0?-r:r;x(I)},[x,r]),q=A(w=>{if(w.button!==0||w.isPrimary===!1)return;g(!0),k({x:w.clientX,y:w.clientY}),N(p);let I=w.currentTarget;I instanceof HTMLElement&&I.setPointerCapture(w.pointerId)},[p]),be=A(w=>{if(!u)return;w.preventDefault();let I=w.clientX-y.x,Ke=w.clientY-y.y;h({x:P.x+I,y:P.y+Ke})},[u,y,P]),W=A(w=>{g(!1);let I=w.currentTarget;I instanceof HTMLElement&&I.releasePointerCapture(w.pointerId)},[]);return at(()=>{let w=l.current;if(w)return w.addEventListener("wheel",B,{passive:!1}),()=>{w.removeEventListener("wheel",B)}},[B]),at(()=>{let w=c.current;if(w&&u)return document.body.style.userSelect="none",w.addEventListener("pointermove",be,{passive:!1}),w.addEventListener("pointerup",W),w.addEventListener("pointercancel",W),()=>{document.body.style.userSelect="",w.removeEventListener("pointermove",be),w.removeEventListener("pointerup",W),w.removeEventListener("pointercancel",W)}},[u,be,W]),ct("div",{className:f("relative",i?"h-full w-full":"w-full",t),ref:l,style:{cursor:u?"grabbing":"grab"},children:[s&&ct("div",{className:f("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:[D("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:L,title:"Zoom in",type:"button",children:D(fn,{size:16})}),D("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:$,title:"Zoom out",type:"button",children:D(hn,{size:16})}),D("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:z,title:"Reset zoom and pan",type:"button",children:D(un,{size:16})})]}),D("div",{className:f("origin-center transition-transform duration-150 ease-out",i&&"flex h-full w-full items-center justify-center"),onPointerDown:q,ref:c,role:"application",style:{transform:`translate(${p.x}px, ${p.y}px) scale(${d})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var oe=async e=>{let o={...{startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0},...e},r=(await import("mermaid")).default;return r.initialize(o),r},mt=(e,t)=>{var n;let o=(n=t==null?void 0:t.scale)!=null?n:5;return new Promise((r,s)=>{let a="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let l=document.createElement("canvas"),c=i.width*o,d=i.height*o;l.width=c,l.height=d;let m=l.getContext("2d");if(!m){s(new Error("Failed to create 2D canvas context for PNG export"));return}m.drawImage(i,0,0,c,d),l.toBlob(p=>{if(!p){s(new Error("Failed to create PNG blob"));return}r(p)},"image/png")},i.onerror=()=>s(new Error("Failed to load SVG image")),i.src=a})};import{jsx as R,jsxs as ne}from"react/jsx-runtime";var re=({chart:e,className:t,config:o,fullscreen:n=!1})=>{let[r,s]=X(null),[a,i]=X(!0),[l,c]=X(""),[d,m]=X(""),[p,h]=X(0),{mermaid:u}=gn(M),g=u==null?void 0:u.errorComponent;if(bn(()=>{(async()=>{try{s(null),i(!0);let P=await oe(o),N=e.split("").reduce(($,z)=>($<<5)-$+z.charCodeAt(0)|0,0),x=`mermaid-${Math.abs(N)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:L}=await P.render(x,e);c(L),m(L)}catch(P){if(!(d||l)){let N=P instanceof Error?P.message:"Failed to render Mermaid chart";s(N)}}finally{i(!1)}})()},[e,o,p]),a&&!l&&!d)return R("div",{className:f("my-4 flex justify-center p-4",t),children:ne("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[R("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),R("span",{className:"text-sm",children:"Loading diagram..."})]})});if(r&&!l&&!d){let k=()=>h(P=>P+1);return g?R(g,{chart:e,error:r,retry:k}):ne("div",{className:f("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[ne("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),ne("details",{className:"mt-2",children:[R("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),R("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let y=l||d;return R(dt,{className:f(n?"h-full w-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:!0,zoomStep:.1,children:R("div",{"aria-label":"Mermaid chart",className:f("flex justify-center",n&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:y},role:"img"})})};import{DownloadIcon as yn}from"lucide-react";import{useContext as wn,useEffect as kn,useRef as Cn,useState as vn}from"react";import{jsx as J,jsxs as pt}from"react/jsx-runtime";var ut=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let[a,i]=vn(!1),l=Cn(null),{isAnimating:c}=wn(M),d=async m=>{try{if(m==="mmd"){E("diagram.mmd",e,"text/plain"),i(!1),n==null||n(m);return}let p=await oe(r),h=e.split("").reduce((y,k)=>(y<<5)-y+k.charCodeAt(0)|0,0),u=`mermaid-${Math.abs(h)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:g}=await p.render(u,e);if(!g){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(m==="svg"){E("diagram.svg",g,"image/svg+xml"),i(!1),n==null||n(m);return}if(m==="png"){let y=await mt(g);E("diagram.png",y,"image/png"),n==null||n(m),i(!1);return}}catch(p){s==null||s(p)}};return kn(()=>{let m=p=>{l.current&&!l.current.contains(p.target)&&i(!1)};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]),pt("div",{className:"relative",ref:l,children:[J("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:c,onClick:()=>i(!a),title:"Download diagram",type:"button",children:t!=null?t:J(yn,{size:14})}),a&&pt("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:[J("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("svg"),type:"button",children:"SVG"}),J("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("png"),type:"button",children:"PNG"}),J("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("mmd"),type:"button",children:"MMD"})]})]})};import{Maximize2Icon as Mn,XIcon as Tn}from"lucide-react";import{useContext as Pn,useEffect as ft,useState as xn}from"react";import{Fragment as Sn,jsx as F,jsxs as ht}from"react/jsx-runtime";var K=0,Nn=()=>{K+=1,K===1&&(document.body.style.overflow="hidden")},In=()=>{K=Math.max(0,K-1),K===0&&(document.body.style.overflow="")},gt=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let[a,i]=xn(!1),{isAnimating:l}=Pn(M),c=()=>{i(!a)};return ft(()=>{if(a){Nn();let d=m=>{m.key==="Escape"&&i(!1)};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),In()}}},[a]),ft(()=>{a?o==null||o():n&&n()},[a,o,n]),ht(Sn,{children:[F("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:l,onClick:c,title:"View fullscreen",type:"button",...s,children:F(Mn,{size:14})}),a&&ht("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:c,onKeyDown:d=>{d.key==="Escape"&&c()},role:"button",tabIndex:0,children:[F("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:c,title:"Exit fullscreen",type:"button",children:F(Tn,{size:20})}),F("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:d=>d.stopPropagation(),onKeyDown:d=>d.stopPropagation(),role:"presentation",children:F(re,{chart:e,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:!0})})]})]})};import{CheckIcon as Bn,CopyIcon as En}from"lucide-react";import{useContext as Ln,useEffect as An,useRef as wt,useState as kt}from"react";var se=e=>{var s,a;let t=[],o=[],n=e.querySelectorAll("thead th");for(let i of n)t.push(((s=i.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let i of r){let l=[],c=i.querySelectorAll("td");for(let d of c)l.push(((a=d.textContent)==null?void 0:a.trim())||"");o.push(l)}return{headers:t,rows:o}},ie=e=>{let{headers:t,rows:o}=e,n=i=>{let l=!1,c=!1;for(let d=0;d<i.length;d+=1){let m=i[d];if(m==='"'){l=!0,c=!0;break}(m===","||m===`
3
- `)&&(l=!0)}return l?c?`"${i.replace(/"/g,'""')}"`:`"${i}"`:i},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(","),a+=1);for(let i of o)s[a]=i.map(n).join(","),a+=1;return s.join(`
4
- `)},bt=e=>{let{headers:t,rows:o}=e,n=i=>{let l=!1;for(let d=0;d<i.length;d+=1){let m=i[d];if(m===" "||m===`
5
- `||m==="\r"){l=!0;break}}if(!l)return i;let c=[];for(let d=0;d<i.length;d+=1){let m=i[d];m===" "?c.push("\\t"):m===`
6
- `?c.push("\\n"):m==="\r"?c.push("\\r"):c.push(m)}return c.join("")},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(" "),a+=1);for(let i of o)s[a]=i.map(n).join(" "),a+=1;return s.join(`
7
- `)},Te=e=>{let t=!1;for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="\\"||r==="|"){t=!0;break}}if(!t)return e;let o=[];for(let n=0;n<e.length;n+=1){let r=e[n];r==="\\"?o.push("\\\\"):r==="|"?o.push("\\|"):o.push(r)}return o.join("")},yt=e=>{let{headers:t,rows:o}=e;if(t.length===0)return"";let n=new Array(o.length+2),r=0,s=t.map(i=>Te(i));n[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let i=0;i<t.length;i+=1)a[i]="---";n[r]=`| ${a.join(" | ")} |`,r+=1;for(let i of o)if(i.length<t.length){let l=new Array(t.length);for(let c=0;c<t.length;c+=1)l[c]=c<i.length?Te(i[c]):"";n[r]=`| ${l.join(" | ")} |`,r+=1}else{let l=i.map(c=>Te(c));n[r]=`| ${l.join(" | ")} |`,r+=1}return n.join(`
8
- `)};import{jsx as ae,jsxs as Ct}from"react/jsx-runtime";var vt=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let[s,a]=kt(!1),[i,l]=kt(!1),c=wt(null),d=wt(0),{isAnimating:m}=Ln(M),p=async u=>{var g,y;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.write)){n==null||n(new Error("Clipboard API not available"));return}try{let k=(y=c.current)==null?void 0:y.closest('[data-streamdown="table-wrapper"]'),P=k==null?void 0:k.querySelector("table");if(!P){n==null||n(new Error("Table not found"));return}let N=se(P),x=u==="csv"?ie(N):bt(N),L=new ClipboardItem({"text/plain":new Blob([x],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([L]),l(!0),a(!1),o==null||o(u),d.current=window.setTimeout(()=>l(!1),r)}catch(k){n==null||n(k)}};An(()=>{let u=g=>{c.current&&!c.current.contains(g.target)&&a(!1)};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u),window.clearTimeout(d.current)}},[]);let h=i?Bn:En;return Ct("div",{className:"relative",ref:c,children:[ae("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>a(!s),title:"Copy table",type:"button",children:e!=null?e:ae(h,{size:14})}),s&&Ct("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:[ae("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("csv"),type:"button",children:"CSV"}),ae("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>p("tsv"),type:"button",children:"TSV"})]})]})};import{DownloadIcon as Rn}from"lucide-react";import{useContext as jn,useEffect as $n,useRef as Dn,useState as Hn}from"react";import{jsx as le,jsxs as Mt}from"react/jsx-runtime";var Tt=({children:e,className:t,onDownload:o,onError:n})=>{let[r,s]=Hn(!1),a=Dn(null),{isAnimating:i}=jn(M),l=c=>{var d;try{let m=(d=a.current)==null?void 0:d.closest('[data-streamdown="table-wrapper"]'),p=m==null?void 0:m.querySelector("table");if(!p){n==null||n(new Error("Table not found"));return}let h=se(p),u=c==="csv"?ie(h):yt(h);E(`table.${c==="csv"?"csv":"md"}`,u,c==="csv"?"text/csv":"text/markdown"),s(!1),o==null||o(c)}catch(m){n==null||n(m)}};return $n(()=>{let c=d=>{a.current&&!a.current.contains(d.target)&&s(!1)};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[]),Mt("div",{className:"relative",ref:a,children:[le("button",{className:f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>s(!r),title:"Download table",type:"button",children:e!=null?e:le(Rn,{size:14})}),r&&Mt("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:[le("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("csv"),type:"button",children:"CSV"}),le("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),type:"button",children:"Markdown"})]})]})};import{jsx as ce,jsxs as Pt}from"react/jsx-runtime";var xt=({children:e,className:t,showControls:o,...n})=>Pt("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[o&&Pt("div",{className:"flex items-center justify-end gap-1",children:[ce(vt,{}),ce(Tt,{})]}),ce("div",{className:"overflow-x-auto",children:ce("table",{className:f("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]});import{Fragment as Qt,jsx as b,jsxs as xe}from"react/jsx-runtime";var On=/language-([^\s]+)/;function de(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&(t!=null&&t.position)))return!1;let o=e.position.start,n=t.position.start,r=e.position.end,s=t.position.end;return(o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function v(e,t){return e.className===t.className&&de(e.node,t.node)}var Ne=(e,t)=>typeof e=="boolean"?e:e[t]!==!1,Pe=(e,t)=>{if(typeof e=="boolean")return e;let o=e.mermaid;return o===!1?!1:o===!0||o===void 0?!0:o[t]!==!1},Ie=C(({children:e,className:t,node:o,...n})=>b("ol",{className:f("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>v(e,t));Ie.displayName="MarkdownOl";var It=C(({children:e,className:t,node:o,...n})=>b("li",{className:f("py-1",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&de(e.node,t.node));It.displayName="MarkdownLi";var St=C(({children:e,className:t,node:o,...n})=>b("ul",{className:f("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>v(e,t));St.displayName="MarkdownUl";var Bt=C(({className:e,node:t,...o})=>b("hr",{className:f("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o}),(e,t)=>v(e,t));Bt.displayName="MarkdownHr";var Et=C(({children:e,className:t,node:o,...n})=>b("span",{className:f("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>v(e,t));Et.displayName="MarkdownStrong";var Lt=C(({children:e,className:t,href:o,node:n,...r})=>{let s=o==="streamdown:incomplete-link";return b("a",{className:f("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":s,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},(e,t)=>v(e,t)&&e.href===t.href);Lt.displayName="MarkdownA";var At=C(({children:e,className:t,node:o,...n})=>b("h1",{className:f("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>v(e,t));At.displayName="MarkdownH1";var Rt=C(({children:e,className:t,node:o,...n})=>b("h2",{className:f("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>v(e,t));Rt.displayName="MarkdownH2";var jt=C(({children:e,className:t,node:o,...n})=>b("h3",{className:f("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>v(e,t));jt.displayName="MarkdownH3";var $t=C(({children:e,className:t,node:o,...n})=>b("h4",{className:f("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>v(e,t));$t.displayName="MarkdownH4";var Dt=C(({children:e,className:t,node:o,...n})=>b("h5",{className:f("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>v(e,t));Dt.displayName="MarkdownH5";var Ht=C(({children:e,className:t,node:o,...n})=>b("h6",{className:f("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>v(e,t));Ht.displayName="MarkdownH6";var Ot=C(({children:e,className:t,node:o,...n})=>{let{controls:r}=Nt(M),s=Ne(r,"table");return b(xt,{className:t,"data-streamdown":"table-wrapper",showControls:s,...n,children:e})},(e,t)=>v(e,t));Ot.displayName="MarkdownTable";var zt=C(({children:e,className:t,node:o,...n})=>b("thead",{className:f("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>v(e,t));zt.displayName="MarkdownThead";var qt=C(({children:e,className:t,node:o,...n})=>b("tbody",{className:f("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>v(e,t));qt.displayName="MarkdownTbody";var _t=C(({children:e,className:t,node:o,...n})=>b("tr",{className:f("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>v(e,t));_t.displayName="MarkdownTr";var Ft=C(({children:e,className:t,node:o,...n})=>b("th",{className:f("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>v(e,t));Ft.displayName="MarkdownTh";var Ut=C(({children:e,className:t,node:o,...n})=>b("td",{className:f("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>v(e,t));Ut.displayName="MarkdownTd";var Wt=C(({children:e,className:t,node:o,...n})=>b("blockquote",{className:f("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>v(e,t));Wt.displayName="MarkdownBlockquote";var Vt=C(({children:e,className:t,node:o,...n})=>b("sup",{className:f("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>v(e,t));Vt.displayName="MarkdownSup";var Xt=C(({children:e,className:t,node:o,...n})=>b("sub",{className:f("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>v(e,t));Xt.displayName="MarkdownSub";var Jt=C(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=l=>{var p,h;if(!U(l))return!1;let c=Array.isArray(l.props.children)?l.props.children:[l.props.children],d=!1,m=!1;for(let u of c)if(u){if(typeof u=="string")u.trim()!==""&&(d=!0);else if(U(u))if(((p=u.props)==null?void 0:p["data-footnote-backref"])!==void 0)m=!0;else{let g=Array.isArray(u.props.children)?u.props.children:[u.props.children];for(let y of g){if(typeof y=="string"&&y.trim()!==""){d=!0;break}if(U(y)&&((h=y.props)==null?void 0:h["data-footnote-backref"])===void 0){d=!0;break}}}}return m&&!d},a=Array.isArray(e)?e.map(l=>{if(!U(l))return l;if(l.type===Ie){let d=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!s(m));return d.length===0?null:{...l,props:{...l.props,children:d}}}return l}):e;return(Array.isArray(a)?a.some(l=>l!==null):a!==null)?b("section",{className:t,...n,children:a}):null}return b("section",{className:t,...n,children:e})},(e,t)=>v(e,t));Jt.displayName="MarkdownSection";var zn=({node:e,className:t,children:o,...n})=>{var m,p,h;let r=((m=e==null?void 0:e.position)==null?void 0:m.start.line)===((p=e==null?void 0:e.position)==null?void 0:p.end.line),{mermaid:s,controls:a}=Nt(M);if(r)return b("code",{className:f("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let i=t==null?void 0:t.match(On),l=(h=i==null?void 0:i.at(1))!=null?h:"",c="";if(U(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"){let u=Ne(a,"mermaid"),g=Pe(a,"download"),y=Pe(a,"copy"),k=Pe(a,"fullscreen");return xe("div",{className:f("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[u&&(g||y||k)&&xe("div",{className:"flex items-center justify-end gap-2",children:[g&&b(ut,{chart:c,config:s==null?void 0:s.config}),y&&b(Me,{code:c}),k&&b(gt,{chart:c,config:s==null?void 0:s.config})]}),b(re,{chart:c,config:s==null?void 0:s.config})]})}let d=Ne(a,"code");return b(tt,{className:f("overflow-x-auto border-border border-t",t),code:c,"data-language":l,"data-streamdown":"code-block",language:l,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:d&&xe(Qt,{children:[b(st,{code:c,language:l}),b(Me,{})]})})},Kt=C(zn,(e,t)=>e.className===t.className&&de(e.node,t.node));Kt.displayName="MarkdownCode";var Zt=C(it,(e,t)=>e.className===t.className&&de(e.node,t.node));Zt.displayName="MarkdownImg";var Gt=C(({children:e,className:t,node:o,...n})=>{var a;let s=(Array.isArray(e)?e:[e]).filter(i=>i!=null&&i!=="");return s.length===1&&U(s[0])&&((a=s[0].props.node)==null?void 0:a.tagName)==="img"?b(Qt,{children:e}):b("p",{className:t,...n,children:e})},(e,t)=>v(e,t));Gt.displayName="MarkdownParagraph";var Yt={ol:Ie,li:It,ul:St,hr:Bt,strong:Et,a:Lt,h1:At,h2:Rt,h3:jt,h4:$t,h5:Dt,h6:Ht,table:Ot,thead:zt,tbody:qt,tr:_t,th:Ft,td:Ut,blockquote:Wt,code:Kt,img:Zt,pre:({children:e})=>e,sup:Vt,sub:Xt,p:Gt,section:Jt};import{toJsxRuntime as Vn}from"hast-util-to-jsx-runtime";import{Fragment as Xn,jsx as Jn,jsxs as Kn}from"react/jsx-runtime";import Zn from"remark-parse";import Gn from"remark-rehype";function Se(e){if(e)throw e}var fe=Ro(lo(),1);function Z(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Be(){let e=[],t={run:o,use:n};return t;function o(...r){let s=-1,a=r.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);i(null,...r);function i(l,...c){let d=e[++s],m=-1;if(l){a(l);return}for(;++m<r.length;)(c[m]===null||c[m]===void 0)&&(c[m]=r[m]);r=c,d?co(d,i)(...c):a(null,...c)}}function n(r){if(typeof r!="function")throw new TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),t}}function co(e,t){let o;return n;function n(...a){let i=e.length>a.length,l;i&&a.push(r);try{l=e.apply(this,a)}catch(c){let d=c;if(i&&o)throw d;return r(d)}i||(l&&l.then&&typeof l.then=="function"?l.then(s,r):l instanceof Error?r(l):s(l))}function r(a,...i){o||(o=!0,t(a,...i))}function s(a){r(null,a)}}function Le(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?mo(e.position):"start"in e||"end"in e?mo(e):"line"in e||"column"in e?Ee(e):""}function Ee(e){return po(e&&e.line)+":"+po(e&&e.column)}function mo(e){return Ee(e&&e.start)+"-"+Ee(e&&e.end)}function po(e){return e&&typeof e=="number"?e:1}var T=class extends Error{constructor(t,o,n){super(),typeof o=="string"&&(n=o,o=void 0);let r="",s={},a=!1;if(o&&("line"in o&&"column"in o?s={place:o}:"start"in o&&"end"in o?s={place:o}:"type"in o?s={ancestors:[o],place:o.position}:s={...o}),typeof t=="string"?r=t:!s.cause&&t&&(a=!0,r=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof n=="string"){let l=n.indexOf(":");l===-1?s.ruleId=n:(s.source=n.slice(0,l),s.ruleId=n.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){let l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}let i=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=i?i.line:void 0,this.name=Le(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};T.prototype.file="";T.prototype.name="";T.prototype.reason="";T.prototype.message="";T.prototype.stack="";T.prototype.column=void 0;T.prototype.line=void 0;T.prototype.ancestors=void 0;T.prototype.cause=void 0;T.prototype.fatal=void 0;T.prototype.place=void 0;T.prototype.ruleId=void 0;T.prototype.source=void 0;import{default as S}from"path";import{default as uo}from"process";import{fileURLToPath as fo}from"url";function pe(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}var Ae=["history","path","basename","stem","extname","dirname"],G=class{constructor(t){let o;t?pe(t)?o={path:t}:typeof t=="string"||qn(t)?o={value:t}:o=t:o={},this.cwd="cwd"in o?"":uo.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Ae.length;){let s=Ae[n];s in o&&o[s]!==void 0&&o[s]!==null&&(this[s]=s==="history"?[...o[s]]:o[s])}let r;for(r in o)Ae.includes(r)||(this[r]=o[r])}get basename(){return typeof this.path=="string"?S.basename(this.path):void 0}set basename(t){je(t,"basename"),Re(t,"basename"),this.path=S.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?S.dirname(this.path):void 0}set dirname(t){ho(this.basename,"dirname"),this.path=S.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?S.extname(this.path):void 0}set extname(t){if(Re(t,"extname"),ho(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=S.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){pe(t)&&(t=fo(t)),je(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?S.basename(this.path,this.extname):void 0}set stem(t){je(t,"stem"),Re(t,"stem"),this.path=S.join(this.dirname||"",t+(this.extname||""))}fail(t,o,n){let r=this.message(t,o,n);throw r.fatal=!0,r}info(t,o,n){let r=this.message(t,o,n);return r.fatal=void 0,r}message(t,o,n){let r=new T(t,o,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}};function Re(e,t){if(e&&e.includes(S.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+S.sep+"`")}function je(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function ho(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function qn(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var go=(function(e){let n=this.constructor.prototype,r=n[e],s=function(){return r.apply(s,arguments)};return Object.setPrototypeOf(s,n),s});var _n={}.hasOwnProperty,Oe=class e extends go{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Be()}copy(){let t=new e,o=-1;for(;++o<this.attachers.length;){let n=this.attachers[o];t.use(...n)}return t.data((0,fe.default)(!0,{},this.namespace)),t}data(t,o){return typeof t=="string"?arguments.length===2?(He("data",this.frozen),this.namespace[t]=o,this):_n.call(this.namespace,t)&&this.namespace[t]||void 0:t?(He("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[o,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=o.call(t,...n);typeof r=="function"&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let o=ue(t),n=this.parser||this.Parser;return $e("parse",n),n(String(o),o)}process(t,o){let n=this;return this.freeze(),$e("process",this.parser||this.Parser),De("process",this.compiler||this.Compiler),o?r(void 0,o):new Promise(r);function r(s,a){let i=ue(t),l=n.parse(i);n.run(l,i,function(d,m,p){if(d||!m||!p)return c(d);let h=m,u=n.stringify(h,p);Un(u)?p.value=u:p.result=u,c(d,p)});function c(d,m){d||!m?a(d):s?s(m):o(void 0,m)}}}processSync(t){let o=!1,n;return this.freeze(),$e("processSync",this.parser||this.Parser),De("processSync",this.compiler||this.Compiler),this.process(t,r),yo("processSync","process",o),n;function r(s,a){o=!0,Se(s),n=a}}run(t,o,n){bo(t),this.freeze();let r=this.transformers;return!n&&typeof o=="function"&&(n=o,o=void 0),n?s(void 0,n):new Promise(s);function s(a,i){let l=ue(o);r.run(t,l,c);function c(d,m,p){let h=m||t;d?i(d):a?a(h):n(void 0,h,p)}}}runSync(t,o){let n=!1,r;return this.run(t,o,s),yo("runSync","run",n),r;function s(a,i){Se(a),r=i,n=!0}}stringify(t,o){this.freeze();let n=ue(o),r=this.compiler||this.Compiler;return De("stringify",r),bo(t),r(t,n)}use(t,...o){let n=this.attachers,r=this.namespace;if(He("use",this.frozen),t!=null)if(typeof t=="function")l(t,o);else if(typeof t=="object")Array.isArray(t)?i(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){let[d,...m]=c;l(d,m)}else a(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function a(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(c.plugins),c.settings&&(r.settings=(0,fe.default)(!0,r.settings,c.settings))}function i(c){let d=-1;if(c!=null)if(Array.isArray(c))for(;++d<c.length;){let m=c[d];s(m)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,d){let m=-1,p=-1;for(;++m<n.length;)if(n[m][0]===c){p=m;break}if(p===-1)n.push([c,...d]);else if(d.length>0){let[h,...u]=d,g=n[p][1];Z(g)&&Z(h)&&(h=(0,fe.default)(!0,g,h)),n[p]=[c,h,...u]}}}},ze=new Oe().freeze();function $e(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function De(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function He(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function bo(e){if(!Z(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function yo(e,t,o){if(!o)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ue(e){return Fn(e)?e:new G(e)}function Fn(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Un(e){return typeof e=="string"||Wn(e)}function Wn(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var wo=[],ko={allowDangerousHtml:!0},he=new WeakMap,qe=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100}generateCacheKey(t){let o=this.keyCache.get(t);if(o)return o;let n=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||r||s)){let m="default";return this.keyCache.set(t,m),m}let a=m=>{if(!m||m.length===0)return"";let p="";for(let h=0;h<m.length;h+=1){let u=m[h];if(h>0&&(p+=","),Array.isArray(u)){let[g,y]=u;if(typeof g=="function"){let k=he.get(g);k||(k=g.name,he.set(g,k)),p+=k}else p+=String(g);p+=":",p+=JSON.stringify(y)}else if(typeof u=="function"){let g=he.get(u);g||(g=u.name,he.set(u,g)),p+=g}else p+=String(u)}return p},i=a(n),l=a(r),c=s?JSON.stringify(s):"",d=`${l}::${i}::${c}`;return this.keyCache.set(t,d),d}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r)}this.cache.set(n,o)}clear(){this.cache.clear()}},Co=new qe,_e=e=>{let t=Yn(e),o=e.children||"";return er(t.runSync(t.parse(o),o),e)},Yn=e=>{let t=Co.get(e);if(t)return t;let o=Qn(e);return Co.set(e,o),o},Qn=e=>{let t=e.rehypePlugins||wo,o=e.remarkPlugins||wo,n=e.remarkRehypeOptions?{...ko,...e.remarkRehypeOptions}:ko;return ze().use(Zn).use(o).use(Gn,n).use(t)},er=(e,t)=>Vn(e,{Fragment:Xn,components:t.components,ignoreInvalidStyle:!0,jsx:Jn,jsxs:Kn,passKeys:!0,passNode:!0});import{Lexer as tr}from"marked";var or=/\[\^[^\]\s]{1,200}\](?!:)/,nr=/\[\^[^\]\s]{1,200}\]:/,rr=/<\/(\w+)>/,sr=/<(\w+)[\s>]/,Fe=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]==="$"},ir=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]==="$"},Ue=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},We=e=>{let t=or.test(e),o=nr.test(e);if(t||o)return[e];let n=tr.lex(e,{gfm:!0}),r=[],s=[];for(let a of n){let i=a.raw,l=r.length;if(s.length>0){if(r[l-1]+=i,a.type==="html"){let d=i.match(rr);if(d){let m=d[1];s.at(-1)===m&&s.pop()}}continue}if(a.type==="html"&&a.block){let d=i.match(sr);if(d){let m=d[1];i.includes(`</${m}>`)||s.push(m)}}if(i.trim()==="$$"&&l>0){let d=r[l-1],m=Fe(d),p=Ue(d);if(m&&p%2===1){r[l-1]=d+i;continue}}if(l>0&&ir(i)){let d=r[l-1],m=Fe(d),p=Ue(d),h=Ue(i);if(m&&p%2===1&&!Fe(i)&&h===1){r[l-1]=d+i;continue}}r.push(i)}return r};var ar=/(\*\*)([^*]*?)$/,lr=/(__)([^_]*?)$/,cr=/(\*\*\*)([^*]*?)$/,dr=/(\*)([^*]*?)$/,mr=/(_)([^_]*?)$/,pr=/(`)([^`]*?)$/,ur=/(~~)([^~]*?)$/,H=/^[\s_~*`]*$/,vo=/^[\s]*[-*+][\s]+$/,fr=/[\p{L}\p{N}_]/u,hr=/^```[^`\n]*```?$/,gr=/^\*{4,}$/,j=e=>{if(!e)return!1;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?!0:fr.test(e)},ge=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
11
- `)};var br=(e,t)=>{let o=1;for(let n=t-1;n>=0;n-=1)if(e[n]==="]")o+=1;else if(e[n]==="["&&(o-=1,o===0))return n;return-1},yr=(e,t)=>{let o=1;for(let n=t+1;n<e.length;n+=1)if(e[n]==="[")o+=1;else if(e[n]==="]"&&(o-=1,o===0))return n;return-1},Ve=(e,t)=>{let o=!1,n=!1;for(let r=0;r<t;r+=1){if(e.substring(r,r+3)==="```"){n=!n,r+=2;continue}!n&&e[r]==="`"&&(o=!o)}return o||n},wr=e=>{let t=e.lastIndexOf("](");if(t!==-1&&!Ve(e,t)&&!e.substring(t+2).includes(")")){let n=br(e,t);if(n!==-1&&!Ve(e,n)){let r=n>0&&e[n-1]==="!",s=r?n-1:n,a=e.substring(0,s),i=e.substring(n+1,t);return r?a:`${a}[${i}](streamdown:incomplete-link)`}}for(let o=e.length-1;o>=0;o-=1)if(e[o]==="["&&!Ve(e,o)){let n=o>0&&e[o-1]==="!",r=n?o-1:o;if(!e.substring(o+1).includes("]")){let i=e.substring(0,r);return n?i:`${e}](streamdown:incomplete-link)`}if(yr(e,o)===-1){let i=e.substring(0,r);return n?i:`${e}](streamdown:incomplete-link)`}}return e},kr=e=>{if(ge(e))return e;let t=e.match(ar);if(t){let o=t[2];if(!o||H.test(o))return e;let n=e.lastIndexOf(t[1]),s=e.substring(0,n).lastIndexOf(`
12
- `),a=s===-1?0:s+1,i=e.substring(a,n);if(vo.test(i)&&o.includes(`
13
- `))return e;if((e.match(/\*\*/g)||[]).length%2===1)return`${e}**`}return e},Cr=e=>{let t=e.match(lr);if(t){let o=t[2];if(!o||H.test(o))return e;let n=e.lastIndexOf(t[1]),s=e.substring(0,n).lastIndexOf(`
14
- `),a=s===-1?0:s+1,i=e.substring(a,n);if(vo.test(i)&&o.includes(`
15
- `))return e;if((e.match(/__/g)||[]).length%2===1)return`${e}__`}return e},vr=e=>{let t=0,o=e.length;for(let n=0;n<o;n+=1){if(e[n]!=="*")continue;let r=n>0?e[n-1]:"",s=n<o-1?e[n+1]:"";if(r==="\\"||r==="*"||s==="*"||r&&s&&j(r)&&j(s))continue;let a=0;for(let l=n-1;l>=0;l-=1)if(e[l]===`
16
- `){a=l+1;break}let i=!0;for(let l=a;l<n;l+=1)if(e[l]!==" "&&e[l]!==" "){i=!1;break}i&&(s===" "||s===" ")||(t+=1)}return t},Mr=e=>{if(ge(e))return e;if(e.match(dr)){let o=-1;for(let s=0;s<e.length;s+=1)if(e[s]==="*"&&e[s-1]!=="*"&&e[s+1]!=="*"&&e[s-1]!=="\\"){let a=s>0?e[s-1]:"",i=s<e.length-1?e[s+1]:"";if(a&&i&&j(a)&&j(i))continue;o=s;break}if(o===-1)return e;let n=e.substring(o+1);if(!n||H.test(n))return e;if(vr(e)%2===1)return`${e}*`}return e},Mo=(e,t)=>{let o=!1,n=!1;for(let r=0;r<e.length&&r<t;r+=1){if(e[r]==="\\"&&e[r+1]==="$"){r+=1;continue}e[r]==="$"&&(e[r+1]==="$"?(n=!n,r+=1,o=!1):n||(o=!o))}return o||n},Tr=e=>{let t=e.includes("$"),o=0,n=e.length;for(let r=0;r<n;r+=1){if(e[r]!=="_")continue;let s=r>0?e[r-1]:"",a=r<n-1?e[r+1]:"";s!=="\\"&&(t&&Mo(e,r)||s==="_"||a==="_"||s&&a&&j(s)&&j(a)||(o+=1))}return o},Pr=e=>{if(ge(e))return e;if(e.match(mr)){let o=-1;for(let s=0;s<e.length;s+=1)if(e[s]==="_"&&e[s-1]!=="_"&&e[s+1]!=="_"&&e[s-1]!=="\\"&&!Mo(e,s)){let a=s>0?e[s-1]:"",i=s<e.length-1?e[s+1]:"";if(a&&i&&j(a)&&j(i))continue;o=s;break}if(o===-1)return e;let n=e.substring(o+1);if(!n||H.test(n))return e;if(Tr(e)%2===1){let s=e.length;for(;s>0&&e[s-1]===`
17
- `;)s-=1;if(s<e.length){let a=e.slice(0,s),i=e.slice(s);return`${a}_${i}`}return`${e}_`}}return e},xr=(e,t)=>{let o=e.substring(t,t+3)==="```",n=t>0&&e.substring(t-1,t+2)==="```",r=t>1&&e.substring(t-2,t+1)==="```";return o||n||r},Nr=e=>{let t=0;for(let o=0;o<e.length;o+=1)e[o]==="`"&&!xr(e,o)&&(t+=1);return t},Ir=e=>{if(e.match(hr)&&!e.includes(`
18
- `))return e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e;let o=(e.match(/```/g)||[]).length,n=o%2===1;if(o>0&&o%2===0&&e.includes(`
19
- `)||(e.endsWith("```\n")||e.endsWith("```"))&&o%2===0)return e;let r=e.match(pr);if(r&&!n){let s=r[2];if(!s||H.test(s))return e;if(Nr(e)%2===1)return`${e}\``}return e},Sr=e=>{let t=e.match(ur);if(t){let o=t[2];if(!o||H.test(o))return e;if((e.match(/~~/g)||[]).length%2===1)return`${e}~~`}return e},Br=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let o=e.indexOf("$$");return o!==-1&&e.indexOf(`
20
- `,o)!==-1&&!e.endsWith(`
21
- `)?`${e}
22
- $$`:`${e}$$`},Er=e=>{let t=0,o=0;for(let n=0;n<e.length;n+=1)e[n]==="*"?o+=1:(o>=3&&(t+=Math.floor(o/3)),o=0);return o>=3&&(t+=Math.floor(o/3)),t},Lr=e=>{if(ge(e)||gr.test(e))return e;let t=e.match(cr);if(t){let o=t[2];if(!o||H.test(o))return e;if(Er(e)%2===1)return`${e}***`}return e},Xe=e=>{if(!e||typeof e!="string")return e;let t=e,o=wr(t);return o.endsWith("](streamdown:incomplete-link)")?o:(t=o,t=Lr(t),t=kr(t),t=Cr(t),t=Mr(t),t=Pr(t),t=Ir(t),t=Sr(t),t=Br(t),t)};import{jsx as O}from"react/jsx-runtime";var Fr={harden:[Dr,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],defaultOrigin:void 0,allowDataImages:!0}],raw:Hr,katex:[Je,{errorColor:"var(--color-muted-foreground)"}]},Ur={gfm:[qr,{}],math:[_r,{singleDollarTextMath:!1}],cjkFriendly:[Or,{}],cjkFriendlyGfmStrikethrough:[zr,{}]},Wr=Object.values(Fr),Vr=Object.values(Ur),Xr={shikiTheme:["github-light","github-dark"],controls:!0,isAnimating:!1,mode:"streaming",mermaid:void 0},M=Ar(Xr),xo=Po(({content:e,shouldParseIncompleteMarkdown:t,...o})=>{let n=Y(()=>typeof e=="string"&&t?Xe(e.trim()):e,[e,t]);return O(_e,{...o,children:n})},(e,t)=>{if(e.content!==t.content||e.shouldParseIncompleteMarkdown!==t.shouldParseIncompleteMarkdown||e.index!==t.index)return!1;if(e.components!==t.components){let o=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(o.length!==n.length||o.some(r=>{var s,a;return((s=e.components)==null?void 0:s[r])!==((a=t.components)==null?void 0:a[r])}))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});xo.displayName="Block";var Jr=["github-light","github-dark"],Kr=Po(({children:e,mode:t="streaming",parseIncompleteMarkdown:o=!0,components:n,rehypePlugins:r=Wr,remarkPlugins:s=Vr,className:a,shikiTheme:i=Jr,mermaid:l,controls:c=!0,isAnimating:d=!1,BlockComponent:m=xo,parseMarkdownIntoBlocksFn:p=We,...h})=>{let u=Rr(),[g,y]=$r(),[k,P]=jr([]),N=Y(()=>p(typeof e=="string"?e:""),[e,p]);To(()=>{t==="streaming"?y(()=>{P(N)}):P(N)},[N,t]);let x=t==="streaming"?k:N,L=Y(()=>x.map((B,q)=>`${u}-${q}`),[x.length,u]),$=Y(()=>({shikiTheme:i,controls:c,isAnimating:d,mode:t,mermaid:l}),[i,c,d,t,l]),z=Y(()=>({...Yt,...n}),[n]);return To(()=>{Array.isArray(r)&&r.some(B=>Array.isArray(B)?B[0]===Je:B===Je)&&import("katex/dist/katex.min.css")},[r]),t==="static"?O(M.Provider,{value:$,children:O("div",{className:f("space-y-4",a),children:O(_e,{components:z,rehypePlugins:r,remarkPlugins:s,...h,children:e})})}):O(M.Provider,{value:$,children:O("div",{className:f("space-y-4",a),children:x.map((B,q)=>O(m,{components:z,content:B,index:q,rehypePlugins:r,remarkPlugins:s,shouldParseIncompleteMarkdown:o,...h},L[q]))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode);Kr.displayName="Streamdown";export{xo as Block,Kr as Streamdown,M as StreamdownContext,Fr as defaultRehypePlugins,Ur as defaultRemarkPlugins,Xe as parseIncompleteMarkdown,We as parseMarkdownIntoBlocks};
1
+ export{i as Block,j as Streamdown,h as StreamdownContext,f as defaultRehypePlugins,g as defaultRemarkPlugins,e as parseIncompleteMarkdown,d as parseMarkdownIntoBlocks}from'./chunk-2LSFTLAB.js';
@@ -0,0 +1 @@
1
+ 'use strict';var chunkUGPOVMD7_cjs=require('./chunk-UGPOVMD7.cjs');Object.defineProperty(exports,"Mermaid",{enumerable:true,get:function(){return chunkUGPOVMD7_cjs.c}});
@@ -0,0 +1 @@
1
+ export{c as Mermaid}from'./chunk-2LSFTLAB.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamdown",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",