@lofcz/streamdown 2.10.2 → 2.10.3
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/chunk-O7PB473J.js +40 -0
- package/dist/{highlighted-body-QA7ERC4U.js → highlighted-body-H53OQTHH.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/scrollable.d.ts +4 -1
- package/dist/lib/streamdown-context.d.ts +2 -2
- package/dist/lib/use-pinned-scroll.d.ts +17 -0
- package/dist/mermaid-2NSXBHVL.js +2 -0
- package/package.json +3 -3
- package/dist/chunk-7GEPSDTS.js +0 -40
- package/dist/mermaid-EMLHH3WB.js +0 -2
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {createContext,memo,useContext,useMemo,lazy,isValidElement,useLayoutEffect,useId,useRef,useEffect,useDeferredValue,cloneElement,createElement,useState,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import Jo from'rehype-raw';import _r,{defaultSchema}from'rehype-sanitize';import fl from'remark-gfm';import gl from'remend';import {visitParents,SKIP as SKIP$1}from'unist-util-visit-parents';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import fa from'remark-parse';import ga from'remark-rehype';import {unified}from'unified';import {visit,SKIP}from'unist-util-visit';import {Lexer}from'marked';import {toText}from'hast-util-to-text';var Xr=300,Ur="300px",Jr=500;function co(e={}){let{immediate:t=false,debounceDelay:o=Xr,rootMargin:n=Ur,idleTimeout:r=Jr}=e,[a,s]=useState(false),c=useRef(null),i=useRef(null),l=useRef(null),d=useMemo(()=>m=>{let g=Date.now();return window.setTimeout(()=>{m({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-g))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(m,g)=>window.requestIdleCallback(m,g):d,[d]),u=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?m=>window.cancelIdleCallback(m):m=>{clearTimeout(m);},[]);return useEffect(()=>{if(t){s(true);return}let m=c.current;if(!m)return;i.current&&(clearTimeout(i.current),i.current=null),l.current&&(u(l.current),l.current=null);let g=()=>{i.current&&(clearTimeout(i.current),i.current=null),l.current&&(u(l.current),l.current=null);},f=k=>{l.current=p(M=>{M.timeRemaining()>0||M.didTimeout?(s(true),k.disconnect()):l.current=p(()=>{s(true),k.disconnect();},{timeout:r/2});},{timeout:r});},h=k=>{g(),i.current=window.setTimeout(()=>{var I,w;let M=k.takeRecords();(M.length===0||(w=(I=M.at(-1))==null?void 0:I.isIntersecting)!=null&&w)&&f(k);},o);},b=(k,M)=>{k.isIntersecting?h(M):g();},T=new IntersectionObserver(k=>{for(let M of k)b(M,T);},{rootMargin:n,threshold:0});return T.observe(m),()=>{i.current&&clearTimeout(i.current),l.current&&u(l.current),T.disconnect();}},[t,o,n,r,u,p]),{shouldRender:a,containerRef:c}}var Yr=320,Qr=4,po=()=>typeof performance=="undefined"?Date.now():performance.now();function St(e){var a,s;let t=(a=e==null?void 0:e.now)!=null?a:po,o=(s=e==null?void 0:e.maxBacklogMs)!=null?s:Yr,n=0,r=0;return {now:t,beginPass(c){r=Math.min(Math.max(n,c),c+o);},mark(){return r},rewind(c){r=c;},take(c,i,l){if(c<=0)return {baseDelay:0,step:Math.max(0,i)};let d=Math.max(0,i),p=d===0?0:Math.min(d,Qr),u=Math.max(r,l),m=l+o,g=u+Math.max(0,c-1)*d,f=d;if(g>m&&c>1)if(u<m){let b=m-u;f=Math.max(p,b/(c-1));}else f=p;let h=Math.max(0,Math.round(u-l));return r=u+c*f,{baseDelay:h,step:f}},commitPass(){n=r;}}}function es(){return {current:0}}var fo=/\s/,Rt=/^\s+$/,ts=new Set(["code","pre","svg","math","annotation"]),os=new Set(["svg","math","annotation"]),Mt=new Set(["img","hr"]),ns=new Set(["ul","ol","li"]),Me=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",It=(e,t)=>{let o=t?os:ts;return e.some(n=>Me(n)&&o.has(n.tagName))},rs=e=>{for(let t=e.length-1;t>=0;t-=1){let o=e[t];if(Me(o)&&o.tagName==="li")return o}},ss=(e,t,o,n)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate-marker"]=true,e.properties.style=`--sd-marker-duration:${t}ms;--sd-marker-delay:${o}ms;--sd-marker-easing:${n}`;},go=e=>{for(let t of e.children)if(Me(t)){if(t.tagName==="input")return t;if(ns.has(t.tagName))continue;let o=go(t);if(o)return o}},bo=(e,t,o,n)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate"]=true;let r=typeof e.properties.style=="string"?`${e.properties.style};`:"";e.properties.style=`${r}--sd-animation:sd-${t.animation};--sd-duration:${o}ms;--sd-easing:${t.easing};--sd-delay:${n}ms`;},as=(e,t,o,n)=>{let r=go(e);r&&bo(r,t,o,n);},ho=e=>{var t;for(let o=e.length-1;o>=0;o-=1){let n=e[o];if(Me(n)){if((t=n.properties)!=null&&t["data-sd-animated"])break;n.properties={...n.properties,"data-sd-animated":true};}}},yo=e=>{let t=[],o="",n=false;for(let r of e){let a=fo.test(r);if(a!==n&&o){if(a){o+=r,n=true;continue}t.push(o),o="";}o+=r,n=a;}return o&&t.push(o),t},Co=e=>{let t=[],o="";for(let n of e)fo.test(n)?t.length>0&&!Rt.test(t.at(-1))?t[t.length-1]+=n:o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&(t.length>0?t[t.length-1]+=o:t.push(o)),t},is=(e,t,o,n,r,a)=>{let s=`--sd-animation:sd-${t};--sd-duration:${r?0:o}ms;--sd-easing:${n}`;return a&&(s+=`;--sd-delay:${Math.round(a)}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:s},children:[{type:"text",value:e}]}},ls=(e,t,o,n)=>{let r=0,a=0;return visitParents(e,s=>s.type==="text"||Me(s)&&Mt.has(s.tagName),(s,c)=>{if(It(c,o.animateCodeBlocks))return SKIP$1;if(Me(s)&&Mt.has(s.tagName)){n>0&&a<n||(r+=1);return}let i=s.value;if(!i.trim()){a+=i.length;return}let l=t.sep==="char"?Co(i):yo(i);for(let d of l){let p=a;a+=d.length,!Rt.test(d)&&(n>0&&p<n||(r+=1));}}),r},cs=(e,t,o,n,r,a)=>{if(It(t,n.animateCodeBlocks))return;let s=n.prevContentLength,c=s>0&&r.count<s,i=c?0:a.baseDelay+r.newIndex++*a.step;bo(e,o,c?0:o.duration,i),ho(t);},ds=(e,t,o,n,r,a)=>{var b;let s=t.at(-1);if(!(s&&"children"in s))return;if(It(t,n.animateCodeBlocks))return SKIP$1;let c=s,i=c.children.indexOf(e);if(i===-1)return;let l=e.value;if(!l.trim()){r.count+=l.length;return}let d=o.sep==="char"?Co(l):yo(l),p=n.prevContentLength,u=false,m=rs(t),g=!!(m&&!((b=m.properties)!=null&&b["data-sd-animate-marker"])),f=false,h=d.map(T=>{let k=r.count;if(r.count+=T.length,Rt.test(T))return {type:"text",value:T};let M=p>0&&k<p,P=M?0:a.baseDelay+r.newIndex++*a.step;if(m&&g&&!f){let I=M?0:o.duration;ss(m,I,P,o.easing),as(m,o,I,P),f=true;}return u=true,is(T,o.animation,o.duration,o.easing,M,P)});return u&&ho(t),c.children.splice(i,1,...h),i+h.length},ms=0;function rt(e){var a,s,c,i,l;let t={animation:(a=e==null?void 0:e.animation)!=null?a:"fadeIn",duration:(s=e==null?void 0:e.duration)!=null?s:150,easing:(c=e==null?void 0:e.easing)!=null?c:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(l=e==null?void 0:e.stagger)!=null?l:40,timeline:e==null?void 0:e.timeline},o={animateCodeBlocks:false,committedCharCount:0,prevContentLength:0,lastRenderCharCount:0,pendingMark:null},n=ms++,r=()=>d=>{var f;let p={count:0,newIndex:0};o.prevContentLength=o.committedCharCount;let u=t.timeline,m=(f=u==null?void 0:u.now())!=null?f:po();u&&(o.pendingMark===null?o.pendingMark=u.mark():u.rewind(o.pendingMark));let g=u?u.take(ls(d,t,o,o.prevContentLength),t.stagger,m):{baseDelay:0,step:t.stagger};visitParents(d,h=>h.type==="text"||Me(h)&&Mt.has(h.tagName),(h,b)=>{if(h.type==="text")return ds(h,b,t,o,p,g);cs(h,b,t,o,p,g);}),o.lastRenderCharCount=p.count,o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(d){o.animateCodeBlocks=d;},setPrevContentLength(d){o.committedCharCount=d,o.prevContentLength=d;},getLastRenderCharCount(){return o.lastRenderCharCount},commit(){o.committedCharCount=o.lastRenderCharCount,o.pendingMark=null;}}}rt();var Et=createContext(false),Lt=()=>useContext(Et);var De=(...e)=>twMerge(clsx(e)),st=e=>{if(e!==void 0)return typeof e=="number"?!Number.isFinite(e)||e<=0?void 0:`${e}px`:e},fs=(e,t)=>{if(!e||!t)return t;let o=`${e}:`;return t.split(/\s+/).filter(Boolean).map(n=>n.startsWith(o)?n:`${e}:${n}`).join(" ")},ko=e=>e?(...t)=>fs(e,twMerge(clsx(t))):De,re=(e,t,o)=>{let n=typeof t=="string"&&o.startsWith("text/csv")?"\uFEFF":"",r=typeof t=="string"?new Blob([n+t],{type:o}):t,a=URL.createObjectURL(r),s=document.createElement("a");s.href=a,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(a);};var at=createContext(De),C=()=>useContext(at);var ze=({scrollRef:e,ref:t,...o})=>jsx("div",{ref:e,...o});var ws=8,xs=e=>e.scrollHeight-e.scrollTop-e.clientHeight<ws,Mo=e=>{var o,n;let t=(n=(o=e.touches[0])!=null?o:e.changedTouches[0])!=null?n:null;return typeof(t==null?void 0:t.clientY)=="number"?t.clientY:null},it=({enabled:e,isAnimating:t,content:o})=>{let[n,r]=useState(null),a=useRef(true),s=useRef(0),c=useCallback(l=>{r(d=>d===l?d:l);},[]),i=useCallback(l=>{t&&a.current&&(l.scrollTo({top:l.scrollHeight,behavior:"instant"}),s.current=l.scrollTop);},[t]);return useEffect(()=>{t||(a.current=true);},[t]),useEffect(()=>{if(!(e&&n))return;s.current=n.scrollTop;let l=()=>{a.current=false;},d=h=>{h.deltaY<0&&l();},p=null,u=h=>{p=Mo(h);},m=h=>{if(p===null)return;let b=Mo(h);if(b===null)return;let T=b-p;Math.abs(T)<=3||(T>0&&l(),p=b);},g=()=>{p=null;},f=()=>{let h=n.scrollTop<s.current;if(s.current=n.scrollTop,h){l();return}xs(n)&&(a.current=true);};return n.addEventListener("wheel",d,{capture:true,passive:true}),n.addEventListener("touchstart",u,{passive:true}),n.addEventListener("touchmove",m,{passive:true}),n.addEventListener("touchend",g,{passive:true}),n.addEventListener("touchcancel",g,{passive:true}),n.addEventListener("scroll",f,{passive:true}),()=>{n.removeEventListener("wheel",d,{capture:true}),n.removeEventListener("touchstart",u),n.removeEventListener("touchmove",m),n.removeEventListener("touchend",g),n.removeEventListener("touchcancel",g),n.removeEventListener("scroll",f);}},[e,n]),useLayoutEffect(()=>{if(!(e&&n)||(i(n),typeof ResizeObserver=="undefined"))return;let l=new ResizeObserver(()=>{i(n);});l.observe(n);for(let d of n.children)l.observe(d);return ()=>{l.disconnect();}},[o,n,e,i]),c};var Ts=De("block"),Ps=De("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),Ms=e=>{let t={};for(let o of e.split(";")){let n=o.indexOf(":");if(n>0){let r=o.slice(0,n).trim(),a=o.slice(n+1).trim();r&&a&&(t[r]=a);}}return t},So=memo(({children:e,result:t,language:o,className:n,maxHeight:r,startLine:a,lineNumbers:s=true,...c})=>{let i=C(),{isAnimating:l,scrollable:d}=useContext(R),p=d!=null?d:ze,u=st(r),m=it({content:t,enabled:!!u,isAnimating:l}),g=useMemo(()=>i(Ps),[i]),f=useMemo(()=>i(Ts),[i]),h=useMemo(()=>{let b={};return t.bg&&(b["--sdm-bg"]=t.bg),t.fg&&(b["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(b,Ms(t.rootStyle)),b},[t.bg,t.fg,t.rootStyle]);return jsx(p,{className:i(n,u?"overflow-x-auto overflow-y-auto":"overflow-x-auto","rounded-md border border-border bg-background p-4 text-sm"),"data-language":o,"data-streamdown":"code-block-body",scrollRef:m,style:u?{maxHeight:u}:void 0,...c,children:jsx("pre",{className:i(n,"bg-[var(--sdm-bg,inherit)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]"),style:h,children:jsx("code",{className:s?i("[counter-increment:line_0] [counter-reset:line]"):void 0,style:s&&a&&a>1?{counterReset:`line ${a-1}`}:void 0,children:t.tokens.map((b,T)=>jsx("span",{className:s?g:f,children:b.length===0||b.length===1&&b[0].content===""?`
|
|
3
|
+
`:b.map((k,M)=>{let P={},I=!!k.bgColor;if(k.color&&(P["--sdm-c"]=k.color),k.bgColor&&(P["--sdm-tbg"]=k.bgColor),k.htmlStyle)for(let[w,_]of Object.entries(k.htmlStyle))w==="color"?P["--sdm-c"]=_:w==="background-color"?(P["--sdm-tbg"]=_,I=true):P[w]=_;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",I&&"bg-[var(--sdm-tbg)]",I&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:P,...k.htmlAttrs,children:k.content},M)})},T))})})})});var At=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let a=C();return jsx("div",{className:a("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r})};var Dt=createContext({code:""}),lt=()=>useContext(Dt);var Ht=({language:e})=>{let t=C();return jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var As=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
|
+
`;)t--;return e.slice(0,t)},Ds=lazy(()=>import('./highlighted-body-H53OQTHH.js').then(e=>({default:e.HighlightedCodeBlockBody}))),Bt=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:a,lineNumbers:s,...c})=>{let i=C(),{codeBlockMaxHeight:l}=useContext(R),d=useMemo(()=>As(e),[e]),p=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
|
|
5
|
+
`).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]);return jsx(Dt.Provider,{value:{code:e},children:jsxs(At,{dir:"ltr",isIncomplete:r,language:t,children:[jsx(Ht,{language:t}),n?jsx("div",{className:i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("div",{className:i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:n})}):null,jsx(Suspense,{fallback:jsx(So,{className:o,language:t,lineNumbers:s,maxHeight:l,result:p,startLine:a,...c}),children:jsx(Ds,{className:o,code:d,language:t,lineNumbers:s,maxHeight:l,raw:p,startLine:a,...c})})]})})};var Eo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),Lo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),No=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),Ao=e=>jsxs("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),Do=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),Ho=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),Bo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),Oo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),_o=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),Vo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var We={CheckIcon:Eo,CopyIcon:Lo,DownloadIcon:No,ExternalLinkIcon:Oo,Loader2Icon:Ao,Maximize2Icon:Do,RotateCcwIcon:Ho,XIcon:Bo,ZoomInIcon:_o,ZoomOutIcon:Vo},$o=createContext(We),Vs=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let o=Object.keys(e),n=Object.keys(t);return o.length!==n.length?false:o.every(r=>e[r]===t[r])},Ot=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...We,...e}:We);Vs(o.current,e)||(o.current=e,n.current=e?{...We,...e}:We);let r=n.current;return jsx($o.Provider,{value:r,children:t})},B=()=>useContext($o);var ct={alertNote:"Note",alertTip:"Tip",alertImportant:"Important",alertWarning:"Warning",alertCaution:"Caution",copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",zoomIn:"Zoom in",zoomOut:"Zoom out",resetView:"Reset zoom and pan",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},dt=createContext(ct),O=()=>useContext(dt);var mt=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:a,...s})=>{let c=C(),[i,l]=useState(false),d=useRef(0),{code:p}=lt(),{isAnimating:u}=useContext(R),m=O(),g=a!=null?a:p,f=async()=>{var T;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(g),l(!0),e==null||e(),d.current=window.setTimeout(()=>l(!1),o));}catch(k){t==null||t(k);}};useEffect(()=>()=>{window.clearTimeout(d.current);},[]);let h=B(),b=i?h.CheckIcon:h.CopyIcon;return jsxs(Fragment,{children:[jsx("button",{"aria-label":m.copyCode,className:c("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:u,onClick:f,title:m.copyCode,type:"button",...s,children:n!=null?n:jsx(b,{"aria-hidden":"true",size:14})}),i&&jsx("output",{"aria-live":"polite",className:"sr-only",children:m.copied})]})};var zo={"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"},Vt=({onDownload:e,onError:t,language:o,children:n,className:r,code:a,...s})=>{let c=C(),{code:i}=lt(),{isAnimating:l}=useContext(R),d=O(),p=B(),u=a!=null?a:i,g=`file.${o&&o in zo?zo[o]:"txt"}`,f="text/plain",h=()=>{try{re(g,u,f),e==null||e();}catch(b){t==null||t(b);}};return jsx("button",{"aria-label":d.downloadFile,className:c("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:l,onClick:h,title:d.downloadFile,type:"button",...s,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var ut=()=>{let{Loader2Icon:e}=B(),t=C();return jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:jsx(e,{className:t("size-4 animate-spin")})})]})};var qe=0,be=()=>{qe+=1,qe===1&&(document.body.style.overflow="hidden");},he=()=>{qe=Math.max(0,qe-1),qe===0&&(document.body.style.overflow="");};var Ys=["github-light","github-dark"],Qs={enabled:true},ea={codeBlockMaxHeight:400,shikiTheme:Ys,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,linkSafety:Qs,tableMaxHeight:300},R=createContext(ea);var ra=/\.[^/.]+$/,qo=(e,t)=>{if(typeof e=="boolean")return e;let o=e.image;return o===false?false:o===true||o===void 0?true:o[t]!==false},Zo=({node:e,className:t,src:o,alt:n,onLoad:r,onError:a,onClick:s,...c})=>{let{DownloadIcon:i,XIcon:l}=B(),d=C(),p=useRef(null),[u,m]=useState(false),[g,f]=useState(false),[h,b]=useState(false),{controls:T}=useContext(R),k=O(),M=qo(T,"download"),P=qo(T,"fullscreen"),I=c.width!=null||c.height!=null,w=M&&(u||I)&&!g,_=g&&!I,V=P&&!!o&&!g&&u;useEffect(()=>{let E=p.current;if(E!=null&&E.complete){let $=E.naturalWidth>0;m($),f(!$);}},[]),useEffect(()=>{if(!h)return;be();let E=$=>{$.key==="Escape"&&b(false);};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E),he();}},[h]);let j=useCallback(E=>{m(true),f(false),r==null||r(E);},[r]),F=useCallback(E=>{m(false),f(true),a==null||a(E);},[a]),D=useCallback(()=>{V&&b(true);},[V]),H=useCallback(()=>{b(false);},[]),W=useCallback(E=>{s==null||s(E),!E.defaultPrevented&&D();},[s,D]),Y=async E=>{if(E.stopPropagation(),!!o)try{let ae=await(await fetch(o)).blob(),te=new URL(o,window.location.origin).pathname.split("/").pop()||"",ce=te.split(".").pop(),oe=te.includes(".")&&ce!==void 0&&ce.length<=4,ee="";if(oe)ee=te;else {let K=ae.type,v="png";K.includes("jpeg")||K.includes("jpg")?v="jpg":K.includes("png")?v="png":K.includes("svg")?v="svg":K.includes("gif")?v="gif":K.includes("webp")&&(v="webp"),ee=`${(n||te||"image").replace(ra,"")}.${v}`;}re(ee,ae,ae.type);}catch($){window.open(o,"_blank");}};return o?o==="streamdown:incomplete-image"?jsx("div",{className:d("group relative my-4 inline-block"),"data-incomplete":"true","data-streamdown":"image-wrapper",children:jsx("div",{className:d("h-24 w-48 animate-pulse rounded-lg bg-muted"),"data-streamdown":"image-placeholder"})}):jsxs(Fragment,{children:[jsxs("div",{className:d("group/image not-prose relative my-2 block max-w-full"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:d("m-0 block h-auto max-w-full rounded-lg",V&&"cursor-zoom-in",_&&"hidden",t),"data-streamdown":"image",onClick:W,onError:F,onLoad:j,ref:p,src:o,...c}),_&&jsx("span",{className:d("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:k.imageNotAvailable}),w&&jsx("button",{className:d("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 focus-visible:opacity-100 group-hover/image:opacity-100"),onClick:Y,title:k.downloadImage,type:"button",children:jsx(i,{size:14})})]}),h?createPortal(jsxs("div",{className:d("fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4"),"data-streamdown":"image-lightbox",onClick:H,onKeyDown:E=>{E.key==="Escape"&&H();},role:"button",tabIndex:0,children:[jsx("button",{className:d("absolute top-4 right-4 z-10 rounded-md p-2 text-white/80 transition-colors hover:bg-white/10 hover:text-white"),onClick:H,title:k.exitFullscreen,type:"button",children:jsx(l,{size:20})}),jsx("div",{onClick:E=>E.stopPropagation(),onKeyDown:E=>E.stopPropagation(),role:"presentation",children:jsx("img",{alt:n,className:d("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:o})})]}),document.body):null]}):null};var Xo=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:a,ExternalLinkIcon:s,XIcon:c}=B(),i=C(),[l,d]=useState(false),p=O(),u=useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(f){}},[e]),m=useCallback(()=>{n(),o();},[n,o]);if(useEffect(()=>{if(t){be();let f=h=>{h.key==="Escape"&&o();};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),he();}}},[t,o]),!t||typeof document=="undefined")return null;let g=jsx("div",{className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:o,onKeyDown:f=>{f.key==="Escape"&&o();},role:"button",tabIndex:0,children:jsxs("div",{className:i("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:f=>f.stopPropagation(),onKeyDown:f=>f.stopPropagation(),role:"presentation",children:[jsx("button",{className:i("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:o,title:p.close,type:"button",children:jsx(c,{size:16})}),jsxs("div",{className:i("flex flex-col gap-2"),children:[jsxs("div",{className:i("flex items-center gap-2 font-semibold text-lg"),children:[jsx(s,{size:20}),jsx("span",{children:p.openExternalLink})]}),jsx("p",{className:i("text-muted-foreground text-sm"),children:p.externalLinkWarning})]}),jsx("div",{className:i("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:i("flex gap-2"),children:[jsx("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:u,type:"button",children:l?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:p.copied})]}):jsxs(Fragment,{children:[jsx(a,{size:14}),jsx("span",{children:p.copyLink})]})}),jsxs("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:m,type:"button",children:[jsx(s,{size:14}),jsx("span",{children:p.openLink})]})]})]})});return createPortal(g,document.body)};var Uo=()=>e=>{visit(e,"html",(o,n,r)=>{!r||typeof n!="number"||(r.children[n]={type:"text",value:o.value});});};var Yo=[],Qo={allowDangerousHtml:true},pt=new WeakMap,Wt=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,a=t.remarkRehypeOptions;if(!(n||r||a)){let p="default";return this.keyCache.set(t,p),p}let s=p=>{if(!p||p.length===0)return "";let u="";for(let m=0;m<p.length;m+=1){let g=p[m];if(m>0&&(u+=","),Array.isArray(g)){let[f,h]=g;if(typeof f=="function"){let b=pt.get(f);b||(b=f.name,pt.set(f,b)),u+=b;}else u+=String(f);u+=":",u+=JSON.stringify(h);}else if(typeof g=="function"){let f=pt.get(g);f||(f=g.name,pt.set(g,f)),u+=f;}else u+=String(g);}return u},c=s(n),i=s(r),l=a?JSON.stringify(a):"",d=`${i}::${c}::${l}`;return this.keyCache.set(t,d),d}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(n,o);}clear(){this.cache.clear();}},en=new Wt,Ke=e=>{let t=ya(e),o=e.children||"",n=t.runSync(t.parse(o),o);return Ta(n,e)},ya=e=>{let t=en.get(e);if(t)return t;let o=wa(e);return en.set(e,o),o},Ca=e=>e.some(t=>Array.isArray(t)?t[0]===Jo:t===Jo),wa=e=>{let t=e.rehypePlugins||Yo,o=e.remarkPlugins||Yo,n=Ca(t)?o:[...o,Uo],r=e.remarkRehypeOptions?{...Qo,...e.remarkRehypeOptions}:Qo;return unified().use(fa).use(n).use(ga,r).use(t)},tn=e=>e,xa=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},ka=(e,t)=>{var o;for(let n in urlAttributes)if(Object.hasOwn(urlAttributes,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],a=urlAttributes[n];(a===null||a.includes(e.tagName))&&(e.properties[n]=(o=t(String(r||""),n,e))!=null?o:void 0);}},va=(e,t,o,n,r,a)=>{let s=false;return n?s=!n.includes(e.tagName):r&&(s=r.includes(e.tagName)),!s&&a&&typeof t=="number"&&(s=!a(e,t,o)),s},Ta=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:a,unwrapDisallowed:s,urlTransform:c}=t;if(o||n||r||a||c){let l=c||tn;visit(e,(d,p,u)=>{if(d.type==="raw"&&u&&typeof p=="number")return xa(u,p,a,d.value),p;if(d.type==="element"&&(ka(d,l),va(d,p,u,n,r,o)&&u&&typeof p=="number"))return s&&d.children?u.children.splice(p,1,...d.children):u.children.splice(p,1),p});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var ft=createContext(null),qt=()=>useContext(ft),Md=()=>{var t;let e=qt();return (t=e==null?void 0:e.code)!=null?t:null},He=()=>{var t;let e=qt();return (t=e==null?void 0:e.mermaid)!=null?t:null};var on=e=>{var o;let t=qt();return t!=null&&t.renderers&&e&&(o=t.renderers.find(n=>Array.isArray(n.language)?n.language.includes(e):n.language===e))!=null?o:null};var Sa=/(<svg\b)/,sn=/<svg\b[^>]*>/i,Ra=/\bviewBox=(['"])(.*?)\1/i,Ia=/\swidth=(['"]).*?\1/i,Ea=/\sheight=(['"]).*?\1/i,nn=/\sstyle=(['"])(.*?)\1/i,rn=/^<svg/i,La=/^width\s*:/i,Na=/^height\s*:/i,Aa=/^max-width\s*:/i,Da=/[\s,]+/,Ha=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(Sa,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),an=e=>{if(typeof DOMParser=="undefined"||typeof XMLSerializer=="undefined")return e;let o=new DOMParser().parseFromString(e,"text/html").querySelector("svg");return o?new XMLSerializer().serializeToString(o):e},Zt=e=>{let t=e.match(sn);if(!t)return null;let n=t[0].match(Ra),r=n==null?void 0:n[2];if(!r)return null;let a=r.trim().split(Da).map(i=>Number.parseFloat(i));if(a.length<4||a.slice(0,4).some(Number.isNaN))return null;let s=a[2],c=a[3];return s>0&&c>0?{height:c,width:s}:null},ln=e=>{let t=e.match(sn);if(!t)return e;try{let o=t[0],n=Zt(e);if(!n)return e;let{width:r,height:a}=n,s=o.replace(Ia,"").replace(Ea,""),c=s.match(nn),i=`width:${r}px;height:${a}px;max-width:none;`;if(c){let l=c[1],p=c[2].split(";").map(m=>m.trim()).filter(Boolean).filter(m=>!(La.test(m)||Na.test(m)||Aa.test(m))).join(";"),u=`${i}${p?`${p};`:""}`;s=s.replace(nn,` style=${l}${u}${l}`);}else s=s.replace(rn,`<svg style="${i}"`);return s=s.replace(rn,`<svg width="${r}" height="${a}"`),e.replace(o,s)}catch(o){return e}},cn=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,a)=>{let s=Ha(e),c="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(s))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let l=document.createElement("canvas"),d=i.width*o,p=i.height*o;l.width=d,l.height=p;let u=l.getContext("2d");if(!u){a(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(i,0,0,d,p),l.toBlob(m=>{if(!m){a(new Error("Failed to create PNG blob"));return}r(m);},"image/png");},i.onerror=()=>a(new Error("Failed to load SVG image")),i.src=c;})};var gt=({chart:e,children:t,className:o,onDownload:n,config:r,onError:a})=>{let s=C(),[c,i]=useState(false),l=useRef(null),{isAnimating:d}=useContext(R),p=B(),u=He(),m=O(),g=async f=>{try{if(f==="mmd"){re("diagram.mmd",e,"text/plain"),i(!1),n==null||n(f);return}if(!u){a==null||a(new Error("Mermaid plugin not available"));return}let h=u.getMermaid(r),b=e.split("").reduce((P,I)=>(P<<5)-P+I.charCodeAt(0)|0,0),T=`mermaid-${Math.abs(b)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:k}=await h.render(T,e);if(!k){a==null||a(new Error("SVG not found. Please wait for the diagram to render."));return}let M=an(k);if(f==="svg"){re("diagram.svg",M,"image/svg+xml"),i(!1),n==null||n(f);return}if(f==="png"){let P=await cn(M);re("diagram.png",P,"image/png"),n==null||n(f),i(!1);return}}catch(h){a==null||a(h);}};return useEffect(()=>{let f=h=>{let b=h.composedPath();l.current&&!b.includes(l.current)&&i(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f);}},[]),jsxs("div",{className:s("relative"),ref:l,children:[jsx("button",{"aria-label":m.downloadDiagram,className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:d,onClick:()=>i(!c),title:m.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{"aria-hidden":"true",size:14})}),c?jsxs("div",{className:s("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",{"aria-label":m.downloadDiagramAsSvg,className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("svg"),title:m.downloadDiagramAsSvg,type:"button",children:m.mermaidFormatSvg}),jsx("button",{"aria-label":m.downloadDiagramAsPng,className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("png"),title:m.downloadDiagramAsPng,type:"button",children:m.mermaidFormatPng}),jsx("button",{"aria-label":m.downloadDiagramAsMmd,className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("mmd"),title:m.downloadDiagramAsMmd,type:"button",children:m.mermaidFormatMmd})]}):null]})};var pn=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...a})=>{let{Maximize2Icon:s,XIcon:c}=B(),i=C(),[l,d]=useState(false),{isAnimating:p,controls:u}=useContext(R),m=O(),g=(()=>{if(typeof u=="boolean")return u;let b=u.mermaid;return b===false?false:b===true||b===void 0?true:b.panZoom!==false})(),f=(()=>{if(typeof u=="boolean")return u;let b=u.mermaid;return b===false?false:b===true||b===void 0?true:b.download!==false})(),h=()=>{d(!l);};return useEffect(()=>{if(l){be();let b=T=>{T.key==="Escape"&&d(false);};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),he();}}},[l]),useEffect(()=>{l?o==null||o():n&&n();},[l,o,n]),jsxs(Fragment,{children:[jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:p,onClick:h,title:m.viewFullscreen,type:"button",...a,"aria-label":m.viewFullscreen,children:jsx(s,{"aria-hidden":"true",size:14})}),l?createPortal(jsxs("div",{"aria-label":m.viewFullscreen,"aria-modal":"true",className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"mermaid-fullscreen",onClick:h,onKeyDown:b=>{b.key==="Escape"&&h();},role:"dialog",children:[jsxs("div",{className:i("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:[f?jsx(gt,{chart:e,config:t}):null,jsx("button",{"aria-label":m.exitFullscreen,className:i("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:m.exitFullscreen,type:"button",children:jsx(c,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:i("flex size-full items-center justify-center p-4"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:jsx(un,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:g})})]}),document.body):null]})};function Gt(e){var o;if(e.nodeType===Node.TEXT_NODE)return (o=e.textContent)!=null?o:"";if(e.nodeType!==Node.ELEMENT_NODE)return "";let t=e;return t.tagName==="BR"?`
|
|
6
|
+
`:Array.from(t.childNodes).map(Gt).join("")}var Be=e=>{let t=[],o=[],n=e.querySelectorAll("thead th");for(let a of n)t.push(Gt(a).trim());let r=e.querySelectorAll("tbody tr");for(let a of r){let s=[],c=a.querySelectorAll("td");for(let i of c)s.push(Gt(i).trim());o.push(s);}return {headers:t,rows:o}},Ee=e=>{let{headers:t,rows:o}=e,n=c=>{let i=false,l=false;for(let d of c){if(d==='"'){i=true,l=true;break}(d===","||d===`
|
|
7
|
+
`)&&(i=true);}return i?l?`"${c.replace(/"/g,'""')}"`:`"${c}"`:c},r=t.length>0?o.length+1:o.length,a=new Array(r),s=0;t.length>0&&(a[s]=t.map(n).join(","),s+=1);for(let c of o)a[s]=c.map(n).join(","),s+=1;return a.join(`
|
|
8
|
+
`)},Xt=e=>{let{headers:t,rows:o}=e,n=c=>{let i=false;for(let d of c)if(d===" "||d===`
|
|
9
|
+
`||d==="\r"){i=true;break}if(!i)return c;let l=[];for(let d of c)d===" "?l.push("\\t"):d===`
|
|
10
|
+
`?l.push("\\n"):d==="\r"?l.push("\\r"):l.push(d);return l.join("")},r=t.length>0?o.length+1:o.length,a=new Array(r),s=0;t.length>0&&(a[s]=t.map(n).join(" "),s+=1);for(let c of o)a[s]=c.map(n).join(" "),s+=1;return a.join(`
|
|
11
|
+
`)},bt=e=>{let t=false;for(let n of e)if(n==="\\"||n==="|"||n===`
|
|
12
|
+
`){t=true;break}if(!t)return e;let o=[];for(let n of e)n==="\\"?o.push("\\\\"):n==="|"?o.push("\\|"):n===`
|
|
13
|
+
`?o.push("<br>"):o.push(n);return o.join("")},Le=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),r=0,a=t.map(c=>bt(c));n[r]=`| ${a.join(" | ")} |`,r+=1;let s=new Array(t.length);for(let c=0;c<t.length;c+=1)s[c]="---";n[r]=`| ${s.join(" | ")} |`,r+=1;for(let c of o)if(c.length<t.length){let i=new Array(t.length);for(let l=0;l<t.length;l+=1)i[l]=l<c.length?bt(c[l]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=c.map(l=>bt(l));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
|
|
14
|
+
`)};var Ue=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let a=C(),[s,c]=useState(false),[i,l]=useState(false),d=useRef(null),p=useRef(0),{isAnimating:u}=useContext(R),m=O(),g=async b=>{var T,k;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.write)){n==null||n(new Error("Clipboard API not available"));return}try{let M=(k=d.current)==null?void 0:k.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),P=M==null?void 0:M.querySelector("table");if(!P){n==null||n(new Error("Table not found"));return}let I=Be(P),V=({csv:Ee,tsv:Xt,md:Le}[b]||Le)(I),j=new ClipboardItem({"text/plain":new Blob([V],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([j]),l(!0),c(!1),o==null||o(b),p.current=window.setTimeout(()=>l(!1),r);}catch(M){n==null||n(M);}};useEffect(()=>{let b=T=>{let k=T.composedPath();d.current&&!k.includes(d.current)&&c(false);};return document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b),window.clearTimeout(p.current);}},[]);let f=B(),h=i?f.CheckIcon:f.CopyIcon;return jsxs("div",{className:a("relative"),ref:d,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>c(!s),title:m.copyTable,type:"button",children:e!=null?e:jsx(h,{height:14,width:14})}),s?jsxs("div",{className:a("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("md"),title:m.copyTableAsMarkdown,type:"button",children:m.tableFormatMarkdown}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("csv"),title:m.copyTableAsCsv,type:"button",children:m.tableFormatCsv}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("tsv"),title:m.copyTableAsTsv,type:"button",children:m.tableFormatTsv})]}):null]})};var Xa=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:a})=>{let s=C(),{isAnimating:c}=useContext(R),i=O(),l=B(),d=p=>{try{let m=p.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),g=m==null?void 0:m.querySelector("table");if(!g){n==null||n(new Error("Table not found"));return}let f=Be(g),h="",b="",T="";switch(r){case "csv":h=Ee(f),b="text/csv",T="csv";break;case "markdown":h=Le(f),b="text/markdown",T="md";break;default:h=Ee(f),b="text/csv",T="csv";}re(`${a||"table"}.${T}`,h,b),o==null||o();}catch(u){n==null||n(u);}};return jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:d,title:r==="csv"?i.downloadTableAsCsv:i.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(l.DownloadIcon,{size:14})})},Je=({children:e,className:t,onDownload:o,onError:n})=>{let r=C(),[a,s]=useState(false),c=useRef(null),{isAnimating:i}=useContext(R),l=O(),d=B(),p=u=>{var m;try{let g=(m=c.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=g==null?void 0:g.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let h=Be(f),b=u==="csv"?Ee(h):Le(h);re(`table.${u==="csv"?"csv":"md"}`,b,u==="csv"?"text/csv":"text/markdown"),s(!1),o==null||o(u);}catch(g){n==null||n(g);}};return useEffect(()=>{let u=m=>{let g=m.composedPath();c.current&&!g.includes(c.current)&&s(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[]),jsxs("div",{className:r("relative"),ref:c,children:[jsx("button",{className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>s(!a),title:l.downloadTable,type:"button",children:e!=null?e:jsx(d.DownloadIcon,{size:14})}),a?jsxs("div",{className:r("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("csv"),title:l.downloadTableAsCsv,type:"button",children:l.tableFormatCsv}),jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("markdown"),title:l.downloadTableAsMarkdown,type:"button",children:l.tableFormatMarkdown})]}):null]})};var Cn=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:a}=B(),s=C(),[c,i]=useState(false),{isAnimating:l}=useContext(R),d=O(),p=()=>{i(true);},u=()=>{i(false);};return useEffect(()=>{if(c){be();let m=g=>{g.key==="Escape"&&i(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),he();}}},[c]),jsxs(Fragment,{children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:p,title:d.viewFullscreen,type:"button",children:jsx(r,{size:14})}),c?createPortal(jsx("div",{"aria-label":d.viewFullscreen,"aria-modal":"true",className:s("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:u,onKeyDown:m=>{m.key==="Escape"&&u();},role:"dialog",children:jsxs("div",{className:s("flex h-full flex-col"),onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),role:"presentation",children:[jsxs("div",{className:s("flex items-center justify-end gap-1 p-4"),children:[o?jsx(Ue,{}):null,n?jsx(Je,{}):null,jsx("button",{className:s("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:u,title:d.exitFullscreen,type:"button",children:jsx(a,{size:20})})]}),jsx("div",{className:s("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:s("w-full table-fixed border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})};var xn=({children:e,className:t,maxHeight:o,showControls:n,showCopy:r=true,showDownload:a=true,showFullscreen:s=true,...c})=>{let i=C(),{isAnimating:l,scrollable:d}=useContext(R),p=d!=null?d:ze,u=st(o),m=it({content:e,enabled:!!u,isAnimating:l}),g=n&&r,f=n&&a,h=n&&s,b=g||f||h;return jsxs("div",{className:i("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[b?jsxs("div",{className:i("flex items-center justify-end gap-1"),children:[g?jsx(Ue,{}):null,f?jsx(Je,{}):null,h?jsx(Cn,{showCopy:g,showDownload:f,children:e}):null]}):null,jsx(p,{className:i("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),scrollRef:m,style:u?{maxHeight:u}:void 0,children:jsx("table",{className:i("w-full min-w-max table-fixed divide-y divide-border",t),"data-streamdown":"table",...c,children:e})})]})};var ai=/startLine=(\d+)/,ii=/\bnoLineNumbers\b/,li=lazy(()=>import('./mermaid-2NSXBHVL.js').then(e=>({default:e.Mermaid}))),ci=/language-([^\s]+)/,le=e=>e.props,di="node";function A(e,t){let o=Object.keys(e);if(o.length!==Object.keys(t).length)return false;let n=e,r=t;for(let a of o)if(a!==di&&!Object.is(n[a],r[a]))return false;return true}function mi(e,t){var o,n;return ((o=e==null?void 0:e.properties)==null?void 0:o.metastring)===((n=t==null?void 0:t.properties)==null?void 0:n.metastring)}function ui(e){if(typeof e=="string")return e;if(isValidElement(e)){let t=le(e).children;if(typeof t=="string")return t}}var Qt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Yt=(e,t)=>{if(typeof e=="boolean")return e;let o=e.table;return o===false?false:o===true||o===void 0?true:o[t]!==false},vn=(e,t)=>{if(typeof e=="boolean")return e;let o=e.code;return o===false?false:o===true||o===void 0?true:o[t]!==false},ht=(e,t)=>{if(typeof e=="boolean")return e;let o=e.mermaid;return o===false?false:o===true||o===void 0?true:o[t]!==false},Qe=createContext({depth:0,ulDepth:0,isUnordered:false}),pi={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},eo=memo(({children:e,className:t,node:o,...n})=>{let r=C(),{depth:a,ulDepth:s}=useContext(Qe),c=useMemo(()=>({depth:a+1,ulDepth:s,isUnordered:false}),[a,s]);return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-depth":a,"data-streamdown":"ordered-list",...n,children:jsx(Qe.Provider,{value:c,children:e})})},(e,t)=>A(e,t));eo.displayName="MarkdownOl";var Sn=memo(({children:e,className:t,node:o,...n})=>{var f;let r=C(),{depth:a,ulDepth:s,isUnordered:c}=useContext(Qe),{listStyle:i}=useContext(R),l=pi[i],d=c&&s>0?l[(s-1)%l.length]:void 0,p=Array.isArray(e)?e.filter(h=>h!==`
|
|
15
|
+
`&&h!==""):[e],u=p[0],m=isValidElement(u)?(f=le(u).node)==null?void 0:f.tagName:void 0,g=p.length===1&&isValidElement(u)&&(u.type==="p"||m==="p")?le(u).children:e;return t!=null&&t.includes("task-list-item")?jsx("li",{className:r("my-1 flex list-none items-center gap-2 [&>input]:m-0 [&>p]:inline",t),"data-depth":a>0?a-1:0,"data-streamdown":"list-item",...n,children:g}):jsx("li",{className:r("py-1 [&>p]:inline",d,t),"data-depth":a>0?a-1:0,"data-streamdown":"list-item",...n,children:g})},(e,t)=>A(e,t));Sn.displayName="MarkdownLi";var Rn=memo(({children:e,className:t,node:o,...n})=>{let r=C(),{depth:a,ulDepth:s}=useContext(Qe),c=useMemo(()=>({depth:a+1,ulDepth:s+1,isUnordered:true}),[a,s]);return jsx("ul",{className:r("list-inside whitespace-normal [li_&]:pl-6",t),"data-depth":a,"data-streamdown":"unordered-list",...n,children:jsx(Qe.Provider,{value:c,children:e})})},(e,t)=>A(e,t));Rn.displayName="MarkdownUl";var In=memo(({className:e,node:t,...o})=>{let n=C();return jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>A(e,t));In.displayName="MarkdownHr";var En=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>A(e,t));En.displayName="MarkdownStrong";var fi=({children:e,className:t,href:o,node:n,...r})=>{let a=C(),{linkSafety:s}=useContext(R),[c,i]=useState(false),l=o==="streamdown:incomplete-link",d=useCallback(async g=>{if(!(!(s!=null&&s.enabled&&o)||l)){if(g.preventDefault(),s.onLinkCheck&&await s.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[s,o,l]),p=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),u=useCallback(()=>{i(false);},[]),m={url:o!=null?o:"",isOpen:c,onClose:u,onConfirm:p};return s!=null&&s.enabled&&o?jsxs(Fragment,{children:[jsx("button",{className:a("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":l,"data-streamdown":"link",onClick:d,type:"button",children:e}),s.renderModal?s.renderModal(m):jsx(Xo,{...m})]}):jsx("a",{className:a("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":l,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},Ln=memo(fi,(e,t)=>A(e,t));Ln.displayName="MarkdownA";var Nn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>A(e,t));Nn.displayName="MarkdownH1";var An=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>A(e,t));An.displayName="MarkdownH2";var Dn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>A(e,t));Dn.displayName="MarkdownH3";var Hn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>A(e,t));Hn.displayName="MarkdownH4";var Bn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>A(e,t));Bn.displayName="MarkdownH5";var On=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>A(e,t));On.displayName="MarkdownH6";var _n=memo(({children:e,className:t,node:o,...n})=>{let{controls:r,tableMaxHeight:a}=useContext(R),s=Qt(r,"table"),c=Yt(r,"copy"),i=Yt(r,"download"),l=Yt(r,"fullscreen");return jsx(xn,{className:t,maxHeight:a,showControls:s,showCopy:c,showDownload:i,showFullscreen:l,...n,children:e})},(e,t)=>A(e,t));_n.displayName="MarkdownTable";var Vn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>A(e,t));Vn.displayName="MarkdownThead";var jn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>A(e,t));jn.displayName="MarkdownTbody";var $n=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>A(e,t));$n.displayName="MarkdownTr";var zn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("th",{className:r("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>A(e,t));zn.displayName="MarkdownTh";var Fn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>A(e,t));Fn.displayName="MarkdownTd";var Wn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e})},(e,t)=>A(e,t));Wn.displayName="MarkdownBlockquote";var qn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>A(e,t));qn.displayName="MarkdownSup";var gi=()=>({}),bi=e=>{try{let t=atob(e),o=Uint8Array.from(t,n=>n.charCodeAt(0));return new TextDecoder().decode(o)}catch(t){return ""}},Zn=memo(({children:e,className:t,node:o,...n})=>{let r=C(),{calloutIcon:a,calloutStyle:s,components:c,remarkPlugins:i,rehypePlugins:l}=useContext(R),d=n,p=d["data-callout-title"],u=d["data-callout-color"],m=d["data-callout-icon"],g=d["data-callout-body"],f=g?bi(g):"",h=(s!=null?s:gi)(u),b=m&&a?a(m):null;return jsxs("div",{className:r("my-4 rounded-md border-l-4 px-4 py-3 [&>p:last-child]:mb-0",t),"data-streamdown":"callout",style:h,...n,children:[p!==void 0?jsxs("p",{className:"mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",children:[b,p]}):null,f.trim().length>0?jsx(Ke,{components:c,rehypePlugins:l,remarkPlugins:i,children:f}):null]})},(e,t)=>A(e,t));Zn.displayName="MarkdownCallout";var Tn={"markdown-alert-note":"border-l-blue-500 bg-blue-500/5 [&_.markdown-alert-title]:text-blue-600 dark:[&_.markdown-alert-title]:text-blue-400","markdown-alert-tip":"border-l-green-600 bg-green-600/5 [&_.markdown-alert-title]:text-green-700 dark:[&_.markdown-alert-title]:text-green-400","markdown-alert-important":"border-l-purple-600 bg-purple-600/5 [&_.markdown-alert-title]:text-purple-700 dark:[&_.markdown-alert-title]:text-purple-400","markdown-alert-warning":"border-l-amber-600 bg-amber-600/5 [&_.markdown-alert-title]:text-amber-700 dark:[&_.markdown-alert-title]:text-amber-400","markdown-alert-caution":"border-l-red-600 bg-red-600/5 [&_.markdown-alert-title]:text-red-700 dark:[&_.markdown-alert-title]:text-red-400"},Kn=memo(({children:e,className:t,node:o,...n})=>{let r=C(),a=t==null?void 0:t.includes("markdown-alert");if(t==null?void 0:t.includes("sdm-callout"))return jsx(Zn,{className:t,node:o,...n,children:e});if(a){let c=Object.keys(Tn).find(i=>t==null?void 0:t.includes(i));return jsx("div",{className:r("my-4 rounded-r-md border-muted-foreground/30 border-l-4 bg-muted/40 px-4 py-3 [&>p:last-child]:mb-0",c?Tn[c]:null,t),...n,children:e})}return jsx("div",{className:r(t),...n,children:e})},(e,t)=>A(e,t));Kn.displayName="MarkdownDiv";var Gn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>A(e,t));Gn.displayName="MarkdownSub";var Xn=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let a=i=>{if(!isValidElement(i))return false;let l=le(i).children,d=Array.isArray(l)?l:[l],p=false,u=false;for(let m of d)if(m){if(typeof m=="string")m.trim()!==""&&(p=true);else if(isValidElement(m))if(le(m)["data-footnote-backref"]!==void 0)u=true;else {let g=le(m).children,f=Array.isArray(g)?g:[g];for(let h of f){if(typeof h=="string"&&h.trim()!==""){p=true;break}if(isValidElement(h)&&le(h)["data-footnote-backref"]===void 0){p=true;break}}}}return u&&!p},s=Array.isArray(e)?e.map(i=>{if(!isValidElement(i))return i;if(i.type===eo){let l=le(i).children,p=(Array.isArray(l)?l:[l]).filter(u=>!a(u));return p.length===0?null:{...i,props:{...le(i),children:p}}}return i}):e;return (Array.isArray(s)?s.some(i=>i!==null):s!==null)?jsx("section",{className:t,...n,children:s}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>A(e,t));Xn.displayName="MarkdownSection";var hi=({node:e,className:t,children:o,...n})=>{var F,D,H;let r=C(),a=!("data-block"in n),{mermaid:s,controls:c,lineNumbers:i}=useContext(R),l=He(),d=Lt(),p=t==null?void 0:t.match(ci),u=(F=p==null?void 0:p.at(1))!=null?F:"",m=on(u);if(a)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let g=(D=e==null?void 0:e.properties)==null?void 0:D.metastring,f=typeof g=="string"?g:void 0,h=f==null?void 0:f.match(ai),b=h?Number.parseInt(h[1],10):void 0,T=b!==void 0&&b>=1?b:void 0,M=!(f?ii.test(f):false)&&i!==false,P=(H=ui(o))!=null?H:"";if(m){let W=m.component;return jsx(Suspense,{fallback:jsx(ut,{}),children:jsx(W,{code:P,isIncomplete:d,language:u,meta:f})})}if(u==="mermaid"&&l){let W=Qt(c,"mermaid"),Y=ht(c,"download"),Q=ht(c,"copy"),E=ht(c,"fullscreen"),$=ht(c,"panZoom"),ae=W&&(Y||Q||E);return jsx(Suspense,{fallback:jsx(ut,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":d||void 0,"data-streamdown":"mermaid-block",children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:"mermaid"})}),ae?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"mermaid-block-actions",children:[Y?jsx(gt,{chart:P,config:s==null?void 0:s.config}):null,Q?jsx(mt,{code:P}):null,E?jsx(pn,{chart:P,config:s==null?void 0:s.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(li,{chart:P,config:s==null?void 0:s.config,showControls:$})})]})})}let I=Qt(c,"code"),w=vn(c,"download"),_=vn(c,"copy"),{"data-block":V,...j}=n;return jsx(Bt,{className:t,code:P,isIncomplete:d,language:u,lineNumbers:M,startLine:T,...j,children:I?jsxs(Fragment,{children:[w?jsx(Vt,{code:P,language:u}):null,_?jsx(mt,{}):null]}):null})},Un=memo(hi,(e,t)=>A(e,t)&&mi(e.node,t.node));Un.displayName="MarkdownCode";var Jn=memo(Zo,(e,t)=>A(e,t));Jn.displayName="MarkdownImg";var Pn={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},Yn=memo(({children:e,className:t,node:o,...n})=>{let r=C(),a=O(),s=n["data-alert-type"],c=s&&s in Pn?Pn[s]:void 0,i=c?a[c]:void 0,l=e;return i&&(l=[...(Array.isArray(e)?e:[e]).filter(u=>!(typeof u=="string"&&u.trim().length>0)),i]),jsx("p",{className:r("mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",t),...n,children:l})},(e,t)=>A(e,t));Yn.displayName="MarkdownAlertTitle";var Qn=memo(({children:e,className:t,node:o,...n})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(Yn,{className:t,node:o,...n,children:e});let a=(Array.isArray(e)?e:[e]).filter(s=>s!=null&&s!=="");if(a.length===1&&isValidElement(a[0])){let s=le(a[0]).node,c=s==null?void 0:s.tagName;if(c==="img")return jsx(Fragment,{children:e});if(c==="code"&&"data-block"in a[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...n,children:e})},(e,t)=>A(e,t));Qn.displayName="MarkdownParagraph";var er={ol:eo,li:Sn,ul:Rn,hr:In,strong:En,a:Ln,h1:Nn,h2:An,h3:Dn,h4:Hn,h5:Bn,h6:On,table:_n,thead:Vn,tbody:jn,tr:$n,th:zn,td:Fn,blockquote:Wn,code:Un,div:Kn,img:Jn,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:qn,sub:Gn,p:Qn,section:Xn};var yi=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Ci=/\p{L}/u;function et(e){let t=e.replace(/(```|~~~)[\s\S]*?\1/g,"").replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,""),o,n=0,r=0;for(let a of t){if(yi.test(a)){o!=null||(o="rtl"),r+=1;continue}Ci.test(a)&&(o!=null||(o="ltr"),n+=1);}return r>n?"rtl":n>r?"ltr":o!=null?o:"ltr"}var wi=/^[ \t]{0,3}(`{3,}|~{3,})/;var tr=e=>{let t=e.split(`
|
|
16
|
+
`),o=null,n=0;for(let r of t){let a=wi.exec(r);if(o===null){if(a){let s=a[1];o=s[0],n=s.length;}}else if(a){let s=a[1],c=s[0],i=s.length;c===o&&i>=n&&(o=null,n=0);}}return o!==null};var ki=/\[\^[\w-]{1,200}\](?!:)/,vi=/\[\^[\w-]{1,200}\]:/,Ti=/<([A-Za-z][\w:-]*)[\s>/]/,Pi=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),or=new Map,nr=new Map,ar=e=>{let t=e.toLowerCase(),o=or.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return or.set(t,n),n},Mi=e=>{let t=e.toLowerCase(),o=nr.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return nr.set(t,n),n},rr=(e,t)=>{if(Pi.has(t.toLowerCase()))return 0;let o=e.match(ar(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},sr=(e,t)=>{let o=e.match(Mi(t));return o?o.length:0},Si=(e,t)=>{let o=e.match(ar(t));return !!o&&o.every(n=>n.trimEnd().endsWith("/>"))},Ri=e=>{let t=0;for(let o=0;o<e.length-1;o+=1)e[o]==="$"&&e[o+1]==="$"&&(t+=1,o+=1);return t},Ct=e=>{let t=ki.test(e),o=vi.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),r=[],a=[],s=false;for(let c of n){let i=c.raw,l=r.length;if(a.length>0){r[l-1]+=i;let d=a.at(-1),p=rr(i,d),u=sr(i,d);for(let m=0;m<p;m+=1)a.push(d);for(let m=0;m<u;m+=1)a.length>0&&a.at(-1)===d&&a.pop();continue}if(c.type==="html"&&c.block){let d=i.match(Ti);if(d){let p=d[1],u=rr(i,p),m=sr(i,p);u>m&&!Si(i,p)&&a.push(p);}}if(l>0&&!s){let d=r[l-1];if(Ri(d)%2===1){r[l-1]=d+i;continue}}r.push(i),c.type!=="space"&&(s=c.type==="code");}return r},to=(e,t,o=Ct)=>{if(!(t!=null&&t.source&&e.startsWith(t.source)))return {source:e,blocks:o(e)};if(e===t.source)return t;if(t.blocks.length<=1)return {source:e,blocks:o(e)};let n=t.blocks.slice(0,-1),r=0;for(let i of n)r+=i.length;let a=e.slice(0,r);if(n.join("")!==a)return {source:e,blocks:o(e)};let s=e.slice(r),c=o(s);return {source:e,blocks:[...n,...c]}};var Ii=/^\n*/,Ei=/\n*$/,oo=/\n\n/g,Li=(e,t,o)=>{if(!t.includes(`
|
|
17
|
+
`))return e+t+o;let r=t.replace(oo,`
|
|
18
|
+
<!---->
|
|
19
|
+
`).replace(Ii,`
|
|
20
|
+
|
|
21
|
+
`).replace(Ei,`
|
|
22
|
+
|
|
23
|
+
`);return `${e}${r}${o}
|
|
24
|
+
|
|
25
|
+
`},Ni=(e,t)=>{let o=new RegExp(`<(${t})(?=[\\s>/])([^>]*)>`,"gi"),n="",r=0,a=o.exec(e);for(;a;){let s=a[0],c=a[1],i=a.index+s.length,l=e.slice(i);if(new RegExp(`</${c}\\s*>`,"i").test(l)){a=o.exec(e);continue}if(n+=e.slice(r,a.index),l.length===0){n+=s,r=i,a=o.exec(e);continue}if(l.startsWith(`
|
|
26
|
+
|
|
27
|
+
`)){let m=l.slice(2).replace(oo,`
|
|
28
|
+
<!---->
|
|
29
|
+
`);n+=`${s}
|
|
30
|
+
|
|
31
|
+
${m}`,r=e.length;break}if(!l.startsWith(`
|
|
32
|
+
`)){n+=s,r=i,a=o.exec(e);continue}let p=l.slice(1);if(p.trim().length===0){n+=s,r=i,a=o.exec(e);continue}let u=p.replace(oo,`
|
|
33
|
+
<!---->
|
|
34
|
+
`);n+=`${s}
|
|
35
|
+
|
|
36
|
+
${u}`,r=e.length;break}return r===0?e:n+e.slice(r)},ir=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`<${n}(?=[\\s>/])((?:"[^"]*"|'[^']*'|[^"'>])*)\\/>`,"gi");o=o.replace(r,(a,s)=>`<${n}${s}></${n}>`);}for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(a,s,c,i)=>Li(s,c,i)),o=Ni(o,n);}return o};var Ai=/([\\`*_~[\]|])/g,Di=e=>e.replace(Ai,"\\$1"),lr=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(a,s,c,i)=>{let l=Di(c).replace(/\n\n/g," ");return s+l+i});}return o};var Bi=new Set(["blockquote","dd","dt","figcaption","h1","h2","h3","h4","h5","h6","li","p","td","th"]),cr=new Set(["code","kbd","pre","samp","var"]);function dr(e){return e.children.map(t=>t.type==="text"?t.value:t.type==="element"&&!cr.has(t.tagName)?dr(t):"").join("")}function mr(){return e=>{visit(e,"element",t=>{if(cr.has(t.tagName)){(t.properties)!=null||(t.properties={}),t.properties.dir="ltr";return}Bi.has(t.tagName)&&((t.properties)!=null||(t.properties={}),typeof t.properties.dir!="string"&&(t.properties.dir=et(dr(t))));});}}var ur=e=>t=>{if(!e||e.length===0)return;let o=new Set(e.map(n=>n.toLowerCase()));visit(t,"element",n=>{var a;if(!o.has(n.tagName.toLowerCase()))return;let r=n.children.filter(s=>s.type==="element").map(s=>{var c;return {tag:s.tagName,props:(c=s.properties)!=null?c:{},text:toText(s).trim()}});n.properties=(a=n.properties)!=null?a:{},n.properties["data-content"]=JSON.stringify(r),n.children=[];});};var pr=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(pr).join(""):"",fr=e=>t=>{if(!e||e.length===0)return;let o=new Set(e.map(n=>n.toLowerCase()));visit(t,"element",n=>{if(o.has(n.tagName.toLowerCase())){let r=pr(n);n.children=r?[{type:"text",value:r}]:[];}});};var Wi=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),qi=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),Zi=e=>{let t=unified().use(fa).use(ga,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},gr=(e,t=[])=>o=>{if(!e||e.length===0)return;let n=new Set(e.map(a=>a.toLowerCase())),r=new Set((t!=null?t:[]).map(a=>a.toLowerCase()));visit(o,"element",a=>{let s=a.tagName.toLowerCase();if(!n.has(s)||r.has(s)||!Wi(a))return;let c=qi(a);if(!c.includes(`
|
|
37
|
+
`))return;let i=Zi(c);a.children=i;});};var br=()=>e=>{visit(e,"code",t=>{var o,n;t.meta&&(t.data=(o=t.data)!=null?o:{},t.data.hProperties={...(n=t.data.hProperties)!=null?n:{},metastring:t.meta});});};var hr=/^>>>[ \t]?(.*)$/,Gi=/^<<<\s*$/,Xi=/^>+\s*$/,Ui=/^<+\s*$/,Ji=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,Yi=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,Qi=/^[a-z0-9-]+$/,el=e=>{let t=Ji.exec(e);if(!(t!=null&&t.groups))return {};let{iconParen:o,iconBrace:n,title:r,color:a}=t.groups,s=o!=null?o:n;return {icon:s&&Qi.test(s)?s:void 0,title:r!==void 0&&r.length>0?r:void 0,color:a&&Yi.test(a)?a:void 0}},no=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),tl=e=>{let t=new TextEncoder().encode(e),o="";for(let n of t)o+=String.fromCharCode(n);return btoa(o)},ol=(e,t)=>{var l;let o=hr.exec(e[t]),n=(l=o==null?void 0:o[1])!=null?l:"",r=el(n),a=[],s=t+1;for(;s<e.length;s+=1){let d=e[s];if(Gi.test(d)){s+=1;break}if(Xi.test(d)||Ui.test(d)){s+=1;break}a.push(d);}let c=a.join(`
|
|
38
|
+
`).trim();return {replacement:`<div ${['class="sdm-callout"',r.title!==void 0?`data-callout-title="${no(r.title)}"`:"",r.color!==void 0?`data-callout-color="${no(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${no(r.icon)}"`:"",`data-callout-body="${tl(c)}"`].filter(Boolean).join(" ")}></div>`,next:s}},yr=e=>{if(!e.includes(">>>"))return e;let t=e.split(`
|
|
39
|
+
`),o=[],n=0,r=false;for(;n<t.length;)if(hr.test(t[n])){let a=ol(t,n);o.push(a.replacement),n=a.next,r=true;}else o.push(t[n]),n+=1;return r?o.join(`
|
|
40
|
+
`):e},Cr=()=>()=>{};var sl={NOTE:{icon:"info",kind:"note",title:"Note",iconPaths:[{d:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]},TIP:{icon:"light-bulb",kind:"tip",title:"Tip",iconPaths:[{d:"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"}]},IMPORTANT:{icon:"report",kind:"important",title:"Important",iconPaths:[{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}]},WARNING:{icon:"alert",kind:"warning",title:"Warning",iconPaths:[{d:"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",fillRule:"evenodd"}]},CAUTION:{icon:"stop",kind:"caution",title:"Caution",iconPaths:[{d:"M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25a.749.749 0 0 1-.53.22H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]}},al=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,wr=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let o="";for(let n of t)o+=wr(n);return o},il=e=>{let t=e.iconPaths.map(o=>`<path d="${o.d}"${o.fillRule?` fill-rule="${o.fillRule}"`:""}></path>`).join("");return {type:"paragraph",children:[{type:"html",value:`<svg class="octicon octicon-${e.icon}" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true">${t}</svg>`},{type:"text",value:e.title}],data:{hName:"p",hProperties:{className:["markdown-alert-title"],"data-alert-type":e.kind}}}},ll=e=>{var p,u;let t=e.children[0];if(!t||t.type!=="paragraph")return;let o=t.children[0];if(!o||o.type!=="text")return;let n=wr(o).trimStart(),r=n.match(al);if(!r)return;let a=sl[r[1].toUpperCase()],s=n.slice(r[0].length),c=t.children.slice(1);if(s.trim().length===0&&c.length===0&&e.children.length===1)return;let i=[il(a)],l=[];s.length>0&&l.push({type:"text",value:s});let d=c;return ((p=d[0])==null?void 0:p.type)==="break"&&(d=d.slice(1)),l.push(...d),l.length>0&&l.some(m=>m.type!=="text"||m.value.trim().length>0)&&i.push({type:"paragraph",children:l}),i.push(...e.children.slice(1)),e.data=(u=e.data)!=null?u:{},e.data.hName="div",e.data.hProperties={className:["markdown-alert",`markdown-alert-${a.kind}`]},e.children=i,SKIP},xr=()=>e=>{visit(e,"blockquote",ll);};var bl=/^[ \t]*<[\w!/?-]/,hl=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,yl=e=>typeof e!="string"||e.length===0||!bl.test(e)?e:e.replace(hl,"$1"),Pr,Mr,Sr,Rr,Ir,Er,Lr,Nr,Ar,Dr,Hr,wt={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(Mr=(Pr=defaultSchema.protocols)==null?void 0:Pr.href)!=null?Mr:[],"tel"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(Rr=(Sr=defaultSchema.attributes)==null?void 0:Sr.div)!=null?Rr:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(Er=(Ir=defaultSchema.attributes)==null?void 0:Ir.p)!=null?Er:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(Nr=(Lr=defaultSchema.attributes)==null?void 0:Lr.svg)!=null?Nr:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(Dr=(Ar=defaultSchema.attributes)==null?void 0:Ar.path)!=null?Dr:[],"d","fillRule"]},tagNames:[...(Hr=defaultSchema.tagNames)!=null?Hr:[],"svg","path"]},ro={raw:Jo,sanitize:[_r,wt],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Cl={gfm:[fl,{}],githubAlerts:xr,containerAlerts:Cr,codeMeta:br},vr=Object.values(ro),wl=Object.values(Cl),Tr=new WeakMap;function xl(e){var r;let t=Tr.get(e);if(t)return t;let o={...wt,tagNames:[...(r=wt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...wt.attributes,...e}},n=[ro.raw,[_r,o],ro.harden];return Tr.set(e,n),n}var kl={block:" \u258B",circle:" \u25CF"},vl=["github-light","github-dark"],Tl={enabled:true},Vr=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:o,index:n,isIncomplete:r,dir:a,animatePlugin:s,...c})=>{useLayoutEffect(()=>{s==null||s.commit();}),s==null||s.setAnimateCodeBlocks(r);let i=typeof e=="string"&&o?yl(e):e,l=jsx(Ke,{...c,children:i});return jsx(Et.Provider,{value:r,children:a?jsx("div",{dir:a,style:{display:"contents"},children:l}):l})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return false;if(e.components!==t.components){let o=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(o.length!==n.length||o.some(r=>{var a,s;return ((a=e.components)==null?void 0:a[r])!==((s=t.components)==null?void 0:s[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins||!!e.animatePlugin!=!!t.animatePlugin)});Vr.displayName="Block";var Pl=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:a,rehypePlugins:s=vr,remarkPlugins:c=wl,className:i,shikiTheme:l,mermaid:d,codeBlockMaxHeight:p=400,controls:u=true,isAnimating:m=false,scrollable:g,tableMaxHeight:f=300,animated:h,BlockComponent:b=Vr,parseMarkdownIntoBlocksFn:T=Ct,caret:k,listStyle:M="hierarchical",calloutIcon:P,calloutStyle:I,plugins:w,remend:_,linkSafety:V=Tl,lineNumbers:j=true,allowedTags:F,literalTagContent:D,dataOnlyTags:H,translations:W,icons:Y,prefix:Q,onAnimationStart:E,onAnimationEnd:$,...ae})=>{let je=useId(),te=useMemo(()=>ko(Q),[Q]),ce=useRef(null),oe=useRef(E),ee=useRef($);oe.current=E,ee.current=$,useEffect(()=>{var S,X,q;if(t==="static")return;let y=ce.current;if(ce.current=m,y===null){m&&((S=oe.current)==null||S.call(oe));return}m&&!y?(X=oe.current)==null||X.call(oe):!m&&y&&((q=ee.current)==null||q.call(ee));},[m,t]);let K=useMemo(()=>F?Object.keys(F):[],[F]),v=useMemo(()=>{if(!(H!=null&&H.length))return K;let y=new Set(H.map(S=>S.toLowerCase()));return K.filter(S=>!y.has(S.toLowerCase()))},[K,H]),z=useRef(null),de=useMemo(()=>{if(typeof e!="string")return "";let y=e;return D&&D.length>0&&(y=lr(y,D)),v.length>0&&(y=ir(y,v)),y=yr(y),y},[e,v,D]),G=useMemo(()=>{let y=t==="streaming"?z.current:null,S=to(de,y,T);if(z.current=t==="streaming"?S:null,!(t==="streaming"&&n)||S.blocks.length===0)return S.blocks;let X=S.blocks.length-1,q=S.blocks[X],me=gl(q,_);if(me===q)return S.blocks;let Pe=S.blocks.slice();return Pe[X]=me,Pe},[de,T,t,n,_]),Ae=useMemo(()=>h===true?"true":h?JSON.stringify(h):"",[h]),ne=useRef(null),$e=useRef([]),xe=useRef([]),so=useRef(null),kt=useRef("");if(Ae){if(kt.current!==Ae){kt.current=Ae;let y=Ae!=="true"?h.maxBacklogMs:void 0;ne.current=St({maxBacklogMs:y}),$e.current=[],xe.current=[];}else ne.current||(ne.current=St());m&&ne.current&&ne.current.beginPass(ne.current.now());}else ne.current=null,$e.current=[],xe.current=[],kt.current="";useLayoutEffect(()=>{var y;m&&((y=ne.current)==null||y.commitPass());});let ke=useDeferredValue(G),ve=useMemo(()=>{if(t!=="streaming"||ne.current||ke===G||ke.length===0)return G;let y=ke.length,S=G.length;if(S===0)return ke;if(y!==S)return G;for(let q=0;q<y-1;q+=1)if(ke[q]!==G[q])return G;let X=ke.slice();return X[y-1]=G[S-1],X},[G,ke,t]),vt=useMemo(()=>o==="auto"?ve.map(et):void 0,[ve,o]),Fr=useMemo(()=>ve.map((y,S)=>`${je}-${S}`),[ve.length,je]),Wr=useMemo(()=>W?JSON.stringify(W):"",[W]),ao=useMemo(()=>({...ct,...W}),[Wr]),ot=useMemo(()=>{let{inlineCode:y,...S}=a!=null?a:{},X={...er,...S};if(y){let q=X.code;X.code=me=>"data-block"in me?q?createElement(q,me):null:createElement(y,me);}return X},[a]),nt=useMemo(()=>{let y=[];return w!=null&&w.cjk&&(y=[...y,...w.cjk.remarkPluginsBefore]),y=[...y,...c],w!=null&&w.cjk&&(y=[...y,...w.cjk.remarkPluginsAfter]),w!=null&&w.math&&(y=[...y,w.math.remarkPlugin]),y},[c,w==null?void 0:w.math,w==null?void 0:w.cjk]),Te=useMemo(()=>{let y=s;return F&&Object.keys(F).length>0&&s===vr&&(y=xl(F)),v.length>0&&(y=[...y,[gr,v,D!=null?D:[]]]),D&&D.length>0&&(y=[...y,[fr,D]]),H&&H.length>0&&(y=[...y,[ur,H]]),w!=null&&w.math&&(y=[...y,w.math.rehypePlugin]),o==="auto"&&t==="static"&&(y=[...y,mr]),y},[s,w==null?void 0:w.math,F,v,D,H,o,t]),io=useMemo(()=>{var y,S;return {calloutIcon:P,calloutStyle:I,codeBlockMaxHeight:p,shikiTheme:(S=l!=null?l:(y=w==null?void 0:w.code)==null?void 0:y.getThemes())!=null?S:vl,controls:u,isAnimating:m,lineNumbers:j,listStyle:M,mode:t,mermaid:d,linkSafety:V,scrollable:g,tableMaxHeight:f,components:ot,remarkPlugins:nt,rehypePlugins:Te}},[P,I,p,l,u,m,j,M,t,d,V,g,w==null?void 0:w.code,f,ot,nt,Te]),qr=useMemo(()=>k&&m?{"--streamdown-caret":`"${kl[k]}"`}:void 0,[k,m]),Zr=y=>{let S=null;if(ne.current&&m){if(!$e.current[y]){let q=Ae&&Ae!=="true"?h:{},{maxBacklogMs:me,...Pe}=q;$e.current[y]=rt({...Pe,timeline:ne.current});}S=$e.current[y];}so.current!==Te&&(xe.current=[],so.current=Te),S&&!xe.current[y]&&(xe.current[y]=[...Te,S.rehypePlugin]);let X=S&&xe.current[y]?xe.current[y]:Te;return {blockAnimatePlugin:S,blockRehypePlugins:X}};return t==="static"?jsx(dt.Provider,{value:ao,children:jsx(ft.Provider,{value:w!=null?w:null,children:jsx(R.Provider,{value:io,children:jsx(Ot,{icons:Y,children:jsx(at.Provider,{value:te,children:jsx("div",{className:te("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:o==="auto"?void 0:o,children:jsx(Ke,{components:ot,rehypePlugins:Te,remarkPlugins:nt,...ae,children:de})})})})})})}):jsx(dt.Provider,{value:ao,children:jsx(ft.Provider,{value:w!=null?w:null,children:jsx(R.Provider,{value:io,children:jsx(Ot,{icons:Y,children:jsx(at.Provider,{value:te,children:jsxs("div",{className:te("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",k?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),"data-streamdown":"container",style:qr,children:[ve.length===0&&k&&m&&jsx("span",{}),ve.map((y,S)=>{var lo;let X=S===ve.length-1,q=m&&X&&tr(y),{blockAnimatePlugin:me,blockRehypePlugins:Pe}=Zr(S);return jsx(b,{animatePlugin:me,components:ot,content:y,dir:(lo=vt==null?void 0:vt[S])!=null?lo:o!=="auto"?o:void 0,index:S,isIncomplete:q,rehypePlugins:Pe,remarkPlugins:nt,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...ae},Fr[S])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.calloutIcon===t.calloutIcon&&e.calloutStyle===t.calloutStyle&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&e.dataOnlyTags===t.dataOnlyTags&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Pl.displayName="Streamdown";var zr=({children:e,className:t,contentSize:o,fitKey:n,minZoom:r=.5,maxZoom:a=3,zoomStep:s=.1,showControls:c=true,initialZoom:i=1,isAutoFit:l=false,fullscreen:d=false})=>{let{RotateCcwIcon:p,ZoomInIcon:u,ZoomOutIcon:m}=B(),g=C(),f=O(),h=useRef(null),b=useRef(null),[T,k]=useState(i),[M,P]=useState(r),[I,w]=useState(i),[_,V]=useState({x:0,y:0}),[j,F]=useState(false),[D,H]=useState(false),[W,Y]=useState({x:0,y:0}),[Q,E]=useState({x:0,y:0}),$=useCallback(v=>{w(z=>Math.max(M,Math.min(a,z+v))),H(true);},[M,a]),ae=useCallback(()=>{$(s);},[$,s]),je=useCallback(()=>{$(-s);},[$,s]),te=useCallback(()=>{w(T),V({x:0,y:0}),H(false);},[T]),ce=useCallback(v=>{v.preventDefault();let z=v.deltaY>0?-s:s;$(z);},[$,s]),oe=useCallback(v=>{if(v.button!==0||v.isPrimary===false)return;F(true),H(true),Y({x:v.clientX,y:v.clientY}),E(_);let z=v.currentTarget;z instanceof HTMLElement&&z.setPointerCapture(v.pointerId);},[_]),ee=useCallback(v=>{if(!j)return;v.preventDefault();let z=v.clientX-W.x,de=v.clientY-W.y;V({x:Q.x+z,y:Q.y+de});},[j,W,Q]),K=useCallback(v=>{F(false);let z=v.currentTarget;z instanceof HTMLElement&&z.releasePointerCapture(v.pointerId);},[]);return useEffect(()=>{P(r),l||(k(i),w(i));},[i,l,r]),useEffect(()=>{if(!(l&&o))return;let v=h.current;if(!v)return;let z=v.clientWidth,de=v.clientHeight;if(!(z>0&&de>0))return;let G=Math.min(z/o.width,de/o.height,1);!(G>0)||Number.isNaN(G)||(k(G),P(Math.min(r,G)),D||(w(G),V({x:0,y:0})));},[o,D,l,r]),useEffect(()=>{l&&H(false);},[l]),useEffect(()=>{let v=h.current;if(v)return v.addEventListener("wheel",ce,{passive:false}),()=>{v.removeEventListener("wheel",ce);}},[ce]),useEffect(()=>{let v=b.current;if(v&&j)return document.body.style.userSelect="none",v.addEventListener("pointermove",ee,{passive:false}),v.addEventListener("pointerup",K),v.addEventListener("pointercancel",K),()=>{document.body.style.userSelect="",v.removeEventListener("pointermove",ee),v.removeEventListener("pointerup",K),v.removeEventListener("pointercancel",K);}},[j,ee,K]),jsxs("div",{className:g("relative flex flex-col",d?"h-full w-full":"min-h-28 w-full",t),ref:h,style:{cursor:j?"grabbing":"grab"},children:[c?jsxs("div",{className:g("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",d?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{"aria-label":f.zoomIn,className:g("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:I>=a,onClick:ae,title:f.zoomIn,type:"button",children:jsx(u,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":f.zoomOut,className:g("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:I<=M,onClick:je,title:f.zoomOut,type:"button",children:jsx(m,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":f.resetView,className:g("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:te,title:f.resetView,type:"button",children:jsx(p,{"aria-hidden":"true",size:16})})]}):null,jsx("div",{className:g("flex-1 origin-center transition-transform duration-150 ease-out",d?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:oe,ref:b,role:"application",style:{transform:`translate(${_.x}px, ${_.y}px) scale(${I})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var un=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let a=C(),[s,c]=useState(null),[i,l]=useState(false),[d,p]=useState(""),[u,m]=useState(null),[g,f]=useState(""),[h,b]=useState(0),{mermaid:T}=useContext(R),k=He(),M=T==null?void 0:T.errorComponent,{shouldRender:P,containerRef:I}=co({immediate:n});if(useEffect(()=>{if(!P)return;if(!k){c("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{c(null),l(!0);let V=k.getMermaid(o),j=e.split("").reduce((Y,Q)=>(Y<<5)-Y+Q.charCodeAt(0)|0,0),F=`mermaid-${Math.abs(j)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:D}=await V.render(F,e),H=Zt(D),W=n?D:ln(D);p(W),m(H),f(W);}catch(V){if(!(g||d)){let j=V instanceof Error?V.message:"Failed to render Mermaid chart";c(j);}}finally{l(false);}})();},[e,o,h,P,k]),!(P||d||g))return jsx("div",{className:a("my-4 min-h-[200px]",t),ref:I});if(i&&!d&&!g)return jsx("div",{className:a("my-4 flex justify-center p-4",t),ref:I,children:jsxs("div",{className:a("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:a("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:a("text-sm"),children:"Loading diagram..."})]})});if(s&&!d&&!g){let _=()=>b(V=>V+1);return M?jsx("div",{ref:I,children:jsx(M,{chart:e,error:s,retry:_})}):jsxs("div",{className:a("rounded-md bg-red-50 p-4",t),ref:I,children:[jsxs("p",{className:a("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",s]}),jsxs("details",{className:a("mt-2"),children:[jsx("summary",{className:a("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:a("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let w=d||g;return jsx("div",{className:a("size-full",t),"data-streamdown":"mermaid",ref:I,children:jsx(zr,{className:a(n?"size-full overflow-hidden":"overflow-hidden",t),contentSize:u,fitKey:e,fullscreen:n,isAutoFit:true,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:a("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:w},role:"img"})})})};export{to as A,yl as B,ro as C,Cl as D,Vr as E,Pl as F,es as a,rt as b,Lt as c,ze as d,So as e,At as f,Ht as g,Md as h,Bt as i,ct as j,mt as k,Vt as l,ut as m,R as n,tn as o,un as p,Be as q,Ee as r,Xt as s,bt as t,Le as u,Ue as v,Xa as w,Je as x,et as y,Ct as z};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {n,h,e}from'./chunk-
|
|
2
|
+
import {n,h,e}from'./chunk-O7PB473J.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var x=({code:s,language:e$1,maxHeight:h$1,raw:t,className:m,startLine:d,lineNumbers:a,...c})=>{let{shikiTheme:l}=useContext(n),i=h(),[p,o]=useState(t);return useEffect(()=>{if(!i){o(t);return}let g=i.highlight({code:s,language:e$1,themes:l},H=>{o(H);});g&&o(g);},[s,e$1,l,i,t]),jsx(e,{className:m,language:e$1,lineNumbers:a,maxHeight:h$1,result:p,startLine:d,...c})};export{x as HighlightedCodeBlockBody};
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export{E as Block,i as CodeBlock,f as CodeBlockContainer,k as CodeBlockCopyButton,l as CodeBlockDownloadButton,g as CodeBlockHeader,m as CodeBlockSkeleton,d as DefaultScrollable,F as Streamdown,n as StreamdownContext,v as TableCopyDropdown,w as TableDownloadButton,x as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,C as defaultRehypePlugins,D as defaultRemarkPlugins,j as defaultTranslations,o as defaultUrlTransform,y as detectTextDirection,t as escapeMarkdownTableCell,q as extractTableDataFromElement,B as normalizeHtmlIndentation,z as parseMarkdownIntoBlocks,A as parseMarkdownIntoBlocksIncremental,r as tableDataToCSV,u as tableDataToMarkdown,s as tableDataToTSV,c as useIsCodeFenceIncomplete}from'./chunk-
|
|
2
|
+
export{E as Block,i as CodeBlock,f as CodeBlockContainer,k as CodeBlockCopyButton,l as CodeBlockDownloadButton,g as CodeBlockHeader,m as CodeBlockSkeleton,d as DefaultScrollable,F as Streamdown,n as StreamdownContext,v as TableCopyDropdown,w as TableDownloadButton,x as TableDownloadDropdown,a as createAnimateCursor,b as createAnimatePlugin,C as defaultRehypePlugins,D as defaultRemarkPlugins,j as defaultTranslations,o as defaultUrlTransform,y as detectTextDirection,t as escapeMarkdownTableCell,q as extractTableDataFromElement,B as normalizeHtmlIndentation,z as parseMarkdownIntoBlocks,A as parseMarkdownIntoBlocksIncremental,r as tableDataToCSV,u as tableDataToMarkdown,s as tableDataToTSV,c as useIsCodeFenceIncomplete}from'./chunk-O7PB473J.js';
|
package/dist/lib/scrollable.d.ts
CHANGED
|
@@ -3,5 +3,8 @@ import type { ScrollableProps } from "./streamdown-context";
|
|
|
3
3
|
* Default horizontal-scroll region: a plain `<div>`. Consumers can override
|
|
4
4
|
* via the `scrollable` prop / `StreamdownContext.scrollable` to plug in a
|
|
5
5
|
* custom scrollbar implementation declaratively.
|
|
6
|
+
*
|
|
7
|
+
* `scrollRef` is applied last so it wins over a forwarded `ref` from rest
|
|
8
|
+
* props — pinning logic needs the actual scrolling node.
|
|
6
9
|
*/
|
|
7
|
-
export declare const DefaultScrollable: ({ scrollRef, ...props }: ScrollableProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const DefaultScrollable: ({ scrollRef, ref: _ignoredRef, ...props }: ScrollableProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -64,8 +64,8 @@ export type CalloutStyleResolver = (color?: string) => CSSProperties;
|
|
|
64
64
|
/**
|
|
65
65
|
* Props passed to the component used for a horizontal-scroll region
|
|
66
66
|
* (code-block body, table inner scroll). `scrollRef` must be attached to the
|
|
67
|
-
* actual scrolling
|
|
68
|
-
*
|
|
67
|
+
* actual scrolling viewport (callback refs are used so async scrollbar init,
|
|
68
|
+
* e.g. OverlayScrollbars, can assign the viewport after first paint).
|
|
69
69
|
*/
|
|
70
70
|
export type ScrollableProps = ComponentProps<"div"> & {
|
|
71
71
|
scrollRef?: React.Ref<HTMLDivElement>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type RefCallback } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Smart snap-to-bottom for a capped scroll region (code-block body, table).
|
|
4
|
+
*
|
|
5
|
+
* While streaming (`isAnimating`) and latched:
|
|
6
|
+
* - new content auto-scrolls to the end
|
|
7
|
+
* - wheel / touch up detaches immediately
|
|
8
|
+
* - scrolling back to the bottom re-latches
|
|
9
|
+
*
|
|
10
|
+
* `scrollRef` is a callback so custom `scrollable` implementations
|
|
11
|
+
* (e.g. OverlayScrollbars) can attach the *viewport* asynchronously.
|
|
12
|
+
*/
|
|
13
|
+
export declare const usePinnedScroll: ({ enabled, isAnimating, content, }: {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
isAnimating: boolean;
|
|
16
|
+
content: unknown;
|
|
17
|
+
}) => RefCallback<HTMLDivElement>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofcz/streamdown",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"typescript": "^7.0.2",
|
|
53
53
|
"vitest": "^4.0.15",
|
|
54
54
|
"@streamdown/cjk": "npm:@lofcz/streamdown-cjk@1.0.3",
|
|
55
|
-
"@streamdown/
|
|
56
|
-
"@streamdown/
|
|
55
|
+
"@streamdown/math": "npm:@lofcz/streamdown-math@1.0.3",
|
|
56
|
+
"@streamdown/mermaid": "npm:@lofcz/streamdown-mermaid@1.0.2"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"react": "^18.0.0 || ^19.0.0",
|
package/dist/chunk-7GEPSDTS.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {createContext,memo,useContext,useRef,useEffect,useMemo,lazy,isValidElement,useLayoutEffect,useId,useDeferredValue,cloneElement,createElement,useState,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import Xo from'rehype-raw';import Or,{defaultSchema}from'rehype-sanitize';import cl from'remark-gfm';import dl from'remend';import {visitParents,SKIP as SKIP$1}from'unist-util-visit-parents';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import ca from'remark-parse';import da from'remark-rehype';import {unified}from'unified';import {visit,SKIP}from'unist-util-visit';import {Lexer}from'marked';import {toText}from'hast-util-to-text';var Gr=300,Xr="300px",Ur=500;function mo(e={}){let{immediate:t=false,debounceDelay:o=Gr,rootMargin:n=Xr,idleTimeout:r=Ur}=e,[a,s]=useState(false),l=useRef(null),i=useRef(null),c=useRef(null),m=useMemo(()=>d=>{let f=Date.now();return window.setTimeout(()=>{d({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-f))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(d,f)=>window.requestIdleCallback(d,f):m,[m]),u=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?d=>window.cancelIdleCallback(d):d=>{clearTimeout(d);},[]);return useEffect(()=>{if(t){s(true);return}let d=l.current;if(!d)return;i.current&&(clearTimeout(i.current),i.current=null),c.current&&(u(c.current),c.current=null);let f=()=>{i.current&&(clearTimeout(i.current),i.current=null),c.current&&(u(c.current),c.current=null);},g=x=>{c.current=p(T=>{T.timeRemaining()>0||T.didTimeout?(s(true),x.disconnect()):c.current=p(()=>{s(true),x.disconnect();},{timeout:r/2});},{timeout:r});},b=x=>{f(),i.current=window.setTimeout(()=>{var I,k;let T=x.takeRecords();(T.length===0||(k=(I=T.at(-1))==null?void 0:I.isIntersecting)!=null&&k)&&g(x);},o);},h=(x,T)=>{x.isIntersecting?b(T):f();},C=new IntersectionObserver(x=>{for(let T of x)h(T,C);},{rootMargin:n,threshold:0});return C.observe(d),()=>{i.current&&clearTimeout(i.current),c.current&&u(c.current),C.disconnect();}},[t,o,n,r,u,p]),{shouldRender:a,containerRef:l}}var Jr=320,Yr=4,fo=()=>typeof performance=="undefined"?Date.now():performance.now();function Mt(e){var a,s;let t=(a=e==null?void 0:e.now)!=null?a:fo,o=(s=e==null?void 0:e.maxBacklogMs)!=null?s:Jr,n=0,r=0;return {now:t,beginPass(l){r=Math.min(Math.max(n,l),l+o);},mark(){return r},rewind(l){r=l;},take(l,i,c){if(l<=0)return {baseDelay:0,step:Math.max(0,i)};let m=Math.max(0,i),p=m===0?0:Math.min(m,Yr),u=Math.max(r,c),d=c+o,f=u+Math.max(0,l-1)*m,g=m;if(f>d&&l>1)if(u<d){let h=d-u;g=Math.max(p,h/(l-1));}else g=p;let b=Math.max(0,Math.round(u-c));return r=u+l*g,{baseDelay:b,step:g}},commitPass(){n=r;}}}function Qr(){return {current:0}}var go=/\s/,St=/^\s+$/,es=new Set(["code","pre","svg","math","annotation"]),ts=new Set(["svg","math","annotation"]),Pt=new Set(["img","hr"]),os=new Set(["ul","ol","li"]),Me=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",It=(e,t)=>{let o=t?ts:es;return e.some(n=>Me(n)&&o.has(n.tagName))},ns=e=>{for(let t=e.length-1;t>=0;t-=1){let o=e[t];if(Me(o)&&o.tagName==="li")return o}},rs=(e,t,o,n)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate-marker"]=true,e.properties.style=`--sd-marker-duration:${t}ms;--sd-marker-delay:${o}ms;--sd-marker-easing:${n}`;},bo=e=>{for(let t of e.children)if(Me(t)){if(t.tagName==="input")return t;if(os.has(t.tagName))continue;let o=bo(t);if(o)return o}},ho=(e,t,o,n)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate"]=true;let r=typeof e.properties.style=="string"?`${e.properties.style};`:"";e.properties.style=`${r}--sd-animation:sd-${t.animation};--sd-duration:${o}ms;--sd-easing:${t.easing};--sd-delay:${n}ms`;},ss=(e,t,o,n)=>{let r=bo(e);r&&ho(r,t,o,n);},yo=e=>{var t;for(let o=e.length-1;o>=0;o-=1){let n=e[o];if(Me(n)){if((t=n.properties)!=null&&t["data-sd-animated"])break;n.properties={...n.properties,"data-sd-animated":true};}}},Co=e=>{let t=[],o="",n=false;for(let r of e){let a=go.test(r);if(a!==n&&o){if(a){o+=r,n=true;continue}t.push(o),o="";}o+=r,n=a;}return o&&t.push(o),t},wo=e=>{let t=[],o="";for(let n of e)go.test(n)?t.length>0&&!St.test(t.at(-1))?t[t.length-1]+=n:o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&(t.length>0?t[t.length-1]+=o:t.push(o)),t},as=(e,t,o,n,r,a)=>{let s=`--sd-animation:sd-${t};--sd-duration:${r?0:o}ms;--sd-easing:${n}`;return a&&(s+=`;--sd-delay:${Math.round(a)}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:s},children:[{type:"text",value:e}]}},is=(e,t,o,n)=>{let r=0,a=0;return visitParents(e,s=>s.type==="text"||Me(s)&&Pt.has(s.tagName),(s,l)=>{if(It(l,o.animateCodeBlocks))return SKIP$1;if(Me(s)&&Pt.has(s.tagName)){n>0&&a<n||(r+=1);return}let i=s.value;if(!i.trim()){a+=i.length;return}let c=t.sep==="char"?wo(i):Co(i);for(let m of c){let p=a;a+=m.length,!St.test(m)&&(n>0&&p<n||(r+=1));}}),r},ls=(e,t,o,n,r,a)=>{if(It(t,n.animateCodeBlocks))return;let s=n.prevContentLength,l=s>0&&r.count<s,i=l?0:a.baseDelay+r.newIndex++*a.step;ho(e,o,l?0:o.duration,i),yo(t);},cs=(e,t,o,n,r,a)=>{var h;let s=t.at(-1);if(!(s&&"children"in s))return;if(It(t,n.animateCodeBlocks))return SKIP$1;let l=s,i=l.children.indexOf(e);if(i===-1)return;let c=e.value;if(!c.trim()){r.count+=c.length;return}let m=o.sep==="char"?wo(c):Co(c),p=n.prevContentLength,u=false,d=ns(t),f=!!(d&&!((h=d.properties)!=null&&h["data-sd-animate-marker"])),g=false,b=m.map(C=>{let x=r.count;if(r.count+=C.length,St.test(C))return {type:"text",value:C};let T=p>0&&x<p,M=T?0:a.baseDelay+r.newIndex++*a.step;if(d&&f&&!g){let I=T?0:o.duration;rs(d,I,M,o.easing),ss(d,o,I,M),g=true;}return u=true,as(C,o.animation,o.duration,o.easing,T,M)});return u&&yo(t),l.children.splice(i,1,...b),i+b.length},ds=0;function rt(e){var a,s,l,i,c;let t={animation:(a=e==null?void 0:e.animation)!=null?a:"fadeIn",duration:(s=e==null?void 0:e.duration)!=null?s:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(c=e==null?void 0:e.stagger)!=null?c:40,timeline:e==null?void 0:e.timeline},o={animateCodeBlocks:false,committedCharCount:0,prevContentLength:0,lastRenderCharCount:0,pendingMark:null},n=ds++,r=()=>m=>{var g;let p={count:0,newIndex:0};o.prevContentLength=o.committedCharCount;let u=t.timeline,d=(g=u==null?void 0:u.now())!=null?g:fo();u&&(o.pendingMark===null?o.pendingMark=u.mark():u.rewind(o.pendingMark));let f=u?u.take(is(m,t,o,o.prevContentLength),t.stagger,d):{baseDelay:0,step:t.stagger};visitParents(m,b=>b.type==="text"||Me(b)&&Pt.has(b.tagName),(b,h)=>{if(b.type==="text")return cs(b,h,t,o,p,f);ls(b,h,t,o,p,f);}),o.lastRenderCharCount=p.count,o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(m){o.animateCodeBlocks=m;},setPrevContentLength(m){o.committedCharCount=m,o.prevContentLength=m;},getLastRenderCharCount(){return o.lastRenderCharCount},commit(){o.committedCharCount=o.lastRenderCharCount,o.pendingMark=null;}}}rt();var Rt=createContext(false),Et=()=>useContext(Rt);var De=(...e)=>twMerge(clsx(e)),st=e=>{if(e!==void 0)return typeof e=="number"?!Number.isFinite(e)||e<=0?void 0:`${e}px`:e},ps=(e,t)=>{if(!e||!t)return t;let o=`${e}:`;return t.split(/\s+/).filter(Boolean).map(n=>n.startsWith(o)?n:`${e}:${n}`).join(" ")},vo=e=>e?(...t)=>ps(e,twMerge(clsx(t))):De,re=(e,t,o)=>{let n=typeof t=="string"&&o.startsWith("text/csv")?"\uFEFF":"",r=typeof t=="string"?new Blob([n+t],{type:o}):t,a=URL.createObjectURL(r),s=document.createElement("a");s.href=a,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(a);};var at=createContext(De),w=()=>useContext(at);var ze=({scrollRef:e,...t})=>jsx("div",{ref:e,...t});var Cs=De("block"),ws=De("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),xs=e=>{let t={};for(let o of e.split(";")){let n=o.indexOf(":");if(n>0){let r=o.slice(0,n).trim(),a=o.slice(n+1).trim();r&&a&&(t[r]=a);}}return t},Po=memo(({children:e,result:t,language:o,className:n,maxHeight:r,startLine:a,lineNumbers:s=true,...l})=>{let i=w(),{isAnimating:c,scrollable:m}=useContext(R),p=m!=null?m:ze,u=useRef(null),d=useRef(true),f=st(r);useEffect(()=>{let C=u.current;if(!(C&&f))return;let x=()=>{let T=C.scrollHeight-C.scrollTop-C.clientHeight<8;d.current=T;};return C.addEventListener("scroll",x,{passive:true}),()=>C.removeEventListener("scroll",x)},[f]),useEffect(()=>{let C=u.current;C&&f&&c&&d.current&&C.scrollTo({top:C.scrollHeight,behavior:"instant"});},[c,f]),useEffect(()=>{c||(d.current=true);},[c]);let g=useMemo(()=>i(ws),[i]),b=useMemo(()=>i(Cs),[i]),h=useMemo(()=>{let C={};return t.bg&&(C["--sdm-bg"]=t.bg),t.fg&&(C["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(C,xs(t.rootStyle)),C},[t.bg,t.fg,t.rootStyle]);return jsx(p,{className:i(n,f?"overflow-x-auto overflow-y-auto":"overflow-x-auto","rounded-md border border-border bg-background p-4 text-sm"),"data-language":o,"data-streamdown":"code-block-body",scrollRef:u,style:f?{maxHeight:f}:void 0,...l,children:jsx("pre",{className:i(n,"bg-[var(--sdm-bg,inherit)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]"),style:h,children:jsx("code",{className:s?i("[counter-increment:line_0] [counter-reset:line]"):void 0,style:s&&a&&a>1?{counterReset:`line ${a-1}`}:void 0,children:t.tokens.map((C,x)=>jsx("span",{className:s?g:b,children:C.length===0||C.length===1&&C[0].content===""?`
|
|
3
|
-
`:C.map((T,M)=>{let I={},k=!!T.bgColor;if(T.color&&(I["--sdm-c"]=T.color),T.bgColor&&(I["--sdm-tbg"]=T.bgColor),T.htmlStyle)for(let[V,D]of Object.entries(T.htmlStyle))V==="color"?I["--sdm-c"]=D:V==="background-color"?(I["--sdm-tbg"]=D,k=true):I[V]=D;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",k&&"bg-[var(--sdm-tbg)]",k&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:I,...T.htmlAttrs,children:T.content},M)})},x))})})})});var At=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let a=w();return jsx("div",{className:a("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r})};var Dt=createContext({code:""}),it=()=>useContext(Dt);var Ht=({language:e})=>{let t=w();return jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var Is=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
|
-
`;)t--;return e.slice(0,t)},Rs=lazy(()=>import('./highlighted-body-QA7ERC4U.js').then(e=>({default:e.HighlightedCodeBlockBody}))),Bt=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:a,lineNumbers:s,...l})=>{let i=w(),{codeBlockMaxHeight:c}=useContext(R),m=useMemo(()=>Is(e),[e]),p=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:m.split(`
|
|
5
|
-
`).map(u=>[{content:u,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[m]);return jsx(Dt.Provider,{value:{code:e},children:jsxs(At,{dir:"ltr",isIncomplete:r,language:t,children:[jsx(Ht,{language:t}),n?jsx("div",{className:i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("div",{className:i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:n})}):null,jsx(Suspense,{fallback:jsx(Po,{className:o,language:t,lineNumbers:s,maxHeight:c,result:p,startLine:a,...l}),children:jsx(Rs,{className:o,code:m,language:t,lineNumbers:s,maxHeight:c,raw:p,startLine:a,...l})})]})})};var Io=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),Ro=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),Eo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),Lo=e=>jsxs("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),No=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),Ao=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),Do=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),Ho=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),Bo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),Oo=e=>jsx("svg",{"aria-hidden":"true",color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var We={CheckIcon:Io,CopyIcon:Ro,DownloadIcon:Eo,ExternalLinkIcon:Ho,Loader2Icon:Lo,Maximize2Icon:No,RotateCcwIcon:Ao,XIcon:Do,ZoomInIcon:Bo,ZoomOutIcon:Oo},Vo=createContext(We),Ds=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let o=Object.keys(e),n=Object.keys(t);return o.length!==n.length?false:o.every(r=>e[r]===t[r])},Ot=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...We,...e}:We);Ds(o.current,e)||(o.current=e,n.current=e?{...We,...e}:We);let r=n.current;return jsx(Vo.Provider,{value:r,children:t})},O=()=>useContext(Vo);var lt={alertNote:"Note",alertTip:"Tip",alertImportant:"Important",alertWarning:"Warning",alertCaution:"Caution",copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",zoomIn:"Zoom in",zoomOut:"Zoom out",resetView:"Reset zoom and pan",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},ct=createContext(lt),_=()=>useContext(ct);var dt=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:a,...s})=>{let l=w(),[i,c]=useState(false),m=useRef(0),{code:p}=it(),{isAnimating:u}=useContext(R),d=_(),f=a!=null?a:p,g=async()=>{var C;if(typeof window=="undefined"||!((C=navigator==null?void 0:navigator.clipboard)!=null&&C.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(f),c(!0),e==null||e(),m.current=window.setTimeout(()=>c(!1),o));}catch(x){t==null||t(x);}};useEffect(()=>()=>{window.clearTimeout(m.current);},[]);let b=O(),h=i?b.CheckIcon:b.CopyIcon;return jsxs(Fragment,{children:[jsx("button",{"aria-label":d.copyCode,className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:u,onClick:g,title:d.copyCode,type:"button",...s,children:n!=null?n:jsx(h,{"aria-hidden":"true",size:14})}),i&&jsx("output",{"aria-live":"polite",className:"sr-only",children:d.copied})]})};var jo={"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"},Vt=({onDownload:e,onError:t,language:o,children:n,className:r,code:a,...s})=>{let l=w(),{code:i}=it(),{isAnimating:c}=useContext(R),m=_(),p=O(),u=a!=null?a:i,f=`file.${o&&o in jo?jo[o]:"txt"}`,g="text/plain",b=()=>{try{re(f,u,g),e==null||e();}catch(h){t==null||t(h);}};return jsx("button",{"aria-label":m.downloadFile,className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:c,onClick:b,title:m.downloadFile,type:"button",...s,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var mt=()=>{let{Loader2Icon:e}=O(),t=w();return jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:jsx(e,{className:t("size-4 animate-spin")})})]})};var qe=0,be=()=>{qe+=1,qe===1&&(document.body.style.overflow="hidden");},he=()=>{qe=Math.max(0,qe-1),qe===0&&(document.body.style.overflow="");};var Ks=["github-light","github-dark"],Gs={enabled:true},Xs={codeBlockMaxHeight:400,shikiTheme:Ks,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,linkSafety:Gs,tableMaxHeight:300},R=createContext(Xs);var Qs=/\.[^/.]+$/,Fo=(e,t)=>{if(typeof e=="boolean")return e;let o=e.image;return o===false?false:o===true||o===void 0?true:o[t]!==false},Wo=({node:e,className:t,src:o,alt:n,onLoad:r,onError:a,onClick:s,...l})=>{let{DownloadIcon:i,XIcon:c}=O(),m=w(),p=useRef(null),[u,d]=useState(false),[f,g]=useState(false),[b,h]=useState(false),{controls:C}=useContext(R),x=_(),T=Fo(C,"download"),M=Fo(C,"fullscreen"),I=l.width!=null||l.height!=null,k=T&&(u||I)&&!f,V=f&&!I,D=M&&!!o&&!f&&u;useEffect(()=>{let E=p.current;if(E!=null&&E.complete){let $=E.naturalWidth>0;d($),g(!$);}},[]),useEffect(()=>{if(!b)return;be();let E=$=>{$.key==="Escape"&&h(false);};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E),he();}},[b]);let j=useCallback(E=>{d(true),g(false),r==null||r(E);},[r]),F=useCallback(E=>{d(false),g(true),a==null||a(E);},[a]),H=useCallback(()=>{D&&h(true);},[D]),B=useCallback(()=>{h(false);},[]),W=useCallback(E=>{s==null||s(E),!E.defaultPrevented&&H();},[s,H]),Y=async E=>{if(E.stopPropagation(),!!o)try{let ae=await(await fetch(o)).blob(),te=new URL(o,window.location.origin).pathname.split("/").pop()||"",ce=te.split(".").pop(),oe=te.includes(".")&&ce!==void 0&&ce.length<=4,ee="";if(oe)ee=te;else {let K=ae.type,P="png";K.includes("jpeg")||K.includes("jpg")?P="jpg":K.includes("png")?P="png":K.includes("svg")?P="svg":K.includes("gif")?P="gif":K.includes("webp")&&(P="webp"),ee=`${(n||te||"image").replace(Qs,"")}.${P}`;}re(ee,ae,ae.type);}catch($){window.open(o,"_blank");}};return o?o==="streamdown:incomplete-image"?jsx("div",{className:m("group relative my-4 inline-block"),"data-incomplete":"true","data-streamdown":"image-wrapper",children:jsx("div",{className:m("h-24 w-48 animate-pulse rounded-lg bg-muted"),"data-streamdown":"image-placeholder"})}):jsxs(Fragment,{children:[jsxs("div",{className:m("group/image not-prose relative my-2 block max-w-full"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:n,className:m("m-0 block h-auto max-w-full rounded-lg",D&&"cursor-zoom-in",V&&"hidden",t),"data-streamdown":"image",onClick:W,onError:F,onLoad:j,ref:p,src:o,...l}),V&&jsx("span",{className:m("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:x.imageNotAvailable}),k&&jsx("button",{className:m("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 focus-visible:opacity-100 group-hover/image:opacity-100"),onClick:Y,title:x.downloadImage,type:"button",children:jsx(i,{size:14})})]}),b?createPortal(jsxs("div",{className:m("fixed inset-0 z-50 flex items-center justify-center bg-black/90 p-4"),"data-streamdown":"image-lightbox",onClick:B,onKeyDown:E=>{E.key==="Escape"&&B();},role:"button",tabIndex:0,children:[jsx("button",{className:m("absolute top-4 right-4 z-10 rounded-md p-2 text-white/80 transition-colors hover:bg-white/10 hover:text-white"),onClick:B,title:x.exitFullscreen,type:"button",children:jsx(c,{size:20})}),jsx("div",{onClick:E=>E.stopPropagation(),onKeyDown:E=>E.stopPropagation(),role:"presentation",children:jsx("img",{alt:n,className:m("max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] object-contain"),"data-streamdown":"image-lightbox-img",src:o})})]}),document.body):null]}):null};var Ko=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:a,ExternalLinkIcon:s,XIcon:l}=O(),i=w(),[c,m]=useState(false),p=_(),u=useCallback(async()=>{try{await navigator.clipboard.writeText(e),m(!0),setTimeout(()=>m(!1),2e3);}catch(g){}},[e]),d=useCallback(()=>{n(),o();},[n,o]);if(useEffect(()=>{if(t){be();let g=b=>{b.key==="Escape"&&o();};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),he();}}},[t,o]),!t||typeof document=="undefined")return null;let f=jsx("div",{className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:o,onKeyDown:g=>{g.key==="Escape"&&o();},role:"button",tabIndex:0,children:jsxs("div",{className:i("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:[jsx("button",{className:i("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:o,title:p.close,type:"button",children:jsx(l,{size:16})}),jsxs("div",{className:i("flex flex-col gap-2"),children:[jsxs("div",{className:i("flex items-center gap-2 font-semibold text-lg"),children:[jsx(s,{size:20}),jsx("span",{children:p.openExternalLink})]}),jsx("p",{className:i("text-muted-foreground text-sm"),children:p.externalLinkWarning})]}),jsx("div",{className:i("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:i("flex gap-2"),children:[jsx("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:u,type:"button",children:c?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:p.copied})]}):jsxs(Fragment,{children:[jsx(a,{size:14}),jsx("span",{children:p.copyLink})]})}),jsxs("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:d,type:"button",children:[jsx(s,{size:14}),jsx("span",{children:p.openLink})]})]})]})});return createPortal(f,document.body)};var Go=()=>e=>{visit(e,"html",(o,n,r)=>{!r||typeof n!="number"||(r.children[n]={type:"text",value:o.value});});};var Uo=[],Jo={allowDangerousHtml:true},ut=new WeakMap,Wt=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,a=t.remarkRehypeOptions;if(!(n||r||a)){let p="default";return this.keyCache.set(t,p),p}let s=p=>{if(!p||p.length===0)return "";let u="";for(let d=0;d<p.length;d+=1){let f=p[d];if(d>0&&(u+=","),Array.isArray(f)){let[g,b]=f;if(typeof g=="function"){let h=ut.get(g);h||(h=g.name,ut.set(g,h)),u+=h;}else u+=String(g);u+=":",u+=JSON.stringify(b);}else if(typeof f=="function"){let g=ut.get(f);g||(g=f.name,ut.set(f,g)),u+=g;}else u+=String(f);}return u},l=s(n),i=s(r),c=a?JSON.stringify(a):"",m=`${i}::${l}::${c}`;return this.keyCache.set(t,m),m}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();}},Yo=new Wt,Ke=e=>{let t=pa(e),o=e.children||"",n=t.runSync(t.parse(o),o);return Ca(n,e)},pa=e=>{let t=Yo.get(e);if(t)return t;let o=ga(e);return Yo.set(e,o),o},fa=e=>e.some(t=>Array.isArray(t)?t[0]===Xo:t===Xo),ga=e=>{let t=e.rehypePlugins||Uo,o=e.remarkPlugins||Uo,n=fa(t)?o:[...o,Go],r=e.remarkRehypeOptions?{...Jo,...e.remarkRehypeOptions}:Jo;return unified().use(ca).use(n).use(da,r).use(t)},Qo=e=>e,ba=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},ha=(e,t)=>{var o;for(let n in urlAttributes)if(Object.hasOwn(urlAttributes,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],a=urlAttributes[n];(a===null||a.includes(e.tagName))&&(e.properties[n]=(o=t(String(r||""),n,e))!=null?o:void 0);}},ya=(e,t,o,n,r,a)=>{let s=false;return n?s=!n.includes(e.tagName):r&&(s=r.includes(e.tagName)),!s&&a&&typeof t=="number"&&(s=!a(e,t,o)),s},Ca=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:a,unwrapDisallowed:s,urlTransform:l}=t;if(o||n||r||a||l){let c=l||Qo;visit(e,(m,p,u)=>{if(m.type==="raw"&&u&&typeof p=="number")return ba(u,p,a,m.value),p;if(m.type==="element"&&(ha(m,c),ya(m,p,u,n,r,o)&&u&&typeof p=="number"))return s&&m.children?u.children.splice(p,1,...m.children):u.children.splice(p,1),p});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var pt=createContext(null),qt=()=>useContext(pt),yd=()=>{var t;let e=qt();return (t=e==null?void 0:e.code)!=null?t:null},He=()=>{var t;let e=qt();return (t=e==null?void 0:e.mermaid)!=null?t:null};var en=e=>{var o;let t=qt();return t!=null&&t.renderers&&e&&(o=t.renderers.find(n=>Array.isArray(n.language)?n.language.includes(e):n.language===e))!=null?o:null};var ka=/(<svg\b)/,nn=/<svg\b[^>]*>/i,va=/\bviewBox=(['"])(.*?)\1/i,Ta=/\swidth=(['"]).*?\1/i,Pa=/\sheight=(['"]).*?\1/i,tn=/\sstyle=(['"])(.*?)\1/i,on=/^<svg/i,Ma=/^width\s*:/i,Sa=/^height\s*:/i,Ia=/^max-width\s*:/i,Ra=/[\s,]+/,Ea=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(ka,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),rn=e=>{if(typeof DOMParser=="undefined"||typeof XMLSerializer=="undefined")return e;let o=new DOMParser().parseFromString(e,"text/html").querySelector("svg");return o?new XMLSerializer().serializeToString(o):e},Zt=e=>{let t=e.match(nn);if(!t)return null;let n=t[0].match(va),r=n==null?void 0:n[2];if(!r)return null;let a=r.trim().split(Ra).map(i=>Number.parseFloat(i));if(a.length<4||a.slice(0,4).some(Number.isNaN))return null;let s=a[2],l=a[3];return s>0&&l>0?{height:l,width:s}:null},sn=e=>{let t=e.match(nn);if(!t)return e;try{let o=t[0],n=Zt(e);if(!n)return e;let{width:r,height:a}=n,s=o.replace(Ta,"").replace(Pa,""),l=s.match(tn),i=`width:${r}px;height:${a}px;max-width:none;`;if(l){let c=l[1],p=l[2].split(";").map(d=>d.trim()).filter(Boolean).filter(d=>!(Ma.test(d)||Sa.test(d)||Ia.test(d))).join(";"),u=`${i}${p?`${p};`:""}`;s=s.replace(tn,` style=${c}${u}${c}`);}else s=s.replace(on,`<svg style="${i}"`);return s=s.replace(on,`<svg width="${r}" height="${a}"`),e.replace(o,s)}catch(o){return e}},an=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,a)=>{let s=Ea(e),l="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(s))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let c=document.createElement("canvas"),m=i.width*o,p=i.height*o;c.width=m,c.height=p;let u=c.getContext("2d");if(!u){a(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(i,0,0,m,p),c.toBlob(d=>{if(!d){a(new Error("Failed to create PNG blob"));return}r(d);},"image/png");},i.onerror=()=>a(new Error("Failed to load SVG image")),i.src=l;})};var ft=({chart:e,children:t,className:o,onDownload:n,config:r,onError:a})=>{let s=w(),[l,i]=useState(false),c=useRef(null),{isAnimating:m}=useContext(R),p=O(),u=He(),d=_(),f=async g=>{try{if(g==="mmd"){re("diagram.mmd",e,"text/plain"),i(!1),n==null||n(g);return}if(!u){a==null||a(new Error("Mermaid plugin not available"));return}let b=u.getMermaid(r),h=e.split("").reduce((M,I)=>(M<<5)-M+I.charCodeAt(0)|0,0),C=`mermaid-${Math.abs(h)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:x}=await b.render(C,e);if(!x){a==null||a(new Error("SVG not found. Please wait for the diagram to render."));return}let T=rn(x);if(g==="svg"){re("diagram.svg",T,"image/svg+xml"),i(!1),n==null||n(g);return}if(g==="png"){let M=await an(T);re("diagram.png",M,"image/png"),n==null||n(g),i(!1);return}}catch(b){a==null||a(b);}};return useEffect(()=>{let g=b=>{let h=b.composedPath();c.current&&!h.includes(c.current)&&i(false);};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g);}},[]),jsxs("div",{className:s("relative"),ref:c,children:[jsx("button",{"aria-label":d.downloadDiagram,className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:m,onClick:()=>i(!l),title:d.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{"aria-hidden":"true",size:14})}),l?jsxs("div",{className:s("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",{"aria-label":d.downloadDiagramAsSvg,className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("svg"),title:d.downloadDiagramAsSvg,type:"button",children:d.mermaidFormatSvg}),jsx("button",{"aria-label":d.downloadDiagramAsPng,className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("png"),title:d.downloadDiagramAsPng,type:"button",children:d.mermaidFormatPng}),jsx("button",{"aria-label":d.downloadDiagramAsMmd,className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("mmd"),title:d.downloadDiagramAsMmd,type:"button",children:d.mermaidFormatMmd})]}):null]})};var mn=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...a})=>{let{Maximize2Icon:s,XIcon:l}=O(),i=w(),[c,m]=useState(false),{isAnimating:p,controls:u}=useContext(R),d=_(),f=(()=>{if(typeof u=="boolean")return u;let h=u.mermaid;return h===false?false:h===true||h===void 0?true:h.panZoom!==false})(),g=(()=>{if(typeof u=="boolean")return u;let h=u.mermaid;return h===false?false:h===true||h===void 0?true:h.download!==false})(),b=()=>{m(!c);};return useEffect(()=>{if(c){be();let h=C=>{C.key==="Escape"&&m(false);};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h),he();}}},[c]),useEffect(()=>{c?o==null||o():n&&n();},[c,o,n]),jsxs(Fragment,{children:[jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:p,onClick:b,title:d.viewFullscreen,type:"button",...a,"aria-label":d.viewFullscreen,children:jsx(s,{"aria-hidden":"true",size:14})}),c?createPortal(jsxs("div",{"aria-label":d.viewFullscreen,"aria-modal":"true",className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),"data-streamdown":"mermaid-fullscreen",onClick:b,onKeyDown:h=>{h.key==="Escape"&&b();},role:"dialog",children:[jsxs("div",{className:i("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:[g?jsx(ft,{chart:e,config:t}):null,jsx("button",{"aria-label":d.exitFullscreen,className:i("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:b,title:d.exitFullscreen,type:"button",children:jsx(l,{"aria-hidden":"true",size:20})})]}),jsx("div",{className:i("flex size-full items-center justify-center p-4"),onClick:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),role:"presentation",children:jsx(dn,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:f})})]}),document.body):null]})};function Gt(e){var o;if(e.nodeType===Node.TEXT_NODE)return (o=e.textContent)!=null?o:"";if(e.nodeType!==Node.ELEMENT_NODE)return "";let t=e;return t.tagName==="BR"?`
|
|
6
|
-
`:Array.from(t.childNodes).map(Gt).join("")}var Be=e=>{let t=[],o=[],n=e.querySelectorAll("thead th");for(let a of n)t.push(Gt(a).trim());let r=e.querySelectorAll("tbody tr");for(let a of r){let s=[],l=a.querySelectorAll("td");for(let i of l)s.push(Gt(i).trim());o.push(s);}return {headers:t,rows:o}},Ee=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false,c=false;for(let m of l){if(m==='"'){i=true,c=true;break}(m===","||m===`
|
|
7
|
-
`)&&(i=true);}return i?c?`"${l.replace(/"/g,'""')}"`:`"${l}"`:l},r=t.length>0?o.length+1:o.length,a=new Array(r),s=0;t.length>0&&(a[s]=t.map(n).join(","),s+=1);for(let l of o)a[s]=l.map(n).join(","),s+=1;return a.join(`
|
|
8
|
-
`)},Xt=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false;for(let m of l)if(m===" "||m===`
|
|
9
|
-
`||m==="\r"){i=true;break}if(!i)return l;let c=[];for(let m of l)m===" "?c.push("\\t"):m===`
|
|
10
|
-
`?c.push("\\n"):m==="\r"?c.push("\\r"):c.push(m);return c.join("")},r=t.length>0?o.length+1:o.length,a=new Array(r),s=0;t.length>0&&(a[s]=t.map(n).join(" "),s+=1);for(let l of o)a[s]=l.map(n).join(" "),s+=1;return a.join(`
|
|
11
|
-
`)},gt=e=>{let t=false;for(let n of e)if(n==="\\"||n==="|"||n===`
|
|
12
|
-
`){t=true;break}if(!t)return e;let o=[];for(let n of e)n==="\\"?o.push("\\\\"):n==="|"?o.push("\\|"):n===`
|
|
13
|
-
`?o.push("<br>"):o.push(n);return o.join("")},Le=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),r=0,a=t.map(l=>gt(l));n[r]=`| ${a.join(" | ")} |`,r+=1;let s=new Array(t.length);for(let l=0;l<t.length;l+=1)s[l]="---";n[r]=`| ${s.join(" | ")} |`,r+=1;for(let l of o)if(l.length<t.length){let i=new Array(t.length);for(let c=0;c<t.length;c+=1)i[c]=c<l.length?gt(l[c]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(c=>gt(c));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
|
|
14
|
-
`)};var Ue=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let a=w(),[s,l]=useState(false),[i,c]=useState(false),m=useRef(null),p=useRef(0),{isAnimating:u}=useContext(R),d=_(),f=async h=>{var C,x;if(typeof window=="undefined"||!((C=navigator==null?void 0:navigator.clipboard)!=null&&C.write)){n==null||n(new Error("Clipboard API not available"));return}try{let T=(x=m.current)==null?void 0:x.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),M=T==null?void 0:T.querySelector("table");if(!M){n==null||n(new Error("Table not found"));return}let I=Be(M),D=({csv:Ee,tsv:Xt,md:Le}[h]||Le)(I),j=new ClipboardItem({"text/plain":new Blob([D],{type:"text/plain"}),"text/html":new Blob([M.outerHTML],{type:"text/html"})});await navigator.clipboard.write([j]),c(!0),l(!1),o==null||o(h),p.current=window.setTimeout(()=>c(!1),r);}catch(T){n==null||n(T);}};useEffect(()=>{let h=C=>{let x=C.composedPath();m.current&&!x.includes(m.current)&&l(false);};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h),window.clearTimeout(p.current);}},[]);let g=O(),b=i?g.CheckIcon:g.CopyIcon;return jsxs("div",{className:a("relative"),ref:m,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:u,onClick:()=>l(!s),title:d.copyTable,type:"button",children:e!=null?e:jsx(b,{height:14,width:14})}),s?jsxs("div",{className:a("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("md"),title:d.copyTableAsMarkdown,type:"button",children:d.tableFormatMarkdown}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("csv"),title:d.copyTableAsCsv,type:"button",children:d.tableFormatCsv}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("tsv"),title:d.copyTableAsTsv,type:"button",children:d.tableFormatTsv})]}):null]})};var Wa=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:a})=>{let s=w(),{isAnimating:l}=useContext(R),i=_(),c=O(),m=p=>{try{let d=p.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=d==null?void 0:d.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let g=Be(f),b="",h="",C="";switch(r){case "csv":b=Ee(g),h="text/csv",C="csv";break;case "markdown":b=Le(g),h="text/markdown",C="md";break;default:b=Ee(g),h="text/csv",C="csv";}re(`${a||"table"}.${C}`,b,h),o==null||o();}catch(u){n==null||n(u);}};return jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:m,title:r==="csv"?i.downloadTableAsCsv:i.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(c.DownloadIcon,{size:14})})},Je=({children:e,className:t,onDownload:o,onError:n})=>{let r=w(),[a,s]=useState(false),l=useRef(null),{isAnimating:i}=useContext(R),c=_(),m=O(),p=u=>{var d;try{let f=(d=l.current)==null?void 0:d.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),g=f==null?void 0:f.querySelector("table");if(!g){n==null||n(new Error("Table not found"));return}let b=Be(g),h=u==="csv"?Ee(b):Le(b);re(`table.${u==="csv"?"csv":"md"}`,h,u==="csv"?"text/csv":"text/markdown"),s(!1),o==null||o(u);}catch(f){n==null||n(f);}};return useEffect(()=>{let u=d=>{let f=d.composedPath();l.current&&!f.includes(l.current)&&s(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[]),jsxs("div",{className:r("relative"),ref:l,children:[jsx("button",{className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>s(!a),title:c.downloadTable,type:"button",children:e!=null?e:jsx(m.DownloadIcon,{size:14})}),a?jsxs("div",{className:r("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("csv"),title:c.downloadTableAsCsv,type:"button",children:c.tableFormatCsv}),jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("markdown"),title:c.downloadTableAsMarkdown,type:"button",children:c.tableFormatMarkdown})]}):null]})};var hn=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:a}=O(),s=w(),[l,i]=useState(false),{isAnimating:c}=useContext(R),m=_(),p=()=>{i(true);},u=()=>{i(false);};return useEffect(()=>{if(l){be();let d=f=>{f.key==="Escape"&&i(false);};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),he();}}},[l]),jsxs(Fragment,{children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:p,title:m.viewFullscreen,type:"button",children:jsx(r,{size:14})}),l?createPortal(jsx("div",{"aria-label":m.viewFullscreen,"aria-modal":"true",className:s("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:u,onKeyDown:d=>{d.key==="Escape"&&u();},role:"dialog",children:jsxs("div",{className:s("flex h-full flex-col"),onClick:d=>d.stopPropagation(),onKeyDown:d=>d.stopPropagation(),role:"presentation",children:[jsxs("div",{className:s("flex items-center justify-end gap-1 p-4"),children:[o?jsx(Ue,{}):null,n?jsx(Je,{}):null,jsx("button",{className:s("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:u,title:m.exitFullscreen,type:"button",children:jsx(a,{size:20})})]}),jsx("div",{className:s("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:s("w-full table-fixed border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})};var wn=({children:e,className:t,maxHeight:o,showControls:n,showCopy:r=true,showDownload:a=true,showFullscreen:s=true,...l})=>{let i=w(),{isAnimating:c,scrollable:m}=useContext(R),p=m!=null?m:ze,u=useRef(null),d=useRef(true),f=st(o);useEffect(()=>{let x=u.current;if(!(x&&f))return;let T=()=>{let M=x.scrollHeight-x.scrollTop-x.clientHeight<8;d.current=M;};return x.addEventListener("scroll",T,{passive:true}),()=>x.removeEventListener("scroll",T)},[f]),useEffect(()=>{let x=u.current;x&&f&&c&&d.current&&x.scrollTo({top:x.scrollHeight,behavior:"instant"});}),useEffect(()=>{c||(d.current=true);},[c]);let g=n&&r,b=n&&a,h=n&&s,C=g||b||h;return jsxs("div",{className:i("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[C?jsxs("div",{className:i("flex items-center justify-end gap-1"),children:[g?jsx(Ue,{}):null,b?jsx(Je,{}):null,h?jsx(hn,{showCopy:g,showDownload:b,children:e}):null]}):null,jsx(p,{className:i("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),scrollRef:u,style:f?{maxHeight:f}:void 0,children:jsx("table",{className:i("w-full min-w-max table-fixed divide-y divide-border",t),"data-streamdown":"table",...l,children:e})})]})};var ti=/startLine=(\d+)/,oi=/\bnoLineNumbers\b/,ni=lazy(()=>import('./mermaid-EMLHH3WB.js').then(e=>({default:e.Mermaid}))),ri=/language-([^\s]+)/,le=e=>e.props,si="node";function A(e,t){let o=Object.keys(e);if(o.length!==Object.keys(t).length)return false;let n=e,r=t;for(let a of o)if(a!==si&&!Object.is(n[a],r[a]))return false;return true}function ai(e,t){var o,n;return ((o=e==null?void 0:e.properties)==null?void 0:o.metastring)===((n=t==null?void 0:t.properties)==null?void 0:n.metastring)}function ii(e){if(typeof e=="string")return e;if(isValidElement(e)){let t=le(e).children;if(typeof t=="string")return t}}var eo=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Qt=(e,t)=>{if(typeof e=="boolean")return e;let o=e.table;return o===false?false:o===true||o===void 0?true:o[t]!==false},kn=(e,t)=>{if(typeof e=="boolean")return e;let o=e.code;return o===false?false:o===true||o===void 0?true:o[t]!==false},bt=(e,t)=>{if(typeof e=="boolean")return e;let o=e.mermaid;return o===false?false:o===true||o===void 0?true:o[t]!==false},Qe=createContext({depth:0,ulDepth:0,isUnordered:false}),li={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},to=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{depth:a,ulDepth:s}=useContext(Qe),l=useMemo(()=>({depth:a+1,ulDepth:s,isUnordered:false}),[a,s]);return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-depth":a,"data-streamdown":"ordered-list",...n,children:jsx(Qe.Provider,{value:l,children:e})})},(e,t)=>A(e,t));to.displayName="MarkdownOl";var Mn=memo(({children:e,className:t,node:o,...n})=>{var g;let r=w(),{depth:a,ulDepth:s,isUnordered:l}=useContext(Qe),{listStyle:i}=useContext(R),c=li[i],m=l&&s>0?c[(s-1)%c.length]:void 0,p=Array.isArray(e)?e.filter(b=>b!==`
|
|
15
|
-
`&&b!==""):[e],u=p[0],d=isValidElement(u)?(g=le(u).node)==null?void 0:g.tagName:void 0,f=p.length===1&&isValidElement(u)&&(u.type==="p"||d==="p")?le(u).children:e;return t!=null&&t.includes("task-list-item")?jsx("li",{className:r("my-1 flex list-none items-center gap-2 [&>input]:m-0 [&>p]:inline",t),"data-depth":a>0?a-1:0,"data-streamdown":"list-item",...n,children:f}):jsx("li",{className:r("py-1 [&>p]:inline",m,t),"data-depth":a>0?a-1:0,"data-streamdown":"list-item",...n,children:f})},(e,t)=>A(e,t));Mn.displayName="MarkdownLi";var Sn=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{depth:a,ulDepth:s}=useContext(Qe),l=useMemo(()=>({depth:a+1,ulDepth:s+1,isUnordered:true}),[a,s]);return jsx("ul",{className:r("list-inside whitespace-normal [li_&]:pl-6",t),"data-depth":a,"data-streamdown":"unordered-list",...n,children:jsx(Qe.Provider,{value:l,children:e})})},(e,t)=>A(e,t));Sn.displayName="MarkdownUl";var In=memo(({className:e,node:t,...o})=>{let n=w();return jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>A(e,t));In.displayName="MarkdownHr";var Rn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>A(e,t));Rn.displayName="MarkdownStrong";var ci=({children:e,className:t,href:o,node:n,...r})=>{let a=w(),{linkSafety:s}=useContext(R),[l,i]=useState(false),c=o==="streamdown:incomplete-link",m=useCallback(async f=>{if(!(!(s!=null&&s.enabled&&o)||c)){if(f.preventDefault(),s.onLinkCheck&&await s.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[s,o,c]),p=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),u=useCallback(()=>{i(false);},[]),d={url:o!=null?o:"",isOpen:l,onClose:u,onConfirm:p};return s!=null&&s.enabled&&o?jsxs(Fragment,{children:[jsx("button",{className:a("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",onClick:m,type:"button",children:e}),s.renderModal?s.renderModal(d):jsx(Ko,{...d})]}):jsx("a",{className:a("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},En=memo(ci,(e,t)=>A(e,t));En.displayName="MarkdownA";var Ln=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>A(e,t));Ln.displayName="MarkdownH1";var Nn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>A(e,t));Nn.displayName="MarkdownH2";var An=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>A(e,t));An.displayName="MarkdownH3";var Dn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>A(e,t));Dn.displayName="MarkdownH4";var Hn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>A(e,t));Hn.displayName="MarkdownH5";var Bn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>A(e,t));Bn.displayName="MarkdownH6";var On=memo(({children:e,className:t,node:o,...n})=>{let{controls:r,tableMaxHeight:a}=useContext(R),s=eo(r,"table"),l=Qt(r,"copy"),i=Qt(r,"download"),c=Qt(r,"fullscreen");return jsx(wn,{className:t,maxHeight:a,showControls:s,showCopy:l,showDownload:i,showFullscreen:c,...n,children:e})},(e,t)=>A(e,t));On.displayName="MarkdownTable";var _n=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>A(e,t));_n.displayName="MarkdownThead";var Vn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>A(e,t));Vn.displayName="MarkdownTbody";var jn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>A(e,t));jn.displayName="MarkdownTr";var $n=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("th",{className:r("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>A(e,t));$n.displayName="MarkdownTh";var zn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>A(e,t));zn.displayName="MarkdownTd";var Fn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e})},(e,t)=>A(e,t));Fn.displayName="MarkdownBlockquote";var Wn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>A(e,t));Wn.displayName="MarkdownSup";var di=()=>({}),mi=e=>{try{let t=atob(e),o=Uint8Array.from(t,n=>n.charCodeAt(0));return new TextDecoder().decode(o)}catch(t){return ""}},qn=memo(({children:e,className:t,node:o,...n})=>{let r=w(),{calloutIcon:a,calloutStyle:s,components:l,remarkPlugins:i,rehypePlugins:c}=useContext(R),m=n,p=m["data-callout-title"],u=m["data-callout-color"],d=m["data-callout-icon"],f=m["data-callout-body"],g=f?mi(f):"",b=(s!=null?s:di)(u),h=d&&a?a(d):null;return jsxs("div",{className:r("my-4 rounded-md border-l-4 px-4 py-3 [&>p:last-child]:mb-0",t),"data-streamdown":"callout",style:b,...n,children:[p!==void 0?jsxs("p",{className:"mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",children:[h,p]}):null,g.trim().length>0?jsx(Ke,{components:l,rehypePlugins:c,remarkPlugins:i,children:g}):null]})},(e,t)=>A(e,t));qn.displayName="MarkdownCallout";var vn={"markdown-alert-note":"border-l-blue-500 bg-blue-500/5 [&_.markdown-alert-title]:text-blue-600 dark:[&_.markdown-alert-title]:text-blue-400","markdown-alert-tip":"border-l-green-600 bg-green-600/5 [&_.markdown-alert-title]:text-green-700 dark:[&_.markdown-alert-title]:text-green-400","markdown-alert-important":"border-l-purple-600 bg-purple-600/5 [&_.markdown-alert-title]:text-purple-700 dark:[&_.markdown-alert-title]:text-purple-400","markdown-alert-warning":"border-l-amber-600 bg-amber-600/5 [&_.markdown-alert-title]:text-amber-700 dark:[&_.markdown-alert-title]:text-amber-400","markdown-alert-caution":"border-l-red-600 bg-red-600/5 [&_.markdown-alert-title]:text-red-700 dark:[&_.markdown-alert-title]:text-red-400"},Zn=memo(({children:e,className:t,node:o,...n})=>{let r=w(),a=t==null?void 0:t.includes("markdown-alert");if(t==null?void 0:t.includes("sdm-callout"))return jsx(qn,{className:t,node:o,...n,children:e});if(a){let l=Object.keys(vn).find(i=>t==null?void 0:t.includes(i));return jsx("div",{className:r("my-4 rounded-r-md border-muted-foreground/30 border-l-4 bg-muted/40 px-4 py-3 [&>p:last-child]:mb-0",l?vn[l]:null,t),...n,children:e})}return jsx("div",{className:r(t),...n,children:e})},(e,t)=>A(e,t));Zn.displayName="MarkdownDiv";var Kn=memo(({children:e,className:t,node:o,...n})=>{let r=w();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>A(e,t));Kn.displayName="MarkdownSub";var Gn=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let a=i=>{if(!isValidElement(i))return false;let c=le(i).children,m=Array.isArray(c)?c:[c],p=false,u=false;for(let d of m)if(d){if(typeof d=="string")d.trim()!==""&&(p=true);else if(isValidElement(d))if(le(d)["data-footnote-backref"]!==void 0)u=true;else {let f=le(d).children,g=Array.isArray(f)?f:[f];for(let b of g){if(typeof b=="string"&&b.trim()!==""){p=true;break}if(isValidElement(b)&&le(b)["data-footnote-backref"]===void 0){p=true;break}}}}return u&&!p},s=Array.isArray(e)?e.map(i=>{if(!isValidElement(i))return i;if(i.type===to){let c=le(i).children,p=(Array.isArray(c)?c:[c]).filter(u=>!a(u));return p.length===0?null:{...i,props:{...le(i),children:p}}}return i}):e;return (Array.isArray(s)?s.some(i=>i!==null):s!==null)?jsx("section",{className:t,...n,children:s}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>A(e,t));Gn.displayName="MarkdownSection";var ui=({node:e,className:t,children:o,...n})=>{var F,H,B;let r=w(),a=!("data-block"in n),{mermaid:s,controls:l,lineNumbers:i}=useContext(R),c=He(),m=Et(),p=t==null?void 0:t.match(ri),u=(F=p==null?void 0:p.at(1))!=null?F:"",d=en(u);if(a)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let f=(H=e==null?void 0:e.properties)==null?void 0:H.metastring,g=typeof f=="string"?f:void 0,b=g==null?void 0:g.match(ti),h=b?Number.parseInt(b[1],10):void 0,C=h!==void 0&&h>=1?h:void 0,T=!(g?oi.test(g):false)&&i!==false,M=(B=ii(o))!=null?B:"";if(d){let W=d.component;return jsx(Suspense,{fallback:jsx(mt,{}),children:jsx(W,{code:M,isIncomplete:m,language:u,meta:g})})}if(u==="mermaid"&&c){let W=eo(l,"mermaid"),Y=bt(l,"download"),Q=bt(l,"copy"),E=bt(l,"fullscreen"),$=bt(l,"panZoom"),ae=W&&(Y||Q||E);return jsx(Suspense,{fallback:jsx(mt,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-incomplete":m||void 0,"data-streamdown":"mermaid-block",children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:"mermaid"})}),ae?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"mermaid-block-actions",children:[Y?jsx(ft,{chart:M,config:s==null?void 0:s.config}):null,Q?jsx(dt,{code:M}):null,E?jsx(mn,{chart:M,config:s==null?void 0:s.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(ni,{chart:M,config:s==null?void 0:s.config,showControls:$})})]})})}let I=eo(l,"code"),k=kn(l,"download"),V=kn(l,"copy"),{"data-block":D,...j}=n;return jsx(Bt,{className:t,code:M,isIncomplete:m,language:u,lineNumbers:T,startLine:C,...j,children:I?jsxs(Fragment,{children:[k?jsx(Vt,{code:M,language:u}):null,V?jsx(dt,{}):null]}):null})},Xn=memo(ui,(e,t)=>A(e,t)&&ai(e.node,t.node));Xn.displayName="MarkdownCode";var Un=memo(Wo,(e,t)=>A(e,t));Un.displayName="MarkdownImg";var Tn={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},Jn=memo(({children:e,className:t,node:o,...n})=>{let r=w(),a=_(),s=n["data-alert-type"],l=s&&s in Tn?Tn[s]:void 0,i=l?a[l]:void 0,c=e;return i&&(c=[...(Array.isArray(e)?e:[e]).filter(u=>!(typeof u=="string"&&u.trim().length>0)),i]),jsx("p",{className:r("mb-1 flex items-center gap-2 font-semibold [&>svg]:inline-block",t),...n,children:c})},(e,t)=>A(e,t));Jn.displayName="MarkdownAlertTitle";var Yn=memo(({children:e,className:t,node:o,...n})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx(Jn,{className:t,node:o,...n,children:e});let a=(Array.isArray(e)?e:[e]).filter(s=>s!=null&&s!=="");if(a.length===1&&isValidElement(a[0])){let s=le(a[0]).node,l=s==null?void 0:s.tagName;if(l==="img")return jsx(Fragment,{children:e});if(l==="code"&&"data-block"in a[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...n,children:e})},(e,t)=>A(e,t));Yn.displayName="MarkdownParagraph";var Qn={ol:to,li:Mn,ul:Sn,hr:In,strong:Rn,a:En,h1:Ln,h2:Nn,h3:An,h4:Dn,h5:Hn,h6:Bn,table:On,thead:_n,tbody:Vn,tr:jn,th:$n,td:zn,blockquote:Fn,code:Xn,div:Zn,img:Un,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:Wn,sub:Kn,p:Yn,section:Gn};var pi=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,fi=/\p{L}/u;function et(e){let t=e.replace(/(```|~~~)[\s\S]*?\1/g,"").replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,""),o,n=0,r=0;for(let a of t){if(pi.test(a)){o!=null||(o="rtl"),r+=1;continue}fi.test(a)&&(o!=null||(o="ltr"),n+=1);}return r>n?"rtl":n>r?"ltr":o!=null?o:"ltr"}var gi=/^[ \t]{0,3}(`{3,}|~{3,})/;var er=e=>{let t=e.split(`
|
|
16
|
-
`),o=null,n=0;for(let r of t){let a=gi.exec(r);if(o===null){if(a){let s=a[1];o=s[0],n=s.length;}}else if(a){let s=a[1],l=s[0],i=s.length;l===o&&i>=n&&(o=null,n=0);}}return o!==null};var hi=/\[\^[\w-]{1,200}\](?!:)/,yi=/\[\^[\w-]{1,200}\]:/,Ci=/<([A-Za-z][\w:-]*)[\s>/]/,wi=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),tr=new Map,or=new Map,sr=e=>{let t=e.toLowerCase(),o=tr.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return tr.set(t,n),n},xi=e=>{let t=e.toLowerCase(),o=or.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return or.set(t,n),n},nr=(e,t)=>{if(wi.has(t.toLowerCase()))return 0;let o=e.match(sr(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},rr=(e,t)=>{let o=e.match(xi(t));return o?o.length:0},ki=(e,t)=>{let o=e.match(sr(t));return !!o&&o.every(n=>n.trimEnd().endsWith("/>"))},vi=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},yt=e=>{let t=hi.test(e),o=yi.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),r=[],a=[],s=false;for(let l of n){let i=l.raw,c=r.length;if(a.length>0){r[c-1]+=i;let m=a.at(-1),p=nr(i,m),u=rr(i,m);for(let d=0;d<p;d+=1)a.push(m);for(let d=0;d<u;d+=1)a.length>0&&a.at(-1)===m&&a.pop();continue}if(l.type==="html"&&l.block){let m=i.match(Ci);if(m){let p=m[1],u=nr(i,p),d=rr(i,p);u>d&&!ki(i,p)&&a.push(p);}}if(c>0&&!s){let m=r[c-1];if(vi(m)%2===1){r[c-1]=m+i;continue}}r.push(i),l.type!=="space"&&(s=l.type==="code");}return r},oo=(e,t,o=yt)=>{if(!(t!=null&&t.source&&e.startsWith(t.source)))return {source:e,blocks:o(e)};if(e===t.source)return t;if(t.blocks.length<=1)return {source:e,blocks:o(e)};let n=t.blocks.slice(0,-1),r=0;for(let i of n)r+=i.length;let a=e.slice(0,r);if(n.join("")!==a)return {source:e,blocks:o(e)};let s=e.slice(r),l=o(s);return {source:e,blocks:[...n,...l]}};var Ti=/^\n*/,Pi=/\n*$/,no=/\n\n/g,Mi=(e,t,o)=>{if(!t.includes(`
|
|
17
|
-
`))return e+t+o;let r=t.replace(no,`
|
|
18
|
-
<!---->
|
|
19
|
-
`).replace(Ti,`
|
|
20
|
-
|
|
21
|
-
`).replace(Pi,`
|
|
22
|
-
|
|
23
|
-
`);return `${e}${r}${o}
|
|
24
|
-
|
|
25
|
-
`},Si=(e,t)=>{let o=new RegExp(`<(${t})(?=[\\s>/])([^>]*)>`,"gi"),n="",r=0,a=o.exec(e);for(;a;){let s=a[0],l=a[1],i=a.index+s.length,c=e.slice(i);if(new RegExp(`</${l}\\s*>`,"i").test(c)){a=o.exec(e);continue}if(n+=e.slice(r,a.index),c.length===0){n+=s,r=i,a=o.exec(e);continue}if(c.startsWith(`
|
|
26
|
-
|
|
27
|
-
`)){let d=c.slice(2).replace(no,`
|
|
28
|
-
<!---->
|
|
29
|
-
`);n+=`${s}
|
|
30
|
-
|
|
31
|
-
${d}`,r=e.length;break}if(!c.startsWith(`
|
|
32
|
-
`)){n+=s,r=i,a=o.exec(e);continue}let p=c.slice(1);if(p.trim().length===0){n+=s,r=i,a=o.exec(e);continue}let u=p.replace(no,`
|
|
33
|
-
<!---->
|
|
34
|
-
`);n+=`${s}
|
|
35
|
-
|
|
36
|
-
${u}`,r=e.length;break}return r===0?e:n+e.slice(r)},ar=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`<${n}(?=[\\s>/])((?:"[^"]*"|'[^']*'|[^"'>])*)\\/>`,"gi");o=o.replace(r,(a,s)=>`<${n}${s}></${n}>`);}for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(a,s,l,i)=>Mi(s,l,i)),o=Si(o,n);}return o};var Ii=/([\\`*_~[\]|])/g,Ri=e=>e.replace(Ii,"\\$1"),ir=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(a,s,l,i)=>{let c=Ri(l).replace(/\n\n/g," ");return s+c+i});}return o};var Li=new Set(["blockquote","dd","dt","figcaption","h1","h2","h3","h4","h5","h6","li","p","td","th"]),lr=new Set(["code","kbd","pre","samp","var"]);function cr(e){return e.children.map(t=>t.type==="text"?t.value:t.type==="element"&&!lr.has(t.tagName)?cr(t):"").join("")}function dr(){return e=>{visit(e,"element",t=>{if(lr.has(t.tagName)){(t.properties)!=null||(t.properties={}),t.properties.dir="ltr";return}Li.has(t.tagName)&&((t.properties)!=null||(t.properties={}),typeof t.properties.dir!="string"&&(t.properties.dir=et(cr(t))));});}}var mr=e=>t=>{if(!e||e.length===0)return;let o=new Set(e.map(n=>n.toLowerCase()));visit(t,"element",n=>{var a;if(!o.has(n.tagName.toLowerCase()))return;let r=n.children.filter(s=>s.type==="element").map(s=>{var l;return {tag:s.tagName,props:(l=s.properties)!=null?l:{},text:toText(s).trim()}});n.properties=(a=n.properties)!=null?a:{},n.properties["data-content"]=JSON.stringify(r),n.children=[];});};var ur=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(ur).join(""):"",pr=e=>t=>{if(!e||e.length===0)return;let o=new Set(e.map(n=>n.toLowerCase()));visit(t,"element",n=>{if(o.has(n.tagName.toLowerCase())){let r=ur(n);n.children=r?[{type:"text",value:r}]:[];}});};var Vi=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),ji=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),$i=e=>{let t=unified().use(ca).use(da,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},fr=(e,t=[])=>o=>{if(!e||e.length===0)return;let n=new Set(e.map(a=>a.toLowerCase())),r=new Set((t!=null?t:[]).map(a=>a.toLowerCase()));visit(o,"element",a=>{let s=a.tagName.toLowerCase();if(!n.has(s)||r.has(s)||!Vi(a))return;let l=ji(a);if(!l.includes(`
|
|
37
|
-
`))return;let i=$i(l);a.children=i;});};var gr=()=>e=>{visit(e,"code",t=>{var o,n;t.meta&&(t.data=(o=t.data)!=null?o:{},t.data.hProperties={...(n=t.data.hProperties)!=null?n:{},metastring:t.meta});});};var br=/^>>>[ \t]?(.*)$/,Fi=/^<<<\s*$/,Wi=/^>+\s*$/,qi=/^<+\s*$/,Zi=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,Ki=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,Gi=/^[a-z0-9-]+$/,Xi=e=>{let t=Zi.exec(e);if(!(t!=null&&t.groups))return {};let{iconParen:o,iconBrace:n,title:r,color:a}=t.groups,s=o!=null?o:n;return {icon:s&&Gi.test(s)?s:void 0,title:r!==void 0&&r.length>0?r:void 0,color:a&&Ki.test(a)?a:void 0}},ro=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),Ui=e=>{let t=new TextEncoder().encode(e),o="";for(let n of t)o+=String.fromCharCode(n);return btoa(o)},Ji=(e,t)=>{var c;let o=br.exec(e[t]),n=(c=o==null?void 0:o[1])!=null?c:"",r=Xi(n),a=[],s=t+1;for(;s<e.length;s+=1){let m=e[s];if(Fi.test(m)){s+=1;break}if(Wi.test(m)||qi.test(m)){s+=1;break}a.push(m);}let l=a.join(`
|
|
38
|
-
`).trim();return {replacement:`<div ${['class="sdm-callout"',r.title!==void 0?`data-callout-title="${ro(r.title)}"`:"",r.color!==void 0?`data-callout-color="${ro(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${ro(r.icon)}"`:"",`data-callout-body="${Ui(l)}"`].filter(Boolean).join(" ")}></div>`,next:s}},hr=e=>{if(!e.includes(">>>"))return e;let t=e.split(`
|
|
39
|
-
`),o=[],n=0,r=false;for(;n<t.length;)if(br.test(t[n])){let a=Ji(t,n);o.push(a.replacement),n=a.next,r=true;}else o.push(t[n]),n+=1;return r?o.join(`
|
|
40
|
-
`):e},yr=()=>()=>{};var el={NOTE:{icon:"info",kind:"note",title:"Note",iconPaths:[{d:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]},TIP:{icon:"light-bulb",kind:"tip",title:"Tip",iconPaths:[{d:"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"}]},IMPORTANT:{icon:"report",kind:"important",title:"Important",iconPaths:[{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}]},WARNING:{icon:"alert",kind:"warning",title:"Warning",iconPaths:[{d:"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",fillRule:"evenodd"}]},CAUTION:{icon:"stop",kind:"caution",title:"Caution",iconPaths:[{d:"M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25a.749.749 0 0 1-.53.22H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"}]}},tl=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,Cr=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let o="";for(let n of t)o+=Cr(n);return o},ol=e=>{let t=e.iconPaths.map(o=>`<path d="${o.d}"${o.fillRule?` fill-rule="${o.fillRule}"`:""}></path>`).join("");return {type:"paragraph",children:[{type:"html",value:`<svg class="octicon octicon-${e.icon}" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true">${t}</svg>`},{type:"text",value:e.title}],data:{hName:"p",hProperties:{className:["markdown-alert-title"],"data-alert-type":e.kind}}}},nl=e=>{var p,u;let t=e.children[0];if(!t||t.type!=="paragraph")return;let o=t.children[0];if(!o||o.type!=="text")return;let n=Cr(o).trimStart(),r=n.match(tl);if(!r)return;let a=el[r[1].toUpperCase()],s=n.slice(r[0].length),l=t.children.slice(1);if(s.trim().length===0&&l.length===0&&e.children.length===1)return;let i=[ol(a)],c=[];s.length>0&&c.push({type:"text",value:s});let m=l;return ((p=m[0])==null?void 0:p.type)==="break"&&(m=m.slice(1)),c.push(...m),c.length>0&&c.some(d=>d.type!=="text"||d.value.trim().length>0)&&i.push({type:"paragraph",children:c}),i.push(...e.children.slice(1)),e.data=(u=e.data)!=null?u:{},e.data.hName="div",e.data.hProperties={className:["markdown-alert",`markdown-alert-${a.kind}`]},e.children=i,SKIP},wr=()=>e=>{visit(e,"blockquote",nl);};var ml=/^[ \t]*<[\w!/?-]/,ul=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,pl=e=>typeof e!="string"||e.length===0||!ml.test(e)?e:e.replace(ul,"$1"),Tr,Pr,Mr,Sr,Ir,Rr,Er,Lr,Nr,Ar,Dr,Ct={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(Pr=(Tr=defaultSchema.protocols)==null?void 0:Tr.href)!=null?Pr:[],"tel"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(Sr=(Mr=defaultSchema.attributes)==null?void 0:Mr.div)!=null?Sr:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(Rr=(Ir=defaultSchema.attributes)==null?void 0:Ir.p)!=null?Rr:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(Lr=(Er=defaultSchema.attributes)==null?void 0:Er.svg)!=null?Lr:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(Ar=(Nr=defaultSchema.attributes)==null?void 0:Nr.path)!=null?Ar:[],"d","fillRule"]},tagNames:[...(Dr=defaultSchema.tagNames)!=null?Dr:[],"svg","path"]},so={raw:Xo,sanitize:[Or,Ct],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},fl={gfm:[cl,{}],githubAlerts:wr,containerAlerts:yr,codeMeta:gr},kr=Object.values(so),gl=Object.values(fl),vr=new WeakMap;function bl(e){var r;let t=vr.get(e);if(t)return t;let o={...Ct,tagNames:[...(r=Ct.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...Ct.attributes,...e}},n=[so.raw,[Or,o],so.harden];return vr.set(e,n),n}var hl={block:" \u258B",circle:" \u25CF"},yl=["github-light","github-dark"],Cl={enabled:true},_r=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:o,index:n,isIncomplete:r,dir:a,animatePlugin:s,...l})=>{useLayoutEffect(()=>{s==null||s.commit();}),s==null||s.setAnimateCodeBlocks(r);let i=typeof e=="string"&&o?pl(e):e,c=jsx(Ke,{...l,children:i});return jsx(Rt.Provider,{value:r,children:a?jsx("div",{dir:a,style:{display:"contents"},children:c}):c})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return false;if(e.components!==t.components){let o=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(o.length!==n.length||o.some(r=>{var a,s;return ((a=e.components)==null?void 0:a[r])!==((s=t.components)==null?void 0:s[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins||!!e.animatePlugin!=!!t.animatePlugin)});_r.displayName="Block";var wl=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:a,rehypePlugins:s=kr,remarkPlugins:l=gl,className:i,shikiTheme:c,mermaid:m,codeBlockMaxHeight:p=400,controls:u=true,isAnimating:d=false,scrollable:f,tableMaxHeight:g=300,animated:b,BlockComponent:h=_r,parseMarkdownIntoBlocksFn:C=yt,caret:x,listStyle:T="hierarchical",calloutIcon:M,calloutStyle:I,plugins:k,remend:V,linkSafety:D=Cl,lineNumbers:j=true,allowedTags:F,literalTagContent:H,dataOnlyTags:B,translations:W,icons:Y,prefix:Q,onAnimationStart:E,onAnimationEnd:$,...ae})=>{let je=useId(),te=useMemo(()=>vo(Q),[Q]),ce=useRef(null),oe=useRef(E),ee=useRef($);oe.current=E,ee.current=$,useEffect(()=>{var S,X,q;if(t==="static")return;let y=ce.current;if(ce.current=d,y===null){d&&((S=oe.current)==null||S.call(oe));return}d&&!y?(X=oe.current)==null||X.call(oe):!d&&y&&((q=ee.current)==null||q.call(ee));},[d,t]);let K=useMemo(()=>F?Object.keys(F):[],[F]),P=useMemo(()=>{if(!(B!=null&&B.length))return K;let y=new Set(B.map(S=>S.toLowerCase()));return K.filter(S=>!y.has(S.toLowerCase()))},[K,B]),z=useRef(null),de=useMemo(()=>{if(typeof e!="string")return "";let y=e;return H&&H.length>0&&(y=ir(y,H)),P.length>0&&(y=ar(y,P)),y=hr(y),y},[e,P,H]),G=useMemo(()=>{let y=t==="streaming"?z.current:null,S=oo(de,y,C);if(z.current=t==="streaming"?S:null,!(t==="streaming"&&n)||S.blocks.length===0)return S.blocks;let X=S.blocks.length-1,q=S.blocks[X],me=dl(q,V);if(me===q)return S.blocks;let Pe=S.blocks.slice();return Pe[X]=me,Pe},[de,C,t,n,V]),Ae=useMemo(()=>b===true?"true":b?JSON.stringify(b):"",[b]),ne=useRef(null),$e=useRef([]),xe=useRef([]),ao=useRef(null),xt=useRef("");if(Ae){if(xt.current!==Ae){xt.current=Ae;let y=Ae!=="true"?b.maxBacklogMs:void 0;ne.current=Mt({maxBacklogMs:y}),$e.current=[],xe.current=[];}else ne.current||(ne.current=Mt());d&&ne.current&&ne.current.beginPass(ne.current.now());}else ne.current=null,$e.current=[],xe.current=[],xt.current="";useLayoutEffect(()=>{var y;d&&((y=ne.current)==null||y.commitPass());});let ke=useDeferredValue(G),ve=useMemo(()=>{if(t!=="streaming"||ne.current||ke===G||ke.length===0)return G;let y=ke.length,S=G.length;if(S===0)return ke;if(y!==S)return G;for(let q=0;q<y-1;q+=1)if(ke[q]!==G[q])return G;let X=ke.slice();return X[y-1]=G[S-1],X},[G,ke,t]),kt=useMemo(()=>o==="auto"?ve.map(et):void 0,[ve,o]),zr=useMemo(()=>ve.map((y,S)=>`${je}-${S}`),[ve.length,je]),Fr=useMemo(()=>W?JSON.stringify(W):"",[W]),io=useMemo(()=>({...lt,...W}),[Fr]),ot=useMemo(()=>{let{inlineCode:y,...S}=a!=null?a:{},X={...Qn,...S};if(y){let q=X.code;X.code=me=>"data-block"in me?q?createElement(q,me):null:createElement(y,me);}return X},[a]),nt=useMemo(()=>{let y=[];return k!=null&&k.cjk&&(y=[...y,...k.cjk.remarkPluginsBefore]),y=[...y,...l],k!=null&&k.cjk&&(y=[...y,...k.cjk.remarkPluginsAfter]),k!=null&&k.math&&(y=[...y,k.math.remarkPlugin]),y},[l,k==null?void 0:k.math,k==null?void 0:k.cjk]),Te=useMemo(()=>{let y=s;return F&&Object.keys(F).length>0&&s===kr&&(y=bl(F)),P.length>0&&(y=[...y,[fr,P,H!=null?H:[]]]),H&&H.length>0&&(y=[...y,[pr,H]]),B&&B.length>0&&(y=[...y,[mr,B]]),k!=null&&k.math&&(y=[...y,k.math.rehypePlugin]),o==="auto"&&t==="static"&&(y=[...y,dr]),y},[s,k==null?void 0:k.math,F,P,H,B,o,t]),lo=useMemo(()=>{var y,S;return {calloutIcon:M,calloutStyle:I,codeBlockMaxHeight:p,shikiTheme:(S=c!=null?c:(y=k==null?void 0:k.code)==null?void 0:y.getThemes())!=null?S:yl,controls:u,isAnimating:d,lineNumbers:j,listStyle:T,mode:t,mermaid:m,linkSafety:D,scrollable:f,tableMaxHeight:g,components:ot,remarkPlugins:nt,rehypePlugins:Te}},[M,I,p,c,u,d,j,T,t,m,D,f,k==null?void 0:k.code,g,ot,nt,Te]),Wr=useMemo(()=>x&&d?{"--streamdown-caret":`"${hl[x]}"`}:void 0,[x,d]),qr=y=>{let S=null;if(ne.current&&d){if(!$e.current[y]){let q=Ae&&Ae!=="true"?b:{},{maxBacklogMs:me,...Pe}=q;$e.current[y]=rt({...Pe,timeline:ne.current});}S=$e.current[y];}ao.current!==Te&&(xe.current=[],ao.current=Te),S&&!xe.current[y]&&(xe.current[y]=[...Te,S.rehypePlugin]);let X=S&&xe.current[y]?xe.current[y]:Te;return {blockAnimatePlugin:S,blockRehypePlugins:X}};return t==="static"?jsx(ct.Provider,{value:io,children:jsx(pt.Provider,{value:k!=null?k:null,children:jsx(R.Provider,{value:lo,children:jsx(Ot,{icons:Y,children:jsx(at.Provider,{value:te,children:jsx("div",{className:te("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:o==="auto"?void 0:o,children:jsx(Ke,{components:ot,rehypePlugins:Te,remarkPlugins:nt,...ae,children:de})})})})})})}):jsx(ct.Provider,{value:io,children:jsx(pt.Provider,{value:k!=null?k:null,children:jsx(R.Provider,{value:lo,children:jsx(Ot,{icons:Y,children:jsx(at.Provider,{value:te,children:jsxs("div",{className:te("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",x?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),"data-streamdown":"container",style:Wr,children:[ve.length===0&&x&&d&&jsx("span",{}),ve.map((y,S)=>{var co;let X=S===ve.length-1,q=d&&X&&er(y),{blockAnimatePlugin:me,blockRehypePlugins:Pe}=qr(S);return jsx(h,{animatePlugin:me,components:ot,content:y,dir:(co=kt==null?void 0:kt[S])!=null?co:o!=="auto"?o:void 0,index:S,isIncomplete:q,rehypePlugins:Pe,remarkPlugins:nt,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...ae},zr[S])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.calloutIcon===t.calloutIcon&&e.calloutStyle===t.calloutStyle&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&e.dataOnlyTags===t.dataOnlyTags&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);wl.displayName="Streamdown";var $r=({children:e,className:t,contentSize:o,fitKey:n,minZoom:r=.5,maxZoom:a=3,zoomStep:s=.1,showControls:l=true,initialZoom:i=1,isAutoFit:c=false,fullscreen:m=false})=>{let{RotateCcwIcon:p,ZoomInIcon:u,ZoomOutIcon:d}=O(),f=w(),g=_(),b=useRef(null),h=useRef(null),[C,x]=useState(i),[T,M]=useState(r),[I,k]=useState(i),[V,D]=useState({x:0,y:0}),[j,F]=useState(false),[H,B]=useState(false),[W,Y]=useState({x:0,y:0}),[Q,E]=useState({x:0,y:0}),$=useCallback(P=>{k(z=>Math.max(T,Math.min(a,z+P))),B(true);},[T,a]),ae=useCallback(()=>{$(s);},[$,s]),je=useCallback(()=>{$(-s);},[$,s]),te=useCallback(()=>{k(C),D({x:0,y:0}),B(false);},[C]),ce=useCallback(P=>{P.preventDefault();let z=P.deltaY>0?-s:s;$(z);},[$,s]),oe=useCallback(P=>{if(P.button!==0||P.isPrimary===false)return;F(true),B(true),Y({x:P.clientX,y:P.clientY}),E(V);let z=P.currentTarget;z instanceof HTMLElement&&z.setPointerCapture(P.pointerId);},[V]),ee=useCallback(P=>{if(!j)return;P.preventDefault();let z=P.clientX-W.x,de=P.clientY-W.y;D({x:Q.x+z,y:Q.y+de});},[j,W,Q]),K=useCallback(P=>{F(false);let z=P.currentTarget;z instanceof HTMLElement&&z.releasePointerCapture(P.pointerId);},[]);return useEffect(()=>{M(r),c||(x(i),k(i));},[i,c,r]),useEffect(()=>{if(!(c&&o))return;let P=b.current;if(!P)return;let z=P.clientWidth,de=P.clientHeight;if(!(z>0&&de>0))return;let G=Math.min(z/o.width,de/o.height,1);!(G>0)||Number.isNaN(G)||(x(G),M(Math.min(r,G)),H||(k(G),D({x:0,y:0})));},[o,H,c,r]),useEffect(()=>{c&&B(false);},[c]),useEffect(()=>{let P=b.current;if(P)return P.addEventListener("wheel",ce,{passive:false}),()=>{P.removeEventListener("wheel",ce);}},[ce]),useEffect(()=>{let P=h.current;if(P&&j)return document.body.style.userSelect="none",P.addEventListener("pointermove",ee,{passive:false}),P.addEventListener("pointerup",K),P.addEventListener("pointercancel",K),()=>{document.body.style.userSelect="",P.removeEventListener("pointermove",ee),P.removeEventListener("pointerup",K),P.removeEventListener("pointercancel",K);}},[j,ee,K]),jsxs("div",{className:f("relative flex flex-col",m?"h-full w-full":"min-h-28 w-full",t),ref:b,style:{cursor:j?"grabbing":"grab"},children:[l?jsxs("div",{className:f("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",m?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{"aria-label":g.zoomIn,className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:I>=a,onClick:ae,title:g.zoomIn,type:"button",children:jsx(u,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":g.zoomOut,className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:I<=T,onClick:je,title:g.zoomOut,type:"button",children:jsx(d,{"aria-hidden":"true",size:16})}),jsx("button",{"aria-label":g.resetView,className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:te,title:g.resetView,type:"button",children:jsx(p,{"aria-hidden":"true",size:16})})]}):null,jsx("div",{className:f("flex-1 origin-center transition-transform duration-150 ease-out",m?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:oe,ref:h,role:"application",style:{transform:`translate(${V.x}px, ${V.y}px) scale(${I})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var dn=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let a=w(),[s,l]=useState(null),[i,c]=useState(false),[m,p]=useState(""),[u,d]=useState(null),[f,g]=useState(""),[b,h]=useState(0),{mermaid:C}=useContext(R),x=He(),T=C==null?void 0:C.errorComponent,{shouldRender:M,containerRef:I}=mo({immediate:n});if(useEffect(()=>{if(!M)return;if(!x){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),c(!0);let D=x.getMermaid(o),j=e.split("").reduce((Y,Q)=>(Y<<5)-Y+Q.charCodeAt(0)|0,0),F=`mermaid-${Math.abs(j)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:H}=await D.render(F,e),B=Zt(H),W=n?H:sn(H);p(W),d(B),g(W);}catch(D){if(!(f||m)){let j=D instanceof Error?D.message:"Failed to render Mermaid chart";l(j);}}finally{c(false);}})();},[e,o,b,M,x]),!(M||m||f))return jsx("div",{className:a("my-4 min-h-[200px]",t),ref:I});if(i&&!m&&!f)return jsx("div",{className:a("my-4 flex justify-center p-4",t),ref:I,children:jsxs("div",{className:a("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:a("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:a("text-sm"),children:"Loading diagram..."})]})});if(s&&!m&&!f){let V=()=>h(D=>D+1);return T?jsx("div",{ref:I,children:jsx(T,{chart:e,error:s,retry:V})}):jsxs("div",{className:a("rounded-md bg-red-50 p-4",t),ref:I,children:[jsxs("p",{className:a("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",s]}),jsxs("details",{className:a("mt-2"),children:[jsx("summary",{className:a("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:a("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let k=m||f;return jsx("div",{className:a("size-full",t),"data-streamdown":"mermaid",ref:I,children:jsx($r,{className:a(n?"size-full overflow-hidden":"overflow-hidden",t),contentSize:u,fitKey:e,fullscreen:n,isAutoFit:true,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:a("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:k},role:"img"})})})};export{oo as A,pl as B,so as C,fl as D,_r as E,wl as F,Qr as a,rt as b,Et as c,ze as d,Po as e,At as f,Ht as g,yd as h,Bt as i,lt as j,dt as k,Vt as l,mt as m,R as n,Qo as o,dn as p,Be as q,Ee as r,Xt as s,gt as t,Le as u,Ue as v,Wa as w,Je as x,et as y,yt as z};
|
package/dist/mermaid-EMLHH3WB.js
DELETED