@lofcz/streamdown 2.9.0 → 2.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-NE4QKYRI.js +29 -0
- package/dist/highlighted-body-5PIGDDHF.js +2 -0
- package/dist/hooks/use-deferred-render.d.ts +57 -0
- package/dist/index.d.ts +53 -498
- package/dist/index.js +1 -1
- package/dist/lib/animate.d.ts +66 -0
- package/dist/lib/block-incomplete-context.d.ts +14 -0
- package/dist/lib/code-block/body.d.ts +12 -0
- package/dist/lib/code-block/container.d.ts +8 -0
- package/dist/lib/code-block/context.d.ts +6 -0
- package/dist/lib/code-block/copy-button.d.ts +9 -0
- package/dist/lib/code-block/download-button.d.ts +9 -0
- package/dist/lib/code-block/header.d.ts +5 -0
- package/dist/lib/code-block/highlighted-body.d.ts +12 -0
- package/dist/lib/code-block/index.d.ts +13 -0
- package/dist/lib/code-block/skeleton.d.ts +1 -0
- package/dist/lib/components.d.ts +2 -0
- package/dist/lib/detect-direction.d.ts +13 -0
- package/dist/lib/icon-context.d.ts +23 -0
- package/dist/lib/icons.d.ts +14 -0
- package/dist/lib/image.d.ts +5 -0
- package/dist/lib/incomplete-code-utils.d.ts +24 -0
- package/dist/lib/link-modal.d.ts +8 -0
- package/dist/lib/markdown.d.ts +30 -0
- package/dist/lib/mermaid/download-button.d.ts +11 -0
- package/dist/lib/mermaid/fullscreen-button.d.ts +10 -0
- package/dist/lib/mermaid/index.d.ts +10 -0
- package/dist/lib/mermaid/pan-zoom.d.ts +19 -0
- package/dist/lib/mermaid/utils.d.ts +41 -0
- package/dist/lib/parse-blocks.d.ts +12 -0
- package/dist/lib/plugin-context.d.ts +29 -0
- package/dist/lib/plugin-types.d.ts +156 -0
- package/dist/lib/prefix-context.d.ts +12 -0
- package/dist/lib/preprocess-custom-tags.d.ts +19 -0
- package/dist/lib/preprocess-literal-tag-content.d.ts +24 -0
- package/dist/lib/rehype/literal-tag-content.d.ts +12 -0
- package/dist/lib/rehype/markdown-in-custom-tags.d.ts +16 -0
- package/dist/lib/remark/code-meta.d.ts +9 -0
- package/dist/lib/remark/container-alerts.d.ts +60 -0
- package/dist/lib/remark/escape-html.d.ts +3 -0
- package/dist/lib/remark/github-alerts.d.ts +16 -0
- package/dist/lib/scroll-lock.d.ts +2 -0
- package/dist/lib/scrollable.d.ts +7 -0
- package/dist/lib/streamdown-context.d.ts +107 -0
- package/dist/lib/table/copy-dropdown.d.ts +8 -0
- package/dist/lib/table/download-dropdown.d.ts +16 -0
- package/dist/lib/table/fullscreen-button.d.ts +8 -0
- package/dist/lib/table/index.d.ts +10 -0
- package/dist/lib/table/utils.d.ts +9 -0
- package/dist/lib/tailwind-classes.d.ts +2 -4
- package/dist/lib/tailwind-classes.js +1 -1
- package/dist/lib/translations-context.d.ts +39 -0
- package/dist/lib/utils.d.ts +23 -0
- package/dist/mermaid-L7RAWDBU.js +2 -0
- package/package.json +9 -6
- package/styles.css +28 -0
- package/dist/chunk-TA335CDR.js +0 -27
- package/dist/highlighted-body-7HCBLPPD.js +0 -2
- package/dist/mermaid-36ZAAFZN.js +0 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {createContext,memo,useContext,useRef,useEffect,useMemo,lazy,isValidElement,useId,useDeferredValue,cloneElement,createElement,useState,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import jo from'rehype-raw';import vr,{defaultSchema}from'rehype-sanitize';import Bi from'remark-gfm';import Oi from'remend';import {visitParents,SKIP}from'unist-util-visit-parents';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import Ks from'remark-parse';import Xs from'remark-rehype';import {unified}from'unified';import {visit,SKIP as SKIP$1}from'unist-util-visit';import {Lexer}from'marked';var Hr=300,Dr="300px",Br=500;function no(e={}){let{immediate:t=false,debounceDelay:o=Hr,rootMargin:n=Dr,idleTimeout:r=Br}=e,[s,a]=useState(false),l=useRef(null),i=useRef(null),c=useRef(null),d=useMemo(()=>m=>{let f=Date.now();return window.setTimeout(()=>{m({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-f))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(m,f)=>window.requestIdleCallback(m,f):d,[d]),u=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?m=>window.cancelIdleCallback(m):m=>{clearTimeout(m);},[]);return useEffect(()=>{if(t){a(true);return}let m=l.current;if(!m)return;i.current&&(clearTimeout(i.current),i.current=null),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);},b=y=>{c.current=p(I=>{I.timeRemaining()>0||I.didTimeout?(a(true),y.disconnect()):c.current=p(()=>{a(true),y.disconnect();},{timeout:r/2});},{timeout:r});},h=y=>{f(),i.current=window.setTimeout(()=>{var S,x;let I=y.takeRecords();(I.length===0||(x=(S=I.at(-1))==null?void 0:S.isIntersecting)!=null&&x)&&b(y);},o);},g=(y,I)=>{y.isIntersecting?h(I):f();},w=new IntersectionObserver(y=>{for(let I of y)g(I,w);},{rootMargin:n,threshold:0});return w.observe(m),()=>{i.current&&clearTimeout(i.current),c.current&&u(c.current),w.disconnect();}},[t,o,n,r,u,p]),{shouldRender:s,containerRef:l}}function vt(){return {current:0}}var so=/\s/,ro=/^\s+$/,_r=new Set(["code","pre","svg","math","annotation"]),jr=new Set(["svg","math","annotation"]),Fr=new Set(["img","hr"]),Ve=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",ao=(e,t)=>{let o=t?jr:_r;return e.some(n=>Ve(n)&&o.has(n.tagName))},$r=e=>{for(let t=e.length-1;t>=0;t--){let o=e[t];if(Ve(o)&&o.tagName==="li")return o}},zr=(e,t,o,n)=>{(e.properties)!=null||(e.properties={}),e.properties["data-sd-animate-marker"]=true,e.properties.style=`--sd-marker-duration:${t}ms;--sd-marker-delay:${o}ms;--sd-marker-easing:${n}`;},Wr=new Set(["ul","ol","li"]),io=e=>{for(let t of e.children)if(Ve(t)){if(t.tagName==="input")return t;if(Wr.has(t.tagName))continue;let o=io(t);if(o)return o}},lo=(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`;},qr=(e,t,o,n)=>{let r=io(e);r&&lo(r,t,o,n);},Zr=(e,t,o,n,r)=>{if(ao(t,n.animateCodeBlocks))return;let s=n.prevContentLength,a=s>0&&r.count<s,l=a?0:(n.startIndex+r.newIndex++)*o.stagger;lo(e,o,a?0:o.duration,l);},Kr=e=>{let t=[],o="",n=false;for(let r of e){let s=so.test(r);s!==n&&o&&(t.push(o),o=""),o+=r,n=s;}return o&&t.push(o),t},Xr=e=>{let t=[],o="";for(let n of e)so.test(n)?o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&t.push(o),t},Gr=(e,t,o,n,r,s)=>{let a=`--sd-animation:sd-${t};--sd-duration:${r?0:o}ms;--sd-easing:${n}`;return s&&(a+=`;--sd-delay:${s}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:a},children:[{type:"text",value:e}]}},Ur=(e,t,o,n,r)=>{var g;let s=t.at(-1);if(!(s&&"children"in s))return;if(ao(t,n.animateCodeBlocks))return SKIP;let a=s,l=a.children.indexOf(e);if(l===-1)return;let i=e.value;if(!i.trim()){r.count+=i.length;return}let c=o.sep==="char"?Xr(i):Kr(i),d=t.some(w=>Ve(w)&&w.tagName==="a"),p=c;if(o.sep==="word"&&d){let w=[];for(let y of c)ro.test(y)&&w.length>0?w[w.length-1]+=y:w.push(y);p=w;}let u=n.prevContentLength,m=$r(t),f=!!(m&&!((g=m.properties)!=null&&g["data-sd-animate-marker"])),b=false,h=p.map(w=>{let y=r.count;if(r.count+=w.length,ro.test(w))return {type:"text",value:w};let I=u>0&&y<u,P=I?0:(n.startIndex+r.newIndex++)*o.stagger;if(m&&f&&!b){let S=I?0:o.duration;zr(m,S,P,o.easing),qr(m,o,S,P),b=true;}return Gr(w,o.animation,o.duration,o.easing,I,P)});return a.children.splice(l,1,...h),l+h.length},Jr=0;function _e(e){var s,a,l,i,c;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",cursor:e==null?void 0:e.cursor,duration:(a=e==null?void 0:e.duration)!=null?a:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(c=e==null?void 0:e.stagger)!=null?c:40},o={animateCodeBlocks:false,prevContentLength:0,lastRenderCharCount:0,lastRenderNewWordCount:0,startIndex:0},n=Jr++,r=()=>d=>{let p={count:0,newIndex:0};t.cursor&&(o.startIndex=t.cursor.current),visitParents(d,u=>u.type==="text"||Ve(u)&&Fr.has(u.tagName),(u,m)=>{if(u.type==="text")return Ur(u,m,t,o,p);Zr(u,m,t,o,p);}),o.lastRenderCharCount=p.count,o.lastRenderNewWordCount=p.newIndex,t.cursor&&(t.cursor.current+=p.newIndex),o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setAnimateCodeBlocks(d){o.animateCodeBlocks=d;},setPrevContentLength(d){o.prevContentLength=d;},setStartIndex(d){o.startIndex=d;},getLastRenderCharCount(){let d=o.lastRenderCharCount;return o.lastRenderCharCount=0,d},getLastRenderNewWordCount(){let d=o.lastRenderNewWordCount;return o.lastRenderNewWordCount=0,d}}}_e();var Pt=createContext(false),Tt=()=>useContext(Pt);var je=(...e)=>twMerge(clsx(e)),ot=e=>{if(e!==void 0)return typeof e=="number"?!Number.isFinite(e)||e<=0?void 0:`${e}px`:e},es=(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(" ")},uo=e=>e?(...t)=>es(e,twMerge(clsx(t))):je,oe=(e,t,o)=>{let n=typeof t=="string"&&o.startsWith("text/csv")?"\uFEFF":"",r=typeof t=="string"?new Blob([n+t],{type:o}):t,s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s);};var nt=createContext(je),C=()=>useContext(nt);var Fe=({scrollRef:e,...t})=>jsx("div",{ref:e,...t});var as=je("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"),is=e=>{let t={};for(let o of e.split(";")){let n=o.indexOf(":");if(n>0){let r=o.slice(0,n).trim(),s=o.slice(n+1).trim();r&&s&&(t[r]=s);}}return t},go=memo(({children:e,result:t,language:o,className:n,maxHeight:r,startLine:s,lineNumbers:a=true,...l})=>{let i=C(),{isAnimating:c,scrollable:d}=useContext(R),p=d!=null?d:Fe,u=useRef(null),m=useRef(true),f=ot(r);useEffect(()=>{let g=u.current;if(!(g&&f))return;let w=()=>{let y=g.scrollHeight-g.scrollTop-g.clientHeight<8;m.current=y;};return g.addEventListener("scroll",w,{passive:true}),()=>g.removeEventListener("scroll",w)},[f]),useEffect(()=>{let g=u.current;g&&f&&c&&m.current&&g.scrollTo({top:g.scrollHeight,behavior:"instant"});},[c,f]),useEffect(()=>{c||(m.current=true);},[c]);let b=useMemo(()=>i(as),[i]),h=useMemo(()=>{let g={};return t.bg&&(g["--sdm-bg"]=t.bg),t.fg&&(g["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(g,is(t.rootStyle)),g},[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:a?i("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&s&&s>1?{counterReset:`line ${s-1}`}:void 0,children:t.tokens.map((g,w)=>jsx("span",{className:a?b:void 0,children:g.length===0||g.length===1&&g[0].content===""?`
|
|
3
|
+
`:g.map((y,I)=>{let P={},S=!!y.bgColor;if(y.color&&(P["--sdm-c"]=y.color),y.bgColor&&(P["--sdm-tbg"]=y.bgColor),y.htmlStyle)for(let[x,j]of Object.entries(y.htmlStyle))x==="color"?P["--sdm-c"]=j:x==="background-color"?(P["--sdm-tbg"]=j,S=true):P[x]=j;return jsx("span",{className:i("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",S&&"bg-[var(--sdm-tbg)]",S&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:P,...y.htmlAttrs,children:y.content},I)})},w))})})})},(e,t)=>e.maxHeight===t.maxHeight&&e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers);var Mt=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let s=C();return jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r})};var Rt=createContext({code:""}),rt=()=>useContext(Rt);var St=({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 fs=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
|
+
`;)t--;return e.slice(0,t)},gs=lazy(()=>import('./highlighted-body-5PIGDDHF.js').then(e=>({default:e.HighlightedCodeBlockBody}))),Lt=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,lineNumbers:a,...l})=>{let i=C(),{codeBlockMaxHeight:c}=useContext(R),d=useMemo(()=>fs(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(Rt.Provider,{value:{code:e},children:jsxs(Mt,{isIncomplete:r,language:t,children:[jsx(St,{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(go,{className:o,language:t,lineNumbers:a,maxHeight:c,result:p,startLine:s,...l}),children:jsx(gs,{className:o,code:d,language:t,lineNumbers:a,maxHeight:c,raw:p,startLine:s,...l})})]})})};var yo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),Co=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),wo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),ko=e=>jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),xo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),vo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),Po=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),To=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),Io=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),Mo=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var ze={CheckIcon:yo,CopyIcon:Co,DownloadIcon:wo,ExternalLinkIcon:To,Loader2Icon:ko,Maximize2Icon:xo,RotateCcwIcon:vo,XIcon:Po,ZoomInIcon:Io,ZoomOutIcon:Mo},So=createContext(ze),ws=(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])},Nt=({icons:e,children:t})=>{let o=useRef(e),n=useRef(e?{...ze,...e}:ze);ws(o.current,e)||(o.current=e,n.current=e?{...ze,...e}:ze);let r=n.current;return jsx(So.Provider,{value:r,children:t})},O=()=>useContext(So);var st={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",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"},at=createContext(st),_=()=>useContext(at);var it=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let l=C(),[i,c]=useState(false),d=useRef(0),{code:p}=rt(),{isAnimating:u}=useContext(R),m=_(),f=s!=null?s:p,b=async()=>{var w;if(typeof window=="undefined"||!((w=navigator==null?void 0:navigator.clipboard)!=null&&w.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(f),c(!0),e==null||e(),d.current=window.setTimeout(()=>c(!1),o));}catch(y){t==null||t(y);}};useEffect(()=>()=>{window.clearTimeout(d.current);},[]);let h=O(),g=i?h.CheckIcon:h.CopyIcon;return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:u,onClick:b,title:m.copyCode,type:"button",...a,children:n!=null?n:jsx(g,{size:14})})};var No={"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"},Et=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let l=C(),{code:i}=rt(),{isAnimating:c}=useContext(R),d=_(),p=O(),u=s!=null?s:i,f=`file.${o&&o in No?No[o]:"txt"}`,b="text/plain",h=()=>{try{oe(f,u,b),e==null||e();}catch(g){t==null||t(g);}};return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:c,onClick:h,title:d.downloadFile,type:"button",...a,children:n!=null?n:jsx(p.DownloadIcon,{size:14})})};var lt=()=>{let{Loader2Icon:e}=O(),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 We=0,ge=()=>{We+=1,We===1&&(document.body.style.overflow="hidden");},be=()=>{We=Math.max(0,We-1),We===0&&(document.body.style.overflow="");};var Ns=["github-light","github-dark"],Es={enabled:true},As={codeBlockMaxHeight:400,shikiTheme:Ns,controls:true,isAnimating:false,lineNumbers:true,listStyle:"hierarchical",mode:"streaming",mermaid:void 0,linkSafety:Es,tableMaxHeight:300},R=createContext(As);var Os=/\.[^/.]+$/,Ho=(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},Do=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,onClick:a,...l})=>{let{DownloadIcon:i,XIcon:c}=O(),d=C(),p=useRef(null),[u,m]=useState(false),[f,b]=useState(false),[h,g]=useState(false),{controls:w}=useContext(R),y=_(),I=Ho(w,"download"),P=Ho(w,"fullscreen"),S=l.width!=null||l.height!=null,x=I&&(u||S)&&!f,j=f&&!S,B=P&&!!o&&!f&&u;useEffect(()=>{let L=p.current;if(L!=null&&L.complete){let Q=L.naturalWidth>0;m(Q),b(!Q);}},[]),useEffect(()=>{if(!h)return;ge();let L=Q=>{Q.key==="Escape"&&g(false);};return document.addEventListener("keydown",L),()=>{document.removeEventListener("keydown",L),be();}},[h]);let W=useCallback(L=>{m(true),b(false),r==null||r(L);},[r]),V=useCallback(L=>{m(false),b(true),s==null||s(L);},[s]),A=useCallback(()=>{B&&g(true);},[B]),F=useCallback(()=>{g(false);},[]),J=useCallback(L=>{a==null||a(L),!L.defaultPrevented&&A();},[a,A]),U=async L=>{if(L.stopPropagation(),!!o)try{let pe=await(await fetch(o)).blob(),ee=new URL(o,window.location.origin).pathname.split("/").pop()||"",Y=ee.split(".").pop(),re=ee.includes(".")&&Y!==void 0&&Y.length<=4,q="";if(re)q=ee;else {let T=pe.type,H="png";T.includes("jpeg")||T.includes("jpg")?H="jpg":T.includes("png")?H="png":T.includes("svg")?H="svg":T.includes("gif")?H="gif":T.includes("webp")&&(H="webp"),q=`${(n||ee||"image").replace(Os,"")}.${H}`;}oe(q,pe,pe.type);}catch(Q){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",B&&"cursor-zoom-in",j&&"hidden",t),"data-streamdown":"image",onClick:J,onError:V,onLoad:W,ref:p,src:o,...l}),j&&jsx("span",{className:d("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:y.imageNotAvailable}),x&&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:U,title:y.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:F,onKeyDown:L=>{L.key==="Escape"&&F();},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:F,title:y.exitFullscreen,type:"button",children:jsx(c,{size:20})}),jsx("div",{onClick:L=>L.stopPropagation(),onKeyDown:L=>L.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 Vo=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=O(),i=C(),[c,d]=useState(false),p=_(),u=useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(b){}},[e]),m=useCallback(()=>{n(),o();},[n,o]);if(useEffect(()=>{if(t){ge();let b=h=>{h.key==="Escape"&&o();};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),be();}}},[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:b=>{b.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:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:[jsx("button",{className:i("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:o,title:p.close,type:"button",children:jsx(l,{size:16})}),jsxs("div",{className:i("flex flex-col gap-2"),children:[jsxs("div",{className:i("flex items-center gap-2 font-semibold text-lg"),children:[jsx(a,{size:20}),jsx("span",{children:p.openExternalLink})]}),jsx("p",{className:i("text-muted-foreground text-sm"),children:p.externalLinkWarning})]}),jsx("div",{className:i("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:i("flex gap-2"),children:[jsx("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:u,type:"button",children:c?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:p.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:p.copyLink})]})}),jsxs("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:m,type:"button",children:[jsx(a,{size:14}),jsx("span",{children:p.openLink})]})]})]})});return createPortal(f,document.body)};var _o=()=>e=>{visit(e,"html",(o,n,r)=>{!r||typeof n!="number"||(r.children[n]={type:"text",value:o.value});});};var Fo=[],$o={allowDangerousHtml:true},ct=new WeakMap,Ot=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let o=this.keyCache.get(t);if(o)return o;let n=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||r||s)){let p="default";return this.keyCache.set(t,p),p}let a=p=>{if(!p||p.length===0)return "";let u="";for(let m=0;m<p.length;m+=1){let f=p[m];if(m>0&&(u+=","),Array.isArray(f)){let[b,h]=f;if(typeof b=="function"){let g=ct.get(b);g||(g=b.name,ct.set(b,g)),u+=g;}else u+=String(b);u+=":",u+=JSON.stringify(h);}else if(typeof f=="function"){let b=ct.get(f);b||(b=f.name,ct.set(f,b)),u+=b;}else u+=String(f);}return u},l=a(n),i=a(r),c=s?JSON.stringify(s):"",d=`${i}::${l}::${c}`;return this.keyCache.set(t,d),d}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(n,o);}clear(){this.cache.clear();}},zo=new Ot,Ze=e=>{let t=Js(e),o=e.children||"",n=t.runSync(t.parse(o),o);return na(n,e)},Js=e=>{let t=zo.get(e);if(t)return t;let o=Qs(e);return zo.set(e,o),o},Ys=e=>e.some(t=>Array.isArray(t)?t[0]===jo:t===jo),Qs=e=>{let t=e.rehypePlugins||Fo,o=e.remarkPlugins||Fo,n=Ys(t)?o:[...o,_o],r=e.remarkRehypeOptions?{...$o,...e.remarkRehypeOptions}:$o;return unified().use(Ks).use(n).use(Xs,r).use(t)},Wo=e=>e,ea=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},ta=(e,t)=>{var o;for(let n in urlAttributes)if(Object.hasOwn(urlAttributes,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],s=urlAttributes[n];(s===null||s.includes(e.tagName))&&(e.properties[n]=(o=t(String(r||""),n,e))!=null?o:void 0);}},oa=(e,t,o,n,r,s)=>{let a=false;return n?a=!n.includes(e.tagName):r&&(a=r.includes(e.tagName)),!a&&s&&typeof t=="number"&&(a=!s(e,t,o)),a},na=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:l}=t;if(o||n||r||s||l){let c=l||Wo;visit(e,(d,p,u)=>{if(d.type==="raw"&&u&&typeof p=="number")return ea(u,p,s,d.value),p;if(d.type==="element"&&(ta(d,c),oa(d,p,u,n,r,o)&&u&&typeof p=="number"))return a&&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 dt=createContext(null),Vt=()=>useContext(dt),Zc=()=>{var t;let e=Vt();return (t=e==null?void 0:e.code)!=null?t:null},Ee=()=>{var t;let e=Vt();return (t=e==null?void 0:e.mermaid)!=null?t:null};var qo=e=>{var o;let t=Vt();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 aa=/(<svg\b)/,Xo=/<svg\b[^>]*>/i,ia=/\bviewBox=(['"])(.*?)\1/i,la=/\swidth=(['"]).*?\1/i,ca=/\sheight=(['"]).*?\1/i,Zo=/\sstyle=(['"])(.*?)\1/i,Ko=/^<svg/i,da=/^width\s*:/i,ma=/^height\s*:/i,ua=/^max-width\s*:/i,pa=/[\s,]+/,fa=e=>!e.includes("xlink:")||e.includes("xmlns:xlink")?e:e.replace(aa,'$1 xmlns:xlink="http://www.w3.org/1999/xlink"'),Go=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},_t=e=>{let t=e.match(Xo);if(!t)return null;let n=t[0].match(ia),r=n==null?void 0:n[2];if(!r)return null;let s=r.trim().split(pa).map(i=>Number.parseFloat(i));if(s.length<4||s.slice(0,4).some(Number.isNaN))return null;let a=s[2],l=s[3];return a>0&&l>0?{height:l,width:a}:null},Uo=e=>{let t=e.match(Xo);if(!t)return e;try{let o=t[0],n=_t(e);if(!n)return e;let{width:r,height:s}=n,a=o.replace(la,"").replace(ca,""),l=a.match(Zo),i=`width:${r}px;height:${s}px;max-width:none;`;if(l){let c=l[1],p=l[2].split(";").map(m=>m.trim()).filter(Boolean).filter(m=>!(da.test(m)||ma.test(m)||ua.test(m))).join(";"),u=`${i}${p?`${p};`:""}`;a=a.replace(Zo,` style=${c}${u}${c}`);}else a=a.replace(Ko,`<svg style="${i}"`);return a=a.replace(Ko,`<svg width="${r}" height="${s}"`),e.replace(o,a)}catch(o){return e}},Jo=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a=fa(e),l="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a))),i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let c=document.createElement("canvas"),d=i.width*o,p=i.height*o;c.width=d,c.height=p;let u=c.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(i,0,0,d,p),c.toBlob(m=>{if(!m){s(new Error("Failed to create PNG blob"));return}r(m);},"image/png");},i.onerror=()=>s(new Error("Failed to load SVG image")),i.src=l;})};var mt=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=C(),[l,i]=useState(false),c=useRef(null),{isAnimating:d}=useContext(R),p=O(),u=Ee(),m=_(),f=async b=>{try{if(b==="mmd"){oe("diagram.mmd",e,"text/plain"),i(!1),n==null||n(b);return}if(!u){s==null||s(new Error("Mermaid plugin not available"));return}let h=u.getMermaid(r),g=e.split("").reduce((P,S)=>(P<<5)-P+S.charCodeAt(0)|0,0),w=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:y}=await h.render(w,e);if(!y){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}let I=Go(y);if(b==="svg"){oe("diagram.svg",I,"image/svg+xml"),i(!1),n==null||n(b);return}if(b==="png"){let P=await Jo(I);oe("diagram.png",P,"image/png"),n==null||n(b),i(!1);return}}catch(h){s==null||s(h);}};return useEffect(()=>{let b=h=>{let g=h.composedPath();c.current&&!g.includes(c.current)&&i(false);};return document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b);}},[]),jsxs("div",{className:a("relative"),ref:c,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:d,onClick:()=>i(!l),title:m.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{size:14})}),l?jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("svg"),title:m.downloadDiagramAsSvg,type:"button",children:m.mermaidFormatSvg}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("png"),title:m.downloadDiagramAsPng,type:"button",children:m.mermaidFormatPng}),jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("mmd"),title:m.downloadDiagramAsMmd,type:"button",children:m.mermaidFormatMmd})]}):null]})};var tn=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=O(),i=C(),[c,d]=useState(false),{isAnimating:p,controls:u}=useContext(R),m=_(),f=(()=>{if(typeof u=="boolean")return u;let g=u.mermaid;return g===false?false:g===true||g===void 0?true:g.panZoom!==false})(),b=(()=>{if(typeof u=="boolean")return u;let g=u.mermaid;return g===false?false:g===true||g===void 0?true:g.download!==false})(),h=()=>{d(!c);};return useEffect(()=>{if(c){ge();let g=w=>{w.key==="Escape"&&d(false);};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),be();}}},[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:h,title:m.viewFullscreen,type:"button",...s,children:jsx(a,{size:14})}),c?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:g=>{g.key==="Escape"&&h();},role:"dialog",children:[jsxs("div",{className:i("absolute top-4 right-4 z-10 flex items-center gap-1"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:[b?jsx(mt,{chart:e,config:t}):null,jsx("button",{className:i("rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:m.exitFullscreen,type:"button",children:jsx(l,{size:20})})]}),jsx("div",{className:i("flex size-full items-center justify-center p-4"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:jsx(en,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:f})})]}),document.body):null]})};var Ae=e=>{var s,a;let t=[],o=[],n=e.querySelectorAll("thead th");for(let l of n)t.push(((s=l.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let l of r){let i=[],c=l.querySelectorAll("td");for(let d of c)i.push(((a=d.textContent)==null?void 0:a.trim())||"");o.push(i);}return {headers:t,rows:o}},Se=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false,c=false;for(let d of l){if(d==='"'){i=true,c=true;break}(d===","||d===`
|
|
6
|
+
`)&&(i=true);}return i?c?`"${l.replace(/"/g,'""')}"`:`"${l}"`:l},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(","),a+=1);for(let l of o)s[a]=l.map(n).join(","),a+=1;return s.join(`
|
|
7
|
+
`)},Ft=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false;for(let d of l)if(d===" "||d===`
|
|
8
|
+
`||d==="\r"){i=true;break}if(!i)return l;let c=[];for(let d of l)d===" "?c.push("\\t"):d===`
|
|
9
|
+
`?c.push("\\n"):d==="\r"?c.push("\\r"):c.push(d);return c.join("")},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(" "),a+=1);for(let l of o)s[a]=l.map(n).join(" "),a+=1;return s.join(`
|
|
10
|
+
`)},ut=e=>{let t=false;for(let n of e)if(n==="\\"||n==="|"){t=true;break}if(!t)return e;let o=[];for(let n of e)n==="\\"?o.push("\\\\"):n==="|"?o.push("\\|"):o.push(n);return o.join("")},Le=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),r=0,s=t.map(l=>ut(l));n[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let l=0;l<t.length;l+=1)a[l]="---";n[r]=`| ${a.join(" | ")} |`,r+=1;for(let l of o)if(l.length<t.length){let i=new Array(t.length);for(let c=0;c<t.length;c+=1)i[c]=c<l.length?ut(l[c]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(c=>ut(c));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
|
|
11
|
+
`)};var Ge=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=C(),[a,l]=useState(false),[i,c]=useState(false),d=useRef(null),p=useRef(0),{isAnimating:u}=useContext(R),m=_(),f=async g=>{var w,y;if(typeof window=="undefined"||!((w=navigator==null?void 0:navigator.clipboard)!=null&&w.write)){n==null||n(new Error("Clipboard API not available"));return}try{let I=(y=d.current)==null?void 0:y.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),P=I==null?void 0:I.querySelector("table");if(!P){n==null||n(new Error("Table not found"));return}let S=Ae(P),B=({csv:Se,tsv:Ft,md:Le}[g]||Le)(S),W=new ClipboardItem({"text/plain":new Blob([B],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([W]),c(!0),l(!1),o==null||o(g),p.current=window.setTimeout(()=>c(!1),r);}catch(I){n==null||n(I);}};useEffect(()=>{let g=w=>{let y=w.composedPath();d.current&&!y.includes(d.current)&&l(false);};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g),window.clearTimeout(p.current);}},[]);let b=O(),h=i?b.CheckIcon:b.CopyIcon;return jsxs("div",{className:s("relative"),ref:d,children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>l(!a),title:m.copyTable,type:"button",children:e!=null?e:jsx(h,{height:14,width:14})}),a?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("md"),title:m.copyTableAsMarkdown,type:"button",children:m.tableFormatMarkdown}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("csv"),title:m.copyTableAsCsv,type:"button",children:m.tableFormatCsv}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("tsv"),title:m.copyTableAsTsv,type:"button",children:m.tableFormatTsv})]}):null]})};var Ra=({children:e,className:t,onDownload:o,onError:n,format:r="csv",filename:s})=>{let a=C(),{isAnimating:l}=useContext(R),i=_(),c=O(),d=p=>{try{let m=p.currentTarget.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),f=m==null?void 0:m.querySelector("table");if(!f){n==null||n(new Error("Table not found"));return}let b=Ae(f),h="",g="",w="";switch(r){case "csv":h=Se(b),g="text/csv",w="csv";break;case "markdown":h=Le(b),g="text/markdown",w="md";break;default:h=Se(b),g="text/csv",w="csv";}oe(`${s||"table"}.${w}`,h,g),o==null||o();}catch(u){n==null||n(u);}};return jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:l,onClick:d,title:r==="csv"?i.downloadTableAsCsv:i.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(c.DownloadIcon,{size:14})})},Ue=({children:e,className:t,onDownload:o,onError:n})=>{let r=C(),[s,a]=useState(false),l=useRef(null),{isAnimating:i}=useContext(R),c=_(),d=O(),p=u=>{var m;try{let f=(m=l.current)==null?void 0:m.closest('[data-streamdown="table-wrapper"], [data-streamdown="table-fullscreen"]'),b=f==null?void 0:f.querySelector("table");if(!b){n==null||n(new Error("Table not found"));return}let h=Ae(b),g=u==="csv"?Se(h):Le(h);oe(`table.${u==="csv"?"csv":"md"}`,g,u==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(u);}catch(f){n==null||n(f);}};return useEffect(()=>{let u=m=>{let f=m.composedPath();l.current&&!f.includes(l.current)&&a(false);};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[]),jsxs("div",{className:r("relative"),ref:l,children:[jsx("button",{className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>a(!s),title:c.downloadTable,type:"button",children:e!=null?e:jsx(d.DownloadIcon,{size:14})}),s?jsxs("div",{className:r("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("csv"),title: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 ln=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=O(),a=C(),[l,i]=useState(false),{isAnimating:c}=useContext(R),d=_(),p=()=>{i(true);},u=()=>{i(false);};return useEffect(()=>{if(l){ge();let m=f=>{f.key==="Escape"&&i(false);};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),be();}}},[l]),jsxs(Fragment,{children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:p,title:d.viewFullscreen,type:"button",children:jsx(r,{size:14})}),l?createPortal(jsx("div",{"aria-label":d.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:u,onKeyDown:m=>{m.key==="Escape"&&u();},role:"dialog",children:jsxs("div",{className:a("flex h-full flex-col"),onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),role:"presentation",children:[jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[o?jsx(Ge,{}):null,n?jsx(Ue,{}):null,jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:u,title:d.exitFullscreen,type:"button",children:jsx(s,{size:20})})]}),jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:a("w-full table-fixed border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})};var mn=({children:e,className:t,maxHeight:o,showControls:n,showCopy:r=true,showDownload:s=true,showFullscreen:a=true,...l})=>{let i=C(),{isAnimating:c,scrollable:d}=useContext(R),p=d!=null?d:Fe,u=useRef(null),m=useRef(true),f=ot(o);useEffect(()=>{let y=u.current;if(!(y&&f))return;let I=()=>{let P=y.scrollHeight-y.scrollTop-y.clientHeight<8;m.current=P;};return y.addEventListener("scroll",I,{passive:true}),()=>y.removeEventListener("scroll",I)},[f]),useEffect(()=>{let y=u.current;y&&f&&c&&m.current&&y.scrollTo({top:y.scrollHeight,behavior:"instant"});}),useEffect(()=>{c||(m.current=true);},[c]);let b=n&&r,h=n&&s,g=n&&a,w=b||h||g;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:[w?jsxs("div",{className:i("flex items-center justify-end gap-1"),children:[b?jsx(Ge,{}):null,h?jsx(Ue,{}):null,g?jsx(ln,{showCopy:b,showDownload:h,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 _a=/startLine=(\d+)/,ja=/\bnoLineNumbers\b/,Fa=lazy(()=>import('./mermaid-L7RAWDBU.js').then(e=>({default:e.Mermaid}))),$a=/language-([^\s]+)/,ae=e=>e.props;function gt(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let o=e.position.start,n=t.position.start,r=e.position.end,s=t.position.end;return (o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(o==null?void 0:o.offset)===(n==null?void 0:n.offset)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)&&(r==null?void 0:r.offset)===(s==null?void 0:s.offset)}function D(e,t){return e.className===t.className&>(e.node,t.node)}var Zt=(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},pn=(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},pt=(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},Ye=createContext({depth:0,ulDepth:0,isUnordered:false}),za={flat:["list-disc"],hierarchical:["list-disc","list-[circle]","list-[square]"]},Kt=memo(({children:e,className:t,node:o,...n})=>{let r=C(),{depth:s,ulDepth:a}=useContext(Ye),l=useMemo(()=>({depth:s+1,ulDepth:a,isUnordered:false}),[s,a]);return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"ordered-list",...n,children:jsx(Ye.Provider,{value:l,children:e})})},(e,t)=>D(e,t));Kt.displayName="MarkdownOl";var hn=memo(({children:e,className:t,node:o,...n})=>{var b;let r=C(),{depth:s,ulDepth:a,isUnordered:l}=useContext(Ye),{listStyle:i}=useContext(R),c=za[i],d=l&&a>0?c[(a-1)%c.length]:void 0,p=Array.isArray(e)?e.filter(h=>h!==`
|
|
12
|
+
`&&h!==""):[e],u=p[0],m=isValidElement(u)?(b=ae(u).node)==null?void 0:b.tagName:void 0,f=p.length===1&&isValidElement(u)&&(u.type==="p"||m==="p")?ae(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":s>0?s-1:0,"data-streamdown":"list-item",...n,children:f}):jsx("li",{className:r("py-1 [&>p]:inline",d,t),"data-depth":s>0?s-1:0,"data-streamdown":"list-item",...n,children:f})},(e,t)=>e.className===t.className&>(e.node,t.node));hn.displayName="MarkdownLi";var yn=memo(({children:e,className:t,node:o,...n})=>{let r=C(),{depth:s,ulDepth:a}=useContext(Ye),l=useMemo(()=>({depth:s+1,ulDepth:a+1,isUnordered:true}),[s,a]);return jsx("ul",{className:r("list-inside whitespace-normal [li_&]:pl-6",t),"data-depth":s,"data-streamdown":"unordered-list",...n,children:jsx(Ye.Provider,{value:l,children:e})})},(e,t)=>D(e,t));yn.displayName="MarkdownUl";var Cn=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)=>D(e,t));Cn.displayName="MarkdownHr";var wn=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)=>D(e,t));wn.displayName="MarkdownStrong";var Wa=({children:e,className:t,href:o,node:n,...r})=>{let s=C(),{linkSafety:a}=useContext(R),[l,i]=useState(false),c=o==="streamdown:incomplete-link",d=useCallback(async f=>{if(!(!(a!=null&&a.enabled&&o)||c)){if(f.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[a,o,c]),p=useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),u=useCallback(()=>{i(false);},[]),m={url:o!=null?o:"",isOpen:l,onClose:u,onConfirm:p};return a!=null&&a.enabled&&o?jsxs(Fragment,{children:[jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",onClick:d,type:"button",children:e}),a.renderModal?a.renderModal(m):jsx(Vo,{...m})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},kn=memo(Wa,(e,t)=>D(e,t)&&e.href===t.href);kn.displayName="MarkdownA";var xn=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)=>D(e,t));xn.displayName="MarkdownH1";var vn=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)=>D(e,t));vn.displayName="MarkdownH2";var Pn=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)=>D(e,t));Pn.displayName="MarkdownH3";var Tn=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)=>D(e,t));Tn.displayName="MarkdownH4";var In=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)=>D(e,t));In.displayName="MarkdownH5";var Mn=memo(({children:e,className:t,node:o,...n})=>{let r=C();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>D(e,t));Mn.displayName="MarkdownH6";var Rn=memo(({children:e,className:t,node:o,...n})=>{let{controls:r,tableMaxHeight:s}=useContext(R),a=Zt(r,"table"),l=qt(r,"copy"),i=qt(r,"download"),c=qt(r,"fullscreen");return jsx(mn,{className:t,maxHeight:s,showControls:a,showCopy:l,showDownload:i,showFullscreen:c,...n,children:e})},(e,t)=>D(e,t));Rn.displayName="MarkdownTable";var Sn=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)=>D(e,t));Sn.displayName="MarkdownThead";var Ln=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)=>D(e,t));Ln.displayName="MarkdownTbody";var Nn=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)=>D(e,t));Nn.displayName="MarkdownTr";var En=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)=>D(e,t));En.displayName="MarkdownTh";var An=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)=>D(e,t));An.displayName="MarkdownTd";var Hn=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)=>D(e,t));Hn.displayName="MarkdownBlockquote";var Dn=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)=>D(e,t));Dn.displayName="MarkdownSup";var qa=()=>({}),Za=e=>{try{let t=atob(e),o=Uint8Array.from(t,n=>n.charCodeAt(0));return new TextDecoder().decode(o)}catch(t){return ""}},Bn=memo(({children:e,className:t,node:o,...n})=>{let r=C(),{calloutIcon:s,calloutStyle:a,components:l,remarkPlugins:i,rehypePlugins:c}=useContext(R),d=n,p=d["data-callout-title"],u=d["data-callout-color"],m=d["data-callout-icon"],f=d["data-callout-body"],b=f?Za(f):"",h=(a!=null?a:qa)(u),g=m&&s?s(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:[g,p]}):null,b.trim().length>0?jsx(Ze,{components:l,rehypePlugins:c,remarkPlugins:i,children:b}):null]})},(e,t)=>D(e,t));Bn.displayName="MarkdownCallout";var fn={"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"},On=memo(({children:e,className:t,node:o,...n})=>{let r=C(),s=t==null?void 0:t.includes("markdown-alert");if(t==null?void 0:t.includes("sdm-callout"))return jsx(Bn,{className:t,node:o,...n,children:e});if(s){let l=Object.keys(fn).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?fn[l]:null,t),...n,children:e})}return jsx("div",{className:r(t),...n,children:e})},(e,t)=>D(e,t));On.displayName="MarkdownDiv";var Vn=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)=>D(e,t));Vn.displayName="MarkdownSub";var _n=memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=i=>{if(!isValidElement(i))return false;let c=ae(i).children,d=Array.isArray(c)?c:[c],p=false,u=false;for(let m of d)if(m){if(typeof m=="string")m.trim()!==""&&(p=true);else if(isValidElement(m))if(ae(m)["data-footnote-backref"]!==void 0)u=true;else {let f=ae(m).children,b=Array.isArray(f)?f:[f];for(let h of b){if(typeof h=="string"&&h.trim()!==""){p=true;break}if(isValidElement(h)&&ae(h)["data-footnote-backref"]===void 0){p=true;break}}}}return u&&!p},a=Array.isArray(e)?e.map(i=>{if(!isValidElement(i))return i;if(i.type===Kt){let c=ae(i).children,p=(Array.isArray(c)?c:[c]).filter(u=>!s(u));return p.length===0?null:{...i,props:{...ae(i),children:p}}}return i}):e;return (Array.isArray(a)?a.some(i=>i!==null):a!==null)?jsx("section",{className:t,...n,children:a}):null}return jsx("section",{className:t,...n,children:e})},(e,t)=>D(e,t));_n.displayName="MarkdownSection";var Ka=({node:e,className:t,children:o,...n})=>{var B,W;let r=C(),s=!("data-block"in n),{mermaid:a,controls:l,lineNumbers:i}=useContext(R),c=Ee(),d=Tt(),p=t==null?void 0:t.match($a),u=(B=p==null?void 0:p.at(1))!=null?B:"",m=qo(u);if(s)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let f=(W=e==null?void 0:e.properties)==null?void 0:W.metastring,b=typeof f=="string"?f:void 0,h=b==null?void 0:b.match(_a),g=h?Number.parseInt(h[1],10):void 0,w=g!==void 0&&g>=1?g:void 0,I=!(b?ja.test(b):false)&&i!==false,P="";if(isValidElement(o)){let V=ae(o).children;typeof V=="string"&&(P=V);}else typeof o=="string"&&(P=o);if(m){let V=m.component;return jsx(Suspense,{fallback:jsx(lt,{}),children:jsx(V,{code:P,isIncomplete:d,language:u,meta:b})})}if(u==="mermaid"&&c){let V=Zt(l,"mermaid"),A=pt(l,"download"),F=pt(l,"copy"),J=pt(l,"fullscreen"),U=pt(l,"panZoom"),ie=V&&(A||F||J);return jsx(Suspense,{fallback:jsx(lt,{}),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"})}),ie?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:[A?jsx(mt,{chart:P,config:a==null?void 0:a.config}):null,F?jsx(it,{code:P}):null,J?jsx(tn,{chart:P,config:a==null?void 0:a.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(Fa,{chart:P,config:a==null?void 0:a.config,showControls:U})})]})})}let S=Zt(l,"code"),x=pn(l,"download"),j=pn(l,"copy");return jsx(Lt,{className:t,code:P,isIncomplete:d,language:u,lineNumbers:I,startLine:w,children:S?jsxs(Fragment,{children:[x?jsx(Et,{code:P,language:u}):null,j?jsx(it,{}):null]}):null})},jn=memo(Ka,(e,t)=>e.className===t.className&>(e.node,t.node));jn.displayName="MarkdownCode";var Fn=memo(Do,(e,t)=>e.className===t.className&>(e.node,t.node));Fn.displayName="MarkdownImg";var gn={caution:"alertCaution",important:"alertImportant",note:"alertNote",tip:"alertTip",warning:"alertWarning"},$n=memo(({children:e,className:t,node:o,...n})=>{let r=C(),s=_(),a=n["data-alert-type"],l=a&&a in gn?gn[a]:void 0,i=l?s[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)=>D(e,t));$n.displayName="MarkdownAlertTitle";var zn=memo(({children:e,className:t,node:o,...n})=>{if(t!=null&&t.includes("markdown-alert-title"))return jsx($n,{className:t,node:o,...n,children:e});let s=(Array.isArray(e)?e:[e]).filter(a=>a!=null&&a!=="");if(s.length===1&&isValidElement(s[0])){let a=ae(s[0]).node,l=a==null?void 0:a.tagName;if(l==="img")return jsx(Fragment,{children:e});if(l==="code"&&"data-block"in s[0].props)return jsx(Fragment,{children:e})}return jsx("p",{className:t,...n,children:e})},(e,t)=>D(e,t));zn.displayName="MarkdownParagraph";var Wn={ol:Kt,li:hn,ul:yn,hr:Cn,strong:wn,a:kn,h1:xn,h2:vn,h3:Pn,h4:Tn,h5:In,h6:Mn,table:Rn,thead:Sn,tbody:Ln,tr:Nn,th:En,td:An,blockquote:Hn,code:jn,div:On,img:Fn,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:Dn,sub:Vn,p:zn,section:_n};var Xa=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Ga=/\p{L}/u;function bt(e){let t=e.replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,"");for(let o of t){if(Xa.test(o))return "rtl";if(Ga.test(o))return "ltr"}return "ltr"}var Ua=/^[ \t]{0,3}(`{3,}|~{3,})/;var qn=e=>{let t=e.split(`
|
|
13
|
+
`),o=null,n=0;for(let r of t){let s=Ua.exec(r);if(o===null){if(s){let a=s[1];o=a[0],n=a.length;}}else if(s){let a=s[1],l=a[0],i=a.length;l===o&&i>=n&&(o=null,n=0);}}return o!==null};var Ya=/\[\^[\w-]{1,200}\](?!:)/,Qa=/\[\^[\w-]{1,200}\]:/;var ei=/<(\w+)[\s>]/,ti=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Zn=new Map,Kn=new Map,Un=e=>{let t=e.toLowerCase(),o=Zn.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Zn.set(t,n),n},oi=e=>{let t=e.toLowerCase(),o=Kn.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return Kn.set(t,n),n},Xn=(e,t)=>{if(ti.has(t.toLowerCase()))return 0;let o=e.match(Un(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},Gn=(e,t)=>{let o=e.match(oi(t));return o?o.length:0},ni=(e,t)=>{let o=e.match(Un(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},ht=e=>{let t=Ya.test(e),o=Qa.test(e);if(t||o)return [e];let n=Lexer.lex(e,{gfm:true}),r=[],s=[],a=false;for(let l of n){let i=l.raw,c=r.length;if(s.length>0){r[c-1]+=i;let d=s.at(-1),p=Xn(i,d),u=Gn(i,d);for(let m=0;m<p;m+=1)s.push(d);for(let m=0;m<u;m+=1)s.length>0&&s.at(-1)===d&&s.pop();continue}if(l.type==="html"&&l.block){let d=i.match(ei);if(d){let p=d[1],u=Xn(i,p),m=Gn(i,p);u>m&&!ni(i,p)&&s.push(p);}}if(c>0&&!a){let d=r[c-1];if(ri(d)%2===1){r[c-1]=d+i;continue}}r.push(i),l.type!=="space"&&(a=l.type==="code");}return r},Xt=(e,t,o=ht)=>{if(!(t!=null&&t.source&&e.startsWith(t.source)))return {source:e,blocks:o(e)};if(e===t.source)return t;if(t.blocks.length<=1)return {source:e,blocks:o(e)};let n=t.blocks.slice(0,-1),r=0;for(let i of n)r+=i.length;let s=e.slice(0,r);if(n.join("")!==s)return {source:e,blocks:o(e)};let a=e.slice(r),l=o(a);return {source:e,blocks:[...n,...l]}};var Jn=(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,(s,a)=>`<${n}${a}></${n}>`);}for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(s,a,l,i)=>{let c=l.includes(`
|
|
14
|
+
|
|
15
|
+
`),d=!l.startsWith(`
|
|
16
|
+
`),p=l.includes(`
|
|
17
|
+
`);if(!(c||d&&p))return a+l+i;let u=l.replace(/\n\n/g,`
|
|
18
|
+
<!---->
|
|
19
|
+
`),m=(u.startsWith(`
|
|
20
|
+
`)?"":`
|
|
21
|
+
`)+u+(u.endsWith(`
|
|
22
|
+
`)?"":`
|
|
23
|
+
`);return `${a}${m}${i}
|
|
24
|
+
|
|
25
|
+
`});}return o};var si=/([\\`*_~[\]|])/g,ai=e=>e.replace(si,"\\$1"),Yn=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(s,a,l,i)=>{let c=ai(l).replace(/\n\n/g," ");return a+c+i});}return o};var Qn=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(Qn).join(""):"",er=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=Qn(n);n.children=r?[{type:"text",value:r}]:[];}});};var ui=e=>e.children.every(t=>t.type==="text"||t.type==="comment"),pi=e=>e.children.map(t=>t.type==="text"?t.value:"").join(""),fi=e=>{let t=unified().use(Ks).use(Xs,{allowDangerousHtml:true}),o=t.parse(e);return t.runSync(o).children},tr=(e,t=[])=>o=>{if(!e||e.length===0)return;let n=new Set(e.map(s=>s.toLowerCase())),r=new Set((t!=null?t:[]).map(s=>s.toLowerCase()));visit(o,"element",s=>{let a=s.tagName.toLowerCase();if(!n.has(a)||r.has(a)||!ui(s))return;let l=pi(s);if(!l.includes(`
|
|
26
|
+
`))return;let i=fi(l);s.children=i;});};var or=()=>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 nr=/^>>>[ \t]?(.*)$/,bi=/^<<<\s*$/,hi=/^>+\s*$/,yi=/^<+\s*$/,Ci=/^\s*(?:\((?<iconParen>[a-z0-9-]+)\)|\{(?<iconBrace>[a-z0-9-]+)\}(?=\s*\[))?\s*(?:\[(?<title>[^\]]*)\])?\s*(?:\{(?<color>[^}]*)\})?\s*$/i,wi=/^(?:#[0-9a-f]{3,8}|[a-z]+)$/i,ki=/^[a-z0-9-]+$/,xi=e=>{let t=Ci.exec(e);if(!(t!=null&&t.groups))return {};let{iconParen:o,iconBrace:n,title:r,color:s}=t.groups,a=o!=null?o:n;return {icon:a&&ki.test(a)?a:void 0,title:r!==void 0&&r.length>0?r:void 0,color:s&&wi.test(s)?s:void 0}},Gt=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),vi=e=>{let t=new TextEncoder().encode(e),o="";for(let n of t)o+=String.fromCharCode(n);return btoa(o)},Pi=(e,t)=>{var c;let o=nr.exec(e[t]),n=(c=o==null?void 0:o[1])!=null?c:"",r=xi(n),s=[],a=t+1;for(;a<e.length;a+=1){let d=e[a];if(bi.test(d)){a+=1;break}if(hi.test(d)||yi.test(d)){a+=1;break}s.push(d);}let l=s.join(`
|
|
27
|
+
`).trim();return {replacement:`<div ${['class="sdm-callout"',r.title!==void 0?`data-callout-title="${Gt(r.title)}"`:"",r.color!==void 0?`data-callout-color="${Gt(r.color)}"`:"",r.icon!==void 0?`data-callout-icon="${Gt(r.icon)}"`:"",`data-callout-body="${vi(l)}"`].filter(Boolean).join(" ")}></div>`,next:a}},rr=e=>{if(!e.includes(">>>"))return e;let t=e.split(`
|
|
28
|
+
`),o=[],n=0,r=false;for(;n<t.length;)if(nr.test(t[n])){let s=Pi(t,n);o.push(s.replacement),n=s.next,r=true;}else o.push(t[n]),n+=1;return r?o.join(`
|
|
29
|
+
`):e},sr=()=>()=>{};var Mi={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"}]}},Ri=/^\[!(note|tip|important|warning|caution)\][ \t]*(?:\n|$)/i,ar=e=>{if(e.type==="text")return e.value;let t=e.children;if(!t)return "";let o="";for(let n of t)o+=ar(n);return o},Si=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}}}},Li=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=ar(o).trimStart(),r=n.match(Ri);if(!r)return;let s=Mi[r[1].toUpperCase()],a=n.slice(r[0].length),l=t.children.slice(1);if(a.trim().length===0&&l.length===0&&e.children.length===1)return;let i=[Si(s)],c=[];a.length>0&&c.push({type:"text",value:a});let d=l;return ((p=d[0])==null?void 0:p.type)==="break"&&(d=d.slice(1)),c.push(...d),c.length>0&&c.some(m=>m.type!=="text"||m.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-${s.kind}`]},e.children=i,SKIP$1},ir=()=>e=>{visit(e,"blockquote",Li);};var Vi=/^[ \t]*<[\w!/?-]/,_i=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,ji=e=>typeof e!="string"||e.length===0||!Vi.test(e)?e:e.replace(_i,"$1"),mr,ur,pr,fr,gr,br,hr,yr,Cr,wr,kr,yt={...defaultSchema,clobberPrefix:"",protocols:{...defaultSchema.protocols,href:[...(ur=(mr=defaultSchema.protocols)==null?void 0:mr.href)!=null?ur:[],"tel"]},attributes:{...defaultSchema.attributes,code:["metastring",["className",/^(language-.+|math-display|math-inline)$/]],div:[...(fr=(pr=defaultSchema.attributes)==null?void 0:pr.div)!=null?fr:[],["className",/^(markdown-alert|markdown-alert-(note|tip|important|warning|caution)|sdm-callout)$/],"dataCalloutTitle","dataCalloutColor","dataCalloutIcon","dataCalloutBody"],p:[...(br=(gr=defaultSchema.attributes)==null?void 0:gr.p)!=null?br:[],["className",/^markdown-alert-title$/],"dataAlertType"],svg:[...(yr=(hr=defaultSchema.attributes)==null?void 0:hr.svg)!=null?yr:[],"className","viewBox","width","height","fill","ariaHidden"],path:[...(wr=(Cr=defaultSchema.attributes)==null?void 0:Cr.path)!=null?wr:[],"d","fillRule"]},tagNames:[...(kr=defaultSchema.tagNames)!=null?kr:[],"svg","path"]},Ut={raw:jo,sanitize:[vr,yt],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Fi={gfm:[Bi,{}],githubAlerts:ir,containerAlerts:sr,codeMeta:or},cr=Object.values(Ut),$i=Object.values(Fi),dr=new WeakMap;function zi(e){var r;let t=dr.get(e);if(t)return t;let o={...yt,tagNames:[...(r=yt.tagNames)!=null?r:[],...Object.keys(e)],attributes:{...yt.attributes,...e}},n=[Ut.raw,[vr,o],Ut.harden];return dr.set(e,n),n}var Wi={block:" \u258B",circle:" \u25CF"},qi=["github-light","github-dark"],Zi={enabled:true},Pr=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:o,index:n,isIncomplete:r,dir:s,animatePlugin:a,...l})=>{if(a){let d=a.getLastRenderCharCount();a.setPrevContentLength(d),a.setAnimateCodeBlocks(r);}let i=typeof e=="string"&&o?ji(e):e,c=jsx(Ze,{...l,children:i});return jsx(Pt.Provider,{value:r,children:s?jsx("div",{dir:s,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 s,a;return ((s=e.components)==null?void 0:s[r])!==((a=t.components)==null?void 0:a[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Pr.displayName="Block";var Ki=memo(({children:e,mode:t="streaming",dir:o,parseIncompleteMarkdown:n=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:a=cr,remarkPlugins:l=$i,className:i,shikiTheme:c=qi,mermaid:d,codeBlockMaxHeight:p=400,controls:u=true,isAnimating:m=false,scrollable:f,tableMaxHeight:b=300,animated:h,BlockComponent:g=Pr,parseMarkdownIntoBlocksFn:w=ht,caret:y,listStyle:I="hierarchical",calloutIcon:P,calloutStyle:S,plugins:x,remend:j,linkSafety:B=Zi,lineNumbers:W=true,allowedTags:V,literalTagContent:A,translations:F,icons:J,prefix:U,onAnimationStart:ie,onAnimationEnd:L,...Q})=>{var to;let pe=useId(),we=useMemo(()=>uo(U),[U]),ee=useRef(null),Y=useRef(ie),re=useRef(L);Y.current=ie,re.current=L,useEffect(()=>{var M,Z,K;if(t==="static")return;let k=ee.current;if(ee.current=m,k===null){m&&((M=Y.current)==null||M.call(Y));return}m&&!k?(Z=Y.current)==null||Z.call(Y):!m&&k&&((K=re.current)==null||K.call(re));},[m,t]);let q=useMemo(()=>V?Object.keys(V):[],[V]),T=useRef(null),H=useMemo(()=>{if(typeof e!="string")return "";let k=e;return A&&A.length>0&&(k=Yn(k,A)),q.length>0&&(k=Jn(k,q)),k=rr(k),k},[e,q,A]),$=useMemo(()=>{let k=t==="streaming"?T.current:null,M=Xt(H,k,w);if(T.current=t==="streaming"?M:null,!(t==="streaming"&&n)||M.blocks.length===0)return M.blocks;let Z=M.blocks.length-1,K=M.blocks[Z],fe=Oi(K,j);if(fe===K)return M.blocks;let Oe=M.blocks.slice();return Oe[Z]=fe,Oe},[H,w,t,n,j]),te=useMemo(()=>h===true?"true":h?JSON.stringify(h):"",[h]),le=useRef(null),ke=useRef([]),xe=useRef([]),Jt=useRef(null),Yt=useRef("");te?(Yt.current!==te&&(Yt.current=te,le.current=vt(),ke.current=[],xe.current=[]),le.current&&(le.current.current=0)):(le.current=null,ke.current=[],xe.current=[]);le.current?(to=ke.current[0])!=null?to:(()=>{var M;let k=_e({...te!=="true"?h:{},cursor:(M=le.current)!=null?M:void 0});return ke.current[0]=k,k})():null;let ve=useDeferredValue($),Pe=useMemo(()=>{if(t!=="streaming"||le.current||ve===$||ve.length===0)return $;let k=ve.length,M=$.length;if(M===0)return ve;if(k!==M)return $;for(let K=0;K<k-1;K+=1)if(ve[K]!==$[K])return $;let Z=ve.slice();return Z[k-1]=$[M-1],Z},[$,ve,t]),wt=useMemo(()=>o==="auto"?Pe.map(bt):void 0,[Pe,o]),Rr=useMemo(()=>Pe.map((k,M)=>`${pe}-${M}`),[Pe.length,pe]),Sr=useMemo(()=>F?JSON.stringify(F):"",[F]),Qt=useMemo(()=>({...st,...F}),[Sr]),et=useMemo(()=>{let{inlineCode:k,...M}=s!=null?s:{},Z={...Wn,...M};if(k){let K=Z.code;Z.code=fe=>"data-block"in fe?K?createElement(K,fe):null:createElement(k,fe);}return Z},[s]),tt=useMemo(()=>{let k=[];return x!=null&&x.cjk&&(k=[...k,...x.cjk.remarkPluginsBefore]),k=[...k,...l],x!=null&&x.cjk&&(k=[...k,...x.cjk.remarkPluginsAfter]),x!=null&&x.math&&(k=[...k,x.math.remarkPlugin]),k},[l,x==null?void 0:x.math,x==null?void 0:x.cjk]),Te=useMemo(()=>{let k=a;return V&&Object.keys(V).length>0&&a===cr&&(k=zi(V)),q.length>0&&(k=[...k,[tr,q,A!=null?A:[]]]),A&&A.length>0&&(k=[...k,[er,A]]),x!=null&&x.math&&(k=[...k,x.math.rehypePlugin]),k},[a,x==null?void 0:x.math,V,q,A]),eo=useMemo(()=>{var k,M;return {calloutIcon:P,calloutStyle:S,codeBlockMaxHeight:p,shikiTheme:(M=(k=x==null?void 0:x.code)==null?void 0:k.getThemes())!=null?M:c,controls:u,isAnimating:m,lineNumbers:W,listStyle:I,mode:t,mermaid:d,linkSafety:B,scrollable:f,tableMaxHeight:b,components:et,remarkPlugins:tt,rehypePlugins:Te}},[P,S,p,c,u,m,W,I,t,d,B,f,x==null?void 0:x.code,b,et,tt,Te]),Lr=useMemo(()=>y&&m?{"--streamdown-caret":`"${Wi[y]}"`}:void 0,[y,m]),Nr=k=>{let M=null;le.current&&m&&(ke.current[k]||(ke.current[k]=_e({...te!=="true"?h:{},cursor:le.current})),M=ke.current[k]),Jt.current!==Te&&(xe.current=[],Jt.current=Te),M&&!xe.current[k]&&(xe.current[k]=[...Te,M.rehypePlugin]);let Z=M&&xe.current[k]?xe.current[k]:Te;return {blockAnimatePlugin:M,blockRehypePlugins:Z}};return t==="static"?jsx(at.Provider,{value:Qt,children:jsx(dt.Provider,{value:x!=null?x:null,children:jsx(R.Provider,{value:eo,children:jsx(Nt,{icons:J,children:jsx(nt.Provider,{value:we,children:jsx("div",{className:we("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",i),dir:o==="auto"?bt(H):o,children:jsx(Ze,{components:et,rehypePlugins:Te,remarkPlugins:tt,...Q,children:H})})})})})})}):jsx(at.Provider,{value:Qt,children:jsx(dt.Provider,{value:x!=null?x:null,children:jsx(R.Provider,{value:eo,children:jsx(Nt,{icons:J,children:jsx(nt.Provider,{value:we,children:jsxs("div",{className:we("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",y?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,i),"data-streamdown":"container",style:Lr,children:[Pe.length===0&&y&&m&&jsx("span",{}),Pe.map((k,M)=>{var oo;let Z=M===Pe.length-1,K=m&&Z&&qn(k),{blockAnimatePlugin:fe,blockRehypePlugins:Oe}=Nr(M);return jsx(g,{animatePlugin:fe,components:et,content:k,dir:(oo=wt==null?void 0:wt[M])!=null?oo:o!=="auto"?o:void 0,index:M,isIncomplete:K,rehypePlugins:Oe,remarkPlugins:tt,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:n,...Q},Rr[M])})]})})})})})})},(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&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Ki.displayName="Streamdown";var Mr=({children:e,className:t,contentSize:o,fitKey:n,minZoom:r=.5,maxZoom:s=3,zoomStep:a=.1,showControls:l=true,initialZoom:i=1,isAutoFit:c=false,fullscreen:d=false})=>{let{RotateCcwIcon:p,ZoomInIcon:u,ZoomOutIcon:m}=O(),f=C(),b=useRef(null),h=useRef(null),[g,w]=useState(i),[y,I]=useState(r),[P,S]=useState(i),[x,j]=useState({x:0,y:0}),[B,W]=useState(false),[V,A]=useState(false),[F,J]=useState({x:0,y:0}),[U,ie]=useState({x:0,y:0}),L=useCallback(T=>{S(H=>Math.max(y,Math.min(s,H+T))),A(true);},[y,s]),Q=useCallback(()=>{L(a);},[L,a]),pe=useCallback(()=>{L(-a);},[L,a]),we=useCallback(()=>{S(g),j({x:0,y:0}),A(false);},[g]),ee=useCallback(T=>{T.preventDefault();let H=T.deltaY>0?-a:a;L(H);},[L,a]),Y=useCallback(T=>{if(T.button!==0||T.isPrimary===false)return;W(true),A(true),J({x:T.clientX,y:T.clientY}),ie(x);let H=T.currentTarget;H instanceof HTMLElement&&H.setPointerCapture(T.pointerId);},[x]),re=useCallback(T=>{if(!B)return;T.preventDefault();let H=T.clientX-F.x,$=T.clientY-F.y;j({x:U.x+H,y:U.y+$});},[B,F,U]),q=useCallback(T=>{W(false);let H=T.currentTarget;H instanceof HTMLElement&&H.releasePointerCapture(T.pointerId);},[]);return useEffect(()=>{I(r),c||(w(i),S(i));},[i,c,r]),useEffect(()=>{if(!(c&&o))return;let T=b.current;if(!T)return;let H=T.clientWidth,$=T.clientHeight;if(!(H>0&&$>0))return;let te=Math.min(H/o.width,$/o.height,1);!(te>0)||Number.isNaN(te)||(w(te),I(Math.min(r,te)),V||(S(te),j({x:0,y:0})));},[o,V,c,r]),useEffect(()=>{c&&A(false);},[c]),useEffect(()=>{let T=b.current;if(T)return T.addEventListener("wheel",ee,{passive:false}),()=>{T.removeEventListener("wheel",ee);}},[ee]),useEffect(()=>{let T=h.current;if(T&&B)return document.body.style.userSelect="none",T.addEventListener("pointermove",re,{passive:false}),T.addEventListener("pointerup",q),T.addEventListener("pointercancel",q),()=>{document.body.style.userSelect="",T.removeEventListener("pointermove",re),T.removeEventListener("pointerup",q),T.removeEventListener("pointercancel",q);}},[B,re,q]),jsxs("div",{className:f("relative flex flex-col",d?"h-full w-full":"min-h-28 w-full",t),ref:b,style:{cursor:B?"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",d?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{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:P>=s,onClick:Q,title:"Zoom in",type:"button",children:jsx(u,{size:16})}),jsx("button",{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:P<=y,onClick:pe,title:"Zoom out",type:"button",children:jsx(m,{size:16})}),jsx("button",{className:f("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:we,title:"Reset zoom and pan",type:"button",children:jsx(p,{size:16})})]}):null,jsx("div",{className:f("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:Y,ref:h,role:"application",style:{transform:`translate(${x.x}px, ${x.y}px) scale(${P})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var en=({chart:e,className:t,config:o,fullscreen:n=false,showControls:r=true})=>{let s=C(),[a,l]=useState(null),[i,c]=useState(false),[d,p]=useState(""),[u,m]=useState(null),[f,b]=useState(""),[h,g]=useState(0),{mermaid:w}=useContext(R),y=Ee(),I=w==null?void 0:w.errorComponent,{shouldRender:P,containerRef:S}=no({immediate:n});if(useEffect(()=>{if(!P)return;if(!y){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),c(!0);let B=y.getMermaid(o),W=e.split("").reduce((U,ie)=>(U<<5)-U+ie.charCodeAt(0)|0,0),V=`mermaid-${Math.abs(W)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:A}=await B.render(V,e),F=_t(A),J=n?A:Uo(A);p(J),m(F),b(J);}catch(B){if(!(f||d)){let W=B instanceof Error?B.message:"Failed to render Mermaid chart";l(W);}}finally{c(false);}})();},[e,o,h,P,y]),!(P||d||f))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:S});if(i&&!d&&!f)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:S,children:jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:s("text-sm"),children:"Loading diagram..."})]})});if(a&&!d&&!f){let j=()=>g(B=>B+1);return I?jsx("div",{ref:S,children:jsx(I,{chart:e,error:a,retry:j})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:S,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",a]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let x=d||f;return jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:S,children:jsx(Mr,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),contentSize:u,fitKey:e,fullscreen:n,isAutoFit:true,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:s("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:x},role:"img"})})})};export{Xt as A,ji as B,Ut as C,Fi as D,Pr as E,Ki as F,vt as a,_e as b,Tt as c,Fe as d,go as e,Mt as f,St as g,Zc as h,Lt as i,st as j,it as k,Et as l,lt as m,R as n,Wo as o,en as p,Ae as q,Se as r,Ft as s,ut as t,Le as u,Ge as v,Ra as w,Ue as x,bt as y,ht as z};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {n,h,e}from'./chunk-NE4QKYRI.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,...p})=>{let{shikiTheme:r}=useContext(n),i=h(),[c,o]=useState(t);return useEffect(()=>{if(!i){o(t);return}let l=i.highlight({code:s,language:e$1,themes:r},H=>{o(H);});l&&o(l);},[s,e$1,r,i,t]),jsx(e,{className:m,language:e$1,lineNumbers:a,maxHeight:h$1,result:c,startLine:d,...p})};export{x as HighlightedCodeBlockBody};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default debounce delay in milliseconds before checking if element is still in view
|
|
3
|
+
*/
|
|
4
|
+
export declare const DEFERRED_RENDER_DEBOUNCE_DELAY = 300;
|
|
5
|
+
/**
|
|
6
|
+
* Default root margin for Intersection Observer
|
|
7
|
+
* Starts rendering when element is 200px away from viewport
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFERRED_RENDER_ROOT_MARGIN = "300px";
|
|
10
|
+
/**
|
|
11
|
+
* Default timeout for requestIdleCallback in milliseconds
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEFERRED_RENDER_IDLE_TIMEOUT = 500;
|
|
14
|
+
export interface UseDeferredRenderOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Debounce delay in milliseconds before checking if still in view
|
|
17
|
+
* @default DEFERRED_RENDER_DEBOUNCE_DELAY
|
|
18
|
+
*/
|
|
19
|
+
debounceDelay?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Timeout for requestIdleCallback in milliseconds
|
|
22
|
+
* @default DEFERRED_RENDER_IDLE_TIMEOUT
|
|
23
|
+
*/
|
|
24
|
+
idleTimeout?: number;
|
|
25
|
+
/**
|
|
26
|
+
* If true, render immediately without waiting for intersection
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
immediate?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Root margin for Intersection Observer (e.g., '200px' to start rendering 200px before entering viewport)
|
|
32
|
+
* @default DEFERRED_RENDER_ROOT_MARGIN
|
|
33
|
+
*/
|
|
34
|
+
rootMargin?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Hook for deferred rendering components when they enter the viewport.
|
|
38
|
+
* Uses Intersection Observer + debounce + requestIdleCallback for optimal performance.
|
|
39
|
+
*
|
|
40
|
+
* @param options Configuration options
|
|
41
|
+
* @returns Object containing `shouldRender` flag and `containerRef` to attach to the element
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* const { shouldRender, containerRef } = useDeferredRender({ immediate: false })
|
|
46
|
+
*
|
|
47
|
+
* return (
|
|
48
|
+
* <div ref={containerRef}>
|
|
49
|
+
* {shouldRender && <ExpensiveComponent />}
|
|
50
|
+
* </div>
|
|
51
|
+
* )
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function useDeferredRender(options?: UseDeferredRenderOptions): {
|
|
55
|
+
shouldRender: boolean;
|
|
56
|
+
containerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
57
|
+
};
|