@aseity/markup 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import {createContext,memo,useContext,useMemo,lazy,isValidElement,useId,useTransition,useRef,useEffect,useState,cloneElement,createElement,useCallback,Suspense}from'react';import {harden}from'rehype-harden';import qo from'rehype-raw';import gr,{defaultSchema}from'rehype-sanitize';import ga from'remark-gfm';import {visitParents,SKIP}from'unist-util-visit-parents';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import {urlAttributes}from'html-url-attributes';import Vi from'remark-parse';import Fi from'remark-rehype';import {unified}from'unified';import {visit}from'unist-util-visit';import {Lexer}from'marked';var xr=300,Sr="300px",Rr=500;function zt(e={}){let{immediate:t=false,debounceDelay:n=xr,rootMargin:o=Sr,idleTimeout:r=Rr}=e,[s,i]=useState(false),l=useRef(null),a=useRef(null),d=useRef(null),c=useMemo(()=>u=>{let f=Date.now();return window.setTimeout(()=>{u({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-f))});},1)},[]),p=useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(u,f)=>window.requestIdleCallback(u,f):c,[c]),m=useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?u=>window.cancelIdleCallback(u):u=>{clearTimeout(u);},[]);return useEffect(()=>{if(t){i(true);return}let u=l.current;if(!u)return;a.current&&(clearTimeout(a.current),a.current=null),d.current&&(m(d.current),d.current=null);let f=()=>{a.current&&(clearTimeout(a.current),a.current=null),d.current&&(m(d.current),d.current=null);},h=v=>{d.current=p(C=>{C.timeRemaining()>0||C.didTimeout?(i(true),v.disconnect()):d.current=p(()=>{i(true),v.disconnect();},{timeout:r/2});},{timeout:r});},b=v=>{f(),a.current=window.setTimeout(()=>{var M,A;let C=v.takeRecords();(C.length===0||(A=(M=C.at(-1))==null?void 0:M.isIntersecting)!=null&&A)&&h(v);},n);},g=(v,C)=>{v.isIntersecting?b(C):f();},T=new IntersectionObserver(v=>{for(let C of v)g(C,T);},{rootMargin:o,threshold:0});return T.observe(u),()=>{a.current&&clearTimeout(a.current),d.current&&m(d.current),T.disconnect();}},[t,n,o,r,m,p]),{shouldRender:s,containerRef:l}}var B=(e,t)=>{let n=false,o=false;for(let r=0;r<t;r+=1){if(e[r]==="\\"&&r+1<e.length&&e[r+1]==="`"){r+=1;continue}if(e.substring(r,r+3)==="```"){o=!o,r+=2;continue}!o&&e[r]==="`"&&(n=!n);}return n||o},Er=(e,t)=>{let n=e.substring(t,t+3)==="```",o=t>0&&e.substring(t-1,t+2)==="```",r=t>1&&e.substring(t-2,t+1)==="```";return n||o||r},Ut=e=>{let t=0;for(let n=0;n<e.length;n+=1){if(e[n]==="\\"&&n+1<e.length&&e[n+1]==="`"){n+=1;continue}e[n]==="`"&&!Er(e,n)&&(t+=1);}return t},Y=(e,t)=>{let n=false,o=false,r=-1;for(let s=0;s<e.length;s+=1){if(e[s]==="\\"&&s+1<e.length&&e[s+1]==="`"){s+=1;continue}if(e.substring(s,s+3)==="```"){o=!o,s+=2;continue}if(!o&&e[s]==="`")if(n){if(r<t&&t<s)return true;n=false,r=-1;}else n=true,r=s;}return false};var Br=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,Kt=e=>!e||typeof e!="string"||!e.includes(">")?e:e.replace(Br,(t,n,o,r)=>B(e,r)?t:`${n}\\>${o}`);var qt=/(\*\*)([^*]*\*?)$/,Zt=/(__)([^_]*?)$/,Xt=/(\*\*\*)([^*]*?)$/,Gt=/(\*)([^*]*?)$/,Jt=/(_)([^_]*?)$/,Yt=/(`)([^`]*?)$/,Qt=/(~~)([^~]*?)$/,Q=/^[\s_~*`]*$/,lt=/^[\s]*[-*+][\s]+$/,en=/[\p{L}\p{N}_]/u,tn=/^```[^`\n]*```?$/,nn=/^\*{4,}$/;var on=/(__)([^_]+)_$/,rn=/(~~)([^~]+)~$/;var ct=/~~/g;var ee=e=>{if(!e)return false;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?true:en.test(e)};var sn=(e,t)=>{let n=1;for(let o=t-1;o>=0;o-=1)if(e[o]==="]")n+=1;else if(e[o]==="["&&(n-=1,n===0))return o;return -1},dt=(e,t)=>{let n=1;for(let o=t+1;o<e.length;o+=1)if(e[o]==="[")n+=1;else if(e[o]==="]"&&(n-=1,n===0))return o;return -1},pe=(e,t)=>{let n=false,o=false;for(let r=0;r<e.length&&r<t;r+=1){if(e[r]==="\\"&&e[r+1]==="$"){r+=1;continue}e[r]==="$"&&(e[r+1]==="$"?(o=!o,r+=1,n=false):o||(n=!n));}return n||o},Ar=(e,t)=>{for(let n=t;n<e.length;n+=1){if(e[n]===")")return true;if(e[n]===`
3
+ `)return false}return false},_e=(e,t)=>{for(let n=t-1;n>=0;n-=1){if(e[n]===")")return false;if(e[n]==="(")return n>0&&e[n-1]==="]"?Ar(e,t):false;if(e[n]===`
4
+ `)return false}return false},an=(e,t)=>{for(let n=t-1;n>=0;n-=1){if(e[n]===">")return false;if(e[n]==="<"){let o=n+1<e.length?e[n+1]:"";return o>="a"&&o<="z"||o>="A"&&o<="Z"||o==="/"}if(e[n]===`
5
+ `)return false}return false},$e=(e,t,n)=>{let o=0;for(let a=t-1;a>=0;a-=1)if(e[a]===`
6
+ `){o=a+1;break}let r=e.length;for(let a=t;a<e.length;a+=1)if(e[a]===`
7
+ `){r=a;break}let s=e.substring(o,r),i=0,l=false;for(let a of s)if(a===n)i+=1;else if(a!==" "&&a!==" "){l=true;break}return i>=3&&!l};var Hr=(e,t,n,o)=>n==="\\"||e.includes("$")&&pe(e,t)?true:n!=="*"&&o==="*"?(t<e.length-2?e[t+2]:"")!=="*":!!(n==="*"||n&&o&&ee(n)&&ee(o)||(!n||n===" "||n===" "||n===`
8
+ `)&&(!o||o===" "||o===" "||o===`
9
+ `)),cn=e=>{let t=0,n=false,o=e.length;for(let r=0;r<o;r+=1){if(e[r]==="`"&&r+2<o&&e[r+1]==="`"&&e[r+2]==="`"){n=!n,r+=2;continue}if(n||e[r]!=="*")continue;let s=r>0?e[r-1]:"",i=r<o-1?e[r+1]:"";Hr(e,r,s,i)||(t+=1);}return t},Dr=(e,t,n,o)=>!!(n==="\\"||e.includes("$")&&pe(e,t)||_e(e,t)||an(e,t)||n==="_"||o==="_"||n&&o&&ee(n)&&ee(o)),Or=e=>{let t=0,n=false,o=e.length;for(let r=0;r<o;r+=1){if(e[r]==="`"&&r+2<o&&e[r+1]==="`"&&e[r+2]==="`"){n=!n,r+=2;continue}if(n||e[r]!=="_")continue;let s=r>0?e[r-1]:"",i=r<o-1?e[r+1]:"";Dr(e,r,s,i)||(t+=1);}return t},_r=e=>{let t=0,n=0,o=false;for(let r=0;r<e.length;r+=1){if(e[r]==="`"&&r+2<e.length&&e[r+1]==="`"&&e[r+2]==="`"){n>=3&&(t+=Math.floor(n/3)),n=0,o=!o,r+=2;continue}o||(e[r]==="*"?n+=1:(n>=3&&(t+=Math.floor(n/3)),n=0));}return n>=3&&(t+=Math.floor(n/3)),t},mt=e=>{let t=0,n=false;for(let o=0;o<e.length;o+=1){if(e[o]==="`"&&o+2<e.length&&e[o+1]==="`"&&e[o+2]==="`"){n=!n,o+=2;continue}n||e[o]==="*"&&o+1<e.length&&e[o+1]==="*"&&(t+=1,o+=1);}return t},ln=e=>{let t=0,n=false;for(let o=0;o<e.length;o+=1){if(e[o]==="`"&&o+2<e.length&&e[o+1]==="`"&&e[o+2]==="`"){n=!n,o+=2;continue}n||e[o]==="_"&&o+1<e.length&&e[o+1]==="_"&&(t+=1,o+=1);}return t},$r=(e,t,n)=>{if(!t||Q.test(t))return true;let r=e.substring(0,n).lastIndexOf(`
10
+ `),s=r===-1?0:r+1,i=e.substring(s,n);return lt.test(i)&&t.includes(`
11
+ `)?true:$e(e,n,"*")},dn=e=>{let t=e.match(qt);if(!t)return e;let n=t[2],o=e.lastIndexOf(t[1]);return B(e,o)||Y(e,o)||$r(e,n,o)?e:mt(e)%2===1?n.endsWith("*")?`${e}*`:`${e}**`:e},Vr=(e,t,n)=>{if(!t||Q.test(t))return true;let r=e.substring(0,n).lastIndexOf(`
12
+ `),s=r===-1?0:r+1,i=e.substring(s,n);return lt.test(i)&&t.includes(`
13
+ `)?true:$e(e,n,"_")},mn=e=>{let t=e.match(Zt);if(!t){let s=e.match(on);if(s){let i=e.lastIndexOf(s[1]);if(!(B(e,i)||Y(e,i))&&ln(e)%2===1)return `${e}_`}return e}let n=t[2],o=e.lastIndexOf(t[1]);return B(e,o)||Y(e,o)||Vr(e,n,o)?e:ln(e)%2===1?`${e}__`:e},Fr=e=>{let t=false;for(let n=0;n<e.length;n+=1){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){t=!t,n+=2;continue}if(!t&&e[n]==="*"&&e[n-1]!=="*"&&e[n+1]!=="*"&&e[n-1]!=="\\"&&!pe(e,n)){let o=n>0?e[n-1]:"",r=n<e.length-1?e[n+1]:"";if((!o||o===" "||o===" "||o===`
14
+ `)&&(!r||r===" "||r===" "||r===`
15
+ `)||o&&r&&ee(o)&&ee(r))continue;return n}}return -1},un=e=>{if(!e.match(Gt))return e;let n=Fr(e);if(n===-1||B(e,n)||Y(e,n))return e;let o=e.substring(n+1);return !o||Q.test(o)?e:cn(e)%2===1?`${e}*`:e},pn=e=>{let t=false;for(let n=0;n<e.length;n+=1){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){t=!t,n+=2;continue}if(!t&&e[n]==="_"&&e[n-1]!=="_"&&e[n+1]!=="_"&&e[n-1]!=="\\"&&!pe(e,n)&&!_e(e,n)){let o=n>0?e[n-1]:"",r=n<e.length-1?e[n+1]:"";if(o&&r&&ee(o)&&ee(r))continue;return n}}return -1},jr=e=>{let t=e.length;for(;t>0&&e[t-1]===`
16
+ `;)t-=1;if(t<e.length){let n=e.slice(0,t),o=e.slice(t);return `${n}_${o}`}return `${e}_`},Wr=e=>{if(!e.endsWith("**"))return null;let t=e.slice(0,-2);if(mt(t)%2!==1)return null;let o=t.indexOf("**"),r=pn(t);return o!==-1&&r!==-1&&o<r?`${t}_**`:null},fn=e=>{if(!e.match(Jt))return e;let n=pn(e);if(n===-1)return e;let o=e.substring(n+1);if(!o||Q.test(o)||B(e,n)||Y(e,n))return e;if(Or(e)%2===1){let s=Wr(e);return s!==null?s:jr(e)}return e},zr=e=>{let t=mt(e),n=cn(e);return t%2===0&&n%2===0},Ur=(e,t,n)=>!t||Q.test(t)||B(e,n)||Y(e,n)?true:$e(e,n,"*"),gn=e=>{if(nn.test(e))return e;let t=e.match(Xt);if(!t)return e;let n=t[2],o=e.lastIndexOf(t[1]);return Ur(e,n,o)?e:_r(e)%2===1?zr(e)?e:`${e}***`:e};var Kr=/<[a-zA-Z/][^>]*$/,bn=e=>{let t=e.match(Kr);return !t||t.index===void 0||B(e,t.index)?e:e.substring(0,t.index).trimEnd()};var qr=e=>!e.match(tn)||e.includes(`
17
+ `)?null:e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e,Zr=e=>(e.match(/```/g)||[]).length%2===1,hn=e=>{let t=qr(e);if(t!==null)return t;let n=e.match(Yt);if(n&&!Zr(e)){let o=n[2];if(!o||Q.test(o))return e;if(Ut(e)%2===1)return `${e}\``}return e};var yn=(e,t)=>t>=2&&e.substring(t-2,t+1)==="```"||t>=1&&e.substring(t-1,t+2)==="```"||t<=e.length-3&&e.substring(t,t+3)==="```",Xr=e=>{let t=0,n=false;for(let o=0;o<e.length-1;o+=1)e[o]==="`"&&!yn(e,o)&&(n=!n),!n&&e[o]==="$"&&e[o+1]==="$"&&(t+=1,o+=1);return t},Gr=e=>{let t=0,n=false;for(let o=0;o<e.length;o+=1){if(e[o]==="\\"){o+=1;continue}if(e[o]==="`"&&!yn(e,o)){n=!n;continue}!n&&e[o]==="$"&&(o+1<e.length&&e[o+1]==="$"?o+=1:t+=1);}return t},Jr=e=>{if(e.endsWith("$")&&!e.endsWith("$$"))return `${e}$`;let t=e.indexOf("$$");return t!==-1&&e.indexOf(`
18
+ `,t)!==-1&&!e.endsWith(`
19
+ `)?`${e}
20
+ $$`:`${e}$$`},Cn=e=>Xr(e)%2===0?e:Jr(e),kn=e=>Gr(e)%2===1?`${e}$`:e;var Yr=(e,t,n)=>{if(e.substring(t+2).includes(")"))return null;let r=sn(e,t);if(r===-1||B(e,r))return null;let s=r>0&&e[r-1]==="!",i=s?r-1:r,l=e.substring(0,i);if(s)return l;let a=e.substring(r+1,t);return n==="text-only"?`${l}${a}`:`${l}[${a}](streamdown:incomplete-link)`},wn=(e,t)=>{for(let n=0;n<t;n++)if(e[n]==="["&&!B(e,n)){if(n>0&&e[n-1]==="!")continue;let o=dt(e,n);if(o===-1)return n;if(o+1<e.length&&e[o+1]==="("){let r=e.indexOf(")",o+2);r!==-1&&(n=r);}}return t},Qr=(e,t,n)=>{let o=t>0&&e[t-1]==="!",r=o?t-1:t;if(!e.substring(t+1).includes("]")){let l=e.substring(0,r);if(o)return l;if(n==="text-only"){let a=wn(e,t);return e.substring(0,a)+e.substring(a+1)}return `${e}](streamdown:incomplete-link)`}if(dt(e,t)===-1){let l=e.substring(0,r);if(o)return l;if(n==="text-only"){let a=wn(e,t);return e.substring(0,a)+e.substring(a+1)}return `${e}](streamdown:incomplete-link)`}return null},ut=(e,t="protocol")=>{let n=e.lastIndexOf("](");if(n!==-1&&!B(e,n)){let o=Yr(e,n,t);if(o!==null)return o}for(let o=e.length-1;o>=0;o-=1)if(e[o]==="["&&!B(e,o)){let r=Qr(e,o,t);if(r!==null)return r}return e};var es=/^-{1,2}$/,ts=/^[\s]*-{1,2}[\s]+$/,ns=/^={1,2}$/,os=/^[\s]*={1,2}[\s]+$/,vn=e=>{if(!e||typeof e!="string")return e;let t=e.lastIndexOf(`
21
+ `);if(t===-1)return e;let n=e.substring(t+1),o=e.substring(0,t),r=n.trim();if(es.test(r)&&!n.match(ts)){let i=o.split(`
22
+ `).at(-1);if(i&&i.trim().length>0)return `${e}\u200B`}if(ns.test(r)&&!n.match(os)){let i=o.split(`
23
+ `).at(-1);if(i&&i.trim().length>0)return `${e}\u200B`}return e};var rs=/(?<=[\p{L}\p{N}_])~(?!~)(?=[\p{L}\p{N}_])/gu,In=e=>!e||typeof e!="string"||!e.includes("~")?e:e.replace(rs,(t,n)=>B(e,n)?t:"\\~");var Tn=e=>{var n,o;let t=e.match(Qt);if(t){let r=t[2];if(!r||Q.test(r))return e;let s=e.lastIndexOf(t[1]);if(B(e,s)||Y(e,s))return e;if(((n=e.match(ct))==null?void 0:n.length)%2===1)return `${e}~~`}else {let r=e.match(rn);if(r){let s=e.lastIndexOf(r[0].slice(0,2));if(B(e,s)||Y(e,s))return e;if(((o=e.match(ct))==null?void 0:o.length)%2===1)return `${e}~`}}return e};var pt=e=>e!==false,ss=e=>e===true,F={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100},is=[{handler:{name:"singleTilde",handle:In,priority:F.SINGLE_TILDE},optionKey:"singleTilde"},{handler:{name:"comparisonOperators",handle:Kt,priority:F.COMPARISON_OPERATORS},optionKey:"comparisonOperators"},{handler:{name:"htmlTags",handle:bn,priority:F.HTML_TAGS},optionKey:"htmlTags"},{handler:{name:"setextHeadings",handle:vn,priority:F.SETEXT_HEADINGS},optionKey:"setextHeadings"},{handler:{name:"links",handle:ut,priority:F.LINKS},optionKey:"links",earlyReturn:e=>e.endsWith("](streamdown:incomplete-link)")},{handler:{name:"boldItalic",handle:gn,priority:F.BOLD_ITALIC},optionKey:"boldItalic"},{handler:{name:"bold",handle:dn,priority:F.BOLD},optionKey:"bold"},{handler:{name:"italicDoubleUnderscore",handle:mn,priority:F.ITALIC_DOUBLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"italicSingleAsterisk",handle:un,priority:F.ITALIC_SINGLE_ASTERISK},optionKey:"italic"},{handler:{name:"italicSingleUnderscore",handle:fn,priority:F.ITALIC_SINGLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"inlineCode",handle:hn,priority:F.INLINE_CODE},optionKey:"inlineCode"},{handler:{name:"strikethrough",handle:Tn,priority:F.STRIKETHROUGH},optionKey:"strikethrough"},{handler:{name:"katex",handle:Cn,priority:F.KATEX},optionKey:"katex"},{handler:{name:"inlineKatex",handle:kn,priority:F.INLINE_KATEX},optionKey:"inlineKatex"}],as=e=>{var n;let t=(n=e==null?void 0:e.linkMode)!=null?n:"protocol";return is.filter(({handler:o,optionKey:r})=>o.name==="links"?pt(e==null?void 0:e.links)||pt(e==null?void 0:e.images):o.name==="inlineKatex"?ss(e==null?void 0:e.inlineKatex):pt(e==null?void 0:e[r])).map(({handler:o,earlyReturn:r})=>o.name==="links"?{handler:{...o,handle:s=>ut(s,t)},earlyReturn:t==="protocol"?r:void 0}:{handler:o,earlyReturn:r})},ls=(e,t)=>{var i;if(!e||typeof e!="string")return e;let n=e.endsWith(" ")&&!e.endsWith(" ")?e.slice(0,-1):e,o=as(t),r=((i=t==null?void 0:t.handlers)!=null?i:[]).map(l=>{var a;return {handler:{...l,priority:(a=l.priority)!=null?a:F.DEFAULT},earlyReturn:void 0}}),s=[...o,...r].sort((l,a)=>{var d,c;return ((d=l.handler.priority)!=null?d:0)-((c=a.handler.priority)!=null?c:0)});for(let{handler:l,earlyReturn:a}of s)if(n=l.handle(n),a!=null&&a(n))return n;return n},Pn=ls;var Mn=/\s/,ms=/^\s+$/,us=new Set(["code","pre","svg","math","annotation"]),ps=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",fs=e=>e.some(t=>ps(t)&&us.has(t.tagName)),gs=e=>{let t=[],n="",o=false;for(let r of e){let s=Mn.test(r);s!==o&&n&&(t.push(n),n=""),n+=r,o=s;}return n&&t.push(n),t},bs=e=>{let t=[],n="";for(let o of e)Mn.test(o)?n+=o:(n&&(t.push(n),n=""),t.push(o));return n&&t.push(n),t},hs=(e,t,n,o,r,s)=>{let i=`--sd-animation:sd-${t};--sd-duration:${r?0:n}ms;--sd-easing:${o}`;return s&&(i+=`;--sd-delay:${s}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":true,style:i},children:[{type:"text",value:e}]}},ys=(e,t,n,o,r)=>{let s=t.at(-1);if(!(s&&"children"in s))return;if(fs(t))return SKIP;let i=s,l=i.children.indexOf(e);if(l===-1)return;let a=e.value;if(!a.trim()){r.count+=a.length;return}let d=n.sep==="char"?bs(a):gs(a),c=o.prevContentLength,p=d.map(m=>{let u=r.count;if(r.count+=m.length,ms.test(m))return {type:"text",value:m};let f=c>0&&u<c,h=f?0:r.newIndex++*n.stagger;return hs(m,n.animation,n.duration,n.easing,f,h)});return i.children.splice(l,1,...p),l+p.length},Cs=0;function ve(e){var s,i,l,a,d;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",duration:(i=e==null?void 0:e.duration)!=null?i:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(a=e==null?void 0:e.sep)!=null?a:"word",stagger:(d=e==null?void 0:e.stagger)!=null?d:40},n={prevContentLength:0,lastRenderCharCount:0},o=Cs++,r=()=>c=>{let p={count:0,newIndex:0};visitParents(c,"text",(m,u)=>ys(m,u,t,n,p)),n.lastRenderCharCount=p.count,n.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${o}`}),{name:"animate",type:"animate",rehypePlugin:r,setPrevContentLength(c){n.prevContentLength=c;},getLastRenderCharCount(){let c=n.lastRenderCharCount;return n.lastRenderCharCount=0,c}}}ve();var ft=createContext(false),gt=()=>useContext(ft);var Ie=(...e)=>twMerge(clsx(e)),vs=(e,t)=>{if(!e||!t)return t;let n=`${e}:`;return t.split(/\s+/).filter(Boolean).map(o=>o.startsWith(n)?o:`${e}:${o}`).join(" ")},xn=e=>e?(...t)=>vs(e,twMerge(clsx(t))):Ie,q=(e,t,n)=>{let o=typeof t=="string"&&n.startsWith("text/csv")?"\uFEFF":"",r=typeof t=="string"?new Blob([o+t],{type:n}):t,s=URL.createObjectURL(r),i=document.createElement("a");i.href=s,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(s);};var Ve=createContext(Ie),y=()=>useContext(Ve);var Ms=Ie("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"),Ns=e=>{let t={};for(let n of e.split(";")){let o=n.indexOf(":");if(o>0){let r=n.slice(0,o).trim(),s=n.slice(o+1).trim();r&&s&&(t[r]=s);}}return t},Rn=memo(({children:e,result:t,language:n,className:o,startLine:r,lineNumbers:s=true,...i})=>{let l=y(),a=useMemo(()=>l(Ms),[l]),d=useMemo(()=>{let c={};return t.bg&&(c["--sdm-bg"]=t.bg),t.fg&&(c["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(c,Ns(t.rootStyle)),c},[t.bg,t.fg,t.rootStyle]);return jsx("div",{className:l(o,"overflow-x-auto rounded-md border border-border bg-background p-4 text-sm"),"data-language":n,"data-streamdown":"code-block-body",...i,children:jsx("pre",{className:l(o,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:d,children:jsx("code",{className:s?l("[counter-increment:line_0] [counter-reset:line]"):void 0,style:s&&r&&r>1?{counterReset:`line ${r-1}`}:void 0,children:t.tokens.map((c,p)=>jsx("span",{className:s?a:void 0,children:c.length===0||c.length===1&&c[0].content===""?`
24
+ `:c.map((m,u)=>{let f={},h=!!m.bgColor;if(m.color&&(f["--sdm-c"]=m.color),m.bgColor&&(f["--sdm-tbg"]=m.bgColor),m.htmlStyle)for(let[b,g]of Object.entries(m.htmlStyle))b==="color"?f["--sdm-c"]=g:b==="background-color"?(f["--sdm-tbg"]=g,h=true):f[b]=g;return jsx("span",{className:l("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",h&&"bg-[var(--sdm-tbg)]",h&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:f,...m.htmlAttrs,children:m.content},u)})},p))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers);var bt=({className:e,language:t,style:n,isIncomplete:o,...r})=>{let s=y();return jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":o||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...r})};var ht=createContext({code:""}),Fe=()=>useContext(ht);var yt=({language:e})=>{let t=y();return jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var Bs=e=>{let t=e.length;for(;t>0&&e[t-1]===`
25
+ `;)t--;return e.slice(0,t)},As=lazy(()=>import('./highlighted-body-CAAXJP3W.js').then(e=>({default:e.HighlightedCodeBlockBody}))),Ct=({code:e,language:t,className:n,children:o,isIncomplete:r=false,startLine:s,lineNumbers:i,...l})=>{let a=y(),d=useMemo(()=>Bs(e),[e]),c=useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
26
+ `).map(p=>[{content:p,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]);return jsx(ht.Provider,{value:{code:e},children:jsxs(bt,{isIncomplete:r,language:t,children:[jsx(yt,{language:t}),o?jsx("div",{className:a("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsx("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":"code-block-actions",children:o})}):null,jsx(Suspense,{fallback:jsx(Rn,{className:n,language:t,lineNumbers:i,result:c,startLine:s,...l}),children:jsx(As,{className:n,code:d,language:t,lineNumbers:i,raw:c,startLine:s,...l})})]})})};var An=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),Hn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),Dn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),On=e=>jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),_n=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),$n=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),Vn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),Fn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),jn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),Wn=e=>jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var Pe={CheckIcon:An,CopyIcon:Hn,DownloadIcon:Dn,ExternalLinkIcon:Fn,Loader2Icon:On,Maximize2Icon:_n,RotateCcwIcon:$n,XIcon:Vn,ZoomInIcon:jn,ZoomOutIcon:Wn},Un=createContext(Pe),$s=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let n=Object.keys(e),o=Object.keys(t);return n.length!==o.length?false:n.every(r=>e[r]===t[r])},kt=({icons:e,children:t})=>{let n=useRef(e),o=useRef(e?{...Pe,...e}:Pe);$s(n.current,e)||(n.current=e,o.current=e?{...Pe,...e}:Pe);let r=o.current;return jsx(Un.Provider,{value:r,children:t})},x=()=>useContext(Un);var je={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"},We=createContext(je),H=()=>useContext(We);var ze=({onCopy:e,onError:t,timeout:n=2e3,children:o,className:r,code:s,...i})=>{let l=y(),[a,d]=useState(false),c=useRef(0),{code:p}=Fe(),{isAnimating:m}=useContext(S),u=H(),f=s!=null?s:p,h=async()=>{var T;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{a||(await navigator.clipboard.writeText(f),d(!0),e==null||e(),c.current=window.setTimeout(()=>d(!1),n));}catch(v){t==null||t(v);}};useEffect(()=>()=>{window.clearTimeout(c.current);},[]);let b=x(),g=a?b.CheckIcon:b.CopyIcon;return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:m,onClick:h,title:u.copyCode,type:"button",...i,children:o!=null?o:jsx(g,{size:14})})};var qn={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",\u6587\u8A00:"wy"},wt=({onDownload:e,onError:t,language:n,children:o,className:r,code:s,...i})=>{let l=y(),{code:a}=Fe(),{isAnimating:d}=useContext(S),c=H(),p=x(),m=s!=null?s:a,f=`file.${n&&n in qn?qn[n]:"txt"}`,h="text/plain",b=()=>{try{q(f,m,h),e==null||e();}catch(g){t==null||t(g);}};return jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:d,onClick:b,title:c.downloadFile,type:"button",...i,children:o!=null?o:jsx(p.DownloadIcon,{size:14})})};var Ue=()=>{let{Loader2Icon:e}=x(),t=y();return jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:jsx(e,{className:t("size-4 animate-spin")})})]})};var Js=/\.[^/.]+$/,Jn=({node:e,className:t,src:n,alt:o,onLoad:r,onError:s,...i})=>{let{DownloadIcon:l}=x(),a=y(),d=useRef(null),[c,p]=useState(false),[m,u]=useState(false),f=H(),h=i.width!=null||i.height!=null,b=(c||h)&&!m,g=m&&!h;useEffect(()=>{let P=d.current;if(P!=null&&P.complete){let M=P.naturalWidth>0;p(M),u(!M);}},[]);let T=useCallback(P=>{p(true),u(false),r==null||r(P);},[r]),v=useCallback(P=>{p(false),u(true),s==null||s(P);},[s]),C=async()=>{if(n)try{let M=await(await fetch(n)).blob(),R=new URL(n,window.location.origin).pathname.split("/").pop()||"",j=R.split(".").pop(),V=R.includes(".")&&j!==void 0&&j.length<=4,W="";if(V)W=R;else {let D=M.type,z="png";D.includes("jpeg")||D.includes("jpg")?z="jpg":D.includes("png")?z="png":D.includes("svg")?z="svg":D.includes("gif")?z="gif":D.includes("webp")&&(z="webp"),W=`${(o||R||"image").replace(Js,"")}.${z}`;}q(W,M,M.type);}catch(P){window.open(n,"_blank");}};return n?jsxs("div",{className:a("group relative my-4 inline-block"),"data-streamdown":"image-wrapper",children:[jsx("img",{alt:o,className:a("max-w-full rounded-lg",g&&"hidden",t),"data-streamdown":"image",onError:v,onLoad:T,ref:d,src:n,...i}),g&&jsx("span",{className:a("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:f.imageNotAvailable}),jsx("div",{className:a("pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block")}),b&&jsx("button",{className:a("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:C,title:f.downloadImage,type:"button",children:jsx(l,{size:14})})]}):null};var Ne=0,fe=()=>{Ne+=1,Ne===1&&(document.body.style.overflow="hidden");},ge=()=>{Ne=Math.max(0,Ne-1),Ne===0&&(document.body.style.overflow="");};var eo=({url:e,isOpen:t,onClose:n,onConfirm:o})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:i,XIcon:l}=x(),a=y(),[d,c]=useState(false),p=H(),m=useCallback(async()=>{try{await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3);}catch(f){}},[e]),u=useCallback(()=>{o(),n();},[o,n]);return useEffect(()=>{if(t){fe();let f=h=>{h.key==="Escape"&&n();};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f),ge();}}},[t,n]),t?jsx("div",{className:a("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:n,onKeyDown:f=>{f.key==="Escape"&&n();},role:"button",tabIndex:0,children:jsxs("div",{className:a("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:f=>f.stopPropagation(),onKeyDown:f=>f.stopPropagation(),role:"presentation",children:[jsx("button",{className:a("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:n,title:p.close,type:"button",children:jsx(l,{size:16})}),jsxs("div",{className:a("flex flex-col gap-2"),children:[jsxs("div",{className:a("flex items-center gap-2 font-semibold text-lg"),children:[jsx(i,{size:20}),jsx("span",{children:p.openExternalLink})]}),jsx("p",{className:a("text-muted-foreground text-sm"),children:p.externalLinkWarning})]}),jsx("div",{className:a("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),jsxs("div",{className:a("flex gap-2"),children:[jsx("button",{className:a("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:m,type:"button",children:d?jsxs(Fragment,{children:[jsx(r,{size:14}),jsx("span",{children:p.copied})]}):jsxs(Fragment,{children:[jsx(s,{size:14}),jsx("span",{children:p.copyLink})]})}),jsxs("button",{className:a("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:u,type:"button",children:[jsx(i,{size:14}),jsx("span",{children:p.openLink})]})]})]})}):null};var Ke=createContext(null),It=()=>useContext(Ke),Dc=()=>{var t;let e=It();return (t=e==null?void 0:e.code)!=null?t:null},be=()=>{var t;let e=It();return (t=e==null?void 0:e.mermaid)!=null?t:null};var to=e=>{var n;let t=It();return t!=null&&t.renderers&&e&&(n=t.renderers.find(o=>Array.isArray(o.language)?o.language.includes(e):o.language===e))!=null?n:null};var no=(e,t)=>{var o;let n=(o=void 0)!=null?o:5;return new Promise((r,s)=>{let i="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),l=new Image;l.crossOrigin="anonymous",l.onload=()=>{let a=document.createElement("canvas"),d=l.width*n,c=l.height*n;a.width=d,a.height=c;let p=a.getContext("2d");if(!p){s(new Error("Failed to create 2D canvas context for PNG export"));return}p.drawImage(l,0,0,d,c),a.toBlob(m=>{if(!m){s(new Error("Failed to create PNG blob"));return}r(m);},"image/png");},l.onerror=()=>s(new Error("Failed to load SVG image")),l.src=i;})};var ro=({chart:e,children:t,className:n,onDownload:o,config:r,onError:s})=>{let i=y(),[l,a]=useState(false),d=useRef(null),{isAnimating:c}=useContext(S),p=x(),m=be(),u=H(),f=async h=>{try{if(h==="mmd"){q("diagram.mmd",e,"text/plain"),a(!1),o==null||o(h);return}if(!m){s==null||s(new Error("Mermaid plugin not available"));return}let b=m.getMermaid(r),g=e.split("").reduce((C,P)=>(C<<5)-C+P.charCodeAt(0)|0,0),T=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:v}=await b.render(T,e);if(!v){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(h==="svg"){q("diagram.svg",v,"image/svg+xml"),a(!1),o==null||o(h);return}if(h==="png"){let C=await no(v);q("diagram.png",C,"image/png"),o==null||o(h),a(!1);return}}catch(b){s==null||s(b);}};return useEffect(()=>{let h=b=>{let g=b.composedPath();d.current&&!g.includes(d.current)&&a(false);};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h);}},[]),jsxs("div",{className:i("relative"),ref:d,children:[jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:c,onClick:()=>a(!l),title:u.downloadDiagram,type:"button",children:t!=null?t:jsx(p.DownloadIcon,{size:14})}),l?jsxs("div",{className:i("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:i("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("svg"),title:u.downloadDiagramAsSvg,type:"button",children:u.mermaidFormatSvg}),jsx("button",{className:i("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("png"),title:u.downloadDiagramAsPng,type:"button",children:u.mermaidFormatPng}),jsx("button",{className:i("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("mmd"),title:u.downloadDiagramAsMmd,type:"button",children:u.mermaidFormatMmd})]}):null]})};var lo=({chart:e,config:t,onFullscreen:n,onExit:o,className:r,...s})=>{let{Maximize2Icon:i,XIcon:l}=x(),a=y(),[d,c]=useState(false),{isAnimating:p,controls:m}=useContext(S),u=H(),f=(()=>{if(typeof m=="boolean")return m;let b=m.mermaid;return b===false?false:b===true||b===void 0?true:b.panZoom!==false})(),h=()=>{c(!d);};return useEffect(()=>{if(d){fe();let b=g=>{g.key==="Escape"&&c(false);};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),ge();}}},[d]),useEffect(()=>{d?n==null||n():o&&o();},[d,n,o]),jsxs(Fragment,{children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:p,onClick:h,title:u.viewFullscreen,type:"button",...s,children:jsx(i,{size:14})}),d?createPortal(jsxs("div",{className:a("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),onClick:h,onKeyDown:b=>{b.key==="Escape"&&h();},role:"button",tabIndex:0,children:[jsx("button",{className:a("absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:u.exitFullscreen,type:"button",children:jsx(l,{size:20})}),jsx("div",{className:a("flex size-full items-center justify-center p-4"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:jsx(ao,{chart:e,className:a("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:f})})]}),document.body):null]})};var ye=e=>{var s,i;let t=[],n=[],o=e.querySelectorAll("thead th");for(let l of o)t.push(((s=l.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let l of r){let a=[],d=l.querySelectorAll("td");for(let c of d)a.push(((i=c.textContent)==null?void 0:i.trim())||"");n.push(a);}return {headers:t,rows:n}},le=e=>{let{headers:t,rows:n}=e,o=l=>{let a=false,d=false;for(let c of l){if(c==='"'){a=true,d=true;break}(c===","||c===`
27
+ `)&&(a=true);}return a?d?`"${l.replace(/"/g,'""')}"`:`"${l}"`:l},r=t.length>0?n.length+1:n.length,s=new Array(r),i=0;t.length>0&&(s[i]=t.map(o).join(","),i+=1);for(let l of n)s[i]=l.map(o).join(","),i+=1;return s.join(`
28
+ `)},Tt=e=>{let{headers:t,rows:n}=e,o=l=>{let a=false;for(let c of l)if(c===" "||c===`
29
+ `||c==="\r"){a=true;break}if(!a)return l;let d=[];for(let c of l)c===" "?d.push("\\t"):c===`
30
+ `?d.push("\\n"):c==="\r"?d.push("\\r"):d.push(c);return d.join("")},r=t.length>0?n.length+1:n.length,s=new Array(r),i=0;t.length>0&&(s[i]=t.map(o).join(" "),i+=1);for(let l of n)s[i]=l.map(o).join(" "),i+=1;return s.join(`
31
+ `)},qe=e=>{let t=false;for(let o of e)if(o==="\\"||o==="|"){t=true;break}if(!t)return e;let n=[];for(let o of e)o==="\\"?n.push("\\\\"):o==="|"?n.push("\\|"):n.push(o);return n.join("")},ce=e=>{let{headers:t,rows:n}=e;if(t.length===0)return "";let o=new Array(n.length+2),r=0,s=t.map(l=>qe(l));o[r]=`| ${s.join(" | ")} |`,r+=1;let i=new Array(t.length);for(let l=0;l<t.length;l+=1)i[l]="---";o[r]=`| ${i.join(" | ")} |`,r+=1;for(let l of n)if(l.length<t.length){let a=new Array(t.length);for(let d=0;d<t.length;d+=1)a[d]=d<l.length?qe(l[d]):"";o[r]=`| ${a.join(" | ")} |`,r+=1;}else {let a=l.map(d=>qe(d));o[r]=`| ${a.join(" | ")} |`,r+=1;}return o.join(`
32
+ `)};var Se=({children:e,className:t,onCopy:n,onError:o,timeout:r=2e3})=>{let s=y(),[i,l]=useState(false),[a,d]=useState(false),c=useRef(null),p=useRef(0),{isAnimating:m}=useContext(S),u=H(),f=async g=>{var T,v;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.write)){o==null||o(new Error("Clipboard API not available"));return}try{let C=(v=c.current)==null?void 0:v.closest('[data-streamdown="table-wrapper"]'),P=C==null?void 0:C.querySelector("table");if(!P){o==null||o(new Error("Table not found"));return}let M=ye(P),j=({csv:le,tsv:Tt,md:ce}[g]||ce)(M),V=new ClipboardItem({"text/plain":new Blob([j],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([V]),d(!0),l(!1),n==null||n(g),p.current=window.setTimeout(()=>d(!1),r);}catch(C){o==null||o(C);}};useEffect(()=>{let g=T=>{let v=T.composedPath();c.current&&!v.includes(c.current)&&l(false);};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g),window.clearTimeout(p.current);}},[]);let h=x(),b=a?h.CheckIcon:h.CopyIcon;return jsxs("div",{className:s("relative"),ref:c,children:[jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>l(!i),title:u.copyTable,type:"button",children:e!=null?e:jsx(b,{height:14,width:14})}),i?jsxs("div",{className:s("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("md"),title:u.copyTableAsMarkdown,type:"button",children:u.tableFormatMarkdown}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("csv"),title:u.copyTableAsCsv,type:"button",children:u.tableFormatCsv}),jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>f("tsv"),title:u.copyTableAsTsv,type:"button",children:u.tableFormatTsv})]}):null]})};var bi=({children:e,className:t,onDownload:n,onError:o,format:r="csv",filename:s})=>{let i=y(),{isAnimating:l}=useContext(S),a=H(),d=x(),c=p=>{try{let u=p.currentTarget.closest('[data-streamdown="table-wrapper"]'),f=u==null?void 0:u.querySelector("table");if(!f){o==null||o(new Error("Table not found"));return}let h=ye(f),b="",g="",T="";switch(r){case "csv":b=le(h),g="text/csv",T="csv";break;case "markdown":b=ce(h),g="text/markdown",T="md";break;default:b=le(h),g="text/csv",T="csv";}q(`${s||"table"}.${T}`,b,g),n==null||n();}catch(m){o==null||o(m);}};return 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:l,onClick:c,title:r==="csv"?a.downloadTableAsCsv:a.downloadTableAsMarkdown,type:"button",children:e!=null?e:jsx(d.DownloadIcon,{size:14})})},Re=({children:e,className:t,onDownload:n,onError:o})=>{let r=y(),[s,i]=useState(false),l=useRef(null),{isAnimating:a}=useContext(S),d=H(),c=x(),p=m=>{var u;try{let f=(u=l.current)==null?void 0:u.closest('[data-streamdown="table-wrapper"]'),h=f==null?void 0:f.querySelector("table");if(!h){o==null||o(new Error("Table not found"));return}let b=ye(h),g=m==="csv"?le(b):ce(b);q(`table.${m==="csv"?"csv":"md"}`,g,m==="csv"?"text/csv":"text/markdown"),i(!1),n==null||n(m);}catch(f){o==null||o(f);}};return useEffect(()=>{let m=u=>{let f=u.composedPath();l.current&&!f.includes(l.current)&&i(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),jsxs("div",{className:r("relative"),ref:l,children:[jsx("button",{className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:a,onClick:()=>i(!s),title:d.downloadTable,type:"button",children:e!=null?e:jsx(c.DownloadIcon,{size:14})}),s?jsxs("div",{className:r("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("csv"),title:d.downloadTableAsCsv,type:"button",children:d.tableFormatCsv}),jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>p("markdown"),title:d.downloadTableAsMarkdown,type:"button",children:d.tableFormatMarkdown})]}):null]})};var go=({children:e,className:t,showCopy:n=true,showDownload:o=true})=>{let{Maximize2Icon:r,XIcon:s}=x(),i=y(),[l,a]=useState(false),{isAnimating:d}=useContext(S),c=H(),p=()=>{a(true);},m=()=>{a(false);};return useEffect(()=>{if(l){fe();let u=f=>{f.key==="Escape"&&a(false);};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u),ge();}}},[l]),jsxs(Fragment,{children:[jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:d,onClick:p,title:c.viewFullscreen,type:"button",children:jsx(r,{size:14})}),l?createPortal(jsx("div",{"aria-label":c.viewFullscreen,"aria-modal":"true",className:i("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:m,onKeyDown:u=>{u.key==="Escape"&&m();},role:"dialog",children:jsxs("div",{className:i("flex h-full flex-col"),onClick:u=>u.stopPropagation(),onKeyDown:u=>u.stopPropagation(),role:"presentation",children:[jsxs("div",{className:i("flex items-center justify-end gap-1 p-4"),children:[n?jsx(Se,{}):null,o?jsx(Re,{}):null,jsx("button",{className:i("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:m,title:c.exitFullscreen,type:"button",children:jsx(s,{size:20})})]}),jsx("div",{className:i("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:jsx("table",{className:i("w-full border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})};var ho=({children:e,className:t,showControls:n,showCopy:o=true,showDownload:r=true,showFullscreen:s=true,...i})=>{let l=y(),a=n&&o,d=n&&r,c=n&&s,p=a||d||c;return jsxs("div",{className:l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[p?jsxs("div",{className:l("flex items-center justify-end gap-1"),children:[a?jsx(Se,{}):null,d?jsx(Re,{}):null,c?jsx(go,{showCopy:a,showDownload:d,children:e}):null]}):null,jsx("div",{className:l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),children:jsx("table",{className:l("w-full divide-y divide-border",t),"data-streamdown":"table",...i,children:e})})]})};var Pi=/startLine=(\d+)/,Mi=/\bnoLineNumbers\b/,Ni=lazy(()=>import('./mermaid-AX4LJ3XW.js').then(e=>({default:e.Mermaid}))),Li=/language-([^\s]+)/;function Je(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let n=e.position.start,o=t.position.start,r=e.position.end,s=t.position.end;return (n==null?void 0:n.line)===(o==null?void 0:o.line)&&(n==null?void 0:n.column)===(o==null?void 0:o.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function E(e,t){return e.className===t.className&&Je(e.node,t.node)}var Lt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,Nt=(e,t)=>{if(typeof e=="boolean")return e;let n=e.table;return n===false?false:n===true||n===void 0?true:n[t]!==false},Co=(e,t)=>{if(typeof e=="boolean")return e;let n=e.code;return n===false?false:n===true||n===void 0?true:n[t]!==false},Ze=(e,t)=>{if(typeof e=="boolean")return e;let n=e.mermaid;return n===false?false:n===true||n===void 0?true:n[t]!==false},St=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...o,children:e})},(e,t)=>E(e,t));St.displayName="MarkdownOl";var ko=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("li",{className:r("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...o,children:e})},(e,t)=>e.className===t.className&&Je(e.node,t.node));ko.displayName="MarkdownLi";var wo=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("ul",{className:r("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...o,children:e})},(e,t)=>E(e,t));wo.displayName="MarkdownUl";var vo=memo(({className:e,node:t,...n})=>{let o=y();return jsx("hr",{className:o("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n})},(e,t)=>E(e,t));vo.displayName="MarkdownHr";var Io=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...o,children:e})},(e,t)=>E(e,t));Io.displayName="MarkdownStrong";var xi=({children:e,className:t,href:n,node:o,...r})=>{let s=y(),{linkSafety:i}=useContext(S),[l,a]=useState(false),d=n==="streamdown:incomplete-link",c=useCallback(async f=>{if(!(!(i!=null&&i.enabled&&n)||d)){if(f.preventDefault(),i.onLinkCheck&&await i.onLinkCheck(n)){window.open(n,"_blank","noreferrer");return}a(true);}},[i,n,d]),p=useCallback(()=>{n&&window.open(n,"_blank","noreferrer");},[n]),m=useCallback(()=>{a(false);},[]),u={url:n!=null?n:"",isOpen:l,onClose:m,onConfirm:p};return i!=null&&i.enabled&&n?jsxs(Fragment,{children:[jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":d,"data-streamdown":"link",onClick:c,type:"button",children:e}),i.renderModal?i.renderModal(u):jsx(eo,{...u})]}):jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":d,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...r,children:e})},To=memo(xi,(e,t)=>E(e,t)&&e.href===t.href);To.displayName="MarkdownA";var Po=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("h1",{className:r("mt-4 mb-1 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e})},(e,t)=>E(e,t));Po.displayName="MarkdownH1";var Mo=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("h2",{className:r("mt-4 mb-1 font-semibold text-xl",t),"data-streamdown":"heading-2",...o,children:e})},(e,t)=>E(e,t));Mo.displayName="MarkdownH2";var No=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("h3",{className:r("mt-4 mb-1 font-semibold text-lg",t),"data-streamdown":"heading-3",...o,children:e})},(e,t)=>E(e,t));No.displayName="MarkdownH3";var Lo=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("h4",{className:r("mt-4 mb-1 font-semibold text-base",t),"data-streamdown":"heading-4",...o,children:e})},(e,t)=>E(e,t));Lo.displayName="MarkdownH4";var xo=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("h5",{className:r("mt-1 mb-1 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e})},(e,t)=>E(e,t));xo.displayName="MarkdownH5";var So=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e})},(e,t)=>E(e,t));So.displayName="MarkdownH6";var Ro=memo(({children:e,className:t,node:n,...o})=>{let{controls:r}=useContext(S),s=Lt(r,"table"),i=Nt(r,"copy"),l=Nt(r,"download"),a=Nt(r,"fullscreen");return jsx(ho,{className:t,showControls:s,showCopy:i,showDownload:l,showFullscreen:a,...o,children:e})},(e,t)=>E(e,t));Ro.displayName="MarkdownTable";var Eo=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e})},(e,t)=>E(e,t));Eo.displayName="MarkdownThead";var Bo=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...o,children:e})},(e,t)=>E(e,t));Bo.displayName="MarkdownTbody";var Ao=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...o,children:e})},(e,t)=>E(e,t));Ao.displayName="MarkdownTr";var Ho=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("th",{className:r("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e})},(e,t)=>E(e,t));Ho.displayName="MarkdownTh";var Do=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e})},(e,t)=>E(e,t));Do.displayName="MarkdownTd";var Oo=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e})},(e,t)=>E(e,t));Oo.displayName="MarkdownBlockquote";var _o=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...o,children:e})},(e,t)=>E(e,t));_o.displayName="MarkdownSup";var $o=memo(({children:e,className:t,node:n,...o})=>{let r=y();return jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...o,children:e})},(e,t)=>E(e,t));$o.displayName="MarkdownSub";var Vo=memo(({children:e,className:t,node:n,...o})=>{if("data-footnotes"in o){let s=a=>{var m,u;if(!isValidElement(a))return false;let d=Array.isArray(a.props.children)?a.props.children:[a.props.children],c=false,p=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(c=true);else if(isValidElement(f))if(((m=f.props)==null?void 0:m["data-footnote-backref"])!==void 0)p=true;else {let h=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let b of h){if(typeof b=="string"&&b.trim()!==""){c=true;break}if(isValidElement(b)&&((u=b.props)==null?void 0:u["data-footnote-backref"])===void 0){c=true;break}}}}return p&&!c},i=Array.isArray(e)?e.map(a=>{if(!isValidElement(a))return a;if(a.type===St){let c=(Array.isArray(a.props.children)?a.props.children:[a.props.children]).filter(p=>!s(p));return c.length===0?null:{...a,props:{...a.props,children:c}}}return a}):e;return (Array.isArray(i)?i.some(a=>a!==null):i!==null)?jsx("section",{className:t,...o,children:i}):null}return jsx("section",{className:t,...o,children:e})},(e,t)=>E(e,t));Vo.displayName="MarkdownSection";var Si=({node:e,className:t,children:n,...o})=>{var R,j;let r=y(),s=!("data-block"in o),{mermaid:i,controls:l,lineNumbers:a}=useContext(S),d=be(),c=gt(),p=t==null?void 0:t.match(Li),m=(R=p==null?void 0:p.at(1))!=null?R:"",u=to(m);if(s)return jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:n});let f=(j=e==null?void 0:e.properties)==null?void 0:j.metastring,h=f==null?void 0:f.match(Pi),b=h?Number.parseInt(h[1],10):void 0,g=b!==void 0&&b>=1?b:void 0,v=!(f?Mi.test(f):false)&&a!==false,C="";if(isValidElement(n)&&n.props&&typeof n.props=="object"&&"children"in n.props&&typeof n.props.children=="string"?C=n.props.children:typeof n=="string"&&(C=n),u){let V=u.component;return jsx(Suspense,{fallback:jsx(Ue,{}),children:jsx(V,{code:C,isIncomplete:c,language:m,meta:f})})}if(m==="mermaid"&&d){let V=Lt(l,"mermaid"),W=Ze(l,"download"),D=Ze(l,"copy"),z=Ze(l,"fullscreen"),re=Ze(l,"panZoom"),te=V&&(W||D||z);return jsx(Suspense,{fallback:jsx(Ue,{}),children:jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-streamdown":"mermaid-block",children:[jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:jsx("span",{className:r("ml-1 font-mono lowercase"),children:"mermaid"})}),te?jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"mermaid-block-actions",children:[W?jsx(ro,{chart:C,config:i==null?void 0:i.config}):null,D?jsx(ze,{code:C}):null,z?jsx(lo,{chart:C,config:i==null?void 0:i.config}):null]})}):null,jsx("div",{className:r("rounded-md border border-border bg-background"),children:jsx(Ni,{chart:C,config:i==null?void 0:i.config,showControls:re})})]})})}let P=Lt(l,"code"),M=Co(l,"download"),A=Co(l,"copy");return jsx(Ct,{className:t,code:C,isIncomplete:c,language:m,lineNumbers:v,startLine:g,children:P?jsxs(Fragment,{children:[M?jsx(wt,{code:C,language:m}):null,A?jsx(ze,{}):null]}):null})},Fo=memo(Si,(e,t)=>e.className===t.className&&Je(e.node,t.node));Fo.displayName="MarkdownCode";var jo=memo(Jn,(e,t)=>e.className===t.className&&Je(e.node,t.node));jo.displayName="MarkdownImg";var Wo=memo(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(s=>s!=null&&s!=="");if(r.length===1&&isValidElement(r[0])){let s=r[0].props.node,i=s==null?void 0:s.tagName;if(i==="img")return jsx(Fragment,{children:e});if(i==="code"&&"data-block"in r[0].props)return jsx(Fragment,{children:e})}return jsx("p",{...n,children:e})},(e,t)=>E(e,t));Wo.displayName="MarkdownParagraph";var zo={ol:St,li:ko,ul:wo,hr:vo,strong:Io,a:To,h1:Po,h2:Mo,h3:No,h4:Lo,h5:xo,h6:So,table:Ro,thead:Eo,tbody:Bo,tr:Ao,th:Ho,td:Do,blockquote:Oo,code:Fo,img:jo,pre:({children:e})=>isValidElement(e)?cloneElement(e,{"data-block":"true"}):e,sup:_o,sub:$o,p:Wo,section:Vo};var Ri=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Ei=/\p{L}/u;function Ye(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 n of t){if(Ri.test(n))return "rtl";if(Ei.test(n))return "ltr"}return "ltr"}var Bi=/^[ \t]{0,3}(`{3,}|~{3,})/,Ai=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,Rt=e=>{let t=e.split(`
33
+ `),n=null,o=0;for(let r of t){let s=Bi.exec(r);if(n===null){if(s){let i=s[1];n=i[0],o=i.length;}}else if(s){let i=s[1],l=i[0],a=i.length;l===n&&a>=o&&(n=null,o=0);}}return n!==null},Uo=e=>{let t=e.split(`
34
+ `);for(let n of t){let o=n.trim();if(o.length>0&&o.includes("|")&&Ai.test(o))return true}return false};var Ko=()=>e=>{visit(e,"html",(t,n,o)=>{!o||typeof n!="number"||(o.children[n]={type:"text",value:t.value});});};var Zo=[],Xo={allowDangerousHtml:true},Qe=new WeakMap,Bt=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let n=this.keyCache.get(t);if(n)return n;let o=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(o||r||s)){let p="default";return this.keyCache.set(t,p),p}let i=p=>{if(!p||p.length===0)return "";let m="";for(let u=0;u<p.length;u+=1){let f=p[u];if(u>0&&(m+=","),Array.isArray(f)){let[h,b]=f;if(typeof h=="function"){let g=Qe.get(h);g||(g=h.name,Qe.set(h,g)),m+=g;}else m+=String(h);m+=":",m+=JSON.stringify(b);}else if(typeof f=="function"){let h=Qe.get(f);h||(h=f.name,Qe.set(f,h)),m+=h;}else m+=String(f);}return m},l=i(o),a=i(r),d=s?JSON.stringify(s):"",c=`${a}::${l}::${d}`;return this.keyCache.set(t,c),c}get(t){let n=this.generateCacheKey(t),o=this.cache.get(n);return o&&(this.cache.delete(n),this.cache.set(n,o)),o}set(t,n){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(o,n);}clear(){this.cache.clear();}},Go=new Bt,At=e=>{let t=zi(e),n=e.children||"",o=t.runSync(t.parse(n),n);return Gi(o,e)},zi=e=>{let t=Go.get(e);if(t)return t;let n=Ki(e);return Go.set(e,n),n},Ui=e=>e.some(t=>Array.isArray(t)?t[0]===qo:t===qo),Ki=e=>{let t=e.rehypePlugins||Zo,n=e.remarkPlugins||Zo,o=Ui(t)?n:[...n,Ko],r=e.remarkRehypeOptions?{...Xo,...e.remarkRehypeOptions}:Xo;return unified().use(Vi).use(o).use(Fi,r).use(t)},Jo=e=>e,qi=(e,t,n,o)=>{n?e.children.splice(t,1):e.children[t]={type:"text",value:o};},Zi=(e,t)=>{var n;for(let o in urlAttributes)if(Object.hasOwn(urlAttributes,o)&&Object.hasOwn(e.properties,o)){let r=e.properties[o],s=urlAttributes[o];(s===null||s.includes(e.tagName))&&(e.properties[o]=(n=t(String(r||""),o,e))!=null?n:void 0);}},Xi=(e,t,n,o,r,s)=>{let i=false;return o?i=!o.includes(e.tagName):r&&(i=r.includes(e.tagName)),!i&&s&&typeof t=="number"&&(i=!s(e,t,n)),i},Gi=(e,t)=>{let{allowElement:n,allowedElements:o,disallowedElements:r,skipHtml:s,unwrapDisallowed:i,urlTransform:l}=t;if(n||o||r||s||l){let d=l||Jo;visit(e,(c,p,m)=>{if(c.type==="raw"&&m&&typeof p=="number")return qi(m,p,s,c.value),p;if(c.type==="element"&&(Zi(c,d),Xi(c,p,m,o,r,n)&&m&&typeof p=="number"))return i&&c.children?m.children.splice(p,1,...c.children):m.children.splice(p,1),p});}return toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true})};var Yi=/\[\^[\w-]{1,200}\](?!:)/,Qi=/\[\^[\w-]{1,200}\]:/;var ea=/<(\w+)[\s>]/,ta=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Yo=new Map,Qo=new Map,na=e=>{let t=e.toLowerCase(),n=Yo.get(t);if(n)return n;let o=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return Yo.set(t,o),o},oa=e=>{let t=e.toLowerCase(),n=Qo.get(t);if(n)return n;let o=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return Qo.set(t,o),o},er=(e,t)=>{if(ta.has(t.toLowerCase()))return 0;let n=e.match(na(t));if(!n)return 0;let o=0;for(let r of n)r.trimEnd().endsWith("/>")||(o+=1);return o},tr=(e,t)=>{let n=e.match(oa(t));return n?n.length:0},ra=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]==="$"&&e[n+1]==="$"&&(t+=1,n+=1);return t},Ht=e=>{let t=Yi.test(e),n=Qi.test(e);if(t||n)return [e];let o=Lexer.lex(e,{gfm:true}),r=[],s=[],i=false;for(let l of o){let a=l.raw,d=r.length;if(s.length>0){r[d-1]+=a;let c=s.at(-1),p=er(a,c),m=tr(a,c);for(let u=0;u<p;u+=1)s.push(c);for(let u=0;u<m;u+=1)s.length>0&&s.at(-1)===c&&s.pop();continue}if(l.type==="html"&&l.block){let c=a.match(ea);if(c){let p=c[1],m=er(a,p),u=tr(a,p);m>u&&s.push(p);}}if(d>0&&!i){let c=r[d-1];if(ra(c)%2===1){r[d-1]=c+a;continue}}r.push(a),l.type!=="space"&&(i=l.type==="code");}return r};var nr=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t){let r=new RegExp(`(<${o}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${o}\\s*>)`,"gi");n=n.replace(r,(s,i,l,a)=>{if(!l.includes(`
35
+
36
+ `))return i+l+a;let d=l.replace(/\n\n/g,`
37
+ <!---->
38
+ `),c=(d.startsWith(`
39
+ `)?"":`
40
+ `)+d+(d.endsWith(`
41
+ `)?"":`
42
+ `);return `${i}${c}${a}
43
+
44
+ `});}return n};var sa=/([\\`*_~[\]|])/g,ia=e=>e.replace(sa,"\\$1"),or=(e,t)=>{if(!t.length)return e;let n=e;for(let o of t){let r=new RegExp(`(<${o}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${o}\\s*>)`,"gi");n=n.replace(r,(s,i,l,a)=>{let d=ia(l).replace(/\n\n/g,"&#10;&#10;");return i+d+a});}return n};var rr=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(rr).join(""):"",sr=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(o=>o.toLowerCase()));visit(t,"element",o=>{if(n.has(o.tagName.toLowerCase())){let r=rr(o);o.children=r?[{type:"text",value:r}]:[];}});};var ir=()=>e=>{visit(e,"code",t=>{var n,o;t.meta&&(t.data=(n=t.data)!=null?n:{},t.data.hProperties={...(o=t.data.hProperties)!=null?o:{},metastring:t.meta});});};var ba=/^[ \t]*<[\w!/?-]/,ha=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,ya=e=>typeof e!="string"||e.length===0||!ba.test(e)?e:e.replace(ha,"$1"),dr,mr,ur,pr,et={...defaultSchema,protocols:{...defaultSchema.protocols,href:[...(mr=(dr=defaultSchema.protocols)==null?void 0:dr.href)!=null?mr:[],"tel"]},attributes:{...defaultSchema.attributes,code:[...(pr=(ur=defaultSchema.attributes)==null?void 0:ur.code)!=null?pr:[],"metastring"]}},Ot={raw:qo,sanitize:[gr,et],harden:[harden,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:true}]},Ca={gfm:[ga,{}],codeMeta:ir},cr=Object.values(Ot),ka=Object.values(Ca),wa={block:" \u258B",circle:" \u25CF"},br=["github-light","github-dark"],hr={enabled:true},va={shikiTheme:br,controls:true,isAnimating:false,lineNumbers:true,mode:"streaming",mermaid:void 0,linkSafety:hr},S=createContext(va),yr=memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:o,isIncomplete:r,dir:s,animatePlugin:i,...l})=>{if(i){let c=i.getLastRenderCharCount();i.setPrevContentLength(c);}let a=typeof e=="string"&&n?ya(e):e,d=jsx(At,{...l,children:a});return jsx(ft.Provider,{value:r,children:s?jsx("div",{dir:s,style:{display:"contents"},children:d}):d})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return false;if(e.components!==t.components){let n=Object.keys(e.components||{}),o=Object.keys(t.components||{});if(n.length!==o.length||n.some(r=>{var s,i;return ((s=e.components)==null?void 0:s[r])!==((i=t.components)==null?void 0:i[r])}))return false}return !(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});yr.displayName="Block";var Ia=memo(({children:e,mode:t="streaming",dir:n,parseIncompleteMarkdown:o=true,normalizeHtmlIndentation:r=false,components:s,rehypePlugins:i=cr,remarkPlugins:l=ka,className:a,shikiTheme:d=br,mermaid:c,controls:p=true,isAnimating:m=false,animated:u,BlockComponent:f=yr,parseMarkdownIntoBlocksFn:h=Ht,caret:b,plugins:g,remend:T,linkSafety:v=hr,lineNumbers:C=true,allowedTags:P,literalTagContent:M,translations:A,icons:R,prefix:j,onAnimationStart:V,onAnimationEnd:W,...D})=>{let z=useId(),[re,te]=useTransition(),I=useMemo(()=>xn(j),[j]),U=useRef(null),X=useRef(V),De=useRef(W);X.current=V,De.current=W,useEffect(()=>{var O,J,se;if(t==="static")return;let w=U.current;if(U.current=m,w===null){m&&((O=X.current)==null||O.call(X));return}m&&!w?(J=X.current)==null||J.call(X):!m&&w&&((se=De.current)==null||se.call(De));},[m,t]);let nt=useMemo(()=>P?Object.keys(P):[],[P]),Oe=useMemo(()=>{if(typeof e!="string")return "";let w=t==="streaming"&&o?Pn(e,T):e;return M&&M.length>0&&(w=or(w,M)),nt.length>0&&(w=nr(w,nt)),w},[e,t,o,T,nt,M]),ke=useMemo(()=>h(Oe),[Oe,h]),[Ir,_t]=useState(ke);useEffect(()=>{t==="streaming"&&!we?te(()=>{_t(ke);}):_t(ke);},[ke,t]);let G=t==="streaming"?Ir:ke,ot=useMemo(()=>n==="auto"?G.map(Ye):void 0,[G,n]),Tr=useMemo(()=>G.map((w,O)=>`${z}-${O}`),[G.length,z]),rt=useMemo(()=>u===true?"true":u?JSON.stringify(u):"",[u]),we=useMemo(()=>rt?rt==="true"?ve():ve(u):null,[rt]),$t=useMemo(()=>{var w,O;return {shikiTheme:(O=(w=g==null?void 0:g.code)==null?void 0:w.getThemes())!=null?O:d,controls:p,isAnimating:m,lineNumbers:C,mode:t,mermaid:c,linkSafety:v}},[d,p,m,C,t,c,v,g==null?void 0:g.code]),Pr=useMemo(()=>A?JSON.stringify(A):"",[A]),Vt=useMemo(()=>({...je,...A}),[Pr]),Ft=useMemo(()=>{let{inlineCode:w,...O}=s!=null?s:{},J={...zo,...O};if(w){let se=J.code;J.code=ue=>"data-block"in ue?se?createElement(se,ue):null:createElement(w,ue);}return J},[s]),jt=useMemo(()=>{let w=[];return g!=null&&g.cjk&&(w=[...w,...g.cjk.remarkPluginsBefore]),w=[...w,...l],g!=null&&g.cjk&&(w=[...w,...g.cjk.remarkPluginsAfter]),g!=null&&g.math&&(w=[...w,g.math.remarkPlugin]),w},[l,g==null?void 0:g.math,g==null?void 0:g.cjk]),Wt=useMemo(()=>{var O;let w=i;if(P&&Object.keys(P).length>0&&i===cr){let J={...et,tagNames:[...(O=et.tagNames)!=null?O:[],...Object.keys(P)],attributes:{...et.attributes,...P}};w=[Ot.raw,[gr,J],Ot.harden];}return M&&M.length>0&&(w=[...w,[sr,M]]),g!=null&&g.math&&(w=[...w,g.math.rehypePlugin]),we&&m&&(w=[...w,we.rehypePlugin]),w},[i,g==null?void 0:g.math,we,m,P,M]),st=useMemo(()=>{if(!m||G.length===0)return false;let w=G.at(-1);return Rt(w)||Uo(w)},[m,G]),Mr=useMemo(()=>b&&m&&!st?{"--streamdown-caret":`"${wa[b]}"`}:void 0,[b,m,st]);return t==="static"?jsx(We.Provider,{value:Vt,children:jsx(Ke.Provider,{value:g!=null?g:null,children:jsx(S.Provider,{value:$t,children:jsx(kt,{icons:R,children:jsx(Ve.Provider,{value:I,children:jsx("div",{className:I("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",a),dir:n==="auto"?Ye(Oe):n,children:jsx(At,{components:Ft,rehypePlugins:Wt,remarkPlugins:jt,...D,children:Oe})})})})})})}):jsx(We.Provider,{value:Vt,children:jsx(Ke.Provider,{value:g!=null?g:null,children:jsx(S.Provider,{value:$t,children:jsx(kt,{icons:R,children:jsx(Ve.Provider,{value:I,children:jsxs("div",{className:I("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",b&&!st?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,a),style:Mr,children:[G.length===0&&b&&m&&jsx("span",{}),G.map((w,O)=>{var ue;let J=O===G.length-1,se=m&&J&&Rt(w);return jsx(f,{animatePlugin:we,components:Ft,content:w,dir:(ue=ot==null?void 0:ot[O])!=null?ue:n!=="auto"?n:void 0,index:O,isIncomplete:se,rehypePlugins:Wt,remarkPlugins:jt,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:o,...D},Tr[O])})]})})})})})})},(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);Ia.displayName="Streamdown";var vr=({children:e,className:t,minZoom:n=.5,maxZoom:o=3,zoomStep:r=.1,showControls:s=true,initialZoom:i=1,fullscreen:l=false})=>{let{RotateCcwIcon:a,ZoomInIcon:d,ZoomOutIcon:c}=x(),p=y(),m=useRef(null),u=useRef(null),[f,h]=useState(i),[b,g]=useState({x:0,y:0}),[T,v]=useState(false),[C,P]=useState({x:0,y:0}),[M,A]=useState({x:0,y:0}),R=useCallback(I=>{h(U=>Math.max(n,Math.min(o,U+I)));},[n,o]),j=useCallback(()=>{R(r);},[R,r]),V=useCallback(()=>{R(-r);},[R,r]),W=useCallback(()=>{h(i),g({x:0,y:0});},[i]),D=useCallback(I=>{I.preventDefault();let U=I.deltaY>0?-r:r;R(U);},[R,r]),z=useCallback(I=>{if(I.button!==0||I.isPrimary===false)return;v(true),P({x:I.clientX,y:I.clientY}),A(b);let U=I.currentTarget;U instanceof HTMLElement&&U.setPointerCapture(I.pointerId);},[b]),re=useCallback(I=>{if(!T)return;I.preventDefault();let U=I.clientX-C.x,X=I.clientY-C.y;g({x:M.x+U,y:M.y+X});},[T,C,M]),te=useCallback(I=>{v(false);let U=I.currentTarget;U instanceof HTMLElement&&U.releasePointerCapture(I.pointerId);},[]);return useEffect(()=>{let I=m.current;if(I)return I.addEventListener("wheel",D,{passive:false}),()=>{I.removeEventListener("wheel",D);}},[D]),useEffect(()=>{let I=u.current;if(I&&T)return document.body.style.userSelect="none",I.addEventListener("pointermove",re,{passive:false}),I.addEventListener("pointerup",te),I.addEventListener("pointercancel",te),()=>{document.body.style.userSelect="",I.removeEventListener("pointermove",re),I.removeEventListener("pointerup",te),I.removeEventListener("pointercancel",te);}},[T,re,te]),jsxs("div",{className:p("relative flex flex-col",l?"h-full w-full":"min-h-28 w-full",t),ref:m,style:{cursor:T?"grabbing":"grab"},children:[s?jsxs("div",{className:p("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",l?"bottom-4 left-4":"bottom-2 left-2"),children:[jsx("button",{className:p("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:f>=o,onClick:j,title:"Zoom in",type:"button",children:jsx(d,{size:16})}),jsx("button",{className:p("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:f<=n,onClick:V,title:"Zoom out",type:"button",children:jsx(c,{size:16})}),jsx("button",{className:p("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:W,title:"Reset zoom and pan",type:"button",children:jsx(a,{size:16})})]}):null,jsx("div",{className:p("flex-1 origin-center transition-transform duration-150 ease-out",l?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:z,ref:u,role:"application",style:{transform:`translate(${b.x}px, ${b.y}px) scale(${f})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})};var ao=({chart:e,className:t,config:n,fullscreen:o=false,showControls:r=true})=>{let s=y(),[i,l]=useState(null),[a,d]=useState(false),[c,p]=useState(""),[m,u]=useState(""),[f,h]=useState(0),{mermaid:b}=useContext(S),g=be(),T=b==null?void 0:b.errorComponent,{shouldRender:v,containerRef:C}=zt({immediate:o});if(useEffect(()=>{if(!v)return;if(!g){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),d(!0);let A=g.getMermaid(n),R=e.split("").reduce((W,D)=>(W<<5)-W+D.charCodeAt(0)|0,0),j=`mermaid-${Math.abs(R)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:V}=await A.render(j,e);p(V),u(V);}catch(A){if(!(m||c)){let R=A instanceof Error?A.message:"Failed to render Mermaid chart";l(R);}}finally{d(false);}})();},[e,n,f,v,g]),!(v||c||m))return jsx("div",{className:s("my-4 min-h-[200px]",t),ref:C});if(a&&!c&&!m)return jsx("div",{className:s("my-4 flex justify-center p-4",t),ref:C,children:jsxs("div",{className:s("flex items-center space-x-2 text-muted-foreground"),children:[jsx("div",{className:s("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),jsx("span",{className:s("text-sm"),children:"Loading diagram..."})]})});if(i&&!c&&!m){let M=()=>h(A=>A+1);return T?jsx("div",{ref:C,children:jsx(T,{chart:e,error:i,retry:M})}):jsxs("div",{className:s("rounded-md bg-red-50 p-4",t),ref:C,children:[jsxs("p",{className:s("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",i]}),jsxs("details",{className:s("mt-2"),children:[jsx("summary",{className:s("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),jsx("pre",{className:s("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let P=c||m;return jsx("div",{className:s("size-full",t),"data-streamdown":"mermaid",ref:C,children:jsx(vr,{className:s(o?"size-full overflow-hidden":"overflow-hidden",t),fullscreen:o,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:jsx("div",{"aria-label":"Mermaid chart",className:s("flex justify-center",o?"size-full items-center":null),dangerouslySetInnerHTML:{__html:P},role:"img"})})})};export{S as A,yr as B,Ia as C,ve as a,gt as b,Rn as c,bt as d,yt as e,Dc as f,Ct as g,je as h,ze as i,wt as j,Ue as k,ao as l,ye as m,le as n,Tt as o,qe as p,ce as q,Se as r,bi as s,Re as t,Ye as u,Jo as v,Ht as w,ya as x,Ot as y,Ca as z};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import {A,f,c}from'./chunk-AIWIVYBM.js';import {useContext,useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';var R=({code:s,language:e,raw:t,className:h,startLine:d,lineNumbers:m,...p})=>{let{shikiTheme:l}=useContext(A),o=f(),[a,i]=useState(t);return useEffect(()=>{if(!o){i(t);return}let r=o.highlight({code:s,language:e,themes:l},c=>{i(c);});r&&i(r);},[s,e,l,o,t]),jsx(c,{className:h,language:e,lineNumbers:m,result:a,startLine:d,...p})};export{R as HighlightedCodeBlockBody};
package/dist/index.d.ts CHANGED
@@ -2,13 +2,68 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
3
  import react__default, { SVGProps, JSX, ComponentType, HTMLAttributes, ComponentProps } from 'react';
4
4
  import { MermaidConfig } from 'mermaid';
5
- import { RemendOptions } from 'remend';
6
5
  import { Pluggable, PluggableList } from 'unified';
7
6
  import { Element, Parents } from 'hast';
8
7
  import { Options as Options$1 } from 'remark-rehype';
9
8
  import { BundledTheme, ThemeRegistrationAny, BundledLanguage } from 'shiki';
10
9
  export { BundledLanguage, BundledTheme, ThemeRegistrationAny } from 'shiki';
11
10
 
11
+ /**
12
+ * Handler function that transforms text during streaming.
13
+ */
14
+ interface RemendHandler {
15
+ /** Handler function: takes text, returns modified text */
16
+ handle: (text: string) => string;
17
+ /** Unique identifier for this handler */
18
+ name: string;
19
+ /** Priority (lower runs first). Built-in priorities: 0-100. Default: 100 */
20
+ priority?: number;
21
+ }
22
+ /**
23
+ * Configuration options for the remend function.
24
+ * Options default to `true` unless noted otherwise.
25
+ * Set an option to `false` to disable that specific completion.
26
+ */
27
+ interface RemendOptions {
28
+ /** Complete bold formatting (e.g., `**text` → `**text**`) */
29
+ bold?: boolean;
30
+ /** Complete bold-italic formatting (e.g., `***text` → `***text***`) */
31
+ boldItalic?: boolean;
32
+ /** Escape > as comparison operators in list items (e.g., `- > 25` → `- \> 25`) */
33
+ comparisonOperators?: boolean;
34
+ /** Custom handlers to extend remend */
35
+ handlers?: RemendHandler[];
36
+ /** Strip incomplete HTML tags at end of streaming text (e.g., `text <custom` → `text`) */
37
+ htmlTags?: boolean;
38
+ /** Complete images (e.g., `![alt](url` → removed) */
39
+ images?: boolean;
40
+ /** Complete inline code formatting (e.g., `` `code `` → `` `code` ``) */
41
+ inlineCode?: boolean;
42
+ /**
43
+ * Complete inline KaTeX math (e.g., `$equation` → `$equation$`).
44
+ * Defaults to `false` — single `$` is ambiguous with currency symbols.
45
+ */
46
+ inlineKatex?: boolean;
47
+ /** Complete italic formatting (e.g., `*text` → `*text*` or `_text` → `_text_`) */
48
+ italic?: boolean;
49
+ /** Complete block KaTeX math (e.g., `$$equation` → `$$equation$$`) */
50
+ katex?: boolean;
51
+ /**
52
+ * How to handle incomplete links:
53
+ * - `'protocol'`: Use `streamdown:incomplete-link` placeholder URL (default)
54
+ * - `'text-only'`: Display only the link text without any link markup
55
+ */
56
+ linkMode?: "protocol" | "text-only";
57
+ /** Complete links and images (e.g., `[text](url` → `[text](streamdown:incomplete-link)`) */
58
+ links?: boolean;
59
+ /** Handle incomplete setext headings to prevent misinterpretation */
60
+ setextHeadings?: boolean;
61
+ /** Escape single ~ between word characters to prevent false strikethrough (e.g., `20~25` → `20\~25`) */
62
+ singleTilde?: boolean;
63
+ /** Complete strikethrough formatting (e.g., `~~text` → `~~text~~`) */
64
+ strikethrough?: boolean;
65
+ }
66
+
12
67
  interface AnimatePlugin {
13
68
  /**
14
69
  * Returns the total HAST text node character count from the last
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export{B as Block,g as CodeBlock,d as CodeBlockContainer,i as CodeBlockCopyButton,j as CodeBlockDownloadButton,e as CodeBlockHeader,k as CodeBlockSkeleton,C as Markup,A as StreamdownContext,r as TableCopyDropdown,s as TableDownloadButton,t as TableDownloadDropdown,a as createAnimatePlugin,y as defaultRehypePlugins,z as defaultRemarkPlugins,h as defaultTranslations,v as defaultUrlTransform,u as detectTextDirection,p as escapeMarkdownTableCell,m as extractTableDataFromElement,x as normalizeHtmlIndentation,w as parseMarkdownIntoBlocks,n as tableDataToCSV,q as tableDataToMarkdown,o as tableDataToTSV,b as useIsCodeFenceIncomplete}from'./chunk-4FHCAHL6.js';
2
+ export{B as Block,g as CodeBlock,d as CodeBlockContainer,i as CodeBlockCopyButton,j as CodeBlockDownloadButton,e as CodeBlockHeader,k as CodeBlockSkeleton,C as Markup,A as StreamdownContext,r as TableCopyDropdown,s as TableDownloadButton,t as TableDownloadDropdown,a as createAnimatePlugin,y as defaultRehypePlugins,z as defaultRemarkPlugins,h as defaultTranslations,v as defaultUrlTransform,u as detectTextDirection,p as escapeMarkdownTableCell,m as extractTableDataFromElement,x as normalizeHtmlIndentation,w as parseMarkdownIntoBlocks,n as tableDataToCSV,q as tableDataToMarkdown,o as tableDataToTSV,b as useIsCodeFenceIncomplete}from'./chunk-AIWIVYBM.js';
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export{l as Mermaid}from'./chunk-AIWIVYBM.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aseity/markup",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -62,7 +62,6 @@
62
62
  "remark-gfm": "^4.0.1",
63
63
  "remark-parse": "^11.0.0",
64
64
  "remark-rehype": "^11.1.2",
65
- "remend": "workspace:*",
66
65
  "tailwind-merge": "^3.4.0",
67
66
  "unified": "^11.0.5",
68
67
  "mermaid": "^11.12.2",