@rizom/brain 0.2.0-alpha.383 → 0.2.0-alpha.384

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.
Files changed (39) hide show
  1. package/dist/brain.js +36 -36
  2. package/dist/chunks/{app-7z5e3c7s.js → app-zn0wshdg.js} +2 -2
  3. package/dist/chunks/{index-ymrghn05.js → index-fe19h0ey.js} +3 -3
  4. package/dist/chunks/{index-ymrghn05.js.map → index-fe19h0ey.js.map} +1 -1
  5. package/dist/chunks/{index-ccy24bdp.js → index-q8rrvgdf.js} +2 -2
  6. package/dist/chunks/{index-3dz3sh65.js → index-y41e244y.js} +2 -2
  7. package/dist/index.js +1 -1
  8. package/dist/model.js +37 -37
  9. package/dist/model.js.map +2 -2
  10. package/dist/ui/studio-app.css +32 -18
  11. package/dist/ui/studio-app.js +3 -3
  12. package/dist/ui/studio-app.js.map +1 -1
  13. package/dist/ui/studio-asset-manifest.json +16 -16
  14. package/dist/ui/studio-chunks/account-view-811dnmr7.js +3 -0
  15. package/dist/ui/studio-chunks/{account-view-4544h367.js.map → account-view-811dnmr7.js.map} +2 -2
  16. package/dist/ui/studio-chunks/{highlighted-body-OFNGDK62-1w01z27m.js → highlighted-body-OFNGDK62-kw57xp1t.js} +2 -2
  17. package/dist/ui/studio-chunks/{highlighted-body-OFNGDK62-1w01z27m.js.map → highlighted-body-OFNGDK62-kw57xp1t.js.map} +1 -1
  18. package/dist/ui/studio-chunks/{main-1gqf08r8.js → main-53ha0ekw.js} +18 -18
  19. package/dist/ui/studio-chunks/{main-1gqf08r8.js.map → main-53ha0ekw.js.map} +4 -7
  20. package/dist/ui/studio-chunks/{main-b34wmcw1.js → main-g0bad58x.js} +4 -4
  21. package/dist/ui/studio-chunks/{main-b34wmcw1.js.map → main-g0bad58x.js.map} +1 -1
  22. package/dist/ui/studio-chunks/main-g6b89p15.js +7 -0
  23. package/dist/ui/studio-chunks/{main-ptks77cs.js.map → main-g6b89p15.js.map} +3 -3
  24. package/dist/ui/studio-chunks/main-me847330.js +50 -0
  25. package/dist/ui/studio-chunks/{main-vzjqx8f9.js.map → main-me847330.js.map} +6 -3
  26. package/dist/ui/studio-chunks/mermaid-GHXKKRXX-hqacyqmt.js +3 -0
  27. package/dist/ui/studio-chunks/{mermaid-GHXKKRXX-ftrk50mv.js.map → mermaid-GHXKKRXX-hqacyqmt.js.map} +1 -1
  28. package/dist/ui/studio-chunks/studio-chat-workspace-hmkhk808.js +5 -0
  29. package/dist/ui/studio-chunks/studio-chat-workspace-hmkhk808.js.map +20 -0
  30. package/package.json +1 -1
  31. package/dist/ui/studio-chunks/account-view-4544h367.js +0 -3
  32. package/dist/ui/studio-chunks/main-ptks77cs.js +0 -7
  33. package/dist/ui/studio-chunks/main-vzjqx8f9.js +0 -50
  34. package/dist/ui/studio-chunks/mermaid-GHXKKRXX-ftrk50mv.js +0 -3
  35. package/dist/ui/studio-chunks/studio-chat-workspace-kpfmp85b.js +0 -5
  36. package/dist/ui/studio-chunks/studio-chat-workspace-kpfmp85b.js.map +0 -21
  37. /package/dist/chunks/{app-7z5e3c7s.js.map → app-zn0wshdg.js.map} +0 -0
  38. /package/dist/chunks/{index-ccy24bdp.js.map → index-q8rrvgdf.js.map} +0 -0
  39. /package/dist/chunks/{index-3dz3sh65.js.map → index-y41e244y.js.map} +0 -0
@@ -106,14 +106,14 @@ ${e}</tr>
106
106
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${wt(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:r}){let n=this.parser.parseInline(r),i=Of(e);if(i===null)return n;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+wt(t)+'"'),s+=">"+n+"</a>",s}image({href:e,title:t,text:r,tokens:n}){n&&(r=this.parser.parseInline(n,this.parser.textRenderer));let i=Of(e);if(i===null)return wt(r);e=i;let s=`<img src="${e}" alt="${wt(r)}"`;return t&&(s+=` title="${wt(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):("escaped"in e)&&e.escaped?e.text:wt(e.text)}},No=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},bt=class e{options;renderer;textRenderer;constructor(t){this.options=t||Nr,this.options.renderer=this.options.renderer||new Ji,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new No}static parse(t,r){return new e(r).parse(t)}static parseInline(t,r){return new e(r).parseInline(t)}parse(t){this.renderer.parser=this;let r="";for(let n=0;n<t.length;n++){let i=t[n];if(this.options.extensions?.renderers?.[i.type]){let a=i,o=this.options.extensions.renderers[a.type].call({parser:this},a);if(o!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){r+=o||"";continue}}let s=i;switch(s.type){case"space":{r+=this.renderer.space(s);break}case"hr":{r+=this.renderer.hr(s);break}case"heading":{r+=this.renderer.heading(s);break}case"code":{r+=this.renderer.code(s);break}case"table":{r+=this.renderer.table(s);break}case"blockquote":{r+=this.renderer.blockquote(s);break}case"list":{r+=this.renderer.list(s);break}case"checkbox":{r+=this.renderer.checkbox(s);break}case"html":{r+=this.renderer.html(s);break}case"def":{r+=this.renderer.def(s);break}case"paragraph":{r+=this.renderer.paragraph(s);break}case"text":{r+=this.renderer.text(s);break}default:{let a='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw Error(a)}}}return r}parseInline(t,r=this.renderer){this.renderer.parser=this;let n="";for(let i=0;i<t.length;i++){let s=t[i];if(this.options.extensions?.renderers?.[s.type]){let o=this.options.extensions.renderers[s.type].call({parser:this},s);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){n+=o||"";continue}}let a=s;switch(a.type){case"escape":{n+=r.text(a);break}case"html":{n+=r.html(a);break}case"link":{n+=r.link(a);break}case"image":{n+=r.image(a);break}case"checkbox":{n+=r.checkbox(a);break}case"strong":{n+=r.strong(a);break}case"em":{n+=r.em(a);break}case"codespan":{n+=r.codespan(a);break}case"br":{n+=r.br(a);break}case"del":{n+=r.del(a);break}case"text":{n+=r.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw Error(o)}}}return n}},qn=class{options;block;constructor(e){this.options=e||Nr}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?it.lex:it.lexInline}provideParser(e=this.block){return e?bt.parse:bt.parseInline}},L2=class{defaults=ko();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=bt;Renderer=Ji;TextRenderer=No;Lexer=it;Tokenizer=Zi;Hooks=qn;constructor(...e){this.use(...e)}walkTokens(e,t){let r=[];for(let n of e)switch(r=r.concat(t.call(this,n)),n.type){case"table":{let i=n;for(let s of i.header)r=r.concat(this.walkTokens(s.tokens,t));for(let s of i.rows)for(let a of s)r=r.concat(this.walkTokens(a.tokens,t));break}case"list":{let i=n;r=r.concat(this.walkTokens(i.items,t));break}default:{let i=n;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach((s)=>{let a=i[s].flat(1/0);r=r.concat(this.walkTokens(a,t))}):i.tokens&&(r=r.concat(this.walkTokens(i.tokens,t)))}}return r}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((r)=>{let n={...r};if(n.async=this.defaults.async||n.async||!1,r.extensions&&(r.extensions.forEach((i)=>{if(!i.name)throw Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...a){let o=i.renderer.apply(this,a);return o===!1&&(o=s.apply(this,a)),o}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),n.extensions=t),r.renderer){let i=this.defaults.renderer||new Ji(this.defaults);for(let s in r.renderer){if(!(s in i))throw Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let a=s,o=r.renderer[a],u=i[a];i[a]=(...c)=>{let d=o.apply(i,c);return d===!1&&(d=u.apply(i,c)),d||""}}n.renderer=i}if(r.tokenizer){let i=this.defaults.tokenizer||new Zi(this.defaults);for(let s in r.tokenizer){if(!(s in i))throw Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let a=s,o=r.tokenizer[a],u=i[a];i[a]=(...c)=>{let d=o.apply(i,c);return d===!1&&(d=u.apply(i,c)),d}}n.tokenizer=i}if(r.hooks){let i=this.defaults.hooks||new qn;for(let s in r.hooks){if(!(s in i))throw Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let a=s,o=r.hooks[a],u=i[a];qn.passThroughHooks.has(s)?i[a]=(c)=>{if(this.defaults.async&&qn.passThroughHooksRespectAsync.has(s))return(async()=>{let f=await o.call(i,c);return u.call(i,f)})();let d=o.call(i,c);return u.call(i,d)}:i[a]=(...c)=>{if(this.defaults.async)return(async()=>{let f=await o.apply(i,c);return f===!1&&(f=await u.apply(i,c)),f})();let d=o.apply(i,c);return d===!1&&(d=u.apply(i,c)),d}}n.hooks=i}if(r.walkTokens){let i=this.defaults.walkTokens,s=r.walkTokens;n.walkTokens=function(a){let o=[];return o.push(s.call(this,a)),i&&(o=o.concat(i.call(this,a))),o}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return it.lex(e,t??this.defaults)}parser(e,t){return bt.parse(e,t??this.defaults)}parseMarkdown(e){return(t,r)=>{let n={...r},i={...this.defaults,...n},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&n.async===!1)return s(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let a=i.hooks?await i.hooks.preprocess(t):t,o=await(i.hooks?await i.hooks.provideLexer(e):e?it.lex:it.lexInline)(a,i),u=i.hooks?await i.hooks.processAllTokens(o):o;i.walkTokens&&await Promise.all(this.walkTokens(u,i.walkTokens));let c=await(i.hooks?await i.hooks.provideParser(e):e?bt.parse:bt.parseInline)(u,i);return i.hooks?await i.hooks.postprocess(c):c})().catch(s);try{i.hooks&&(t=i.hooks.preprocess(t));let a=(i.hooks?i.hooks.provideLexer(e):e?it.lex:it.lexInline)(t,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let o=(i.hooks?i.hooks.provideParser(e):e?bt.parse:bt.parseInline)(a,i);return i.hooks&&(o=i.hooks.postprocess(o)),o}catch(a){return s(a)}}}onError(e,t){return(r)=>{if(r.message+=`
107
107
  Please report this to https://github.com/markedjs/marked.`,e){let n="<p>An error occurred:</p><pre>"+wt(r.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(r);throw r}}},wr=new L2;function Ee(e,t){return wr.parse(e,t)}Ee.options=Ee.setOptions=function(e){return wr.setOptions(e),Ee.defaults=wr.defaults,Mf(Ee.defaults),Ee};Ee.getDefaults=ko;Ee.defaults=Nr;Ee.use=function(...e){return wr.use(...e),Ee.defaults=wr.defaults,Mf(Ee.defaults),Ee};Ee.walkTokens=function(e,t){return wr.walkTokens(e,t)};Ee.parseInline=wr.parseInline;Ee.Parser=bt;Ee.parser=bt.parse;Ee.Renderer=Ji;Ee.TextRenderer=No;Ee.Lexer=it;Ee.lexer=it.lex;Ee.Tokenizer=Zi;Ee.Hooks=qn;Ee.parse=Ee;var{options:fP,setOptions:hP,use:pP,walkTokens:mP,parseInline:gP}=Ee;var bP=bt.parse,EP=it.lex;var P2=300,M2="300px",v2=500;function B2(e={}){let{immediate:t=!1,debounceDelay:r=P2,rootMargin:n=M2,idleTimeout:i=v2}=e,[s,a]=w.useState(!1),o=w.useRef(null),u=w.useRef(null),c=w.useRef(null),d=w.useMemo(()=>(g)=>{let b=Date.now();return window.setTimeout(()=>{g({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-b))})},1)},[]),f=w.useMemo(()=>typeof window<"u"&&window.requestIdleCallback?(g,b)=>window.requestIdleCallback(g,b):d,[d]),p=w.useMemo(()=>typeof window<"u"&&window.cancelIdleCallback?(g)=>window.cancelIdleCallback(g):(g)=>{clearTimeout(g)},[]);return w.useEffect(()=>{if(t){a(!0);return}let g=o.current;if(!g)return;u.current&&(clearTimeout(u.current),u.current=null),c.current&&(p(c.current),c.current=null);let b=()=>{u.current&&(clearTimeout(u.current),u.current=null),c.current&&(p(c.current),c.current=null)},C=(D)=>{c.current=f((Y)=>{Y.timeRemaining()>0||Y.didTimeout?(a(!0),D.disconnect()):c.current=f(()=>{a(!0),D.disconnect()},{timeout:i/2})},{timeout:i})},I=(D)=>{b(),u.current=window.setTimeout(()=>{var Y,U;let L=D.takeRecords();(L.length===0||(U=(Y=L.at(-1))==null?void 0:Y.isIntersecting)!=null&&U)&&C(D)},r)},_=(D,Y)=>{D.isIntersecting?I(Y):b()},P=new IntersectionObserver((D)=>{for(let Y of D)_(Y,P)},{rootMargin:n,threshold:0});return P.observe(g),()=>{u.current&&clearTimeout(u.current),c.current&&p(c.current),P.disconnect()}},[t,r,n,i,p,f]),{shouldRender:s,containerRef:o}}var dh=/\s/,F2=/^\s+$/,H2=new Set(["code","pre","svg","math","annotation"]),U2=(e)=>typeof e=="object"&&e!==null&&("type"in e)&&e.type==="element",z2=(e)=>e.some((t)=>U2(t)&&H2.has(t.tagName)),q2=(e)=>{let t=[],r="",n=!1;for(let i of e){let s=dh.test(i);s!==n&&r&&(t.push(r),r=""),r+=i,n=s}return r&&t.push(r),t},Y2=(e)=>{let t=[],r="";for(let n of e)dh.test(n)?r+=n:(r&&(t.push(r),r=""),t.push(n));return r&&t.push(r),t},j2=(e,t,r,n,i,s)=>{let a=`--sd-animation:sd-${t};--sd-duration:${i?0:r}ms;--sd-easing:${n}`;return s&&(a+=`;--sd-delay:${s}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":!0,style:a},children:[{type:"text",value:e}]}},V2=(e,t,r,n,i)=>{let s=t.at(-1);if(!(s&&("children"in s)))return;if(z2(t))return ct;let a=s,o=a.children.indexOf(e);if(o===-1)return;let u=e.value;if(!u.trim()){i.count+=u.length;return}let c=r.sep==="char"?Y2(u):q2(u),d=n.prevContentLength,f=c.map((p)=>{let g=i.count;if(i.count+=p.length,F2.test(p))return{type:"text",value:p};let b=d>0&&g<d,C=b?0:i.newIndex++*r.stagger;return j2(p,r.animation,r.duration,r.easing,b,C)});return a.children.splice(o,1,...f),o+f.length},W2=0;function Oo(e){var t,r,n,i,s;let a={animation:(t=e==null?void 0:e.animation)!=null?t:"fadeIn",duration:(r=e==null?void 0:e.duration)!=null?r:150,easing:(n=e==null?void 0:e.easing)!=null?n:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word",stagger:(s=e==null?void 0:e.stagger)!=null?s:40},o={prevContentLength:0,lastRenderCharCount:0},u=W2++,c=()=>(d)=>{let f={count:0,newIndex:0};or(d,"text",(p,g)=>V2(p,g,a,o,f)),o.lastRenderCharCount=f.count,o.prevContentLength=0};return Object.defineProperty(c,"name",{value:`rehypeAnimate$${u}`}),{name:"animate",type:"animate",rehypePlugin:c,setPrevContentLength(d){o.prevContentLength=d},getLastRenderCharCount(){let d=o.lastRenderCharCount;return o.lastRenderCharCount=0,d}}}Oo();var fh=w.createContext(!1),G2=()=>w.useContext(fh),Uo=(...e)=>$s(js(e)),$2=(e,t)=>{if(!e||!t)return t;let r=`${e}:`;return t.split(/\s+/).filter(Boolean).map((n)=>n.startsWith(r)?n:`${e}:${n}`).join(" ")},Q2=(e)=>e?(...t)=>$2(e,$s(js(t))):Uo,en=(e,t,r)=>{let n=typeof t=="string"&&r.startsWith("text/csv")?"\uFEFF":"",i=typeof t=="string"?new Blob([n+t],{type:r}):t,s=URL.createObjectURL(i),a=document.createElement("a");a.href=s,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s)},Do=w.createContext(Uo),ce=()=>w.useContext(Do),X2=Uo("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"),K2=(e)=>{let t={};for(let r of e.split(";")){let n=r.indexOf(":");if(n>0){let i=r.slice(0,n).trim(),s=r.slice(n+1).trim();i&&s&&(t[i]=s)}}return t},Z2=w.memo(({children:e,result:t,language:r,className:n,startLine:i,lineNumbers:s=!0,...a})=>{let o=ce(),u=w.useMemo(()=>o(X2),[o]),c=w.useMemo(()=>{let d={};return t.bg&&(d["--sdm-bg"]=t.bg),t.fg&&(d["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(d,K2(t.rootStyle)),d},[t.bg,t.fg,t.rootStyle]);return A.jsx("div",{className:o(n,"overflow-x-auto rounded-md border border-border bg-background p-4 text-sm"),"data-language":r,"data-streamdown":"code-block-body",...a,children:A.jsx("pre",{className:o(n,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:c,children:A.jsx("code",{className:s?o("[counter-increment:line_0] [counter-reset:line]"):void 0,style:s&&i&&i>1?{counterReset:`line ${i-1}`}:void 0,children:t.tokens.map((d,f)=>A.jsx("span",{className:s?u:void 0,children:d.length===0||d.length===1&&d[0].content===""?`
108
108
  `:d.map((p,g)=>{let b={},C=!!p.bgColor;if(p.color&&(b["--sdm-c"]=p.color),p.bgColor&&(b["--sdm-tbg"]=p.bgColor),p.htmlStyle)for(let[I,_]of Object.entries(p.htmlStyle))I==="color"?b["--sdm-c"]=_:I==="background-color"?(b["--sdm-tbg"]=_,C=!0):b[I]=_;return A.jsx("span",{className:o("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",C&&"bg-[var(--sdm-tbg)]",C&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:b,...p.htmlAttrs,children:p.content},g)})},f))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),J2=({className:e,language:t,style:r,isIncomplete:n,...i})=>{let s=ce();return A.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",...r},...i})},hh=w.createContext({code:""}),ph=()=>w.useContext(hh),ey=({language:e})=>{let t=ce();return A.jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:A.jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})},ty=(e)=>{let t=e.length;for(;t>0&&e[t-1]===`
109
- `;)t--;return e.slice(0,t)},ry=w.lazy(()=>import("./highlighted-body-OFNGDK62-1w01z27m.js").then((e)=>({default:e.HighlightedCodeBlockBody}))),ny=({code:e,language:t,className:r,children:n,isIncomplete:i=!1,startLine:s,lineNumbers:a,...o})=>{let u=ce(),c=w.useMemo(()=>ty(e),[e]),d=w.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:c.split(`
109
+ `;)t--;return e.slice(0,t)},ry=w.lazy(()=>import("./highlighted-body-OFNGDK62-kw57xp1t.js").then((e)=>({default:e.HighlightedCodeBlockBody}))),ny=({code:e,language:t,className:r,children:n,isIncomplete:i=!1,startLine:s,lineNumbers:a,...o})=>{let u=ce(),c=w.useMemo(()=>ty(e),[e]),d=w.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:c.split(`
110
110
  `).map((f)=>[{content:f,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[c]);return A.jsx(hh.Provider,{value:{code:e},children:A.jsxs(J2,{isIncomplete:i,language:t,children:[A.jsx(ey,{language:t}),n?A.jsx("div",{className:u("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:A.jsx("div",{className:u("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,A.jsx(w.Suspense,{fallback:A.jsx(Z2,{className:r,language:t,lineNumbers:a,result:d,startLine:s,...o}),children:A.jsx(ry,{className:r,code:c,language:t,lineNumbers:a,raw:d,startLine:s,...o})})]})})},iy=(e)=>A.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:A.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"})}),ay=(e)=>A.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:A.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"})}),sy=(e)=>A.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:A.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"})}),oy=(e)=>A.jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[A.jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),A.jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),A.jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),A.jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),A.jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),A.jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),A.jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),A.jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),A.jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),A.jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),uy=(e)=>A.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:A.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"})}),ly=(e)=>A.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:A.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"})}),cy=(e)=>A.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:A.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"})}),dy=(e)=>A.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:A.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"})}),fy=(e)=>A.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:A.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"})}),hy=(e)=>A.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:A.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"})}),jn={CheckIcon:iy,CopyIcon:ay,DownloadIcon:sy,ExternalLinkIcon:dy,Loader2Icon:oy,Maximize2Icon:uy,RotateCcwIcon:ly,XIcon:cy,ZoomInIcon:fy,ZoomOutIcon:hy},mh=w.createContext(jn),py=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let r=Object.keys(e),n=Object.keys(t);return r.length!==n.length?!1:r.every((i)=>e[i]===t[i])},Vf=({icons:e,children:t})=>{let r=w.useRef(e),n=w.useRef(e?{...jn,...e}:jn);py(r.current,e)||(r.current=e,n.current=e?{...jn,...e}:jn);let i=n.current;return A.jsx(mh.Provider,{value:i,children:t})},Et=()=>w.useContext(mh),gh={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"},Po=w.createContext(gh),zt=()=>w.useContext(Po),Wf=({onCopy:e,onError:t,timeout:r=2000,children:n,className:i,code:s,...a})=>{let o=ce(),[u,c]=w.useState(!1),d=w.useRef(0),{code:f}=ph(),{isAnimating:p}=w.useContext(at),g=zt(),b=s!=null?s:f,C=async()=>{var P;if(typeof window>"u"||!((P=navigator==null?void 0:navigator.clipboard)!=null&&P.writeText)){t==null||t(Error("Clipboard API not available"));return}try{u||(await navigator.clipboard.writeText(b),c(!0),e==null||e(),d.current=window.setTimeout(()=>c(!1),r))}catch(D){t==null||t(D)}};w.useEffect(()=>()=>{window.clearTimeout(d.current)},[]);let I=Et(),_=u?I.CheckIcon:I.CopyIcon;return A.jsx("button",{className:o("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),"data-streamdown":"code-block-copy-button",disabled:p,onClick:C,title:g.copyCode,type:"button",...a,children:n!=null?n:A.jsx(_,{size:14})})},Gf={"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",文言:"wy"},my=({onDownload:e,onError:t,language:r,children:n,className:i,code:s,...a})=>{let o=ce(),{code:u}=ph(),{isAnimating:c}=w.useContext(at),d=zt(),f=Et(),p=s!=null?s:u,g=`file.${r&&r in Gf?Gf[r]:"txt"}`,b="text/plain",C=()=>{try{en(g,p,b),e==null||e()}catch(I){t==null||t(I)}};return A.jsx("button",{className:o("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),"data-streamdown":"code-block-download-button",disabled:c,onClick:C,title:d.downloadFile,type:"button",...a,children:n!=null?n:A.jsx(f.DownloadIcon,{size:14})})},$f=()=>{let{Loader2Icon:e}=Et(),t=ce();return A.jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[A.jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),A.jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:A.jsx(e,{className:t("size-4 animate-spin")})})]})},gy=/\.[^/.]+$/,by=({node:e,className:t,src:r,alt:n,onLoad:i,onError:s,...a})=>{let{DownloadIcon:o}=Et(),u=ce(),c=w.useRef(null),[d,f]=w.useState(!1),[p,g]=w.useState(!1),b=zt(),C=a.width!=null||a.height!=null,I=(d||C)&&!p,_=p&&!C;w.useEffect(()=>{let U=c.current;if(U!=null&&U.complete){let L=U.naturalWidth>0;f(L),g(!L)}},[]);let P=w.useCallback((U)=>{f(!0),g(!1),i==null||i(U)},[i]),D=w.useCallback((U)=>{f(!1),g(!0),s==null||s(U)},[s]),Y=async()=>{if(r)try{let U=await(await fetch(r)).blob(),L=new URL(r,window.location.origin).pathname.split("/").pop()||"",K=L.split(".").pop(),H=L.includes(".")&&K!==void 0&&K.length<=4,Z="";if(H)Z=L;else{let R=U.type,oe="png";R.includes("jpeg")||R.includes("jpg")?oe="jpg":R.includes("png")?oe="png":R.includes("svg")?oe="svg":R.includes("gif")?oe="gif":R.includes("webp")&&(oe="webp"),Z=`${(n||L||"image").replace(gy,"")}.${oe}`}en(Z,U,U.type)}catch(U){window.open(r,"_blank")}};return r?A.jsxs("div",{className:u("group relative my-4 inline-block"),"data-streamdown":"image-wrapper",children:[A.jsx("img",{alt:n,className:u("max-w-full rounded-lg",_&&"hidden",t),"data-streamdown":"image",onError:D,onLoad:P,ref:c,src:r,...a}),_&&A.jsx("span",{className:u("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:b.imageNotAvailable}),A.jsx("div",{className:u("pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block")}),I&&A.jsx("button",{className:u("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:Y,title:b.downloadImage,type:"button",children:A.jsx(o,{size:14})})]}):null},Vn=0,zo=()=>{Vn+=1,Vn===1&&(document.body.style.overflow="hidden")},qo=()=>{Vn=Math.max(0,Vn-1),Vn===0&&(document.body.style.overflow="")},Ey=({url:e,isOpen:t,onClose:r,onConfirm:n})=>{let{CheckIcon:i,CopyIcon:s,ExternalLinkIcon:a,XIcon:o}=Et(),u=ce(),[c,d]=w.useState(!1),f=zt(),p=w.useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2000)}catch(b){}},[e]),g=w.useCallback(()=>{n(),r()},[n,r]);return w.useEffect(()=>{if(t){zo();let b=(C)=>{C.key==="Escape"&&r()};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),qo()}}},[t,r]),t?A.jsx("div",{className:u("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:r,onKeyDown:(b)=>{b.key==="Escape"&&r()},role:"button",tabIndex:0,children:A.jsxs("div",{className:u("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:[A.jsx("button",{className:u("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:r,title:f.close,type:"button",children:A.jsx(o,{size:16})}),A.jsxs("div",{className:u("flex flex-col gap-2"),children:[A.jsxs("div",{className:u("flex items-center gap-2 font-semibold text-lg"),children:[A.jsx(a,{size:20}),A.jsx("span",{children:f.openExternalLink})]}),A.jsx("p",{className:u("text-muted-foreground text-sm"),children:f.externalLinkWarning})]}),A.jsx("div",{className:u("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),A.jsxs("div",{className:u("flex gap-2"),children:[A.jsx("button",{className:u("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:p,type:"button",children:c?A.jsxs(A.Fragment,{children:[A.jsx(i,{size:14}),A.jsx("span",{children:f.copied})]}):A.jsxs(A.Fragment,{children:[A.jsx(s,{size:14}),A.jsx("span",{children:f.copyLink})]})}),A.jsxs("button",{className:u("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:g,type:"button",children:[A.jsx(a,{size:14}),A.jsx("span",{children:f.openLink})]})]})]})}):null},Mo=w.createContext(null),Yo=()=>w.useContext(Mo),UP=()=>{var e;let t=Yo();return(e=t==null?void 0:t.code)!=null?e:null},jo=()=>{var e;let t=Yo();return(e=t==null?void 0:t.mermaid)!=null?e:null},Ty=(e)=>{var t;let r=Yo();return r!=null&&r.renderers&&e&&(t=r.renderers.find((n)=>Array.isArray(n.language)?n.language.includes(e):n.language===e))!=null?t:null},xy=(e,t)=>{var r;let n=(r=void 0)!=null?r:5;return new Promise((i,s)=>{let a="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),o=new Image;o.crossOrigin="anonymous",o.onload=()=>{let u=document.createElement("canvas"),c=o.width*n,d=o.height*n;u.width=c,u.height=d;let f=u.getContext("2d");if(!f){s(Error("Failed to create 2D canvas context for PNG export"));return}f.drawImage(o,0,0,c,d),u.toBlob((p)=>{if(!p){s(Error("Failed to create PNG blob"));return}i(p)},"image/png")},o.onerror=()=>s(Error("Failed to load SVG image")),o.src=a})},ky=({chart:e,children:t,className:r,onDownload:n,config:i,onError:s})=>{let a=ce(),[o,u]=w.useState(!1),c=w.useRef(null),{isAnimating:d}=w.useContext(at),f=Et(),p=jo(),g=zt(),b=async(C)=>{try{if(C==="mmd"){en("diagram.mmd",e,"text/plain"),u(!1),n==null||n(C);return}if(!p){s==null||s(Error("Mermaid plugin not available"));return}let I=p.getMermaid(i),_=e.split("").reduce((Y,U)=>(Y<<5)-Y+U.charCodeAt(0)|0,0),P=`mermaid-${Math.abs(_)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:D}=await I.render(P,e);if(!D){s==null||s(Error("SVG not found. Please wait for the diagram to render."));return}if(C==="svg"){en("diagram.svg",D,"image/svg+xml"),u(!1),n==null||n(C);return}if(C==="png"){let Y=await xy(D);en("diagram.png",Y,"image/png"),n==null||n(C),u(!1);return}}catch(I){s==null||s(I)}};return w.useEffect(()=>{let C=(I)=>{let _=I.composedPath();c.current&&!_.includes(c.current)&&u(!1)};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[]),A.jsxs("div",{className:a("relative"),ref:c,children:[A.jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:d,onClick:()=>u(!o),title:g.downloadDiagram,type:"button",children:t!=null?t:A.jsx(f.DownloadIcon,{size:14})}),o?A.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:[A.jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>b("svg"),title:g.downloadDiagramAsSvg,type:"button",children:g.mermaidFormatSvg}),A.jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>b("png"),title:g.downloadDiagramAsPng,type:"button",children:g.mermaidFormatPng}),A.jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>b("mmd"),title:g.downloadDiagramAsMmd,type:"button",children:g.mermaidFormatMmd})]}):null]})},yy=({chart:e,config:t,onFullscreen:r,onExit:n,className:i,...s})=>{let{Maximize2Icon:a,XIcon:o}=Et(),u=ce(),[c,d]=w.useState(!1),{isAnimating:f,controls:p}=w.useContext(at),g=zt(),b=(()=>{if(typeof p=="boolean")return p;let I=p.mermaid;return I===!1?!1:I===!0||I===void 0?!0:I.panZoom!==!1})(),C=()=>{d(!c)};return w.useEffect(()=>{if(c){zo();let I=(_)=>{_.key==="Escape"&&d(!1)};return document.addEventListener("keydown",I),()=>{document.removeEventListener("keydown",I),qo()}}},[c]),w.useEffect(()=>{c?r==null||r():n&&n()},[c,r,n]),A.jsxs(A.Fragment,{children:[A.jsx("button",{className:u("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),disabled:f,onClick:C,title:g.viewFullscreen,type:"button",...s,children:A.jsx(a,{size:14})}),c?Ho.createPortal(A.jsxs("div",{className:u("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),onClick:C,onKeyDown:(I)=>{I.key==="Escape"&&C()},role:"button",tabIndex:0,children:[A.jsx("button",{className:u("absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:C,title:g.exitFullscreen,type:"button",children:A.jsx(o,{size:20})}),A.jsx("div",{className:u("flex size-full items-center justify-center p-4"),onClick:(I)=>I.stopPropagation(),onKeyDown:(I)=>I.stopPropagation(),role:"presentation",children:A.jsx(b3,{chart:e,className:u("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:!0,showControls:b})})]}),document.body):null]})},bh=(e)=>{var t,r;let n=[],i=[],s=e.querySelectorAll("thead th");for(let o of s)n.push(((t=o.textContent)==null?void 0:t.trim())||"");let a=e.querySelectorAll("tbody tr");for(let o of a){let u=[],c=o.querySelectorAll("td");for(let d of c)u.push(((r=d.textContent)==null?void 0:r.trim())||"");i.push(u)}return{headers:n,rows:i}},Eh=(e)=>{let{headers:t,rows:r}=e,n=(o)=>{let u=!1,c=!1;for(let d of o){if(d==='"'){u=!0,c=!0;break}(d===","||d===`
111
111
  `)&&(u=!0)}return u?c?`"${o.replace(/"/g,'""')}"`:`"${o}"`:o},i=t.length>0?r.length+1:r.length,s=Array(i),a=0;t.length>0&&(s[a]=t.map(n).join(","),a+=1);for(let o of r)s[a]=o.map(n).join(","),a+=1;return s.join(`
112
112
  `)},Ay=(e)=>{let{headers:t,rows:r}=e,n=(o)=>{let u=!1;for(let d of o)if(d==="\t"||d===`
113
113
  `||d==="\r"){u=!0;break}if(!u)return o;let c=[];for(let d of o)d==="\t"?c.push("\\t"):d===`
114
114
  `?c.push("\\n"):d==="\r"?c.push("\\r"):c.push(d);return c.join("")},i=t.length>0?r.length+1:r.length,s=Array(i),a=0;t.length>0&&(s[a]=t.map(n).join("\t"),a+=1);for(let o of r)s[a]=o.map(n).join("\t"),a+=1;return s.join(`
115
115
  `)},Lo=(e)=>{let t=!1;for(let n of e)if(n==="\\"||n==="|"){t=!0;break}if(!t)return e;let r=[];for(let n of e)n==="\\"?r.push("\\\\"):n==="|"?r.push("\\|"):r.push(n);return r.join("")},vo=(e)=>{let{headers:t,rows:r}=e;if(t.length===0)return"";let n=Array(r.length+2),i=0,s=t.map((o)=>Lo(o));n[i]=`| ${s.join(" | ")} |`,i+=1;let a=Array(t.length);for(let o=0;o<t.length;o+=1)a[o]="---";n[i]=`| ${a.join(" | ")} |`,i+=1;for(let o of r)if(o.length<t.length){let u=Array(t.length);for(let c=0;c<t.length;c+=1)u[c]=c<o.length?Lo(o[c]):"";n[i]=`| ${u.join(" | ")} |`,i+=1}else{let u=o.map((c)=>Lo(c));n[i]=`| ${u.join(" | ")} |`,i+=1}return n.join(`
116
- `)},Th=({children:e,className:t,onCopy:r,onError:n,timeout:i=2000})=>{let s=ce(),[a,o]=w.useState(!1),[u,c]=w.useState(!1),d=w.useRef(null),f=w.useRef(0),{isAnimating:p}=w.useContext(at),g=zt(),b=async(_)=>{var P,D;if(typeof window>"u"||!((P=navigator==null?void 0:navigator.clipboard)!=null&&P.write)){n==null||n(Error("Clipboard API not available"));return}try{let Y=(D=d.current)==null?void 0:D.closest('[data-streamdown="table-wrapper"]'),U=Y==null?void 0:Y.querySelector("table");if(!U){n==null||n(Error("Table not found"));return}let L=bh(U),K=({csv:Eh,tsv:Ay,md:vo}[_]||vo)(L),H=new ClipboardItem({"text/plain":new Blob([K],{type:"text/plain"}),"text/html":new Blob([U.outerHTML],{type:"text/html"})});await navigator.clipboard.write([H]),c(!0),o(!1),r==null||r(_),f.current=window.setTimeout(()=>c(!1),i)}catch(Y){n==null||n(Y)}};w.useEffect(()=>{let _=(P)=>{let D=P.composedPath();d.current&&!D.includes(d.current)&&o(!1)};return document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_),window.clearTimeout(f.current)}},[]);let C=Et(),I=u?C.CheckIcon:C.CopyIcon;return A.jsxs("div",{className:s("relative"),ref:d,children:[A.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:p,onClick:()=>o(!a),title:g.copyTable,type:"button",children:e!=null?e:A.jsx(I,{height:14,width:14})}),a?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:[A.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>b("md"),title:g.copyTableAsMarkdown,type:"button",children:g.tableFormatMarkdown}),A.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>b("csv"),title:g.copyTableAsCsv,type:"button",children:g.tableFormatCsv}),A.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>b("tsv"),title:g.copyTableAsTsv,type:"button",children:g.tableFormatTsv})]}):null]})};var xh=({children:e,className:t,onDownload:r,onError:n})=>{let i=ce(),[s,a]=w.useState(!1),o=w.useRef(null),{isAnimating:u}=w.useContext(at),c=zt(),d=Et(),f=(p)=>{var g;try{let b=(g=o.current)==null?void 0:g.closest('[data-streamdown="table-wrapper"]'),C=b==null?void 0:b.querySelector("table");if(!C){n==null||n(Error("Table not found"));return}let I=bh(C),_=p==="csv"?Eh(I):vo(I);en(`table.${p==="csv"?"csv":"md"}`,_,p==="csv"?"text/csv":"text/markdown"),a(!1),r==null||r(p)}catch(b){n==null||n(b)}};return w.useEffect(()=>{let p=(g)=>{let b=g.composedPath();o.current&&!b.includes(o.current)&&a(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[]),A.jsxs("div",{className:i("relative"),ref:o,children:[A.jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>a(!s),title:c.downloadTable,type:"button",children:e!=null?e:A.jsx(d.DownloadIcon,{size:14})}),s?A.jsxs("div",{className:i("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[A.jsx("button",{className:i("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("csv"),title:c.downloadTableAsCsv,type:"button",children:c.tableFormatCsv}),A.jsx("button",{className:i("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("markdown"),title:c.downloadTableAsMarkdown,type:"button",children:c.tableFormatMarkdown})]}):null]})},Cy=({children:e,className:t,showCopy:r=!0,showDownload:n=!0})=>{let{Maximize2Icon:i,XIcon:s}=Et(),a=ce(),[o,u]=w.useState(!1),{isAnimating:c}=w.useContext(at),d=zt(),f=()=>{u(!0)},p=()=>{u(!1)};return w.useEffect(()=>{if(o){zo();let g=(b)=>{b.key==="Escape"&&u(!1)};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),qo()}}},[o]),A.jsxs(A.Fragment,{children:[A.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:f,title:d.viewFullscreen,type:"button",children:A.jsx(i,{size:14})}),o?Ho.createPortal(A.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:p,onKeyDown:(g)=>{g.key==="Escape"&&p()},role:"dialog",children:A.jsxs("div",{className:a("flex h-full flex-col"),onClick:(g)=>g.stopPropagation(),onKeyDown:(g)=>g.stopPropagation(),role:"presentation",children:[A.jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[r?A.jsx(Th,{}):null,n?A.jsx(xh,{}):null,A.jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:p,title:d.exitFullscreen,type:"button",children:A.jsx(s,{size:20})})]}),A.jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:A.jsx("table",{className:a("w-full border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})},_y=({children:e,className:t,showControls:r,showCopy:n=!0,showDownload:i=!0,showFullscreen:s=!0,...a})=>{let o=ce(),u=r&&n,c=r&&i,d=r&&s,f=u||c||d;return A.jsxs("div",{className:o("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[f?A.jsxs("div",{className:o("flex items-center justify-end gap-1"),children:[u?A.jsx(Th,{}):null,c?A.jsx(xh,{}):null,d?A.jsx(Cy,{showCopy:u,showDownload:c,children:e}):null]}):null,A.jsx("div",{className:o("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),children:A.jsx("table",{className:o("w-full divide-y divide-border",t),"data-streamdown":"table",...a,children:e})})]})},Sy=/startLine=(\d+)/,Iy=/\bnoLineNumbers\b/,wy=w.lazy(()=>import("./mermaid-GHXKKRXX-ftrk50mv.js").then((e)=>({default:e.Mermaid}))),Ny=/language-([^\s]+)/;function aa(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&(t!=null&&t.position)))return!1;let r=e.position.start,n=t.position.start,i=e.position.end,s=t.position.end;return(r==null?void 0:r.line)===(n==null?void 0:n.line)&&(r==null?void 0:r.column)===(n==null?void 0:n.column)&&(i==null?void 0:i.line)===(s==null?void 0:s.line)&&(i==null?void 0:i.column)===(s==null?void 0:s.column)}function Ie(e,t){return e.className===t.className&&aa(e.node,t.node)}var Bo=(e,t)=>typeof e=="boolean"?e:e[t]!==!1,Ro=(e,t)=>{if(typeof e=="boolean")return e;let r=e.table;return r===!1?!1:r===!0||r===void 0?!0:r[t]!==!1},Qf=(e,t)=>{if(typeof e=="boolean")return e;let r=e.code;return r===!1?!1:r===!0||r===void 0?!0:r[t]!==!1},ra=(e,t)=>{if(typeof e=="boolean")return e;let r=e.mermaid;return r===!1?!1:r===!0||r===void 0?!0:r[t]!==!1},Vo=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("ol",{className:i("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e})},(e,t)=>Ie(e,t));Vo.displayName="MarkdownOl";var kh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("li",{className:i("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e})},(e,t)=>e.className===t.className&&aa(e.node,t.node));kh.displayName="MarkdownLi";var yh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("ul",{className:i("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e})},(e,t)=>Ie(e,t));yh.displayName="MarkdownUl";var Ah=w.memo(({className:e,node:t,...r})=>{let n=ce();return A.jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...r})},(e,t)=>Ie(e,t));Ah.displayName="MarkdownHr";var Ch=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("span",{className:i("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>Ie(e,t));Ch.displayName="MarkdownStrong";var Ly=({children:e,className:t,href:r,node:n,...i})=>{let s=ce(),{linkSafety:a}=w.useContext(at),[o,u]=w.useState(!1),c=r==="streamdown:incomplete-link",d=w.useCallback(async(b)=>{if(!(!(a!=null&&a.enabled&&r)||c)){if(b.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(r)){window.open(r,"_blank","noreferrer");return}u(!0)}},[a,r,c]),f=w.useCallback(()=>{r&&window.open(r,"_blank","noreferrer")},[r]),p=w.useCallback(()=>{u(!1)},[]),g={url:r!=null?r:"",isOpen:o,onClose:p,onConfirm:f};return a!=null&&a.enabled&&r?A.jsxs(A.Fragment,{children:[A.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(g):A.jsx(Ey,{...g})]}):A.jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",href:r,rel:"noreferrer",target:"_blank",...i,children:e})},_h=w.memo(Ly,(e,t)=>Ie(e,t)&&e.href===t.href);_h.displayName="MarkdownA";var Sh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("h1",{className:i("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>Ie(e,t));Sh.displayName="MarkdownH1";var Ih=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("h2",{className:i("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>Ie(e,t));Ih.displayName="MarkdownH2";var wh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("h3",{className:i("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>Ie(e,t));wh.displayName="MarkdownH3";var Nh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("h4",{className:i("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>Ie(e,t));Nh.displayName="MarkdownH4";var Lh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("h5",{className:i("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>Ie(e,t));Lh.displayName="MarkdownH5";var Rh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("h6",{className:i("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>Ie(e,t));Rh.displayName="MarkdownH6";var Oh=w.memo(({children:e,className:t,node:r,...n})=>{let{controls:i}=w.useContext(at),s=Bo(i,"table"),a=Ro(i,"copy"),o=Ro(i,"download"),u=Ro(i,"fullscreen");return A.jsx(_y,{className:t,showControls:s,showCopy:a,showDownload:o,showFullscreen:u,...n,children:e})},(e,t)=>Ie(e,t));Oh.displayName="MarkdownTable";var Dh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("thead",{className:i("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>Ie(e,t));Dh.displayName="MarkdownThead";var Ph=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("tbody",{className:i("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>Ie(e,t));Ph.displayName="MarkdownTbody";var Mh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("tr",{className:i("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>Ie(e,t));Mh.displayName="MarkdownTr";var vh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("th",{className:i("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>Ie(e,t));vh.displayName="MarkdownTh";var Bh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("td",{className:i("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>Ie(e,t));Bh.displayName="MarkdownTd";var Fh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("blockquote",{className:i("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e})},(e,t)=>Ie(e,t));Fh.displayName="MarkdownBlockquote";var Hh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("sup",{className:i("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>Ie(e,t));Hh.displayName="MarkdownSup";var Uh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("sub",{className:i("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>Ie(e,t));Uh.displayName="MarkdownSub";var zh=w.memo(({children:e,className:t,node:r,...n})=>{if("data-footnotes"in n){let i=(a)=>{var o,u;if(!w.isValidElement(a))return!1;let c=Array.isArray(a.props.children)?a.props.children:[a.props.children],d=!1,f=!1;for(let p of c)if(p){if(typeof p=="string")p.trim()!==""&&(d=!0);else if(w.isValidElement(p))if(((o=p.props)==null?void 0:o["data-footnote-backref"])!==void 0)f=!0;else{let g=Array.isArray(p.props.children)?p.props.children:[p.props.children];for(let b of g){if(typeof b=="string"&&b.trim()!==""){d=!0;break}if(w.isValidElement(b)&&((u=b.props)==null?void 0:u["data-footnote-backref"])===void 0){d=!0;break}}}}return f&&!d},s=Array.isArray(e)?e.map((a)=>{if(!w.isValidElement(a))return a;if(a.type===Vo){let o=(Array.isArray(a.props.children)?a.props.children:[a.props.children]).filter((u)=>!i(u));return o.length===0?null:{...a,props:{...a.props,children:o}}}return a}):e;return(Array.isArray(s)?s.some((a)=>a!==null):s!==null)?A.jsx("section",{className:t,...n,children:s}):null}return A.jsx("section",{className:t,...n,children:e})},(e,t)=>Ie(e,t));zh.displayName="MarkdownSection";var Ry=({node:e,className:t,children:r,...n})=>{var i,s;let a=ce(),o=!("data-block"in n),{mermaid:u,controls:c,lineNumbers:d}=w.useContext(at),f=jo(),p=G2(),g=t==null?void 0:t.match(Ny),b=(i=g==null?void 0:g.at(1))!=null?i:"",C=Ty(b);if(o)return A.jsx("code",{className:a("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:r});let I=(s=e==null?void 0:e.properties)==null?void 0:s.metastring,_=I==null?void 0:I.match(Sy),P=_?Number.parseInt(_[1],10):void 0,D=P!==void 0&&P>=1?P:void 0,Y=!(I?Iy.test(I):!1)&&d!==!1,U="";if(w.isValidElement(r)&&r.props&&typeof r.props=="object"&&"children"in r.props&&typeof r.props.children=="string"?U=r.props.children:typeof r=="string"&&(U=r),C){let Z=C.component;return A.jsx(w.Suspense,{fallback:A.jsx($f,{}),children:A.jsx(Z,{code:U,isIncomplete:p,language:b,meta:I})})}if(b==="mermaid"&&f){let Z=Bo(c,"mermaid"),R=ra(c,"download"),oe=ra(c,"copy"),ie=ra(c,"fullscreen"),V=ra(c,"panZoom"),J=Z&&(R||oe||ie);return A.jsx(w.Suspense,{fallback:A.jsx($f,{}),children:A.jsxs("div",{className:a("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-streamdown":"mermaid-block",children:[A.jsx("div",{className:a("flex h-8 items-center text-muted-foreground text-xs"),children:A.jsx("span",{className:a("ml-1 font-mono lowercase"),children:"mermaid"})}),J?A.jsx("div",{className:a("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:A.jsxs("div",{className:a("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:[R?A.jsx(ky,{chart:U,config:u==null?void 0:u.config}):null,oe?A.jsx(Wf,{code:U}):null,ie?A.jsx(yy,{chart:U,config:u==null?void 0:u.config}):null]})}):null,A.jsx("div",{className:a("rounded-md border border-border bg-background"),children:A.jsx(wy,{chart:U,config:u==null?void 0:u.config,showControls:V})})]})})}let L=Bo(c,"code"),K=Qf(c,"download"),H=Qf(c,"copy");return A.jsx(ny,{className:t,code:U,isIncomplete:p,language:b,lineNumbers:Y,startLine:D,children:L?A.jsxs(A.Fragment,{children:[K?A.jsx(my,{code:U,language:b}):null,H?A.jsx(Wf,{}):null]}):null})},qh=w.memo(Ry,(e,t)=>e.className===t.className&&aa(e.node,t.node));qh.displayName="MarkdownCode";var Yh=w.memo(by,(e,t)=>e.className===t.className&&aa(e.node,t.node));Yh.displayName="MarkdownImg";var jh=w.memo(({children:e,node:t,...r})=>{let n=(Array.isArray(e)?e:[e]).filter((i)=>i!=null&&i!=="");if(n.length===1&&w.isValidElement(n[0])){let i=n[0].props.node,s=i==null?void 0:i.tagName;if(s==="img")return A.jsx(A.Fragment,{children:e});if(s==="code"&&"data-block"in n[0].props)return A.jsx(A.Fragment,{children:e})}return A.jsx("p",{...r,children:e})},(e,t)=>Ie(e,t));jh.displayName="MarkdownParagraph";var Oy={ol:Vo,li:kh,ul:yh,hr:Ah,strong:Ch,a:_h,h1:Sh,h2:Ih,h3:wh,h4:Nh,h5:Lh,h6:Rh,table:Oh,thead:Dh,tbody:Ph,tr:Mh,th:vh,td:Bh,blockquote:Fh,code:qh,img:Yh,pre:({children:e})=>w.isValidElement(e)?w.cloneElement(e,{"data-block":"true"}):e,sup:Hh,sub:Uh,p:jh,section:zh},Dy=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Py=/\p{L}/u;function Xf(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 r of t){if(Dy.test(r))return"rtl";if(Py.test(r))return"ltr"}return"ltr"}var My=/^[ \t]{0,3}(`{3,}|~{3,})/,vy=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,Kf=(e)=>{let t=e.split(`
116
+ `)},Th=({children:e,className:t,onCopy:r,onError:n,timeout:i=2000})=>{let s=ce(),[a,o]=w.useState(!1),[u,c]=w.useState(!1),d=w.useRef(null),f=w.useRef(0),{isAnimating:p}=w.useContext(at),g=zt(),b=async(_)=>{var P,D;if(typeof window>"u"||!((P=navigator==null?void 0:navigator.clipboard)!=null&&P.write)){n==null||n(Error("Clipboard API not available"));return}try{let Y=(D=d.current)==null?void 0:D.closest('[data-streamdown="table-wrapper"]'),U=Y==null?void 0:Y.querySelector("table");if(!U){n==null||n(Error("Table not found"));return}let L=bh(U),K=({csv:Eh,tsv:Ay,md:vo}[_]||vo)(L),H=new ClipboardItem({"text/plain":new Blob([K],{type:"text/plain"}),"text/html":new Blob([U.outerHTML],{type:"text/html"})});await navigator.clipboard.write([H]),c(!0),o(!1),r==null||r(_),f.current=window.setTimeout(()=>c(!1),i)}catch(Y){n==null||n(Y)}};w.useEffect(()=>{let _=(P)=>{let D=P.composedPath();d.current&&!D.includes(d.current)&&o(!1)};return document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_),window.clearTimeout(f.current)}},[]);let C=Et(),I=u?C.CheckIcon:C.CopyIcon;return A.jsxs("div",{className:s("relative"),ref:d,children:[A.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:p,onClick:()=>o(!a),title:g.copyTable,type:"button",children:e!=null?e:A.jsx(I,{height:14,width:14})}),a?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:[A.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>b("md"),title:g.copyTableAsMarkdown,type:"button",children:g.tableFormatMarkdown}),A.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>b("csv"),title:g.copyTableAsCsv,type:"button",children:g.tableFormatCsv}),A.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>b("tsv"),title:g.copyTableAsTsv,type:"button",children:g.tableFormatTsv})]}):null]})};var xh=({children:e,className:t,onDownload:r,onError:n})=>{let i=ce(),[s,a]=w.useState(!1),o=w.useRef(null),{isAnimating:u}=w.useContext(at),c=zt(),d=Et(),f=(p)=>{var g;try{let b=(g=o.current)==null?void 0:g.closest('[data-streamdown="table-wrapper"]'),C=b==null?void 0:b.querySelector("table");if(!C){n==null||n(Error("Table not found"));return}let I=bh(C),_=p==="csv"?Eh(I):vo(I);en(`table.${p==="csv"?"csv":"md"}`,_,p==="csv"?"text/csv":"text/markdown"),a(!1),r==null||r(p)}catch(b){n==null||n(b)}};return w.useEffect(()=>{let p=(g)=>{let b=g.composedPath();o.current&&!b.includes(o.current)&&a(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[]),A.jsxs("div",{className:i("relative"),ref:o,children:[A.jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>a(!s),title:c.downloadTable,type:"button",children:e!=null?e:A.jsx(d.DownloadIcon,{size:14})}),s?A.jsxs("div",{className:i("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[A.jsx("button",{className:i("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("csv"),title:c.downloadTableAsCsv,type:"button",children:c.tableFormatCsv}),A.jsx("button",{className:i("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("markdown"),title:c.downloadTableAsMarkdown,type:"button",children:c.tableFormatMarkdown})]}):null]})},Cy=({children:e,className:t,showCopy:r=!0,showDownload:n=!0})=>{let{Maximize2Icon:i,XIcon:s}=Et(),a=ce(),[o,u]=w.useState(!1),{isAnimating:c}=w.useContext(at),d=zt(),f=()=>{u(!0)},p=()=>{u(!1)};return w.useEffect(()=>{if(o){zo();let g=(b)=>{b.key==="Escape"&&u(!1)};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),qo()}}},[o]),A.jsxs(A.Fragment,{children:[A.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:f,title:d.viewFullscreen,type:"button",children:A.jsx(i,{size:14})}),o?Ho.createPortal(A.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:p,onKeyDown:(g)=>{g.key==="Escape"&&p()},role:"dialog",children:A.jsxs("div",{className:a("flex h-full flex-col"),onClick:(g)=>g.stopPropagation(),onKeyDown:(g)=>g.stopPropagation(),role:"presentation",children:[A.jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[r?A.jsx(Th,{}):null,n?A.jsx(xh,{}):null,A.jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:p,title:d.exitFullscreen,type:"button",children:A.jsx(s,{size:20})})]}),A.jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:A.jsx("table",{className:a("w-full border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})},_y=({children:e,className:t,showControls:r,showCopy:n=!0,showDownload:i=!0,showFullscreen:s=!0,...a})=>{let o=ce(),u=r&&n,c=r&&i,d=r&&s,f=u||c||d;return A.jsxs("div",{className:o("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[f?A.jsxs("div",{className:o("flex items-center justify-end gap-1"),children:[u?A.jsx(Th,{}):null,c?A.jsx(xh,{}):null,d?A.jsx(Cy,{showCopy:u,showDownload:c,children:e}):null]}):null,A.jsx("div",{className:o("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),children:A.jsx("table",{className:o("w-full divide-y divide-border",t),"data-streamdown":"table",...a,children:e})})]})},Sy=/startLine=(\d+)/,Iy=/\bnoLineNumbers\b/,wy=w.lazy(()=>import("./mermaid-GHXKKRXX-hqacyqmt.js").then((e)=>({default:e.Mermaid}))),Ny=/language-([^\s]+)/;function aa(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&(t!=null&&t.position)))return!1;let r=e.position.start,n=t.position.start,i=e.position.end,s=t.position.end;return(r==null?void 0:r.line)===(n==null?void 0:n.line)&&(r==null?void 0:r.column)===(n==null?void 0:n.column)&&(i==null?void 0:i.line)===(s==null?void 0:s.line)&&(i==null?void 0:i.column)===(s==null?void 0:s.column)}function Ie(e,t){return e.className===t.className&&aa(e.node,t.node)}var Bo=(e,t)=>typeof e=="boolean"?e:e[t]!==!1,Ro=(e,t)=>{if(typeof e=="boolean")return e;let r=e.table;return r===!1?!1:r===!0||r===void 0?!0:r[t]!==!1},Qf=(e,t)=>{if(typeof e=="boolean")return e;let r=e.code;return r===!1?!1:r===!0||r===void 0?!0:r[t]!==!1},ra=(e,t)=>{if(typeof e=="boolean")return e;let r=e.mermaid;return r===!1?!1:r===!0||r===void 0?!0:r[t]!==!1},Vo=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("ol",{className:i("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e})},(e,t)=>Ie(e,t));Vo.displayName="MarkdownOl";var kh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("li",{className:i("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e})},(e,t)=>e.className===t.className&&aa(e.node,t.node));kh.displayName="MarkdownLi";var yh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("ul",{className:i("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e})},(e,t)=>Ie(e,t));yh.displayName="MarkdownUl";var Ah=w.memo(({className:e,node:t,...r})=>{let n=ce();return A.jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...r})},(e,t)=>Ie(e,t));Ah.displayName="MarkdownHr";var Ch=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("span",{className:i("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>Ie(e,t));Ch.displayName="MarkdownStrong";var Ly=({children:e,className:t,href:r,node:n,...i})=>{let s=ce(),{linkSafety:a}=w.useContext(at),[o,u]=w.useState(!1),c=r==="streamdown:incomplete-link",d=w.useCallback(async(b)=>{if(!(!(a!=null&&a.enabled&&r)||c)){if(b.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(r)){window.open(r,"_blank","noreferrer");return}u(!0)}},[a,r,c]),f=w.useCallback(()=>{r&&window.open(r,"_blank","noreferrer")},[r]),p=w.useCallback(()=>{u(!1)},[]),g={url:r!=null?r:"",isOpen:o,onClose:p,onConfirm:f};return a!=null&&a.enabled&&r?A.jsxs(A.Fragment,{children:[A.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(g):A.jsx(Ey,{...g})]}):A.jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",href:r,rel:"noreferrer",target:"_blank",...i,children:e})},_h=w.memo(Ly,(e,t)=>Ie(e,t)&&e.href===t.href);_h.displayName="MarkdownA";var Sh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("h1",{className:i("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>Ie(e,t));Sh.displayName="MarkdownH1";var Ih=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("h2",{className:i("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>Ie(e,t));Ih.displayName="MarkdownH2";var wh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("h3",{className:i("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>Ie(e,t));wh.displayName="MarkdownH3";var Nh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("h4",{className:i("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>Ie(e,t));Nh.displayName="MarkdownH4";var Lh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("h5",{className:i("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>Ie(e,t));Lh.displayName="MarkdownH5";var Rh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("h6",{className:i("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>Ie(e,t));Rh.displayName="MarkdownH6";var Oh=w.memo(({children:e,className:t,node:r,...n})=>{let{controls:i}=w.useContext(at),s=Bo(i,"table"),a=Ro(i,"copy"),o=Ro(i,"download"),u=Ro(i,"fullscreen");return A.jsx(_y,{className:t,showControls:s,showCopy:a,showDownload:o,showFullscreen:u,...n,children:e})},(e,t)=>Ie(e,t));Oh.displayName="MarkdownTable";var Dh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("thead",{className:i("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>Ie(e,t));Dh.displayName="MarkdownThead";var Ph=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("tbody",{className:i("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>Ie(e,t));Ph.displayName="MarkdownTbody";var Mh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("tr",{className:i("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>Ie(e,t));Mh.displayName="MarkdownTr";var vh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("th",{className:i("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>Ie(e,t));vh.displayName="MarkdownTh";var Bh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("td",{className:i("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>Ie(e,t));Bh.displayName="MarkdownTd";var Fh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("blockquote",{className:i("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e})},(e,t)=>Ie(e,t));Fh.displayName="MarkdownBlockquote";var Hh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("sup",{className:i("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>Ie(e,t));Hh.displayName="MarkdownSup";var Uh=w.memo(({children:e,className:t,node:r,...n})=>{let i=ce();return A.jsx("sub",{className:i("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>Ie(e,t));Uh.displayName="MarkdownSub";var zh=w.memo(({children:e,className:t,node:r,...n})=>{if("data-footnotes"in n){let i=(a)=>{var o,u;if(!w.isValidElement(a))return!1;let c=Array.isArray(a.props.children)?a.props.children:[a.props.children],d=!1,f=!1;for(let p of c)if(p){if(typeof p=="string")p.trim()!==""&&(d=!0);else if(w.isValidElement(p))if(((o=p.props)==null?void 0:o["data-footnote-backref"])!==void 0)f=!0;else{let g=Array.isArray(p.props.children)?p.props.children:[p.props.children];for(let b of g){if(typeof b=="string"&&b.trim()!==""){d=!0;break}if(w.isValidElement(b)&&((u=b.props)==null?void 0:u["data-footnote-backref"])===void 0){d=!0;break}}}}return f&&!d},s=Array.isArray(e)?e.map((a)=>{if(!w.isValidElement(a))return a;if(a.type===Vo){let o=(Array.isArray(a.props.children)?a.props.children:[a.props.children]).filter((u)=>!i(u));return o.length===0?null:{...a,props:{...a.props,children:o}}}return a}):e;return(Array.isArray(s)?s.some((a)=>a!==null):s!==null)?A.jsx("section",{className:t,...n,children:s}):null}return A.jsx("section",{className:t,...n,children:e})},(e,t)=>Ie(e,t));zh.displayName="MarkdownSection";var Ry=({node:e,className:t,children:r,...n})=>{var i,s;let a=ce(),o=!("data-block"in n),{mermaid:u,controls:c,lineNumbers:d}=w.useContext(at),f=jo(),p=G2(),g=t==null?void 0:t.match(Ny),b=(i=g==null?void 0:g.at(1))!=null?i:"",C=Ty(b);if(o)return A.jsx("code",{className:a("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:r});let I=(s=e==null?void 0:e.properties)==null?void 0:s.metastring,_=I==null?void 0:I.match(Sy),P=_?Number.parseInt(_[1],10):void 0,D=P!==void 0&&P>=1?P:void 0,Y=!(I?Iy.test(I):!1)&&d!==!1,U="";if(w.isValidElement(r)&&r.props&&typeof r.props=="object"&&"children"in r.props&&typeof r.props.children=="string"?U=r.props.children:typeof r=="string"&&(U=r),C){let Z=C.component;return A.jsx(w.Suspense,{fallback:A.jsx($f,{}),children:A.jsx(Z,{code:U,isIncomplete:p,language:b,meta:I})})}if(b==="mermaid"&&f){let Z=Bo(c,"mermaid"),R=ra(c,"download"),oe=ra(c,"copy"),ie=ra(c,"fullscreen"),V=ra(c,"panZoom"),J=Z&&(R||oe||ie);return A.jsx(w.Suspense,{fallback:A.jsx($f,{}),children:A.jsxs("div",{className:a("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-streamdown":"mermaid-block",children:[A.jsx("div",{className:a("flex h-8 items-center text-muted-foreground text-xs"),children:A.jsx("span",{className:a("ml-1 font-mono lowercase"),children:"mermaid"})}),J?A.jsx("div",{className:a("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:A.jsxs("div",{className:a("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:[R?A.jsx(ky,{chart:U,config:u==null?void 0:u.config}):null,oe?A.jsx(Wf,{code:U}):null,ie?A.jsx(yy,{chart:U,config:u==null?void 0:u.config}):null]})}):null,A.jsx("div",{className:a("rounded-md border border-border bg-background"),children:A.jsx(wy,{chart:U,config:u==null?void 0:u.config,showControls:V})})]})})}let L=Bo(c,"code"),K=Qf(c,"download"),H=Qf(c,"copy");return A.jsx(ny,{className:t,code:U,isIncomplete:p,language:b,lineNumbers:Y,startLine:D,children:L?A.jsxs(A.Fragment,{children:[K?A.jsx(my,{code:U,language:b}):null,H?A.jsx(Wf,{}):null]}):null})},qh=w.memo(Ry,(e,t)=>e.className===t.className&&aa(e.node,t.node));qh.displayName="MarkdownCode";var Yh=w.memo(by,(e,t)=>e.className===t.className&&aa(e.node,t.node));Yh.displayName="MarkdownImg";var jh=w.memo(({children:e,node:t,...r})=>{let n=(Array.isArray(e)?e:[e]).filter((i)=>i!=null&&i!=="");if(n.length===1&&w.isValidElement(n[0])){let i=n[0].props.node,s=i==null?void 0:i.tagName;if(s==="img")return A.jsx(A.Fragment,{children:e});if(s==="code"&&"data-block"in n[0].props)return A.jsx(A.Fragment,{children:e})}return A.jsx("p",{...r,children:e})},(e,t)=>Ie(e,t));jh.displayName="MarkdownParagraph";var Oy={ol:Vo,li:kh,ul:yh,hr:Ah,strong:Ch,a:_h,h1:Sh,h2:Ih,h3:wh,h4:Nh,h5:Lh,h6:Rh,table:Oh,thead:Dh,tbody:Ph,tr:Mh,th:vh,td:Bh,blockquote:Fh,code:qh,img:Yh,pre:({children:e})=>w.isValidElement(e)?w.cloneElement(e,{"data-block":"true"}):e,sup:Hh,sub:Uh,p:jh,section:zh},Dy=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Py=/\p{L}/u;function Xf(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 r of t){if(Dy.test(r))return"rtl";if(Py.test(r))return"ltr"}return"ltr"}var My=/^[ \t]{0,3}(`{3,}|~{3,})/,vy=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,Kf=(e)=>{let t=e.split(`
117
117
  `),r=null,n=0;for(let i of t){let s=My.exec(i);if(r===null){if(s){let a=s[1];r=a[0],n=a.length}}else if(s){let a=s[1],o=a[0],u=a.length;o===r&&u>=n&&(r=null,n=0)}}return r!==null},By=(e)=>{let t=e.split(`
118
118
  `);for(let r of t){let n=r.trim();if(n.length>0&&n.includes("|")&&vy.test(n))return!0}return!1},Fy=()=>(e)=>{He(e,"html",(t,r,n)=>{!n||typeof r!="number"||(n.children[r]={type:"text",value:t.value})})},Zf=[],Jf={allowDangerousHtml:!0},na=new WeakMap,Hy=class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(e){let t=this.keyCache.get(e);if(t)return t;let{rehypePlugins:r,remarkPlugins:n,remarkRehypeOptions:i}=e;if(!(r||n||i)){let d="default";return this.keyCache.set(e,d),d}let s=(d)=>{if(!d||d.length===0)return"";let f="";for(let p=0;p<d.length;p+=1){let g=d[p];if(p>0&&(f+=","),Array.isArray(g)){let[b,C]=g;if(typeof b=="function"){let I=na.get(b);I||(I=b.name,na.set(b,I)),f+=I}else f+=String(b);f+=":",f+=JSON.stringify(C)}else if(typeof g=="function"){let b=na.get(g);b||(b=g.name,na.set(g,b)),f+=b}else f+=String(g)}return f},a=s(r),o=s(n),u=i?JSON.stringify(i):"",c=`${o}::${a}::${u}`;return this.keyCache.set(e,c),c}get(e){let t=this.generateCacheKey(e),r=this.cache.get(t);return r&&(this.cache.delete(t),this.cache.set(t,r)),r}set(e,t){let r=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let n=this.cache.keys().next().value;n&&this.cache.delete(n)}this.cache.set(r,t)}clear(){this.cache.clear()}},eh=new Hy,Vh=(e)=>{let t=Uy(e),r=e.children||"",n=t.runSync(t.parse(r),r);return Gy(n,e)},Uy=(e)=>{let t=eh.get(e);if(t)return t;let r=qy(e);return eh.set(e,r),r},zy=(e)=>e.some((t)=>Array.isArray(t)?t[0]===qr:t===qr),qy=(e)=>{let t=e.rehypePlugins||Zf,r=e.remarkPlugins||Zf,n=zy(t)?r:[...r,Fy],i=e.remarkRehypeOptions?{...Jf,...e.remarkRehypeOptions}:Jf;return To().use(zi).use(n).use(Vi,i).use(t)},Yy=(e)=>e,jy=(e,t,r,n)=>{r?e.children.splice(t,1):e.children[t]={type:"text",value:n}},Vy=(e,t)=>{var r;for(let n in vn)if(Object.hasOwn(vn,n)&&Object.hasOwn(e.properties,n)){let i=e.properties[n],s=vn[n];(s===null||s.includes(e.tagName))&&(e.properties[n]=(r=t(String(i||""),n,e))!=null?r:void 0)}},Wy=(e,t,r,n,i,s)=>{let a=!1;return n?a=!n.includes(e.tagName):i&&(a=i.includes(e.tagName)),!a&&s&&typeof t=="number"&&(a=!s(e,t,r)),a},Gy=(e,t)=>{let{allowElement:r,allowedElements:n,disallowedElements:i,skipHtml:s,unwrapDisallowed:a,urlTransform:o}=t;if(r||n||i||s||o){let u=o||Yy;He(e,(c,d,f)=>{if(c.type==="raw"&&f&&typeof d=="number")return jy(f,d,s,c.value),d;if(c.type==="element"&&(Vy(c,u),Wy(c,d,f,n,i,r)&&f&&typeof d=="number"))return a&&c.children?f.children.splice(d,1,...c.children):f.children.splice(d,1),d})}return eo(e,{Fragment:A.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:A.jsx,jsxs:A.jsxs,passKeys:!0,passNode:!0})},$y=/\[\^[\w-]{1,200}\](?!:)/,Qy=/\[\^[\w-]{1,200}\]:/,Xy=/<(\w+)[\s>]/,Ky=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),th=new Map,rh=new Map,Zy=(e)=>{let t=e.toLowerCase(),r=th.get(t);if(r)return r;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return th.set(t,n),n},Jy=(e)=>{let t=e.toLowerCase(),r=rh.get(t);if(r)return r;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return rh.set(t,n),n},nh=(e,t)=>{if(Ky.has(t.toLowerCase()))return 0;let r=e.match(Zy(t));if(!r)return 0;let n=0;for(let i of r)i.trimEnd().endsWith("/>")||(n+=1);return n},ih=(e,t)=>{let r=e.match(Jy(t));return r?r.length:0},e3=(e)=>{let t=0;for(let r=0;r<e.length-1;r+=1)e[r]==="$"&&e[r+1]==="$"&&(t+=1,r+=1);return t},t3=(e)=>{let t=$y.test(e),r=Qy.test(e);if(t||r)return[e];let n=it.lex(e,{gfm:!0}),i=[],s=[],a=!1;for(let o of n){let u=o.raw,c=i.length;if(s.length>0){i[c-1]+=u;let d=s.at(-1),f=nh(u,d),p=ih(u,d);for(let g=0;g<f;g+=1)s.push(d);for(let g=0;g<p;g+=1)s.length>0&&s.at(-1)===d&&s.pop();continue}if(o.type==="html"&&o.block){let d=u.match(Xy);if(d){let f=d[1],p=nh(u,f),g=ih(u,f);p>g&&s.push(f)}}if(c>0&&!a){let d=i[c-1];if(e3(d)%2===1){i[c-1]=d+u;continue}}i.push(u),o.type!=="space"&&(a=o.type==="code")}return i},r3=(e,t)=>{if(!t.length)return e;let r=e;for(let n of t){let i=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");r=r.replace(i,(s,a,o,u)=>{if(!o.includes(`
119
119
 
@@ -126,6 +126,6 @@ Please report this to https://github.com/markedjs/marked.`,e){let n="<p>An error
126
126
  `);return`${a}${d}${u}
127
127
 
128
128
  `})}return r},n3=/([\\`*_~[\]|])/g,i3=(e)=>e.replace(n3,"\\$1"),a3=(e,t)=>{if(!t.length)return e;let r=e;for(let n of t){let i=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");r=r.replace(i,(s,a,o,u)=>{let c=i3(o).replace(/\n\n/g,"&#10;&#10;");return a+c+u})}return r},Wh=(e)=>e.type==="text"?e.value:("children"in e)&&Array.isArray(e.children)?e.children.map(Wh).join(""):"",s3=(e)=>(t)=>{if(!e||e.length===0)return;let r=new Set(e.map((n)=>n.toLowerCase()));He(t,"element",(n)=>{if(r.has(n.tagName.toLowerCase())){let i=Wh(n);n.children=i?[{type:"text",value:i}]:[]}})},o3=()=>(e)=>{He(e,"code",(t)=>{var r,n;t.meta&&(t.data=(r=t.data)!=null?r:{},t.data.hProperties={...(n=t.data.hProperties)!=null?n:{},metastring:t.meta})})},u3=/^[ \t]*<[\w!/?-]/,l3=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,c3=(e)=>typeof e!="string"||e.length===0||!u3.test(e)?e:e.replace(l3,"$1"),ah,sh,oh,uh,ia={...mt,protocols:{...mt.protocols,href:[...(sh=(ah=mt.protocols)==null?void 0:ah.href)!=null?sh:[],"tel"]},attributes:{...mt.attributes,code:[...(uh=(oh=mt.attributes)==null?void 0:oh.code)!=null?uh:[],"metastring"]}},Fo={raw:qr,sanitize:[Sn,ia],harden:[Xo,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:!0}]},d3={gfm:[Di,{}],codeMeta:o3},lh=Object.values(Fo),f3=Object.values(d3),h3={block:" ▋",circle:" ●"},Gh=["github-light","github-dark"],$h={enabled:!0},p3={shikiTheme:Gh,controls:!0,isAnimating:!1,lineNumbers:!0,mode:"streaming",mermaid:void 0,linkSafety:$h},at=w.createContext(p3),Qh=w.memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:r,index:n,isIncomplete:i,dir:s,animatePlugin:a,...o})=>{if(a){let d=a.getLastRenderCharCount();a.setPrevContentLength(d)}let u=typeof e=="string"&&r?c3(e):e,c=A.jsx(Vh,{...o,children:u});return A.jsx(fh.Provider,{value:i,children:s?A.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!1;if(e.components!==t.components){let r=Object.keys(e.components||{}),n=Object.keys(t.components||{});if(r.length!==n.length||r.some((i)=>{var s,a;return((s=e.components)==null?void 0:s[i])!==((a=t.components)==null?void 0:a[i])}))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Qh.displayName="Block";var m3=w.memo(({children:e,mode:t="streaming",dir:r,parseIncompleteMarkdown:n=!0,normalizeHtmlIndentation:i=!1,components:s,rehypePlugins:a=lh,remarkPlugins:o=f3,className:u,shikiTheme:c=Gh,mermaid:d,controls:f=!0,isAnimating:p=!1,animated:g,BlockComponent:b=Qh,parseMarkdownIntoBlocksFn:C=t3,caret:I,plugins:_,remend:P,linkSafety:D=$h,lineNumbers:Y=!0,allowedTags:U,literalTagContent:L,translations:K,icons:H,prefix:Z,onAnimationStart:R,onAnimationEnd:oe,...ie})=>{let V=w.useId(),[J,ee]=w.useTransition(),W=w.useMemo(()=>Q2(Z),[Z]),ae=w.useRef(null),ye=w.useRef(R),Pe=w.useRef(oe);ye.current=R,Pe.current=oe,w.useEffect(()=>{var de,xe,Je;if(t==="static")return;let xt=ae.current;if(ae.current=p,xt===null){p&&((de=ye.current)==null||de.call(ye));return}p&&!xt?(xe=ye.current)==null||xe.call(ye):!p&&xt&&((Je=Pe.current)==null||Je.call(Pe))},[p,t]);let x=w.useMemo(()=>U?Object.keys(U):[],[U]),Ne=w.useMemo(()=>{if(typeof e!="string")return"";let de=t==="streaming"&&n?Cc(e,P):e;return L&&L.length>0&&(de=a3(de,L)),x.length>0&&(de=r3(de,x)),de},[e,t,n,P,x,L]),Me=w.useMemo(()=>C(Ne),[Ne,C]),[S,Le]=w.useState(Me);w.useEffect(()=>{t==="streaming"&&!me?ee(()=>{Le(Me)}):Le(Me)},[Me,t]);let he=t==="streaming"?S:Me,Ce=w.useMemo(()=>r==="auto"?he.map(Xf):void 0,[he,r]),lt=w.useMemo(()=>he.map((de,xe)=>`${V}-${xe}`),[he.length,V]),Te=w.useMemo(()=>g===!0?"true":g?JSON.stringify(g):"",[g]),me=w.useMemo(()=>Te?Te==="true"?Oo():Oo(g):null,[Te]),je=w.useMemo(()=>{var de,xe;return{shikiTheme:(xe=(de=_==null?void 0:_.code)==null?void 0:de.getThemes())!=null?xe:c,controls:f,isAnimating:p,lineNumbers:Y,mode:t,mermaid:d,linkSafety:D}},[c,f,p,Y,t,d,D,_==null?void 0:_.code]),Ke=w.useMemo(()=>K?JSON.stringify(K):"",[K]),Ze=w.useMemo(()=>({...gh,...K}),[Ke]),Tt=w.useMemo(()=>{let{inlineCode:de,...xe}=s!=null?s:{},Je={...Oy,...xe};if(de){let xt=Je.code;Je.code=(ir)=>("data-block"in ir)?xt?w.createElement(xt,ir):null:w.createElement(de,ir)}return Je},[s]),Nt=w.useMemo(()=>{let de=[];return _!=null&&_.cjk&&(de=[...de,..._.cjk.remarkPluginsBefore]),de=[...de,...o],_!=null&&_.cjk&&(de=[...de,..._.cjk.remarkPluginsAfter]),_!=null&&_.math&&(de=[...de,_.math.remarkPlugin]),de},[o,_==null?void 0:_.math,_==null?void 0:_.cjk]),tn=w.useMemo(()=>{var de;let xe=a;if(U&&Object.keys(U).length>0&&a===lh){let Je={...ia,tagNames:[...(de=ia.tagNames)!=null?de:[],...Object.keys(U)],attributes:{...ia.attributes,...U}};xe=[Fo.raw,[Sn,Je],Fo.harden]}return L&&L.length>0&&(xe=[...xe,[s3,L]]),_!=null&&_.math&&(xe=[...xe,_.math.rehypePlugin]),me&&p&&(xe=[...xe,me.rehypePlugin]),xe},[a,_==null?void 0:_.math,me,p,U,L]),Lr=w.useMemo(()=>{if(!p||he.length===0)return!1;let de=he.at(-1);return Kf(de)||By(de)},[p,he]),Wn=w.useMemo(()=>I&&p&&!Lr?{"--streamdown-caret":`"${h3[I]}"`}:void 0,[I,p,Lr]);return t==="static"?A.jsx(Po.Provider,{value:Ze,children:A.jsx(Mo.Provider,{value:_!=null?_:null,children:A.jsx(at.Provider,{value:je,children:A.jsx(Vf,{icons:H,children:A.jsx(Do.Provider,{value:W,children:A.jsx("div",{className:W("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",u),dir:r==="auto"?Xf(Ne):r,children:A.jsx(Vh,{components:Tt,rehypePlugins:tn,remarkPlugins:Nt,...ie,children:Ne})})})})})})}):A.jsx(Po.Provider,{value:Ze,children:A.jsx(Mo.Provider,{value:_!=null?_:null,children:A.jsx(at.Provider,{value:je,children:A.jsx(Vf,{icons:H,children:A.jsx(Do.Provider,{value:W,children:A.jsxs("div",{className:W("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",I&&!Lr?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,u),style:Wn,children:[he.length===0&&I&&p&&A.jsx("span",{}),he.map((de,xe)=>{var Je;let xt=xe===he.length-1,ir=p&&xt&&Kf(de);return A.jsx(b,{animatePlugin:me,components:Tt,content:de,dir:(Je=Ce==null?void 0:Ce[xe])!=null?Je:r!=="auto"?r:void 0,index:xe,isIncomplete:ir,rehypePlugins:tn,remarkPlugins:Nt,shouldNormalizeHtmlIndentation:i,shouldParseIncompleteMarkdown:n,...ie},lt[xe])})]})})})})})})},(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.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);m3.displayName="Streamdown";var g3=({children:e,className:t,minZoom:r=0.5,maxZoom:n=3,zoomStep:i=0.1,showControls:s=!0,initialZoom:a=1,fullscreen:o=!1})=>{let{RotateCcwIcon:u,ZoomInIcon:c,ZoomOutIcon:d}=Et(),f=ce(),p=w.useRef(null),g=w.useRef(null),[b,C]=w.useState(a),[I,_]=w.useState({x:0,y:0}),[P,D]=w.useState(!1),[Y,U]=w.useState({x:0,y:0}),[L,K]=w.useState({x:0,y:0}),H=w.useCallback((W)=>{C((ae)=>Math.max(r,Math.min(n,ae+W)))},[r,n]),Z=w.useCallback(()=>{H(i)},[H,i]),R=w.useCallback(()=>{H(-i)},[H,i]),oe=w.useCallback(()=>{C(a),_({x:0,y:0})},[a]),ie=w.useCallback((W)=>{W.preventDefault();let ae=W.deltaY>0?-i:i;H(ae)},[H,i]),V=w.useCallback((W)=>{if(W.button!==0||W.isPrimary===!1)return;D(!0),U({x:W.clientX,y:W.clientY}),K(I);let ae=W.currentTarget;ae instanceof HTMLElement&&ae.setPointerCapture(W.pointerId)},[I]),J=w.useCallback((W)=>{if(!P)return;W.preventDefault();let ae=W.clientX-Y.x,ye=W.clientY-Y.y;_({x:L.x+ae,y:L.y+ye})},[P,Y,L]),ee=w.useCallback((W)=>{D(!1);let ae=W.currentTarget;ae instanceof HTMLElement&&ae.releasePointerCapture(W.pointerId)},[]);return w.useEffect(()=>{let W=p.current;if(W)return W.addEventListener("wheel",ie,{passive:!1}),()=>{W.removeEventListener("wheel",ie)}},[ie]),w.useEffect(()=>{let W=g.current;if(W&&P)return document.body.style.userSelect="none",W.addEventListener("pointermove",J,{passive:!1}),W.addEventListener("pointerup",ee),W.addEventListener("pointercancel",ee),()=>{document.body.style.userSelect="",W.removeEventListener("pointermove",J),W.removeEventListener("pointerup",ee),W.removeEventListener("pointercancel",ee)}},[P,J,ee]),A.jsxs("div",{className:f("relative flex flex-col",o?"h-full w-full":"min-h-28 w-full",t),ref:p,style:{cursor:P?"grabbing":"grab"},children:[s?A.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",o?"bottom-4 left-4":"bottom-2 left-2"),children:[A.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:b>=n,onClick:Z,title:"Zoom in",type:"button",children:A.jsx(c,{size:16})}),A.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:b<=r,onClick:R,title:"Zoom out",type:"button",children:A.jsx(d,{size:16})}),A.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:oe,title:"Reset zoom and pan",type:"button",children:A.jsx(u,{size:16})})]}):null,A.jsx("div",{className:f("flex-1 origin-center transition-transform duration-150 ease-out",o?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:V,ref:g,role:"application",style:{transform:`translate(${I.x}px, ${I.y}px) scale(${b})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})},b3=({chart:e,className:t,config:r,fullscreen:n=!1,showControls:i=!0})=>{let s=ce(),[a,o]=w.useState(null),[u,c]=w.useState(!1),[d,f]=w.useState(""),[p,g]=w.useState(""),[b,C]=w.useState(0),{mermaid:I}=w.useContext(at),_=jo(),P=I==null?void 0:I.errorComponent,{shouldRender:D,containerRef:Y}=B2({immediate:n});if(w.useEffect(()=>{if(!D)return;if(!_){o("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{o(null),c(!0);let L=_.getMermaid(r),K=e.split("").reduce((R,oe)=>(R<<5)-R+oe.charCodeAt(0)|0,0),H=`mermaid-${Math.abs(K)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:Z}=await L.render(H,e);f(Z),g(Z)}catch(L){if(!(p||d)){let K=L instanceof Error?L.message:"Failed to render Mermaid chart";o(K)}}finally{c(!1)}})()},[e,r,b,D,_]),!(D||d||p))return A.jsx("div",{className:s("my-4 min-h-[200px]",t),ref:Y});if(u&&!d&&!p)return A.jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:Y,children:A.jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[A.jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),A.jsx("span",{className:s("text-sm"),children:"Loading diagram..."})]})});if(a&&!d&&!p)return P?A.jsx("div",{ref:Y,children:A.jsx(P,{chart:e,error:a,retry:()=>C((K)=>K+1)})}):A.jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:Y,children:[A.jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",a]}),A.jsxs("details",{className:s("mt-2"),children:[A.jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),A.jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]});let U=d||p;return A.jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:Y,children:A.jsx(g3,{className:s(n?"size-full overflow-hidden":"overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:0.5,showControls:i,zoomStep:0.1,children:A.jsx("div",{"aria-label":"Mermaid chart",className:s("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:U},role:"img"})})})};
129
- export{Z2 as Ha,Wf as Ia,UP as Ja,at as Ka,m3 as La,b3 as Ma};
129
+ export{Z2 as Ma,Wf as Na,UP as Oa,at as Pa,m3 as Qa,b3 as Ra};
130
130
 
131
- //# debugId=2420F04153D4F33764756E2164756E21
131
+ //# debugId=284AF01591FAE8AD64756E2164756E21