db-studio 1.2.21 → 1.2.22

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 (68) hide show
  1. package/dist/core-dist/assets/{_baseUniq-riwirsMn.js → _baseUniq-BnS4oWxG.js} +1 -1
  2. package/dist/core-dist/assets/{_pathlessLayout-DmCNfa5q.js → _pathlessLayout-J4rDhSFV.js} +2 -2
  3. package/dist/core-dist/assets/{_queryId-DuU-RQq2.js → _queryId-BGnLBhn8.js} +1 -1
  4. package/dist/core-dist/assets/{_table-DKcTbCMo.js → _table-C_4RREBi.js} +1 -1
  5. package/dist/core-dist/assets/{arc-Bmwb62d7.js → arc-BzayzQuy.js} +1 -1
  6. package/dist/core-dist/assets/{architectureDiagram-VXUJARFQ-DAdKU_Vv.js → architectureDiagram-VXUJARFQ-CDKgWmU1.js} +1 -1
  7. package/dist/core-dist/assets/{blockDiagram-VD42YOAC-CKWdAOVU.js → blockDiagram-VD42YOAC-DajA7Gs0.js} +1 -1
  8. package/dist/core-dist/assets/{c4Diagram-YG6GDRKO-B_sL4HQA.js → c4Diagram-YG6GDRKO-DFgrz0k6.js} +1 -1
  9. package/dist/core-dist/assets/{cdoe-editor-DAlfFmLj.js → cdoe-editor-Bv60qmc3.js} +1 -1
  10. package/dist/core-dist/assets/channel-D7_kpMKZ.js +1 -0
  11. package/dist/core-dist/assets/{chunk-4BX2VUAB-Cce3fVJH.js → chunk-4BX2VUAB-B3yeq0dh.js} +1 -1
  12. package/dist/core-dist/assets/{chunk-55IACEB6-QBcon4M7.js → chunk-55IACEB6-DFZ6X9qg.js} +1 -1
  13. package/dist/core-dist/assets/{chunk-B4BG7PRW-BSf5pb79.js → chunk-B4BG7PRW-BmPKklye.js} +1 -1
  14. package/dist/core-dist/assets/{chunk-DI55MBZ5-DftEFpN1.js → chunk-DI55MBZ5-BA4d2Wbt.js} +1 -1
  15. package/dist/core-dist/assets/{chunk-FMBD7UC4-4VeSB__T.js → chunk-FMBD7UC4-XJsNmwVW.js} +1 -1
  16. package/dist/core-dist/assets/{chunk-QN33PNHL-B8h-nEFL.js → chunk-QN33PNHL-CujeLF1b.js} +1 -1
  17. package/dist/core-dist/assets/{chunk-QZHKN3VN-DMYBfSug.js → chunk-QZHKN3VN-BGMtvFJQ.js} +1 -1
  18. package/dist/core-dist/assets/{chunk-TZMSLE5B-Ct-1qAdT.js → chunk-TZMSLE5B-JJzEtNYD.js} +1 -1
  19. package/dist/core-dist/assets/classDiagram-2ON5EDUG-CeZr_QVj.js +1 -0
  20. package/dist/core-dist/assets/classDiagram-v2-WZHVMYZB-CeZr_QVj.js +1 -0
  21. package/dist/core-dist/assets/clone-Bq17CDff.js +1 -0
  22. package/dist/core-dist/assets/{code-block-IT6T5CEO-DA6hEb7Y.js → code-block-IT6T5CEO-mzJGOnKv.js} +1 -1
  23. package/dist/core-dist/assets/{cose-bilkent-S5V4N54A-CloLjUMy.js → cose-bilkent-S5V4N54A-CG3x36O6.js} +1 -1
  24. package/dist/core-dist/assets/{dagre-6UL2VRFP-2A2fgc9Z.js → dagre-6UL2VRFP-CUAYXvH9.js} +1 -1
  25. package/dist/core-dist/assets/{diagram-PSM6KHXK-DPA5DEpE.js → diagram-PSM6KHXK-CjdajvGI.js} +1 -1
  26. package/dist/core-dist/assets/{diagram-QEK2KX5R-C4bOPS0Q.js → diagram-QEK2KX5R-BwP9Rm7l.js} +1 -1
  27. package/dist/core-dist/assets/{diagram-S2PKOQOG-tq0GNkdW.js → diagram-S2PKOQOG-RojbbeSs.js} +1 -1
  28. package/dist/core-dist/assets/{erDiagram-Q2GNP2WA-PM-4jbqi.js → erDiagram-Q2GNP2WA-D9N7nS0_.js} +1 -1
  29. package/dist/core-dist/assets/{flowDiagram-NV44I4VS-T1UN3giy.js → flowDiagram-NV44I4VS-BD4JG33X.js} +1 -1
  30. package/dist/core-dist/assets/{ganttDiagram-JELNMOA3-BonXgJoj.js → ganttDiagram-JELNMOA3-D4z9L9nY.js} +1 -1
  31. package/dist/core-dist/assets/{gitGraphDiagram-NY62KEGX-BuVB_0wZ.js → gitGraphDiagram-NY62KEGX-B2yHGcIC.js} +1 -1
  32. package/dist/core-dist/assets/{graph-DYVP2SvU.js → graph-CNujjUl6.js} +1 -1
  33. package/dist/core-dist/assets/index-B4CH9odE.js +1 -0
  34. package/dist/core-dist/assets/index-Dq7-70tK.js +58 -0
  35. package/dist/core-dist/assets/{index-C6Oo3d0L.js → index-pzKFI-Vs.js} +1 -1
  36. package/dist/core-dist/assets/{infoDiagram-WHAUD3N6-CbjR8HY4.js → infoDiagram-WHAUD3N6-BvkFeyEE.js} +1 -1
  37. package/dist/core-dist/assets/{journeyDiagram-XKPGCS4Q-CCwLC7Dr.js → journeyDiagram-XKPGCS4Q-CkG5moWM.js} +1 -1
  38. package/dist/core-dist/assets/{kanban-definition-3W4ZIXB7-DUawu5sK.js → kanban-definition-3W4ZIXB7-CfaZK5R9.js} +1 -1
  39. package/dist/core-dist/assets/{layout-IC-bH2B0.js → layout-CrsquEuM.js} +1 -1
  40. package/dist/core-dist/assets/{linear-ZJuqjgQK.js → linear-bD-svMHh.js} +1 -1
  41. package/dist/core-dist/assets/{mermaid-VLURNSYL-CN8SKxCb.js → mermaid-VLURNSYL-BZBKtjwf.js} +4 -4
  42. package/dist/core-dist/assets/{mermaid.core-CaljvboY.js → mermaid.core-DmainLbW.js} +5 -5
  43. package/dist/core-dist/assets/{min-DmRs0sgj.js → min-Cs3I0vDk.js} +1 -1
  44. package/dist/core-dist/assets/{mindmap-definition-VGOIOE7T-fkttDhdk.js → mindmap-definition-VGOIOE7T-COrHba51.js} +1 -1
  45. package/dist/core-dist/assets/{pieDiagram-ADFJNKIX-ByGngzi8.js → pieDiagram-ADFJNKIX-C_wSihFn.js} +1 -1
  46. package/dist/core-dist/assets/{quadrantDiagram-AYHSOK5B-DO_C9v_v.js → quadrantDiagram-AYHSOK5B-6QBSTaSf.js} +1 -1
  47. package/dist/core-dist/assets/{queries.store-DZ-MnOG6.js → queries.store-BqdJNevl.js} +1 -1
  48. package/dist/core-dist/assets/{requirementDiagram-UZGBJVZJ-BDzpQlVK.js → requirementDiagram-UZGBJVZJ-BmH--ndW.js} +1 -1
  49. package/dist/core-dist/assets/{runner-tab-CxwQsug8.js → runner-tab-FdI7lq06.js} +3 -3
  50. package/dist/core-dist/assets/{sankeyDiagram-TZEHDZUN-HnCFDh0I.js → sankeyDiagram-TZEHDZUN-BgePY74D.js} +1 -1
  51. package/dist/core-dist/assets/{scroll-area-DP3yG54v.js → scroll-area-NHyDhTA5.js} +1 -1
  52. package/dist/core-dist/assets/{sequenceDiagram-WL72ISMW-ZzL5mp2w.js → sequenceDiagram-WL72ISMW-DyKFIest.js} +1 -1
  53. package/dist/core-dist/assets/{stateDiagram-FKZM4ZOC-DVgE6W5u.js → stateDiagram-FKZM4ZOC-CoTNg4O5.js} +1 -1
  54. package/dist/core-dist/assets/stateDiagram-v2-4FDKWEC3-VLFCTZ_U.js +1 -0
  55. package/dist/core-dist/assets/{timeline-definition-IT6M3QCI-C2z733gB.js → timeline-definition-IT6M3QCI-BvUQ9Pv-.js} +1 -1
  56. package/dist/core-dist/assets/{treemap-KMMF4GRG-D-vNn6yN.js → treemap-KMMF4GRG-DLmWUMp8.js} +1 -1
  57. package/dist/core-dist/assets/{xychartDiagram-PRI3JC2R-BGDvUT2K.js → xychartDiagram-PRI3JC2R-3ZAFpM_j.js} +1 -1
  58. package/dist/core-dist/index.html +1 -1
  59. package/dist/index.js +19 -19
  60. package/dist/index.js.map +1 -1
  61. package/package.json +1 -1
  62. package/dist/core-dist/assets/channel-pRz1hcM0.js +0 -1
  63. package/dist/core-dist/assets/classDiagram-2ON5EDUG-Dw839vW9.js +0 -1
  64. package/dist/core-dist/assets/classDiagram-v2-WZHVMYZB-Dw839vW9.js +0 -1
  65. package/dist/core-dist/assets/clone-DIzOT_B6.js +0 -1
  66. package/dist/core-dist/assets/index-BKhtUOFL.js +0 -1
  67. package/dist/core-dist/assets/index-jesypFsg.js +0 -58
  68. package/dist/core-dist/assets/stateDiagram-v2-4FDKWEC3-DffmOHiZ.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-CaljvboY.js","assets/monaco-editor-BMj4E99D.js","assets/monaco-editor-Ck3IbhyB.css","assets/icons-cLYU3CQS.js","assets/code-block-IT6T5CEO-DA6hEb7Y.js","assets/radix-ui-d5EbBw33.js","assets/react-dom-BWKcCUTe.js","assets/tanstack-D5ysZnPZ.js","assets/index-jesypFsg.js","assets/index-DEXHOoGJ.css","assets/scroll-area-DP3yG54v.js","assets/index-C6Oo3d0L.js","assets/_pathlessLayout-DmCNfa5q.js","assets/queries.store-DZ-MnOG6.js","assets/katex-DvXFAOB1.css"])))=>i.map(i=>d[i]);
2
- import{j as I,B as bd,ag as Ed,ah as Td,ai as xd,aj as Ms}from"./radix-ui-d5EbBw33.js";import{q as yd,r as kd}from"./tanstack-D5ysZnPZ.js";import{r as B,_ as vd,g as to,a0 as qa,a1 as ro,a2 as no,a3 as Ad,a4 as wd,a5 as Sd,a6 as Cd,a7 as Nd,a8 as _d,p as Id,J as Dd,a9 as Ld,X as Rd,aa as Od,l as Md,d as Pd}from"./icons-cLYU3CQS.js";import{a as He,B as R0,a9 as Bd,aa as Fd,ab as zd,ac as Hd,ad as Ud,ae as qd,m as jd,X as $d,D as Yd}from"./index-jesypFsg.js";import{S as Vd,n as Gd}from"./scroll-area-DP3yG54v.js";import{T as Wd,a as Xd,b as Qd}from"./index-C6Oo3d0L.js";import{u as Kd}from"./_pathlessLayout-DmCNfa5q.js";import{_ as ja}from"./monaco-editor-BMj4E99D.js";const Zd=["Show me all tables in my database","What columns are in the users table?","Write a query to find all active users","How many orders were placed last month?","Find top 5 customers by total spend","Write a JOIN between users and orders","Users who haven't made any purchase yet","Generate monthly revenue summary query","Suggest useful indexes for better performance","Show schema of the products / inventory table","Latest 20 orders with customer names","Help me write a safe UPDATE query"];const Jd={damping:.7,stiffness:.05,mass:1.25},ef=70,tf=1e3/60,rf=350;let $a=!1;globalThis.document?.addEventListener("mousedown",()=>{$a=!0});globalThis.document?.addEventListener("mouseup",()=>{$a=!1});globalThis.document?.addEventListener("click",()=>{$a=!1});const nf=(e={})=>{const[t,r]=B.useState(!1),[n,a]=B.useState(e.initial!==!1),[i,s]=B.useState(!1),u=B.useRef(null);u.current=e;const l=B.useCallback(()=>{if(!$a)return!1;const w=window.getSelection();if(!w||!w.rangeCount)return!1;const L=w.getRangeAt(0);return L.commonAncestorContainer.contains(v.current)||v.current?.contains(L.commonAncestorContainer)},[]),o=B.useCallback(w=>{c.isAtBottom=w,a(w)},[]),h=B.useCallback(w=>{c.escapedFromLock=w,r(w)},[]),c=B.useMemo(()=>{let w;return{escapedFromLock:t,isAtBottom:n,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return v.current?.scrollTop??0},set scrollTop(L){v.current&&(v.current.scrollTop=L,c.ignoreScrollToTop=v.current.scrollTop)},get targetScrollTop(){return!v.current||!A.current?0:v.current.scrollHeight-1-v.current.clientHeight},get calculatedTargetScrollTop(){if(!v.current||!A.current)return 0;const{targetScrollTop:L}=this;if(!e.targetScrollTop)return L;if(w?.targetScrollTop===L)return w.calculatedScrollTop;const z=Math.max(Math.min(e.targetScrollTop(L,{scrollElement:v.current,contentElement:A.current}),L),0);return w={targetScrollTop:L,calculatedScrollTop:z},requestAnimationFrame(()=>{w=void 0}),z},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=ef}}},[]),m=B.useCallback((w={})=>{typeof w=="string"&&(w={animation:w}),w.preserveScrollPosition||o(!0);const L=Date.now()+(Number(w.wait)||0),z=mi(u.current,w.animation),{ignoreEscapes:q=!1}=w;let O,Y=c.calculatedTargetScrollTop;w.duration instanceof Promise?w.duration.finally(()=>{O=Date.now()}):O=L+(w.duration??0);const J=async()=>{const Q=new Promise(requestAnimationFrame).then(()=>{if(!c.isAtBottom)return c.animation=void 0,!1;const{scrollTop:P}=c,Z=performance.now(),U=(Z-(c.lastTick??Z))/tf;if(c.animation||(c.animation={behavior:z,promise:Q,ignoreEscapes:q}),c.animation.behavior===z&&(c.lastTick=Z),l()||L>Date.now())return J();if(P<Math.min(Y,c.calculatedTargetScrollTop)){if(c.animation?.behavior===z){if(z==="instant")return c.scrollTop=c.calculatedTargetScrollTop,J();c.velocity=(z.damping*c.velocity+z.stiffness*c.scrollDifference)/z.mass,c.accumulated+=c.velocity*U,c.scrollTop+=c.accumulated,c.scrollTop!==P&&(c.accumulated=0)}return J()}return O>Date.now()?(Y=c.calculatedTargetScrollTop,J()):(c.animation=void 0,c.scrollTop<c.calculatedTargetScrollTop?m({animation:mi(u.current,u.current.resize),ignoreEscapes:q,duration:Math.max(0,O-Date.now())||void 0}):c.isAtBottom)});return Q.then(P=>(requestAnimationFrame(()=>{c.animation||(c.lastTick=void 0,c.velocity=0)}),P))};return w.wait!==!0&&(c.animation=void 0),c.animation?.behavior===z?c.animation.promise:J()},[o,l,c]),g=B.useCallback(()=>{h(!0),o(!1)},[h,o]),E=B.useCallback(({target:w})=>{if(w!==v.current)return;const{scrollTop:L,ignoreScrollToTop:z}=c;let{lastScrollTop:q=L}=c;c.lastScrollTop=L,c.ignoreScrollToTop=void 0,z&&z>L&&(q=z),s(c.isNearBottom),setTimeout(()=>{if(c.resizeDifference||L===z)return;if(l()){h(!0),o(!1);return}const O=L>q,Y=L<q;if(c.animation?.ignoreEscapes){c.scrollTop=q;return}Y&&(h(!0),o(!1)),O&&h(!1),!c.escapedFromLock&&c.isNearBottom&&o(!0)},1)},[h,o,l,c]),y=B.useCallback(({target:w,deltaY:L})=>{let z=w;for(;!["scroll","auto"].includes(getComputedStyle(z).overflow);){if(!z.parentElement)return;z=z.parentElement}z===v.current&&L<0&&v.current.scrollHeight>v.current.clientHeight&&!c.animation?.ignoreEscapes&&(h(!0),o(!1))},[h,o,c]),v=Ps(w=>{v.current?.removeEventListener("scroll",E),v.current?.removeEventListener("wheel",y),w?.addEventListener("scroll",E,{passive:!0}),w?.addEventListener("wheel",y,{passive:!0})},[]),A=Ps(w=>{if(c.resizeObserver?.disconnect(),!w)return;let L;c.resizeObserver=new ResizeObserver(([z])=>{const{height:q}=z.contentRect,O=q-(L??q);if(c.resizeDifference=O,c.scrollTop>c.targetScrollTop&&(c.scrollTop=c.targetScrollTop),s(c.isNearBottom),O>=0){const Y=mi(u.current,L?u.current.resize:u.current.initial);m({animation:Y,wait:!0,preserveScrollPosition:!0,duration:Y==="instant"?void 0:rf})}else c.isNearBottom&&(h(!1),o(!0));L=q,requestAnimationFrame(()=>{setTimeout(()=>{c.resizeDifference===O&&(c.resizeDifference=0)},1)})}),c.resizeObserver?.observe(w)},[]);return{contentRef:A,scrollRef:v,scrollToBottom:m,stopScroll:g,isAtBottom:n||i,isNearBottom:i,escapedFromLock:t,state:c}};function Ps(e,t){const r=B.useCallback(n=>(r.current=n,e(n)),t);return r}const fi=new Map;function mi(...e){const t={...Jd};let r=!1;for(const a of e){if(a==="instant"){r=!0;continue}typeof a=="object"&&(r=!1,t.damping=a.damping??t.damping,t.stiffness=a.stiffness??t.stiffness,t.mass=a.mass??t.mass)}const n=JSON.stringify(t);return fi.has(n)||fi.set(n,Object.freeze(t)),r?"instant":fi.get(n)}const ao=B.createContext(null),af=typeof window<"u"?B.useLayoutEffect:B.useEffect;function wa({instance:e,children:t,resize:r,initial:n,mass:a,damping:i,stiffness:s,targetScrollTop:u,contextRef:l,...o}){const h=B.useRef(null),c=B.useCallback((q,O)=>(z?.targetScrollTop??u)?.(q,O)??q,[u]),m=nf({mass:a,damping:i,stiffness:s,resize:r,initial:n,targetScrollTop:c}),{scrollRef:g,contentRef:E,scrollToBottom:y,stopScroll:v,isAtBottom:A,escapedFromLock:w,state:L}=e??m,z=B.useMemo(()=>({scrollToBottom:y,stopScroll:v,scrollRef:g,isAtBottom:A,escapedFromLock:w,contentRef:E,state:L,get targetScrollTop(){return h.current},set targetScrollTop(q){h.current=q}}),[y,A,E,g,v,w,L]);return B.useImperativeHandle(l,()=>z,[z]),af(()=>{g.current&&getComputedStyle(g.current).overflow==="visible"&&(g.current.style.overflow="auto")},[]),I.jsx(ao.Provider,{value:z,children:I.jsx("div",{...o,children:typeof t=="function"?t(z):t})})}(function(e){function t({children:r,...n}){const a=io();return I.jsx("div",{ref:a.scrollRef,style:{height:"100%",width:"100%"},children:I.jsx("div",{...n,ref:a.contentRef,children:typeof r=="function"?r(a):r})})}e.Content=t})(wa||(wa={}));function io(){const e=B.useContext(ao);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}const sf=({className:e,...t})=>I.jsx(wa,{className:He("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),uf=({className:e,...t})=>I.jsx(wa.Content,{className:He("flex flex-col gap-8 p-4",e),...t}),lf=({className:e,...t})=>{const{isAtBottom:r,scrollToBottom:n}=io(),a=B.useCallback(()=>{n()},[n]);return!r&&I.jsx(R0,{className:He("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:a,size:"icon",type:"button",variant:"outline",...t,children:I.jsx(vd,{className:"size-4"})})},Bs=[{variant:"shine",component:({children:e,className:t,...r})=>I.jsx("span",{...r,className:He("bg-[linear-gradient(110deg,#bfbfbf,35%,#000,50%,#bfbfbf,75%,#bfbfbf)] dark:bg-[linear-gradient(110deg,#404040,35%,#fff,50%,#404040,75%,#404040)]","bg-size-[200%_100%] bg-clip-text text-transparent","animate-shine",t),children:e})}];function of({variant:e="shine",className:t,...r}){const i=Bs.find(s=>s.variant===e)?.component||Bs[0].component;return I.jsx(bd,{className:He("font-medium text-sm"),children:I.jsx(i,{...r,className:t})})}const Vn=(function(e){if(e==null)return ff;if(typeof e=="function")return Ya(e);if(typeof e=="object")return Array.isArray(e)?cf(e):hf(e);if(typeof e=="string")return df(e);throw new Error("Expected function, string, or object as test")});function cf(e){const t=[];let r=-1;for(;++r<e.length;)t[r]=Vn(e[r]);return Ya(n);function n(...a){let i=-1;for(;++i<t.length;)if(t[i].apply(this,a))return!0;return!1}}function hf(e){const t=e;return Ya(r);function r(n){const a=n;let i;for(i in e)if(a[i]!==t[i])return!1;return!0}}function df(e){return Ya(t);function t(r){return r&&r.type===e}}function Ya(e){return t;function t(r,n,a){return!!(mf(r)&&e.call(this,r,typeof n=="number"?n:void 0,a||void 0))}}function ff(){return!0}function mf(e){return e!==null&&typeof e=="object"&&"type"in e}const so=[],vn=!0,Ji=!1,Sa="skip";function O0(e,t,r,n){let a;typeof t=="function"&&typeof r!="function"?(n=r,r=t):a=t;const i=Vn(a),s=n?-1:1;u(e,void 0,[])();function u(l,o,h){const c=l&&typeof l=="object"?l:{};if(typeof c.type=="string"){const g=typeof c.tagName=="string"?c.tagName:typeof c.name=="string"?c.name:void 0;Object.defineProperty(m,"name",{value:"node ("+(l.type+(g?"<"+g+">":""))+")"})}return m;function m(){let g=so,E,y,v;if((!t||i(l,o,h[h.length-1]||void 0))&&(g=pf(r(l,h)),g[0]===Ji))return g;if("children"in l&&l.children){const A=l;if(A.children&&g[0]!==Sa)for(y=(n?A.children.length:-1)+s,v=h.concat(A);y>-1&&y<A.children.length;){const w=A.children[y];if(E=u(w,y,v)(),E[0]===Ji)return E;y=typeof E[1]=="number"?E[1]:y+s}}return g}}}function pf(e){return Array.isArray(e)?e:typeof e=="number"?[vn,e]:e==null?so:[e]}function Qr(e,t,r,n){let a,i,s;typeof t=="function"&&typeof r!="function"?(i=void 0,s=t,a=r):(i=t,s=r,a=n),O0(e,i,u,a);function u(l,o){const h=o[o.length-1],c=h?h.children.indexOf(l):void 0;return s(l,c,h)}}function gf({defaultOrigin:e="",allowedLinkPrefixes:t=[],allowedImagePrefixes:r=[],allowDataImages:n=!1,allowedProtocols:a=[],blockedImageClass:i="inline-block bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-400 px-3 py-1 rounded text-sm",blockedLinkClass:s="text-gray-500"}){const u=t.length&&!t.every(o=>o==="*"),l=r.length&&!r.every(o=>o==="*");if(!e&&(u||l))throw new Error("defaultOrigin is required when allowedLinkPrefixes or allowedImagePrefixes are provided");return o=>{const h=xf(e,t,r,n,a,i,s);Qr(o,h)}}function Fs(e,t){if(typeof e!="string")return null;try{return new URL(e)}catch{if(t)try{return new URL(e,t)}catch{return null}if(e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))try{return new URL(e,"http://example.com")}catch{return null}return null}}function bf(e){return typeof e!="string"?!1:e.startsWith("/")||e.startsWith("./")||e.startsWith("../")}const Ef=new Set(["https:","http:","irc:","ircs:","mailto:","xmpp:","blob:"]),Tf=new Set(["javascript:","data:","file:","vbscript:"]);function zs(e,t,r,n=!1,a=!1,i=[]){if(!e)return null;if(typeof e=="string"&&e.startsWith("#")&&!a)try{if(new URL(e,"http://example.com").hash===e)return e}catch{}if(typeof e=="string"&&e.startsWith("data:"))return a&&n&&e.startsWith("data:image/")?e:null;if(typeof e=="string"&&e.startsWith("blob:")){try{if(new URL(e).protocol==="blob:"&&e.length>5){const h=e.substring(5);if(h&&h.length>0&&h!=="invalid")return e}}catch{return null}return null}const s=Fs(e,r);if(!s||Tf.has(s.protocol)||!(Ef.has(s.protocol)||i.includes(s.protocol)||i.includes("*")))return null;if(s.protocol==="mailto:"||!s.protocol.match(/^https?:$/))return s.href;const l=bf(e);return s&&t.some(o=>{const h=Fs(o,r);return!h||h.origin!==s.origin?!1:s.href.startsWith(h.href)})?l?s.pathname+s.search+s.hash:s.href:t.includes("*")?s.protocol!=="https:"&&s.protocol!=="http:"?null:l?s.pathname+s.search+s.hash:s.href:null}const pi=Symbol("node-seen"),xf=(e,t,r,n,a,i,s)=>{const u=(l,o,h)=>{if(l.type!=="element"||l[pi])return vn;if(l.tagName==="a"){const c=zs(l.properties.href,t,e,!1,!1,a);return c===null?(l[pi]=!0,Qr(l,u),h&&typeof o=="number"&&(h.children[o]={type:"element",tagName:"span",properties:{title:"Blocked URL: "+String(l.properties.href),class:s},children:[...l.children,{type:"text",value:" [blocked]"}]}),Sa):(l.properties.href=c,l.properties.target="_blank",l.properties.rel="noopener noreferrer",vn)}if(l.tagName==="img"){const c=zs(l.properties.src,r,e,n,!0,a);return c===null?(l[pi]=!0,Qr(l,u),h&&typeof o=="number"&&(h.children[o]={type:"element",tagName:"span",properties:{class:i},children:[{type:"text",value:"[Image blocked: "+String(l.properties.alt||"No description")+"]"}]}),Sa):(l.properties.src=c,vn)}return vn};return u};class Gn{constructor(t,r,n){this.normal=r,this.property=t,n&&(this.space=n)}}Gn.prototype.normal={};Gn.prototype.property={};Gn.prototype.space=void 0;function uo(e,t){const r={},n={};for(const a of e)Object.assign(r,a.property),Object.assign(n,a.normal);return new Gn(r,n,t)}function zn(e){return e.toLowerCase()}class dt{constructor(t,r){this.attribute=r,this.property=t}}dt.prototype.attribute="";dt.prototype.booleanish=!1;dt.prototype.boolean=!1;dt.prototype.commaOrSpaceSeparated=!1;dt.prototype.commaSeparated=!1;dt.prototype.defined=!1;dt.prototype.mustUseProperty=!1;dt.prototype.number=!1;dt.prototype.overloadedBoolean=!1;dt.prototype.property="";dt.prototype.spaceSeparated=!1;dt.prototype.space=void 0;let yf=0;const me=Dr(),$e=Dr(),e0=Dr(),K=Dr(),Le=Dr(),Vr=Dr(),pt=Dr();function Dr(){return 2**++yf}const t0=Object.freeze(Object.defineProperty({__proto__:null,boolean:me,booleanish:$e,commaOrSpaceSeparated:pt,commaSeparated:Vr,number:K,overloadedBoolean:e0,spaceSeparated:Le},Symbol.toStringTag,{value:"Module"})),gi=Object.keys(t0);class M0 extends dt{constructor(t,r,n,a){let i=-1;if(super(t,r),Hs(this,"space",a),typeof n=="number")for(;++i<gi.length;){const s=gi[i];Hs(this,gi[i],(n&t0[s])===t0[s])}}}M0.prototype.defined=!0;function Hs(e,t,r){r&&(e[t]=r)}function tn(e){const t={},r={};for(const[n,a]of Object.entries(e.properties)){const i=new M0(n,e.transform(e.attributes||{},n),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(n)&&(i.mustUseProperty=!0),t[n]=i,r[zn(n)]=n,r[zn(i.attribute)]=n}return new Gn(t,r,e.space)}const lo=tn({properties:{ariaActiveDescendant:null,ariaAtomic:$e,ariaAutoComplete:null,ariaBusy:$e,ariaChecked:$e,ariaColCount:K,ariaColIndex:K,ariaColSpan:K,ariaControls:Le,ariaCurrent:null,ariaDescribedBy:Le,ariaDetails:null,ariaDisabled:$e,ariaDropEffect:Le,ariaErrorMessage:null,ariaExpanded:$e,ariaFlowTo:Le,ariaGrabbed:$e,ariaHasPopup:null,ariaHidden:$e,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Le,ariaLevel:K,ariaLive:null,ariaModal:$e,ariaMultiLine:$e,ariaMultiSelectable:$e,ariaOrientation:null,ariaOwns:Le,ariaPlaceholder:null,ariaPosInSet:K,ariaPressed:$e,ariaReadOnly:$e,ariaRelevant:null,ariaRequired:$e,ariaRoleDescription:Le,ariaRowCount:K,ariaRowIndex:K,ariaRowSpan:K,ariaSelected:$e,ariaSetSize:K,ariaSort:null,ariaValueMax:K,ariaValueMin:K,ariaValueNow:K,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function oo(e,t){return t in e?e[t]:t}function co(e,t){return oo(e,t.toLowerCase())}const kf=tn({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Vr,acceptCharset:Le,accessKey:Le,action:null,allow:null,allowFullScreen:me,allowPaymentRequest:me,allowUserMedia:me,alt:null,as:null,async:me,autoCapitalize:null,autoComplete:Le,autoFocus:me,autoPlay:me,blocking:Le,capture:null,charSet:null,checked:me,cite:null,className:Le,cols:K,colSpan:null,content:null,contentEditable:$e,controls:me,controlsList:Le,coords:K|Vr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:me,defer:me,dir:null,dirName:null,disabled:me,download:e0,draggable:$e,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:me,formTarget:null,headers:Le,height:K,hidden:e0,high:K,href:null,hrefLang:null,htmlFor:Le,httpEquiv:Le,id:null,imageSizes:null,imageSrcSet:null,inert:me,inputMode:null,integrity:null,is:null,isMap:me,itemId:null,itemProp:Le,itemRef:Le,itemScope:me,itemType:Le,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:me,low:K,manifest:null,max:null,maxLength:K,media:null,method:null,min:null,minLength:K,multiple:me,muted:me,name:null,nonce:null,noModule:me,noValidate:me,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:me,optimum:K,pattern:null,ping:Le,placeholder:null,playsInline:me,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:me,referrerPolicy:null,rel:Le,required:me,reversed:me,rows:K,rowSpan:K,sandbox:Le,scope:null,scoped:me,seamless:me,selected:me,shadowRootClonable:me,shadowRootDelegatesFocus:me,shadowRootMode:null,shape:null,size:K,sizes:null,slot:null,span:K,spellCheck:$e,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K,step:null,style:null,tabIndex:K,target:null,title:null,translate:null,type:null,typeMustMatch:me,useMap:null,value:$e,width:K,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Le,axis:null,background:null,bgColor:null,border:K,borderColor:null,bottomMargin:K,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:me,declare:me,event:null,face:null,frame:null,frameBorder:null,hSpace:K,leftMargin:K,link:null,longDesc:null,lowSrc:null,marginHeight:K,marginWidth:K,noResize:me,noHref:me,noShade:me,noWrap:me,object:null,profile:null,prompt:null,rev:null,rightMargin:K,rules:null,scheme:null,scrolling:$e,standby:null,summary:null,text:null,topMargin:K,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:me,disableRemotePlayback:me,prefix:null,property:null,results:K,security:null,unselectable:null},space:"html",transform:co}),vf=tn({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:pt,accentHeight:K,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K,amplitude:K,arabicForm:null,ascent:K,attributeName:null,attributeType:null,azimuth:K,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K,by:null,calcMode:null,capHeight:K,className:Le,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:K,diffuseConstant:K,direction:null,display:null,dur:null,divisor:K,dominantBaseline:null,download:me,dx:null,dy:null,edgeMode:null,editable:null,elevation:K,enableBackground:null,end:null,event:null,exponent:K,externalResourcesRequired:null,fill:null,fillOpacity:K,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Vr,g2:Vr,glyphName:Vr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K,horizOriginX:K,horizOriginY:K,id:null,ideographic:K,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K,k:K,k1:K,k2:K,k3:K,k4:K,kernelMatrix:pt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:K,overlineThickness:K,paintOrder:null,panose1:null,path:null,pathLength:K,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Le,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K,pointsAtY:K,pointsAtZ:K,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:pt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:pt,rev:pt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:pt,requiredFeatures:pt,requiredFonts:pt,requiredFormats:pt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:K,specularExponent:K,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K,strikethroughThickness:K,string:null,stroke:null,strokeDashArray:pt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K,strokeOpacity:K,strokeWidth:null,style:null,surfaceScale:K,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:pt,tabIndex:K,tableValues:null,target:null,targetX:K,targetY:K,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:pt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K,underlineThickness:K,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K,values:null,vAlphabetic:K,vMathematical:K,vectorEffect:null,vHanging:K,vIdeographic:K,version:null,vertAdvY:K,vertOriginX:K,vertOriginY:K,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:oo}),ho=tn({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),fo=tn({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:co}),mo=tn({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Af={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},wf=/[A-Z]/g,Us=/-[a-z]/g,Sf=/^data[-\w.:]+$/i;function Va(e,t){const r=zn(t);let n=t,a=dt;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&Sf.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(Us,Nf);n="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!Us.test(i)){let s=i.replace(wf,Cf);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}a=M0}return new a(n,t)}function Cf(e){return"-"+e.toLowerCase()}function Nf(e){return e.charAt(1).toUpperCase()}const Wn=uo([lo,kf,ho,fo,mo],"html"),Er=uo([lo,vf,ho,fo,mo],"svg");function qs(e){const t=[],r=String(e||"");let n=r.indexOf(","),a=0,i=!1;for(;!i;){n===-1&&(n=r.length,i=!0);const s=r.slice(a,n).trim();(s||!i)&&t.push(s),a=n+1,n=r.indexOf(",",a)}return t}function po(e,t){const r=t||{};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const js=/[#.]/g;function _f(e,t){const r=e||"",n={};let a=0,i,s;for(;a<r.length;){js.lastIndex=a;const u=js.exec(r),l=r.slice(a,u?u.index:r.length);l&&(i?i==="#"?n.id=l:Array.isArray(n.className)?n.className.push(l):n.className=[l]:s=l,a+=l.length),u&&(i=u[0],a++)}return{type:"element",tagName:s||t||"div",properties:n,children:[]}}function $s(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function go(e){return e.join(" ").trim()}function bo(e,t,r){const n=r?Rf(r):void 0;function a(i,s,...u){let l;if(i==null){l={type:"root",children:[]};const o=s;u.unshift(o)}else{l=_f(i,t);const o=l.tagName.toLowerCase(),h=n?n.get(o):void 0;if(l.tagName=h||o,If(s))u.unshift(s);else for(const[c,m]of Object.entries(s))Df(e,l.properties,c,m)}for(const o of u)r0(l.children,o);return l.type==="element"&&l.tagName==="template"&&(l.content={type:"root",children:l.children},l.children=[]),l}return a}function If(e){if(e===null||typeof e!="object"||Array.isArray(e))return!0;if(typeof e.type!="string")return!1;const t=e,r=Object.keys(e);for(const n of r){const a=t[n];if(a&&typeof a=="object"){if(!Array.isArray(a))return!0;const i=a;for(const s of i)if(typeof s!="number"&&typeof s!="string")return!0}}return!!("children"in e&&Array.isArray(e.children))}function Df(e,t,r,n){const a=Va(e,r);let i;if(n!=null){if(typeof n=="number"){if(Number.isNaN(n))return;i=n}else typeof n=="boolean"?i=n:typeof n=="string"?a.spaceSeparated?i=$s(n):a.commaSeparated?i=qs(n):a.commaOrSpaceSeparated?i=$s(qs(n).join(" ")):i=Ys(a,a.property,n):Array.isArray(n)?i=[...n]:i=a.property==="style"?Lf(n):String(n);if(Array.isArray(i)){const s=[];for(const u of i)s.push(Ys(a,a.property,u));i=s}a.property==="className"&&Array.isArray(t.className)&&(i=t.className.concat(i)),t[a.property]=i}}function r0(e,t){if(t!=null)if(typeof t=="number"||typeof t=="string")e.push({type:"text",value:String(t)});else if(Array.isArray(t))for(const r of t)r0(e,r);else if(typeof t=="object"&&"type"in t)t.type==="root"?r0(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function Ys(e,t,r){if(typeof r=="string"){if(e.number&&r&&!Number.isNaN(Number(r)))return Number(r);if((e.boolean||e.overloadedBoolean)&&(r===""||zn(r)===zn(t)))return!0}return r}function Lf(e){const t=[];for(const[r,n]of Object.entries(e))t.push([r,n].join(": "));return t.join("; ")}function Rf(e){const t=new Map;for(const r of e)t.set(r.toLowerCase(),r);return t}const Of=["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"],Eo=bo(Wn,"div"),To=bo(Er,"g",Of),zt={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Mf(e,t){return xo(e,{})||{type:"root",children:[]}}function xo(e,t){const r=Pf(e,t);return r&&t.afterTransform&&t.afterTransform(e,r),r}function Pf(e,t){switch(e.nodeType){case 1:return Hf(e,t);case 3:return Ff(e);case 8:return zf(e);case 9:return Vs(e,t);case 10:return Bf();case 11:return Vs(e,t);default:return}}function Vs(e,t){return{type:"root",children:yo(e,t)}}function Bf(){return{type:"doctype"}}function Ff(e){return{type:"text",value:e.nodeValue||""}}function zf(e){return{type:"comment",value:e.nodeValue||""}}function Hf(e,t){const r=e.namespaceURI,n=r===zt.svg?To:Eo,a=r===zt.html?e.tagName.toLowerCase():e.tagName,i=r===zt.html&&a==="template"?e.content:e,s=e.getAttributeNames(),u={};let l=-1;for(;++l<s.length;)u[s[l]]=e.getAttribute(s[l])||"";return n(a,u,yo(i,t))}function yo(e,t){const r=e.childNodes,n=[];let a=-1;for(;++a<r.length;){const i=xo(r[a],t);i!==void 0&&n.push(i)}return n}new DOMParser;function Uf(e,t){const r=qf(e);return Mf(r)}function qf(e){const t=document.createElement("template");return t.innerHTML=e,t.content}const Gs=(function(e,t,r){const n=Vn(r);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++t<e.children.length;)if(n(e.children[t],t,e))return e.children[t]}),Lr=(function(e){if(e==null)return Yf;if(typeof e=="string")return $f(e);if(typeof e=="object")return jf(e);if(typeof e=="function")return P0(e);throw new Error("Expected function, string, or array as `test`")});function jf(e){const t=[];let r=-1;for(;++r<e.length;)t[r]=Lr(e[r]);return P0(n);function n(...a){let i=-1;for(;++i<t.length;)if(t[i].apply(this,a))return!0;return!1}}function $f(e){return P0(t);function t(r){return r.tagName===e}}function P0(e){return t;function t(r,n,a){return!!(Vf(r)&&e.call(this,r,typeof n=="number"?n:void 0,a||void 0))}}function Yf(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function Vf(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const Ws=/\n/g,Xs=/[\t ]+/g,n0=Lr("br"),Qs=Lr(em),Gf=Lr("p"),Ks=Lr("tr"),Wf=Lr(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",Jf,tm]),ko=Lr(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function Xf(e,t){const r=t||{},n="children"in e?e.children:[],a=ko(e),i=wo(e,{whitespace:r.whitespace||"normal"}),s=[];(e.type==="text"||e.type==="comment")&&s.push(...Ao(e,{breakBefore:!0,breakAfter:!0}));let u=-1;for(;++u<n.length;)s.push(...vo(n[u],e,{whitespace:i,breakBefore:u?void 0:a,breakAfter:u<n.length-1?n0(n[u+1]):a}));const l=[];let o;for(u=-1;++u<s.length;){const h=s[u];typeof h=="number"?o!==void 0&&h>o&&(o=h):h&&(o!==void 0&&o>-1&&l.push(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-DmainLbW.js","assets/monaco-editor-BMj4E99D.js","assets/monaco-editor-Ck3IbhyB.css","assets/icons-cLYU3CQS.js","assets/code-block-IT6T5CEO-mzJGOnKv.js","assets/radix-ui-d5EbBw33.js","assets/react-dom-BWKcCUTe.js","assets/tanstack-D5ysZnPZ.js","assets/index-Dq7-70tK.js","assets/index-DEXHOoGJ.css","assets/scroll-area-NHyDhTA5.js","assets/index-pzKFI-Vs.js","assets/_pathlessLayout-J4rDhSFV.js","assets/queries.store-BqdJNevl.js","assets/katex-DvXFAOB1.css"])))=>i.map(i=>d[i]);
2
+ import{j as I,B as bd,ag as Ed,ah as Td,ai as xd,aj as Ms}from"./radix-ui-d5EbBw33.js";import{q as yd,r as kd}from"./tanstack-D5ysZnPZ.js";import{r as B,_ as vd,g as to,a0 as qa,a1 as ro,a2 as no,a3 as Ad,a4 as wd,a5 as Sd,a6 as Cd,a7 as Nd,a8 as _d,p as Id,J as Dd,a9 as Ld,X as Rd,aa as Od,l as Md,d as Pd}from"./icons-cLYU3CQS.js";import{a as He,B as R0,a9 as Bd,aa as Fd,ab as zd,ac as Hd,ad as Ud,ae as qd,m as jd,X as $d,D as Yd}from"./index-Dq7-70tK.js";import{S as Vd,n as Gd}from"./scroll-area-NHyDhTA5.js";import{T as Wd,a as Xd,b as Qd}from"./index-pzKFI-Vs.js";import{u as Kd}from"./_pathlessLayout-J4rDhSFV.js";import{_ as ja}from"./monaco-editor-BMj4E99D.js";const Zd=["Show me all tables in my database","What columns are in the users table?","Write a query to find all active users","How many orders were placed last month?","Find top 5 customers by total spend","Write a JOIN between users and orders","Users who haven't made any purchase yet","Generate monthly revenue summary query","Suggest useful indexes for better performance","Show schema of the products / inventory table","Latest 20 orders with customer names","Help me write a safe UPDATE query"];const Jd={damping:.7,stiffness:.05,mass:1.25},ef=70,tf=1e3/60,rf=350;let $a=!1;globalThis.document?.addEventListener("mousedown",()=>{$a=!0});globalThis.document?.addEventListener("mouseup",()=>{$a=!1});globalThis.document?.addEventListener("click",()=>{$a=!1});const nf=(e={})=>{const[t,r]=B.useState(!1),[n,a]=B.useState(e.initial!==!1),[i,s]=B.useState(!1),u=B.useRef(null);u.current=e;const l=B.useCallback(()=>{if(!$a)return!1;const w=window.getSelection();if(!w||!w.rangeCount)return!1;const L=w.getRangeAt(0);return L.commonAncestorContainer.contains(v.current)||v.current?.contains(L.commonAncestorContainer)},[]),o=B.useCallback(w=>{c.isAtBottom=w,a(w)},[]),h=B.useCallback(w=>{c.escapedFromLock=w,r(w)},[]),c=B.useMemo(()=>{let w;return{escapedFromLock:t,isAtBottom:n,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return v.current?.scrollTop??0},set scrollTop(L){v.current&&(v.current.scrollTop=L,c.ignoreScrollToTop=v.current.scrollTop)},get targetScrollTop(){return!v.current||!A.current?0:v.current.scrollHeight-1-v.current.clientHeight},get calculatedTargetScrollTop(){if(!v.current||!A.current)return 0;const{targetScrollTop:L}=this;if(!e.targetScrollTop)return L;if(w?.targetScrollTop===L)return w.calculatedScrollTop;const z=Math.max(Math.min(e.targetScrollTop(L,{scrollElement:v.current,contentElement:A.current}),L),0);return w={targetScrollTop:L,calculatedScrollTop:z},requestAnimationFrame(()=>{w=void 0}),z},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=ef}}},[]),m=B.useCallback((w={})=>{typeof w=="string"&&(w={animation:w}),w.preserveScrollPosition||o(!0);const L=Date.now()+(Number(w.wait)||0),z=mi(u.current,w.animation),{ignoreEscapes:q=!1}=w;let O,Y=c.calculatedTargetScrollTop;w.duration instanceof Promise?w.duration.finally(()=>{O=Date.now()}):O=L+(w.duration??0);const J=async()=>{const Q=new Promise(requestAnimationFrame).then(()=>{if(!c.isAtBottom)return c.animation=void 0,!1;const{scrollTop:P}=c,Z=performance.now(),U=(Z-(c.lastTick??Z))/tf;if(c.animation||(c.animation={behavior:z,promise:Q,ignoreEscapes:q}),c.animation.behavior===z&&(c.lastTick=Z),l()||L>Date.now())return J();if(P<Math.min(Y,c.calculatedTargetScrollTop)){if(c.animation?.behavior===z){if(z==="instant")return c.scrollTop=c.calculatedTargetScrollTop,J();c.velocity=(z.damping*c.velocity+z.stiffness*c.scrollDifference)/z.mass,c.accumulated+=c.velocity*U,c.scrollTop+=c.accumulated,c.scrollTop!==P&&(c.accumulated=0)}return J()}return O>Date.now()?(Y=c.calculatedTargetScrollTop,J()):(c.animation=void 0,c.scrollTop<c.calculatedTargetScrollTop?m({animation:mi(u.current,u.current.resize),ignoreEscapes:q,duration:Math.max(0,O-Date.now())||void 0}):c.isAtBottom)});return Q.then(P=>(requestAnimationFrame(()=>{c.animation||(c.lastTick=void 0,c.velocity=0)}),P))};return w.wait!==!0&&(c.animation=void 0),c.animation?.behavior===z?c.animation.promise:J()},[o,l,c]),g=B.useCallback(()=>{h(!0),o(!1)},[h,o]),E=B.useCallback(({target:w})=>{if(w!==v.current)return;const{scrollTop:L,ignoreScrollToTop:z}=c;let{lastScrollTop:q=L}=c;c.lastScrollTop=L,c.ignoreScrollToTop=void 0,z&&z>L&&(q=z),s(c.isNearBottom),setTimeout(()=>{if(c.resizeDifference||L===z)return;if(l()){h(!0),o(!1);return}const O=L>q,Y=L<q;if(c.animation?.ignoreEscapes){c.scrollTop=q;return}Y&&(h(!0),o(!1)),O&&h(!1),!c.escapedFromLock&&c.isNearBottom&&o(!0)},1)},[h,o,l,c]),y=B.useCallback(({target:w,deltaY:L})=>{let z=w;for(;!["scroll","auto"].includes(getComputedStyle(z).overflow);){if(!z.parentElement)return;z=z.parentElement}z===v.current&&L<0&&v.current.scrollHeight>v.current.clientHeight&&!c.animation?.ignoreEscapes&&(h(!0),o(!1))},[h,o,c]),v=Ps(w=>{v.current?.removeEventListener("scroll",E),v.current?.removeEventListener("wheel",y),w?.addEventListener("scroll",E,{passive:!0}),w?.addEventListener("wheel",y,{passive:!0})},[]),A=Ps(w=>{if(c.resizeObserver?.disconnect(),!w)return;let L;c.resizeObserver=new ResizeObserver(([z])=>{const{height:q}=z.contentRect,O=q-(L??q);if(c.resizeDifference=O,c.scrollTop>c.targetScrollTop&&(c.scrollTop=c.targetScrollTop),s(c.isNearBottom),O>=0){const Y=mi(u.current,L?u.current.resize:u.current.initial);m({animation:Y,wait:!0,preserveScrollPosition:!0,duration:Y==="instant"?void 0:rf})}else c.isNearBottom&&(h(!1),o(!0));L=q,requestAnimationFrame(()=>{setTimeout(()=>{c.resizeDifference===O&&(c.resizeDifference=0)},1)})}),c.resizeObserver?.observe(w)},[]);return{contentRef:A,scrollRef:v,scrollToBottom:m,stopScroll:g,isAtBottom:n||i,isNearBottom:i,escapedFromLock:t,state:c}};function Ps(e,t){const r=B.useCallback(n=>(r.current=n,e(n)),t);return r}const fi=new Map;function mi(...e){const t={...Jd};let r=!1;for(const a of e){if(a==="instant"){r=!0;continue}typeof a=="object"&&(r=!1,t.damping=a.damping??t.damping,t.stiffness=a.stiffness??t.stiffness,t.mass=a.mass??t.mass)}const n=JSON.stringify(t);return fi.has(n)||fi.set(n,Object.freeze(t)),r?"instant":fi.get(n)}const ao=B.createContext(null),af=typeof window<"u"?B.useLayoutEffect:B.useEffect;function wa({instance:e,children:t,resize:r,initial:n,mass:a,damping:i,stiffness:s,targetScrollTop:u,contextRef:l,...o}){const h=B.useRef(null),c=B.useCallback((q,O)=>(z?.targetScrollTop??u)?.(q,O)??q,[u]),m=nf({mass:a,damping:i,stiffness:s,resize:r,initial:n,targetScrollTop:c}),{scrollRef:g,contentRef:E,scrollToBottom:y,stopScroll:v,isAtBottom:A,escapedFromLock:w,state:L}=e??m,z=B.useMemo(()=>({scrollToBottom:y,stopScroll:v,scrollRef:g,isAtBottom:A,escapedFromLock:w,contentRef:E,state:L,get targetScrollTop(){return h.current},set targetScrollTop(q){h.current=q}}),[y,A,E,g,v,w,L]);return B.useImperativeHandle(l,()=>z,[z]),af(()=>{g.current&&getComputedStyle(g.current).overflow==="visible"&&(g.current.style.overflow="auto")},[]),I.jsx(ao.Provider,{value:z,children:I.jsx("div",{...o,children:typeof t=="function"?t(z):t})})}(function(e){function t({children:r,...n}){const a=io();return I.jsx("div",{ref:a.scrollRef,style:{height:"100%",width:"100%"},children:I.jsx("div",{...n,ref:a.contentRef,children:typeof r=="function"?r(a):r})})}e.Content=t})(wa||(wa={}));function io(){const e=B.useContext(ao);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}const sf=({className:e,...t})=>I.jsx(wa,{className:He("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),uf=({className:e,...t})=>I.jsx(wa.Content,{className:He("flex flex-col gap-8 p-4",e),...t}),lf=({className:e,...t})=>{const{isAtBottom:r,scrollToBottom:n}=io(),a=B.useCallback(()=>{n()},[n]);return!r&&I.jsx(R0,{className:He("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:a,size:"icon",type:"button",variant:"outline",...t,children:I.jsx(vd,{className:"size-4"})})},Bs=[{variant:"shine",component:({children:e,className:t,...r})=>I.jsx("span",{...r,className:He("bg-[linear-gradient(110deg,#bfbfbf,35%,#000,50%,#bfbfbf,75%,#bfbfbf)] dark:bg-[linear-gradient(110deg,#404040,35%,#fff,50%,#404040,75%,#404040)]","bg-size-[200%_100%] bg-clip-text text-transparent","animate-shine",t),children:e})}];function of({variant:e="shine",className:t,...r}){const i=Bs.find(s=>s.variant===e)?.component||Bs[0].component;return I.jsx(bd,{className:He("font-medium text-sm"),children:I.jsx(i,{...r,className:t})})}const Vn=(function(e){if(e==null)return ff;if(typeof e=="function")return Ya(e);if(typeof e=="object")return Array.isArray(e)?cf(e):hf(e);if(typeof e=="string")return df(e);throw new Error("Expected function, string, or object as test")});function cf(e){const t=[];let r=-1;for(;++r<e.length;)t[r]=Vn(e[r]);return Ya(n);function n(...a){let i=-1;for(;++i<t.length;)if(t[i].apply(this,a))return!0;return!1}}function hf(e){const t=e;return Ya(r);function r(n){const a=n;let i;for(i in e)if(a[i]!==t[i])return!1;return!0}}function df(e){return Ya(t);function t(r){return r&&r.type===e}}function Ya(e){return t;function t(r,n,a){return!!(mf(r)&&e.call(this,r,typeof n=="number"?n:void 0,a||void 0))}}function ff(){return!0}function mf(e){return e!==null&&typeof e=="object"&&"type"in e}const so=[],vn=!0,Ji=!1,Sa="skip";function O0(e,t,r,n){let a;typeof t=="function"&&typeof r!="function"?(n=r,r=t):a=t;const i=Vn(a),s=n?-1:1;u(e,void 0,[])();function u(l,o,h){const c=l&&typeof l=="object"?l:{};if(typeof c.type=="string"){const g=typeof c.tagName=="string"?c.tagName:typeof c.name=="string"?c.name:void 0;Object.defineProperty(m,"name",{value:"node ("+(l.type+(g?"<"+g+">":""))+")"})}return m;function m(){let g=so,E,y,v;if((!t||i(l,o,h[h.length-1]||void 0))&&(g=pf(r(l,h)),g[0]===Ji))return g;if("children"in l&&l.children){const A=l;if(A.children&&g[0]!==Sa)for(y=(n?A.children.length:-1)+s,v=h.concat(A);y>-1&&y<A.children.length;){const w=A.children[y];if(E=u(w,y,v)(),E[0]===Ji)return E;y=typeof E[1]=="number"?E[1]:y+s}}return g}}}function pf(e){return Array.isArray(e)?e:typeof e=="number"?[vn,e]:e==null?so:[e]}function Qr(e,t,r,n){let a,i,s;typeof t=="function"&&typeof r!="function"?(i=void 0,s=t,a=r):(i=t,s=r,a=n),O0(e,i,u,a);function u(l,o){const h=o[o.length-1],c=h?h.children.indexOf(l):void 0;return s(l,c,h)}}function gf({defaultOrigin:e="",allowedLinkPrefixes:t=[],allowedImagePrefixes:r=[],allowDataImages:n=!1,allowedProtocols:a=[],blockedImageClass:i="inline-block bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-400 px-3 py-1 rounded text-sm",blockedLinkClass:s="text-gray-500"}){const u=t.length&&!t.every(o=>o==="*"),l=r.length&&!r.every(o=>o==="*");if(!e&&(u||l))throw new Error("defaultOrigin is required when allowedLinkPrefixes or allowedImagePrefixes are provided");return o=>{const h=xf(e,t,r,n,a,i,s);Qr(o,h)}}function Fs(e,t){if(typeof e!="string")return null;try{return new URL(e)}catch{if(t)try{return new URL(e,t)}catch{return null}if(e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))try{return new URL(e,"http://example.com")}catch{return null}return null}}function bf(e){return typeof e!="string"?!1:e.startsWith("/")||e.startsWith("./")||e.startsWith("../")}const Ef=new Set(["https:","http:","irc:","ircs:","mailto:","xmpp:","blob:"]),Tf=new Set(["javascript:","data:","file:","vbscript:"]);function zs(e,t,r,n=!1,a=!1,i=[]){if(!e)return null;if(typeof e=="string"&&e.startsWith("#")&&!a)try{if(new URL(e,"http://example.com").hash===e)return e}catch{}if(typeof e=="string"&&e.startsWith("data:"))return a&&n&&e.startsWith("data:image/")?e:null;if(typeof e=="string"&&e.startsWith("blob:")){try{if(new URL(e).protocol==="blob:"&&e.length>5){const h=e.substring(5);if(h&&h.length>0&&h!=="invalid")return e}}catch{return null}return null}const s=Fs(e,r);if(!s||Tf.has(s.protocol)||!(Ef.has(s.protocol)||i.includes(s.protocol)||i.includes("*")))return null;if(s.protocol==="mailto:"||!s.protocol.match(/^https?:$/))return s.href;const l=bf(e);return s&&t.some(o=>{const h=Fs(o,r);return!h||h.origin!==s.origin?!1:s.href.startsWith(h.href)})?l?s.pathname+s.search+s.hash:s.href:t.includes("*")?s.protocol!=="https:"&&s.protocol!=="http:"?null:l?s.pathname+s.search+s.hash:s.href:null}const pi=Symbol("node-seen"),xf=(e,t,r,n,a,i,s)=>{const u=(l,o,h)=>{if(l.type!=="element"||l[pi])return vn;if(l.tagName==="a"){const c=zs(l.properties.href,t,e,!1,!1,a);return c===null?(l[pi]=!0,Qr(l,u),h&&typeof o=="number"&&(h.children[o]={type:"element",tagName:"span",properties:{title:"Blocked URL: "+String(l.properties.href),class:s},children:[...l.children,{type:"text",value:" [blocked]"}]}),Sa):(l.properties.href=c,l.properties.target="_blank",l.properties.rel="noopener noreferrer",vn)}if(l.tagName==="img"){const c=zs(l.properties.src,r,e,n,!0,a);return c===null?(l[pi]=!0,Qr(l,u),h&&typeof o=="number"&&(h.children[o]={type:"element",tagName:"span",properties:{class:i},children:[{type:"text",value:"[Image blocked: "+String(l.properties.alt||"No description")+"]"}]}),Sa):(l.properties.src=c,vn)}return vn};return u};class Gn{constructor(t,r,n){this.normal=r,this.property=t,n&&(this.space=n)}}Gn.prototype.normal={};Gn.prototype.property={};Gn.prototype.space=void 0;function uo(e,t){const r={},n={};for(const a of e)Object.assign(r,a.property),Object.assign(n,a.normal);return new Gn(r,n,t)}function zn(e){return e.toLowerCase()}class dt{constructor(t,r){this.attribute=r,this.property=t}}dt.prototype.attribute="";dt.prototype.booleanish=!1;dt.prototype.boolean=!1;dt.prototype.commaOrSpaceSeparated=!1;dt.prototype.commaSeparated=!1;dt.prototype.defined=!1;dt.prototype.mustUseProperty=!1;dt.prototype.number=!1;dt.prototype.overloadedBoolean=!1;dt.prototype.property="";dt.prototype.spaceSeparated=!1;dt.prototype.space=void 0;let yf=0;const me=Dr(),$e=Dr(),e0=Dr(),K=Dr(),Le=Dr(),Vr=Dr(),pt=Dr();function Dr(){return 2**++yf}const t0=Object.freeze(Object.defineProperty({__proto__:null,boolean:me,booleanish:$e,commaOrSpaceSeparated:pt,commaSeparated:Vr,number:K,overloadedBoolean:e0,spaceSeparated:Le},Symbol.toStringTag,{value:"Module"})),gi=Object.keys(t0);class M0 extends dt{constructor(t,r,n,a){let i=-1;if(super(t,r),Hs(this,"space",a),typeof n=="number")for(;++i<gi.length;){const s=gi[i];Hs(this,gi[i],(n&t0[s])===t0[s])}}}M0.prototype.defined=!0;function Hs(e,t,r){r&&(e[t]=r)}function tn(e){const t={},r={};for(const[n,a]of Object.entries(e.properties)){const i=new M0(n,e.transform(e.attributes||{},n),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(n)&&(i.mustUseProperty=!0),t[n]=i,r[zn(n)]=n,r[zn(i.attribute)]=n}return new Gn(t,r,e.space)}const lo=tn({properties:{ariaActiveDescendant:null,ariaAtomic:$e,ariaAutoComplete:null,ariaBusy:$e,ariaChecked:$e,ariaColCount:K,ariaColIndex:K,ariaColSpan:K,ariaControls:Le,ariaCurrent:null,ariaDescribedBy:Le,ariaDetails:null,ariaDisabled:$e,ariaDropEffect:Le,ariaErrorMessage:null,ariaExpanded:$e,ariaFlowTo:Le,ariaGrabbed:$e,ariaHasPopup:null,ariaHidden:$e,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Le,ariaLevel:K,ariaLive:null,ariaModal:$e,ariaMultiLine:$e,ariaMultiSelectable:$e,ariaOrientation:null,ariaOwns:Le,ariaPlaceholder:null,ariaPosInSet:K,ariaPressed:$e,ariaReadOnly:$e,ariaRelevant:null,ariaRequired:$e,ariaRoleDescription:Le,ariaRowCount:K,ariaRowIndex:K,ariaRowSpan:K,ariaSelected:$e,ariaSetSize:K,ariaSort:null,ariaValueMax:K,ariaValueMin:K,ariaValueNow:K,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function oo(e,t){return t in e?e[t]:t}function co(e,t){return oo(e,t.toLowerCase())}const kf=tn({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Vr,acceptCharset:Le,accessKey:Le,action:null,allow:null,allowFullScreen:me,allowPaymentRequest:me,allowUserMedia:me,alt:null,as:null,async:me,autoCapitalize:null,autoComplete:Le,autoFocus:me,autoPlay:me,blocking:Le,capture:null,charSet:null,checked:me,cite:null,className:Le,cols:K,colSpan:null,content:null,contentEditable:$e,controls:me,controlsList:Le,coords:K|Vr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:me,defer:me,dir:null,dirName:null,disabled:me,download:e0,draggable:$e,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:me,formTarget:null,headers:Le,height:K,hidden:e0,high:K,href:null,hrefLang:null,htmlFor:Le,httpEquiv:Le,id:null,imageSizes:null,imageSrcSet:null,inert:me,inputMode:null,integrity:null,is:null,isMap:me,itemId:null,itemProp:Le,itemRef:Le,itemScope:me,itemType:Le,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:me,low:K,manifest:null,max:null,maxLength:K,media:null,method:null,min:null,minLength:K,multiple:me,muted:me,name:null,nonce:null,noModule:me,noValidate:me,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:me,optimum:K,pattern:null,ping:Le,placeholder:null,playsInline:me,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:me,referrerPolicy:null,rel:Le,required:me,reversed:me,rows:K,rowSpan:K,sandbox:Le,scope:null,scoped:me,seamless:me,selected:me,shadowRootClonable:me,shadowRootDelegatesFocus:me,shadowRootMode:null,shape:null,size:K,sizes:null,slot:null,span:K,spellCheck:$e,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K,step:null,style:null,tabIndex:K,target:null,title:null,translate:null,type:null,typeMustMatch:me,useMap:null,value:$e,width:K,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Le,axis:null,background:null,bgColor:null,border:K,borderColor:null,bottomMargin:K,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:me,declare:me,event:null,face:null,frame:null,frameBorder:null,hSpace:K,leftMargin:K,link:null,longDesc:null,lowSrc:null,marginHeight:K,marginWidth:K,noResize:me,noHref:me,noShade:me,noWrap:me,object:null,profile:null,prompt:null,rev:null,rightMargin:K,rules:null,scheme:null,scrolling:$e,standby:null,summary:null,text:null,topMargin:K,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:me,disableRemotePlayback:me,prefix:null,property:null,results:K,security:null,unselectable:null},space:"html",transform:co}),vf=tn({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:pt,accentHeight:K,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K,amplitude:K,arabicForm:null,ascent:K,attributeName:null,attributeType:null,azimuth:K,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K,by:null,calcMode:null,capHeight:K,className:Le,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:K,diffuseConstant:K,direction:null,display:null,dur:null,divisor:K,dominantBaseline:null,download:me,dx:null,dy:null,edgeMode:null,editable:null,elevation:K,enableBackground:null,end:null,event:null,exponent:K,externalResourcesRequired:null,fill:null,fillOpacity:K,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Vr,g2:Vr,glyphName:Vr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K,horizOriginX:K,horizOriginY:K,id:null,ideographic:K,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K,k:K,k1:K,k2:K,k3:K,k4:K,kernelMatrix:pt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:K,overlineThickness:K,paintOrder:null,panose1:null,path:null,pathLength:K,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Le,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K,pointsAtY:K,pointsAtZ:K,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:pt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:pt,rev:pt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:pt,requiredFeatures:pt,requiredFonts:pt,requiredFormats:pt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:K,specularExponent:K,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K,strikethroughThickness:K,string:null,stroke:null,strokeDashArray:pt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K,strokeOpacity:K,strokeWidth:null,style:null,surfaceScale:K,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:pt,tabIndex:K,tableValues:null,target:null,targetX:K,targetY:K,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:pt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K,underlineThickness:K,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K,values:null,vAlphabetic:K,vMathematical:K,vectorEffect:null,vHanging:K,vIdeographic:K,version:null,vertAdvY:K,vertOriginX:K,vertOriginY:K,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:oo}),ho=tn({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),fo=tn({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:co}),mo=tn({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Af={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},wf=/[A-Z]/g,Us=/-[a-z]/g,Sf=/^data[-\w.:]+$/i;function Va(e,t){const r=zn(t);let n=t,a=dt;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&Sf.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(Us,Nf);n="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!Us.test(i)){let s=i.replace(wf,Cf);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}a=M0}return new a(n,t)}function Cf(e){return"-"+e.toLowerCase()}function Nf(e){return e.charAt(1).toUpperCase()}const Wn=uo([lo,kf,ho,fo,mo],"html"),Er=uo([lo,vf,ho,fo,mo],"svg");function qs(e){const t=[],r=String(e||"");let n=r.indexOf(","),a=0,i=!1;for(;!i;){n===-1&&(n=r.length,i=!0);const s=r.slice(a,n).trim();(s||!i)&&t.push(s),a=n+1,n=r.indexOf(",",a)}return t}function po(e,t){const r=t||{};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const js=/[#.]/g;function _f(e,t){const r=e||"",n={};let a=0,i,s;for(;a<r.length;){js.lastIndex=a;const u=js.exec(r),l=r.slice(a,u?u.index:r.length);l&&(i?i==="#"?n.id=l:Array.isArray(n.className)?n.className.push(l):n.className=[l]:s=l,a+=l.length),u&&(i=u[0],a++)}return{type:"element",tagName:s||t||"div",properties:n,children:[]}}function $s(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function go(e){return e.join(" ").trim()}function bo(e,t,r){const n=r?Rf(r):void 0;function a(i,s,...u){let l;if(i==null){l={type:"root",children:[]};const o=s;u.unshift(o)}else{l=_f(i,t);const o=l.tagName.toLowerCase(),h=n?n.get(o):void 0;if(l.tagName=h||o,If(s))u.unshift(s);else for(const[c,m]of Object.entries(s))Df(e,l.properties,c,m)}for(const o of u)r0(l.children,o);return l.type==="element"&&l.tagName==="template"&&(l.content={type:"root",children:l.children},l.children=[]),l}return a}function If(e){if(e===null||typeof e!="object"||Array.isArray(e))return!0;if(typeof e.type!="string")return!1;const t=e,r=Object.keys(e);for(const n of r){const a=t[n];if(a&&typeof a=="object"){if(!Array.isArray(a))return!0;const i=a;for(const s of i)if(typeof s!="number"&&typeof s!="string")return!0}}return!!("children"in e&&Array.isArray(e.children))}function Df(e,t,r,n){const a=Va(e,r);let i;if(n!=null){if(typeof n=="number"){if(Number.isNaN(n))return;i=n}else typeof n=="boolean"?i=n:typeof n=="string"?a.spaceSeparated?i=$s(n):a.commaSeparated?i=qs(n):a.commaOrSpaceSeparated?i=$s(qs(n).join(" ")):i=Ys(a,a.property,n):Array.isArray(n)?i=[...n]:i=a.property==="style"?Lf(n):String(n);if(Array.isArray(i)){const s=[];for(const u of i)s.push(Ys(a,a.property,u));i=s}a.property==="className"&&Array.isArray(t.className)&&(i=t.className.concat(i)),t[a.property]=i}}function r0(e,t){if(t!=null)if(typeof t=="number"||typeof t=="string")e.push({type:"text",value:String(t)});else if(Array.isArray(t))for(const r of t)r0(e,r);else if(typeof t=="object"&&"type"in t)t.type==="root"?r0(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function Ys(e,t,r){if(typeof r=="string"){if(e.number&&r&&!Number.isNaN(Number(r)))return Number(r);if((e.boolean||e.overloadedBoolean)&&(r===""||zn(r)===zn(t)))return!0}return r}function Lf(e){const t=[];for(const[r,n]of Object.entries(e))t.push([r,n].join(": "));return t.join("; ")}function Rf(e){const t=new Map;for(const r of e)t.set(r.toLowerCase(),r);return t}const Of=["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"],Eo=bo(Wn,"div"),To=bo(Er,"g",Of),zt={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Mf(e,t){return xo(e,{})||{type:"root",children:[]}}function xo(e,t){const r=Pf(e,t);return r&&t.afterTransform&&t.afterTransform(e,r),r}function Pf(e,t){switch(e.nodeType){case 1:return Hf(e,t);case 3:return Ff(e);case 8:return zf(e);case 9:return Vs(e,t);case 10:return Bf();case 11:return Vs(e,t);default:return}}function Vs(e,t){return{type:"root",children:yo(e,t)}}function Bf(){return{type:"doctype"}}function Ff(e){return{type:"text",value:e.nodeValue||""}}function zf(e){return{type:"comment",value:e.nodeValue||""}}function Hf(e,t){const r=e.namespaceURI,n=r===zt.svg?To:Eo,a=r===zt.html?e.tagName.toLowerCase():e.tagName,i=r===zt.html&&a==="template"?e.content:e,s=e.getAttributeNames(),u={};let l=-1;for(;++l<s.length;)u[s[l]]=e.getAttribute(s[l])||"";return n(a,u,yo(i,t))}function yo(e,t){const r=e.childNodes,n=[];let a=-1;for(;++a<r.length;){const i=xo(r[a],t);i!==void 0&&n.push(i)}return n}new DOMParser;function Uf(e,t){const r=qf(e);return Mf(r)}function qf(e){const t=document.createElement("template");return t.innerHTML=e,t.content}const Gs=(function(e,t,r){const n=Vn(r);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++t<e.children.length;)if(n(e.children[t],t,e))return e.children[t]}),Lr=(function(e){if(e==null)return Yf;if(typeof e=="string")return $f(e);if(typeof e=="object")return jf(e);if(typeof e=="function")return P0(e);throw new Error("Expected function, string, or array as `test`")});function jf(e){const t=[];let r=-1;for(;++r<e.length;)t[r]=Lr(e[r]);return P0(n);function n(...a){let i=-1;for(;++i<t.length;)if(t[i].apply(this,a))return!0;return!1}}function $f(e){return P0(t);function t(r){return r.tagName===e}}function P0(e){return t;function t(r,n,a){return!!(Vf(r)&&e.call(this,r,typeof n=="number"?n:void 0,a||void 0))}}function Yf(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function Vf(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const Ws=/\n/g,Xs=/[\t ]+/g,n0=Lr("br"),Qs=Lr(em),Gf=Lr("p"),Ks=Lr("tr"),Wf=Lr(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",Jf,tm]),ko=Lr(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function Xf(e,t){const r=t||{},n="children"in e?e.children:[],a=ko(e),i=wo(e,{whitespace:r.whitespace||"normal"}),s=[];(e.type==="text"||e.type==="comment")&&s.push(...Ao(e,{breakBefore:!0,breakAfter:!0}));let u=-1;for(;++u<n.length;)s.push(...vo(n[u],e,{whitespace:i,breakBefore:u?void 0:a,breakAfter:u<n.length-1?n0(n[u+1]):a}));const l=[];let o;for(u=-1;++u<s.length;){const h=s[u];typeof h=="number"?o!==void 0&&h>o&&(o=h):h&&(o!==void 0&&o>-1&&l.push(`
3
3
  `.repeat(o)||" "),o=-1,l.push(h))}return l.join("")}function vo(e,t,r){return e.type==="element"?Qf(e,t,r):e.type==="text"?r.whitespace==="normal"?Ao(e,r):Kf(e):[]}function Qf(e,t,r){const n=wo(e,r),a=e.children||[];let i=-1,s=[];if(Wf(e))return s;let u,l;for(n0(e)||Ks(e)&&Gs(t,e,Ks)?l=`
4
4
  `:Gf(e)?(u=2,l=2):ko(e)&&(u=1,l=1);++i<a.length;)s=s.concat(vo(a[i],e,{whitespace:n,breakBefore:i?void 0:u,breakAfter:i<a.length-1?n0(a[i+1]):l}));return Qs(e)&&Gs(t,e,Qs)&&s.push(" "),u&&s.unshift(u),l&&s.push(l),s}function Ao(e,t){const r=String(e.value),n=[],a=[];let i=0;for(;i<=r.length;){Ws.lastIndex=i;const l=Ws.exec(r),o=l&&"index"in l?l.index:r.length;n.push(Zf(r.slice(i,o).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),i===0?t.breakBefore:!0,o===r.length?t.breakAfter:!0)),i=o+1}let s=-1,u;for(;++s<n.length;)n[s].charCodeAt(n[s].length-1)===8203||s<n.length-1&&n[s+1].charCodeAt(0)===8203?(a.push(n[s]),u=void 0):n[s]?(typeof u=="number"&&a.push(u),a.push(n[s]),u=0):(s===0||s===n.length-1)&&a.push(0);return a}function Kf(e){return[String(e.value)]}function Zf(e,t,r){const n=[];let a=0,i;for(;a<e.length;){Xs.lastIndex=a;const s=Xs.exec(e);i=s?s.index:e.length,!a&&!i&&s&&!t&&n.push(""),a!==i&&n.push(e.slice(a,i)),a=s?i+s[0].length:i}return a!==i&&!r&&n.push(""),n.join(" ")}function wo(e,t){if(e.type==="element"){const r=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return r.wrap?"pre-wrap":"pre";case"td":case"th":return r.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap"}}return t.whitespace}function Jf(e){return!!(e.properties||{}).hidden}function em(e){return e.tagName==="td"||e.tagName==="th"}function tm(e){return e.tagName==="dialog"&&!(e.properties||{}).open}class ht{constructor(t,r,n){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=t,this.start=r,this.end=n}static range(t,r){return r?!t||!t.loc||!r.loc||t.loc.lexer!==r.loc.lexer?null:new ht(t.loc.lexer,t.loc.start,r.loc.end):t&&t.loc}}class bt{constructor(t,r){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=t,this.loc=r}range(t,r){return new bt(r,ht.range(this,t))}}class X{constructor(t,r){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var n="KaTeX parse error: "+t,a,i,s=r&&r.loc;if(s&&s.start<=s.end){var u=s.lexer.input;a=s.start,i=s.end,a===u.length?n+=" at end of input: ":n+=" at position "+(a+1)+": ";var l=u.slice(a,i).replace(/[^]/g,"$&̲"),o;a>15?o="…"+u.slice(a-15,a):o=u.slice(0,a);var h;i+15<u.length?h=u.slice(i,i+15)+"…":h=u.slice(i),n+=o+l+h}var c=new Error(n);return c.name="ParseError",c.__proto__=X.prototype,c.position=a,a!=null&&i!=null&&(c.length=i-a),c.rawMessage=t,c}}X.prototype.__proto__=Error.prototype;var rm=function(t,r){return t===void 0?r:t},nm=/([A-Z])/g,am=function(t){return t.replace(nm,"-$1").toLowerCase()},im={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},sm=/[&><"']/g;function um(e){return String(e).replace(sm,t=>im[t])}var So=function e(t){return t.type==="ordgroup"||t.type==="color"?t.body.length===1?e(t.body[0]):t:t.type==="font"?e(t.body):t},lm=function(t){var r=So(t);return r.type==="mathord"||r.type==="textord"||r.type==="atom"},om=function(t){if(!t)throw new Error("Expected non-null, but got "+String(t));return t},cm=function(t){var r=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(t);return r?r[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(r[1])?null:r[1].toLowerCase():"_relative"},we={deflt:rm,escape:um,hyphenate:am,getBaseElem:So,isCharacterBox:lm,protocolFromUrl:cm},Cn={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:e=>Math.max(0,e),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:e=>Math.max(0,e),cli:"-e, --max-expand <n>",cliProcessor:e=>e==="Infinity"?1/0:parseInt(e)},globalGroup:{type:"boolean",cli:!1}};function hm(e){if(e.default)return e.default;var t=e.type,r=Array.isArray(t)?t[0]:t;if(typeof r!="string")return r.enum[0];switch(r){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class B0{constructor(t){this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,t=t||{};for(var r in Cn)if(Cn.hasOwnProperty(r)){var n=Cn[r];this[r]=t[r]!==void 0?n.processor?n.processor(t[r]):t[r]:hm(n)}}reportNonstrict(t,r,n){var a=this.strict;if(typeof a=="function"&&(a=a(t,r,n)),!(!a||a==="ignore")){if(a===!0||a==="error")throw new X("LaTeX-incompatible input and strict mode is set to 'error': "+(r+" ["+t+"]"),n);a==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(r+" ["+t+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+a+"': "+r+" ["+t+"]"))}}useStrictBehavior(t,r,n){var a=this.strict;if(typeof a=="function")try{a=a(t,r,n)}catch{a="error"}return!a||a==="ignore"?!1:a===!0||a==="error"?!0:a==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(r+" ["+t+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+a+"': "+r+" ["+t+"]")),!1)}isTrusted(t){if(t.url&&!t.protocol){var r=we.protocolFromUrl(t.url);if(r==null)return!1;t.protocol=r}var n=typeof this.trust=="function"?this.trust(t):this.trust;return!!n}}class sr{constructor(t,r,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=t,this.size=r,this.cramped=n}sup(){return Bt[dm[this.id]]}sub(){return Bt[fm[this.id]]}fracNum(){return Bt[mm[this.id]]}fracDen(){return Bt[pm[this.id]]}cramp(){return Bt[gm[this.id]]}text(){return Bt[bm[this.id]]}isTight(){return this.size>=2}}var F0=0,Ca=1,Gr=2,Jt=3,Hn=4,vt=5,Kr=6,it=7,Bt=[new sr(F0,0,!1),new sr(Ca,0,!0),new sr(Gr,1,!1),new sr(Jt,1,!0),new sr(Hn,2,!1),new sr(vt,2,!0),new sr(Kr,3,!1),new sr(it,3,!0)],dm=[Hn,vt,Hn,vt,Kr,it,Kr,it],fm=[vt,vt,vt,vt,it,it,it,it],mm=[Gr,Jt,Hn,vt,Kr,it,Kr,it],pm=[Jt,Jt,vt,vt,it,it,it,it],gm=[Ca,Ca,Jt,Jt,vt,vt,it,it],bm=[F0,Ca,Gr,Jt,Gr,Jt,Gr,Jt],ce={DISPLAY:Bt[F0],TEXT:Bt[Gr],SCRIPT:Bt[Hn],SCRIPTSCRIPT:Bt[Kr]},a0=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];function Em(e){for(var t=0;t<a0.length;t++)for(var r=a0[t],n=0;n<r.blocks.length;n++){var a=r.blocks[n];if(e>=a[0]&&e<=a[1])return r.name}return null}var ya=[];a0.forEach(e=>e.blocks.forEach(t=>ya.push(...t)));function Co(e){for(var t=0;t<ya.length;t+=2)if(e>=ya[t]&&e<=ya[t+1])return!0;return!1}var Ur=80,Tm=function(t,r){return"M95,"+(622+t+r)+`
5
5
  c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
@@ -365,13 +365,13 @@ ${e}</tr>
365
365
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),r=e.header?"th":"td";return(e.align?`<${r} align="${e.align}">`:`<${r}>`)+t+`</${r}>
366
366
  `}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>${Ot(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),a=ql(e);if(a===null)return n;e=a;let i='<a href="'+e+'"';return t&&(i+=' title="'+Ot(t)+'"'),i+=">"+n+"</a>",i}image({href:e,title:t,text:r,tokens:n}){n&&(r=this.parser.parseInline(n,this.parser.textRenderer));let a=ql(e);if(a===null)return Ot(r);e=a;let i=`<img src="${e}" alt="${r}"`;return t&&(i+=` title="${Ot(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ot(e.text)}},Ds=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""}},It=class D0{options;renderer;textRenderer;constructor(t){this.options=t||Pr,this.options.renderer=this.options.renderer||new Ua,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ds}static parse(t,r){return new D0(r).parse(t)}static parseInline(t,r){return new D0(r).parseInline(t)}parse(t,r=!0){let n="";for(let a=0;a<t.length;a++){let i=t[a];if(this.options.extensions?.renderers?.[i.type]){let u=i,l=this.options.extensions.renderers[u.type].call({parser:this},u);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(u.type)){n+=l||"";continue}}let s=i;switch(s.type){case"space":{n+=this.renderer.space(s);continue}case"hr":{n+=this.renderer.hr(s);continue}case"heading":{n+=this.renderer.heading(s);continue}case"code":{n+=this.renderer.code(s);continue}case"table":{n+=this.renderer.table(s);continue}case"blockquote":{n+=this.renderer.blockquote(s);continue}case"list":{n+=this.renderer.list(s);continue}case"html":{n+=this.renderer.html(s);continue}case"def":{n+=this.renderer.def(s);continue}case"paragraph":{n+=this.renderer.paragraph(s);continue}case"text":{let u=s,l=this.renderer.text(u);for(;a+1<t.length&&t[a+1].type==="text";)u=t[++a],l+=`
367
367
  `+this.renderer.text(u);r?n+=this.renderer.paragraph({type:"paragraph",raw:l,text:l,tokens:[{type:"text",raw:l,text:l,escaped:!0}]}):n+=l;continue}default:{let u='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}parseInline(t,r=this.renderer){let n="";for(let a=0;a<t.length;a++){let i=t[a];if(this.options.extensions?.renderers?.[i.type]){let u=this.options.extensions.renderers[i.type].call({parser:this},i);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=u||"";continue}}let s=i;switch(s.type){case"escape":{n+=r.text(s);break}case"html":{n+=r.html(s);break}case"link":{n+=r.link(s);break}case"image":{n+=r.image(s);break}case"strong":{n+=r.strong(s);break}case"em":{n+=r.em(s);break}case"codespan":{n+=r.codespan(s);break}case"br":{n+=r.br(s);break}case"del":{n+=r.del(s);break}case"text":{n+=r.text(s);break}default:{let u='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}},Sn=class{options;block;constructor(e){this.options=e||Pr}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(){return this.block?kt.lex:kt.lexInline}provideParser(){return this.block?It.parse:It.parseInline}},oT=class{defaults=vs();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=It;Renderer=Ua;TextRenderer=Ds;Lexer=kt;Tokenizer=Ha;Hooks=Sn;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 a=n;for(let i of a.header)r=r.concat(this.walkTokens(i.tokens,t));for(let i of a.rows)for(let s of i)r=r.concat(this.walkTokens(s.tokens,t));break}case"list":{let a=n;r=r.concat(this.walkTokens(a.items,t));break}default:{let a=n;this.defaults.extensions?.childTokens?.[a.type]?this.defaults.extensions.childTokens[a.type].forEach(i=>{let s=a[i].flat(1/0);r=r.concat(this.walkTokens(s,t))}):a.tokens&&(r=r.concat(this.walkTokens(a.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(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){let i=t.renderers[a.name];i?t.renderers[a.name]=function(...s){let u=a.renderer.apply(this,s);return u===!1&&(u=i.apply(this,s)),u}:t.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=t[a.level];i?i.unshift(a.tokenizer):t[a.level]=[a.tokenizer],a.start&&(a.level==="block"?t.startBlock?t.startBlock.push(a.start):t.startBlock=[a.start]:a.level==="inline"&&(t.startInline?t.startInline.push(a.start):t.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(t.childTokens[a.name]=a.childTokens)}),n.extensions=t),r.renderer){let a=this.defaults.renderer||new Ua(this.defaults);for(let i in r.renderer){if(!(i in a))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let s=i,u=r.renderer[s],l=a[s];a[s]=(...o)=>{let h=u.apply(a,o);return h===!1&&(h=l.apply(a,o)),h||""}}n.renderer=a}if(r.tokenizer){let a=this.defaults.tokenizer||new Ha(this.defaults);for(let i in r.tokenizer){if(!(i in a))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let s=i,u=r.tokenizer[s],l=a[s];a[s]=(...o)=>{let h=u.apply(a,o);return h===!1&&(h=l.apply(a,o)),h}}n.tokenizer=a}if(r.hooks){let a=this.defaults.hooks||new Sn;for(let i in r.hooks){if(!(i in a))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let s=i,u=r.hooks[s],l=a[s];Sn.passThroughHooks.has(i)?a[s]=o=>{if(this.defaults.async&&Sn.passThroughHooksRespectAsync.has(i))return(async()=>{let c=await u.call(a,o);return l.call(a,c)})();let h=u.call(a,o);return l.call(a,h)}:a[s]=(...o)=>{if(this.defaults.async)return(async()=>{let c=await u.apply(a,o);return c===!1&&(c=await l.apply(a,o)),c})();let h=u.apply(a,o);return h===!1&&(h=l.apply(a,o)),h}}n.hooks=a}if(r.walkTokens){let a=this.defaults.walkTokens,i=r.walkTokens;n.walkTokens=function(s){let u=[];return u.push(i.call(this,s)),a&&(u=u.concat(a.call(this,s))),u}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return kt.lex(e,t??this.defaults)}parser(e,t){return It.parse(e,t??this.defaults)}parseMarkdown(e){return(t,r)=>{let n={...r},a={...this.defaults,...n},i=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&n.async===!1)return i(new 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 i(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(a.hooks&&(a.hooks.options=a,a.hooks.block=e),a.async)return(async()=>{let s=a.hooks?await a.hooks.preprocess(t):t,u=await(a.hooks?await a.hooks.provideLexer():e?kt.lex:kt.lexInline)(s,a),l=a.hooks?await a.hooks.processAllTokens(u):u;a.walkTokens&&await Promise.all(this.walkTokens(l,a.walkTokens));let o=await(a.hooks?await a.hooks.provideParser():e?It.parse:It.parseInline)(l,a);return a.hooks?await a.hooks.postprocess(o):o})().catch(i);try{a.hooks&&(t=a.hooks.preprocess(t));let s=(a.hooks?a.hooks.provideLexer():e?kt.lex:kt.lexInline)(t,a);a.hooks&&(s=a.hooks.processAllTokens(s)),a.walkTokens&&this.walkTokens(s,a.walkTokens);let u=(a.hooks?a.hooks.provideParser():e?It.parse:It.parseInline)(s,a);return a.hooks&&(u=a.hooks.postprocess(u)),u}catch(s){return i(s)}}}onError(e,t){return r=>{if(r.message+=`
368
- Please report this to https://github.com/markedjs/marked.`,e){let n="<p>An error occurred:</p><pre>"+Ot(r.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(r);throw r}}},Ir=new oT;function Ne(e,t){return Ir.parse(e,t)}Ne.options=Ne.setOptions=function(e){return Ir.setOptions(e),Ne.defaults=Ir.defaults,gh(Ne.defaults),Ne};Ne.getDefaults=vs;Ne.defaults=Pr;Ne.use=function(...e){return Ir.use(...e),Ne.defaults=Ir.defaults,gh(Ne.defaults),Ne};Ne.walkTokens=function(e,t){return Ir.walkTokens(e,t)};Ne.parseInline=Ir.parseInline;Ne.Parser=It;Ne.parser=It.parse;Ne.Renderer=Ua;Ne.TextRenderer=Ds;Ne.Lexer=kt;Ne.lexer=kt.lex;Ne.Tokenizer=Ha;Ne.Hooks=Sn;Ne.parse=Ne;Ne.options;Ne.setOptions;Ne.use;Ne.walkTokens;Ne.parseInline;It.parse;kt.lex;var pe=(...e)=>Bd(Fd(e)),Xr=(e,t,r)=>{let n=typeof t=="string"?new Blob([t],{type:r}):t,a=URL.createObjectURL(n),i=document.createElement("a");i.href=a,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(a)},cT=B.createContext({code:""}),Ch=()=>B.useContext(cT),Yl=({onCopy:e,onError:t,timeout:r=2e3,children:n,className:a,code:i,...s})=>{let[u,l]=B.useState(!1),o=B.useRef(0),{code:h}=Ch(),{isAnimating:c}=B.useContext(Lt),m=i??h,g=async()=>{var y;if(typeof window>"u"||!((y=navigator?.clipboard)!=null&&y.writeText)){t?.(new Error("Clipboard API not available"));return}try{u||(await navigator.clipboard.writeText(m),l(!0),e?.(),o.current=window.setTimeout(()=>l(!1),r))}catch(v){t?.(v)}};B.useEffect(()=>()=>{window.clearTimeout(o.current)},[]);let E=u?ro:no;return I.jsx("button",{className:pe("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",a),"data-streamdown":"code-block-copy-button",disabled:c,onClick:g,title:"Copy Code",type:"button",...s,children:n??I.jsx(E,{size:14})})},Vl={"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"},hT=({onDownload:e,onError:t,language:r,children:n,className:a,code:i,...s})=>{let{code:u}=Ch(),{isAnimating:l}=B.useContext(Lt),o=i??u,h=`file.${r&&r in Vl?Vl[r]:"txt"}`,c="text/plain",m=()=>{try{Xr(h,o,c),e?.()}catch(g){t?.(g)}};return I.jsx("button",{className:pe("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",a),"data-streamdown":"code-block-download-button",disabled:l,onClick:m,title:"Download file",type:"button",...s,children:n??I.jsx(qa,{size:14})})},Gl=()=>I.jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[I.jsx("div",{className:"h-[46px] w-full bg-muted/80"}),I.jsx("div",{className:"flex w-full items-center justify-center p-4",children:I.jsx(Sd,{className:"size-4 animate-spin"})})]}),dT=/\.[^/.]+$/,fT=({node:e,className:t,src:r,alt:n,...a})=>{let i=async()=>{if(r)try{let s=await(await fetch(r)).blob(),u=new URL(r,window.location.origin).pathname.split("/").pop()||"",l=u.split(".").pop(),o=u.includes(".")&&l!==void 0&&l.length<=4,h="";if(o)h=u;else{let c=s.type,m="png";c.includes("jpeg")||c.includes("jpg")?m="jpg":c.includes("png")?m="png":c.includes("svg")?m="svg":c.includes("gif")?m="gif":c.includes("webp")&&(m="webp"),h=`${(n||u||"image").replace(dT,"")}.${m}`}Xr(h,s,s.type)}catch(s){console.error("Failed to download image:",s)}};return r?I.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[I.jsx("img",{alt:n,className:pe("max-w-full rounded-lg",t),"data-streamdown":"image",src:r,...a}),I.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),I.jsx("button",{className:pe("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:i,title:"Download image",type:"button",children:I.jsx(qa,{size:14})})]}):null},Nh=async e=>{let t={startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0,...e},r=(await ja(async()=>{const{default:n}=await import("./mermaid.core-CaljvboY.js").then(a=>a.bA);return{default:n}},__vite__mapDeps([0,1,2,3]))).default;return r.initialize(t),r},mT=(e,t)=>{var r;let n=(r=void 0)!=null?r:5;return new Promise((a,i)=>{let s="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),u=new Image;u.crossOrigin="anonymous",u.onload=()=>{let l=document.createElement("canvas"),o=u.width*n,h=u.height*n;l.width=o,l.height=h;let c=l.getContext("2d");if(!c){i(new Error("Failed to create 2D canvas context for PNG export"));return}c.drawImage(u,0,0,o,h),l.toBlob(m=>{if(!m){i(new Error("Failed to create PNG blob"));return}a(m)},"image/png")},u.onerror=()=>i(new Error("Failed to load SVG image")),u.src=s})},pT=({chart:e,children:t,className:r,onDownload:n,config:a,onError:i})=>{let[s,u]=B.useState(!1),l=B.useRef(null),{isAnimating:o}=B.useContext(Lt),h=async c=>{try{if(c==="mmd"){Xr("diagram.mmd",e,"text/plain"),u(!1),n?.(c);return}let m=await Nh(a),g=e.split("").reduce((v,A)=>(v<<5)-v+A.charCodeAt(0)|0,0),E=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:y}=await m.render(E,e);if(!y){i?.(new Error("SVG not found. Please wait for the diagram to render."));return}if(c==="svg"){Xr("diagram.svg",y,"image/svg+xml"),u(!1),n?.(c);return}if(c==="png"){let v=await mT(y);Xr("diagram.png",v,"image/png"),n?.(c),u(!1);return}}catch(m){i?.(m)}};return B.useEffect(()=>{let c=m=>{l.current&&!l.current.contains(m.target)&&u(!1)};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[]),I.jsxs("div",{className:"relative",ref:l,children:[I.jsx("button",{className:pe("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:o,onClick:()=>u(!s),title:"Download diagram",type:"button",children:t??I.jsx(qa,{size:14})}),s&&I.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>h("svg"),title:"Download diagram as SVG",type:"button",children:"SVG"}),I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>h("png"),title:"Download diagram as PNG",type:"button",children:"PNG"}),I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>h("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]})]})},Fn=0,gT=()=>{Fn+=1,Fn===1&&(document.body.style.overflow="hidden")},bT=()=>{Fn=Math.max(0,Fn-1),Fn===0&&(document.body.style.overflow="")},ET=({chart:e,config:t,onFullscreen:r,onExit:n,className:a,...i})=>{let[s,u]=B.useState(!1),{isAnimating:l,controls:o}=B.useContext(Lt),h=(()=>{if(typeof o=="boolean")return o;let m=o.mermaid;return m===!1?!1:m===!0||m===void 0?!0:m.panZoom!==!1})(),c=()=>{u(!s)};return B.useEffect(()=>{if(s){gT();let m=g=>{g.key==="Escape"&&u(!1)};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),bT()}}},[s]),B.useEffect(()=>{s?r?.():n&&n()},[s,r,n]),I.jsxs(I.Fragment,{children:[I.jsx("button",{className:pe("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",a),disabled:l,onClick:c,title:"View fullscreen",type:"button",...i,children:I.jsx(Ad,{size:14})}),s&&I.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:c,onKeyDown:m=>{m.key==="Escape"&&c()},role:"button",tabIndex:0,children:[I.jsx("button",{className:"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:"Exit fullscreen",type:"button",children:I.jsx(wd,{size:20})}),I.jsx("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),role:"presentation",children:I.jsx(nd,{chart:e,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:!0,showControls:h})})]})]})},_h=e=>{var t,r;let n=[],a=[],i=e.querySelectorAll("thead th");for(let u of i)n.push(((t=u.textContent)==null?void 0:t.trim())||"");let s=e.querySelectorAll("tbody tr");for(let u of s){let l=[],o=u.querySelectorAll("td");for(let h of o)l.push(((r=h.textContent)==null?void 0:r.trim())||"");a.push(l)}return{headers:n,rows:a}},Ih=e=>{let{headers:t,rows:r}=e,n=u=>{let l=!1,o=!1;for(let h=0;h<u.length;h+=1){let c=u[h];if(c==='"'){l=!0,o=!0;break}(c===","||c===`
368
+ Please report this to https://github.com/markedjs/marked.`,e){let n="<p>An error occurred:</p><pre>"+Ot(r.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(r);throw r}}},Ir=new oT;function Ne(e,t){return Ir.parse(e,t)}Ne.options=Ne.setOptions=function(e){return Ir.setOptions(e),Ne.defaults=Ir.defaults,gh(Ne.defaults),Ne};Ne.getDefaults=vs;Ne.defaults=Pr;Ne.use=function(...e){return Ir.use(...e),Ne.defaults=Ir.defaults,gh(Ne.defaults),Ne};Ne.walkTokens=function(e,t){return Ir.walkTokens(e,t)};Ne.parseInline=Ir.parseInline;Ne.Parser=It;Ne.parser=It.parse;Ne.Renderer=Ua;Ne.TextRenderer=Ds;Ne.Lexer=kt;Ne.lexer=kt.lex;Ne.Tokenizer=Ha;Ne.Hooks=Sn;Ne.parse=Ne;Ne.options;Ne.setOptions;Ne.use;Ne.walkTokens;Ne.parseInline;It.parse;kt.lex;var pe=(...e)=>Bd(Fd(e)),Xr=(e,t,r)=>{let n=typeof t=="string"?new Blob([t],{type:r}):t,a=URL.createObjectURL(n),i=document.createElement("a");i.href=a,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(a)},cT=B.createContext({code:""}),Ch=()=>B.useContext(cT),Yl=({onCopy:e,onError:t,timeout:r=2e3,children:n,className:a,code:i,...s})=>{let[u,l]=B.useState(!1),o=B.useRef(0),{code:h}=Ch(),{isAnimating:c}=B.useContext(Lt),m=i??h,g=async()=>{var y;if(typeof window>"u"||!((y=navigator?.clipboard)!=null&&y.writeText)){t?.(new Error("Clipboard API not available"));return}try{u||(await navigator.clipboard.writeText(m),l(!0),e?.(),o.current=window.setTimeout(()=>l(!1),r))}catch(v){t?.(v)}};B.useEffect(()=>()=>{window.clearTimeout(o.current)},[]);let E=u?ro:no;return I.jsx("button",{className:pe("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",a),"data-streamdown":"code-block-copy-button",disabled:c,onClick:g,title:"Copy Code",type:"button",...s,children:n??I.jsx(E,{size:14})})},Vl={"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"},hT=({onDownload:e,onError:t,language:r,children:n,className:a,code:i,...s})=>{let{code:u}=Ch(),{isAnimating:l}=B.useContext(Lt),o=i??u,h=`file.${r&&r in Vl?Vl[r]:"txt"}`,c="text/plain",m=()=>{try{Xr(h,o,c),e?.()}catch(g){t?.(g)}};return I.jsx("button",{className:pe("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",a),"data-streamdown":"code-block-download-button",disabled:l,onClick:m,title:"Download file",type:"button",...s,children:n??I.jsx(qa,{size:14})})},Gl=()=>I.jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[I.jsx("div",{className:"h-[46px] w-full bg-muted/80"}),I.jsx("div",{className:"flex w-full items-center justify-center p-4",children:I.jsx(Sd,{className:"size-4 animate-spin"})})]}),dT=/\.[^/.]+$/,fT=({node:e,className:t,src:r,alt:n,...a})=>{let i=async()=>{if(r)try{let s=await(await fetch(r)).blob(),u=new URL(r,window.location.origin).pathname.split("/").pop()||"",l=u.split(".").pop(),o=u.includes(".")&&l!==void 0&&l.length<=4,h="";if(o)h=u;else{let c=s.type,m="png";c.includes("jpeg")||c.includes("jpg")?m="jpg":c.includes("png")?m="png":c.includes("svg")?m="svg":c.includes("gif")?m="gif":c.includes("webp")&&(m="webp"),h=`${(n||u||"image").replace(dT,"")}.${m}`}Xr(h,s,s.type)}catch(s){console.error("Failed to download image:",s)}};return r?I.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[I.jsx("img",{alt:n,className:pe("max-w-full rounded-lg",t),"data-streamdown":"image",src:r,...a}),I.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),I.jsx("button",{className:pe("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:i,title:"Download image",type:"button",children:I.jsx(qa,{size:14})})]}):null},Nh=async e=>{let t={startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0,...e},r=(await ja(async()=>{const{default:n}=await import("./mermaid.core-DmainLbW.js").then(a=>a.bA);return{default:n}},__vite__mapDeps([0,1,2,3]))).default;return r.initialize(t),r},mT=(e,t)=>{var r;let n=(r=void 0)!=null?r:5;return new Promise((a,i)=>{let s="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),u=new Image;u.crossOrigin="anonymous",u.onload=()=>{let l=document.createElement("canvas"),o=u.width*n,h=u.height*n;l.width=o,l.height=h;let c=l.getContext("2d");if(!c){i(new Error("Failed to create 2D canvas context for PNG export"));return}c.drawImage(u,0,0,o,h),l.toBlob(m=>{if(!m){i(new Error("Failed to create PNG blob"));return}a(m)},"image/png")},u.onerror=()=>i(new Error("Failed to load SVG image")),u.src=s})},pT=({chart:e,children:t,className:r,onDownload:n,config:a,onError:i})=>{let[s,u]=B.useState(!1),l=B.useRef(null),{isAnimating:o}=B.useContext(Lt),h=async c=>{try{if(c==="mmd"){Xr("diagram.mmd",e,"text/plain"),u(!1),n?.(c);return}let m=await Nh(a),g=e.split("").reduce((v,A)=>(v<<5)-v+A.charCodeAt(0)|0,0),E=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:y}=await m.render(E,e);if(!y){i?.(new Error("SVG not found. Please wait for the diagram to render."));return}if(c==="svg"){Xr("diagram.svg",y,"image/svg+xml"),u(!1),n?.(c);return}if(c==="png"){let v=await mT(y);Xr("diagram.png",v,"image/png"),n?.(c),u(!1);return}}catch(m){i?.(m)}};return B.useEffect(()=>{let c=m=>{l.current&&!l.current.contains(m.target)&&u(!1)};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[]),I.jsxs("div",{className:"relative",ref:l,children:[I.jsx("button",{className:pe("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:o,onClick:()=>u(!s),title:"Download diagram",type:"button",children:t??I.jsx(qa,{size:14})}),s&&I.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>h("svg"),title:"Download diagram as SVG",type:"button",children:"SVG"}),I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>h("png"),title:"Download diagram as PNG",type:"button",children:"PNG"}),I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>h("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]})]})},Fn=0,gT=()=>{Fn+=1,Fn===1&&(document.body.style.overflow="hidden")},bT=()=>{Fn=Math.max(0,Fn-1),Fn===0&&(document.body.style.overflow="")},ET=({chart:e,config:t,onFullscreen:r,onExit:n,className:a,...i})=>{let[s,u]=B.useState(!1),{isAnimating:l,controls:o}=B.useContext(Lt),h=(()=>{if(typeof o=="boolean")return o;let m=o.mermaid;return m===!1?!1:m===!0||m===void 0?!0:m.panZoom!==!1})(),c=()=>{u(!s)};return B.useEffect(()=>{if(s){gT();let m=g=>{g.key==="Escape"&&u(!1)};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m),bT()}}},[s]),B.useEffect(()=>{s?r?.():n&&n()},[s,r,n]),I.jsxs(I.Fragment,{children:[I.jsx("button",{className:pe("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",a),disabled:l,onClick:c,title:"View fullscreen",type:"button",...i,children:I.jsx(Ad,{size:14})}),s&&I.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:c,onKeyDown:m=>{m.key==="Escape"&&c()},role:"button",tabIndex:0,children:[I.jsx("button",{className:"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:"Exit fullscreen",type:"button",children:I.jsx(wd,{size:20})}),I.jsx("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),role:"presentation",children:I.jsx(nd,{chart:e,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:!0,showControls:h})})]})]})},_h=e=>{var t,r;let n=[],a=[],i=e.querySelectorAll("thead th");for(let u of i)n.push(((t=u.textContent)==null?void 0:t.trim())||"");let s=e.querySelectorAll("tbody tr");for(let u of s){let l=[],o=u.querySelectorAll("td");for(let h of o)l.push(((r=h.textContent)==null?void 0:r.trim())||"");a.push(l)}return{headers:n,rows:a}},Ih=e=>{let{headers:t,rows:r}=e,n=u=>{let l=!1,o=!1;for(let h=0;h<u.length;h+=1){let c=u[h];if(c==='"'){l=!0,o=!0;break}(c===","||c===`
369
369
  `)&&(l=!0)}return l?o?`"${u.replace(/"/g,'""')}"`:`"${u}"`:u},a=t.length>0?r.length+1:r.length,i=new Array(a),s=0;t.length>0&&(i[s]=t.map(n).join(","),s+=1);for(let u of r)i[s]=u.map(n).join(","),s+=1;return i.join(`
370
370
  `)},TT=e=>{let{headers:t,rows:r}=e,n=u=>{let l=!1;for(let h=0;h<u.length;h+=1){let c=u[h];if(c===" "||c===`
371
371
  `||c==="\r"){l=!0;break}}if(!l)return u;let o=[];for(let h=0;h<u.length;h+=1){let c=u[h];c===" "?o.push("\\t"):c===`
372
372
  `?o.push("\\n"):c==="\r"?o.push("\\r"):o.push(c)}return o.join("")},a=t.length>0?r.length+1:r.length,i=new Array(a),s=0;t.length>0&&(i[s]=t.map(n).join(" "),s+=1);for(let u of r)i[s]=u.map(n).join(" "),s+=1;return i.join(`
373
373
  `)},Qi=e=>{let t=!1;for(let n=0;n<e.length;n+=1){let a=e[n];if(a==="\\"||a==="|"){t=!0;break}}if(!t)return e;let r=[];for(let n=0;n<e.length;n+=1){let a=e[n];a==="\\"?r.push("\\\\"):a==="|"?r.push("\\|"):r.push(a)}return r.join("")},xT=e=>{let{headers:t,rows:r}=e;if(t.length===0)return"";let n=new Array(r.length+2),a=0,i=t.map(u=>Qi(u));n[a]=`| ${i.join(" | ")} |`,a+=1;let s=new Array(t.length);for(let u=0;u<t.length;u+=1)s[u]="---";n[a]=`| ${s.join(" | ")} |`,a+=1;for(let u of r)if(u.length<t.length){let l=new Array(t.length);for(let o=0;o<t.length;o+=1)l[o]=o<u.length?Qi(u[o]):"";n[a]=`| ${l.join(" | ")} |`,a+=1}else{let l=u.map(o=>Qi(o));n[a]=`| ${l.join(" | ")} |`,a+=1}return n.join(`
374
- `)},yT=({children:e,className:t,onCopy:r,onError:n,timeout:a=2e3})=>{let[i,s]=B.useState(!1),[u,l]=B.useState(!1),o=B.useRef(null),h=B.useRef(0),{isAnimating:c}=B.useContext(Lt),m=async E=>{var y,v;if(typeof window>"u"||!((y=navigator?.clipboard)!=null&&y.write)){n?.(new Error("Clipboard API not available"));return}try{let A=(v=o.current)==null?void 0:v.closest('[data-streamdown="table-wrapper"]'),w=A?.querySelector("table");if(!w){n?.(new Error("Table not found"));return}let L=_h(w),z=E==="csv"?Ih(L):TT(L),q=new ClipboardItem({"text/plain":new Blob([z],{type:"text/plain"}),"text/html":new Blob([w.outerHTML],{type:"text/html"})});await navigator.clipboard.write([q]),l(!0),s(!1),r?.(E),h.current=window.setTimeout(()=>l(!1),a)}catch(A){n?.(A)}};B.useEffect(()=>{let E=y=>{o.current&&!o.current.contains(y.target)&&s(!1)};return document.addEventListener("mousedown",E),()=>{document.removeEventListener("mousedown",E),window.clearTimeout(h.current)}},[]);let g=u?ro:no;return I.jsxs("div",{className:"relative",ref:o,children:[I.jsx("button",{className:pe("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:()=>s(!i),title:"Copy table",type:"button",children:e??I.jsx(g,{size:14})}),i&&I.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]})]})},kT=({children:e,className:t,onDownload:r,onError:n})=>{let[a,i]=B.useState(!1),s=B.useRef(null),{isAnimating:u}=B.useContext(Lt),l=o=>{var h;try{let c=(h=s.current)==null?void 0:h.closest('[data-streamdown="table-wrapper"]'),m=c?.querySelector("table");if(!m){n?.(new Error("Table not found"));return}let g=_h(m),E=o==="csv"?Ih(g):xT(g);Xr(`table.${o==="csv"?"csv":"md"}`,E,o==="csv"?"text/csv":"text/markdown"),i(!1),r?.(o)}catch(c){n?.(c)}};return B.useEffect(()=>{let o=h=>{s.current&&!s.current.contains(h.target)&&i(!1)};return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[]),I.jsxs("div",{className:"relative",ref:s,children:[I.jsx("button",{className:pe("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>i(!a),title:"Download table",type:"button",children:e??I.jsx(qa,{size:14})}),a&&I.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]})]})},vT=({children:e,className:t,showControls:r,...n})=>I.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[r&&I.jsxs("div",{className:"flex items-center justify-end gap-1",children:[I.jsx(yT,{}),I.jsx(kT,{})]}),I.jsx("div",{className:"overflow-x-auto",children:I.jsx("table",{className:pe("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]}),AT=B.lazy(()=>ja(()=>import("./code-block-IT6T5CEO-DA6hEb7Y.js"),__vite__mapDeps([4,3,5,6,1,2,7,8,9,10,11,12,13])).then(e=>({default:e.CodeBlock}))),wT=B.lazy(()=>ja(()=>Promise.resolve().then(()=>gx),void 0).then(e=>({default:e.Mermaid}))),ST=/language-([^\s]+)/;function ci(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,a=e.position.end,i=t.position.end;return r?.line===n?.line&&r?.column===n?.column&&a?.line===i?.line&&a?.column===i?.column}function Ue(e,t){return e.className===t.className&&ci(e.node,t.node)}var L0=(e,t)=>typeof e=="boolean"?e:e[t]!==!1,Ta=(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},Ls=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("ol",{className:pe("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>Ue(e,t));Ls.displayName="MarkdownOl";var Dh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("li",{className:pe("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&ci(e.node,t.node));Dh.displayName="MarkdownLi";var Lh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("ul",{className:pe("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>Ue(e,t));Lh.displayName="MarkdownUl";var Rh=B.memo(({className:e,node:t,...r})=>I.jsx("hr",{className:pe("my-6 border-border",e),"data-streamdown":"horizontal-rule",...r}),(e,t)=>Ue(e,t));Rh.displayName="MarkdownHr";var Oh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("span",{className:pe("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>Ue(e,t));Oh.displayName="MarkdownStrong";var Mh=B.memo(({children:e,className:t,href:r,node:n,...a})=>{let i=r==="streamdown:incomplete-link";return I.jsx("a",{className:pe("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":i,"data-streamdown":"link",href:r,rel:"noreferrer",target:"_blank",...a,children:e})},(e,t)=>Ue(e,t)&&e.href===t.href);Mh.displayName="MarkdownA";var Ph=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("h1",{className:pe("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>Ue(e,t));Ph.displayName="MarkdownH1";var Bh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("h2",{className:pe("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>Ue(e,t));Bh.displayName="MarkdownH2";var Fh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("h3",{className:pe("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>Ue(e,t));Fh.displayName="MarkdownH3";var zh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("h4",{className:pe("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>Ue(e,t));zh.displayName="MarkdownH4";var Hh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("h5",{className:pe("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>Ue(e,t));Hh.displayName="MarkdownH5";var Uh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("h6",{className:pe("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>Ue(e,t));Uh.displayName="MarkdownH6";var qh=B.memo(({children:e,className:t,node:r,...n})=>{let{controls:a}=B.useContext(Lt),i=L0(a,"table");return I.jsx(vT,{className:t,"data-streamdown":"table-wrapper",showControls:i,...n,children:e})},(e,t)=>Ue(e,t));qh.displayName="MarkdownTable";var jh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("thead",{className:pe("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>Ue(e,t));jh.displayName="MarkdownThead";var $h=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("tbody",{className:pe("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>Ue(e,t));$h.displayName="MarkdownTbody";var Yh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("tr",{className:pe("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>Ue(e,t));Yh.displayName="MarkdownTr";var Vh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("th",{className:pe("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>Ue(e,t));Vh.displayName="MarkdownTh";var Gh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("td",{className:pe("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>Ue(e,t));Gh.displayName="MarkdownTd";var Wh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("blockquote",{className:pe("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>Ue(e,t));Wh.displayName="MarkdownBlockquote";var Xh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("sup",{className:pe("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>Ue(e,t));Xh.displayName="MarkdownSup";var Qh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("sub",{className:pe("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>Ue(e,t));Qh.displayName="MarkdownSub";var Kh=B.memo(({children:e,className:t,node:r,...n})=>{if("data-footnotes"in n){let a=s=>{var u,l;if(!B.isValidElement(s))return!1;let o=Array.isArray(s.props.children)?s.props.children:[s.props.children],h=!1,c=!1;for(let m of o)if(m){if(typeof m=="string")m.trim()!==""&&(h=!0);else if(B.isValidElement(m))if(((u=m.props)==null?void 0:u["data-footnote-backref"])!==void 0)c=!0;else{let g=Array.isArray(m.props.children)?m.props.children:[m.props.children];for(let E of g){if(typeof E=="string"&&E.trim()!==""){h=!0;break}if(B.isValidElement(E)&&((l=E.props)==null?void 0:l["data-footnote-backref"])===void 0){h=!0;break}}}}return c&&!h},i=Array.isArray(e)?e.map(s=>{if(!B.isValidElement(s))return s;if(s.type===Ls){let u=(Array.isArray(s.props.children)?s.props.children:[s.props.children]).filter(l=>!a(l));return u.length===0?null:{...s,props:{...s.props,children:u}}}return s}):e;return(Array.isArray(i)?i.some(s=>s!==null):i!==null)?I.jsx("section",{className:t,...n,children:i}):null}return I.jsx("section",{className:t,...n,children:e})},(e,t)=>Ue(e,t));Kh.displayName="MarkdownSection";var CT=({node:e,className:t,children:r,...n})=>{var a,i,s;let u=((a=e?.position)==null?void 0:a.start.line)===((i=e?.position)==null?void 0:i.end.line),{mermaid:l,controls:o}=B.useContext(Lt);if(u)return I.jsx("code",{className:pe("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:r});let h=t?.match(ST),c=(s=h?.at(1))!=null?s:"",m="";if(B.isValidElement(r)&&r.props&&typeof r.props=="object"&&"children"in r.props&&typeof r.props.children=="string"?m=r.props.children:typeof r=="string"&&(m=r),c==="mermaid"){let E=L0(o,"mermaid"),y=Ta(o,"download"),v=Ta(o,"copy"),A=Ta(o,"fullscreen"),w=Ta(o,"panZoom");return I.jsx(B.Suspense,{fallback:I.jsx(Gl,{}),children:I.jsxs("div",{className:pe("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[E&&(y||v||A)&&I.jsxs("div",{className:"flex items-center justify-end gap-2",children:[y&&I.jsx(pT,{chart:m,config:l?.config}),v&&I.jsx(Yl,{code:m}),A&&I.jsx(ET,{chart:m,config:l?.config})]}),I.jsx(wT,{chart:m,config:l?.config,showControls:w})]})})}let g=L0(o,"code");return I.jsx(B.Suspense,{fallback:I.jsx(Gl,{}),children:I.jsx(AT,{className:pe("overflow-x-auto border-border border-t",t),code:m,language:c,children:g&&I.jsxs(I.Fragment,{children:[I.jsx(hT,{code:m,language:c}),I.jsx(Yl,{})]})})})},Zh=B.memo(CT,(e,t)=>e.className===t.className&&ci(e.node,t.node));Zh.displayName="MarkdownCode";var Jh=B.memo(fT,(e,t)=>e.className===t.className&&ci(e.node,t.node));Jh.displayName="MarkdownImg";var ed=B.memo(({children:e,className:t,node:r,...n})=>{var a;let i=(Array.isArray(e)?e:[e]).filter(s=>s!=null&&s!=="");return i.length===1&&B.isValidElement(i[0])&&((a=i[0].props.node)==null?void 0:a.tagName)==="img"?I.jsx(I.Fragment,{children:e}):I.jsx("p",{className:t,...n,children:e})},(e,t)=>Ue(e,t));ed.displayName="MarkdownParagraph";var NT={ol:Ls,li:Dh,ul:Lh,hr:Rh,strong:Oh,a:Mh,h1:Ph,h2:Bh,h3:Fh,h4:zh,h5:Hh,h6:Uh,table:qh,thead:jh,tbody:$h,tr:Yh,th:Vh,td:Gh,blockquote:Wh,code:Zh,img:Jh,pre:({children:e})=>e,sup:Xh,sub:Qh,p:ed,section:Kh},Wl=[],Xl={allowDangerousHtml:!0},xa=new WeakMap,_T=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 r=e.rehypePlugins,n=e.remarkPlugins,a=e.remarkRehypeOptions;if(!(r||n||a)){let h="default";return this.keyCache.set(e,h),h}let i=h=>{if(!h||h.length===0)return"";let c="";for(let m=0;m<h.length;m+=1){let g=h[m];if(m>0&&(c+=","),Array.isArray(g)){let[E,y]=g;if(typeof E=="function"){let v=xa.get(E);v||(v=E.name,xa.set(E,v)),c+=v}else c+=String(E);c+=":",c+=JSON.stringify(y)}else if(typeof g=="function"){let E=xa.get(g);E||(E=g.name,xa.set(g,E)),c+=E}else c+=String(g)}return c},s=i(r),u=i(n),l=a?JSON.stringify(a):"",o=`${u}::${s}::${l}`;return this.keyCache.set(e,o),o}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()}},Ql=new _T,td=e=>{let t=IT(e),r=e.children||"";return LT(t.runSync(t.parse(r),r),e)},IT=e=>{let t=Ql.get(e);if(t)return t;let r=DT(e);return Ql.set(e,r),r},DT=e=>{let t=e.rehypePlugins||Wl,r=e.remarkPlugins||Wl,n=e.remarkRehypeOptions?{...Xl,...e.remarkRehypeOptions}:Xl;return vE().use(k9).use(r).use(aE,n).use(t)},LT=(e,t)=>Ib(e,{Fragment:I.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:I.jsx,jsxs:I.jsxs,passKeys:!0,passNode:!0}),RT=/\[\^[^\]\s]{1,200}\](?!:)/,OT=/\[\^[^\]\s]{1,200}\]:/,MT=/<\/(\w+)>/,PT=/<(\w+)[\s>]/,Ki=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
374
+ `)},yT=({children:e,className:t,onCopy:r,onError:n,timeout:a=2e3})=>{let[i,s]=B.useState(!1),[u,l]=B.useState(!1),o=B.useRef(null),h=B.useRef(0),{isAnimating:c}=B.useContext(Lt),m=async E=>{var y,v;if(typeof window>"u"||!((y=navigator?.clipboard)!=null&&y.write)){n?.(new Error("Clipboard API not available"));return}try{let A=(v=o.current)==null?void 0:v.closest('[data-streamdown="table-wrapper"]'),w=A?.querySelector("table");if(!w){n?.(new Error("Table not found"));return}let L=_h(w),z=E==="csv"?Ih(L):TT(L),q=new ClipboardItem({"text/plain":new Blob([z],{type:"text/plain"}),"text/html":new Blob([w.outerHTML],{type:"text/html"})});await navigator.clipboard.write([q]),l(!0),s(!1),r?.(E),h.current=window.setTimeout(()=>l(!1),a)}catch(A){n?.(A)}};B.useEffect(()=>{let E=y=>{o.current&&!o.current.contains(y.target)&&s(!1)};return document.addEventListener("mousedown",E),()=>{document.removeEventListener("mousedown",E),window.clearTimeout(h.current)}},[]);let g=u?ro:no;return I.jsxs("div",{className:"relative",ref:o,children:[I.jsx("button",{className:pe("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:()=>s(!i),title:"Copy table",type:"button",children:e??I.jsx(g,{size:14})}),i&&I.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]})]})},kT=({children:e,className:t,onDownload:r,onError:n})=>{let[a,i]=B.useState(!1),s=B.useRef(null),{isAnimating:u}=B.useContext(Lt),l=o=>{var h;try{let c=(h=s.current)==null?void 0:h.closest('[data-streamdown="table-wrapper"]'),m=c?.querySelector("table");if(!m){n?.(new Error("Table not found"));return}let g=_h(m),E=o==="csv"?Ih(g):xT(g);Xr(`table.${o==="csv"?"csv":"md"}`,E,o==="csv"?"text/csv":"text/markdown"),i(!1),r?.(o)}catch(c){n?.(c)}};return B.useEffect(()=>{let o=h=>{s.current&&!s.current.contains(h.target)&&i(!1)};return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[]),I.jsxs("div",{className:"relative",ref:s,children:[I.jsx("button",{className:pe("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>i(!a),title:"Download table",type:"button",children:e??I.jsx(qa,{size:14})}),a&&I.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),I.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]})]})},vT=({children:e,className:t,showControls:r,...n})=>I.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[r&&I.jsxs("div",{className:"flex items-center justify-end gap-1",children:[I.jsx(yT,{}),I.jsx(kT,{})]}),I.jsx("div",{className:"overflow-x-auto",children:I.jsx("table",{className:pe("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]}),AT=B.lazy(()=>ja(()=>import("./code-block-IT6T5CEO-mzJGOnKv.js"),__vite__mapDeps([4,3,5,6,1,2,7,8,9,10,11,12,13])).then(e=>({default:e.CodeBlock}))),wT=B.lazy(()=>ja(()=>Promise.resolve().then(()=>gx),void 0).then(e=>({default:e.Mermaid}))),ST=/language-([^\s]+)/;function ci(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,a=e.position.end,i=t.position.end;return r?.line===n?.line&&r?.column===n?.column&&a?.line===i?.line&&a?.column===i?.column}function Ue(e,t){return e.className===t.className&&ci(e.node,t.node)}var L0=(e,t)=>typeof e=="boolean"?e:e[t]!==!1,Ta=(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},Ls=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("ol",{className:pe("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>Ue(e,t));Ls.displayName="MarkdownOl";var Dh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("li",{className:pe("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&ci(e.node,t.node));Dh.displayName="MarkdownLi";var Lh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("ul",{className:pe("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>Ue(e,t));Lh.displayName="MarkdownUl";var Rh=B.memo(({className:e,node:t,...r})=>I.jsx("hr",{className:pe("my-6 border-border",e),"data-streamdown":"horizontal-rule",...r}),(e,t)=>Ue(e,t));Rh.displayName="MarkdownHr";var Oh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("span",{className:pe("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>Ue(e,t));Oh.displayName="MarkdownStrong";var Mh=B.memo(({children:e,className:t,href:r,node:n,...a})=>{let i=r==="streamdown:incomplete-link";return I.jsx("a",{className:pe("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":i,"data-streamdown":"link",href:r,rel:"noreferrer",target:"_blank",...a,children:e})},(e,t)=>Ue(e,t)&&e.href===t.href);Mh.displayName="MarkdownA";var Ph=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("h1",{className:pe("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>Ue(e,t));Ph.displayName="MarkdownH1";var Bh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("h2",{className:pe("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>Ue(e,t));Bh.displayName="MarkdownH2";var Fh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("h3",{className:pe("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>Ue(e,t));Fh.displayName="MarkdownH3";var zh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("h4",{className:pe("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>Ue(e,t));zh.displayName="MarkdownH4";var Hh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("h5",{className:pe("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>Ue(e,t));Hh.displayName="MarkdownH5";var Uh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("h6",{className:pe("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>Ue(e,t));Uh.displayName="MarkdownH6";var qh=B.memo(({children:e,className:t,node:r,...n})=>{let{controls:a}=B.useContext(Lt),i=L0(a,"table");return I.jsx(vT,{className:t,"data-streamdown":"table-wrapper",showControls:i,...n,children:e})},(e,t)=>Ue(e,t));qh.displayName="MarkdownTable";var jh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("thead",{className:pe("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>Ue(e,t));jh.displayName="MarkdownThead";var $h=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("tbody",{className:pe("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>Ue(e,t));$h.displayName="MarkdownTbody";var Yh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("tr",{className:pe("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>Ue(e,t));Yh.displayName="MarkdownTr";var Vh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("th",{className:pe("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>Ue(e,t));Vh.displayName="MarkdownTh";var Gh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("td",{className:pe("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>Ue(e,t));Gh.displayName="MarkdownTd";var Wh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("blockquote",{className:pe("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>Ue(e,t));Wh.displayName="MarkdownBlockquote";var Xh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("sup",{className:pe("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>Ue(e,t));Xh.displayName="MarkdownSup";var Qh=B.memo(({children:e,className:t,node:r,...n})=>I.jsx("sub",{className:pe("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>Ue(e,t));Qh.displayName="MarkdownSub";var Kh=B.memo(({children:e,className:t,node:r,...n})=>{if("data-footnotes"in n){let a=s=>{var u,l;if(!B.isValidElement(s))return!1;let o=Array.isArray(s.props.children)?s.props.children:[s.props.children],h=!1,c=!1;for(let m of o)if(m){if(typeof m=="string")m.trim()!==""&&(h=!0);else if(B.isValidElement(m))if(((u=m.props)==null?void 0:u["data-footnote-backref"])!==void 0)c=!0;else{let g=Array.isArray(m.props.children)?m.props.children:[m.props.children];for(let E of g){if(typeof E=="string"&&E.trim()!==""){h=!0;break}if(B.isValidElement(E)&&((l=E.props)==null?void 0:l["data-footnote-backref"])===void 0){h=!0;break}}}}return c&&!h},i=Array.isArray(e)?e.map(s=>{if(!B.isValidElement(s))return s;if(s.type===Ls){let u=(Array.isArray(s.props.children)?s.props.children:[s.props.children]).filter(l=>!a(l));return u.length===0?null:{...s,props:{...s.props,children:u}}}return s}):e;return(Array.isArray(i)?i.some(s=>s!==null):i!==null)?I.jsx("section",{className:t,...n,children:i}):null}return I.jsx("section",{className:t,...n,children:e})},(e,t)=>Ue(e,t));Kh.displayName="MarkdownSection";var CT=({node:e,className:t,children:r,...n})=>{var a,i,s;let u=((a=e?.position)==null?void 0:a.start.line)===((i=e?.position)==null?void 0:i.end.line),{mermaid:l,controls:o}=B.useContext(Lt);if(u)return I.jsx("code",{className:pe("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:r});let h=t?.match(ST),c=(s=h?.at(1))!=null?s:"",m="";if(B.isValidElement(r)&&r.props&&typeof r.props=="object"&&"children"in r.props&&typeof r.props.children=="string"?m=r.props.children:typeof r=="string"&&(m=r),c==="mermaid"){let E=L0(o,"mermaid"),y=Ta(o,"download"),v=Ta(o,"copy"),A=Ta(o,"fullscreen"),w=Ta(o,"panZoom");return I.jsx(B.Suspense,{fallback:I.jsx(Gl,{}),children:I.jsxs("div",{className:pe("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[E&&(y||v||A)&&I.jsxs("div",{className:"flex items-center justify-end gap-2",children:[y&&I.jsx(pT,{chart:m,config:l?.config}),v&&I.jsx(Yl,{code:m}),A&&I.jsx(ET,{chart:m,config:l?.config})]}),I.jsx(wT,{chart:m,config:l?.config,showControls:w})]})})}let g=L0(o,"code");return I.jsx(B.Suspense,{fallback:I.jsx(Gl,{}),children:I.jsx(AT,{className:pe("overflow-x-auto border-border border-t",t),code:m,language:c,children:g&&I.jsxs(I.Fragment,{children:[I.jsx(hT,{code:m,language:c}),I.jsx(Yl,{})]})})})},Zh=B.memo(CT,(e,t)=>e.className===t.className&&ci(e.node,t.node));Zh.displayName="MarkdownCode";var Jh=B.memo(fT,(e,t)=>e.className===t.className&&ci(e.node,t.node));Jh.displayName="MarkdownImg";var ed=B.memo(({children:e,className:t,node:r,...n})=>{var a;let i=(Array.isArray(e)?e:[e]).filter(s=>s!=null&&s!=="");return i.length===1&&B.isValidElement(i[0])&&((a=i[0].props.node)==null?void 0:a.tagName)==="img"?I.jsx(I.Fragment,{children:e}):I.jsx("p",{className:t,...n,children:e})},(e,t)=>Ue(e,t));ed.displayName="MarkdownParagraph";var NT={ol:Ls,li:Dh,ul:Lh,hr:Rh,strong:Oh,a:Mh,h1:Ph,h2:Bh,h3:Fh,h4:zh,h5:Hh,h6:Uh,table:qh,thead:jh,tbody:$h,tr:Yh,th:Vh,td:Gh,blockquote:Wh,code:Zh,img:Jh,pre:({children:e})=>e,sup:Xh,sub:Qh,p:ed,section:Kh},Wl=[],Xl={allowDangerousHtml:!0},xa=new WeakMap,_T=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 r=e.rehypePlugins,n=e.remarkPlugins,a=e.remarkRehypeOptions;if(!(r||n||a)){let h="default";return this.keyCache.set(e,h),h}let i=h=>{if(!h||h.length===0)return"";let c="";for(let m=0;m<h.length;m+=1){let g=h[m];if(m>0&&(c+=","),Array.isArray(g)){let[E,y]=g;if(typeof E=="function"){let v=xa.get(E);v||(v=E.name,xa.set(E,v)),c+=v}else c+=String(E);c+=":",c+=JSON.stringify(y)}else if(typeof g=="function"){let E=xa.get(g);E||(E=g.name,xa.set(g,E)),c+=E}else c+=String(g)}return c},s=i(r),u=i(n),l=a?JSON.stringify(a):"",o=`${u}::${s}::${l}`;return this.keyCache.set(e,o),o}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()}},Ql=new _T,td=e=>{let t=IT(e),r=e.children||"";return LT(t.runSync(t.parse(r),r),e)},IT=e=>{let t=Ql.get(e);if(t)return t;let r=DT(e);return Ql.set(e,r),r},DT=e=>{let t=e.rehypePlugins||Wl,r=e.remarkPlugins||Wl,n=e.remarkRehypeOptions?{...Xl,...e.remarkRehypeOptions}:Xl;return vE().use(k9).use(r).use(aE,n).use(t)},LT=(e,t)=>Ib(e,{Fragment:I.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:I.jsx,jsxs:I.jsxs,passKeys:!0,passNode:!0}),RT=/\[\^[^\]\s]{1,200}\](?!:)/,OT=/\[\^[^\]\s]{1,200}\]:/,MT=/<\/(\w+)>/,PT=/<(\w+)[\s>]/,Ki=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
375
375
  `||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},BT=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
376
376
  `||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},Zi=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},FT=e=>{let t=RT.test(e),r=OT.test(e);if(t||r)return[e];let n=kt.lex(e,{gfm:!0}),a=[],i=[];for(let s of n){let u=s.raw,l=a.length;if(i.length>0){if(a[l-1]+=u,s.type==="html"){let o=u.match(MT);if(o){let h=o[1];i.at(-1)===h&&i.pop()}}continue}if(s.type==="html"&&s.block){let o=u.match(PT);if(o){let h=o[1];u.includes(`</${h}>`)||i.push(h)}}if(u.trim()==="$$"&&l>0){let o=a[l-1],h=Ki(o),c=Zi(o);if(h&&c%2===1){a[l-1]=o+u;continue}}if(l>0&&BT(u)){let o=a[l-1],h=Ki(o),c=Zi(o),m=Zi(u);if(h&&c%2===1&&!Ki(u)&&m===1){a[l-1]=o+u;continue}}a.push(u)}return a},zT={raw:a6,katex:[m0,{errorColor:"var(--color-muted-foreground)"}],sanitize:[m6,{}],harden:[gf,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:!0}]},HT={gfm:[T8,{}],math:[v0,{singleDollarTextMath:!1}],cjkFriendly:[U6,{}],cjkFriendlyGfmStrikethrough:[j6,{}]},UT=Object.values(zT),qT=Object.values(HT),jT={shikiTheme:["github-light","github-dark"],controls:!0,isAnimating:!1,mode:"streaming",mermaid:void 0},Lt=B.createContext(jT),rd=B.memo(({content:e,shouldParseIncompleteMarkdown:t,...r})=>{let n=B.useMemo(()=>typeof e=="string"&&t?mb(e.trim()):e,[e,t]);return I.jsx(td,{...r,children:n})},(e,t)=>{if(e.content!==t.content||e.shouldParseIncompleteMarkdown!==t.shouldParseIncompleteMarkdown||e.index!==t.index)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(a=>{var i,s;return((i=e.components)==null?void 0:i[a])!==((s=t.components)==null?void 0:s[a])}))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});rd.displayName="Block";var $T=["github-light","github-dark"],Rs=B.memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:r=!0,components:n,rehypePlugins:a=UT,remarkPlugins:i=qT,className:s,shikiTheme:u=$T,mermaid:l,controls:o=!0,isAnimating:h=!1,BlockComponent:c=rd,parseMarkdownIntoBlocksFn:m=FT,...g})=>{let E=B.useId(),[y,v]=B.useTransition(),[A,w]=B.useState([]),L=B.useMemo(()=>m(typeof e=="string"?e:""),[e,m]);B.useEffect(()=>{t==="streaming"?v(()=>{w(L)}):w(L)},[L,t]);let z=t==="streaming"?A:L,q=B.useMemo(()=>z.map((J,Q)=>`${E}-${Q}`),[z.length,E]),O=B.useMemo(()=>({shikiTheme:u,controls:o,isAnimating:h,mode:t,mermaid:l}),[u,o,h,t,l]),Y=B.useMemo(()=>({...NT,...n}),[n]);return B.useEffect(()=>{if(!(Array.isArray(a)&&a.some(U=>Array.isArray(U)?U[0]===m0:U===m0)))return;let J=!1;if(Array.isArray(i)){let U=i.find(le=>Array.isArray(le)?le[0]===v0:le===v0);U&&Array.isArray(U)&&U[1]&&(J=U[1].singleDollarTextMath===!0)}let Q=typeof e=="string"?e:"",P=Q.includes("$$"),Z=J&&(/[^$]\$[^$]/.test(Q)||/^\$[^$]/.test(Q)||/[^$]\$$/.test(Q));(P||Z)&&ja(()=>Promise.resolve({}),__vite__mapDeps([14]))},[a,i,e]),t==="static"?I.jsx(Lt.Provider,{value:O,children:I.jsx("div",{className:pe("space-y-4 whitespace-normal",s),children:I.jsx(td,{components:Y,rehypePlugins:a,remarkPlugins:i,...g,children:e})})}):I.jsx(Lt.Provider,{value:O,children:I.jsx("div",{className:pe("space-y-4 whitespace-normal",s),children:z.map((J,Q)=>I.jsx(c,{components:Y,content:J,index:Q,rehypePlugins:a,remarkPlugins:i,shouldParseIncompleteMarkdown:r,...g},q[Q]))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode);Rs.displayName="Streamdown";var YT=({children:e,className:t,minZoom:r=.5,maxZoom:n=3,zoomStep:a=.1,showControls:i=!0,initialZoom:s=1,fullscreen:u=!1})=>{let l=B.useRef(null),o=B.useRef(null),[h,c]=B.useState(s),[m,g]=B.useState({x:0,y:0}),[E,y]=B.useState(!1),[v,A]=B.useState({x:0,y:0}),[w,L]=B.useState({x:0,y:0}),z=B.useCallback(U=>{c(le=>Math.max(r,Math.min(n,le+U)))},[r,n]),q=B.useCallback(()=>{z(a)},[z,a]),O=B.useCallback(()=>{z(-a)},[z,a]),Y=B.useCallback(()=>{c(s),g({x:0,y:0})},[s]),J=B.useCallback(U=>{U.preventDefault();let le=U.deltaY>0?-a:a;z(le)},[z,a]),Q=B.useCallback(U=>{if(U.button!==0||U.isPrimary===!1)return;y(!0),A({x:U.clientX,y:U.clientY}),L(m);let le=U.currentTarget;le instanceof HTMLElement&&le.setPointerCapture(U.pointerId)},[m]),P=B.useCallback(U=>{if(!E)return;U.preventDefault();let le=U.clientX-v.x,ae=U.clientY-v.y;g({x:w.x+le,y:w.y+ae})},[E,v,w]),Z=B.useCallback(U=>{y(!1);let le=U.currentTarget;le instanceof HTMLElement&&le.releasePointerCapture(U.pointerId)},[]);return B.useEffect(()=>{let U=l.current;if(U)return U.addEventListener("wheel",J,{passive:!1}),()=>{U.removeEventListener("wheel",J)}},[J]),B.useEffect(()=>{let U=o.current;if(U&&E)return document.body.style.userSelect="none",U.addEventListener("pointermove",P,{passive:!1}),U.addEventListener("pointerup",Z),U.addEventListener("pointercancel",Z),()=>{document.body.style.userSelect="",U.removeEventListener("pointermove",P),U.removeEventListener("pointerup",Z),U.removeEventListener("pointercancel",Z)}},[E,P,Z]),I.jsxs("div",{className:pe("relative",u?"h-full w-full":"w-full",t),ref:l,style:{cursor:E?"grabbing":"grab"},children:[i&&I.jsxs("div",{className:pe("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",u?"bottom-4 left-4":"bottom-2 left-2"),children:[I.jsx("button",{className:"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:h>=n,onClick:q,title:"Zoom in",type:"button",children:I.jsx(Cd,{size:16})}),I.jsx("button",{className:"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:h<=r,onClick:O,title:"Zoom out",type:"button",children:I.jsx(Nd,{size:16})}),I.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:Y,title:"Reset zoom and pan",type:"button",children:I.jsx(_d,{size:16})})]}),I.jsx("div",{className:pe("origin-center transition-transform duration-150 ease-out",u&&"flex w-full items-center justify-center"),onPointerDown:Q,ref:o,role:"application",style:{transform:`translate(${m.x}px, ${m.y}px) scale(${h})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})},nd=({chart:e,className:t,config:r,fullscreen:n=!1,showControls:a=!0})=>{let[i,s]=B.useState(null),[u,l]=B.useState(!0),[o,h]=B.useState(""),[c,m]=B.useState(""),[g,E]=B.useState(0),{mermaid:y}=B.useContext(Lt),v=y?.errorComponent;if(B.useEffect(()=>{(async()=>{try{s(null),l(!0);let w=await Nh(r),L=e.split("").reduce((O,Y)=>(O<<5)-O+Y.charCodeAt(0)|0,0),z=`mermaid-${Math.abs(L)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:q}=await w.render(z,e);h(q),m(q)}catch(w){if(!(c||o)){let L=w instanceof Error?w.message:"Failed to render Mermaid chart";s(L)}}finally{l(!1)}})()},[e,r,g]),u&&!o&&!c)return I.jsx("div",{className:pe("my-4 flex justify-center p-4",t),children:I.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[I.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),I.jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(i&&!o&&!c){let w=()=>E(L=>L+1);return v?I.jsx(v,{chart:e,error:i,retry:w}):I.jsxs("div",{className:pe("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[I.jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",i]}),I.jsxs("details",{className:"mt-2",children:[I.jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),I.jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let A=o||c;return I.jsx(YT,{className:pe(n?"h-full w-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:a,zoomStep:.1,children:I.jsx("div",{"aria-label":"Mermaid chart",className:pe("flex justify-center",n&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:A},role:"img"})})};const Kl=({className:e,from:t,...r})=>I.jsx("div",{className:He("group flex w-full max-w-[95%] flex-col gap-2",t==="user"?"is-user ml-auto justify-end":"is-assistant",e),...r}),Zl=({children:e,className:t,...r})=>I.jsx("div",{className:He("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",t),...r,children:e}),ad=B.createContext(null),VT=()=>{const e=B.useContext(ad);if(!e)throw new Error("MessageBranch components must be used within MessageBranch");return e},Jl=({defaultBranch:e=0,onBranchChange:t,className:r,...n})=>{const[a,i]=B.useState(e),[s,u]=B.useState([]),l=m=>{i(m),t?.(m)},o=()=>{const m=a>0?a-1:s.length-1;l(m)},h=()=>{const m=a<s.length-1?a+1:0;l(m)},c={currentBranch:a,totalBranches:s.length,goToPrevious:o,goToNext:h,branches:s,setBranches:u};return I.jsx(ad.Provider,{value:c,children:I.jsx("div",{className:He("grid w-full gap-2 [&>div]:pb-0",r),...n})})},eo=({children:e,...t})=>{const{currentBranch:r,setBranches:n,branches:a}=VT(),i=Array.isArray(e)?e:[e];return B.useEffect(()=>{a.length!==i.length&&n(i)},[i,a,n]),i.map((s,u)=>I.jsx("div",{className:He("grid gap-2 overflow-hidden [&>div]:pb-0",u===r?"block":"hidden"),...t,children:s},s.key))},id=B.memo(({className:e,...t})=>I.jsx(Rs,{className:He("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);id.displayName="MessageResponse";const GT="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let WT=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=GT[r[e]&63];return t};const XT=B.createContext(null),QT=B.createContext(null),sd=()=>B.useContext(XT),KT=()=>B.useContext(QT),ud=B.createContext(null),ZT=()=>{const e=KT(),t=B.useContext(ud),r=e??t;if(!r)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return r},JT=({className:e,accept:t,multiple:r,globalDrop:n,syncHiddenInput:a,maxFiles:i,maxFileSize:s,onError:u,onSubmit:l,children:o,...h})=>{const c=sd(),m=!!c,g=B.useRef(null),E=B.useRef(null),[y,v]=B.useState([]),A=m?c.attachments.files:y,w=B.useRef(A);w.current=A;const L=B.useCallback(()=>{g.current?.click()},[]),z=B.useCallback(se=>!t||t.trim()===""?!0:t.split(",").map(fe=>fe.trim()).filter(Boolean).some(fe=>{if(fe.endsWith("/*")){const N=fe.slice(0,-1);return se.type.startsWith(N)}return se.type===fe}),[t]),q=B.useCallback(se=>{const Te=Array.from(se),fe=Te.filter(Ce=>z(Ce));if(Te.length&&fe.length===0){u?.({code:"accept",message:"No files match the accepted types."});return}const N=Ce=>s?Ce.size<=s:!0,Ee=fe.filter(N);if(fe.length>0&&Ee.length===0){u?.({code:"max_file_size",message:"All files exceed the maximum size."});return}v(Ce=>{const D=typeof i=="number"?Math.max(0,i-Ce.length):void 0,Xe=typeof D=="number"?Ee.slice(0,D):Ee;typeof D=="number"&&Ee.length>D&&u?.({code:"max_files",message:"Too many files. Some were not added."});const Qe=[];for(const Oe of Xe)Qe.push({id:WT(),type:"file",url:URL.createObjectURL(Oe),mediaType:Oe.type,filename:Oe.name});return Ce.concat(Qe)})},[z,i,s,u]),O=B.useCallback(se=>v(Te=>{const fe=Te.find(N=>N.id===se);return fe?.url&&URL.revokeObjectURL(fe.url),Te.filter(N=>N.id!==se)}),[]),Y=B.useCallback(()=>v(se=>{for(const Te of se)Te.url&&URL.revokeObjectURL(Te.url);return[]}),[]),J=m?c.attachments.add:q,Q=m?c.attachments.remove:O,P=m?c.attachments.clear:Y,Z=m?c.attachments.openFileDialog:L;B.useEffect(()=>{m&&c.__registerFileInput(g,()=>g.current?.click())},[m,c]),B.useEffect(()=>{a&&g.current&&A.length===0&&(g.current.value="")},[A,a]),B.useEffect(()=>{const se=E.current;if(!se||n)return;const Te=N=>{N.dataTransfer?.types?.includes("Files")&&N.preventDefault()},fe=N=>{N.dataTransfer?.types?.includes("Files")&&N.preventDefault(),N.dataTransfer?.files&&N.dataTransfer.files.length>0&&J(N.dataTransfer.files)};return se.addEventListener("dragover",Te),se.addEventListener("drop",fe),()=>{se.removeEventListener("dragover",Te),se.removeEventListener("drop",fe)}},[J,n]),B.useEffect(()=>{if(!n)return;const se=fe=>{fe.dataTransfer?.types?.includes("Files")&&fe.preventDefault()},Te=fe=>{fe.dataTransfer?.types?.includes("Files")&&fe.preventDefault(),fe.dataTransfer?.files&&fe.dataTransfer.files.length>0&&J(fe.dataTransfer.files)};return document.addEventListener("dragover",se),document.addEventListener("drop",Te),()=>{document.removeEventListener("dragover",se),document.removeEventListener("drop",Te)}},[J,n]),B.useEffect(()=>()=>{if(!m)for(const se of w.current)se.url&&URL.revokeObjectURL(se.url)},[m]);const U=se=>{se.currentTarget.files&&J(se.currentTarget.files),se.currentTarget.value=""},le=async se=>{try{const fe=await(await fetch(se)).blob();return new Promise(N=>{const Ee=new FileReader;Ee.onloadend=()=>N(Ee.result),Ee.onerror=()=>N(null),Ee.readAsDataURL(fe)})}catch{return null}},ae=B.useMemo(()=>({files:A.map(se=>({...se,id:se.id})),add:J,remove:Q,clear:P,openFileDialog:Z,fileInputRef:g}),[A,J,Q,P,Z]),ee=se=>{se.preventDefault();const Te=se.currentTarget,fe=m?c.textInput.value:new FormData(Te).get("message")||"";m||Te.reset(),Promise.all(A.map(async({id:N,...Ee})=>{if(Ee.url?.startsWith("blob:")){const Ce=await le(Ee.url);return{...Ee,url:Ce??Ee.url}}return Ee})).then(N=>{try{const Ee=l({text:fe,files:N},se);Ee instanceof Promise?Ee.then(()=>{P(),m&&c.textInput.clear()}).catch(()=>{}):(P(),m&&c.textInput.clear())}catch{}}).catch(()=>{})},be=I.jsxs(I.Fragment,{children:[I.jsx("input",{accept:t,"aria-label":"Upload files",className:"hidden",multiple:r,onChange:U,ref:g,title:"Upload files",type:"file"}),I.jsx("form",{className:He("w-full",e),onSubmit:ee,ref:E,...h,children:I.jsx(zd,{className:"overflow-hidden",children:o})})]});return m?be:I.jsx(ud.Provider,{value:ae,children:be})},ex=({className:e,...t})=>I.jsx("div",{className:He("contents",e),...t}),tx=({onChange:e,className:t,placeholder:r="What would you like to know?",...n})=>{const a=sd(),i=ZT(),[s,u]=B.useState(!1),l=c=>{if(c.key==="Enter"){if(s||c.nativeEvent.isComposing||c.shiftKey)return;c.preventDefault();const m=c.currentTarget.form;if(m?.querySelector('button[type="submit"]')?.disabled)return;m?.requestSubmit()}if(c.key==="Backspace"&&c.currentTarget.value===""&&i.files.length>0){c.preventDefault();const m=i.files.at(-1);m&&i.remove(m.id)}},o=c=>{const m=c.clipboardData?.items;if(!m)return;const g=[];for(const E of m)if(E.kind==="file"){const y=E.getAsFile();y&&g.push(y)}g.length>0&&(c.preventDefault(),i.add(g))},h=a?{value:a.textInput.value,onChange:c=>{a.textInput.setInput(c.currentTarget.value),e?.(c)}}:{onChange:e};return I.jsx(Hd,{className:He("field-sizing-content max-h-48 min-h-16",t),name:"message",onCompositionEnd:()=>u(!1),onCompositionStart:()=>u(!0),onKeyDown:l,onPaste:o,placeholder:r,...n,...h})},rx=({className:e,...t})=>I.jsx(Ud,{align:"block-end",className:He("justify-between justify-end gap-1",e),...t}),nx=({className:e,variant:t="default",size:r="icon-sm",status:n,children:a,...i})=>{let s=I.jsx(Id,{className:"size-4"});return n==="submitted"?s=I.jsx(Dd,{className:"size-4 animate-spin"}):n==="streaming"?s=I.jsx(Ld,{className:"size-4"}):n==="error"&&(s=I.jsx(Rd,{className:"size-4"})),I.jsx(qd,{"aria-label":"Submit",className:He(e),size:r,type:"submit",variant:t,...i,children:a??s})};function ax({...e}){return I.jsx(Ed,{"data-slot":"collapsible",...e})}function ix({...e}){return I.jsx(Td,{"data-slot":"collapsible-trigger",...e})}function sx({...e}){return I.jsx(xd,{"data-slot":"collapsible-content",...e})}const ux=({children:e,as:t="p",className:r,duration:n=2,spread:a=2})=>{const i=B.useMemo(()=>(e?.length??0)*a,[e,a]);return I.jsx(t,{className:He("relative inline-block bg-size-[250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]","animate-shimmer",r),style:{"--spread":`${i}px`,"--duration":`${n}s`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},children:e})},lx=B.memo(ux),ld=B.createContext(null),ox=()=>{const e=B.useContext(ld);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},cx=1e3,hx=1e3,od=B.memo(({className:e,isStreaming:t=!1,open:r,defaultOpen:n=!0,onOpenChange:a,duration:i,children:s,...u})=>{const[l,o]=Ms({prop:r,defaultProp:n,onChange:a}),[h,c]=Ms({prop:i,defaultProp:void 0}),[m,g]=B.useState(!1),[E,y]=B.useState(null);B.useEffect(()=>{t?E===null&&y(Date.now()):E!==null&&(c(Math.ceil((Date.now()-E)/hx)),y(null))},[t,E,c]),B.useEffect(()=>{if(n&&!t&&l&&!m){const A=setTimeout(()=>{o(!1),g(!0)},cx);return()=>clearTimeout(A)}},[t,l,n,o,m]);const v=A=>{o(A)};return I.jsx(ld.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:o,duration:h},children:I.jsx(ax,{className:He("not-prose mb-4",e),onOpenChange:v,open:l,...u,children:s})})}),dx=(e,t)=>e||t===0?I.jsx(lx,{duration:1,children:"Thinking..."}):t===void 0?I.jsx("p",{children:"Thought for a few seconds"}):I.jsxs("p",{children:["Thought for ",t," seconds"]}),cd=B.memo(({className:e,children:t,getThinkingMessage:r=dx,...n})=>{const{isStreaming:a,isOpen:i,duration:s}=ox();return I.jsx(ix,{className:He("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:t??I.jsxs(I.Fragment,{children:[I.jsx(Od,{className:"size-4"}),r(a,s),I.jsx(Md,{className:He("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),hd=B.memo(({className:e,children:t,...r})=>I.jsx(sx,{className:He("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...r,children:I.jsx(Rs,{...r,children:t})}));od.displayName="Reasoning";cd.displayName="ReasoningTrigger";hd.displayName="ReasoningContent";const fx=({className:e,children:t,...r})=>I.jsxs(Vd,{className:"w-full overflow-x-auto whitespace-nowrap",...r,children:[I.jsx("div",{className:He("flex w-max flex-nowrap items-center gap-2",e),children:t}),I.jsx(Gd,{className:"hidden",orientation:"horizontal"})]}),mx=({suggestion:e,onClick:t,className:r,variant:n="outline",size:a="sm",children:i,...s})=>{const u=()=>{t?.(e)};return I.jsx(R0,{className:He("cursor-pointer rounded-full px-4",r),onClick:u,size:a,type:"button",variant:n,...s,children:i||e})},px=()=>{const{rateLimit:e,refetchRateLimit:t}=Kd(),[r,n]=B.useState(""),{isSheetOpen:a,closeSheet:i}=jd(),{messages:s,sendMessage:u,isLoading:l,clear:o,stop:h}=yd({connection:kd(`${Yd.BASE_URL}/chat`),onError:v=>console.error("Error:",v.message),onResponse:v=>console.log("Response:",v),onFinish:v=>{console.log("Finish:",v),t()}}),c=v=>{const A=!!v.text,w=!!v.files?.length;!(A||w)||l||(u(v.text),n(""))},m=()=>{o(),n("")},g=v=>{u(v),n("")},E=()=>{h(),n("")},y=l?"streaming":"ready";return I.jsx($d,{title:"AI Assistant",cta:I.jsxs("div",{className:"flex items-center gap-2",children:[e&&I.jsxs(Wd,{children:[I.jsx(Xd,{asChild:!0,children:I.jsxs("span",{className:"text-xs px-2 py-1 cursor-default text-muted-foreground",children:[e.remaining,"/",e.limit]})}),I.jsx(Qd,{side:"bottom",children:I.jsxs("p",{children:[e.remaining," messages remaining"]})})]}),I.jsxs(R0,{type:"button",variant:"outline",size:"lg",onClick:m,disabled:l,children:[I.jsx(Pd,{className:"h-4 w-4 mr-1"}),"New Chat"]})]}),closeButton:!1,open:a("ai-assistant"),size:"max-w-2xl!",contentClassName:"p-0 flex flex-col h-[calc(100vh-4rem)] flex-1",onOpenChange:v=>{v||i("ai-assistant")},children:I.jsxs("div",{className:"relative flex size-full flex-col divide-y overflow-hidden",children:[I.jsxs(sf,{children:[I.jsx(uf,{children:s.length===0?I.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:I.jsxs("div",{className:"text-center space-y-2",children:[I.jsx("p",{className:"text-lg font-medium",children:"Start a new conversation"}),I.jsx("p",{className:"text-sm",children:"Ask me anything to get started"})]})}):I.jsxs(I.Fragment,{children:[s.map(v=>{const A=v.parts.filter(z=>z.type==="thinking"),w=v.parts.filter(z=>z.type==="text").map(z=>z.content).join(""),L=A.length>0;return I.jsx(Jl,{defaultBranch:0,children:I.jsx(eo,{children:I.jsx(Kl,{from:v.role==="user"?"user":"assistant",children:I.jsxs("div",{children:[L&&v.role==="assistant"&&I.jsxs(od,{duration:0,children:[I.jsx(cd,{}),I.jsx(hd,{children:A.map(z=>z.content).join(`
377
377
  `)})]}),I.jsx(Zl,{children:I.jsx(id,{children:w})})]})})})},v.id)}),l&&I.jsx(Jl,{defaultBranch:0,children:I.jsx(eo,{children:I.jsx(Kl,{from:"assistant",children:I.jsx(Zl,{children:I.jsx(of,{children:"Thinking..."})})})})})]})}),I.jsx(lf,{})]}),I.jsxs("div",{className:"grid shrink-0 gap-4 pt-3",children:[s.length===0&&I.jsx(fx,{className:"px-4",children:Zd.map(v=>I.jsx(mx,{onClick:()=>g(v),suggestion:v,size:"lg",children:v},v))}),I.jsx("div",{className:"w-full px-4 pb-4",children:I.jsxs(JT,{globalDrop:!0,multiple:!0,onSubmit:c,children:[I.jsx(ex,{children:I.jsx(tx,{onChange:v=>n(v.target.value),value:r,placeholder:"Type a message..."})}),I.jsx(rx,{children:I.jsx(nx,{className:"h-8!",status:y,onClick:l?E:void 0,disabled:e&&e.remaining===0})})]})})]})]})})},Sx=Object.freeze(Object.defineProperty({__proto__:null,ChatSidebar:px},Symbol.toStringTag,{value:"Module"})),gx=Object.freeze(Object.defineProperty({__proto__:null,Mermaid:nd},Symbol.toStringTag,{value:"Module"}));export{Lt as C,cT as D,po as a,go as b,rl as c,g2 as d,wx as e,Va as f,Sx as g,Wn as h,Ne as k,Er as s,pe as u,Tb as w,Rc as z};