@ashwin_droid/notion-stream 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/{_baseUniq-CWfjzMhC.js → _baseUniq-D32sgNIc.js} +1 -1
  2. package/dist/{_baseUniq-Db9ouzA-.mjs → _baseUniq-DCnQIx8G.mjs} +1 -1
  3. package/dist/{arc-DxDH4CNq.js → arc-B0uBm0sN.js} +1 -1
  4. package/dist/{arc-CHlsWOEE.mjs → arc-OrNNmmBm.mjs} +1 -1
  5. package/dist/{architecture-U656AL7Q-DqUhwOXk.js → architecture-U656AL7Q-CLYqYgyv.js} +1 -1
  6. package/dist/{architecture-U656AL7Q-DpmenltQ.mjs → architecture-U656AL7Q-seCMyeyz.mjs} +1 -1
  7. package/dist/{architectureDiagram-VXUJARFQ-LwDhoqXa.js → architectureDiagram-VXUJARFQ-BGsDPmi_.js} +1 -1
  8. package/dist/{architectureDiagram-VXUJARFQ-C2hauZCK.mjs → architectureDiagram-VXUJARFQ-BmPLNLcs.mjs} +3 -3
  9. package/dist/{blockDiagram-VD42YOAC-yWS4_TxE.mjs → blockDiagram-VD42YOAC-CXKvT-9-.mjs} +5 -5
  10. package/dist/{blockDiagram-VD42YOAC-Cws7af6P.js → blockDiagram-VD42YOAC-NQhzFvsO.js} +1 -1
  11. package/dist/{c4Diagram-YG6GDRKO-DLoBqiir.js → c4Diagram-YG6GDRKO-CMXx6pyB.js} +1 -1
  12. package/dist/{c4Diagram-YG6GDRKO-K4ShvkML.mjs → c4Diagram-YG6GDRKO-DAGMHESb.mjs} +2 -2
  13. package/dist/{channel-_5jzmP-I.mjs → channel-BXGyzQA6.mjs} +1 -1
  14. package/dist/channel-Dw8BXC8D.js +1 -0
  15. package/dist/{chunk-4BX2VUAB-6hr5PCkV.js → chunk-4BX2VUAB-MnK73C0-.js} +1 -1
  16. package/dist/{chunk-4BX2VUAB-DBTu5W6L.mjs → chunk-4BX2VUAB-ZaWvd3Xe.mjs} +1 -1
  17. package/dist/{chunk-55IACEB6-BLs0Xswy.js → chunk-55IACEB6-B1EpdpVW.js} +1 -1
  18. package/dist/{chunk-55IACEB6-_brNODlK.mjs → chunk-55IACEB6-iKbZBHA5.mjs} +1 -1
  19. package/dist/{chunk-B4BG7PRW-6HdbiUFA.js → chunk-B4BG7PRW-Bo_sfBKL.js} +1 -1
  20. package/dist/{chunk-B4BG7PRW-CWohxZt0.mjs → chunk-B4BG7PRW-DgqSow4f.mjs} +4 -4
  21. package/dist/{chunk-DI55MBZ5-db62NlMD.mjs → chunk-DI55MBZ5-BAHL-2VJ.mjs} +3 -3
  22. package/dist/{chunk-DI55MBZ5-DehdsbpI.js → chunk-DI55MBZ5-BuuMLI1S.js} +1 -1
  23. package/dist/{chunk-FMBD7UC4-BegOwXuP.mjs → chunk-FMBD7UC4-BE8MbNLe.mjs} +1 -1
  24. package/dist/{chunk-FMBD7UC4-B2j81cAo.js → chunk-FMBD7UC4-Cs1BNv23.js} +1 -1
  25. package/dist/{chunk-QN33PNHL-CJ1oa0p-.js → chunk-QN33PNHL-MX1ZMWu-.js} +1 -1
  26. package/dist/{chunk-QN33PNHL-CpBQYWWf.mjs → chunk-QN33PNHL-ZaWv5vaA.mjs} +1 -1
  27. package/dist/{chunk-QZHKN3VN-BG9vC9tQ.mjs → chunk-QZHKN3VN-D2X7PBDi.mjs} +1 -1
  28. package/dist/{chunk-QZHKN3VN-DV3-w0rK.js → chunk-QZHKN3VN-Db6mVb9M.js} +1 -1
  29. package/dist/{chunk-TZMSLE5B-D3cmOS_D.mjs → chunk-TZMSLE5B-AMFXF6mq.mjs} +1 -1
  30. package/dist/{chunk-TZMSLE5B-DtKjE4RE.js → chunk-TZMSLE5B-CzjtACDr.js} +1 -1
  31. package/dist/{classDiagram-v2-WZHVMYZB-DAL3V7Dx.mjs → classDiagram-2ON5EDUG-CPwvtUDj.mjs} +2 -2
  32. package/dist/{classDiagram-2ON5EDUG-uOMmrtgR.js → classDiagram-2ON5EDUG-UNrH9bQo.js} +1 -1
  33. package/dist/{classDiagram-2ON5EDUG-DAL3V7Dx.mjs → classDiagram-v2-WZHVMYZB-CPwvtUDj.mjs} +2 -2
  34. package/dist/{classDiagram-v2-WZHVMYZB-uOMmrtgR.js → classDiagram-v2-WZHVMYZB-UNrH9bQo.js} +1 -1
  35. package/dist/{clone-BiSDKkgs.mjs → clone-CV4F8CSW.mjs} +1 -1
  36. package/dist/clone-HVsPHeK3.js +1 -0
  37. package/dist/{code-block-37QAKDTI-BILtfzQC.js → code-block-37QAKDTI-38K5Mxo2.js} +1 -1
  38. package/dist/{code-block-37QAKDTI-MauA-22z.mjs → code-block-37QAKDTI-Q-OOsw6q.mjs} +1 -1
  39. package/dist/{cose-bilkent-S5V4N54A-CPJoKUiO.js → cose-bilkent-S5V4N54A-1B77PywG.js} +1 -1
  40. package/dist/{cose-bilkent-S5V4N54A-rUEUYQdF.mjs → cose-bilkent-S5V4N54A-greBbyuM.mjs} +1 -1
  41. package/dist/{dagre-6UL2VRFP-r_ADTb0O.js → dagre-6UL2VRFP-DEQXyXKh.js} +1 -1
  42. package/dist/{dagre-6UL2VRFP-b0VfOp5y.mjs → dagre-6UL2VRFP-DN5Inkgr.mjs} +5 -5
  43. package/dist/{diagram-PSM6KHXK-CuHqLGUt.js → diagram-PSM6KHXK-C7tjFZpr.js} +1 -1
  44. package/dist/{diagram-PSM6KHXK-ax3IfFcX.mjs → diagram-PSM6KHXK-D-GS1fTc.mjs} +4 -4
  45. package/dist/{diagram-QEK2KX5R-Dn47K2He.mjs → diagram-QEK2KX5R-DJXBxeH4.mjs} +3 -3
  46. package/dist/{diagram-QEK2KX5R-B5Lo9E-s.js → diagram-QEK2KX5R-Doa8ooC_.js} +1 -1
  47. package/dist/{diagram-S2PKOQOG-B0W-tWPV.js → diagram-S2PKOQOG-BN04h93a.js} +1 -1
  48. package/dist/{diagram-S2PKOQOG-C5jPENyu.mjs → diagram-S2PKOQOG-BuPevKqw.mjs} +3 -3
  49. package/dist/{erDiagram-Q2GNP2WA-k7niLq9H.js → erDiagram-Q2GNP2WA-AS2vnQKc.js} +1 -1
  50. package/dist/{erDiagram-Q2GNP2WA-XP6-Fsuy.mjs → erDiagram-Q2GNP2WA-DxOmvmqL.mjs} +4 -4
  51. package/dist/{flowDiagram-NV44I4VS-BAdaW0zG.js → flowDiagram-NV44I4VS-BChiRwcp.js} +1 -1
  52. package/dist/{flowDiagram-NV44I4VS-DzHvKZ3e.mjs → flowDiagram-NV44I4VS-Cs_jC87H.mjs} +5 -5
  53. package/dist/{ganttDiagram-JELNMOA3-BRenKPXr.mjs → ganttDiagram-JELNMOA3-02b_-xyZ.mjs} +2 -2
  54. package/dist/{ganttDiagram-JELNMOA3-CddDOxeO.js → ganttDiagram-JELNMOA3-BGy1b6TD.js} +1 -1
  55. package/dist/{gitGraph-F6HP7TQM-Dq8gDI5R.mjs → gitGraph-F6HP7TQM-BWm0SBV4.mjs} +1 -1
  56. package/dist/{gitGraph-F6HP7TQM-BLshE7A8.js → gitGraph-F6HP7TQM-DVfckSNX.js} +1 -1
  57. package/dist/{gitGraphDiagram-NY62KEGX-B-rSecLz.mjs → gitGraphDiagram-NY62KEGX-CfzoE07P.mjs} +4 -4
  58. package/dist/{gitGraphDiagram-NY62KEGX-C980oVrU.js → gitGraphDiagram-NY62KEGX-Cm9ywQoW.js} +1 -1
  59. package/dist/{graph-DxtCPktv.mjs → graph-DEu7-ZhH.mjs} +2 -2
  60. package/dist/{graph-BlL96kLy.js → graph-Dw_87ii6.js} +1 -1
  61. package/dist/{index-DIQbvlIr.js → index-BwYOYPeK.js} +4 -4
  62. package/dist/{index-yf1-93v5.mjs → index-DH3CVXwD.mjs} +37 -34
  63. package/dist/index.d.ts +1 -0
  64. package/dist/index.js +1 -1
  65. package/dist/index.mjs +1 -1
  66. package/dist/{info-NVLQJR56-Bls_Dqxs.js → info-NVLQJR56-BpKxONZx.js} +1 -1
  67. package/dist/info-NVLQJR56-MmJP3L6S.mjs +5 -0
  68. package/dist/{infoDiagram-WHAUD3N6-FnUO4LNo.mjs → infoDiagram-WHAUD3N6-Bfsucvti.mjs} +2 -2
  69. package/dist/{infoDiagram-WHAUD3N6-DwsUlSxN.js → infoDiagram-WHAUD3N6-q-yX3_By.js} +1 -1
  70. package/dist/{journeyDiagram-XKPGCS4Q-7k1g8rPF.js → journeyDiagram-XKPGCS4Q-BqtyHvQF.js} +1 -1
  71. package/dist/{journeyDiagram-XKPGCS4Q-Bvn5lhxn.mjs → journeyDiagram-XKPGCS4Q-dFRLmnr-.mjs} +4 -4
  72. package/dist/{kanban-definition-3W4ZIXB7-D29d9Rl2.mjs → kanban-definition-3W4ZIXB7-DeOl9Eme.mjs} +2 -2
  73. package/dist/{kanban-definition-3W4ZIXB7-Cqf7XpzW.js → kanban-definition-3W4ZIXB7-DraMxv75.js} +1 -1
  74. package/dist/{layout-B_kkbzwQ.js → layout-BKTUO8WZ.js} +1 -1
  75. package/dist/{layout-BlUfzTib.mjs → layout-CpL-hYTa.mjs} +4 -4
  76. package/dist/{linear-CC_oUBkf.mjs → linear-CLwIU3di.mjs} +1 -1
  77. package/dist/{linear-DF2d9TVq.js → linear-DvM229Di.js} +1 -1
  78. package/dist/mermaid-4DMBBIKO-BpqXz0_U.mjs +4 -0
  79. package/dist/{mermaid-4DMBBIKO-2ufyMRt4.js → mermaid-4DMBBIKO-Cd15t2pT.js} +1 -1
  80. package/dist/{mermaid-parser.core-DQkQZAvG.js → mermaid-parser.core-BVlc9Lqd.js} +2 -2
  81. package/dist/{mermaid-parser.core-CkXMNpV7.mjs → mermaid-parser.core-CLAapB2-.mjs} +10 -10
  82. package/dist/{min-VPOHWCTf.mjs → min--ML-ONY_.mjs} +2 -2
  83. package/dist/{min-I7eFb2cg.js → min-BQ4NUvNf.js} +1 -1
  84. package/dist/{mindmap-definition-VGOIOE7T-CawQ5XYo.mjs → mindmap-definition-VGOIOE7T-78K_EDCb.mjs} +3 -3
  85. package/dist/{mindmap-definition-VGOIOE7T-d8uGKtHO.js → mindmap-definition-VGOIOE7T-ZHY70ZzV.js} +1 -1
  86. package/dist/notion-stream.css +1 -0
  87. package/dist/{packet-BFZMPI3H-BbdhMsyD.mjs → packet-BFZMPI3H-B34lFb6T.mjs} +1 -1
  88. package/dist/{packet-BFZMPI3H-CiqPNXx_.js → packet-BFZMPI3H-C9xcJQVN.js} +1 -1
  89. package/dist/{pie-7BOR55EZ-BfYvvrxF.js → pie-7BOR55EZ-Bz_jfTd_.js} +1 -1
  90. package/dist/pie-7BOR55EZ-DW2Zgje5.mjs +5 -0
  91. package/dist/{pieDiagram-ADFJNKIX-BlNrJLdh.js → pieDiagram-ADFJNKIX-CKzchAXU.js} +1 -1
  92. package/dist/{pieDiagram-ADFJNKIX-TQppVIgS.mjs → pieDiagram-ADFJNKIX-Ctp6QR7f.mjs} +4 -4
  93. package/dist/{quadrantDiagram-AYHSOK5B-fy7-bMNk.js → quadrantDiagram-AYHSOK5B-D2Rt32D2.js} +1 -1
  94. package/dist/{quadrantDiagram-AYHSOK5B-CysN5Kyu.mjs → quadrantDiagram-AYHSOK5B-D3U_Qicu.mjs} +2 -2
  95. package/dist/{radar-NHE76QYJ-BlbyKqWL.mjs → radar-NHE76QYJ-CO5ECFHq.mjs} +1 -1
  96. package/dist/{radar-NHE76QYJ-BjbmLxde.js → radar-NHE76QYJ-DI4PJJjm.js} +1 -1
  97. package/dist/{requirementDiagram-UZGBJVZJ-CGgt75Rl.js → requirementDiagram-UZGBJVZJ-CSgb6U9N.js} +1 -1
  98. package/dist/{requirementDiagram-UZGBJVZJ-CfMcIbMc.mjs → requirementDiagram-UZGBJVZJ-Da_yWSD1.mjs} +3 -3
  99. package/dist/{sankeyDiagram-TZEHDZUN-q-r70ybp.js → sankeyDiagram-TZEHDZUN-C8jpBnM0.js} +1 -1
  100. package/dist/{sankeyDiagram-TZEHDZUN-aFz48-W2.mjs → sankeyDiagram-TZEHDZUN-Dp3Eyl8Q.mjs} +1 -1
  101. package/dist/{sequenceDiagram-WL72ISMW-nlFlEmNQ.js → sequenceDiagram-WL72ISMW-BZJ7d_X4.js} +1 -1
  102. package/dist/{sequenceDiagram-WL72ISMW-B9w1iL31.mjs → sequenceDiagram-WL72ISMW-yJKe02sV.mjs} +3 -3
  103. package/dist/{stateDiagram-FKZM4ZOC-C9DXFs3P.js → stateDiagram-FKZM4ZOC-Cfuygt_P.js} +1 -1
  104. package/dist/{stateDiagram-FKZM4ZOC-e4SGJ8oh.mjs → stateDiagram-FKZM4ZOC-z0IX85WL.mjs} +4 -4
  105. package/dist/{stateDiagram-v2-4FDKWEC3-QUPk_c9P.mjs → stateDiagram-v2-4FDKWEC3-BDMFqSat.mjs} +2 -2
  106. package/dist/{stateDiagram-v2-4FDKWEC3-FoEBCoPy.js → stateDiagram-v2-4FDKWEC3-BiriAQkj.js} +1 -1
  107. package/dist/{timeline-definition-IT6M3QCI-Br9KrJcU.mjs → timeline-definition-IT6M3QCI-BmEq-RM3.mjs} +2 -2
  108. package/dist/{timeline-definition-IT6M3QCI-BqUt3ka4.js → timeline-definition-IT6M3QCI-CBmpRgUM.js} +1 -1
  109. package/dist/{treemap-KMMF4GRG-DVxjgEhu.mjs → treemap-KMMF4GRG-IaHP18r_.mjs} +1 -1
  110. package/dist/{treemap-KMMF4GRG-DTii969M.js → treemap-KMMF4GRG-qP0VzKwW.js} +1 -1
  111. package/dist/{xychartDiagram-PRI3JC2R-BygtBGgX.mjs → xychartDiagram-PRI3JC2R-BSaI76KX.mjs} +2 -2
  112. package/dist/{xychartDiagram-PRI3JC2R-Bi02nVw4.js → xychartDiagram-PRI3JC2R-CQgij0Fy.js} +1 -1
  113. package/package.json +2 -2
  114. package/dist/channel-BqjR_aPb.js +0 -1
  115. package/dist/clone-Bl9s3LR9.js +0 -1
  116. package/dist/info-NVLQJR56-BQNoY6_p.mjs +0 -5
  117. package/dist/mermaid-4DMBBIKO-BizANXE3.mjs +0 -4
  118. package/dist/pie-7BOR55EZ-CkKpjIfF.mjs +0 -5
@@ -108,7 +108,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error
108
108
  `||u==="\r"){l=!0;break}if(!l)return o;let c=[];for(let u of o)u===" "?c.push("\\t"):u===`
109
109
  `?c.push("\\n"):u==="\r"?c.push("\\r"):c.push(u);return c.join("")},i=t.length>0?r.length+1:r.length,a=new Array(i),s=0;t.length>0&&(a[s]=t.map(n).join(" "),s+=1);for(let o of r)a[s]=o.map(n).join(" "),s+=1;return a.join(`
110
110
  `)},vd=e=>{let t=!1;for(let n of e)if(n==="\\"||n==="|"){t=!0;break}if(!t)return e;let r=[];for(let n of e)n==="\\"?r.push("\\\\"):n==="|"?r.push("\\|"):r.push(n);return r.join("")},lF=e=>{let{headers:t,rows:r}=e;if(t.length===0)return"";let n=new Array(r.length+2),i=0,a=t.map(o=>vd(o));n[i]=`| ${a.join(" | ")} |`,i+=1;let s=new Array(t.length);for(let o=0;o<t.length;o+=1)s[o]="---";n[i]=`| ${s.join(" | ")} |`,i+=1;for(let o of r)if(o.length<t.length){let l=new Array(t.length);for(let c=0;c<t.length;c+=1)l[c]=c<o.length?vd(o[c]):"";n[i]=`| ${l.join(" | ")} |`,i+=1}else{let l=o.map(c=>vd(c));n[i]=`| ${l.join(" | ")} |`,i+=1}return n.join(`
111
- `)},cF=({children:e,className:t,onCopy:r,onError:n,timeout:i=2e3})=>{let[a,s]=P.useState(!1),[o,l]=P.useState(!1),c=P.useRef(null),u=P.useRef(0),{isAnimating:h}=P.useContext(bn),d=async p=>{var m,b;if(typeof window>"u"||!((m=navigator?.clipboard)!=null&&m.write)){n?.(new Error("Clipboard API not available"));return}try{let y=(b=c.current)==null?void 0:b.closest('[data-streamdown="table-wrapper"]'),v=y?.querySelector("table");if(!v){n?.(new Error("Table not found"));return}let T=W6(v),A=p==="csv"?G6(T):oF(T),E=new ClipboardItem({"text/plain":new Blob([A],{type:"text/plain"}),"text/html":new Blob([v.outerHTML],{type:"text/html"})});await navigator.clipboard.write([E]),l(!0),s(!1),r?.(p),u.current=window.setTimeout(()=>l(!1),i)}catch(y){n?.(y)}};P.useEffect(()=>{let p=m=>{let b=m.composedPath();c.current&&!b.includes(c.current)&&s(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p),window.clearTimeout(u.current)}},[]);let f=o?Ym:Vm;return C.jsxs("div",{className:"relative",ref:c,children:[C.jsx("button",{className:ct("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:h,onClick:()=>s(!a),title:"Copy table",type:"button",children:e??C.jsx(f,{size:14})}),a?C.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:[C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})},uF=({children:e,className:t,onDownload:r,onError:n})=>{let[i,a]=P.useState(!1),s=P.useRef(null),{isAnimating:o}=P.useContext(bn),l=c=>{var u;try{let h=(u=s.current)==null?void 0:u.closest('[data-streamdown="table-wrapper"]'),d=h?.querySelector("table");if(!d){n?.(new Error("Table not found"));return}let f=W6(d),p=c==="csv"?G6(f):lF(f);Bs(`table.${c==="csv"?"csv":"md"}`,p,c==="csv"?"text/csv":"text/markdown"),a(!1),r?.(c)}catch(h){n?.(h)}};return P.useEffect(()=>{let c=u=>{let h=u.composedPath();s.current&&!h.includes(s.current)&&a(!1)};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[]),C.jsxs("div",{className:"relative",ref:s,children:[C.jsx("button",{className:ct("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:o,onClick:()=>a(!i),title:"Download table",type:"button",children:e??C.jsx(nh,{size:14})}),i?C.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:[C.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"}),C.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"})]}):null]})},hF=({children:e,className:t,showControls:r,...n})=>C.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[r?C.jsxs("div",{className:"flex items-center justify-end gap-1",children:[C.jsx(cF,{}),C.jsx(uF,{})]}):null,C.jsx("div",{className:"overflow-x-auto",children:C.jsx("table",{className:ct("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]}),dF=P.lazy(()=>Promise.resolve().then(()=>require("./code-block-37QAKDTI-BILtfzQC.js")).then(e=>({default:e.CodeBlock}))),fF=P.lazy(()=>Promise.resolve().then(()=>require("./mermaid-4DMBBIKO-2ufyMRt4.js")).then(e=>({default:e.Mermaid}))),pF=/language-([^\s]+)/;function ih(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let r=e.position.start,n=t.position.start,i=e.position.end,a=t.position.end;return r?.line===n?.line&&r?.column===n?.column&&i?.line===a?.line&&i?.column===a?.column}function Xt(e,t){return e.className===t.className&&ih(e.node,t.node)}var Ff=(e,t)=>typeof e=="boolean"?e:e[t]!==!1,Fc=(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},Km=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("ol",{className:ct("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>Xt(e,t));Km.displayName="MarkdownOl";var Y6=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("li",{className:ct("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&ih(e.node,t.node));Y6.displayName="MarkdownLi";var V6=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("ul",{className:ct("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>Xt(e,t));V6.displayName="MarkdownUl";var X6=P.memo(({className:e,node:t,...r})=>C.jsx("hr",{className:ct("my-6 border-border",e),"data-streamdown":"horizontal-rule",...r}),(e,t)=>Xt(e,t));X6.displayName="MarkdownHr";var K6=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("span",{className:ct("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>Xt(e,t));K6.displayName="MarkdownStrong";var mF=({children:e,className:t,href:r,node:n,...i})=>{let{linkSafety:a}=P.useContext(bn),[s,o]=P.useState(!1),l=r==="streamdown:incomplete-link",c=P.useCallback(async f=>{if(!(!(a!=null&&a.enabled&&r)||l)){if(f.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(r)){window.open(r,"_blank","noreferrer");return}o(!0)}},[a,r,l]),u=P.useCallback(()=>{r&&window.open(r,"_blank","noreferrer")},[r]),h=P.useCallback(()=>{o(!1)},[]),d={url:r??"",isOpen:s,onClose:h,onConfirm:u};return a!=null&&a.enabled&&r?C.jsxs(C.Fragment,{children:[C.jsx("button",{className:ct("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":l,"data-streamdown":"link",onClick:c,type:"button",children:e}),a.renderModal?a.renderModal(d):C.jsx(eF,{...d})]}):C.jsx("a",{className:ct("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":l,"data-streamdown":"link",href:r,rel:"noreferrer",target:"_blank",...i,children:e})},Q6=P.memo(mF,(e,t)=>Xt(e,t)&&e.href===t.href);Q6.displayName="MarkdownA";var Z6=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("h1",{className:ct("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>Xt(e,t));Z6.displayName="MarkdownH1";var J6=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("h2",{className:ct("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>Xt(e,t));J6.displayName="MarkdownH2";var e5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("h3",{className:ct("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>Xt(e,t));e5.displayName="MarkdownH3";var t5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("h4",{className:ct("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>Xt(e,t));t5.displayName="MarkdownH4";var r5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("h5",{className:ct("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>Xt(e,t));r5.displayName="MarkdownH5";var n5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("h6",{className:ct("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>Xt(e,t));n5.displayName="MarkdownH6";var i5=P.memo(({children:e,className:t,node:r,...n})=>{let{controls:i}=P.useContext(bn),a=Ff(i,"table");return C.jsx(hF,{className:t,showControls:a,...n,children:e})},(e,t)=>Xt(e,t));i5.displayName="MarkdownTable";var a5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("thead",{className:ct("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>Xt(e,t));a5.displayName="MarkdownThead";var s5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("tbody",{className:ct("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>Xt(e,t));s5.displayName="MarkdownTbody";var o5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("tr",{className:ct("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>Xt(e,t));o5.displayName="MarkdownTr";var l5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("th",{className:ct("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>Xt(e,t));l5.displayName="MarkdownTh";var c5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("td",{className:ct("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>Xt(e,t));c5.displayName="MarkdownTd";var u5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("blockquote",{className:ct("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>Xt(e,t));u5.displayName="MarkdownBlockquote";var h5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("sup",{className:ct("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>Xt(e,t));h5.displayName="MarkdownSup";var d5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("sub",{className:ct("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>Xt(e,t));d5.displayName="MarkdownSub";var f5=P.memo(({children:e,className:t,node:r,...n})=>{if("data-footnotes"in n){let i=s=>{var o,l;if(!P.isValidElement(s))return!1;let c=Array.isArray(s.props.children)?s.props.children:[s.props.children],u=!1,h=!1;for(let d of c)if(d){if(typeof d=="string")d.trim()!==""&&(u=!0);else if(P.isValidElement(d))if(((o=d.props)==null?void 0:o["data-footnote-backref"])!==void 0)h=!0;else{let f=Array.isArray(d.props.children)?d.props.children:[d.props.children];for(let p of f){if(typeof p=="string"&&p.trim()!==""){u=!0;break}if(P.isValidElement(p)&&((l=p.props)==null?void 0:l["data-footnote-backref"])===void 0){u=!0;break}}}}return h&&!u},a=Array.isArray(e)?e.map(s=>{if(!P.isValidElement(s))return s;if(s.type===Km){let o=(Array.isArray(s.props.children)?s.props.children:[s.props.children]).filter(l=>!i(l));return o.length===0?null:{...s,props:{...s.props,children:o}}}return s}):e;return(Array.isArray(a)?a.some(s=>s!==null):a!==null)?C.jsx("section",{className:t,...n,children:a}):null}return C.jsx("section",{className:t,...n,children:e})},(e,t)=>Xt(e,t));f5.displayName="MarkdownSection";var gF=({node:e,className:t,children:r,...n})=>{var i,a,s;let o=((i=e?.position)==null?void 0:i.start.line)===((a=e?.position)==null?void 0:a.end.line),{mermaid:l,controls:c}=P.useContext(bn),u=Xm();if(o)return C.jsx("code",{className:ct("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(pF),d=(s=h?.at(1))!=null?s:"",f="";if(P.isValidElement(r)&&r.props&&typeof r.props=="object"&&"children"in r.props&&typeof r.props.children=="string"?f=r.props.children:typeof r=="string"&&(f=r),d==="mermaid"&&u){let m=Ff(c,"mermaid"),b=Fc(c,"download"),y=Fc(c,"copy"),v=Fc(c,"fullscreen"),T=Fc(c,"panZoom"),A=m&&(b||y||v);return C.jsx(P.Suspense,{fallback:C.jsx(xb,{}),children:C.jsxs("div",{className:ct("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[A?C.jsxs("div",{className:"flex items-center justify-end gap-2",children:[b?C.jsx(nF,{chart:f,config:l?.config}):null,y?C.jsx(bb,{code:f}):null,v?C.jsx(sF,{chart:f,config:l?.config}):null]}):null,C.jsx(fF,{chart:f,config:l?.config,showControls:T})]})})}let p=Ff(c,"code");return C.jsx(P.Suspense,{fallback:C.jsx(xb,{}),children:C.jsx(dF,{className:ct("overflow-x-auto border-border border-t",t),code:f,language:d,children:p?C.jsxs(C.Fragment,{children:[C.jsx(XP,{code:f,language:d}),C.jsx(bb,{})]}):null})})},p5=P.memo(gF,(e,t)=>e.className===t.className&&ih(e.node,t.node));p5.displayName="MarkdownCode";var m5=P.memo(QP,(e,t)=>e.className===t.className&&ih(e.node,t.node));m5.displayName="MarkdownImg";var g5=P.memo(({children:e,className:t,node:r,...n})=>{var i,a;let s=(Array.isArray(e)?e:[e]).filter(o=>o!=null&&o!=="");if(s.length===1&&P.isValidElement(s[0])){let o=s[0].props.node,l=o?.tagName;if(l==="img")return C.jsx(C.Fragment,{children:e});if(l==="code"&&((i=o?.position)==null?void 0:i.start.line)!==((a=o?.position)==null?void 0:a.end.line))return C.jsx(C.Fragment,{children:e})}return C.jsx("p",{className:t,...n,children:e})},(e,t)=>Xt(e,t));g5.displayName="MarkdownParagraph";var bF={ol:Km,li:Y6,ul:V6,hr:X6,strong:K6,a:Q6,h1:Z6,h2:J6,h3:e5,h4:t5,h5:r5,h6:n5,table:i5,thead:a5,tbody:s5,tr:o5,th:l5,td:c5,blockquote:u5,code:p5,img:m5,pre:({children:e})=>e,sup:h5,sub:d5,p:g5,section:f5},vb=[],kb={allowDangerousHtml:!0},$c=new WeakMap,yF=class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(t){let r=this.keyCache.get(t);if(r)return r;let n=t.rehypePlugins,i=t.remarkPlugins,a=t.remarkRehypeOptions;if(!(n||i||a)){let h="default";return this.keyCache.set(t,h),h}let s=h=>{if(!h||h.length===0)return"";let d="";for(let f=0;f<h.length;f+=1){let p=h[f];if(f>0&&(d+=","),Array.isArray(p)){let[m,b]=p;if(typeof m=="function"){let y=$c.get(m);y||(y=m.name,$c.set(m,y)),d+=y}else d+=String(m);d+=":",d+=JSON.stringify(b)}else if(typeof p=="function"){let m=$c.get(p);m||(m=p.name,$c.set(p,m)),d+=m}else d+=String(p)}return d},o=s(n),l=s(i),c=a?JSON.stringify(a):"",u=`${l}::${o}::${c}`;return this.keyCache.set(t,u),u}get(t){let r=this.generateCacheKey(t),n=this.cache.get(r);return n&&(this.cache.delete(r),this.cache.set(r,n)),n}set(t,r){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let i=this.cache.keys().next().value;i&&this.cache.delete(i)}this.cache.set(n,r)}clear(){this.cache.clear()}},wb=new yF,b5=e=>{let t=xF(e),r=e.children||"";return kF(t.runSync(t.parse(r),r),e)},xF=e=>{let t=wb.get(e);if(t)return t;let r=vF(e);return wb.set(e,r),r},vF=e=>{let t=e.rehypePlugins||vb,r=e.remarkPlugins||vb,n=e.remarkRehypeOptions?{...kb,...e.remarkRehypeOptions}:kb;return JO().use(ZD).use(r).use(BO,n).use(t)},kF=(e,t)=>sD(e,{Fragment:C.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:C.jsx,jsxs:C.jsxs,passKeys:!0,passNode:!0}),wF=/\[\^[^\]\s]{1,200}\](?!:)/,TF=/\[\^[^\]\s]{1,200}\]:/,CF=/<\/(\w+)>/,SF=/<(\w+)[\s>]/,kd=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
111
+ `)},cF=({children:e,className:t,onCopy:r,onError:n,timeout:i=2e3})=>{let[a,s]=P.useState(!1),[o,l]=P.useState(!1),c=P.useRef(null),u=P.useRef(0),{isAnimating:h}=P.useContext(bn),d=async p=>{var m,b;if(typeof window>"u"||!((m=navigator?.clipboard)!=null&&m.write)){n?.(new Error("Clipboard API not available"));return}try{let y=(b=c.current)==null?void 0:b.closest('[data-streamdown="table-wrapper"]'),v=y?.querySelector("table");if(!v){n?.(new Error("Table not found"));return}let T=W6(v),A=p==="csv"?G6(T):oF(T),E=new ClipboardItem({"text/plain":new Blob([A],{type:"text/plain"}),"text/html":new Blob([v.outerHTML],{type:"text/html"})});await navigator.clipboard.write([E]),l(!0),s(!1),r?.(p),u.current=window.setTimeout(()=>l(!1),i)}catch(y){n?.(y)}};P.useEffect(()=>{let p=m=>{let b=m.composedPath();c.current&&!b.includes(c.current)&&s(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p),window.clearTimeout(u.current)}},[]);let f=o?Ym:Vm;return C.jsxs("div",{className:"relative",ref:c,children:[C.jsx("button",{className:ct("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:h,onClick:()=>s(!a),title:"Copy table",type:"button",children:e??C.jsx(f,{size:14})}),a?C.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:[C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),C.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>d("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})},uF=({children:e,className:t,onDownload:r,onError:n})=>{let[i,a]=P.useState(!1),s=P.useRef(null),{isAnimating:o}=P.useContext(bn),l=c=>{var u;try{let h=(u=s.current)==null?void 0:u.closest('[data-streamdown="table-wrapper"]'),d=h?.querySelector("table");if(!d){n?.(new Error("Table not found"));return}let f=W6(d),p=c==="csv"?G6(f):lF(f);Bs(`table.${c==="csv"?"csv":"md"}`,p,c==="csv"?"text/csv":"text/markdown"),a(!1),r?.(c)}catch(h){n?.(h)}};return P.useEffect(()=>{let c=u=>{let h=u.composedPath();s.current&&!h.includes(s.current)&&a(!1)};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[]),C.jsxs("div",{className:"relative",ref:s,children:[C.jsx("button",{className:ct("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:o,onClick:()=>a(!i),title:"Download table",type:"button",children:e??C.jsx(nh,{size:14})}),i?C.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:[C.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"}),C.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"})]}):null]})},hF=({children:e,className:t,showControls:r,...n})=>C.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[r?C.jsxs("div",{className:"flex items-center justify-end gap-1",children:[C.jsx(cF,{}),C.jsx(uF,{})]}):null,C.jsx("div",{className:"overflow-x-auto",children:C.jsx("table",{className:ct("w-full border-collapse border border-border",t),"data-streamdown":"table",...n,children:e})})]}),dF=P.lazy(()=>Promise.resolve().then(()=>require("./code-block-37QAKDTI-38K5Mxo2.js")).then(e=>({default:e.CodeBlock}))),fF=P.lazy(()=>Promise.resolve().then(()=>require("./mermaid-4DMBBIKO-Cd15t2pT.js")).then(e=>({default:e.Mermaid}))),pF=/language-([^\s]+)/;function ih(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let r=e.position.start,n=t.position.start,i=e.position.end,a=t.position.end;return r?.line===n?.line&&r?.column===n?.column&&i?.line===a?.line&&i?.column===a?.column}function Xt(e,t){return e.className===t.className&&ih(e.node,t.node)}var Ff=(e,t)=>typeof e=="boolean"?e:e[t]!==!1,Fc=(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},Km=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("ol",{className:ct("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e}),(e,t)=>Xt(e,t));Km.displayName="MarkdownOl";var Y6=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("li",{className:ct("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e}),(e,t)=>e.className===t.className&&ih(e.node,t.node));Y6.displayName="MarkdownLi";var V6=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("ul",{className:ct("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e}),(e,t)=>Xt(e,t));V6.displayName="MarkdownUl";var X6=P.memo(({className:e,node:t,...r})=>C.jsx("hr",{className:ct("my-6 border-border",e),"data-streamdown":"horizontal-rule",...r}),(e,t)=>Xt(e,t));X6.displayName="MarkdownHr";var K6=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("span",{className:ct("font-semibold",t),"data-streamdown":"strong",...n,children:e}),(e,t)=>Xt(e,t));K6.displayName="MarkdownStrong";var mF=({children:e,className:t,href:r,node:n,...i})=>{let{linkSafety:a}=P.useContext(bn),[s,o]=P.useState(!1),l=r==="streamdown:incomplete-link",c=P.useCallback(async f=>{if(!(!(a!=null&&a.enabled&&r)||l)){if(f.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(r)){window.open(r,"_blank","noreferrer");return}o(!0)}},[a,r,l]),u=P.useCallback(()=>{r&&window.open(r,"_blank","noreferrer")},[r]),h=P.useCallback(()=>{o(!1)},[]),d={url:r??"",isOpen:s,onClose:h,onConfirm:u};return a!=null&&a.enabled&&r?C.jsxs(C.Fragment,{children:[C.jsx("button",{className:ct("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":l,"data-streamdown":"link",onClick:c,type:"button",children:e}),a.renderModal?a.renderModal(d):C.jsx(eF,{...d})]}):C.jsx("a",{className:ct("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":l,"data-streamdown":"link",href:r,rel:"noreferrer",target:"_blank",...i,children:e})},Q6=P.memo(mF,(e,t)=>Xt(e,t)&&e.href===t.href);Q6.displayName="MarkdownA";var Z6=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("h1",{className:ct("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e}),(e,t)=>Xt(e,t));Z6.displayName="MarkdownH1";var J6=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("h2",{className:ct("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e}),(e,t)=>Xt(e,t));J6.displayName="MarkdownH2";var e5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("h3",{className:ct("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e}),(e,t)=>Xt(e,t));e5.displayName="MarkdownH3";var t5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("h4",{className:ct("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e}),(e,t)=>Xt(e,t));t5.displayName="MarkdownH4";var r5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("h5",{className:ct("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e}),(e,t)=>Xt(e,t));r5.displayName="MarkdownH5";var n5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("h6",{className:ct("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e}),(e,t)=>Xt(e,t));n5.displayName="MarkdownH6";var i5=P.memo(({children:e,className:t,node:r,...n})=>{let{controls:i}=P.useContext(bn),a=Ff(i,"table");return C.jsx(hF,{className:t,showControls:a,...n,children:e})},(e,t)=>Xt(e,t));i5.displayName="MarkdownTable";var a5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("thead",{className:ct("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e}),(e,t)=>Xt(e,t));a5.displayName="MarkdownThead";var s5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("tbody",{className:ct("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...n,children:e}),(e,t)=>Xt(e,t));s5.displayName="MarkdownTbody";var o5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("tr",{className:ct("border-border border-b",t),"data-streamdown":"table-row",...n,children:e}),(e,t)=>Xt(e,t));o5.displayName="MarkdownTr";var l5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("th",{className:ct("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e}),(e,t)=>Xt(e,t));l5.displayName="MarkdownTh";var c5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("td",{className:ct("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e}),(e,t)=>Xt(e,t));c5.displayName="MarkdownTd";var u5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("blockquote",{className:ct("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e}),(e,t)=>Xt(e,t));u5.displayName="MarkdownBlockquote";var h5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("sup",{className:ct("text-sm",t),"data-streamdown":"superscript",...n,children:e}),(e,t)=>Xt(e,t));h5.displayName="MarkdownSup";var d5=P.memo(({children:e,className:t,node:r,...n})=>C.jsx("sub",{className:ct("text-sm",t),"data-streamdown":"subscript",...n,children:e}),(e,t)=>Xt(e,t));d5.displayName="MarkdownSub";var f5=P.memo(({children:e,className:t,node:r,...n})=>{if("data-footnotes"in n){let i=s=>{var o,l;if(!P.isValidElement(s))return!1;let c=Array.isArray(s.props.children)?s.props.children:[s.props.children],u=!1,h=!1;for(let d of c)if(d){if(typeof d=="string")d.trim()!==""&&(u=!0);else if(P.isValidElement(d))if(((o=d.props)==null?void 0:o["data-footnote-backref"])!==void 0)h=!0;else{let f=Array.isArray(d.props.children)?d.props.children:[d.props.children];for(let p of f){if(typeof p=="string"&&p.trim()!==""){u=!0;break}if(P.isValidElement(p)&&((l=p.props)==null?void 0:l["data-footnote-backref"])===void 0){u=!0;break}}}}return h&&!u},a=Array.isArray(e)?e.map(s=>{if(!P.isValidElement(s))return s;if(s.type===Km){let o=(Array.isArray(s.props.children)?s.props.children:[s.props.children]).filter(l=>!i(l));return o.length===0?null:{...s,props:{...s.props,children:o}}}return s}):e;return(Array.isArray(a)?a.some(s=>s!==null):a!==null)?C.jsx("section",{className:t,...n,children:a}):null}return C.jsx("section",{className:t,...n,children:e})},(e,t)=>Xt(e,t));f5.displayName="MarkdownSection";var gF=({node:e,className:t,children:r,...n})=>{var i,a,s;let o=((i=e?.position)==null?void 0:i.start.line)===((a=e?.position)==null?void 0:a.end.line),{mermaid:l,controls:c}=P.useContext(bn),u=Xm();if(o)return C.jsx("code",{className:ct("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(pF),d=(s=h?.at(1))!=null?s:"",f="";if(P.isValidElement(r)&&r.props&&typeof r.props=="object"&&"children"in r.props&&typeof r.props.children=="string"?f=r.props.children:typeof r=="string"&&(f=r),d==="mermaid"&&u){let m=Ff(c,"mermaid"),b=Fc(c,"download"),y=Fc(c,"copy"),v=Fc(c,"fullscreen"),T=Fc(c,"panZoom"),A=m&&(b||y||v);return C.jsx(P.Suspense,{fallback:C.jsx(xb,{}),children:C.jsxs("div",{className:ct("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[A?C.jsxs("div",{className:"flex items-center justify-end gap-2",children:[b?C.jsx(nF,{chart:f,config:l?.config}):null,y?C.jsx(bb,{code:f}):null,v?C.jsx(sF,{chart:f,config:l?.config}):null]}):null,C.jsx(fF,{chart:f,config:l?.config,showControls:T})]})})}let p=Ff(c,"code");return C.jsx(P.Suspense,{fallback:C.jsx(xb,{}),children:C.jsx(dF,{className:ct("overflow-x-auto border-border border-t",t),code:f,language:d,children:p?C.jsxs(C.Fragment,{children:[C.jsx(XP,{code:f,language:d}),C.jsx(bb,{})]}):null})})},p5=P.memo(gF,(e,t)=>e.className===t.className&&ih(e.node,t.node));p5.displayName="MarkdownCode";var m5=P.memo(QP,(e,t)=>e.className===t.className&&ih(e.node,t.node));m5.displayName="MarkdownImg";var g5=P.memo(({children:e,className:t,node:r,...n})=>{var i,a;let s=(Array.isArray(e)?e:[e]).filter(o=>o!=null&&o!=="");if(s.length===1&&P.isValidElement(s[0])){let o=s[0].props.node,l=o?.tagName;if(l==="img")return C.jsx(C.Fragment,{children:e});if(l==="code"&&((i=o?.position)==null?void 0:i.start.line)!==((a=o?.position)==null?void 0:a.end.line))return C.jsx(C.Fragment,{children:e})}return C.jsx("p",{className:t,...n,children:e})},(e,t)=>Xt(e,t));g5.displayName="MarkdownParagraph";var bF={ol:Km,li:Y6,ul:V6,hr:X6,strong:K6,a:Q6,h1:Z6,h2:J6,h3:e5,h4:t5,h5:r5,h6:n5,table:i5,thead:a5,tbody:s5,tr:o5,th:l5,td:c5,blockquote:u5,code:p5,img:m5,pre:({children:e})=>e,sup:h5,sub:d5,p:g5,section:f5},vb=[],kb={allowDangerousHtml:!0},$c=new WeakMap,yF=class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(t){let r=this.keyCache.get(t);if(r)return r;let n=t.rehypePlugins,i=t.remarkPlugins,a=t.remarkRehypeOptions;if(!(n||i||a)){let h="default";return this.keyCache.set(t,h),h}let s=h=>{if(!h||h.length===0)return"";let d="";for(let f=0;f<h.length;f+=1){let p=h[f];if(f>0&&(d+=","),Array.isArray(p)){let[m,b]=p;if(typeof m=="function"){let y=$c.get(m);y||(y=m.name,$c.set(m,y)),d+=y}else d+=String(m);d+=":",d+=JSON.stringify(b)}else if(typeof p=="function"){let m=$c.get(p);m||(m=p.name,$c.set(p,m)),d+=m}else d+=String(p)}return d},o=s(n),l=s(i),c=a?JSON.stringify(a):"",u=`${l}::${o}::${c}`;return this.keyCache.set(t,u),u}get(t){let r=this.generateCacheKey(t),n=this.cache.get(r);return n&&(this.cache.delete(r),this.cache.set(r,n)),n}set(t,r){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let i=this.cache.keys().next().value;i&&this.cache.delete(i)}this.cache.set(n,r)}clear(){this.cache.clear()}},wb=new yF,b5=e=>{let t=xF(e),r=e.children||"";return kF(t.runSync(t.parse(r),r),e)},xF=e=>{let t=wb.get(e);if(t)return t;let r=vF(e);return wb.set(e,r),r},vF=e=>{let t=e.rehypePlugins||vb,r=e.remarkPlugins||vb,n=e.remarkRehypeOptions?{...kb,...e.remarkRehypeOptions}:kb;return JO().use(ZD).use(r).use(BO,n).use(t)},kF=(e,t)=>sD(e,{Fragment:C.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:C.jsx,jsxs:C.jsxs,passKeys:!0,passNode:!0}),wF=/\[\^[^\]\s]{1,200}\](?!:)/,TF=/\[\^[^\]\s]{1,200}\]:/,CF=/<\/(\w+)>/,SF=/<(\w+)[\s>]/,kd=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
112
112
  `||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},EF=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
113
113
  `||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},wd=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},_F=e=>{let t=wF.test(e),r=TF.test(e);if(t||r)return[e];let n=En.lex(e,{gfm:!0}),i=[],a=[];for(let s of n){let o=s.raw,l=i.length;if(a.length>0){if(i[l-1]+=o,s.type==="html"){let c=o.match(CF);if(c){let u=c[1];a.at(-1)===u&&a.pop()}}continue}if(s.type==="html"&&s.block){let c=o.match(SF);if(c){let u=c[1];o.includes(`</${u}>`)||a.push(u)}}if(o.trim()==="$$"&&l>0){let c=i[l-1],u=kd(c),h=wd(c);if(u&&h%2===1){i[l-1]=c+o;continue}}if(l>0&&EF(o)){let c=i[l-1],u=kd(c),h=wd(c),d=wd(o);if(u&&h%2===1&&!kd(o)&&d===1){i[l-1]=c+o;continue}}i.push(o)}return i},AF={raw:cN,sanitize:[xN,{}],harden:[FE,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:!0}]},NF={gfm:[ZI,{}]},LF=Object.values(AF),MF=Object.values(NF),IF={block:" ▋",circle:" ●"},RF={shikiTheme:["github-light","github-dark"],controls:!0,isAnimating:!1,mode:"streaming",mermaid:void 0,linkSafety:{enabled:!0}},bn=P.createContext(RF),y5=P.memo(({content:e,shouldParseIncompleteMarkdown:t,index:r,...n})=>C.jsx(b5,{...n,children:e}),(e,t)=>{if(e.content!==t.content||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(i=>{var a,s;return((a=e.components)==null?void 0:a[i])!==((s=t.components)==null?void 0:s[i])}))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});y5.displayName="Block";var BF=["github-light","github-dark"],Ka=P.memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:r=!0,components:n,rehypePlugins:i=LF,remarkPlugins:a=MF,className:s,shikiTheme:o=BF,mermaid:l,controls:c=!0,isAnimating:u=!1,BlockComponent:h=y5,parseMarkdownIntoBlocksFn:d=_F,caret:f,plugins:p,remend:m,linkSafety:b={enabled:!0},...y})=>{let v=P.useId(),[T,A]=P.useTransition(),E=P.useMemo(()=>typeof e!="string"?"":t==="streaming"&&r?rB(e,m):e,[e,t,r,m]),S=P.useMemo(()=>d(E),[E,d]),[I,D]=P.useState(S);P.useEffect(()=>{t==="streaming"?A(()=>{D(S)}):D(S)},[S,t]);let H=t==="streaming"?I:S,R=P.useMemo(()=>H.map((W,Z)=>`${v}-${Z}`),[H.length,v]),F=P.useMemo(()=>{var W,Z;return{shikiTheme:(Z=(W=p?.code)==null?void 0:W.getThemes())!=null?Z:o,controls:c,isAnimating:u,mode:t,mermaid:l,linkSafety:b}},[o,c,u,t,l,b,p?.code]),G=P.useMemo(()=>({...bF,...n}),[n]),ee=P.useMemo(()=>{let W=[];return p!=null&&p.cjk&&(W=[...W,...p.cjk.remarkPluginsBefore]),W=[...W,...a],p!=null&&p.cjk&&(W=[...W,...p.cjk.remarkPluginsAfter]),p!=null&&p.math&&(W=[...W,p.math.remarkPlugin]),W},[a,p?.math,p?.cjk]),$=P.useMemo(()=>p!=null&&p.math?[...i,p.math.rehypePlugin]:i,[i,p?.math]),q=P.useMemo(()=>f&&u?{"--streamdown-caret":`"${IF[f]}"`}:void 0,[f,u]);return t==="static"?C.jsx(Pf.Provider,{value:p??null,children:C.jsx(bn.Provider,{value:F,children:C.jsx("div",{className:ct("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",s),children:C.jsx(b5,{components:G,rehypePlugins:$,remarkPlugins:ee,...y,children:e})})})}):C.jsx(Pf.Provider,{value:p??null,children:C.jsx(bn.Provider,{value:F,children:C.jsxs("div",{className:ct("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",f?"*:last:after:inline *:last:after:align-baseline *:last:after:content-(--streamdown-caret)":null,s),style:q,children:[H.length===0&&f&&u&&C.jsx("span",{}),H.map((W,Z)=>C.jsx(h,{components:G,content:W,index:Z,rehypePlugins:$,remarkPlugins:ee,shouldParseIncompleteMarkdown:r,...y},R[Z]))]})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety);Ka.displayName="Streamdown";var DF=({children:e,className:t,minZoom:r=.5,maxZoom:n=3,zoomStep:i=.1,showControls:a=!0,initialZoom:s=1,fullscreen:o=!1})=>{let l=P.useRef(null),c=P.useRef(null),[u,h]=P.useState(s),[d,f]=P.useState({x:0,y:0}),[p,m]=P.useState(!1),[b,y]=P.useState({x:0,y:0}),[v,T]=P.useState({x:0,y:0}),A=P.useCallback(G=>{h(ee=>Math.max(r,Math.min(n,ee+G)))},[r,n]),E=P.useCallback(()=>{A(i)},[A,i]),S=P.useCallback(()=>{A(-i)},[A,i]),I=P.useCallback(()=>{h(s),f({x:0,y:0})},[s]),D=P.useCallback(G=>{G.preventDefault();let ee=G.deltaY>0?-i:i;A(ee)},[A,i]),H=P.useCallback(G=>{if(G.button!==0||G.isPrimary===!1)return;m(!0),y({x:G.clientX,y:G.clientY}),T(d);let ee=G.currentTarget;ee instanceof HTMLElement&&ee.setPointerCapture(G.pointerId)},[d]),R=P.useCallback(G=>{if(!p)return;G.preventDefault();let ee=G.clientX-b.x,$=G.clientY-b.y;f({x:v.x+ee,y:v.y+$})},[p,b,v]),F=P.useCallback(G=>{m(!1);let ee=G.currentTarget;ee instanceof HTMLElement&&ee.releasePointerCapture(G.pointerId)},[]);return P.useEffect(()=>{let G=l.current;if(G)return G.addEventListener("wheel",D,{passive:!1}),()=>{G.removeEventListener("wheel",D)}},[D]),P.useEffect(()=>{let G=c.current;if(G&&p)return document.body.style.userSelect="none",G.addEventListener("pointermove",R,{passive:!1}),G.addEventListener("pointerup",F),G.addEventListener("pointercancel",F),()=>{document.body.style.userSelect="",G.removeEventListener("pointermove",R),G.removeEventListener("pointerup",F),G.removeEventListener("pointercancel",F)}},[p,R,F]),C.jsxs("div",{className:ct("relative flex flex-col",o?"h-full w-full":"min-h-28 w-full",t),ref:l,style:{cursor:p?"grabbing":"grab"},children:[a?C.jsxs("div",{className:ct("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",o?"bottom-4 left-4":"bottom-2 left-2"),children:[C.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:u>=n,onClick:E,title:"Zoom in",type:"button",children:C.jsx(YP,{size:16})}),C.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:u<=r,onClick:S,title:"Zoom out",type:"button",children:C.jsx(VP,{size:16})}),C.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:I,title:"Reset zoom and pan",type:"button",children:C.jsx(GP,{size:16})})]}):null,C.jsx("div",{className:ct("flex-1 origin-center transition-transform duration-150 ease-out",o?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:H,ref:c,role:"application",style:{transform:`translate(${d.x}px, ${d.y}px) scale(${u})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})},x5=({chart:e,className:t,config:r,fullscreen:n=!1,showControls:i=!0})=>{let[a,s]=P.useState(null),[o,l]=P.useState(!1),[c,u]=P.useState(""),[h,d]=P.useState(""),[f,p]=P.useState(0),{mermaid:m}=P.useContext(bn),b=Xm(),y=m?.errorComponent,{shouldRender:v,containerRef:T}=jP({immediate:n});if(P.useEffect(()=>{if(v){if(!b){s("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{s(null),l(!0);let E=b.getMermaid(r),S=e.split("").reduce((H,R)=>(H<<5)-H+R.charCodeAt(0)|0,0),I=`mermaid-${Math.abs(S)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:D}=await E.render(I,e);u(D),d(D)}catch(E){if(!(h||c)){let S=E instanceof Error?E.message:"Failed to render Mermaid chart";s(S)}}finally{l(!1)}})()}},[e,r,f,v,b]),!(v||c||h))return C.jsx("div",{className:ct("my-4 min-h-[200px]",t),ref:T});if(o&&!c&&!h)return C.jsx("div",{className:ct("my-4 flex justify-center p-4",t),ref:T,children:C.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[C.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),C.jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(a&&!c&&!h){let E=()=>p(S=>S+1);return y?C.jsx("div",{ref:T,children:C.jsx(y,{chart:e,error:a,retry:E})}):C.jsxs("div",{className:ct("rounded-lg border border-red-200 bg-red-50 p-4",t),ref:T,children:[C.jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",a]}),C.jsxs("details",{className:"mt-2",children:[C.jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),C.jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let A=c||h;return C.jsx("div",{className:ct("size-full",t),"data-streamdown":"mermaid",ref:T,children:C.jsx(DF,{className:ct(n?"size-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:n,maxZoom:3,minZoom:.5,showControls:i,zoomStep:.1,children:C.jsx("div",{"aria-label":"Mermaid chart",className:ct("flex justify-center",n?"size-full items-center":null),dangerouslySetInnerHTML:{__html:A},role:"img"})})})};let nr=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function OF(e){return Qm(e)}function Qm(e){return Array.isArray(e)?PF(e):e instanceof RegExp?e:typeof e=="object"?FF(e):e}function PF(e){let t=[];for(let r=0,n=e.length;r<n;r++)t[r]=Qm(e[r]);return t}function FF(e){let t={};for(let r in e)t[r]=Qm(e[r]);return t}function v5(e,...t){return t.forEach(r=>{for(let n in r)e[n]=r[n]}),e}function k5(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?k5(e.substring(0,e.length-1)):e.substr(~t+1)}var Td=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,zc=class{static hasCaptures(e){return e===null?!1:(Td.lastIndex=0,Td.test(e))}static replaceCaptures(e,t,r){return e.replace(Td,(n,i,a,s)=>{let o=r[parseInt(i||a,10)];if(o){let l=t.substring(o.start,o.end);for(;l[0]===".";)l=l.substring(1);switch(s){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return n})}};function w5(e,t){return e<t?-1:e>t?1:0}function T5(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let r=e.length,n=t.length;if(r===n){for(let i=0;i<r;i++){let a=w5(e[i],t[i]);if(a!==0)return a}return 0}return r-n}function Tb(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function C5(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var S5=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},Wu=class{constructor(t,r,n){this._colorMap=t,this._defaults=r,this._root=n}static createFromRawTheme(t,r){return this.createFromParsedTheme(HF(t),r)}static createFromParsedTheme(t,r){return jF(t,r)}_cachedMatchRoot=new S5(t=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;const r=t.scopeName,i=this._cachedMatchRoot.get(r).find(a=>$F(t.parent,a.parentScopes));return i?new E5(i.fontStyle,i.foreground,i.background):null}},Cd=class mu{constructor(t,r){this.parent=t,this.scopeName=r}static push(t,r){for(const n of r)t=new mu(t,n);return t}static from(...t){let r=null;for(let n=0;n<t.length;n++)r=new mu(r,t[n]);return r}push(t){return new mu(this,t)}getSegments(){let t=this;const r=[];for(;t;)r.push(t.scopeName),t=t.parent;return r.reverse(),r}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const r=[];let n=this;for(;n&&n!==t;)r.push(n.scopeName),n=n.parent;return n===t?r.reverse():void 0}};function $F(e,t){if(t.length===0)return!0;for(let r=0;r<t.length;r++){let n=t[r],i=!1;if(n===">"){if(r===t.length-1)return!1;n=t[++r],i=!0}for(;e&&!zF(e.scopeName,n);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function zF(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var E5=class{constructor(e,t,r){this.fontStyle=e,this.foregroundId=t,this.backgroundId=r}};function HF(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,r=[],n=0;for(let i=0,a=t.length;i<a;i++){let s=t[i];if(!s.settings)continue;let o;if(typeof s.scope=="string"){let h=s.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),o=h.split(",")}else Array.isArray(s.scope)?o=s.scope:o=[""];let l=-1;if(typeof s.settings.fontStyle=="string"){l=0;let h=s.settings.fontStyle.split(" ");for(let d=0,f=h.length;d<f;d++)switch(h[d]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let c=null;typeof s.settings.foreground=="string"&&Tb(s.settings.foreground)&&(c=s.settings.foreground);let u=null;typeof s.settings.background=="string"&&Tb(s.settings.background)&&(u=s.settings.background);for(let h=0,d=o.length;h<d;h++){let p=o[h].trim().split(" "),m=p[p.length-1],b=null;p.length>1&&(b=p.slice(0,p.length-1),b.reverse()),r[n++]=new qF(m,b,i,l,c,u)}}return r}var qF=class{constructor(e,t,r,n,i,a){this.scope=e,this.parentScopes=t,this.index=r,this.fontStyle=n,this.foreground=i,this.background=a}},Mr=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(Mr||{});function jF(e,t){e.sort((l,c)=>{let u=w5(l.scope,c.scope);return u!==0||(u=T5(l.parentScopes,c.parentScopes),u!==0)?u:l.index-c.index});let r=0,n="#000000",i="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(r=l.fontStyle),l.foreground!==null&&(n=l.foreground),l.background!==null&&(i=l.background)}let a=new UF(t),s=new E5(r,a.getId(n),a.getId(i)),o=new GF(new $f(0,null,-1,0,0),[]);for(let l=0,c=e.length;l<c;l++){let u=e[l];o.insert(0,u.scope,u.parentScopes,u.fontStyle,a.getId(u.foreground),a.getId(u.background))}return new Wu(a,s,o)}var UF=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,r=e.length;t<r;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},WF=Object.freeze([]),$f=class _5{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,r,n,i,a){this.scopeDepth=t,this.parentScopes=r||WF,this.fontStyle=n,this.foreground=i,this.background=a}clone(){return new _5(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let r=[];for(let n=0,i=t.length;n<i;n++)r[n]=t[n].clone();return r}acceptOverwrite(t,r,n,i){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,r!==-1&&(this.fontStyle=r),n!==0&&(this.foreground=n),i!==0&&(this.background=i)}},GF=class zf{constructor(t,r=[],n={}){this._mainRule=t,this._children=n,this._rulesWithParentScopes=r}_rulesWithParentScopes;static _cmpBySpecificity(t,r){if(t.scopeDepth!==r.scopeDepth)return r.scopeDepth-t.scopeDepth;let n=0,i=0;for(;t.parentScopes[n]===">"&&n++,r.parentScopes[i]===">"&&i++,!(n>=t.parentScopes.length||i>=r.parentScopes.length);){const a=r.parentScopes[i].length-t.parentScopes[n].length;if(a!==0)return a;n++,i++}return r.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let n=t.indexOf("."),i,a;if(n===-1?(i=t,a=""):(i=t.substring(0,n),a=t.substring(n+1)),this._children.hasOwnProperty(i))return this._children[i].match(a)}const r=this._rulesWithParentScopes.concat(this._mainRule);return r.sort(zf._cmpBySpecificity),r}insert(t,r,n,i,a,s){if(r===""){this._doInsertHere(t,n,i,a,s);return}let o=r.indexOf("."),l,c;o===-1?(l=r,c=""):(l=r.substring(0,o),c=r.substring(o+1));let u;this._children.hasOwnProperty(l)?u=this._children[l]:(u=new zf(this._mainRule.clone(),$f.cloneArr(this._rulesWithParentScopes)),this._children[l]=u),u.insert(t+1,c,n,i,a,s)}_doInsertHere(t,r,n,i,a){if(r===null){this._mainRule.acceptOverwrite(t,n,i,a);return}for(let s=0,o=this._rulesWithParentScopes.length;s<o;s++){let l=this._rulesWithParentScopes[s];if(T5(l.parentScopes,r)===0){l.acceptOverwrite(t,n,i,a);return}}n===-1&&(n=this._mainRule.fontStyle),i===0&&(i=this._mainRule.foreground),a===0&&(a=this._mainRule.background),this._rulesWithParentScopes.push(new $f(t,r,n,i,a))}},Js=class Tn{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const r=Tn.getLanguageId(t),n=Tn.getTokenType(t),i=Tn.getFontStyle(t),a=Tn.getForeground(t),s=Tn.getBackground(t);console.log({languageId:r,tokenType:n,fontStyle:i,foreground:a,background:s})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,r,n,i,a,s,o){let l=Tn.getLanguageId(t),c=Tn.getTokenType(t),u=Tn.containsBalancedBrackets(t)?1:0,h=Tn.getFontStyle(t),d=Tn.getForeground(t),f=Tn.getBackground(t);return r!==0&&(l=r),n!==8&&(c=n),i!==null&&(u=i?1:0),a!==-1&&(h=a),s!==0&&(d=s),o!==0&&(f=o),(l<<0|c<<8|u<<10|h<<11|d<<15|f<<24)>>>0}};function Gu(e,t){const r=[],n=YF(e);let i=n.next();for(;i!==null;){let l=0;if(i.length===2&&i.charAt(1)===":"){switch(i.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=n.next()}let c=s();if(r.push({matcher:c,priority:l}),i!==",")break;i=n.next()}return r;function a(){if(i==="-"){i=n.next();const l=a();return c=>!!l&&!l(c)}if(i==="("){i=n.next();const l=o();return i===")"&&(i=n.next()),l}if(Cb(i)){const l=[];do l.push(i),i=n.next();while(Cb(i));return c=>t(l,c)}return null}function s(){const l=[];let c=a();for(;c;)l.push(c),c=a();return u=>l.every(h=>h(u))}function o(){const l=[];let c=s();for(;c&&(l.push(c),i==="|"||i===",");){do i=n.next();while(i==="|"||i===",");c=s()}return u=>l.some(h=>h(u))}}function Cb(e){return!!e&&!!e.match(/[\w\.:]+/)}function YF(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,r=t.exec(e);return{next:()=>{if(!r)return null;const n=r[0];return r=t.exec(e),n}}}function A5(e){typeof e.dispose=="function"&&e.dispose()}var Hl=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},VF=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},XF=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},KF=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Hl(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const e=this.Q;this.Q=[];const t=new XF;for(const r of e)QF(r,this.initialScopeName,this.repo,t);for(const r of t.references)if(r instanceof Hl){if(this.seenFullScopeRequests.has(r.scopeName))continue;this.seenFullScopeRequests.add(r.scopeName),this.Q.push(r)}else{if(this.seenFullScopeRequests.has(r.scopeName)||this.seenPartialScopeRequests.has(r.toKey()))continue;this.seenPartialScopeRequests.add(r.toKey()),this.Q.push(r)}}};function QF(e,t,r,n){const i=r.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const a=r.lookup(t);e instanceof Hl?gu({baseGrammar:a,selfGrammar:i},n):Hf(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},n);const s=r.injections(e.scopeName);if(s)for(const o of s)n.add(new Hl(o))}function Hf(e,t,r){if(t.repository&&t.repository[e]){const n=t.repository[e];Yu([n],t,r)}}function gu(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Yu(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Yu(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Yu(e,t,r){for(const n of e){if(r.visitedRule.has(n))continue;r.visitedRule.add(n);const i=n.repository?v5({},t.repository,n.repository):t.repository;Array.isArray(n.patterns)&&Yu(n.patterns,{...t,repository:i},r);const a=n.include;if(!a)continue;const s=N5(a);switch(s.kind){case 0:gu({...t,selfGrammar:t.baseGrammar},r);break;case 1:gu(t,r);break;case 2:Hf(s.ruleName,{...t,repository:i},r);break;case 3:case 4:const o=s.scopeName===t.selfGrammar.scopeName?t.selfGrammar:s.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(o){const l={baseGrammar:t.baseGrammar,selfGrammar:o,repository:i};s.kind===4?Hf(s.ruleName,l,r):gu(l,r)}else s.kind===4?r.add(new VF(s.scopeName,s.ruleName)):r.add(new Hl(s.scopeName));break}}}var ZF=class{kind=0},JF=class{kind=1},e$=class{constructor(e){this.ruleName=e}kind=2},t$=class{constructor(e){this.scopeName=e}kind=3},r$=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function N5(e){if(e==="$base")return new ZF;if(e==="$self")return new JF;const t=e.indexOf("#");if(t===-1)return new t$(e);if(t===0)return new e$(e.substring(1));{const r=e.substring(0,t),n=e.substring(t+1);return new r$(r,n)}}var n$=/\\(\d+)/,Sb=/\\(\d+)/g,i$=-1,L5=-2;var bc=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,r,n){this.$location=e,this.id=t,this._name=r||null,this._nameIsCapturing=zc.hasCaptures(this._name),this._contentName=n||null,this._contentNameIsCapturing=zc.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${k5(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:zc.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:zc.replaceCaptures(this._contentName,e,t)}},a$=class extends bc{retokenizeCapturedWithRuleId;constructor(e,t,r,n,i){super(e,t,r,n),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,r,n){throw new Error("Not supported!")}},s$=class extends bc{_match;captures;_cachedCompiledPatterns;constructor(e,t,r,n,i){super(e,t,r,null),this._match=new ql(n,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,r,n){return this._getCachedCompiledPatterns(e).compileAG(e,r,n)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new jl,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Eb=class extends bc{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,r,n,i){super(e,t,r,n),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const r of this.patterns)e.getRule(r).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,r,n){return this._getCachedCompiledPatterns(e).compileAG(e,r,n)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new jl,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},qf=class extends bc{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,r,n,i,a,s,o,l,c){super(e,t,r,n),this._begin=new ql(i,this.id),this.beginCaptures=a,this._end=new ql(s||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=o,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,r,n){return this._getCachedCompiledPatterns(e,t).compileAG(e,r,n)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new jl;for(const r of this.patterns)e.getRule(r).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Vu=class extends bc{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,r,n,i,a,s,o,l){super(e,t,r,n),this._begin=new ql(i,this.id),this.beginCaptures=a,this.whileCaptures=o,this._while=new ql(s,L5),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,r,n){return this._getCachedCompiledPatterns(e).compileAG(e,r,n)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new jl;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,r,n){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,r,n)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new jl,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"￿"),this._cachedCompiledWhilePatterns}},M5=class Ar{static createCaptureRule(t,r,n,i,a){return t.registerRule(s=>new a$(r,s,n,i,a))}static getCompiledRuleId(t,r,n){return t.id||r.registerRule(i=>{if(t.id=i,t.match)return new s$(t.$vscodeTextmateLocation,t.id,t.name,t.match,Ar._compileCaptures(t.captures,r,n));if(typeof t.begin>"u"){t.repository&&(n=v5({},n,t.repository));let a=t.patterns;return typeof a>"u"&&t.include&&(a=[{include:t.include}]),new Eb(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Ar._compilePatterns(a,r,n))}return t.while?new Vu(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Ar._compileCaptures(t.beginCaptures||t.captures,r,n),t.while,Ar._compileCaptures(t.whileCaptures||t.captures,r,n),Ar._compilePatterns(t.patterns,r,n)):new qf(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Ar._compileCaptures(t.beginCaptures||t.captures,r,n),t.end,Ar._compileCaptures(t.endCaptures||t.captures,r,n),t.applyEndPatternLast,Ar._compilePatterns(t.patterns,r,n))}),t.id}static _compileCaptures(t,r,n){let i=[];if(t){let a=0;for(const s in t){if(s==="$vscodeTextmateLocation")continue;const o=parseInt(s,10);o>a&&(a=o)}for(let s=0;s<=a;s++)i[s]=null;for(const s in t){if(s==="$vscodeTextmateLocation")continue;const o=parseInt(s,10);let l=0;t[s].patterns&&(l=Ar.getCompiledRuleId(t[s],r,n)),i[o]=Ar.createCaptureRule(r,t[s].$vscodeTextmateLocation,t[s].name,t[s].contentName,l)}}return i}static _compilePatterns(t,r,n){let i=[];if(t)for(let a=0,s=t.length;a<s;a++){const o=t[a];let l=-1;if(o.include){const c=N5(o.include);switch(c.kind){case 0:case 1:l=Ar.getCompiledRuleId(n[o.include],r,n);break;case 2:let u=n[c.ruleName];u&&(l=Ar.getCompiledRuleId(u,r,n));break;case 3:case 4:const h=c.scopeName,d=c.kind===4?c.ruleName:null,f=r.getExternalGrammar(h,n);if(f)if(d){let p=f.repository[d];p&&(l=Ar.getCompiledRuleId(p,r,f.repository))}else l=Ar.getCompiledRuleId(f.repository.$self,r,f.repository);break}}else l=Ar.getCompiledRuleId(o,r,n);if(l!==-1){const c=r.getRule(l);let u=!1;if((c instanceof Eb||c instanceof qf||c instanceof Vu)&&c.hasMissingPatterns&&c.patterns.length===0&&(u=!0),u)continue;i.push(l)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},ql=class I5{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,r){if(t&&typeof t=="string"){const n=t.length;let i=0,a=[],s=!1;for(let o=0;o<n;o++)if(t.charAt(o)==="\\"&&o+1<n){const c=t.charAt(o+1);c==="z"?(a.push(t.substring(i,o)),a.push("$(?!\\n)(?<!\\n)"),i=o+2):(c==="A"||c==="G")&&(s=!0),o++}this.hasAnchor=s,i===0?this.source=t:(a.push(t.substring(i,n)),this.source=a.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=r,typeof this.source=="string"?this.hasBackReferences=n$.test(this.source):this.hasBackReferences=!1}clone(){return new I5(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,r){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let n=r.map(i=>t.substring(i.start,i.end));return Sb.lastIndex=0,this.source.replace(Sb,(i,a)=>C5(n[parseInt(a,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],r=[],n=[],i=[],a,s,o,l;for(a=0,s=this.source.length;a<s;a++)o=this.source.charAt(a),t[a]=o,r[a]=o,n[a]=o,i[a]=o,o==="\\"&&a+1<s&&(l=this.source.charAt(a+1),l==="A"?(t[a+1]="￿",r[a+1]="￿",n[a+1]="A",i[a+1]="A"):l==="G"?(t[a+1]="￿",r[a+1]="G",n[a+1]="￿",i[a+1]="G"):(t[a+1]=l,r[a+1]=l,n[a+1]=l,i[a+1]=l),a++);return{A0_G0:t.join(""),A0_G1:r.join(""),A1_G0:n.join(""),A1_G1:i.join("")}}resolveAnchors(t,r){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?r?this._anchorCache.A1_G1:this._anchorCache.A1_G0:r?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},jl=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(r=>r.source);this._cached=new _b(e,t,this._items.map(r=>r.ruleId))}return this._cached}compileAG(e,t,r){return this._hasAnchors?t?r?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,r)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,r)),this._anchorCache.A1_G0):r?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,r)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,r)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,r){let n=this._items.map(i=>i.resolveAnchors(t,r));return new _b(e,n,this._items.map(i=>i.ruleId))}},_b=class{constructor(e,t,r){this.regExps=t,this.rules=r,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,r=this.rules.length;t<r;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
114
114
  `)}findNextMatchSync(e,t,r){const n=this.scanner.findNextMatchSync(e,t,r);return n?{ruleId:this.rules[n.index],captureIndices:n.captureIndices}:null}},Sd=class{constructor(e,t){this.languageId=e,this.tokenType=t}},o$=class jf{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,r){this._defaultAttributes=new Sd(t,8),this._embeddedLanguagesMatcher=new l$(Object.entries(r||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?jf._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Sd(0,0);_getBasicScopeAttributes=new S5(t=>{const r=this._scopeToLanguage(t),n=this._toStandardTokenType(t);return new Sd(r,n)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const r=t.match(jf.STANDARD_TOKEN_TYPE_REGEXP);if(!r)return 8;switch(r[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},l$=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([r,n])=>C5(r));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;const t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}};typeof process<"u"&&process.env.VSCODE_TEXTMATE_DEBUG;var Ab=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function R5(e,t,r,n,i,a,s,o){const l=t.content.length;let c=!1,u=-1;if(s){const f=c$(e,t,r,n,i,a);i=f.stack,n=f.linePos,r=f.isFirstLine,u=f.anchorPosition}const h=Date.now();for(;!c;){if(o!==0&&Date.now()-h>o)return new Ab(i,!0);d()}return new Ab(i,!1);function d(){const f=u$(e,t,r,n,i,u);if(!f){a.produce(i,l),c=!0;return}const p=f.captureIndices,m=f.matchedRuleId,b=p&&p.length>0?p[0].end>n:!1;if(m===i$){const y=i.getRule(e);a.produce(i,p[0].start),i=i.withContentNameScopesList(i.nameScopesList),al(e,t,r,i,a,y.endCaptures,p),a.produce(i,p[0].end);const v=i;if(i=i.parent,u=v.getAnchorPos(),!b&&v.getEnterPos()===n){i=v,a.produce(i,l),c=!0;return}}else{const y=e.getRule(m);a.produce(i,p[0].start);const v=i,T=y.getName(t.content,p),A=i.contentNameScopesList.pushAttributed(T,e);if(i=i.push(m,n,u,p[0].end===l,null,A,A),y instanceof qf){const E=y;al(e,t,r,i,a,E.beginCaptures,p),a.produce(i,p[0].end),u=p[0].end;const S=E.getContentName(t.content,p),I=A.pushAttributed(S,e);if(i=i.withContentNameScopesList(I),E.endHasBackReferences&&(i=i.withEndRule(E.getEndWithResolvedBackReferences(t.content,p))),!b&&v.hasSameRuleAs(i)){i=i.pop(),a.produce(i,l),c=!0;return}}else if(y instanceof Vu){const E=y;al(e,t,r,i,a,E.beginCaptures,p),a.produce(i,p[0].end),u=p[0].end;const S=E.getContentName(t.content,p),I=A.pushAttributed(S,e);if(i=i.withContentNameScopesList(I),E.whileHasBackReferences&&(i=i.withEndRule(E.getWhileWithResolvedBackReferences(t.content,p))),!b&&v.hasSameRuleAs(i)){i=i.pop(),a.produce(i,l),c=!0;return}}else if(al(e,t,r,i,a,y.captures,p),a.produce(i,p[0].end),i=i.pop(),!b){i=i.safePop(),a.produce(i,l),c=!0;return}}p[0].end>n&&(n=p[0].end,r=!1)}}function c$(e,t,r,n,i,a){let s=i.beginRuleCapturedEOL?0:-1;const o=[];for(let l=i;l;l=l.pop()){const c=l.getRule(e);c instanceof Vu&&o.push({rule:c,stack:l})}for(let l=o.pop();l;l=o.pop()){const{ruleScanner:c,findOptions:u}=f$(l.rule,e,l.stack.endRule,r,n===s),h=c.findNextMatchSync(t,n,u);if(h){if(h.ruleId!==L5){i=l.stack.pop();break}h.captureIndices&&h.captureIndices.length&&(a.produce(l.stack,h.captureIndices[0].start),al(e,t,r,l.stack,a,l.rule.whileCaptures,h.captureIndices),a.produce(l.stack,h.captureIndices[0].end),s=h.captureIndices[0].end,h.captureIndices[0].end>n&&(n=h.captureIndices[0].end,r=!1))}else{i=l.stack.pop();break}}return{stack:i,linePos:n,anchorPosition:s,isFirstLine:r}}function u$(e,t,r,n,i,a){const s=h$(e,t,r,n,i,a),o=e.getInjections();if(o.length===0)return s;const l=d$(o,e,t,r,n,i,a);if(!l)return s;if(!s)return l;const c=s.captureIndices[0].start,u=l.captureIndices[0].start;return u<c||l.priorityMatch&&u===c?l:s}function h$(e,t,r,n,i,a){const s=i.getRule(e),{ruleScanner:o,findOptions:l}=B5(s,e,i.endRule,r,n===a),c=o.findNextMatchSync(t,n,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function d$(e,t,r,n,i,a,s){let o=Number.MAX_VALUE,l=null,c,u=0;const h=a.contentNameScopesList.getScopeNames();for(let d=0,f=e.length;d<f;d++){const p=e[d];if(!p.matcher(h))continue;const m=t.getRule(p.ruleId),{ruleScanner:b,findOptions:y}=B5(m,t,null,n,i===s),v=b.findNextMatchSync(r,i,y);if(!v)continue;const T=v.captureIndices[0].start;if(!(T>=o)&&(o=T,l=v.captureIndices,c=v.ruleId,u=p.priority,o===i))break}return l?{priorityMatch:u===-1,captureIndices:l,matchedRuleId:c}:null}function B5(e,t,r,n,i){return{ruleScanner:e.compileAG(t,r,n,i),findOptions:0}}function f$(e,t,r,n,i){return{ruleScanner:e.compileWhileAG(t,r,n,i),findOptions:0}}function al(e,t,r,n,i,a,s){if(a.length===0)return;const o=t.content,l=Math.min(a.length,s.length),c=[],u=s[0].end;for(let h=0;h<l;h++){const d=a[h];if(d===null)continue;const f=s[h];if(f.length===0)continue;if(f.start>u)break;for(;c.length>0&&c[c.length-1].endPos<=f.start;)i.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?i.produceFromScopes(c[c.length-1].scopes,f.start):i.produce(n,f.start),d.retokenizeCapturedWithRuleId){const m=d.getName(o,s),b=n.contentNameScopesList.pushAttributed(m,e),y=d.getContentName(o,s),v=b.pushAttributed(y,e),T=n.push(d.retokenizeCapturedWithRuleId,f.start,-1,!1,null,b,v),A=e.createOnigString(o.substring(0,f.end));R5(e,A,r&&f.start===0,f.start,T,i,!1,0),A5(A);continue}const p=d.getName(o,s);if(p!==null){const b=(c.length>0?c[c.length-1].scopes:n.contentNameScopesList).pushAttributed(p,e);c.push(new p$(b,f.end))}}for(;c.length>0;)i.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var p$=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function m$(e,t,r,n,i,a,s,o){return new b$(e,t,r,n,i,a,s,o)}function Nb(e,t,r,n,i){const a=Gu(t,Xu),s=M5.getCompiledRuleId(r,n,i.repository);for(const o of a)e.push({debugSelector:t,matcher:o.matcher,ruleId:s,grammar:i,priority:o.priority})}function Xu(e,t){if(t.length<e.length)return!1;let r=0;return e.every(n=>{for(let i=r;i<t.length;i++)if(g$(t[i],n))return r=i+1,!0;return!1})}function g$(e,t){if(!e)return!1;if(e===t)return!0;const r=t.length;return e.length>r&&e.substr(0,r)===t&&e[r]==="."}var b$=class{constructor(e,t,r,n,i,a,s,o){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=o,this._basicScopeAttributesProvider=new o$(r,n),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=s,this._grammar=Lb(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(const l of Object.keys(i)){const c=Gu(l,Xu);for(const u of c)this._tokenTypeMatchers.push({matcher:u.matcher,type:i[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:i=>i===this._rootScopeName?this._grammar:this.getExternalGrammar(i),injections:i=>this._grammarRepository.injections(i)},t=[],r=this._rootScopeName,n=e.lookup(r);if(n){const i=n.injections;if(i)for(let s in i)Nb(t,s,i[s],this,n);const a=this._grammarRepository.injections(r);a&&a.forEach(s=>{const o=this.getExternalGrammar(s);if(o){const l=o.injectionSelector;l&&Nb(t,l,o,this,o)}})}return t.sort((i,a)=>i.priority-a.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,r=e(t);return this._ruleId2desc[t]=r,r}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const r=this._grammarRepository.lookup(e);if(r)return this._includedGrammars[e]=Lb(r,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,r=0){const n=this._tokenize(e,t,!1,r);return{tokens:n.lineTokens.getResult(n.ruleStack,n.lineLength),ruleStack:n.ruleStack,stoppedEarly:n.stoppedEarly}}tokenizeLine2(e,t,r=0){const n=this._tokenize(e,t,!0,r);return{tokens:n.lineTokens.getBinaryResult(n.ruleStack,n.lineLength),ruleStack:n.ruleStack,stoppedEarly:n.stoppedEarly}}_tokenize(e,t,r,n){this._rootId===-1&&(this._rootId=M5.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===Uf.NULL){i=!0;const c=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),h=Js.set(0,c.languageId,c.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),d=this.getRule(this._rootId).getName(null,null);let f;d?f=Al.createRootAndLookUpScopeName(d,h,this):f=Al.createRoot("unknown",h),t=new Uf(null,this._rootId,-1,-1,!1,null,f,f)}else i=!1,t.reset();e=e+`
@@ -626,8 +626,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error
626
626
  node : x:${e.x} y:${e.y} w:${e.width} h:${e.height}`);const n=e.x,i=e.y,a=Math.abs(n-r.x),s=e.width/2;let o=r.x<t.x?s-a:s+a;const l=e.height/2,c=Math.abs(t.y-r.y),u=Math.abs(t.x-r.x);if(Math.abs(i-t.y)*s>Math.abs(n-t.x)*l){let h=r.y<t.y?t.y-l-i:i-l-t.y;o=u*h/c;const d={x:r.x<t.x?r.x+o:r.x-u+o,y:r.y<t.y?r.y+c-h:r.y-c+h};return o===0&&(d.x=t.x,d.y=t.y),u===0&&(d.x=t.x),c===0&&(d.y=t.y),he.debug(`abc89 top/bottom calc, Q ${c}, q ${h}, R ${u}, r ${o}`,d),d}else{r.x<t.x?o=t.x-s-n:o=n-s-t.x;let h=c*o/u,d=r.x<t.x?r.x+u-o:r.x-u+o,f=r.y<t.y?r.y+h:r.y-h;return he.debug(`sides calc abc89, Q ${c}, q ${h}, R ${u}, r ${o}`,{_x:d,_y:f}),o===0&&(d=t.x,f=t.y),u===0&&(d=t.x),c===0&&(f=t.y),{x:d,y:f}}},"intersection"),jx=k((e,t)=>{he.warn("abc88 cutPathAtIntersect",e,t);let r=[],n=e[0],i=!1;return e.forEach(a=>{if(he.info("abc88 checking point",a,t),!Yee(t,a)&&!i){const s=Vee(t,n,a);he.debug("abc88 inside",a,n,s),he.debug("abc88 intersection",s,t);let o=!1;r.forEach(l=>{o=o||l.x===s.x&&l.y===s.y}),r.some(l=>l.x===s.x&&l.y===s.y)?he.warn("abc88 no intersect",s,r):r.push(s),i=!0}else he.warn("abc88 outside",a,n),n=a,i||r.push(a)}),he.debug("returning points",r),r},"cutPathAtIntersect");function cS(e){const t=[],r=[];for(let n=1;n<e.length-1;n++){const i=e[n-1],a=e[n],s=e[n+1];(i.x===a.x&&a.y===s.y&&Math.abs(a.x-s.x)>5&&Math.abs(a.y-i.y)>5||i.y===a.y&&a.x===s.x&&Math.abs(a.x-i.x)>5&&Math.abs(a.y-s.y)>5)&&(t.push(a),r.push(n))}return{cornerPoints:t,cornerPointPositions:r}}k(cS,"extractCornerPoints");var Ux=k(function(e,t,r){const n=t.x-e.x,i=t.y-e.y,a=Math.sqrt(n*n+i*i),s=r/a;return{x:t.x-s*n,y:t.y-s*i}},"findAdjacentPoint"),Xee=k(function(e){const{cornerPointPositions:t}=cS(e),r=[];for(let n=0;n<e.length;n++)if(t.includes(n)){const i=e[n-1],a=e[n+1],s=e[n],o=Ux(i,s,5),l=Ux(a,s,5),c=l.x-o.x,u=l.y-o.y;r.push(o);const h=Math.sqrt(2)*2;let d={x:s.x,y:s.y};if(Math.abs(a.x-i.x)>10&&Math.abs(a.y-i.y)>=10){he.debug("Corner point fixing",Math.abs(a.x-i.x),Math.abs(a.y-i.y));const f=5;s.x===o.x?d={x:c<0?o.x-f+h:o.x+f-h,y:u<0?o.y-h:o.y+h}:d={x:c<0?o.x-h:o.x+h,y:u<0?o.y-f+h:o.y+f-h}}else he.debug("Corner point skipping fixing",Math.abs(a.x-i.x),Math.abs(a.y-i.y));r.push(d,l)}else r.push(e[n]);return r},"fixCorners"),Kee=k((e,t,r)=>{const n=e-t-r,i=2,a=2,s=i+a,o=Math.floor(n/s),l=Array(o).fill(`${i} ${a}`).join(" ");return`0 ${t} ${l} ${r}`},"generateDashArray"),uS=k(function(e,t,r,n,i,a,s,o=!1){const{handDrawnSeed:l}=Mt();let c=t.points,u=!1;const h=i;var d=a;const f=[];for(const $ in t.cssCompiledStyles)tg($)||f.push(t.cssCompiledStyles[$]);he.debug("UIO intersect check",t.points,d.x,h.x),d.intersect&&h.intersect&&!o&&(c=c.slice(1,t.points.length-1),c.unshift(h.intersect(c[0])),he.debug("Last point UIO",t.start,"-->",t.end,c[c.length-1],d,d.intersect(c[c.length-1])),c.push(d.intersect(c[c.length-1])));const p=btoa(JSON.stringify(c));t.toCluster&&(he.info("to cluster abc88",r.get(t.toCluster)),c=jx(t.points,r.get(t.toCluster).node),u=!0),t.fromCluster&&(he.debug("from cluster abc88",r.get(t.fromCluster),JSON.stringify(c,null,2)),c=jx(c.reverse(),r.get(t.fromCluster).node).reverse(),u=!0);let m=c.filter($=>!Number.isNaN($.y));m=Xee(m);let b=Bl;switch(b=y0,t.curve){case"linear":b=y0;break;case"basis":b=Bl;break;case"cardinal":b=kw;break;case"bumpX":b=gw;break;case"bumpY":b=bw;break;case"catmullRom":b=Tw;break;case"monotoneX":b=Nw;break;case"monotoneY":b=Lw;break;case"natural":b=Iw;break;case"step":b=Rw;break;case"stepAfter":b=Dw;break;case"stepBefore":b=Bw;break;default:b=Bl}const{x:y,y:v}=v8(t),T=pw().x(y).y(v).curve(b);let A;switch(t.thickness){case"normal":A="edge-thickness-normal";break;case"thick":A="edge-thickness-thick";break;case"invisible":A="edge-thickness-invisible";break;default:A="edge-thickness-normal"}switch(t.pattern){case"solid":A+=" edge-pattern-solid";break;case"dotted":A+=" edge-pattern-dotted";break;case"dashed":A+=" edge-pattern-dashed";break;default:A+=" edge-pattern-solid"}let E,S=t.curve==="rounded"?hS(dS(m,t),5):T(m);const I=Array.isArray(t.style)?t.style:[t.style];let D=I.find($=>$?.startsWith("stroke:")),H=!1;if(t.look==="handDrawn"){const $=Fe.svg(e);Object.assign([],m);const q=$.path(S,{roughness:.3,seed:l});A+=" transition",E=Ct(q).select("path").attr("id",t.id).attr("class"," "+A+(t.classes?" "+t.classes:"")).attr("style",I?I.reduce((Z,V)=>Z+";"+V,""):"");let W=E.attr("d");E.attr("d",W),e.node().appendChild(E.node())}else{const $=f.join(";"),q=I?I.reduce((ne,N)=>ne+N+";",""):"";let W="";t.animate&&(W=" edge-animation-fast"),t.animation&&(W=" edge-animation-"+t.animation);const Z=($?$+";"+q+";":q)+";"+(I?I.reduce((ne,N)=>ne+";"+N,""):"");E=e.append("path").attr("d",S).attr("id",t.id).attr("class"," "+A+(t.classes?" "+t.classes:"")+(W??"")).attr("style",Z),D=Z.match(/stroke:([^;]+)/)?.[1],H=t.animate===!0||!!t.animation||$.includes("animation");const V=E.node(),ve=typeof V.getTotalLength=="function"?V.getTotalLength():0,L=lx[t.arrowTypeStart]||0,ae=lx[t.arrowTypeEnd]||0;if(t.look==="neo"&&!H){const N=`stroke-dasharray: ${t.pattern==="dotted"||t.pattern==="dashed"?Kee(ve,L,ae):`0 ${L} ${ve-L-ae} ${ae}`}; stroke-dashoffset: 0;`;E.attr("style",N+E.attr("style"))}}E.attr("data-edge",!0),E.attr("data-et","edge"),E.attr("data-id",t.id),E.attr("data-points",p),t.showPoints&&m.forEach($=>{e.append("circle").style("stroke","red").style("fill","red").attr("r",1).attr("cx",$.x).attr("cy",$.y)});let R="";(Mt().flowchart.arrowMarkerAbsolute||Mt().state.arrowMarkerAbsolute)&&(R=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,R=R.replace(/\(/g,"\\(").replace(/\)/g,"\\)")),he.info("arrowTypeStart",t.arrowTypeStart),he.info("arrowTypeEnd",t.arrowTypeEnd),Uee(E,t,R,s,n,D);const F=Math.floor(c.length/2),G=c[F];_n.isLabelCoordinateInPath(G,E.attr("d"))||(u=!0);let ee={};return u&&(ee.updatedPath=c),ee.originalPath=t.points,ee},"insertEdge");function hS(e,t){if(e.length<2)return"";let r="";const n=e.length,i=1e-5;for(let a=0;a<n;a++){const s=e[a],o=e[a-1],l=e[a+1];if(a===0)r+=`M${s.x},${s.y}`;else if(a===n-1)r+=`L${s.x},${s.y}`;else{const c=s.x-o.x,u=s.y-o.y,h=l.x-s.x,d=l.y-s.y,f=Math.hypot(c,u),p=Math.hypot(h,d);if(f<i||p<i){r+=`L${s.x},${s.y}`;continue}const m=c/f,b=u/f,y=h/p,v=d/p,T=m*y+b*v,A=Math.max(-1,Math.min(1,T)),E=Math.acos(A);if(E<i||Math.abs(Math.PI-E)<i){r+=`L${s.x},${s.y}`;continue}const S=Math.min(t/Math.sin(E/2),f/2,p/2),I=s.x-m*S,D=s.y-b*S,H=s.x+y*S,R=s.y+v*S;r+=`L${I},${D}`,r+=`Q${s.x},${s.y} ${H},${R}`}}return r}k(hS,"generateRoundedPath");function rm(e,t){if(!e||!t)return{angle:0,deltaX:0,deltaY:0};const r=t.x-e.x,n=t.y-e.y;return{angle:Math.atan2(n,r),deltaX:r,deltaY:n}}k(rm,"calculateDeltaAndAngle");function dS(e,t){const r=e.map(i=>({...i}));if(e.length>=2&&Lr[t.arrowTypeStart]){const i=Lr[t.arrowTypeStart],a=e[0],s=e[1],{angle:o}=rm(a,s),l=i*Math.cos(o),c=i*Math.sin(o);r[0].x=a.x+l,r[0].y=a.y+c}const n=e.length;if(n>=2&&Lr[t.arrowTypeEnd]){const i=Lr[t.arrowTypeEnd],a=e[n-1],s=e[n-2],{angle:o}=rm(s,a),l=i*Math.cos(o),c=i*Math.sin(o);r[n-1].x=a.x-l,r[n-1].y=a.y-c}return r}k(dS,"applyMarkerOffsetsToPoints");var Qee=k((e,t,r,n)=>{t.forEach(i=>{fte[i](e,r,n)})},"insertMarkers"),Zee=k((e,t,r)=>{he.trace("Making markers for ",r),e.append("defs").append("marker").attr("id",r+"_"+t+"-extensionStart").attr("class","marker extension "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 1,7 L18,13 V 1 Z"),e.append("defs").append("marker").attr("id",r+"_"+t+"-extensionEnd").attr("class","marker extension "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 1,1 V 13 L18,7 Z")},"extension"),Jee=k((e,t,r)=>{e.append("defs").append("marker").attr("id",r+"_"+t+"-compositionStart").attr("class","marker composition "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),e.append("defs").append("marker").attr("id",r+"_"+t+"-compositionEnd").attr("class","marker composition "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},"composition"),ete=k((e,t,r)=>{e.append("defs").append("marker").attr("id",r+"_"+t+"-aggregationStart").attr("class","marker aggregation "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),e.append("defs").append("marker").attr("id",r+"_"+t+"-aggregationEnd").attr("class","marker aggregation "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},"aggregation"),tte=k((e,t,r)=>{e.append("defs").append("marker").attr("id",r+"_"+t+"-dependencyStart").attr("class","marker dependency "+t).attr("refX",6).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 5,7 L9,13 L1,7 L9,1 Z"),e.append("defs").append("marker").attr("id",r+"_"+t+"-dependencyEnd").attr("class","marker dependency "+t).attr("refX",13).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L14,7 L9,1 Z")},"dependency"),rte=k((e,t,r)=>{e.append("defs").append("marker").attr("id",r+"_"+t+"-lollipopStart").attr("class","marker lollipop "+t).attr("refX",13).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("stroke","black").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6),e.append("defs").append("marker").attr("id",r+"_"+t+"-lollipopEnd").attr("class","marker lollipop "+t).attr("refX",1).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("stroke","black").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6)},"lollipop"),nte=k((e,t,r)=>{e.append("marker").attr("id",r+"_"+t+"-pointEnd").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",8).attr("markerHeight",8).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),e.append("marker").attr("id",r+"_"+t+"-pointStart").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",4.5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",8).attr("markerHeight",8).attr("orient","auto").append("path").attr("d","M 0 5 L 10 10 L 10 0 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},"point"),ite=k((e,t,r)=>{e.append("marker").attr("id",r+"_"+t+"-circleEnd").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",11).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),e.append("marker").attr("id",r+"_"+t+"-circleStart").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",-1).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},"circle"),ate=k((e,t,r)=>{e.append("marker").attr("id",r+"_"+t+"-crossEnd").attr("class","marker cross "+t).attr("viewBox","0 0 11 11").attr("refX",12).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0"),e.append("marker").attr("id",r+"_"+t+"-crossStart").attr("class","marker cross "+t).attr("viewBox","0 0 11 11").attr("refX",-1).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0")},"cross"),ste=k((e,t,r)=>{e.append("defs").append("marker").attr("id",r+"_"+t+"-barbEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",14).attr("markerUnits","userSpaceOnUse").attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},"barb"),ote=k((e,t,r)=>{e.append("defs").append("marker").attr("id",r+"_"+t+"-onlyOneStart").attr("class","marker onlyOne "+t).attr("refX",0).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("d","M9,0 L9,18 M15,0 L15,18"),e.append("defs").append("marker").attr("id",r+"_"+t+"-onlyOneEnd").attr("class","marker onlyOne "+t).attr("refX",18).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("d","M3,0 L3,18 M9,0 L9,18")},"only_one"),lte=k((e,t,r)=>{const n=e.append("defs").append("marker").attr("id",r+"_"+t+"-zeroOrOneStart").attr("class","marker zeroOrOne "+t).attr("refX",0).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto");n.append("circle").attr("fill","white").attr("cx",21).attr("cy",9).attr("r",6),n.append("path").attr("d","M9,0 L9,18");const i=e.append("defs").append("marker").attr("id",r+"_"+t+"-zeroOrOneEnd").attr("class","marker zeroOrOne "+t).attr("refX",30).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto");i.append("circle").attr("fill","white").attr("cx",9).attr("cy",9).attr("r",6),i.append("path").attr("d","M21,0 L21,18")},"zero_or_one"),cte=k((e,t,r)=>{e.append("defs").append("marker").attr("id",r+"_"+t+"-oneOrMoreStart").attr("class","marker oneOrMore "+t).attr("refX",18).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("d","M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27"),e.append("defs").append("marker").attr("id",r+"_"+t+"-oneOrMoreEnd").attr("class","marker oneOrMore "+t).attr("refX",27).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("d","M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18")},"one_or_more"),ute=k((e,t,r)=>{const n=e.append("defs").append("marker").attr("id",r+"_"+t+"-zeroOrMoreStart").attr("class","marker zeroOrMore "+t).attr("refX",18).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto");n.append("circle").attr("fill","white").attr("cx",48).attr("cy",18).attr("r",6),n.append("path").attr("d","M0,18 Q18,0 36,18 Q18,36 0,18");const i=e.append("defs").append("marker").attr("id",r+"_"+t+"-zeroOrMoreEnd").attr("class","marker zeroOrMore "+t).attr("refX",39).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto");i.append("circle").attr("fill","white").attr("cx",9).attr("cy",18).attr("r",6),i.append("path").attr("d","M21,18 Q39,0 57,18 Q39,36 21,18")},"zero_or_more"),hte=k((e,t,r)=>{e.append("defs").append("marker").attr("id",r+"_"+t+"-requirement_arrowEnd").attr("refX",20).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("path").attr("d",`M0,0
627
627
  L20,10
628
628
  M20,10
629
- L0,20`)},"requirement_arrow"),dte=k((e,t,r)=>{const n=e.append("defs").append("marker").attr("id",r+"_"+t+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");n.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),n.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),n.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),fte={extension:Zee,composition:Jee,aggregation:ete,dependency:tte,lollipop:rte,point:nte,circle:ite,cross:ate,barb:ste,only_one:ote,zero_or_one:lte,one_or_more:cte,zero_or_more:ute,requirement_arrow:hte,requirement_contains:dte},fS=Qee,pte={common:hs,getConfig:Cr,insertCluster:q7,insertEdge:uS,insertEdgeLabel:oS,insertMarkers:fS,insertNode:Ng,interpolateToCurve:og,labelHelper:it,log:he,positionEdgeLabel:lS},sc={},pS=k(e=>{for(const t of e)sc[t.name]=t},"registerLayoutLoaders"),mte=k(()=>{pS([{name:"dagre",loader:k(async()=>await Promise.resolve().then(()=>require("./dagre-6UL2VRFP-r_ADTb0O.js")),"loader")},{name:"cose-bilkent",loader:k(async()=>await Promise.resolve().then(()=>require("./cose-bilkent-S5V4N54A-CPJoKUiO.js")),"loader")}])},"registerDefaultLayoutLoaders");mte();var gte=k(async(e,t)=>{if(!(e.layoutAlgorithm in sc))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);const r=sc[e.layoutAlgorithm];return(await r.loader()).render(e,t,pte,{algorithm:r.algorithm})},"render"),bte=k((e="",{fallback:t="dagre"}={})=>{if(e in sc)return e;if(t in sc)return he.warn(`Layout algorithm ${e} is not registered. Using ${t} as fallback.`),t;throw new Error(`Both layout algorithms ${e} and ${t} are not registered.`)},"getRegisteredLayoutAlgorithm"),mS="comm",gS="rule",bS="decl",yte="@import",xte="@namespace",vte="@keyframes",kte="@layer",yS=Math.abs,Lg=String.fromCharCode;function xS(e){return e.trim()}function Nu(e,t,r){return e.replace(t,r)}function wte(e,t,r){return e.indexOf(t,r)}function zs(e,t){return e.charCodeAt(t)|0}function lo(e,t,r){return e.slice(t,r)}function ei(e){return e.length}function Tte(e){return e.length}function uu(e,t){return t.push(e),e}var Vh=1,co=1,vS=0,In=0,ir=0,Lo="";function Mg(e,t,r,n,i,a,s,o){return{value:e,root:t,parent:r,type:n,props:i,children:a,line:Vh,column:co,length:s,return:"",siblings:o}}function Cte(){return ir}function Ste(){return ir=In>0?zs(Lo,--In):0,co--,ir===10&&(co=1,Vh--),ir}function qn(){return ir=In<vS?zs(Lo,In++):0,co++,ir===10&&(co=1,Vh++),ir}function ca(){return zs(Lo,In)}function Lu(){return In}function Xh(e,t){return lo(Lo,e,t)}function oc(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Ete(e){return Vh=co=1,vS=ei(Lo=e),In=0,[]}function _te(e){return Lo="",e}function ff(e){return xS(Xh(In-1,nm(e===91?e+2:e===40?e+1:e)))}function Ate(e){for(;(ir=ca())&&ir<33;)qn();return oc(e)>2||oc(ir)>3?"":" "}function Nte(e,t){for(;--t&&qn()&&!(ir<48||ir>102||ir>57&&ir<65||ir>70&&ir<97););return Xh(e,Lu()+(t<6&&ca()==32&&qn()==32))}function nm(e){for(;qn();)switch(ir){case e:return In;case 34:case 39:e!==34&&e!==39&&nm(ir);break;case 40:e===41&&nm(e);break;case 92:qn();break}return In}function Lte(e,t){for(;qn()&&e+ir!==57;)if(e+ir===84&&ca()===47)break;return"/*"+Xh(t,In-1)+"*"+Lg(e===47?e:qn())}function Mte(e){for(;!oc(ca());)qn();return Xh(e,In)}function Ite(e){return _te(Mu("",null,null,null,[""],e=Ete(e),0,[0],e))}function Mu(e,t,r,n,i,a,s,o,l){for(var c=0,u=0,h=s,d=0,f=0,p=0,m=1,b=1,y=1,v=0,T="",A=i,E=a,S=n,I=T;b;)switch(p=v,v=qn()){case 40:if(p!=108&&zs(I,h-1)==58){wte(I+=Nu(ff(v),"&","&\f"),"&\f",yS(c?o[c-1]:0))!=-1&&(y=-1);break}case 34:case 39:case 91:I+=ff(v);break;case 9:case 10:case 13:case 32:I+=Ate(p);break;case 92:I+=Nte(Lu()-1,7);continue;case 47:switch(ca()){case 42:case 47:uu(Rte(Lte(qn(),Lu()),t,r,l),l),(oc(p||1)==5||oc(ca()||1)==5)&&ei(I)&&lo(I,-1,void 0)!==" "&&(I+=" ");break;default:I+="/"}break;case 123*m:o[c++]=ei(I)*y;case 125*m:case 59:case 0:switch(v){case 0:case 125:b=0;case 59+u:y==-1&&(I=Nu(I,/\f/g,"")),f>0&&(ei(I)-h||m===0&&p===47)&&uu(f>32?Gx(I+";",n,r,h-1,l):Gx(Nu(I," ","")+";",n,r,h-2,l),l);break;case 59:I+=";";default:if(uu(S=Wx(I,t,r,c,u,i,o,T,A=[],E=[],h,a),a),v===123)if(u===0)Mu(I,t,S,S,A,a,h,o,E);else{switch(d){case 99:if(zs(I,3)===110)break;case 108:if(zs(I,2)===97)break;default:u=0;case 100:case 109:case 115:}u?Mu(e,S,S,n&&uu(Wx(e,S,S,0,0,i,o,T,i,A=[],h,E),E),i,E,h,o,n?A:E):Mu(I,S,S,S,[""],E,0,o,E)}}c=u=f=0,m=y=1,T=I="",h=s;break;case 58:h=1+ei(I),f=p;default:if(m<1){if(v==123)--m;else if(v==125&&m++==0&&Ste()==125)continue}switch(I+=Lg(v),v*m){case 38:y=u>0?1:(I+="\f",-1);break;case 44:o[c++]=(ei(I)-1)*y,y=1;break;case 64:ca()===45&&(I+=ff(qn())),d=ca(),u=h=ei(T=I+=Mte(Lu())),v++;break;case 45:p===45&&ei(I)==2&&(m=0)}}return a}function Wx(e,t,r,n,i,a,s,o,l,c,u,h){for(var d=i-1,f=i===0?a:[""],p=Tte(f),m=0,b=0,y=0;m<n;++m)for(var v=0,T=lo(e,d+1,d=yS(b=s[m])),A=e;v<p;++v)(A=xS(b>0?f[v]+" "+T:Nu(T,/&\f/g,f[v])))&&(l[y++]=A);return Mg(e,t,r,i===0?gS:o,l,c,u,h)}function Rte(e,t,r,n){return Mg(e,t,r,mS,Lg(Cte()),lo(e,2,-2),0,n)}function Gx(e,t,r,n,i){return Mg(e,t,r,bS,lo(e,0,n),lo(e,n+1,-1),n,i)}function im(e,t){for(var r="",n=0;n<e.length;n++)r+=t(e[n],n,e,t)||"";return r}function Bte(e,t,r,n){switch(e.type){case kte:if(e.children.length)break;case yte:case xte:case bS:return e.return=e.return||e.value;case mS:return"";case vte:return e.return=e.value+"{"+im(e.children,n)+"}";case gS:if(!ei(e.value=e.props.join(",")))return""}return ei(r=im(e.children,n))?e.return=e.value+"{"+r+"}":""}var Dte=L8(Object.keys,Object),Ote=Object.prototype,Pte=Ote.hasOwnProperty;function kS(e){if(!Ph(e))return Dte(e);var t=[];for(var r in Object(e))Pte.call(e,r)&&r!="constructor"&&t.push(r);return t}var am=ps(bi,"DataView"),sm=ps(bi,"Promise"),$0=ps(bi,"Set"),om=ps(bi,"WeakMap"),Yx="[object Map]",Fte="[object Object]",Vx="[object Promise]",Xx="[object Set]",Kx="[object WeakMap]",Qx="[object DataView]",$te=fs(am),zte=fs(rc),Hte=fs(sm),qte=fs($0),jte=fs(om);exports.getTag=ds;(am&&exports.getTag(new am(new ArrayBuffer(1)))!=Qx||rc&&exports.getTag(new rc)!=Yx||sm&&exports.getTag(sm.resolve())!=Vx||$0&&exports.getTag(new $0)!=Xx||om&&exports.getTag(new om)!=Kx)&&(exports.getTag=function(e){var t=ds(e),r=t==Fte?e.constructor:void 0,n=r?fs(r):"";if(n)switch(n){case $te:return Qx;case zte:return Yx;case Hte:return Vx;case qte:return Xx;case jte:return Kx}return t});var Ute="[object Map]",Wte="[object Set]",Gte=Object.prototype,Yte=Gte.hasOwnProperty;function lm(e){if(e==null)return!0;if(Cc(e)&&(ic(e)||typeof e=="string"||typeof e.splice=="function"||Fh(e)||$h(e)||nc(e)))return!e.length;var t=exports.getTag(e);if(t==Ute||t==Wte)return!e.size;if(Ph(e))return!kS(e).length;for(var r in e)if(Yte.call(e,r))return!1;return!0}var wS="c4",Vte=k(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),Xte=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./c4Diagram-YG6GDRKO-DLoBqiir.js"));return{id:wS,diagram:e}},"loader"),Kte={id:wS,detector:Vte,loader:Xte},Qte=Kte,TS="flowchart",Zte=k((e,t)=>t?.flowchart?.defaultRenderer==="dagre-wrapper"||t?.flowchart?.defaultRenderer==="elk"?!1:/^\s*graph/.test(e),"detector"),Jte=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./flowDiagram-NV44I4VS-BAdaW0zG.js"));return{id:TS,diagram:e}},"loader"),ere={id:TS,detector:Zte,loader:Jte},tre=ere,CS="flowchart-v2",rre=k((e,t)=>t?.flowchart?.defaultRenderer==="dagre-d3"?!1:(t?.flowchart?.defaultRenderer==="elk"&&(t.layout="elk"),/^\s*graph/.test(e)&&t?.flowchart?.defaultRenderer==="dagre-wrapper"?!0:/^\s*flowchart/.test(e)),"detector"),nre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./flowDiagram-NV44I4VS-BAdaW0zG.js"));return{id:CS,diagram:e}},"loader"),ire={id:CS,detector:rre,loader:nre},are=ire,SS="er",sre=k(e=>/^\s*erDiagram/.test(e),"detector"),ore=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./erDiagram-Q2GNP2WA-k7niLq9H.js"));return{id:SS,diagram:e}},"loader"),lre={id:SS,detector:sre,loader:ore},cre=lre,ES="gitGraph",ure=k(e=>/^\s*gitGraph/.test(e),"detector"),hre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./gitGraphDiagram-NY62KEGX-C980oVrU.js"));return{id:ES,diagram:e}},"loader"),dre={id:ES,detector:ure,loader:hre},fre=dre,_S="gantt",pre=k(e=>/^\s*gantt/.test(e),"detector"),mre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./ganttDiagram-JELNMOA3-CddDOxeO.js"));return{id:_S,diagram:e}},"loader"),gre={id:_S,detector:pre,loader:mre},bre=gre,AS="info",yre=k(e=>/^\s*info/.test(e),"detector"),xre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./infoDiagram-WHAUD3N6-DwsUlSxN.js"));return{id:AS,diagram:e}},"loader"),vre={id:AS,detector:yre,loader:xre},NS="pie",kre=k(e=>/^\s*pie/.test(e),"detector"),wre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./pieDiagram-ADFJNKIX-BlNrJLdh.js"));return{id:NS,diagram:e}},"loader"),Tre={id:NS,detector:kre,loader:wre},LS="quadrantChart",Cre=k(e=>/^\s*quadrantChart/.test(e),"detector"),Sre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./quadrantDiagram-AYHSOK5B-fy7-bMNk.js"));return{id:LS,diagram:e}},"loader"),Ere={id:LS,detector:Cre,loader:Sre},_re=Ere,MS="xychart",Are=k(e=>/^\s*xychart(-beta)?/.test(e),"detector"),Nre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./xychartDiagram-PRI3JC2R-Bi02nVw4.js"));return{id:MS,diagram:e}},"loader"),Lre={id:MS,detector:Are,loader:Nre},Mre=Lre,IS="requirement",Ire=k(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),Rre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./requirementDiagram-UZGBJVZJ-CGgt75Rl.js"));return{id:IS,diagram:e}},"loader"),Bre={id:IS,detector:Ire,loader:Rre},Dre=Bre,RS="sequence",Ore=k(e=>/^\s*sequenceDiagram/.test(e),"detector"),Pre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./sequenceDiagram-WL72ISMW-nlFlEmNQ.js"));return{id:RS,diagram:e}},"loader"),Fre={id:RS,detector:Ore,loader:Pre},$re=Fre,BS="class",zre=k((e,t)=>t?.class?.defaultRenderer==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e),"detector"),Hre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./classDiagram-2ON5EDUG-uOMmrtgR.js"));return{id:BS,diagram:e}},"loader"),qre={id:BS,detector:zre,loader:Hre},jre=qre,DS="classDiagram",Ure=k((e,t)=>/^\s*classDiagram/.test(e)&&t?.class?.defaultRenderer==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e),"detector"),Wre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./classDiagram-v2-WZHVMYZB-uOMmrtgR.js"));return{id:DS,diagram:e}},"loader"),Gre={id:DS,detector:Ure,loader:Wre},Yre=Gre,OS="state",Vre=k((e,t)=>t?.state?.defaultRenderer==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e),"detector"),Xre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./stateDiagram-FKZM4ZOC-C9DXFs3P.js"));return{id:OS,diagram:e}},"loader"),Kre={id:OS,detector:Vre,loader:Xre},Qre=Kre,PS="stateDiagram",Zre=k((e,t)=>!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&t?.state?.defaultRenderer==="dagre-wrapper"),"detector"),Jre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./stateDiagram-v2-4FDKWEC3-FoEBCoPy.js"));return{id:PS,diagram:e}},"loader"),ene={id:PS,detector:Zre,loader:Jre},tne=ene,FS="journey",rne=k(e=>/^\s*journey/.test(e),"detector"),nne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./journeyDiagram-XKPGCS4Q-7k1g8rPF.js"));return{id:FS,diagram:e}},"loader"),ine={id:FS,detector:rne,loader:nne},ane=ine,sne=k((e,t,r)=>{he.debug(`rendering svg for syntax error
630
- `);const n=Ow(t),i=n.append("g");n.attr("viewBox","0 0 2412 512"),L1(n,100,512,!0),i.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),i.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),i.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),i.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),i.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),i.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),i.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),i.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${r}`)},"draw"),$S={draw:sne},one=$S,lne={db:{},renderer:$S,parser:{parse:k(()=>{},"parse")}},cne=lne,zS="flowchart-elk",une=k((e,t={})=>/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&t?.flowchart?.defaultRenderer==="elk"?(t.layout="elk",!0):!1,"detector"),hne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./flowDiagram-NV44I4VS-BAdaW0zG.js"));return{id:zS,diagram:e}},"loader"),dne={id:zS,detector:une,loader:hne},fne=dne,HS="timeline",pne=k(e=>/^\s*timeline/.test(e),"detector"),mne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./timeline-definition-IT6M3QCI-BqUt3ka4.js"));return{id:HS,diagram:e}},"loader"),gne={id:HS,detector:pne,loader:mne},bne=gne,qS="mindmap",yne=k(e=>/^\s*mindmap/.test(e),"detector"),xne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./mindmap-definition-VGOIOE7T-d8uGKtHO.js"));return{id:qS,diagram:e}},"loader"),vne={id:qS,detector:yne,loader:xne},kne=vne,jS="kanban",wne=k(e=>/^\s*kanban/.test(e),"detector"),Tne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./kanban-definition-3W4ZIXB7-Cqf7XpzW.js"));return{id:jS,diagram:e}},"loader"),Cne={id:jS,detector:wne,loader:Tne},Sne=Cne,US="sankey",Ene=k(e=>/^\s*sankey(-beta)?/.test(e),"detector"),_ne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./sankeyDiagram-TZEHDZUN-q-r70ybp.js"));return{id:US,diagram:e}},"loader"),Ane={id:US,detector:Ene,loader:_ne},Nne=Ane,WS="packet",Lne=k(e=>/^\s*packet(-beta)?/.test(e),"detector"),Mne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./diagram-S2PKOQOG-B0W-tWPV.js"));return{id:WS,diagram:e}},"loader"),Ine={id:WS,detector:Lne,loader:Mne},GS="radar",Rne=k(e=>/^\s*radar-beta/.test(e),"detector"),Bne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./diagram-QEK2KX5R-B5Lo9E-s.js"));return{id:GS,diagram:e}},"loader"),Dne={id:GS,detector:Rne,loader:Bne},YS="block",One=k(e=>/^\s*block(-beta)?/.test(e),"detector"),Pne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./blockDiagram-VD42YOAC-Cws7af6P.js"));return{id:YS,diagram:e}},"loader"),Fne={id:YS,detector:One,loader:Pne},$ne=Fne,VS="architecture",zne=k(e=>/^\s*architecture/.test(e),"detector"),Hne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./architectureDiagram-VXUJARFQ-LwDhoqXa.js"));return{id:VS,diagram:e}},"loader"),qne={id:VS,detector:zne,loader:Hne},jne=qne,XS="treemap",Une=k(e=>/^\s*treemap/.test(e),"detector"),Wne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./diagram-PSM6KHXK-CuHqLGUt.js"));return{id:XS,diagram:e}},"loader"),Gne={id:XS,detector:Une,loader:Wne},Zx=!1,Kh=k(()=>{Zx||(Zx=!0,h0("error",cne,e=>e.toLowerCase().trim()==="error"),h0("---",{db:{clear:k(()=>{},"clear")},styles:{},renderer:{draw:k(()=>{},"draw")},parser:{parse:k(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:k(()=>null,"init")},e=>e.toLowerCase().trimStart().startsWith("---")),cp(fne,kne,jne),cp(Qte,Sne,Yre,jre,cre,bre,vre,Tre,Dre,$re,are,tre,bne,fre,tne,Qre,ane,_re,Nne,Ine,Mre,$ne,Dne,Gne))},"addDiagrams"),Yne=k(async()=>{he.debug("Loading registered diagrams");const t=(await Promise.allSettled(Object.entries(Qa).map(async([r,{detector:n,loader:i}])=>{if(i)try{pp(r)}catch{try{const{diagram:a,id:s}=await i();h0(s,a,n)}catch(a){throw he.error(`Failed to load external diagram with key ${r}. Removing from detectors.`),delete Qa[r],a}}}))).filter(r=>r.status==="rejected");if(t.length>0){he.error(`Failed to load ${t.length} external diagrams`);for(const r of t)he.error(r);throw new Error(`Failed to load ${t.length} external diagrams`)}},"loadRegisteredDiagrams"),Vne="graphics-document document";function KS(e,t){e.attr("role",Vne),t!==""&&e.attr("aria-roledescription",t)}k(KS,"setA11yDiagramInfo");function QS(e,t,r,n){if(e.insert!==void 0){if(r){const i=`chart-desc-${n}`;e.attr("aria-describedby",i),e.insert("desc",":first-child").attr("id",i).text(r)}if(t){const i=`chart-title-${n}`;e.attr("aria-labelledby",i),e.insert("title",":first-child").attr("id",i).text(t)}}}k(QS,"addSVGa11yTitleDescription");var Ga,cm=(Ga=class{constructor(t,r,n,i,a){this.type=t,this.text=r,this.db=n,this.parser=i,this.renderer=a}static async fromText(t,r={}){const n=Cr(),i=A1(t,n);t=VZ(t)+`
629
+ L0,20`)},"requirement_arrow"),dte=k((e,t,r)=>{const n=e.append("defs").append("marker").attr("id",r+"_"+t+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");n.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),n.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),n.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),fte={extension:Zee,composition:Jee,aggregation:ete,dependency:tte,lollipop:rte,point:nte,circle:ite,cross:ate,barb:ste,only_one:ote,zero_or_one:lte,one_or_more:cte,zero_or_more:ute,requirement_arrow:hte,requirement_contains:dte},fS=Qee,pte={common:hs,getConfig:Cr,insertCluster:q7,insertEdge:uS,insertEdgeLabel:oS,insertMarkers:fS,insertNode:Ng,interpolateToCurve:og,labelHelper:it,log:he,positionEdgeLabel:lS},sc={},pS=k(e=>{for(const t of e)sc[t.name]=t},"registerLayoutLoaders"),mte=k(()=>{pS([{name:"dagre",loader:k(async()=>await Promise.resolve().then(()=>require("./dagre-6UL2VRFP-DEQXyXKh.js")),"loader")},{name:"cose-bilkent",loader:k(async()=>await Promise.resolve().then(()=>require("./cose-bilkent-S5V4N54A-1B77PywG.js")),"loader")}])},"registerDefaultLayoutLoaders");mte();var gte=k(async(e,t)=>{if(!(e.layoutAlgorithm in sc))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);const r=sc[e.layoutAlgorithm];return(await r.loader()).render(e,t,pte,{algorithm:r.algorithm})},"render"),bte=k((e="",{fallback:t="dagre"}={})=>{if(e in sc)return e;if(t in sc)return he.warn(`Layout algorithm ${e} is not registered. Using ${t} as fallback.`),t;throw new Error(`Both layout algorithms ${e} and ${t} are not registered.`)},"getRegisteredLayoutAlgorithm"),mS="comm",gS="rule",bS="decl",yte="@import",xte="@namespace",vte="@keyframes",kte="@layer",yS=Math.abs,Lg=String.fromCharCode;function xS(e){return e.trim()}function Nu(e,t,r){return e.replace(t,r)}function wte(e,t,r){return e.indexOf(t,r)}function zs(e,t){return e.charCodeAt(t)|0}function lo(e,t,r){return e.slice(t,r)}function ei(e){return e.length}function Tte(e){return e.length}function uu(e,t){return t.push(e),e}var Vh=1,co=1,vS=0,In=0,ir=0,Lo="";function Mg(e,t,r,n,i,a,s,o){return{value:e,root:t,parent:r,type:n,props:i,children:a,line:Vh,column:co,length:s,return:"",siblings:o}}function Cte(){return ir}function Ste(){return ir=In>0?zs(Lo,--In):0,co--,ir===10&&(co=1,Vh--),ir}function qn(){return ir=In<vS?zs(Lo,In++):0,co++,ir===10&&(co=1,Vh++),ir}function ca(){return zs(Lo,In)}function Lu(){return In}function Xh(e,t){return lo(Lo,e,t)}function oc(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Ete(e){return Vh=co=1,vS=ei(Lo=e),In=0,[]}function _te(e){return Lo="",e}function ff(e){return xS(Xh(In-1,nm(e===91?e+2:e===40?e+1:e)))}function Ate(e){for(;(ir=ca())&&ir<33;)qn();return oc(e)>2||oc(ir)>3?"":" "}function Nte(e,t){for(;--t&&qn()&&!(ir<48||ir>102||ir>57&&ir<65||ir>70&&ir<97););return Xh(e,Lu()+(t<6&&ca()==32&&qn()==32))}function nm(e){for(;qn();)switch(ir){case e:return In;case 34:case 39:e!==34&&e!==39&&nm(ir);break;case 40:e===41&&nm(e);break;case 92:qn();break}return In}function Lte(e,t){for(;qn()&&e+ir!==57;)if(e+ir===84&&ca()===47)break;return"/*"+Xh(t,In-1)+"*"+Lg(e===47?e:qn())}function Mte(e){for(;!oc(ca());)qn();return Xh(e,In)}function Ite(e){return _te(Mu("",null,null,null,[""],e=Ete(e),0,[0],e))}function Mu(e,t,r,n,i,a,s,o,l){for(var c=0,u=0,h=s,d=0,f=0,p=0,m=1,b=1,y=1,v=0,T="",A=i,E=a,S=n,I=T;b;)switch(p=v,v=qn()){case 40:if(p!=108&&zs(I,h-1)==58){wte(I+=Nu(ff(v),"&","&\f"),"&\f",yS(c?o[c-1]:0))!=-1&&(y=-1);break}case 34:case 39:case 91:I+=ff(v);break;case 9:case 10:case 13:case 32:I+=Ate(p);break;case 92:I+=Nte(Lu()-1,7);continue;case 47:switch(ca()){case 42:case 47:uu(Rte(Lte(qn(),Lu()),t,r,l),l),(oc(p||1)==5||oc(ca()||1)==5)&&ei(I)&&lo(I,-1,void 0)!==" "&&(I+=" ");break;default:I+="/"}break;case 123*m:o[c++]=ei(I)*y;case 125*m:case 59:case 0:switch(v){case 0:case 125:b=0;case 59+u:y==-1&&(I=Nu(I,/\f/g,"")),f>0&&(ei(I)-h||m===0&&p===47)&&uu(f>32?Gx(I+";",n,r,h-1,l):Gx(Nu(I," ","")+";",n,r,h-2,l),l);break;case 59:I+=";";default:if(uu(S=Wx(I,t,r,c,u,i,o,T,A=[],E=[],h,a),a),v===123)if(u===0)Mu(I,t,S,S,A,a,h,o,E);else{switch(d){case 99:if(zs(I,3)===110)break;case 108:if(zs(I,2)===97)break;default:u=0;case 100:case 109:case 115:}u?Mu(e,S,S,n&&uu(Wx(e,S,S,0,0,i,o,T,i,A=[],h,E),E),i,E,h,o,n?A:E):Mu(I,S,S,S,[""],E,0,o,E)}}c=u=f=0,m=y=1,T=I="",h=s;break;case 58:h=1+ei(I),f=p;default:if(m<1){if(v==123)--m;else if(v==125&&m++==0&&Ste()==125)continue}switch(I+=Lg(v),v*m){case 38:y=u>0?1:(I+="\f",-1);break;case 44:o[c++]=(ei(I)-1)*y,y=1;break;case 64:ca()===45&&(I+=ff(qn())),d=ca(),u=h=ei(T=I+=Mte(Lu())),v++;break;case 45:p===45&&ei(I)==2&&(m=0)}}return a}function Wx(e,t,r,n,i,a,s,o,l,c,u,h){for(var d=i-1,f=i===0?a:[""],p=Tte(f),m=0,b=0,y=0;m<n;++m)for(var v=0,T=lo(e,d+1,d=yS(b=s[m])),A=e;v<p;++v)(A=xS(b>0?f[v]+" "+T:Nu(T,/&\f/g,f[v])))&&(l[y++]=A);return Mg(e,t,r,i===0?gS:o,l,c,u,h)}function Rte(e,t,r,n){return Mg(e,t,r,mS,Lg(Cte()),lo(e,2,-2),0,n)}function Gx(e,t,r,n,i){return Mg(e,t,r,bS,lo(e,0,n),lo(e,n+1,-1),n,i)}function im(e,t){for(var r="",n=0;n<e.length;n++)r+=t(e[n],n,e,t)||"";return r}function Bte(e,t,r,n){switch(e.type){case kte:if(e.children.length)break;case yte:case xte:case bS:return e.return=e.return||e.value;case mS:return"";case vte:return e.return=e.value+"{"+im(e.children,n)+"}";case gS:if(!ei(e.value=e.props.join(",")))return""}return ei(r=im(e.children,n))?e.return=e.value+"{"+r+"}":""}var Dte=L8(Object.keys,Object),Ote=Object.prototype,Pte=Ote.hasOwnProperty;function kS(e){if(!Ph(e))return Dte(e);var t=[];for(var r in Object(e))Pte.call(e,r)&&r!="constructor"&&t.push(r);return t}var am=ps(bi,"DataView"),sm=ps(bi,"Promise"),$0=ps(bi,"Set"),om=ps(bi,"WeakMap"),Yx="[object Map]",Fte="[object Object]",Vx="[object Promise]",Xx="[object Set]",Kx="[object WeakMap]",Qx="[object DataView]",$te=fs(am),zte=fs(rc),Hte=fs(sm),qte=fs($0),jte=fs(om);exports.getTag=ds;(am&&exports.getTag(new am(new ArrayBuffer(1)))!=Qx||rc&&exports.getTag(new rc)!=Yx||sm&&exports.getTag(sm.resolve())!=Vx||$0&&exports.getTag(new $0)!=Xx||om&&exports.getTag(new om)!=Kx)&&(exports.getTag=function(e){var t=ds(e),r=t==Fte?e.constructor:void 0,n=r?fs(r):"";if(n)switch(n){case $te:return Qx;case zte:return Yx;case Hte:return Vx;case qte:return Xx;case jte:return Kx}return t});var Ute="[object Map]",Wte="[object Set]",Gte=Object.prototype,Yte=Gte.hasOwnProperty;function lm(e){if(e==null)return!0;if(Cc(e)&&(ic(e)||typeof e=="string"||typeof e.splice=="function"||Fh(e)||$h(e)||nc(e)))return!e.length;var t=exports.getTag(e);if(t==Ute||t==Wte)return!e.size;if(Ph(e))return!kS(e).length;for(var r in e)if(Yte.call(e,r))return!1;return!0}var wS="c4",Vte=k(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),Xte=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./c4Diagram-YG6GDRKO-CMXx6pyB.js"));return{id:wS,diagram:e}},"loader"),Kte={id:wS,detector:Vte,loader:Xte},Qte=Kte,TS="flowchart",Zte=k((e,t)=>t?.flowchart?.defaultRenderer==="dagre-wrapper"||t?.flowchart?.defaultRenderer==="elk"?!1:/^\s*graph/.test(e),"detector"),Jte=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./flowDiagram-NV44I4VS-BChiRwcp.js"));return{id:TS,diagram:e}},"loader"),ere={id:TS,detector:Zte,loader:Jte},tre=ere,CS="flowchart-v2",rre=k((e,t)=>t?.flowchart?.defaultRenderer==="dagre-d3"?!1:(t?.flowchart?.defaultRenderer==="elk"&&(t.layout="elk"),/^\s*graph/.test(e)&&t?.flowchart?.defaultRenderer==="dagre-wrapper"?!0:/^\s*flowchart/.test(e)),"detector"),nre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./flowDiagram-NV44I4VS-BChiRwcp.js"));return{id:CS,diagram:e}},"loader"),ire={id:CS,detector:rre,loader:nre},are=ire,SS="er",sre=k(e=>/^\s*erDiagram/.test(e),"detector"),ore=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./erDiagram-Q2GNP2WA-AS2vnQKc.js"));return{id:SS,diagram:e}},"loader"),lre={id:SS,detector:sre,loader:ore},cre=lre,ES="gitGraph",ure=k(e=>/^\s*gitGraph/.test(e),"detector"),hre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./gitGraphDiagram-NY62KEGX-Cm9ywQoW.js"));return{id:ES,diagram:e}},"loader"),dre={id:ES,detector:ure,loader:hre},fre=dre,_S="gantt",pre=k(e=>/^\s*gantt/.test(e),"detector"),mre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./ganttDiagram-JELNMOA3-BGy1b6TD.js"));return{id:_S,diagram:e}},"loader"),gre={id:_S,detector:pre,loader:mre},bre=gre,AS="info",yre=k(e=>/^\s*info/.test(e),"detector"),xre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./infoDiagram-WHAUD3N6-q-yX3_By.js"));return{id:AS,diagram:e}},"loader"),vre={id:AS,detector:yre,loader:xre},NS="pie",kre=k(e=>/^\s*pie/.test(e),"detector"),wre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./pieDiagram-ADFJNKIX-CKzchAXU.js"));return{id:NS,diagram:e}},"loader"),Tre={id:NS,detector:kre,loader:wre},LS="quadrantChart",Cre=k(e=>/^\s*quadrantChart/.test(e),"detector"),Sre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./quadrantDiagram-AYHSOK5B-D2Rt32D2.js"));return{id:LS,diagram:e}},"loader"),Ere={id:LS,detector:Cre,loader:Sre},_re=Ere,MS="xychart",Are=k(e=>/^\s*xychart(-beta)?/.test(e),"detector"),Nre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./xychartDiagram-PRI3JC2R-CQgij0Fy.js"));return{id:MS,diagram:e}},"loader"),Lre={id:MS,detector:Are,loader:Nre},Mre=Lre,IS="requirement",Ire=k(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),Rre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./requirementDiagram-UZGBJVZJ-CSgb6U9N.js"));return{id:IS,diagram:e}},"loader"),Bre={id:IS,detector:Ire,loader:Rre},Dre=Bre,RS="sequence",Ore=k(e=>/^\s*sequenceDiagram/.test(e),"detector"),Pre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./sequenceDiagram-WL72ISMW-BZJ7d_X4.js"));return{id:RS,diagram:e}},"loader"),Fre={id:RS,detector:Ore,loader:Pre},$re=Fre,BS="class",zre=k((e,t)=>t?.class?.defaultRenderer==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e),"detector"),Hre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./classDiagram-2ON5EDUG-UNrH9bQo.js"));return{id:BS,diagram:e}},"loader"),qre={id:BS,detector:zre,loader:Hre},jre=qre,DS="classDiagram",Ure=k((e,t)=>/^\s*classDiagram/.test(e)&&t?.class?.defaultRenderer==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e),"detector"),Wre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./classDiagram-v2-WZHVMYZB-UNrH9bQo.js"));return{id:DS,diagram:e}},"loader"),Gre={id:DS,detector:Ure,loader:Wre},Yre=Gre,OS="state",Vre=k((e,t)=>t?.state?.defaultRenderer==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e),"detector"),Xre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./stateDiagram-FKZM4ZOC-Cfuygt_P.js"));return{id:OS,diagram:e}},"loader"),Kre={id:OS,detector:Vre,loader:Xre},Qre=Kre,PS="stateDiagram",Zre=k((e,t)=>!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&t?.state?.defaultRenderer==="dagre-wrapper"),"detector"),Jre=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./stateDiagram-v2-4FDKWEC3-BiriAQkj.js"));return{id:PS,diagram:e}},"loader"),ene={id:PS,detector:Zre,loader:Jre},tne=ene,FS="journey",rne=k(e=>/^\s*journey/.test(e),"detector"),nne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./journeyDiagram-XKPGCS4Q-BqtyHvQF.js"));return{id:FS,diagram:e}},"loader"),ine={id:FS,detector:rne,loader:nne},ane=ine,sne=k((e,t,r)=>{he.debug(`rendering svg for syntax error
630
+ `);const n=Ow(t),i=n.append("g");n.attr("viewBox","0 0 2412 512"),L1(n,100,512,!0),i.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),i.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),i.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),i.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),i.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),i.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),i.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),i.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${r}`)},"draw"),$S={draw:sne},one=$S,lne={db:{},renderer:$S,parser:{parse:k(()=>{},"parse")}},cne=lne,zS="flowchart-elk",une=k((e,t={})=>/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&t?.flowchart?.defaultRenderer==="elk"?(t.layout="elk",!0):!1,"detector"),hne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./flowDiagram-NV44I4VS-BChiRwcp.js"));return{id:zS,diagram:e}},"loader"),dne={id:zS,detector:une,loader:hne},fne=dne,HS="timeline",pne=k(e=>/^\s*timeline/.test(e),"detector"),mne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./timeline-definition-IT6M3QCI-CBmpRgUM.js"));return{id:HS,diagram:e}},"loader"),gne={id:HS,detector:pne,loader:mne},bne=gne,qS="mindmap",yne=k(e=>/^\s*mindmap/.test(e),"detector"),xne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./mindmap-definition-VGOIOE7T-ZHY70ZzV.js"));return{id:qS,diagram:e}},"loader"),vne={id:qS,detector:yne,loader:xne},kne=vne,jS="kanban",wne=k(e=>/^\s*kanban/.test(e),"detector"),Tne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./kanban-definition-3W4ZIXB7-DraMxv75.js"));return{id:jS,diagram:e}},"loader"),Cne={id:jS,detector:wne,loader:Tne},Sne=Cne,US="sankey",Ene=k(e=>/^\s*sankey(-beta)?/.test(e),"detector"),_ne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./sankeyDiagram-TZEHDZUN-C8jpBnM0.js"));return{id:US,diagram:e}},"loader"),Ane={id:US,detector:Ene,loader:_ne},Nne=Ane,WS="packet",Lne=k(e=>/^\s*packet(-beta)?/.test(e),"detector"),Mne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./diagram-S2PKOQOG-BN04h93a.js"));return{id:WS,diagram:e}},"loader"),Ine={id:WS,detector:Lne,loader:Mne},GS="radar",Rne=k(e=>/^\s*radar-beta/.test(e),"detector"),Bne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./diagram-QEK2KX5R-Doa8ooC_.js"));return{id:GS,diagram:e}},"loader"),Dne={id:GS,detector:Rne,loader:Bne},YS="block",One=k(e=>/^\s*block(-beta)?/.test(e),"detector"),Pne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./blockDiagram-VD42YOAC-NQhzFvsO.js"));return{id:YS,diagram:e}},"loader"),Fne={id:YS,detector:One,loader:Pne},$ne=Fne,VS="architecture",zne=k(e=>/^\s*architecture/.test(e),"detector"),Hne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./architectureDiagram-VXUJARFQ-BGsDPmi_.js"));return{id:VS,diagram:e}},"loader"),qne={id:VS,detector:zne,loader:Hne},jne=qne,XS="treemap",Une=k(e=>/^\s*treemap/.test(e),"detector"),Wne=k(async()=>{const{diagram:e}=await Promise.resolve().then(()=>require("./diagram-PSM6KHXK-C7tjFZpr.js"));return{id:XS,diagram:e}},"loader"),Gne={id:XS,detector:Une,loader:Wne},Zx=!1,Kh=k(()=>{Zx||(Zx=!0,h0("error",cne,e=>e.toLowerCase().trim()==="error"),h0("---",{db:{clear:k(()=>{},"clear")},styles:{},renderer:{draw:k(()=>{},"draw")},parser:{parse:k(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:k(()=>null,"init")},e=>e.toLowerCase().trimStart().startsWith("---")),cp(fne,kne,jne),cp(Qte,Sne,Yre,jre,cre,bre,vre,Tre,Dre,$re,are,tre,bne,fre,tne,Qre,ane,_re,Nne,Ine,Mre,$ne,Dne,Gne))},"addDiagrams"),Yne=k(async()=>{he.debug("Loading registered diagrams");const t=(await Promise.allSettled(Object.entries(Qa).map(async([r,{detector:n,loader:i}])=>{if(i)try{pp(r)}catch{try{const{diagram:a,id:s}=await i();h0(s,a,n)}catch(a){throw he.error(`Failed to load external diagram with key ${r}. Removing from detectors.`),delete Qa[r],a}}}))).filter(r=>r.status==="rejected");if(t.length>0){he.error(`Failed to load ${t.length} external diagrams`);for(const r of t)he.error(r);throw new Error(`Failed to load ${t.length} external diagrams`)}},"loadRegisteredDiagrams"),Vne="graphics-document document";function KS(e,t){e.attr("role",Vne),t!==""&&e.attr("aria-roledescription",t)}k(KS,"setA11yDiagramInfo");function QS(e,t,r,n){if(e.insert!==void 0){if(r){const i=`chart-desc-${n}`;e.attr("aria-describedby",i),e.insert("desc",":first-child").attr("id",i).text(r)}if(t){const i=`chart-title-${n}`;e.attr("aria-labelledby",i),e.insert("title",":first-child").attr("id",i).text(t)}}}k(QS,"addSVGa11yTitleDescription");var Ga,cm=(Ga=class{constructor(t,r,n,i,a){this.type=t,this.text=r,this.db=n,this.parser=i,this.renderer=a}static async fromText(t,r={}){const n=Cr(),i=A1(t,n);t=VZ(t)+`
631
631
  `;try{pp(i)}catch{const c=WU(i);if(!c)throw new gk(`Diagram ${i} not found.`);const{id:u,diagram:h}=await c();h0(u,h)}const{db:a,parser:s,renderer:o,init:l}=pp(i);return s.parser&&(s.parser.yy=a),a.clear?.(),l?.(n),r.title&&a.setDiagramTitle?.(r.title),await s.parse(t),new Ga(i,t,a,s,o)}async render(t,r){await this.renderer.draw(this.text,t,r,this)}getParser(){return this.parser}getType(){return this.type}},k(Ga,"Diagram"),Ga),Jx=[],Xne=k(()=>{Jx.forEach(e=>{e()}),Jx=[]},"attachFunctions"),Kne=k(e=>e.replace(/^\s*%%(?!{)[^\n]+\n?/gm,"").trimStart(),"cleanupComments");function ZS(e){const t=e.match(mk);if(!t)return{text:e,metadata:{}};let r=x8(t[1],{schema:y8})??{};r=typeof r=="object"&&!Array.isArray(r)?r:{};const n={};return r.displayMode&&(n.displayMode=r.displayMode.toString()),r.title&&(n.title=r.title.toString()),r.config&&(n.config=r.config),{text:e.slice(t[0].length),metadata:n}}k(ZS,"extractFrontMatter");var Qne=k(e=>e.replace(/\r\n?/g,`
632
632
  `).replace(/<(\w+)([^>]*)>/g,(t,r,n)=>"<"+r+n.replace(/="([^"]*)"/g,"='$1'")+">"),"cleanupText"),Zne=k(e=>{const{text:t,metadata:r}=ZS(e),{displayMode:n,title:i,config:a={}}=r;return n&&(a.gantt||(a.gantt={}),a.gantt.displayMode=n),{title:i,config:a,text:t}},"processFrontmatter"),Jne=k(e=>{const t=_n.detectInit(e)??{},r=_n.detectDirective(e,"wrap");return Array.isArray(r)?t.wrap=r.some(({type:n})=>n==="wrap"):r?.type==="wrap"&&(t.wrap=!0),{text:FZ(e),directive:t}},"processDirectives");function Ig(e){const t=Qne(e),r=Zne(t),n=Jne(r.text),i=zh(r.config,n.directive);return e=Kne(n.text),{code:e,title:r.title,config:i}}k(Ig,"preprocessDiagram");function JS(e){const t=new TextEncoder().encode(e),r=Array.from(t,n=>String.fromCodePoint(n)).join("");return btoa(r)}k(JS,"toBase64");var eie=5e4,tie="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa",rie="sandbox",nie="loose",iie="http://www.w3.org/2000/svg",aie="http://www.w3.org/1999/xlink",sie="http://www.w3.org/1999/xhtml",oie="100%",lie="100%",cie="border:0;margin:0;",uie="margin:0",hie="allow-top-navigation-by-user-activation allow-popups",die='The "iframe" tag is not supported by your browser.',fie=["foreignobject"],pie=["dominant-baseline"];function Rg(e){const t=Ig(e);return c0(),sW(t.config??{}),t}k(Rg,"processAndSetConfigs");async function eE(e,t){Kh();try{const{code:r,config:n}=Rg(e);return{diagramType:(await rE(r)).type,config:n}}catch(r){if(t?.suppressErrors)return!1;throw r}}k(eE,"parse");var e4=k((e,t,r=[])=>`
633
633
  .${e} ${t} { ${r.join(" !important; ")} !important; }`,"cssImportantStyles"),mie=k((e,t=new Map)=>{let r="";if(e.themeCSS!==void 0&&(r+=`
@@ -651,7 +651,7 @@ $$`;case"image":return n(),"![image]("+s.content+")";case"table":{n();const l=s.
651
651
  `)}case"list":{const l=s.depth||0,c=" ".repeat(l),u=pn(s.spans);if(s.listType==="ordered"){for(;r.length<=l;)r.push(0);r[l]=(r[l]||0)+1;for(let h=l+1;h<r.length;h++)r[h]=0;return`${c}${r[l]}. ${u}`}return`${c}- ${u}`}case"blockquote":return n(),`> ${pn(s.spans)}`;case"divider":return n(),"---";case"paragraph":return n(),pn(s.spans);default:return n(),s.content??""}};let a=null;for(const s of e){const o=i(s);if(t.length>0){const l=a==="list"&&s.type==="list"?`
652
652
  `:`
653
653
 
654
- `;t.push(l)}t.push(o),a=s.type}return t.join("")}function mE({markdown:e,isStreaming:t}){const r=P.useRef([]);return{blocks:P.useMemo(()=>{const i=Ui(e,t,r.current);return r.current=i,i},[e,t])}}const Qie={"# ":1,"## ":2,"### ":3,"#### ":4,"##### ":5,"###### ":6},Zie={"- ":"unordered","* ":"unordered","1. ":"ordered"},c4={"\\* ":"* ","\\- ":"- ","\\> ":"> "};function gE({onBlockTypeChange:e}={}){const t=P.useCallback(i=>{for(const[a,s]of Object.entries(c4))if(i===a)return s;return null},[]),r=P.useCallback(i=>{for(const s of Object.keys(c4))if(i===s)return null;for(const[s,o]of Object.entries(Qie))if(i.startsWith(s))return{newType:"heading",newContent:i.slice(s.length),level:o};for(const[s,o]of Object.entries(Zie))if(i.startsWith(s))return{newType:"list",newContent:i.slice(s.length),listType:o};if(i.startsWith("> "))return{newType:"blockquote",newContent:i.slice(2)};if(i==="---"||i==="***"||i==="___")return{newType:"divider",newContent:""};const a=i.match(/^```([\w-]*)\s$/);return a?{newType:"code",newContent:"",language:a[1]||"text"}:null},[]),n=P.useCallback((i,a,s,o)=>{if(i.key===" "&&o===s.length){const l=s+" ";if(t(l)&&a.type==="paragraph")return!1;const u=r(l);if(u&&a.type==="paragraph")return i.preventDefault(),e?.(a.id,u.newType,u.newContent,{level:u.level,listType:u.listType,language:u.language}),!0;if(u&&u.newType==="list"&&a.type==="list"&&u.listType!==a.listType)return i.preventDefault(),e?.(a.id,"list",u.newContent,{listType:u.listType,depth:a.depth??0}),!0}if(i.key==="Enter"&&o===s.length){const l=s+" ",c=r(l);if(c?.newType==="code"&&a.type==="paragraph")return i.preventDefault(),e?.(a.id,c.newType,c.newContent,{language:c.language}),!0}return i.key==="Backspace"&&o===0&&a.type!=="paragraph"&&s===""?(i.preventDefault(),e?.(a.id,"paragraph",""),!0):(i.key==="Enter"&&a.type==="code",!1)},[r,t,e]);return{detectShortcut:r,detectEscape:t,handleKeyDown:n}}function Jie(e){const{bold:t,italic:r,strike:n}=e;return t&&r&&n?"boldItalicStrikethrough":t&&r?"boldItalic":t&&n?"boldStrikethrough":r&&n?"italicStrikethrough":t?"bold":r?"italic":n?"strikethrough":"plain"}function eae(e){const t={bold:!1,italic:!1,strike:!1};let r,n=!1,i=!1,a=!1,s=e.parentNode;for(;s&&s.nodeType===Node.ELEMENT_NODE;){const o=s,l=o.tagName.toLowerCase();l==="code"&&(n=!0),l==="a"&&(i=!0,r=o.getAttribute("href")||""),(l==="strong"||l==="b")&&(t.bold=!0),(l==="em"||l==="i")&&(t.italic=!0),(l==="s"||l==="del"||l==="strike")&&(t.strike=!0),l==="span"&&o.getAttribute("data-math")==="1"&&(a=!0),s=s.parentNode}return n?{style:"code"}:a?{style:"math"}:i?{style:"link",href:r}:{style:Jie(t)}}function Og(e){let t=e.parentNode;for(;t&&t.nodeType===Node.ELEMENT_NODE;){if(t.getAttribute("data-math-delim")==="1")return!0;t=t.parentNode}return!1}function bE(e,t){let r=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;r&&r!==t;){if(r.getAttribute("data-math")==="1")return r;r=r.parentElement}return null}function tae(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let r=null,n;for(;n=t.nextNode();)Og(n)||(r=n);return r}function rae(e,t,r){if(t.nodeType===Node.ELEMENT_NODE){const i=t;if(r>0)return i.childNodes[r-1]||null}if(t.nodeType===Node.TEXT_NODE&&r>0)return null;let n=t;for(;n&&n!==e;){if(n.previousSibling)return n.previousSibling;n=n.parentNode}return null}function u4(e,t,r){const n=bE(t,e);if(n){if(t.nodeType===Node.ELEMENT_NODE&&t===n){const a=n.childNodes.length;if(r>=a)return"afterMath"}return"insideMath"}const i=rae(e,t,r);if(i&&i.nodeType===Node.ELEMENT_NODE&&i.getAttribute("data-math")==="1")return"afterMath"}function aa(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let n;for(;n=r.nextNode();){const i=n.textContent||"";if(!i||Og(n))continue;const a=eae(n);if(a.style==="link"){t.push({text:i,style:"link",href:a.href});continue}if(a.style==="math"){t.push({text:i,style:"math"});continue}t.push({text:i,style:a.style})}return Bi(t)}function dn(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);if(!e.contains(r.startContainer)||!e.contains(r.endContainer))return null;const n=h4(e,r.startContainer,r.startOffset),i=h4(e,r.endContainer,r.endOffset);return n===null||i===null?null:{start:n,end:i,startAffinity:u4(e,r.startContainer,r.startOffset),endAffinity:u4(e,r.endContainer,r.endOffset)}}function h4(e,t,r){const n=document.createRange();try{n.selectNodeContents(e),n.setEnd(t,r)}catch{return null}const i=n.cloneContents();return i.querySelectorAll?.('[data-math-delim="1"]').forEach(a=>a.remove()),i.textContent?.length??0}function Ri(e,t,r,n={}){const i=d4(e,t,n.startAffinity),a=d4(e,r,n.endAffinity);if(!i||!a)return;const s=document.createRange();s.setStart(i.node,i.offset),s.setEnd(a.node,a.offset);const o=window.getSelection();o?.removeAllRanges(),o?.addRange(s)}function d4(e,t,r){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let i=0,a;for(;a=n.nextNode();){if(Og(a))continue;const s=a.textContent?.length||0;if(i+s>t)return{node:a,offset:Math.max(0,t-i)};if(i+s===t){const o=bE(a,e);if(o){const l=tae(o);if(l&&l===a&&r==="afterMath"){const c=o.parentNode;if(c){const u=Array.prototype.indexOf.call(c.childNodes,o);if(u!==-1)return{node:c,offset:u+1}}}}return{node:a,offset:s}}i+=s}return{node:e,offset:e.childNodes.length}}const nae=220,f4=8;function iae({containerRef:e,onFormat:t,isMathSelection:r}){const[n,i]=P.useState(!1),[a,s]=P.useState({top:0,left:0}),[o,l]=P.useState(!1),c=P.useRef(null),u=P.useCallback(()=>{const d=window.getSelection();if(!d||d.isCollapsed||!d.rangeCount){i(!1),l(!1);return}const f=d.getRangeAt(0);if(!e.current?.contains(f.commonAncestorContainer)){i(!1),l(!1);return}l(!!r?.(f));const p=f.getBoundingClientRect(),b=(c.current?.offsetWidth||nae)/2,y=p.left+p.width/2,v=b+f4,T=window.innerWidth-b-f4,A=Math.max(v,Math.min(T,y));s({top:p.top-45,left:A}),i(!0)},[e,r]);P.useEffect(()=>{const d=()=>{requestAnimationFrame(u)};return document.addEventListener("selectionchange",d),()=>{document.removeEventListener("selectionchange",d)}},[u]),P.useEffect(()=>{const d=f=>{f.target.closest(".floating-toolbar")};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[]);const h=P.useCallback(d=>{o&&d!=="math"||t(d)},[t,o]);return n?C.jsxs("div",{ref:c,className:"floating-toolbar fixed z-[100] flex items-center gap-1 px-2 py-1.5 bg-notion-bg-elevated rounded-lg shadow-lg border border-notion-border",style:{top:a.top,left:a.left,transform:"translateX(-50%)"},onMouseDown:d=>d.preventDefault(),children:[C.jsx(Cs,{onClick:()=>h("bold"),title:"Bold (⌘B)",disabled:o,children:C.jsx(aae,{})}),C.jsx(Cs,{onClick:()=>h("italic"),title:"Italic (⌘I)",disabled:o,children:C.jsx(sae,{})}),C.jsx(Cs,{onClick:()=>h("strikethrough"),title:"Strikethrough",disabled:o,children:C.jsx(oae,{})}),C.jsx(Cs,{onClick:()=>h("code"),title:"Code (⌘E)",disabled:o,children:C.jsx(lae,{})}),C.jsx(Cs,{onClick:()=>h("math"),title:"Math (LaTeX) (⌘M)",disabled:!1,children:C.jsx(uae,{})}),C.jsx("div",{className:"w-px h-5 bg-notion-border mx-1"}),C.jsx(Cs,{onClick:()=>h("link"),title:"Link (⌘K)",disabled:o,children:C.jsx(cae,{})})]}):null}function Cs({children:e,onClick:t,title:r,disabled:n}){return C.jsx("button",{type:"button",onClick:t,title:r,disabled:n,className:`p-1.5 rounded text-notion-text-secondary transition-colors ${n?"opacity-40 cursor-not-allowed":"hover:bg-notion-bg-hover hover:text-notion-text"}`,children:e})}function aae(){return C.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),C.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]})}function sae(){return C.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("line",{x1:"19",y1:"4",x2:"10",y2:"4"}),C.jsx("line",{x1:"14",y1:"20",x2:"5",y2:"20"}),C.jsx("line",{x1:"15",y1:"4",x2:"9",y2:"20"})]})}function oae(){return C.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("path",{d:"M16 4H9a3 3 0 0 0-3 3v1a3 3 0 0 0 3 3h6a3 3 0 0 1 3 3v1a3 3 0 0 1-3 3H8"}),C.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function lae(){return C.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("polyline",{points:"16 18 22 12 16 6"}),C.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function cae(){return C.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),C.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function uae(){return C.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("path",{d:"M4 4h6l4 16h6"}),C.jsx("path",{d:"M4 12h16"})]})}function hae({isOpen:e,onSubmit:t,onCancel:r,initialHref:n=""}){const[i,a]=P.useState(n),s=P.useRef(null),o=P.useRef(null);P.useEffect(()=>{e&&(a(n),requestAnimationFrame(()=>{s.current?.focus(),s.current?.select()}))},[e,n]);const l=P.useCallback(u=>{u.preventDefault();const h=i.trim();if(h){const d=h.match(/^https?:\/\//)?h:`https://${h}`;t(d)}},[i,t]),c=P.useCallback(u=>{u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),r())},[r]);return e?C.jsxs("div",{className:"link-modal fixed inset-0 z-[100] flex items-center justify-center",onKeyDown:c,children:[C.jsx("div",{className:"absolute inset-0 bg-black/20 backdrop-blur-[1px]",onClick:r}),C.jsxs("div",{ref:o,className:"relative bg-notion-bg-elevated rounded-xl shadow-2xl border border-notion-border/60 w-full max-w-md mx-4 overflow-hidden animate-in fade-in zoom-in-95 duration-150",style:{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05)"},children:[C.jsx("div",{className:"px-5 pt-5 pb-3",children:C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx("div",{className:"w-9 h-9 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center shadow-sm",children:C.jsx(dae,{className:"w-4.5 h-4.5 text-white"})}),C.jsxs("div",{children:[C.jsx("h3",{className:"text-[15px] font-semibold text-notion-text tracking-[-0.01em]",children:"Insert link"}),C.jsx("p",{className:"text-xs text-notion-text-secondary mt-0.5",children:"Enter a URL for the selected text"})]})]})}),C.jsxs("form",{onSubmit:l,className:"px-5 pb-5",children:[C.jsxs("div",{className:"relative",children:[C.jsx("div",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none",children:C.jsx(fae,{className:"w-4 h-4 text-notion-text-secondary"})}),C.jsx("input",{ref:s,type:"text",value:i,onChange:u=>a(u.target.value),placeholder:"https://example.com",className:"w-full pl-10 pr-4 py-2.5 text-sm bg-notion-hover/50 border border-notion-border/60 rounded-lg text-notion-text placeholder:text-notion-text-secondary/60 focus:outline-none focus:ring-2 focus:ring-blue-500/30 focus:border-blue-500/50 transition-all duration-150",autoComplete:"url",spellCheck:!1})]}),C.jsxs("div",{className:"flex items-center justify-end gap-2 mt-4",children:[C.jsx("button",{type:"button",onClick:r,className:"px-3.5 py-1.5 text-sm font-medium text-notion-text-secondary hover:text-notion-text hover:bg-notion-hover rounded-lg transition-colors duration-150",children:"Cancel"}),C.jsx("button",{type:"submit",disabled:!i.trim(),className:"px-4 py-1.5 text-sm font-medium text-white bg-blue-500 hover:bg-blue-600 disabled:opacity-40 disabled:cursor-not-allowed rounded-lg shadow-sm transition-all duration-150 hover:shadow",children:"Apply"})]})]}),C.jsx("div",{className:"px-5 py-2.5 bg-notion-hover/30 border-t border-notion-border/40",children:C.jsxs("div",{className:"flex items-center justify-between text-[11px] text-notion-text-secondary",children:[C.jsxs("span",{className:"flex items-center gap-1.5",children:[C.jsx("kbd",{className:"px-1.5 py-0.5 bg-notion-bg-elevated rounded border border-notion-border/60 font-mono text-[10px] shadow-sm",children:"Enter"}),C.jsx("span",{children:"to apply"})]}),C.jsxs("span",{className:"flex items-center gap-1.5",children:[C.jsx("kbd",{className:"px-1.5 py-0.5 bg-notion-bg-elevated rounded border border-notion-border/60 font-mono text-[10px] shadow-sm",children:"Esc"}),C.jsx("span",{children:"to cancel"})]})]})})]})]}):null}function dae({className:e}){return C.jsxs("svg",{className:e,width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),C.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function fae({className:e}){return C.jsxs("svg",{className:e,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("circle",{cx:"12",cy:"12",r:"10"}),C.jsx("path",{d:"M2 12h20"}),C.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}const pae=400;function Ac({block:e,isEditing:t,onContentChange:r,onStartEdit:n,onEndEdit:i,onKeyDown:a,className:s="",editingClassName:o="",viewClassName:l="",placeholder:c="Type something...",renderWrapper:u,readonly:h=!1}){const d=P.useRef(null),f=P.useRef(null),p=P.useRef(null),m=P.useRef(e.spans),b=P.useRef(null),[y,v]=P.useState(!1),T=P.useRef(null),A=P.useRef(null),E=P.useCallback(()=>t?d.current:f.current,[t]);P.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]),P.useEffect(()=>{if(t&&d.current){d.current.innerHTML=Ns(e.spans),m.current=e.spans,d.current.focus();const L=A.current;if(A.current=null,L)Ri(d.current,L.start,L.end,{startAffinity:L.startAffinity,endAffinity:L.endAffinity});else{const ae=document.createRange(),ne=window.getSelection();ae.selectNodeContents(d.current),ae.collapse(!1),ne?.removeAllRanges(),ne?.addRange(ae)}}},[t]),P.useEffect(()=>{if(!t||!d.current)return;const L=d.current,ae=Ns(e.spans),ne=L.innerHTML;if(ae===ne)return;const N=dn(L);L.innerHTML=ae,N&&Ri(L,N.start,N.end,{startAffinity:N.startAffinity,endAffinity:N.endAffinity}),m.current=e.spans},[e.spans,t]);const S=P.useCallback(()=>{if(!d.current)return;const L=dn(d.current),ae=aa(d.current);m.current=ae,r(ae);const N=Array.from(d.current.querySelectorAll('[data-math="1"]')).every(ge=>ge.querySelectorAll('[data-math-delim="1"]').length===2);b.current&&clearTimeout(b.current);const ke=()=>{if(!d.current)return;const ge=aa(d.current),Se=Ns(ge),_e=d.current.innerHTML;Se!==_e&&(d.current.innerHTML=Se,L&&Ri(d.current,L.start,L.end,{startAffinity:L.startAffinity,endAffinity:L.endAffinity}))};N?b.current=setTimeout(ke,pae):ke()},[r]),I=P.useCallback(L=>{if(!L.relatedTarget?.closest(".floating-toolbar")&&!L.relatedTarget?.closest(".link-modal")){if(d.current){const ae=aa(d.current);r(ae)}i()}},[r,i]),D=P.useCallback(()=>{!t&&!h&&n()},[t,n,h]),H=P.useCallback(()=>{if(!f.current)return;const L=f.current,ae=window.getSelection();if(!ae||ae.rangeCount===0)return;const ne=ae.getRangeAt(0);if(!L.contains(ne.startContainer)||!L.contains(ne.endContainer))return;const N=Ue=>(Ue.nodeType===Node.ELEMENT_NODE?Ue:Ue.parentElement)?.closest("[data-span-start]"),ke=(Ue,$e,ht)=>{if(Ue.nodeType!==Node.ELEMENT_NODE)return null;const dt=Ue,Lt=dt.childNodes[$e]||null,Re=$e>0&&dt.childNodes[$e-1]||null,ue=de=>de&&de.nodeType===Node.ELEMENT_NODE?de.closest("[data-span-start]"):null;return ht==="start"?ue(Lt)||ue(Re):ue(Re)||ue(Lt)},ge=(Ue,$e,ht)=>{let dt=N(Ue);if(dt||(dt=ke(Ue,$e,ht)),!dt)return null;const Lt=dt.getAttribute("data-span-start"),Re=dt.getAttribute("data-span-len");if(!Lt||!Re)return null;const ue=Number(Lt),de=Number(Re);if(dt.getAttribute("data-span-style")==="math")return{pos:ht==="start"?ue:ue+de,affinity:"insideMath"};try{const Bt=document.createRange();Bt.selectNodeContents(dt),Bt.setEnd(Ue,$e);const Jt=Bt.toString().length;return{pos:ue+Jt}}catch{return{pos:ht==="start"?ue:ue+de}}},Se=N(ne.startContainer)||ke(ne.startContainer,ne.startOffset,"start");if(ne.collapsed&&Se?.getAttribute("data-span-style")==="math"){const Ue=Number(Se.getAttribute("data-span-start")||"0");A.current={start:Ue,end:Ue,startAffinity:"insideMath",endAffinity:"insideMath"};return}const _e=ge(ne.startContainer,ne.startOffset,"start"),at=ge(ne.endContainer,ne.endOffset,"end");!_e||!at||(A.current={start:_e.pos,end:at.pos,startAffinity:_e.affinity,endAffinity:at.affinity})},[]),R=P.useCallback((L,ae)=>{const ne=E();if(!ne)return;const N=dn(ne);if(!(!N||N.start===N.end))if(t&&d.current){const ke=aa(d.current),ge=gl(ke,N.start,N.end,L,ae);d.current.innerHTML=Ns(ge),Ri(d.current,N.start,N.end,{startAffinity:N.startAffinity,endAffinity:N.endAffinity}),m.current=ge,r(ge)}else{const ke=gl(e.spans,N.start,N.end,L,ae);r(ke),window.getSelection()?.removeAllRanges()}},[t,e.spans,r,E]),F=P.useCallback(L=>{if((L.key==="ArrowRight"||L.key==="ArrowLeft")&&d.current){const ae=d.current,ne=window.getSelection();if(ne&&ne.rangeCount>0){const N=ne.getRangeAt(0);if(N.collapsed&&ae.contains(N.startContainer)){const ke=Re=>{let ue=Re.nodeType===Node.ELEMENT_NODE?Re:Re.parentElement;for(;ue&&ue!==ae;){if(ue.getAttribute("data-math")==="1")return ue;ue=ue.parentElement}return null},ge=Re=>{let ue=Re.parentNode;for(;ue&&ue.nodeType===Node.ELEMENT_NODE;){if(ue.getAttribute("data-math-delim")==="1")return!0;ue=ue.parentNode}return!1},Se=Re=>{const ue=document.createTreeWalker(Re,NodeFilter.SHOW_TEXT,null);let de;for(;de=ue.nextNode();)if(!ge(de))return de;return null},_e=Re=>{const ue=document.createTreeWalker(Re,NodeFilter.SHOW_TEXT,null);let de=null,pt;for(;pt=ue.nextNode();)ge(pt)||(de=pt);return de},at=Re=>{const ue=Re.parentNode;if(!ue)return;const de=Array.prototype.indexOf.call(ue.childNodes,Re);if(de===-1)return;const pt=document.createRange();pt.setStart(ue,de+1),pt.collapse(!0),ne.removeAllRanges(),ne.addRange(pt)},Ue=Re=>{const ue=Re.parentNode;if(!ue)return;const de=Array.prototype.indexOf.call(ue.childNodes,Re);if(de===-1)return;const pt=document.createRange();pt.setStart(ue,de),pt.collapse(!0),ne.removeAllRanges(),ne.addRange(pt)},$e=Re=>{const ue=Se(Re),de=document.createRange();ue?de.setStart(ue,0):de.setStart(Re,1),de.collapse(!0),ne.removeAllRanges(),ne.addRange(de)},ht=Re=>{const ue=_e(Re),de=document.createRange();ue?de.setStart(ue,ue.textContent?.length??0):de.setStart(Re,1),de.collapse(!0),ne.removeAllRanges(),ne.addRange(de)},dt=()=>{const Re=N.startContainer,ue=N.startOffset;if(Re.nodeType===Node.ELEMENT_NODE){const pt=Re;if(ue>0)return pt.childNodes[ue-1]||null}if(Re.nodeType===Node.TEXT_NODE&&ue>0)return null;let de=Re;for(;de&&de!==ae;){if(de.previousSibling)return de.previousSibling;de=de.parentNode}return null},Lt=()=>{const Re=N.startContainer,ue=N.startOffset;if(Re.nodeType===Node.ELEMENT_NODE)return Re.childNodes[ue]||null;if(Re.nodeType===Node.TEXT_NODE){const pt=Re.textContent||"";if(ue<pt.length)return null}let de=Re;for(;de&&de!==ae;){if(de.nextSibling)return de.nextSibling;de=de.parentNode}return null};if(L.key==="ArrowRight"){const Re=ke(N.startContainer);if(Re){const de=_e(Re);if(de&&N.startContainer===de&&N.startOffset===(de.textContent?.length??0)){L.preventDefault(),at(Re);return}}const ue=Lt();if(ue&&ue.nodeType===Node.ELEMENT_NODE){const de=ue;if(de.getAttribute("data-math")==="1"){L.preventDefault(),$e(de);return}}}if(L.key==="ArrowLeft"){const Re=dt();if(Re&&Re.nodeType===Node.ELEMENT_NODE){const de=Re;if(de.getAttribute("data-math")==="1"){L.preventDefault(),ht(de);return}}const ue=ke(N.startContainer);if(ue){const de=Se(ue);if(de&&N.startContainer===de&&N.startOffset===0){L.preventDefault(),Ue(ue);return}}}}}}if((L.metaKey||L.ctrlKey)&&d.current)switch(L.key.toLowerCase()){case"b":L.preventDefault(),R("bold");return;case"i":L.preventDefault(),R("italic");return;case"e":L.preventDefault(),R("code");return;case"m":L.preventDefault(),R("math");return;case"k":L.preventDefault();const ae=dn(d.current);ae&&ae.start!==ae.end&&(T.current=ae,v(!0));return}if(L.key==="Escape"){if(d.current){const ae=aa(d.current);r(ae)}i();return}a(L)},[R,r,i,a]),G=P.useCallback(L=>{const ae=E();if(ae){if(L==="link"){const ne=dn(ae);ne&&ne.start!==ne.end&&(T.current=ne,v(!0));return}R(L)}},[R,E]),ee=P.useCallback(L=>{if(v(!1),!T.current)return;const ae=T.current;if(T.current=null,t&&d.current){const ne=aa(d.current),N=gl(ne,ae.start,ae.end,"link",{href:L});d.current.innerHTML=Ns(N),Ri(d.current,ae.start,ae.end,{startAffinity:ae.startAffinity,endAffinity:ae.endAffinity}),m.current=N,r(N),d.current.focus()}else{const ne=gl(e.spans,ae.start,ae.end,"link",{href:L});r(ne),window.getSelection()?.removeAllRanges()}},[t,e.spans,r]),$=P.useCallback(()=>{v(!1),T.current=null,t&&d.current?.focus()},[t]),q=P.useCallback(L=>{if(t&&d.current){const ae=dn(d.current);if(!ae||ae.start===ae.end)return!1;const ne=aa(d.current);let N=0;for(const ke of ne){const ge=N,Se=N+ke.text.length;if(Se>ae.start&&ge<ae.end&&ke.style==="math")return!0;N=Se}return!1}if(!t&&f.current){const ae=f.current,ne=Array.from(ae.querySelectorAll('[data-span-style="math"]'));for(const N of ne)try{if(L.intersectsNode(N))return!0}catch{}}return!1},[t]),W=P.useCallback(L=>{const ne=L.nativeEvent.inputType,N=ne==="deleteContentBackward"||ne==="deleteContentForward",ke=ne==="insertText"||ne==="insertCompositionText"||ne==="insertFromPaste";if(!N&&!ke)return;const ge=d.current;if(!ge)return;const Se=window.getSelection();if(!Se||Se.rangeCount===0)return;const _e=Se.getRangeAt(0),at=ue=>{let de=ue.nodeType===Node.ELEMENT_NODE?ue:ue.parentElement;for(;de&&de!==ge;){if(de.getAttribute("data-math")==="1")return de;de=de.parentElement}return null},Ue=ue=>{const de=ue.parentNode;if(!de)return;const pt=Array.prototype.indexOf.call(de.childNodes,ue);if(pt===-1)return;const Bt=document.createRange();Bt.setStart(de,pt+1),Bt.collapse(!0),Se.removeAllRanges(),Se.addRange(Bt)},$e=ue=>{if(!ue)return!1;if(ue.nodeType===Node.ELEMENT_NODE){const pt=ue;return pt.getAttribute("data-math-delim")==="1"?!0:!!pt.querySelector('[data-math-delim="1"]')}const de=ue.parentElement;return!!de&&de.getAttribute("data-math-delim")==="1"},ht=ue=>{let de=ue;for(;de&&de!==ge;){if(de.previousSibling)return de.previousSibling;de=de.parentNode}return null},dt=ue=>{let de=ue;for(;de&&de!==ge;){if(de.nextSibling)return de.nextSibling;de=de.parentNode}return null},Lt=(ue,de)=>{if(ue.nodeType===Node.ELEMENT_NODE){const pt=ue;return de>0?pt.childNodes[de-1]||null:ht(ue)}return ue.nodeType===Node.TEXT_NODE&&de>0?null:ht(ue)},Re=(ue,de)=>{if(ue.nodeType===Node.ELEMENT_NODE)return ue.childNodes[de]||dt(ue);if(ue.nodeType===Node.TEXT_NODE){const pt=ue.textContent||"";return de<pt.length?null:dt(ue)}return dt(ue)};if(!_e.collapsed){_e.cloneContents().querySelector?.('[data-math-delim="1"]')&&N&&L.preventDefault();return}if(ke){const ue=at(_e.startContainer);if(ue&&_e.startContainer===ue&&_e.startOffset>=ue.childNodes.length){Ue(ue);return}}if(N){const ue=ne==="deleteContentBackward"?Lt(_e.startContainer,_e.startOffset):Re(_e.startContainer,_e.startOffset);$e(ue)&&L.preventDefault()}},[]),Z=C.jsx("div",{ref:d,className:`outline-none cursor-text ${s} ${o}`,contentEditable:!0,suppressContentEditableWarning:!0,onMouseDown:L=>{const ne=L.target.closest?.('[data-math-delim="1"]');if(!ne||!d.current)return;const N=ne.closest?.('[data-math="1"]');if(!N)return;L.preventDefault();const ke=window.getSelection();if(!ke)return;const ge=N.firstElementChild===ne,Se=document.createTreeWalker(N,NodeFilter.SHOW_TEXT,null);let _e=null,at=null,Ue;for(;Ue=Se.nextNode();)Ue.parentElement?.getAttribute("data-math-delim")!=="1"&&(_e||(_e=Ue),at=Ue);const $e=document.createRange();ge?_e?$e.setStart(_e,0):$e.setStart(N,1):at?$e.setStart(at,at.textContent?.length??0):$e.setStart(N,1),$e.collapse(!0),ke.removeAllRanges(),ke.addRange($e)},onBeforeInput:W,onInput:S,onBlur:I,onKeyDown:F},"editing"),V=C.jsxs("div",{ref:f,className:`outline-none ${h?"cursor-default":"cursor-text"} ${s} ${l}`,onMouseUp:h?void 0:H,onClick:h?void 0:D,children:[e.spans.length>0?Dg(e.spans):!h&&C.jsx("span",{className:"text-notion-text-secondary",children:c}),e.isStreaming&&C.jsx("span",{className:"inline-block w-0.5 h-4 bg-notion-text animate-pulse ml-0.5"})]},"viewing"),ve=t?u?u(Z,!0):Z:u?u(V,!1):V;return C.jsxs("div",{ref:p,className:"relative",children:[!h&&C.jsxs(C.Fragment,{children:[C.jsx(iae,{containerRef:p,onFormat:G,isMathSelection:q}),C.jsx(hae,{isOpen:y,onSubmit:ee,onCancel:$})]}),ve]})}function yE({block:e,isEditing:t,onContentChange:r,onStartEdit:n,onEndEdit:i,onKeyDown:a,readonly:s=!1}){return C.jsx(Ac,{block:e,isEditing:t,onContentChange:r,onStartEdit:n,onEndEdit:i,onKeyDown:a,className:"notion-paragraph text-notion-text leading-relaxed min-h-[1.5em]",placeholder:"Type something...",readonly:s})}const p4={1:"text-3xl font-bold",2:"text-2xl font-bold",3:"text-xl font-semibold",4:"text-lg font-semibold",5:"text-base font-semibold",6:"text-sm font-semibold"};function xE({block:e,isEditing:t,onContentChange:r,onStartEdit:n,onEndEdit:i,onKeyDown:a,readonly:s=!1}){const o=e.level||1,l=p4[o]||p4[1];return C.jsx(Ac,{block:e,isEditing:t,onContentChange:r,onStartEdit:n,onEndEdit:i,onKeyDown:a,className:`notion-heading ${l} text-notion-text`,placeholder:`Heading ${o}`,readonly:s,renderWrapper:(c,u)=>C.jsx("div",{role:"heading","aria-level":o,children:c})})}function vE(e){const{block:t,isEditing:r,onContentChange:n,onStartEdit:i,onEndEdit:a,onKeyDown:s,readonly:o=!1}=e,l=P.useRef(null);P.useEffect(()=>{r&&l.current&&(l.current.focus(),l.current.selectionStart=l.current.value.length,l.current.selectionEnd=l.current.value.length)},[r]);const c=f=>{n(f.target.value)},u=()=>{a()},h=f=>{if(f.key==="Tab"){f.preventDefault();const p=f.currentTarget,m=p.selectionStart,b=p.selectionEnd,y=p.value,v=y.substring(0,m)+" "+y.substring(b);n(v),setTimeout(()=>{p.selectionStart=p.selectionEnd=m+2},0);return}if(f.key==="Escape"){a();return}s(f)},d="```"+(t.language||"")+`
654
+ `;t.push(l)}t.push(o),a=s.type}return t.join("")}function mE({markdown:e,isStreaming:t}){const r=P.useRef([]);return{blocks:P.useMemo(()=>{const i=Ui(e,t,r.current);return r.current=i,i},[e,t])}}const Qie={"# ":1,"## ":2,"### ":3,"#### ":4,"##### ":5,"###### ":6},Zie={"- ":"unordered","* ":"unordered","1. ":"ordered"},c4={"\\* ":"* ","\\- ":"- ","\\> ":"> "};function gE({onBlockTypeChange:e}={}){const t=P.useCallback(i=>{for(const[a,s]of Object.entries(c4))if(i===a)return s;return null},[]),r=P.useCallback(i=>{for(const s of Object.keys(c4))if(i===s)return null;for(const[s,o]of Object.entries(Qie))if(i.startsWith(s))return{newType:"heading",newContent:i.slice(s.length),level:o};for(const[s,o]of Object.entries(Zie))if(i.startsWith(s))return{newType:"list",newContent:i.slice(s.length),listType:o};if(i.startsWith("> "))return{newType:"blockquote",newContent:i.slice(2)};if(i==="---"||i==="***"||i==="___")return{newType:"divider",newContent:""};const a=i.match(/^```([\w-]*)\s$/);return a?{newType:"code",newContent:"",language:a[1]||"text"}:null},[]),n=P.useCallback((i,a,s,o)=>{if(i.key===" "&&o===s.length){const l=s+" ";if(t(l)&&a.type==="paragraph")return!1;const u=r(l);if(u&&a.type==="paragraph")return i.preventDefault(),e?.(a.id,u.newType,u.newContent,{level:u.level,listType:u.listType,language:u.language}),!0;if(u&&u.newType==="list"&&a.type==="list"&&u.listType!==a.listType)return i.preventDefault(),e?.(a.id,"list",u.newContent,{listType:u.listType,depth:a.depth??0}),!0}if(i.key==="Enter"&&o===s.length){const l=s+" ",c=r(l);if(c?.newType==="code"&&a.type==="paragraph")return i.preventDefault(),e?.(a.id,c.newType,c.newContent,{language:c.language}),!0}return i.key==="Backspace"&&o===0&&a.type!=="paragraph"&&s===""?(i.preventDefault(),e?.(a.id,"paragraph",""),!0):(i.key==="Enter"&&a.type==="code",!1)},[r,t,e]);return{detectShortcut:r,detectEscape:t,handleKeyDown:n}}function Jie(e){const{bold:t,italic:r,strike:n}=e;return t&&r&&n?"boldItalicStrikethrough":t&&r?"boldItalic":t&&n?"boldStrikethrough":r&&n?"italicStrikethrough":t?"bold":r?"italic":n?"strikethrough":"plain"}function eae(e){const t={bold:!1,italic:!1,strike:!1};let r,n=!1,i=!1,a=!1,s=e.parentNode;for(;s&&s.nodeType===Node.ELEMENT_NODE;){const o=s,l=o.tagName.toLowerCase();l==="code"&&(n=!0),l==="a"&&(i=!0,r=o.getAttribute("href")||""),(l==="strong"||l==="b")&&(t.bold=!0),(l==="em"||l==="i")&&(t.italic=!0),(l==="s"||l==="del"||l==="strike")&&(t.strike=!0),l==="span"&&o.getAttribute("data-math")==="1"&&(a=!0),s=s.parentNode}return n?{style:"code"}:a?{style:"math"}:i?{style:"link",href:r}:{style:Jie(t)}}function Og(e){let t=e.parentNode;for(;t&&t.nodeType===Node.ELEMENT_NODE;){if(t.getAttribute("data-math-delim")==="1")return!0;t=t.parentNode}return!1}function bE(e,t){let r=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;r&&r!==t;){if(r.getAttribute("data-math")==="1")return r;r=r.parentElement}return null}function tae(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let r=null,n;for(;n=t.nextNode();)Og(n)||(r=n);return r}function rae(e,t,r){if(t.nodeType===Node.ELEMENT_NODE){const i=t;if(r>0)return i.childNodes[r-1]||null}if(t.nodeType===Node.TEXT_NODE&&r>0)return null;let n=t;for(;n&&n!==e;){if(n.previousSibling)return n.previousSibling;n=n.parentNode}return null}function u4(e,t,r){const n=bE(t,e);if(n){if(t.nodeType===Node.ELEMENT_NODE&&t===n){const a=n.childNodes.length;if(r>=a)return"afterMath"}return"insideMath"}const i=rae(e,t,r);if(i&&i.nodeType===Node.ELEMENT_NODE&&i.getAttribute("data-math")==="1")return"afterMath"}function aa(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let n;for(;n=r.nextNode();){const i=n.textContent||"";if(!i||Og(n))continue;const a=eae(n);if(a.style==="link"){t.push({text:i,style:"link",href:a.href});continue}if(a.style==="math"){t.push({text:i,style:"math"});continue}t.push({text:i,style:a.style})}return Bi(t)}function dn(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);if(!e.contains(r.startContainer)||!e.contains(r.endContainer))return null;const n=h4(e,r.startContainer,r.startOffset),i=h4(e,r.endContainer,r.endOffset);return n===null||i===null?null:{start:n,end:i,startAffinity:u4(e,r.startContainer,r.startOffset),endAffinity:u4(e,r.endContainer,r.endOffset)}}function h4(e,t,r){const n=document.createRange();try{n.selectNodeContents(e),n.setEnd(t,r)}catch{return null}const i=n.cloneContents();return i.querySelectorAll?.('[data-math-delim="1"]').forEach(a=>a.remove()),i.textContent?.length??0}function Ri(e,t,r,n={}){const i=d4(e,t,n.startAffinity),a=d4(e,r,n.endAffinity);if(!i||!a)return;const s=document.createRange();s.setStart(i.node,i.offset),s.setEnd(a.node,a.offset);const o=window.getSelection();o?.removeAllRanges(),o?.addRange(s)}function d4(e,t,r){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let i=0,a;for(;a=n.nextNode();){if(Og(a))continue;const s=a.textContent?.length||0;if(i+s>t)return{node:a,offset:Math.max(0,t-i)};if(i+s===t){const o=bE(a,e);if(o){const l=tae(o);if(l&&l===a&&r==="afterMath"){const c=o.parentNode;if(c){const u=Array.prototype.indexOf.call(c.childNodes,o);if(u!==-1)return{node:c,offset:u+1}}}}return{node:a,offset:s}}i+=s}return{node:e,offset:e.childNodes.length}}const nae=220,f4=8;function iae({containerRef:e,onFormat:t,isMathSelection:r}){const[n,i]=P.useState(!1),[a,s]=P.useState({top:0,left:0}),[o,l]=P.useState(!1),c=P.useRef(null),u=P.useCallback(()=>{const d=window.getSelection();if(!d||d.isCollapsed||!d.rangeCount){i(!1),l(!1);return}const f=d.getRangeAt(0);if(!e.current?.contains(f.commonAncestorContainer)){i(!1),l(!1);return}l(!!r?.(f));const p=f.getBoundingClientRect(),b=(c.current?.offsetWidth||nae)/2,y=p.left+p.width/2,v=b+f4,T=window.innerWidth-b-f4,A=Math.max(v,Math.min(T,y));s({top:p.top-45,left:A}),i(!0)},[e,r]);P.useEffect(()=>{const d=()=>{requestAnimationFrame(u)},f=()=>{i(!1)};return document.addEventListener("selectionchange",d),window.addEventListener("blur",f),()=>{document.removeEventListener("selectionchange",d),window.removeEventListener("blur",f)}},[u]),P.useEffect(()=>{const d=f=>{const p=f.target;!p.closest(".floating-toolbar")&&!e.current?.contains(p)&&i(!1)};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[e]);const h=P.useCallback(d=>{o&&d!=="math"||t(d)},[t,o]);return n?C.jsxs("div",{ref:c,className:"floating-toolbar fixed z-[100] flex items-center gap-1 px-2 py-1.5 bg-notion-bg-elevated rounded-lg shadow-lg border border-notion-border",style:{top:a.top,left:a.left,transform:"translateX(-50%)"},onMouseDown:d=>d.preventDefault(),children:[C.jsx(Cs,{onClick:()=>h("bold"),title:"Bold (⌘B)",disabled:o,children:C.jsx(aae,{})}),C.jsx(Cs,{onClick:()=>h("italic"),title:"Italic (⌘I)",disabled:o,children:C.jsx(sae,{})}),C.jsx(Cs,{onClick:()=>h("strikethrough"),title:"Strikethrough",disabled:o,children:C.jsx(oae,{})}),C.jsx(Cs,{onClick:()=>h("code"),title:"Code (⌘E)",disabled:o,children:C.jsx(lae,{})}),C.jsx(Cs,{onClick:()=>h("math"),title:"Math (LaTeX) (⌘M)",disabled:!1,children:C.jsx(uae,{})}),C.jsx("div",{className:"w-px h-5 bg-notion-border mx-1"}),C.jsx(Cs,{onClick:()=>h("link"),title:"Link (⌘K)",disabled:o,children:C.jsx(cae,{})})]}):null}function Cs({children:e,onClick:t,title:r,disabled:n}){return C.jsx("button",{type:"button",onClick:t,title:r,disabled:n,className:`p-1.5 rounded text-notion-text-secondary transition-colors ${n?"opacity-40 cursor-not-allowed":"hover:bg-notion-bg-hover hover:text-notion-text"}`,children:e})}function aae(){return C.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),C.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]})}function sae(){return C.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("line",{x1:"19",y1:"4",x2:"10",y2:"4"}),C.jsx("line",{x1:"14",y1:"20",x2:"5",y2:"20"}),C.jsx("line",{x1:"15",y1:"4",x2:"9",y2:"20"})]})}function oae(){return C.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("path",{d:"M16 4H9a3 3 0 0 0-3 3v1a3 3 0 0 0 3 3h6a3 3 0 0 1 3 3v1a3 3 0 0 1-3 3H8"}),C.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function lae(){return C.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("polyline",{points:"16 18 22 12 16 6"}),C.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function cae(){return C.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),C.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function uae(){return C.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("path",{d:"M4 4h6l4 16h6"}),C.jsx("path",{d:"M4 12h16"})]})}function hae({isOpen:e,onSubmit:t,onCancel:r,initialHref:n=""}){const[i,a]=P.useState(n),s=P.useRef(null),o=P.useRef(null);P.useEffect(()=>{e&&(a(n),requestAnimationFrame(()=>{s.current?.focus(),s.current?.select()}))},[e,n]);const l=P.useCallback(u=>{u.preventDefault();const h=i.trim();if(h){const d=h.match(/^https?:\/\//)?h:`https://${h}`;t(d)}},[i,t]),c=P.useCallback(u=>{u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),r())},[r]);return e?C.jsxs("div",{className:"link-modal fixed inset-0 z-[100] flex items-center justify-center",onKeyDown:c,children:[C.jsx("div",{className:"absolute inset-0 bg-black/20 backdrop-blur-[1px]",onClick:r}),C.jsxs("div",{ref:o,className:"relative bg-notion-bg-elevated rounded-xl shadow-2xl border border-notion-border/60 w-full max-w-md mx-4 overflow-hidden animate-in fade-in zoom-in-95 duration-150",style:{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05)"},children:[C.jsx("div",{className:"px-5 pt-5 pb-3",children:C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx("div",{className:"w-9 h-9 rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 flex items-center justify-center shadow-sm",children:C.jsx(dae,{className:"w-4.5 h-4.5 text-white"})}),C.jsxs("div",{children:[C.jsx("h3",{className:"text-[15px] font-semibold text-notion-text tracking-[-0.01em]",children:"Insert link"}),C.jsx("p",{className:"text-xs text-notion-text-secondary mt-0.5",children:"Enter a URL for the selected text"})]})]})}),C.jsxs("form",{onSubmit:l,className:"px-5 pb-5",children:[C.jsxs("div",{className:"relative",children:[C.jsx("div",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none",children:C.jsx(fae,{className:"w-4 h-4 text-notion-text-secondary"})}),C.jsx("input",{ref:s,type:"text",value:i,onChange:u=>a(u.target.value),placeholder:"https://example.com",className:"w-full pl-10 pr-4 py-2.5 text-sm bg-notion-hover/50 border border-notion-border/60 rounded-lg text-notion-text placeholder:text-notion-text-secondary/60 focus:outline-none focus:ring-2 focus:ring-blue-500/30 focus:border-blue-500/50 transition-all duration-150",autoComplete:"url",spellCheck:!1})]}),C.jsxs("div",{className:"flex items-center justify-end gap-2 mt-4",children:[C.jsx("button",{type:"button",onClick:r,className:"px-3.5 py-1.5 text-sm font-medium text-notion-text-secondary hover:text-notion-text hover:bg-notion-hover rounded-lg transition-colors duration-150",children:"Cancel"}),C.jsx("button",{type:"submit",disabled:!i.trim(),className:"px-4 py-1.5 text-sm font-medium text-white bg-blue-500 hover:bg-blue-600 disabled:opacity-40 disabled:cursor-not-allowed rounded-lg shadow-sm transition-all duration-150 hover:shadow",children:"Apply"})]})]}),C.jsx("div",{className:"px-5 py-2.5 bg-notion-hover/30 border-t border-notion-border/40",children:C.jsxs("div",{className:"flex items-center justify-between text-[11px] text-notion-text-secondary",children:[C.jsxs("span",{className:"flex items-center gap-1.5",children:[C.jsx("kbd",{className:"px-1.5 py-0.5 bg-notion-bg-elevated rounded border border-notion-border/60 font-mono text-[10px] shadow-sm",children:"Enter"}),C.jsx("span",{children:"to apply"})]}),C.jsxs("span",{className:"flex items-center gap-1.5",children:[C.jsx("kbd",{className:"px-1.5 py-0.5 bg-notion-bg-elevated rounded border border-notion-border/60 font-mono text-[10px] shadow-sm",children:"Esc"}),C.jsx("span",{children:"to cancel"})]})]})})]})]}):null}function dae({className:e}){return C.jsxs("svg",{className:e,width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),C.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function fae({className:e}){return C.jsxs("svg",{className:e,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("circle",{cx:"12",cy:"12",r:"10"}),C.jsx("path",{d:"M2 12h20"}),C.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}const pae=400;function Ac({block:e,isEditing:t,onContentChange:r,onStartEdit:n,onEndEdit:i,onKeyDown:a,className:s="",editingClassName:o="",viewClassName:l="",placeholder:c="Type something...",renderWrapper:u,readonly:h=!1}){const d=P.useRef(null),f=P.useRef(null),p=P.useRef(null),m=P.useRef(e.spans),b=P.useRef(null),[y,v]=P.useState(!1),T=P.useRef(null),A=P.useRef(null),E=P.useCallback(()=>t?d.current:f.current,[t]);P.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]),P.useEffect(()=>{if(t&&d.current){d.current.innerHTML=Ns(e.spans),m.current=e.spans,d.current.focus();const L=A.current;if(A.current=null,L)Ri(d.current,L.start,L.end,{startAffinity:L.startAffinity,endAffinity:L.endAffinity});else{const ae=document.createRange(),ne=window.getSelection();ae.selectNodeContents(d.current),ae.collapse(!1),ne?.removeAllRanges(),ne?.addRange(ae)}}},[t]),P.useEffect(()=>{if(!t||!d.current)return;const L=d.current,ae=Ns(e.spans),ne=L.innerHTML;if(ae===ne)return;const N=dn(L);L.innerHTML=ae,N&&Ri(L,N.start,N.end,{startAffinity:N.startAffinity,endAffinity:N.endAffinity}),m.current=e.spans},[e.spans,t]);const S=P.useCallback(()=>{if(!d.current)return;const L=dn(d.current),ae=aa(d.current);m.current=ae,r(ae);const N=Array.from(d.current.querySelectorAll('[data-math="1"]')).every(ge=>ge.querySelectorAll('[data-math-delim="1"]').length===2);b.current&&clearTimeout(b.current);const ke=()=>{if(!d.current)return;const ge=aa(d.current),Se=Ns(ge),_e=d.current.innerHTML;Se!==_e&&(d.current.innerHTML=Se,L&&Ri(d.current,L.start,L.end,{startAffinity:L.startAffinity,endAffinity:L.endAffinity}))};N?b.current=setTimeout(ke,pae):ke()},[r]),I=P.useCallback(L=>{if(!L.relatedTarget?.closest(".floating-toolbar")&&!L.relatedTarget?.closest(".link-modal")){if(d.current){const ae=aa(d.current);r(ae)}i()}},[r,i]),D=P.useCallback(()=>{!t&&!h&&n()},[t,n,h]),H=P.useCallback(()=>{if(!f.current)return;const L=f.current,ae=window.getSelection();if(!ae||ae.rangeCount===0)return;const ne=ae.getRangeAt(0);if(!L.contains(ne.startContainer)||!L.contains(ne.endContainer))return;const N=Ue=>(Ue.nodeType===Node.ELEMENT_NODE?Ue:Ue.parentElement)?.closest("[data-span-start]"),ke=(Ue,$e,ht)=>{if(Ue.nodeType!==Node.ELEMENT_NODE)return null;const dt=Ue,Lt=dt.childNodes[$e]||null,Re=$e>0&&dt.childNodes[$e-1]||null,ue=de=>de&&de.nodeType===Node.ELEMENT_NODE?de.closest("[data-span-start]"):null;return ht==="start"?ue(Lt)||ue(Re):ue(Re)||ue(Lt)},ge=(Ue,$e,ht)=>{let dt=N(Ue);if(dt||(dt=ke(Ue,$e,ht)),!dt)return null;const Lt=dt.getAttribute("data-span-start"),Re=dt.getAttribute("data-span-len");if(!Lt||!Re)return null;const ue=Number(Lt),de=Number(Re);if(dt.getAttribute("data-span-style")==="math")return{pos:ht==="start"?ue:ue+de,affinity:"insideMath"};try{const Bt=document.createRange();Bt.selectNodeContents(dt),Bt.setEnd(Ue,$e);const Jt=Bt.toString().length;return{pos:ue+Jt}}catch{return{pos:ht==="start"?ue:ue+de}}},Se=N(ne.startContainer)||ke(ne.startContainer,ne.startOffset,"start");if(ne.collapsed&&Se?.getAttribute("data-span-style")==="math"){const Ue=Number(Se.getAttribute("data-span-start")||"0");A.current={start:Ue,end:Ue,startAffinity:"insideMath",endAffinity:"insideMath"};return}const _e=ge(ne.startContainer,ne.startOffset,"start"),at=ge(ne.endContainer,ne.endOffset,"end");!_e||!at||(A.current={start:_e.pos,end:at.pos,startAffinity:_e.affinity,endAffinity:at.affinity})},[]),R=P.useCallback((L,ae)=>{const ne=E();if(!ne)return;const N=dn(ne);if(!(!N||N.start===N.end))if(t&&d.current){const ke=aa(d.current),ge=gl(ke,N.start,N.end,L,ae);d.current.innerHTML=Ns(ge),Ri(d.current,N.start,N.end,{startAffinity:N.startAffinity,endAffinity:N.endAffinity}),m.current=ge,r(ge)}else{const ke=gl(e.spans,N.start,N.end,L,ae);r(ke),window.getSelection()?.removeAllRanges()}},[t,e.spans,r,E]),F=P.useCallback(L=>{if((L.key==="ArrowRight"||L.key==="ArrowLeft")&&d.current){const ae=d.current,ne=window.getSelection();if(ne&&ne.rangeCount>0){const N=ne.getRangeAt(0);if(N.collapsed&&ae.contains(N.startContainer)){const ke=Re=>{let ue=Re.nodeType===Node.ELEMENT_NODE?Re:Re.parentElement;for(;ue&&ue!==ae;){if(ue.getAttribute("data-math")==="1")return ue;ue=ue.parentElement}return null},ge=Re=>{let ue=Re.parentNode;for(;ue&&ue.nodeType===Node.ELEMENT_NODE;){if(ue.getAttribute("data-math-delim")==="1")return!0;ue=ue.parentNode}return!1},Se=Re=>{const ue=document.createTreeWalker(Re,NodeFilter.SHOW_TEXT,null);let de;for(;de=ue.nextNode();)if(!ge(de))return de;return null},_e=Re=>{const ue=document.createTreeWalker(Re,NodeFilter.SHOW_TEXT,null);let de=null,pt;for(;pt=ue.nextNode();)ge(pt)||(de=pt);return de},at=Re=>{const ue=Re.parentNode;if(!ue)return;const de=Array.prototype.indexOf.call(ue.childNodes,Re);if(de===-1)return;const pt=document.createRange();pt.setStart(ue,de+1),pt.collapse(!0),ne.removeAllRanges(),ne.addRange(pt)},Ue=Re=>{const ue=Re.parentNode;if(!ue)return;const de=Array.prototype.indexOf.call(ue.childNodes,Re);if(de===-1)return;const pt=document.createRange();pt.setStart(ue,de),pt.collapse(!0),ne.removeAllRanges(),ne.addRange(pt)},$e=Re=>{const ue=Se(Re),de=document.createRange();ue?de.setStart(ue,0):de.setStart(Re,1),de.collapse(!0),ne.removeAllRanges(),ne.addRange(de)},ht=Re=>{const ue=_e(Re),de=document.createRange();ue?de.setStart(ue,ue.textContent?.length??0):de.setStart(Re,1),de.collapse(!0),ne.removeAllRanges(),ne.addRange(de)},dt=()=>{const Re=N.startContainer,ue=N.startOffset;if(Re.nodeType===Node.ELEMENT_NODE){const pt=Re;if(ue>0)return pt.childNodes[ue-1]||null}if(Re.nodeType===Node.TEXT_NODE&&ue>0)return null;let de=Re;for(;de&&de!==ae;){if(de.previousSibling)return de.previousSibling;de=de.parentNode}return null},Lt=()=>{const Re=N.startContainer,ue=N.startOffset;if(Re.nodeType===Node.ELEMENT_NODE)return Re.childNodes[ue]||null;if(Re.nodeType===Node.TEXT_NODE){const pt=Re.textContent||"";if(ue<pt.length)return null}let de=Re;for(;de&&de!==ae;){if(de.nextSibling)return de.nextSibling;de=de.parentNode}return null};if(L.key==="ArrowRight"){const Re=ke(N.startContainer);if(Re){const de=_e(Re);if(de&&N.startContainer===de&&N.startOffset===(de.textContent?.length??0)){L.preventDefault(),at(Re);return}}const ue=Lt();if(ue&&ue.nodeType===Node.ELEMENT_NODE){const de=ue;if(de.getAttribute("data-math")==="1"){L.preventDefault(),$e(de);return}}}if(L.key==="ArrowLeft"){const Re=dt();if(Re&&Re.nodeType===Node.ELEMENT_NODE){const de=Re;if(de.getAttribute("data-math")==="1"){L.preventDefault(),ht(de);return}}const ue=ke(N.startContainer);if(ue){const de=Se(ue);if(de&&N.startContainer===de&&N.startOffset===0){L.preventDefault(),Ue(ue);return}}}}}}if((L.metaKey||L.ctrlKey)&&d.current)switch(L.key.toLowerCase()){case"b":L.preventDefault(),R("bold");return;case"i":L.preventDefault(),R("italic");return;case"e":L.preventDefault(),R("code");return;case"m":L.preventDefault(),R("math");return;case"k":L.preventDefault();const ae=dn(d.current);ae&&ae.start!==ae.end&&(T.current=ae,v(!0));return}if(L.key==="Escape"){if(d.current){const ae=aa(d.current);r(ae)}i();return}a(L)},[R,r,i,a]),G=P.useCallback(L=>{const ae=E();if(ae){if(L==="link"){const ne=dn(ae);ne&&ne.start!==ne.end&&(T.current=ne,v(!0));return}R(L)}},[R,E]),ee=P.useCallback(L=>{if(v(!1),!T.current)return;const ae=T.current;if(T.current=null,t&&d.current){const ne=aa(d.current),N=gl(ne,ae.start,ae.end,"link",{href:L});d.current.innerHTML=Ns(N),Ri(d.current,ae.start,ae.end,{startAffinity:ae.startAffinity,endAffinity:ae.endAffinity}),m.current=N,r(N),d.current.focus()}else{const ne=gl(e.spans,ae.start,ae.end,"link",{href:L});r(ne),window.getSelection()?.removeAllRanges()}},[t,e.spans,r]),$=P.useCallback(()=>{v(!1),T.current=null,t&&d.current?.focus()},[t]),q=P.useCallback(L=>{if(t&&d.current){const ae=dn(d.current);if(!ae||ae.start===ae.end)return!1;const ne=aa(d.current);let N=0;for(const ke of ne){const ge=N,Se=N+ke.text.length;if(Se>ae.start&&ge<ae.end&&ke.style==="math")return!0;N=Se}return!1}if(!t&&f.current){const ae=f.current,ne=Array.from(ae.querySelectorAll('[data-span-style="math"]'));for(const N of ne)try{if(L.intersectsNode(N))return!0}catch{}}return!1},[t]),W=P.useCallback(L=>{const ne=L.nativeEvent.inputType,N=ne==="deleteContentBackward"||ne==="deleteContentForward",ke=ne==="insertText"||ne==="insertCompositionText"||ne==="insertFromPaste";if(!N&&!ke)return;const ge=d.current;if(!ge)return;const Se=window.getSelection();if(!Se||Se.rangeCount===0)return;const _e=Se.getRangeAt(0),at=ue=>{let de=ue.nodeType===Node.ELEMENT_NODE?ue:ue.parentElement;for(;de&&de!==ge;){if(de.getAttribute("data-math")==="1")return de;de=de.parentElement}return null},Ue=ue=>{const de=ue.parentNode;if(!de)return;const pt=Array.prototype.indexOf.call(de.childNodes,ue);if(pt===-1)return;const Bt=document.createRange();Bt.setStart(de,pt+1),Bt.collapse(!0),Se.removeAllRanges(),Se.addRange(Bt)},$e=ue=>{if(!ue)return!1;if(ue.nodeType===Node.ELEMENT_NODE){const pt=ue;return pt.getAttribute("data-math-delim")==="1"?!0:!!pt.querySelector('[data-math-delim="1"]')}const de=ue.parentElement;return!!de&&de.getAttribute("data-math-delim")==="1"},ht=ue=>{let de=ue;for(;de&&de!==ge;){if(de.previousSibling)return de.previousSibling;de=de.parentNode}return null},dt=ue=>{let de=ue;for(;de&&de!==ge;){if(de.nextSibling)return de.nextSibling;de=de.parentNode}return null},Lt=(ue,de)=>{if(ue.nodeType===Node.ELEMENT_NODE){const pt=ue;return de>0?pt.childNodes[de-1]||null:ht(ue)}return ue.nodeType===Node.TEXT_NODE&&de>0?null:ht(ue)},Re=(ue,de)=>{if(ue.nodeType===Node.ELEMENT_NODE)return ue.childNodes[de]||dt(ue);if(ue.nodeType===Node.TEXT_NODE){const pt=ue.textContent||"";return de<pt.length?null:dt(ue)}return dt(ue)};if(!_e.collapsed){_e.cloneContents().querySelector?.('[data-math-delim="1"]')&&N&&L.preventDefault();return}if(ke){const ue=at(_e.startContainer);if(ue&&_e.startContainer===ue&&_e.startOffset>=ue.childNodes.length){Ue(ue);return}}if(N){const ue=ne==="deleteContentBackward"?Lt(_e.startContainer,_e.startOffset):Re(_e.startContainer,_e.startOffset);$e(ue)&&L.preventDefault()}},[]),Z=C.jsx("div",{ref:d,className:`outline-none cursor-text ${s} ${o}`,contentEditable:!0,suppressContentEditableWarning:!0,onMouseDown:L=>{const ne=L.target.closest?.('[data-math-delim="1"]');if(!ne||!d.current)return;const N=ne.closest?.('[data-math="1"]');if(!N)return;L.preventDefault();const ke=window.getSelection();if(!ke)return;const ge=N.firstElementChild===ne,Se=document.createTreeWalker(N,NodeFilter.SHOW_TEXT,null);let _e=null,at=null,Ue;for(;Ue=Se.nextNode();)Ue.parentElement?.getAttribute("data-math-delim")!=="1"&&(_e||(_e=Ue),at=Ue);const $e=document.createRange();ge?_e?$e.setStart(_e,0):$e.setStart(N,1):at?$e.setStart(at,at.textContent?.length??0):$e.setStart(N,1),$e.collapse(!0),ke.removeAllRanges(),ke.addRange($e)},onBeforeInput:W,onInput:S,onBlur:I,onKeyDown:F},"editing"),V=C.jsxs("div",{ref:f,className:`outline-none ${h?"cursor-default":"cursor-text"} ${s} ${l}`,onMouseUp:h?void 0:H,onClick:h?void 0:D,children:[e.spans.length>0?Dg(e.spans):!h&&C.jsx("span",{className:"text-notion-text-secondary",children:c}),e.isStreaming&&C.jsx("span",{className:"inline-block w-0.5 h-4 bg-notion-text animate-pulse ml-0.5"})]},"viewing"),ve=t?u?u(Z,!0):Z:u?u(V,!1):V;return C.jsxs("div",{ref:p,className:"relative",children:[!h&&C.jsxs(C.Fragment,{children:[C.jsx(iae,{containerRef:p,onFormat:G,isMathSelection:q}),C.jsx(hae,{isOpen:y,onSubmit:ee,onCancel:$})]}),ve]})}function yE({block:e,isEditing:t,onContentChange:r,onStartEdit:n,onEndEdit:i,onKeyDown:a,readonly:s=!1}){return C.jsx(Ac,{block:e,isEditing:t,onContentChange:r,onStartEdit:n,onEndEdit:i,onKeyDown:a,className:"notion-paragraph text-notion-text leading-relaxed min-h-[1.5em]",placeholder:"Type something...",readonly:s})}const p4={1:"text-3xl font-bold",2:"text-2xl font-bold",3:"text-xl font-semibold",4:"text-lg font-semibold",5:"text-base font-semibold",6:"text-sm font-semibold"};function xE({block:e,isEditing:t,onContentChange:r,onStartEdit:n,onEndEdit:i,onKeyDown:a,readonly:s=!1}){const o=e.level||1,l=p4[o]||p4[1];return C.jsx(Ac,{block:e,isEditing:t,onContentChange:r,onStartEdit:n,onEndEdit:i,onKeyDown:a,className:`notion-heading ${l} text-notion-text`,placeholder:`Heading ${o}`,readonly:s,renderWrapper:(c,u)=>C.jsx("div",{role:"heading","aria-level":o,children:c})})}function vE(e){const{block:t,isEditing:r,onContentChange:n,onStartEdit:i,onEndEdit:a,onKeyDown:s,readonly:o=!1}=e,l=P.useRef(null);P.useEffect(()=>{r&&l.current&&(l.current.focus(),l.current.selectionStart=l.current.value.length,l.current.selectionEnd=l.current.value.length)},[r]);const c=f=>{n(f.target.value)},u=()=>{a()},h=f=>{if(f.key==="Tab"){f.preventDefault();const p=f.currentTarget,m=p.selectionStart,b=p.selectionEnd,y=p.value,v=y.substring(0,m)+" "+y.substring(b);n(v),setTimeout(()=>{p.selectionStart=p.selectionEnd=m+2},0);return}if(f.key==="Escape"){a();return}s(f)},d="```"+(t.language||"")+`
655
655
  `+t.content+"\n```";return r?C.jsxs("div",{className:"notion-code-block rounded-md bg-notion-code-bg border border-notion-border overflow-hidden",children:[C.jsx("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-notion-border bg-notion-hover",children:C.jsx("span",{className:"text-xs text-notion-text-secondary font-mono",children:t.language||"text"})}),C.jsx("textarea",{ref:l,className:"w-full p-3 font-mono text-sm bg-transparent text-notion-text outline-none resize-none",value:t.content,onChange:c,onBlur:u,onKeyDown:h,rows:Math.max(3,t.content.split(`
656
656
  `).length),spellCheck:!1})]}):C.jsxs("div",{className:`notion-code-block ${o?"cursor-default":"cursor-text"}`,onClick:o?void 0:i,children:[C.jsx(Ka,{plugins:{code:J5},shikiTheme:["min-light","min-dark"],isAnimating:t.isStreaming,children:d}),t.isStreaming&&C.jsx("div",{className:"flex justify-end px-3 py-1",children:C.jsx("span",{className:"inline-block w-0.5 h-4 bg-notion-text animate-pulse"})})]})}function kE({block:e,isEditing:t,onContentChange:r,onStartEdit:n,onEndEdit:i,readonly:a=!1}){const[s,o]=P.useState(!1),[l,c]=P.useState(!0),u=()=>{c(!1),o(!1)},h=()=>{c(!1),o(!0)},d=f=>{r(f.target.value),o(!1),c(!0)};return t?C.jsxs("div",{className:"notion-image-block space-y-2",children:[C.jsx("input",{type:"text",className:"w-full px-3 py-2 text-sm border border-notion-border rounded bg-notion-bg-elevated text-notion-text outline-none focus:border-blue-500",value:e.content,onChange:d,onBlur:i,placeholder:"Enter image URL...",autoFocus:!0}),e.content&&!s&&C.jsx("img",{src:e.content,alt:"Preview",className:"max-w-full h-auto rounded",onLoad:u,onError:h})]}):e.content?s?C.jsxs("div",{className:`notion-image-block border border-red-200 bg-red-50 rounded-lg p-4 ${a?"cursor-default":"cursor-pointer"}`,onClick:a?void 0:n,children:[C.jsx("p",{className:"text-sm text-red-600",children:"Failed to load image"}),C.jsx("p",{className:"text-xs text-red-400 truncate",children:e.content})]}):C.jsxs("div",{className:`notion-image-block relative group ${a?"":"cursor-pointer"}`,onClick:a?void 0:n,children:[l&&C.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-notion-hover rounded",children:C.jsx("div",{className:"w-6 h-6 border-2 border-notion-text-secondary border-t-transparent rounded-full animate-spin"})}),C.jsx("img",{src:e.content,alt:"Image",className:`max-w-full h-auto rounded ${a?"cursor-default":"cursor-pointer"} transition-opacity ${l?"opacity-0":"opacity-100"}`,onLoad:u,onError:h}),e.isStreaming&&C.jsx("div",{className:"absolute bottom-2 right-2 px-2 py-1 bg-black/50 text-white text-xs rounded",children:"Loading..."})]}):a?null:C.jsx("div",{className:"notion-image-block border-2 border-dashed border-notion-border rounded-lg p-8 text-center cursor-pointer hover:bg-notion-hover transition-colors",onClick:n,children:C.jsxs("div",{className:"text-notion-text-secondary",children:[C.jsx("svg",{className:"w-12 h-12 mx-auto mb-2 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),C.jsx("p",{className:"text-sm",children:"Click to add image URL"})]})})}function wE(e){const{block:t,isEditing:r,onContentChange:n,onStartEdit:i,onEndEdit:a,onKeyDown:s,readonly:o=!1}=e,l=P.useRef(null);P.useEffect(()=>{r&&l.current&&(l.current.focus(),l.current.selectionStart=l.current.value.length,l.current.selectionEnd=l.current.value.length)},[r]);const c=f=>{n(f.target.value)},u=()=>{a()},h=f=>{if(f.key==="Escape"){a();return}s(f)},d=`$$
657
657
  ${t.content}