@echoease/streamdown-edge 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/package.json +1 -3
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';var chunkYHGJ7S36_cjs=require('./chunk-YHGJ7S36.cjs'),react=require('react'),
|
|
2
|
+
'use strict';var chunkYHGJ7S36_cjs=require('./chunk-YHGJ7S36.cjs'),react=require('react'),G=require('rehype-katex'),_t=require('remark-cjk-friendly'),Ut=require('remark-cjk-friendly-gfm-strikethrough'),Gt=require('remark-gfm'),Y=require('remark-math'),Yt=require('remend'),lucideReact=require('lucide-react'),jsxRuntime=require('react/jsx-runtime'),hastUtilToJsxRuntime=require('hast-util-to-jsx-runtime'),jt=require('remark-parse'),At=require('remark-rehype'),unified=require('unified'),marked=require('marked');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var G__default=/*#__PURE__*/_interopDefault(G);var _t__default=/*#__PURE__*/_interopDefault(_t);var Ut__default=/*#__PURE__*/_interopDefault(Ut);var Gt__default=/*#__PURE__*/_interopDefault(Gt);var Y__default=/*#__PURE__*/_interopDefault(Y);var Yt__default=/*#__PURE__*/_interopDefault(Yt);var jt__default=/*#__PURE__*/_interopDefault(jt);var At__default=/*#__PURE__*/_interopDefault(At);var te=({onCopy:e,onError:t,timeout:s=2e3,children:o,className:a,code:n,...c})=>{let[r,l]=react.useState(false),d=react.useRef(0),{code:i}=chunkYHGJ7S36_cjs.d(),{isAnimating:m}=react.useContext(v),u=n!=null?n:i,b=async()=>{var y;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{r||(await navigator.clipboard.writeText(u),l(!0),e==null||e(),d.current=window.setTimeout(()=>l(!1),s));}catch(k){t==null||t(k);}};react.useEffect(()=>()=>{window.clearTimeout(d.current);},[]);let f=r?lucideReact.CheckIcon:lucideReact.CopyIcon;return jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",a),"data-streamdown":"code-block-copy-button",disabled:m,onClick:b,title:"Copy Code",type:"button",...c,children:o!=null?o:jsxRuntime.jsx(f,{size:14})})};var oe={"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"},ne=({onDownload:e,onError:t,language:s,children:o,className:a,code:n,...c})=>{let{code:r}=chunkYHGJ7S36_cjs.d(),{isAnimating:l}=react.useContext(v),d=n!=null?n:r,m=`file.${s&&s in oe?oe[s]:"txt"}`,u="text/plain",b=()=>{try{chunkYHGJ7S36_cjs.b(m,d,u),e==null||e();}catch(f){t==null||t(f);}};return jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",a),"data-streamdown":"code-block-download-button",disabled:l,onClick:b,title:"Download file",type:"button",...c,children:o!=null?o:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})})};var re=()=>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(lucideReact.Loader2Icon,{className:"size-4 animate-spin"})})]});var dt=/\.[^/.]+$/,ae=({node:e,className:t,src:s,alt:o,...a})=>{let n=async()=>{if(s)try{let r=await(await fetch(s)).blob(),d=new URL(s,window.location.origin).pathname.split("/").pop()||"",i=d.split(".").pop(),m=d.includes(".")&&i!==void 0&&i.length<=4,u="";if(m)u=d;else {let b=r.type,f="png";b.includes("jpeg")||b.includes("jpg")?f="jpg":b.includes("png")?f="png":b.includes("svg")?f="svg":b.includes("gif")?f="gif":b.includes("webp")&&(f="webp"),u=`${(o||d||"image").replace(dt,"")}.${f}`;}chunkYHGJ7S36_cjs.b(u,r,r.type);}catch(c){console.error("Failed to download image:",c);}};return s?jsxRuntime.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsxRuntime.jsx("img",{alt:o,className:chunkYHGJ7S36_cjs.a("max-w-full rounded-lg",t),"data-streamdown":"image",src:s,...a}),jsxRuntime.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("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:n,title:"Download image",type:"button",children:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})})]}):null};var E=e=>{var n,c;let t=[],s=[],o=e.querySelectorAll("thead th");for(let r of o)t.push(((n=r.textContent)==null?void 0:n.trim())||"");let a=e.querySelectorAll("tbody tr");for(let r of a){let l=[],d=r.querySelectorAll("td");for(let i of d)l.push(((c=i.textContent)==null?void 0:c.trim())||"");s.push(l);}return {headers:t,rows:s}},I=e=>{let{headers:t,rows:s}=e,o=r=>{let l=false,d=false;for(let i of r){if(i==='"'){l=true,d=true;break}(i===","||i===`
|
|
3
3
|
`)&&(l=true);}return l?d?`"${r.replace(/"/g,'""')}"`:`"${r}"`:r},a=t.length>0?s.length+1:s.length,n=new Array(a),c=0;t.length>0&&(n[c]=t.map(o).join(","),c+=1);for(let r of s)n[c]=r.map(o).join(","),c+=1;return n.join(`
|
|
4
4
|
`)},le=e=>{let{headers:t,rows:s}=e,o=r=>{let l=false;for(let i of r)if(i===" "||i===`
|
|
5
5
|
`||i==="\r"){l=true;break}if(!l)return r;let d=[];for(let i of r)i===" "?d.push("\\t"):i===`
|
|
6
6
|
`?d.push("\\n"):i==="\r"?d.push("\\r"):d.push(i);return d.join("")},a=t.length>0?s.length+1:s.length,n=new Array(a),c=0;t.length>0&&(n[c]=t.map(o).join(" "),c+=1);for(let r of s)n[c]=r.map(o).join(" "),c+=1;return n.join(`
|
|
7
7
|
`)},X=e=>{let t=false;for(let o of e)if(o==="\\"||o==="|"){t=true;break}if(!t)return e;let s=[];for(let o of e)o==="\\"?s.push("\\\\"):o==="|"?s.push("\\|"):s.push(o);return s.join("")},ie=e=>{let{headers:t,rows:s}=e;if(t.length===0)return "";let o=new Array(s.length+2),a=0,n=t.map(r=>X(r));o[a]=`| ${n.join(" | ")} |`,a+=1;let c=new Array(t.length);for(let r=0;r<t.length;r+=1)c[r]="---";o[a]=`| ${c.join(" | ")} |`,a+=1;for(let r of s)if(r.length<t.length){let l=new Array(t.length);for(let d=0;d<t.length;d+=1)l[d]=d<r.length?X(r[d]):"";o[a]=`| ${l.join(" | ")} |`,a+=1;}else {let l=r.map(d=>X(d));o[a]=`| ${l.join(" | ")} |`,a+=1;}return o.join(`
|
|
8
|
-
`)};var pe=({children:e,className:t,onCopy:s,onError:o,timeout:a=2e3})=>{let[n,c]=react.useState(false),[r,l]=react.useState(false),d=react.useRef(null),i=react.useRef(0),{isAnimating:m}=react.useContext(v),u=async f=>{var y,k;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.write)){o==null||o(new Error("Clipboard API not available"));return}try{let x=(k=d.current)==null?void 0:k.closest('[data-streamdown="table-wrapper"]'),P=x==null?void 0:x.querySelector("table");if(!P){o==null||o(new Error("Table not found"));return}let T=I(P),R=f==="csv"?E(T):le(T),$=new ClipboardItem({"text/plain":new Blob([R],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([$]),l(!0),c(!1),s==null||s(f),i.current=window.setTimeout(()=>l(!1),a);}catch(x){o==null||o(x);}};react.useEffect(()=>{let f=y=>{d.current&&!d.current.contains(y.target)&&c(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(i.current);}},[]);let b=r?lucideReact.CheckIcon:lucideReact.CopyIcon;return jsxRuntime.jsxs("div",{className:"relative",ref:d,children:[jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>c(!n),title:"Copy table",type:"button",children:e!=null?e:jsxRuntime.jsx(b,{size:14})}),n?jsxRuntime.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var fe=({children:e,className:t,onDownload:s,onError:o})=>{let[a,n]=react.useState(false),c=react.useRef(null),{isAnimating:r}=react.useContext(v),l=d=>{var i;try{let m=(i=c.current)==null?void 0:i.closest('[data-streamdown="table-wrapper"]'),u=m==null?void 0:m.querySelector("table");if(!u){o==null||o(new Error("Table not found"));return}let b=I(u),f=d==="csv"?E(b):ie(b);chunkYHGJ7S36_cjs.b(`table.${d==="csv"?"csv":"md"}`,f,d==="csv"?"text/csv":"text/markdown"),n(!1),s==null||s(d);}catch(m){o==null||o(m);}};return react.useEffect(()=>{let d=i=>{c.current&&!c.current.contains(i.target)&&n(false);};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:c,children:[jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:r,onClick:()=>n(!a),title:"Download table",type:"button",children:e!=null?e:jsxRuntime.jsx(lucideReact.DownloadIcon,{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:()=>l("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var be=({children:e,className:t,showControls:s,...o})=>jsxRuntime.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[s?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsxRuntime.jsx(pe,{}),jsxRuntime.jsx(fe,{})]}):null,jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsx("table",{className:chunkYHGJ7S36_cjs.a("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var Tt=react.lazy(()=>import('./code-block-RZYTVPVD.cjs').then(e=>({default:e.CodeBlock}))),Ct=/language-([^\s]+)/;function O(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 s=e.position.start,o=t.position.start,a=e.position.end,n=t.position.end;return (s==null?void 0:s.line)===(o==null?void 0:o.line)&&(s==null?void 0:s.column)===(o==null?void 0:o.column)&&(a==null?void 0:a.line)===(n==null?void 0:n.line)&&(a==null?void 0:a.column)===(n==null?void 0:n.column)}function w(e,t){return e.className===t.className&&O(e.node,t.node)}var ye=(e,t)=>typeof e=="boolean"?e:e[t]!==false,W=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("ol",{className:chunkYHGJ7S36_cjs.a("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>w(e,t));W.displayName="MarkdownOl";var we=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("li",{className:chunkYHGJ7S36_cjs.a("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&O(e.node,t.node));we.displayName="MarkdownLi";var ke=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("ul",{className:chunkYHGJ7S36_cjs.a("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>w(e,t));ke.displayName="MarkdownUl";var xe=react.memo(({className:e,node:t,...s})=>jsxRuntime.jsx("hr",{className:chunkYHGJ7S36_cjs.a("my-6 border-border",e),"data-streamdown":"horizontal-rule",...s}),(e,t)=>w(e,t));xe.displayName="MarkdownHr";var ve=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("span",{className:chunkYHGJ7S36_cjs.a("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>w(e,t));ve.displayName="MarkdownStrong";var Te=react.memo(({children:e,className:t,href:s,node:o,...a})=>{let n=s==="streamdown:incomplete-link";return jsxRuntime.jsx("a",{className:chunkYHGJ7S36_cjs.a("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":n,"data-streamdown":"link",href:s,rel:"noreferrer",target:"_blank",...a,children:e})},(e,t)=>w(e,t)&&e.href===t.href);Te.displayName="MarkdownA";var Ce=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h1",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>w(e,t));Ce.displayName="MarkdownH1";var Pe=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h2",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>w(e,t));Pe.displayName="MarkdownH2";var Ne=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h3",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>w(e,t));Ne.displayName="MarkdownH3";var Me=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h4",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>w(e,t));Me.displayName="MarkdownH4";var Se=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h5",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>w(e,t));Se.displayName="MarkdownH5";var De=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h6",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>w(e,t));De.displayName="MarkdownH6";var Re=react.memo(({children:e,className:t,node:s,...o})=>{let{controls:a}=react.useContext(v),n=ye(a,"table");return jsxRuntime.jsx(be,{className:t,"data-streamdown":"table-wrapper",showControls:n,...o,children:e})},(e,t)=>w(e,t));Re.displayName="MarkdownTable";var je=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("thead",{className:chunkYHGJ7S36_cjs.a("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>w(e,t));je.displayName="MarkdownThead";var Ae=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("tbody",{className:chunkYHGJ7S36_cjs.a("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>w(e,t));Ae.displayName="MarkdownTbody";var Ie=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("tr",{className:chunkYHGJ7S36_cjs.a("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>w(e,t));Ie.displayName="MarkdownTr";var Ee=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("th",{className:chunkYHGJ7S36_cjs.a("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>w(e,t));Ee.displayName="MarkdownTh";var Le=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("td",{className:chunkYHGJ7S36_cjs.a("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>w(e,t));Le.displayName="MarkdownTd";var He=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("blockquote",{className:chunkYHGJ7S36_cjs.a("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>w(e,t));He.displayName="MarkdownBlockquote";var Be=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("sup",{className:chunkYHGJ7S36_cjs.a("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>w(e,t));Be.displayName="MarkdownSup";var Oe=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("sub",{className:chunkYHGJ7S36_cjs.a("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>w(e,t));Oe.displayName="MarkdownSub";var qe=react.memo(({children:e,className:t,node:s,...o})=>{if("data-footnotes"in o){let n=l=>{var u,b;if(!react.isValidElement(l))return false;let d=Array.isArray(l.props.children)?l.props.children:[l.props.children],i=false,m=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(i=true);else if(react.isValidElement(f))if(((u=f.props)==null?void 0:u["data-footnote-backref"])!==void 0)m=true;else {let y=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let k of y){if(typeof k=="string"&&k.trim()!==""){i=true;break}if(react.isValidElement(k)&&((b=k.props)==null?void 0:b["data-footnote-backref"])===void 0){i=true;break}}}}return m&&!i},c=Array.isArray(e)?e.map(l=>{if(!react.isValidElement(l))return l;if(l.type===W){let i=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!n(m));return i.length===0?null:{...l,props:{...l.props,children:i}}}return l}):e;return (Array.isArray(c)?c.some(l=>l!==null):c!==null)?jsxRuntime.jsx("section",{className:t,...o,children:c}):null}return jsxRuntime.jsx("section",{className:t,...o,children:e})},(e,t)=>w(e,t));qe.displayName="MarkdownSection";var Pt=({node:e,className:t,children:s,...o})=>{var i,m,u;let a=((i=e==null?void 0:e.position)==null?void 0:i.start.line)===((m=e==null?void 0:e.position)==null?void 0:m.end.line),{controls:n}=react.useContext(v);if(a)return jsxRuntime.jsx("code",{className:chunkYHGJ7S36_cjs.a("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:s});let c=t==null?void 0:t.match(Ct),r=(u=c==null?void 0:c.at(1))!=null?u:"",l="";react.isValidElement(s)&&s.props&&typeof s.props=="object"&&"children"in s.props&&typeof s.props.children=="string"?l=s.props.children:typeof s=="string"&&(l=s);let d=ye(n,"code");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(re,{}),children:jsxRuntime.jsx(Tt,{className:chunkYHGJ7S36_cjs.a("overflow-x-auto border-border border-t",t),code:l,language:r,children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ne,{code:l,language:r}),jsxRuntime.jsx(te,{})]}):null})})},$e=react.memo(Pt,(e,t)=>e.className===t.className&&O(e.node,t.node));$e.displayName="MarkdownCode";var Je=react.memo(ae,(e,t)=>e.className===t.className&&O(e.node,t.node));Je.displayName="MarkdownImg";var ze=react.memo(({children:e,className:t,node:s,...o})=>{var c;let n=(Array.isArray(e)?e:[e]).filter(r=>r!=null&&r!=="");return n.length===1&&react.isValidElement(n[0])&&((c=n[0].props.node)==null?void 0:c.tagName)==="img"?jsxRuntime.jsx(jsxRuntime.Fragment,{children:e}):jsxRuntime.jsx("p",{className:t,...o,children:e})},(e,t)=>w(e,t));ze.displayName="MarkdownParagraph";var Xe={ol:W,li:we,ul:ke,hr:xe,strong:ve,a:Te,h1:Ce,h2:Pe,h3:Ne,h4:Me,h5:Se,h6:De,table:Re,thead:je,tbody:Ae,tr:Ie,th:Ee,td:Le,blockquote:He,code:$e,img:Je,pre:({children:e})=>e,sup:Be,sub:Oe,p:ze,section:qe};var Ke=[],Ve={allowDangerousHtml:true},q=new WeakMap,K=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let s=this.keyCache.get(t);if(s)return s;let o=t.rehypePlugins,a=t.remarkPlugins,n=t.remarkRehypeOptions;if(!(o||a||n)){let m="default";return this.keyCache.set(t,m),m}let c=m=>{if(!m||m.length===0)return "";let u="";for(let b=0;b<m.length;b+=1){let f=m[b];if(b>0&&(u+=","),Array.isArray(f)){let[y,k]=f;if(typeof y=="function"){let x=q.get(y);x||(x=y.name,q.set(y,x)),u+=x;}else u+=String(y);u+=":",u+=JSON.stringify(k);}else if(typeof f=="function"){let y=q.get(f);y||(y=f.name,q.set(f,y)),u+=y;}else u+=String(f);}return u},r=c(o),l=c(a),d=n?JSON.stringify(n):"",i=`${l}::${r}::${d}`;return this.keyCache.set(t,i),i}get(t){let s=this.generateCacheKey(t),o=this.cache.get(s);return o&&(this.cache.delete(s),this.cache.set(s,o)),o}set(t,s){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let a=this.cache.keys().next().value;a&&this.cache.delete(a);}this.cache.set(o,s);}clear(){this.cache.clear();}},Fe=new K,V=e=>{let t=Et(e),s=e.children||"";return Ht(t.runSync(t.parse(s),s),e)},Et=e=>{let t=Fe.get(e);if(t)return t;let s=Lt(e);return Fe.set(e,s),s},Lt=e=>{let t=e.rehypePlugins||Ke,s=e.remarkPlugins||Ke,o=e.remarkRehypeOptions?{...Ve,...e.remarkRehypeOptions}:Ve;return unified.unified().use(jt__default.default).use(s).use(At__default.default,o).use(t)},Ht=(e,t)=>hastUtilToJsxRuntime.toJsxRuntime(e,{Fragment:jsxRuntime.Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsxRuntime.jsx,jsxs:jsxRuntime.jsxs,passKeys:true,passNode:true});var Ot=/\[\^[^\]\s]{1,200}\](?!:)/,qt=/\[\^[^\]\s]{1,200}\]:/,$t=/<\/(\w+)>/,Jt=/<(\w+)[\s>]/,F=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
8
|
+
`)};var pe=({children:e,className:t,onCopy:s,onError:o,timeout:a=2e3})=>{let[n,c]=react.useState(false),[r,l]=react.useState(false),d=react.useRef(null),i=react.useRef(0),{isAnimating:m}=react.useContext(v),u=async f=>{var y,k;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.write)){o==null||o(new Error("Clipboard API not available"));return}try{let x=(k=d.current)==null?void 0:k.closest('[data-streamdown="table-wrapper"]'),P=x==null?void 0:x.querySelector("table");if(!P){o==null||o(new Error("Table not found"));return}let T=E(P),R=f==="csv"?I(T):le(T),$=new ClipboardItem({"text/plain":new Blob([R],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([$]),l(!0),c(!1),s==null||s(f),i.current=window.setTimeout(()=>l(!1),a);}catch(x){o==null||o(x);}};react.useEffect(()=>{let f=y=>{d.current&&!d.current.contains(y.target)&&c(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(i.current);}},[]);let b=r?lucideReact.CheckIcon:lucideReact.CopyIcon;return jsxRuntime.jsxs("div",{className:"relative",ref:d,children:[jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>c(!n),title:"Copy table",type:"button",children:e!=null?e:jsxRuntime.jsx(b,{size:14})}),n?jsxRuntime.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var fe=({children:e,className:t,onDownload:s,onError:o})=>{let[a,n]=react.useState(false),c=react.useRef(null),{isAnimating:r}=react.useContext(v),l=d=>{var i;try{let m=(i=c.current)==null?void 0:i.closest('[data-streamdown="table-wrapper"]'),u=m==null?void 0:m.querySelector("table");if(!u){o==null||o(new Error("Table not found"));return}let b=E(u),f=d==="csv"?I(b):ie(b);chunkYHGJ7S36_cjs.b(`table.${d==="csv"?"csv":"md"}`,f,d==="csv"?"text/csv":"text/markdown"),n(!1),s==null||s(d);}catch(m){o==null||o(m);}};return react.useEffect(()=>{let d=i=>{c.current&&!c.current.contains(i.target)&&n(false);};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:c,children:[jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:r,onClick:()=>n(!a),title:"Download table",type:"button",children:e!=null?e:jsxRuntime.jsx(lucideReact.DownloadIcon,{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:()=>l("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var be=({children:e,className:t,showControls:s,...o})=>jsxRuntime.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[s?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsxRuntime.jsx(pe,{}),jsxRuntime.jsx(fe,{})]}):null,jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsx("table",{className:chunkYHGJ7S36_cjs.a("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var Tt=react.lazy(()=>import('./code-block-RZYTVPVD.cjs').then(e=>({default:e.CodeBlock}))),Ct=/language-([^\s]+)/;function O(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 s=e.position.start,o=t.position.start,a=e.position.end,n=t.position.end;return (s==null?void 0:s.line)===(o==null?void 0:o.line)&&(s==null?void 0:s.column)===(o==null?void 0:o.column)&&(a==null?void 0:a.line)===(n==null?void 0:n.line)&&(a==null?void 0:a.column)===(n==null?void 0:n.column)}function w(e,t){return e.className===t.className&&O(e.node,t.node)}var ye=(e,t)=>typeof e=="boolean"?e:e[t]!==false,W=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("ol",{className:chunkYHGJ7S36_cjs.a("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>w(e,t));W.displayName="MarkdownOl";var we=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("li",{className:chunkYHGJ7S36_cjs.a("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&O(e.node,t.node));we.displayName="MarkdownLi";var ke=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("ul",{className:chunkYHGJ7S36_cjs.a("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>w(e,t));ke.displayName="MarkdownUl";var xe=react.memo(({className:e,node:t,...s})=>jsxRuntime.jsx("hr",{className:chunkYHGJ7S36_cjs.a("my-6 border-border",e),"data-streamdown":"horizontal-rule",...s}),(e,t)=>w(e,t));xe.displayName="MarkdownHr";var ve=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("span",{className:chunkYHGJ7S36_cjs.a("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>w(e,t));ve.displayName="MarkdownStrong";var Te=react.memo(({children:e,className:t,href:s,node:o,...a})=>{let n=s==="streamdown:incomplete-link";return jsxRuntime.jsx("a",{className:chunkYHGJ7S36_cjs.a("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":n,"data-streamdown":"link",href:s,rel:"noreferrer",target:"_blank",...a,children:e})},(e,t)=>w(e,t)&&e.href===t.href);Te.displayName="MarkdownA";var Ce=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h1",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>w(e,t));Ce.displayName="MarkdownH1";var Pe=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h2",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>w(e,t));Pe.displayName="MarkdownH2";var Ne=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h3",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>w(e,t));Ne.displayName="MarkdownH3";var Me=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h4",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>w(e,t));Me.displayName="MarkdownH4";var Se=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h5",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>w(e,t));Se.displayName="MarkdownH5";var De=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h6",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>w(e,t));De.displayName="MarkdownH6";var Re=react.memo(({children:e,className:t,node:s,...o})=>{let{controls:a}=react.useContext(v),n=ye(a,"table");return jsxRuntime.jsx(be,{className:t,"data-streamdown":"table-wrapper",showControls:n,...o,children:e})},(e,t)=>w(e,t));Re.displayName="MarkdownTable";var je=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("thead",{className:chunkYHGJ7S36_cjs.a("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>w(e,t));je.displayName="MarkdownThead";var Ae=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("tbody",{className:chunkYHGJ7S36_cjs.a("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>w(e,t));Ae.displayName="MarkdownTbody";var Ee=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("tr",{className:chunkYHGJ7S36_cjs.a("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>w(e,t));Ee.displayName="MarkdownTr";var Ie=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("th",{className:chunkYHGJ7S36_cjs.a("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>w(e,t));Ie.displayName="MarkdownTh";var Le=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("td",{className:chunkYHGJ7S36_cjs.a("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>w(e,t));Le.displayName="MarkdownTd";var He=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("blockquote",{className:chunkYHGJ7S36_cjs.a("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>w(e,t));He.displayName="MarkdownBlockquote";var Be=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("sup",{className:chunkYHGJ7S36_cjs.a("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>w(e,t));Be.displayName="MarkdownSup";var Oe=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("sub",{className:chunkYHGJ7S36_cjs.a("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>w(e,t));Oe.displayName="MarkdownSub";var qe=react.memo(({children:e,className:t,node:s,...o})=>{if("data-footnotes"in o){let n=l=>{var u,b;if(!react.isValidElement(l))return false;let d=Array.isArray(l.props.children)?l.props.children:[l.props.children],i=false,m=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(i=true);else if(react.isValidElement(f))if(((u=f.props)==null?void 0:u["data-footnote-backref"])!==void 0)m=true;else {let y=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let k of y){if(typeof k=="string"&&k.trim()!==""){i=true;break}if(react.isValidElement(k)&&((b=k.props)==null?void 0:b["data-footnote-backref"])===void 0){i=true;break}}}}return m&&!i},c=Array.isArray(e)?e.map(l=>{if(!react.isValidElement(l))return l;if(l.type===W){let i=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!n(m));return i.length===0?null:{...l,props:{...l.props,children:i}}}return l}):e;return (Array.isArray(c)?c.some(l=>l!==null):c!==null)?jsxRuntime.jsx("section",{className:t,...o,children:c}):null}return jsxRuntime.jsx("section",{className:t,...o,children:e})},(e,t)=>w(e,t));qe.displayName="MarkdownSection";var Pt=({node:e,className:t,children:s,...o})=>{var i,m,u;let a=((i=e==null?void 0:e.position)==null?void 0:i.start.line)===((m=e==null?void 0:e.position)==null?void 0:m.end.line),{controls:n}=react.useContext(v);if(a)return jsxRuntime.jsx("code",{className:chunkYHGJ7S36_cjs.a("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:s});let c=t==null?void 0:t.match(Ct),r=(u=c==null?void 0:c.at(1))!=null?u:"",l="";react.isValidElement(s)&&s.props&&typeof s.props=="object"&&"children"in s.props&&typeof s.props.children=="string"?l=s.props.children:typeof s=="string"&&(l=s);let d=ye(n,"code");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(re,{}),children:jsxRuntime.jsx(Tt,{className:chunkYHGJ7S36_cjs.a("overflow-x-auto border-border border-t",t),code:l,language:r,children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ne,{code:l,language:r}),jsxRuntime.jsx(te,{})]}):null})})},$e=react.memo(Pt,(e,t)=>e.className===t.className&&O(e.node,t.node));$e.displayName="MarkdownCode";var Je=react.memo(ae,(e,t)=>e.className===t.className&&O(e.node,t.node));Je.displayName="MarkdownImg";var ze=react.memo(({children:e,className:t,node:s,...o})=>{var c;let n=(Array.isArray(e)?e:[e]).filter(r=>r!=null&&r!=="");return n.length===1&&react.isValidElement(n[0])&&((c=n[0].props.node)==null?void 0:c.tagName)==="img"?jsxRuntime.jsx(jsxRuntime.Fragment,{children:e}):jsxRuntime.jsx("p",{className:t,...o,children:e})},(e,t)=>w(e,t));ze.displayName="MarkdownParagraph";var Xe={ol:W,li:we,ul:ke,hr:xe,strong:ve,a:Te,h1:Ce,h2:Pe,h3:Ne,h4:Me,h5:Se,h6:De,table:Re,thead:je,tbody:Ae,tr:Ee,th:Ie,td:Le,blockquote:He,code:$e,img:Je,pre:({children:e})=>e,sup:Be,sub:Oe,p:ze,section:qe};var Ke=[],Ve={allowDangerousHtml:true},q=new WeakMap,K=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let s=this.keyCache.get(t);if(s)return s;let o=t.rehypePlugins,a=t.remarkPlugins,n=t.remarkRehypeOptions;if(!(o||a||n)){let m="default";return this.keyCache.set(t,m),m}let c=m=>{if(!m||m.length===0)return "";let u="";for(let b=0;b<m.length;b+=1){let f=m[b];if(b>0&&(u+=","),Array.isArray(f)){let[y,k]=f;if(typeof y=="function"){let x=q.get(y);x||(x=y.name,q.set(y,x)),u+=x;}else u+=String(y);u+=":",u+=JSON.stringify(k);}else if(typeof f=="function"){let y=q.get(f);y||(y=f.name,q.set(f,y)),u+=y;}else u+=String(f);}return u},r=c(o),l=c(a),d=n?JSON.stringify(n):"",i=`${l}::${r}::${d}`;return this.keyCache.set(t,i),i}get(t){let s=this.generateCacheKey(t),o=this.cache.get(s);return o&&(this.cache.delete(s),this.cache.set(s,o)),o}set(t,s){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let a=this.cache.keys().next().value;a&&this.cache.delete(a);}this.cache.set(o,s);}clear(){this.cache.clear();}},Fe=new K,V=e=>{let t=It(e),s=e.children||"";return Ht(t.runSync(t.parse(s),s),e)},It=e=>{let t=Fe.get(e);if(t)return t;let s=Lt(e);return Fe.set(e,s),s},Lt=e=>{let t=e.rehypePlugins||Ke,s=e.remarkPlugins||Ke,o=e.remarkRehypeOptions?{...Ve,...e.remarkRehypeOptions}:Ve;return unified.unified().use(jt__default.default).use(s).use(At__default.default,o).use(t)},Ht=(e,t)=>hastUtilToJsxRuntime.toJsxRuntime(e,{Fragment:jsxRuntime.Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsxRuntime.jsx,jsxs:jsxRuntime.jsxs,passKeys:true,passNode:true});var Ot=/\[\^[^\]\s]{1,200}\](?!:)/,qt=/\[\^[^\]\s]{1,200}\]:/,$t=/<\/(\w+)>/,Jt=/<(\w+)[\s>]/,F=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
9
9
|
`||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},zt=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]==="$"},_=e=>{let t=0;for(let s=0;s<e.length-1;s+=1)e[s]==="$"&&e[s+1]==="$"&&(t+=1,s+=1);return t},U=e=>{let t=Ot.test(e),s=qt.test(e);if(t||s)return [e];let o=marked.Lexer.lex(e,{gfm:true}),a=[],n=[];for(let c of o){let r=c.raw,l=a.length;if(n.length>0){if(a[l-1]+=r,c.type==="html"){let i=r.match($t);if(i){let m=i[1];n.at(-1)===m&&n.pop();}}continue}if(c.type==="html"&&c.block){let i=r.match(Jt);if(i){let m=i[1];r.includes(`</${m}>`)||n.push(m);}}if(r.trim()==="$$"&&l>0){let i=a[l-1],m=F(i),u=_(i);if(m&&u%2===1){a[l-1]=i+r;continue}}if(l>0&&zt(r)){let i=a[l-1],m=F(i),u=_(i),b=_(r);if(m&&u%2===1&&!F(r)&&b===1){a[l-1]=i+r;continue}}a.push(r);}return a};var _e={dependencies:{"rehype-katex":"^7.0.1"}};var
|
|
11
|
-
exports.Block=Ye;exports.Streamdown=
|
|
10
|
+
`||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},_=e=>{let t=0;for(let s=0;s<e.length-1;s+=1)e[s]==="$"&&e[s+1]==="$"&&(t+=1,s+=1);return t},U=e=>{let t=Ot.test(e),s=qt.test(e);if(t||s)return [e];let o=marked.Lexer.lex(e,{gfm:true}),a=[],n=[];for(let c of o){let r=c.raw,l=a.length;if(n.length>0){if(a[l-1]+=r,c.type==="html"){let i=r.match($t);if(i){let m=i[1];n.at(-1)===m&&n.pop();}}continue}if(c.type==="html"&&c.block){let i=r.match(Jt);if(i){let m=i[1];r.includes(`</${m}>`)||n.push(m);}}if(r.trim()==="$$"&&l>0){let i=a[l-1],m=F(i),u=_(i);if(m&&u%2===1){a[l-1]=i+r;continue}}if(l>0&&zt(r)){let i=a[l-1],m=F(i),u=_(i),b=_(r);if(m&&u%2===1&&!F(r)&&b===1){a[l-1]=i+r;continue}}a.push(r);}return a};var _e={dependencies:{"rehype-katex":"^7.0.1"}};var Qt=/[^$]\$[^$]/,Zt=/^\$[^$]/,eo=/[^$]\$$/,to={katex:[G__default.default,{errorColor:"var(--color-muted-foreground)"}]},oo={gfm:[Gt__default.default,{}],math:[Y__default.default,{singleDollarTextMath:false}],cjkFriendly:[_t__default.default,{}],cjkFriendlyGfmStrikethrough:[Ut__default.default,{}]},so=Object.values(to),no=Object.values(oo),ro={block:" \u258B",circle:" \u25CF"},ao={controls:true,isAnimating:false,mode:"streaming"},v=react.createContext(ao),Ye=react.memo(({content:e,...t})=>jsxRuntime.jsx(V,{...t,children:e}),(e,t)=>{if(e.content!==t.content||e.index!==t.index)return false;if(e.components!==t.components){let s=Object.keys(e.components||{}),o=Object.keys(t.components||{});if(s.length!==o.length||s.some(a=>{var n,c;return ((n=e.components)==null?void 0:n[a])!==((c=t.components)==null?void 0:c[a])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Ye.displayName="Block";var lo=e=>Array.isArray(e)&&e.some(t=>Array.isArray(t)?t[0]===G__default.default:t===G__default.default),io=e=>{if(!Array.isArray(e))return false;let t=e.find(s=>Array.isArray(s)?s[0]===Y__default.default:s===Y__default.default);return t&&Array.isArray(t)&&t[1]?t[1].singleDollarTextMath===true:false},co=(e,t)=>{let s=e.includes("$$"),o=t&&(Qt.test(e)||Zt.test(e)||eo.test(e));return s||o},mo=/^\^/,po=()=>{let e=_e.dependencies["rehype-katex"].replace(mo,"").split(".")[0],s={7:"0.16.22"}[e]||"0.16.22",o=document.createElement("link");o.rel="stylesheet",o.href=`https://cdn.jsdelivr.net/npm/katex@${s}/dist/katex.min.css`,document.head.appendChild(o);},uo=react.memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:s=true,components:o,rehypePlugins:a=so,remarkPlugins:n=no,className:c,controls:r=true,isAnimating:l=false,BlockComponent:d=Ye,parseMarkdownIntoBlocksFn:i=U,caret:m,...u})=>{let b=react.useId(),[f,y]=react.useTransition(),[k,x]=react.useState([]),P=react.useMemo(()=>typeof e!="string"?"":t==="streaming"&&s?Yt__default.default(e):e,[e,t,s]),T=react.useMemo(()=>i(P),[P,i]);react.useEffect(()=>{t==="streaming"?y(()=>{x(T);}):x(T);},[T,t]);let R=t==="streaming"?k:T,$=react.useMemo(()=>R.map((J,N)=>`${b}-${N}`),[R.length,b]),Q=react.useMemo(()=>({controls:r,isAnimating:l,mode:t}),[r,l,t]),Z=react.useMemo(()=>({...Xe,...o}),[o]);react.useEffect(()=>{if(!lo(a))return;let N=io(n);co(typeof e=="string"?e:"",N)&&po();},[a,n,e]);let Qe=react.useMemo(()=>m&&l?{"--streamdown-caret":`"${ro[m]}"`}:void 0,[m,l]);return t==="static"?jsxRuntime.jsx(v.Provider,{value:Q,children:jsxRuntime.jsx("div",{className:chunkYHGJ7S36_cjs.a("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",c),children:jsxRuntime.jsx(V,{components:Z,rehypePlugins:a,remarkPlugins:n,...u,children:e})})}):jsxRuntime.jsx(v.Provider,{value:Q,children:jsxRuntime.jsx("div",{className:chunkYHGJ7S36_cjs.a("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",m?"*:last:after:inline *:last:after:align-baseline *:last:after:content-(--streamdown-caret)":null,c),style:Qe,children:R.map((J,N)=>jsxRuntime.jsx(d,{components:Z,content:J,index:N,rehypePlugins:a,remarkPlugins:n,shouldParseIncompleteMarkdown:s,...u},$[N]))})})},(e,t)=>e.children===t.children&&e.isAnimating===t.isAnimating&&e.mode===t.mode);uo.displayName="Streamdown";
|
|
11
|
+
exports.Block=Ye;exports.Streamdown=uo;exports.StreamdownContext=v;exports.defaultRehypePlugins=to;exports.defaultRemarkPlugins=oo;exports.parseMarkdownIntoBlocks=U;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {a,d,b}from'./chunk-DDL734BZ.js';import {lazy,memo,useContext,createContext,isValidElement,useId,useTransition,useState,useMemo,useEffect,Suspense,useRef}from'react';import
|
|
2
|
+
import {a,d,b}from'./chunk-DDL734BZ.js';import {lazy,memo,useContext,createContext,isValidElement,useId,useTransition,useState,useMemo,useEffect,Suspense,useRef}from'react';import G from'rehype-katex';import _t from'remark-cjk-friendly';import Ut from'remark-cjk-friendly-gfm-strikethrough';import Gt from'remark-gfm';import Y from'remark-math';import Yt from'remend';import {DownloadIcon,CheckIcon,CopyIcon,Loader2Icon}from'lucide-react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import jt from'remark-parse';import At from'remark-rehype';import {unified}from'unified';import {Lexer}from'marked';var te=({onCopy:e,onError:t,timeout:s=2e3,children:o,className:a$1,code:n,...c})=>{let[r,l]=useState(false),d$1=useRef(0),{code:i}=d(),{isAnimating:m}=useContext(v),u=n!=null?n:i,b=async()=>{var y;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{r||(await navigator.clipboard.writeText(u),l(!0),e==null||e(),d$1.current=window.setTimeout(()=>l(!1),s));}catch(k){t==null||t(k);}};useEffect(()=>()=>{window.clearTimeout(d$1.current);},[]);let f=r?CheckIcon:CopyIcon;return jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",a$1),"data-streamdown":"code-block-copy-button",disabled:m,onClick:b,title:"Copy Code",type:"button",...c,children:o!=null?o:jsx(f,{size:14})})};var oe={"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"},ne=({onDownload:e,onError:t,language:s,children:o,className:a$1,code:n,...c})=>{let{code:r}=d(),{isAnimating:l}=useContext(v),d$1=n!=null?n:r,m=`file.${s&&s in oe?oe[s]:"txt"}`,u="text/plain",b$1=()=>{try{b(m,d$1,u),e==null||e();}catch(f){t==null||t(f);}};return jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",a$1),"data-streamdown":"code-block-download-button",disabled:l,onClick:b$1,title:"Download file",type:"button",...c,children:o!=null?o:jsx(DownloadIcon,{size:14})})};var re=()=>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(Loader2Icon,{className:"size-4 animate-spin"})})]});var dt=/\.[^/.]+$/,ae=({node:e,className:t,src:s,alt:o,...a$1})=>{let n=async()=>{if(s)try{let r=await(await fetch(s)).blob(),d=new URL(s,window.location.origin).pathname.split("/").pop()||"",i=d.split(".").pop(),m=d.includes(".")&&i!==void 0&&i.length<=4,u="";if(m)u=d;else {let b=r.type,f="png";b.includes("jpeg")||b.includes("jpg")?f="jpg":b.includes("png")?f="png":b.includes("svg")?f="svg":b.includes("gif")?f="gif":b.includes("webp")&&(f="webp"),u=`${(o||d||"image").replace(dt,"")}.${f}`;}b(u,r,r.type);}catch(c){console.error("Failed to download image:",c);}};return s?jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsx("img",{alt:o,className:a("max-w-full rounded-lg",t),"data-streamdown":"image",src:s,...a$1}),jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsx("button",{className:a("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:n,title:"Download image",type:"button",children:jsx(DownloadIcon,{size:14})})]}):null};var E=e=>{var n,c;let t=[],s=[],o=e.querySelectorAll("thead th");for(let r of o)t.push(((n=r.textContent)==null?void 0:n.trim())||"");let a=e.querySelectorAll("tbody tr");for(let r of a){let l=[],d=r.querySelectorAll("td");for(let i of d)l.push(((c=i.textContent)==null?void 0:c.trim())||"");s.push(l);}return {headers:t,rows:s}},I=e=>{let{headers:t,rows:s}=e,o=r=>{let l=false,d=false;for(let i of r){if(i==='"'){l=true,d=true;break}(i===","||i===`
|
|
3
3
|
`)&&(l=true);}return l?d?`"${r.replace(/"/g,'""')}"`:`"${r}"`:r},a=t.length>0?s.length+1:s.length,n=new Array(a),c=0;t.length>0&&(n[c]=t.map(o).join(","),c+=1);for(let r of s)n[c]=r.map(o).join(","),c+=1;return n.join(`
|
|
4
4
|
`)},le=e=>{let{headers:t,rows:s}=e,o=r=>{let l=false;for(let i of r)if(i===" "||i===`
|
|
5
5
|
`||i==="\r"){l=true;break}if(!l)return r;let d=[];for(let i of r)i===" "?d.push("\\t"):i===`
|
|
6
6
|
`?d.push("\\n"):i==="\r"?d.push("\\r"):d.push(i);return d.join("")},a=t.length>0?s.length+1:s.length,n=new Array(a),c=0;t.length>0&&(n[c]=t.map(o).join(" "),c+=1);for(let r of s)n[c]=r.map(o).join(" "),c+=1;return n.join(`
|
|
7
7
|
`)},X=e=>{let t=false;for(let o of e)if(o==="\\"||o==="|"){t=true;break}if(!t)return e;let s=[];for(let o of e)o==="\\"?s.push("\\\\"):o==="|"?s.push("\\|"):s.push(o);return s.join("")},ie=e=>{let{headers:t,rows:s}=e;if(t.length===0)return "";let o=new Array(s.length+2),a=0,n=t.map(r=>X(r));o[a]=`| ${n.join(" | ")} |`,a+=1;let c=new Array(t.length);for(let r=0;r<t.length;r+=1)c[r]="---";o[a]=`| ${c.join(" | ")} |`,a+=1;for(let r of s)if(r.length<t.length){let l=new Array(t.length);for(let d=0;d<t.length;d+=1)l[d]=d<r.length?X(r[d]):"";o[a]=`| ${l.join(" | ")} |`,a+=1;}else {let l=r.map(d=>X(d));o[a]=`| ${l.join(" | ")} |`,a+=1;}return o.join(`
|
|
8
|
-
`)};var pe=({children:e,className:t,onCopy:s,onError:o,timeout:a$1=2e3})=>{let[n,c]=useState(false),[r,l]=useState(false),d=useRef(null),i=useRef(0),{isAnimating:m}=useContext(v),u=async f=>{var y,k;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.write)){o==null||o(new Error("Clipboard API not available"));return}try{let x=(k=d.current)==null?void 0:k.closest('[data-streamdown="table-wrapper"]'),P=x==null?void 0:x.querySelector("table");if(!P){o==null||o(new Error("Table not found"));return}let T=I(P),R=f==="csv"?E(T):le(T),$=new ClipboardItem({"text/plain":new Blob([R],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([$]),l(!0),c(!1),s==null||s(f),i.current=window.setTimeout(()=>l(!1),a$1);}catch(x){o==null||o(x);}};useEffect(()=>{let f=y=>{d.current&&!d.current.contains(y.target)&&c(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(i.current);}},[]);let b=r?CheckIcon:CopyIcon;return jsxs("div",{className:"relative",ref:d,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>c(!n),title:"Copy table",type:"button",children:e!=null?e:jsx(b,{size:14})}),n?jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var fe=({children:e,className:t,onDownload:s,onError:o})=>{let[a$1,n]=useState(false),c=useRef(null),{isAnimating:r}=useContext(v),l=d=>{var i;try{let m=(i=c.current)==null?void 0:i.closest('[data-streamdown="table-wrapper"]'),u=m==null?void 0:m.querySelector("table");if(!u){o==null||o(new Error("Table not found"));return}let b$1=I(u),f=d==="csv"?E(b$1):ie(b$1);b(`table.${d==="csv"?"csv":"md"}`,f,d==="csv"?"text/csv":"text/markdown"),n(!1),s==null||s(d);}catch(m){o==null||o(m);}};return useEffect(()=>{let d=i=>{c.current&&!c.current.contains(i.target)&&n(false);};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d);}},[]),jsxs("div",{className:"relative",ref:c,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:r,onClick:()=>n(!a$1),title:"Download table",type:"button",children:e!=null?e:jsx(DownloadIcon,{size:14})}),a$1?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"),title:"Download table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var be=({children:e,className:t,showControls:s,...o})=>jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[s?jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsx(pe,{}),jsx(fe,{})]}):null,jsx("div",{className:"overflow-x-auto",children:jsx("table",{className:a("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var Tt=lazy(()=>import('./code-block-HNJHFH25.js').then(e=>({default:e.CodeBlock}))),Ct=/language-([^\s]+)/;function O(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 s=e.position.start,o=t.position.start,a=e.position.end,n=t.position.end;return (s==null?void 0:s.line)===(o==null?void 0:o.line)&&(s==null?void 0:s.column)===(o==null?void 0:o.column)&&(a==null?void 0:a.line)===(n==null?void 0:n.line)&&(a==null?void 0:a.column)===(n==null?void 0:n.column)}function w(e,t){return e.className===t.className&&O(e.node,t.node)}var ye=(e,t)=>typeof e=="boolean"?e:e[t]!==false,W=memo(({children:e,className:t,node:s,...o})=>jsx("ol",{className:a("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>w(e,t));W.displayName="MarkdownOl";var we=memo(({children:e,className:t,node:s,...o})=>jsx("li",{className:a("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&O(e.node,t.node));we.displayName="MarkdownLi";var ke=memo(({children:e,className:t,node:s,...o})=>jsx("ul",{className:a("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>w(e,t));ke.displayName="MarkdownUl";var xe=memo(({className:e,node:t,...s})=>jsx("hr",{className:a("my-6 border-border",e),"data-streamdown":"horizontal-rule",...s}),(e,t)=>w(e,t));xe.displayName="MarkdownHr";var ve=memo(({children:e,className:t,node:s,...o})=>jsx("span",{className:a("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>w(e,t));ve.displayName="MarkdownStrong";var Te=memo(({children:e,className:t,href:s,node:o,...a$1})=>{let n=s==="streamdown:incomplete-link";return jsx("a",{className:a("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":n,"data-streamdown":"link",href:s,rel:"noreferrer",target:"_blank",...a$1,children:e})},(e,t)=>w(e,t)&&e.href===t.href);Te.displayName="MarkdownA";var Ce=memo(({children:e,className:t,node:s,...o})=>jsx("h1",{className:a("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>w(e,t));Ce.displayName="MarkdownH1";var Pe=memo(({children:e,className:t,node:s,...o})=>jsx("h2",{className:a("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>w(e,t));Pe.displayName="MarkdownH2";var Ne=memo(({children:e,className:t,node:s,...o})=>jsx("h3",{className:a("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>w(e,t));Ne.displayName="MarkdownH3";var Me=memo(({children:e,className:t,node:s,...o})=>jsx("h4",{className:a("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>w(e,t));Me.displayName="MarkdownH4";var Se=memo(({children:e,className:t,node:s,...o})=>jsx("h5",{className:a("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>w(e,t));Se.displayName="MarkdownH5";var De=memo(({children:e,className:t,node:s,...o})=>jsx("h6",{className:a("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>w(e,t));De.displayName="MarkdownH6";var Re=memo(({children:e,className:t,node:s,...o})=>{let{controls:a}=useContext(v),n=ye(a,"table");return jsx(be,{className:t,"data-streamdown":"table-wrapper",showControls:n,...o,children:e})},(e,t)=>w(e,t));Re.displayName="MarkdownTable";var je=memo(({children:e,className:t,node:s,...o})=>jsx("thead",{className:a("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>w(e,t));je.displayName="MarkdownThead";var Ae=memo(({children:e,className:t,node:s,...o})=>jsx("tbody",{className:a("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>w(e,t));Ae.displayName="MarkdownTbody";var Ie=memo(({children:e,className:t,node:s,...o})=>jsx("tr",{className:a("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>w(e,t));Ie.displayName="MarkdownTr";var Ee=memo(({children:e,className:t,node:s,...o})=>jsx("th",{className:a("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>w(e,t));Ee.displayName="MarkdownTh";var Le=memo(({children:e,className:t,node:s,...o})=>jsx("td",{className:a("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>w(e,t));Le.displayName="MarkdownTd";var He=memo(({children:e,className:t,node:s,...o})=>jsx("blockquote",{className:a("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>w(e,t));He.displayName="MarkdownBlockquote";var Be=memo(({children:e,className:t,node:s,...o})=>jsx("sup",{className:a("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>w(e,t));Be.displayName="MarkdownSup";var Oe=memo(({children:e,className:t,node:s,...o})=>jsx("sub",{className:a("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>w(e,t));Oe.displayName="MarkdownSub";var qe=memo(({children:e,className:t,node:s,...o})=>{if("data-footnotes"in o){let n=l=>{var u,b;if(!isValidElement(l))return false;let d=Array.isArray(l.props.children)?l.props.children:[l.props.children],i=false,m=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(i=true);else if(isValidElement(f))if(((u=f.props)==null?void 0:u["data-footnote-backref"])!==void 0)m=true;else {let y=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let k of y){if(typeof k=="string"&&k.trim()!==""){i=true;break}if(isValidElement(k)&&((b=k.props)==null?void 0:b["data-footnote-backref"])===void 0){i=true;break}}}}return m&&!i},c=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===W){let i=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!n(m));return i.length===0?null:{...l,props:{...l.props,children:i}}}return l}):e;return (Array.isArray(c)?c.some(l=>l!==null):c!==null)?jsx("section",{className:t,...o,children:c}):null}return jsx("section",{className:t,...o,children:e})},(e,t)=>w(e,t));qe.displayName="MarkdownSection";var Pt=({node:e,className:t,children:s,...o})=>{var i,m,u;let a$1=((i=e==null?void 0:e.position)==null?void 0:i.start.line)===((m=e==null?void 0:e.position)==null?void 0:m.end.line),{controls:n}=useContext(v);if(a$1)return jsx("code",{className:a("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:s});let c=t==null?void 0:t.match(Ct),r=(u=c==null?void 0:c.at(1))!=null?u:"",l="";isValidElement(s)&&s.props&&typeof s.props=="object"&&"children"in s.props&&typeof s.props.children=="string"?l=s.props.children:typeof s=="string"&&(l=s);let d=ye(n,"code");return jsx(Suspense,{fallback:jsx(re,{}),children:jsx(Tt,{className:a("overflow-x-auto border-border border-t",t),code:l,language:r,children:d?jsxs(Fragment,{children:[jsx(ne,{code:l,language:r}),jsx(te,{})]}):null})})},$e=memo(Pt,(e,t)=>e.className===t.className&&O(e.node,t.node));$e.displayName="MarkdownCode";var Je=memo(ae,(e,t)=>e.className===t.className&&O(e.node,t.node));Je.displayName="MarkdownImg";var ze=memo(({children:e,className:t,node:s,...o})=>{var c;let n=(Array.isArray(e)?e:[e]).filter(r=>r!=null&&r!=="");return n.length===1&&isValidElement(n[0])&&((c=n[0].props.node)==null?void 0:c.tagName)==="img"?jsx(Fragment,{children:e}):jsx("p",{className:t,...o,children:e})},(e,t)=>w(e,t));ze.displayName="MarkdownParagraph";var Xe={ol:W,li:we,ul:ke,hr:xe,strong:ve,a:Te,h1:Ce,h2:Pe,h3:Ne,h4:Me,h5:Se,h6:De,table:Re,thead:je,tbody:Ae,tr:Ie,th:Ee,td:Le,blockquote:He,code:$e,img:Je,pre:({children:e})=>e,sup:Be,sub:Oe,p:ze,section:qe};var Ke=[],Ve={allowDangerousHtml:true},q=new WeakMap,K=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let s=this.keyCache.get(t);if(s)return s;let o=t.rehypePlugins,a=t.remarkPlugins,n=t.remarkRehypeOptions;if(!(o||a||n)){let m="default";return this.keyCache.set(t,m),m}let c=m=>{if(!m||m.length===0)return "";let u="";for(let b=0;b<m.length;b+=1){let f=m[b];if(b>0&&(u+=","),Array.isArray(f)){let[y,k]=f;if(typeof y=="function"){let x=q.get(y);x||(x=y.name,q.set(y,x)),u+=x;}else u+=String(y);u+=":",u+=JSON.stringify(k);}else if(typeof f=="function"){let y=q.get(f);y||(y=f.name,q.set(f,y)),u+=y;}else u+=String(f);}return u},r=c(o),l=c(a),d=n?JSON.stringify(n):"",i=`${l}::${r}::${d}`;return this.keyCache.set(t,i),i}get(t){let s=this.generateCacheKey(t),o=this.cache.get(s);return o&&(this.cache.delete(s),this.cache.set(s,o)),o}set(t,s){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let a=this.cache.keys().next().value;a&&this.cache.delete(a);}this.cache.set(o,s);}clear(){this.cache.clear();}},Fe=new K,V=e=>{let t=Et(e),s=e.children||"";return Ht(t.runSync(t.parse(s),s),e)},Et=e=>{let t=Fe.get(e);if(t)return t;let s=Lt(e);return Fe.set(e,s),s},Lt=e=>{let t=e.rehypePlugins||Ke,s=e.remarkPlugins||Ke,o=e.remarkRehypeOptions?{...Ve,...e.remarkRehypeOptions}:Ve;return unified().use(jt).use(s).use(At,o).use(t)},Ht=(e,t)=>toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true});var Ot=/\[\^[^\]\s]{1,200}\](?!:)/,qt=/\[\^[^\]\s]{1,200}\]:/,$t=/<\/(\w+)>/,Jt=/<(\w+)[\s>]/,F=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
8
|
+
`)};var pe=({children:e,className:t,onCopy:s,onError:o,timeout:a$1=2e3})=>{let[n,c]=useState(false),[r,l]=useState(false),d=useRef(null),i=useRef(0),{isAnimating:m}=useContext(v),u=async f=>{var y,k;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.write)){o==null||o(new Error("Clipboard API not available"));return}try{let x=(k=d.current)==null?void 0:k.closest('[data-streamdown="table-wrapper"]'),P=x==null?void 0:x.querySelector("table");if(!P){o==null||o(new Error("Table not found"));return}let T=E(P),R=f==="csv"?I(T):le(T),$=new ClipboardItem({"text/plain":new Blob([R],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([$]),l(!0),c(!1),s==null||s(f),i.current=window.setTimeout(()=>l(!1),a$1);}catch(x){o==null||o(x);}};useEffect(()=>{let f=y=>{d.current&&!d.current.contains(y.target)&&c(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(i.current);}},[]);let b=r?CheckIcon:CopyIcon;return jsxs("div",{className:"relative",ref:d,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>c(!n),title:"Copy table",type:"button",children:e!=null?e:jsx(b,{size:14})}),n?jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var fe=({children:e,className:t,onDownload:s,onError:o})=>{let[a$1,n]=useState(false),c=useRef(null),{isAnimating:r}=useContext(v),l=d=>{var i;try{let m=(i=c.current)==null?void 0:i.closest('[data-streamdown="table-wrapper"]'),u=m==null?void 0:m.querySelector("table");if(!u){o==null||o(new Error("Table not found"));return}let b$1=E(u),f=d==="csv"?I(b$1):ie(b$1);b(`table.${d==="csv"?"csv":"md"}`,f,d==="csv"?"text/csv":"text/markdown"),n(!1),s==null||s(d);}catch(m){o==null||o(m);}};return useEffect(()=>{let d=i=>{c.current&&!c.current.contains(i.target)&&n(false);};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d);}},[]),jsxs("div",{className:"relative",ref:c,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:r,onClick:()=>n(!a$1),title:"Download table",type:"button",children:e!=null?e:jsx(DownloadIcon,{size:14})}),a$1?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"),title:"Download table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var be=({children:e,className:t,showControls:s,...o})=>jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[s?jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsx(pe,{}),jsx(fe,{})]}):null,jsx("div",{className:"overflow-x-auto",children:jsx("table",{className:a("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var Tt=lazy(()=>import('./code-block-HNJHFH25.js').then(e=>({default:e.CodeBlock}))),Ct=/language-([^\s]+)/;function O(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 s=e.position.start,o=t.position.start,a=e.position.end,n=t.position.end;return (s==null?void 0:s.line)===(o==null?void 0:o.line)&&(s==null?void 0:s.column)===(o==null?void 0:o.column)&&(a==null?void 0:a.line)===(n==null?void 0:n.line)&&(a==null?void 0:a.column)===(n==null?void 0:n.column)}function w(e,t){return e.className===t.className&&O(e.node,t.node)}var ye=(e,t)=>typeof e=="boolean"?e:e[t]!==false,W=memo(({children:e,className:t,node:s,...o})=>jsx("ol",{className:a("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>w(e,t));W.displayName="MarkdownOl";var we=memo(({children:e,className:t,node:s,...o})=>jsx("li",{className:a("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&O(e.node,t.node));we.displayName="MarkdownLi";var ke=memo(({children:e,className:t,node:s,...o})=>jsx("ul",{className:a("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>w(e,t));ke.displayName="MarkdownUl";var xe=memo(({className:e,node:t,...s})=>jsx("hr",{className:a("my-6 border-border",e),"data-streamdown":"horizontal-rule",...s}),(e,t)=>w(e,t));xe.displayName="MarkdownHr";var ve=memo(({children:e,className:t,node:s,...o})=>jsx("span",{className:a("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>w(e,t));ve.displayName="MarkdownStrong";var Te=memo(({children:e,className:t,href:s,node:o,...a$1})=>{let n=s==="streamdown:incomplete-link";return jsx("a",{className:a("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":n,"data-streamdown":"link",href:s,rel:"noreferrer",target:"_blank",...a$1,children:e})},(e,t)=>w(e,t)&&e.href===t.href);Te.displayName="MarkdownA";var Ce=memo(({children:e,className:t,node:s,...o})=>jsx("h1",{className:a("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>w(e,t));Ce.displayName="MarkdownH1";var Pe=memo(({children:e,className:t,node:s,...o})=>jsx("h2",{className:a("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>w(e,t));Pe.displayName="MarkdownH2";var Ne=memo(({children:e,className:t,node:s,...o})=>jsx("h3",{className:a("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>w(e,t));Ne.displayName="MarkdownH3";var Me=memo(({children:e,className:t,node:s,...o})=>jsx("h4",{className:a("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>w(e,t));Me.displayName="MarkdownH4";var Se=memo(({children:e,className:t,node:s,...o})=>jsx("h5",{className:a("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>w(e,t));Se.displayName="MarkdownH5";var De=memo(({children:e,className:t,node:s,...o})=>jsx("h6",{className:a("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>w(e,t));De.displayName="MarkdownH6";var Re=memo(({children:e,className:t,node:s,...o})=>{let{controls:a}=useContext(v),n=ye(a,"table");return jsx(be,{className:t,"data-streamdown":"table-wrapper",showControls:n,...o,children:e})},(e,t)=>w(e,t));Re.displayName="MarkdownTable";var je=memo(({children:e,className:t,node:s,...o})=>jsx("thead",{className:a("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>w(e,t));je.displayName="MarkdownThead";var Ae=memo(({children:e,className:t,node:s,...o})=>jsx("tbody",{className:a("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>w(e,t));Ae.displayName="MarkdownTbody";var Ee=memo(({children:e,className:t,node:s,...o})=>jsx("tr",{className:a("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>w(e,t));Ee.displayName="MarkdownTr";var Ie=memo(({children:e,className:t,node:s,...o})=>jsx("th",{className:a("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>w(e,t));Ie.displayName="MarkdownTh";var Le=memo(({children:e,className:t,node:s,...o})=>jsx("td",{className:a("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>w(e,t));Le.displayName="MarkdownTd";var He=memo(({children:e,className:t,node:s,...o})=>jsx("blockquote",{className:a("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>w(e,t));He.displayName="MarkdownBlockquote";var Be=memo(({children:e,className:t,node:s,...o})=>jsx("sup",{className:a("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>w(e,t));Be.displayName="MarkdownSup";var Oe=memo(({children:e,className:t,node:s,...o})=>jsx("sub",{className:a("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>w(e,t));Oe.displayName="MarkdownSub";var qe=memo(({children:e,className:t,node:s,...o})=>{if("data-footnotes"in o){let n=l=>{var u,b;if(!isValidElement(l))return false;let d=Array.isArray(l.props.children)?l.props.children:[l.props.children],i=false,m=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(i=true);else if(isValidElement(f))if(((u=f.props)==null?void 0:u["data-footnote-backref"])!==void 0)m=true;else {let y=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let k of y){if(typeof k=="string"&&k.trim()!==""){i=true;break}if(isValidElement(k)&&((b=k.props)==null?void 0:b["data-footnote-backref"])===void 0){i=true;break}}}}return m&&!i},c=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===W){let i=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!n(m));return i.length===0?null:{...l,props:{...l.props,children:i}}}return l}):e;return (Array.isArray(c)?c.some(l=>l!==null):c!==null)?jsx("section",{className:t,...o,children:c}):null}return jsx("section",{className:t,...o,children:e})},(e,t)=>w(e,t));qe.displayName="MarkdownSection";var Pt=({node:e,className:t,children:s,...o})=>{var i,m,u;let a$1=((i=e==null?void 0:e.position)==null?void 0:i.start.line)===((m=e==null?void 0:e.position)==null?void 0:m.end.line),{controls:n}=useContext(v);if(a$1)return jsx("code",{className:a("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:s});let c=t==null?void 0:t.match(Ct),r=(u=c==null?void 0:c.at(1))!=null?u:"",l="";isValidElement(s)&&s.props&&typeof s.props=="object"&&"children"in s.props&&typeof s.props.children=="string"?l=s.props.children:typeof s=="string"&&(l=s);let d=ye(n,"code");return jsx(Suspense,{fallback:jsx(re,{}),children:jsx(Tt,{className:a("overflow-x-auto border-border border-t",t),code:l,language:r,children:d?jsxs(Fragment,{children:[jsx(ne,{code:l,language:r}),jsx(te,{})]}):null})})},$e=memo(Pt,(e,t)=>e.className===t.className&&O(e.node,t.node));$e.displayName="MarkdownCode";var Je=memo(ae,(e,t)=>e.className===t.className&&O(e.node,t.node));Je.displayName="MarkdownImg";var ze=memo(({children:e,className:t,node:s,...o})=>{var c;let n=(Array.isArray(e)?e:[e]).filter(r=>r!=null&&r!=="");return n.length===1&&isValidElement(n[0])&&((c=n[0].props.node)==null?void 0:c.tagName)==="img"?jsx(Fragment,{children:e}):jsx("p",{className:t,...o,children:e})},(e,t)=>w(e,t));ze.displayName="MarkdownParagraph";var Xe={ol:W,li:we,ul:ke,hr:xe,strong:ve,a:Te,h1:Ce,h2:Pe,h3:Ne,h4:Me,h5:Se,h6:De,table:Re,thead:je,tbody:Ae,tr:Ee,th:Ie,td:Le,blockquote:He,code:$e,img:Je,pre:({children:e})=>e,sup:Be,sub:Oe,p:ze,section:qe};var Ke=[],Ve={allowDangerousHtml:true},q=new WeakMap,K=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let s=this.keyCache.get(t);if(s)return s;let o=t.rehypePlugins,a=t.remarkPlugins,n=t.remarkRehypeOptions;if(!(o||a||n)){let m="default";return this.keyCache.set(t,m),m}let c=m=>{if(!m||m.length===0)return "";let u="";for(let b=0;b<m.length;b+=1){let f=m[b];if(b>0&&(u+=","),Array.isArray(f)){let[y,k]=f;if(typeof y=="function"){let x=q.get(y);x||(x=y.name,q.set(y,x)),u+=x;}else u+=String(y);u+=":",u+=JSON.stringify(k);}else if(typeof f=="function"){let y=q.get(f);y||(y=f.name,q.set(f,y)),u+=y;}else u+=String(f);}return u},r=c(o),l=c(a),d=n?JSON.stringify(n):"",i=`${l}::${r}::${d}`;return this.keyCache.set(t,i),i}get(t){let s=this.generateCacheKey(t),o=this.cache.get(s);return o&&(this.cache.delete(s),this.cache.set(s,o)),o}set(t,s){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let a=this.cache.keys().next().value;a&&this.cache.delete(a);}this.cache.set(o,s);}clear(){this.cache.clear();}},Fe=new K,V=e=>{let t=It(e),s=e.children||"";return Ht(t.runSync(t.parse(s),s),e)},It=e=>{let t=Fe.get(e);if(t)return t;let s=Lt(e);return Fe.set(e,s),s},Lt=e=>{let t=e.rehypePlugins||Ke,s=e.remarkPlugins||Ke,o=e.remarkRehypeOptions?{...Ve,...e.remarkRehypeOptions}:Ve;return unified().use(jt).use(s).use(At,o).use(t)},Ht=(e,t)=>toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true});var Ot=/\[\^[^\]\s]{1,200}\](?!:)/,qt=/\[\^[^\]\s]{1,200}\]:/,$t=/<\/(\w+)>/,Jt=/<(\w+)[\s>]/,F=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
9
9
|
`||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},zt=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]==="$"},_=e=>{let t=0;for(let s=0;s<e.length-1;s+=1)e[s]==="$"&&e[s+1]==="$"&&(t+=1,s+=1);return t},U=e=>{let t=Ot.test(e),s=qt.test(e);if(t||s)return [e];let o=Lexer.lex(e,{gfm:true}),a=[],n=[];for(let c of o){let r=c.raw,l=a.length;if(n.length>0){if(a[l-1]+=r,c.type==="html"){let i=r.match($t);if(i){let m=i[1];n.at(-1)===m&&n.pop();}}continue}if(c.type==="html"&&c.block){let i=r.match(Jt);if(i){let m=i[1];r.includes(`</${m}>`)||n.push(m);}}if(r.trim()==="$$"&&l>0){let i=a[l-1],m=F(i),u=_(i);if(m&&u%2===1){a[l-1]=i+r;continue}}if(l>0&&zt(r)){let i=a[l-1],m=F(i),u=_(i),b=_(r);if(m&&u%2===1&&!F(r)&&b===1){a[l-1]=i+r;continue}}a.push(r);}return a};var _e={dependencies:{"rehype-katex":"^7.0.1"}};var
|
|
11
|
-
export{Ye as Block,
|
|
10
|
+
`||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},_=e=>{let t=0;for(let s=0;s<e.length-1;s+=1)e[s]==="$"&&e[s+1]==="$"&&(t+=1,s+=1);return t},U=e=>{let t=Ot.test(e),s=qt.test(e);if(t||s)return [e];let o=Lexer.lex(e,{gfm:true}),a=[],n=[];for(let c of o){let r=c.raw,l=a.length;if(n.length>0){if(a[l-1]+=r,c.type==="html"){let i=r.match($t);if(i){let m=i[1];n.at(-1)===m&&n.pop();}}continue}if(c.type==="html"&&c.block){let i=r.match(Jt);if(i){let m=i[1];r.includes(`</${m}>`)||n.push(m);}}if(r.trim()==="$$"&&l>0){let i=a[l-1],m=F(i),u=_(i);if(m&&u%2===1){a[l-1]=i+r;continue}}if(l>0&&zt(r)){let i=a[l-1],m=F(i),u=_(i),b=_(r);if(m&&u%2===1&&!F(r)&&b===1){a[l-1]=i+r;continue}}a.push(r);}return a};var _e={dependencies:{"rehype-katex":"^7.0.1"}};var Qt=/[^$]\$[^$]/,Zt=/^\$[^$]/,eo=/[^$]\$$/,to={katex:[G,{errorColor:"var(--color-muted-foreground)"}]},oo={gfm:[Gt,{}],math:[Y,{singleDollarTextMath:false}],cjkFriendly:[_t,{}],cjkFriendlyGfmStrikethrough:[Ut,{}]},so=Object.values(to),no=Object.values(oo),ro={block:" \u258B",circle:" \u25CF"},ao={controls:true,isAnimating:false,mode:"streaming"},v=createContext(ao),Ye=memo(({content:e,...t})=>jsx(V,{...t,children:e}),(e,t)=>{if(e.content!==t.content||e.index!==t.index)return false;if(e.components!==t.components){let s=Object.keys(e.components||{}),o=Object.keys(t.components||{});if(s.length!==o.length||s.some(a=>{var n,c;return ((n=e.components)==null?void 0:n[a])!==((c=t.components)==null?void 0:c[a])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Ye.displayName="Block";var lo=e=>Array.isArray(e)&&e.some(t=>Array.isArray(t)?t[0]===G:t===G),io=e=>{if(!Array.isArray(e))return false;let t=e.find(s=>Array.isArray(s)?s[0]===Y:s===Y);return t&&Array.isArray(t)&&t[1]?t[1].singleDollarTextMath===true:false},co=(e,t)=>{let s=e.includes("$$"),o=t&&(Qt.test(e)||Zt.test(e)||eo.test(e));return s||o},mo=/^\^/,po=()=>{let e=_e.dependencies["rehype-katex"].replace(mo,"").split(".")[0],s={7:"0.16.22"}[e]||"0.16.22",o=document.createElement("link");o.rel="stylesheet",o.href=`https://cdn.jsdelivr.net/npm/katex@${s}/dist/katex.min.css`,document.head.appendChild(o);},uo=memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:s=true,components:o,rehypePlugins:a$1=so,remarkPlugins:n=no,className:c,controls:r=true,isAnimating:l=false,BlockComponent:d=Ye,parseMarkdownIntoBlocksFn:i=U,caret:m,...u})=>{let b=useId(),[f,y]=useTransition(),[k,x]=useState([]),P=useMemo(()=>typeof e!="string"?"":t==="streaming"&&s?Yt(e):e,[e,t,s]),T=useMemo(()=>i(P),[P,i]);useEffect(()=>{t==="streaming"?y(()=>{x(T);}):x(T);},[T,t]);let R=t==="streaming"?k:T,$=useMemo(()=>R.map((J,N)=>`${b}-${N}`),[R.length,b]),Q=useMemo(()=>({controls:r,isAnimating:l,mode:t}),[r,l,t]),Z=useMemo(()=>({...Xe,...o}),[o]);useEffect(()=>{if(!lo(a$1))return;let N=io(n);co(typeof e=="string"?e:"",N)&&po();},[a$1,n,e]);let Qe=useMemo(()=>m&&l?{"--streamdown-caret":`"${ro[m]}"`}:void 0,[m,l]);return t==="static"?jsx(v.Provider,{value:Q,children:jsx("div",{className:a("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",c),children:jsx(V,{components:Z,rehypePlugins:a$1,remarkPlugins:n,...u,children:e})})}):jsx(v.Provider,{value:Q,children:jsx("div",{className:a("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",m?"*:last:after:inline *:last:after:align-baseline *:last:after:content-(--streamdown-caret)":null,c),style:Qe,children:R.map((J,N)=>jsx(d,{components:Z,content:J,index:N,rehypePlugins:a$1,remarkPlugins:n,shouldParseIncompleteMarkdown:s,...u},$[N]))})})},(e,t)=>e.children===t.children&&e.isAnimating===t.isAnimating&&e.mode===t.mode);uo.displayName="Streamdown";
|
|
11
|
+
export{Ye as Block,uo as Streamdown,v as StreamdownContext,to as defaultRehypePlugins,oo as defaultRemarkPlugins,U as parseMarkdownIntoBlocks};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@echoease/streamdown-edge",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -47,9 +47,7 @@
|
|
|
47
47
|
"lucide-react": "^0.560.0",
|
|
48
48
|
"marked": "^17.0.1",
|
|
49
49
|
"prism-react-renderer": "^2.4.1",
|
|
50
|
-
"rehype-harden": "^1.1.7",
|
|
51
50
|
"rehype-katex": "^7.0.1",
|
|
52
|
-
"rehype-raw": "^7.0.0",
|
|
53
51
|
"rehype-sanitize": "^6.0.0",
|
|
54
52
|
"remark-cjk-friendly": "^1.2.3",
|
|
55
53
|
"remark-cjk-friendly-gfm-strikethrough": "^1.2.3",
|