@datalayer/agent-runtimes 1.6.97 → 1.6.98

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 (356) hide show
  1. package/dist-embed/chunks/{AgentDetails-B5csrqWi.js → AgentDetails-CqMfY8zN.js} +1 -1
  2. package/dist-embed/chunks/{AgentDetailsDialog-gGnV2mTY.js → AgentDetailsDialog-lxnKA_dF.js} +1 -1
  3. package/dist-embed/chunks/{CellSidebarExtension-B4QBsTRy.js → CellSidebarExtension-CrdbRLaE.js} +1 -1
  4. package/dist-embed/chunks/ChatView-B9oVgZ72.js +32 -0
  5. package/dist-embed/chunks/{CollapsiblePlugin-vjE7wFOu.js → CollapsiblePlugin-CnG1qA1e.js} +1 -1
  6. package/dist-embed/chunks/{ContextPie-Dqj618Q2.js → ContextPie-DAZz2yzl.js} +1 -1
  7. package/dist-embed/chunks/{DeckComponent-CSxElvrq.js → DeckComponent-qAMqKLzs.js} +1 -1
  8. package/dist-embed/chunks/{DeckRenderer-DcyoBlq5.js → DeckRenderer-DQmjQ_vE.js} +2 -2
  9. package/dist-embed/chunks/{DeckStage-DJJkDWlM.js → DeckStage-LDi6nZOg.js} +2 -2
  10. package/dist-embed/chunks/{DiagramView-D8385Uvy.js → DiagramView-CpCoC99y.js} +1 -1
  11. package/dist-embed/chunks/{DocumentView-pHXY2GUy.js → DocumentView-B-lWAJgm.js} +1 -1
  12. package/dist-embed/chunks/{DrawingStage-CBhXNP2j.js → DrawingStage-DEeTWKLT.js} +1 -1
  13. package/dist-embed/chunks/{EphemeralDocument-C12bJ2Zi.js → EphemeralDocument-CZNRDs_b.js} +1 -1
  14. package/dist-embed/chunks/{EphemeralNotebook-DW9uU70P.js → EphemeralNotebook-BDutT9GQ.js} +1 -1
  15. package/dist-embed/chunks/{ExcalidrawComponent-BvB8s8DF.js → ExcalidrawComponent-CmJy7bb4.js} +1 -1
  16. package/dist-embed/chunks/{ExcalidrawModal-CLGo6lxD.js → ExcalidrawModal-D_DmAro7.js} +1 -1
  17. package/dist-embed/chunks/{FormulaBar-IFoQ6yN8.js → FormulaBar-f9U7lupQ.js} +1 -1
  18. package/dist-embed/chunks/{JupyterLexicalExtension-DhlGUbc0.js → JupyterLexicalExtension-DpGAnn7v.js} +9 -9
  19. package/dist-embed/chunks/{KernelVariables-COPHuvQe.js → KernelVariables-BIWju6rZ.js} +1 -1
  20. package/dist-embed/chunks/{LexicalToolRegistry-mRwpy8uR.js → LexicalToolRegistry-BqxU1w4N.js} +1 -1
  21. package/dist-embed/chunks/{NotebookToolSurfaces-f0K0s6tk.js → NotebookToolSurfaces-CqU9CVCl.js} +1 -1
  22. package/dist-embed/chunks/{NotebookView-CkgduWGZ.js → NotebookView-CpOBHIut.js} +1 -1
  23. package/dist-embed/chunks/{Output-BlVb0nsN.js → Output-DLpf2Of9.js} +6 -6
  24. package/dist-embed/chunks/{SandboxDetailsDialog-BWr3ZHmy.js → SandboxDetailsDialog-yUjpxBdw.js} +1 -1
  25. package/dist-embed/chunks/{SchemaForm-BYx28f9R.js → SchemaForm-N0hu4z_p.js} +1 -1
  26. package/dist-embed/chunks/{SheetStage-UDDuD0c-.js → SheetStage-gUVhALxR.js} +1 -1
  27. package/dist-embed/chunks/{SheetTabs-CRqCh6SH.js → SheetTabs-sx_-jWyq.js} +1 -1
  28. package/dist-embed/chunks/{SignInIcon-C0lCx6yN.js → SignInIcon-XIbntAUw.js} +1 -1
  29. package/dist-embed/chunks/{SpreadsheetPreviewView-D3bm2FuW.js → SpreadsheetPreviewView-C9LaI5mp.js} +1 -1
  30. package/dist-embed/chunks/{SpreadsheetView-C0jqVlH0.js → SpreadsheetView-FfnOGHeU.js} +1 -1
  31. package/dist-embed/chunks/{WidgetVariableView-CEWGssAP.js → WidgetVariableView-CKcw-pPX.js} +1 -1
  32. package/dist-embed/chunks/{YouTubePlugin-CwtVeT4X.js → YouTubePlugin-DUDVTb3B.js} +1 -1
  33. package/dist-embed/chunks/{abnfDiagram-VCTEODGH-JXHACDBz.js → abnfDiagram-VCTEODGH-B0MQRzNo.js} +1 -1
  34. package/dist-embed/chunks/{abnfDiagram-VCTEODGH-C-5M28HY.js → abnfDiagram-VCTEODGH-BM2pAacI.js} +1 -1
  35. package/dist-embed/chunks/{abnfDiagram-VCTEODGH-Bwv6WjS-.js → abnfDiagram-VCTEODGH-fcR8gNdJ.js} +1 -1
  36. package/dist-embed/chunks/{ar-SA-G6X2FPQ2-BM34ImM5.js → ar-SA-G6X2FPQ2-BfVZMCow.js} +1 -1
  37. package/dist-embed/chunks/{architectureDiagram-5GKGNRK7-DpujQos2.js → architectureDiagram-5GKGNRK7-CnP0s6uJ.js} +1 -1
  38. package/dist-embed/chunks/{architectureDiagram-5GKGNRK7-KCUb-Mex.js → architectureDiagram-5GKGNRK7-Cpu0tfD1.js} +1 -1
  39. package/dist-embed/chunks/{architectureDiagram-5GKGNRK7-CAgLqF4a.js → architectureDiagram-5GKGNRK7-GZ5981UE.js} +1 -1
  40. package/dist-embed/chunks/{az-AZ-76LH7QW2-ClbRZkch.js → az-AZ-76LH7QW2-BeD9jzcd.js} +1 -1
  41. package/dist-embed/chunks/{bg-BG-XCXSNQG7-C9-xTdL3.js → bg-BG-XCXSNQG7-VUraF-a0.js} +1 -1
  42. package/dist-embed/chunks/{blockDiagram-868be97b-BIKcIMyQ.js → blockDiagram-868be97b-BK7odeOZ.js} +1 -1
  43. package/dist-embed/chunks/{blockDiagram-I7D4REHJ-6rNTajX4.js → blockDiagram-I7D4REHJ-BMQSOcOL.js} +1 -1
  44. package/dist-embed/chunks/{blockDiagram-I7D4REHJ-Dk3ubhN6.js → blockDiagram-I7D4REHJ-CZlh2u1A.js} +1 -1
  45. package/dist-embed/chunks/{blockDiagram-I7D4REHJ-Dg9wRDSP.js → blockDiagram-I7D4REHJ-DiBWN476.js} +1 -1
  46. package/dist-embed/chunks/{bn-BD-2XOGV67Q-yHaSEyU7.js → bn-BD-2XOGV67Q-DjghL9Ba.js} +1 -1
  47. package/dist-embed/chunks/{c4Diagram-3f4bdde3-DX31j648.js → c4Diagram-3f4bdde3-CMf0cOcM.js} +1 -1
  48. package/dist-embed/chunks/{c4Diagram-7LVT6UL2-Blhl5Ivg.js → c4Diagram-7LVT6UL2-BYPUXI1P.js} +1 -1
  49. package/dist-embed/chunks/{c4Diagram-7LVT6UL2-DotUFrPy.js → c4Diagram-7LVT6UL2-plU3oizm.js} +1 -1
  50. package/dist-embed/chunks/{c4Diagram-7LVT6UL2-kO868bTp.js → c4Diagram-7LVT6UL2-qmYneJtb.js} +1 -1
  51. package/dist-embed/chunks/{ca-ES-6MX7JW3Y-Co3yrY97.js → ca-ES-6MX7JW3Y-J6FuV-ut.js} +1 -1
  52. package/dist-embed/chunks/{celltoolbartracker-DzouPWbZ.js → celltoolbartracker-0MFBHjtq.js} +1 -1
  53. package/dist-embed/chunks/{chunk-2Q5K7J3B-BC8SN0W_.js → chunk-2Q5K7J3B-B5DIEbuU.js} +1 -1
  54. package/dist-embed/chunks/{chunk-2Q5K7J3B-BB4YNChb.js → chunk-2Q5K7J3B-BfCPaxeK.js} +1 -1
  55. package/dist-embed/chunks/{chunk-2Q5K7J3B-COf2HInf.js → chunk-2Q5K7J3B-Cj3jAIkT.js} +1 -1
  56. package/dist-embed/chunks/{chunk-5VM5RSS4-C3jze8cb.js → chunk-5VM5RSS4-BZGDG9GF.js} +1 -1
  57. package/dist-embed/chunks/{chunk-5VM5RSS4-DiJWlaEG.js → chunk-5VM5RSS4-DYeTGvz7.js} +1 -1
  58. package/dist-embed/chunks/{chunk-5VM5RSS4-cXmhCpsu.js → chunk-5VM5RSS4-g3id5Hpo.js} +1 -1
  59. package/dist-embed/chunks/{chunk-F27PBJKO-BXMw8fcU.js → chunk-F27PBJKO-DvclqQhV.js} +1 -1
  60. package/dist-embed/chunks/{chunk-F27PBJKO-DaAtxZ3_.js → chunk-F27PBJKO-S3msebgW.js} +1 -1
  61. package/dist-embed/chunks/{chunk-F27PBJKO-DZJGymAh.js → chunk-F27PBJKO-kACIRR-8.js} +1 -1
  62. package/dist-embed/chunks/{chunk-IMKFNOWR-CR3C15pD.js → chunk-IMKFNOWR-Ch7v5XHt.js} +1 -1
  63. package/dist-embed/chunks/{chunk-IMKFNOWR-C4f2Xvwg.js → chunk-IMKFNOWR-DjIARM3y.js} +1 -1
  64. package/dist-embed/chunks/{chunk-IMKFNOWR-Ct7GddYG.js → chunk-IMKFNOWR-SiS0o9FR.js} +1 -1
  65. package/dist-embed/chunks/{chunk-JWPE2WC7-9KydF4Cl.js → chunk-JWPE2WC7-BwLKeh91.js} +1 -1
  66. package/dist-embed/chunks/{chunk-JWPE2WC7-B54sCK-y.js → chunk-JWPE2WC7-CVacxpin.js} +1 -1
  67. package/dist-embed/chunks/{chunk-JWPE2WC7-D9_2-oUP.js → chunk-JWPE2WC7-M6oulZhu.js} +1 -1
  68. package/dist-embed/chunks/{chunk-POPQ4Y6H-BaMRoQVu.js → chunk-POPQ4Y6H-BCHaCocF.js} +1 -1
  69. package/dist-embed/chunks/{chunk-POPQ4Y6H-BgtIg837.js → chunk-POPQ4Y6H-DacAiEUG.js} +1 -1
  70. package/dist-embed/chunks/{chunk-POPQ4Y6H-Db5GUGhc.js → chunk-POPQ4Y6H-DicNgh7k.js} +1 -1
  71. package/dist-embed/chunks/{chunk-SVP7TREG-CeM8qf58.js → chunk-SVP7TREG-3X_ReA6d.js} +1 -1
  72. package/dist-embed/chunks/{chunk-SVP7TREG-F4uclbvM.js → chunk-SVP7TREG-COLBrDOd.js} +1 -1
  73. package/dist-embed/chunks/{chunk-SVP7TREG-BYkF4CFZ.js → chunk-SVP7TREG-Cit7UeF2.js} +1 -1
  74. package/dist-embed/chunks/{chunk-TICWLB2K-D-Wwl7XB.js → chunk-TICWLB2K-C4D-h9t1.js} +1 -1
  75. package/dist-embed/chunks/{chunk-TICWLB2K-BFf8Le3M.js → chunk-TICWLB2K-DfGZ1S46.js} +1 -1
  76. package/dist-embed/chunks/{chunk-TICWLB2K-BHq2Ystt.js → chunk-TICWLB2K-TaUeWpZb.js} +1 -1
  77. package/dist-embed/chunks/{chunk-XXDRQBXY-BHMLcU9A.js → chunk-XXDRQBXY-B6fuzLc9.js} +1 -1
  78. package/dist-embed/chunks/{chunk-XXDRQBXY-BlVD4u-l.js → chunk-XXDRQBXY-Bo_XDdf-.js} +1 -1
  79. package/dist-embed/chunks/{chunk-XXDRQBXY-DTCYLV17.js → chunk-XXDRQBXY-Bz5lFaJG.js} +1 -1
  80. package/dist-embed/chunks/{classDiagram-ZZMXUADV-B1H5YR5N.js → classDiagram-ZZMXUADV-DDZ5U8jk.js} +1 -1
  81. package/dist-embed/chunks/{classDiagram-ZZMXUADV-C69Ng482.js → classDiagram-ZZMXUADV-DpQTfwXC.js} +1 -1
  82. package/dist-embed/chunks/{classDiagram-ZZMXUADV-fah4qQBw.js → classDiagram-ZZMXUADV-orzU8a0Z.js} +1 -1
  83. package/dist-embed/chunks/{classDiagram-f62afe4f-BpmDNOf_.js → classDiagram-f62afe4f-CNI3U8Mt.js} +1 -1
  84. package/dist-embed/chunks/{classDiagram-v2-604399ef-DXSVTZaU.js → classDiagram-v2-604399ef-CLQHn0oB.js} +1 -1
  85. package/dist-embed/chunks/{classDiagram-v2-VYDZK3BY-B1H5YR5N.js → classDiagram-v2-VYDZK3BY-DDZ5U8jk.js} +1 -1
  86. package/dist-embed/chunks/{classDiagram-v2-VYDZK3BY-C69Ng482.js → classDiagram-v2-VYDZK3BY-DpQTfwXC.js} +1 -1
  87. package/dist-embed/chunks/{classDiagram-v2-VYDZK3BY-fah4qQBw.js → classDiagram-v2-VYDZK3BY-orzU8a0Z.js} +1 -1
  88. package/dist-embed/chunks/{code-block-IT6T5CEO-BzV6dOeo.js → code-block-IT6T5CEO-DjmCcA6a.js} +1 -1
  89. package/dist-embed/chunks/{component-DQ0vRpmL.js → component-B62XEB_I.js} +1 -1
  90. package/dist-embed/chunks/{core-YLcIWC_X.js → core-CsMGn5rr.js} +1 -1
  91. package/dist-embed/chunks/{cose-bilkent-JH36ORCC-DUgmse9Z.js → cose-bilkent-JH36ORCC-B_IELYPJ.js} +1 -1
  92. package/dist-embed/chunks/{cose-bilkent-JH36ORCC-CFC6-4OL.js → cose-bilkent-JH36ORCC-CE9lt3OO.js} +1 -1
  93. package/dist-embed/chunks/{cose-bilkent-JH36ORCC-B13OR0_2.js → cose-bilkent-JH36ORCC-CJiHk5L4.js} +1 -1
  94. package/dist-embed/chunks/{createText-aed3d8b3-Cft4GZJy.js → createText-aed3d8b3-DTAS6DfQ.js} +1 -1
  95. package/dist-embed/chunks/{cs-CZ-2BRQDIVT-BXDHJOy0.js → cs-CZ-2BRQDIVT-BJRVSuxc.js} +1 -1
  96. package/dist-embed/chunks/{cynefinDiagram-5FMLGOSQ-Baap8yDb.js → cynefinDiagram-5FMLGOSQ-B2073FgP.js} +1 -1
  97. package/dist-embed/chunks/{cynefinDiagram-5FMLGOSQ-B7_plLD6.js → cynefinDiagram-5FMLGOSQ-CyHkNAUC.js} +1 -1
  98. package/dist-embed/chunks/{cynefinDiagram-5FMLGOSQ-kHl-Cu_e.js → cynefinDiagram-5FMLGOSQ-HsJLw9Ow.js} +1 -1
  99. package/dist-embed/chunks/{da-DK-5WZEPLOC-Bv_vMRQS.js → da-DK-5WZEPLOC-DmvpQmCz.js} +1 -1
  100. package/dist-embed/chunks/{dagre-GXQ25YYZ-l25rB3RT.js → dagre-GXQ25YYZ-BkxHUUfX.js} +1 -1
  101. package/dist-embed/chunks/{dagre-GXQ25YYZ-DLkLgXkX.js → dagre-GXQ25YYZ-DzmuuJ_r.js} +1 -1
  102. package/dist-embed/chunks/{dagre-GXQ25YYZ-De_KrzkJ.js → dagre-GXQ25YYZ-R_lzFrVl.js} +1 -1
  103. package/dist-embed/chunks/{de-DE-XR44H4JA-Bko2COU8.js → de-DE-XR44H4JA-aRPZsjh8.js} +1 -1
  104. package/dist-embed/chunks/{diagram-S7CK7UJ4-uPenisEP.js → diagram-S7CK7UJ4-1KpTTJPB.js} +1 -1
  105. package/dist-embed/chunks/{diagram-S7CK7UJ4-uDpubVD_.js → diagram-S7CK7UJ4-BANHWGqU.js} +1 -1
  106. package/dist-embed/chunks/{diagram-S7CK7UJ4-BiZ-ex3Q.js → diagram-S7CK7UJ4-DsEYZOqE.js} +1 -1
  107. package/dist-embed/chunks/{diagram-UQ7AKVKN-FzXo7K78.js → diagram-UQ7AKVKN-B-SbMZjY.js} +1 -1
  108. package/dist-embed/chunks/{diagram-UQ7AKVKN-BzBp2O2s.js → diagram-UQ7AKVKN-BadWwEqS.js} +1 -1
  109. package/dist-embed/chunks/{diagram-UQ7AKVKN-DbPeWUnW.js → diagram-UQ7AKVKN-E5q5_JWL.js} +1 -1
  110. package/dist-embed/chunks/{diagram-VSXAHHWV-DLDYySj7.js → diagram-VSXAHHWV-B-ZTas3h.js} +1 -1
  111. package/dist-embed/chunks/{diagram-VSXAHHWV-CwicQwvc.js → diagram-VSXAHHWV-BsdL7E17.js} +1 -1
  112. package/dist-embed/chunks/{diagram-VSXAHHWV-BcQHUbuO.js → diagram-VSXAHHWV-D_7x_Ody.js} +1 -1
  113. package/dist-embed/chunks/{diagram-VX7I27RA-Ft45yb-L.js → diagram-VX7I27RA-BGyPrgPC.js} +1 -1
  114. package/dist-embed/chunks/{diagram-VX7I27RA-BscrabRG.js → diagram-VX7I27RA-CNSwTKHP.js} +1 -1
  115. package/dist-embed/chunks/{diagram-VX7I27RA-BSiMudGz.js → diagram-VX7I27RA-C_1S9aIm.js} +1 -1
  116. package/dist-embed/chunks/{diagram-Z3DM3KII-C5mNapBw.js → diagram-Z3DM3KII-B5t8N8ZT.js} +1 -1
  117. package/dist-embed/chunks/{diagram-Z3DM3KII-B86lp0dM.js → diagram-Z3DM3KII-C2gtrmQ9.js} +1 -1
  118. package/dist-embed/chunks/{diagram-Z3DM3KII-Y-lVwha7.js → diagram-Z3DM3KII-yVDxeysg.js} +1 -1
  119. package/dist-embed/chunks/{ebnfDiagram-PWID7BFC-DuGxLmkd.js → ebnfDiagram-PWID7BFC-BgfF1EZn.js} +1 -1
  120. package/dist-embed/chunks/{ebnfDiagram-PWID7BFC-COn39ksr.js → ebnfDiagram-PWID7BFC-C7dUKFPT.js} +1 -1
  121. package/dist-embed/chunks/{ebnfDiagram-PWID7BFC-Tzta9jsh.js → ebnfDiagram-PWID7BFC-LCa7gn5F.js} +1 -1
  122. package/dist-embed/chunks/{edges-b2856ca0-B0fzIYH0.js → edges-b2856ca0-J2ON9YC7.js} +1 -1
  123. package/dist-embed/chunks/{el-GR-BZB4AONW-CGifhWk7.js → el-GR-BZB4AONW-BBpO4fOL.js} +1 -1
  124. package/dist-embed/chunks/{erDiagram-5d81789a-Bs2AlkA7.js → erDiagram-5d81789a-BM5rHLzM.js} +1 -1
  125. package/dist-embed/chunks/{erDiagram-RLTQ6QDP-gNk7K_1a.js → erDiagram-RLTQ6QDP-BguBlD55.js} +1 -1
  126. package/dist-embed/chunks/{erDiagram-RLTQ6QDP-dY0zbwz5.js → erDiagram-RLTQ6QDP-C35O3IA_.js} +1 -1
  127. package/dist-embed/chunks/{erDiagram-RLTQ6QDP-69KYQDkg.js → erDiagram-RLTQ6QDP-CX1vL7D6.js} +1 -1
  128. package/dist-embed/chunks/{es-ES-U4NZUMDT-CG3eLB2T.js → es-ES-U4NZUMDT-CyrQHwAL.js} +1 -1
  129. package/dist-embed/chunks/{esm-jxjWs5qw.js → esm-BaC41XaP.js} +1 -1
  130. package/dist-embed/chunks/{esm-DXOCHrTC.js → esm-DNtiNaWu.js} +1 -1
  131. package/dist-embed/chunks/{eu-ES-A7QVB2H4-DzPN5Wvi.js → eu-ES-A7QVB2H4-BJG9zHud.js} +1 -1
  132. package/dist-embed/chunks/{fa-IR-HGAKTJCU-DFiN2zZy.js → fa-IR-HGAKTJCU-BOnLqEaQ.js} +1 -1
  133. package/dist-embed/chunks/{fi-FI-Z5N7JZ37-DoWgfc_V.js → fi-FI-Z5N7JZ37-DdQTDw9O.js} +1 -1
  134. package/dist-embed/chunks/{flowDb-185abca5-CX3GWJVI.js → flowDb-185abca5-CLfj2Qv7.js} +1 -1
  135. package/dist-embed/chunks/{flowDiagram-1629c991-CLqeIp_x.js → flowDiagram-1629c991-DjfIfqQ2.js} +1 -1
  136. package/dist-embed/chunks/{flowDiagram-HODETNUW-BHSFqLFz.js → flowDiagram-HODETNUW-CmpkqsRJ.js} +1 -1
  137. package/dist-embed/chunks/{flowDiagram-HODETNUW-CJEJhhfg.js → flowDiagram-HODETNUW-Cuv1YfzK.js} +1 -1
  138. package/dist-embed/chunks/{flowDiagram-HODETNUW-Du69fYws.js → flowDiagram-HODETNUW-DEVM2ZrI.js} +1 -1
  139. package/dist-embed/chunks/{flowDiagram-v2-1d953310-CBHgUV1p.js → flowDiagram-v2-1d953310-4wSPcojK.js} +1 -1
  140. package/dist-embed/chunks/{flowchart-elk-definition-6df44142-DeZ--5a6.js → flowchart-elk-definition-6df44142-Cb0xBerO.js} +1 -1
  141. package/dist-embed/chunks/{fr-FR-RHASNOE6-J88GG3aE.js → fr-FR-RHASNOE6-DQXpQs87.js} +1 -1
  142. package/dist-embed/chunks/{ganttDiagram-3b0b3873-C2r1fH39.js → ganttDiagram-3b0b3873-DI6DrFsY.js} +1 -1
  143. package/dist-embed/chunks/{ganttDiagram-EL5Y4UJY-7MMvC1fh.js → ganttDiagram-EL5Y4UJY-CSmChevD.js} +1 -1
  144. package/dist-embed/chunks/{ganttDiagram-EL5Y4UJY-DKaPd3MM.js → ganttDiagram-EL5Y4UJY-DdKCj2ex.js} +1 -1
  145. package/dist-embed/chunks/{ganttDiagram-EL5Y4UJY-C3YxQe7W.js → ganttDiagram-EL5Y4UJY-drl1C7t5.js} +1 -1
  146. package/dist-embed/chunks/{gitGraphDiagram-WWUBYQGX-Cnig1EpR.js → gitGraphDiagram-WWUBYQGX-Dna0JScG.js} +1 -1
  147. package/dist-embed/chunks/{gitGraphDiagram-WWUBYQGX-BhAiY2G7.js → gitGraphDiagram-WWUBYQGX-PLhOfVTI.js} +1 -1
  148. package/dist-embed/chunks/{gitGraphDiagram-WWUBYQGX-DL75-74K.js → gitGraphDiagram-WWUBYQGX-gYDVDk5C.js} +1 -1
  149. package/dist-embed/chunks/{gitGraphDiagram-f01e8bc2-DpCnh99K.js → gitGraphDiagram-f01e8bc2-BmE4UKm_.js} +1 -1
  150. package/dist-embed/chunks/{gl-ES-HMX3MZ6V-DCx-cx3z.js → gl-ES-HMX3MZ6V-DzfCce3N.js} +1 -1
  151. package/dist-embed/chunks/{he-IL-6SHJWFNN-DSVCS7oh.js → he-IL-6SHJWFNN-DRlcBbb7.js} +1 -1
  152. package/dist-embed/chunks/{hi-IN-IWLTKZ5I-dYf4Ui9C.js → hi-IN-IWLTKZ5I-BrerMuM3.js} +1 -1
  153. package/dist-embed/chunks/{hu-HU-A5ZG7DT2-D62ZhqXS.js → hu-HU-A5ZG7DT2-DFTsPGh6.js} +1 -1
  154. package/dist-embed/chunks/{id-ID-SAP4L64H-CPbEyEGt.js → id-ID-SAP4L64H-D0pKFdUL.js} +1 -1
  155. package/dist-embed/chunks/{index-DUo_Q0bE.js → index-46VEGuyz.js} +2 -2
  156. package/dist-embed/chunks/{index-9bae90f3-BXKxYnBg.js → index-9bae90f3-Cc18qrXw.js} +1 -1
  157. package/dist-embed/chunks/{index-h3ezbReI.js → index-B5W7CVUY.js} +1 -1
  158. package/dist-embed/chunks/{index-BeTQYXBa.js → index-BQEWUnIX.js} +1 -1
  159. package/dist-embed/chunks/{index-C1V3QrNG.js → index-BXY2kJ1z.js} +1 -1
  160. package/dist-embed/chunks/{index-BDfHQl3F.js → index-BzdaTJ02.js} +4 -4
  161. package/dist-embed/chunks/{index-BxqT3iXs.js → index-C-4crJTg.js} +4 -4
  162. package/dist-embed/chunks/{index-BrEfsSSF.js → index-CBWGYoQM.js} +1 -1
  163. package/dist-embed/chunks/{index-D6Jo2GVI.js → index-CET7bv5d.js} +1 -1
  164. package/dist-embed/chunks/{index-BAjfjlr1.js → index-h8lXpqtD.js} +1 -1
  165. package/dist-embed/chunks/index.esm-DwyYEnhk.js +1 -0
  166. package/dist-embed/chunks/{index.esm-hHiWwus_.js → index.esm-fF--io5D.js} +1 -1
  167. package/dist-embed/chunks/{infoDiagram-27XIBGKW-DR9uGGbg.js → infoDiagram-27XIBGKW-BZLQcxTA.js} +1 -1
  168. package/dist-embed/chunks/{infoDiagram-27XIBGKW-BWng8B0-.js → infoDiagram-27XIBGKW-DlOi-VkF.js} +1 -1
  169. package/dist-embed/chunks/{infoDiagram-27XIBGKW-CUOzYTfJ.js → infoDiagram-27XIBGKW-Ir7z7vae.js} +1 -1
  170. package/dist-embed/chunks/{infoDiagram-a29d40f1-HEc-jV3D.js → infoDiagram-a29d40f1-B_50LXsh.js} +1 -1
  171. package/dist-embed/chunks/{ishikawaDiagram-5VMMS53U-bN5K7Z_H.js → ishikawaDiagram-5VMMS53U-CUxqPwbA.js} +1 -1
  172. package/dist-embed/chunks/{ishikawaDiagram-5VMMS53U-D-4s54qG.js → ishikawaDiagram-5VMMS53U-CmchLGEY.js} +1 -1
  173. package/dist-embed/chunks/{ishikawaDiagram-5VMMS53U-A0e9fSuG.js → ishikawaDiagram-5VMMS53U-Erx01g7S.js} +1 -1
  174. package/dist-embed/chunks/{it-IT-JPQ66NNP-B82xwLEQ.js → it-IT-JPQ66NNP-CbZLqWAE.js} +1 -1
  175. package/dist-embed/chunks/{ja-JP-DBVTYXUO-CM-98LRm.js → ja-JP-DBVTYXUO-9xZnJjLg.js} +1 -1
  176. package/dist-embed/chunks/{journeyDiagram-3NMN7TZE-Bi4bGCmh.js → journeyDiagram-3NMN7TZE-B6PqY62p.js} +1 -1
  177. package/dist-embed/chunks/{journeyDiagram-3NMN7TZE-BxzwEGdA.js → journeyDiagram-3NMN7TZE-BRe0KiaN.js} +1 -1
  178. package/dist-embed/chunks/{journeyDiagram-3NMN7TZE-8G4uOxBl.js → journeyDiagram-3NMN7TZE-C9s2og1s.js} +1 -1
  179. package/dist-embed/chunks/{journeyDiagram-95396277-eqSlSLqg.js → journeyDiagram-95396277-BsoN0fKG.js} +1 -1
  180. package/dist-embed/chunks/{kaa-6HZHGXH3-Ef811qmk.js → kaa-6HZHGXH3-CO2r0Hb-.js} +1 -1
  181. package/dist-embed/chunks/{kab-KAB-ZGHBKWFO-DXBRnDqR.js → kab-KAB-ZGHBKWFO-0WoWjCrc.js} +1 -1
  182. package/dist-embed/chunks/{kanban-definition-UXKFOSKX-CmTw15_j.js → kanban-definition-UXKFOSKX-B6PDcRlF.js} +1 -1
  183. package/dist-embed/chunks/{kanban-definition-UXKFOSKX-DMF43A4Q.js → kanban-definition-UXKFOSKX-BO0-y3yZ.js} +1 -1
  184. package/dist-embed/chunks/{kanban-definition-UXKFOSKX-DMkqn8yL.js → kanban-definition-UXKFOSKX-CKIjAYbp.js} +1 -1
  185. package/dist-embed/chunks/{kk-KZ-P5N5QNE5-DXPHFZv8.js → kk-KZ-P5N5QNE5-DFQE1uuw.js} +1 -1
  186. package/dist-embed/chunks/{km-KH-HSX4SM5Z-fcVwn7la.js → km-KH-HSX4SM5Z-D0Bja56Q.js} +1 -1
  187. package/dist-embed/chunks/{ko-KR-MTYHY66A-fPmaSt-R.js → ko-KR-MTYHY66A-C6MeQrMU.js} +1 -1
  188. package/dist-embed/chunks/{ku-TR-6OUDTVRD-DLO8mEqc.js → ku-TR-6OUDTVRD-CweepkXr.js} +1 -1
  189. package/dist-embed/chunks/{layout-BQJeAUxn.js → layout-Bz98EP0E.js} +1 -1
  190. package/dist-embed/chunks/{layout-DKKRYrOx.js → layout-DPmNjViN.js} +1 -1
  191. package/dist-embed/chunks/{layout-BiwLrHFv.js → layout-mk0FGxVc.js} +1 -1
  192. package/dist-embed/chunks/{lexicalHooks-CJT40c-i.js → lexicalHooks-Cj3BNPDC.js} +1 -1
  193. package/dist-embed/chunks/{lib-CCs8IFk9.js → lib-0j0dfH8p.js} +1 -1
  194. package/dist-embed/chunks/{lib-BWVYnyap.js → lib-B01oDNlH.js} +1 -1
  195. package/dist-embed/chunks/{lib-DGyQX8HH.js → lib-B62N3zGB.js} +1 -1
  196. package/dist-embed/chunks/{lib-DjnzrDLN.js → lib-BItrfBU4.js} +1 -1
  197. package/dist-embed/chunks/{lib-DiaM9sQK.js → lib-BmoHRaAo.js} +1 -1
  198. package/dist-embed/chunks/{lib-Bt7-2uko.js → lib-BnAfx9wF.js} +1 -1
  199. package/dist-embed/chunks/{lib-5GRWA8Zf.js → lib-C-8NAvI1.js} +1 -1
  200. package/dist-embed/chunks/{lib-D-sHfT2H.js → lib-COg_k5cY.js} +1 -1
  201. package/dist-embed/chunks/{lib-DlJpF03q.js → lib-CY6QUCzq.js} +1 -1
  202. package/dist-embed/chunks/{lib-Bkasfzit.js → lib-CjicD0Pj.js} +1 -1
  203. package/dist-embed/chunks/{lib-Ct98HeTv.js → lib-CkKgTevD.js} +1 -1
  204. package/dist-embed/chunks/{lib-CAO9TgtV.js → lib-D8Ksfd49.js} +1 -1
  205. package/dist-embed/chunks/{lib-hGDX-thU.js → lib-DCBCbRKN.js} +1 -1
  206. package/dist-embed/chunks/{lib-C9Xg-F1Z.js → lib-DpZphKNm.js} +1 -1
  207. package/dist-embed/chunks/{lib-D63-MDjq.js → lib-DzVf9ZJD.js} +1 -1
  208. package/dist-embed/chunks/{lib-Duu9jvZE.js → lib-Hgl-pfON.js} +1 -1
  209. package/dist-embed/chunks/{lib-D7hI6faK.js → lib-f60SfhfM.js} +1 -1
  210. package/dist-embed/chunks/{lib-Bp97CI40.js → lib-ku1U2GxE.js} +1 -1
  211. package/dist-embed/chunks/{lib-B9ZzlHt8.js → lib-tR3XRdBe.js} +1 -1
  212. package/dist-embed/chunks/{lib-BBunDtjl.js → lib-w650Gz0V.js} +1 -1
  213. package/dist-embed/chunks/{lt-LT-XHIRWOB4-CDj2NwJ7.js → lt-LT-XHIRWOB4-DrPOBOia.js} +1 -1
  214. package/dist-embed/chunks/{lv-LV-5QDEKY6T-DM0UmntK.js → lv-LV-5QDEKY6T-BlGiDUA0.js} +1 -1
  215. package/dist-embed/chunks/{mermaid.core-BFu8E2Ch.js → mermaid.core-1p09QPXM.js} +3 -3
  216. package/dist-embed/chunks/{mermaid.core-oCOrUXH6.js → mermaid.core-BiF8MSuv.js} +5 -5
  217. package/dist-embed/chunks/{mindmap-definition-YA3MSWOX-BBOAmrK9.js → mindmap-definition-YA3MSWOX-CEFrcqEk.js} +1 -1
  218. package/dist-embed/chunks/{mindmap-definition-YA3MSWOX-D5P4dsfO.js → mindmap-definition-YA3MSWOX-DpAy5heR.js} +1 -1
  219. package/dist-embed/chunks/{mindmap-definition-YA3MSWOX-k9DaqQ85.js → mindmap-definition-YA3MSWOX-t1pDKjS3.js} +1 -1
  220. package/dist-embed/chunks/{mindmap-definition-e4c1d938-pjtVjzMw.js → mindmap-definition-e4c1d938-DcepOwKv.js} +1 -1
  221. package/dist-embed/chunks/{model-BlGqAZ_E.js → model-jLDiOPpQ.js} +1 -1
  222. package/dist-embed/chunks/{mr-IN-CRQNXWMA-DKu7Lbyh.js → mr-IN-CRQNXWMA-BWEVprKf.js} +1 -1
  223. package/dist-embed/chunks/{my-MM-5M5IBNSE-OpXhxQFy.js → my-MM-5M5IBNSE-BBxutJOz.js} +1 -1
  224. package/dist-embed/chunks/{nb-NO-T6EIAALU-CaW58ARR.js → nb-NO-T6EIAALU-DJnrKa7W.js} +1 -1
  225. package/dist-embed/chunks/{nl-NL-IS3SIHDZ-D4WjKwio.js → nl-NL-IS3SIHDZ-DQfv4h3e.js} +1 -1
  226. package/dist-embed/chunks/{nn-NO-6E72VCQL-n-7vV9Cs.js → nn-NO-6E72VCQL-DiGj9RA6.js} +1 -1
  227. package/dist-embed/chunks/{oc-FR-POXYY2M6-CB6dwikR.js → oc-FR-POXYY2M6-WJRn50ji.js} +1 -1
  228. package/dist-embed/chunks/{pa-IN-N4M65BXN-Cq4oiAGn.js → pa-IN-N4M65BXN-U7QCzNgm.js} +1 -1
  229. package/dist-embed/chunks/{pegDiagram-XKGWAZYB-oNVN1IG9.js → pegDiagram-XKGWAZYB-BlYwAwEo.js} +1 -1
  230. package/dist-embed/chunks/{pegDiagram-XKGWAZYB-BTn5P1TU.js → pegDiagram-XKGWAZYB-CudwiD3O.js} +1 -1
  231. package/dist-embed/chunks/{pegDiagram-XKGWAZYB-Cge-GlZ7.js → pegDiagram-XKGWAZYB-iE6rBtXO.js} +1 -1
  232. package/dist-embed/chunks/{percentages-BXMCSKIN-DRR-eJCX.js → percentages-BXMCSKIN-DhE6_GLO.js} +5 -5
  233. package/dist-embed/chunks/{pieDiagram-E7YTZNPT-C9syugZr.js → pieDiagram-E7YTZNPT-CIawCiDR.js} +1 -1
  234. package/dist-embed/chunks/{pieDiagram-E7YTZNPT-LKAJV-f9.js → pieDiagram-E7YTZNPT-Cy6Wueqp.js} +1 -1
  235. package/dist-embed/chunks/{pieDiagram-E7YTZNPT-LRVEFdTA.js → pieDiagram-E7YTZNPT-DkhDYj7K.js} +1 -1
  236. package/dist-embed/chunks/{pieDiagram-c941bede-DjCRmn-L.js → pieDiagram-c941bede-Ds-rlqjJ.js} +1 -1
  237. package/dist-embed/chunks/{pl-PL-T2D74RX3-C1YHW5JY.js → pl-PL-T2D74RX3-D5hzyBxL.js} +1 -1
  238. package/dist-embed/chunks/{plugin-DdlXgZum.js → plugin-BqLEv-U0.js} +1 -1
  239. package/dist-embed/chunks/{pt-BR-5N22H2LF-CeAhQlI9.js → pt-BR-5N22H2LF-CAs1Vbwd.js} +1 -1
  240. package/dist-embed/chunks/{pt-PT-UZXXM6DQ-GWUC3hdB.js → pt-PT-UZXXM6DQ-f3BuGnIL.js} +1 -1
  241. package/dist-embed/chunks/{quadrantDiagram-AXDQQJYC-8vY1ABOf.js → quadrantDiagram-AXDQQJYC-1ViFLfLW.js} +1 -1
  242. package/dist-embed/chunks/{quadrantDiagram-AXDQQJYC-C2i8SYpJ.js → quadrantDiagram-AXDQQJYC-B30POsrM.js} +1 -1
  243. package/dist-embed/chunks/{quadrantDiagram-AXDQQJYC-DFP2Eoj5.js → quadrantDiagram-AXDQQJYC-CqArYUyr.js} +1 -1
  244. package/dist-embed/chunks/{quadrantDiagram-cf8b8fe0-Bgejfr6D.js → quadrantDiagram-cf8b8fe0-QoN4fcns.js} +1 -1
  245. package/dist-embed/chunks/{railroadDiagram-O6MQD6OU-D8iXssMi.js → railroadDiagram-O6MQD6OU-BKrSAEIz.js} +1 -1
  246. package/dist-embed/chunks/{railroadDiagram-O6MQD6OU-Ck2bziJ8.js → railroadDiagram-O6MQD6OU-BelGMNLe.js} +1 -1
  247. package/dist-embed/chunks/{railroadDiagram-O6MQD6OU-B54ysFcl.js → railroadDiagram-O6MQD6OU-nWQg4Zha.js} +1 -1
  248. package/dist-embed/chunks/{renderer-Dsm4_V5Z.js → renderer-NdtLW87o.js} +1 -1
  249. package/dist-embed/chunks/{requirementDiagram-53bda41b-Don9LmwH.js → requirementDiagram-53bda41b-DRQpj1S7.js} +1 -1
  250. package/dist-embed/chunks/{requirementDiagram-BXWQKSXE-BKfTxvAx.js → requirementDiagram-BXWQKSXE-BsKIaNx-.js} +1 -1
  251. package/dist-embed/chunks/{requirementDiagram-BXWQKSXE-BluOoSWL.js → requirementDiagram-BXWQKSXE-C-ZNAzIA.js} +1 -1
  252. package/dist-embed/chunks/{requirementDiagram-BXWQKSXE-DzYOora7.js → requirementDiagram-BXWQKSXE-Dj_84sJE.js} +1 -1
  253. package/dist-embed/chunks/{ro-RO-JPDTUUEW-CfstrBRj.js → ro-RO-JPDTUUEW-Ck6Pl6T-.js} +1 -1
  254. package/dist-embed/chunks/{ru-RU-B4JR7IUQ-CprdF87i.js → ru-RU-B4JR7IUQ-B5ZFvbSm.js} +1 -1
  255. package/dist-embed/chunks/{sankeyDiagram-P5KCCOFB-BbWM5efa.js → sankeyDiagram-P5KCCOFB-BwrjNR9f.js} +1 -1
  256. package/dist-embed/chunks/{sankeyDiagram-P5KCCOFB-BO6yMQvy.js → sankeyDiagram-P5KCCOFB-CvESkMt0.js} +1 -1
  257. package/dist-embed/chunks/{sankeyDiagram-P5KCCOFB-CFPCOaBB.js → sankeyDiagram-P5KCCOFB-DNcJ8lTV.js} +1 -1
  258. package/dist-embed/chunks/{sankeyDiagram-c3ef121a-foGV8N2_.js → sankeyDiagram-c3ef121a-NSdOSIUQ.js} +1 -1
  259. package/dist-embed/chunks/{sequenceDiagram-82a5b84f-6pLDiDbB.js → sequenceDiagram-82a5b84f-Cxc06-S6.js} +1 -1
  260. package/dist-embed/chunks/{sequenceDiagram-WJ2MYXX4-C0zWhG8B.js → sequenceDiagram-WJ2MYXX4-CdKf7EXa.js} +1 -1
  261. package/dist-embed/chunks/{sequenceDiagram-WJ2MYXX4-w41G2RsH.js → sequenceDiagram-WJ2MYXX4-DYkcZR01.js} +1 -1
  262. package/dist-embed/chunks/{sequenceDiagram-WJ2MYXX4-BGIbaSlI.js → sequenceDiagram-WJ2MYXX4-vrbMF2lh.js} +1 -1
  263. package/dist-embed/chunks/{sheet-4YYsjTBK.js → sheet-BFp5lgzm.js} +1 -1
  264. package/dist-embed/chunks/{si-LK-N5RQ5JYF-CBECC-z7.js → si-LK-N5RQ5JYF-turarKuZ.js} +1 -1
  265. package/dist-embed/chunks/{sizeCapture-INFHLROL-C4Um3fMN.js → sizeCapture-INFHLROL-B05-5pAF.js} +1 -1
  266. package/dist-embed/chunks/{sizeCapture-INFHLROL-WE85tnHS.js → sizeCapture-INFHLROL-BTK449Mq.js} +1 -1
  267. package/dist-embed/chunks/{sizeCapture-INFHLROL-DAIM469w.js → sizeCapture-INFHLROL-DBDGASUh.js} +1 -1
  268. package/dist-embed/chunks/{sk-SK-C5VTKIMK-DMJnHZkB.js → sk-SK-C5VTKIMK-B61Eejyh.js} +1 -1
  269. package/dist-embed/chunks/{sl-SI-NN7IZMDC-7Z4OGoYj.js → sl-SI-NN7IZMDC-Vmd7HFee.js} +1 -1
  270. package/dist-embed/chunks/{state-DWaoyyF_.js → state-B-9Ja93T.js} +1 -1
  271. package/dist-embed/chunks/{stateDiagram-43e79a5f-S14mEvLi.js → stateDiagram-43e79a5f-BNfT8BMf.js} +1 -1
  272. package/dist-embed/chunks/{stateDiagram-D77RDMKH-BC6_D1er.js → stateDiagram-D77RDMKH-B4P4foWm.js} +1 -1
  273. package/dist-embed/chunks/{stateDiagram-D77RDMKH-BKswuz-D.js → stateDiagram-D77RDMKH-DGy5pPcJ.js} +1 -1
  274. package/dist-embed/chunks/{stateDiagram-D77RDMKH-DaQTz1j_.js → stateDiagram-D77RDMKH-cX1LxuDW.js} +1 -1
  275. package/dist-embed/chunks/{stateDiagram-v2-2041ed4f-3GcjyBy-.js → stateDiagram-v2-2041ed4f-DT_Cb2bL.js} +1 -1
  276. package/dist-embed/chunks/{stateDiagram-v2-MP3YSRHH-Bm6DUSD7.js → stateDiagram-v2-MP3YSRHH-BSxDwfLM.js} +1 -1
  277. package/dist-embed/chunks/{stateDiagram-v2-MP3YSRHH-z0Ujpn87.js → stateDiagram-v2-MP3YSRHH-CoF-m0JB.js} +1 -1
  278. package/dist-embed/chunks/{stateDiagram-v2-MP3YSRHH-DOLQNFRH.js → stateDiagram-v2-MP3YSRHH-GuE-uLPq.js} +1 -1
  279. package/dist-embed/chunks/{styles-455b33cd-BRr4X9hL.js → styles-455b33cd-Cp1Ujuo8.js} +1 -1
  280. package/dist-embed/chunks/{styles-f932cba9-UDBXX5a8.js → styles-f932cba9-CxoS5hwQ.js} +1 -1
  281. package/dist-embed/chunks/{styles-fcc2142b-CSFZuop9.js → styles-fcc2142b-ByLmqETE.js} +1 -1
  282. package/dist-embed/chunks/{subset-shared.chunk-B3u5KdN0.js → subset-shared.chunk-BsVAPxIg.js} +1 -1
  283. package/dist-embed/chunks/{subset-worker.chunk-CT6VKIPU.js → subset-worker.chunk-BS8PIaQX.js} +1 -1
  284. package/dist-embed/chunks/{substates-CZP38fPi.js → substates-CeUNAPt2.js} +1 -1
  285. package/dist-embed/chunks/{sv-SE-XGPEYMSR-FpJ1BpmI.js → sv-SE-XGPEYMSR-C9lMr16n.js} +1 -1
  286. package/dist-embed/chunks/{svgDrawCommon-148a3cd9-F4sRB6k0.js → svgDrawCommon-148a3cd9-BHhr6lti.js} +1 -1
  287. package/dist-embed/chunks/{swimlanes-42K2YHIH-EibPKc5o.js → swimlanes-42K2YHIH-DKdFBGRm.js} +1 -1
  288. package/dist-embed/chunks/{swimlanes-42K2YHIH-Bm2EMEIj.js → swimlanes-42K2YHIH-DQJZa-xA.js} +1 -1
  289. package/dist-embed/chunks/{swimlanes-42K2YHIH-60OSS3vA.js → swimlanes-42K2YHIH-RHIIyMRW.js} +1 -1
  290. package/dist-embed/chunks/{swimlanesDiagram-VR7AAH4N-C5g-ZOer.js → swimlanesDiagram-VR7AAH4N-DPhzMK19.js} +1 -1
  291. package/dist-embed/chunks/{swimlanesDiagram-VR7AAH4N-mQfKwLBP.js → swimlanesDiagram-VR7AAH4N-qQpIxgus.js} +1 -1
  292. package/dist-embed/chunks/{swimlanesDiagram-VR7AAH4N-Dd4rkKxx.js → swimlanesDiagram-VR7AAH4N-rV-EK234.js} +1 -1
  293. package/dist-embed/chunks/{ta-IN-2NMHFXQM-CGrfHW-T.js → ta-IN-2NMHFXQM-DDvtKbYb.js} +1 -1
  294. package/dist-embed/chunks/{th-TH-HPSO5L25-XSyuAjYd.js → th-TH-HPSO5L25-Cuk9i9q1.js} +1 -1
  295. package/dist-embed/chunks/{timeline-definition-24CTP7MA-Dw-j__OF.js → timeline-definition-24CTP7MA-B0VfyyC9.js} +1 -1
  296. package/dist-embed/chunks/{timeline-definition-24CTP7MA-DrK86SXx.js → timeline-definition-24CTP7MA-BYQXqujM.js} +1 -1
  297. package/dist-embed/chunks/{timeline-definition-24CTP7MA-4xcdFEe3.js → timeline-definition-24CTP7MA-CNJYLQV3.js} +1 -1
  298. package/dist-embed/chunks/{timeline-definition-7545f45a-BbuRGmnt.js → timeline-definition-7545f45a-B6u65RjP.js} +1 -1
  299. package/dist-embed/chunks/{tr-TR-DEFEU3FU-Bmilf4wA.js → tr-TR-DEFEU3FU-Dt5AbXXF.js} +1 -1
  300. package/dist-embed/chunks/{uk-UA-QMV73CPH-D7__x2rc.js → uk-UA-QMV73CPH-CqxkvO2g.js} +1 -1
  301. package/dist-embed/chunks/{vennDiagram-4TSXK5OY-Dyygo0QE.js → vennDiagram-4TSXK5OY-8GPjZ_rY.js} +1 -1
  302. package/dist-embed/chunks/{vennDiagram-4TSXK5OY-DU_TiJPw.js → vennDiagram-4TSXK5OY-BC0uMGWS.js} +1 -1
  303. package/dist-embed/chunks/{vennDiagram-4TSXK5OY-aBwLZ5sI.js → vennDiagram-4TSXK5OY-ERcpoENM.js} +1 -1
  304. package/dist-embed/chunks/{vi-VN-M7AON7JQ-Cp1NNDFR.js → vi-VN-M7AON7JQ-CZtlZzss.js} +1 -1
  305. package/dist-embed/chunks/{wardleyDiagram-VM6X3IG4-BUupZELs.js → wardleyDiagram-VM6X3IG4-Bubuc1xO.js} +1 -1
  306. package/dist-embed/chunks/{wardleyDiagram-VM6X3IG4-8uoJ6em9.js → wardleyDiagram-VM6X3IG4-DMJNYu8Y.js} +1 -1
  307. package/dist-embed/chunks/{wardleyDiagram-VM6X3IG4-DJsJzMBH.js → wardleyDiagram-VM6X3IG4-DdRbpzRB.js} +1 -1
  308. package/dist-embed/chunks/workbook-BQLbQvZ-.js +1 -0
  309. package/dist-embed/chunks/{write-DDDJmUTa.js → write-D-y9_9sL.js} +1 -1
  310. package/dist-embed/chunks/{xychartDiagram-3f383b91-CbuvIhMQ.js → xychartDiagram-3f383b91-CEkYRds9.js} +1 -1
  311. package/dist-embed/chunks/{xychartDiagram-S5SC5T6Z-D2_kfHro.js → xychartDiagram-S5SC5T6Z-C0WCXM2P.js} +1 -1
  312. package/dist-embed/chunks/{xychartDiagram-S5SC5T6Z-AUNwwAUK.js → xychartDiagram-S5SC5T6Z-DKWKSC-B.js} +1 -1
  313. package/dist-embed/chunks/{xychartDiagram-S5SC5T6Z-B9ZiyRsR.js → xychartDiagram-S5SC5T6Z-iG96dorC.js} +1 -1
  314. package/dist-embed/chunks/{zh-CN-LNUGB5OW-1W7T5K4d.js → zh-CN-LNUGB5OW-6_SDF9o2.js} +1 -1
  315. package/dist-embed/chunks/{zh-HK-E62DVLB3-6wLRdIMH.js → zh-HK-E62DVLB3-em8dd9Nl.js} +1 -1
  316. package/dist-embed/chunks/{zh-TW-RAJ6MFWO-Bq3E0gIc.js → zh-TW-RAJ6MFWO-BCzbAoXj.js} +1 -1
  317. package/dist-embed/datalayer-app-main.js +68 -74
  318. package/lib/apps/plugins/chat/ChatView.js +96 -38
  319. package/lib/chat/anonymous/AnonymousChat.d.ts +0 -3
  320. package/lib/chat/anonymous/anonymousMode.d.ts +0 -4
  321. package/lib/chat/anonymous/anonymousMode.js +0 -4
  322. package/lib/chat/base/ChatBase.js +2 -58
  323. package/lib/chat/index.d.ts +1 -1
  324. package/lib/chat/index.js +1 -1
  325. package/lib/chat/indicators/index.d.ts +3 -12
  326. package/lib/chat/indicators/index.js +0 -15
  327. package/lib/chat/prompt/InputPrompt.d.ts +28 -16
  328. package/lib/chat/prompt/InputPrompt.js +60 -12
  329. package/lib/chat/prompt/menus/EquipmentMenus.d.ts +58 -81
  330. package/lib/chat/prompt/menus/EquipmentMenus.js +190 -127
  331. package/lib/chat/prompt/menus/ToolsMenu.d.ts +2 -11
  332. package/lib/chat/prompt/menus/ToolsMenu.js +8 -43
  333. package/lib/chat/prompt/menus/equipmentRows.d.ts +160 -0
  334. package/lib/chat/prompt/menus/equipmentRows.js +349 -0
  335. package/lib/chat/prompt/menus/index.d.ts +2 -1
  336. package/lib/chat/prompt/menus/index.js +2 -1
  337. package/lib/hooks/useConversationSwitches.d.ts +29 -0
  338. package/lib/hooks/useConversationSwitches.js +102 -0
  339. package/lib/hooks/useMcpToolSwitches.d.ts +13 -0
  340. package/lib/hooks/useMcpToolSwitches.js +96 -0
  341. package/lib/portable/index.d.ts +1 -1
  342. package/lib/portable/sessions.d.ts +47 -0
  343. package/lib/portable/sessions.js +7 -0
  344. package/lib/types/chat.d.ts +2 -3
  345. package/package.json +1 -1
  346. package/dist-embed/chunks/ChatView-BxxW10wd.js +0 -32
  347. package/dist-embed/chunks/index.esm-ClpGzk_d.js +0 -1
  348. package/dist-embed/chunks/workbook-B-AfiHkC.js +0 -1
  349. package/lib/chat/indicators/DisabledIndicator.d.ts +0 -18
  350. package/lib/chat/indicators/DisabledIndicator.js +0 -22
  351. package/lib/chat/indicators/McpStatusIndicator.d.ts +0 -18
  352. package/lib/chat/indicators/McpStatusIndicator.js +0 -106
  353. package/lib/chat/indicators/SkillsStatusIndicator.d.ts +0 -13
  354. package/lib/chat/indicators/SkillsStatusIndicator.js +0 -88
  355. package/lib/chat/prompt/menus/SkillsMenu.d.ts +0 -10
  356. package/lib/chat/prompt/menus/SkillsMenu.js +0 -49
@@ -1,6 +1,6 @@
1
- import{r as C,b1 as Km,b2 as Wm,j as w,aF as Y,a9 as yn,T as Le,en as Jm,bM as Au,a1 as Hm,dH as qm,B as Yr,I as Pt,fn as Dg,hq as qa,pz as Vm,bH as Tt,b0 as pe,pA as Oe,pB as He,pC as Te,pD as Rt,mM as j,pE as Nt,pF as gr,mr as H,mw as oe,mx as vt,pG as jt,bd as se,v as ft,b6 as Pg,eo as Rs,em as Ym,hx as At,_ as me,le as jg,aI as Gm,D as Fg,pH as Xm,pI as to,pJ as Hl,pK as To,mz as bt,pL as $n,mq as xt,be as ne,pM as ys,ck as de,pN as Zm,mO as Er,mL as P,cn as ee,pO as on,pP as Bg,pQ as Qm,pR as ws,mZ as sn,n0 as ke,my as ue,pS as Ye,pT as Ge,pU as Ug,pV as Ru,pW as gt,pX as eb,mQ as Nr,mK as mn,pY as Va,mP as Mt,pZ as an,p_ as pr,p$ as pt,q0 as Ht,q1 as hr,q2 as os,q3 as zg,q4 as fi,q5 as tb,q6 as Zs,q7 as jn,q8 as nb,q9 as rb,aG as Q,qa as ob,mn as De,fM as Kg,Y as ir,m$ as Me,qb as sb,qc as ib,qd as ab,qe as Bt,qf as go,qg as Jn,qh as Hn,qi as ss,qj as bn,qk as xs,ql as qn,qm as pn,qn as Cs,mU as ve,mR as re,qo as V,qp as Wg,qq as ql,qr as Gr,cm as po,qs as lb,qt as Xr,qu as Mu,qv as Jg,qw as Hg,qx as Ya,qy as cb,qz as qg,qA as Vl,qB as ub,qC as db,qD as Yl,qE as Ga,qF as Vg,qG as fb,qH as Yg,qI as gb,qJ as Gl,qK as is,mI as Ee,qL as pb,mW as Cn,qM as $u,qN as hb,qO as _b,qP as Du,qQ as Xa,mJ as ho,qR as Xl,qS as Qs,qT as $i,qU as Gg,qV as Zl,qW as Di,qX as Ms,qY as Pu,qZ as ju,q_ as Ss,q$ as Fu,r0 as An,r1 as mb,r2 as bb,r3 as Xe,r4 as yb,r5 as wb,r6 as Xg,r7 as Zg,r8 as Qg,cl as vs,r9 as Ql,ra as xb,rb as he,rc as ep,rd as as,re as ra,rf as tp,rg as ec,rh as Za,ri as Cb,rj as _r,rk as yt,mV as Vn,rl as Pi,rm as Sb,rn as tc,ro as np,rp as nc,rq as Xo,rr as Bu,rs as it,mo as ht,rt as Uu,ru as Wt,rv as ji,rw as rp,rx as op,ry as sp,rz as Dn,rA as vb,rB as kb,rC as gi,rD as Ib,rE as Tb,rF as Eb,rG as Qa,rH as rr,rI as ip,rJ as Nb,rK as el,rL as pi,rM as ap,mS as Kt,rN as _o,mN as qe,rO as lp,rP as Lb,rQ as Ob,mm as Ab,rR as no,rS as Yn,rT as cp,rU as Rb,rV as Mb,rW as rc,rX as up,rY as $b,rZ as zu,r_ as Db,r$ as Ku,s0 as Pb,s1 as jb,s2 as oc,s3 as Fb,s4 as Wu,mG as Bb,mF as Ub,mE as zb,s5 as Ju,mH as Kb,s6 as Hu,s7 as dp,an as fe,mX as Wb,s8 as Jb,s9 as Hb,sa as qb,sb as qu,sc as Vb,sd as Yb,se as Vu,sf as Yu,sg as Fn,sh as Gb,si as Xb,sj as Zb,sk as Qb,sl as sc,sm as ey,sn as ty,l1 as tl,fw as ls,mT as ro,so as fp,sp as hi,mp as gp,mu as ic,mt as ac,ms as pp,mv as hp,sq as _p,sr as nl,ss as Gu,st as ny,su as rl,sv as Fi,sw as mp,sx as bp,sy as ry,sz as yp,sA as wp,sB as Tn,sC as oy,nX as sy,o1 as Xu,o2 as ol,o4 as iy,o5 as ay,sD as xp,sE as Cp,sF as Sp,sG as vp,sH as Zu,z as kp,A as ly,sI as cy,sJ as uy,H as dy,sK as fy,sL as gy,b5 as py,b7 as hy,W as Ip,sM as _y,bf as Tp,sN as my,bb as by,sO as yy,sP as wy,lj as Et,lr as We,lp as ar,lm as Qe,lq as lr,lo as Gt,lt as xy,a5 as Cy,a2 as oa,V as Sy,dL as ei,sQ as Rn,fx as Ep,sR as vy,bJ as lc,aH as ky,sS as cc,fW as Iy,sT as Ty,fK as Np,sU as Ey,sV as Ny,sW as Ly,sX as Oy,sY as Lp,sZ as we,dI as oo,bA as Ie,s_ as Op,X as _i,s$ as Ay,t0 as Ry,t1 as $s,lu as My,gq as $y,t2 as Dy,M as Py,t3 as Eo}from"../datalayer-app-main.js";import{d as jy,b as Fy,E as By,u as Uy,c as zy,e as Ky,f as Wy}from"./NotebookSkeleton-DHQ--KEB.js";import{p as Ko,e as Jy,s as Hy,u as qy}from"./url-4_0MnaFQ.js";import{r as Vy,a as Yy}from"./isObject-CeOzAI2h.js";import{t as Qu}from"./toNumber-DUdf79Nr.js";import{B as Ap,I as Rp,S as Mp}from"./StrikethroughIcon-CbiEuPT-.js";import{P as Gy,C as mi,D as uc,T as $p,H as Xy,L as Dp,F as Zo,Q as Pp,a as bi,M as Zy,b as Qy,R as ew,c as tw,d as nw}from"./TypographyIcon-CCkcdj7U.js";import{A as rw}from"./Avatar-B0TcOj_b.js";import{A as ow,a as sw}from"./ArrowUpIcon-y5enrVH9.js";import{u as iw,i as Ds,a as ed,o as td,s as nd}from"./floating-ui.react-dom-Bcd0th1j.js";import{S as aw}from"./SortDescIcon-Qif6E10I.js";import{V as ks}from"./VideoIcon-BTOb9gRv.js";import{P as sl,p as lw}from"./PrismCss-C5fDCsu9.js";import{j as il,O as cw,C as uw}from"./Output-BlVb0nsN.js";import{d as ge,l as Zr}from"./LexicalToolRegistry-mRwpy8uR.js";const yi=(n,e,t)=>Math.min(t,Math.max(e,n));function jo(n){const e=n.trim(),t=/^rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i.exec(e);if(t){const[,o,s,i]=t;return{r:Number(o),g:Number(s),b:Number(i)}}let r=e.replace(/^#/,"");return r.length===3&&(r=r.split("").map(o=>o+o).join("")),/^[0-9a-f]{6}$/i.test(r)?{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}:{r:0,g:0,b:0}}function Xn({r:n,g:e,b:t}){const r=o=>yi(Math.round(o),0,255).toString(16).padStart(2,"0");return`#${r(n)}${r(e)}${r(t)}`}function sa({r:n,g:e,b:t}){const r=n/255,o=e/255,s=t/255,i=Math.max(r,o,s),a=Math.min(r,o,s),l=i-a;let c=0;return l!==0&&(i===r?c=60*((o-s)/l%6):i===o?c=60*((s-r)/l+2):c=60*((r-o)/l+4)),c<0&&(c+=360),{h:c,s:i===0?0:l/i*100,v:i*100}}function Ps({h:n,s:e,v:t}){const r=e/100,o=t/100,s=o*r,i=s*(1-Math.abs(n/60%2-1)),a=o-s,l=Math.floor((n%360+360)%360/60),[c,u,f]=[[s,i,0],[i,s,0],[0,s,i],[0,i,s],[i,0,s],[s,0,i]][l];return{r:Math.round((c+a)*255),g:Math.round((u+a)*255),b:Math.round((f+a)*255)}}function rd(n){const e=n.trim();return/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(e)||/^rgba?\(\s*\d+[,\s]+\d+[,\s]+\d+/i.test(e)}const dw=["#cf222e","#bc4c00","#9a6700","#1a7f37","#0969da","#8250df","#bf3989","#24292f","#57606a","#8c959f","#d0d7de","#ffffff"];function fw(n="datalayer",e="light"){const t=Jm(n,e),r=Au[n]??Au.datalayer,s=(e==="auto"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e)==="dark"?r.themeStyles.dark:r.themeStyles.light,i=a=>s[a];return{label:r.label,colors:[i("--bgColor-default"),i("--bgColor-muted"),i("--fgColor-default"),i("--fgColor-muted"),i("--fgColor-accent"),i("--fgColor-success"),i("--fgColor-attention"),i("--fgColor-danger"),t.glow,t.pop,t.spark,t.blaze,t.surge,t.flame,t.gold].filter(Boolean)}}function gw(n="datalayer",e="dark"){return{label:"Collaborators",colors:jy(n,e)}}const pw=150,hw=12;function od(n){const e=C.useRef(null),t=C.useRef(!1),r=C.useCallback(s=>{const i=e.current;if(!i)return;const a=i.getBoundingClientRect();n(yi((s.clientX-a.left)/a.width,0,1),yi((s.clientY-a.top)/a.height,0,1))},[n]);return C.useEffect(()=>{const s=a=>t.current&&r(a),i=()=>{t.current=!1};return window.addEventListener("pointermove",s),window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i),()=>{window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)}},[r]),{ref:e,onPointerDown:s=>{t.current=!0,r(s)}}}function _w({color:n,onChange:e,presets:t=dw,showPresets:r=!0,presetGroups:o,showThemeColors:s=!0,showCollaboratorColors:i=!1,showInput:a=!0,width:l=232,"aria-label":c="Colour picker"}){const[u,f]=C.useState(()=>sa(jo(n))),[d,p]=C.useState(()=>Xn(jo(n))),h=C.useRef(!1);C.useEffect(()=>{if(h.current){h.current=!1;return}const L=jo(n);f(sa(L)),p(Xn(L))},[n]);const _=C.useMemo(()=>Ps(u),[u]),m=C.useMemo(()=>Xn(_),[_]),y=C.useCallback(L=>{h.current=!0,f(L);const R=Xn(Ps(L));p(R),e?.(R)},[e]),x=od(C.useCallback((L,R)=>y({...u,s:L*100,v:(1-R)*100}),[y,u])),S=od(C.useCallback(L=>y({...u,h:L*360}),[y,u])),{theme:v,colorMode:I}=Km(),E=Wm(),T=I==="auto"?E:I,N=C.useMemo(()=>{const L=[];return r&&t.length>0&&L.push({label:"Presets",colors:t}),s&&L.push(fw(v,T)),i&&L.push(gw(v,T)),L.concat(o??[])},[v,o,t,T,i,r,s]),O=C.useId(),M=L=>{if(p(L),rd(L)){const R=sa(jo(L));h.current=!0,f(R),e?.(Xn(jo(L)))}},A=(L,R)=>{const B=L.shiftKey?10:1,F=L.key==="ArrowLeft"||L.key==="ArrowDown",U=L.key==="ArrowRight"||L.key==="ArrowUp";if(!F&&!U)return;L.preventDefault();const K=U?B:-B,W=R==="h"?360:100;y({...u,[R]:yi(u[R]+K,0,W)})},$={position:"absolute",width:14,height:14,borderRadius:"50%",border:"2px solid #ffffff",boxShadow:"0 0 0 1px rgba(0, 0, 0, 0.35)",transform:"translate(-50%, -50%)",pointerEvents:"none"};return w.jsxs(Y,{role:"group","aria-label":c,sx:{display:"grid",gap:2,width:l,minWidth:0},children:[w.jsx(Y,{ref:x.ref,role:"slider",tabIndex:0,"aria-label":"Saturation and brightness","aria-valuetext":`saturation ${Math.round(u.s)}%, brightness ${Math.round(u.v)}%`,onPointerDown:x.onPointerDown,onKeyDown:L=>A(L,L.key==="ArrowUp"||L.key==="ArrowDown"?"v":"s"),sx:{position:"relative",height:pw,borderRadius:"var(--theme-radius-card)",border:"1px solid",borderColor:"var(--borderColor-default)",cursor:"crosshair",touchAction:"none",backgroundColor:Xn(Ps({h:u.h,s:100,v:100})),backgroundImage:"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)",backgroundOrigin:"border-box","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}},children:w.jsx(Y,{sx:{...$,left:`${u.s}%`,top:`${100-u.v}%`,backgroundColor:m}})}),w.jsx(Y,{ref:S.ref,role:"slider",tabIndex:0,"aria-label":"Hue","aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":Math.round(u.h),onPointerDown:S.onPointerDown,onKeyDown:L=>A(L,"h"),sx:{position:"relative",height:hw,borderRadius:"var(--theme-radius-control)",border:"1px solid",borderColor:"var(--borderColor-default)",cursor:"ew-resize",touchAction:"none",backgroundImage:"linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}},children:w.jsx(Y,{sx:{...$,left:`${u.h/360*100}%`,top:"50%",backgroundColor:Xn(Ps({h:u.h,s:100,v:100}))}})}),a?w.jsxs(Y,{sx:{display:"flex",gap:2,alignItems:"center"},children:[w.jsx(Y,{"aria-hidden":"true",sx:{width:28,height:28,flex:"0 0 auto",borderRadius:"var(--borderRadius-medium)",border:"1px solid",borderColor:"var(--borderColor-default)",backgroundColor:m}}),w.jsx(yn,{"aria-label":"Colour, as hex",value:d,onChange:L=>M(L.target.value),onBlur:()=>p(m),size:"small",sx:{flex:"1 1 auto",fontFamily:"mono"},validationStatus:rd(d)?void 0:"error"})]}):null,N.map(L=>w.jsxs(Y,{children:[w.jsx(Le,{id:`${O}-${L.label}`,sx:{fontSize:0,color:"var(--fgColor-muted)",display:"block",mb:1},children:L.label}),w.jsx(Y,{role:"group","aria-labelledby":`${O}-${L.label}`,sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(22px, 1fr))",gap:1},children:L.colors.map((R,B)=>{const F=R.toLowerCase()===m.toLowerCase();return w.jsx(Y,{as:"button",type:"button","aria-label":R,"aria-pressed":F,onClick:()=>M(R),sx:{height:22,borderRadius:"var(--theme-radius-control)",cursor:"pointer",backgroundColor:R,border:"1px solid",borderColor:F?"var(--borderColor-accent-emphasis)":"var(--borderColor-default)",boxShadow:F?"inset 0 0 0 2px var(--bgColor-default)":"none","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}}},`${R}-${B}`)})})]},L.label))]})}const mw=n=>{const{closeButtonRef:e,content:t,direction:r,headingRef:o,isOpen:s,openButtonRef:i,setIsOpen:a,width:l,zIndex:c}=n,{theme:u,colorMode:f}=Hm(),[d,p]=C.useState(r),[h,_]=C.useState(0);C.useEffect(()=>{_(o?.current?.getBoundingClientRect().bottom??0)},[o]);const m=()=>a(!1),y=S=>{S.target instanceof HTMLElement&&S.target.closest('[role="dialog"]')||m()},x=w.jsx(qm,{theme:u,colorMode:f,children:w.jsxs(Yr,{sx:{height:`calc(100vh - ${h}px - 8px)`,width:l,display:"flex",flexDirection:"column",alignItems:"center",padding:"4px"},children:[w.jsx(Yr,{sx:{display:"flex",justifyContent:"right",width:"100%"},children:w.jsx(Pt,{variant:"invisible",ref:e,onClick:m,icon:Dg,"aria-label":"Close"})}),t]})});return e&&i?w.jsx(w.Fragment,{children:s?d==="left"?w.jsx(Yr,{sx:{zIndex:c},children:w.jsx(qa,{initialFocusRef:e,returnFocusRef:i,ignoreClickRefs:[i],onEscape:m,onClickOutside:y,width:"auto",anchorSide:"inside-right",left:0,position:"fixed",top:h,children:x})}):w.jsx(Yr,{sx:{zIndex:c},children:w.jsx(qa,{initialFocusRef:e,returnFocusRef:i,ignoreClickRefs:[i],onEscape:m,onClickOutside:y,width:"auto",anchorSide:"inside-left",right:0,position:"fixed",top:h,children:x})}):w.jsx(w.Fragment,{})}):w.jsx(w.Fragment,{})},bw=({width:n="500px",direction:e="left",zIndex:t=100,...r})=>w.jsx(mw,{width:n,direction:e,zIndex:t,...r});function yw(n,e,t,r=10,o=5){if(n===null){e.style.opacity="0",e.style.transform="translateY(-4px)",e.style.top="-10000px",e.style.left="-10000px";return}const s=e.getBoundingClientRect(),i=t.getBoundingClientRect();let a=n.top-i.top-s.height-r,l=n.left-i.left-o;a<0&&(a=n.bottom-i.top+r),l+s.width>i.width&&(l=i.width-s.width-o),l<o&&(l=o),e.style.opacity="1",e.style.transform="translateY(0)",e.style.top=`${a}px`,e.style.left=`${l}px`}function ww({items:n,extraItems:e,anchorElement:t,isVisible:r,className:o,disabled:s,ariaLabel:i="Floating toolbar",portalContainer:a}){const l=C.useRef(null),c=C.useMemo(()=>e?.length?[...n,...e]:n,[n,e]),u=C.useCallback(()=>{const p=l.current;if(!p||!t)return;const h=window.getSelection();if(!h||h.isCollapsed||!r){p.style.opacity="0",p.style.transform="translateY(-4px)";return}const m=h.getRangeAt(0).getBoundingClientRect();yw(m,p,t)},[t,r]);if(C.useEffect(()=>{if(!r)return;const p=()=>u();window.addEventListener("resize",p),window.addEventListener("scroll",p,!0);const h=t?.parentElement;return h&&h.addEventListener("scroll",p),p(),()=>{window.removeEventListener("resize",p),window.removeEventListener("scroll",p,!0),h&&h.removeEventListener("scroll",p)}},[r,u,t]),!r||c.length===0)return null;const f=a||t||document.body,d=w.jsx(Yr,{ref:l,className:o,role:"toolbar","aria-label":i,display:"flex",alignItems:"center",gap:"2px",px:1,py:"4px",bg:"canvas.overlay",color:"fg.default",border:"1px solid",borderColor:"border.default",borderRadius:"overlay",boxShadow:"shadow.large",position:"absolute",zIndex:10,top:"-10000px",left:"-10000px",opacity:0,transition:"opacity 0.15s ease, transform 0.15s ease",transform:"translateY(-4px)",children:w.jsx(Vm,{items:c,disabled:s,size:"small"})});return Tt.createPortal(d,f)}var ia=function(){return Vy.Date.now()},xw="Expected a function",Cw=Math.max,Sw=Math.min;function vw(n,e,t){var r,o,s,i,a,l,c=0,u=!1,f=!1,d=!0;if(typeof n!="function")throw new TypeError(xw);e=Qu(e)||0,Yy(t)&&(u=!!t.leading,f="maxWait"in t,s=f?Cw(Qu(t.maxWait)||0,e):s,d="trailing"in t?!!t.trailing:d);function p(E){var T=r,N=o;return r=o=void 0,c=E,i=n.apply(N,T),i}function h(E){return c=E,a=setTimeout(y,e),u?p(E):i}function _(E){var T=E-l,N=E-c,O=e-T;return f?Sw(O,s-N):O}function m(E){var T=E-l,N=E-c;return l===void 0||T>=e||T<0||f&&N>=s}function y(){var E=ia();if(m(E))return x(E);a=setTimeout(y,_(E))}function x(E){return a=void 0,d&&r?p(E):(r=o=void 0,i)}function S(){a!==void 0&&clearTimeout(a),c=0,r=l=o=a=void 0}function v(){return a===void 0?i:x(ia())}function I(){var E=ia(),T=m(E);if(r=arguments,o=this,l=E,T){if(a===void 0)return h(l);if(f)return clearTimeout(a),a=setTimeout(y,e),p(l)}return a===void 0&&(a=setTimeout(y,e)),i}return I.cancel=S,I.flush=v,I}const jp=[];let cs=class extends Oe{__ids;$config(){return this.config("mark",{extends:Oe})}afterCloneFrom(e){super.afterCloneFrom(e),this.__ids=e.__ids}updateFromJSON(e){return super.updateFromJSON(e).setIDs(e.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(e=jp,t){super(t),this.__ids=e}createDOM(e){const t=He().createElement("mark");return Te(t,e.theme.mark),this.__ids.length>1&&Te(t,e.theme.markOverlap),t}updateDOM(e,t,r){const o=e.__ids,s=this.__ids,i=o.length,a=s.length,l=r.theme.markOverlap;return i!==a&&(i===1?a===2&&Te(t,l):a===1&&Rt(t,l)),!1}hasID(e){return this.getIDs().includes(e)}getIDs(){return Array.from(this.getLatest().__ids)}setIDs(e){const t=this.getWritable();return t.__ids=e,t}addID(e){const t=this.getWritable();return t.__ids.includes(e)?t:t.setIDs([...t.__ids,e])}deleteID(e){const t=this.getWritable(),r=t.__ids.indexOf(e);if(r===-1)return t;const o=Array.from(t.__ids);return o.splice(r,1),t.setIDs(o)}insertNewAfter(e,t=!0){const r=dc(this.__ids);return this.insertAfter(r,t),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,r){if(!j(t)||r==="html")return!1;const o=t.anchor,s=t.focus,i=o.getNode(),a=s.getNode(),l=t.isBackward()?o.offset-s.offset:s.offset-o.offset;return this.isParentOf(i)&&this.isParentOf(a)&&this.getTextContent().length===l}excludeFromCopy(e){return e!=="clone"}};function dc(n=jp){return Nt(new cs(n))}function mo(n){return n instanceof cs}function kw(n){const e=n.getChildren();let t=null;for(let r=0;r<e.length;r++){const o=e[r];t===null?n.insertBefore(o):t.insertAfter(o),t=o}n.remove()}function Iw(n,e,t,r){const o=gr(),[s,i]=n.isBackward()?[n.focus,n.anchor]:[n.anchor,n.focus];let a,l;o.anchor.set(s.key,s.offset,s.type),o.focus.set(i.key,i.offset,i.type);const c=o.extract();for(const u of c){if(H(l)&&l.isParentOf(u))continue;let f=null;if(oe(u))f=u;else{if(mo(u))continue;(H(u)||vt(u))&&u.isInline()&&(f=u)}if(f!==null){if(f&&f.is(a))continue;const d=f.getParent();d!=null&&d.is(a)||(l=void 0),a=d,l===void 0&&(l=dc([t]),f.insertBefore(l)),l.append(f)}else a=void 0,l=void 0}H(l)&&(e?l.selectStart():l.selectEnd())}function Tw(n,e){let t=n;for(;t!==null;){if(mo(t))return t.getIDs();if(oe(t)&&e===t.getTextContentSize()){const r=t.getNextSibling();if(mo(r))return r.getIDs()}t=t.getParent()}return null}const Ew=pe({name:"@lexical/mark",nodes:()=>[cs]});class bo extends jt{__id;__quote;__comments;static getType(){return"comment-thread"}static clone(e){return new bo(e.__id,e.__quote,e.__comments,e.__key)}static importJSON(e){return new bo(e.id,e.quote,e.comments)}exportJSON(){return{type:"comment-thread",version:1,id:this.__id,quote:this.__quote,comments:this.__comments}}constructor(e,t,r,o){super(o),this.__id=e,this.__quote=t,this.__comments=r}createDOM(e){const t=document.createElement("div");return t.style.display="none",t}updateDOM(){return!1}isInline(){return!1}getId(){return this.__id}getQuote(){return this.__quote}getComments(){return this.__comments}addComment(e){const t=this.getWritable();t.__comments=[...t.__comments,e]}deleteComment(e){const t=this.getWritable();t.__comments=t.__comments.map(r=>r.id===e?{...r,deleted:!0,content:"[Deleted Comment]"}:r)}decorate(e){return w.jsx(w.Fragment,{})}}function Nw(n,e,t){return new bo(n,e,t)}function js(n){return n instanceof bo}const so=n=>n.name||n.handle||n.uid,fc=n=>n.name||n.handle||n.uid||"Anonymous",gc=n=>({kind:"anonymous",name:n||"Anonymous"}),Lw=n=>n.authorPrincipal??gc(n.author);function Fp(n,e){const t=[];for(const r of e)n.includes(`@${so(r)}`)&&!t.includes(r.uid)&&t.push(r.uid);return t}function Bp(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Up(n,e,t,r,o,s){const i=typeof e=="string"?gc(e):e;return{author:fc(i),authorPrincipal:i,content:n,deleted:o===void 0?!1:o,id:t===void 0?Bp():t,...s&&s.length>0?{mentions:s}:{},timeStamp:r===void 0?Date.now():r,type:"comment"}}function Ow(n,e,t){return{comments:e,id:t===void 0?Bp():t,quote:n,type:"thread"}}function Aw(n){return{author:n.author,...n.authorPrincipal?{authorPrincipal:n.authorPrincipal}:{},content:"[Deleted Comment]",deleted:!0,id:n.id,timeStamp:n.timeStamp,type:"comment"}}function Rw(n){const e=n._changeListeners;for(const t of e)t()}class Mw{_editor;_changeListeners;constructor(e){this._editor=e,this._changeListeners=new Set,this._editor.registerUpdateListener(()=>{Rw(this)})}getComments(){const e=[];return this._editor.getEditorState().read(()=>{se().getChildren().forEach(r=>{if(js(r)){const o=r;e.push({type:"thread",id:o.getId(),quote:o.getQuote(),comments:o.getComments()})}})}),e}addComment(e,t,r){this._editor.update(()=>{if(t!==void 0&&e.type==="comment")se().getChildren().forEach(s=>{if(js(s)){const i=s;i.getId()===t.id&&i.addComment(e)}});else if(e.type==="thread"){const o=Nw(e.id,e.quote,e.comments);se().append(o)}})}deleteComment(e,t){const r=this.deleteCommentOrThread(e,t);r!==null&&this.addComment(r.markedComment,t,r.index)}deleteThread(e){this.deleteCommentOrThread(e)}deleteCommentOrThread(e,t){let r=null;return this._editor.update(()=>{t!==void 0&&e.type==="comment"?se().getChildren().forEach(s=>{if(js(s)){const i=s;i.getId()===t.id&&(r=i.getComments().findIndex(l=>l.id===e.id),i.deleteComment(e.id))}}):se().getChildren().forEach(s=>{js(s)&&s.getId()===e.id&&s.remove()})}),e.type==="comment"?{index:r!==null?r:0,markedComment:Aw(e)}:null}registerOnChange(e){const t=this._changeListeners;return t.add(e),()=>{t.delete(e)}}}function $w(n){const[e,t]=C.useState(n.getComments());return C.useEffect(()=>(t(n.getComments()),n.registerOnChange(()=>{t(n.getComments())})),[n]),e}const cr=({"data-test-id":n,children:e,className:t,onClick:r,disabled:o,small:s,title:i})=>w.jsx(ft,{disabled:o,onClick:r,title:i,"aria-label":i,size:s?"small":"medium",variant:"default",className:t,...n&&{"data-test-id":n},children:e}),Dw=({className:n,style:e})=>w.jsx(Pg,{className:n||"ContentEditable__root",style:e});function SA({label:n="Loading the document",header:e=!1,maxWidth:t=760}={}){return w.jsxs(Fy,{label:n,sx:{flex:1,minHeight:0,width:"100%",overflow:"hidden"},children:[e?w.jsx(By,{}):null,w.jsxs(Yr,{sx:{px:4,py:e?0:4,pb:4,display:"grid",gap:4,maxWidth:t,mx:"auto",width:"100%"},children:[w.jsx(Rs,{size:"titleLarge",lines:1,maxWidth:"22rem"}),w.jsx(Rs,{size:"bodyMedium",lines:3}),w.jsx(Rs,{size:"bodyMedium",lines:4,maxWidth:"92%"}),w.jsx(Ym,{width:"100%",height:"120px"}),w.jsx(Rs,{size:"bodyMedium",lines:3,maxWidth:"88%"})]})]})}function Pw({equation:n,setEquation:e,inline:t,inputRef:r}){const s={equation:n,inputRef:r,onChange:i=>{e(i.target.value)}};return t?w.jsx(jw,{...s,inputRef:r}):w.jsx(Fw,{...s,inputRef:r})}function jw({equation:n,onChange:e,inputRef:t}){return w.jsxs("span",{className:"EquationEditor_inputBackground",children:[w.jsx("span",{className:"EquationEditor_dollarSign",children:"$"}),w.jsx("input",{className:"EquationEditor_inlineEditor",value:n,onChange:e,autoFocus:!0,ref:t}),w.jsx("span",{className:"EquationEditor_dollarSign",children:"$"})]})}function Fw({equation:n,onChange:e,inputRef:t}){return w.jsxs("div",{className:"EquationEditor_inputBackground",children:[w.jsx("span",{className:"EquationEditor_dollarSign",children:`$$
1
+ import{r as C,b1 as Km,b2 as Wm,j as w,aF as Y,a9 as yn,T as Le,en as Jm,bM as Au,a1 as Hm,dH as qm,B as Yr,I as Pt,fn as Dg,hq as qa,pD as Vm,bH as Tt,b0 as pe,pE as Oe,pF as He,pG as Te,pH as Rt,mQ as j,pI as Nt,pJ as gr,mv as H,mA as oe,mB as vt,pK as jt,bd as se,v as ft,b6 as Pg,eo as Rs,em as Ym,hx as At,_ as me,li as jg,aI as Gm,D as Fg,pL as Xm,pM as to,pN as Hl,pO as To,mD as bt,pP as $n,mu as xt,be as ne,pQ as ys,ck as de,pR as Zm,mS as Er,mP as P,cn as ee,pS as on,pT as Bg,pU as Qm,pV as ws,n1 as sn,n4 as ke,mC as ue,pW as Ye,pX as Ge,pY as Ug,pZ as Ru,p_ as gt,p$ as eb,mU as Nr,mO as mn,q0 as Va,mT as Mt,q1 as an,q2 as pr,q3 as pt,q4 as Ht,q5 as hr,q6 as os,q7 as zg,q8 as fi,q9 as tb,qa as Zs,qb as jn,qc as nb,qd as rb,aG as Q,qe as ob,mr as De,fM as Kg,Y as ir,n3 as Me,qf as sb,qg as ib,qh as ab,qi as Bt,qj as go,qk as Jn,ql as Hn,qm as ss,qn as bn,qo as xs,qp as qn,qq as pn,qr as Cs,mY as ve,mV as re,qs as V,qt as Wg,qu as ql,qv as Gr,cm as po,qw as lb,qx as Xr,qy as Mu,qz as Jg,qA as Hg,qB as Ya,qC as cb,qD as qg,qE as Vl,qF as ub,qG as db,qH as Yl,qI as Ga,qJ as Vg,qK as fb,qL as Yg,qM as gb,qN as Gl,qO as is,mM as Ee,qP as pb,m_ as Cn,qQ as $u,qR as hb,qS as _b,qT as Du,qU as Xa,mN as ho,qV as Xl,qW as Qs,qX as $i,qY as Gg,qZ as Zl,q_ as Di,q$ as Ms,r0 as Pu,r1 as ju,r2 as Ss,r3 as Fu,r4 as An,r5 as mb,r6 as bb,r7 as Xe,r8 as yb,r9 as wb,ra as Xg,rb as Zg,rc as Qg,cl as vs,rd as Ql,re as xb,rf as he,rg as ep,rh as as,ri as ra,rj as tp,rk as ec,rl as Za,rm as Cb,rn as _r,ro as yt,mZ as Vn,rp as Pi,rq as Sb,rr as tc,rs as np,rt as nc,ru as Xo,rv as Bu,rw as it,ms as ht,rx as Uu,ry as Wt,rz as ji,rA as rp,rB as op,rC as sp,rD as Dn,rE as vb,rF as kb,rG as gi,rH as Ib,rI as Tb,rJ as Eb,rK as Qa,rL as rr,rM as ip,rN as Nb,rO as el,rP as pi,rQ as ap,mW as Kt,rR as _o,mR as qe,rS as lp,rT as Lb,rU as Ob,mq as Ab,rV as no,rW as Yn,rX as cp,rY as Rb,rZ as Mb,r_ as rc,r$ as up,s0 as $b,s1 as zu,s2 as Db,s3 as Ku,s4 as Pb,s5 as jb,s6 as oc,s7 as Fb,s8 as Wu,mK as Bb,mJ as Ub,mI as zb,s9 as Ju,mL as Kb,sa as Hu,sb as dp,an as fe,m$ as Wb,sc as Jb,sd as Hb,se as qb,sf as qu,sg as Vb,sh as Yb,si as Vu,sj as Yu,sk as Fn,sl as Gb,sm as Xb,sn as Zb,so as Qb,sp as sc,sq as ey,sr as ty,l5 as tl,fw as ls,mX as ro,ss as fp,st as hi,mt as gp,my as ic,mx as ac,mw as pp,mz as hp,su as _p,sv as nl,sw as Gu,sx as ny,sy as rl,sz as Fi,sA as mp,sB as bp,sC as ry,sD as yp,sE as wp,sF as Tn,sG as oy,n$ as sy,o5 as Xu,o6 as ol,o8 as iy,o9 as ay,sH as xp,sI as Cp,sJ as Sp,sK as vp,sL as Zu,z as kp,A as ly,sM as cy,sN as uy,H as dy,sO as fy,sP as gy,b5 as py,b7 as hy,W as Ip,sQ as _y,bf as Tp,sR as my,bb as by,sS as yy,sT as wy,ln as Et,lv as We,lt as ar,lq as Qe,lu as lr,ls as Gt,lx as xy,a5 as Cy,a2 as oa,V as Sy,dL as ei,sU as Rn,fx as Ep,sV as vy,bJ as lc,aH as ky,sW as cc,fW as Iy,sX as Ty,fK as Np,sY as Ey,sZ as Ny,s_ as Ly,s$ as Oy,t0 as Lp,t1 as we,dI as oo,bA as Ie,t2 as Op,X as _i,t3 as Ay,t4 as Ry,t5 as $s,ly as My,gq as $y,t6 as Dy,M as Py,t7 as Eo}from"../datalayer-app-main.js";import{d as jy,b as Fy,E as By,u as Uy,c as zy,e as Ky,f as Wy}from"./NotebookSkeleton-DHQ--KEB.js";import{p as Ko,e as Jy,s as Hy,u as qy}from"./url-4_0MnaFQ.js";import{r as Vy,a as Yy}from"./isObject-CeOzAI2h.js";import{t as Qu}from"./toNumber-DUdf79Nr.js";import{B as Ap,I as Rp,S as Mp}from"./StrikethroughIcon-CbiEuPT-.js";import{P as Gy,C as mi,D as uc,T as $p,H as Xy,L as Dp,F as Zo,Q as Pp,a as bi,M as Zy,b as Qy,R as ew,c as tw,d as nw}from"./TypographyIcon-CCkcdj7U.js";import{A as rw}from"./Avatar-B0TcOj_b.js";import{A as ow,a as sw}from"./ArrowUpIcon-y5enrVH9.js";import{u as iw,i as Ds,a as ed,o as td,s as nd}from"./floating-ui.react-dom-Bcd0th1j.js";import{S as aw}from"./SortDescIcon-Qif6E10I.js";import{V as ks}from"./VideoIcon-BTOb9gRv.js";import{P as sl,p as lw}from"./PrismCss-C5fDCsu9.js";import{j as il,O as cw,C as uw}from"./Output-DLpf2Of9.js";import{d as ge,l as Zr}from"./LexicalToolRegistry-BqxU1w4N.js";const yi=(n,e,t)=>Math.min(t,Math.max(e,n));function jo(n){const e=n.trim(),t=/^rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i.exec(e);if(t){const[,o,s,i]=t;return{r:Number(o),g:Number(s),b:Number(i)}}let r=e.replace(/^#/,"");return r.length===3&&(r=r.split("").map(o=>o+o).join("")),/^[0-9a-f]{6}$/i.test(r)?{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}:{r:0,g:0,b:0}}function Xn({r:n,g:e,b:t}){const r=o=>yi(Math.round(o),0,255).toString(16).padStart(2,"0");return`#${r(n)}${r(e)}${r(t)}`}function sa({r:n,g:e,b:t}){const r=n/255,o=e/255,s=t/255,i=Math.max(r,o,s),a=Math.min(r,o,s),l=i-a;let c=0;return l!==0&&(i===r?c=60*((o-s)/l%6):i===o?c=60*((s-r)/l+2):c=60*((r-o)/l+4)),c<0&&(c+=360),{h:c,s:i===0?0:l/i*100,v:i*100}}function Ps({h:n,s:e,v:t}){const r=e/100,o=t/100,s=o*r,i=s*(1-Math.abs(n/60%2-1)),a=o-s,l=Math.floor((n%360+360)%360/60),[c,u,f]=[[s,i,0],[i,s,0],[0,s,i],[0,i,s],[i,0,s],[s,0,i]][l];return{r:Math.round((c+a)*255),g:Math.round((u+a)*255),b:Math.round((f+a)*255)}}function rd(n){const e=n.trim();return/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(e)||/^rgba?\(\s*\d+[,\s]+\d+[,\s]+\d+/i.test(e)}const dw=["#cf222e","#bc4c00","#9a6700","#1a7f37","#0969da","#8250df","#bf3989","#24292f","#57606a","#8c959f","#d0d7de","#ffffff"];function fw(n="datalayer",e="light"){const t=Jm(n,e),r=Au[n]??Au.datalayer,s=(e==="auto"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e)==="dark"?r.themeStyles.dark:r.themeStyles.light,i=a=>s[a];return{label:r.label,colors:[i("--bgColor-default"),i("--bgColor-muted"),i("--fgColor-default"),i("--fgColor-muted"),i("--fgColor-accent"),i("--fgColor-success"),i("--fgColor-attention"),i("--fgColor-danger"),t.glow,t.pop,t.spark,t.blaze,t.surge,t.flame,t.gold].filter(Boolean)}}function gw(n="datalayer",e="dark"){return{label:"Collaborators",colors:jy(n,e)}}const pw=150,hw=12;function od(n){const e=C.useRef(null),t=C.useRef(!1),r=C.useCallback(s=>{const i=e.current;if(!i)return;const a=i.getBoundingClientRect();n(yi((s.clientX-a.left)/a.width,0,1),yi((s.clientY-a.top)/a.height,0,1))},[n]);return C.useEffect(()=>{const s=a=>t.current&&r(a),i=()=>{t.current=!1};return window.addEventListener("pointermove",s),window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i),()=>{window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)}},[r]),{ref:e,onPointerDown:s=>{t.current=!0,r(s)}}}function _w({color:n,onChange:e,presets:t=dw,showPresets:r=!0,presetGroups:o,showThemeColors:s=!0,showCollaboratorColors:i=!1,showInput:a=!0,width:l=232,"aria-label":c="Colour picker"}){const[u,f]=C.useState(()=>sa(jo(n))),[d,p]=C.useState(()=>Xn(jo(n))),h=C.useRef(!1);C.useEffect(()=>{if(h.current){h.current=!1;return}const L=jo(n);f(sa(L)),p(Xn(L))},[n]);const _=C.useMemo(()=>Ps(u),[u]),m=C.useMemo(()=>Xn(_),[_]),y=C.useCallback(L=>{h.current=!0,f(L);const R=Xn(Ps(L));p(R),e?.(R)},[e]),x=od(C.useCallback((L,R)=>y({...u,s:L*100,v:(1-R)*100}),[y,u])),S=od(C.useCallback(L=>y({...u,h:L*360}),[y,u])),{theme:v,colorMode:I}=Km(),E=Wm(),T=I==="auto"?E:I,N=C.useMemo(()=>{const L=[];return r&&t.length>0&&L.push({label:"Presets",colors:t}),s&&L.push(fw(v,T)),i&&L.push(gw(v,T)),L.concat(o??[])},[v,o,t,T,i,r,s]),O=C.useId(),M=L=>{if(p(L),rd(L)){const R=sa(jo(L));h.current=!0,f(R),e?.(Xn(jo(L)))}},A=(L,R)=>{const B=L.shiftKey?10:1,F=L.key==="ArrowLeft"||L.key==="ArrowDown",U=L.key==="ArrowRight"||L.key==="ArrowUp";if(!F&&!U)return;L.preventDefault();const K=U?B:-B,W=R==="h"?360:100;y({...u,[R]:yi(u[R]+K,0,W)})},$={position:"absolute",width:14,height:14,borderRadius:"50%",border:"2px solid #ffffff",boxShadow:"0 0 0 1px rgba(0, 0, 0, 0.35)",transform:"translate(-50%, -50%)",pointerEvents:"none"};return w.jsxs(Y,{role:"group","aria-label":c,sx:{display:"grid",gap:2,width:l,minWidth:0},children:[w.jsx(Y,{ref:x.ref,role:"slider",tabIndex:0,"aria-label":"Saturation and brightness","aria-valuetext":`saturation ${Math.round(u.s)}%, brightness ${Math.round(u.v)}%`,onPointerDown:x.onPointerDown,onKeyDown:L=>A(L,L.key==="ArrowUp"||L.key==="ArrowDown"?"v":"s"),sx:{position:"relative",height:pw,borderRadius:"var(--theme-radius-card)",border:"1px solid",borderColor:"var(--borderColor-default)",cursor:"crosshair",touchAction:"none",backgroundColor:Xn(Ps({h:u.h,s:100,v:100})),backgroundImage:"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)",backgroundOrigin:"border-box","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}},children:w.jsx(Y,{sx:{...$,left:`${u.s}%`,top:`${100-u.v}%`,backgroundColor:m}})}),w.jsx(Y,{ref:S.ref,role:"slider",tabIndex:0,"aria-label":"Hue","aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":Math.round(u.h),onPointerDown:S.onPointerDown,onKeyDown:L=>A(L,"h"),sx:{position:"relative",height:hw,borderRadius:"var(--theme-radius-control)",border:"1px solid",borderColor:"var(--borderColor-default)",cursor:"ew-resize",touchAction:"none",backgroundImage:"linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}},children:w.jsx(Y,{sx:{...$,left:`${u.h/360*100}%`,top:"50%",backgroundColor:Xn(Ps({h:u.h,s:100,v:100}))}})}),a?w.jsxs(Y,{sx:{display:"flex",gap:2,alignItems:"center"},children:[w.jsx(Y,{"aria-hidden":"true",sx:{width:28,height:28,flex:"0 0 auto",borderRadius:"var(--borderRadius-medium)",border:"1px solid",borderColor:"var(--borderColor-default)",backgroundColor:m}}),w.jsx(yn,{"aria-label":"Colour, as hex",value:d,onChange:L=>M(L.target.value),onBlur:()=>p(m),size:"small",sx:{flex:"1 1 auto",fontFamily:"mono"},validationStatus:rd(d)?void 0:"error"})]}):null,N.map(L=>w.jsxs(Y,{children:[w.jsx(Le,{id:`${O}-${L.label}`,sx:{fontSize:0,color:"var(--fgColor-muted)",display:"block",mb:1},children:L.label}),w.jsx(Y,{role:"group","aria-labelledby":`${O}-${L.label}`,sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(22px, 1fr))",gap:1},children:L.colors.map((R,B)=>{const F=R.toLowerCase()===m.toLowerCase();return w.jsx(Y,{as:"button",type:"button","aria-label":R,"aria-pressed":F,onClick:()=>M(R),sx:{height:22,borderRadius:"var(--theme-radius-control)",cursor:"pointer",backgroundColor:R,border:"1px solid",borderColor:F?"var(--borderColor-accent-emphasis)":"var(--borderColor-default)",boxShadow:F?"inset 0 0 0 2px var(--bgColor-default)":"none","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}}},`${R}-${B}`)})})]},L.label))]})}const mw=n=>{const{closeButtonRef:e,content:t,direction:r,headingRef:o,isOpen:s,openButtonRef:i,setIsOpen:a,width:l,zIndex:c}=n,{theme:u,colorMode:f}=Hm(),[d,p]=C.useState(r),[h,_]=C.useState(0);C.useEffect(()=>{_(o?.current?.getBoundingClientRect().bottom??0)},[o]);const m=()=>a(!1),y=S=>{S.target instanceof HTMLElement&&S.target.closest('[role="dialog"]')||m()},x=w.jsx(qm,{theme:u,colorMode:f,children:w.jsxs(Yr,{sx:{height:`calc(100vh - ${h}px - 8px)`,width:l,display:"flex",flexDirection:"column",alignItems:"center",padding:"4px"},children:[w.jsx(Yr,{sx:{display:"flex",justifyContent:"right",width:"100%"},children:w.jsx(Pt,{variant:"invisible",ref:e,onClick:m,icon:Dg,"aria-label":"Close"})}),t]})});return e&&i?w.jsx(w.Fragment,{children:s?d==="left"?w.jsx(Yr,{sx:{zIndex:c},children:w.jsx(qa,{initialFocusRef:e,returnFocusRef:i,ignoreClickRefs:[i],onEscape:m,onClickOutside:y,width:"auto",anchorSide:"inside-right",left:0,position:"fixed",top:h,children:x})}):w.jsx(Yr,{sx:{zIndex:c},children:w.jsx(qa,{initialFocusRef:e,returnFocusRef:i,ignoreClickRefs:[i],onEscape:m,onClickOutside:y,width:"auto",anchorSide:"inside-left",right:0,position:"fixed",top:h,children:x})}):w.jsx(w.Fragment,{})}):w.jsx(w.Fragment,{})},bw=({width:n="500px",direction:e="left",zIndex:t=100,...r})=>w.jsx(mw,{width:n,direction:e,zIndex:t,...r});function yw(n,e,t,r=10,o=5){if(n===null){e.style.opacity="0",e.style.transform="translateY(-4px)",e.style.top="-10000px",e.style.left="-10000px";return}const s=e.getBoundingClientRect(),i=t.getBoundingClientRect();let a=n.top-i.top-s.height-r,l=n.left-i.left-o;a<0&&(a=n.bottom-i.top+r),l+s.width>i.width&&(l=i.width-s.width-o),l<o&&(l=o),e.style.opacity="1",e.style.transform="translateY(0)",e.style.top=`${a}px`,e.style.left=`${l}px`}function ww({items:n,extraItems:e,anchorElement:t,isVisible:r,className:o,disabled:s,ariaLabel:i="Floating toolbar",portalContainer:a}){const l=C.useRef(null),c=C.useMemo(()=>e?.length?[...n,...e]:n,[n,e]),u=C.useCallback(()=>{const p=l.current;if(!p||!t)return;const h=window.getSelection();if(!h||h.isCollapsed||!r){p.style.opacity="0",p.style.transform="translateY(-4px)";return}const m=h.getRangeAt(0).getBoundingClientRect();yw(m,p,t)},[t,r]);if(C.useEffect(()=>{if(!r)return;const p=()=>u();window.addEventListener("resize",p),window.addEventListener("scroll",p,!0);const h=t?.parentElement;return h&&h.addEventListener("scroll",p),p(),()=>{window.removeEventListener("resize",p),window.removeEventListener("scroll",p,!0),h&&h.removeEventListener("scroll",p)}},[r,u,t]),!r||c.length===0)return null;const f=a||t||document.body,d=w.jsx(Yr,{ref:l,className:o,role:"toolbar","aria-label":i,display:"flex",alignItems:"center",gap:"2px",px:1,py:"4px",bg:"canvas.overlay",color:"fg.default",border:"1px solid",borderColor:"border.default",borderRadius:"overlay",boxShadow:"shadow.large",position:"absolute",zIndex:10,top:"-10000px",left:"-10000px",opacity:0,transition:"opacity 0.15s ease, transform 0.15s ease",transform:"translateY(-4px)",children:w.jsx(Vm,{items:c,disabled:s,size:"small"})});return Tt.createPortal(d,f)}var ia=function(){return Vy.Date.now()},xw="Expected a function",Cw=Math.max,Sw=Math.min;function vw(n,e,t){var r,o,s,i,a,l,c=0,u=!1,f=!1,d=!0;if(typeof n!="function")throw new TypeError(xw);e=Qu(e)||0,Yy(t)&&(u=!!t.leading,f="maxWait"in t,s=f?Cw(Qu(t.maxWait)||0,e):s,d="trailing"in t?!!t.trailing:d);function p(E){var T=r,N=o;return r=o=void 0,c=E,i=n.apply(N,T),i}function h(E){return c=E,a=setTimeout(y,e),u?p(E):i}function _(E){var T=E-l,N=E-c,O=e-T;return f?Sw(O,s-N):O}function m(E){var T=E-l,N=E-c;return l===void 0||T>=e||T<0||f&&N>=s}function y(){var E=ia();if(m(E))return x(E);a=setTimeout(y,_(E))}function x(E){return a=void 0,d&&r?p(E):(r=o=void 0,i)}function S(){a!==void 0&&clearTimeout(a),c=0,r=l=o=a=void 0}function v(){return a===void 0?i:x(ia())}function I(){var E=ia(),T=m(E);if(r=arguments,o=this,l=E,T){if(a===void 0)return h(l);if(f)return clearTimeout(a),a=setTimeout(y,e),p(l)}return a===void 0&&(a=setTimeout(y,e)),i}return I.cancel=S,I.flush=v,I}const jp=[];let cs=class extends Oe{__ids;$config(){return this.config("mark",{extends:Oe})}afterCloneFrom(e){super.afterCloneFrom(e),this.__ids=e.__ids}updateFromJSON(e){return super.updateFromJSON(e).setIDs(e.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(e=jp,t){super(t),this.__ids=e}createDOM(e){const t=He().createElement("mark");return Te(t,e.theme.mark),this.__ids.length>1&&Te(t,e.theme.markOverlap),t}updateDOM(e,t,r){const o=e.__ids,s=this.__ids,i=o.length,a=s.length,l=r.theme.markOverlap;return i!==a&&(i===1?a===2&&Te(t,l):a===1&&Rt(t,l)),!1}hasID(e){return this.getIDs().includes(e)}getIDs(){return Array.from(this.getLatest().__ids)}setIDs(e){const t=this.getWritable();return t.__ids=e,t}addID(e){const t=this.getWritable();return t.__ids.includes(e)?t:t.setIDs([...t.__ids,e])}deleteID(e){const t=this.getWritable(),r=t.__ids.indexOf(e);if(r===-1)return t;const o=Array.from(t.__ids);return o.splice(r,1),t.setIDs(o)}insertNewAfter(e,t=!0){const r=dc(this.__ids);return this.insertAfter(r,t),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,r){if(!j(t)||r==="html")return!1;const o=t.anchor,s=t.focus,i=o.getNode(),a=s.getNode(),l=t.isBackward()?o.offset-s.offset:s.offset-o.offset;return this.isParentOf(i)&&this.isParentOf(a)&&this.getTextContent().length===l}excludeFromCopy(e){return e!=="clone"}};function dc(n=jp){return Nt(new cs(n))}function mo(n){return n instanceof cs}function kw(n){const e=n.getChildren();let t=null;for(let r=0;r<e.length;r++){const o=e[r];t===null?n.insertBefore(o):t.insertAfter(o),t=o}n.remove()}function Iw(n,e,t,r){const o=gr(),[s,i]=n.isBackward()?[n.focus,n.anchor]:[n.anchor,n.focus];let a,l;o.anchor.set(s.key,s.offset,s.type),o.focus.set(i.key,i.offset,i.type);const c=o.extract();for(const u of c){if(H(l)&&l.isParentOf(u))continue;let f=null;if(oe(u))f=u;else{if(mo(u))continue;(H(u)||vt(u))&&u.isInline()&&(f=u)}if(f!==null){if(f&&f.is(a))continue;const d=f.getParent();d!=null&&d.is(a)||(l=void 0),a=d,l===void 0&&(l=dc([t]),f.insertBefore(l)),l.append(f)}else a=void 0,l=void 0}H(l)&&(e?l.selectStart():l.selectEnd())}function Tw(n,e){let t=n;for(;t!==null;){if(mo(t))return t.getIDs();if(oe(t)&&e===t.getTextContentSize()){const r=t.getNextSibling();if(mo(r))return r.getIDs()}t=t.getParent()}return null}const Ew=pe({name:"@lexical/mark",nodes:()=>[cs]});class bo extends jt{__id;__quote;__comments;static getType(){return"comment-thread"}static clone(e){return new bo(e.__id,e.__quote,e.__comments,e.__key)}static importJSON(e){return new bo(e.id,e.quote,e.comments)}exportJSON(){return{type:"comment-thread",version:1,id:this.__id,quote:this.__quote,comments:this.__comments}}constructor(e,t,r,o){super(o),this.__id=e,this.__quote=t,this.__comments=r}createDOM(e){const t=document.createElement("div");return t.style.display="none",t}updateDOM(){return!1}isInline(){return!1}getId(){return this.__id}getQuote(){return this.__quote}getComments(){return this.__comments}addComment(e){const t=this.getWritable();t.__comments=[...t.__comments,e]}deleteComment(e){const t=this.getWritable();t.__comments=t.__comments.map(r=>r.id===e?{...r,deleted:!0,content:"[Deleted Comment]"}:r)}decorate(e){return w.jsx(w.Fragment,{})}}function Nw(n,e,t){return new bo(n,e,t)}function js(n){return n instanceof bo}const so=n=>n.name||n.handle||n.uid,fc=n=>n.name||n.handle||n.uid||"Anonymous",gc=n=>({kind:"anonymous",name:n||"Anonymous"}),Lw=n=>n.authorPrincipal??gc(n.author);function Fp(n,e){const t=[];for(const r of e)n.includes(`@${so(r)}`)&&!t.includes(r.uid)&&t.push(r.uid);return t}function Bp(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Up(n,e,t,r,o,s){const i=typeof e=="string"?gc(e):e;return{author:fc(i),authorPrincipal:i,content:n,deleted:o===void 0?!1:o,id:t===void 0?Bp():t,...s&&s.length>0?{mentions:s}:{},timeStamp:r===void 0?Date.now():r,type:"comment"}}function Ow(n,e,t){return{comments:e,id:t===void 0?Bp():t,quote:n,type:"thread"}}function Aw(n){return{author:n.author,...n.authorPrincipal?{authorPrincipal:n.authorPrincipal}:{},content:"[Deleted Comment]",deleted:!0,id:n.id,timeStamp:n.timeStamp,type:"comment"}}function Rw(n){const e=n._changeListeners;for(const t of e)t()}class Mw{_editor;_changeListeners;constructor(e){this._editor=e,this._changeListeners=new Set,this._editor.registerUpdateListener(()=>{Rw(this)})}getComments(){const e=[];return this._editor.getEditorState().read(()=>{se().getChildren().forEach(r=>{if(js(r)){const o=r;e.push({type:"thread",id:o.getId(),quote:o.getQuote(),comments:o.getComments()})}})}),e}addComment(e,t,r){this._editor.update(()=>{if(t!==void 0&&e.type==="comment")se().getChildren().forEach(s=>{if(js(s)){const i=s;i.getId()===t.id&&i.addComment(e)}});else if(e.type==="thread"){const o=Nw(e.id,e.quote,e.comments);se().append(o)}})}deleteComment(e,t){const r=this.deleteCommentOrThread(e,t);r!==null&&this.addComment(r.markedComment,t,r.index)}deleteThread(e){this.deleteCommentOrThread(e)}deleteCommentOrThread(e,t){let r=null;return this._editor.update(()=>{t!==void 0&&e.type==="comment"?se().getChildren().forEach(s=>{if(js(s)){const i=s;i.getId()===t.id&&(r=i.getComments().findIndex(l=>l.id===e.id),i.deleteComment(e.id))}}):se().getChildren().forEach(s=>{js(s)&&s.getId()===e.id&&s.remove()})}),e.type==="comment"?{index:r!==null?r:0,markedComment:Aw(e)}:null}registerOnChange(e){const t=this._changeListeners;return t.add(e),()=>{t.delete(e)}}}function $w(n){const[e,t]=C.useState(n.getComments());return C.useEffect(()=>(t(n.getComments()),n.registerOnChange(()=>{t(n.getComments())})),[n]),e}const cr=({"data-test-id":n,children:e,className:t,onClick:r,disabled:o,small:s,title:i})=>w.jsx(ft,{disabled:o,onClick:r,title:i,"aria-label":i,size:s?"small":"medium",variant:"default",className:t,...n&&{"data-test-id":n},children:e}),Dw=({className:n,style:e})=>w.jsx(Pg,{className:n||"ContentEditable__root",style:e});function SA({label:n="Loading the document",header:e=!1,maxWidth:t=760}={}){return w.jsxs(Fy,{label:n,sx:{flex:1,minHeight:0,width:"100%",overflow:"hidden"},children:[e?w.jsx(By,{}):null,w.jsxs(Yr,{sx:{px:4,py:e?0:4,pb:4,display:"grid",gap:4,maxWidth:t,mx:"auto",width:"100%"},children:[w.jsx(Rs,{size:"titleLarge",lines:1,maxWidth:"22rem"}),w.jsx(Rs,{size:"bodyMedium",lines:3}),w.jsx(Rs,{size:"bodyMedium",lines:4,maxWidth:"92%"}),w.jsx(Ym,{width:"100%",height:"120px"}),w.jsx(Rs,{size:"bodyMedium",lines:3,maxWidth:"88%"})]})]})}function Pw({equation:n,setEquation:e,inline:t,inputRef:r}){const s={equation:n,inputRef:r,onChange:i=>{e(i.target.value)}};return t?w.jsx(jw,{...s,inputRef:r}):w.jsx(Fw,{...s,inputRef:r})}function jw({equation:n,onChange:e,inputRef:t}){return w.jsxs("span",{className:"EquationEditor_inputBackground",children:[w.jsx("span",{className:"EquationEditor_dollarSign",children:"$"}),w.jsx("input",{className:"EquationEditor_inlineEditor",value:n,onChange:e,autoFocus:!0,ref:t}),w.jsx("span",{className:"EquationEditor_dollarSign",children:"$"})]})}function Fw({equation:n,onChange:e,inputRef:t}){return w.jsxs("div",{className:"EquationEditor_inputBackground",children:[w.jsx("span",{className:"EquationEditor_dollarSign",children:`$$
2
2
  `}),w.jsx("textarea",{className:"EquationEditor_blockEditor",value:n,onChange:e,ref:t}),w.jsx("span",{className:"EquationEditor_dollarSign",children:`
3
- $$`})]})}const Bw=({accept:n,label:e,onChange:t,"data-test-id":r})=>w.jsxs(At,{children:[w.jsx(At.Label,{children:e}),w.jsx(yn,{type:"file",accept:n,onChange:o=>t(o.target.files),"data-test-id":r,block:!0})]});function aa(n,e,t){return Math.min(Math.max(n,e),t)}const Ae={east:1,north:8,south:2,west:4},Uw=({onResizeStart:n,onResizeEnd:e,buttonRef:t,imageRef:r,maxWidth:o,editor:s,showCaption:i,setShowCaption:a})=>{const l=C.useRef(null),c=C.useRef({priority:"",value:"default"}),u=C.useRef({currentHeight:0,currentWidth:0,direction:0,isResizing:!1,ratio:0,startHeight:0,startWidth:0,startX:0,startY:0}),f=s.getRootElement(),d=o||(f!==null?f.getBoundingClientRect().width-20:100),p=f!==null?f.getBoundingClientRect().height-20:100,h=100,_=100,m=I=>{const E=I===Ae.east||I===Ae.west,T=I===Ae.north||I===Ae.south,N=I&Ae.north&&I&Ae.west||I&Ae.south&&I&Ae.east,O=E?"ew":T?"ns":N?"nwse":"nesw";f!==null&&f.style.setProperty("cursor",`${O}-resize`,"important"),document.body!==null&&(document.body.style.setProperty("cursor",`${O}-resize`,"important"),c.current.value=document.body.style.getPropertyValue("-webkit-user-select"),c.current.priority=document.body.style.getPropertyPriority("-webkit-user-select"),document.body.style.setProperty("-webkit-user-select","none","important"))},y=()=>{f!==null&&f.style.setProperty("cursor","default"),document.body!==null&&(document.body.style.setProperty("cursor","default"),document.body.style.setProperty("-webkit-user-select",c.current.value,c.current.priority))},x=(I,E)=>{const T=r.current,N=l.current;if(T!==null&&N!==null){const{width:O,height:M}=T.getBoundingClientRect(),A=u.current;A.startWidth=O,A.startHeight=M,A.ratio=O/M,A.currentWidth=O,A.currentHeight=M,A.startX=I.clientX,A.startY=I.clientY,A.isResizing=!0,A.direction=E,m(E),n(),N.classList.add("image-control-wrapper--resizing"),T.style.height=`${M}px`,T.style.width=`${O}px`,document.addEventListener("pointermove",S),document.addEventListener("pointerup",v)}},S=I=>{const E=r.current,T=u.current,N=T.direction&(Ae.east|Ae.west),O=T.direction&(Ae.south|Ae.north);if(E!==null&&T.isResizing)if(N&&O){let M=Math.floor(T.startX-I.clientX);M=T.direction&Ae.east?-M:M;const A=aa(T.startWidth+M,h,d),$=A/T.ratio;E.style.width=`${A}px`,E.style.height=`${$}px`,T.currentHeight=$,T.currentWidth=A}else if(O){let M=Math.floor(T.startY-I.clientY);M=T.direction&Ae.south?-M:M;const A=aa(T.startHeight+M,_,p);E.style.height=`${A}px`,T.currentHeight=A}else{let M=Math.floor(T.startX-I.clientX);M=T.direction&Ae.east?-M:M;const A=aa(T.startWidth+M,h,d);E.style.width=`${A}px`,T.currentWidth=A}},v=()=>{const I=r.current,E=u.current,T=l.current;if(I!==null&&T!==null&&E.isResizing){const N=E.currentWidth,O=E.currentHeight;E.startWidth=0,E.startHeight=0,E.ratio=0,E.startX=0,E.startY=0,E.currentWidth=0,E.currentHeight=0,E.isResizing=!1,T.classList.remove("image-control-wrapper--resizing"),y(),e(N,O),document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",v)}};return w.jsxs("div",{ref:l,children:[!i&&w.jsx(ft,{ref:t,size:"small",sx:{position:"absolute",bottom:12,left:"50%",transform:"translateX(-50%)",zIndex:10},onClick:()=>{a(!i)},children:"Add Caption"}),w.jsx("div",{className:"image-resizer image-resizer-n",onPointerDown:I=>{x(I,Ae.north)}}),w.jsx("div",{className:"image-resizer image-resizer-ne",onPointerDown:I=>{x(I,Ae.north|Ae.east)}}),w.jsx("div",{className:"image-resizer image-resizer-e",onPointerDown:I=>{x(I,Ae.east)}}),w.jsx("div",{className:"image-resizer image-resizer-se",onPointerDown:I=>{x(I,Ae.south|Ae.east)}}),w.jsx("div",{className:"image-resizer image-resizer-s",onPointerDown:I=>{x(I,Ae.south)}}),w.jsx("div",{className:"image-resizer image-resizer-sw",onPointerDown:I=>{x(I,Ae.south|Ae.west)}}),w.jsx("div",{className:"image-resizer image-resizer-w",onPointerDown:I=>{x(I,Ae.west)}}),w.jsx("div",{className:"image-resizer image-resizer-nw",onPointerDown:I=>{x(I,Ae.north|Ae.west)}})]})};let Fs;function zp(){return Fs||(Fs=Promise.all([me(()=>import("../datalayer-app-main.js").then(n=>n.vd),[],import.meta.url),me(()=>Promise.resolve({}),[],import.meta.url)]).then(([n])=>n.default,n=>{throw Fs=void 0,n})),Fs}function Kp({equation:n,inline:e,onClick:t}){const r=C.useRef(null);return C.useEffect(()=>{let o=!1;return zp().then(s=>{const i=r.current;o||i===null||s.render(n,i,{displayMode:!e,errorColor:"var(--fgColor-danger, #cc0000)",output:"html",strict:"warn",throwOnError:!1,trust:!1})}).catch(s=>{console.debug("KaTeX could not be loaded",s)}),()=>{o=!0}},[n,e]),w.jsxs(w.Fragment,{children:[w.jsx("span",{children:" "}),w.jsx("span",{role:"button",tabIndex:-1,onClick:t,ref:r}),w.jsx("span",{children:" "})]})}const zw=({onConfirm:n,initialEquation:e=""})=>{const[t,r]=C.useState(e),[o,s]=C.useState(!0),i=C.useCallback(()=>{n(t,o)},[n,t,o]),a=C.useCallback(()=>{s(!o)},[s,o]);return w.jsxs(w.Fragment,{children:[w.jsx(Y,{sx:{mb:2},children:w.jsxs(At,{children:[w.jsx(jg,{checked:o,onChange:a}),w.jsx(At.Label,{children:"Inline"})]})}),w.jsx(Le,{sx:{fontSize:1,fontWeight:"bold",mb:1},children:"Equation"}),w.jsx(Y,{sx:{mb:2},children:o?w.jsx(yn,{onChange:l=>{r(l.target.value)},value:t,block:!0}):w.jsx(Gm,{onChange:l=>{r(l.target.value)},value:t,block:!0,rows:6})}),w.jsx(Le,{sx:{fontSize:1,fontWeight:"bold",mb:1},children:"Visualization"}),w.jsx(Y,{sx:{mb:2,p:2,border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,textAlign:"center"},children:w.jsx(Kp,{equation:t,inline:!1,onClick:()=>null})}),w.jsx(Y,{sx:{display:"flex",justifyContent:"flex-end"},children:w.jsx(cr,{onClick:i,children:"Confirm"})})]})},Kw=({onClose:n,children:e,title:t,closeOnClickOutside:r=!1})=>w.jsx(Fg,{title:t,onClose:()=>n(),width:"medium",height:"auto",children:e}),Wp=({children:n,className:e})=>w.jsx("div",{className:e||"Placeholder__root",children:n});function Bi(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of e)r.append("v",o);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Jp(n,e){let t=n;for(let r=gt(n,e);r&&(Ve(r.origin)||bt(r.origin));r=r.getAdjacentCaret())t=r.origin;return t}function ur(n){return Jp(n,"previous")}function io(n){return Jp(n,"next")}function Ww(n){const e=ur(n),t=io(n);let r=e;for(;r!==null;){if(Ve(r)){const s=rb(r.getTextContent());if(s!==null)return s}if(r===t)break;r=r.getNextSibling()}const o=e.getParent();if(H(o)){const s=o.getDirection();if(s==="ltr"||s==="rtl")return s}return null}function Jw(n,e){let t=null,r=null,o=n,s=e,i=n.getTextContent();for(;;){if(s===0){const c=o.getPreviousSibling();if(c===null){o=null;break}if(Ve(c)||bt(c)||ue(c)||Bi(167),o=c,ue(o)){t={node:o,offset:1};break}s=Math.max(0,o.getTextContentSize()-1),i=o.getTextContent()}else s--;const l=i[s];Ve(o)&&l!==" "&&(r={node:o,offset:s})}if(r!==null)return r;let a=null;if(e<n.getTextContentSize())Ve(n)&&(a=n.getTextContent()[e]);else{const l=n.getNextSibling();Ve(l)&&(a=l.getTextContent()[0])}if(a!==null&&a!==" ")return t;{const l=(function(c,u){let f=c,d=u,p=c.getTextContent(),h=c.getTextContentSize();for(;;){if(!Ve(f)||d===h){if(f=f.getNextSibling(),f===null||ue(f))return null;Ve(f)&&(d=0,p=f.getTextContent(),h=f.getTextContentSize())}if(Ve(f)){if(p[d]!==" ")return{node:f,offset:d};d++}}})(n,e);return l!==null?l:t}}function Hw(n){const e=io(n);return ue(e)&&Bi(168),e}function qw(n){const e=[];return zg(n,{linebreak:()=>e.push(xt()),tab:()=>e.push($n()),text:t=>e.push(pc(t))}),e}const Vw="javascript";function Hp(n,e){for(const t of n.childNodes)if(ke(t)&&t.tagName===e||Hp(t,e))return!0;return!1}const Wo="data-language",Fo="data-highlight-language",Bs="data-theme";class ln extends Oe{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:Oe,importDOM:{code:e=>e.textContent!=null&&(/\r?\n/.test(e.textContent)||Hp(e,"BR"))?{conversion:sd,priority:1}:null,div:()=>({conversion:Yw,priority:1}),pre:()=>({conversion:sd,priority:0}),table:e=>la(e)?{conversion:Gw,priority:3}:null,td:e=>{const t=e,r=t.closest("table");return t.classList.contains("js-file-line")||r&&la(r)?{conversion:id,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&la(t)?{conversion:id,priority:3}:null}}})}constructor(e=void 0,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(e){const t=He().createElement("code");Te(t,e.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(t.setAttribute(Wo,r),this.getIsSyntaxHighlightSupported()&&t.setAttribute(Fo,r));const o=this.getTheme();o&&t.setAttribute(Bs,o);const s=this.getStyle();return s&&to(t.style,s),t}updateDOM(e,t,r){const o=this.__language,s=e.__language;o?o!==s&&t.setAttribute(Wo,o):s&&t.removeAttribute(Wo);const i=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&s?i&&o?o!==s&&t.setAttribute(Fo,o):t.removeAttribute(Fo):i&&o&&t.setAttribute(Fo,o);const a=this.__theme,l=e.__theme;a?a!==l&&t.setAttribute(Bs,a):l&&t.removeAttribute(Bs);const c=this.__style,u=e.__style;return c!==u&&to(t.style,c,u),!1}exportDOM(e){const t=He().createElement("pre");Te(t,e._config.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(t.setAttribute(Wo,r),this.getIsSyntaxHighlightSupported()&&t.setAttribute(Fo,r));const o=this.getTheme();o&&t.setAttribute(Bs,o);const s=this.getStyle();return s&&to(t.style,s),{element:t}}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(e,t=!0){if(!Hl(To(),"@lexical/code")){const i=qp(e);if(i)return i}const{anchor:r,focus:o}=e,s=(r.isBefore(o)?r:o).getNode();if(oe(s)){let i=ur(s);const a=[];for(;;)if(bt(i))a.push($n()),i=i.getNextSibling();else{if(!Ve(i))break;{let h=0;const _=i.getTextContent(),m=i.getTextContentSize();for(;h<m&&_[h]===" ";)h++;if(h!==0&&a.push(pc(" ".repeat(h))),h!==m)break;i=i.getNextSibling()}}const l=s.splitText(r.offset)[0],c=r.offset===0?0:1,u=l.getIndexWithinParent()+c,f=s.getParentOrThrow(),d=[xt(),...a];f.splice(u,0,d);const p=a[a.length-1];p?p.select():r.offset===0?l.selectPrevious():l.getNextSibling().selectNext(0,0)}if(je(s)){const{offset:i}=e.anchor;s.splice(i,0,[xt()]),s.select(i+1,i+1)}return null}canIndent(){return!1}collapseAtStart(){const e=ne();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}setLanguage(e){const t=this.getWritable();return t.__language=e||void 0,t}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(e){const t=this.getWritable();return t.__isSyntaxHighlightSupported=e,t}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(e){const t=this.getWritable();return t.__theme=e||void 0,t}getTheme(){return this.getLatest().__theme}}function Ze(n,e){return Xm(ln).setLanguage(n).setTheme(e)}function je(n){return n instanceof ln}function sd(n){return{node:Ze(n.getAttribute(Wo))}}function Yw(n){const e=n,t=ad(e);return t||(function(r){let o=r.parentElement;for(;o!==null;){if(ad(o))return!0;o=o.parentElement}return!1})(e)?{node:t?Ze():null}:{node:null}}function Gw(){return{node:Ze()}}function id(){return{node:null}}function ad(n){return n.style.fontFamily.match("monospace")!==null}function la(n){return n.classList.contains("js-file-line-container")}function qp(n){const{anchor:e}=n;if(n.isCollapsed()&&e.type==="element"){const t=e.getNode();if(je(t)){const r=t.getChildrenSize();if(r>=2&&e.offset===r){const o=t.getLastChild();if(ue(o)&&ue(o.getPreviousSibling())){const s=ne();return t.splice(r-2,2,[]).insertAfter(s,!1),s.select(),s}}}}return null}class Is extends sn{__highlightType;constructor(e="",t,r){super(e,r),this.__highlightType=t}$config(){return this.config("code-highlight",{extends:sn})}afterCloneFrom(e){super.afterCloneFrom(e),this.__highlightType=e.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(e){const t=super.createDOM(e),r=ca(e.theme,this.__highlightType);return Te(t,r),t}updateDOM(e,t,r){const o=super.updateDOM(e,t,r),s=ca(r.theme,e.__highlightType),i=ca(r.theme,this.__highlightType);return s!==i&&(s&&Rt(t,s),i&&Te(t,i)),o}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return Ze()}}function ca(n,e){return e&&n&&n.codeHighlight&&n.codeHighlight[e]}function pc(n="",e){return Nt(new Is(n,e))}function Ve(n){return n instanceof Is}const Vp="data-language";function Yp(n){return n.style.fontFamily.match("monospace")!==null}function al(n){let e=n.parentElement;for(;e!==null;){if(Yp(e))return!0;e=e.parentElement}return!1}const Xw=Ug([Ye({$import:(n,e)=>n.$importChildren(e),match:Ge.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),Zw=Ye({$import:(n,e)=>[Ze(e.getAttribute(Vp)).splice(0,0,n.$importChildren(e))],match:Ge.tag("pre"),name:"@lexical/code/pre"}),Qw=Ye({$import:(n,e,t)=>{const r=e.textContent||"";return/\r?\n/.test(r)||e.querySelector("br")!==null?[Ze(e.getAttribute(Vp)).splice(0,0,n.$importChildren(e))]:t()},match:Ge.tag("code"),name:"@lexical/code/code-multiline"});function Qr(n){if(!ke(n))return!1;const e=n.style.fontFamily,t=n.style.whiteSpace;return typeof e=="string"&&/monospace/i.test(e)&&typeof t=="string"&&t.startsWith("pre")}function Gp(n){let e=!1;const t=[];let r="",o=!1;const s=()=>{o&&(t.push(r),r="",o=!1)};for(const i of Array.from(n.childNodes))if(ke(i))i.tagName==="DIV"?(s(),t.push(i.textContent||""),e=!0):i.tagName==="BR"?(s(),t.push(""),e=!0):(r+=i.textContent||"",o=!0);else if(eb(i)){const a=i.textContent||"";a.length>0&&(r+=a,o=!0)}return s(),e?t:null}function Xp(n){for(const e of Array.from(n.children)){if(ke(e)&&Qr(e)){if(Gp(e)!==null)return!0;const t=e.nextElementSibling;if(t&&Qr(t))return!0;continue}if(Xp(e))return!0}return!1}const ex=Ug([Ye({$import:(n,e,t)=>{if(!Qr(e)||al(e))return t();const r=Gp(e);return r===null||r.length===0?t():[Ze().splice(0,0,Ru(r.join(`
3
+ $$`})]})}const Bw=({accept:n,label:e,onChange:t,"data-test-id":r})=>w.jsxs(At,{children:[w.jsx(At.Label,{children:e}),w.jsx(yn,{type:"file",accept:n,onChange:o=>t(o.target.files),"data-test-id":r,block:!0})]});function aa(n,e,t){return Math.min(Math.max(n,e),t)}const Ae={east:1,north:8,south:2,west:4},Uw=({onResizeStart:n,onResizeEnd:e,buttonRef:t,imageRef:r,maxWidth:o,editor:s,showCaption:i,setShowCaption:a})=>{const l=C.useRef(null),c=C.useRef({priority:"",value:"default"}),u=C.useRef({currentHeight:0,currentWidth:0,direction:0,isResizing:!1,ratio:0,startHeight:0,startWidth:0,startX:0,startY:0}),f=s.getRootElement(),d=o||(f!==null?f.getBoundingClientRect().width-20:100),p=f!==null?f.getBoundingClientRect().height-20:100,h=100,_=100,m=I=>{const E=I===Ae.east||I===Ae.west,T=I===Ae.north||I===Ae.south,N=I&Ae.north&&I&Ae.west||I&Ae.south&&I&Ae.east,O=E?"ew":T?"ns":N?"nwse":"nesw";f!==null&&f.style.setProperty("cursor",`${O}-resize`,"important"),document.body!==null&&(document.body.style.setProperty("cursor",`${O}-resize`,"important"),c.current.value=document.body.style.getPropertyValue("-webkit-user-select"),c.current.priority=document.body.style.getPropertyPriority("-webkit-user-select"),document.body.style.setProperty("-webkit-user-select","none","important"))},y=()=>{f!==null&&f.style.setProperty("cursor","default"),document.body!==null&&(document.body.style.setProperty("cursor","default"),document.body.style.setProperty("-webkit-user-select",c.current.value,c.current.priority))},x=(I,E)=>{const T=r.current,N=l.current;if(T!==null&&N!==null){const{width:O,height:M}=T.getBoundingClientRect(),A=u.current;A.startWidth=O,A.startHeight=M,A.ratio=O/M,A.currentWidth=O,A.currentHeight=M,A.startX=I.clientX,A.startY=I.clientY,A.isResizing=!0,A.direction=E,m(E),n(),N.classList.add("image-control-wrapper--resizing"),T.style.height=`${M}px`,T.style.width=`${O}px`,document.addEventListener("pointermove",S),document.addEventListener("pointerup",v)}},S=I=>{const E=r.current,T=u.current,N=T.direction&(Ae.east|Ae.west),O=T.direction&(Ae.south|Ae.north);if(E!==null&&T.isResizing)if(N&&O){let M=Math.floor(T.startX-I.clientX);M=T.direction&Ae.east?-M:M;const A=aa(T.startWidth+M,h,d),$=A/T.ratio;E.style.width=`${A}px`,E.style.height=`${$}px`,T.currentHeight=$,T.currentWidth=A}else if(O){let M=Math.floor(T.startY-I.clientY);M=T.direction&Ae.south?-M:M;const A=aa(T.startHeight+M,_,p);E.style.height=`${A}px`,T.currentHeight=A}else{let M=Math.floor(T.startX-I.clientX);M=T.direction&Ae.east?-M:M;const A=aa(T.startWidth+M,h,d);E.style.width=`${A}px`,T.currentWidth=A}},v=()=>{const I=r.current,E=u.current,T=l.current;if(I!==null&&T!==null&&E.isResizing){const N=E.currentWidth,O=E.currentHeight;E.startWidth=0,E.startHeight=0,E.ratio=0,E.startX=0,E.startY=0,E.currentWidth=0,E.currentHeight=0,E.isResizing=!1,T.classList.remove("image-control-wrapper--resizing"),y(),e(N,O),document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",v)}};return w.jsxs("div",{ref:l,children:[!i&&w.jsx(ft,{ref:t,size:"small",sx:{position:"absolute",bottom:12,left:"50%",transform:"translateX(-50%)",zIndex:10},onClick:()=>{a(!i)},children:"Add Caption"}),w.jsx("div",{className:"image-resizer image-resizer-n",onPointerDown:I=>{x(I,Ae.north)}}),w.jsx("div",{className:"image-resizer image-resizer-ne",onPointerDown:I=>{x(I,Ae.north|Ae.east)}}),w.jsx("div",{className:"image-resizer image-resizer-e",onPointerDown:I=>{x(I,Ae.east)}}),w.jsx("div",{className:"image-resizer image-resizer-se",onPointerDown:I=>{x(I,Ae.south|Ae.east)}}),w.jsx("div",{className:"image-resizer image-resizer-s",onPointerDown:I=>{x(I,Ae.south)}}),w.jsx("div",{className:"image-resizer image-resizer-sw",onPointerDown:I=>{x(I,Ae.south|Ae.west)}}),w.jsx("div",{className:"image-resizer image-resizer-w",onPointerDown:I=>{x(I,Ae.west)}}),w.jsx("div",{className:"image-resizer image-resizer-nw",onPointerDown:I=>{x(I,Ae.north|Ae.west)}})]})};let Fs;function zp(){return Fs||(Fs=Promise.all([me(()=>import("../datalayer-app-main.js").then(n=>n.vi),[],import.meta.url),me(()=>Promise.resolve({}),[],import.meta.url)]).then(([n])=>n.default,n=>{throw Fs=void 0,n})),Fs}function Kp({equation:n,inline:e,onClick:t}){const r=C.useRef(null);return C.useEffect(()=>{let o=!1;return zp().then(s=>{const i=r.current;o||i===null||s.render(n,i,{displayMode:!e,errorColor:"var(--fgColor-danger, #cc0000)",output:"html",strict:"warn",throwOnError:!1,trust:!1})}).catch(s=>{console.debug("KaTeX could not be loaded",s)}),()=>{o=!0}},[n,e]),w.jsxs(w.Fragment,{children:[w.jsx("span",{children:" "}),w.jsx("span",{role:"button",tabIndex:-1,onClick:t,ref:r}),w.jsx("span",{children:" "})]})}const zw=({onConfirm:n,initialEquation:e=""})=>{const[t,r]=C.useState(e),[o,s]=C.useState(!0),i=C.useCallback(()=>{n(t,o)},[n,t,o]),a=C.useCallback(()=>{s(!o)},[s,o]);return w.jsxs(w.Fragment,{children:[w.jsx(Y,{sx:{mb:2},children:w.jsxs(At,{children:[w.jsx(jg,{checked:o,onChange:a}),w.jsx(At.Label,{children:"Inline"})]})}),w.jsx(Le,{sx:{fontSize:1,fontWeight:"bold",mb:1},children:"Equation"}),w.jsx(Y,{sx:{mb:2},children:o?w.jsx(yn,{onChange:l=>{r(l.target.value)},value:t,block:!0}):w.jsx(Gm,{onChange:l=>{r(l.target.value)},value:t,block:!0,rows:6})}),w.jsx(Le,{sx:{fontSize:1,fontWeight:"bold",mb:1},children:"Visualization"}),w.jsx(Y,{sx:{mb:2,p:2,border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,textAlign:"center"},children:w.jsx(Kp,{equation:t,inline:!1,onClick:()=>null})}),w.jsx(Y,{sx:{display:"flex",justifyContent:"flex-end"},children:w.jsx(cr,{onClick:i,children:"Confirm"})})]})},Kw=({onClose:n,children:e,title:t,closeOnClickOutside:r=!1})=>w.jsx(Fg,{title:t,onClose:()=>n(),width:"medium",height:"auto",children:e}),Wp=({children:n,className:e})=>w.jsx("div",{className:e||"Placeholder__root",children:n});function Bi(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of e)r.append("v",o);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Jp(n,e){let t=n;for(let r=gt(n,e);r&&(Ve(r.origin)||bt(r.origin));r=r.getAdjacentCaret())t=r.origin;return t}function ur(n){return Jp(n,"previous")}function io(n){return Jp(n,"next")}function Ww(n){const e=ur(n),t=io(n);let r=e;for(;r!==null;){if(Ve(r)){const s=rb(r.getTextContent());if(s!==null)return s}if(r===t)break;r=r.getNextSibling()}const o=e.getParent();if(H(o)){const s=o.getDirection();if(s==="ltr"||s==="rtl")return s}return null}function Jw(n,e){let t=null,r=null,o=n,s=e,i=n.getTextContent();for(;;){if(s===0){const c=o.getPreviousSibling();if(c===null){o=null;break}if(Ve(c)||bt(c)||ue(c)||Bi(167),o=c,ue(o)){t={node:o,offset:1};break}s=Math.max(0,o.getTextContentSize()-1),i=o.getTextContent()}else s--;const l=i[s];Ve(o)&&l!==" "&&(r={node:o,offset:s})}if(r!==null)return r;let a=null;if(e<n.getTextContentSize())Ve(n)&&(a=n.getTextContent()[e]);else{const l=n.getNextSibling();Ve(l)&&(a=l.getTextContent()[0])}if(a!==null&&a!==" ")return t;{const l=(function(c,u){let f=c,d=u,p=c.getTextContent(),h=c.getTextContentSize();for(;;){if(!Ve(f)||d===h){if(f=f.getNextSibling(),f===null||ue(f))return null;Ve(f)&&(d=0,p=f.getTextContent(),h=f.getTextContentSize())}if(Ve(f)){if(p[d]!==" ")return{node:f,offset:d};d++}}})(n,e);return l!==null?l:t}}function Hw(n){const e=io(n);return ue(e)&&Bi(168),e}function qw(n){const e=[];return zg(n,{linebreak:()=>e.push(xt()),tab:()=>e.push($n()),text:t=>e.push(pc(t))}),e}const Vw="javascript";function Hp(n,e){for(const t of n.childNodes)if(ke(t)&&t.tagName===e||Hp(t,e))return!0;return!1}const Wo="data-language",Fo="data-highlight-language",Bs="data-theme";class ln extends Oe{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:Oe,importDOM:{code:e=>e.textContent!=null&&(/\r?\n/.test(e.textContent)||Hp(e,"BR"))?{conversion:sd,priority:1}:null,div:()=>({conversion:Yw,priority:1}),pre:()=>({conversion:sd,priority:0}),table:e=>la(e)?{conversion:Gw,priority:3}:null,td:e=>{const t=e,r=t.closest("table");return t.classList.contains("js-file-line")||r&&la(r)?{conversion:id,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&la(t)?{conversion:id,priority:3}:null}}})}constructor(e=void 0,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(e){const t=He().createElement("code");Te(t,e.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(t.setAttribute(Wo,r),this.getIsSyntaxHighlightSupported()&&t.setAttribute(Fo,r));const o=this.getTheme();o&&t.setAttribute(Bs,o);const s=this.getStyle();return s&&to(t.style,s),t}updateDOM(e,t,r){const o=this.__language,s=e.__language;o?o!==s&&t.setAttribute(Wo,o):s&&t.removeAttribute(Wo);const i=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&s?i&&o?o!==s&&t.setAttribute(Fo,o):t.removeAttribute(Fo):i&&o&&t.setAttribute(Fo,o);const a=this.__theme,l=e.__theme;a?a!==l&&t.setAttribute(Bs,a):l&&t.removeAttribute(Bs);const c=this.__style,u=e.__style;return c!==u&&to(t.style,c,u),!1}exportDOM(e){const t=He().createElement("pre");Te(t,e._config.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(t.setAttribute(Wo,r),this.getIsSyntaxHighlightSupported()&&t.setAttribute(Fo,r));const o=this.getTheme();o&&t.setAttribute(Bs,o);const s=this.getStyle();return s&&to(t.style,s),{element:t}}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(e,t=!0){if(!Hl(To(),"@lexical/code")){const i=qp(e);if(i)return i}const{anchor:r,focus:o}=e,s=(r.isBefore(o)?r:o).getNode();if(oe(s)){let i=ur(s);const a=[];for(;;)if(bt(i))a.push($n()),i=i.getNextSibling();else{if(!Ve(i))break;{let h=0;const _=i.getTextContent(),m=i.getTextContentSize();for(;h<m&&_[h]===" ";)h++;if(h!==0&&a.push(pc(" ".repeat(h))),h!==m)break;i=i.getNextSibling()}}const l=s.splitText(r.offset)[0],c=r.offset===0?0:1,u=l.getIndexWithinParent()+c,f=s.getParentOrThrow(),d=[xt(),...a];f.splice(u,0,d);const p=a[a.length-1];p?p.select():r.offset===0?l.selectPrevious():l.getNextSibling().selectNext(0,0)}if(je(s)){const{offset:i}=e.anchor;s.splice(i,0,[xt()]),s.select(i+1,i+1)}return null}canIndent(){return!1}collapseAtStart(){const e=ne();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}setLanguage(e){const t=this.getWritable();return t.__language=e||void 0,t}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(e){const t=this.getWritable();return t.__isSyntaxHighlightSupported=e,t}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(e){const t=this.getWritable();return t.__theme=e||void 0,t}getTheme(){return this.getLatest().__theme}}function Ze(n,e){return Xm(ln).setLanguage(n).setTheme(e)}function je(n){return n instanceof ln}function sd(n){return{node:Ze(n.getAttribute(Wo))}}function Yw(n){const e=n,t=ad(e);return t||(function(r){let o=r.parentElement;for(;o!==null;){if(ad(o))return!0;o=o.parentElement}return!1})(e)?{node:t?Ze():null}:{node:null}}function Gw(){return{node:Ze()}}function id(){return{node:null}}function ad(n){return n.style.fontFamily.match("monospace")!==null}function la(n){return n.classList.contains("js-file-line-container")}function qp(n){const{anchor:e}=n;if(n.isCollapsed()&&e.type==="element"){const t=e.getNode();if(je(t)){const r=t.getChildrenSize();if(r>=2&&e.offset===r){const o=t.getLastChild();if(ue(o)&&ue(o.getPreviousSibling())){const s=ne();return t.splice(r-2,2,[]).insertAfter(s,!1),s.select(),s}}}}return null}class Is extends sn{__highlightType;constructor(e="",t,r){super(e,r),this.__highlightType=t}$config(){return this.config("code-highlight",{extends:sn})}afterCloneFrom(e){super.afterCloneFrom(e),this.__highlightType=e.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(e){const t=super.createDOM(e),r=ca(e.theme,this.__highlightType);return Te(t,r),t}updateDOM(e,t,r){const o=super.updateDOM(e,t,r),s=ca(r.theme,e.__highlightType),i=ca(r.theme,this.__highlightType);return s!==i&&(s&&Rt(t,s),i&&Te(t,i)),o}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return Ze()}}function ca(n,e){return e&&n&&n.codeHighlight&&n.codeHighlight[e]}function pc(n="",e){return Nt(new Is(n,e))}function Ve(n){return n instanceof Is}const Vp="data-language";function Yp(n){return n.style.fontFamily.match("monospace")!==null}function al(n){let e=n.parentElement;for(;e!==null;){if(Yp(e))return!0;e=e.parentElement}return!1}const Xw=Ug([Ye({$import:(n,e)=>n.$importChildren(e),match:Ge.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),Zw=Ye({$import:(n,e)=>[Ze(e.getAttribute(Vp)).splice(0,0,n.$importChildren(e))],match:Ge.tag("pre"),name:"@lexical/code/pre"}),Qw=Ye({$import:(n,e,t)=>{const r=e.textContent||"";return/\r?\n/.test(r)||e.querySelector("br")!==null?[Ze(e.getAttribute(Vp)).splice(0,0,n.$importChildren(e))]:t()},match:Ge.tag("code"),name:"@lexical/code/code-multiline"});function Qr(n){if(!ke(n))return!1;const e=n.style.fontFamily,t=n.style.whiteSpace;return typeof e=="string"&&/monospace/i.test(e)&&typeof t=="string"&&t.startsWith("pre")}function Gp(n){let e=!1;const t=[];let r="",o=!1;const s=()=>{o&&(t.push(r),r="",o=!1)};for(const i of Array.from(n.childNodes))if(ke(i))i.tagName==="DIV"?(s(),t.push(i.textContent||""),e=!0):i.tagName==="BR"?(s(),t.push(""),e=!0):(r+=i.textContent||"",o=!0);else if(eb(i)){const a=i.textContent||"";a.length>0&&(r+=a,o=!0)}return s(),e?t:null}function Xp(n){for(const e of Array.from(n.children)){if(ke(e)&&Qr(e)){if(Gp(e)!==null)return!0;const t=e.nextElementSibling;if(t&&Qr(t))return!0;continue}if(Xp(e))return!0}return!1}const ex=Ug([Ye({$import:(n,e,t)=>{if(!Qr(e)||al(e))return t();const r=Gp(e);return r===null||r.length===0?t():[Ze().splice(0,0,Ru(r.join(`
4
4
  `)))]},match:Ge.tag("div"),name:"@lexical/code/vscode-wrapper"}),Ye({$import:(n,e,t)=>{if(!Qr(e)||al(e))return t();const r=e.previousElementSibling;if(r&&Qr(r))return[];const o=[];let s=e;for(;s&&Qr(s);)o.push(s.tagName==="BR"?"":s.textContent||""),s=s.nextElementSibling;return o.length<2?t():[Ze().splice(0,0,Ru(o.join(`
5
5
  `)))]},match:Ge.tag("div","br"),name:"@lexical/code/vscode-line-run"})]),tx=Ye({$import:(n,e,t)=>Yp(e)?[Ze().splice(0,0,n.$importChildren(e))]:al(e)?n.$importChildren(e):t(),match:Ge.tag("div"),name:"@lexical/code/div"}),nx=[Ye({$import:(n,e)=>[Ze().splice(0,0,n.$importChildren(e,{rules:Xw}))],match:Ge.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"}),Ye({$import:(n,e)=>n.$importChildren(e),match:Ge.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"}),Qw,Zw,tx],Zp=pe({dependencies:[ys,on(ws,{preprocess:[(n,e,t)=>{Xp(Bg(n)?n.body:n)&&e.session.update(Qm,r=>[...r,ex]),t()}],rules:nx})],name:"@lexical/code",nodes:()=>[ln,Is],register:n=>de(n.registerCommand(Er,e=>{const t=P();return!(!j(t)||!qp(t))&&(e!==null&&e.preventDefault(),!0)},ee),n.registerNodeTransform(Zm,e=>{e.getFormat()!==0&&je(e.getParent())&&e.setFormat(0)}))});function or(n){if(!j(n))return!1;const e=n.anchor.getNode(),t=je(e)?e:e.getParent(),r=n.focus.getNode(),o=je(r)?r:r.getParent();return je(t)&&t.is(o)}function Qp(n){const e=n.getNodes(),t=[];if(e.length===1&&je(e[0]))return t;let r=[];for(let o=0;o<e.length;o++){const s=e[o];Ve(s)||bt(s)||ue(s)||Bi(169),ue(s)?r.length>0&&(t.push(r),r=[]):r.push(s)}if(r.length>0){const o=n.isBackward()?n.anchor:n.focus,s=an(r[0].getKey(),0,"text");o.is(s)||t.push(r)}return t}function ld(n,e){const t=P();if(!j(t)||!or(t))return!1;const r=Qp(t),o=r.length;if(o===0&&t.isCollapsed())return n===Mt&&t.insertNodes([$n()]),!0;if(o===0&&n===Mt&&t.getTextContent()===`
6
6
  `){const s=$n(),i=xt(),a=t.isBackward()?"previous":"next";return t.insertNodes([s,i]),fi(tb(Zs(nb(s,"next",0),jn(gt(i,"next"))),a)),!0}for(let s=0;s<o;s++){const i=r[s];if(i.length>0){let a=i[0];if(s===0&&(a=ur(a)),n===Mt){const l=$n();if(a.insertBefore(l),s===0){const c=t.isBackward()?"focus":"anchor",u=an(a.getKey(),0,"text");t[c].is(u)&&t[c].set(l.getKey(),0,"text")}}else bt(a)&&a.remove()}}return!0}function cd(n,e){const t=P();if(!j(t))return!1;const{anchor:r,focus:o}=t,s=r.offset,i=o.offset,a=r.getNode(),l=o.getNode(),c=n===pt;if(!or(t)||!Ve(a)&&!bt(a)||!Ve(l)&&!bt(l))return!1;if(!e.altKey){if(t.isCollapsed()){const y=a.getParentOrThrow();if(c&&s===0&&a.getPreviousSibling()===null){if(y.getPreviousSibling()===null)return y.selectPrevious(),e.preventDefault(),!1}else if(!c&&s===a.getTextContentSize()&&a.getNextSibling()===null&&y.getNextSibling()===null)return y.selectNext(),e.preventDefault(),!1}return!1}let u,f;if(a.isBefore(l)?(u=ur(a),f=io(l)):(u=ur(l),f=io(a)),u==null||f==null)return!1;const d=u.getNodesBetween(f);for(let y=0;y<d.length;y++){const x=d[y];if(!Ve(x)&&!bt(x)&&!ue(x))return!1}e.preventDefault(),e.stopPropagation();const p=c?u.getPreviousSibling():f.getNextSibling();if(!ue(p))return!0;const h=c?p.getPreviousSibling():p.getNextSibling();if(h==null)return!0;const _=Ve(h)||bt(h)||ue(h)?c?ur(h):io(h):null;let m=_??h;return p.remove(),d.forEach(y=>y.remove()),n===pt?(d.forEach(y=>m.insertBefore(y)),m.insertBefore(p)):(m.insertAfter(p),m=p,d.forEach(y=>{m.insertAfter(y),m=y})),t.setTextNodeRange(a,s,l,i),!0}function ud(n,e){const t=P();if(!j(t))return!1;const{anchor:r,focus:o}=t,s=r.getNode(),i=o.getNode(),a=n===hr;if(!or(t)||!Ve(s)&&!bt(s)||!Ve(i)&&!bt(i))return!1;const l=i,c=Ww(l)==="rtl"?!a:a,u=r.key,f=r.offset,d=r.type;if(c){const p=Jw(l,o.offset);if(p!==null){const{node:h,offset:_}=p;ue(h)?h.selectNext(0,0):t.setTextNodeRange(h,_,h,_)}else l.getParentOrThrow().selectStart()}else Hw(l).select();return e.shiftKey&&t.anchor.set(u,f,d),e.preventDefault(),e.stopPropagation(),!0}function rx(n,e,t){return de(n.registerCommand(Nr,r=>{const o=(function(s){const i=P();if(!j(i)||!or(i))return null;const a=s?mn:Mt,l=s?mn:Va,c=i.anchor,u=i.focus;if(c.is(u))return l;const f=Qp(i);if(f.length!==1)return a;const d=f[0];let p,h;d.length===0&&Bi(285),i.isBackward()?(p=u,h=c):(p=c,h=u);const _=ur(d[0]),m=io(d[0]),y=an(_.getKey(),0,"text"),x=an(m.getKey(),m.getTextContentSize(),"text");return p.isBefore(y)||x.isBefore(h)?a:y.isBefore(p)||h.isBefore(x)?l:a})(r.shiftKey);return o!==null&&(r.preventDefault(),n.dispatchCommand(o),!0)},ee),n.registerCommand(Va,()=>!!or(P())&&(pr([$n()]),!0),ee),n.registerCommand(Mt,()=>ld(Mt),ee),n.registerCommand(mn,()=>ld(mn,e),ee),n.registerCommand(pt,r=>{const o=P();if(!j(o))return!1;const{anchor:s}=o,i=s.getNode();if(!or(o))return!1;const a=i.getParent();return o.isCollapsed()&&s.offset===0&&i.getPreviousSibling()===null&&je(a)&&a.getPreviousSibling()===null?(r.preventDefault(),!0):cd(pt,r)},ee),n.registerCommand(Ht,r=>{const o=P();if(!j(o))return!1;const{anchor:s}=o,i=s.getNode();return!!or(o)&&(o.isCollapsed()&&s.offset===i.getTextContentSize()&&i.getNextSibling()===null&&je(i.getParentOrThrow())&&i.getParentOrThrow().getNextSibling()===null?(r.preventDefault(),!0):cd(Ht,r))},ee),n.registerCommand(hr,r=>ud(hr,r),ee),n.registerCommand(os,r=>ud(os,r),ee))}(function(n){n.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var e={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(e).forEach(function(t){var r=e[t],o=[];/^\w+$/.test(t)||o.push(/\w+/.exec(t)[0]),t==="diff"&&o.push("bold"),n.languages.diff[t]={pattern:RegExp("^(?:["+r+`].*(?:\r
@@ -81,14 +81,14 @@ summary.Collapsible__title::marker {
81
81
  display: none;
82
82
  user-select: none;
83
83
  }
84
- `;let Ca=!1;function Hc(){if(Ca||typeof document>"u")return;if(document.getElementById(lf)){Ca=!0;return}const n=document.createElement("style");n.id=lf,n.textContent=XC,document.head.appendChild(n),Ca=!0}const ZC={background:"var(--bgColor-muted, #f8f8f8)",border:"1px solid var(--borderColor-default, #e0e0e0)",borderRadius:"6px",margin:"12px 0",padding:"0",overflow:"hidden"},QC={cursor:"pointer",padding:"12px 12px 12px 36px",position:"relative",fontWeight:"600",fontSize:"14px",listStyle:"none",display:"block",outline:"none",color:"var(--fgColor-default, #333)",userSelect:"none",transition:"background-color 0.15s ease",margin:"0",WebkitAppearance:"none"},eS={padding:"12px 16px 16px 36px"};function qc(n,e){for(const[t,r]of Object.entries(e))r!=null&&(n.style[t]=r)}function tS(n){const e=n.open!==void 0?n.open:!0;return{node:Vc(e)}}class Cr extends Oe{__open;constructor(e,t){super(t),this.__open=e}static getType(){return"collapsible-container"}static clone(e){return new Cr(e.__open,e.__key)}isShadowRoot(){return!0}collapseAtStart(e){const t=[];for(const s of this.getChildren())H(s)&&t.push(...s.getChildren());nc(gt(this,"previous")).splice(1,t);const[o]=t;return o&&o.selectStart().deleteCharacter(!0),!0}createDOM(e,t){Hc();let r;if(hi)r=document.createElement("div"),r.setAttribute("open","");else{const o=document.createElement("details");o.open=this.__open,o.addEventListener("toggle",()=>{t.getEditorState().read(()=>this.getOpen())!==o.open&&t.update(()=>this.toggleOpen())}),r=o}return r.classList.add("Collapsible__container"),qc(r,ZC),r}updateDOM(e,t){const r=this.__open;if(e.__open!==r)if(hi){const o=t.children[1];if(!ke(o))throw new Error("Expected contentDom to be an HTMLElement");r?(t.setAttribute("open",""),o.hidden=!1):(t.removeAttribute("open"),t_(o))}else t.open=this.__open;return!1}static importDOM(){return{details:e=>({conversion:tS,priority:1})}}static importJSON(e){return Vc(e.open).updateFromJSON(e)}exportDOM(){const e=document.createElement("details");return e.classList.add("Collapsible__container"),e.setAttribute("open",this.__open.toString()),{element:e}}exportJSON(){return{...super.exportJSON(),open:this.__open}}setOpen(e){const t=this.getWritable();t.__open=e}getOpen(){return this.getLatest().__open}toggleOpen(){this.setOpen(!this.getOpen())}}function Vc(n){return new Cr(n)}function $t(n){return n instanceof Cr}function nS(n){return{node:Yc()}}class Sr extends Oe{static getType(){return"collapsible-content"}static clone(e){return new Sr(e.__key)}createDOM(e,t){Hc();const r=document.createElement("div");return r.classList.add("Collapsible__content"),qc(r,eS),hi&&(t.getEditorState().read(()=>{const o=this.getParentOrThrow();if(!$t(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.__open||t_(r)}),GC(r,()=>{t.update(()=>{const o=this.getParentOrThrow().getLatest();if(!$t(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.__open||o.toggleOpen()})})),r}updateDOM(e,t){return!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-collapsible-content")?{conversion:nS,priority:2}:null}}exportDOM(){const e=document.createElement("div");return e.classList.add("Collapsible__content"),e.setAttribute("data-lexical-collapsible-content","true"),{element:e}}static importJSON(e){return Yc().updateFromJSON(e)}isShadowRoot(){return!0}}function Yc(){return new Sr}function Gc(n){return n instanceof Sr}function rS(n){return{node:n_()}}class ps extends Oe{$config(){return this.config("collapsible-title",{$transform(e){e.isEmpty()&&e.remove()},extends:Oe,importDOM:tc({summary:()=>({conversion:rS,priority:1})})})}createDOM(e,t){Hc();const r=document.createElement("summary");return r.classList.add("Collapsible__title"),qc(r,QC),hi&&r.addEventListener("click",()=>{t.update(()=>{const o=this.getLatest().getParentOrThrow();if(!$t(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.toggleOpen()})}),r}updateDOM(e,t){return!1}insertNewAfter(e,t=!0){const r=this.getParentOrThrow();if(!$t(r))throw new Error("CollapsibleTitleNode expects to be child of CollapsibleContainerNode");if(r.getOpen()){const o=this.getNextSibling();if(!Gc(o))throw new Error("CollapsibleTitleNode expects to have CollapsibleContentNode sibling");const s=o.getFirstChild();if(H(s))return s;{const i=ne();return o.append(i),i}}else{const o=ne();return r.insertAfter(o,t),o}}}function n_(){return new ps}function ni(n){return n instanceof ps}function oS(n){const t=window.getComputedStyle(n).getPropertyValue("grid-template-columns");return t?{node:Xc(t)}:null}class vr extends Oe{__templateColumns;constructor(e,t){super(t),this.__templateColumns=e}static getType(){return"layout-container"}static clone(e){return new vr(e.__templateColumns,e.__key)}createDOM(e){const t=document.createElement("div");return t.style.gridTemplateColumns=this.__templateColumns,typeof e.theme.layoutContainer=="string"&&Te(t,e.theme.layoutContainer),t}exportDOM(){const e=document.createElement("div");return e.style.gridTemplateColumns=this.__templateColumns,e.setAttribute("data-lexical-layout-container","true"),{element:e}}updateDOM(e,t){return e.__templateColumns!==this.__templateColumns&&(t.style.gridTemplateColumns=this.__templateColumns),!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-layout-container")?{conversion:oS,priority:2}:null}}static importJSON(e){return Xc().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setTemplateColumns(e.templateColumns)}isShadowRoot(){return!0}canBeEmpty(){return!1}exportJSON(){return{...super.exportJSON(),templateColumns:this.__templateColumns}}getTemplateColumns(){return this.getLatest().__templateColumns}setTemplateColumns(e){const t=this.getWritable();return t.__templateColumns=e,t}}function Xc(n=""){return new vr(n)}function ri(n){return n instanceof vr}function sS(){return{node:Zc()}}function iS(n){if(!Qc(n)||n.getChildrenSize()!==1)return!1;const e=n.getFirstChild();return ht(e)&&e.isEmpty()}class kr extends Oe{constructor(e){super(e)}static getType(){return"layout-item"}static clone(e){return new kr(e.__key)}createDOM(e){const t=document.createElement("div");return t.setAttribute("data-lexical-layout-item","true"),typeof e.theme.layoutItem=="string"&&Te(t,e.theme.layoutItem),t}updateDOM(){return!1}collapseAtStart(){const e=this.getParentOrThrow();return this.is(e.getFirstChild())&&e.getChildren().every(iS)?(e.remove(),!0):!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-layout-item")?{conversion:sS,priority:2}:null}}static importJSON(e){return Zc().updateFromJSON(e)}isShadowRoot(){return!0}}function Zc(){return new kr}function Qc(n){return n instanceof kr}const r_="@datalayer/jupyter-lexical/Loom",Jo=new WeakMap;function PA(n,e){return e?Jo.set(n,e):Jo.delete(n),()=>{Jo.get(n)===e&&Jo.delete(n)}}function aS(n){return Jo.get(n)}const lS=/^https?:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/(?:[^/?#]*-)?([0-9a-f]{32})(?:[/?#].*)?$/i;function wn(n){const e=lS.exec(n.trim());return e?e[1].toLowerCase():null}function eu(n){return`https://www.loom.com/share/${n}`}function o_(n){return`https://www.loom.com/embed/${n}`}async function s_(n){const e=wn(n);if(!e)throw new Error(`Not a Loom video address: ${n}`);const t=eu(e);try{const{oembed:r}=await me(async()=>{const{oembed:a}=await import("./esm-BSpvs9Ep.js");return{oembed:a}},[],import.meta.url),{title:o,width:s,height:i}=await r(t);return{url:t,title:o||void 0,width:Number(s)||void 0,height:Number(i)||void 0}}catch{return{url:t}}}const Sa=new Map;function cS(n){const e=n instanceof Error?n.message:String(n),t=e.toLowerCase(),r=t.indexOf("is not a function");return t.includes("render is not a function")||r>=0&&t.includes("render",r)?"The Loom recorder needs React 18 and this page runs React 19. See the Loom notes in the jupyter-lexical README to give it one.":`Loom could not start recording: ${e}`}function uS(n){let e=Sa.get(n);return e||(e=(async()=>{const{isSupported:t}=await me(async()=>{const{isSupported:f}=await import("./is-supported-CKr056Mu.js");return{isSupported:f}},[],import.meta.url),{supported:r,error:o}=await t();if(!r)throw new Error(`this browser cannot record with Loom (${o})`);const{setup:s}=await me(async()=>{const{setup:f}=await import("./esm-jxjWs5qw.js");return{setup:f}},[],import.meta.url),{configureButton:i}=await s({publicAppId:n}),a=i();let l;const c=new Map,u=f=>{let d=c.get(f.id);!d&&l&&(d=l,c.set(f.id,d)),d?.(f)};return a.on("recording-complete",u),a.on("upload-complete",u),a.on("insert-click",u),{record:f=>{l=f,a.openPreRecordPanel()}}})(),e.catch(()=>Sa.delete(n)),Sa.set(n,e)),e}function dS({video:n}){const e=wn(n.url);return e?w.jsx("div",{"data-lexical-loom-player":e,style:{position:"relative",width:"100%",aspectRatio:`${n.width||16} / ${n.height||9}`,borderRadius:6,overflow:"hidden",background:"var(--bgColor-muted, #f6f8fa)"},children:w.jsx("iframe",{src:o_(e),title:n.title||"Loom video",allow:"fullscreen; picture-in-picture",style:{position:"absolute",inset:0,width:"100%",height:"100%",border:0}})}):null}function fS({nodeKey:n}){const[e]=fe(),t=Or(),[r,o]=C.useState(""),[s,i]=C.useState(),[a,l]=C.useState(),c=Hl(e,r_)?.config.publicAppId??aS(e),u=C.useCallback(p=>{e.update(()=>{const h=Q(n);nu(h)&&h.setVideo(p)})},[e,n]),f=C.useCallback(async()=>{if(c){l(void 0),i("recording");try{(await uS(c)).record(h=>u({url:h.sharedUrl,title:h.title,width:h.width,height:h.height}))}catch(p){l(cS(p))}finally{i(void 0)}}},[c,u]),d=C.useCallback(async()=>{if(!wn(r)){l("That is not the address of a Loom video: it looks like https://www.loom.com/share/…");return}l(void 0),i("embedding");try{u(await s_(r))}finally{i(void 0)}},[r,u]);return t?w.jsxs(Y,{"data-lexical-loom-placeholder":"",sx:{display:"grid",gap:2,p:3,border:"1px dashed",borderColor:"border.default",borderRadius:2,bg:"canvas.subtle"},children:[w.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[w.jsx(ks,{size:16}),w.jsx(Le,{sx:{fontWeight:"bold"},children:"Loom Video"})]}),w.jsx(Le,{sx:{color:"fg.muted",fontSize:0},children:"Recorded with Loom: Loom asks you to sign in to your Loom account, and the video is saved there, so it stays in the document."}),w.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[w.jsx(ft,{variant:"primary",onClick:()=>{f()},disabled:!c||s!==void 0,children:s==="recording"?"Starting…":"Record"}),w.jsx(Le,{sx:{color:"fg.muted",fontSize:1},children:"or"}),w.jsx(yn,{"aria-label":"Address of a Loom video",placeholder:"https://www.loom.com/share/…",value:r,onChange:p=>o(p.target.value),onFocus:()=>e.update(()=>Ee(null)),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),d())},sx:{flex:"1 1 240px"}}),w.jsx(ft,{onClick:()=>{d()},disabled:!r.trim()||s!==void 0,children:s==="embedding"?"Embedding…":"Embed"})]}),!c&&w.jsxs(Y,{"data-lexical-loom-no-app-id":"",sx:{display:"flex",gap:2,alignItems:"flex-start",color:"attention.fg",fontSize:1},children:[w.jsx(Kg,{size:16}),w.jsxs(Le,{children:["Recording with Loom is off in this editor: it was given no Loom public app id, and without one Loom cannot open to let you sign in. Its host passes the id to ",w.jsx("code",{children:"LoomExtension"}),". A Loom video can still be embedded by its address."]})]}),a&&w.jsx(Le,{role:"alert",sx:{color:"danger.fg",fontSize:1},children:a})]}):w.jsx(Le,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:"A Loom video goes here."})}function gS({className:n,format:e,nodeKey:t,video:r}){return w.jsx(gs,{className:n,format:e,nodeKey:t,children:wn(r.url)?w.jsx(dS,{video:r}):w.jsx(fS,{nodeKey:t})})}function pS(n){const e=n.getAttribute("data-lexical-loom"),t=wn(e||n.getAttribute("src")||"");return t?{node:tu({url:eu(t),title:n.getAttribute("title")||void 0})}:null}class Ro extends Oo{__url;__title;__width;__height;static getType(){return"loom"}static clone(e){return new Ro({url:e.__url,title:e.__title,width:e.__width,height:e.__height},e.__format,e.__key)}static importJSON(e){const t=tu({url:e.url,title:e.title,width:e.width,height:e.height});return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"loom",version:1,url:this.__url,...this.__title?{title:this.__title}:{},...this.__width?{width:this.__width}:{},...this.__height?{height:this.__height}:{}}}static importDOM(){return{iframe:e=>e.hasAttribute("data-lexical-loom")||wn(e.getAttribute("src")||"")?{conversion:pS,priority:1}:null}}exportDOM(){const e=wn(this.__url);if(!e)return{element:null};const t=document.createElement("iframe");return t.setAttribute("data-lexical-loom",this.__url),t.setAttribute("src",o_(e)),t.setAttribute("title",this.__title||"Loom video"),t.setAttribute("width",String(this.__width||640)),t.setAttribute("height",String(this.__height||360)),t.setAttribute("frameborder","0"),t.setAttribute("allowfullscreen","true"),{element:t}}constructor(e={url:""},t,r){super(t,r),this.__url=e.url,this.__title=e.title,this.__width=e.width,this.__height=e.height}getVideo(){const e=this.getLatest();return{url:e.__url,title:e.__title,width:e.__width,height:e.__height}}setVideo(e){const t=this.getWritable();t.__url=e.url,t.__title=e.title,t.__width=e.width,t.__height=e.height}getTextContent(){return this.__url}updateDOM(){return!1}decorate(e,t){const r=t.theme.embedBlock||{};return w.jsx(gS,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),video:{url:this.__url,title:this.__title,width:this.__width,height:this.__height}})}isTopLevel(){return!0}}function tu(n){return new Ro(n)}function nu(n){return n instanceof Ro}function hS(n,e){const t={};for(const r of n){const o=e(r);t[o]?t[o].push(r):t[o]=[r]}return t}function _S(n){const e=hS(n,t=>t.type);return{element:e.element||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const cf=/[!-/:-@[-`{-~\s]/,mS=/^\s{0,3}$/,uf=/^```(\w{1,10})?\s?$/;function bS(n){const e=_S(n),t=SS(e.textFormat);return r=>{const o=r.split(`
84
+ `;let Ca=!1;function Hc(){if(Ca||typeof document>"u")return;if(document.getElementById(lf)){Ca=!0;return}const n=document.createElement("style");n.id=lf,n.textContent=XC,document.head.appendChild(n),Ca=!0}const ZC={background:"var(--bgColor-muted, #f8f8f8)",border:"1px solid var(--borderColor-default, #e0e0e0)",borderRadius:"6px",margin:"12px 0",padding:"0",overflow:"hidden"},QC={cursor:"pointer",padding:"12px 12px 12px 36px",position:"relative",fontWeight:"600",fontSize:"14px",listStyle:"none",display:"block",outline:"none",color:"var(--fgColor-default, #333)",userSelect:"none",transition:"background-color 0.15s ease",margin:"0",WebkitAppearance:"none"},eS={padding:"12px 16px 16px 36px"};function qc(n,e){for(const[t,r]of Object.entries(e))r!=null&&(n.style[t]=r)}function tS(n){const e=n.open!==void 0?n.open:!0;return{node:Vc(e)}}class Cr extends Oe{__open;constructor(e,t){super(t),this.__open=e}static getType(){return"collapsible-container"}static clone(e){return new Cr(e.__open,e.__key)}isShadowRoot(){return!0}collapseAtStart(e){const t=[];for(const s of this.getChildren())H(s)&&t.push(...s.getChildren());nc(gt(this,"previous")).splice(1,t);const[o]=t;return o&&o.selectStart().deleteCharacter(!0),!0}createDOM(e,t){Hc();let r;if(hi)r=document.createElement("div"),r.setAttribute("open","");else{const o=document.createElement("details");o.open=this.__open,o.addEventListener("toggle",()=>{t.getEditorState().read(()=>this.getOpen())!==o.open&&t.update(()=>this.toggleOpen())}),r=o}return r.classList.add("Collapsible__container"),qc(r,ZC),r}updateDOM(e,t){const r=this.__open;if(e.__open!==r)if(hi){const o=t.children[1];if(!ke(o))throw new Error("Expected contentDom to be an HTMLElement");r?(t.setAttribute("open",""),o.hidden=!1):(t.removeAttribute("open"),t_(o))}else t.open=this.__open;return!1}static importDOM(){return{details:e=>({conversion:tS,priority:1})}}static importJSON(e){return Vc(e.open).updateFromJSON(e)}exportDOM(){const e=document.createElement("details");return e.classList.add("Collapsible__container"),e.setAttribute("open",this.__open.toString()),{element:e}}exportJSON(){return{...super.exportJSON(),open:this.__open}}setOpen(e){const t=this.getWritable();t.__open=e}getOpen(){return this.getLatest().__open}toggleOpen(){this.setOpen(!this.getOpen())}}function Vc(n){return new Cr(n)}function $t(n){return n instanceof Cr}function nS(n){return{node:Yc()}}class Sr extends Oe{static getType(){return"collapsible-content"}static clone(e){return new Sr(e.__key)}createDOM(e,t){Hc();const r=document.createElement("div");return r.classList.add("Collapsible__content"),qc(r,eS),hi&&(t.getEditorState().read(()=>{const o=this.getParentOrThrow();if(!$t(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.__open||t_(r)}),GC(r,()=>{t.update(()=>{const o=this.getParentOrThrow().getLatest();if(!$t(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.__open||o.toggleOpen()})})),r}updateDOM(e,t){return!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-collapsible-content")?{conversion:nS,priority:2}:null}}exportDOM(){const e=document.createElement("div");return e.classList.add("Collapsible__content"),e.setAttribute("data-lexical-collapsible-content","true"),{element:e}}static importJSON(e){return Yc().updateFromJSON(e)}isShadowRoot(){return!0}}function Yc(){return new Sr}function Gc(n){return n instanceof Sr}function rS(n){return{node:n_()}}class ps extends Oe{$config(){return this.config("collapsible-title",{$transform(e){e.isEmpty()&&e.remove()},extends:Oe,importDOM:tc({summary:()=>({conversion:rS,priority:1})})})}createDOM(e,t){Hc();const r=document.createElement("summary");return r.classList.add("Collapsible__title"),qc(r,QC),hi&&r.addEventListener("click",()=>{t.update(()=>{const o=this.getLatest().getParentOrThrow();if(!$t(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.toggleOpen()})}),r}updateDOM(e,t){return!1}insertNewAfter(e,t=!0){const r=this.getParentOrThrow();if(!$t(r))throw new Error("CollapsibleTitleNode expects to be child of CollapsibleContainerNode");if(r.getOpen()){const o=this.getNextSibling();if(!Gc(o))throw new Error("CollapsibleTitleNode expects to have CollapsibleContentNode sibling");const s=o.getFirstChild();if(H(s))return s;{const i=ne();return o.append(i),i}}else{const o=ne();return r.insertAfter(o,t),o}}}function n_(){return new ps}function ni(n){return n instanceof ps}function oS(n){const t=window.getComputedStyle(n).getPropertyValue("grid-template-columns");return t?{node:Xc(t)}:null}class vr extends Oe{__templateColumns;constructor(e,t){super(t),this.__templateColumns=e}static getType(){return"layout-container"}static clone(e){return new vr(e.__templateColumns,e.__key)}createDOM(e){const t=document.createElement("div");return t.style.gridTemplateColumns=this.__templateColumns,typeof e.theme.layoutContainer=="string"&&Te(t,e.theme.layoutContainer),t}exportDOM(){const e=document.createElement("div");return e.style.gridTemplateColumns=this.__templateColumns,e.setAttribute("data-lexical-layout-container","true"),{element:e}}updateDOM(e,t){return e.__templateColumns!==this.__templateColumns&&(t.style.gridTemplateColumns=this.__templateColumns),!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-layout-container")?{conversion:oS,priority:2}:null}}static importJSON(e){return Xc().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setTemplateColumns(e.templateColumns)}isShadowRoot(){return!0}canBeEmpty(){return!1}exportJSON(){return{...super.exportJSON(),templateColumns:this.__templateColumns}}getTemplateColumns(){return this.getLatest().__templateColumns}setTemplateColumns(e){const t=this.getWritable();return t.__templateColumns=e,t}}function Xc(n=""){return new vr(n)}function ri(n){return n instanceof vr}function sS(){return{node:Zc()}}function iS(n){if(!Qc(n)||n.getChildrenSize()!==1)return!1;const e=n.getFirstChild();return ht(e)&&e.isEmpty()}class kr extends Oe{constructor(e){super(e)}static getType(){return"layout-item"}static clone(e){return new kr(e.__key)}createDOM(e){const t=document.createElement("div");return t.setAttribute("data-lexical-layout-item","true"),typeof e.theme.layoutItem=="string"&&Te(t,e.theme.layoutItem),t}updateDOM(){return!1}collapseAtStart(){const e=this.getParentOrThrow();return this.is(e.getFirstChild())&&e.getChildren().every(iS)?(e.remove(),!0):!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-layout-item")?{conversion:sS,priority:2}:null}}static importJSON(e){return Zc().updateFromJSON(e)}isShadowRoot(){return!0}}function Zc(){return new kr}function Qc(n){return n instanceof kr}const r_="@datalayer/jupyter-lexical/Loom",Jo=new WeakMap;function PA(n,e){return e?Jo.set(n,e):Jo.delete(n),()=>{Jo.get(n)===e&&Jo.delete(n)}}function aS(n){return Jo.get(n)}const lS=/^https?:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/(?:[^/?#]*-)?([0-9a-f]{32})(?:[/?#].*)?$/i;function wn(n){const e=lS.exec(n.trim());return e?e[1].toLowerCase():null}function eu(n){return`https://www.loom.com/share/${n}`}function o_(n){return`https://www.loom.com/embed/${n}`}async function s_(n){const e=wn(n);if(!e)throw new Error(`Not a Loom video address: ${n}`);const t=eu(e);try{const{oembed:r}=await me(async()=>{const{oembed:a}=await import("./esm-BSpvs9Ep.js");return{oembed:a}},[],import.meta.url),{title:o,width:s,height:i}=await r(t);return{url:t,title:o||void 0,width:Number(s)||void 0,height:Number(i)||void 0}}catch{return{url:t}}}const Sa=new Map;function cS(n){const e=n instanceof Error?n.message:String(n),t=e.toLowerCase(),r=t.indexOf("is not a function");return t.includes("render is not a function")||r>=0&&t.includes("render",r)?"The Loom recorder needs React 18 and this page runs React 19. See the Loom notes in the jupyter-lexical README to give it one.":`Loom could not start recording: ${e}`}function uS(n){let e=Sa.get(n);return e||(e=(async()=>{const{isSupported:t}=await me(async()=>{const{isSupported:f}=await import("./is-supported-CKr056Mu.js");return{isSupported:f}},[],import.meta.url),{supported:r,error:o}=await t();if(!r)throw new Error(`this browser cannot record with Loom (${o})`);const{setup:s}=await me(async()=>{const{setup:f}=await import("./esm-BaC41XaP.js");return{setup:f}},[],import.meta.url),{configureButton:i}=await s({publicAppId:n}),a=i();let l;const c=new Map,u=f=>{let d=c.get(f.id);!d&&l&&(d=l,c.set(f.id,d)),d?.(f)};return a.on("recording-complete",u),a.on("upload-complete",u),a.on("insert-click",u),{record:f=>{l=f,a.openPreRecordPanel()}}})(),e.catch(()=>Sa.delete(n)),Sa.set(n,e)),e}function dS({video:n}){const e=wn(n.url);return e?w.jsx("div",{"data-lexical-loom-player":e,style:{position:"relative",width:"100%",aspectRatio:`${n.width||16} / ${n.height||9}`,borderRadius:6,overflow:"hidden",background:"var(--bgColor-muted, #f6f8fa)"},children:w.jsx("iframe",{src:o_(e),title:n.title||"Loom video",allow:"fullscreen; picture-in-picture",style:{position:"absolute",inset:0,width:"100%",height:"100%",border:0}})}):null}function fS({nodeKey:n}){const[e]=fe(),t=Or(),[r,o]=C.useState(""),[s,i]=C.useState(),[a,l]=C.useState(),c=Hl(e,r_)?.config.publicAppId??aS(e),u=C.useCallback(p=>{e.update(()=>{const h=Q(n);nu(h)&&h.setVideo(p)})},[e,n]),f=C.useCallback(async()=>{if(c){l(void 0),i("recording");try{(await uS(c)).record(h=>u({url:h.sharedUrl,title:h.title,width:h.width,height:h.height}))}catch(p){l(cS(p))}finally{i(void 0)}}},[c,u]),d=C.useCallback(async()=>{if(!wn(r)){l("That is not the address of a Loom video: it looks like https://www.loom.com/share/…");return}l(void 0),i("embedding");try{u(await s_(r))}finally{i(void 0)}},[r,u]);return t?w.jsxs(Y,{"data-lexical-loom-placeholder":"",sx:{display:"grid",gap:2,p:3,border:"1px dashed",borderColor:"border.default",borderRadius:2,bg:"canvas.subtle"},children:[w.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[w.jsx(ks,{size:16}),w.jsx(Le,{sx:{fontWeight:"bold"},children:"Loom Video"})]}),w.jsx(Le,{sx:{color:"fg.muted",fontSize:0},children:"Recorded with Loom: Loom asks you to sign in to your Loom account, and the video is saved there, so it stays in the document."}),w.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[w.jsx(ft,{variant:"primary",onClick:()=>{f()},disabled:!c||s!==void 0,children:s==="recording"?"Starting…":"Record"}),w.jsx(Le,{sx:{color:"fg.muted",fontSize:1},children:"or"}),w.jsx(yn,{"aria-label":"Address of a Loom video",placeholder:"https://www.loom.com/share/…",value:r,onChange:p=>o(p.target.value),onFocus:()=>e.update(()=>Ee(null)),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),d())},sx:{flex:"1 1 240px"}}),w.jsx(ft,{onClick:()=>{d()},disabled:!r.trim()||s!==void 0,children:s==="embedding"?"Embedding…":"Embed"})]}),!c&&w.jsxs(Y,{"data-lexical-loom-no-app-id":"",sx:{display:"flex",gap:2,alignItems:"flex-start",color:"attention.fg",fontSize:1},children:[w.jsx(Kg,{size:16}),w.jsxs(Le,{children:["Recording with Loom is off in this editor: it was given no Loom public app id, and without one Loom cannot open to let you sign in. Its host passes the id to ",w.jsx("code",{children:"LoomExtension"}),". A Loom video can still be embedded by its address."]})]}),a&&w.jsx(Le,{role:"alert",sx:{color:"danger.fg",fontSize:1},children:a})]}):w.jsx(Le,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:"A Loom video goes here."})}function gS({className:n,format:e,nodeKey:t,video:r}){return w.jsx(gs,{className:n,format:e,nodeKey:t,children:wn(r.url)?w.jsx(dS,{video:r}):w.jsx(fS,{nodeKey:t})})}function pS(n){const e=n.getAttribute("data-lexical-loom"),t=wn(e||n.getAttribute("src")||"");return t?{node:tu({url:eu(t),title:n.getAttribute("title")||void 0})}:null}class Ro extends Oo{__url;__title;__width;__height;static getType(){return"loom"}static clone(e){return new Ro({url:e.__url,title:e.__title,width:e.__width,height:e.__height},e.__format,e.__key)}static importJSON(e){const t=tu({url:e.url,title:e.title,width:e.width,height:e.height});return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"loom",version:1,url:this.__url,...this.__title?{title:this.__title}:{},...this.__width?{width:this.__width}:{},...this.__height?{height:this.__height}:{}}}static importDOM(){return{iframe:e=>e.hasAttribute("data-lexical-loom")||wn(e.getAttribute("src")||"")?{conversion:pS,priority:1}:null}}exportDOM(){const e=wn(this.__url);if(!e)return{element:null};const t=document.createElement("iframe");return t.setAttribute("data-lexical-loom",this.__url),t.setAttribute("src",o_(e)),t.setAttribute("title",this.__title||"Loom video"),t.setAttribute("width",String(this.__width||640)),t.setAttribute("height",String(this.__height||360)),t.setAttribute("frameborder","0"),t.setAttribute("allowfullscreen","true"),{element:t}}constructor(e={url:""},t,r){super(t,r),this.__url=e.url,this.__title=e.title,this.__width=e.width,this.__height=e.height}getVideo(){const e=this.getLatest();return{url:e.__url,title:e.__title,width:e.__width,height:e.__height}}setVideo(e){const t=this.getWritable();t.__url=e.url,t.__title=e.title,t.__width=e.width,t.__height=e.height}getTextContent(){return this.__url}updateDOM(){return!1}decorate(e,t){const r=t.theme.embedBlock||{};return w.jsx(gS,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),video:{url:this.__url,title:this.__title,width:this.__width,height:this.__height}})}isTopLevel(){return!0}}function tu(n){return new Ro(n)}function nu(n){return n instanceof Ro}function hS(n,e){const t={};for(const r of n){const o=e(r);t[o]?t[o].push(r):t[o]=[r]}return t}function _S(n){const e=hS(n,t=>t.type);return{element:e.element||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const cf=/[!-/:-@[-`{-~\s]/,mS=/^\s{0,3}$/,uf=/^```(\w{1,10})?\s?$/;function bS(n){const e=_S(n),t=SS(e.textFormat);return r=>{const o=r.split(`
85
85
  `),s=o.length,i=se();for(let l=0;l<s;l++){const c=o[l],[u,f]=xS(o,l,i);if(u!=null){l=f;continue}wS(c,i,e.element,t,e.textMatch)}const a=i.getChildren();for(const l of a)yS(l)&&l.remove();i.selectEnd()}}function yS(n){if(!ht(n))return!1;const e=n.getFirstChild();return e==null||n.getChildrenSize()===1&&oe(e)&&mS.test(e.getTextContent())}function wS(n,e,t,r,o){const s=n.trim(),i=De(s),a=ne();a.append(i),e.append(a);for(const{regExp:l,replace:c}of t){const u=n.match(l);if(u){i.setTextContent(n.slice(u[0].length)),c(a,[i],u,!0);break}}if(oi(i,r,o),a.isAttached()&&s.length>0){const l=a.getPreviousSibling();if(ht(l)||Bn(l)||Z(l)){let c=l;if(Z(l)){const u=l.getLastDescendant();u==null?c=null:c=re(u,le)}c!=null&&c.getTextContentSize()>0&&(c.splice(c.getChildrenSize(),0,[xt(),...a.getChildren()]),a.remove())}}}function xS(n,e,t){const r=n[e].match(uf);if(r){let o=e;const s=n.length;for(;++o<s;)if(n[o].match(uf)){const a=Rr(r[1]),l=De(n.slice(e+1,o).join(`
86
86
  `));return a.append(l),t.append(a),[a,o]}}return[null,e]}function oi(n,e,t){const r=n.getTextContent(),o=CS(r,e);if(!o){i_(n,t);return}let s,i,a;if(o[0]===r)s=n;else{const c=o.index||0,u=c+o[0].length;c===0?[s,i]=n.splitText(u):[a,s,i]=n.splitText(c,u)}s.setTextContent(o[2]);const l=e.transformersByTag[o[1]];if(l)for(const c of l.format)s.hasFormat(c)||s.toggleFormat(c);s.hasFormat("code")||oi(s,e,t),a&&oi(a,e,t),i&&oi(i,e,t)}function i_(n,e){let t=n;e:for(;t;){for(const r of e){const o=t.getTextContent().match(r.importRegExp);if(!o)continue;const s=o.index||0,i=s+o[0].length;let a,l;s===0?[a,t]=t.splitText(i):[,a,l]=t.splitText(s,i),l&&i_(l,e),r.replace(a,o);continue e}break}}function CS(n,e){const t=n.match(e.openTagsRegExp);if(t==null)return null;for(const r of t){const o=r.replace(/^\s/,""),s=e.fullMatchRegExpByTag[o];if(s==null)continue;const i=n.match(s),a=e.transformersByTag[o];if(i!=null&&a!=null){if(a.intraword!==!1)return i;const{index:l=0}=i,c=n[l-1],u=n[l+i[0].length];if((!c||cf.test(c))&&(!u||cf.test(u)))return i}}return null}function SS(n){const e={},t={},r=[];for(const o of n){const{tag:s}=o;e[s]=o;const i=s.replace(/(\*|\^)/g,"\\$1");r.push(i),t[s]=new RegExp(`(${i})(?![${i}\\s])(.*?[^${i}\\s])${i}(?!${i})`)}return{fullMatchRegExpByTag:t,openTagsRegExp:new RegExp("("+r.join("|")+")","g"),transformersByTag:e}}const a_=n=>(e,t,r)=>{const o=n(r);o.append(...t),e.replace(o),o.select(0,0)},l_=4,ru=n=>(e,t,r)=>{const o=e.getPreviousSibling(),s=wt(n==="check"?r[3]==="x":void 0);if(Z(o)&&o.getListType()===n)o.append(s),e.remove();else{const a=kt(n,n==="number"?Number(r[2]):void 0);a.append(s),e.replace(a)}s.append(...t),s.select(0,0);const i=Math.floor(r[1].length/l_);i&&s.setIndent(i)},ea=(n,e,t)=>{const r=[],o=n.getChildren();let s=0;for(const i of o)if(le(i)){if(i.getChildrenSize()===1){const u=i.getFirstChild();if(Z(u)){r.push(ea(u,e,t+1));continue}}const a=" ".repeat(t*l_),l=n.getListType(),c=l==="number"?`${n.getStart()+s}. `:l==="check"?`- [${i.getChecked()?"x":" "}] `:"- ";r.push(a+c+e(i)),s++}return r.join(`
87
87
  `)},vS={dependencies:[Es],export:(n,e)=>{if(!Lr(n))return null;const t=Number(n.getTag().slice(1));return"#".repeat(t)+" "+e(n)},regExp:/^(#{1,6})\s/,replace:a_(n=>{const e="h"+n[1].length;return cn(e)}),type:"element"},kS={dependencies:[Ts],export:(n,e)=>{if(!Bn(n))return null;const t=e(n).split(`
88
88
  `),r=[];for(const o of t)r.push("> "+o);return r.join(`
89
89
  `)},regExp:/^>\s/,replace:(n,e,t,r)=>{if(r){const s=n.getPreviousSibling();if(Bn(s)){s.splice(s.getChildrenSize(),0,[xt(),...e]),s.select(0,0),n.remove();return}}const o=Sn();o.append(...e),n.replace(o),o.select(0,0)},type:"element"},IS={dependencies:[It],export:n=>{if(!st(n))return null;const e=n.getTextContent();return"```"+(n.getLanguage()||"")+(e?`
90
90
  `+e:"")+"\n```"},regExp:/^```(\w{1,10})?\s/,replace:a_(n=>Rr(n?n[1]:void 0)),type:"element"},TS={dependencies:[qt,hn],export:(n,e)=>Z(n)?ea(n,e,0):null,regExp:/^(\s*)[-*+]\s/,replace:ru("bullet"),type:"element"},ES={dependencies:[qt,hn],export:(n,e)=>Z(n)?ea(n,e,0):null,regExp:/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,replace:ru("check"),type:"element"},NS={dependencies:[qt,hn],export:(n,e)=>Z(n)?ea(n,e,0):null,regExp:/^(\s*)(\d{1,})\.\s/,replace:ru("number"),type:"element"},LS={format:["code"],tag:"`",type:"text-format"},OS={format:["bold","italic"],tag:"***",type:"text-format"},AS={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},RS={format:["bold"],tag:"**",type:"text-format"},MS={format:["bold"],intraword:!1,tag:"__",type:"text-format"},$S={format:["strikethrough"],tag:"~~",type:"text-format"},DS={format:["italic"],tag:"*",type:"text-format"},PS={format:["italic"],intraword:!1,tag:"_",type:"text-format"},jS={dependencies:[un],export:(n,e,t)=>{if(!Pe(n))return null;const r=`[${n.getTextContent()}](${n.getURL()})`,o=n.getFirstChild();return n.getChildrenSize()===1&&oe(o)?t(o,r):r},importRegExp:/(?:\[([^[]+)\])(?:\(([^(]+)\))/,regExp:/(?:\[([^[]+)\])(?:\(([^(]+)\))$/,replace:(n,e)=>{const[,t,r]=e,o=yo(r),s=De(t);s.setFormat(n.getFormat()),o.append(s),n.replace(o)},trigger:")",type:"text-match"},c_=[vS,kS,IS,TS,NS],u_=[LS,OS,AS,RS,MS,DS,PS,$S],d_=[jS],FS=[...c_,...u_,...d_];function jA(n,e=FS){return bS(e)(n)}const BS={dependencies:[Pc],export:n=>gp(n)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(n,e,t,r)=>{const o=Vi();r||n.getNextSibling()!=null?n.replace(o):n.insertBefore(o)},type:"element"},US={dependencies:[Ar],export:(n,e,t)=>Pn(n)?`![${n.getAltText()}](${n.getSrc()})`:null,importRegExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))/,regExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))$/,replace:(n,e)=>{const[,t,r]=e,o=Xi({altText:t,maxWidth:800,src:r});n.replace(o)},trigger:")",type:"text-match"},zS={dependencies:[Gn],export:n=>{if(!ht(n)||n.getChildrenSize()!==1)return null;const e=n.getFirstChild();return!wr(e)||e.__inline?null:`$$${e.getEquation()}$$`},regExp:/^\$\$(.+?)\$\$\s?$/,replace:(n,e,t)=>{const r=ne();r.append(Yi(t[1].trim(),!1)),n.replace(r)},type:"element"},KS={dependencies:[Gn],export:(n,e,t)=>wr(n)?`$${n.getEquation()}$`:null,importRegExp:/\$([^$].+?)\$/,regExp:/\$([^$].+?)\$$/,replace:(n,e)=>{const[,t]=e,r=Yi(t,!0);n.replace(r)},trigger:"$",type:"text-match"},f_=/^(?:\|)(.+)(?:\|)\s?$/,WS=/^:?-+:?$/,JS={dependencies:[Yt,No,Vt],export:(n,e)=>{if(!be(n))return null;const t=[];for(const r of n.getChildren()){const o=[];if(ce(r))for(const s of r.getChildren())H(s)&&o.push(e(s));t.push(`| ${o.join(" | ")} |`),t.length===1&&ce(r)&&r.getChildrenSize()>0&&r.getChildren().every(s=>J(s)&&s.hasHeader())&&t.push(`| ${o.map(()=>"---").join(" | ")} |`)}return t.join(`
91
- `)},regExp:f_,replace:(n,e,t)=>{const r=df(t[0]);if(r==null)return;const o=[r];let s=n.getPreviousSibling(),i=r.length;for(;s&&!(!ht(s)||s.getChildrenSize()!==1);){const f=s.getFirstChild();if(!oe(f))break;const d=df(f.getTextContent());if(d==null)break;i=Math.max(i,d.length),o.unshift(d);const p=s.getPreviousSibling();s.remove(),s=p}const a=o.findIndex(f=>f.every(d=>WS.test(d.getTextContent().trim())));if(a===0){const f=n.getPreviousSibling();if(be(f)){const d=f.getLastChild();ce(d)&&d.getChildren().forEach(p=>{J(p)&&p.setHeaderStyles(te.ROW,te.ROW)}),n.remove();return}}const l=a>0?a:0;if(a>=0&&o.splice(a,1),o.length===0){n.remove();return}const c=Lo();for(const[f,d]of o.entries()){const p=dn();c.append(p);for(let h=0;h<i;h++){const _=h<d.length?d[h]:g_(null);f<l&&_.setHeaderStyles(te.ROW,te.ROW),p.append(_)}}const u=n.getPreviousSibling();be(u)&&HS(u)===i?(u.append(...c.getChildren()),n.remove()):n.replace(c),c.selectEnd()},type:"element"};function HS(n){const e=n.getFirstChild();return ce(e)?e.getChildrenSize():0}const g_=n=>{const e=lt(te.NO_STATUS),t=ne();return n!=null&&t.append(De(n.trim())),e.append(t),e},df=n=>{const e=n.match(f_);return!e||!e[1]?null:e[1].split("|").map(t=>g_(t))},qS=[zS,JS,BS,US,KS,ES,...c_,...u_,...d_],VS=C.lazy(()=>me(()=>import("./ExcalidrawComponent-BvB8s8DF.js"),[],import.meta.url));function YS(n){const e=n.getAttribute("data-lexical-excalidraw-json"),t=window.getComputedStyle(n),r=t.getPropertyValue("height"),o=t.getPropertyValue("width"),s=!r||r==="inherit"?"inherit":parseInt(r,10),i=!o||o==="inherit"?"inherit":parseInt(o,10);return e?{node:ou(e,i,s)}:null}class Un extends jt{__data;__width;__height;static getType(){return"excalidraw"}static clone(e){return new Un(e.__data,e.__width,e.__height,e.__key)}static importJSON(e){return new Un(e.data,e.width??"inherit",e.height??"inherit").updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),data:this.__data,height:this.__height==="inherit"?void 0:this.__height,width:this.__width==="inherit"?void 0:this.__width}}constructor(e="[]",t="inherit",r="inherit",o){super(o),this.__data=e,this.__width=t,this.__height=r}createDOM(e){const t=document.createElement("span"),o=e.theme.image;return o!==void 0&&(t.className=o),t}updateDOM(){return!1}static importDOM(){return{span:e=>e.hasAttribute("data-lexical-excalidraw-json")?{conversion:YS,priority:1}:null}}exportDOM(e){const t=document.createElement("span");t.style.display="inline-block";const r=e.getElementByKey(this.getKey());if(r!==null){const o=r.querySelector("svg");o!==null&&(t.innerHTML=o.outerHTML)}return t.style.width=this.__width==="inherit"?"inherit":`${this.__width}px`,t.style.height=this.__height==="inherit"?"inherit":`${this.__height}px`,t.setAttribute("data-lexical-excalidraw-json",this.__data),{element:t}}setData(e){const t=this.getWritable();t.__data=e}getWidth(){return this.getLatest().__width}setWidth(e){const t=this.getWritable();t.__width=e}getHeight(){return this.getLatest().__height}setHeight(e){const t=this.getWritable();t.__height=e}decorate(e,t){return w.jsx(VS,{nodeKey:this.getKey(),data:this.__data,width:this.__width,height:this.__height})}}function ou(n="[]",e="inherit",t="inherit"){return new Un(n,e,t)}function su(n){return n instanceof Un}const GS=Object.freeze(Object.defineProperty({__proto__:null,$createExcalidrawNode:ou,$isExcalidrawNode:su,ExcalidrawNode:Un},Symbol.toStringTag,{value:"Module"}));function XS(n,e){const t=n.split(/\s+/).map(r=>parseFloat(r)).filter(r=>!Number.isNaN(r)&&r>0);return t.length===e?t:Array.from({length:e},()=>1)}function Ol(n){const e=n.getFormatType();return e==="center"||e==="right"||e==="justify"?e:"left"}function er(n,e){return iu(n.getChildren(),e)}function iu(n,e){const t=[];for(const r of n)if(ue(r))t.push({kind:"break"});else if(bt(r))t.push({kind:"text",text:" ",link:e});else if(oe(r)){const o=r.getTextContent();o&&t.push({kind:"text",text:o,bold:r.hasFormat("bold"),italic:r.hasFormat("italic"),code:r.hasFormat("code"),underline:r.hasFormat("underline"),strikethrough:r.hasFormat("strikethrough"),subscript:r.hasFormat("subscript"),superscript:r.hasFormat("superscript"),highlight:r.hasFormat("highlight"),link:e})}else if(Pe(r))t.push(...er(r,r.getURL()));else if(wr(r))t.push({kind:"equation",equation:r.getEquation(),key:r.getKey()});else if(H(r))t.push(...er(r,e));else if(vt(r)){const o=r.getTextContent();o&&t.push({kind:"text",text:o,link:e})}return t}function si(n){const e=[],t=r=>{e.length&&r.length&&e.push({kind:"break"}),e.push(...r)};for(const r of n)switch(r.kind){case"heading":t(r.inlines.map(o=>o.kind==="text"?{...o,bold:!0}:o));break;case"paragraph":t(r.inlines);break;case"quote":case"collapsible":t(si(r.blocks));break;case"list":r.items.forEach((o,s)=>{const i=r.ordered?`${r.start+s}. `:"• ";t([{kind:"text",text:i},...si(o.blocks)])});break;case"code":t([{kind:"text",text:r.text,code:!0}]);break;case"equation":t([{kind:"equation",equation:r.equation,key:r.key}]);break;case"image":t([{kind:"text",text:r.alt||"[image]",italic:!0}]);break;case"embed":t([{kind:"text",text:r.label,link:r.url}]);break;case"table":r.rows.forEach(o=>t(o.flatMap((s,i)=>[...i?[{kind:"text",text:" | "}]:[],...s.inlines])));break;case"columns":r.columns.forEach(o=>t(si(o)));break}return e}function ZS(n){const e=[];for(const t of n.getChildren()){if(!le(t))continue;const r=t.getFirstChild();if(t.getChildrenSize()===1&&Z(r)){const i=Ni(r),a=e[e.length-1];a&&i?a.blocks.push(i):i&&e.push({checked:null,blocks:[i]});continue}const o=[],s=[];for(const i of t.getChildren()){if(H(i)&&!Pe(i)){const a=Ni(i);if(a&&a.kind!=="paragraph"){s.length&&(o.push({kind:"paragraph",inlines:[...s],align:"left",indent:0}),s.length=0),o.push(a);continue}}s.push(...iu([i]))}(s.length||o.length===0)&&o.unshift({kind:"paragraph",inlines:s,align:"left",indent:0}),e.push({checked:n.getListType()==="check"?t.getChecked()===!0:null,blocks:o})}return e}function Ni(n){if(Lr(n))return{kind:"heading",level:Math.min(6,Math.max(1,Number(n.getTag().slice(1))||1)),inlines:er(n),align:Ol(n),indent:n.getIndent()};if(Bn(n))return{kind:"quote",blocks:[{kind:"paragraph",inlines:er(n),align:"left",indent:0}]};if(Z(n))return{kind:"list",ordered:n.getListType()==="number",start:n.getStart(),items:ZS(n)};if(st(n))return{kind:"code",language:n.getLanguage()??"python",text:n.getTextContent(),executable:!0,key:n.getKey()};if(je(n))return{kind:"code",language:n.getLanguage()??null,text:n.getTextContent(),executable:!1,key:n.getKey()};if(zc(n))return{kind:"outputs",outputs:n.getOutputs(),key:n.getKey()};if(be(n)){const e=[];for(const t of n.getChildren()){if(!ce(t))continue;const r=[];for(const o of t.getChildren())J(o)&&r.push({header:o.hasHeader(),colSpan:Math.max(1,o.getColSpan()),inlines:si(Ho(o.getChildren()))});e.push(r)}return{kind:"table",rows:e}}if(ri(n)){const e=n.getChildren().filter(Qc),t=n.getTemplateColumns().trim(),r=Math.max(e.length,t?t.split(/\s+/).length:0);return{kind:"columns",weights:XS(n.getTemplateColumns(),r).slice(0,e.length),columns:e.map(o=>Ho(o.getChildren()))}}if($t(n)){const e=n.getChildren().find(ni),t=n.getChildren().find(Gc);return{kind:"collapsible",title:e?er(e):[],blocks:t?Ho(t.getChildren()):[],open:n.getOpen()}}if(gp(n))return{kind:"rule"};if(Pn(n))return{kind:"image",src:n.getSrc(),alt:n.getAltText(),key:n.getKey()};if(wr(n))return{kind:"equation",equation:n.getEquation(),key:n.getKey()};if(Vh(n)){const e=n.getId();return{kind:"embed",label:`YouTube video ${e}`,url:`https://www.youtube.com/watch?v=${e}`,key:n.getKey()}}if(su(n))return{kind:"drawing",key:n.getKey(),label:"Drawing"};if(nu(n)){const{url:e,title:t}=n.getVideo();return wn(e)?{kind:"embed",label:t?`Loom video: ${t}`:"Loom video",url:e,key:n.getKey()}:null}if(ht(n)){const e=er(n),t=n.getChildrenSize()===1?n.getFirstChild():null;return t&&wr(t)&&!t.__inline?{kind:"equation",equation:t.getEquation(),key:t.getKey()}:t&&Pn(t)?{kind:"image",src:t.getSrc(),alt:t.getAltText(),key:t.getKey()}:{kind:"paragraph",inlines:e,align:Ol(n),indent:n.getIndent()}}if(H(n)){const e=Ho(n.getChildren());if(e.length)return e.length===1?e[0]:{kind:"quote",blocks:e};const t=er(n);return t.length?{kind:"paragraph",inlines:t,align:"left",indent:0}:null}return vt(n)?{kind:"drawing",key:n.getKey(),label:n.getTextContent()||n.getType()}:null}function p_(n){return H(n)&&!Pe(n)&&!n.isInline()&&!ht(n)||be(n)||Z(n)||je(n)||Pn(n)||su(n)||Vh(n)||nu(n)||wr(n)&&!n.__inline}function QS(n){const e=[];let t=[];const r=()=>{if(t.length){const o=iu(t);o.length&&e.push({kind:"paragraph",inlines:o,align:Ol(n),indent:n.getIndent()}),t=[]}};for(const o of n.getChildren())if(p_(o)){r();const s=Ni(o);s&&e.push(s)}else t.push(o);return r(),e}function Ho(n){const e=[];for(const t of n){if(ht(t)&&t.getChildren().some(p_)){e.push(...QS(t));continue}const r=Ni(t);r&&e.push(r)}return e}function h_(n){return n.map(e=>e.kind==="text"?e.text:e.kind==="break"?`
91
+ `)},regExp:f_,replace:(n,e,t)=>{const r=df(t[0]);if(r==null)return;const o=[r];let s=n.getPreviousSibling(),i=r.length;for(;s&&!(!ht(s)||s.getChildrenSize()!==1);){const f=s.getFirstChild();if(!oe(f))break;const d=df(f.getTextContent());if(d==null)break;i=Math.max(i,d.length),o.unshift(d);const p=s.getPreviousSibling();s.remove(),s=p}const a=o.findIndex(f=>f.every(d=>WS.test(d.getTextContent().trim())));if(a===0){const f=n.getPreviousSibling();if(be(f)){const d=f.getLastChild();ce(d)&&d.getChildren().forEach(p=>{J(p)&&p.setHeaderStyles(te.ROW,te.ROW)}),n.remove();return}}const l=a>0?a:0;if(a>=0&&o.splice(a,1),o.length===0){n.remove();return}const c=Lo();for(const[f,d]of o.entries()){const p=dn();c.append(p);for(let h=0;h<i;h++){const _=h<d.length?d[h]:g_(null);f<l&&_.setHeaderStyles(te.ROW,te.ROW),p.append(_)}}const u=n.getPreviousSibling();be(u)&&HS(u)===i?(u.append(...c.getChildren()),n.remove()):n.replace(c),c.selectEnd()},type:"element"};function HS(n){const e=n.getFirstChild();return ce(e)?e.getChildrenSize():0}const g_=n=>{const e=lt(te.NO_STATUS),t=ne();return n!=null&&t.append(De(n.trim())),e.append(t),e},df=n=>{const e=n.match(f_);return!e||!e[1]?null:e[1].split("|").map(t=>g_(t))},qS=[zS,JS,BS,US,KS,ES,...c_,...u_,...d_],VS=C.lazy(()=>me(()=>import("./ExcalidrawComponent-CmJy7bb4.js"),[],import.meta.url));function YS(n){const e=n.getAttribute("data-lexical-excalidraw-json"),t=window.getComputedStyle(n),r=t.getPropertyValue("height"),o=t.getPropertyValue("width"),s=!r||r==="inherit"?"inherit":parseInt(r,10),i=!o||o==="inherit"?"inherit":parseInt(o,10);return e?{node:ou(e,i,s)}:null}class Un extends jt{__data;__width;__height;static getType(){return"excalidraw"}static clone(e){return new Un(e.__data,e.__width,e.__height,e.__key)}static importJSON(e){return new Un(e.data,e.width??"inherit",e.height??"inherit").updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),data:this.__data,height:this.__height==="inherit"?void 0:this.__height,width:this.__width==="inherit"?void 0:this.__width}}constructor(e="[]",t="inherit",r="inherit",o){super(o),this.__data=e,this.__width=t,this.__height=r}createDOM(e){const t=document.createElement("span"),o=e.theme.image;return o!==void 0&&(t.className=o),t}updateDOM(){return!1}static importDOM(){return{span:e=>e.hasAttribute("data-lexical-excalidraw-json")?{conversion:YS,priority:1}:null}}exportDOM(e){const t=document.createElement("span");t.style.display="inline-block";const r=e.getElementByKey(this.getKey());if(r!==null){const o=r.querySelector("svg");o!==null&&(t.innerHTML=o.outerHTML)}return t.style.width=this.__width==="inherit"?"inherit":`${this.__width}px`,t.style.height=this.__height==="inherit"?"inherit":`${this.__height}px`,t.setAttribute("data-lexical-excalidraw-json",this.__data),{element:t}}setData(e){const t=this.getWritable();t.__data=e}getWidth(){return this.getLatest().__width}setWidth(e){const t=this.getWritable();t.__width=e}getHeight(){return this.getLatest().__height}setHeight(e){const t=this.getWritable();t.__height=e}decorate(e,t){return w.jsx(VS,{nodeKey:this.getKey(),data:this.__data,width:this.__width,height:this.__height})}}function ou(n="[]",e="inherit",t="inherit"){return new Un(n,e,t)}function su(n){return n instanceof Un}const GS=Object.freeze(Object.defineProperty({__proto__:null,$createExcalidrawNode:ou,$isExcalidrawNode:su,ExcalidrawNode:Un},Symbol.toStringTag,{value:"Module"}));function XS(n,e){const t=n.split(/\s+/).map(r=>parseFloat(r)).filter(r=>!Number.isNaN(r)&&r>0);return t.length===e?t:Array.from({length:e},()=>1)}function Ol(n){const e=n.getFormatType();return e==="center"||e==="right"||e==="justify"?e:"left"}function er(n,e){return iu(n.getChildren(),e)}function iu(n,e){const t=[];for(const r of n)if(ue(r))t.push({kind:"break"});else if(bt(r))t.push({kind:"text",text:" ",link:e});else if(oe(r)){const o=r.getTextContent();o&&t.push({kind:"text",text:o,bold:r.hasFormat("bold"),italic:r.hasFormat("italic"),code:r.hasFormat("code"),underline:r.hasFormat("underline"),strikethrough:r.hasFormat("strikethrough"),subscript:r.hasFormat("subscript"),superscript:r.hasFormat("superscript"),highlight:r.hasFormat("highlight"),link:e})}else if(Pe(r))t.push(...er(r,r.getURL()));else if(wr(r))t.push({kind:"equation",equation:r.getEquation(),key:r.getKey()});else if(H(r))t.push(...er(r,e));else if(vt(r)){const o=r.getTextContent();o&&t.push({kind:"text",text:o,link:e})}return t}function si(n){const e=[],t=r=>{e.length&&r.length&&e.push({kind:"break"}),e.push(...r)};for(const r of n)switch(r.kind){case"heading":t(r.inlines.map(o=>o.kind==="text"?{...o,bold:!0}:o));break;case"paragraph":t(r.inlines);break;case"quote":case"collapsible":t(si(r.blocks));break;case"list":r.items.forEach((o,s)=>{const i=r.ordered?`${r.start+s}. `:"• ";t([{kind:"text",text:i},...si(o.blocks)])});break;case"code":t([{kind:"text",text:r.text,code:!0}]);break;case"equation":t([{kind:"equation",equation:r.equation,key:r.key}]);break;case"image":t([{kind:"text",text:r.alt||"[image]",italic:!0}]);break;case"embed":t([{kind:"text",text:r.label,link:r.url}]);break;case"table":r.rows.forEach(o=>t(o.flatMap((s,i)=>[...i?[{kind:"text",text:" | "}]:[],...s.inlines])));break;case"columns":r.columns.forEach(o=>t(si(o)));break}return e}function ZS(n){const e=[];for(const t of n.getChildren()){if(!le(t))continue;const r=t.getFirstChild();if(t.getChildrenSize()===1&&Z(r)){const i=Ni(r),a=e[e.length-1];a&&i?a.blocks.push(i):i&&e.push({checked:null,blocks:[i]});continue}const o=[],s=[];for(const i of t.getChildren()){if(H(i)&&!Pe(i)){const a=Ni(i);if(a&&a.kind!=="paragraph"){s.length&&(o.push({kind:"paragraph",inlines:[...s],align:"left",indent:0}),s.length=0),o.push(a);continue}}s.push(...iu([i]))}(s.length||o.length===0)&&o.unshift({kind:"paragraph",inlines:s,align:"left",indent:0}),e.push({checked:n.getListType()==="check"?t.getChecked()===!0:null,blocks:o})}return e}function Ni(n){if(Lr(n))return{kind:"heading",level:Math.min(6,Math.max(1,Number(n.getTag().slice(1))||1)),inlines:er(n),align:Ol(n),indent:n.getIndent()};if(Bn(n))return{kind:"quote",blocks:[{kind:"paragraph",inlines:er(n),align:"left",indent:0}]};if(Z(n))return{kind:"list",ordered:n.getListType()==="number",start:n.getStart(),items:ZS(n)};if(st(n))return{kind:"code",language:n.getLanguage()??"python",text:n.getTextContent(),executable:!0,key:n.getKey()};if(je(n))return{kind:"code",language:n.getLanguage()??null,text:n.getTextContent(),executable:!1,key:n.getKey()};if(zc(n))return{kind:"outputs",outputs:n.getOutputs(),key:n.getKey()};if(be(n)){const e=[];for(const t of n.getChildren()){if(!ce(t))continue;const r=[];for(const o of t.getChildren())J(o)&&r.push({header:o.hasHeader(),colSpan:Math.max(1,o.getColSpan()),inlines:si(Ho(o.getChildren()))});e.push(r)}return{kind:"table",rows:e}}if(ri(n)){const e=n.getChildren().filter(Qc),t=n.getTemplateColumns().trim(),r=Math.max(e.length,t?t.split(/\s+/).length:0);return{kind:"columns",weights:XS(n.getTemplateColumns(),r).slice(0,e.length),columns:e.map(o=>Ho(o.getChildren()))}}if($t(n)){const e=n.getChildren().find(ni),t=n.getChildren().find(Gc);return{kind:"collapsible",title:e?er(e):[],blocks:t?Ho(t.getChildren()):[],open:n.getOpen()}}if(gp(n))return{kind:"rule"};if(Pn(n))return{kind:"image",src:n.getSrc(),alt:n.getAltText(),key:n.getKey()};if(wr(n))return{kind:"equation",equation:n.getEquation(),key:n.getKey()};if(Vh(n)){const e=n.getId();return{kind:"embed",label:`YouTube video ${e}`,url:`https://www.youtube.com/watch?v=${e}`,key:n.getKey()}}if(su(n))return{kind:"drawing",key:n.getKey(),label:"Drawing"};if(nu(n)){const{url:e,title:t}=n.getVideo();return wn(e)?{kind:"embed",label:t?`Loom video: ${t}`:"Loom video",url:e,key:n.getKey()}:null}if(ht(n)){const e=er(n),t=n.getChildrenSize()===1?n.getFirstChild():null;return t&&wr(t)&&!t.__inline?{kind:"equation",equation:t.getEquation(),key:t.getKey()}:t&&Pn(t)?{kind:"image",src:t.getSrc(),alt:t.getAltText(),key:t.getKey()}:{kind:"paragraph",inlines:e,align:Ol(n),indent:n.getIndent()}}if(H(n)){const e=Ho(n.getChildren());if(e.length)return e.length===1?e[0]:{kind:"quote",blocks:e};const t=er(n);return t.length?{kind:"paragraph",inlines:t,align:"left",indent:0}:null}return vt(n)?{kind:"drawing",key:n.getKey(),label:n.getTextContent()||n.getType()}:null}function p_(n){return H(n)&&!Pe(n)&&!n.isInline()&&!ht(n)||be(n)||Z(n)||je(n)||Pn(n)||su(n)||Vh(n)||nu(n)||wr(n)&&!n.__inline}function QS(n){const e=[];let t=[];const r=()=>{if(t.length){const o=iu(t);o.length&&e.push({kind:"paragraph",inlines:o,align:Ol(n),indent:n.getIndent()}),t=[]}};for(const o of n.getChildren())if(p_(o)){r();const s=Ni(o);s&&e.push(s)}else t.push(o);return r(),e}function Ho(n){const e=[];for(const t of n){if(ht(t)&&t.getChildren().some(p_)){e.push(...QS(t));continue}const r=Ni(t);r&&e.push(r)}return e}function h_(n){return n.map(e=>e.kind==="text"?e.text:e.kind==="break"?`
92
92
  `:e.equation).join("")}function ev(){const n=Ho(se().getChildren()),e=n.find(t=>t.kind==="heading");return{blocks:n,title:e&&e.kind==="heading"?h_(e.inlines):null}}function au(n){return n.getEditorState().read(ev)}const Vs=["Helvetica","Helvetica-Bold","Helvetica-Oblique","Helvetica-BoldOblique","Courier","Courier-Bold"],ff=[278,278,355,556,556,889,667,191,333,333,389,584,278,333,278,278,556,556,556,556,556,556,556,556,556,556,278,278,584,584,584,556,1015,667,667,722,722,667,611,778,722,278,500,667,556,833,722,778,667,778,722,667,611,722,667,944,667,667,611,278,278,278,469,556,333,556,556,500,556,556,278,556,556,222,222,500,222,833,556,556,556,556,333,500,278,556,500,722,500,500,500,334,260,334,584],gf=[278,333,474,556,556,889,722,238,333,333,389,584,278,333,278,278,556,556,556,556,556,556,556,556,556,556,333,333,584,584,584,611,975,722,722,722,722,667,611,778,722,278,556,722,611,833,722,778,667,778,722,667,611,722,667,944,667,667,611,333,278,333,584,556,333,556,611,556,611,556,333,611,611,278,278,556,278,889,611,611,611,611,389,556,333,611,556,778,556,556,500,389,280,389,584],tv={"—":[1e3,1e3],"–":[556,556],"•":[350,350],"‘":[222,278],"’":[222,278],"“":[333,500],"”":[333,500],"…":[1e3,1e3],"€":[556,556],"·":[278,278],"×":[584,584],"°":[400,400],"±":[584,584]," ":[278,278],"©":[737,737],"®":[737,737],"™":[1e3,1e3],"«":[556,556],"»":[556,556],"§":[556,556],"¶":[537,556]},nv={"−":"-","→":"->","←":"<-","⇒":"=>","≤":"<=","≥":">=","≠":"!=","≈":"~","∎":"#","■":"#","□":"[ ]","☐":"[ ]","☑":"[x]","☒":"[x]","✓":"v","✔":"v","▸":">","▾":"v"," ":" "," ":" "," ":" ","​":"","\uFEFF":"","­":""},pf={"€":128,"‚":130,ƒ:131,"„":132,"…":133,"†":134,"‡":135,"ˆ":136,"‰":137,Š:138,"‹":139,Œ:140,Ž:142,"‘":145,"’":146,"“":147,"”":148,"•":149,"–":150,"—":151,"˜":152,"™":153,š:154,"›":155,œ:156,ž:158,Ÿ:159};function rv(n){const e=[];let t="";for(const r of n){const o=nv[r],s=o!==void 0?o:r;for(const i of s){const a=i.codePointAt(0)??63;if(a<128||a>=160&&a<=255)e.push(a),t+=i;else if(pf[i]!==void 0)e.push(pf[i]),t+=i;else{const l=i.normalize("NFD").replace(/[̀-ͯ]/g,""),c=l.codePointAt(0)??63;l.length===1&&c<128?(e.push(c),t+=l):(e.push(63),t+="?")}}}return{bytes:e,text:t}}function ov(n){return n==="Helvetica-Bold"||n==="Helvetica-BoldOblique"}function sv(n,e){if(e==="Courier"||e==="Courier-Bold")return 600;const t=ov(e),r=n.codePointAt(0)??32;if(r>=32&&r<=126)return(t?gf:ff)[r-32];const o=tv[n];if(o)return o[t?1:0];const s=n.normalize("NFD").replace(/[̀-ͯ]/g,""),i=s.codePointAt(0)??32;return s.length===1&&i>=32&&i<=126?(t?gf:ff)[i-32]:t?611:556}function Zn(n,e,t){let r=0;for(const o of n)r+=sv(o,e);return r*t/1e3}function hf(n){return n.code?n.bold?"Courier-Bold":"Courier":n.bold&&n.italic?"Helvetica-BoldOblique":n.bold?"Helvetica-Bold":n.italic?"Helvetica-Oblique":"Helvetica"}const hs={a4:{width:595.28,height:841.89},letter:{width:612,height:792}};function Ys(n){if(typeof n=="string"){const e=n.replace("#",""),t=e.length===3?e.split("").map(a=>a+a).join(""):e,r=parseInt(t,16),o=(r>>16&255)/255,s=(r>>8&255)/255,i=(r&255)/255;return`${Fe(o)} ${Fe(s)} ${Fe(i)}`}return n.map(Fe).join(" ")}function Fe(n){return Number.isInteger(n)?String(n):n.toFixed(3).replace(/\.?0+$/,"")}function __(n){let e="";for(const t of n)e+=t.toString(16).padStart(2,"0");return e}function Bo(n){const e=[254,255];for(let t=0;t<n.length;t++){const r=n.charCodeAt(t);e.push(r>>8,r&255)}return`<${__(e)}>`}function iv(n){const e=t=>String(t).padStart(2,"0");return`D:${n.getUTCFullYear()}${e(n.getUTCMonth()+1)}${e(n.getUTCDate())}${e(n.getUTCHours())}${e(n.getUTCMinutes())}${e(n.getUTCSeconds())}Z`}class av{index;width;height;fontName;ops=[];links=[];images=new Set;constructor(e,t,r,o){this.index=e,this.width=t,this.height=r,this.fontName=o}text(e,t,r,o,s,i="#000000"){const{bytes:a}=rv(r);a.length!==0&&this.ops.push(`BT ${Ys(i)} rg /${this.fontName(o)} ${Fe(s)} Tf 1 0 0 1 ${Fe(e)} ${Fe(this.height-t)} Tm <${__(a)}> Tj ET`)}rect(e,t,r,o,s){const i=["q"];s.fill&&i.push(`${Ys(s.fill)} rg`),s.stroke&&i.push(`${Ys(s.stroke)} RG ${Fe(s.lineWidth??.5)} w`),i.push(`${Fe(e)} ${Fe(this.height-t-o)} ${Fe(r)} ${Fe(o)} re`),i.push(s.fill&&s.stroke?"B":s.fill?"f":"S","Q"),this.ops.push(i.join(" "))}line(e,t,r,o,s="#000000",i=.5){this.ops.push(`q ${Ys(s)} RG ${Fe(i)} w ${Fe(e)} ${Fe(this.height-t)} m ${Fe(r)} ${Fe(this.height-o)} l S Q`)}image(e,t,r,o,s){this.images.add(e.id),this.ops.push(`q ${Fe(o)} 0 0 ${Fe(s)} ${Fe(t)} ${Fe(this.height-r-s)} cm /Im${e.id} Do Q`)}link(e,t,r,o,s){this.links.push({rect:[e,this.height-t-o,e+r,this.height-t],url:s})}}class m_{options;pages=[];size;images=[];fonts=new Map;constructor(e={}){this.options=e,this.size=e.size??hs.a4,Vs.forEach((t,r)=>this.fonts.set(t,`F${r+1}`))}addPage(){const e=new av(this.pages.length,this.size.width,this.size.height,t=>this.fonts.get(t)??"F1");return this.pages.push(e),e}addJpeg(e,t,r){const o={id:this.images.length+1,width:t,height:r,bytes:e};return this.images.push(o),o}build(){const e=new TextEncoder,t=[];let r=0;const o=S=>{const v=typeof S=="string"?lv(S):S;t.push(v),r+=v.length},s=[],i=(S,v)=>{s[S]=r,o(`${S} 0 obj
93
93
  `),typeof v=="string"?o(v):v.forEach(o),o(`
94
94
  endobj
@@ -211,7 +211,7 @@ ${n.stack}`:r}function E1(){let n,e;try{const o=g.__wbindgen_add_to_stack_pointe
211
211
  user-select: none;
212
212
  white-space: pre;
213
213
  `,t}updateDOM(){return!1}static importJSON(e){return Pl(e.completionText)}exportJSON(){return{completionText:"",type:"inline-completion",version:1}}static importDOM(){return null}exportDOM(){return{element:null}}getCompletionText(){return this.__completionText}setCompletionText(e){const t=this.getWritable();t.__completionText=e}decorate(){return w.jsx(wE,{completionText:this.__completionText})}isInline(){return!0}isKeyboardSelectable(){return!1}}function Pl(n){return new Os(n)}function Vo(n){return n instanceof Os}function wE({completionText:n}){return w.jsx("span",{className:"inline-completion-text",style:{opacity:.5,color:"var(--vscode-editorSuggestWidget-foreground, #999)",pointerEvents:"none",userSelect:"none",whiteSpace:"pre"},children:n})}const xE=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,CE=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,SE=[n=>{const e=xE.exec(n);if(e){const t=e[0].startsWith("http")?e[0]:`https://${e[0]}`;return{index:e.index,length:e[0].length,text:e[0],url:t,attributes:{rel:"noopener noreferrer",target:"_blank"}}}return null},n=>{const e=CE.exec(n);return e?{index:e.index,length:e[0].length,text:e[0],url:`mailto:${e[0]}`}:null}],vE=pe({name:"@datalayer/jupyter-lexical/AutoLink",dependencies:[on(d0,{matchers:SE})]});function W_(n){const e=n.anchor,t=n.focus,r=n.anchor.getNode(),o=n.focus.getNode();return r===o?r:n.isBackward()?Zu(t)?r:o:Zu(e)?o:r}const kE=new Set(["http:","https:","mailto:","sms:","tel:"]);function IE(n){try{const e=new URL(n);if(!kE.has(e.protocol))return"about:blank"}catch{return n}return n}const TE=new RegExp(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/);function KA(n){return n==="https://"||TE.test(n)}function J_(n,e,t){const r=C.useRef(null);return r.current=n,C.useMemo(()=>vw((...o)=>{r.current&&r.current(...o)},e,{maxWait:t}),[e,t])}function Fa(n){return n instanceof HTMLElement}class H_{_x;_y;constructor(e,t){this._x=e,this._y=t}get x(){return this._x}get y(){return this._y}equals({x:e,y:t}){return this.x===e&&this.y===t}calcDeltaXTo({x:e}){return this.x-e}calcDeltaYTo({y:e}){return this.y-e}calcHorizontalDistanceTo(e){return Math.abs(this.calcDeltaXTo(e))}calcVerticalDistance(e){return Math.abs(this.calcDeltaYTo(e))}calcDistanceTo(e){return Math.sqrt(Math.pow(this.calcDeltaXTo(e),2)+Math.pow(this.calcDeltaYTo(e),2))}}function EE(n){return n instanceof H_}class nr{_left;_top;_right;_bottom;constructor(e,t,r,o){const[s,i]=t<=o?[t,o]:[o,t],[a,l]=e<=r?[e,r]:[r,e];this._top=s,this._right=l,this._left=a,this._bottom=i}get top(){return this._top}get right(){return this._right}get bottom(){return this._bottom}get left(){return this._left}get width(){return Math.abs(this._left-this._right)}get height(){return Math.abs(this._bottom-this._top)}equals({top:e,left:t,bottom:r,right:o}){return e===this._top&&r===this._bottom&&t===this._left&&o===this._right}contains(e){if(EE(e)){const{x:t,y:r}=e,o=r<this._top,s=r>this._bottom,i=t<this._left,a=t>this._right;return{reason:{isOnBottomSide:s,isOnLeftSide:i,isOnRightSide:a,isOnTopSide:o},result:!o&&!s&&!i&&!a}}else{const{top:t,left:r,bottom:o,right:s}=e;return t>=this._top&&t<=this._bottom&&o>=this._top&&o<=this._bottom&&r>=this._left&&r<=this._right&&s>=this._left&&s<=this._right}}intersectsWith(e){const{left:t,top:r,width:o,height:s}=e,{left:i,top:a,width:l,height:c}=this,u=t+o>=i+l?t+o:i+l,f=r+s>=a+c?r+s:a+c,d=t<=i?t:i,p=r<=a?r:a;return u-d<=o+l&&f-p<=s+c}generateNewRect({left:e=this.left,top:t=this.top,right:r=this.right,bottom:o=this.bottom}){return new nr(e,t,r,o)}static fromLTRB(e,t,r,o){return new nr(e,t,r,o)}static fromLWTH(e,t,r,o){return new nr(e,r,e+t,r+o)}static fromPoints(e,t){const{y:r,x:o}=e,{y:s,x:i}=t;return nr.fromLTRB(o,r,i,s)}static fromDOM(e){const{top:t,width:r,left:o,height:s}=e.getBoundingClientRect();return nr.fromLWTH(o,r,t,s)}}const Oi=new Map,bs=new Map,jl=new Set;function li(n,e){e?Oi.set(n,e):Oi.delete(n),jl.forEach(t=>t())}function NE(n){return jl.add(n),()=>jl.delete(n)}function LE(n){return Oi.get(n)}function OE(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`video-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function AE(){return typeof MediaRecorder<"u"&&typeof navigator<"u"&&!!navigator.mediaDevices}function RE(){if(!(typeof MediaRecorder>"u"))return["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(n=>MediaRecorder.isTypeSupported(n))}function ME(n){const e=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-"),t=n.mimeType.startsWith("video/mp4")?"mp4":"webm";return`recording-${e}.${t}`}function $E(n){const e=n instanceof DOMException?n.name:"";return e==="NotAllowedError"?"Recording did not start: the browser was not allowed to capture.":e==="NotFoundError"?"Recording did not start: there is no camera or microphone to record.":`Recording did not start: ${n instanceof Error?n.message:String(n)}`}function DE(n){if(n.length<=1)return{track:n[0],close:()=>{}};const e=new AudioContext,t=e.createMediaStreamDestination();for(const r of n)e.createMediaStreamSource(new MediaStream([r])).connect(t);return{track:t.stream.getAudioTracks()[0],close:()=>{e.close()}}}async function PE(n,{source:e,microphone:t},r){const o=[],s=()=>o.forEach(i=>i.getTracks().forEach(a=>a.stop()));try{const i=navigator.mediaDevices;let a;const l=[];if(e==="screen"){const m=await i.getDisplayMedia({video:!0,audio:!0});if(o.push(m),a=m.getVideoTracks()[0],l.push(...m.getAudioTracks()),t){const y=await i.getUserMedia({audio:!0}).catch(()=>{});y&&(o.push(y),l.push(...y.getAudioTracks()))}}else{const m=await i.getUserMedia({video:!0,audio:t});o.push(m),a=m.getVideoTracks()[0],l.push(...m.getAudioTracks())}if(!a)throw new Error("there was no picture to record");const c=DE(l),u=new MediaStream(c.track?[a,c.track]:[a]),f=RE(),d=new MediaRecorder(u,f?{mimeType:f}:void 0),p=[],h=Date.now();d.ondataavailable=m=>{m.data.size>0&&p.push(m.data)};const _=()=>{s(),c.close()};d.onstop=()=>{_(),bs.delete(n);const m=d.mimeType||f||"video/webm",y=new Blob(p,{type:m}),x={status:"recorded",url:URL.createObjectURL(y),blob:y,mimeType:m,durationMs:Date.now()-h};li(n,x),r?.(x)},a.addEventListener("ended",()=>pu(n)),bs.set(n,{recorder:d,release:_}),d.start(1e3),li(n,{status:"recording",startedAt:h,preview:new MediaStream([a])})}catch(i){s(),li(n,{status:"failed",message:$E(i)})}}function pu(n){const e=bs.get(n);e&&e.recorder.state!=="inactive"&&e.recorder.stop()}function jE(n){const e=bs.get(n);e&&(e.recorder.onstop=null,e.recorder.state!=="inactive"&&e.recorder.stop(),e.release(),bs.delete(n));const t=Oi.get(n);t?.status==="recorded"&&URL.revokeObjectURL(t.url),li(n,void 0)}function FE(n,e){return e?e.status:n?"lost":"idle"}const hu=zh?C.useLayoutEffect:C.useEffect;function BE({editor:n,getCodeDOMNode:e}){const[t,r]=C.useState(!1),o=J_(()=>{r(!1)},1e3);async function s(){const i=e();if(!i)return;let a="";n.update(()=>{const l=Me(i);je(l)&&(a=l.getTextContent());const c=P();Ee(c)});try{await navigator.clipboard.writeText(a),r(!0),o()}catch(l){console.error("Failed to copy: ",l)}}return w.jsx(Pt,{icon:t?kp:ly,size:"small",variant:"invisible",onClick:s,"aria-label":"copy",sx:t?{color:"var(--fgColor-success)"}:void 0})}const UE=8;function zE({anchorElem:n}){const[e]=fe(),[t,r]=C.useState(""),[o,s]=C.useState(!1),[i,a]=C.useState(!1),[l,c]=C.useState({right:"0",top:"0"}),u=C.useRef(new Set),f=C.useRef(null);function d(){return f.current}const p=J_(m=>{const{codeDOMNode:y,isOutside:x}=KE(m);if(x){s(!1);return}if(!y)return;f.current=y;let S=null,v="";if(e.update(()=>{const I=Me(y);je(I)&&(S=I,v=S.getLanguage()||"")}),S){const{y:I,right:E}=n.getBoundingClientRect(),{y:T,right:N}=y.getBoundingClientRect();r(v),s(!0),c({right:`${E-N+UE}px`,top:`${T-I}px`})}},50,1e3);C.useEffect(()=>{if(i)return document.addEventListener("mousemove",p),()=>{s(!1),p.cancel(),document.removeEventListener("mousemove",p)}},[i,p]),C.useEffect(()=>e.registerMutationListener(ln,m=>{e.getEditorState().read(()=>{for(const[y,x]of m)switch(x){case"created":u.current.add(y);break;case"destroyed":u.current.delete(y);break}}),a(u.current.size>0)},{skipInitialization:!1}),[e]);const h=_x(t),_=hx(t);return w.jsx(w.Fragment,{children:o?w.jsxs("div",{className:"code-action-menu-container",style:{...l},children:[w.jsx(Le,{sx:{fontSize:0,color:"var(--fgColor-muted)",alignSelf:"center",px:1},children:_}),w.jsx(BE,{editor:e,getCodeDOMNode:d}),Cx(h)?w.jsx(vx,{editor:e,getCodeDOMNode:d,lang:h}):null]}):null})}function KE(n){const e=n.target;if(ke(e)){const t=e.closest("code.JupyterLexicalTheme__code"),r=!(t||e.closest("div.code-action-menu-container"));return{codeDOMNode:t,isOutside:r}}else return{codeDOMNode:null,isOutside:!0}}function WA({anchorElem:n=document.body}){return Tt.createPortal(w.jsx(zE,{anchorElem:n}),n)}function Vf(n,e){const t=e.getElementByKey(n.getKey());if(t===null)return;const r=n.getChildren(),o=r.length;if(o===t.__cachedChildrenLength)return;t.__cachedChildrenLength=o;let s="1",i=1;for(let a=0;a<o;a++)ue(r[a])&&(s+=`
214
- `+ ++i);t.setAttribute("data-gutter",s)}function q_(n){const e=[];if(n instanceof ln&&e.push(n),H(n))for(const t of n.getChildren())H(t)&&e.push(...q_(t));return e}function WE(n){const e=de(mx(n),n.registerNodeTransform(ln,t=>{Vf(t,n)}));return n.getEditorState().read(()=>{for(const t of q_(se()))Vf(t,n)}),e}const JE=pe({name:"@datalayer/jupyter-lexical/CodeBlockHighlight",dependencies:[Zp],register:WE}),_u=he("INSERT_COLLAPSIBLE_COMMAND"),Yf=()=>{const n=P();if(j(n)&&n.isCollapsed()&&n.anchor.offset===0){const e=re(n.anchor.getNode(),$t);if($t(e)){const t=e.getParent();t!==null&&t.getFirstChild()===e&&n.anchor.key===e.getFirstDescendant()?.getKey()&&e.insertBefore(ne())}}return!1},Gf=()=>{const n=P();if(j(n)&&n.isCollapsed()){const e=re(n.anchor.getNode(),$t);if($t(e)){const t=e.getParent();if(t!==null&&t.getLastChild()===e){const r=e.getFirstDescendant(),o=e.getLastDescendant();(o!==null&&n.anchor.key===o.getKey()&&n.anchor.offset===o.getTextContentSize()||r!==null&&n.anchor.key===r.getKey()&&n.anchor.offset===r.getTextContentSize())&&e.insertAfter(ne())}}}return!1};function HE(n){if(!n.hasNodes([Cr,ps,Sr]))throw new Error("CollapsiblePlugin: CollapsibleContainerNode, CollapsibleTitleNode, or CollapsibleContentNode not registered on editor");return de(n.registerNodeTransform(Sr,e=>{const t=e.getParent();if(!$t(t)){const r=e.getChildren();for(const o of r)e.insertBefore(o);e.remove()}}),n.registerNodeTransform(ps,e=>{const t=e.getParent();if(!$t(t)){e.replace(ne().append(...e.getChildren()));return}}),n.registerNodeTransform(Cr,e=>{const t=e.getChildren();if(t.length!==2||!ni(t[0])||!Gc(t[1])){for(const r of t)e.insertBefore(r);e.remove()}}),n.registerCommand(Ht,Gf,ee),n.registerCommand(Di,Gf,ee),n.registerCommand(pt,Yf,ee),n.registerCommand(Ss,Yf,ee),n.registerCommand(ho,()=>{const e=P();if(j(e)){const t=re(e.anchor.getNode(),r=>ni(r));if(ni(t)){const r=t.getParent();if(r&&$t(r))return r.getOpen()||r.toggleOpen(),t.getNextSibling()?.selectEnd(),!0}}return!1},ee),n.registerCommand(_u,()=>(n.update(()=>{const e=n_(),t=ne();Yn(Vc(!0).append(e.append(t),Yc().append(ne()))),t.select()}),!0),ee))}const qE=pe({name:"@datalayer/jupyter-lexical/Collapsible",nodes:()=>[Cr,ps,Sr],register:HE}),VE=Fn?C.useLayoutEffect:C.useEffect;class V_{key;ref;icon;title;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}const Xf=n=>{const e=n.closest("#typeahead-menu");if(!e)return;const t=e.getBoundingClientRect();t.top+t.height>window.innerHeight&&e.scrollIntoView({block:"center"}),t.top<0&&e.scrollIntoView({block:"center"}),n.scrollIntoView({block:"nearest"})};function Zf(n,e){const t=n.getBoundingClientRect(),r=e.getBoundingClientRect();return t.top>=r.top-6&&t.top<=r.bottom+6}function YE(n,e,t,r){const[o]=fe();C.useEffect(()=>{if(e!=null&&n!=null){const s=o.getRootElement(),i=s!=null?Cp(s,!1):document.body;let a=!1,l=Zf(e,i);const c=function(){a||(window.requestAnimationFrame(function(){t(),a=!1}),a=!0);const d=Zf(e,i);d!==l&&(l=d,r?.(d))},u=new ResizeObserver(t),f=Sp(s??e);return u.observe(e),de(Wt(window,"resize",t),Wt(document,"scroll",c,{capture:!0,passive:!0}),...f.map(d=>Wt(d,"scroll",c,{capture:!0,passive:!0})),()=>u.unobserve(e))}},[e,o,r,t,n])}const Qf=he("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function GE({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){let s="item";return e&&(s+=" selected"),w.jsxs("li",{tabIndex:-1,className:s,ref:o.setRefElement,role:"option","aria-selected":e,id:"typeahead-item-"+n,onMouseEnter:r,onClick:t,children:[o.icon,w.jsx("span",{className:"text",children:o.title})]},o.key)}function XE({close:n,editor:e,anchorElementRef:t,resolution:r,options:o,menuRenderFn:s,onSelectOption:i,shouldSplitNodeWithQuery:a=!1,commandPriority:l=ee,preselectFirstItem:c=!0}){const[u,f]=C.useState(null),d=u!==null?Math.min(o.length-1,u):null,p=r.match&&r.match.matchingString;C.useEffect(()=>{c&&f(0)},[p,c]);const h=C.useCallback(x=>{e.update(()=>{const S=r.match!=null&&a?(function(v){const I=P();if(!j(I)||!I.isCollapsed())return null;const E=I.anchor;if(E.type!=="text")return null;const T=E.getNode();if(!T.isSimpleText())return null;const N=E.offset,O=T.getTextContent().slice(0,N),M=v.replaceableString.length,A=N-(function(L,R,B){let F=B;for(let U=F;U<=R.length;U++)L.slice(-U)===R.substring(0,U)&&(F=U);return F})(O,v.matchingString,M);if(A<0)return null;let $;return A===0?[$]=T.splitText(N):[,$]=T.splitText(A,N),$})(r.match):null;i(x,S,n,r.match?r.match.matchingString:"")})},[e,a,r.match,i,n]),_=C.useCallback(x=>{const S=e.getRootElement();S!==null&&(S.setAttribute("aria-activedescendant","typeahead-item-"+x),f(x))},[e]),m=C.useCallback(()=>t.current&&o.length?vp.createPortal(w.jsx("div",{className:"typeahead-popover mentions-menu",children:w.jsx("ul",{children:o.map((x,S)=>w.jsx(GE,{index:S,isSelected:d===S,onClick:()=>{f(S),h(x)},onMouseEnter:()=>{f(S)},option:x},x.key))})}),t.current):null,[t,o,d,h,f]);C.useEffect(()=>()=>{const x=e.getRootElement();x!==null&&x.removeAttribute("aria-activedescendant")},[e]),VE(()=>{o===null?f(null):d===null&&c&&_(0)},[o,d,_,c]),C.useEffect(()=>de(e.registerCommand(Qf,({option:x})=>!(!x.ref||x.ref.current==null)&&(Xf(x.ref.current),!0),l)),[e,_,l]),C.useEffect(()=>de(e.registerCommand(Ht,x=>{const S=x;if(o!==null&&o.length){const v=d===null?0:d!==o.length-1?d+1:0;_(v);const I=o[v];if(!I)return _(-1),S.preventDefault(),S.stopImmediatePropagation(),!0;I.ref&&I.ref.current&&e.dispatchCommand(Qf,{index:v,option:I}),S.preventDefault(),S.stopImmediatePropagation()}return!0},l),e.registerCommand(pt,x=>{const S=x;if(o!==null&&o.length){const v=d===null?o.length-1:d!==0?d-1:o.length-1;_(v);const I=o[v];if(!I)return _(-1),S.preventDefault(),S.stopImmediatePropagation(),!0;I.ref&&I.ref.current&&Xf(I.ref.current),S.preventDefault(),S.stopImmediatePropagation()}return!0},l),e.registerCommand(Cn,x=>{const S=x;return S.preventDefault(),S.stopImmediatePropagation(),n(),!0},l),e.registerCommand(Nr,x=>{const S=x;return o!==null&&d!==null&&o[d]!=null&&(S.preventDefault(),S.stopImmediatePropagation(),h(o[d]),!0)},l),e.registerCommand(Er,x=>!(o===null||d===null||o[d]==null||x&&x.shiftKey)&&(x!==null&&(x.preventDefault(),x.stopImmediatePropagation()),h(o[d]),!0),l)),[h,n,e,o,d,_,l]);const y=C.useMemo(()=>({options:o,selectOptionAndCleanUp:h,selectedIndex:d,setHighlightedIndex:f}),[h,d,o]);return s!=null?s(t,y,r.match?r.match.matchingString:""):m()}function eg(n,e){e!=null&&(n.className=e),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute"}function ZE(n,e,t,r,o=!0){const[s]=fe(),i=r??(function(f){if(!Fn)return;const d=f.getRootElement();if(d!==null){const p=d.getRootNode();return oc(p)?p:d.ownerDocument.body}return document.body})(s),a=Fn?xp(s.getRootElement()).createElement("div"):null,l=C.useRef(a),c=C.useCallback(()=>{if(l.current===null||i===void 0)return;l.current.style.top=l.current.style.bottom;const f=s.getRootElement(),d=l.current,p=d.firstChild;if(f!==null&&n!==null){const{left:h,top:_,width:m,height:y}=n.getRect(),x=l.current.offsetHeight;if(d.style.top=`${_+x+3+(o?window.pageYOffset:0)}px`,d.style.left=`${h+window.pageXOffset}px`,d.style.height=`${y}px`,d.style.width=`${m}px`,p!==null){p.style.top=`${_}`;const S=p.getBoundingClientRect(),v=S.height,I=S.width,E=f.getBoundingClientRect();h+I>E.right&&(d.style.left=`${E.right-I+window.pageXOffset}px`),(_+v>window.innerHeight||_+v>E.bottom)&&_-E.top>v+y&&(d.style.top=`${_-v-y+(o?window.pageYOffset:0)}px`)}d.isConnected||(eg(d,t),i.append(d)),d.setAttribute("id","typeahead-menu"),f.setAttribute("aria-controls","typeahead-menu")}},[s,n,o,t,i]);C.useEffect(()=>{const f=s.getRootElement();return n!==null&&c(),()=>{f!==null&&f.removeAttribute("aria-controls");const d=l.current;d!==null&&d.isConnected&&(d.remove(),d.removeAttribute("id"))}},[s,c,n]);const u=C.useCallback(f=>{n!==null&&(f||e(null))},[n,e]);return YE(n,l.current,c,u),a!=null&&a===l.current&&(eg(a,t),i?.append(a)),l}const QE=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function Y_(n,{minLength:e=1,maxLength:t=75,punctuation:r=QE,allowWhitespace:o=!1}){return C.useCallback(s=>{const i=new RegExp("(^|\\s|\\()(["+n+"]((?:"+("[^"+n+r+(o?"":"\\s")+"]")+"){0,"+t+"}))$").exec(s);if(i!==null){const a=i[1],l=i[3];if(l.length>=e)return{leadOffset:i.index+a.length,matchingString:l,replaceableString:i[2]}}return null},[o,n,r,t,e])}function G_({options:n,onQueryChange:e,onSelectOption:t,onOpen:r,onClose:o,menuRenderFn:s,triggerFn:i,anchorClassName:a,commandPriority:l=ee,parent:c,preselectFirstItem:u=!0,ignoreEntityBoundary:f=!1}){const[d]=fe(),[p,h]=C.useState(null),_=ZE(p,h,a,c),m=C.useCallback(()=>{if(p===null)return;const x=()=>{h(null)};let S;try{S=o&&o()}finally{S?S.then(x,x):x()}},[o,p]),y=C.useCallback(x=>{h(x),r!=null&&p===null&&r(x)},[r,p]);return C.useEffect(()=>{const x=d.registerUpdateListener(()=>{d.read("latest",()=>{if(!d.isEditable())return void m();if(d.isComposing())return;const S=d._window||window,v=S.document.createRange(),I=P(),E=(function(N){let O=null;return N.read("latest",()=>{const M=P();j(M)&&(O=(function(A){const $=A.anchor;if($.type!=="text")return null;const L=$.getNode();if(!L.isSimpleText())return null;const R=$.offset;return L.getTextContent().slice(0,R)})(M))}),O})(d);if(!j(I)||!I.isCollapsed()||E===null||v===null)return void m();const T=i(E,d);if(e(T?T.matchingString:null),T!==null&&(f||!(function(N,O){return O===0&&N.read("latest",()=>{const M=P();if(j(M)){const A=M.anchor.getNode().getPreviousSibling();return oe(A)&&A.isTextEntity()}return!1})})(d,T.leadOffset))&&(function(O,M,A,$){const L=Vn(A);if(L===null||!L.isCollapsed)return!1;const R=rc(L,$),B=R.anchorNode,F=O,U=R.anchorOffset;if(B==null||U==null)return!1;try{M.setStart(B,F),M.setEnd(B,U)}catch{return!1}return!0})(T.leadOffset,v,S,d.getRootElement())!==null)return void C.startTransition(()=>y({getRect:()=>v.getBoundingClientRect(),match:T}));m()})});return()=>{x()}},[d,i,e,p,m,y,f]),C.useEffect(()=>d.registerEditableListener(x=>{x||m()}),[d,m]),p===null||d===null||_.current===null?null:w.jsx(XE,{close:m,resolution:p,editor:d,anchorElementRef:_,options:n,menuRenderFn:s,shouldSplitNodeWithQuery:!0,onSelectOption:t,commandPriority:l,preselectFirstItem:u})}const eN=n=>n.split(/[\s._-]+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join("")||"?";function tN({author:n,size:e}){const t=fc(n);return n.avatarUrl?w.jsx(rw,{src:n.avatarUrl,size:e,alt:t}):w.jsx(Y,{as:"span","aria-hidden":!0,title:t,sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:e,height:e,borderRadius:"50%",bg:"neutral.muted",color:"fg.muted",fontSize:`${Math.round(e*.45)}px`,fontWeight:"bold"},children:n.kind==="anonymous"?w.jsx(cy,{size:Math.round(e*.65)}):eN(t)})}const Ir=C.createContext({}),nN=[],rN=250;function X_(n){const{searchPeople:e}=C.useContext(Ir),[t,r]=C.useState(null);return C.useEffect(()=>{if(!e||!n)return;let o=!0;const s=setTimeout(()=>{e(n).then(i=>{o&&r({query:n,people:i})},()=>{o&&r({query:n,people:[]})})},rN);return()=>{o=!1,clearTimeout(s)}},[n,e]),t&&t.query===n?t.people:nN}class oN extends V_{person;constructor(e){super(e.uid),this.person=e}}function sN({onMention:n}){const[e]=fe(),{searchPeople:t}=C.useContext(Ir),[r,o]=C.useState(null),s=X_(r),i=C.useMemo(()=>s.map(c=>new oN(c)),[s]),a=Y_("@",{minLength:1}),l=C.useCallback((c,u,f)=>{e.update(()=>{const d=De(`@${so(c.person)} `);u&&u.replace(d),d.select(),f()}),n(c.person)},[e,n]);return t?w.jsx(G_,{onQueryChange:o,onSelectOption:l,triggerFn:a,options:i,menuRenderFn:(c,{selectedIndex:u,selectOptionAndCleanUp:f,setHighlightedIndex:d})=>c.current&&i.length>0?Tt.createPortal(w.jsx(Y,{as:"ul",role:"listbox","aria-label":"People to mention",sx:{position:"relative",zIndex:1e3,listStyle:"none",m:0,p:1,bg:"var(--overlay-bgColor)",border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,boxShadow:"var(--shadow-floating-large, 0 0 0 1px #d1d9e0, 0 40px 80px 0 #25292e3d)",minWidth:200},children:i.map((p,h)=>w.jsxs(Y,{as:"li",role:"option","aria-selected":u===h,ref:_=>p.setRefElement(_),onMouseEnter:()=>d(h),onClick:()=>{d(h),f(p)},sx:{px:2,py:1,borderRadius:1,cursor:"pointer",bg:u===h?"actionListItem.default.hoverBg":"transparent"},children:[w.jsx(Le,{children:so(p.person)}),p.person.handle?w.jsxs(Le,{sx:{color:"var(--fgColor-muted)",ml:1},children:["@",p.person.handle]}):null]},p.key))}),c.current):null}):null}function iN({thread:n}){const{searchPeople:e,assignThread:t}=C.useContext(Ir),[r,o]=C.useState(!1),[s,i]=C.useState(""),a=X_(r&&s.trim()?s.trim():null),l=n.assignee??null;if(!t||!e)return l?w.jsxs(Le,{as:"p",sx:{fontSize:0,color:"var(--fgColor-muted)",m:0,mt:1},children:["Assigned to ",so(l)]}):null;const c=u=>{t(n,u),o(!1),i("")};return w.jsxs(Y,{sx:{mt:1},onClick:u=>u.stopPropagation(),children:[w.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:1},children:[w.jsx(Le,{sx:{fontSize:0,color:"var(--fgColor-muted)"},children:l?`Assigned to ${so(l)}`:"Not assigned"}),w.jsx(Pt,{icon:Gy,"aria-label":"Assign thread",variant:"invisible",size:"small",onClick:()=>o(!r)}),l?w.jsx(ft,{variant:"invisible",size:"small",onClick:()=>c(null),children:"Unassign"}):null]}),r?w.jsxs(Y,{sx:{mt:1},children:[w.jsx(yn,{"aria-label":"Find a person to assign",placeholder:"Name or handle",size:"small",block:!0,autoFocus:!0,value:s,onChange:u=>i(u.target.value)}),w.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0,mt:1},children:a.map(u=>w.jsx(Y,{as:"li",children:w.jsx(ft,{variant:"invisible",size:"small",onClick:()=>c(u),children:so(u)})},u.uid))})]}):null]})}const aN={characterLimit:"JupyterLexicalTheme__characterLimit",code:"JupyterLexicalTheme__code",codeHighlight:{atrule:"JupyterLexicalTheme__tokenAttr",attr:"JupyterLexicalTheme__tokenAttr",boolean:"JupyterLexicalTheme__tokenProperty",builtin:"JupyterLexicalTheme__tokenSelector",cdata:"JupyterLexicalTheme__tokenComment",char:"JupyterLexicalTheme__tokenSelector",class:"JupyterLexicalTheme__tokenFunction","class-name":"JupyterLexicalTheme__tokenFunction",comment:"JupyterLexicalTheme__tokenComment",constant:"JupyterLexicalTheme__tokenProperty",deleted:"JupyterLexicalTheme__tokenProperty",doctype:"JupyterLexicalTheme__tokenComment",entity:"JupyterLexicalTheme__tokenOperator",function:"JupyterLexicalTheme__tokenFunction",important:"JupyterLexicalTheme__tokenVariable",inserted:"JupyterLexicalTheme__tokenSelector",keyword:"JupyterLexicalTheme__tokenAttr",namespace:"JupyterLexicalTheme__tokenVariable",number:"JupyterLexicalTheme__tokenProperty",operator:"JupyterLexicalTheme__tokenOperator",prolog:"JupyterLexicalTheme__tokenComment",property:"JupyterLexicalTheme__tokenProperty",punctuation:"JupyterLexicalTheme__tokenPunctuation",regex:"JupyterLexicalTheme__tokenVariable",selector:"JupyterLexicalTheme__tokenSelector",string:"JupyterLexicalTheme__tokenSelector",symbol:"JupyterLexicalTheme__tokenProperty",tag:"JupyterLexicalTheme__tokenProperty",url:"JupyterLexicalTheme__tokenOperator",variable:"JupyterLexicalTheme__tokenVariable"},embedBlock:{base:"JupyterLexicalTheme__embedBlock",focus:"JupyterLexicalTheme__embedBlockFocus"},hashtag:"JupyterLexicalTheme__hashtag",heading:{h1:"JupyterLexicalTheme__h1",h2:"JupyterLexicalTheme__h2",h3:"JupyterLexicalTheme__h3",h4:"JupyterLexicalTheme__h4",h5:"JupyterLexicalTheme__h5",h6:"JupyterLexicalTheme__h6"},image:"editor-image",link:"JupyterLexicalTheme__link",list:{listitem:"JupyterLexicalTheme__listItem",listitemChecked:"JupyterLexicalTheme__listItemChecked",listitemUnchecked:"JupyterLexicalTheme__listItemUnchecked",nested:{listitem:"JupyterLexicalTheme__nestedListItem"},olDepth:["JupyterLexicalTheme__ol1","JupyterLexicalTheme__ol2","JupyterLexicalTheme__ol3","JupyterLexicalTheme__ol4","JupyterLexicalTheme__ol5"],ul:"JupyterLexicalTheme__ul"},ltr:"JupyterLexicalTheme__ltr",mark:"JupyterLexicalTheme__mark",markOverlap:"JupyterLexicalTheme__markOverlap",layoutContainer:"JupyterLexicalTheme__layoutContainer",layoutItem:"JupyterLexicalTheme__layoutItem",paragraph:"JupyterLexicalTheme__paragraph",quote:"JupyterLexicalTheme__quote",rtl:"JupyterLexicalTheme__rtl",table:"JupyterLexicalTheme__table",tableCell:"JupyterLexicalTheme__tableCell",tableCellHeader:"JupyterLexicalTheme__tableCellHeader",text:{bold:"JupyterLexicalTheme__textBold",code:"JupyterLexicalTheme__textCode",italic:"JupyterLexicalTheme__textItalic",strikethrough:"JupyterLexicalTheme__textStrikethrough",subscript:"JupyterLexicalTheme__textSubscript",superscript:"JupyterLexicalTheme__textSuperscript",underline:"JupyterLexicalTheme__textUnderline",underlineStrikethrough:"JupyterLexicalTheme__textUnderlineStrikethrough"}},lN={...aN,paragraph:"CommentEditorTheme__paragraph"},ns=he();function cN({anchorKey:n,editor:e,onAddComment:t}){const r=C.useRef(null),o=C.useCallback(()=>{const s=r.current,i=e.getRootElement(),a=e.getElementByKey(n);if(s!==null&&i!==null&&a!==null){const{right:l}=i.getBoundingClientRect(),{top:c}=a.getBoundingClientRect();s.style.left=`${l-20}px`,s.style.top=`${c-30}px`}},[n,e]);return C.useEffect(()=>(window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o)}),[e,o]),hu(()=>{o()},[n,e,o]),w.jsx(Y,{ref:r,sx:{position:"absolute",zIndex:10},children:w.jsx(Pt,{icon:mi,"aria-label":"Add comment",variant:"invisible",size:"small",onClick:t})})}const Z_=pe({name:"@datalayer/jupyter-lexical/CommentComposer",namespace:"Commenting",theme:lN,dependencies:[_y,Tp,my]}),uN=pe({name:"@datalayer/jupyter-lexical/CommentComposer/Focused",dependencies:[Z_,by]});function dN({editorRef:n}){const[e]=fe();return hu(()=>(n.current=e,()=>{n.current=null}),[e,n]),null}function fN({onEscape:n}){const[e]=fe();return C.useEffect(()=>e.registerCommand(Cn,t=>n(t),2),[e,n]),null}function Q_({style:n,autoFocus:e,onEscape:t,onChange:r,onMention:o,editorRef:s,placeholder:i="Type a comment..."}){const a=e===!1?Z_:uN;return w.jsx(py,{extension:a,contentEditable:null,children:w.jsxs(Y,{sx:{position:"relative",m:"10px",borderRadius:2},children:[w.jsx(Pg,{className:"ContentEditable__root",style:n,placeholder:w.jsx(Wp,{children:i}),"aria-placeholder":i}),w.jsx(hy,{onChange:r}),w.jsx(fN,{onEscape:t}),o!==void 0&&w.jsx(sN,{onMention:o}),s!==void 0&&w.jsx(dN,{editorRef:s})]})})}function em(n,e){return C.useCallback((t,r)=>{t.read(()=>{n(fy()),e(!gy(r.isComposing(),!0))})},[e,n])}const tg=256;function gN({editor:n,cancelAddComment:e,submitAddComment:t}){const[r,o]=C.useState(""),[s,i]=C.useState(!1),[a,l]=C.useState(null),c=C.useRef(null),u=C.useMemo(()=>({container:document.createElement("div"),elements:[]}),[]),f=nm(),d=C.useCallback(()=>{n.getEditorState().read(()=>{const S=P();if(j(S)){const v=S.anchor,I=S.focus,E=_p(n,v.getNode(),v.offset,I.getNode(),I.offset);if(E!==null){const{left:T,bottom:N,width:O}=E.getBoundingClientRect(),M=nl(n,E);let A=M.length===1?T+O/2-tg/2:T-tg/2;A<10&&(A=10),l({left:A,top:N+20});const $=M.length,{container:L}=u,R=u.elements,B=R.length;for(let F=0;F<$;F++){const U=M[F];let K=R[F];K===void 0&&(K=document.createElement("span"),R[F]=K,L.appendChild(K));const q=`position:absolute;top:${U.top}px;left:${U.left}px;height:${U.height}px;width:${U.width}px;background-color:var(--bgColor-attention-muted, rgba(255, 212, 0, 0.3));pointer-events:none;z-index:5;`;K.style.cssText=q}for(let F=B-1;F>=$;F--){const U=R[F];L.removeChild(U),R.pop()}}}})},[n,u]);hu(()=>{c.current=n.getRootElement(),d();const S=u.container,v=document.body;if(v!==null)return v.appendChild(S),()=>{v.removeChild(S)}},[n,u.container,d]),C.useEffect(()=>(window.addEventListener("resize",d),()=>{window.removeEventListener("resize",d)}),[d]);const p=S=>(S.preventDefault(),e(),!0),h=C.useRef(new Map),_=C.useCallback(S=>{h.current.set(S.uid,S)},[]),m=()=>{if(s){let S=n.getEditorState().read(()=>{const v=P();return v!==null?v.getTextContent():""});S.length>100&&(S=S.slice(0,99)+"…"),t(Ow(S,[Up(r,f,void 0,void 0,void 0,Fp(r,h.current.values()))]),!0)}},y=em(o,i),x=S=>{const v=S.target;v instanceof HTMLElement&&v.closest('[role="listbox"]')||e()};return a===null?null:w.jsxs(qa,{role:"dialog","aria-label":"Add a comment",width:"small",position:"fixed",left:a.left,top:a.top,onEscape:e,onClickOutside:x,returnFocusRef:c,preventFocusOnOpen:!0,children:[w.jsx(Q_,{style:{position:"relative",border:"1px solid var(--borderColor-default)",backgroundColor:"var(--bgColor-default)",borderRadius:"6px",fontSize:"15px",caretColor:"var(--fgColor-default)",display:"block",padding:"9px 10px 10px 9px",minHeight:"80px"},onEscape:p,onChange:y,onMention:_}),w.jsxs(Y,{sx:{display:"flex",gap:2,justifyContent:"flex-end",mt:2,px:2,pb:2},children:[w.jsx(ft,{onClick:e,variant:"invisible",size:"small",children:"Cancel"}),w.jsx(ft,{onClick:m,disabled:!s,variant:"primary",size:"small",children:"Comment"})]})]})}function pN({submitAddComment:n,thread:e,placeholder:t}){const[r,o]=C.useState(""),[s,i]=C.useState(!1),a=C.useRef(null),l=nm(),c=C.useRef(new Map),u=C.useCallback(p=>{c.current.set(p.uid,p)},[]),f=em(o,i),d=()=>{if(s){n(Up(r,l,void 0,void 0,void 0,Fp(r,c.current.values())),!1,e),c.current.clear();const p=a.current;p!==null&&p.dispatchCommand(wy,void 0)}};return w.jsxs(w.Fragment,{children:[w.jsx(Q_,{style:{position:"relative",border:"1px solid",borderColor:"var(--borderColor-default, #ccc)",backgroundColor:"var(--bgColor-default, #fff)",borderRadius:"6px",fontSize:"15px",caretColor:"var(--fgColor-default)",display:"block",padding:"9px 10px 10px 9px",minHeight:"20px"},autoFocus:!1,onEscape:()=>!0,onChange:f,onMention:u,editorRef:a,placeholder:t}),w.jsx(Pt,{icon:yy,"aria-label":"Send comment",variant:"invisible",size:"small",onClick:d,disabled:!s})]})}function tm({commentOrThread:n,deleteCommentOrThread:e,onClose:t,thread:r=void 0}){return w.jsxs(w.Fragment,{children:["Are you sure you want to delete this ",n.type,"?",w.jsxs(Y,{sx:{display:"flex",gap:2,justifyContent:"flex-end",mt:3},children:[w.jsx(ft,{variant:"invisible",onClick:()=>{t()},children:"Cancel"}),w.jsx(ft,{variant:"danger",onClick:()=>{e(n,r),t()},children:"Delete"})]})]})}function hN(n,e){const t=Math.round((e-Date.now())/1e3);if(t>-10)return"Just now";const r=Math.round(t/60);if(r>-60)return n.format(r,"minute");const o=Math.round(r/60);return o>-24?n.format(o,"hour"):n.format(Math.round(o/24),"day")}function ng({comment:n,deleteComment:e,thread:t,rtf:r}){const[o,s]=$o(),{Avatar:i=tN}=C.useContext(Ir),a=Lw(n);return w.jsxs(Y,{as:"li",sx:{p:2,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)"},children:[w.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[w.jsx(i,{author:a,size:20}),w.jsx(Le,{sx:{fontWeight:"bold",fontSize:1},children:fc(a)}),a.agentUid&&w.jsx(Le,{sx:{color:"var(--fgColor-muted)",fontSize:0},children:"· with an agent"}),w.jsxs(Le,{sx:{color:"var(--fgColor-muted)",fontSize:0},children:["· ",hN(r,n.timeStamp)]})]}),w.jsx(Le,{as:"p",sx:{fontSize:1,m:0,...n.deleted?{color:"var(--fgColor-muted)",fontStyle:"italic"}:{}},children:n.content}),!n.deleted&&w.jsxs(w.Fragment,{children:[w.jsx(Pt,{icon:Ip,"aria-label":"Delete comment",variant:"invisible",size:"small",sx:{color:"var(--fgColor-danger)",mt:1},onClick:()=>{s("Delete Comment",l=>w.jsx(tm,{commentOrThread:n,deleteCommentOrThread:e,thread:t,onClose:l}))}}),o]})]})}function _N({activeIDs:n,comments:e,deleteCommentOrThread:t,listRef:r,submitAddComment:o,markNodeMap:s,resolveThread:i}){const[a]=fe(),[l,c]=C.useState(0),[u,f]=$o(),d=C.useMemo(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return C.useEffect(()=>{const p=setTimeout(()=>{c(l+1)},1e4);return()=>{clearTimeout(p)}},[l]),w.jsx(Y,{as:"ul",ref:r,sx:{listStyle:"none",m:0,p:0},children:e.map(p=>{const h=p.id;if(p.type==="thread"){const _=()=>{const m=s.get(h);if(m!==void 0&&(n===null||n.indexOf(h)===-1)){const y=document.activeElement;a.update(()=>{const x=Array.from(m)[0],S=Q(x);mo(S)&&S.selectStart()},{onUpdate(){y!==null&&y.focus()}})}};return w.jsxs(Y,{as:"li",onClick:_,sx:{p:2,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)",cursor:s.has(h)?"pointer":"default",bg:n.indexOf(h)===-1?"var(--bgColor-default)":"var(--bgColor-accent-muted)","&:hover":s.has(h)?{bg:"var(--bgColor-muted)"}:{}},children:[w.jsxs(Y,{sx:{display:"flex",alignItems:"flex-start",gap:2},children:[w.jsxs(Y,{as:"blockquote",sx:{flex:1,m:0,pl:2,borderLeft:"3px solid",borderColor:"var(--bgColor-accent-muted)",color:"var(--fgColor-muted)",fontSize:1},children:["> ",w.jsx("span",{children:p.quote})]}),i&&w.jsx(Pt,{icon:kp,"aria-label":"Resolve thread",variant:"invisible",size:"small",onClick:m=>{m.stopPropagation(),i(p)}}),w.jsx(Pt,{icon:Ip,"aria-label":"Delete thread",variant:"invisible",size:"small",sx:{color:"var(--fgColor-danger)"},onClick:()=>{f("Delete Thread",m=>w.jsx(tm,{commentOrThread:p,deleteCommentOrThread:t,onClose:m}))}}),u]}),w.jsx(iN,{thread:p}),w.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0,mt:2},children:p.comments.map(m=>w.jsx(ng,{comment:m,deleteComment:t,thread:p,rtf:d},m.id))}),w.jsx(Y,{sx:{mt:2},children:w.jsx(pN,{submitAddComment:o,thread:p,placeholder:"Reply to comment..."})})]},h)}return w.jsx(ng,{comment:p,deleteComment:t,rtf:d},h)})})}function mN({activeIDs:n,deleteCommentOrThread:e,comments:t,submitAddComment:r,markNodeMap:o,resolveThread:s}){const i=C.useRef(null),a=t.length===0;return w.jsxs(Y,{sx:{bg:"var(--bgColor-default)",borderRadius:2,overflow:"hidden",width:"100%",flex:1,display:"flex",flexDirection:"column"},children:[w.jsx(dy,{as:"h2",sx:{fontSize:2,p:3,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)",m:0},children:"Comments"}),a?w.jsx(Y,{sx:{p:3,color:"var(--fgColor-muted)",textAlign:"center"},children:"No Comments"}):w.jsx(_N,{activeIDs:n,comments:t,deleteCommentOrThread:e,listRef:i,submitAddComment:r,markNodeMap:o,resolveThread:s})]})}function nm(){const{author:n}=C.useContext(Ir),{name:e}=M_();return n??gc(e)}function JA({providerFactory:n,showFloatingAddButton:e=!0,commentStore:t,author:r,Avatar:o}){const[s]=fe(),{showComments:i,setShowComments:a}=oh(),l=C.useRef(null),c=C.useRef(null),u=C.useMemo(()=>t??new Mw(s),[s,t]),f=$w(u),d=C.useMemo(()=>new Map,[]),[p,h]=C.useState(),[_,m]=C.useState([]),[y,x]=C.useState(!1),S=C.useCallback(A=>{a(typeof A=="function"?A(i):A)},[a,i]),v=C.useCallback(()=>{s.update(()=>{const A=P();A!==null&&(A.dirty=!0)}),x(!1)},[s]),I=C.useCallback(A=>{const $=d.get(A);$!==void 0&&setTimeout(()=>{s.update(()=>{for(const L of $){const R=Q(L);mo(R)&&(R.deleteID(A),R.getIDs().length===0&&kw(R))}})})},[s,d]),E=C.useCallback((A,$)=>{A.type==="comment"?u.deleteComment(A,$):(u.deleteThread(A),I($!==void 0?$.id:A.id))},[u,I]),T=C.useMemo(()=>{if(u.resolveThread)return A=>{u.resolveThread?.(A),I(A.id)}},[u,I]),N=C.useCallback((A,$,L)=>{u.addComment(A,L),$&&(s.update(()=>{const R=P();if(j(R)){const B=R.focus,F=R.anchor,U=R.isBackward(),K=A.id;Iw(R,U,K),U?B.set(F.key,F.offset,F.type):F.set(B.key,B.offset,B.type)}}),x(!1))},[u,s]);C.useEffect(()=>{const A=[];for(let $=0;$<_.length;$++){const L=_[$],R=d.get(L);if(R!==void 0)for(const B of R){const F=s.getElementByKey(B);F!==null&&(F.classList.add("selected"),A.push(F),a(!0))}}return()=>{for(let $=0;$<A.length;$++)A[$].classList.remove("selected")}},[_,s,d]),C.useEffect(()=>{const A=new Map;return de(uy(s,cs,$=>dc($.getIDs()),($,L)=>{$.getIDs().forEach(B=>{L.addID(B)})}),s.registerMutationListener(cs,$=>{s.getEditorState().read(()=>{for(const[L,R]of $){const B=Q(L);let F=[];R==="destroyed"?F=A.get(L)||[]:mo(B)&&(F=B.getIDs());for(let U=0;U<F.length;U++){const K=F[U];let W=d.get(K);A.set(L,F),R==="destroyed"?W!==void 0&&(W.delete(L),W.size===0&&d.delete(K)):(W===void 0&&(W=new Set,d.set(K,W)),W.has(L)||W.add(L))}}})}),s.registerUpdateListener(({editorState:$,tags:L})=>{$.read(()=>{const R=P();let B=!1,F=!1;if(j(R)){const U=R.anchor.getNode();if(oe(U)){const K=Tw(U,R.anchor.offset);K!==null&&(m(K),B=!0),R.isCollapsed()||(h(U.getKey()),F=!0)}}B||m(U=>U.length===0?U:[]),F||h(null)}),L.has("collaboration")||x(!1)}),s.registerCommand(ns,()=>{const $=window.getSelection();return $!==null&&$.removeAllRanges(),x(!0),!0},V))},[s,d]);const O=()=>{s.dispatchCommand(ns,void 0)},M=C.useMemo(()=>({searchPeople:u.searchPeople?.bind(u),assignThread:u.assignThread?.bind(u),author:r,Avatar:o}),[u,r,o]);return w.jsxs(Ir.Provider,{value:M,children:[y&&w.jsx(Ir.Provider,{value:M,children:w.jsx(gN,{editor:s,cancelAddComment:v,submitAddComment:N})}),e&&p!==null&&p!==void 0&&!y&&Tt.createPortal(w.jsx(cN,{anchorKey:p,editor:s,onAddComment:O}),document.body),w.jsx("button",{ref:l,style:{display:"none"},"aria-hidden":"true"}),w.jsx(bw,{isOpen:i,setIsOpen:S,openButtonRef:l,closeButtonRef:c,direction:"right",width:"350px",content:w.jsx(mN,{comments:f,submitAddComment:N,deleteCommentOrThread:E,activeIDs:_,markNodeMap:d,resolveThread:T})})]})}const vo=Qe().describe("CSS colour, e.g. '#1e1e1e', '#e03131', 'transparent'"),rm=Et({type:lr(["rectangle","ellipse","diamond","text","arrow","line","frame"]).describe("What to draw"),x:We().describe("Left edge, in scene coordinates"),y:We().describe("Top edge, in scene coordinates"),width:We().optional().describe("Width in pixels (shapes only)"),height:We().optional().describe("Height in pixels (shapes only)"),id:Qe().optional().describe("Your own id for this element, so a later arrow can point at it by name. Any string; Excalidraw keeps it."),text:Qe().optional().describe("The text itself, for type 'text'"),label:Qe().optional().describe("Text to put inside the shape. Excalidraw binds it to the shape, so moving the shape moves the label."),fontSize:We().optional().describe("Font size in pixels, e.g. 16, 20, 28"),strokeColor:vo.optional().describe("Outline colour"),backgroundColor:vo.optional().describe("Fill colour"),fillStyle:lr(["hachure","cross-hatch","solid"]).optional().describe("How the fill is drawn"),strokeWidth:We().optional().describe("Outline thickness, 1 | 2 | 4"),strokeStyle:lr(["solid","dashed","dotted"]).optional().describe("Outline style"),roughness:We().optional().describe("0 for architect (clean), 1 for artist, 2 for cartoonist"),opacity:We().optional().describe("0-100"),angle:We().optional().describe("Rotation in radians"),startId:Qe().optional().describe("For 'arrow' and 'line': the id of the element the arrow starts at. The arrow stays attached when either element moves."),endId:Qe().optional().describe("For 'arrow' and 'line': the id of the element the arrow points at."),points:ar(ar(We())).optional().describe("For 'arrow' and 'line' without bindings: points relative to x,y, e.g. [[0,0],[120,0]]"),children:ar(Qe()).optional().describe("For 'frame': the ids of the elements it contains"),name:Qe().optional().describe("For 'frame': its name")}),om=Qe().describe("Where to put the drawing: 'TOP' for the beginning of the document, 'BOTTOM' for the end, or the block_id to insert after"),vn=Qe().describe("The block_id of the drawing, from excalidrawListDrawings or readAllBlocks"),sm=Et({afterId:om,elements:ar(rm).optional().describe("The drawing itself. Omit to insert an empty canvas for a person to draw on."),width:We().optional().describe("Rendered width in pixels. Omit to size to the content."),height:We().optional().describe("Rendered height in pixels. Omit to size to the content.")}),im=Et({}),am=Et({blockId:vn,detail:lr(["summary","full"]).optional().describe("'summary' (default) gives each element's id, type, position, size and text — enough to change it. 'full' gives the raw Excalidraw elements, which is large; ask for it only when you need a field the summary omits.")}),lm=Et({blockId:vn,elements:ar(rm).describe("The elements to add. Existing elements are left alone.")}),cm=Et({blockId:vn,updates:ar(Et({id:Qe().describe("The element id, from excalidrawReadScene"),x:We().optional(),y:We().optional(),width:We().optional(),height:We().optional(),text:Qe().optional().describe("New text. On a shape this rewrites the label bound inside it; on a 'text' element it rewrites the element."),strokeColor:vo.optional(),backgroundColor:vo.optional(),fillStyle:lr(["hachure","cross-hatch","solid"]).optional(),strokeWidth:We().optional(),strokeStyle:lr(["solid","dashed","dotted"]).optional(),opacity:We().optional().describe("0-100"),angle:We().optional().describe("Rotation in radians")})).describe("One entry per element to change. Fields left out are kept.")}),um=Et({blockId:vn,elementIds:ar(Qe()).describe("The ids to remove, from excalidrawReadScene")}),dm=Et({blockId:vn,fromId:Qe().describe("The element the arrow starts at"),toId:Qe().describe("The element the arrow points at"),label:Qe().optional().describe('Text to sit on the arrow, e.g. "yes", "then"'),strokeColor:vo.optional(),strokeStyle:lr(["solid","dashed","dotted"]).optional()}),fm=Et({blockId:vn,viewBackgroundColor:vo.optional().describe("The canvas colour behind the drawing"),gridSize:We().optional().describe("Grid spacing in pixels. 0 turns the grid off.")}),gm=Et({blockId:vn,width:We().optional().describe("Rendered width in pixels. Omit to go back to sizing by content."),height:We().optional().describe("Rendered height in pixels. Omit to go back to sizing by content.")}),pm=Et({blockId:vn}),hm=Et({blockId:vn.optional().describe("The drawing to replace. Omit to insert a new drawing instead, positioned by afterId."),afterId:om.optional().describe("Where a new drawing goes: 'TOP', 'BOTTOM', or a block_id. Ignored when blockId is given."),mermaid:Qe().describe("Mermaid source. Flowcharts, sequence diagrams and class diagrams convert to real shapes; anything else comes across as an image."),fontSize:We().optional().describe("Font size for the generated text, in pixels")}),Xt=n=>`datalayer_${n}`,Fr={requiresConfirmation:!1,canBeReferencedInPrompt:!0,priority:"medium"},Zt=["lexical","excalidraw","drawing","diagram"],bN={name:Xt("excalidrawInsertNode"),displayName:"Insert Drawing",toolReferenceName:"excalidrawInsertNode",description:"Insert an Excalidraw drawing into the Lexical document, optionally with its contents. This is how you draw a diagram: give the elements you want and they are laid out as you place them, in scene coordinates where x grows right and y grows down. Give a shape an `id` and a later arrow can bind to it with `startId`/`endId`, so the arrow follows the shape when it moves. Put text on a shape with `label` rather than positioning a separate text element on top of it. Returns the new block_id — keep it, every other excalidraw tool needs it. Omit `elements` to insert an empty canvas for a person to draw on themselves.",parameters:Gt(sm),operation:"excalidrawInsertNode",config:{confirmationMessage:n=>`Insert a drawing of ${n.elements?.length??0} element(s)?`,invocationMessage:()=>"Drawing in the lexical document",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"high"},tags:[...Zt,"insert"]},yN={name:Xt("excalidrawListDrawings"),displayName:"List Drawings",toolReferenceName:"excalidrawListDrawings",description:'List the Excalidraw drawings in the open Lexical document, with the block_id of each and a one-line description of what it holds. Call this first when asked to change "the diagram" and you do not already know its block_id.',parameters:Gt(im),operation:"excalidrawListDrawings",config:{...Fr,invocationMessage:()=>"Looking for drawings"},tags:[...Zt,"read"]},wN={name:Xt("excalidrawReadScene"),displayName:"Read Drawing",toolReferenceName:"excalidrawReadScene",description:"Read what is inside one drawing: every element with its id, type, position, size and text. The element ids are the only way to address a shape, so read the scene before updating, deleting or connecting anything. The default 'summary' detail is what you want; 'full' returns the raw Excalidraw elements and is large.",parameters:Gt(am),operation:"excalidrawReadScene",config:{...Fr,invocationMessage:()=>"Reading the drawing"},tags:[...Zt,"read"]},xN={name:Xt("excalidrawAddElements"),displayName:"Add to Drawing",toolReferenceName:"excalidrawAddElements",description:"Add elements to a drawing that already exists, leaving what is there alone. Same element format as excalidrawInsertNode. To attach a new arrow to a shape already in the drawing, pass that shape's existing element id as `startId` or `endId`. Read the scene first if you need to know where there is room.",parameters:Gt(lm),operation:"excalidrawAddElements",config:{...Fr,invocationMessage:()=>"Adding to the drawing",priority:"high"},tags:[...Zt,"edit"]},CN={name:Xt("excalidrawUpdateElements"),displayName:"Update Drawing Elements",toolReferenceName:"excalidrawUpdateElements",description:"Change elements already in a drawing — move them, resize them, recolour them, or rewrite their text. Address each one by the element id from excalidrawReadScene. Fields you leave out are kept as they are. Setting `text` on a shape rewrites the label bound inside it rather than replacing the shape.",parameters:Gt(cm),operation:"excalidrawUpdateElements",config:{...Fr,invocationMessage:()=>"Changing the drawing"},tags:[...Zt,"edit"]},SN={name:Xt("excalidrawDeleteElements"),displayName:"Delete Drawing Elements",toolReferenceName:"excalidrawDeleteElements",description:"Remove elements from a drawing by their element ids. Deleting a shape also removes the text bound inside it and detaches any arrows that pointed at it, so the drawing stays consistent.",parameters:Gt(um),operation:"excalidrawDeleteElements",config:{confirmationMessage:n=>`Delete ${n.elementIds?.length??0} element(s) from the drawing?`,invocationMessage:()=>"Removing from the drawing",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"medium"},tags:[...Zt,"edit","delete"]},vN={name:Xt("excalidrawConnectElements"),displayName:"Connect Drawing Elements",toolReferenceName:"excalidrawConnectElements",description:"Draw an arrow from one element to another and bind it to both, so it follows them when either moves. Excalidraw works out where the arrow should meet each shape. Use this rather than adding an arrow with hand-computed points whenever both ends are existing shapes.",parameters:Gt(dm),operation:"excalidrawConnectElements",config:{...Fr,invocationMessage:()=>"Connecting two shapes"},tags:[...Zt,"edit"]},kN={name:Xt("excalidrawSetAppState"),displayName:"Set Drawing Canvas",toolReferenceName:"excalidrawSetAppState",description:"Set the canvas behind a drawing: its background colour and its grid. This is about the canvas, not the shapes on it — use excalidrawUpdateElements to recolour a shape.",parameters:Gt(fm),operation:"excalidrawSetAppState",config:{...Fr,invocationMessage:()=>"Setting up the canvas"},tags:[...Zt,"edit"]},IN={name:Xt("excalidrawResize"),displayName:"Resize Drawing",toolReferenceName:"excalidrawResize",description:"Set how large the drawing is rendered in the document. This scales the picture on the page; it does not move or resize anything inside it. Omit width and height to go back to sizing by content.",parameters:Gt(gm),operation:"excalidrawResize",config:{...Fr,invocationMessage:()=>"Resizing the drawing"},tags:[...Zt,"edit"]},TN={name:Xt("excalidrawClearScene"),displayName:"Clear Drawing",toolReferenceName:"excalidrawClearScene",description:"Empty a drawing, keeping the block so it can be drawn into again. To remove the drawing from the document altogether, use deleteBlocks with its block_id.",parameters:Gt(pm),operation:"excalidrawClearScene",config:{confirmationMessage:()=>"Empty this drawing?",invocationMessage:()=>"Emptying the drawing",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"low"},tags:[...Zt,"edit","delete"]},EN={name:Xt("excalidrawFromMermaid"),displayName:"Draw from Mermaid",toolReferenceName:"excalidrawFromMermaid",description:"Turn Mermaid source into a real Excalidraw drawing — shapes and arrows that can then be moved, recoloured and edited like anything else you drew. This is the fastest way to produce a flowchart, sequence diagram or class diagram: write the Mermaid and let the layout be worked out for you, rather than placing boxes by hand. Give blockId to replace an existing drawing, or afterId to insert a new one.",parameters:Gt(hm),operation:"excalidrawFromMermaid",config:{confirmationMessage:n=>n.blockId?"Replace this drawing with the Mermaid diagram?":"Insert the Mermaid diagram as a drawing?",invocationMessage:()=>"Drawing the Mermaid diagram",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"high"},tags:[...Zt,"insert","mermaid"]},_m=[bN,EN,yN,wN,xN,CN,vN,SN,kN,IN,TN],Ba=()=>({elements:[],appState:{},files:{}});function mu(n){if(!n)return Ba();let e;try{e=JSON.parse(n)}catch{return Ba()}if(Array.isArray(e))return{elements:e,appState:{},files:{}};if(!e||typeof e!="object")return Ba();const t=e;return{elements:Array.isArray(t.elements)?t.elements:[],appState:t.appState??{},files:t.files??{}}}function bu(n){return JSON.stringify({elements:n.elements,appState:n.appState,files:n.files})}const As=n=>n.elements.filter(e=>!e?.isDeleted);function NN(n){const e={id:String(n?.id??""),type:String(n?.type??"unknown"),x:Number(n?.x??0),y:Number(n?.y??0),width:Number(n?.width??0),height:Number(n?.height??0)};return typeof n?.text=="string"&&n.text.length>0&&(e.text=n.text),n?.strokeColor&&(e.strokeColor=String(n.strokeColor)),n?.backgroundColor&&(e.backgroundColor=String(n.backgroundColor)),n?.containerId&&(e.containerId=String(n.containerId)),n?.startBinding?.elementId&&(e.startBoundElementId=String(n.startBinding.elementId)),n?.endBinding?.elementId&&(e.endBoundElementId=String(n.endBinding.elementId)),Array.isArray(n?.groupIds)&&n.groupIds.length>0&&(e.groupIds=n.groupIds.map(String)),e}function LN(n){const e=new Map;for(const t of n)t?.type==="text"&&t?.containerId&&t?.text&&e.set(String(t.containerId),String(t.text));return n.map(t=>{const r=NN(t);if(r.text===void 0){const o=e.get(r.id);o&&(r.text=o)}return r})}function yu(n){const e=As(n);if(e.length===0)return"empty drawing";const t=new Map,r=[];for(const i of e){const a=String(i?.type??"unknown");if(a==="text"){const l=String(i?.text??"").trim();if(l&&r.push(l),i?.containerId)continue}t.set(a,(t.get(a)??0)+1)}const o=[...t.entries()].sort((i,a)=>a[1]-i[1]||i[0].localeCompare(a[0])).map(([i,a])=>`${a} ${i}${a>1?"s":""}`).join(", "),s=r.slice(0,3).join(", ");return s?`${o}: ${s}`:o}function wu(n){return{...n,version:Number(n?.version??1)+1,versionNonce:Math.floor(Math.random()*2**31),updated:Date.now()}}const Ai=4;function mm(n,e){let t=null,r;if(n.getEditorState().read(()=>{const o=Q(e);o&&(r=o.getType?.(),r==="excalidraw"&&(t=o))}),!t)throw new Error(r?`Block '${e}' is a '${r}', not a drawing. Call excalidrawListDrawings to find the drawings in this document.`:`No block '${e}' in this document. Call excalidrawListDrawings to find the drawings in this document.`);return t}function kn(n,e){const t=mm(n,e);let r="";return n.getEditorState().read(()=>{r=t.__data??""}),mu(r)}function Br(n,e,t){const r=bu(t);return new Promise(o=>{n.update(()=>{const s=Q(e);s?.setData&&s.setData(r)},{onUpdate:()=>o()})})}const gn=(n,e,t)=>({success:!0,blockId:n,elementCount:As(e).length,...t});let ON=0;const AN=()=>`dla-${Date.now().toString(36)}-${(ON+=1).toString(36)}`;function RN(n,e){const{label:t,startId:r,endId:o,fontSize:s,text:i,children:a,name:l,...c}=n,u={...c,id:e};return n.type==="text"?(u.text=i??t??"",s&&(u.fontSize=s)):t&&(u.label=s?{text:t,fontSize:s}:{text:t}),(n.type==="arrow"||n.type==="line")&&(r&&(u.start={id:r}),o&&(u.end={id:o})),(n.type==="frame"||n.type==="magicframe")&&(u.children=a??[],l&&(u.name=l)),u}async function xu(n,e){const{convertToExcalidrawElements:t}=await me(async()=>{const{convertToExcalidrawElements:i}=await import("./percentages-BXMCSKIN-DRR-eJCX.js").then(a=>a.i);return{convertToExcalidrawElements:i}},[],import.meta.url),r=[],o=n.map(i=>{let a=String(i.id??"").trim();return(!a||e.has(a))&&(a=AN()),e.add(a),r.push(a),RN(i,a)});return{elements:[...t(o,{regenerateIds:!1})],ids:r}}const Fl=n=>({x:Number(n.x??0)+Number(n.width??0)/2,y:Number(n.y??0)+Number(n.height??0)/2});function rg(n,e){const t=Fl(n),r=e.x-t.x,o=e.y-t.y;if(r===0&&o===0)return t;const s=Number(n.width??0)/2+Ai,i=Number(n.height??0)/2+Ai,a=Math.min(r===0?1/0:Math.abs(s/r),o===0?1/0:Math.abs(i/o));return{x:t.x+r*a,y:t.y+o*a}}function MN(n,e){const t=Array.isArray(n.boundElements)?[...n.boundElements]:[];return t.some(r=>r?.id===e)||t.push({id:e,type:"arrow"}),wu({...n,boundElements:t})}function bm(n,e,t,r){const o=n.elements.find(c=>c.id===t),s=n.elements.find(c=>c.id===r);if(!o||!s){const c=o?r:t;throw new Error(`No element '${c}' in this drawing. Call excalidrawReadScene to see the element ids it holds.`)}const i=rg(o,Fl(s)),a=rg(s,Fl(o)),l={...e,x:i.x,y:i.y,width:Math.abs(a.x-i.x),height:Math.abs(a.y-i.y),points:[[0,0],[a.x-i.x,a.y-i.y]],startBinding:{elementId:t,focus:0,gap:Ai},endBinding:{elementId:r,focus:0,gap:Ai}};return n.elements=n.elements.map(c=>c.id===t||c.id===r?MN(c,String(e.id)):c),l}const $N=async(n,e)=>{const t=e.elements??[],r=t.length>0?await xu(t,new Set):{elements:[],ids:[]},o={elements:r.elements,appState:{},files:{}},s=await n.insertBlock({block_id:"",block_type:"excalidraw",source:"",metadata:{data:bu(o),width:e.width,height:e.height}},String(e.afterId??"BOTTOM"));if(!s.success||!s.blockId)throw new Error(s.error||"Failed to insert the drawing");return gn(s.blockId,o,{createdIds:r.ids,message:`Drawing inserted with ${r.elements.length} element(s)`})},DN=async n=>{const t=(await n.getBlocks("detailed")).filter(r=>r.block_type==="excalidraw").map(r=>{const o=mu(r.metadata?.data);return{blockId:r.block_id,elementCount:As(o).length,description:yu(o),width:r.metadata?.width,height:r.metadata?.height}});return{drawings:t,count:t.length}},PN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t),o=As(r);return{blockId:t,elementCount:o.length,elements:e.detail==="full"?o:LN(o),appState:r.appState,description:yu(r)}},jN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t),o=new Set(r.elements.map(u=>String(u.id))),s=e.elements??[],i=new Set(s.map(u=>String(u.id??"")).filter(Boolean)),a=new Map,l=s.map((u,f)=>{const{startId:d,endId:p}=u;if((u.type==="arrow"||u.type==="line")&&d&&p&&(!i.has(String(d))||!i.has(String(p)))){a.set(f,{fromId:String(d),toId:String(p)});const{startId:_,endId:m,...y}=u;return y}return u}),c=await xu(l,o);r.elements=[...r.elements,...c.elements];for(const[u,f]of a){const d=c.ids[u],p=r.elements.find(h=>h.id===d);if(p){const h=bm(r,p,f.fromId,f.toId);r.elements=r.elements.map(_=>_.id===d?h:_)}}return await Br(n.editor,t,r),gn(t,r,{createdIds:c.ids,message:`Added ${c.elements.length} element(s)`})},FN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t),o=e.updates??[],s=new Map;for(const l of r.elements)l?.type==="text"&&l?.containerId&&s.set(String(l.containerId),String(l.id));const i=new Map,a=[];for(const l of o){const c=String(l.id),u=r.elements.find(_=>_.id===c);if(!u){a.push(c);continue}const{id:f,text:d,...p}=l,h=u.type!=="text"&&s.get(c);d!==void 0&&(h?i.set(h,{...i.get(h)??{},text:d,originalText:d}):(p.text=d,p.originalText=d)),Object.keys(p).length>0&&i.set(c,{...i.get(c)??{},...p})}if(a.length>0)throw new Error(`No element(s) ${a.map(l=>`'${l}'`).join(", ")} in this drawing. Call excalidrawReadScene to see the element ids it holds.`);return r.elements=r.elements.map(l=>{const c=i.get(String(l.id));return c?wu({...l,...c}):l}),await Br(n.editor,t,r),gn(t,r,{message:`Updated ${o.length} element(s)`})},BN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t),o=new Set(e.elementIds.map(String)),s=new Set(o);for(const a of r.elements)a?.containerId&&o.has(String(a.containerId))&&s.add(String(a.id));const i=r.elements.length;return r.elements=r.elements.filter(a=>!s.has(String(a.id))).map(a=>{const l={};if(s.has(String(a.startBinding?.elementId))&&(l.startBinding=null),s.has(String(a.endBinding?.elementId))&&(l.endBinding=null),Array.isArray(a.boundElements)){const c=a.boundElements.filter(u=>!s.has(String(u?.id)));c.length!==a.boundElements.length&&(l.boundElements=c)}return Object.keys(l).length>0?wu({...a,...l}):a}),await Br(n.editor,t,r),gn(t,r,{message:`Removed ${i-r.elements.length} element(s)`})},UN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t),o=String(e.fromId),s=String(e.toId),i=new Set(r.elements.map(d=>String(d.id))),{elements:a,ids:l}=await xu([{type:"arrow",x:0,y:0,...e.label?{label:e.label}:{},...e.strokeColor?{strokeColor:e.strokeColor}:{},...e.strokeStyle?{strokeStyle:e.strokeStyle}:{}}],i),c=l[0];r.elements=[...r.elements,...a];const u=r.elements.find(d=>d.id===c),f=bm(r,u,o,s);return r.elements=r.elements.map(d=>d.id===c?f:d),await Br(n.editor,t,r),gn(t,r,{createdIds:[c],message:`Connected '${o}' to '${s}'`})},zN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t);return e.viewBackgroundColor!==void 0&&(r.appState.viewBackgroundColor=e.viewBackgroundColor),e.gridSize!==void 0&&(r.appState.gridSize=Number(e.gridSize)||null),await Br(n.editor,t,r),gn(t,r,{message:"Canvas updated"})},KN=async(n,e)=>{const t=String(e.blockId),r=mm(n.editor,t),o=e.width===void 0?"inherit":Number(e.width),s=e.height===void 0?"inherit":Number(e.height);await new Promise(a=>{n.editor.update(()=>{r.setWidth(o),r.setHeight(s)},{onUpdate:()=>a()})});const i=kn(n.editor,t);return gn(t,i,{message:o==="inherit"&&s==="inherit"?"Drawing sized to its content":`Drawing sized to ${o} x ${s}`})},WN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t),o=As(r).length;return r.elements=[],r.files={},await Br(n.editor,t,r),gn(t,r,{message:`Emptied the drawing (${o} element(s) removed)`})},JN=async(n,e)=>{const{parseMermaidToExcalidraw:t}=await me(async()=>{const{parseMermaidToExcalidraw:c}=await import("./index-BxqT3iXs.js").then(u=>u.an);return{parseMermaidToExcalidraw:c}},[],import.meta.url),{convertToExcalidrawElements:r}=await me(async()=>{const{convertToExcalidrawElements:c}=await import("./percentages-BXMCSKIN-DRR-eJCX.js").then(u=>u.i);return{convertToExcalidrawElements:c}},[],import.meta.url);let o;try{o=await t(String(e.mermaid),{fontSize:e.fontSize?Number(e.fontSize):void 0})}catch(c){const u=c instanceof Error?c.message:String(c);throw new Error(`That Mermaid source did not parse: ${u}. Flowcharts, sequence diagrams and class diagrams are the ones that convert to shapes.`,{cause:c})}const s=[...r(o.elements)],i=o.files??{};if(e.blockId){const c=String(e.blockId),u=kn(n.editor,c);return u.elements=s,u.files=i,await Br(n.editor,c,u),gn(c,u,{createdIds:s.map(f=>String(f.id)),message:`Drawing replaced with ${s.length} element(s) from Mermaid`})}const a={elements:s,appState:{},files:i},l=await n.insertBlock({block_id:"",block_type:"excalidraw",source:"",metadata:{data:bu(a)}},String(e.afterId??"BOTTOM"));if(!l.success||!l.blockId)throw new Error(l.error||"Failed to insert the drawing");return gn(l.blockId,a,{createdIds:s.map(c=>String(c.id)),message:`Drawing inserted with ${s.length} element(s) from Mermaid`})},Bl={excalidrawInsertNode:$N,excalidrawListDrawings:DN,excalidrawReadScene:PN,excalidrawAddElements:jN,excalidrawUpdateElements:FN,excalidrawDeleteElements:BN,excalidrawConnectElements:UN,excalidrawSetAppState:zN,excalidrawResize:KN,excalidrawClearScene:WN,excalidrawFromMermaid:JN};function Qt(n,e){return{name:n,async execute(t,r){const o=xy(e,t??{},n);if(!r.documentId)throw new Error(`Document ID is required for ${n}. Ensure the tool execution context includes a valid documentId.`);if(!r.executor)throw new Error(`Executor is required for ${n}. This should be provided by the platform (DefaultExecutor, BridgeExecutor, etc.)`);try{return await r.executor.execute(n,o)}catch(s){const i=s instanceof Error?s.message:String(s);throw new Error(`Failed to run ${n}: ${i}`,{cause:s})}}}}const HN=Qt("excalidrawInsertNode",sm),qN=Qt("excalidrawListDrawings",im),VN=Qt("excalidrawReadScene",am),YN=Qt("excalidrawAddElements",lm),GN=Qt("excalidrawUpdateElements",cm),XN=Qt("excalidrawDeleteElements",um),ZN=Qt("excalidrawConnectElements",dm),QN=Qt("excalidrawSetAppState",fm),e2=Qt("excalidrawResize",gm),t2=Qt("excalidrawClearScene",pm),n2=Qt("excalidrawFromMermaid",hm),ci={excalidrawInsertNode:HN,excalidrawListDrawings:qN,excalidrawReadScene:VN,excalidrawAddElements:YN,excalidrawUpdateElements:GN,excalidrawDeleteElements:XN,excalidrawConnectElements:ZN,excalidrawSetAppState:QN,excalidrawResize:e2,excalidrawClearScene:t2,excalidrawFromMermaid:n2},og={name:"excalidraw",definitions:_m,operations:ci,handlers:Bl};function HA(){const n=[];for(const e of _m)ci[e.operation]||n.push(`${e.name} points at operation '${e.operation}', which does not exist`),e.toolReferenceName.startsWith("excalidraw")||n.push(`${e.name} is not named for the plugin it belongs to`);for(const e of Object.keys(ci))Bl[e]||n.push(`operation '${e}' has no handler`);for(const e of Object.keys(Bl))ci[e]||n.push(`handler '${e}' has no operation`);return n}const r2=C.lazy(()=>me(()=>import("./ExcalidrawModal-CLGo6lxD.js"),[],import.meta.url)),Cu=he();function o2(){const[n]=fe(),[e,t]=C.useState(!1),o=Ex()?.lexicalId;C.useEffect(()=>{if(!n.hasNodes([Un]))throw new Error("ExcalidrawPlugin: ExcalidrawNode not registered");return n.registerCommand(Cu,()=>(t(!0),!0),V)},[n]),C.useEffect(()=>{if(o)return Zr.getState().registerPluginTools(o,og),()=>{Zr.getState().unregisterPluginTools(o,og.name)}},[o]);const s=(l,c,u)=>{n.update(()=>{const f=ou();f.setData(JSON.stringify({elements:l,appState:c,files:u})),pr([f]),yt(f.getParentOrThrow())&&sc(f,ne).selectEnd()}),t(!1)},i=()=>{t(!1)},a=()=>{t(!1)};return e?w.jsx(C.Suspense,{fallback:null,children:w.jsx(r2,{initialElements:[],initialAppState:{},initialFiles:{},isShown:e,onSave:s,onDelete:i,onClose:a,closeOnClickOutside:!1})}):null}const s2=C.lazy(()=>me(()=>import("./DeckComponent-CSxElvrq.js"),[],import.meta.url));function i2(){return{deck:{title:"Untitled deck",template:"datalayer"},slides:[{type:"title",title:"A new slide",meta:"Double-click to edit its specification"}]}}function a2(n){const e=n.getAttribute("data-lexical-deck");if(!e)return null;try{return{node:Su(JSON.parse(e))}}catch{return null}}class Do extends Oo{__spec;static getType(){return"deck"}static clone(e){return new Do(e.__spec,e.__format,e.__key)}static importJSON(e){const t=Su(e.spec);return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"deck",version:1,spec:this.__spec}}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-deck")?{conversion:a2,priority:2}:null}}exportDOM(){const e=document.createElement("div");e.setAttribute("data-lexical-deck",JSON.stringify(this.__spec));const t=document.createElement("p");return t.textContent=this.__spec.deck?.title||"Deck",e.appendChild(t),{element:e}}constructor(e,t,r){super(t,r),this.__spec=e??i2()}getSpec(){return this.getLatest().__spec}setSpec(e){this.getWritable().__spec=e}getTextContent(){return this.__spec.deck?.title||""}updateDOM(){return!1}decorate(e,t){const r=t.theme.embedBlock||{};return w.jsx(C.Suspense,{fallback:null,children:w.jsx(s2,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),spec:this.__spec})})}isTopLevel(){return!0}}function Su(n){return new Do(n)}function qA(n){return n instanceof Do}const vu=he("INSERT_DECK_COMMAND");function l2(n){if(!n.hasNodes([Do]))throw new Error("DeckExtension: DeckNode not registered on editor");return n.registerCommand(vu,e=>(Yn(Su(e)),!0),V)}const c2=pe({name:"@datalayer/jupyter-lexical/Deck",nodes:()=>[Do],register:l2}),sg="Kept in this page’s memory only: it is lost when the page reloads, and nobody else sees it. Download it to keep it.",ym={position:"relative",width:"100%",aspectRatio:"16 / 9",borderRadius:2,overflow:"hidden",bg:"black"};function u2(n){const e=Math.max(0,Math.floor(n/1e3));return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}function d2(n){const e=n.currentTarget;if(Number.isFinite(e.duration))return;const t=()=>{e.removeEventListener("timeupdate",t),e.currentTime=0};e.addEventListener("timeupdate",t),e.currentTime=Number.MAX_SAFE_INTEGER}function f2({recordingId:n,recording:e}){const t=C.useRef(null),[r,o]=C.useState(()=>Date.now());return C.useEffect(()=>{t.current&&(t.current.srcObject=e.preview)},[e.preview]),C.useEffect(()=>{const s=window.setInterval(()=>o(Date.now()),500);return()=>window.clearInterval(s)},[]),w.jsxs(Y,{sx:{display:"grid",gap:2},children:[w.jsx(Y,{sx:ym,children:w.jsx("video",{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"100%",objectFit:"contain"}})}),w.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[w.jsx(Y,{"aria-hidden":!0,sx:{width:10,height:10,borderRadius:"50%",bg:"danger.fg"}}),w.jsx(Le,{sx:{fontFamily:"mono"},"aria-live":"off",children:u2(r-e.startedAt)}),w.jsx(ft,{variant:"danger",leadingVisual:Sy,onClick:()=>pu(n),sx:{ml:"auto"},children:"Stop"})]})]})}function g2({className:n,format:e,nodeKey:t,recordingId:r,recorded:o}){const[s]=fe(),i=Or(),a=C.useSyncExternalStore(NE,()=>LE(r)),l=FE(o,a),[c,u]=C.useState("screen"),[f,d]=C.useState(!0),p=C.useCallback(x=>{s.update(()=>{const S=Q(t);wm(S)&&S.setRecorded(x)})},[s,t]),h=()=>{PE(r,{source:c,microphone:f},()=>p(!0))},_=()=>{jE(r),p(!1)},m=x=>{const S=document.createElement("a");S.href=x.url,S.download=ME(x),S.click()};let y;return a?.status==="recording"?y=w.jsx(f2,{recordingId:r,recording:a}):a?.status==="recorded"?y=w.jsxs(Y,{sx:{display:"grid",gap:2},children:[w.jsx(Y,{sx:ym,children:w.jsx("video",{src:a.url,controls:!0,playsInline:!0,onLoadedMetadata:d2,style:{width:"100%",height:"100%",objectFit:"contain"}})}),w.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:2},children:[w.jsx(Le,{sx:{color:"fg.muted",fontSize:0,flex:"1 1 240px"},children:sg}),w.jsx(ft,{leadingVisual:Cy,onClick:()=>m(a),children:"Download"}),i&&w.jsx(ft,{onClick:_,children:"Record again"})]})]}):l==="lost"?y=w.jsxs(Y,{sx:{display:"grid",gap:2,justifyItems:"start"},children:[w.jsx(Le,{sx:{color:"fg.muted",fontSize:1},children:"The video recorded here is gone: it was kept in the memory of the page that recorded it, and that page has been reloaded or closed."}),i&&w.jsx(ft,{onClick:()=>p(!1),children:"Record a new one"})]}):i?y=w.jsxs(Y,{sx:{display:"grid",gap:2},children:[w.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[w.jsx(uc,{size:16}),w.jsx(Le,{sx:{fontWeight:"bold"},children:"Video"})]}),w.jsxs(Le,{sx:{color:"fg.muted",fontSize:0},children:["Recorded by this browser, with no account. ",sg]}),AE()?w.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:3},children:[w.jsxs(oa,{"aria-label":"What to record",size:"small",children:[w.jsx(oa.Button,{selected:c==="screen",onClick:()=>u("screen"),children:"Screen"}),w.jsx(oa.Button,{selected:c==="camera",onClick:()=>u("camera"),children:"Camera"})]}),w.jsxs(At,{children:[w.jsx(jg,{checked:f,onChange:x=>d(x.target.checked)}),w.jsx(At.Label,{children:"Microphone"})]}),w.jsx(ft,{variant:"primary",onClick:h,children:"Record"})]}):w.jsx(Le,{sx:{color:"danger.fg",fontSize:1},children:"This browser cannot record video."}),a?.status==="failed"&&w.jsx(Le,{role:"alert",sx:{color:"danger.fg",fontSize:1},children:a.message})]}):y=w.jsx(Le,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:"A video goes here."}),w.jsx(gs,{className:n,format:e,nodeKey:t,children:w.jsx(Y,{"data-lexical-video":l,onFocusCapture:()=>s.update(()=>Ee(null)),sx:{p:l==="recorded"||l==="recording"?0:3,border:"1px dashed",borderColor:l==="recorded"||l==="recording"?"transparent":"border.default",borderRadius:2,bg:l==="recorded"||l==="recording"?"transparent":"canvas.subtle"},children:y})})}class Wn extends Oo{__recordingId;__recorded;static getType(){return"video"}static clone(e){return new Wn(e.__recordingId,e.__recorded,e.__format,e.__key)}static importJSON(e){const t=new Wn(e.recordingId,e.recorded);return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"video",version:1,recordingId:this.__recordingId,recorded:this.__recorded}}exportDOM(){return{element:null}}constructor(e,t=!1,r,o){super(r,o),this.__recordingId=e||OE(),this.__recorded=t}getRecordingId(){return this.getLatest().__recordingId}isRecorded(){return this.getLatest().__recorded}setRecorded(e){this.getWritable().__recorded=e}getTextContent(){return""}updateDOM(){return!1}decorate(e,t){const r=t.theme.embedBlock||{};return w.jsx(g2,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),recordingId:this.__recordingId,recorded:this.__recorded})}isTopLevel(){return!0}}function p2(){return new Wn}function wm(n){return n instanceof Wn}const ku=he("INSERT_VIDEO_COMMAND");function h2(n){if(!n.hasNodes([Wn]))throw new Error("VideoExtension: VideoNode not registered on editor");return de(n.registerCommand(ku,()=>(Yn(p2()),!0),V),n.registerMutationListener(Wn,(e,{prevEditorState:t})=>{for(const[r,o]of e){if(o!=="destroyed")continue;const s=t.read(()=>{const i=Q(r);return wm(i)?i.__recordingId:void 0});s&&pu(s)}},{skipInitialization:!0}))}const _2=pe({name:"@datalayer/jupyter-lexical/Video",nodes:()=>[Wn],register:h2});function m2({onConfirm:n,onClose:e}){const[t,r]=C.useState("5"),[o,s]=C.useState("5"),i=C.useRef(null),a=()=>{const c=parseInt(t,10),u=parseInt(o,10);c>0&&c<=500&&u>0&&u<=50&&n(c,u)},l=c=>{c.key==="Enter"&&a()};return w.jsx(Fg,{title:"Insert Table",onClose:()=>e(),width:"small",height:"auto",initialFocusRef:i,footerButtons:[{buttonType:"default",content:"Cancel",onClick:e},{buttonType:"primary",content:"Confirm",onClick:a}],children:w.jsxs(Y,{sx:{display:"flex",flexDirection:"column",gap:3},onKeyDown:l,children:[w.jsxs(At,{children:[w.jsx(At.Label,{children:"Rows"}),w.jsx(yn,{ref:i,type:"number",min:1,max:500,value:t,onChange:c=>r(c.target.value),block:!0})]}),w.jsxs(At,{children:[w.jsx(At.Label,{children:"Columns"}),w.jsx(yn,{type:"number",min:1,max:50,value:o,onChange:c=>s(c.target.value),block:!0})]})]})})}const rs=he();function xm(){const[n]=fe(),[e,t]=C.useState(!1);C.useEffect(()=>n.registerCommand(rs,()=>(t(!0),!0),V),[n]);const r=(s,i)=>{n.dispatchCommand(Cc,{rows:s.toString(),columns:i.toString()}),t(!1)},o=()=>{t(!1)};return e?w.jsx(m2,{onConfirm:r,onClose:o}):null}function VA(){return w.jsxs(w.Fragment,{children:[w.jsx(Uh,{}),w.jsx(xm,{})]})}const Iu=he("INSERT_EQUATION_COMMAND");function Cm(n){if(!n.hasNodes([Gn]))throw new Error("EquationsPlugins: EquationsNode not registered on editor");return n.registerCommand(Iu,e=>{const{equation:t,inline:r}=e,o=Yi(t,r);return pr([o]),yt(o.getParentOrThrow())&&sc(o,ne).selectEnd(),!0},V)}const Sm=pe({name:"@datalayer/jupyter-lexical/Equations",nodes:()=>[Gn],register:Cm});function Tu({activeEditor:n,onClose:e}){const t=C.useCallback((r,o)=>{n.dispatchCommand(Iu,{equation:r,inline:o}),e()},[n,e]);return w.jsx(zw,{onConfirm:t})}const ig=()=>{const[n]=fe();return C.useEffect(()=>Cm(n),[n]),null},b2=Object.freeze(Object.defineProperty({__proto__:null,EquationsPlugin:ig,INSERT_EQUATION_COMMAND:Iu,InsertEquationDialog:Tu,default:ig},Symbol.toStringTag,{value:"Module"}));class Ke extends V_{title;icon;keywords;keyboardShortcut;onSelect;disabled;constructor(e,t){super(e),this.title=e,this.keywords=t.keywords||[],this.icon=t.icon,this.keyboardShortcut=t.keyboardShortcut,this.onSelect=t.onSelect.bind(this),this.disabled=t.disabled||!1}}function y2({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){const s=C.useCallback(l=>o.setRefElement(l),[o]),i=o.disabled?void 0:t,a=o.disabled?void 0:r;return w.jsxs(Y,{as:"li",tabIndex:-1,ref:s,role:"option","aria-selected":e&&!o.disabled,"aria-disabled":o.disabled,id:"typeahead-item-"+n,onMouseEnter:a,onClick:i,sx:{display:"flex",alignItems:"center",gap:2,px:2,py:"6px",borderRadius:2,cursor:o.disabled?"not-allowed":"pointer",opacity:o.disabled?.5:1,bg:e&&!o.disabled?"actionListItem.default.selectedBg":"transparent",color:"var(--fgColor-default)","&:hover":o.disabled?{}:{bg:"actionListItem.default.hoverBg"},listStyle:"none"},children:[w.jsx(Y,{sx:{display:"flex",alignItems:"center",color:"var(--fgColor-muted)",flexShrink:0},children:o.icon}),w.jsx(Le,{sx:{fontSize:1},children:o.title})]},o.key)}const w2=({kernel:n,initCode:e=""}={})=>{const[t]=fe(),[r,o]=$o(),[s,i]=C.useState(null),a=Y_("/",{minLength:0}),l=C.useCallback(()=>{const f=[];if(s==null)return f;const d=new RegExp(/^([1-9]|10)x([1-9]|10)$/),p=new RegExp(/^([1-9]|10)x?$/),h=d.exec(s),_=p.exec(s);if(h){const[m,y]=h[0].split("x").map(x=>parseInt(x,10));f.push(new Ke(`${m}x${y} Table`,{icon:w.jsx(ei,{size:16}),keywords:["table"],onSelect:()=>t.dispatchCommand(rs,void 0)}))}else if(_){const m=parseInt(_[0],10);f.push(...Array.from({length:5},(y,x)=>x+1).map(y=>new Ke(`${m}x${y} Table`,{icon:w.jsx(ei,{size:16}),keywords:["table"],onSelect:()=>t.dispatchCommand(rs,void 0)})))}return f},[t,s]),c=C.useMemo(()=>{const f=[new Ke("Jupyter Cell",{icon:w.jsx(ir,{size:16}),keywords:["javascript","python","js","codeblock","jupyter"],onSelect:()=>{t.dispatchCommand(Ei,{code:e,outputs:Nl,loading:"Loading..."})}}),new Ke("Marimo Cell",{icon:w.jsx(ir,{size:16}),keywords:["marimo","reactive","python","cell"],onSelect:()=>{t.dispatchCommand(Ei,{code:e,outputs:Nl,loading:"Loading...",variant:"marimo"})}}),new Ke("Paragraph",{icon:w.jsx($p,{size:16}),keywords:["normal","paragraph","p","text"],onSelect:()=>t.update(()=>{const p=P();j(p)&&Rn(p,()=>ne())})}),...Array.from({length:3},(p,h)=>h+1).map(p=>new Ke(`Heading ${p}`,{icon:w.jsx(Xy,{size:16}),keywords:["heading","header",`h${p}`],onSelect:()=>t.update(()=>{const h=P();j(h)&&Rn(h,()=>cn(`h${p}`))})})),new Ke("Numbered List",{icon:w.jsx(Dp,{size:16}),keywords:["numbered list","ordered list","ol"],onSelect:()=>t.dispatchCommand(wc,void 0)}),new Ke("Bulleted List",{icon:w.jsx(Ep,{size:16}),keywords:["bulleted list","unordered list","ul"],onSelect:()=>t.dispatchCommand(yc,void 0)}),new Ke("Check List",{icon:w.jsx(vy,{size:16}),keywords:["check list","todo list"],onSelect:()=>t.dispatchCommand(bc,void 0)}),new Ke("Table",{icon:w.jsx(ei,{size:16}),keywords:["table","grid","spreadsheet"],onSelect:()=>{ge("[ComponentPicker] Table selected, dispatching INSERT_TABLE_WITH_DIALOG_COMMAND"),t.dispatchCommand(rs,void 0)}}),new Ke("Collapsible Container",{icon:w.jsx(lc,{size:16}),keywords:["collapsible","collapse","expand","toggle","accordion","container"],onSelect:()=>t.dispatchCommand(_u,void 0)}),new Ke("Excalidraw",{icon:w.jsx(ky,{size:16}),keywords:["excalidraw","drawing","diagram","sketch","whiteboard","draw"],onSelect:()=>t.dispatchCommand(Cu,void 0)}),new Ke("Video",{icon:w.jsx(uc,{size:16}),keywords:["video","record","recording","screen","camera","webcam"],onSelect:()=>t.dispatchCommand(ku,void 0)}),new Ke("Loom Video",{icon:w.jsx(ks,{size:16}),keywords:["loom","video","record","recording","screen"],onSelect:()=>t.dispatchCommand(ta,void 0)}),new Ke("Deck Slide",{icon:w.jsx(Zo,{size:16}),keywords:["deck","slide","slides","presentation","pitch"],onSelect:()=>t.dispatchCommand(vu,void 0)}),new Ke("Quote",{icon:w.jsx(Pp,{size:16}),keywords:["block quote"],onSelect:()=>t.update(()=>{const p=P();j(p)&&Rn(p,()=>Sn())})}),new Ke("Code",{icon:w.jsx(ir,{size:16}),keywords:["javascript","python","js","codeblock"],onSelect:()=>t.update(()=>{const p=P();if(j(p))if(p.isCollapsed())Rn(p,()=>Ze());else{const h=p.getTextContent(),_=Ze();p.insertNodes([_]),p.insertRawText(h)}})}),new Ke("Divider",{icon:w.jsx(bi,{size:16}),keywords:["horizontal rule","divider","hr"],onSelect:()=>t.dispatchCommand(cc,void 0)}),...gu.map(p=>new Ke(`Embed ${p.contentName}`,{icon:p.icon,keywords:[...p.keywords,"embed"],onSelect:()=>t.dispatchCommand(fu,p.type)})),new Ke("Equation",{icon:w.jsx(Iy,{size:16}),keywords:["equation","latex","math"],onSelect:()=>o("Insert Equation",p=>w.jsx(Tu,{activeEditor:t,onClose:p}))}),new Ke("GIF",{icon:w.jsx(Zo,{size:16}),keywords:["gif","animate","image","file"],onSelect:()=>{Fc().then(p=>{p&&t.dispatchCommand(Ls,p)})}}),new Ke("Image",{icon:w.jsx(Zo,{size:16}),keywords:["image","photo","picture","file"],onSelect:()=>o("Insert Image",p=>w.jsx(Hh,{activeEditor:t,onClose:p}))}),...["left","center","right","justify"].map(p=>new Ke(`Align ${p}`,{icon:p==="left"?w.jsx(Zy,{size:16}):p==="right"?w.jsx(Qy,{size:16}):w.jsx(bi,{size:16}),keywords:["align","justify",p],onSelect:()=>t.dispatchCommand(An,p)}))],d=l();return s?[...d,...f.filter(p=>new RegExp(s,"gi").exec(p.title)||p.keywords!=null?p.keywords.some(h=>new RegExp(s,"gi").exec(h)):!1)]:f},[t,l,s,o,n,e]),u=C.useCallback((f,d,p,h)=>{f.disabled||t.update(()=>{d&&d.remove(),f.onSelect(h),p()})},[t]);return w.jsxs(w.Fragment,{children:[r,w.jsx(G_,{onQueryChange:i,onSelectOption:u,triggerFn:a,options:c,menuRenderFn:(f,{selectedIndex:d,selectOptionAndCleanUp:p,setHighlightedIndex:h})=>f.current&&c.length?Tt.createPortal(w.jsx(Y,{onMouseDown:_=>{_.preventDefault()},sx:{position:"relative",zIndex:1e3,bg:"var(--overlay-bgColor)",border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,boxShadow:"var(--shadow-floating-large, 0 0 0 1px #d1d9e0, 0 40px 80px 0 #25292e3d)",p:1,maxHeight:300,overflow:"auto",minWidth:200},children:w.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0},children:c.map((_,m)=>w.jsx(y2,{index:m,isSelected:d===m,onClick:()=>{_.disabled||(h(m),p(_))},onMouseEnter:()=>{_.disabled||h(m)},option:_},_.key))})}),f.current):null})]})},Ul=4,x2=2,C2="draggable-block-menu",ag="application/x-lexical-drag-block",lg=28,S2=1,v2=-1,cg=0;let ui=1/0;function k2(n){return n===0?1/0:ui>=0&&ui<n?ui:Math.floor(n/2)}function I2(n){return n.getEditorState().read(()=>se().getChildrenKeys())}function vm(n){const e=(l,c)=>l?parseFloat(window.getComputedStyle(l)[c]):0,{marginTop:t,marginBottom:r}=window.getComputedStyle(n),o=e(n.previousElementSibling,"marginBottom"),s=e(n.nextElementSibling,"marginTop"),i=Math.max(parseFloat(t),o);return{marginBottom:Math.max(parseFloat(r),s),marginTop:i}}function Ua(n,e,t,r=!1){const o=n.getBoundingClientRect(),s=I2(e);let i=null;return e.getEditorState().read(()=>{if(r){const[c,u]=[e.getElementByKey(s[0]),e.getElementByKey(s[s.length-1])],[f,d]=[c?.getBoundingClientRect(),u?.getBoundingClientRect()];if(f&&d){const p=Dn(c),h=Dn(u);if(t.y/p<f.top?i=c:t.y/h>d.bottom&&(i=u),i)return}}let a=k2(s.length),l=cg;for(;a>=0&&a<s.length;){const c=s[a],u=e.getElementByKey(c);if(u===null)break;const f=Dn(u),d=new H_(t.x/f,t.y/f),p=nr.fromDOM(u),{marginTop:h,marginBottom:_}=vm(u),m=p.generateNewRect({bottom:p.bottom+_,left:o.left,right:o.right,top:p.top-h}),{result:y,reason:{isOnTopSide:x,isOnBottomSide:S}}=m.contains(d);if(y){i=u,ui=a;break}l===cg&&(x?l=v2:S?l=S2:l=1/0),a+=l}}),i}function T2(n){return!!n.closest(`.${C2}`)}function km(n){const e=window.getComputedStyle(n),t=e.overflowY==="auto"||e.overflowY==="scroll",r=e.overflowX==="auto"||e.overflowX==="scroll";if(t||r)return{element:n,scrollTop:n.scrollTop||0,scrollLeft:n.scrollLeft||0};const o=n.parentElement;if(o){const s=window.getComputedStyle(o),i=s.overflowY==="auto"||s.overflowY==="scroll",a=s.overflowX==="auto"||s.overflowX==="scroll";if(i||a)return{element:o,scrollTop:o.scrollTop||0,scrollLeft:o.scrollLeft||0}}return{element:n,scrollTop:0,scrollLeft:0}}function E2(n,e,t){if(!n){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}const r=n.getBoundingClientRect(),o=window.getComputedStyle(n),s=e.getBoundingClientRect(),i=t.getBoundingClientRect(),{scrollTop:a}=km(t),c=(parseInt(o.lineHeight,10)-s.height)/2,u=r.top+c-i.top+a,f=Ul;e.style.opacity="1",e.style.transform=`translate(${f}px, ${u}px)`}function N2(n,e){const{transform:t}=e.style;e.style.transform="translateZ(0)",n.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=t})}function L2(n,e,t,r){const{top:o,height:s}=e.getBoundingClientRect(),{top:i,width:a}=r.getBoundingClientRect(),{marginTop:l,marginBottom:c}=vm(e),{scrollTop:u}=km(r);let f=o;t>=o?f+=s+c/2:f-=l/2;const d=f-i-x2+u,p=lg-Ul;n.style.transform=`translate(${p}px, ${d}px)`,n.style.width=`${a-(lg-Ul)*2}px`,n.style.opacity=".4"}function O2(n){n&&(n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)")}function A2(n,e,t){const r=C.useRef(null),o=C.useRef(null),s=C.useRef(!1),[i,a]=C.useState(null),l=n._config.theme,c=l.draggableBlockMenu||"",u=l.draggableBlockTargetLine||"";C.useEffect(()=>{function p(_){const m=_.target;if(!Fa(m)){a(null);return}if(!e.contains(m)||T2(m))return;const y=Ua(e,n,_);a(y)}function h(){a(null)}return document.addEventListener("mousemove",p),document.addEventListener("mouseleave",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseleave",h)}},[e,n]),C.useEffect(()=>{r.current&&E2(i,r.current,e)},[e,i]),C.useEffect(()=>{function p(_){if(!s.current)return!1;const[m]=Gr(_);if(m)return!1;const{pageY:y,target:x}=_;if(!Fa(x))return!1;const S=Ua(e,n,_,!0),v=o.current;return S===null||v===null?!1:(L2(v,S,y/Dn(x),e),_.preventDefault(),!0)}function h(_){if(!s.current)return!1;const[m]=Gr(_);if(m)return!1;const{target:y,dataTransfer:x,pageY:S}=_,v=x?.getData(ag)||"",I=Q(v);if(!I||!Fa(y))return!1;const E=Ua(e,n,_,!0);if(!E)return!1;const T=Me(E);if(!T)return!1;if(T===I)return!0;const N=E.getBoundingClientRect().top;return S/Dn(y)>=N?T.insertAfter(I):T.insertBefore(I),a(null),!0}return de(n.registerCommand(Yl,_=>p(_),ee),n.registerCommand(Gl,_=>h(_),qe))},[e,n]);function f(p){const h=p.dataTransfer;if(!h||!i)return;N2(h,i);let _="";n.update(()=>{const m=Me(i);m&&(_=m.getKey())}),s.current=!0,h.setData(ag,_)}function d(){s.current=!1,O2(o.current)}return Tt.createPortal(w.jsxs(w.Fragment,{children:[w.jsx("div",{className:`draggable-block-menu ${c}`,ref:r,draggable:!0,onDragStart:f,onDragEnd:d,children:t?w.jsx(Ty,{size:16}):null}),w.jsx("div",{className:`draggable-block-target-line ${u}`,ref:o})]}),e)}function YA({anchorElem:n=document.body}){const[e]=fe();return A2(e,n,e._editable)}const R2=()=>w.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:[w.jsx("path",{d:"M4.5 2v5.5a3.5 3.5 0 1 0 7 0V2H13v5.5a5 5 0 0 1-10 0V2h1.5Z"}),w.jsx("rect",{x:"2",y:"14",width:"12",height:"1.5",rx:".75"})]});function M2(n,e,t,r){const[o,s]=C.useState(!1),[i,a]=C.useState(!1),[l,c]=C.useState(!1),[u,f]=C.useState(!1),[d,p]=C.useState(!1),[h,_]=C.useState(!1),[m,y]=C.useState(!1),[x,S]=C.useState(!1),[v,I]=C.useState(!1),E=C.useCallback(()=>{n.getEditorState().read(()=>{if(n.isComposing())return;const M=P(),A=window.getSelection(),$=n.getRootElement();if(A!==null&&(!j(M)||$===null||!$.contains(A.anchorNode))){s(!1);return}if(!j(M))return;const L=W_(M);c(M.hasFormat("bold")),f(M.hasFormat("italic")),p(M.hasFormat("underline")),_(M.hasFormat("strikethrough")),y(M.hasFormat("subscript")),S(M.hasFormat("superscript")),I(M.hasFormat("code"));const R=L.getParent();Pe(R)||Pe(L)?a(!0):a(!1),!Ve(M.anchor.getNode())&&M.getTextContent()!==""?s(oe(L)):s(!1)})},[n]);C.useEffect(()=>(document.addEventListener("selectionchange",E),()=>{document.removeEventListener("selectionchange",E)}),[E]),C.useEffect(()=>de(n.registerUpdateListener(()=>{E()}),n.registerRootListener(()=>{n.getRootElement()===null&&s(!1)}),n.registerCommand(ns,()=>(s(!1),!1),ee)),[n,E]);const T=C.useCallback(()=>{i?(t(!1),n.dispatchCommand(br,null)):(t(!0),n.dispatchCommand(br,"https://example.com"))},[n,i,t]),N=C.useMemo(()=>n.isEditable()?[{key:"bold",type:"button",order:0,ariaLabel:"Format text as bold",title:"Bold",icon:Ap,isActive:l,onClick:()=>n.dispatchCommand(Xe,"bold")},{key:"italic",type:"button",order:1,ariaLabel:"Format text as italics",title:"Italic",icon:Rp,isActive:u,onClick:()=>n.dispatchCommand(Xe,"italic")},{key:"underline",type:"button",order:2,ariaLabel:"Format text to underlined",title:"Underline",icon:R2,isActive:d,onClick:()=>n.dispatchCommand(Xe,"underline")},{key:"strikethrough",type:"button",order:3,ariaLabel:"Format text with a strikethrough",title:"Strikethrough",icon:Mp,isActive:h,onClick:()=>n.dispatchCommand(Xe,"strikethrough")},{key:"subscript",type:"button",order:4,ariaLabel:"Format Subscript",title:"Subscript",icon:void 0,label:"x₂",isActive:m,onClick:()=>n.dispatchCommand(Xe,"subscript")},{key:"superscript",type:"button",order:5,ariaLabel:"Format Superscript",title:"Superscript",icon:void 0,label:"x²",isActive:x,onClick:()=>n.dispatchCommand(Xe,"superscript")},{key:"code",type:"button",order:6,ariaLabel:"Insert code block",title:"Code",icon:ir,isActive:v,onClick:()=>n.dispatchCommand(Xe,"code")},{key:"link",type:"button",order:7,ariaLabel:"Insert link",title:"Link",icon:Np,isActive:i,onClick:T},{key:"comment",type:"button",order:8,ariaLabel:"Insert comment",title:"Comment",icon:mi,onClick:()=>n.dispatchCommand(ns,void 0)}]:[{key:"comment",type:"button",order:100,ariaLabel:"Insert comment",icon:mi,onClick:()=>n.dispatchCommand(ns,void 0)}],[n,l,u,d,h,m,x,v,i,T]),O=o&&!i;return w.jsx(ww,{items:N,extraItems:r,anchorElement:e,isVisible:O,ariaLabel:"Floating text format toolbar"})}function GA({anchorElem:n=document.body,setIsLinkEditMode:e,extraItems:t}){const[r]=fe();return M2(r,n,e,t)}function $2(n){return n.registerCommand(cc,()=>{const e=P();if(!j(e))return!1;if(e.focus.getNode()!==null){const r=Vi();e.insertParagraph(),e.focus.getNode().getTopLevelElementOrThrow().insertBefore(r)}return!0},V)}const Im=pe({name:"@datalayer/jupyter-lexical/HorizontalRule",nodes:()=>[Pc],register:$2}),zo={code:{triggerMode:"auto",contextBefore:-1,contextAfter:-1,language:"python"},prose:{triggerMode:"manual",contextBefore:-1,contextAfter:-1},debounceMs:200,manualTriggerKey:"Cmd+Shift+,"};function D2(n){return n?{code:{...zo.code,...n.code},prose:{...zo.prose,...n.prose},debounceMs:n.debounceMs??zo.debounceMs,manualTriggerKey:n.manualTriggerKey??zo.manualTriggerKey}:{...zo}}function XA(n){return n===-1||n>=0}function ZA(n){return n.triggerMode==="auto"}function QA(n){return n.triggerMode==="manual"||n.triggerMode==="auto"}function eR(n){return n.triggerMode==="disabled"}const ug="jupyter-cell";class Tr extends jt{__code;__outputs;__loading;__autoStart;__data;__variant;static getType(){return ug}static clone(e){return console.debug(`clone: node: ${JSON.stringify(e,null,2)}`),new Tr(e.__code,e.__outputs,e.__loading,e.__autoStart,e.__data,e.__key,e.__variant)}constructor(e,t,r,o,s="[]",i,a){super(i),this.__code=e,this.__outputs=t,this.__loading=r,this.__autoStart=o,this.__data=s,this.__variant=a}createDOM(e){const t=document.createElement("div"),o=e.theme.image;return o!==void 0&&(t.className=o),ge("createDOM",t),t}updateDOM(){return!1}decorate(e){return ge(`decorate -> key: ${this.getKey()} outputs: ${this.__outputs} data: ${this.__data}`),w.jsx(uw,{source:this.__code,outputs:this.__outputs,autoStart:this.__autoStart,variant:this.__variant})}setCode(e){const t=this.getWritable();t.__code=e}get code(){return this.__code}setOutputs(e){const t=this.getWritable();t.__outputs=e}get outputs(){return this.__outputs}setLoading(e){const t=this.getWritable();t.__loading=e}get loading(){return this.__loading}setAutostart(e){const t=this.getWritable();t.__autoStart=e}get autoStart(){return this.__autoStart}get variant(){return this.__variant}setData(e){const t=this.getWritable();t.__data=e}get data(){return this.__data}static importJSON(e){const t=e;return new Tr(t.code,t.outputs,t.loading,t.autoStart,t.data,void 0,t.variant)}exportJSON(){return{code:this.__code,outputs:this.__outputs,loading:this.__loading,autoStart:this.__autoStart,data:this.__data,variant:this.__variant,type:ug,version:1}}}function dg(n){const{code:e,outputs:t,loading:r,autoStart:o}=n;return new Tr(e,t,r,o)}function tR(n){return n instanceof Tr}const P2=he(),j2=he();function F2(n){if(!n.hasNodes([Tr]))throw new Error("JupyterCellNode is not registered.");return de(n.registerCommand(P2,e=>{const t=dg(e);return pr([t]),!0},V),n.registerCommand(j2,e=>{const t=dg({...e});return pr([t]),!0},V))}const B2=pe({name:"@datalayer/jupyter-lexical/JupyterCell",nodes:()=>[Tr],register:F2}),U2=he("INSERT_LAYOUT_COMMAND");function z2(n){return n.trim().split(/\s+/).length}function nR(n){return Array.from({length:Math.max(1,n)},()=>"1fr").join(" ")}function K2(n){if(!n.hasNodes([vr,kr]))throw new Error("LayoutPlugin: LayoutContainerNode, or LayoutItemNode not registered on editor");const e=t=>{const r=P();if(j(r)&&r.isCollapsed()&&r.anchor.offset===0){const o=re(r.anchor.getNode(),ri);if(ri(o)){const s=o.getParent(),i=s&&(t?s.getFirstChild():s.getLastChild()),a=t?o.getFirstDescendant()?.getKey():o.getLastDescendant()?.getKey();s!==null&&i===o&&r.anchor.key===a&&(t?o.insertBefore(ne()):o.insertAfter(ne()))}}return!1};return de(n.registerCommand(Ht,()=>e(!1),ee),n.registerCommand(Di,()=>e(!1),ee),n.registerCommand(pt,()=>e(!0),ee),n.registerCommand(Ss,()=>e(!0),ee),n.registerCommand(U2,t=>(n.update(()=>{const r=Xc(t);for(let o=0;o<z2(t);o++)r.append(Zc().append(ne()));Yn(r),r.selectStart()}),!0),V),n.registerNodeTransform(kr,t=>{const r=t.getParent();if(!ri(r)){for(const o of t.getChildren())t.insertBefore(o);t.remove();return}t.isEmpty()&&t.append(ne())}),n.registerNodeTransform(vr,t=>{const r=t.getChildren();if(!r.every(Qc)){for(const o of r)t.insertBefore(o);t.remove();return}r.length===0&&t.remove()}))}const W2=pe({name:"@datalayer/jupyter-lexical/Layout",nodes:()=>[vr,kr],register:K2});function fg(n,e,t,r,o){return n==="code"?J2(e,t):H2(e,t,r,o)}function J2(n,e){const t=n.getTextContent(),r=Y2(n,e),o=t.substring(0,r),s=t.substring(r);return{before:o,after:s,fullText:t}}function H2(n,e,t,r){const s=se().getChildren(),i=q2(n);if(!i)return{before:"",after:"",fullText:""};const a=s.indexOf(i);if(a===-1)return{before:"",after:"",fullText:""};const l=t===-1?0:Math.max(0,a-t),c=r===-1?s.length-1:Math.min(s.length-1,a+r);let u="";for(let _=l;_<a;_++)u+=s[_].getTextContent()+`
214
+ `+ ++i);t.setAttribute("data-gutter",s)}function q_(n){const e=[];if(n instanceof ln&&e.push(n),H(n))for(const t of n.getChildren())H(t)&&e.push(...q_(t));return e}function WE(n){const e=de(mx(n),n.registerNodeTransform(ln,t=>{Vf(t,n)}));return n.getEditorState().read(()=>{for(const t of q_(se()))Vf(t,n)}),e}const JE=pe({name:"@datalayer/jupyter-lexical/CodeBlockHighlight",dependencies:[Zp],register:WE}),_u=he("INSERT_COLLAPSIBLE_COMMAND"),Yf=()=>{const n=P();if(j(n)&&n.isCollapsed()&&n.anchor.offset===0){const e=re(n.anchor.getNode(),$t);if($t(e)){const t=e.getParent();t!==null&&t.getFirstChild()===e&&n.anchor.key===e.getFirstDescendant()?.getKey()&&e.insertBefore(ne())}}return!1},Gf=()=>{const n=P();if(j(n)&&n.isCollapsed()){const e=re(n.anchor.getNode(),$t);if($t(e)){const t=e.getParent();if(t!==null&&t.getLastChild()===e){const r=e.getFirstDescendant(),o=e.getLastDescendant();(o!==null&&n.anchor.key===o.getKey()&&n.anchor.offset===o.getTextContentSize()||r!==null&&n.anchor.key===r.getKey()&&n.anchor.offset===r.getTextContentSize())&&e.insertAfter(ne())}}}return!1};function HE(n){if(!n.hasNodes([Cr,ps,Sr]))throw new Error("CollapsiblePlugin: CollapsibleContainerNode, CollapsibleTitleNode, or CollapsibleContentNode not registered on editor");return de(n.registerNodeTransform(Sr,e=>{const t=e.getParent();if(!$t(t)){const r=e.getChildren();for(const o of r)e.insertBefore(o);e.remove()}}),n.registerNodeTransform(ps,e=>{const t=e.getParent();if(!$t(t)){e.replace(ne().append(...e.getChildren()));return}}),n.registerNodeTransform(Cr,e=>{const t=e.getChildren();if(t.length!==2||!ni(t[0])||!Gc(t[1])){for(const r of t)e.insertBefore(r);e.remove()}}),n.registerCommand(Ht,Gf,ee),n.registerCommand(Di,Gf,ee),n.registerCommand(pt,Yf,ee),n.registerCommand(Ss,Yf,ee),n.registerCommand(ho,()=>{const e=P();if(j(e)){const t=re(e.anchor.getNode(),r=>ni(r));if(ni(t)){const r=t.getParent();if(r&&$t(r))return r.getOpen()||r.toggleOpen(),t.getNextSibling()?.selectEnd(),!0}}return!1},ee),n.registerCommand(_u,()=>(n.update(()=>{const e=n_(),t=ne();Yn(Vc(!0).append(e.append(t),Yc().append(ne()))),t.select()}),!0),ee))}const qE=pe({name:"@datalayer/jupyter-lexical/Collapsible",nodes:()=>[Cr,ps,Sr],register:HE}),VE=Fn?C.useLayoutEffect:C.useEffect;class V_{key;ref;icon;title;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}const Xf=n=>{const e=n.closest("#typeahead-menu");if(!e)return;const t=e.getBoundingClientRect();t.top+t.height>window.innerHeight&&e.scrollIntoView({block:"center"}),t.top<0&&e.scrollIntoView({block:"center"}),n.scrollIntoView({block:"nearest"})};function Zf(n,e){const t=n.getBoundingClientRect(),r=e.getBoundingClientRect();return t.top>=r.top-6&&t.top<=r.bottom+6}function YE(n,e,t,r){const[o]=fe();C.useEffect(()=>{if(e!=null&&n!=null){const s=o.getRootElement(),i=s!=null?Cp(s,!1):document.body;let a=!1,l=Zf(e,i);const c=function(){a||(window.requestAnimationFrame(function(){t(),a=!1}),a=!0);const d=Zf(e,i);d!==l&&(l=d,r?.(d))},u=new ResizeObserver(t),f=Sp(s??e);return u.observe(e),de(Wt(window,"resize",t),Wt(document,"scroll",c,{capture:!0,passive:!0}),...f.map(d=>Wt(d,"scroll",c,{capture:!0,passive:!0})),()=>u.unobserve(e))}},[e,o,r,t,n])}const Qf=he("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function GE({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){let s="item";return e&&(s+=" selected"),w.jsxs("li",{tabIndex:-1,className:s,ref:o.setRefElement,role:"option","aria-selected":e,id:"typeahead-item-"+n,onMouseEnter:r,onClick:t,children:[o.icon,w.jsx("span",{className:"text",children:o.title})]},o.key)}function XE({close:n,editor:e,anchorElementRef:t,resolution:r,options:o,menuRenderFn:s,onSelectOption:i,shouldSplitNodeWithQuery:a=!1,commandPriority:l=ee,preselectFirstItem:c=!0}){const[u,f]=C.useState(null),d=u!==null?Math.min(o.length-1,u):null,p=r.match&&r.match.matchingString;C.useEffect(()=>{c&&f(0)},[p,c]);const h=C.useCallback(x=>{e.update(()=>{const S=r.match!=null&&a?(function(v){const I=P();if(!j(I)||!I.isCollapsed())return null;const E=I.anchor;if(E.type!=="text")return null;const T=E.getNode();if(!T.isSimpleText())return null;const N=E.offset,O=T.getTextContent().slice(0,N),M=v.replaceableString.length,A=N-(function(L,R,B){let F=B;for(let U=F;U<=R.length;U++)L.slice(-U)===R.substring(0,U)&&(F=U);return F})(O,v.matchingString,M);if(A<0)return null;let $;return A===0?[$]=T.splitText(N):[,$]=T.splitText(A,N),$})(r.match):null;i(x,S,n,r.match?r.match.matchingString:"")})},[e,a,r.match,i,n]),_=C.useCallback(x=>{const S=e.getRootElement();S!==null&&(S.setAttribute("aria-activedescendant","typeahead-item-"+x),f(x))},[e]),m=C.useCallback(()=>t.current&&o.length?vp.createPortal(w.jsx("div",{className:"typeahead-popover mentions-menu",children:w.jsx("ul",{children:o.map((x,S)=>w.jsx(GE,{index:S,isSelected:d===S,onClick:()=>{f(S),h(x)},onMouseEnter:()=>{f(S)},option:x},x.key))})}),t.current):null,[t,o,d,h,f]);C.useEffect(()=>()=>{const x=e.getRootElement();x!==null&&x.removeAttribute("aria-activedescendant")},[e]),VE(()=>{o===null?f(null):d===null&&c&&_(0)},[o,d,_,c]),C.useEffect(()=>de(e.registerCommand(Qf,({option:x})=>!(!x.ref||x.ref.current==null)&&(Xf(x.ref.current),!0),l)),[e,_,l]),C.useEffect(()=>de(e.registerCommand(Ht,x=>{const S=x;if(o!==null&&o.length){const v=d===null?0:d!==o.length-1?d+1:0;_(v);const I=o[v];if(!I)return _(-1),S.preventDefault(),S.stopImmediatePropagation(),!0;I.ref&&I.ref.current&&e.dispatchCommand(Qf,{index:v,option:I}),S.preventDefault(),S.stopImmediatePropagation()}return!0},l),e.registerCommand(pt,x=>{const S=x;if(o!==null&&o.length){const v=d===null?o.length-1:d!==0?d-1:o.length-1;_(v);const I=o[v];if(!I)return _(-1),S.preventDefault(),S.stopImmediatePropagation(),!0;I.ref&&I.ref.current&&Xf(I.ref.current),S.preventDefault(),S.stopImmediatePropagation()}return!0},l),e.registerCommand(Cn,x=>{const S=x;return S.preventDefault(),S.stopImmediatePropagation(),n(),!0},l),e.registerCommand(Nr,x=>{const S=x;return o!==null&&d!==null&&o[d]!=null&&(S.preventDefault(),S.stopImmediatePropagation(),h(o[d]),!0)},l),e.registerCommand(Er,x=>!(o===null||d===null||o[d]==null||x&&x.shiftKey)&&(x!==null&&(x.preventDefault(),x.stopImmediatePropagation()),h(o[d]),!0),l)),[h,n,e,o,d,_,l]);const y=C.useMemo(()=>({options:o,selectOptionAndCleanUp:h,selectedIndex:d,setHighlightedIndex:f}),[h,d,o]);return s!=null?s(t,y,r.match?r.match.matchingString:""):m()}function eg(n,e){e!=null&&(n.className=e),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute"}function ZE(n,e,t,r,o=!0){const[s]=fe(),i=r??(function(f){if(!Fn)return;const d=f.getRootElement();if(d!==null){const p=d.getRootNode();return oc(p)?p:d.ownerDocument.body}return document.body})(s),a=Fn?xp(s.getRootElement()).createElement("div"):null,l=C.useRef(a),c=C.useCallback(()=>{if(l.current===null||i===void 0)return;l.current.style.top=l.current.style.bottom;const f=s.getRootElement(),d=l.current,p=d.firstChild;if(f!==null&&n!==null){const{left:h,top:_,width:m,height:y}=n.getRect(),x=l.current.offsetHeight;if(d.style.top=`${_+x+3+(o?window.pageYOffset:0)}px`,d.style.left=`${h+window.pageXOffset}px`,d.style.height=`${y}px`,d.style.width=`${m}px`,p!==null){p.style.top=`${_}`;const S=p.getBoundingClientRect(),v=S.height,I=S.width,E=f.getBoundingClientRect();h+I>E.right&&(d.style.left=`${E.right-I+window.pageXOffset}px`),(_+v>window.innerHeight||_+v>E.bottom)&&_-E.top>v+y&&(d.style.top=`${_-v-y+(o?window.pageYOffset:0)}px`)}d.isConnected||(eg(d,t),i.append(d)),d.setAttribute("id","typeahead-menu"),f.setAttribute("aria-controls","typeahead-menu")}},[s,n,o,t,i]);C.useEffect(()=>{const f=s.getRootElement();return n!==null&&c(),()=>{f!==null&&f.removeAttribute("aria-controls");const d=l.current;d!==null&&d.isConnected&&(d.remove(),d.removeAttribute("id"))}},[s,c,n]);const u=C.useCallback(f=>{n!==null&&(f||e(null))},[n,e]);return YE(n,l.current,c,u),a!=null&&a===l.current&&(eg(a,t),i?.append(a)),l}const QE=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function Y_(n,{minLength:e=1,maxLength:t=75,punctuation:r=QE,allowWhitespace:o=!1}){return C.useCallback(s=>{const i=new RegExp("(^|\\s|\\()(["+n+"]((?:"+("[^"+n+r+(o?"":"\\s")+"]")+"){0,"+t+"}))$").exec(s);if(i!==null){const a=i[1],l=i[3];if(l.length>=e)return{leadOffset:i.index+a.length,matchingString:l,replaceableString:i[2]}}return null},[o,n,r,t,e])}function G_({options:n,onQueryChange:e,onSelectOption:t,onOpen:r,onClose:o,menuRenderFn:s,triggerFn:i,anchorClassName:a,commandPriority:l=ee,parent:c,preselectFirstItem:u=!0,ignoreEntityBoundary:f=!1}){const[d]=fe(),[p,h]=C.useState(null),_=ZE(p,h,a,c),m=C.useCallback(()=>{if(p===null)return;const x=()=>{h(null)};let S;try{S=o&&o()}finally{S?S.then(x,x):x()}},[o,p]),y=C.useCallback(x=>{h(x),r!=null&&p===null&&r(x)},[r,p]);return C.useEffect(()=>{const x=d.registerUpdateListener(()=>{d.read("latest",()=>{if(!d.isEditable())return void m();if(d.isComposing())return;const S=d._window||window,v=S.document.createRange(),I=P(),E=(function(N){let O=null;return N.read("latest",()=>{const M=P();j(M)&&(O=(function(A){const $=A.anchor;if($.type!=="text")return null;const L=$.getNode();if(!L.isSimpleText())return null;const R=$.offset;return L.getTextContent().slice(0,R)})(M))}),O})(d);if(!j(I)||!I.isCollapsed()||E===null||v===null)return void m();const T=i(E,d);if(e(T?T.matchingString:null),T!==null&&(f||!(function(N,O){return O===0&&N.read("latest",()=>{const M=P();if(j(M)){const A=M.anchor.getNode().getPreviousSibling();return oe(A)&&A.isTextEntity()}return!1})})(d,T.leadOffset))&&(function(O,M,A,$){const L=Vn(A);if(L===null||!L.isCollapsed)return!1;const R=rc(L,$),B=R.anchorNode,F=O,U=R.anchorOffset;if(B==null||U==null)return!1;try{M.setStart(B,F),M.setEnd(B,U)}catch{return!1}return!0})(T.leadOffset,v,S,d.getRootElement())!==null)return void C.startTransition(()=>y({getRect:()=>v.getBoundingClientRect(),match:T}));m()})});return()=>{x()}},[d,i,e,p,m,y,f]),C.useEffect(()=>d.registerEditableListener(x=>{x||m()}),[d,m]),p===null||d===null||_.current===null?null:w.jsx(XE,{close:m,resolution:p,editor:d,anchorElementRef:_,options:n,menuRenderFn:s,shouldSplitNodeWithQuery:!0,onSelectOption:t,commandPriority:l,preselectFirstItem:u})}const eN=n=>n.split(/[\s._-]+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join("")||"?";function tN({author:n,size:e}){const t=fc(n);return n.avatarUrl?w.jsx(rw,{src:n.avatarUrl,size:e,alt:t}):w.jsx(Y,{as:"span","aria-hidden":!0,title:t,sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:e,height:e,borderRadius:"50%",bg:"neutral.muted",color:"fg.muted",fontSize:`${Math.round(e*.45)}px`,fontWeight:"bold"},children:n.kind==="anonymous"?w.jsx(cy,{size:Math.round(e*.65)}):eN(t)})}const Ir=C.createContext({}),nN=[],rN=250;function X_(n){const{searchPeople:e}=C.useContext(Ir),[t,r]=C.useState(null);return C.useEffect(()=>{if(!e||!n)return;let o=!0;const s=setTimeout(()=>{e(n).then(i=>{o&&r({query:n,people:i})},()=>{o&&r({query:n,people:[]})})},rN);return()=>{o=!1,clearTimeout(s)}},[n,e]),t&&t.query===n?t.people:nN}class oN extends V_{person;constructor(e){super(e.uid),this.person=e}}function sN({onMention:n}){const[e]=fe(),{searchPeople:t}=C.useContext(Ir),[r,o]=C.useState(null),s=X_(r),i=C.useMemo(()=>s.map(c=>new oN(c)),[s]),a=Y_("@",{minLength:1}),l=C.useCallback((c,u,f)=>{e.update(()=>{const d=De(`@${so(c.person)} `);u&&u.replace(d),d.select(),f()}),n(c.person)},[e,n]);return t?w.jsx(G_,{onQueryChange:o,onSelectOption:l,triggerFn:a,options:i,menuRenderFn:(c,{selectedIndex:u,selectOptionAndCleanUp:f,setHighlightedIndex:d})=>c.current&&i.length>0?Tt.createPortal(w.jsx(Y,{as:"ul",role:"listbox","aria-label":"People to mention",sx:{position:"relative",zIndex:1e3,listStyle:"none",m:0,p:1,bg:"var(--overlay-bgColor)",border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,boxShadow:"var(--shadow-floating-large, 0 0 0 1px #d1d9e0, 0 40px 80px 0 #25292e3d)",minWidth:200},children:i.map((p,h)=>w.jsxs(Y,{as:"li",role:"option","aria-selected":u===h,ref:_=>p.setRefElement(_),onMouseEnter:()=>d(h),onClick:()=>{d(h),f(p)},sx:{px:2,py:1,borderRadius:1,cursor:"pointer",bg:u===h?"actionListItem.default.hoverBg":"transparent"},children:[w.jsx(Le,{children:so(p.person)}),p.person.handle?w.jsxs(Le,{sx:{color:"var(--fgColor-muted)",ml:1},children:["@",p.person.handle]}):null]},p.key))}),c.current):null}):null}function iN({thread:n}){const{searchPeople:e,assignThread:t}=C.useContext(Ir),[r,o]=C.useState(!1),[s,i]=C.useState(""),a=X_(r&&s.trim()?s.trim():null),l=n.assignee??null;if(!t||!e)return l?w.jsxs(Le,{as:"p",sx:{fontSize:0,color:"var(--fgColor-muted)",m:0,mt:1},children:["Assigned to ",so(l)]}):null;const c=u=>{t(n,u),o(!1),i("")};return w.jsxs(Y,{sx:{mt:1},onClick:u=>u.stopPropagation(),children:[w.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:1},children:[w.jsx(Le,{sx:{fontSize:0,color:"var(--fgColor-muted)"},children:l?`Assigned to ${so(l)}`:"Not assigned"}),w.jsx(Pt,{icon:Gy,"aria-label":"Assign thread",variant:"invisible",size:"small",onClick:()=>o(!r)}),l?w.jsx(ft,{variant:"invisible",size:"small",onClick:()=>c(null),children:"Unassign"}):null]}),r?w.jsxs(Y,{sx:{mt:1},children:[w.jsx(yn,{"aria-label":"Find a person to assign",placeholder:"Name or handle",size:"small",block:!0,autoFocus:!0,value:s,onChange:u=>i(u.target.value)}),w.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0,mt:1},children:a.map(u=>w.jsx(Y,{as:"li",children:w.jsx(ft,{variant:"invisible",size:"small",onClick:()=>c(u),children:so(u)})},u.uid))})]}):null]})}const aN={characterLimit:"JupyterLexicalTheme__characterLimit",code:"JupyterLexicalTheme__code",codeHighlight:{atrule:"JupyterLexicalTheme__tokenAttr",attr:"JupyterLexicalTheme__tokenAttr",boolean:"JupyterLexicalTheme__tokenProperty",builtin:"JupyterLexicalTheme__tokenSelector",cdata:"JupyterLexicalTheme__tokenComment",char:"JupyterLexicalTheme__tokenSelector",class:"JupyterLexicalTheme__tokenFunction","class-name":"JupyterLexicalTheme__tokenFunction",comment:"JupyterLexicalTheme__tokenComment",constant:"JupyterLexicalTheme__tokenProperty",deleted:"JupyterLexicalTheme__tokenProperty",doctype:"JupyterLexicalTheme__tokenComment",entity:"JupyterLexicalTheme__tokenOperator",function:"JupyterLexicalTheme__tokenFunction",important:"JupyterLexicalTheme__tokenVariable",inserted:"JupyterLexicalTheme__tokenSelector",keyword:"JupyterLexicalTheme__tokenAttr",namespace:"JupyterLexicalTheme__tokenVariable",number:"JupyterLexicalTheme__tokenProperty",operator:"JupyterLexicalTheme__tokenOperator",prolog:"JupyterLexicalTheme__tokenComment",property:"JupyterLexicalTheme__tokenProperty",punctuation:"JupyterLexicalTheme__tokenPunctuation",regex:"JupyterLexicalTheme__tokenVariable",selector:"JupyterLexicalTheme__tokenSelector",string:"JupyterLexicalTheme__tokenSelector",symbol:"JupyterLexicalTheme__tokenProperty",tag:"JupyterLexicalTheme__tokenProperty",url:"JupyterLexicalTheme__tokenOperator",variable:"JupyterLexicalTheme__tokenVariable"},embedBlock:{base:"JupyterLexicalTheme__embedBlock",focus:"JupyterLexicalTheme__embedBlockFocus"},hashtag:"JupyterLexicalTheme__hashtag",heading:{h1:"JupyterLexicalTheme__h1",h2:"JupyterLexicalTheme__h2",h3:"JupyterLexicalTheme__h3",h4:"JupyterLexicalTheme__h4",h5:"JupyterLexicalTheme__h5",h6:"JupyterLexicalTheme__h6"},image:"editor-image",link:"JupyterLexicalTheme__link",list:{listitem:"JupyterLexicalTheme__listItem",listitemChecked:"JupyterLexicalTheme__listItemChecked",listitemUnchecked:"JupyterLexicalTheme__listItemUnchecked",nested:{listitem:"JupyterLexicalTheme__nestedListItem"},olDepth:["JupyterLexicalTheme__ol1","JupyterLexicalTheme__ol2","JupyterLexicalTheme__ol3","JupyterLexicalTheme__ol4","JupyterLexicalTheme__ol5"],ul:"JupyterLexicalTheme__ul"},ltr:"JupyterLexicalTheme__ltr",mark:"JupyterLexicalTheme__mark",markOverlap:"JupyterLexicalTheme__markOverlap",layoutContainer:"JupyterLexicalTheme__layoutContainer",layoutItem:"JupyterLexicalTheme__layoutItem",paragraph:"JupyterLexicalTheme__paragraph",quote:"JupyterLexicalTheme__quote",rtl:"JupyterLexicalTheme__rtl",table:"JupyterLexicalTheme__table",tableCell:"JupyterLexicalTheme__tableCell",tableCellHeader:"JupyterLexicalTheme__tableCellHeader",text:{bold:"JupyterLexicalTheme__textBold",code:"JupyterLexicalTheme__textCode",italic:"JupyterLexicalTheme__textItalic",strikethrough:"JupyterLexicalTheme__textStrikethrough",subscript:"JupyterLexicalTheme__textSubscript",superscript:"JupyterLexicalTheme__textSuperscript",underline:"JupyterLexicalTheme__textUnderline",underlineStrikethrough:"JupyterLexicalTheme__textUnderlineStrikethrough"}},lN={...aN,paragraph:"CommentEditorTheme__paragraph"},ns=he();function cN({anchorKey:n,editor:e,onAddComment:t}){const r=C.useRef(null),o=C.useCallback(()=>{const s=r.current,i=e.getRootElement(),a=e.getElementByKey(n);if(s!==null&&i!==null&&a!==null){const{right:l}=i.getBoundingClientRect(),{top:c}=a.getBoundingClientRect();s.style.left=`${l-20}px`,s.style.top=`${c-30}px`}},[n,e]);return C.useEffect(()=>(window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o)}),[e,o]),hu(()=>{o()},[n,e,o]),w.jsx(Y,{ref:r,sx:{position:"absolute",zIndex:10},children:w.jsx(Pt,{icon:mi,"aria-label":"Add comment",variant:"invisible",size:"small",onClick:t})})}const Z_=pe({name:"@datalayer/jupyter-lexical/CommentComposer",namespace:"Commenting",theme:lN,dependencies:[_y,Tp,my]}),uN=pe({name:"@datalayer/jupyter-lexical/CommentComposer/Focused",dependencies:[Z_,by]});function dN({editorRef:n}){const[e]=fe();return hu(()=>(n.current=e,()=>{n.current=null}),[e,n]),null}function fN({onEscape:n}){const[e]=fe();return C.useEffect(()=>e.registerCommand(Cn,t=>n(t),2),[e,n]),null}function Q_({style:n,autoFocus:e,onEscape:t,onChange:r,onMention:o,editorRef:s,placeholder:i="Type a comment..."}){const a=e===!1?Z_:uN;return w.jsx(py,{extension:a,contentEditable:null,children:w.jsxs(Y,{sx:{position:"relative",m:"10px",borderRadius:2},children:[w.jsx(Pg,{className:"ContentEditable__root",style:n,placeholder:w.jsx(Wp,{children:i}),"aria-placeholder":i}),w.jsx(hy,{onChange:r}),w.jsx(fN,{onEscape:t}),o!==void 0&&w.jsx(sN,{onMention:o}),s!==void 0&&w.jsx(dN,{editorRef:s})]})})}function em(n,e){return C.useCallback((t,r)=>{t.read(()=>{n(fy()),e(!gy(r.isComposing(),!0))})},[e,n])}const tg=256;function gN({editor:n,cancelAddComment:e,submitAddComment:t}){const[r,o]=C.useState(""),[s,i]=C.useState(!1),[a,l]=C.useState(null),c=C.useRef(null),u=C.useMemo(()=>({container:document.createElement("div"),elements:[]}),[]),f=nm(),d=C.useCallback(()=>{n.getEditorState().read(()=>{const S=P();if(j(S)){const v=S.anchor,I=S.focus,E=_p(n,v.getNode(),v.offset,I.getNode(),I.offset);if(E!==null){const{left:T,bottom:N,width:O}=E.getBoundingClientRect(),M=nl(n,E);let A=M.length===1?T+O/2-tg/2:T-tg/2;A<10&&(A=10),l({left:A,top:N+20});const $=M.length,{container:L}=u,R=u.elements,B=R.length;for(let F=0;F<$;F++){const U=M[F];let K=R[F];K===void 0&&(K=document.createElement("span"),R[F]=K,L.appendChild(K));const q=`position:absolute;top:${U.top}px;left:${U.left}px;height:${U.height}px;width:${U.width}px;background-color:var(--bgColor-attention-muted, rgba(255, 212, 0, 0.3));pointer-events:none;z-index:5;`;K.style.cssText=q}for(let F=B-1;F>=$;F--){const U=R[F];L.removeChild(U),R.pop()}}}})},[n,u]);hu(()=>{c.current=n.getRootElement(),d();const S=u.container,v=document.body;if(v!==null)return v.appendChild(S),()=>{v.removeChild(S)}},[n,u.container,d]),C.useEffect(()=>(window.addEventListener("resize",d),()=>{window.removeEventListener("resize",d)}),[d]);const p=S=>(S.preventDefault(),e(),!0),h=C.useRef(new Map),_=C.useCallback(S=>{h.current.set(S.uid,S)},[]),m=()=>{if(s){let S=n.getEditorState().read(()=>{const v=P();return v!==null?v.getTextContent():""});S.length>100&&(S=S.slice(0,99)+"…"),t(Ow(S,[Up(r,f,void 0,void 0,void 0,Fp(r,h.current.values()))]),!0)}},y=em(o,i),x=S=>{const v=S.target;v instanceof HTMLElement&&v.closest('[role="listbox"]')||e()};return a===null?null:w.jsxs(qa,{role:"dialog","aria-label":"Add a comment",width:"small",position:"fixed",left:a.left,top:a.top,onEscape:e,onClickOutside:x,returnFocusRef:c,preventFocusOnOpen:!0,children:[w.jsx(Q_,{style:{position:"relative",border:"1px solid var(--borderColor-default)",backgroundColor:"var(--bgColor-default)",borderRadius:"6px",fontSize:"15px",caretColor:"var(--fgColor-default)",display:"block",padding:"9px 10px 10px 9px",minHeight:"80px"},onEscape:p,onChange:y,onMention:_}),w.jsxs(Y,{sx:{display:"flex",gap:2,justifyContent:"flex-end",mt:2,px:2,pb:2},children:[w.jsx(ft,{onClick:e,variant:"invisible",size:"small",children:"Cancel"}),w.jsx(ft,{onClick:m,disabled:!s,variant:"primary",size:"small",children:"Comment"})]})]})}function pN({submitAddComment:n,thread:e,placeholder:t}){const[r,o]=C.useState(""),[s,i]=C.useState(!1),a=C.useRef(null),l=nm(),c=C.useRef(new Map),u=C.useCallback(p=>{c.current.set(p.uid,p)},[]),f=em(o,i),d=()=>{if(s){n(Up(r,l,void 0,void 0,void 0,Fp(r,c.current.values())),!1,e),c.current.clear();const p=a.current;p!==null&&p.dispatchCommand(wy,void 0)}};return w.jsxs(w.Fragment,{children:[w.jsx(Q_,{style:{position:"relative",border:"1px solid",borderColor:"var(--borderColor-default, #ccc)",backgroundColor:"var(--bgColor-default, #fff)",borderRadius:"6px",fontSize:"15px",caretColor:"var(--fgColor-default)",display:"block",padding:"9px 10px 10px 9px",minHeight:"20px"},autoFocus:!1,onEscape:()=>!0,onChange:f,onMention:u,editorRef:a,placeholder:t}),w.jsx(Pt,{icon:yy,"aria-label":"Send comment",variant:"invisible",size:"small",onClick:d,disabled:!s})]})}function tm({commentOrThread:n,deleteCommentOrThread:e,onClose:t,thread:r=void 0}){return w.jsxs(w.Fragment,{children:["Are you sure you want to delete this ",n.type,"?",w.jsxs(Y,{sx:{display:"flex",gap:2,justifyContent:"flex-end",mt:3},children:[w.jsx(ft,{variant:"invisible",onClick:()=>{t()},children:"Cancel"}),w.jsx(ft,{variant:"danger",onClick:()=>{e(n,r),t()},children:"Delete"})]})]})}function hN(n,e){const t=Math.round((e-Date.now())/1e3);if(t>-10)return"Just now";const r=Math.round(t/60);if(r>-60)return n.format(r,"minute");const o=Math.round(r/60);return o>-24?n.format(o,"hour"):n.format(Math.round(o/24),"day")}function ng({comment:n,deleteComment:e,thread:t,rtf:r}){const[o,s]=$o(),{Avatar:i=tN}=C.useContext(Ir),a=Lw(n);return w.jsxs(Y,{as:"li",sx:{p:2,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)"},children:[w.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[w.jsx(i,{author:a,size:20}),w.jsx(Le,{sx:{fontWeight:"bold",fontSize:1},children:fc(a)}),a.agentUid&&w.jsx(Le,{sx:{color:"var(--fgColor-muted)",fontSize:0},children:"· with an agent"}),w.jsxs(Le,{sx:{color:"var(--fgColor-muted)",fontSize:0},children:["· ",hN(r,n.timeStamp)]})]}),w.jsx(Le,{as:"p",sx:{fontSize:1,m:0,...n.deleted?{color:"var(--fgColor-muted)",fontStyle:"italic"}:{}},children:n.content}),!n.deleted&&w.jsxs(w.Fragment,{children:[w.jsx(Pt,{icon:Ip,"aria-label":"Delete comment",variant:"invisible",size:"small",sx:{color:"var(--fgColor-danger)",mt:1},onClick:()=>{s("Delete Comment",l=>w.jsx(tm,{commentOrThread:n,deleteCommentOrThread:e,thread:t,onClose:l}))}}),o]})]})}function _N({activeIDs:n,comments:e,deleteCommentOrThread:t,listRef:r,submitAddComment:o,markNodeMap:s,resolveThread:i}){const[a]=fe(),[l,c]=C.useState(0),[u,f]=$o(),d=C.useMemo(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return C.useEffect(()=>{const p=setTimeout(()=>{c(l+1)},1e4);return()=>{clearTimeout(p)}},[l]),w.jsx(Y,{as:"ul",ref:r,sx:{listStyle:"none",m:0,p:0},children:e.map(p=>{const h=p.id;if(p.type==="thread"){const _=()=>{const m=s.get(h);if(m!==void 0&&(n===null||n.indexOf(h)===-1)){const y=document.activeElement;a.update(()=>{const x=Array.from(m)[0],S=Q(x);mo(S)&&S.selectStart()},{onUpdate(){y!==null&&y.focus()}})}};return w.jsxs(Y,{as:"li",onClick:_,sx:{p:2,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)",cursor:s.has(h)?"pointer":"default",bg:n.indexOf(h)===-1?"var(--bgColor-default)":"var(--bgColor-accent-muted)","&:hover":s.has(h)?{bg:"var(--bgColor-muted)"}:{}},children:[w.jsxs(Y,{sx:{display:"flex",alignItems:"flex-start",gap:2},children:[w.jsxs(Y,{as:"blockquote",sx:{flex:1,m:0,pl:2,borderLeft:"3px solid",borderColor:"var(--bgColor-accent-muted)",color:"var(--fgColor-muted)",fontSize:1},children:["> ",w.jsx("span",{children:p.quote})]}),i&&w.jsx(Pt,{icon:kp,"aria-label":"Resolve thread",variant:"invisible",size:"small",onClick:m=>{m.stopPropagation(),i(p)}}),w.jsx(Pt,{icon:Ip,"aria-label":"Delete thread",variant:"invisible",size:"small",sx:{color:"var(--fgColor-danger)"},onClick:()=>{f("Delete Thread",m=>w.jsx(tm,{commentOrThread:p,deleteCommentOrThread:t,onClose:m}))}}),u]}),w.jsx(iN,{thread:p}),w.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0,mt:2},children:p.comments.map(m=>w.jsx(ng,{comment:m,deleteComment:t,thread:p,rtf:d},m.id))}),w.jsx(Y,{sx:{mt:2},children:w.jsx(pN,{submitAddComment:o,thread:p,placeholder:"Reply to comment..."})})]},h)}return w.jsx(ng,{comment:p,deleteComment:t,rtf:d},h)})})}function mN({activeIDs:n,deleteCommentOrThread:e,comments:t,submitAddComment:r,markNodeMap:o,resolveThread:s}){const i=C.useRef(null),a=t.length===0;return w.jsxs(Y,{sx:{bg:"var(--bgColor-default)",borderRadius:2,overflow:"hidden",width:"100%",flex:1,display:"flex",flexDirection:"column"},children:[w.jsx(dy,{as:"h2",sx:{fontSize:2,p:3,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)",m:0},children:"Comments"}),a?w.jsx(Y,{sx:{p:3,color:"var(--fgColor-muted)",textAlign:"center"},children:"No Comments"}):w.jsx(_N,{activeIDs:n,comments:t,deleteCommentOrThread:e,listRef:i,submitAddComment:r,markNodeMap:o,resolveThread:s})]})}function nm(){const{author:n}=C.useContext(Ir),{name:e}=M_();return n??gc(e)}function JA({providerFactory:n,showFloatingAddButton:e=!0,commentStore:t,author:r,Avatar:o}){const[s]=fe(),{showComments:i,setShowComments:a}=oh(),l=C.useRef(null),c=C.useRef(null),u=C.useMemo(()=>t??new Mw(s),[s,t]),f=$w(u),d=C.useMemo(()=>new Map,[]),[p,h]=C.useState(),[_,m]=C.useState([]),[y,x]=C.useState(!1),S=C.useCallback(A=>{a(typeof A=="function"?A(i):A)},[a,i]),v=C.useCallback(()=>{s.update(()=>{const A=P();A!==null&&(A.dirty=!0)}),x(!1)},[s]),I=C.useCallback(A=>{const $=d.get(A);$!==void 0&&setTimeout(()=>{s.update(()=>{for(const L of $){const R=Q(L);mo(R)&&(R.deleteID(A),R.getIDs().length===0&&kw(R))}})})},[s,d]),E=C.useCallback((A,$)=>{A.type==="comment"?u.deleteComment(A,$):(u.deleteThread(A),I($!==void 0?$.id:A.id))},[u,I]),T=C.useMemo(()=>{if(u.resolveThread)return A=>{u.resolveThread?.(A),I(A.id)}},[u,I]),N=C.useCallback((A,$,L)=>{u.addComment(A,L),$&&(s.update(()=>{const R=P();if(j(R)){const B=R.focus,F=R.anchor,U=R.isBackward(),K=A.id;Iw(R,U,K),U?B.set(F.key,F.offset,F.type):F.set(B.key,B.offset,B.type)}}),x(!1))},[u,s]);C.useEffect(()=>{const A=[];for(let $=0;$<_.length;$++){const L=_[$],R=d.get(L);if(R!==void 0)for(const B of R){const F=s.getElementByKey(B);F!==null&&(F.classList.add("selected"),A.push(F),a(!0))}}return()=>{for(let $=0;$<A.length;$++)A[$].classList.remove("selected")}},[_,s,d]),C.useEffect(()=>{const A=new Map;return de(uy(s,cs,$=>dc($.getIDs()),($,L)=>{$.getIDs().forEach(B=>{L.addID(B)})}),s.registerMutationListener(cs,$=>{s.getEditorState().read(()=>{for(const[L,R]of $){const B=Q(L);let F=[];R==="destroyed"?F=A.get(L)||[]:mo(B)&&(F=B.getIDs());for(let U=0;U<F.length;U++){const K=F[U];let W=d.get(K);A.set(L,F),R==="destroyed"?W!==void 0&&(W.delete(L),W.size===0&&d.delete(K)):(W===void 0&&(W=new Set,d.set(K,W)),W.has(L)||W.add(L))}}})}),s.registerUpdateListener(({editorState:$,tags:L})=>{$.read(()=>{const R=P();let B=!1,F=!1;if(j(R)){const U=R.anchor.getNode();if(oe(U)){const K=Tw(U,R.anchor.offset);K!==null&&(m(K),B=!0),R.isCollapsed()||(h(U.getKey()),F=!0)}}B||m(U=>U.length===0?U:[]),F||h(null)}),L.has("collaboration")||x(!1)}),s.registerCommand(ns,()=>{const $=window.getSelection();return $!==null&&$.removeAllRanges(),x(!0),!0},V))},[s,d]);const O=()=>{s.dispatchCommand(ns,void 0)},M=C.useMemo(()=>({searchPeople:u.searchPeople?.bind(u),assignThread:u.assignThread?.bind(u),author:r,Avatar:o}),[u,r,o]);return w.jsxs(Ir.Provider,{value:M,children:[y&&w.jsx(Ir.Provider,{value:M,children:w.jsx(gN,{editor:s,cancelAddComment:v,submitAddComment:N})}),e&&p!==null&&p!==void 0&&!y&&Tt.createPortal(w.jsx(cN,{anchorKey:p,editor:s,onAddComment:O}),document.body),w.jsx("button",{ref:l,style:{display:"none"},"aria-hidden":"true"}),w.jsx(bw,{isOpen:i,setIsOpen:S,openButtonRef:l,closeButtonRef:c,direction:"right",width:"350px",content:w.jsx(mN,{comments:f,submitAddComment:N,deleteCommentOrThread:E,activeIDs:_,markNodeMap:d,resolveThread:T})})]})}const vo=Qe().describe("CSS colour, e.g. '#1e1e1e', '#e03131', 'transparent'"),rm=Et({type:lr(["rectangle","ellipse","diamond","text","arrow","line","frame"]).describe("What to draw"),x:We().describe("Left edge, in scene coordinates"),y:We().describe("Top edge, in scene coordinates"),width:We().optional().describe("Width in pixels (shapes only)"),height:We().optional().describe("Height in pixels (shapes only)"),id:Qe().optional().describe("Your own id for this element, so a later arrow can point at it by name. Any string; Excalidraw keeps it."),text:Qe().optional().describe("The text itself, for type 'text'"),label:Qe().optional().describe("Text to put inside the shape. Excalidraw binds it to the shape, so moving the shape moves the label."),fontSize:We().optional().describe("Font size in pixels, e.g. 16, 20, 28"),strokeColor:vo.optional().describe("Outline colour"),backgroundColor:vo.optional().describe("Fill colour"),fillStyle:lr(["hachure","cross-hatch","solid"]).optional().describe("How the fill is drawn"),strokeWidth:We().optional().describe("Outline thickness, 1 | 2 | 4"),strokeStyle:lr(["solid","dashed","dotted"]).optional().describe("Outline style"),roughness:We().optional().describe("0 for architect (clean), 1 for artist, 2 for cartoonist"),opacity:We().optional().describe("0-100"),angle:We().optional().describe("Rotation in radians"),startId:Qe().optional().describe("For 'arrow' and 'line': the id of the element the arrow starts at. The arrow stays attached when either element moves."),endId:Qe().optional().describe("For 'arrow' and 'line': the id of the element the arrow points at."),points:ar(ar(We())).optional().describe("For 'arrow' and 'line' without bindings: points relative to x,y, e.g. [[0,0],[120,0]]"),children:ar(Qe()).optional().describe("For 'frame': the ids of the elements it contains"),name:Qe().optional().describe("For 'frame': its name")}),om=Qe().describe("Where to put the drawing: 'TOP' for the beginning of the document, 'BOTTOM' for the end, or the block_id to insert after"),vn=Qe().describe("The block_id of the drawing, from excalidrawListDrawings or readAllBlocks"),sm=Et({afterId:om,elements:ar(rm).optional().describe("The drawing itself. Omit to insert an empty canvas for a person to draw on."),width:We().optional().describe("Rendered width in pixels. Omit to size to the content."),height:We().optional().describe("Rendered height in pixels. Omit to size to the content.")}),im=Et({}),am=Et({blockId:vn,detail:lr(["summary","full"]).optional().describe("'summary' (default) gives each element's id, type, position, size and text — enough to change it. 'full' gives the raw Excalidraw elements, which is large; ask for it only when you need a field the summary omits.")}),lm=Et({blockId:vn,elements:ar(rm).describe("The elements to add. Existing elements are left alone.")}),cm=Et({blockId:vn,updates:ar(Et({id:Qe().describe("The element id, from excalidrawReadScene"),x:We().optional(),y:We().optional(),width:We().optional(),height:We().optional(),text:Qe().optional().describe("New text. On a shape this rewrites the label bound inside it; on a 'text' element it rewrites the element."),strokeColor:vo.optional(),backgroundColor:vo.optional(),fillStyle:lr(["hachure","cross-hatch","solid"]).optional(),strokeWidth:We().optional(),strokeStyle:lr(["solid","dashed","dotted"]).optional(),opacity:We().optional().describe("0-100"),angle:We().optional().describe("Rotation in radians")})).describe("One entry per element to change. Fields left out are kept.")}),um=Et({blockId:vn,elementIds:ar(Qe()).describe("The ids to remove, from excalidrawReadScene")}),dm=Et({blockId:vn,fromId:Qe().describe("The element the arrow starts at"),toId:Qe().describe("The element the arrow points at"),label:Qe().optional().describe('Text to sit on the arrow, e.g. "yes", "then"'),strokeColor:vo.optional(),strokeStyle:lr(["solid","dashed","dotted"]).optional()}),fm=Et({blockId:vn,viewBackgroundColor:vo.optional().describe("The canvas colour behind the drawing"),gridSize:We().optional().describe("Grid spacing in pixels. 0 turns the grid off.")}),gm=Et({blockId:vn,width:We().optional().describe("Rendered width in pixels. Omit to go back to sizing by content."),height:We().optional().describe("Rendered height in pixels. Omit to go back to sizing by content.")}),pm=Et({blockId:vn}),hm=Et({blockId:vn.optional().describe("The drawing to replace. Omit to insert a new drawing instead, positioned by afterId."),afterId:om.optional().describe("Where a new drawing goes: 'TOP', 'BOTTOM', or a block_id. Ignored when blockId is given."),mermaid:Qe().describe("Mermaid source. Flowcharts, sequence diagrams and class diagrams convert to real shapes; anything else comes across as an image."),fontSize:We().optional().describe("Font size for the generated text, in pixels")}),Xt=n=>`datalayer_${n}`,Fr={requiresConfirmation:!1,canBeReferencedInPrompt:!0,priority:"medium"},Zt=["lexical","excalidraw","drawing","diagram"],bN={name:Xt("excalidrawInsertNode"),displayName:"Insert Drawing",toolReferenceName:"excalidrawInsertNode",description:"Insert an Excalidraw drawing into the Lexical document, optionally with its contents. This is how you draw a diagram: give the elements you want and they are laid out as you place them, in scene coordinates where x grows right and y grows down. Give a shape an `id` and a later arrow can bind to it with `startId`/`endId`, so the arrow follows the shape when it moves. Put text on a shape with `label` rather than positioning a separate text element on top of it. Returns the new block_id — keep it, every other excalidraw tool needs it. Omit `elements` to insert an empty canvas for a person to draw on themselves.",parameters:Gt(sm),operation:"excalidrawInsertNode",config:{confirmationMessage:n=>`Insert a drawing of ${n.elements?.length??0} element(s)?`,invocationMessage:()=>"Drawing in the lexical document",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"high"},tags:[...Zt,"insert"]},yN={name:Xt("excalidrawListDrawings"),displayName:"List Drawings",toolReferenceName:"excalidrawListDrawings",description:'List the Excalidraw drawings in the open Lexical document, with the block_id of each and a one-line description of what it holds. Call this first when asked to change "the diagram" and you do not already know its block_id.',parameters:Gt(im),operation:"excalidrawListDrawings",config:{...Fr,invocationMessage:()=>"Looking for drawings"},tags:[...Zt,"read"]},wN={name:Xt("excalidrawReadScene"),displayName:"Read Drawing",toolReferenceName:"excalidrawReadScene",description:"Read what is inside one drawing: every element with its id, type, position, size and text. The element ids are the only way to address a shape, so read the scene before updating, deleting or connecting anything. The default 'summary' detail is what you want; 'full' returns the raw Excalidraw elements and is large.",parameters:Gt(am),operation:"excalidrawReadScene",config:{...Fr,invocationMessage:()=>"Reading the drawing"},tags:[...Zt,"read"]},xN={name:Xt("excalidrawAddElements"),displayName:"Add to Drawing",toolReferenceName:"excalidrawAddElements",description:"Add elements to a drawing that already exists, leaving what is there alone. Same element format as excalidrawInsertNode. To attach a new arrow to a shape already in the drawing, pass that shape's existing element id as `startId` or `endId`. Read the scene first if you need to know where there is room.",parameters:Gt(lm),operation:"excalidrawAddElements",config:{...Fr,invocationMessage:()=>"Adding to the drawing",priority:"high"},tags:[...Zt,"edit"]},CN={name:Xt("excalidrawUpdateElements"),displayName:"Update Drawing Elements",toolReferenceName:"excalidrawUpdateElements",description:"Change elements already in a drawing — move them, resize them, recolour them, or rewrite their text. Address each one by the element id from excalidrawReadScene. Fields you leave out are kept as they are. Setting `text` on a shape rewrites the label bound inside it rather than replacing the shape.",parameters:Gt(cm),operation:"excalidrawUpdateElements",config:{...Fr,invocationMessage:()=>"Changing the drawing"},tags:[...Zt,"edit"]},SN={name:Xt("excalidrawDeleteElements"),displayName:"Delete Drawing Elements",toolReferenceName:"excalidrawDeleteElements",description:"Remove elements from a drawing by their element ids. Deleting a shape also removes the text bound inside it and detaches any arrows that pointed at it, so the drawing stays consistent.",parameters:Gt(um),operation:"excalidrawDeleteElements",config:{confirmationMessage:n=>`Delete ${n.elementIds?.length??0} element(s) from the drawing?`,invocationMessage:()=>"Removing from the drawing",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"medium"},tags:[...Zt,"edit","delete"]},vN={name:Xt("excalidrawConnectElements"),displayName:"Connect Drawing Elements",toolReferenceName:"excalidrawConnectElements",description:"Draw an arrow from one element to another and bind it to both, so it follows them when either moves. Excalidraw works out where the arrow should meet each shape. Use this rather than adding an arrow with hand-computed points whenever both ends are existing shapes.",parameters:Gt(dm),operation:"excalidrawConnectElements",config:{...Fr,invocationMessage:()=>"Connecting two shapes"},tags:[...Zt,"edit"]},kN={name:Xt("excalidrawSetAppState"),displayName:"Set Drawing Canvas",toolReferenceName:"excalidrawSetAppState",description:"Set the canvas behind a drawing: its background colour and its grid. This is about the canvas, not the shapes on it — use excalidrawUpdateElements to recolour a shape.",parameters:Gt(fm),operation:"excalidrawSetAppState",config:{...Fr,invocationMessage:()=>"Setting up the canvas"},tags:[...Zt,"edit"]},IN={name:Xt("excalidrawResize"),displayName:"Resize Drawing",toolReferenceName:"excalidrawResize",description:"Set how large the drawing is rendered in the document. This scales the picture on the page; it does not move or resize anything inside it. Omit width and height to go back to sizing by content.",parameters:Gt(gm),operation:"excalidrawResize",config:{...Fr,invocationMessage:()=>"Resizing the drawing"},tags:[...Zt,"edit"]},TN={name:Xt("excalidrawClearScene"),displayName:"Clear Drawing",toolReferenceName:"excalidrawClearScene",description:"Empty a drawing, keeping the block so it can be drawn into again. To remove the drawing from the document altogether, use deleteBlocks with its block_id.",parameters:Gt(pm),operation:"excalidrawClearScene",config:{confirmationMessage:()=>"Empty this drawing?",invocationMessage:()=>"Emptying the drawing",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"low"},tags:[...Zt,"edit","delete"]},EN={name:Xt("excalidrawFromMermaid"),displayName:"Draw from Mermaid",toolReferenceName:"excalidrawFromMermaid",description:"Turn Mermaid source into a real Excalidraw drawing — shapes and arrows that can then be moved, recoloured and edited like anything else you drew. This is the fastest way to produce a flowchart, sequence diagram or class diagram: write the Mermaid and let the layout be worked out for you, rather than placing boxes by hand. Give blockId to replace an existing drawing, or afterId to insert a new one.",parameters:Gt(hm),operation:"excalidrawFromMermaid",config:{confirmationMessage:n=>n.blockId?"Replace this drawing with the Mermaid diagram?":"Insert the Mermaid diagram as a drawing?",invocationMessage:()=>"Drawing the Mermaid diagram",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"high"},tags:[...Zt,"insert","mermaid"]},_m=[bN,EN,yN,wN,xN,CN,vN,SN,kN,IN,TN],Ba=()=>({elements:[],appState:{},files:{}});function mu(n){if(!n)return Ba();let e;try{e=JSON.parse(n)}catch{return Ba()}if(Array.isArray(e))return{elements:e,appState:{},files:{}};if(!e||typeof e!="object")return Ba();const t=e;return{elements:Array.isArray(t.elements)?t.elements:[],appState:t.appState??{},files:t.files??{}}}function bu(n){return JSON.stringify({elements:n.elements,appState:n.appState,files:n.files})}const As=n=>n.elements.filter(e=>!e?.isDeleted);function NN(n){const e={id:String(n?.id??""),type:String(n?.type??"unknown"),x:Number(n?.x??0),y:Number(n?.y??0),width:Number(n?.width??0),height:Number(n?.height??0)};return typeof n?.text=="string"&&n.text.length>0&&(e.text=n.text),n?.strokeColor&&(e.strokeColor=String(n.strokeColor)),n?.backgroundColor&&(e.backgroundColor=String(n.backgroundColor)),n?.containerId&&(e.containerId=String(n.containerId)),n?.startBinding?.elementId&&(e.startBoundElementId=String(n.startBinding.elementId)),n?.endBinding?.elementId&&(e.endBoundElementId=String(n.endBinding.elementId)),Array.isArray(n?.groupIds)&&n.groupIds.length>0&&(e.groupIds=n.groupIds.map(String)),e}function LN(n){const e=new Map;for(const t of n)t?.type==="text"&&t?.containerId&&t?.text&&e.set(String(t.containerId),String(t.text));return n.map(t=>{const r=NN(t);if(r.text===void 0){const o=e.get(r.id);o&&(r.text=o)}return r})}function yu(n){const e=As(n);if(e.length===0)return"empty drawing";const t=new Map,r=[];for(const i of e){const a=String(i?.type??"unknown");if(a==="text"){const l=String(i?.text??"").trim();if(l&&r.push(l),i?.containerId)continue}t.set(a,(t.get(a)??0)+1)}const o=[...t.entries()].sort((i,a)=>a[1]-i[1]||i[0].localeCompare(a[0])).map(([i,a])=>`${a} ${i}${a>1?"s":""}`).join(", "),s=r.slice(0,3).join(", ");return s?`${o}: ${s}`:o}function wu(n){return{...n,version:Number(n?.version??1)+1,versionNonce:Math.floor(Math.random()*2**31),updated:Date.now()}}const Ai=4;function mm(n,e){let t=null,r;if(n.getEditorState().read(()=>{const o=Q(e);o&&(r=o.getType?.(),r==="excalidraw"&&(t=o))}),!t)throw new Error(r?`Block '${e}' is a '${r}', not a drawing. Call excalidrawListDrawings to find the drawings in this document.`:`No block '${e}' in this document. Call excalidrawListDrawings to find the drawings in this document.`);return t}function kn(n,e){const t=mm(n,e);let r="";return n.getEditorState().read(()=>{r=t.__data??""}),mu(r)}function Br(n,e,t){const r=bu(t);return new Promise(o=>{n.update(()=>{const s=Q(e);s?.setData&&s.setData(r)},{onUpdate:()=>o()})})}const gn=(n,e,t)=>({success:!0,blockId:n,elementCount:As(e).length,...t});let ON=0;const AN=()=>`dla-${Date.now().toString(36)}-${(ON+=1).toString(36)}`;function RN(n,e){const{label:t,startId:r,endId:o,fontSize:s,text:i,children:a,name:l,...c}=n,u={...c,id:e};return n.type==="text"?(u.text=i??t??"",s&&(u.fontSize=s)):t&&(u.label=s?{text:t,fontSize:s}:{text:t}),(n.type==="arrow"||n.type==="line")&&(r&&(u.start={id:r}),o&&(u.end={id:o})),(n.type==="frame"||n.type==="magicframe")&&(u.children=a??[],l&&(u.name=l)),u}async function xu(n,e){const{convertToExcalidrawElements:t}=await me(async()=>{const{convertToExcalidrawElements:i}=await import("./percentages-BXMCSKIN-DhE6_GLO.js").then(a=>a.i);return{convertToExcalidrawElements:i}},[],import.meta.url),r=[],o=n.map(i=>{let a=String(i.id??"").trim();return(!a||e.has(a))&&(a=AN()),e.add(a),r.push(a),RN(i,a)});return{elements:[...t(o,{regenerateIds:!1})],ids:r}}const Fl=n=>({x:Number(n.x??0)+Number(n.width??0)/2,y:Number(n.y??0)+Number(n.height??0)/2});function rg(n,e){const t=Fl(n),r=e.x-t.x,o=e.y-t.y;if(r===0&&o===0)return t;const s=Number(n.width??0)/2+Ai,i=Number(n.height??0)/2+Ai,a=Math.min(r===0?1/0:Math.abs(s/r),o===0?1/0:Math.abs(i/o));return{x:t.x+r*a,y:t.y+o*a}}function MN(n,e){const t=Array.isArray(n.boundElements)?[...n.boundElements]:[];return t.some(r=>r?.id===e)||t.push({id:e,type:"arrow"}),wu({...n,boundElements:t})}function bm(n,e,t,r){const o=n.elements.find(c=>c.id===t),s=n.elements.find(c=>c.id===r);if(!o||!s){const c=o?r:t;throw new Error(`No element '${c}' in this drawing. Call excalidrawReadScene to see the element ids it holds.`)}const i=rg(o,Fl(s)),a=rg(s,Fl(o)),l={...e,x:i.x,y:i.y,width:Math.abs(a.x-i.x),height:Math.abs(a.y-i.y),points:[[0,0],[a.x-i.x,a.y-i.y]],startBinding:{elementId:t,focus:0,gap:Ai},endBinding:{elementId:r,focus:0,gap:Ai}};return n.elements=n.elements.map(c=>c.id===t||c.id===r?MN(c,String(e.id)):c),l}const $N=async(n,e)=>{const t=e.elements??[],r=t.length>0?await xu(t,new Set):{elements:[],ids:[]},o={elements:r.elements,appState:{},files:{}},s=await n.insertBlock({block_id:"",block_type:"excalidraw",source:"",metadata:{data:bu(o),width:e.width,height:e.height}},String(e.afterId??"BOTTOM"));if(!s.success||!s.blockId)throw new Error(s.error||"Failed to insert the drawing");return gn(s.blockId,o,{createdIds:r.ids,message:`Drawing inserted with ${r.elements.length} element(s)`})},DN=async n=>{const t=(await n.getBlocks("detailed")).filter(r=>r.block_type==="excalidraw").map(r=>{const o=mu(r.metadata?.data);return{blockId:r.block_id,elementCount:As(o).length,description:yu(o),width:r.metadata?.width,height:r.metadata?.height}});return{drawings:t,count:t.length}},PN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t),o=As(r);return{blockId:t,elementCount:o.length,elements:e.detail==="full"?o:LN(o),appState:r.appState,description:yu(r)}},jN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t),o=new Set(r.elements.map(u=>String(u.id))),s=e.elements??[],i=new Set(s.map(u=>String(u.id??"")).filter(Boolean)),a=new Map,l=s.map((u,f)=>{const{startId:d,endId:p}=u;if((u.type==="arrow"||u.type==="line")&&d&&p&&(!i.has(String(d))||!i.has(String(p)))){a.set(f,{fromId:String(d),toId:String(p)});const{startId:_,endId:m,...y}=u;return y}return u}),c=await xu(l,o);r.elements=[...r.elements,...c.elements];for(const[u,f]of a){const d=c.ids[u],p=r.elements.find(h=>h.id===d);if(p){const h=bm(r,p,f.fromId,f.toId);r.elements=r.elements.map(_=>_.id===d?h:_)}}return await Br(n.editor,t,r),gn(t,r,{createdIds:c.ids,message:`Added ${c.elements.length} element(s)`})},FN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t),o=e.updates??[],s=new Map;for(const l of r.elements)l?.type==="text"&&l?.containerId&&s.set(String(l.containerId),String(l.id));const i=new Map,a=[];for(const l of o){const c=String(l.id),u=r.elements.find(_=>_.id===c);if(!u){a.push(c);continue}const{id:f,text:d,...p}=l,h=u.type!=="text"&&s.get(c);d!==void 0&&(h?i.set(h,{...i.get(h)??{},text:d,originalText:d}):(p.text=d,p.originalText=d)),Object.keys(p).length>0&&i.set(c,{...i.get(c)??{},...p})}if(a.length>0)throw new Error(`No element(s) ${a.map(l=>`'${l}'`).join(", ")} in this drawing. Call excalidrawReadScene to see the element ids it holds.`);return r.elements=r.elements.map(l=>{const c=i.get(String(l.id));return c?wu({...l,...c}):l}),await Br(n.editor,t,r),gn(t,r,{message:`Updated ${o.length} element(s)`})},BN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t),o=new Set(e.elementIds.map(String)),s=new Set(o);for(const a of r.elements)a?.containerId&&o.has(String(a.containerId))&&s.add(String(a.id));const i=r.elements.length;return r.elements=r.elements.filter(a=>!s.has(String(a.id))).map(a=>{const l={};if(s.has(String(a.startBinding?.elementId))&&(l.startBinding=null),s.has(String(a.endBinding?.elementId))&&(l.endBinding=null),Array.isArray(a.boundElements)){const c=a.boundElements.filter(u=>!s.has(String(u?.id)));c.length!==a.boundElements.length&&(l.boundElements=c)}return Object.keys(l).length>0?wu({...a,...l}):a}),await Br(n.editor,t,r),gn(t,r,{message:`Removed ${i-r.elements.length} element(s)`})},UN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t),o=String(e.fromId),s=String(e.toId),i=new Set(r.elements.map(d=>String(d.id))),{elements:a,ids:l}=await xu([{type:"arrow",x:0,y:0,...e.label?{label:e.label}:{},...e.strokeColor?{strokeColor:e.strokeColor}:{},...e.strokeStyle?{strokeStyle:e.strokeStyle}:{}}],i),c=l[0];r.elements=[...r.elements,...a];const u=r.elements.find(d=>d.id===c),f=bm(r,u,o,s);return r.elements=r.elements.map(d=>d.id===c?f:d),await Br(n.editor,t,r),gn(t,r,{createdIds:[c],message:`Connected '${o}' to '${s}'`})},zN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t);return e.viewBackgroundColor!==void 0&&(r.appState.viewBackgroundColor=e.viewBackgroundColor),e.gridSize!==void 0&&(r.appState.gridSize=Number(e.gridSize)||null),await Br(n.editor,t,r),gn(t,r,{message:"Canvas updated"})},KN=async(n,e)=>{const t=String(e.blockId),r=mm(n.editor,t),o=e.width===void 0?"inherit":Number(e.width),s=e.height===void 0?"inherit":Number(e.height);await new Promise(a=>{n.editor.update(()=>{r.setWidth(o),r.setHeight(s)},{onUpdate:()=>a()})});const i=kn(n.editor,t);return gn(t,i,{message:o==="inherit"&&s==="inherit"?"Drawing sized to its content":`Drawing sized to ${o} x ${s}`})},WN=async(n,e)=>{const t=String(e.blockId),r=kn(n.editor,t),o=As(r).length;return r.elements=[],r.files={},await Br(n.editor,t,r),gn(t,r,{message:`Emptied the drawing (${o} element(s) removed)`})},JN=async(n,e)=>{const{parseMermaidToExcalidraw:t}=await me(async()=>{const{parseMermaidToExcalidraw:c}=await import("./index-C-4crJTg.js").then(u=>u.an);return{parseMermaidToExcalidraw:c}},[],import.meta.url),{convertToExcalidrawElements:r}=await me(async()=>{const{convertToExcalidrawElements:c}=await import("./percentages-BXMCSKIN-DhE6_GLO.js").then(u=>u.i);return{convertToExcalidrawElements:c}},[],import.meta.url);let o;try{o=await t(String(e.mermaid),{fontSize:e.fontSize?Number(e.fontSize):void 0})}catch(c){const u=c instanceof Error?c.message:String(c);throw new Error(`That Mermaid source did not parse: ${u}. Flowcharts, sequence diagrams and class diagrams are the ones that convert to shapes.`,{cause:c})}const s=[...r(o.elements)],i=o.files??{};if(e.blockId){const c=String(e.blockId),u=kn(n.editor,c);return u.elements=s,u.files=i,await Br(n.editor,c,u),gn(c,u,{createdIds:s.map(f=>String(f.id)),message:`Drawing replaced with ${s.length} element(s) from Mermaid`})}const a={elements:s,appState:{},files:i},l=await n.insertBlock({block_id:"",block_type:"excalidraw",source:"",metadata:{data:bu(a)}},String(e.afterId??"BOTTOM"));if(!l.success||!l.blockId)throw new Error(l.error||"Failed to insert the drawing");return gn(l.blockId,a,{createdIds:s.map(c=>String(c.id)),message:`Drawing inserted with ${s.length} element(s) from Mermaid`})},Bl={excalidrawInsertNode:$N,excalidrawListDrawings:DN,excalidrawReadScene:PN,excalidrawAddElements:jN,excalidrawUpdateElements:FN,excalidrawDeleteElements:BN,excalidrawConnectElements:UN,excalidrawSetAppState:zN,excalidrawResize:KN,excalidrawClearScene:WN,excalidrawFromMermaid:JN};function Qt(n,e){return{name:n,async execute(t,r){const o=xy(e,t??{},n);if(!r.documentId)throw new Error(`Document ID is required for ${n}. Ensure the tool execution context includes a valid documentId.`);if(!r.executor)throw new Error(`Executor is required for ${n}. This should be provided by the platform (DefaultExecutor, BridgeExecutor, etc.)`);try{return await r.executor.execute(n,o)}catch(s){const i=s instanceof Error?s.message:String(s);throw new Error(`Failed to run ${n}: ${i}`,{cause:s})}}}}const HN=Qt("excalidrawInsertNode",sm),qN=Qt("excalidrawListDrawings",im),VN=Qt("excalidrawReadScene",am),YN=Qt("excalidrawAddElements",lm),GN=Qt("excalidrawUpdateElements",cm),XN=Qt("excalidrawDeleteElements",um),ZN=Qt("excalidrawConnectElements",dm),QN=Qt("excalidrawSetAppState",fm),e2=Qt("excalidrawResize",gm),t2=Qt("excalidrawClearScene",pm),n2=Qt("excalidrawFromMermaid",hm),ci={excalidrawInsertNode:HN,excalidrawListDrawings:qN,excalidrawReadScene:VN,excalidrawAddElements:YN,excalidrawUpdateElements:GN,excalidrawDeleteElements:XN,excalidrawConnectElements:ZN,excalidrawSetAppState:QN,excalidrawResize:e2,excalidrawClearScene:t2,excalidrawFromMermaid:n2},og={name:"excalidraw",definitions:_m,operations:ci,handlers:Bl};function HA(){const n=[];for(const e of _m)ci[e.operation]||n.push(`${e.name} points at operation '${e.operation}', which does not exist`),e.toolReferenceName.startsWith("excalidraw")||n.push(`${e.name} is not named for the plugin it belongs to`);for(const e of Object.keys(ci))Bl[e]||n.push(`operation '${e}' has no handler`);for(const e of Object.keys(Bl))ci[e]||n.push(`handler '${e}' has no operation`);return n}const r2=C.lazy(()=>me(()=>import("./ExcalidrawModal-D_DmAro7.js"),[],import.meta.url)),Cu=he();function o2(){const[n]=fe(),[e,t]=C.useState(!1),o=Ex()?.lexicalId;C.useEffect(()=>{if(!n.hasNodes([Un]))throw new Error("ExcalidrawPlugin: ExcalidrawNode not registered");return n.registerCommand(Cu,()=>(t(!0),!0),V)},[n]),C.useEffect(()=>{if(o)return Zr.getState().registerPluginTools(o,og),()=>{Zr.getState().unregisterPluginTools(o,og.name)}},[o]);const s=(l,c,u)=>{n.update(()=>{const f=ou();f.setData(JSON.stringify({elements:l,appState:c,files:u})),pr([f]),yt(f.getParentOrThrow())&&sc(f,ne).selectEnd()}),t(!1)},i=()=>{t(!1)},a=()=>{t(!1)};return e?w.jsx(C.Suspense,{fallback:null,children:w.jsx(r2,{initialElements:[],initialAppState:{},initialFiles:{},isShown:e,onSave:s,onDelete:i,onClose:a,closeOnClickOutside:!1})}):null}const s2=C.lazy(()=>me(()=>import("./DeckComponent-qAMqKLzs.js"),[],import.meta.url));function i2(){return{deck:{title:"Untitled deck",template:"datalayer"},slides:[{type:"title",title:"A new slide",meta:"Double-click to edit its specification"}]}}function a2(n){const e=n.getAttribute("data-lexical-deck");if(!e)return null;try{return{node:Su(JSON.parse(e))}}catch{return null}}class Do extends Oo{__spec;static getType(){return"deck"}static clone(e){return new Do(e.__spec,e.__format,e.__key)}static importJSON(e){const t=Su(e.spec);return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"deck",version:1,spec:this.__spec}}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-deck")?{conversion:a2,priority:2}:null}}exportDOM(){const e=document.createElement("div");e.setAttribute("data-lexical-deck",JSON.stringify(this.__spec));const t=document.createElement("p");return t.textContent=this.__spec.deck?.title||"Deck",e.appendChild(t),{element:e}}constructor(e,t,r){super(t,r),this.__spec=e??i2()}getSpec(){return this.getLatest().__spec}setSpec(e){this.getWritable().__spec=e}getTextContent(){return this.__spec.deck?.title||""}updateDOM(){return!1}decorate(e,t){const r=t.theme.embedBlock||{};return w.jsx(C.Suspense,{fallback:null,children:w.jsx(s2,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),spec:this.__spec})})}isTopLevel(){return!0}}function Su(n){return new Do(n)}function qA(n){return n instanceof Do}const vu=he("INSERT_DECK_COMMAND");function l2(n){if(!n.hasNodes([Do]))throw new Error("DeckExtension: DeckNode not registered on editor");return n.registerCommand(vu,e=>(Yn(Su(e)),!0),V)}const c2=pe({name:"@datalayer/jupyter-lexical/Deck",nodes:()=>[Do],register:l2}),sg="Kept in this page’s memory only: it is lost when the page reloads, and nobody else sees it. Download it to keep it.",ym={position:"relative",width:"100%",aspectRatio:"16 / 9",borderRadius:2,overflow:"hidden",bg:"black"};function u2(n){const e=Math.max(0,Math.floor(n/1e3));return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}function d2(n){const e=n.currentTarget;if(Number.isFinite(e.duration))return;const t=()=>{e.removeEventListener("timeupdate",t),e.currentTime=0};e.addEventListener("timeupdate",t),e.currentTime=Number.MAX_SAFE_INTEGER}function f2({recordingId:n,recording:e}){const t=C.useRef(null),[r,o]=C.useState(()=>Date.now());return C.useEffect(()=>{t.current&&(t.current.srcObject=e.preview)},[e.preview]),C.useEffect(()=>{const s=window.setInterval(()=>o(Date.now()),500);return()=>window.clearInterval(s)},[]),w.jsxs(Y,{sx:{display:"grid",gap:2},children:[w.jsx(Y,{sx:ym,children:w.jsx("video",{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"100%",objectFit:"contain"}})}),w.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[w.jsx(Y,{"aria-hidden":!0,sx:{width:10,height:10,borderRadius:"50%",bg:"danger.fg"}}),w.jsx(Le,{sx:{fontFamily:"mono"},"aria-live":"off",children:u2(r-e.startedAt)}),w.jsx(ft,{variant:"danger",leadingVisual:Sy,onClick:()=>pu(n),sx:{ml:"auto"},children:"Stop"})]})]})}function g2({className:n,format:e,nodeKey:t,recordingId:r,recorded:o}){const[s]=fe(),i=Or(),a=C.useSyncExternalStore(NE,()=>LE(r)),l=FE(o,a),[c,u]=C.useState("screen"),[f,d]=C.useState(!0),p=C.useCallback(x=>{s.update(()=>{const S=Q(t);wm(S)&&S.setRecorded(x)})},[s,t]),h=()=>{PE(r,{source:c,microphone:f},()=>p(!0))},_=()=>{jE(r),p(!1)},m=x=>{const S=document.createElement("a");S.href=x.url,S.download=ME(x),S.click()};let y;return a?.status==="recording"?y=w.jsx(f2,{recordingId:r,recording:a}):a?.status==="recorded"?y=w.jsxs(Y,{sx:{display:"grid",gap:2},children:[w.jsx(Y,{sx:ym,children:w.jsx("video",{src:a.url,controls:!0,playsInline:!0,onLoadedMetadata:d2,style:{width:"100%",height:"100%",objectFit:"contain"}})}),w.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:2},children:[w.jsx(Le,{sx:{color:"fg.muted",fontSize:0,flex:"1 1 240px"},children:sg}),w.jsx(ft,{leadingVisual:Cy,onClick:()=>m(a),children:"Download"}),i&&w.jsx(ft,{onClick:_,children:"Record again"})]})]}):l==="lost"?y=w.jsxs(Y,{sx:{display:"grid",gap:2,justifyItems:"start"},children:[w.jsx(Le,{sx:{color:"fg.muted",fontSize:1},children:"The video recorded here is gone: it was kept in the memory of the page that recorded it, and that page has been reloaded or closed."}),i&&w.jsx(ft,{onClick:()=>p(!1),children:"Record a new one"})]}):i?y=w.jsxs(Y,{sx:{display:"grid",gap:2},children:[w.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[w.jsx(uc,{size:16}),w.jsx(Le,{sx:{fontWeight:"bold"},children:"Video"})]}),w.jsxs(Le,{sx:{color:"fg.muted",fontSize:0},children:["Recorded by this browser, with no account. ",sg]}),AE()?w.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:3},children:[w.jsxs(oa,{"aria-label":"What to record",size:"small",children:[w.jsx(oa.Button,{selected:c==="screen",onClick:()=>u("screen"),children:"Screen"}),w.jsx(oa.Button,{selected:c==="camera",onClick:()=>u("camera"),children:"Camera"})]}),w.jsxs(At,{children:[w.jsx(jg,{checked:f,onChange:x=>d(x.target.checked)}),w.jsx(At.Label,{children:"Microphone"})]}),w.jsx(ft,{variant:"primary",onClick:h,children:"Record"})]}):w.jsx(Le,{sx:{color:"danger.fg",fontSize:1},children:"This browser cannot record video."}),a?.status==="failed"&&w.jsx(Le,{role:"alert",sx:{color:"danger.fg",fontSize:1},children:a.message})]}):y=w.jsx(Le,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:"A video goes here."}),w.jsx(gs,{className:n,format:e,nodeKey:t,children:w.jsx(Y,{"data-lexical-video":l,onFocusCapture:()=>s.update(()=>Ee(null)),sx:{p:l==="recorded"||l==="recording"?0:3,border:"1px dashed",borderColor:l==="recorded"||l==="recording"?"transparent":"border.default",borderRadius:2,bg:l==="recorded"||l==="recording"?"transparent":"canvas.subtle"},children:y})})}class Wn extends Oo{__recordingId;__recorded;static getType(){return"video"}static clone(e){return new Wn(e.__recordingId,e.__recorded,e.__format,e.__key)}static importJSON(e){const t=new Wn(e.recordingId,e.recorded);return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"video",version:1,recordingId:this.__recordingId,recorded:this.__recorded}}exportDOM(){return{element:null}}constructor(e,t=!1,r,o){super(r,o),this.__recordingId=e||OE(),this.__recorded=t}getRecordingId(){return this.getLatest().__recordingId}isRecorded(){return this.getLatest().__recorded}setRecorded(e){this.getWritable().__recorded=e}getTextContent(){return""}updateDOM(){return!1}decorate(e,t){const r=t.theme.embedBlock||{};return w.jsx(g2,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),recordingId:this.__recordingId,recorded:this.__recorded})}isTopLevel(){return!0}}function p2(){return new Wn}function wm(n){return n instanceof Wn}const ku=he("INSERT_VIDEO_COMMAND");function h2(n){if(!n.hasNodes([Wn]))throw new Error("VideoExtension: VideoNode not registered on editor");return de(n.registerCommand(ku,()=>(Yn(p2()),!0),V),n.registerMutationListener(Wn,(e,{prevEditorState:t})=>{for(const[r,o]of e){if(o!=="destroyed")continue;const s=t.read(()=>{const i=Q(r);return wm(i)?i.__recordingId:void 0});s&&pu(s)}},{skipInitialization:!0}))}const _2=pe({name:"@datalayer/jupyter-lexical/Video",nodes:()=>[Wn],register:h2});function m2({onConfirm:n,onClose:e}){const[t,r]=C.useState("5"),[o,s]=C.useState("5"),i=C.useRef(null),a=()=>{const c=parseInt(t,10),u=parseInt(o,10);c>0&&c<=500&&u>0&&u<=50&&n(c,u)},l=c=>{c.key==="Enter"&&a()};return w.jsx(Fg,{title:"Insert Table",onClose:()=>e(),width:"small",height:"auto",initialFocusRef:i,footerButtons:[{buttonType:"default",content:"Cancel",onClick:e},{buttonType:"primary",content:"Confirm",onClick:a}],children:w.jsxs(Y,{sx:{display:"flex",flexDirection:"column",gap:3},onKeyDown:l,children:[w.jsxs(At,{children:[w.jsx(At.Label,{children:"Rows"}),w.jsx(yn,{ref:i,type:"number",min:1,max:500,value:t,onChange:c=>r(c.target.value),block:!0})]}),w.jsxs(At,{children:[w.jsx(At.Label,{children:"Columns"}),w.jsx(yn,{type:"number",min:1,max:50,value:o,onChange:c=>s(c.target.value),block:!0})]})]})})}const rs=he();function xm(){const[n]=fe(),[e,t]=C.useState(!1);C.useEffect(()=>n.registerCommand(rs,()=>(t(!0),!0),V),[n]);const r=(s,i)=>{n.dispatchCommand(Cc,{rows:s.toString(),columns:i.toString()}),t(!1)},o=()=>{t(!1)};return e?w.jsx(m2,{onConfirm:r,onClose:o}):null}function VA(){return w.jsxs(w.Fragment,{children:[w.jsx(Uh,{}),w.jsx(xm,{})]})}const Iu=he("INSERT_EQUATION_COMMAND");function Cm(n){if(!n.hasNodes([Gn]))throw new Error("EquationsPlugins: EquationsNode not registered on editor");return n.registerCommand(Iu,e=>{const{equation:t,inline:r}=e,o=Yi(t,r);return pr([o]),yt(o.getParentOrThrow())&&sc(o,ne).selectEnd(),!0},V)}const Sm=pe({name:"@datalayer/jupyter-lexical/Equations",nodes:()=>[Gn],register:Cm});function Tu({activeEditor:n,onClose:e}){const t=C.useCallback((r,o)=>{n.dispatchCommand(Iu,{equation:r,inline:o}),e()},[n,e]);return w.jsx(zw,{onConfirm:t})}const ig=()=>{const[n]=fe();return C.useEffect(()=>Cm(n),[n]),null},b2=Object.freeze(Object.defineProperty({__proto__:null,EquationsPlugin:ig,INSERT_EQUATION_COMMAND:Iu,InsertEquationDialog:Tu,default:ig},Symbol.toStringTag,{value:"Module"}));class Ke extends V_{title;icon;keywords;keyboardShortcut;onSelect;disabled;constructor(e,t){super(e),this.title=e,this.keywords=t.keywords||[],this.icon=t.icon,this.keyboardShortcut=t.keyboardShortcut,this.onSelect=t.onSelect.bind(this),this.disabled=t.disabled||!1}}function y2({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){const s=C.useCallback(l=>o.setRefElement(l),[o]),i=o.disabled?void 0:t,a=o.disabled?void 0:r;return w.jsxs(Y,{as:"li",tabIndex:-1,ref:s,role:"option","aria-selected":e&&!o.disabled,"aria-disabled":o.disabled,id:"typeahead-item-"+n,onMouseEnter:a,onClick:i,sx:{display:"flex",alignItems:"center",gap:2,px:2,py:"6px",borderRadius:2,cursor:o.disabled?"not-allowed":"pointer",opacity:o.disabled?.5:1,bg:e&&!o.disabled?"actionListItem.default.selectedBg":"transparent",color:"var(--fgColor-default)","&:hover":o.disabled?{}:{bg:"actionListItem.default.hoverBg"},listStyle:"none"},children:[w.jsx(Y,{sx:{display:"flex",alignItems:"center",color:"var(--fgColor-muted)",flexShrink:0},children:o.icon}),w.jsx(Le,{sx:{fontSize:1},children:o.title})]},o.key)}const w2=({kernel:n,initCode:e=""}={})=>{const[t]=fe(),[r,o]=$o(),[s,i]=C.useState(null),a=Y_("/",{minLength:0}),l=C.useCallback(()=>{const f=[];if(s==null)return f;const d=new RegExp(/^([1-9]|10)x([1-9]|10)$/),p=new RegExp(/^([1-9]|10)x?$/),h=d.exec(s),_=p.exec(s);if(h){const[m,y]=h[0].split("x").map(x=>parseInt(x,10));f.push(new Ke(`${m}x${y} Table`,{icon:w.jsx(ei,{size:16}),keywords:["table"],onSelect:()=>t.dispatchCommand(rs,void 0)}))}else if(_){const m=parseInt(_[0],10);f.push(...Array.from({length:5},(y,x)=>x+1).map(y=>new Ke(`${m}x${y} Table`,{icon:w.jsx(ei,{size:16}),keywords:["table"],onSelect:()=>t.dispatchCommand(rs,void 0)})))}return f},[t,s]),c=C.useMemo(()=>{const f=[new Ke("Jupyter Cell",{icon:w.jsx(ir,{size:16}),keywords:["javascript","python","js","codeblock","jupyter"],onSelect:()=>{t.dispatchCommand(Ei,{code:e,outputs:Nl,loading:"Loading..."})}}),new Ke("Marimo Cell",{icon:w.jsx(ir,{size:16}),keywords:["marimo","reactive","python","cell"],onSelect:()=>{t.dispatchCommand(Ei,{code:e,outputs:Nl,loading:"Loading...",variant:"marimo"})}}),new Ke("Paragraph",{icon:w.jsx($p,{size:16}),keywords:["normal","paragraph","p","text"],onSelect:()=>t.update(()=>{const p=P();j(p)&&Rn(p,()=>ne())})}),...Array.from({length:3},(p,h)=>h+1).map(p=>new Ke(`Heading ${p}`,{icon:w.jsx(Xy,{size:16}),keywords:["heading","header",`h${p}`],onSelect:()=>t.update(()=>{const h=P();j(h)&&Rn(h,()=>cn(`h${p}`))})})),new Ke("Numbered List",{icon:w.jsx(Dp,{size:16}),keywords:["numbered list","ordered list","ol"],onSelect:()=>t.dispatchCommand(wc,void 0)}),new Ke("Bulleted List",{icon:w.jsx(Ep,{size:16}),keywords:["bulleted list","unordered list","ul"],onSelect:()=>t.dispatchCommand(yc,void 0)}),new Ke("Check List",{icon:w.jsx(vy,{size:16}),keywords:["check list","todo list"],onSelect:()=>t.dispatchCommand(bc,void 0)}),new Ke("Table",{icon:w.jsx(ei,{size:16}),keywords:["table","grid","spreadsheet"],onSelect:()=>{ge("[ComponentPicker] Table selected, dispatching INSERT_TABLE_WITH_DIALOG_COMMAND"),t.dispatchCommand(rs,void 0)}}),new Ke("Collapsible Container",{icon:w.jsx(lc,{size:16}),keywords:["collapsible","collapse","expand","toggle","accordion","container"],onSelect:()=>t.dispatchCommand(_u,void 0)}),new Ke("Excalidraw",{icon:w.jsx(ky,{size:16}),keywords:["excalidraw","drawing","diagram","sketch","whiteboard","draw"],onSelect:()=>t.dispatchCommand(Cu,void 0)}),new Ke("Video",{icon:w.jsx(uc,{size:16}),keywords:["video","record","recording","screen","camera","webcam"],onSelect:()=>t.dispatchCommand(ku,void 0)}),new Ke("Loom Video",{icon:w.jsx(ks,{size:16}),keywords:["loom","video","record","recording","screen"],onSelect:()=>t.dispatchCommand(ta,void 0)}),new Ke("Deck Slide",{icon:w.jsx(Zo,{size:16}),keywords:["deck","slide","slides","presentation","pitch"],onSelect:()=>t.dispatchCommand(vu,void 0)}),new Ke("Quote",{icon:w.jsx(Pp,{size:16}),keywords:["block quote"],onSelect:()=>t.update(()=>{const p=P();j(p)&&Rn(p,()=>Sn())})}),new Ke("Code",{icon:w.jsx(ir,{size:16}),keywords:["javascript","python","js","codeblock"],onSelect:()=>t.update(()=>{const p=P();if(j(p))if(p.isCollapsed())Rn(p,()=>Ze());else{const h=p.getTextContent(),_=Ze();p.insertNodes([_]),p.insertRawText(h)}})}),new Ke("Divider",{icon:w.jsx(bi,{size:16}),keywords:["horizontal rule","divider","hr"],onSelect:()=>t.dispatchCommand(cc,void 0)}),...gu.map(p=>new Ke(`Embed ${p.contentName}`,{icon:p.icon,keywords:[...p.keywords,"embed"],onSelect:()=>t.dispatchCommand(fu,p.type)})),new Ke("Equation",{icon:w.jsx(Iy,{size:16}),keywords:["equation","latex","math"],onSelect:()=>o("Insert Equation",p=>w.jsx(Tu,{activeEditor:t,onClose:p}))}),new Ke("GIF",{icon:w.jsx(Zo,{size:16}),keywords:["gif","animate","image","file"],onSelect:()=>{Fc().then(p=>{p&&t.dispatchCommand(Ls,p)})}}),new Ke("Image",{icon:w.jsx(Zo,{size:16}),keywords:["image","photo","picture","file"],onSelect:()=>o("Insert Image",p=>w.jsx(Hh,{activeEditor:t,onClose:p}))}),...["left","center","right","justify"].map(p=>new Ke(`Align ${p}`,{icon:p==="left"?w.jsx(Zy,{size:16}):p==="right"?w.jsx(Qy,{size:16}):w.jsx(bi,{size:16}),keywords:["align","justify",p],onSelect:()=>t.dispatchCommand(An,p)}))],d=l();return s?[...d,...f.filter(p=>new RegExp(s,"gi").exec(p.title)||p.keywords!=null?p.keywords.some(h=>new RegExp(s,"gi").exec(h)):!1)]:f},[t,l,s,o,n,e]),u=C.useCallback((f,d,p,h)=>{f.disabled||t.update(()=>{d&&d.remove(),f.onSelect(h),p()})},[t]);return w.jsxs(w.Fragment,{children:[r,w.jsx(G_,{onQueryChange:i,onSelectOption:u,triggerFn:a,options:c,menuRenderFn:(f,{selectedIndex:d,selectOptionAndCleanUp:p,setHighlightedIndex:h})=>f.current&&c.length?Tt.createPortal(w.jsx(Y,{onMouseDown:_=>{_.preventDefault()},sx:{position:"relative",zIndex:1e3,bg:"var(--overlay-bgColor)",border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,boxShadow:"var(--shadow-floating-large, 0 0 0 1px #d1d9e0, 0 40px 80px 0 #25292e3d)",p:1,maxHeight:300,overflow:"auto",minWidth:200},children:w.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0},children:c.map((_,m)=>w.jsx(y2,{index:m,isSelected:d===m,onClick:()=>{_.disabled||(h(m),p(_))},onMouseEnter:()=>{_.disabled||h(m)},option:_},_.key))})}),f.current):null})]})},Ul=4,x2=2,C2="draggable-block-menu",ag="application/x-lexical-drag-block",lg=28,S2=1,v2=-1,cg=0;let ui=1/0;function k2(n){return n===0?1/0:ui>=0&&ui<n?ui:Math.floor(n/2)}function I2(n){return n.getEditorState().read(()=>se().getChildrenKeys())}function vm(n){const e=(l,c)=>l?parseFloat(window.getComputedStyle(l)[c]):0,{marginTop:t,marginBottom:r}=window.getComputedStyle(n),o=e(n.previousElementSibling,"marginBottom"),s=e(n.nextElementSibling,"marginTop"),i=Math.max(parseFloat(t),o);return{marginBottom:Math.max(parseFloat(r),s),marginTop:i}}function Ua(n,e,t,r=!1){const o=n.getBoundingClientRect(),s=I2(e);let i=null;return e.getEditorState().read(()=>{if(r){const[c,u]=[e.getElementByKey(s[0]),e.getElementByKey(s[s.length-1])],[f,d]=[c?.getBoundingClientRect(),u?.getBoundingClientRect()];if(f&&d){const p=Dn(c),h=Dn(u);if(t.y/p<f.top?i=c:t.y/h>d.bottom&&(i=u),i)return}}let a=k2(s.length),l=cg;for(;a>=0&&a<s.length;){const c=s[a],u=e.getElementByKey(c);if(u===null)break;const f=Dn(u),d=new H_(t.x/f,t.y/f),p=nr.fromDOM(u),{marginTop:h,marginBottom:_}=vm(u),m=p.generateNewRect({bottom:p.bottom+_,left:o.left,right:o.right,top:p.top-h}),{result:y,reason:{isOnTopSide:x,isOnBottomSide:S}}=m.contains(d);if(y){i=u,ui=a;break}l===cg&&(x?l=v2:S?l=S2:l=1/0),a+=l}}),i}function T2(n){return!!n.closest(`.${C2}`)}function km(n){const e=window.getComputedStyle(n),t=e.overflowY==="auto"||e.overflowY==="scroll",r=e.overflowX==="auto"||e.overflowX==="scroll";if(t||r)return{element:n,scrollTop:n.scrollTop||0,scrollLeft:n.scrollLeft||0};const o=n.parentElement;if(o){const s=window.getComputedStyle(o),i=s.overflowY==="auto"||s.overflowY==="scroll",a=s.overflowX==="auto"||s.overflowX==="scroll";if(i||a)return{element:o,scrollTop:o.scrollTop||0,scrollLeft:o.scrollLeft||0}}return{element:n,scrollTop:0,scrollLeft:0}}function E2(n,e,t){if(!n){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}const r=n.getBoundingClientRect(),o=window.getComputedStyle(n),s=e.getBoundingClientRect(),i=t.getBoundingClientRect(),{scrollTop:a}=km(t),c=(parseInt(o.lineHeight,10)-s.height)/2,u=r.top+c-i.top+a,f=Ul;e.style.opacity="1",e.style.transform=`translate(${f}px, ${u}px)`}function N2(n,e){const{transform:t}=e.style;e.style.transform="translateZ(0)",n.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=t})}function L2(n,e,t,r){const{top:o,height:s}=e.getBoundingClientRect(),{top:i,width:a}=r.getBoundingClientRect(),{marginTop:l,marginBottom:c}=vm(e),{scrollTop:u}=km(r);let f=o;t>=o?f+=s+c/2:f-=l/2;const d=f-i-x2+u,p=lg-Ul;n.style.transform=`translate(${p}px, ${d}px)`,n.style.width=`${a-(lg-Ul)*2}px`,n.style.opacity=".4"}function O2(n){n&&(n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)")}function A2(n,e,t){const r=C.useRef(null),o=C.useRef(null),s=C.useRef(!1),[i,a]=C.useState(null),l=n._config.theme,c=l.draggableBlockMenu||"",u=l.draggableBlockTargetLine||"";C.useEffect(()=>{function p(_){const m=_.target;if(!Fa(m)){a(null);return}if(!e.contains(m)||T2(m))return;const y=Ua(e,n,_);a(y)}function h(){a(null)}return document.addEventListener("mousemove",p),document.addEventListener("mouseleave",h),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseleave",h)}},[e,n]),C.useEffect(()=>{r.current&&E2(i,r.current,e)},[e,i]),C.useEffect(()=>{function p(_){if(!s.current)return!1;const[m]=Gr(_);if(m)return!1;const{pageY:y,target:x}=_;if(!Fa(x))return!1;const S=Ua(e,n,_,!0),v=o.current;return S===null||v===null?!1:(L2(v,S,y/Dn(x),e),_.preventDefault(),!0)}function h(_){if(!s.current)return!1;const[m]=Gr(_);if(m)return!1;const{target:y,dataTransfer:x,pageY:S}=_,v=x?.getData(ag)||"",I=Q(v);if(!I||!Fa(y))return!1;const E=Ua(e,n,_,!0);if(!E)return!1;const T=Me(E);if(!T)return!1;if(T===I)return!0;const N=E.getBoundingClientRect().top;return S/Dn(y)>=N?T.insertAfter(I):T.insertBefore(I),a(null),!0}return de(n.registerCommand(Yl,_=>p(_),ee),n.registerCommand(Gl,_=>h(_),qe))},[e,n]);function f(p){const h=p.dataTransfer;if(!h||!i)return;N2(h,i);let _="";n.update(()=>{const m=Me(i);m&&(_=m.getKey())}),s.current=!0,h.setData(ag,_)}function d(){s.current=!1,O2(o.current)}return Tt.createPortal(w.jsxs(w.Fragment,{children:[w.jsx("div",{className:`draggable-block-menu ${c}`,ref:r,draggable:!0,onDragStart:f,onDragEnd:d,children:t?w.jsx(Ty,{size:16}):null}),w.jsx("div",{className:`draggable-block-target-line ${u}`,ref:o})]}),e)}function YA({anchorElem:n=document.body}){const[e]=fe();return A2(e,n,e._editable)}const R2=()=>w.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:[w.jsx("path",{d:"M4.5 2v5.5a3.5 3.5 0 1 0 7 0V2H13v5.5a5 5 0 0 1-10 0V2h1.5Z"}),w.jsx("rect",{x:"2",y:"14",width:"12",height:"1.5",rx:".75"})]});function M2(n,e,t,r){const[o,s]=C.useState(!1),[i,a]=C.useState(!1),[l,c]=C.useState(!1),[u,f]=C.useState(!1),[d,p]=C.useState(!1),[h,_]=C.useState(!1),[m,y]=C.useState(!1),[x,S]=C.useState(!1),[v,I]=C.useState(!1),E=C.useCallback(()=>{n.getEditorState().read(()=>{if(n.isComposing())return;const M=P(),A=window.getSelection(),$=n.getRootElement();if(A!==null&&(!j(M)||$===null||!$.contains(A.anchorNode))){s(!1);return}if(!j(M))return;const L=W_(M);c(M.hasFormat("bold")),f(M.hasFormat("italic")),p(M.hasFormat("underline")),_(M.hasFormat("strikethrough")),y(M.hasFormat("subscript")),S(M.hasFormat("superscript")),I(M.hasFormat("code"));const R=L.getParent();Pe(R)||Pe(L)?a(!0):a(!1),!Ve(M.anchor.getNode())&&M.getTextContent()!==""?s(oe(L)):s(!1)})},[n]);C.useEffect(()=>(document.addEventListener("selectionchange",E),()=>{document.removeEventListener("selectionchange",E)}),[E]),C.useEffect(()=>de(n.registerUpdateListener(()=>{E()}),n.registerRootListener(()=>{n.getRootElement()===null&&s(!1)}),n.registerCommand(ns,()=>(s(!1),!1),ee)),[n,E]);const T=C.useCallback(()=>{i?(t(!1),n.dispatchCommand(br,null)):(t(!0),n.dispatchCommand(br,"https://example.com"))},[n,i,t]),N=C.useMemo(()=>n.isEditable()?[{key:"bold",type:"button",order:0,ariaLabel:"Format text as bold",title:"Bold",icon:Ap,isActive:l,onClick:()=>n.dispatchCommand(Xe,"bold")},{key:"italic",type:"button",order:1,ariaLabel:"Format text as italics",title:"Italic",icon:Rp,isActive:u,onClick:()=>n.dispatchCommand(Xe,"italic")},{key:"underline",type:"button",order:2,ariaLabel:"Format text to underlined",title:"Underline",icon:R2,isActive:d,onClick:()=>n.dispatchCommand(Xe,"underline")},{key:"strikethrough",type:"button",order:3,ariaLabel:"Format text with a strikethrough",title:"Strikethrough",icon:Mp,isActive:h,onClick:()=>n.dispatchCommand(Xe,"strikethrough")},{key:"subscript",type:"button",order:4,ariaLabel:"Format Subscript",title:"Subscript",icon:void 0,label:"x₂",isActive:m,onClick:()=>n.dispatchCommand(Xe,"subscript")},{key:"superscript",type:"button",order:5,ariaLabel:"Format Superscript",title:"Superscript",icon:void 0,label:"x²",isActive:x,onClick:()=>n.dispatchCommand(Xe,"superscript")},{key:"code",type:"button",order:6,ariaLabel:"Insert code block",title:"Code",icon:ir,isActive:v,onClick:()=>n.dispatchCommand(Xe,"code")},{key:"link",type:"button",order:7,ariaLabel:"Insert link",title:"Link",icon:Np,isActive:i,onClick:T},{key:"comment",type:"button",order:8,ariaLabel:"Insert comment",title:"Comment",icon:mi,onClick:()=>n.dispatchCommand(ns,void 0)}]:[{key:"comment",type:"button",order:100,ariaLabel:"Insert comment",icon:mi,onClick:()=>n.dispatchCommand(ns,void 0)}],[n,l,u,d,h,m,x,v,i,T]),O=o&&!i;return w.jsx(ww,{items:N,extraItems:r,anchorElement:e,isVisible:O,ariaLabel:"Floating text format toolbar"})}function GA({anchorElem:n=document.body,setIsLinkEditMode:e,extraItems:t}){const[r]=fe();return M2(r,n,e,t)}function $2(n){return n.registerCommand(cc,()=>{const e=P();if(!j(e))return!1;if(e.focus.getNode()!==null){const r=Vi();e.insertParagraph(),e.focus.getNode().getTopLevelElementOrThrow().insertBefore(r)}return!0},V)}const Im=pe({name:"@datalayer/jupyter-lexical/HorizontalRule",nodes:()=>[Pc],register:$2}),zo={code:{triggerMode:"auto",contextBefore:-1,contextAfter:-1,language:"python"},prose:{triggerMode:"manual",contextBefore:-1,contextAfter:-1},debounceMs:200,manualTriggerKey:"Cmd+Shift+,"};function D2(n){return n?{code:{...zo.code,...n.code},prose:{...zo.prose,...n.prose},debounceMs:n.debounceMs??zo.debounceMs,manualTriggerKey:n.manualTriggerKey??zo.manualTriggerKey}:{...zo}}function XA(n){return n===-1||n>=0}function ZA(n){return n.triggerMode==="auto"}function QA(n){return n.triggerMode==="manual"||n.triggerMode==="auto"}function eR(n){return n.triggerMode==="disabled"}const ug="jupyter-cell";class Tr extends jt{__code;__outputs;__loading;__autoStart;__data;__variant;static getType(){return ug}static clone(e){return console.debug(`clone: node: ${JSON.stringify(e,null,2)}`),new Tr(e.__code,e.__outputs,e.__loading,e.__autoStart,e.__data,e.__key,e.__variant)}constructor(e,t,r,o,s="[]",i,a){super(i),this.__code=e,this.__outputs=t,this.__loading=r,this.__autoStart=o,this.__data=s,this.__variant=a}createDOM(e){const t=document.createElement("div"),o=e.theme.image;return o!==void 0&&(t.className=o),ge("createDOM",t),t}updateDOM(){return!1}decorate(e){return ge(`decorate -> key: ${this.getKey()} outputs: ${this.__outputs} data: ${this.__data}`),w.jsx(uw,{source:this.__code,outputs:this.__outputs,autoStart:this.__autoStart,variant:this.__variant})}setCode(e){const t=this.getWritable();t.__code=e}get code(){return this.__code}setOutputs(e){const t=this.getWritable();t.__outputs=e}get outputs(){return this.__outputs}setLoading(e){const t=this.getWritable();t.__loading=e}get loading(){return this.__loading}setAutostart(e){const t=this.getWritable();t.__autoStart=e}get autoStart(){return this.__autoStart}get variant(){return this.__variant}setData(e){const t=this.getWritable();t.__data=e}get data(){return this.__data}static importJSON(e){const t=e;return new Tr(t.code,t.outputs,t.loading,t.autoStart,t.data,void 0,t.variant)}exportJSON(){return{code:this.__code,outputs:this.__outputs,loading:this.__loading,autoStart:this.__autoStart,data:this.__data,variant:this.__variant,type:ug,version:1}}}function dg(n){const{code:e,outputs:t,loading:r,autoStart:o}=n;return new Tr(e,t,r,o)}function tR(n){return n instanceof Tr}const P2=he(),j2=he();function F2(n){if(!n.hasNodes([Tr]))throw new Error("JupyterCellNode is not registered.");return de(n.registerCommand(P2,e=>{const t=dg(e);return pr([t]),!0},V),n.registerCommand(j2,e=>{const t=dg({...e});return pr([t]),!0},V))}const B2=pe({name:"@datalayer/jupyter-lexical/JupyterCell",nodes:()=>[Tr],register:F2}),U2=he("INSERT_LAYOUT_COMMAND");function z2(n){return n.trim().split(/\s+/).length}function nR(n){return Array.from({length:Math.max(1,n)},()=>"1fr").join(" ")}function K2(n){if(!n.hasNodes([vr,kr]))throw new Error("LayoutPlugin: LayoutContainerNode, or LayoutItemNode not registered on editor");const e=t=>{const r=P();if(j(r)&&r.isCollapsed()&&r.anchor.offset===0){const o=re(r.anchor.getNode(),ri);if(ri(o)){const s=o.getParent(),i=s&&(t?s.getFirstChild():s.getLastChild()),a=t?o.getFirstDescendant()?.getKey():o.getLastDescendant()?.getKey();s!==null&&i===o&&r.anchor.key===a&&(t?o.insertBefore(ne()):o.insertAfter(ne()))}}return!1};return de(n.registerCommand(Ht,()=>e(!1),ee),n.registerCommand(Di,()=>e(!1),ee),n.registerCommand(pt,()=>e(!0),ee),n.registerCommand(Ss,()=>e(!0),ee),n.registerCommand(U2,t=>(n.update(()=>{const r=Xc(t);for(let o=0;o<z2(t);o++)r.append(Zc().append(ne()));Yn(r),r.selectStart()}),!0),V),n.registerNodeTransform(kr,t=>{const r=t.getParent();if(!ri(r)){for(const o of t.getChildren())t.insertBefore(o);t.remove();return}t.isEmpty()&&t.append(ne())}),n.registerNodeTransform(vr,t=>{const r=t.getChildren();if(!r.every(Qc)){for(const o of r)t.insertBefore(o);t.remove();return}r.length===0&&t.remove()}))}const W2=pe({name:"@datalayer/jupyter-lexical/Layout",nodes:()=>[vr,kr],register:K2});function fg(n,e,t,r,o){return n==="code"?J2(e,t):H2(e,t,r,o)}function J2(n,e){const t=n.getTextContent(),r=Y2(n,e),o=t.substring(0,r),s=t.substring(r);return{before:o,after:s,fullText:t}}function H2(n,e,t,r){const s=se().getChildren(),i=q2(n);if(!i)return{before:"",after:"",fullText:""};const a=s.indexOf(i);if(a===-1)return{before:"",after:"",fullText:""};const l=t===-1?0:Math.max(0,a-t),c=r===-1?s.length-1:Math.min(s.length-1,a+r);let u="";for(let _=l;_<a;_++)u+=s[_].getTextContent()+`
215
215
  `;const f=i.getTextContent(),d=V2(i,e);u+=f.substring(0,d);let p=f.substring(d);for(let _=a+1;_<=c;_++)p+=`
216
216
  `+s[_].getTextContent();const h=u+p;return{before:u,after:p,fullText:h}}function q2(n){let e=n;for(;e;){if(ht(e)||e.getType()==="heading"||e.getType()==="listitem")return e;e=e.getParent()}return se()}function V2(n,e){try{const t=n.getFirstDescendant(),r=t?t.getKey():n.getKey(),o=0,s=t?"text":"element",i=e.clone();return i.anchor.set(r,o,s),i.focus.set(e.anchor.key,e.anchor.offset,e.anchor.type),i.getTextContent().length}catch(t){return console.error("[ContextExtractor] Error getting cursor offset:",t),0}}function Y2(n,e){try{const t=n.getFirstDescendant(),r=t?t.getKey():n.getKey(),o=0,s=t?"text":"element",i=e.clone();return i.anchor.set(r,o,s),i.focus.set(e.anchor.key,e.anchor.offset,e.anchor.type),i.getTextContent().length}catch(t){return console.error("[ContextExtractor] Error getting cursor offset:",t),0}}function G2(n){switch(n){case 1:case 2:return"𝑓";case 5:return"𝑥";case 6:return"C";case 8:return"M";case 9:return"∙";case 13:return"🔑";default:return"•"}}function X2(n,e){if(!e||e.length===0)return w.jsx(w.Fragment,{children:n});const t=n.toLowerCase(),r=e.toLowerCase(),o=t.indexOf(r);if(o===-1)return w.jsx(w.Fragment,{children:n});const s=n.substring(0,o),i=n.substring(o,o+e.length),a=n.substring(o+e.length);return w.jsxs(w.Fragment,{children:[s,w.jsx("strong",{style:{color:"var(--vscode-editorSuggestWidget-highlightForeground)",fontWeight:"bold"},children:i}),a]})}function Z2({items:n,onSelect:e,onClose:t,position:r,filterText:o}){const[s,i]=C.useState(0),[a,l]=C.useState(r),c=C.useRef(null),u=C.useRef([]),f=C.useRef(null);return C.useEffect(()=>{const d=window.getSelection();if(d&&d.rangeCount>0){const p=d.getRangeAt(0);f.current=p.startContainer.parentElement}},[]),C.useEffect(()=>{const d=()=>{const p=window.getSelection();if(!p||p.rangeCount===0)return;const _=p.getRangeAt(0).getBoundingClientRect();l({top:_.bottom+window.scrollY,left:_.left+window.scrollX})};return window.addEventListener("scroll",d,!0),()=>window.removeEventListener("scroll",d,!0)},[]),C.useEffect(()=>{const d=u.current[s];d&&d.scrollIntoView({block:"nearest"})},[s]),C.useEffect(()=>{const d=p=>{switch(p.key){case"ArrowDown":p.preventDefault(),i(h=>Math.min(h+1,n.length-1));break;case"ArrowUp":p.preventDefault(),i(h=>Math.max(h-1,0));break;case"Enter":p.preventDefault(),n[s]&&e(n[s]);break;case"Escape":p.preventDefault(),t();break;case"Tab":p.preventDefault(),n[s]&&e(n[s]);break}};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,n,e,t]),C.useEffect(()=>{const d=p=>{c.current&&!c.current.contains(p.target)&&t()};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[t]),n.length===0?w.jsx(w.Fragment,{}):w.jsx("div",{ref:c,style:{position:"fixed",top:`${a.top}px`,left:`${a.left}px`,zIndex:1e4,background:"var(--vscode-editorSuggestWidget-background)",border:"1px solid var(--vscode-editorSuggestWidget-border)",borderRadius:"4px",boxShadow:"var(--shadow-resting-medium, 0 1px 1px 0 #25292e1a, 0 3px 6px 0 #25292e1f)",maxHeight:"300px",overflowY:"auto",minWidth:"300px"},children:w.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0"},children:n.map((d,p)=>{const h=p===s;return w.jsxs("li",{ref:_=>{u.current[p]=_},onClick:()=>e(d),onMouseEnter:()=>i(p),style:{padding:"4px 8px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",backgroundColor:h?"var(--vscode-editorSuggestWidget-selectedBackground)":"transparent",color:h?"var(--vscode-editorSuggestWidget-selectedForeground)":"var(--vscode-editorSuggestWidget-foreground)"},children:[w.jsx("span",{style:{opacity:.7,fontSize:"12px",minWidth:"16px",textAlign:"center"},children:G2(d.kind)}),w.jsx("span",{style:{flex:1},children:X2(d.label,o)}),d.detail&&w.jsx("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"auto"},children:d.detail})]},`${d.label}-${p}`)})})})}const zl=he("LSP_MENU_STATE_COMMAND"),Kl=he("LSP_COMPLETION_INSERTED_COMMAND");function za(n,e,t){let r=0;function o(i){if(i===e)return r+=t,!0;if(H(i)){const a=i.getChildren();for(const l of a)if(o(l))return!0}else r+=i.getTextContent().length;return!1}const s=n.getChildren();for(const i of s)if(o(i))break;return r}function Q2(n){const e=n.getChildren();for(const t of e)if(Vo(t))return!0;return!1}function gg(n){let e=n;for(;e;){if(st(e))return e;e=e.getParent()}return null}function eL(n,e){let t=0,r=0;for(let o=0;o<e&&o<n.length;o++)n[o]===`
217
217
  `?(t++,r=0):r++;return{line:t,character:r}}function tL(n){const e=n.getLanguage();return!e||e==="python"||e==="py"?"python":e==="markdown"||e==="md"||e==="text"?"markdown":"unknown"}function nL(n,e){if(!e)return n;const t=e.toLowerCase(),r=[],o=[];for(const s of n){const i=(s.filterText||s.label).toLowerCase();i.startsWith(t)?r.push(s):i.includes(t)&&o.push(s)}return[...r,...o]}function rR({providers:n,disabled:e=!1}){const[t]=fe(),[r,o]=C.useState([]),[s,i]=C.useState([]),[a,l]=C.useState(!1),[c,u]=C.useState({top:0,left:0}),[f,d]=C.useState(""),p=C.useRef(0),h=C.useRef(null),_=C.useCallback(()=>{const S=window.getSelection();if(!S||S.rangeCount===0)return{top:0,left:0};const I=S.getRangeAt(0).getBoundingClientRect();return{top:I.bottom+window.scrollY,left:I.left+window.scrollX}},[]),m=C.useCallback(()=>{l(!1),o([]),i([]),d(""),p.current=0,h.current=null,t.dispatchCommand(zl,!1)},[t]),y=C.useCallback(S=>{t.update(()=>{const v=P();if(!j(v))return;const I=v.anchor.getNode(),E=v.anchor.offset,T=h.current;if(T){const O=za(T,I,E)-p.current;if(O>0){const M=E-O;if(M>=0){const A=I.getKey();v.anchor.set(A,M,"text"),v.focus.set(A,E,"text")}}}v.insertText(S.insertText)}),t.dispatchCommand(Kl,void 0),m()},[t,m]);C.useEffect(()=>{if(!(!a||r.length===0))return t.registerUpdateListener(({editorState:S})=>{S.read(()=>{const v=P();if(!j(v)||!v.isCollapsed()){m();return}const I=v.anchor.getNode(),E=h.current;if(!E)return;const T=gg(I);if(!T){m();return}const N=T.getJupyterInputNodeUuid(),O=E.getJupyterInputNodeUuid();if(N!==O){m();return}h.current=T;const M=v.anchor.offset,A=za(T,I,M);if(A<p.current){m();return}const L=T.getTextContent().substring(p.current,A),R=nL(r,L);i(R),d(L),R.length===0&&m()})})},[t,a,r,m]);const x=C.useCallback(async(S,v)=>{if(n.length===0||e)return;const I=S.getJupyterInputNodeUuid(),E=S.getTextContent(),T=tL(S);if(T==="unknown")return;const N=eL(E,v),M=(await Promise.all(n.map(A=>A.fetchCompletions(I,E,N,T)))).flat();if(M.length===1){const A=M[0];t.update(()=>{const $=P();if(j($)){const L=$.anchor.getNode(),R=$.anchor.offset,B=L.getTextContent();let F=R;for(;F>0&&/[a-zA-Z0-9_]/.test(B[F-1]);)F--;if(R-F>0){const K=L.getKey();$.anchor.set(K,F,"text"),$.focus.set(K,R,"text")}$.insertText(A.insertText)}}),t.dispatchCommand(Kl,void 0)}else if(M.length>1){const A=_();u(A),o(M),i(M),d(""),p.current=v,h.current=S,l(!0),t.dispatchCommand(zl,!0)}},[n,e,_,t]);return C.useEffect(()=>{if(!e)return t.registerCommand(Nr,S=>{const v=P();if(!j(v)||!v.isCollapsed())return!1;const I=v.anchor.getNode(),E=gg(I);if(!E||Q2(E))return!1;if(a)return S?.preventDefault(),!0;S?.preventDefault();const T=v.anchor.getNode(),N=v.anchor.offset,O=za(E,T,N);return x(E,O),!0},ro)},[t,e,a,x]),e||n.length===0?null:a&&s.length>0?w.jsx(Z2,{items:s,onSelect:y,onClose:m,position:c,filterText:f}):null}const pg=he("TRIGGER_INLINE_COMPLETION_COMMAND");function rL({providers:n,debounceMs:e,enabled:t=!0,config:r}){const[o]=fe(),[s,i]=C.useState(null),[a,l]=C.useState(!1),c=C.useMemo(()=>D2(r),[r]),u=r?.debounceMs??e??Math.max(c.debounceMs,500),f=C.useRef(null),d=C.useRef(""),p=C.useRef(""),h=C.useRef(null),_=C.useRef(null),m=C.useRef(0);C.useEffect(()=>()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]),C.useEffect(()=>{if(t)return o.registerCommand(zl,x=>(l(x),x&&(f.current&&(clearTimeout(f.current),f.current=null),i(null)),!1),ee)},[o,t]),C.useEffect(()=>{if(t)return o.registerCommand(Kl,()=>(m.current=Date.now(),i(null),!1),ee)},[o,t]);const y=C.useCallback(async(x,S,v,I="code",E="auto")=>{if(!n||n.length===0)return;const T=n[0];try{const N=x.substring(0,S),O=x.substring(S),M=await T.fetch({text:x,offset:S,language:v,contentType:I},{before:N,after:O,inCodeCell:I==="code",triggerKind:E});if(M&&M.items&&M.items.length>0){const A=M.items[0].insertText;i(A)}else i(null)}catch(N){console.error("[InlineCompletionPlugin] Error requesting completion:",N),i(null)}},[n]);return C.useEffect(()=>{_.current=y},[y]),C.useEffect(()=>{if(t)return o.registerUpdateListener(({editorState:x})=>{x.read(()=>{if(!c){ge("[InlineCompletionPlugin] Config not ready, skipping auto-trigger"),i(null);return}if(a){i(null);return}if(Date.now()-m.current<300){i(null);return}const I=P();if(!j(I)||!I.isCollapsed()){i(null);return}const E=I.anchor.getNode(),T=hg(E),N=T==="code"?c.code:c.prose;if(ge("[InlineCompletionPlugin] Auto-trigger check:",{contentType:T,triggerMode:N.triggerMode,willTrigger:N.triggerMode==="auto"}),N.triggerMode==="auto")if(T==="code"){const O=Ka(E);if(!O){i(null);return}const M=O.getTextContent(),A=_g(O,I);if(M===p.current)return;p.current=M;const $=M.substring(0,A);if($.trim().length===0){i(null);return}const L=$.lastIndexOf(`
@@ -224,16 +224,16 @@ ${n.stack}`:r}function E1(){let n,e;try{const o=g.__wbindgen_add_to_stack_pointe
224
224
  `);return{block_id:t,block_type:"table",source:c,metadata:{rows:i,columns:a,data:l}}}if(e==="collapsible-container"){const o=n,s=o.getOpen?.()||o.__open||!1,i=o.getChildren?.()||[];let a="";return i[0]?.getType()==="collapsible-title"&&(a=i[0].getTextContent()),{block_id:t,block_type:"collapsible",source:a,metadata:{open:s,title:a}}}if(e==="collapsible-title")return null;const r=n.getTextContent();return{block_id:t,block_type:e,source:r}}function Vr(n){const e=[];let t=!1;const r=n.getTextContent(),o="getChildren"in n?n.getChildren():[];if(o.length>0)for(const s of o)if(s.getType()==="text"){const i=s.getTextContent(),a=s.getFormat?.()||0;e.push({text:i,format:a}),a!==0&&(t=!0)}else{const i=Vr(s);i.formatting?(e.push(...i.formatting),t=!0):e.push({text:i.text,format:0})}else{const s="getFormat"in n&&n.getFormat?.()||0;e.push({text:r,format:s}),s!==0&&(t=!0)}return{text:r,formatting:t&&e.length>0?e:void 0}}function bg(n){const s=[];let i=0;const a=[{regex:/\*\*\*(.*?)\*\*\*/g,format:3},{regex:/\*\*(.*?)\*\*/g,format:1},{regex:/\*(.*?)\*/g,format:2},{regex:/~~(.*?)~~/g,format:4},{regex:/`(.*?)`/g,format:16}],l=[];for(const c of a){c.regex.lastIndex=0;let u;for(;(u=c.regex.exec(n))!==null;)l.some(d=>u.index>=d.start&&u.index<d.end||u.index+u[0].length>d.start&&u.index+u[0].length<=d.end)||l.push({start:u.index,end:u.index+u[0].length,text:u[1],format:c.format})}l.sort((c,u)=>c.start-u.start);for(const c of l){if(c.start>i){const u=n.substring(i,c.start);u&&s.push({text:u,format:0})}s.push({text:c.text,format:c.format}),i=c.end}if(i<n.length){const c=n.substring(i);c&&s.push({text:c,format:0})}return s.length===0&&s.push({text:n,format:0}),s}class aL{_editor;_defaultBlockType="paragraph";_serviceManager;_runAllAbortController=null;constructor(e,t){this._editor=e,this._serviceManager=t}get editor(){return this._editor}get serviceManager(){return this._serviceManager}setDefaultBlockType(e){this._defaultBlockType=e}get defaultBlockType(){return this._defaultBlockType}async getBlocks(e="brief"){return new Promise(t=>{const r=Wa(this._editor,e);t(r)})}async getBlock(e){return new Promise(t=>{const r=Wa(this._editor,"detailed");e>=0&&e<r.length?t(r[e]):t(null)})}async getBlockById(e){return new Promise(t=>{const o=Wa(this._editor,"detailed").find(s=>s.block_id===e);t(o||null)})}async getBlockCount(){return(await this.getBlocks()).length}async insertBlock(e,t){const r=Array.isArray(e.source)?e.source.join(`
225
225
  `):e.source;if((e.block_type==="paragraph"||e.block_type==="text")&&this.containsBlockLevelMarkdown(r)){const s=this.parseMarkdownToBlocks(r);if(s.length>1){let i=t,a;for(const l of s){l.metadata={...l.metadata,...e.metadata};const c=await this.insertBlock(l,i);if(!c.success)return c;c.blockId&&(a=c.blockId,i=c.blockId)}return{success:!0,blockId:a,message:`Inserted ${s.length} blocks from markdown`}}}if(e.metadata?.collapsible){const s=e.metadata.collapsible;return s==="TOP"||s==="BOTTOM"?Promise.resolve({success:!1,error:`Invalid collapsible ID: "${s}". To insert blocks inside a collapsible: 1) First insert the collapsible container (returns blockId), 2) Then insert nested blocks with properties.collapsible set to that blockId. Use afterId for positioning (TOP/BOTTOM/blockId), not properties.collapsible.`}):new Promise(i=>{this._editor.update(()=>{const c=se().getChildren().find(p=>p.getKey()===s);if(!c||c.getType()!=="collapsible-container"){i({success:!1,error:`Collapsible container ${s} not found`});return}const f=(c.getChildren?.()||[]).find(p=>p.getType()==="collapsible-content");if(!f){i({success:!1,error:`Collapsible content node not found in ${s}`});return}const d={...e,metadata:{...e.metadata,collapsible:void 0}};this.insertBlock(d,"BOTTOM").then(p=>{if(!p.success||!p.blockId){i({success:!1,error:`Failed to insert ${e.block_type}: ${p.error||"Unknown error"}`});return}setTimeout(()=>{this._editor.update(()=>{const m=se().getChildren().find(y=>y.getKey()===p.blockId);if(!m){i({success:!1,error:`Could not find inserted node ${p.blockId}`});return}m.remove(),f.append(m),i({success:!0,blockId:p.blockId,message:`Block of type '${e.block_type}' inserted inside collapsible ${s}`})})},50)}).catch(p=>{i({success:!1,error:`Failed to insert block: ${p.message||String(p)}`})})})})}return this.requiresCommand(e.block_type)?this.insertViaCommand(e,t):this.insertViaNode(e,t)}async deleteBlock(e){try{const t=await this.getBlocks("detailed"),r=new Set(t.map(a=>a.block_id)),o=[];for(const a of e)r.has(a)||o.push(a);if(o.length>0)return{success:!1,error:`Block ID(s) not found: ${o.join(", ")}. Document has ${t.length} blocks.`};const s=[...e].sort((a,l)=>{const c=t.findIndex(f=>f.block_id===a);return t.findIndex(f=>f.block_id===l)-c}),i=[];for(const a of s){const l=await this._deleteSingleBlock(a);if(l.success)i.push({id:a});else{if(l.error?.includes("not found"))continue;return l}}return{success:!0,deletedBlocks:i}}catch(t){return{success:!1,error:t instanceof Error?t.message:String(t)}}}async _deleteSingleBlock(e){return new Promise(t=>{this._editor.update(()=>{try{const r=se(),o=(l,c)=>{if(l.getKey()===c)return l;if("getChildren"in l){const u=l.getChildren();for(const f of u){const d=o(f,c);if(d)return d}}return null},s=o(r,e);if(!s){t({success:!1,error:`Block with ID ${e} not found`});return}const i=s.getType(),a=s.getParent();(i==="equation"||i==="excalidraw")&&a&&a.getType()==="paragraph"?a.remove():s.remove(),t({success:!0})}catch(r){t({success:!1,error:r instanceof Error?r.message:String(r)})}})})}async updateBlock(e,t){const r=await this.deleteBlock([e]);if(!r.success)return r;const o=await this.getBlocks(),s=o.findIndex(a=>a.block_id===e),i=s>0?o[s-1].block_id:"TOP";return this.insertBlock(t,i)}async runBlock(e){if(!e){let o=null;if(this._editor.getEditorState().read(()=>{const s=P();if(!s)return;const i=s.getNodes();if(i.length===0)return;let l=i[0];for(;l;){const c=l.getType();if(c==="jupyter-cell"||c==="jupyter-input"){o=l.getKey();break}const u=l.getParent();if(!u)break;l=u}}),!o)return{success:!1,error:"No jupyter cell is currently focused"};e=o}const t=await this.getBlockById(e);if(!t)return{success:!1,error:`Block with ID ${e} not found`};if(!["jupyter-cell","jupyter-input"].includes(t.block_type))return{success:!1,error:`Block type ${t.block_type} is not executable`};try{const o=Date.now(),s=await new Promise((c,u)=>{this._editor.update(()=>{try{const f=se();let d=null,p="";const h=m=>{if(m.getType()==="jupyter-cell"&&m.getKey()===e)return m.getChildren().forEach(S=>{S.getType()==="jupyter-input"?p=S.getTextContent():S.getType()==="jupyter-output"&&(d=S)}),!0;if(m.getType()==="jupyter-input"&&m.getKey()===e){p=m.getTextContent();const x=m.getJupyterInputNodeUuid();return d=Qn(x),!0}const y=m.getChildren?.()||[];for(const x of y)if(h(x))return!0;return!1};for(const m of f.getChildren())if(h(m))break;if(!d){u(new Error("Could not find jupyter-output node for execution"));return}if(!p||p.trim()===""){u(new Error("No code to execute"));return}d.executeCode(p);const _=d.__outputAdapter;if(!_){u(new Error("No outputAdapter available"));return}c({outputAdapter:_,code:p})}catch(f){u(f)}})});await new Promise(c=>setTimeout(c,500));const i=s.outputAdapter.outputArea.model.toJSON(),a=(Date.now()-o)/1e3;return{success:!0,execution_count:i.length>0?1:null,outputs:i,elapsed_time:a,message:`Block executed in ${a.toFixed(2)}s`}}catch(o){return{success:!1,error:`Failed to execute block: ${o instanceof Error?o.message:String(o)}`}}}async runAllBlocks(){this._runAllAbortController&&this._runAllAbortController.abort(),this._runAllAbortController=new AbortController;const e=this._runAllAbortController.signal;try{const r=(await this.getBlocks()).filter(o=>o.block_type==="jupyter-cell");for(const o of r){if(e.aborted)return{success:!1,error:"Run all blocks was cancelled (new run all started)"};const s=await this.runBlock(o.block_id);if(!s.success)return console.error(`[LexicalAdapter] Block ${o.block_id} failed:`,s.error),{success:!1,error:`Failed to run block ${o.block_id}: ${s.error}`}}return{success:!0,blockId:r.length>0?r[r.length-1].block_id:void 0}}finally{this._runAllAbortController?.signal===e&&(this._runAllAbortController=null)}}async clearAllOutputs(){return new Promise(e=>{this._editor.update(()=>{let t=0;function r(s){if(s.getType&&s.getType()==="jupyter-output"&&s.__outputAdapter&&(s.__outputAdapter.clear(),t++),s.getChildren){const i=s.getChildren();for(const a of i)r(a)}}const o=se();r(o),e({success:!0,message:t>0?`Cleared outputs from ${t} jupyter cells`:"No jupyter cells found to clear"})})})}async restartKernel(){return new Promise(e=>{me(()=>Promise.resolve().then(()=>rf),void 0,import.meta.url).then(t=>{const{RESTART_JUPYTER_KERNEL_COMMAND:r}=t,o=this._editor.dispatchCommand(r,void 0);e(o?{success:!0,message:"Kernel restart initiated"}:{success:!1,error:"RESTART_JUPYTER_KERNEL_COMMAND was not handled"})}).catch(t=>{e({success:!1,error:`Failed to load restart command: ${t.message}`})})})}requiresCommand(e){return["jupyter-cell","image","equation","youtube","excalidraw","table","collapsible"].includes(e)}async insertViaCommand(e,t){return new Promise(async r=>{try{if(e.block_type==="equation"){const{INSERT_EQUATION_COMMAND:o}=await me(async()=>{const{INSERT_EQUATION_COMMAND:l}=await Promise.resolve().then(()=>b2);return{INSERT_EQUATION_COMMAND:l}},void 0,import.meta.url),s=Array.isArray(e.source)?e.source.join(`
226
226
  `):e.source,i=e.metadata?.equation||e.metadata?.latex||s,a=!1;this._editor.update(()=>{const l=se(),c=l.getChildren(),u=ne();if(u.append(De("__EQUATION_MARKER__")),t==="TOP")c.length>0?c[0].insertBefore(u):l.append(u);else if(t==="BOTTOM"||!t)l.append(u);else{const f=c.find(d=>d.getKey()===t);if(f)f.insertAfter(u);else throw new Error(`Block ID ${t} not found`)}}),setTimeout(()=>{this._editor.update(()=>{const f=se().getChildren().find(d=>d.getType()==="paragraph"&&d.getTextContent()==="__EQUATION_MARKER__");f&&(f.selectEnd(),f.remove())}),this._editor.dispatchCommand(o,{equation:i,inline:a});let l;setTimeout(()=>{this._editor.getEditorState().read(()=>{const u=se().getChildren();for(let f=u.length-1;f>=0;f--)if(u[f].getType()==="equation"){l=u[f].getKey();break}}),r({success:!0,blockId:l})},20)},10)}else if(e.block_type==="jupyter-cell"){const{INSERT_JUPYTER_INPUT_OUTPUT_COMMAND:o}=await me(async()=>{const{INSERT_JUPYTER_INPUT_OUTPUT_COMMAND:l}=await Promise.resolve().then(()=>rf);return{INSERT_JUPYTER_INPUT_OUTPUT_COMMAND:l}},void 0,import.meta.url),i={code:Array.isArray(e.source)?e.source.join(`
227
- `):e.source,outputs:e.metadata?.outputs||[],loading:""};this._editor.update(()=>{const l=se(),c=l.getChildren(),u=ne();if(t==="TOP")c.length>0?c[0].insertBefore(u):l.append(u);else if(t==="BOTTOM"||!t)l.append(u);else{const f=c.find(d=>d.getKey()===t);if(f)f.insertAfter(u);else throw new Error(`Block ID ${t} not found`)}u.selectStart(),this._editor.dispatchCommand(o,i)});let a;setTimeout(()=>{this._editor.getEditorState().read(()=>{const l=se(),c=(f,d)=>{let p=null;if(f.getType()===d&&(p=f),"getChildren"in f&&typeof f.getChildren=="function")for(const h of f.getChildren()){const _=c(h,d);_&&(p=_)}return p},u=c(l,"jupyter-input");u&&(a=u.getKey())}),r({success:!0,blockId:a})},20)}else if(e.block_type==="youtube"){const{INSERT_YOUTUBE_COMMAND:o}=await me(async()=>{const{INSERT_YOUTUBE_COMMAND:c}=await import("./YouTubePlugin-CwtVeT4X.js");return{INSERT_YOUTUBE_COMMAND:c}},[],import.meta.url),s=Array.isArray(e.source)?e.source.join(`
228
- `):e.source,a=(c=>{const u=c.trim();if(/^[a-zA-Z0-9_-]{11}$/.test(u))return u;const f=u.match(/youtu\.be\/([a-zA-Z0-9_-]{11})/);if(f)return f[1];const d=u.match(/[?&]v=([a-zA-Z0-9_-]{11})/);return d?d[1]:"lO2p9LQB7ds"})(s||"");await this.insertWithMarker(t,()=>{this._editor.dispatchCommand(o,a)});let l;setTimeout(()=>{this._editor.getEditorState().read(()=>{const u=se().getChildren();for(let f=u.length-1;f>=0;f--)if(u[f].getType()==="youtube"){l=u[f].getKey();break}}),r({success:!0,blockId:l})},20)}else if(e.block_type==="excalidraw"){const{$createExcalidrawNode:o}=await me(async()=>{const{$createExcalidrawNode:f}=await Promise.resolve().then(()=>GS);return{$createExcalidrawNode:f}},void 0,import.meta.url),{$wrapNodeInElement:s}=await me(async()=>{const{$wrapNodeInElement:f}=await import("../datalayer-app-main.js").then(d=>d.vf);return{$wrapNodeInElement:f}},[],import.meta.url),{$isRootOrShadowRoot:i}=await me(async()=>{const{$isRootOrShadowRoot:f}=await import("../datalayer-app-main.js").then(d=>d.ve);return{$isRootOrShadowRoot:f}},[],import.meta.url),a=e.metadata?.data||"[]",l=e.metadata?.width,c=e.metadata?.height;let u;this._editor.update(()=>{const f=o(a,l||"inherit",c||"inherit");this.insertNodeAtPosition(f,t),u=f.getKey(),i(f.getParentOrThrow())&&s(f,ne).selectEnd()}),r({success:!0,blockId:u})}else if(e.block_type==="table"){const{INSERT_TABLE_COMMAND:o}=await me(async()=>{const{INSERT_TABLE_COMMAND:p}=await Promise.resolve().then(()=>zd);return{INSERT_TABLE_COMMAND:p}},void 0,import.meta.url),{$getTableCellNodeFromLexicalNode:s,$getTableNodeFromLexicalNodeOrThrow:i}=await me(async()=>{const{$getTableCellNodeFromLexicalNode:p,$getTableNodeFromLexicalNodeOrThrow:h}=await Promise.resolve().then(()=>zd);return{$getTableCellNodeFromLexicalNode:p,$getTableNodeFromLexicalNodeOrThrow:h}},void 0,import.meta.url);let a=e.metadata?.rows||2,l=e.metadata?.columns||2,c=e.metadata?.data;const u=e.metadata?.includeHeaders!==!1;c&&Array.isArray(c)&&c.length>0&&(a=c.length,l=c[0].length);const f=Array.isArray(e.source)?e.source.join(`
227
+ `):e.source,outputs:e.metadata?.outputs||[],loading:""};this._editor.update(()=>{const l=se(),c=l.getChildren(),u=ne();if(t==="TOP")c.length>0?c[0].insertBefore(u):l.append(u);else if(t==="BOTTOM"||!t)l.append(u);else{const f=c.find(d=>d.getKey()===t);if(f)f.insertAfter(u);else throw new Error(`Block ID ${t} not found`)}u.selectStart(),this._editor.dispatchCommand(o,i)});let a;setTimeout(()=>{this._editor.getEditorState().read(()=>{const l=se(),c=(f,d)=>{let p=null;if(f.getType()===d&&(p=f),"getChildren"in f&&typeof f.getChildren=="function")for(const h of f.getChildren()){const _=c(h,d);_&&(p=_)}return p},u=c(l,"jupyter-input");u&&(a=u.getKey())}),r({success:!0,blockId:a})},20)}else if(e.block_type==="youtube"){const{INSERT_YOUTUBE_COMMAND:o}=await me(async()=>{const{INSERT_YOUTUBE_COMMAND:c}=await import("./YouTubePlugin-DUDVTb3B.js");return{INSERT_YOUTUBE_COMMAND:c}},[],import.meta.url),s=Array.isArray(e.source)?e.source.join(`
228
+ `):e.source,a=(c=>{const u=c.trim();if(/^[a-zA-Z0-9_-]{11}$/.test(u))return u;const f=u.match(/youtu\.be\/([a-zA-Z0-9_-]{11})/);if(f)return f[1];const d=u.match(/[?&]v=([a-zA-Z0-9_-]{11})/);return d?d[1]:"lO2p9LQB7ds"})(s||"");await this.insertWithMarker(t,()=>{this._editor.dispatchCommand(o,a)});let l;setTimeout(()=>{this._editor.getEditorState().read(()=>{const u=se().getChildren();for(let f=u.length-1;f>=0;f--)if(u[f].getType()==="youtube"){l=u[f].getKey();break}}),r({success:!0,blockId:l})},20)}else if(e.block_type==="excalidraw"){const{$createExcalidrawNode:o}=await me(async()=>{const{$createExcalidrawNode:f}=await Promise.resolve().then(()=>GS);return{$createExcalidrawNode:f}},void 0,import.meta.url),{$wrapNodeInElement:s}=await me(async()=>{const{$wrapNodeInElement:f}=await import("../datalayer-app-main.js").then(d=>d.vk);return{$wrapNodeInElement:f}},[],import.meta.url),{$isRootOrShadowRoot:i}=await me(async()=>{const{$isRootOrShadowRoot:f}=await import("../datalayer-app-main.js").then(d=>d.vj);return{$isRootOrShadowRoot:f}},[],import.meta.url),a=e.metadata?.data||"[]",l=e.metadata?.width,c=e.metadata?.height;let u;this._editor.update(()=>{const f=o(a,l||"inherit",c||"inherit");this.insertNodeAtPosition(f,t),u=f.getKey(),i(f.getParentOrThrow())&&s(f,ne).selectEnd()}),r({success:!0,blockId:u})}else if(e.block_type==="table"){const{INSERT_TABLE_COMMAND:o}=await me(async()=>{const{INSERT_TABLE_COMMAND:p}=await Promise.resolve().then(()=>zd);return{INSERT_TABLE_COMMAND:p}},void 0,import.meta.url),{$getTableCellNodeFromLexicalNode:s,$getTableNodeFromLexicalNodeOrThrow:i}=await me(async()=>{const{$getTableCellNodeFromLexicalNode:p,$getTableNodeFromLexicalNodeOrThrow:h}=await Promise.resolve().then(()=>zd);return{$getTableCellNodeFromLexicalNode:p,$getTableNodeFromLexicalNodeOrThrow:h}},void 0,import.meta.url);let a=e.metadata?.rows||2,l=e.metadata?.columns||2,c=e.metadata?.data;const u=e.metadata?.includeHeaders!==!1;c&&Array.isArray(c)&&c.length>0&&(a=c.length,l=c[0].length);const f=Array.isArray(e.source)?e.source.join(`
229
229
  `):e.source;if(f&&typeof f=="string"&&f.includes("|"))try{const p=f.split(`
230
- `).filter(_=>_.trim()),h=[];for(const _ of p){if(_.match(/^\|?[\s-|]+\|?$/))continue;const m=_.split("|").slice(1,-1).map(y=>y.trim());m.length>0&&h.push(m)}h.length>0&&(c=h,a=h.length,l=h[0].length)}catch{}await this.insertWithMarker(t,()=>{this._editor.dispatchCommand(o,{rows:a.toString(),columns:l.toString(),includeHeaders:u})});let d;setTimeout(()=>{this._editor.update(()=>{const h=se().getChildren();for(let _=h.length-1;_>=0;_--)if(h[_].getType()==="table"){if(d=h[_].getKey(),c&&c.length>0)try{const y=i(h[_]).getChildren();for(let x=0;x<Math.min(c.length,y.length);x++){const v=y[x].getChildren();for(let I=0;I<Math.min(c[x].length,v.length);I++){const E=s(v[I]);E&&(E.clear(),E.append(De(c[x][I])))}}}catch{}break}}),r({success:!0,blockId:d})},20)}else if(e.block_type==="collapsible"){const{INSERT_COLLAPSIBLE_COMMAND:o}=await me(async()=>{const{INSERT_COLLAPSIBLE_COMMAND:l}=await import("./CollapsiblePlugin-vjE7wFOu.js");return{INSERT_COLLAPSIBLE_COMMAND:l}},[],import.meta.url),s=e.metadata?.open??!0,i=Array.isArray(e.source)?e.source.join(`
230
+ `).filter(_=>_.trim()),h=[];for(const _ of p){if(_.match(/^\|?[\s-|]+\|?$/))continue;const m=_.split("|").slice(1,-1).map(y=>y.trim());m.length>0&&h.push(m)}h.length>0&&(c=h,a=h.length,l=h[0].length)}catch{}await this.insertWithMarker(t,()=>{this._editor.dispatchCommand(o,{rows:a.toString(),columns:l.toString(),includeHeaders:u})});let d;setTimeout(()=>{this._editor.update(()=>{const h=se().getChildren();for(let _=h.length-1;_>=0;_--)if(h[_].getType()==="table"){if(d=h[_].getKey(),c&&c.length>0)try{const y=i(h[_]).getChildren();for(let x=0;x<Math.min(c.length,y.length);x++){const v=y[x].getChildren();for(let I=0;I<Math.min(c[x].length,v.length);I++){const E=s(v[I]);E&&(E.clear(),E.append(De(c[x][I])))}}}catch{}break}}),r({success:!0,blockId:d})},20)}else if(e.block_type==="collapsible"){const{INSERT_COLLAPSIBLE_COMMAND:o}=await me(async()=>{const{INSERT_COLLAPSIBLE_COMMAND:l}=await import("./CollapsiblePlugin-CnG1qA1e.js");return{INSERT_COLLAPSIBLE_COMMAND:l}},[],import.meta.url),s=e.metadata?.open??!0,i=Array.isArray(e.source)?e.source.join(`
231
231
  `):e.source||"";await this.insertWithMarker(t,()=>{this._editor.dispatchCommand(o,void 0)});let a;setTimeout(()=>{this._editor.update(()=>{const c=se().getChildren();for(let u=c.length-1;u>=0;u--)if(c[u].getType()==="collapsible-container"){const f=c[u];a=f.getKey(),f.setOpen?.(s);const d=f.getChildren();d[0]&&i&&(d[0].clear(),d[0].append(De(i)));break}}),r({success:!0,blockId:a})},20)}else r({success:!1,error:`Unsupported command-based block type: ${e.block_type}`})}catch(o){r({success:!1,error:o instanceof Error?o.message:String(o)})}})}async insertViaNode(e,t){return new Promise(r=>{this._editor.update(()=>{try{const o=se(),s=this.createSimpleNode(e);if(!s){r({success:!1,error:`Failed to create node for type: ${e.block_type}`});return}const i=o.getChildren();if(t==="TOP")i.length>0?i[0].insertBefore(s):o.append(s);else if(t==="BOTTOM"||!t)o.append(s);else{const a=i.find(l=>l.getKey()===t);if(a)a.insertAfter(s);else{r({success:!1,error:`Block ID ${t} not found`});return}}r({success:!0,blockId:s.getKey()})}catch(o){r({success:!1,error:o instanceof Error?o.message:String(o)})}})})}createSimpleNode(e){const t=Array.isArray(e.source)?e.source.join(`
232
232
  `):e.source,r=()=>e.formatting&&e.formatting.length>0?e.formatting.map(o=>{const s=De(o.text);return o.format&&s.setFormat(o.format),s}):bg(t||"").map(s=>{const i=De(s.text);return s.format&&i.setFormat(s.format),i});switch(e.block_type){case"paragraph":{const o=ne();return r().forEach(s=>o.append(s)),o}case"heading":{const s=`h${e.metadata?.level||1}`,i=cn(s);return r().forEach(a=>i.append(a)),i}case"code":{const o=e.metadata?.language||"plaintext",s=Ze(o);return s.append(De(t)),s}case"quote":{const o=Sn();return r().forEach(s=>o.append(s)),o}case"list":{const o=e.metadata?.listType||"bullet",s=kt(o),i=t.split(`
233
233
  `).map(a=>a.trim()).filter(a=>a.length>0);if(i.length===0){const a=wt();s.append(a)}else i.forEach(a=>{const l=wt();bg(a).forEach(u=>{const f=De(u.text);u.format&&f.setFormat(u.format),l.append(f)}),s.append(l)});return s}case"horizontalrule":return Vi();case"listitem":{const o=wt();return e.metadata?.checked!==void 0&&o.setChecked(e.metadata.checked),r().forEach(s=>o.append(s)),o}default:return null}}containsBlockLevelMarkdown(e){return!e||typeof e!="string"?!1:!!(/^#{1,6}[ \t]+\S/m.test(e)||/^[ \t]*[-*+][ \t]+\S/m.test(e)||/^[ \t]*\d+\.[ \t]+\S/m.test(e)||/\n\s*\n/.test(e))}parseMarkdownToBlocks(e){const t=[],r=e.split(`
234
234
  `);let o=null;for(let s=0;s<r.length;s++){const i=r[s],a=i.trim();if(a===""){o&&o.lines.length>0&&(t.push(this.createBlockFromParsed(o)),o=null);continue}const l=a.match(/^(#{1,6})\s+(\S.*)$/);if(l){o&&o.lines.length>0&&t.push(this.createBlockFromParsed(o));const f=l[1].length;t.push({block_id:"",block_type:"heading",source:l[2],metadata:{tag:`h${f}`}}),o=null;continue}const c=a.match(/^[-*+]\s+(\S.*)$/);if(c){!o||o.type!=="list-bullet"?(o&&o.lines.length>0&&t.push(this.createBlockFromParsed(o)),o={type:"list-bullet",lines:[c[1]],metadata:{listType:"bullet"}}):o.lines.push(c[1]);continue}const u=a.match(/^\d+\.\s+(\S.*)$/);if(u){!o||o.type!=="list-number"?(o&&o.lines.length>0&&t.push(this.createBlockFromParsed(o)),o={type:"list-number",lines:[u[1]],metadata:{listType:"number"}}):o.lines.push(u[1]);continue}!o||o.type.startsWith("list-")?(o&&o.lines.length>0&&t.push(this.createBlockFromParsed(o)),o={type:"paragraph",lines:[i]}):o.lines.push(i)}return o&&o.lines.length>0&&t.push(this.createBlockFromParsed(o)),t}createBlockFromParsed(e){return e.type==="list-bullet"||e.type==="list-number"?{block_id:"",block_type:"list",source:e.lines.join(`
235
235
  `),metadata:e.metadata||{}}:{block_id:"",block_type:e.type,source:e.lines.join(`
236
- `),metadata:e.metadata||{}}}async executeCode(e,t,r,o){const s=e||"";if(!s.trim())return{success:!1,error:"Code parameter is required and cannot be empty"};if(!this._serviceManager)return{success:!1,error:"No ServiceManager available. LexicalAdapter requires a ServiceManager to execute code."};let i;try{await this._serviceManager.kernels.refreshRunning();const a=Array.from(this._serviceManager.kernels.running());if(a.length===0)return{success:!1,error:"No active kernel found. Please start a kernel first."};const l=a[0];i=await this._serviceManager.kernels.connectTo({model:l})}catch(a){return{success:!1,error:`Failed to connect to kernel: ${a instanceof Error?a.message:String(a)}`}}if(!i||typeof i.requestExecute!="function")return{success:!1,error:"Kernel connection does not have requestExecute method."};try{const a=i.requestExecute({code:s,stop_on_error:o??!0,store_history:t??!0,silent:r??!1,allow_stdin:!1}),l=[];let c;return a.onIOPub=u=>{const f=u.header.msg_type;f==="stream"?l.push({type:"stream",content:u.content}):f==="execute_result"?(l.push({type:"execute_result",content:u.content}),c=u.content.execution_count):f==="display_data"?l.push({type:"display_data",content:u.content}):f==="error"&&l.push({type:"error",content:u.content})},await a.done,{success:!0,outputs:l,executionCount:c}}catch(a){return{success:!1,error:a instanceof Error?a.message:String(a)}}}async insertWithMarker(e,t){return new Promise(r=>{this._editor.update(()=>{const o=se(),s=o.getChildren(),i=ne();if(i.append(De("__MARKER__")),e==="TOP")s.length>0?s[0].insertBefore(i):o.append(i);else if(e==="BOTTOM"||!e)o.append(i);else{const a=s.find(l=>l.getKey()===e);if(a)a.insertAfter(i);else throw new Error(`Block ${e} not found`)}}),setTimeout(()=>{this._editor.update(()=>{const s=se().getChildren().find(i=>i.getType()==="paragraph"&&i.getTextContent()==="__MARKER__");s&&(s.selectEnd(),s.remove())}),t(),r()},10)})}insertNodeAtPosition(e,t){const r=se(),o=r.getChildren();if(t==="TOP")o.length>0?o[0].insertBefore(e):r.append(e);else if(t==="BOTTOM"||!t)r.append(e);else{const s=o.find(i=>i.getKey()===t);if(s)s.insertAfter(e);else throw new Error(`Block ${t} not found`)}}async listAvailableBlocks(){try{const{listAvailableBlocksOperation:e}=await me(async()=>{const{listAvailableBlocksOperation:r}=await import("./LexicalToolRegistry-mRwpy8uR.js").then(o=>o.A);return{listAvailableBlocksOperation:r}},[],import.meta.url);return await e.execute({type:"all"},{documentId:"static-operation",executor:null})}catch(e){return{success:!1,error:e instanceof Error?e.message:String(e)}}}}function Tm(n,e,t){const r=new aL(n,t),o=new Map(Zr.getState().lexicals);return o.set(e,{adapter:r}),Zr.getState().setLexicals(o),()=>{const s=new Map(Zr.getState().lexicals);s.delete(e),Zr.getState().setLexicals(s)}}const lL=pe({name:"@datalayer/jupyter-lexical/LexicalState",config:Jn({lexicalId:null,serviceManager:void 0}),build:(n,e)=>Hn(e),register:(n,e,t)=>{const{lexicalId:r,serviceManager:o}=t.getOutput();return Bt(()=>{const s=r.value;if(s)return Tm(n,s,o.value)})}});function oR(){const[n]=fe(),{lexicalId:e,serviceManager:t}=Tx();return C.useEffect(()=>Tm(n,e,t),[n,e,t]),null}const Em=7;function cL(n){const e=n.getNodes();return e.length===0?new Set([n.anchor.getNode().getParentOrThrow(),n.focus.getNode().getParentOrThrow()]):new Set(e.map(t=>H(t)?t:t.getParentOrThrow()))}function uL(n){const e=P();if(!j(e))return!1;const t=cL(e);let r=0;for(const o of t)if(Z(o))r=Math.max(us(o)+1,r);else if(le(o)){const s=o.getParent();if(!Z(s))throw new Error("ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent.");r=Math.max(us(s)+1,r)}return r<=n}function dL(n,e=Em){return n.registerCommand(Mt,()=>!uL(e),qe)}const fL=pe({name:"@datalayer/jupyter-lexical/ListMaxIndentLevel",config:Jn({maxDepth:Em}),dependencies:[Ui],build:(n,e)=>Hn(e),register:(n,e,t)=>{const{maxDepth:r}=t.getOutput();return Bt(()=>dL(n,r.value))}});function Wl(n,e){const t={};for(const r of n){const o=e(r);o&&(t[o]?t[o].push(r):t[o]=[r])}return t}function gL(n){const e=Wl(n,t=>t.type);return{element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const yg=/[!-/:-@[-`{-~\s]/;function wg(n){return n.replace(/\\([!-/:-@[-`{-~])/g,"$1").replace(/&#(\d+);/g,(e,t)=>String.fromCodePoint(Number(t)))}const pL=/^(\s*)(\d{1,})\.\s/,hL=/^(\s*)[-*+]\s/,_L=/^(#{1,6})\s/,mL=/^>\s/,bL=/^([ \t]*`{3,})([\w-]+)?[ \t]?/,yL=/^[ \t]*`{3,}$/,Yo=Cs("mdListMarker",{parse:n=>typeof n=="string"&&/^[-*+]$/.test(n)?n:"-",resetOnCopyNode:!0}),xg=Cs("mdCodeFence",{parse:n=>typeof n=="string"&&/^`{3,}$/.test(n)?n:"```",resetOnCopyNode:!0}),wL=Cs("mdHardLineBreak",{parse:n=>typeof n=="string"&&/^(\\| {2,})$/.test(n)?n:"",resetOnCopyNode:!0});function xL(n){if(n.endsWith("\\"))return[n.slice(0,-1),"\\"];const e=n.match(/^(.*?\S)( {2,})$/);return e?[e[1],e[2]]:null}function CL(n){const e=n.getChildren(),t=e.length-1,r=e[t];if(!oe(r))return null;const o=r.getTextContent(),s=xL(o);if(s!==null){const[i,a]=s;return r.setTextContent(i),a}return/^ {2,}$/.test(o)&&(function(i,a){for(let l=a-1;l>=0;l--){if(ue(i[l]))return!1;if(/\S/.test(i[l].getTextContent()))return!0}return!1})(e,t)?(r.setTextContent(""),o):null}function SL(n){const e=xt(),t=CL(n);return t!==null&&bn(e,wL,t),e}const Nm=n=>(e,t,r,o)=>{const s=n(r);s.append(...t),e.replace(s),o||s.select(0,0)},Lm=n=>(e,t,r,o)=>{if(Lr(e))return!1;const s=e.getPreviousSibling(),i=e.getNextSibling(),a=wt(n==="check"?r[3]==="x":void 0),l=r[0].trim()[0],c=n!=="bullet"&&n!=="check"||l!==Yo.parse(l)?void 0:l;if(Z(i)&&i.getListType()===n){c&&bn(i,Yo,c);const f=i.getFirstChild();f!==null?f.insertBefore(a):i.append(a),n==="number"&&i.setStart(Number(r[2])),e.remove()}else if(Z(s)&&s.getListType()===n)c&&bn(s,Yo,c),s.append(a),e.remove();else{const f=kt(n,n==="number"?Number(r[2]):void 0);c&&bn(f,Yo,c),f.append(a),e.replace(f)}a.append(...t),o||a.select(0,0);const u=(function(f){const d=f.match(/\t/g),p=f.match(/ /g);let h=0;return d&&(h+=d.length),p&&(h+=Math.floor(p.length/4)),h})(r[1]);u&&a.setIndent(u)},Eu=(n,e,t,r)=>{const o=[],s=n.getChildren();let i=0;for(const a of s)if(le(a)){if(a.getChildrenSize()===1){const p=a.getFirstChild();if(Z(p)){const h=Eu(p,e,t+1,r);h&&o.push(h);continue}}if(r&&!a.getChildren().some(p=>p.isSelected(r)))continue;const l=" ".repeat(4*t),c=n.getListType(),u=ss(n,Yo),f=c==="number"?`${n.getStart()+i}. `:c==="check"?`${u} [${a.getChecked()?"x":" "}] `:u+" ";let d=e(a);c!=="number"&&(d=d.replace(/^(\s{0,3}\d+)(\.\s)/,"$1\\$2")),o.push(l+f+d),i++}return o.join(`
236
+ `),metadata:e.metadata||{}}}async executeCode(e,t,r,o){const s=e||"";if(!s.trim())return{success:!1,error:"Code parameter is required and cannot be empty"};if(!this._serviceManager)return{success:!1,error:"No ServiceManager available. LexicalAdapter requires a ServiceManager to execute code."};let i;try{await this._serviceManager.kernels.refreshRunning();const a=Array.from(this._serviceManager.kernels.running());if(a.length===0)return{success:!1,error:"No active kernel found. Please start a kernel first."};const l=a[0];i=await this._serviceManager.kernels.connectTo({model:l})}catch(a){return{success:!1,error:`Failed to connect to kernel: ${a instanceof Error?a.message:String(a)}`}}if(!i||typeof i.requestExecute!="function")return{success:!1,error:"Kernel connection does not have requestExecute method."};try{const a=i.requestExecute({code:s,stop_on_error:o??!0,store_history:t??!0,silent:r??!1,allow_stdin:!1}),l=[];let c;return a.onIOPub=u=>{const f=u.header.msg_type;f==="stream"?l.push({type:"stream",content:u.content}):f==="execute_result"?(l.push({type:"execute_result",content:u.content}),c=u.content.execution_count):f==="display_data"?l.push({type:"display_data",content:u.content}):f==="error"&&l.push({type:"error",content:u.content})},await a.done,{success:!0,outputs:l,executionCount:c}}catch(a){return{success:!1,error:a instanceof Error?a.message:String(a)}}}async insertWithMarker(e,t){return new Promise(r=>{this._editor.update(()=>{const o=se(),s=o.getChildren(),i=ne();if(i.append(De("__MARKER__")),e==="TOP")s.length>0?s[0].insertBefore(i):o.append(i);else if(e==="BOTTOM"||!e)o.append(i);else{const a=s.find(l=>l.getKey()===e);if(a)a.insertAfter(i);else throw new Error(`Block ${e} not found`)}}),setTimeout(()=>{this._editor.update(()=>{const s=se().getChildren().find(i=>i.getType()==="paragraph"&&i.getTextContent()==="__MARKER__");s&&(s.selectEnd(),s.remove())}),t(),r()},10)})}insertNodeAtPosition(e,t){const r=se(),o=r.getChildren();if(t==="TOP")o.length>0?o[0].insertBefore(e):r.append(e);else if(t==="BOTTOM"||!t)r.append(e);else{const s=o.find(i=>i.getKey()===t);if(s)s.insertAfter(e);else throw new Error(`Block ${t} not found`)}}async listAvailableBlocks(){try{const{listAvailableBlocksOperation:e}=await me(async()=>{const{listAvailableBlocksOperation:r}=await import("./LexicalToolRegistry-BqxU1w4N.js").then(o=>o.A);return{listAvailableBlocksOperation:r}},[],import.meta.url);return await e.execute({type:"all"},{documentId:"static-operation",executor:null})}catch(e){return{success:!1,error:e instanceof Error?e.message:String(e)}}}}function Tm(n,e,t){const r=new aL(n,t),o=new Map(Zr.getState().lexicals);return o.set(e,{adapter:r}),Zr.getState().setLexicals(o),()=>{const s=new Map(Zr.getState().lexicals);s.delete(e),Zr.getState().setLexicals(s)}}const lL=pe({name:"@datalayer/jupyter-lexical/LexicalState",config:Jn({lexicalId:null,serviceManager:void 0}),build:(n,e)=>Hn(e),register:(n,e,t)=>{const{lexicalId:r,serviceManager:o}=t.getOutput();return Bt(()=>{const s=r.value;if(s)return Tm(n,s,o.value)})}});function oR(){const[n]=fe(),{lexicalId:e,serviceManager:t}=Tx();return C.useEffect(()=>Tm(n,e,t),[n,e,t]),null}const Em=7;function cL(n){const e=n.getNodes();return e.length===0?new Set([n.anchor.getNode().getParentOrThrow(),n.focus.getNode().getParentOrThrow()]):new Set(e.map(t=>H(t)?t:t.getParentOrThrow()))}function uL(n){const e=P();if(!j(e))return!1;const t=cL(e);let r=0;for(const o of t)if(Z(o))r=Math.max(us(o)+1,r);else if(le(o)){const s=o.getParent();if(!Z(s))throw new Error("ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent.");r=Math.max(us(s)+1,r)}return r<=n}function dL(n,e=Em){return n.registerCommand(Mt,()=>!uL(e),qe)}const fL=pe({name:"@datalayer/jupyter-lexical/ListMaxIndentLevel",config:Jn({maxDepth:Em}),dependencies:[Ui],build:(n,e)=>Hn(e),register:(n,e,t)=>{const{maxDepth:r}=t.getOutput();return Bt(()=>dL(n,r.value))}});function Wl(n,e){const t={};for(const r of n){const o=e(r);o&&(t[o]?t[o].push(r):t[o]=[r])}return t}function gL(n){const e=Wl(n,t=>t.type);return{element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const yg=/[!-/:-@[-`{-~\s]/;function wg(n){return n.replace(/\\([!-/:-@[-`{-~])/g,"$1").replace(/&#(\d+);/g,(e,t)=>String.fromCodePoint(Number(t)))}const pL=/^(\s*)(\d{1,})\.\s/,hL=/^(\s*)[-*+]\s/,_L=/^(#{1,6})\s/,mL=/^>\s/,bL=/^([ \t]*`{3,})([\w-]+)?[ \t]?/,yL=/^[ \t]*`{3,}$/,Yo=Cs("mdListMarker",{parse:n=>typeof n=="string"&&/^[-*+]$/.test(n)?n:"-",resetOnCopyNode:!0}),xg=Cs("mdCodeFence",{parse:n=>typeof n=="string"&&/^`{3,}$/.test(n)?n:"```",resetOnCopyNode:!0}),wL=Cs("mdHardLineBreak",{parse:n=>typeof n=="string"&&/^(\\| {2,})$/.test(n)?n:"",resetOnCopyNode:!0});function xL(n){if(n.endsWith("\\"))return[n.slice(0,-1),"\\"];const e=n.match(/^(.*?\S)( {2,})$/);return e?[e[1],e[2]]:null}function CL(n){const e=n.getChildren(),t=e.length-1,r=e[t];if(!oe(r))return null;const o=r.getTextContent(),s=xL(o);if(s!==null){const[i,a]=s;return r.setTextContent(i),a}return/^ {2,}$/.test(o)&&(function(i,a){for(let l=a-1;l>=0;l--){if(ue(i[l]))return!1;if(/\S/.test(i[l].getTextContent()))return!0}return!1})(e,t)?(r.setTextContent(""),o):null}function SL(n){const e=xt(),t=CL(n);return t!==null&&bn(e,wL,t),e}const Nm=n=>(e,t,r,o)=>{const s=n(r);s.append(...t),e.replace(s),o||s.select(0,0)},Lm=n=>(e,t,r,o)=>{if(Lr(e))return!1;const s=e.getPreviousSibling(),i=e.getNextSibling(),a=wt(n==="check"?r[3]==="x":void 0),l=r[0].trim()[0],c=n!=="bullet"&&n!=="check"||l!==Yo.parse(l)?void 0:l;if(Z(i)&&i.getListType()===n){c&&bn(i,Yo,c);const f=i.getFirstChild();f!==null?f.insertBefore(a):i.append(a),n==="number"&&i.setStart(Number(r[2])),e.remove()}else if(Z(s)&&s.getListType()===n)c&&bn(s,Yo,c),s.append(a),e.remove();else{const f=kt(n,n==="number"?Number(r[2]):void 0);c&&bn(f,Yo,c),f.append(a),e.replace(f)}a.append(...t),o||a.select(0,0);const u=(function(f){const d=f.match(/\t/g),p=f.match(/ /g);let h=0;return d&&(h+=d.length),p&&(h+=Math.floor(p.length/4)),h})(r[1]);u&&a.setIndent(u)},Eu=(n,e,t,r)=>{const o=[],s=n.getChildren();let i=0;for(const a of s)if(le(a)){if(a.getChildrenSize()===1){const p=a.getFirstChild();if(Z(p)){const h=Eu(p,e,t+1,r);h&&o.push(h);continue}}if(r&&!a.getChildren().some(p=>p.isSelected(r)))continue;const l=" ".repeat(4*t),c=n.getListType(),u=ss(n,Yo),f=c==="number"?`${n.getStart()+i}. `:c==="check"?`${u} [${a.getChecked()?"x":" "}] `:u+" ";let d=e(a);c!=="number"&&(d=d.replace(/^(\s{0,3}\d+)(\.\s)/,"$1\\$2")),o.push(l+f+d),i++}return o.join(`
237
237
  `)},vL={dependencies:[Es],export:(n,e)=>{if(!Lr(n))return null;const t=Number(n.getTag().slice(1));return"#".repeat(t)+" "+e(n)},regExp:_L,replace:Nm(n=>{const e="h"+n[1].length;return cn(e)}),triggerOnEnter:!0,type:"element"},kL={dependencies:[Ts],export:(n,e)=>{if(!Bn(n))return null;const t=e(n).split(`
238
238
  `),r=[];for(const o of t)r.push("> "+o);return r.join(`
239
239
  `)},regExp:mL,replace:(n,e,t,r)=>{if(r){const s=n.getPreviousSibling();if(Bn(s))return s.splice(s.getChildrenSize(),0,[SL(s),...e]),void n.remove()}const o=Sn();o.append(...e),n.replace(o),r||o.select(0,0)},triggerOnEnter:!0,type:"element"},di={dependencies:[ln],export:n=>{if(!je(n))return null;const e=n.getTextContent();let t=ss(n,xg);if(e.indexOf(t)>-1){const r=e.match(/`{3,}/g);if(r){const o=Math.max(...r.map(s=>s.length));t="`".repeat(o+1)}}return t+(n.getLanguage()||"")+(e?`