@datalayer/agent-runtimes 1.5.7 → 1.5.8
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.
- package/dist-embed/chunks/{AgentDetails-KezohVQI.js → AgentDetails-CMBy5o1q.js} +1 -1
- package/dist-embed/chunks/{AgentDetailsDialog-CklhMnk7.js → AgentDetailsDialog-D2vH2Nrd.js} +1 -1
- package/dist-embed/chunks/{AgentInspector-CtCaRc1L.js → AgentInspector-Bd0oHNAX.js} +1 -1
- package/dist-embed/chunks/{AgentInspectorDialog-DB9cx3Gd.js → AgentInspectorDialog-BJUgBPAE.js} +1 -1
- package/dist-embed/chunks/{CellSidebarExtension-CfaJL6DQ.js → CellSidebarExtension-CYOVwk1t.js} +6 -6
- package/dist-embed/chunks/ChatView-DIdw1rtZ.js +32 -0
- package/dist-embed/chunks/{ContextPie-1vP4f-3N.js → ContextPie-B9mAKJc2.js} +1 -1
- package/dist-embed/chunks/{DeckComponent-82GVdsoi.js → DeckComponent-CbmzVWcF.js} +2 -2
- package/dist-embed/chunks/{DocumentView-SrJloJDo.js → DocumentView-BqsGfNys.js} +1 -1
- package/dist-embed/chunks/{EphemeralDocument-t1KulOH8.js → EphemeralDocument-DLaNvwm_.js} +1 -1
- package/dist-embed/chunks/{EphemeralNotebook-Co-WQWCc.js → EphemeralNotebook-jnqAJFPI.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawComponent-5NeLUYVB.js → ExcalidrawComponent-Cb8yeXqu.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawModal-9ZnOB03n.js → ExcalidrawModal-DaPSGYek.js} +1 -1
- package/dist-embed/chunks/{JupyterLexicalExtension-Cize8RXy.js → JupyterLexicalExtension-BQINjIFV.js} +9 -9
- package/dist-embed/chunks/{KernelVariables-Cl57Zze1.js → KernelVariables-CGQkS5EX.js} +1 -1
- package/dist-embed/chunks/{LexicalToolRegistry-CoM9ROsx.js → LexicalToolRegistry-BJ6mpMWn.js} +1 -1
- package/dist-embed/chunks/{NotebookToolSurfaces-CWfppxBN.js → NotebookToolSurfaces-DiPifvaW.js} +1 -1
- package/dist-embed/chunks/{NotebookView-DOf_K74b.js → NotebookView-IX0wNuX8.js} +1 -1
- package/dist-embed/chunks/{Output-9DKTscSv.js → Output-B9XAhyoF.js} +1 -1
- package/dist-embed/chunks/{SandboxDetailsDialog-BCfDm6MB.js → SandboxDetailsDialog-COCpmo8m.js} +1 -1
- package/dist-embed/chunks/{SchemaForm-BOYPrvf8.js → SchemaForm-WIwdKnrk.js} +1 -1
- package/dist-embed/chunks/{WidgetVariableView-BTOwHP78.js → WidgetVariableView-BoGROi-A.js} +1 -1
- package/dist-embed/chunks/{YouTubePlugin-Bs4zZIB1.js → YouTubePlugin-BEQBWMwx.js} +1 -1
- package/dist-embed/chunks/{abnfDiagram-VCTEODGH-D5p59vS_.js → abnfDiagram-VCTEODGH-CG18Hf18.js} +1 -1
- package/dist-embed/chunks/{abnfDiagram-VCTEODGH-DRYbUvhc.js → abnfDiagram-VCTEODGH-D3_T0Lze.js} +1 -1
- package/dist-embed/chunks/{ar-SA-G6X2FPQ2-D6XRzkBS.js → ar-SA-G6X2FPQ2-BDWXsTdt.js} +1 -1
- package/dist-embed/chunks/{architectureDiagram-5GKGNRK7-DQGv0imf.js → architectureDiagram-5GKGNRK7-B1QPAYO8.js} +1 -1
- package/dist-embed/chunks/{architectureDiagram-5GKGNRK7-B7ITKDup.js → architectureDiagram-5GKGNRK7-B5kSsKje.js} +1 -1
- package/dist-embed/chunks/{az-AZ-76LH7QW2-DBTdUiqp.js → az-AZ-76LH7QW2-BGchGiT7.js} +1 -1
- package/dist-embed/chunks/{bg-BG-XCXSNQG7-DuhcsaSL.js → bg-BG-XCXSNQG7-vCII6Zuq.js} +1 -1
- package/dist-embed/chunks/{blockDiagram-868be97b-DYe-XTjy.js → blockDiagram-868be97b-BvM0ptp7.js} +1 -1
- package/dist-embed/chunks/{blockDiagram-I7D4REHJ-y7tEFo3j.js → blockDiagram-I7D4REHJ-B8BmxOM4.js} +1 -1
- package/dist-embed/chunks/{blockDiagram-I7D4REHJ-IltJXCd6.js → blockDiagram-I7D4REHJ-ClwWG8yx.js} +1 -1
- package/dist-embed/chunks/{bn-BD-2XOGV67Q-CPFeLVSN.js → bn-BD-2XOGV67Q-Beu9yUTu.js} +1 -1
- package/dist-embed/chunks/{c4Diagram-3f4bdde3-Bybp0wky.js → c4Diagram-3f4bdde3-S92W2yOx.js} +1 -1
- package/dist-embed/chunks/{c4Diagram-7LVT6UL2-DpaHndz8.js → c4Diagram-7LVT6UL2-CNWW_-u7.js} +1 -1
- package/dist-embed/chunks/{c4Diagram-7LVT6UL2-CizxVqqX.js → c4Diagram-7LVT6UL2-nSCKKLuX.js} +1 -1
- package/dist-embed/chunks/{ca-ES-6MX7JW3Y-gDR_kEC6.js → ca-ES-6MX7JW3Y-CnEo6YQi.js} +1 -1
- package/dist-embed/chunks/{celltoolbartracker-DLF4PWyW.js → celltoolbartracker-CO6V5FhH.js} +1 -1
- package/dist-embed/chunks/{chunk-2Q5K7J3B-BI6lURun.js → chunk-2Q5K7J3B--r8j4N5L.js} +1 -1
- package/dist-embed/chunks/{chunk-2Q5K7J3B-DWoLSrj9.js → chunk-2Q5K7J3B-D3fTIaw3.js} +1 -1
- package/dist-embed/chunks/{chunk-5VM5RSS4-SleuNqDC.js → chunk-5VM5RSS4-D76mXyWz.js} +1 -1
- package/dist-embed/chunks/{chunk-5VM5RSS4-CDh4wYym.js → chunk-5VM5RSS4-QmrgOATO.js} +1 -1
- package/dist-embed/chunks/{chunk-F27PBJKO-h_FwJMTr.js → chunk-F27PBJKO-DdSgBnK0.js} +1 -1
- package/dist-embed/chunks/{chunk-F27PBJKO-AvWsNGYY.js → chunk-F27PBJKO-DvNrStTM.js} +1 -1
- package/dist-embed/chunks/{chunk-IMKFNOWR-DGRceKiU.js → chunk-IMKFNOWR-DpxND1Ct.js} +1 -1
- package/dist-embed/chunks/{chunk-IMKFNOWR-Hx4a5yny.js → chunk-IMKFNOWR-DwqmSZhU.js} +1 -1
- package/dist-embed/chunks/{chunk-JWPE2WC7-A4gy2qc4.js → chunk-JWPE2WC7-i7V3vMtZ.js} +1 -1
- package/dist-embed/chunks/{chunk-JWPE2WC7-BuJactJo.js → chunk-JWPE2WC7-jla8jvq5.js} +1 -1
- package/dist-embed/chunks/{chunk-POPQ4Y6H-CFM-817s.js → chunk-POPQ4Y6H-BGCugXU7.js} +1 -1
- package/dist-embed/chunks/{chunk-POPQ4Y6H-CmRF80iG.js → chunk-POPQ4Y6H-ofrenTaa.js} +1 -1
- package/dist-embed/chunks/{chunk-SVP7TREG-CryZx9JE.js → chunk-SVP7TREG-2Q2uQyQk.js} +1 -1
- package/dist-embed/chunks/{chunk-SVP7TREG-DSNzmytH.js → chunk-SVP7TREG-BIxxVjkU.js} +1 -1
- package/dist-embed/chunks/{chunk-TICWLB2K-DyGS3fIj.js → chunk-TICWLB2K-BqA5q52L.js} +1 -1
- package/dist-embed/chunks/{chunk-TICWLB2K-CEaDF8ZJ.js → chunk-TICWLB2K-LNiCmYq5.js} +1 -1
- package/dist-embed/chunks/{chunk-XXDRQBXY-8Cnzpdjz.js → chunk-XXDRQBXY-CNMg_gvd.js} +1 -1
- package/dist-embed/chunks/{chunk-XXDRQBXY-DxQBcVOz.js → chunk-XXDRQBXY-CqtfA3WC.js} +1 -1
- package/dist-embed/chunks/{classDiagram-ZZMXUADV-yvP3zMO3.js → classDiagram-ZZMXUADV-Co0jT9i-.js} +1 -1
- package/dist-embed/chunks/{classDiagram-ZZMXUADV-BQkO1UYr.js → classDiagram-ZZMXUADV-D6z_X195.js} +1 -1
- package/dist-embed/chunks/{classDiagram-f62afe4f-AYfpYKtp.js → classDiagram-f62afe4f-lN62p17q.js} +1 -1
- package/dist-embed/chunks/{classDiagram-v2-604399ef-BWyNcT_y.js → classDiagram-v2-604399ef-B_QJ6H8h.js} +1 -1
- package/dist-embed/chunks/{classDiagram-v2-VYDZK3BY-yvP3zMO3.js → classDiagram-v2-VYDZK3BY-Co0jT9i-.js} +1 -1
- package/dist-embed/chunks/{classDiagram-v2-VYDZK3BY-BQkO1UYr.js → classDiagram-v2-VYDZK3BY-D6z_X195.js} +1 -1
- package/dist-embed/chunks/{code-block-IT6T5CEO-F4BSIGY6.js → code-block-IT6T5CEO-BA38Km-f.js} +1 -1
- package/dist-embed/chunks/{component-DMQ8W8n1.js → component-Chor_J7e.js} +1 -1
- package/dist-embed/chunks/{cose-bilkent-JH36ORCC-C3HC0XIY.js → cose-bilkent-JH36ORCC-B5H1cwBa.js} +1 -1
- package/dist-embed/chunks/{cose-bilkent-JH36ORCC-MVxlcfpd.js → cose-bilkent-JH36ORCC-C3cTgEcU.js} +1 -1
- package/dist-embed/chunks/{createText-aed3d8b3-CEJODAXJ.js → createText-aed3d8b3-BtgHeyNs.js} +1 -1
- package/dist-embed/chunks/{cs-CZ-2BRQDIVT-BXQxcYp6.js → cs-CZ-2BRQDIVT-ClBKH9_y.js} +1 -1
- package/dist-embed/chunks/{cynefinDiagram-5FMLGOSQ-DNRKTIHx.js → cynefinDiagram-5FMLGOSQ-DPQLh9z7.js} +1 -1
- package/dist-embed/chunks/{cynefinDiagram-5FMLGOSQ-D87ENxS0.js → cynefinDiagram-5FMLGOSQ-sdsAonZm.js} +1 -1
- package/dist-embed/chunks/{da-DK-5WZEPLOC-Ck3vidj3.js → da-DK-5WZEPLOC-BqFDUAty.js} +1 -1
- package/dist-embed/chunks/{dagre-GXQ25YYZ-BOhThFKd.js → dagre-GXQ25YYZ-Bwf_WjLM.js} +1 -1
- package/dist-embed/chunks/{dagre-GXQ25YYZ-DscCD5Uq.js → dagre-GXQ25YYZ-DHF-9-7e.js} +1 -1
- package/dist-embed/chunks/{de-DE-XR44H4JA-CPZgrOuc.js → de-DE-XR44H4JA-6dsEQn7Z.js} +1 -1
- package/dist-embed/chunks/{diagram-S7CK7UJ4-zDQduoQy.js → diagram-S7CK7UJ4-C-N7Ei3I.js} +1 -1
- package/dist-embed/chunks/{diagram-S7CK7UJ4-CUhme3Bl.js → diagram-S7CK7UJ4-DEqGRBMT.js} +1 -1
- package/dist-embed/chunks/{diagram-UQ7AKVKN-BxhQPjAM.js → diagram-UQ7AKVKN-CvSBE0YU.js} +1 -1
- package/dist-embed/chunks/{diagram-UQ7AKVKN-Byi-v8UN.js → diagram-UQ7AKVKN-DACyxI-v.js} +1 -1
- package/dist-embed/chunks/{diagram-VSXAHHWV-au-v2v9D.js → diagram-VSXAHHWV-DFze2xro.js} +1 -1
- package/dist-embed/chunks/{diagram-VSXAHHWV-CqihYkDH.js → diagram-VSXAHHWV-DOb69VtE.js} +1 -1
- package/dist-embed/chunks/{diagram-VX7I27RA-Cd5PaF_n.js → diagram-VX7I27RA-8EKYM_Sx.js} +1 -1
- package/dist-embed/chunks/{diagram-VX7I27RA-ETzwrw79.js → diagram-VX7I27RA-CVTSdYyZ.js} +1 -1
- package/dist-embed/chunks/{diagram-Z3DM3KII-DkbsvY2A.js → diagram-Z3DM3KII-B-689FF6.js} +1 -1
- package/dist-embed/chunks/{diagram-Z3DM3KII-AcMuRFo5.js → diagram-Z3DM3KII-DyiBmBFy.js} +1 -1
- package/dist-embed/chunks/{ebnfDiagram-PWID7BFC-DuWfMZcD.js → ebnfDiagram-PWID7BFC-DcKvqn_h.js} +1 -1
- package/dist-embed/chunks/{ebnfDiagram-PWID7BFC-BrEs-SB2.js → ebnfDiagram-PWID7BFC-gj8dgCWR.js} +1 -1
- package/dist-embed/chunks/{edges-b2856ca0-Czd3-xvj.js → edges-b2856ca0-BqGGNnb4.js} +1 -1
- package/dist-embed/chunks/{el-GR-BZB4AONW-CjQSkw0P.js → el-GR-BZB4AONW-DOMW2ttY.js} +1 -1
- package/dist-embed/chunks/{erDiagram-5d81789a-JegaF4gy.js → erDiagram-5d81789a-Bf1Ik49K.js} +1 -1
- package/dist-embed/chunks/{erDiagram-RLTQ6QDP-xubaXuKR.js → erDiagram-RLTQ6QDP-B0PyZB_3.js} +1 -1
- package/dist-embed/chunks/{erDiagram-RLTQ6QDP-Cpn6_cd1.js → erDiagram-RLTQ6QDP-GSu-_IUJ.js} +1 -1
- package/dist-embed/chunks/{es-ES-U4NZUMDT-CQz3Tsxk.js → es-ES-U4NZUMDT-DeyWqjw1.js} +1 -1
- package/dist-embed/chunks/{eu-ES-A7QVB2H4-DPwxHXvP.js → eu-ES-A7QVB2H4-CUGbZ0Pv.js} +1 -1
- package/dist-embed/chunks/{fa-IR-HGAKTJCU-DlQyRFJP.js → fa-IR-HGAKTJCU-Br8UEVO1.js} +1 -1
- package/dist-embed/chunks/{fi-FI-Z5N7JZ37-BL9Dv0rT.js → fi-FI-Z5N7JZ37-BSHjwo8G.js} +1 -1
- package/dist-embed/chunks/{flowDb-185abca5-BN_8lgCO.js → flowDb-185abca5-U9PwWSO4.js} +1 -1
- package/dist-embed/chunks/{flowDiagram-1629c991-YRlRqB59.js → flowDiagram-1629c991-BecgzQgp.js} +1 -1
- package/dist-embed/chunks/{flowDiagram-HODETNUW-lW-icIxi.js → flowDiagram-HODETNUW-2vih3kWM.js} +1 -1
- package/dist-embed/chunks/{flowDiagram-HODETNUW-CzRvxVGK.js → flowDiagram-HODETNUW-tcAkcGh4.js} +1 -1
- package/dist-embed/chunks/{flowDiagram-v2-1d953310-DBFSFroi.js → flowDiagram-v2-1d953310-Bdmc9G3m.js} +1 -1
- package/dist-embed/chunks/{flowchart-elk-definition-6df44142-RjL83g27.js → flowchart-elk-definition-6df44142-oWOWsVNc.js} +1 -1
- package/dist-embed/chunks/{fr-FR-RHASNOE6-xB7HyFVv.js → fr-FR-RHASNOE6-BukqZYPz.js} +1 -1
- package/dist-embed/chunks/{ganttDiagram-3b0b3873-Dowe9cKl.js → ganttDiagram-3b0b3873-B7lmD9r9.js} +1 -1
- package/dist-embed/chunks/{ganttDiagram-EL5Y4UJY-CNQPBdAP.js → ganttDiagram-EL5Y4UJY-D0E7se_Z.js} +1 -1
- package/dist-embed/chunks/{ganttDiagram-EL5Y4UJY-CLaynGwe.js → ganttDiagram-EL5Y4UJY-DDbqMevq.js} +1 -1
- package/dist-embed/chunks/{gitGraphDiagram-WWUBYQGX-CupHqYWl.js → gitGraphDiagram-WWUBYQGX-DK3EJl5z.js} +1 -1
- package/dist-embed/chunks/{gitGraphDiagram-WWUBYQGX-CDuBbPX3.js → gitGraphDiagram-WWUBYQGX-DnVwXJWu.js} +1 -1
- package/dist-embed/chunks/{gitGraphDiagram-f01e8bc2-C06Sje1n.js → gitGraphDiagram-f01e8bc2-B9vpLy6R.js} +1 -1
- package/dist-embed/chunks/{gl-ES-HMX3MZ6V-BX50ltap.js → gl-ES-HMX3MZ6V-BxVOJiaI.js} +1 -1
- package/dist-embed/chunks/{he-IL-6SHJWFNN-DR3hLzYG.js → he-IL-6SHJWFNN-Dv2VRxlJ.js} +1 -1
- package/dist-embed/chunks/{hi-IN-IWLTKZ5I-C3bSDqVc.js → hi-IN-IWLTKZ5I-CFo5RUMz.js} +1 -1
- package/dist-embed/chunks/{hu-HU-A5ZG7DT2--mRUDQG6.js → hu-HU-A5ZG7DT2-ul3dS3un.js} +1 -1
- package/dist-embed/chunks/{id-ID-SAP4L64H-D6psdwdp.js → id-ID-SAP4L64H-ItVb-zwI.js} +1 -1
- package/dist-embed/chunks/{index-qsUgit40.js → index-7FNjj0f2.js} +1 -1
- package/dist-embed/chunks/{index-9bae90f3-BY7E8HZU.js → index-9bae90f3-D9849sgo.js} +1 -1
- package/dist-embed/chunks/{index-DToDguC3.js → index-B-L6ocEV.js} +1 -1
- package/dist-embed/chunks/{index-C01nR1dW.js → index-B0wMyD8Y.js} +1 -1
- package/dist-embed/chunks/{index-BzXMsI1v.js → index-B5zrJYwn.js} +6 -6
- package/dist-embed/chunks/{index-DcZQ2Oqj.js → index-B764si9c.js} +1 -1
- package/dist-embed/chunks/{index-3O3ob63z.js → index-BM6oRiO1.js} +1 -1
- package/dist-embed/chunks/{index-DVUMPcVw.js → index-BNFRRs9d.js} +1 -1
- package/dist-embed/chunks/{index-D0DBuFMt.js → index-BOYhJnrD.js} +1 -1
- package/dist-embed/chunks/{index-CA8D7U2s.js → index-BT4vYFeY.js} +1 -1
- package/dist-embed/chunks/{index-C8IekrmL.js → index-BfUXEHI0.js} +1 -1
- package/dist-embed/chunks/{index-DvWWLOj6.js → index-BiTIdbkn.js} +1 -1
- package/dist-embed/chunks/{index-BhU2ra4k.js → index-BkKEXqQS.js} +1 -1
- package/dist-embed/chunks/{index-CpcHHQd7.js → index-BqMoyzEk.js} +1 -1
- package/dist-embed/chunks/{index-D1lY79hS.js → index-BrD9dtoV.js} +1 -1
- package/dist-embed/chunks/{index-B063q-PC.js → index-CRpZyQIR.js} +4 -4
- package/dist-embed/chunks/{index-BblwlEJB.js → index-CZdWsyNw.js} +1 -1
- package/dist-embed/chunks/{index-Azo_wV3K.js → index-CjM49jS0.js} +1 -1
- package/dist-embed/chunks/{index-rfsiH_M6.js → index-Cp2aJ2ZR.js} +1 -1
- package/dist-embed/chunks/{index-Cknn3VQD.js → index-Cql9gOsL.js} +1 -1
- package/dist-embed/chunks/{index-jy9kOmqu.js → index-CsgaCZaW.js} +1 -1
- package/dist-embed/chunks/{index-DB46n9Tf.js → index-CsxlyZef.js} +1 -1
- package/dist-embed/chunks/{index-MTdX216X.js → index-D2LvuQlP.js} +1 -1
- package/dist-embed/chunks/{index-s3hayhRS.js → index-DQQXY-7d.js} +2 -2
- package/dist-embed/chunks/{index-B0KVfQGJ.js → index-DSF21-29.js} +1 -1
- package/dist-embed/chunks/{index-BYMZi_1t.js → index-DSvebR7d.js} +1 -1
- package/dist-embed/chunks/{index-a51XM5L8.js → index-DoBEQ07P.js} +3 -3
- package/dist-embed/chunks/{index-kpqZuE4J.js → index-O2jaI8TY.js} +1 -1
- package/dist-embed/chunks/{index-C6wF35Kk.js → index-QZ3sHHT3.js} +1 -1
- package/dist-embed/chunks/{index-BlWZloLe.js → index-TEcp7-f6.js} +2 -2
- package/dist-embed/chunks/{index-EpYurdzk.js → index-YlGTgJvL.js} +5 -5
- package/dist-embed/chunks/{index-CUL9WiLS.js → index-bm8APcDZ.js} +1 -1
- package/dist-embed/chunks/{index-BipXK1tF.js → index-jh9S19of.js} +1 -1
- package/dist-embed/chunks/{index-C643Hfu1.js → index-oGqh9y23.js} +1 -1
- package/dist-embed/chunks/{index-BdvS7Q4t.js → index-xiH3WzLm.js} +1 -1
- package/dist-embed/chunks/{index.esm-CWygaJYM.js → index.esm-B7KoTOBb.js} +1 -1
- package/dist-embed/chunks/{index.esm-DYeUXS4c.js → index.esm-CkSite-X.js} +1 -1
- package/dist-embed/chunks/{infoDiagram-27XIBGKW-Ctm-zk09.js → infoDiagram-27XIBGKW-DDO50Ria.js} +1 -1
- package/dist-embed/chunks/{infoDiagram-27XIBGKW-DRzH33_4.js → infoDiagram-27XIBGKW-O3q53Qe2.js} +1 -1
- package/dist-embed/chunks/{infoDiagram-a29d40f1-c78-ZMuT.js → infoDiagram-a29d40f1-jOvOHUyu.js} +1 -1
- package/dist-embed/chunks/{isEqual-niFNV5MZ.js → isEqual-CGLTk7wU.js} +1 -1
- package/dist-embed/chunks/{ishikawaDiagram-5VMMS53U-DKv5KL85.js → ishikawaDiagram-5VMMS53U-DuiWhpVW.js} +1 -1
- package/dist-embed/chunks/{ishikawaDiagram-5VMMS53U-CILSTTqm.js → ishikawaDiagram-5VMMS53U-IzmbYzxv.js} +1 -1
- package/dist-embed/chunks/{it-IT-JPQ66NNP-BfrG_atL.js → it-IT-JPQ66NNP-BuCUBzia.js} +1 -1
- package/dist-embed/chunks/{ja-JP-DBVTYXUO-sahpmNGY.js → ja-JP-DBVTYXUO-BhtQz4sy.js} +1 -1
- package/dist-embed/chunks/{journeyDiagram-3NMN7TZE-CSMQRlsr.js → journeyDiagram-3NMN7TZE-DGLcsVfC.js} +1 -1
- package/dist-embed/chunks/{journeyDiagram-3NMN7TZE-DlMPiHSP.js → journeyDiagram-3NMN7TZE-sO-Cfp65.js} +1 -1
- package/dist-embed/chunks/{journeyDiagram-95396277-VzHClVrX.js → journeyDiagram-95396277-CA4bGq0G.js} +1 -1
- package/dist-embed/chunks/{kaa-6HZHGXH3-BrkhtXQj.js → kaa-6HZHGXH3-B_TI8Aa0.js} +1 -1
- package/dist-embed/chunks/{kab-KAB-ZGHBKWFO-DwtFIV_I.js → kab-KAB-ZGHBKWFO-BsSg_l-j.js} +1 -1
- package/dist-embed/chunks/{kanban-definition-UXKFOSKX-BkxvAXq2.js → kanban-definition-UXKFOSKX-0wjvwDqk.js} +1 -1
- package/dist-embed/chunks/{kanban-definition-UXKFOSKX-esf1amn7.js → kanban-definition-UXKFOSKX-CDtLkjnU.js} +1 -1
- package/dist-embed/chunks/{kk-KZ-P5N5QNE5-UxN1LGH5.js → kk-KZ-P5N5QNE5-B7XK5OQq.js} +1 -1
- package/dist-embed/chunks/{km-KH-HSX4SM5Z-B7lolfpy.js → km-KH-HSX4SM5Z-Cm2LA9F8.js} +1 -1
- package/dist-embed/chunks/{ko-KR-MTYHY66A-CnxefCaN.js → ko-KR-MTYHY66A-CL5s99y5.js} +1 -1
- package/dist-embed/chunks/{ku-TR-6OUDTVRD-Bt7bmFnv.js → ku-TR-6OUDTVRD-CiijvKHq.js} +1 -1
- package/dist-embed/chunks/{layout-D7Mk1riq.js → layout-BBbB54WC.js} +1 -1
- package/dist-embed/chunks/{layout-Sl9Lf6Ae.js → layout-CzrlbzeK.js} +1 -1
- package/dist-embed/chunks/{lexicalHooks-DKF-DsxG.js → lexicalHooks-DQxNZEiJ.js} +1 -1
- package/dist-embed/chunks/{lt-LT-XHIRWOB4-D6qkXs9m.js → lt-LT-XHIRWOB4-CcA_Z5jR.js} +1 -1
- package/dist-embed/chunks/{lv-LV-5QDEKY6T-D8g27j86.js → lv-LV-5QDEKY6T-CAQS9wGm.js} +1 -1
- package/dist-embed/chunks/{mermaid.core-BhiOhb5K.js → mermaid.core-DfgoT1cz.js} +3 -3
- package/dist-embed/chunks/{mermaid.core-CRlujv29.js → mermaid.core-s-D09gpV.js} +5 -5
- package/dist-embed/chunks/{mindmap-definition-YA3MSWOX-eCxs0BsL.js → mindmap-definition-YA3MSWOX-B6_K5ZvV.js} +1 -1
- package/dist-embed/chunks/{mindmap-definition-YA3MSWOX-BJQsz4H1.js → mindmap-definition-YA3MSWOX-BCiSPRJk.js} +1 -1
- package/dist-embed/chunks/{mindmap-definition-e4c1d938-DoGG9eDO.js → mindmap-definition-e4c1d938-D7gmABiC.js} +1 -1
- package/dist-embed/chunks/{mr-IN-CRQNXWMA-CMbVGyJm.js → mr-IN-CRQNXWMA-DMAAvsDA.js} +1 -1
- package/dist-embed/chunks/{my-MM-5M5IBNSE-B-KPsx1j.js → my-MM-5M5IBNSE-t2TKqrjW.js} +1 -1
- package/dist-embed/chunks/{nb-NO-T6EIAALU-Cl7QLAt7.js → nb-NO-T6EIAALU-Bi3ZI-HQ.js} +1 -1
- package/dist-embed/chunks/{nl-NL-IS3SIHDZ-Brzte_o2.js → nl-NL-IS3SIHDZ-B8UdlW1K.js} +1 -1
- package/dist-embed/chunks/{nn-NO-6E72VCQL-CzCKEx02.js → nn-NO-6E72VCQL-Bt87hI27.js} +1 -1
- package/dist-embed/chunks/{oc-FR-POXYY2M6-DA72PkVY.js → oc-FR-POXYY2M6-009NL0Pk.js} +1 -1
- package/dist-embed/chunks/{pa-IN-N4M65BXN-CzkFYtL0.js → pa-IN-N4M65BXN-BfUtS2yt.js} +1 -1
- package/dist-embed/chunks/{pegDiagram-XKGWAZYB-CD3xZvKE.js → pegDiagram-XKGWAZYB-BX0ZYMng.js} +1 -1
- package/dist-embed/chunks/{pegDiagram-XKGWAZYB-CV-d6HkK.js → pegDiagram-XKGWAZYB-CBrnWUaX.js} +1 -1
- package/dist-embed/chunks/{percentages-BXMCSKIN-mjCCp4uI.js → percentages-BXMCSKIN-CfzulzOv.js} +5 -5
- package/dist-embed/chunks/{pieDiagram-E7YTZNPT-toANOh_O.js → pieDiagram-E7YTZNPT-B1My5W85.js} +1 -1
- package/dist-embed/chunks/{pieDiagram-E7YTZNPT-DipS--g7.js → pieDiagram-E7YTZNPT-Ct8dzoLU.js} +1 -1
- package/dist-embed/chunks/{pieDiagram-c941bede-DytniBrW.js → pieDiagram-c941bede-7DZ-Bl8U.js} +1 -1
- package/dist-embed/chunks/{pl-PL-T2D74RX3-F4ebFTYK.js → pl-PL-T2D74RX3-DbtOl9_x.js} +1 -1
- package/dist-embed/chunks/{pt-BR-5N22H2LF-B5i8LuE4.js → pt-BR-5N22H2LF-B1pjR1_T.js} +1 -1
- package/dist-embed/chunks/{pt-PT-UZXXM6DQ-BQ7hfRRg.js → pt-PT-UZXXM6DQ-takC7TRa.js} +1 -1
- package/dist-embed/chunks/{quadrantDiagram-AXDQQJYC-D_j5dzK-.js → quadrantDiagram-AXDQQJYC-B1mlT7fN.js} +1 -1
- package/dist-embed/chunks/{quadrantDiagram-AXDQQJYC-DlhtjZ-k.js → quadrantDiagram-AXDQQJYC-B7p4unpj.js} +1 -1
- package/dist-embed/chunks/{quadrantDiagram-cf8b8fe0-BQ2yjLYu.js → quadrantDiagram-cf8b8fe0-CTMh_Ad5.js} +1 -1
- package/dist-embed/chunks/{railroadDiagram-O6MQD6OU-CZFkdwSz.js → railroadDiagram-O6MQD6OU-CJEwr5d9.js} +1 -1
- package/dist-embed/chunks/{railroadDiagram-O6MQD6OU-aWlxxhLc.js → railroadDiagram-O6MQD6OU-xr8bPIl7.js} +1 -1
- package/dist-embed/chunks/{renderer-2D5v6hpK.js → renderer-Ba0Cwb4p.js} +1 -1
- package/dist-embed/chunks/{requirementDiagram-53bda41b-CWV_b9FE.js → requirementDiagram-53bda41b-Dv1Piop_.js} +1 -1
- package/dist-embed/chunks/{requirementDiagram-BXWQKSXE-EVwiX2gg.js → requirementDiagram-BXWQKSXE-Bw89vFiC.js} +1 -1
- package/dist-embed/chunks/{requirementDiagram-BXWQKSXE-BSF51uZZ.js → requirementDiagram-BXWQKSXE-rabT3v-j.js} +1 -1
- package/dist-embed/chunks/{ro-RO-JPDTUUEW-BdcZRS6h.js → ro-RO-JPDTUUEW-DkkqyFBF.js} +1 -1
- package/dist-embed/chunks/{ru-RU-B4JR7IUQ-Cta1z8f6.js → ru-RU-B4JR7IUQ-CikD-ITp.js} +1 -1
- package/dist-embed/chunks/{sankeyDiagram-P5KCCOFB-BqD6w06O.js → sankeyDiagram-P5KCCOFB-5SpI76uK.js} +1 -1
- package/dist-embed/chunks/{sankeyDiagram-P5KCCOFB-t6rHaBZJ.js → sankeyDiagram-P5KCCOFB-D--cx9I2.js} +1 -1
- package/dist-embed/chunks/{sankeyDiagram-c3ef121a-C9O52Zx9.js → sankeyDiagram-c3ef121a-DbhtSWkB.js} +1 -1
- package/dist-embed/chunks/{sequenceDiagram-82a5b84f-Dga-BwWi.js → sequenceDiagram-82a5b84f-DpxBSKAk.js} +1 -1
- package/dist-embed/chunks/{sequenceDiagram-WJ2MYXX4-ih6W0378.js → sequenceDiagram-WJ2MYXX4-DGNwWgf8.js} +1 -1
- package/dist-embed/chunks/{sequenceDiagram-WJ2MYXX4-DphVeQVS.js → sequenceDiagram-WJ2MYXX4-D_wK-z7a.js} +1 -1
- package/dist-embed/chunks/{sessions-APuuDN3K.js → sessions-DQkTozai.js} +1 -1
- package/dist-embed/chunks/{si-LK-N5RQ5JYF-DYy_OKHx.js → si-LK-N5RQ5JYF-BqlWRhwK.js} +1 -1
- package/dist-embed/chunks/{sizeCapture-INFHLROL-o0dzt8-T.js → sizeCapture-INFHLROL-4Uh8JUjf.js} +1 -1
- package/dist-embed/chunks/{sizeCapture-INFHLROL-CxIMCruL.js → sizeCapture-INFHLROL-g-K-6XON.js} +1 -1
- package/dist-embed/chunks/{sk-SK-C5VTKIMK-B4A8rgzq.js → sk-SK-C5VTKIMK-DGsmi02E.js} +1 -1
- package/dist-embed/chunks/{sl-SI-NN7IZMDC-Dn2yU1RA.js → sl-SI-NN7IZMDC-HFz45GOs.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-43e79a5f-RBFnM6HD.js → stateDiagram-43e79a5f-DxbV4jP9.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-D77RDMKH-R5RRRvFY.js → stateDiagram-D77RDMKH-C_wYpqah.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-D77RDMKH-DUbaZs3a.js → stateDiagram-D77RDMKH-D-l3u-WY.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-v2-2041ed4f-O5FpnsEz.js → stateDiagram-v2-2041ed4f-BzxzaDdI.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-v2-MP3YSRHH-xKTLvXGN.js → stateDiagram-v2-MP3YSRHH-BGYkOvTS.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-v2-MP3YSRHH-CxTXB7mT.js → stateDiagram-v2-MP3YSRHH-IEMNMwm0.js} +1 -1
- package/dist-embed/chunks/{styles-455b33cd-D4Xv2qYx.js → styles-455b33cd-C42Lyulv.js} +1 -1
- package/dist-embed/chunks/{styles-f932cba9-BRIqeB8k.js → styles-f932cba9-Bf6H3IMq.js} +1 -1
- package/dist-embed/chunks/{styles-fcc2142b-CSNd2DtU.js → styles-fcc2142b-OZg6fE-p.js} +1 -1
- package/dist-embed/chunks/{subset-shared.chunk-SugOGKH0.js → subset-shared.chunk-KC0vshev.js} +1 -1
- package/dist-embed/chunks/{subset-worker.chunk-CHn-RJwQ.js → subset-worker.chunk-CXZAV_Z5.js} +1 -1
- package/dist-embed/chunks/{sv-SE-XGPEYMSR-DIGNKjA1.js → sv-SE-XGPEYMSR-yEdPvwHy.js} +1 -1
- package/dist-embed/chunks/{svgDrawCommon-148a3cd9-ioBjWI45.js → svgDrawCommon-148a3cd9-D9MRwoYw.js} +1 -1
- package/dist-embed/chunks/{swimlanes-42K2YHIH-DID4P1mJ.js → swimlanes-42K2YHIH-CPkom4Q8.js} +1 -1
- package/dist-embed/chunks/{swimlanes-42K2YHIH-BPXSOfWl.js → swimlanes-42K2YHIH-DJLFcHMt.js} +1 -1
- package/dist-embed/chunks/{swimlanesDiagram-VR7AAH4N-C5LAWW5q.js → swimlanesDiagram-VR7AAH4N-BJOhuN-y.js} +1 -1
- package/dist-embed/chunks/{swimlanesDiagram-VR7AAH4N-B216TpFb.js → swimlanesDiagram-VR7AAH4N-BRTtY1QX.js} +1 -1
- package/dist-embed/chunks/{ta-IN-2NMHFXQM-h5n2V9ms.js → ta-IN-2NMHFXQM-0i424YGX.js} +1 -1
- package/dist-embed/chunks/{th-TH-HPSO5L25-DPUFV7b6.js → th-TH-HPSO5L25-BidF5zNO.js} +1 -1
- package/dist-embed/chunks/{timeline-definition-24CTP7MA-CsrTDzso.js → timeline-definition-24CTP7MA-BasSLg-_.js} +1 -1
- package/dist-embed/chunks/{timeline-definition-24CTP7MA-Y3tUsmSp.js → timeline-definition-24CTP7MA-BfGIJi1H.js} +1 -1
- package/dist-embed/chunks/{timeline-definition-7545f45a-Dwe7O50H.js → timeline-definition-7545f45a-BWwgvKxJ.js} +1 -1
- package/dist-embed/chunks/{tr-TR-DEFEU3FU-BezJkdMx.js → tr-TR-DEFEU3FU-BoHR9SlC.js} +1 -1
- package/dist-embed/chunks/{uk-UA-QMV73CPH-CqILlosm.js → uk-UA-QMV73CPH-DfRkqqO0.js} +1 -1
- package/dist-embed/chunks/{vennDiagram-4TSXK5OY-BhVdyHxt.js → vennDiagram-4TSXK5OY-D1T__rd2.js} +1 -1
- package/dist-embed/chunks/{vennDiagram-4TSXK5OY-ClTlC2ql.js → vennDiagram-4TSXK5OY-DMIYCfJ-.js} +1 -1
- package/dist-embed/chunks/{vi-VN-M7AON7JQ-CnkPVQ0a.js → vi-VN-M7AON7JQ-CvZ4wpTw.js} +1 -1
- package/dist-embed/chunks/{wardleyDiagram-VM6X3IG4-kS16z5iB.js → wardleyDiagram-VM6X3IG4-CiKuFI26.js} +1 -1
- package/dist-embed/chunks/{wardleyDiagram-VM6X3IG4-DbWIMpvU.js → wardleyDiagram-VM6X3IG4-DtlNUHLy.js} +1 -1
- package/dist-embed/chunks/{xychartDiagram-3f383b91-DYoT_EjG.js → xychartDiagram-3f383b91-DzyuxW4K.js} +1 -1
- package/dist-embed/chunks/{xychartDiagram-S5SC5T6Z-KeQp-cQ1.js → xychartDiagram-S5SC5T6Z-BIeFUHrS.js} +1 -1
- package/dist-embed/chunks/{xychartDiagram-S5SC5T6Z-CdwuwQAF.js → xychartDiagram-S5SC5T6Z-p6pYRkk6.js} +1 -1
- package/dist-embed/chunks/{zh-CN-LNUGB5OW-CNdfctAT.js → zh-CN-LNUGB5OW-Cx1Azgu2.js} +1 -1
- package/dist-embed/chunks/{zh-HK-E62DVLB3-DEXwa5-T.js → zh-HK-E62DVLB3-DMjy1d4Z.js} +1 -1
- package/dist-embed/chunks/{zh-TW-RAJ6MFWO-BF7cCYAK.js → zh-TW-RAJ6MFWO-J-YjINmR.js} +1 -1
- package/dist-embed/datalayer-app-main.js +22 -22
- package/lib/apps/apps/appspec.d.ts +10 -1
- package/lib/apps/apps/appspec.js +64 -6
- package/lib/apps/core/index.d.ts +26 -0
- package/lib/apps/core/index.js +20 -0
- package/lib/apps/plugins/chat/ChatView.js +21 -4
- package/lib/specs/apps.js +38 -16
- package/lib/specs/appspecSchema.js +75 -2
- package/lib/types/agentspecs.d.ts +32 -1
- package/package.json +1 -1
- package/dist-embed/chunks/ChatView-B3QqHhAP.js +0 -32
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{r as S,ar as Xb,as as Gb,j as x,bi as Y,co as vn,T as Le,d2 as Zb,bj as bd,gk as Qb,nS as ey,B as co,I as Ft,e4 as Rp,nT as kl,bd as St,aq as pe,nU as Oe,nV as Je,nW as Ie,nX as $t,k_ as F,nY as Ot,nZ as kr,kF as q,kK as oe,kL as It,n_ as Bt,aD as se,c as ft,aw as Ap,d4 as Zs,d1 as ty,eQ as Mt,_ as me,jv as Mp,eS as ny,D as $p,n$ as ry,o0 as _o,o1 as Tc,o2 as zo,kN as bt,o3 as Kn,kE as vt,aE as ne,o4 as js,bS as de,o5 as oy,l0 as zr,kZ as D,bV as ee,o6 as ln,o7 as Dp,o8 as sy,o9 as Fs,lb as cn,le as ke,kM as ue,oa as Ye,ob as Xe,oc as Pp,od as yd,oe as gt,of as iy,l2 as Kr,kY as wn,og as Tl,l1 as Dt,oh as un,oi as Tr,oj as pt,ok as Vt,ol as Ir,om as xs,on as jp,oo as Ri,op as ay,oq as mi,or as Jn,os as ly,ot as cy,bW as Q,ou as uy,kB as $e,ez as Fp,n as br,ld as Ae,ov as dy,ow as fy,ox as gy,oy as zt,oz as Eo,oA as tr,oB as nr,oC as Cs,oD as xn,oE as Bs,oF as rr,oG as mn,oH as Us,l6 as ve,l3 as re,oI as V,oJ as Bp,oK as Ic,oL as uo,bU as No,oM as py,oN as fo,oO as wd,oP as Up,oQ as zp,oR as Il,oS as hy,oT as Kp,oU as Ec,oV as _y,oW as my,oX as Nc,oY as El,oZ as Wp,o_ as by,o$ as Hp,p0 as yy,p1 as Lc,p2 as Ss,kW as Ee,p3 as wy,l8 as Nn,p4 as xd,p5 as xy,p6 as Cy,p7 as Cd,p8 as Nl,kX as Lo,p9 as Oc,pa as bi,pb as sa,pc as Jp,pd as Rc,pe as ia,pf as Qs,pg as Sd,ph as vd,pi as zs,pj as kd,pk as Bn,pl as Sy,pm as vy,pn as Ge,po as ky,pp as Ty,pq as qp,pr as Vp,ps as Yp,bT as Ks,pt as Ac,pu as Iy,pv as he,pw as Xp,px as vs,py as Ra,pz as Gp,pA as Mc,pB as Ll,pC as Ey,pD as Er,pE as wt,l7 as or,pF as aa,pG as Ny,pH as $c,pI as Zp,pJ as Dc,pK as ps,pL as Td,pM as it,kC as ht,pN as Id,pO as Jt,pP as la,pQ as Qp,pR as eh,pS as th,pT as Wn,pU as Ly,pV as Oy,pW as Ai,pX as Ry,pY as Ay,pZ as My,p_ as Ol,p$ as hr,q0 as nh,q1 as $y,q2 as Rl,q3 as Mi,q4 as rh,l4 as Ht,q5 as Oo,k$ as qe,q6 as oh,q7 as Dy,q8 as Py,kA as jy,q9 as mo,qa as sr,qb as sh,qc as Fy,qd as By,qe as Pc,qf as ih,qg as Uy,qh as Ed,qi as zy,qj as Nd,qk as Ky,ql as Wy,qm as jc,qn as Hy,qo as Ld,kU as Jy,kT as qy,kS as Vy,qp as Od,kV as Yy,qq as Rd,qr as ah,K as fe,l9 as Xy,qs as Gy,qt as Zy,qu as Qy,qv as Ad,qw as ew,qx as tw,qy as Md,qz as $d,qA as qn,qB as nw,qC as rw,qD as ow,qE as sw,qF as Fc,qG as iw,qH as aw,j8 as Al,ee as ks,l5 as bo,qI as lh,qJ as $i,kD as ch,kI as Bc,kH as Uc,kG as uh,kJ as dh,qK as fh,qL as Ml,qM as Dd,qN as lw,qO as $l,qP as ca,qQ as gh,qR as ph,qS as cw,qT as hh,qU as _h,qV as $n,qW as uw,m9 as dw,mf as Pd,mg as Dl,mi as fw,mj as gw,qX as mh,qY as bh,qZ as yh,q_ as wh,q$ as jd,C as xh,f as pw,r0 as hw,r1 as _w,H as mw,r2 as bw,r3 as yw,av as ww,ax as xw,k as Ch,r4 as Cw,aF as Sh,r5 as Sw,aB as vw,r6 as kw,r7 as Tw,jB as Lt,jJ as Ke,jH as yr,jE as Qe,jI as wr,jG as Zt,jL as Iw,e7 as Ew,ek as Aa,i as Nw,r8 as yi,r9 as Un,el as vh,ra as Lw,bf as zc,bX as Ow,rb as Kc,eI as Rw,rc as Aw,rd as Mw,re as $w,rf as Dw,rg as Pw,rh as kh,ri as we,d6 as yo,b6 as Te,rj as Th,m as Di,rk as jw,rl as Fw,rm as ei,gp as Bw,rn as Uw,ro as Ko}from"../datalayer-app-main.js";import{d as zw,b as Kw,E as Ww,u as Hw,c as Jw,e as qw,f as Vw}from"./NotebookSkeleton-CI7ovjNW.js";import{p as is,e as Yw,s as Xw,u as Gw}from"./url-DuKx0yk0.js";import{r as Zw,a as Qw}from"./isSymbol-BLtK9CV6.js";import{t as Fd}from"./toNumber-B1wj8-wx.js";import{V as Ws,P as ex,C as Pi,D as Wc,T as Ih,H as tx,L as Eh,F as hs,Q as Nh,a as ji,M as nx,b as rx,B as Lh,I as Oh,S as Rh,R as ox,c as sx,d as ix}from"./VideoIcon-BjP_LDa4.js";import{L as Ah}from"./LinkIcon-DUI0jw25.js";import{A as ax}from"./Avatar-9MpXENSs.js";import{a as lx,T as cx}from"./Toolbar-CGQDY041.js";import{A as ux,a as dx}from"./ArrowUpIcon-BUCpIXDR.js";import{S as fx}from"./SortDescIcon-CS4EzHeS.js";import{P as gx}from"./PaintbrushIcon-CLU8RilX.js";import{P as Pl,p as px}from"./PrismCss-CcU1ChRk.js";import{j as jl,O as hx,C as _x}from"./Output-9DKTscSv.js";import{d as ge,l as go}from"./LexicalToolRegistry-CoM9ROsx.js";const Fi=(n,e,t)=>Math.min(t,Math.max(e,n));function ts(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 lr({r:n,g:e,b:t}){const r=o=>Fi(Math.round(o),0,255).toString(16).padStart(2,"0");return`#${r(n)}${r(e)}${r(t)}`}function Ma({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 ti({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 Bd(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 mx=["#cf222e","#bc4c00","#9a6700","#1a7f37","#0969da","#8250df","#bf3989","#24292f","#57606a","#8c959f","#d0d7de","#ffffff"];function bx(n="datalayer",e="light"){const t=Zb(n,e),r=bd[n]??bd.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 yx(n="datalayer",e="dark"){return{label:"Collaborators",colors:zw(n,e)}}const wx=150,xx=12;function Ud(n){const e=S.useRef(null),t=S.useRef(!1),r=S.useCallback(s=>{const i=e.current;if(!i)return;const a=i.getBoundingClientRect();n(Fi((s.clientX-a.left)/a.width,0,1),Fi((s.clientY-a.top)/a.height,0,1))},[n]);return S.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 Cx({color:n,onChange:e,presets:t=mx,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]=S.useState(()=>Ma(ts(n))),[d,g]=S.useState(()=>lr(ts(n))),h=S.useRef(!1);S.useEffect(()=>{if(h.current){h.current=!1;return}const L=ts(n);f(Ma(L)),g(lr(L))},[n]);const _=S.useMemo(()=>ti(u),[u]),m=S.useMemo(()=>lr(_),[_]),b=S.useCallback(L=>{h.current=!0,f(L);const A=lr(ti(L));g(A),e?.(A)},[e]),w=Ud(S.useCallback((L,A)=>b({...u,s:L*100,v:(1-A)*100}),[b,u])),C=Ud(S.useCallback(L=>b({...u,h:L*360}),[b,u])),{theme:v,colorMode:k}=Xb(),I=Gb(),E=k==="auto"?I:k,N=S.useMemo(()=>{const L=[];return r&&t.length>0&&L.push({label:"Presets",colors:t}),s&&L.push(bx(v,E)),i&&L.push(yx(v,E)),L.concat(o??[])},[v,o,t,E,i,r,s]),O=S.useId(),M=L=>{if(g(L),Bd(L)){const A=Ma(ts(L));h.current=!0,f(A),e?.(lr(ts(L)))}},R=(L,A)=>{const B=L.shiftKey?10:1,j=L.key==="ArrowLeft"||L.key==="ArrowDown",U=L.key==="ArrowRight"||L.key==="ArrowUp";if(!j&&!U)return;L.preventDefault();const z=U?B:-B,K=A==="h"?360:100;b({...u,[A]:Fi(u[A]+z,0,K)})},$={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 x.jsxs(Y,{role:"group","aria-label":c,sx:{display:"grid",gap:2,width:l,minWidth:0},children:[x.jsx(Y,{ref:w.ref,role:"slider",tabIndex:0,"aria-label":"Saturation and brightness","aria-valuetext":`saturation ${Math.round(u.s)}%, brightness ${Math.round(u.v)}%`,onPointerDown:w.onPointerDown,onKeyDown:L=>R(L,L.key==="ArrowUp"||L.key==="ArrowDown"?"v":"s"),sx:{position:"relative",height:wx,borderRadius:"var(--theme-radius-card)",border:"1px solid",borderColor:"var(--borderColor-default)",cursor:"crosshair",touchAction:"none",backgroundColor:lr(ti({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:x.jsx(Y,{sx:{...$,left:`${u.s}%`,top:`${100-u.v}%`,backgroundColor:m}})}),x.jsx(Y,{ref:C.ref,role:"slider",tabIndex:0,"aria-label":"Hue","aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":Math.round(u.h),onPointerDown:C.onPointerDown,onKeyDown:L=>R(L,"h"),sx:{position:"relative",height:xx,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:x.jsx(Y,{sx:{...$,left:`${u.h/360*100}%`,top:"50%",backgroundColor:lr(ti({h:u.h,s:100,v:100}))}})}),a?x.jsxs(Y,{sx:{display:"flex",gap:2,alignItems:"center"},children:[x.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}}),x.jsx(vn,{"aria-label":"Colour, as hex",value:d,onChange:L=>M(L.target.value),onBlur:()=>g(m),size:"small",sx:{flex:"1 1 auto",fontFamily:"mono"},validationStatus:Bd(d)?void 0:"error"})]}):null,N.map(L=>x.jsxs(Y,{children:[x.jsx(Le,{id:`${O}-${L.label}`,sx:{fontSize:0,color:"var(--fgColor-muted)",display:"block",mb:1},children:L.label}),x.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((A,B)=>{const j=A.toLowerCase()===m.toLowerCase();return x.jsx(Y,{as:"button",type:"button","aria-label":A,"aria-pressed":j,onClick:()=>M(A),sx:{height:22,borderRadius:"var(--theme-radius-control)",cursor:"pointer",backgroundColor:A,border:"1px solid",borderColor:j?"var(--borderColor-accent-emphasis)":"var(--borderColor-default)",boxShadow:j?"inset 0 0 0 2px var(--bgColor-default)":"none","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}}},`${A}-${B}`)})})]},L.label))]})}const Sx=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}=Qb(),[d,g]=S.useState(r),[h,_]=S.useState(0);S.useEffect(()=>{_(o?.current?.getBoundingClientRect().bottom??0)},[o]);const m=()=>a(!1),b=C=>{C.target instanceof HTMLElement&&C.target.closest('[role="dialog"]')||m()},w=x.jsx(ey,{theme:u,colorMode:f,children:x.jsxs(co,{sx:{height:`calc(100vh - ${h}px - 8px)`,width:l,display:"flex",flexDirection:"column",alignItems:"center",padding:"4px"},children:[x.jsx(co,{sx:{display:"flex",justifyContent:"right",width:"100%"},children:x.jsx(Ft,{variant:"invisible",ref:e,onClick:m,icon:Rp,"aria-label":"Close"})}),t]})});return e&&i?x.jsx(x.Fragment,{children:s?d==="left"?x.jsx(co,{sx:{zIndex:c},children:x.jsx(kl,{initialFocusRef:e,returnFocusRef:i,ignoreClickRefs:[i],onEscape:m,onClickOutside:b,width:"auto",anchorSide:"inside-right",left:0,position:"fixed",top:h,children:w})}):x.jsx(co,{sx:{zIndex:c},children:x.jsx(kl,{initialFocusRef:e,returnFocusRef:i,ignoreClickRefs:[i],onEscape:m,onClickOutside:b,width:"auto",anchorSide:"inside-left",right:0,position:"fixed",top:h,children:w})}):x.jsx(x.Fragment,{})}):x.jsx(x.Fragment,{})},vx=({width:n="500px",direction:e="left",zIndex:t=100,...r})=>x.jsx(Sx,{width:n,direction:e,zIndex:t,...r});function kx(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 Tx({items:n,extraItems:e,anchorElement:t,isVisible:r,className:o,disabled:s,ariaLabel:i="Floating toolbar",portalContainer:a}){const l=S.useRef(null),c=S.useMemo(()=>e?.length?[...n,...e]:n,[n,e]),u=S.useCallback(()=>{const g=l.current;if(!g||!t)return;const h=window.getSelection();if(!h||h.isCollapsed||!r){g.style.opacity="0",g.style.transform="translateY(-4px)";return}const m=h.getRangeAt(0).getBoundingClientRect();kx(m,g,t)},[t,r]);if(S.useEffect(()=>{if(!r)return;const g=()=>u();window.addEventListener("resize",g),window.addEventListener("scroll",g,!0);const h=t?.parentElement;return h&&h.addEventListener("scroll",g),g(),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0),h&&h.removeEventListener("scroll",g)}},[r,u,t]),!r||c.length===0)return null;const f=a||t||document.body,d=x.jsx(co,{ref:l,className:o,role:"toolbar","aria-label":i,sx:{display:"flex",alignItems:"center",gap:"2px",px:1,py:"4px",bg:"var(--overlay-bgColor, var(--bgColor-default))",border:"1px solid",borderColor:"var(--borderColor-muted, transparent)",borderRadius:2,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:x.jsx(lx,{items:c,disabled:s,size:"small"})});return St.createPortal(d,f)}var $a=function(){return Zw.Date.now()},Ix="Expected a function",Ex=Math.max,Nx=Math.min;function Lx(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(Ix);e=Fd(e)||0,Qw(t)&&(u=!!t.leading,f="maxWait"in t,s=f?Ex(Fd(t.maxWait)||0,e):s,d="trailing"in t?!!t.trailing:d);function g(I){var E=r,N=o;return r=o=void 0,c=I,i=n.apply(N,E),i}function h(I){return c=I,a=setTimeout(b,e),u?g(I):i}function _(I){var E=I-l,N=I-c,O=e-E;return f?Nx(O,s-N):O}function m(I){var E=I-l,N=I-c;return l===void 0||E>=e||E<0||f&&N>=s}function b(){var I=$a();if(m(I))return w(I);a=setTimeout(b,_(I))}function w(I){return a=void 0,d&&r?g(I):(r=o=void 0,i)}function C(){a!==void 0&&clearTimeout(a),c=0,r=l=o=a=void 0}function v(){return a===void 0?i:w($a())}function k(){var I=$a(),E=m(I);if(r=arguments,o=this,l=I,E){if(a===void 0)return h(l);if(f)return clearTimeout(a),a=setTimeout(b,e),g(l)}return a===void 0&&(a=setTimeout(b,e)),i}return k.cancel=C,k.flush=v,k}const Mh=[];let Ts=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=Mh,t){super(t),this.__ids=e}createDOM(e){const t=Je().createElement("mark");return Ie(t,e.theme.mark),this.__ids.length>1&&Ie(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&&Ie(t,l):a===1&&$t(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=Hc(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(!F(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 Hc(n=Mh){return Ot(new Ts(n))}function Ro(n){return n instanceof Ts}function Ox(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 Rx(n,e,t,r){const o=kr(),[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(q(l)&&l.isParentOf(u))continue;let f=null;if(oe(u))f=u;else{if(Ro(u))continue;(q(u)||It(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=Hc([t]),f.insertBefore(l)),l.append(f)}else a=void 0,l=void 0}q(l)&&(e?l.selectStart():l.selectEnd())}function Ax(n,e){let t=n;for(;t!==null;){if(Ro(t))return t.getIDs();if(oe(t)&&e===t.getTextContentSize()){const r=t.getNextSibling();if(Ro(r))return r.getIDs()}t=t.getParent()}return null}const Mx=pe({name:"@lexical/mark",nodes:()=>[Ts]});class Ao extends Bt{__id;__quote;__comments;static getType(){return"comment-thread"}static clone(e){return new Ao(e.__id,e.__quote,e.__comments,e.__key)}static importJSON(e){return new Ao(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 x.jsx(x.Fragment,{})}}function $x(n,e,t){return new Ao(n,e,t)}function ni(n){return n instanceof Ao}const wo=n=>n.name||n.handle||n.uid,Jc=n=>n.name||n.handle||n.uid||"Anonymous",qc=n=>({kind:"anonymous",name:n||"Anonymous"}),Dx=n=>n.authorPrincipal??qc(n.author);function $h(n,e){const t=[];for(const r of e)n.includes(`@${wo(r)}`)&&!t.includes(r.uid)&&t.push(r.uid);return t}function Dh(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Ph(n,e,t,r,o,s){const i=typeof e=="string"?qc(e):e;return{author:Jc(i),authorPrincipal:i,content:n,deleted:o===void 0?!1:o,id:t===void 0?Dh():t,...s&&s.length>0?{mentions:s}:{},timeStamp:r===void 0?Date.now():r,type:"comment"}}function Px(n,e,t){return{comments:e,id:t===void 0?Dh():t,quote:n,type:"thread"}}function jx(n){return{author:n.author,...n.authorPrincipal?{authorPrincipal:n.authorPrincipal}:{},content:"[Deleted Comment]",deleted:!0,id:n.id,timeStamp:n.timeStamp,type:"comment"}}function Fx(n){const e=n._changeListeners;for(const t of e)t()}class Bx{_editor;_changeListeners;constructor(e){this._editor=e,this._changeListeners=new Set,this._editor.registerUpdateListener(()=>{Fx(this)})}getComments(){const e=[];return this._editor.getEditorState().read(()=>{se().getChildren().forEach(r=>{if(ni(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(ni(s)){const i=s;i.getId()===t.id&&i.addComment(e)}});else if(e.type==="thread"){const o=$x(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(ni(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=>{ni(s)&&s.getId()===e.id&&s.remove()})}),e.type==="comment"?{index:r!==null?r:0,markedComment:jx(e)}:null}registerOnChange(e){const t=this._changeListeners;return t.add(e),()=>{t.delete(e)}}}function Ux(n){const[e,t]=S.useState(n.getComments());return S.useEffect(()=>(t(n.getComments()),n.registerOnChange(()=>{t(n.getComments())})),[n]),e}const xr=({"data-test-id":n,children:e,className:t,onClick:r,disabled:o,small:s,title:i})=>x.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}),zx=({className:n,style:e})=>x.jsx(Ap,{className:n||"ContentEditable__root",style:e});function IM({label:n="Loading the document",header:e=!1,maxWidth:t=760}={}){return x.jsxs(Kw,{label:n,sx:{flex:1,minHeight:0,width:"100%",overflow:"hidden"},children:[e?x.jsx(Ww,{}):null,x.jsxs(co,{sx:{px:4,py:e?0:4,pb:4,display:"grid",gap:4,maxWidth:t,mx:"auto",width:"100%"},children:[x.jsx(Zs,{size:"titleLarge",lines:1,maxWidth:"22rem"}),x.jsx(Zs,{size:"bodyMedium",lines:3}),x.jsx(Zs,{size:"bodyMedium",lines:4,maxWidth:"92%"}),x.jsx(ty,{width:"100%",height:"120px"}),x.jsx(Zs,{size:"bodyMedium",lines:3,maxWidth:"88%"})]})]})}function Kx({equation:n,setEquation:e,inline:t,inputRef:r}){const s={equation:n,inputRef:r,onChange:i=>{e(i.target.value)}};return t?x.jsx(Wx,{...s,inputRef:r}):x.jsx(Hx,{...s,inputRef:r})}function Wx({equation:n,onChange:e,inputRef:t}){return x.jsxs("span",{className:"EquationEditor_inputBackground",children:[x.jsx("span",{className:"EquationEditor_dollarSign",children:"$"}),x.jsx("input",{className:"EquationEditor_inlineEditor",value:n,onChange:e,autoFocus:!0,ref:t}),x.jsx("span",{className:"EquationEditor_dollarSign",children:"$"})]})}function Hx({equation:n,onChange:e,inputRef:t}){return x.jsxs("div",{className:"EquationEditor_inputBackground",children:[x.jsx("span",{className:"EquationEditor_dollarSign",children:`$$
|
|
1
|
+
import{r as S,ar as Xb,as as Gb,j as x,bi as Y,co as vn,T as Le,d2 as Zb,bj as bd,gl as Qb,nT as ey,B as co,I as Ft,e4 as Rp,nU as kl,bd as St,aq as pe,nV as Oe,nW as Je,nX as Ie,nY as $t,k$ as F,nZ as Ot,n_ as kr,kG as q,kL as oe,kM as It,n$ as Bt,aD as se,c as ft,aw as Ap,d4 as Zs,d1 as ty,eQ as Mt,_ as me,jw as Mp,eS as ny,D as $p,o0 as ry,o1 as _o,o2 as Tc,o3 as zo,kO as bt,o4 as Kn,kF as vt,aE as ne,o5 as js,bS as de,o6 as oy,l1 as zr,k_ as D,bV as ee,o7 as ln,o8 as Dp,o9 as sy,oa as Fs,lc as cn,lf as ke,kN as ue,ob as Ye,oc as Xe,od as Pp,oe as yd,of as gt,og as iy,l3 as Kr,kZ as wn,oh as Tl,l2 as Dt,oi as un,oj as Tr,ok as pt,ol as Vt,om as Ir,on as xs,oo as jp,op as Ri,oq as ay,or as mi,os as Jn,ot as ly,ou as cy,bW as Q,ov as uy,kC as $e,ez as Fp,n as br,le as Ae,ow as dy,ox as fy,oy as gy,oz as zt,oA as Eo,oB as tr,oC as nr,oD as Cs,oE as xn,oF as Bs,oG as rr,oH as mn,oI as Us,l7 as ve,l4 as re,oJ as V,oK as Bp,oL as Ic,oM as uo,bU as No,oN as py,oO as fo,oP as wd,oQ as Up,oR as zp,oS as Il,oT as hy,oU as Kp,oV as Ec,oW as _y,oX as my,oY as Nc,oZ as El,o_ as Wp,o$ as by,p0 as Hp,p1 as yy,p2 as Lc,p3 as Ss,kX as Ee,p4 as wy,l9 as Nn,p5 as xd,p6 as xy,p7 as Cy,p8 as Cd,p9 as Nl,kY as Lo,pa as Oc,pb as bi,pc as sa,pd as Jp,pe as Rc,pf as ia,pg as Qs,ph as Sd,pi as vd,pj as zs,pk as kd,pl as Bn,pm as Sy,pn as vy,po as Ge,pp as ky,pq as Ty,pr as qp,ps as Vp,pt as Yp,bT as Ks,pu as Ac,pv as Iy,pw as he,px as Xp,py as vs,pz as Ra,pA as Gp,pB as Mc,pC as Ll,pD as Ey,pE as Er,pF as wt,l8 as or,pG as aa,pH as Ny,pI as $c,pJ as Zp,pK as Dc,pL as ps,pM as Td,pN as it,kD as ht,pO as Id,pP as Jt,pQ as la,pR as Qp,pS as eh,pT as th,pU as Wn,pV as Ly,pW as Oy,pX as Ai,pY as Ry,pZ as Ay,p_ as My,p$ as Ol,q0 as hr,q1 as nh,q2 as $y,q3 as Rl,q4 as Mi,q5 as rh,l5 as Ht,q6 as Oo,l0 as qe,q7 as oh,q8 as Dy,q9 as Py,kB as jy,qa as mo,qb as sr,qc as sh,qd as Fy,qe as By,qf as Pc,qg as ih,qh as Uy,qi as Ed,qj as zy,qk as Nd,ql as Ky,qm as Wy,qn as jc,qo as Hy,qp as Ld,kV as Jy,kU as qy,kT as Vy,qq as Od,kW as Yy,qr as Rd,qs as ah,K as fe,la as Xy,qt as Gy,qu as Zy,qv as Qy,qw as Ad,qx as ew,qy as tw,qz as Md,qA as $d,qB as qn,qC as nw,qD as rw,qE as ow,qF as sw,qG as Fc,qH as iw,qI as aw,j9 as Al,ee as ks,l6 as bo,qJ as lh,qK as $i,kE as ch,kJ as Bc,kI as Uc,kH as uh,kK as dh,qL as fh,qM as Ml,qN as Dd,qO as lw,qP as $l,qQ as ca,qR as gh,qS as ph,qT as cw,qU as hh,qV as _h,qW as $n,qX as uw,ma as dw,mg as Pd,mh as Dl,mj as fw,mk as gw,qY as mh,qZ as bh,q_ as yh,q$ as wh,r0 as jd,C as xh,f as pw,r1 as hw,r2 as _w,H as mw,r3 as bw,r4 as yw,av as ww,ax as xw,k as Ch,r5 as Cw,aF as Sh,r6 as Sw,aB as vw,r7 as kw,r8 as Tw,jC as Lt,jK as Ke,jI as yr,jF as Qe,jJ as wr,jH as Zt,jM as Iw,e7 as Ew,ek as Aa,i as Nw,r9 as yi,ra as Un,el as vh,rb as Lw,bf as zc,bX as Ow,rc as Kc,eI as Rw,rd as Aw,re as Mw,rf as $w,rg as Dw,rh as Pw,ri as kh,rj as we,d6 as yo,b6 as Te,rk as Th,m as Di,rl as jw,rm as Fw,rn as ei,gq as Bw,ro as Uw,rp as Ko}from"../datalayer-app-main.js";import{d as zw,b as Kw,E as Ww,u as Hw,c as Jw,e as qw,f as Vw}from"./NotebookSkeleton-CI7ovjNW.js";import{p as is,e as Yw,s as Xw,u as Gw}from"./url-DuKx0yk0.js";import{r as Zw,a as Qw}from"./isSymbol-BLtK9CV6.js";import{t as Fd}from"./toNumber-B1wj8-wx.js";import{V as Ws,P as ex,C as Pi,D as Wc,T as Ih,H as tx,L as Eh,F as hs,Q as Nh,a as ji,M as nx,b as rx,B as Lh,I as Oh,S as Rh,R as ox,c as sx,d as ix}from"./VideoIcon-BjP_LDa4.js";import{L as Ah}from"./LinkIcon-DUI0jw25.js";import{A as ax}from"./Avatar-9MpXENSs.js";import{a as lx,T as cx}from"./Toolbar-CGQDY041.js";import{A as ux,a as dx}from"./ArrowUpIcon-BUCpIXDR.js";import{S as fx}from"./SortDescIcon-CS4EzHeS.js";import{P as gx}from"./PaintbrushIcon-CLU8RilX.js";import{P as Pl,p as px}from"./PrismCss-CcU1ChRk.js";import{j as jl,O as hx,C as _x}from"./Output-B9XAhyoF.js";import{d as ge,l as go}from"./LexicalToolRegistry-BJ6mpMWn.js";const Fi=(n,e,t)=>Math.min(t,Math.max(e,n));function ts(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 lr({r:n,g:e,b:t}){const r=o=>Fi(Math.round(o),0,255).toString(16).padStart(2,"0");return`#${r(n)}${r(e)}${r(t)}`}function Ma({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 ti({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 Bd(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 mx=["#cf222e","#bc4c00","#9a6700","#1a7f37","#0969da","#8250df","#bf3989","#24292f","#57606a","#8c959f","#d0d7de","#ffffff"];function bx(n="datalayer",e="light"){const t=Zb(n,e),r=bd[n]??bd.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 yx(n="datalayer",e="dark"){return{label:"Collaborators",colors:zw(n,e)}}const wx=150,xx=12;function Ud(n){const e=S.useRef(null),t=S.useRef(!1),r=S.useCallback(s=>{const i=e.current;if(!i)return;const a=i.getBoundingClientRect();n(Fi((s.clientX-a.left)/a.width,0,1),Fi((s.clientY-a.top)/a.height,0,1))},[n]);return S.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 Cx({color:n,onChange:e,presets:t=mx,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]=S.useState(()=>Ma(ts(n))),[d,g]=S.useState(()=>lr(ts(n))),h=S.useRef(!1);S.useEffect(()=>{if(h.current){h.current=!1;return}const L=ts(n);f(Ma(L)),g(lr(L))},[n]);const _=S.useMemo(()=>ti(u),[u]),m=S.useMemo(()=>lr(_),[_]),b=S.useCallback(L=>{h.current=!0,f(L);const A=lr(ti(L));g(A),e?.(A)},[e]),w=Ud(S.useCallback((L,A)=>b({...u,s:L*100,v:(1-A)*100}),[b,u])),C=Ud(S.useCallback(L=>b({...u,h:L*360}),[b,u])),{theme:v,colorMode:k}=Xb(),I=Gb(),E=k==="auto"?I:k,N=S.useMemo(()=>{const L=[];return r&&t.length>0&&L.push({label:"Presets",colors:t}),s&&L.push(bx(v,E)),i&&L.push(yx(v,E)),L.concat(o??[])},[v,o,t,E,i,r,s]),O=S.useId(),M=L=>{if(g(L),Bd(L)){const A=Ma(ts(L));h.current=!0,f(A),e?.(lr(ts(L)))}},R=(L,A)=>{const B=L.shiftKey?10:1,j=L.key==="ArrowLeft"||L.key==="ArrowDown",U=L.key==="ArrowRight"||L.key==="ArrowUp";if(!j&&!U)return;L.preventDefault();const z=U?B:-B,K=A==="h"?360:100;b({...u,[A]:Fi(u[A]+z,0,K)})},$={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 x.jsxs(Y,{role:"group","aria-label":c,sx:{display:"grid",gap:2,width:l,minWidth:0},children:[x.jsx(Y,{ref:w.ref,role:"slider",tabIndex:0,"aria-label":"Saturation and brightness","aria-valuetext":`saturation ${Math.round(u.s)}%, brightness ${Math.round(u.v)}%`,onPointerDown:w.onPointerDown,onKeyDown:L=>R(L,L.key==="ArrowUp"||L.key==="ArrowDown"?"v":"s"),sx:{position:"relative",height:wx,borderRadius:"var(--theme-radius-card)",border:"1px solid",borderColor:"var(--borderColor-default)",cursor:"crosshair",touchAction:"none",backgroundColor:lr(ti({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:x.jsx(Y,{sx:{...$,left:`${u.s}%`,top:`${100-u.v}%`,backgroundColor:m}})}),x.jsx(Y,{ref:C.ref,role:"slider",tabIndex:0,"aria-label":"Hue","aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":Math.round(u.h),onPointerDown:C.onPointerDown,onKeyDown:L=>R(L,"h"),sx:{position:"relative",height:xx,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:x.jsx(Y,{sx:{...$,left:`${u.h/360*100}%`,top:"50%",backgroundColor:lr(ti({h:u.h,s:100,v:100}))}})}),a?x.jsxs(Y,{sx:{display:"flex",gap:2,alignItems:"center"},children:[x.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}}),x.jsx(vn,{"aria-label":"Colour, as hex",value:d,onChange:L=>M(L.target.value),onBlur:()=>g(m),size:"small",sx:{flex:"1 1 auto",fontFamily:"mono"},validationStatus:Bd(d)?void 0:"error"})]}):null,N.map(L=>x.jsxs(Y,{children:[x.jsx(Le,{id:`${O}-${L.label}`,sx:{fontSize:0,color:"var(--fgColor-muted)",display:"block",mb:1},children:L.label}),x.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((A,B)=>{const j=A.toLowerCase()===m.toLowerCase();return x.jsx(Y,{as:"button",type:"button","aria-label":A,"aria-pressed":j,onClick:()=>M(A),sx:{height:22,borderRadius:"var(--theme-radius-control)",cursor:"pointer",backgroundColor:A,border:"1px solid",borderColor:j?"var(--borderColor-accent-emphasis)":"var(--borderColor-default)",boxShadow:j?"inset 0 0 0 2px var(--bgColor-default)":"none","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}}},`${A}-${B}`)})})]},L.label))]})}const Sx=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}=Qb(),[d,g]=S.useState(r),[h,_]=S.useState(0);S.useEffect(()=>{_(o?.current?.getBoundingClientRect().bottom??0)},[o]);const m=()=>a(!1),b=C=>{C.target instanceof HTMLElement&&C.target.closest('[role="dialog"]')||m()},w=x.jsx(ey,{theme:u,colorMode:f,children:x.jsxs(co,{sx:{height:`calc(100vh - ${h}px - 8px)`,width:l,display:"flex",flexDirection:"column",alignItems:"center",padding:"4px"},children:[x.jsx(co,{sx:{display:"flex",justifyContent:"right",width:"100%"},children:x.jsx(Ft,{variant:"invisible",ref:e,onClick:m,icon:Rp,"aria-label":"Close"})}),t]})});return e&&i?x.jsx(x.Fragment,{children:s?d==="left"?x.jsx(co,{sx:{zIndex:c},children:x.jsx(kl,{initialFocusRef:e,returnFocusRef:i,ignoreClickRefs:[i],onEscape:m,onClickOutside:b,width:"auto",anchorSide:"inside-right",left:0,position:"fixed",top:h,children:w})}):x.jsx(co,{sx:{zIndex:c},children:x.jsx(kl,{initialFocusRef:e,returnFocusRef:i,ignoreClickRefs:[i],onEscape:m,onClickOutside:b,width:"auto",anchorSide:"inside-left",right:0,position:"fixed",top:h,children:w})}):x.jsx(x.Fragment,{})}):x.jsx(x.Fragment,{})},vx=({width:n="500px",direction:e="left",zIndex:t=100,...r})=>x.jsx(Sx,{width:n,direction:e,zIndex:t,...r});function kx(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 Tx({items:n,extraItems:e,anchorElement:t,isVisible:r,className:o,disabled:s,ariaLabel:i="Floating toolbar",portalContainer:a}){const l=S.useRef(null),c=S.useMemo(()=>e?.length?[...n,...e]:n,[n,e]),u=S.useCallback(()=>{const g=l.current;if(!g||!t)return;const h=window.getSelection();if(!h||h.isCollapsed||!r){g.style.opacity="0",g.style.transform="translateY(-4px)";return}const m=h.getRangeAt(0).getBoundingClientRect();kx(m,g,t)},[t,r]);if(S.useEffect(()=>{if(!r)return;const g=()=>u();window.addEventListener("resize",g),window.addEventListener("scroll",g,!0);const h=t?.parentElement;return h&&h.addEventListener("scroll",g),g(),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0),h&&h.removeEventListener("scroll",g)}},[r,u,t]),!r||c.length===0)return null;const f=a||t||document.body,d=x.jsx(co,{ref:l,className:o,role:"toolbar","aria-label":i,sx:{display:"flex",alignItems:"center",gap:"2px",px:1,py:"4px",bg:"var(--overlay-bgColor, var(--bgColor-default))",border:"1px solid",borderColor:"var(--borderColor-muted, transparent)",borderRadius:2,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:x.jsx(lx,{items:c,disabled:s,size:"small"})});return St.createPortal(d,f)}var $a=function(){return Zw.Date.now()},Ix="Expected a function",Ex=Math.max,Nx=Math.min;function Lx(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(Ix);e=Fd(e)||0,Qw(t)&&(u=!!t.leading,f="maxWait"in t,s=f?Ex(Fd(t.maxWait)||0,e):s,d="trailing"in t?!!t.trailing:d);function g(I){var E=r,N=o;return r=o=void 0,c=I,i=n.apply(N,E),i}function h(I){return c=I,a=setTimeout(b,e),u?g(I):i}function _(I){var E=I-l,N=I-c,O=e-E;return f?Nx(O,s-N):O}function m(I){var E=I-l,N=I-c;return l===void 0||E>=e||E<0||f&&N>=s}function b(){var I=$a();if(m(I))return w(I);a=setTimeout(b,_(I))}function w(I){return a=void 0,d&&r?g(I):(r=o=void 0,i)}function C(){a!==void 0&&clearTimeout(a),c=0,r=l=o=a=void 0}function v(){return a===void 0?i:w($a())}function k(){var I=$a(),E=m(I);if(r=arguments,o=this,l=I,E){if(a===void 0)return h(l);if(f)return clearTimeout(a),a=setTimeout(b,e),g(l)}return a===void 0&&(a=setTimeout(b,e)),i}return k.cancel=C,k.flush=v,k}const Mh=[];let Ts=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=Mh,t){super(t),this.__ids=e}createDOM(e){const t=Je().createElement("mark");return Ie(t,e.theme.mark),this.__ids.length>1&&Ie(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&&Ie(t,l):a===1&&$t(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=Hc(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(!F(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 Hc(n=Mh){return Ot(new Ts(n))}function Ro(n){return n instanceof Ts}function Ox(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 Rx(n,e,t,r){const o=kr(),[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(q(l)&&l.isParentOf(u))continue;let f=null;if(oe(u))f=u;else{if(Ro(u))continue;(q(u)||It(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=Hc([t]),f.insertBefore(l)),l.append(f)}else a=void 0,l=void 0}q(l)&&(e?l.selectStart():l.selectEnd())}function Ax(n,e){let t=n;for(;t!==null;){if(Ro(t))return t.getIDs();if(oe(t)&&e===t.getTextContentSize()){const r=t.getNextSibling();if(Ro(r))return r.getIDs()}t=t.getParent()}return null}const Mx=pe({name:"@lexical/mark",nodes:()=>[Ts]});class Ao extends Bt{__id;__quote;__comments;static getType(){return"comment-thread"}static clone(e){return new Ao(e.__id,e.__quote,e.__comments,e.__key)}static importJSON(e){return new Ao(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 x.jsx(x.Fragment,{})}}function $x(n,e,t){return new Ao(n,e,t)}function ni(n){return n instanceof Ao}const wo=n=>n.name||n.handle||n.uid,Jc=n=>n.name||n.handle||n.uid||"Anonymous",qc=n=>({kind:"anonymous",name:n||"Anonymous"}),Dx=n=>n.authorPrincipal??qc(n.author);function $h(n,e){const t=[];for(const r of e)n.includes(`@${wo(r)}`)&&!t.includes(r.uid)&&t.push(r.uid);return t}function Dh(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Ph(n,e,t,r,o,s){const i=typeof e=="string"?qc(e):e;return{author:Jc(i),authorPrincipal:i,content:n,deleted:o===void 0?!1:o,id:t===void 0?Dh():t,...s&&s.length>0?{mentions:s}:{},timeStamp:r===void 0?Date.now():r,type:"comment"}}function Px(n,e,t){return{comments:e,id:t===void 0?Dh():t,quote:n,type:"thread"}}function jx(n){return{author:n.author,...n.authorPrincipal?{authorPrincipal:n.authorPrincipal}:{},content:"[Deleted Comment]",deleted:!0,id:n.id,timeStamp:n.timeStamp,type:"comment"}}function Fx(n){const e=n._changeListeners;for(const t of e)t()}class Bx{_editor;_changeListeners;constructor(e){this._editor=e,this._changeListeners=new Set,this._editor.registerUpdateListener(()=>{Fx(this)})}getComments(){const e=[];return this._editor.getEditorState().read(()=>{se().getChildren().forEach(r=>{if(ni(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(ni(s)){const i=s;i.getId()===t.id&&i.addComment(e)}});else if(e.type==="thread"){const o=$x(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(ni(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=>{ni(s)&&s.getId()===e.id&&s.remove()})}),e.type==="comment"?{index:r!==null?r:0,markedComment:jx(e)}:null}registerOnChange(e){const t=this._changeListeners;return t.add(e),()=>{t.delete(e)}}}function Ux(n){const[e,t]=S.useState(n.getComments());return S.useEffect(()=>(t(n.getComments()),n.registerOnChange(()=>{t(n.getComments())})),[n]),e}const xr=({"data-test-id":n,children:e,className:t,onClick:r,disabled:o,small:s,title:i})=>x.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}),zx=({className:n,style:e})=>x.jsx(Ap,{className:n||"ContentEditable__root",style:e});function IM({label:n="Loading the document",header:e=!1,maxWidth:t=760}={}){return x.jsxs(Kw,{label:n,sx:{flex:1,minHeight:0,width:"100%",overflow:"hidden"},children:[e?x.jsx(Ww,{}):null,x.jsxs(co,{sx:{px:4,py:e?0:4,pb:4,display:"grid",gap:4,maxWidth:t,mx:"auto",width:"100%"},children:[x.jsx(Zs,{size:"titleLarge",lines:1,maxWidth:"22rem"}),x.jsx(Zs,{size:"bodyMedium",lines:3}),x.jsx(Zs,{size:"bodyMedium",lines:4,maxWidth:"92%"}),x.jsx(ty,{width:"100%",height:"120px"}),x.jsx(Zs,{size:"bodyMedium",lines:3,maxWidth:"88%"})]})]})}function Kx({equation:n,setEquation:e,inline:t,inputRef:r}){const s={equation:n,inputRef:r,onChange:i=>{e(i.target.value)}};return t?x.jsx(Wx,{...s,inputRef:r}):x.jsx(Hx,{...s,inputRef:r})}function Wx({equation:n,onChange:e,inputRef:t}){return x.jsxs("span",{className:"EquationEditor_inputBackground",children:[x.jsx("span",{className:"EquationEditor_dollarSign",children:"$"}),x.jsx("input",{className:"EquationEditor_inlineEditor",value:n,onChange:e,autoFocus:!0,ref:t}),x.jsx("span",{className:"EquationEditor_dollarSign",children:"$"})]})}function Hx({equation:n,onChange:e,inputRef:t}){return x.jsxs("div",{className:"EquationEditor_inputBackground",children:[x.jsx("span",{className:"EquationEditor_dollarSign",children:`$$
|
|
2
2
|
`}),x.jsx("textarea",{className:"EquationEditor_blockEditor",value:n,onChange:e,ref:t}),x.jsx("span",{className:"EquationEditor_dollarSign",children:`
|
|
3
|
-
$$`})]})}const Jx=({accept:n,label:e,onChange:t,"data-test-id":r})=>x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:e}),x.jsx(vn,{type:"file",accept:n,onChange:o=>t(o.target.files),"data-test-id":r,block:!0})]});function Da(n,e,t){return Math.min(Math.max(n,e),t)}const Re={east:1,north:8,south:2,west:4},qx=({onResizeStart:n,onResizeEnd:e,buttonRef:t,imageRef:r,maxWidth:o,editor:s,showCaption:i,setShowCaption:a})=>{const l=S.useRef(null),c=S.useRef({priority:"",value:"default"}),u=S.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),g=f!==null?f.getBoundingClientRect().height-20:100,h=100,_=100,m=k=>{const I=k===Re.east||k===Re.west,E=k===Re.north||k===Re.south,N=k&Re.north&&k&Re.west||k&Re.south&&k&Re.east,O=I?"ew":E?"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"))},b=()=>{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))},w=(k,I)=>{const E=r.current,N=l.current;if(E!==null&&N!==null){const{width:O,height:M}=E.getBoundingClientRect(),R=u.current;R.startWidth=O,R.startHeight=M,R.ratio=O/M,R.currentWidth=O,R.currentHeight=M,R.startX=k.clientX,R.startY=k.clientY,R.isResizing=!0,R.direction=I,m(I),n(),N.classList.add("image-control-wrapper--resizing"),E.style.height=`${M}px`,E.style.width=`${O}px`,document.addEventListener("pointermove",C),document.addEventListener("pointerup",v)}},C=k=>{const I=r.current,E=u.current,N=E.direction&(Re.east|Re.west),O=E.direction&(Re.south|Re.north);if(I!==null&&E.isResizing)if(N&&O){let M=Math.floor(E.startX-k.clientX);M=E.direction&Re.east?-M:M;const R=Da(E.startWidth+M,h,d),$=R/E.ratio;I.style.width=`${R}px`,I.style.height=`${$}px`,E.currentHeight=$,E.currentWidth=R}else if(O){let M=Math.floor(E.startY-k.clientY);M=E.direction&Re.south?-M:M;const R=Da(E.startHeight+M,_,g);I.style.height=`${R}px`,E.currentHeight=R}else{let M=Math.floor(E.startX-k.clientX);M=E.direction&Re.east?-M:M;const R=Da(E.startWidth+M,h,d);I.style.width=`${R}px`,E.currentWidth=R}},v=()=>{const k=r.current,I=u.current,E=l.current;if(k!==null&&E!==null&&I.isResizing){const N=I.currentWidth,O=I.currentHeight;I.startWidth=0,I.startHeight=0,I.ratio=0,I.startX=0,I.startY=0,I.currentWidth=0,I.currentHeight=0,I.isResizing=!1,E.classList.remove("image-control-wrapper--resizing"),b(),e(N,O),document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",v)}};return x.jsxs("div",{ref:l,children:[!i&&x.jsx(ft,{ref:t,size:"small",sx:{position:"absolute",bottom:12,left:"50%",transform:"translateX(-50%)",zIndex:10},onClick:()=>{a(!i)},children:"Add Caption"}),x.jsx("div",{className:"image-resizer image-resizer-n",onPointerDown:k=>{w(k,Re.north)}}),x.jsx("div",{className:"image-resizer image-resizer-ne",onPointerDown:k=>{w(k,Re.north|Re.east)}}),x.jsx("div",{className:"image-resizer image-resizer-e",onPointerDown:k=>{w(k,Re.east)}}),x.jsx("div",{className:"image-resizer image-resizer-se",onPointerDown:k=>{w(k,Re.south|Re.east)}}),x.jsx("div",{className:"image-resizer image-resizer-s",onPointerDown:k=>{w(k,Re.south)}}),x.jsx("div",{className:"image-resizer image-resizer-sw",onPointerDown:k=>{w(k,Re.south|Re.west)}}),x.jsx("div",{className:"image-resizer image-resizer-w",onPointerDown:k=>{w(k,Re.west)}}),x.jsx("div",{className:"image-resizer image-resizer-nw",onPointerDown:k=>{w(k,Re.north|Re.west)}})]})};let ri;function jh(){return ri||(ri=Promise.all([me(()=>import("../datalayer-app-main.js").then(n=>n.tu),[],import.meta.url),me(()=>Promise.resolve({}),[],import.meta.url)]).then(([n])=>n.default,n=>{throw ri=void 0,n})),ri}function Fh({equation:n,inline:e,onClick:t}){const r=S.useRef(null);return S.useEffect(()=>{let o=!1;return jh().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]),x.jsxs(x.Fragment,{children:[x.jsx("span",{children:" "}),x.jsx("span",{role:"button",tabIndex:-1,onClick:t,ref:r}),x.jsx("span",{children:" "})]})}const Vx=({onConfirm:n,initialEquation:e=""})=>{const[t,r]=S.useState(e),[o,s]=S.useState(!0),i=S.useCallback(()=>{n(t,o)},[n,t,o]),a=S.useCallback(()=>{s(!o)},[s,o]);return x.jsxs(x.Fragment,{children:[x.jsx(Y,{sx:{mb:2},children:x.jsxs(Mt,{children:[x.jsx(Mp,{checked:o,onChange:a}),x.jsx(Mt.Label,{children:"Inline"})]})}),x.jsx(Le,{sx:{fontSize:1,fontWeight:"bold",mb:1},children:"Equation"}),x.jsx(Y,{sx:{mb:2},children:o?x.jsx(vn,{onChange:l=>{r(l.target.value)},value:t,block:!0}):x.jsx(ny,{onChange:l=>{r(l.target.value)},value:t,block:!0,rows:6})}),x.jsx(Le,{sx:{fontSize:1,fontWeight:"bold",mb:1},children:"Visualization"}),x.jsx(Y,{sx:{mb:2,p:2,border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,textAlign:"center"},children:x.jsx(Fh,{equation:t,inline:!1,onClick:()=>null})}),x.jsx(Y,{sx:{display:"flex",justifyContent:"flex-end"},children:x.jsx(xr,{onClick:i,children:"Confirm"})})]})},Yx=({onClose:n,children:e,title:t,closeOnClickOutside:r=!1})=>x.jsx($p,{title:t,onClose:()=>n(),width:"medium",height:"auto",children:e}),Bh=({children:n,className:e})=>x.jsx("div",{className:e||"Placeholder__root",children:n});function ua(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 Uh(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 Cr(n){return Uh(n,"previous")}function xo(n){return Uh(n,"next")}function Xx(n){const e=Cr(n),t=xo(n);let r=e;for(;r!==null;){if(Ve(r)){const s=cy(r.getTextContent());if(s!==null)return s}if(r===t)break;r=r.getNextSibling()}const o=e.getParent();if(q(o)){const s=o.getDirection();if(s==="ltr"||s==="rtl")return s}return null}function Gx(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)||ua(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,g=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,g=f.getTextContent(),h=f.getTextContentSize())}if(Ve(f)){if(g[d]!==" ")return{node:f,offset:d};d++}}})(n,e);return l!==null?l:t}}function Zx(n){const e=xo(n);return ue(e)&&ua(168),e}function Qx(n){const e=[];return jp(n,{linebreak:()=>e.push(vt()),tab:()=>e.push(Kn()),text:t=>e.push(Vc(t))}),e}const e0="javascript";function zh(n,e){for(const t of n.childNodes)if(ke(t)&&t.tagName===e||zh(t,e))return!0;return!1}const as="data-language",ns="data-highlight-language",oi="data-theme";class dn extends Oe{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:Oe,importDOM:{code:e=>e.textContent!=null&&(/\r?\n/.test(e.textContent)||zh(e,"BR"))?{conversion:zd,priority:1}:null,div:()=>({conversion:t0,priority:1}),pre:()=>({conversion:zd,priority:0}),table:e=>Pa(e)?{conversion:n0,priority:3}:null,td:e=>{const t=e,r=t.closest("table");return t.classList.contains("js-file-line")||r&&Pa(r)?{conversion:Kd,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&Pa(t)?{conversion:Kd,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=Je().createElement("code");Ie(t,e.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(t.setAttribute(as,r),this.getIsSyntaxHighlightSupported()&&t.setAttribute(ns,r));const o=this.getTheme();o&&t.setAttribute(oi,o);const s=this.getStyle();return s&&_o(t.style,s),t}updateDOM(e,t,r){const o=this.__language,s=e.__language;o?o!==s&&t.setAttribute(as,o):s&&t.removeAttribute(as);const i=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&s?i&&o?o!==s&&t.setAttribute(ns,o):t.removeAttribute(ns):i&&o&&t.setAttribute(ns,o);const a=this.__theme,l=e.__theme;a?a!==l&&t.setAttribute(oi,a):l&&t.removeAttribute(oi);const c=this.__style,u=e.__style;return c!==u&&_o(t.style,c,u),!1}exportDOM(e){const t=Je().createElement("pre");Ie(t,e._config.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(t.setAttribute(as,r),this.getIsSyntaxHighlightSupported()&&t.setAttribute(ns,r));const o=this.getTheme();o&&t.setAttribute(oi,o);const s=this.getStyle();return s&&_o(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(!Tc(zo(),"@lexical/code")){const i=Kh(e);if(i)return i}const{anchor:r,focus:o}=e,s=(r.isBefore(o)?r:o).getNode();if(oe(s)){let i=Cr(s);const a=[];for(;;)if(bt(i))a.push(Kn()),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(Vc(" ".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=[vt(),...a];f.splice(u,0,d);const g=a[a.length-1];g?g.select():r.offset===0?l.selectPrevious():l.getNextSibling().selectNext(0,0)}if(je(s)){const{offset:i}=e.anchor;s.splice(i,0,[vt()]),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 ry(dn).setLanguage(n).setTheme(e)}function je(n){return n instanceof dn}function zd(n){return{node:Ze(n.getAttribute(as))}}function t0(n){const e=n,t=Wd(e);return t||(function(r){let o=r.parentElement;for(;o!==null;){if(Wd(o))return!0;o=o.parentElement}return!1})(e)?{node:t?Ze():null}:{node:null}}function n0(){return{node:Ze()}}function Kd(){return{node:null}}function Wd(n){return n.style.fontFamily.match("monospace")!==null}function Pa(n){return n.classList.contains("js-file-line-container")}function Kh(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 Hs extends cn{__highlightType;constructor(e="",t,r){super(e,r),this.__highlightType=t}$config(){return this.config("code-highlight",{extends:cn})}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=ja(e.theme,this.__highlightType);return Ie(t,r),t}updateDOM(e,t,r){const o=super.updateDOM(e,t,r),s=ja(r.theme,e.__highlightType),i=ja(r.theme,this.__highlightType);return s!==i&&(s&&$t(t,s),i&&Ie(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 ja(n,e){return e&&n&&n.codeHighlight&&n.codeHighlight[e]}function Vc(n="",e){return Ot(new Hs(n,e))}function Ve(n){return n instanceof Hs}const Wh="data-language";function Hh(n){return n.style.fontFamily.match("monospace")!==null}function Fl(n){let e=n.parentElement;for(;e!==null;){if(Hh(e))return!0;e=e.parentElement}return!1}const r0=Pp([Ye({$import:(n,e)=>n.$importChildren(e),match:Xe.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),o0=Ye({$import:(n,e)=>[Ze(e.getAttribute(Wh)).splice(0,0,n.$importChildren(e))],match:Xe.tag("pre"),name:"@lexical/code/pre"}),s0=Ye({$import:(n,e,t)=>{const r=e.textContent||"";return/\r?\n/.test(r)||e.querySelector("br")!==null?[Ze(e.getAttribute(Wh)).splice(0,0,n.$importChildren(e))]:t()},match:Xe.tag("code"),name:"@lexical/code/code-multiline"});function po(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 Jh(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(iy(i)){const a=i.textContent||"";a.length>0&&(r+=a,o=!0)}return s(),e?t:null}function qh(n){for(const e of Array.from(n.children)){if(ke(e)&&po(e)){if(Jh(e)!==null)return!0;const t=e.nextElementSibling;if(t&&po(t))return!0;continue}if(qh(e))return!0}return!1}const i0=Pp([Ye({$import:(n,e,t)=>{if(!po(e)||Fl(e))return t();const r=Jh(e);return r===null||r.length===0?t():[Ze().splice(0,0,yd(r.join(`
|
|
3
|
+
$$`})]})}const Jx=({accept:n,label:e,onChange:t,"data-test-id":r})=>x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:e}),x.jsx(vn,{type:"file",accept:n,onChange:o=>t(o.target.files),"data-test-id":r,block:!0})]});function Da(n,e,t){return Math.min(Math.max(n,e),t)}const Re={east:1,north:8,south:2,west:4},qx=({onResizeStart:n,onResizeEnd:e,buttonRef:t,imageRef:r,maxWidth:o,editor:s,showCaption:i,setShowCaption:a})=>{const l=S.useRef(null),c=S.useRef({priority:"",value:"default"}),u=S.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),g=f!==null?f.getBoundingClientRect().height-20:100,h=100,_=100,m=k=>{const I=k===Re.east||k===Re.west,E=k===Re.north||k===Re.south,N=k&Re.north&&k&Re.west||k&Re.south&&k&Re.east,O=I?"ew":E?"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"))},b=()=>{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))},w=(k,I)=>{const E=r.current,N=l.current;if(E!==null&&N!==null){const{width:O,height:M}=E.getBoundingClientRect(),R=u.current;R.startWidth=O,R.startHeight=M,R.ratio=O/M,R.currentWidth=O,R.currentHeight=M,R.startX=k.clientX,R.startY=k.clientY,R.isResizing=!0,R.direction=I,m(I),n(),N.classList.add("image-control-wrapper--resizing"),E.style.height=`${M}px`,E.style.width=`${O}px`,document.addEventListener("pointermove",C),document.addEventListener("pointerup",v)}},C=k=>{const I=r.current,E=u.current,N=E.direction&(Re.east|Re.west),O=E.direction&(Re.south|Re.north);if(I!==null&&E.isResizing)if(N&&O){let M=Math.floor(E.startX-k.clientX);M=E.direction&Re.east?-M:M;const R=Da(E.startWidth+M,h,d),$=R/E.ratio;I.style.width=`${R}px`,I.style.height=`${$}px`,E.currentHeight=$,E.currentWidth=R}else if(O){let M=Math.floor(E.startY-k.clientY);M=E.direction&Re.south?-M:M;const R=Da(E.startHeight+M,_,g);I.style.height=`${R}px`,E.currentHeight=R}else{let M=Math.floor(E.startX-k.clientX);M=E.direction&Re.east?-M:M;const R=Da(E.startWidth+M,h,d);I.style.width=`${R}px`,E.currentWidth=R}},v=()=>{const k=r.current,I=u.current,E=l.current;if(k!==null&&E!==null&&I.isResizing){const N=I.currentWidth,O=I.currentHeight;I.startWidth=0,I.startHeight=0,I.ratio=0,I.startX=0,I.startY=0,I.currentWidth=0,I.currentHeight=0,I.isResizing=!1,E.classList.remove("image-control-wrapper--resizing"),b(),e(N,O),document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",v)}};return x.jsxs("div",{ref:l,children:[!i&&x.jsx(ft,{ref:t,size:"small",sx:{position:"absolute",bottom:12,left:"50%",transform:"translateX(-50%)",zIndex:10},onClick:()=>{a(!i)},children:"Add Caption"}),x.jsx("div",{className:"image-resizer image-resizer-n",onPointerDown:k=>{w(k,Re.north)}}),x.jsx("div",{className:"image-resizer image-resizer-ne",onPointerDown:k=>{w(k,Re.north|Re.east)}}),x.jsx("div",{className:"image-resizer image-resizer-e",onPointerDown:k=>{w(k,Re.east)}}),x.jsx("div",{className:"image-resizer image-resizer-se",onPointerDown:k=>{w(k,Re.south|Re.east)}}),x.jsx("div",{className:"image-resizer image-resizer-s",onPointerDown:k=>{w(k,Re.south)}}),x.jsx("div",{className:"image-resizer image-resizer-sw",onPointerDown:k=>{w(k,Re.south|Re.west)}}),x.jsx("div",{className:"image-resizer image-resizer-w",onPointerDown:k=>{w(k,Re.west)}}),x.jsx("div",{className:"image-resizer image-resizer-nw",onPointerDown:k=>{w(k,Re.north|Re.west)}})]})};let ri;function jh(){return ri||(ri=Promise.all([me(()=>import("../datalayer-app-main.js").then(n=>n.tv),[],import.meta.url),me(()=>Promise.resolve({}),[],import.meta.url)]).then(([n])=>n.default,n=>{throw ri=void 0,n})),ri}function Fh({equation:n,inline:e,onClick:t}){const r=S.useRef(null);return S.useEffect(()=>{let o=!1;return jh().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]),x.jsxs(x.Fragment,{children:[x.jsx("span",{children:" "}),x.jsx("span",{role:"button",tabIndex:-1,onClick:t,ref:r}),x.jsx("span",{children:" "})]})}const Vx=({onConfirm:n,initialEquation:e=""})=>{const[t,r]=S.useState(e),[o,s]=S.useState(!0),i=S.useCallback(()=>{n(t,o)},[n,t,o]),a=S.useCallback(()=>{s(!o)},[s,o]);return x.jsxs(x.Fragment,{children:[x.jsx(Y,{sx:{mb:2},children:x.jsxs(Mt,{children:[x.jsx(Mp,{checked:o,onChange:a}),x.jsx(Mt.Label,{children:"Inline"})]})}),x.jsx(Le,{sx:{fontSize:1,fontWeight:"bold",mb:1},children:"Equation"}),x.jsx(Y,{sx:{mb:2},children:o?x.jsx(vn,{onChange:l=>{r(l.target.value)},value:t,block:!0}):x.jsx(ny,{onChange:l=>{r(l.target.value)},value:t,block:!0,rows:6})}),x.jsx(Le,{sx:{fontSize:1,fontWeight:"bold",mb:1},children:"Visualization"}),x.jsx(Y,{sx:{mb:2,p:2,border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,textAlign:"center"},children:x.jsx(Fh,{equation:t,inline:!1,onClick:()=>null})}),x.jsx(Y,{sx:{display:"flex",justifyContent:"flex-end"},children:x.jsx(xr,{onClick:i,children:"Confirm"})})]})},Yx=({onClose:n,children:e,title:t,closeOnClickOutside:r=!1})=>x.jsx($p,{title:t,onClose:()=>n(),width:"medium",height:"auto",children:e}),Bh=({children:n,className:e})=>x.jsx("div",{className:e||"Placeholder__root",children:n});function ua(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 Uh(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 Cr(n){return Uh(n,"previous")}function xo(n){return Uh(n,"next")}function Xx(n){const e=Cr(n),t=xo(n);let r=e;for(;r!==null;){if(Ve(r)){const s=cy(r.getTextContent());if(s!==null)return s}if(r===t)break;r=r.getNextSibling()}const o=e.getParent();if(q(o)){const s=o.getDirection();if(s==="ltr"||s==="rtl")return s}return null}function Gx(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)||ua(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,g=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,g=f.getTextContent(),h=f.getTextContentSize())}if(Ve(f)){if(g[d]!==" ")return{node:f,offset:d};d++}}})(n,e);return l!==null?l:t}}function Zx(n){const e=xo(n);return ue(e)&&ua(168),e}function Qx(n){const e=[];return jp(n,{linebreak:()=>e.push(vt()),tab:()=>e.push(Kn()),text:t=>e.push(Vc(t))}),e}const e0="javascript";function zh(n,e){for(const t of n.childNodes)if(ke(t)&&t.tagName===e||zh(t,e))return!0;return!1}const as="data-language",ns="data-highlight-language",oi="data-theme";class dn extends Oe{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:Oe,importDOM:{code:e=>e.textContent!=null&&(/\r?\n/.test(e.textContent)||zh(e,"BR"))?{conversion:zd,priority:1}:null,div:()=>({conversion:t0,priority:1}),pre:()=>({conversion:zd,priority:0}),table:e=>Pa(e)?{conversion:n0,priority:3}:null,td:e=>{const t=e,r=t.closest("table");return t.classList.contains("js-file-line")||r&&Pa(r)?{conversion:Kd,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&Pa(t)?{conversion:Kd,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=Je().createElement("code");Ie(t,e.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(t.setAttribute(as,r),this.getIsSyntaxHighlightSupported()&&t.setAttribute(ns,r));const o=this.getTheme();o&&t.setAttribute(oi,o);const s=this.getStyle();return s&&_o(t.style,s),t}updateDOM(e,t,r){const o=this.__language,s=e.__language;o?o!==s&&t.setAttribute(as,o):s&&t.removeAttribute(as);const i=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&s?i&&o?o!==s&&t.setAttribute(ns,o):t.removeAttribute(ns):i&&o&&t.setAttribute(ns,o);const a=this.__theme,l=e.__theme;a?a!==l&&t.setAttribute(oi,a):l&&t.removeAttribute(oi);const c=this.__style,u=e.__style;return c!==u&&_o(t.style,c,u),!1}exportDOM(e){const t=Je().createElement("pre");Ie(t,e._config.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(t.setAttribute(as,r),this.getIsSyntaxHighlightSupported()&&t.setAttribute(ns,r));const o=this.getTheme();o&&t.setAttribute(oi,o);const s=this.getStyle();return s&&_o(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(!Tc(zo(),"@lexical/code")){const i=Kh(e);if(i)return i}const{anchor:r,focus:o}=e,s=(r.isBefore(o)?r:o).getNode();if(oe(s)){let i=Cr(s);const a=[];for(;;)if(bt(i))a.push(Kn()),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(Vc(" ".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=[vt(),...a];f.splice(u,0,d);const g=a[a.length-1];g?g.select():r.offset===0?l.selectPrevious():l.getNextSibling().selectNext(0,0)}if(je(s)){const{offset:i}=e.anchor;s.splice(i,0,[vt()]),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 ry(dn).setLanguage(n).setTheme(e)}function je(n){return n instanceof dn}function zd(n){return{node:Ze(n.getAttribute(as))}}function t0(n){const e=n,t=Wd(e);return t||(function(r){let o=r.parentElement;for(;o!==null;){if(Wd(o))return!0;o=o.parentElement}return!1})(e)?{node:t?Ze():null}:{node:null}}function n0(){return{node:Ze()}}function Kd(){return{node:null}}function Wd(n){return n.style.fontFamily.match("monospace")!==null}function Pa(n){return n.classList.contains("js-file-line-container")}function Kh(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 Hs extends cn{__highlightType;constructor(e="",t,r){super(e,r),this.__highlightType=t}$config(){return this.config("code-highlight",{extends:cn})}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=ja(e.theme,this.__highlightType);return Ie(t,r),t}updateDOM(e,t,r){const o=super.updateDOM(e,t,r),s=ja(r.theme,e.__highlightType),i=ja(r.theme,this.__highlightType);return s!==i&&(s&&$t(t,s),i&&Ie(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 ja(n,e){return e&&n&&n.codeHighlight&&n.codeHighlight[e]}function Vc(n="",e){return Ot(new Hs(n,e))}function Ve(n){return n instanceof Hs}const Wh="data-language";function Hh(n){return n.style.fontFamily.match("monospace")!==null}function Fl(n){let e=n.parentElement;for(;e!==null;){if(Hh(e))return!0;e=e.parentElement}return!1}const r0=Pp([Ye({$import:(n,e)=>n.$importChildren(e),match:Xe.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),o0=Ye({$import:(n,e)=>[Ze(e.getAttribute(Wh)).splice(0,0,n.$importChildren(e))],match:Xe.tag("pre"),name:"@lexical/code/pre"}),s0=Ye({$import:(n,e,t)=>{const r=e.textContent||"";return/\r?\n/.test(r)||e.querySelector("br")!==null?[Ze(e.getAttribute(Wh)).splice(0,0,n.$importChildren(e))]:t()},match:Xe.tag("code"),name:"@lexical/code/code-multiline"});function po(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 Jh(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(iy(i)){const a=i.textContent||"";a.length>0&&(r+=a,o=!0)}return s(),e?t:null}function qh(n){for(const e of Array.from(n.children)){if(ke(e)&&po(e)){if(Jh(e)!==null)return!0;const t=e.nextElementSibling;if(t&&po(t))return!0;continue}if(qh(e))return!0}return!1}const i0=Pp([Ye({$import:(n,e,t)=>{if(!po(e)||Fl(e))return t();const r=Jh(e);return r===null||r.length===0?t():[Ze().splice(0,0,yd(r.join(`
|
|
4
4
|
`)))]},match:Xe.tag("div"),name:"@lexical/code/vscode-wrapper"}),Ye({$import:(n,e,t)=>{if(!po(e)||Fl(e))return t();const r=e.previousElementSibling;if(r&&po(r))return[];const o=[];let s=e;for(;s&&po(s);)o.push(s.tagName==="BR"?"":s.textContent||""),s=s.nextElementSibling;return o.length<2?t():[Ze().splice(0,0,yd(o.join(`
|
|
5
5
|
`)))]},match:Xe.tag("div","br"),name:"@lexical/code/vscode-line-run"})]),a0=Ye({$import:(n,e,t)=>Hh(e)?[Ze().splice(0,0,n.$importChildren(e))]:Fl(e)?n.$importChildren(e):t(),match:Xe.tag("div"),name:"@lexical/code/div"}),l0=[Ye({$import:(n,e)=>[Ze().splice(0,0,n.$importChildren(e,{rules:r0}))],match:Xe.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"}),Ye({$import:(n,e)=>n.$importChildren(e),match:Xe.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"}),s0,o0,a0],Vh=pe({dependencies:[js,ln(Fs,{preprocess:[(n,e,t)=>{qh(Dp(n)?n.body:n)&&e.session.update(sy,r=>[...r,i0]),t()}],rules:l0})],name:"@lexical/code",nodes:()=>[dn,Hs],register:n=>de(n.registerCommand(zr,e=>{const t=D();return!(!F(t)||!Kh(t))&&(e!==null&&e.preventDefault(),!0)},ee),n.registerNodeTransform(oy,e=>{e.getFormat()!==0&&je(e.getParent())&&e.setFormat(0)}))});function _r(n){if(!F(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 Yh(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)||ua(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=un(r[0].getKey(),0,"text");o.is(s)||t.push(r)}return t}function Hd(n,e){const t=D();if(!F(t)||!_r(t))return!1;const r=Yh(t),o=r.length;if(o===0&&t.isCollapsed())return n===Dt&&t.insertNodes([Kn()]),!0;if(o===0&&n===Dt&&t.getTextContent()===`
|
|
6
6
|
`){const s=Kn(),i=vt(),a=t.isBackward()?"previous":"next";return t.insertNodes([s,i]),Ri(ay(mi(ly(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=Cr(a)),n===Dt){const l=Kn();if(a.insertBefore(l),s===0){const c=t.isBackward()?"focus":"anchor",u=un(a.getKey(),0,"text");t[c].is(u)&&t[c].set(l.getKey(),0,"text")}}else bt(a)&&a.remove()}}return!0}function Jd(n,e){const t=D();if(!F(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(!_r(t)||!Ve(a)&&!bt(a)||!Ve(l)&&!bt(l))return!1;if(!e.altKey){if(t.isCollapsed()){const b=a.getParentOrThrow();if(c&&s===0&&a.getPreviousSibling()===null){if(b.getPreviousSibling()===null)return b.selectPrevious(),e.preventDefault(),!1}else if(!c&&s===a.getTextContentSize()&&a.getNextSibling()===null&&b.getNextSibling()===null)return b.selectNext(),e.preventDefault(),!1}return!1}let u,f;if(a.isBefore(l)?(u=Cr(a),f=xo(l)):(u=Cr(l),f=xo(a)),u==null||f==null)return!1;const d=u.getNodesBetween(f);for(let b=0;b<d.length;b++){const w=d[b];if(!Ve(w)&&!bt(w)&&!ue(w))return!1}e.preventDefault(),e.stopPropagation();const g=c?u.getPreviousSibling():f.getNextSibling();if(!ue(g))return!0;const h=c?g.getPreviousSibling():g.getNextSibling();if(h==null)return!0;const _=Ve(h)||bt(h)||ue(h)?c?Cr(h):xo(h):null;let m=_??h;return g.remove(),d.forEach(b=>b.remove()),n===pt?(d.forEach(b=>m.insertBefore(b)),m.insertBefore(g)):(m.insertAfter(g),m=g,d.forEach(b=>{m.insertAfter(b),m=b})),t.setTextNodeRange(a,s,l,i),!0}function qd(n,e){const t=D();if(!F(t))return!1;const{anchor:r,focus:o}=t,s=r.getNode(),i=o.getNode(),a=n===Ir;if(!_r(t)||!Ve(s)&&!bt(s)||!Ve(i)&&!bt(i))return!1;const l=i,c=Xx(l)==="rtl"?!a:a,u=r.key,f=r.offset,d=r.type;if(c){const g=Gx(l,o.offset);if(g!==null){const{node:h,offset:_}=g;ue(h)?h.selectNext(0,0):t.setTextNodeRange(h,_,h,_)}else l.getParentOrThrow().selectStart()}else Zx(l).select();return e.shiftKey&&t.anchor.set(u,f,d),e.preventDefault(),e.stopPropagation(),!0}function c0(n,e,t){return de(n.registerCommand(Kr,r=>{const o=(function(s){const i=D();if(!F(i)||!_r(i))return null;const a=s?wn:Dt,l=s?wn:Tl,c=i.anchor,u=i.focus;if(c.is(u))return l;const f=Yh(i);if(f.length!==1)return a;const d=f[0];let g,h;d.length===0&&ua(285),i.isBackward()?(g=u,h=c):(g=c,h=u);const _=Cr(d[0]),m=xo(d[0]),b=un(_.getKey(),0,"text"),w=un(m.getKey(),m.getTextContentSize(),"text");return g.isBefore(b)||w.isBefore(h)?a:b.isBefore(g)||h.isBefore(w)?l:a})(r.shiftKey);return o!==null&&(r.preventDefault(),n.dispatchCommand(o),!0)},ee),n.registerCommand(Tl,()=>!!_r(D())&&(Tr([Kn()]),!0),ee),n.registerCommand(Dt,()=>Hd(Dt),ee),n.registerCommand(wn,()=>Hd(wn,e),ee),n.registerCommand(pt,r=>{const o=D();if(!F(o))return!1;const{anchor:s}=o,i=s.getNode();if(!_r(o))return!1;const a=i.getParent();return o.isCollapsed()&&s.offset===0&&i.getPreviousSibling()===null&&je(a)&&a.getPreviousSibling()===null?(r.preventDefault(),!0):Jd(pt,r)},ee),n.registerCommand(Vt,r=>{const o=D();if(!F(o))return!1;const{anchor:s}=o,i=s.getNode();return!!_r(o)&&(o.isCollapsed()&&s.offset===i.getTextContentSize()&&i.getNextSibling()===null&&je(i.getParentOrThrow())&&i.getParentOrThrow().getNextSibling()===null?(r.preventDefault(),!0):Jd(Vt,r))},ee),n.registerCommand(Ir,r=>qd(Ir,r),ee),n.registerCommand(xs,r=>qd(xs,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 Ga=!1;function Tu(){if(Ga||typeof document>"u")return;if(document.getElementById(Hf)){Ga=!0;return}const n=document.createElement("style");n.id=Hf,n.textContent=rv,document.head.appendChild(n),Ga=!0}const ov={background:"var(--bgColor-muted, #f8f8f8)",border:"1px solid var(--borderColor-default, #e0e0e0)",borderRadius:"6px",margin:"12px 0",padding:"0",overflow:"hidden"},sv={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"},iv={padding:"12px 16px 16px 36px"};function Iu(n,e){for(const[t,r]of Object.entries(e))r!=null&&(n.style[t]=r)}function av(n){const e=n.open!==void 0?n.open:!0;return{node:Eu(e)}}class Mr extends Oe{__open;constructor(e,t){super(t),this.__open=e}static getType(){return"collapsible-container"}static clone(e){return new Mr(e.__open,e.__key)}isShadowRoot(){return!0}collapseAtStart(e){const t=[];for(const s of this.getChildren())q(s)&&t.push(...s.getChildren());Dc(gt(this,"previous")).splice(1,t);const[o]=t;return o&&o.selectStart().deleteCharacter(!0),!0}createDOM(e,t){Tu();let r;if($i)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"),Iu(r,ov),r}updateDOM(e,t){const r=this.__open;if(e.__open!==r)if($i){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"),G_(o))}else t.open=this.__open;return!1}static importDOM(){return{details:e=>({conversion:av,priority:1})}}static importJSON(e){return Eu(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 Eu(n){return new Mr(n)}function Pt(n){return n instanceof Mr}function lv(n){return{node:Nu()}}class $r extends Oe{static getType(){return"collapsible-content"}static clone(e){return new $r(e.__key)}createDOM(e,t){Tu();const r=document.createElement("div");return r.classList.add("Collapsible__content"),Iu(r,iv),$i&&(t.getEditorState().read(()=>{const o=this.getParentOrThrow();if(!Pt(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.__open||G_(r)}),nv(r,()=>{t.update(()=>{const o=this.getParentOrThrow().getLatest();if(!Pt(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:lv,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 Nu().updateFromJSON(e)}isShadowRoot(){return!0}}function Nu(){return new $r}function Lu(n){return n instanceof $r}function cv(n){return{node:Z_()}}class Os extends Oe{$config(){return this.config("collapsible-title",{$transform(e){e.isEmpty()&&e.remove()},extends:Oe,importDOM:$c({summary:()=>({conversion:cv,priority:1})})})}createDOM(e,t){Tu();const r=document.createElement("summary");return r.classList.add("Collapsible__title"),Iu(r,sv),$i&&r.addEventListener("click",()=>{t.update(()=>{const o=this.getLatest().getParentOrThrow();if(!Pt(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(!Pt(r))throw new Error("CollapsibleTitleNode expects to be child of CollapsibleContainerNode");if(r.getOpen()){const o=this.getNextSibling();if(!Lu(o))throw new Error("CollapsibleTitleNode expects to have CollapsibleContentNode sibling");const s=o.getFirstChild();if(q(s))return s;{const i=ne();return o.append(i),i}}else{const o=ne();return r.insertAfter(o,t),o}}}function Z_(){return new Os}function xi(n){return n instanceof Os}function uv(n){const t=window.getComputedStyle(n).getPropertyValue("grid-template-columns");return t?{node:Ou(t)}:null}class Dr extends Oe{__templateColumns;constructor(e,t){super(t),this.__templateColumns=e}static getType(){return"layout-container"}static clone(e){return new Dr(e.__templateColumns,e.__key)}createDOM(e){const t=document.createElement("div");return t.style.gridTemplateColumns=this.__templateColumns,typeof e.theme.layoutContainer=="string"&&Ie(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:uv,priority:2}:null}}static importJSON(e){return Ou().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 Ou(n=""){return new Dr(n)}function Ci(n){return n instanceof Dr}function dv(){return{node:Ru()}}function fv(n){if(!Au(n)||n.getChildrenSize()!==1)return!1;const e=n.getFirstChild();return ht(e)&&e.isEmpty()}class Pr extends Oe{constructor(e){super(e)}static getType(){return"layout-item"}static clone(e){return new Pr(e.__key)}createDOM(e){const t=document.createElement("div");return t.setAttribute("data-lexical-layout-item","true"),typeof e.theme.layoutItem=="string"&&Ie(t,e.theme.layoutItem),t}updateDOM(){return!1}collapseAtStart(){const e=this.getParentOrThrow();return this.is(e.getFirstChild())&&e.getChildren().every(fv)?(e.remove(),!0):!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-layout-item")?{conversion:dv,priority:2}:null}}static importJSON(e){return Ru().updateFromJSON(e)}isShadowRoot(){return!0}}function Ru(){return new Pr}function Au(n){return n instanceof Pr}const Q_="@datalayer/jupyter-lexical/Loom",ls=new WeakMap;function UM(n,e){return e?ls.set(n,e):ls.delete(n),()=>{ls.get(n)===e&&ls.delete(n)}}function gv(n){return ls.get(n)}const pv=/^https?:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/(?:[^/?#]*-)?([0-9a-f]{32})(?:[/?#].*)?$/i;function kn(n){const e=pv.exec(n.trim());return e?e[1].toLowerCase():null}function Mu(n){return`https://www.loom.com/share/${n}`}function em(n){return`https://www.loom.com/embed/${n}`}async function tm(n){const e=kn(n);if(!e)throw new Error(`Not a Loom video address: ${n}`);const t=Mu(e);try{const{oembed:r}=await me(async()=>{const{oembed:a}=await import("./index-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 Za=new Map;function hv(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 _v(n){let e=Za.get(n);return e||(e=(async()=>{const{isSupported:t}=await me(async()=>{const{isSupported:f}=await import("./is-supported-dYYctHET.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("./index-DvWWLOj6.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(()=>Za.delete(n)),Za.set(n,e)),e}function mv({video:n}){const e=kn(n.url);return e?x.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:x.jsx("iframe",{src:em(e),title:n.title||"Loom video",allow:"fullscreen; picture-in-picture",style:{position:"absolute",inset:0,width:"100%",height:"100%",border:0}})}):null}function bv({nodeKey:n}){const[e]=fe(),t=Hr(),[r,o]=S.useState(""),[s,i]=S.useState(),[a,l]=S.useState(),c=Tc(e,Q_)?.config.publicAppId??gv(e),u=S.useCallback(g=>{e.update(()=>{const h=Q(n);Du(h)&&h.setVideo(g)})},[e,n]),f=S.useCallback(async()=>{if(c){l(void 0),i("recording");try{(await _v(c)).record(h=>u({url:h.sharedUrl,title:h.title,width:h.width,height:h.height}))}catch(g){l(hv(g))}finally{i(void 0)}}},[c,u]),d=S.useCallback(async()=>{if(!kn(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 tm(r))}finally{i(void 0)}},[r,u]);return t?x.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:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[x.jsx(Ws,{size:16}),x.jsx(Le,{sx:{fontWeight:"bold"},children:"Loom Video"})]}),x.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."}),x.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[x.jsx(ft,{variant:"primary",onClick:()=>{f()},disabled:!c||s!==void 0,children:s==="recording"?"Starting…":"Record"}),x.jsx(Le,{sx:{color:"fg.muted",fontSize:1},children:"or"}),x.jsx(vn,{"aria-label":"Address of a Loom video",placeholder:"https://www.loom.com/share/…",value:r,onChange:g=>o(g.target.value),onFocus:()=>e.update(()=>Ee(null)),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),d())},sx:{flex:"1 1 240px"}}),x.jsx(ft,{onClick:()=>{d()},disabled:!r.trim()||s!==void 0,children:s==="embedding"?"Embedding…":"Embed"})]}),!c&&x.jsxs(Y,{"data-lexical-loom-no-app-id":"",sx:{display:"flex",gap:2,alignItems:"flex-start",color:"attention.fg",fontSize:1},children:[x.jsx(Fp,{size:16}),x.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 ",x.jsx("code",{children:"LoomExtension"}),". A Loom video can still be embedded by its address."]})]}),a&&x.jsx(Le,{role:"alert",sx:{color:"danger.fg",fontSize:1},children:a})]}):x.jsx(Le,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:"A Loom video goes here."})}function yv({className:n,format:e,nodeKey:t,video:r}){return x.jsx(Ls,{className:n,format:e,nodeKey:t,children:kn(r.url)?x.jsx(mv,{video:r}):x.jsx(bv,{nodeKey:t})})}function wv(n){const e=n.getAttribute("data-lexical-loom"),t=kn(e||n.getAttribute("src")||"");return t?{node:$u({url:Mu(t),title:n.getAttribute("title")||void 0})}:null}class Vo extends Jo{__url;__title;__width;__height;static getType(){return"loom"}static clone(e){return new Vo({url:e.__url,title:e.__title,width:e.__width,height:e.__height},e.__format,e.__key)}static importJSON(e){const t=$u({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")||kn(e.getAttribute("src")||"")?{conversion:wv,priority:1}:null}}exportDOM(){const e=kn(this.__url);if(!e)return{element:null};const t=document.createElement("iframe");return t.setAttribute("data-lexical-loom",this.__url),t.setAttribute("src",em(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 x.jsx(yv,{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 $u(n){return new Vo(n)}function Du(n){return n instanceof Vo}function xv(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 Cv(n){const e=xv(n,t=>t.type);return{element:e.element||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const Jf=/[!-/:-@[-`{-~\s]/,Sv=/^\s{0,3}$/,qf=/^```(\w{1,10})?\s?$/;function vv(n){const e=Cv(n),t=Nv(e.textFormat);return r=>{const o=r.split(`
|
|
84
|
+
`;let Ga=!1;function Tu(){if(Ga||typeof document>"u")return;if(document.getElementById(Hf)){Ga=!0;return}const n=document.createElement("style");n.id=Hf,n.textContent=rv,document.head.appendChild(n),Ga=!0}const ov={background:"var(--bgColor-muted, #f8f8f8)",border:"1px solid var(--borderColor-default, #e0e0e0)",borderRadius:"6px",margin:"12px 0",padding:"0",overflow:"hidden"},sv={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"},iv={padding:"12px 16px 16px 36px"};function Iu(n,e){for(const[t,r]of Object.entries(e))r!=null&&(n.style[t]=r)}function av(n){const e=n.open!==void 0?n.open:!0;return{node:Eu(e)}}class Mr extends Oe{__open;constructor(e,t){super(t),this.__open=e}static getType(){return"collapsible-container"}static clone(e){return new Mr(e.__open,e.__key)}isShadowRoot(){return!0}collapseAtStart(e){const t=[];for(const s of this.getChildren())q(s)&&t.push(...s.getChildren());Dc(gt(this,"previous")).splice(1,t);const[o]=t;return o&&o.selectStart().deleteCharacter(!0),!0}createDOM(e,t){Tu();let r;if($i)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"),Iu(r,ov),r}updateDOM(e,t){const r=this.__open;if(e.__open!==r)if($i){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"),G_(o))}else t.open=this.__open;return!1}static importDOM(){return{details:e=>({conversion:av,priority:1})}}static importJSON(e){return Eu(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 Eu(n){return new Mr(n)}function Pt(n){return n instanceof Mr}function lv(n){return{node:Nu()}}class $r extends Oe{static getType(){return"collapsible-content"}static clone(e){return new $r(e.__key)}createDOM(e,t){Tu();const r=document.createElement("div");return r.classList.add("Collapsible__content"),Iu(r,iv),$i&&(t.getEditorState().read(()=>{const o=this.getParentOrThrow();if(!Pt(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.__open||G_(r)}),nv(r,()=>{t.update(()=>{const o=this.getParentOrThrow().getLatest();if(!Pt(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:lv,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 Nu().updateFromJSON(e)}isShadowRoot(){return!0}}function Nu(){return new $r}function Lu(n){return n instanceof $r}function cv(n){return{node:Z_()}}class Os extends Oe{$config(){return this.config("collapsible-title",{$transform(e){e.isEmpty()&&e.remove()},extends:Oe,importDOM:$c({summary:()=>({conversion:cv,priority:1})})})}createDOM(e,t){Tu();const r=document.createElement("summary");return r.classList.add("Collapsible__title"),Iu(r,sv),$i&&r.addEventListener("click",()=>{t.update(()=>{const o=this.getLatest().getParentOrThrow();if(!Pt(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(!Pt(r))throw new Error("CollapsibleTitleNode expects to be child of CollapsibleContainerNode");if(r.getOpen()){const o=this.getNextSibling();if(!Lu(o))throw new Error("CollapsibleTitleNode expects to have CollapsibleContentNode sibling");const s=o.getFirstChild();if(q(s))return s;{const i=ne();return o.append(i),i}}else{const o=ne();return r.insertAfter(o,t),o}}}function Z_(){return new Os}function xi(n){return n instanceof Os}function uv(n){const t=window.getComputedStyle(n).getPropertyValue("grid-template-columns");return t?{node:Ou(t)}:null}class Dr extends Oe{__templateColumns;constructor(e,t){super(t),this.__templateColumns=e}static getType(){return"layout-container"}static clone(e){return new Dr(e.__templateColumns,e.__key)}createDOM(e){const t=document.createElement("div");return t.style.gridTemplateColumns=this.__templateColumns,typeof e.theme.layoutContainer=="string"&&Ie(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:uv,priority:2}:null}}static importJSON(e){return Ou().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 Ou(n=""){return new Dr(n)}function Ci(n){return n instanceof Dr}function dv(){return{node:Ru()}}function fv(n){if(!Au(n)||n.getChildrenSize()!==1)return!1;const e=n.getFirstChild();return ht(e)&&e.isEmpty()}class Pr extends Oe{constructor(e){super(e)}static getType(){return"layout-item"}static clone(e){return new Pr(e.__key)}createDOM(e){const t=document.createElement("div");return t.setAttribute("data-lexical-layout-item","true"),typeof e.theme.layoutItem=="string"&&Ie(t,e.theme.layoutItem),t}updateDOM(){return!1}collapseAtStart(){const e=this.getParentOrThrow();return this.is(e.getFirstChild())&&e.getChildren().every(fv)?(e.remove(),!0):!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-layout-item")?{conversion:dv,priority:2}:null}}static importJSON(e){return Ru().updateFromJSON(e)}isShadowRoot(){return!0}}function Ru(){return new Pr}function Au(n){return n instanceof Pr}const Q_="@datalayer/jupyter-lexical/Loom",ls=new WeakMap;function UM(n,e){return e?ls.set(n,e):ls.delete(n),()=>{ls.get(n)===e&&ls.delete(n)}}function gv(n){return ls.get(n)}const pv=/^https?:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/(?:[^/?#]*-)?([0-9a-f]{32})(?:[/?#].*)?$/i;function kn(n){const e=pv.exec(n.trim());return e?e[1].toLowerCase():null}function Mu(n){return`https://www.loom.com/share/${n}`}function em(n){return`https://www.loom.com/embed/${n}`}async function tm(n){const e=kn(n);if(!e)throw new Error(`Not a Loom video address: ${n}`);const t=Mu(e);try{const{oembed:r}=await me(async()=>{const{oembed:a}=await import("./index-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 Za=new Map;function hv(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 _v(n){let e=Za.get(n);return e||(e=(async()=>{const{isSupported:t}=await me(async()=>{const{isSupported:f}=await import("./is-supported-dYYctHET.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("./index-BiTIdbkn.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(()=>Za.delete(n)),Za.set(n,e)),e}function mv({video:n}){const e=kn(n.url);return e?x.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:x.jsx("iframe",{src:em(e),title:n.title||"Loom video",allow:"fullscreen; picture-in-picture",style:{position:"absolute",inset:0,width:"100%",height:"100%",border:0}})}):null}function bv({nodeKey:n}){const[e]=fe(),t=Hr(),[r,o]=S.useState(""),[s,i]=S.useState(),[a,l]=S.useState(),c=Tc(e,Q_)?.config.publicAppId??gv(e),u=S.useCallback(g=>{e.update(()=>{const h=Q(n);Du(h)&&h.setVideo(g)})},[e,n]),f=S.useCallback(async()=>{if(c){l(void 0),i("recording");try{(await _v(c)).record(h=>u({url:h.sharedUrl,title:h.title,width:h.width,height:h.height}))}catch(g){l(hv(g))}finally{i(void 0)}}},[c,u]),d=S.useCallback(async()=>{if(!kn(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 tm(r))}finally{i(void 0)}},[r,u]);return t?x.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:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[x.jsx(Ws,{size:16}),x.jsx(Le,{sx:{fontWeight:"bold"},children:"Loom Video"})]}),x.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."}),x.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[x.jsx(ft,{variant:"primary",onClick:()=>{f()},disabled:!c||s!==void 0,children:s==="recording"?"Starting…":"Record"}),x.jsx(Le,{sx:{color:"fg.muted",fontSize:1},children:"or"}),x.jsx(vn,{"aria-label":"Address of a Loom video",placeholder:"https://www.loom.com/share/…",value:r,onChange:g=>o(g.target.value),onFocus:()=>e.update(()=>Ee(null)),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),d())},sx:{flex:"1 1 240px"}}),x.jsx(ft,{onClick:()=>{d()},disabled:!r.trim()||s!==void 0,children:s==="embedding"?"Embedding…":"Embed"})]}),!c&&x.jsxs(Y,{"data-lexical-loom-no-app-id":"",sx:{display:"flex",gap:2,alignItems:"flex-start",color:"attention.fg",fontSize:1},children:[x.jsx(Fp,{size:16}),x.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 ",x.jsx("code",{children:"LoomExtension"}),". A Loom video can still be embedded by its address."]})]}),a&&x.jsx(Le,{role:"alert",sx:{color:"danger.fg",fontSize:1},children:a})]}):x.jsx(Le,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:"A Loom video goes here."})}function yv({className:n,format:e,nodeKey:t,video:r}){return x.jsx(Ls,{className:n,format:e,nodeKey:t,children:kn(r.url)?x.jsx(mv,{video:r}):x.jsx(bv,{nodeKey:t})})}function wv(n){const e=n.getAttribute("data-lexical-loom"),t=kn(e||n.getAttribute("src")||"");return t?{node:$u({url:Mu(t),title:n.getAttribute("title")||void 0})}:null}class Vo extends Jo{__url;__title;__width;__height;static getType(){return"loom"}static clone(e){return new Vo({url:e.__url,title:e.__title,width:e.__width,height:e.__height},e.__format,e.__key)}static importJSON(e){const t=$u({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")||kn(e.getAttribute("src")||"")?{conversion:wv,priority:1}:null}}exportDOM(){const e=kn(this.__url);if(!e)return{element:null};const t=document.createElement("iframe");return t.setAttribute("data-lexical-loom",this.__url),t.setAttribute("src",em(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 x.jsx(yv,{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 $u(n){return new Vo(n)}function Du(n){return n instanceof Vo}function xv(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 Cv(n){const e=xv(n,t=>t.type);return{element:e.element||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const Jf=/[!-/:-@[-`{-~\s]/,Sv=/^\s{0,3}$/,qf=/^```(\w{1,10})?\s?$/;function vv(n){const e=Cv(n),t=Nv(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]=Iv(o,l,i);if(u!=null){l=f;continue}Tv(c,i,e.element,t,e.textMatch)}const a=i.getChildren();for(const l of a)kv(l)&&l.remove();i.selectEnd()}}function kv(n){if(!ht(n))return!1;const e=n.getFirstChild();return e==null||n.getChildrenSize()===1&&oe(e)&&Sv.test(e.getTextContent())}function Tv(n,e,t,r,o){const s=n.trim(),i=$e(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(Si(i,r,o),a.isAttached()&&s.length>0){const l=a.getPreviousSibling();if(ht(l)||Vn(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,[vt(),...a.getChildren()]),a.remove())}}}function Iv(n,e,t){const r=n[e].match(qf);if(r){let o=e;const s=n.length;for(;++o<s;)if(n[o].match(qf)){const a=qr(r[1]),l=$e(n.slice(e+1,o).join(`
|
|
86
86
|
`));return a.append(l),t.append(a),[a,o]}}return[null,e]}function Si(n,e,t){const r=n.getTextContent(),o=Ev(r,e);if(!o){nm(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")||Si(s,e,t),a&&Si(a,e,t),i&&Si(i,e,t)}function nm(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&&nm(l,e),r.replace(a,o);continue e}break}}function Ev(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||Jf.test(c))&&(!u||Jf.test(u)))return i}}return null}function Nv(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 rm=n=>(e,t,r)=>{const o=n(r);o.append(...t),e.replace(o),o.select(0,0)},om=4,Pu=n=>(e,t,r)=>{const o=e.getPreviousSibling(),s=xt(n==="check"?r[3]==="x":void 0);if(Z(o)&&o.getListType()===n)o.append(s),e.remove();else{const a=Et(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/om);i&&s.setIndent(i)},va=(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(va(u,e,t+1));continue}}const a=" ".repeat(t*om),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
|
`)},Lv={dependencies:[qs],export:(n,e)=>{if(!Wr(n))return null;const t=Number(n.getTag().slice(1));return"#".repeat(t)+" "+e(n)},regExp:/^(#{1,6})\s/,replace:rm(n=>{const e="h"+n[1].length;return fn(e)}),type:"element"},Ov={dependencies:[Js],export:(n,e)=>{if(!Vn(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(Vn(s)){s.splice(s.getChildrenSize(),0,[vt(),...e]),s.select(0,0),n.remove();return}}const o=Ln();o.append(...e),n.replace(o),o.select(0,0)},type:"element"},Rv={dependencies:[Nt],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:rm(n=>qr(n?n[1]:void 0)),type:"element"},Av={dependencies:[Yt,bn],export:(n,e)=>Z(n)?va(n,e,0):null,regExp:/^(\s*)[-*+]\s/,replace:Pu("bullet"),type:"element"},Mv={dependencies:[Yt,bn],export:(n,e)=>Z(n)?va(n,e,0):null,regExp:/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,replace:Pu("check"),type:"element"},$v={dependencies:[Yt,bn],export:(n,e)=>Z(n)?va(n,e,0):null,regExp:/^(\s*)(\d{1,})\.\s/,replace:Pu("number"),type:"element"},Dv={format:["code"],tag:"`",type:"text-format"},Pv={format:["bold","italic"],tag:"***",type:"text-format"},jv={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},Fv={format:["bold"],tag:"**",type:"text-format"},Bv={format:["bold"],intraword:!1,tag:"__",type:"text-format"},Uv={format:["strikethrough"],tag:"~~",type:"text-format"},zv={format:["italic"],tag:"*",type:"text-format"},Kv={format:["italic"],intraword:!1,tag:"_",type:"text-format"},Wv={dependencies:[gn],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=Mo(r),s=$e(t);s.setFormat(n.getFormat()),o.append(s),n.replace(o)},trigger:")",type:"text-match"},sm=[Lv,Ov,Rv,Av,$v],im=[Dv,Pv,jv,Fv,Bv,zv,Kv,Uv],am=[Wv],Hv=[...sm,...im,...am];function zM(n,e=Hv){return vv(e)(n)}const Jv={dependencies:[mu],export:n=>ch(n)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(n,e,t,r)=>{const o=ba();r||n.getNextSibling()!=null?n.replace(o):n.insertBefore(o)},type:"element"},qv={dependencies:[Jr],export:(n,e,t)=>Hn(n)?`})`:null,importRegExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))/,regExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))$/,replace:(n,e)=>{const[,t,r]=e,o=xa({altText:t,maxWidth:800,src:r});n.replace(o)},trigger:")",type:"text-match"},Vv={dependencies:[ir],export:n=>{if(!ht(n)||n.getChildrenSize()!==1)return null;const e=n.getFirstChild();return!Rr(e)||e.__inline?null:`$$${e.getEquation()}$$`},regExp:/^\$\$(.+?)\$\$\s?$/,replace:(n,e,t)=>{const r=ne();r.append(ya(t[1].trim(),!1)),n.replace(r)},type:"element"},Yv={dependencies:[ir],export:(n,e,t)=>Rr(n)?`$${n.getEquation()}$`:null,importRegExp:/\$([^$].+?)\$/,regExp:/\$([^$].+?)\$$/,replace:(n,e)=>{const[,t]=e,r=ya(t,!0);n.replace(r)},trigger:"$",type:"text-match"},lm=/^(?:\|)(.+)(?:\|)\s?$/,Xv=/^:?-+:?$/,Gv={dependencies:[Gt,Wo,Xt],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())q(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:lm,replace:(n,e,t)=>{const r=Vf(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=Vf(f.getTextContent());if(d==null)break;i=Math.max(i,d.length),o.unshift(d);const g=s.getPreviousSibling();s.remove(),s=g}const a=o.findIndex(f=>f.every(d=>Xv.test(d.getTextContent().trim())));if(a===0){const f=n.getPreviousSibling();if(be(f)){const d=f.getLastChild();ce(d)&&d.getChildren().forEach(g=>{J(g)&&g.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=Ho();for(const[f,d]of o.entries()){const g=pn();c.append(g);for(let h=0;h<i;h++){const _=h<d.length?d[h]:cm(null);f<l&&_.setHeaderStyles(te.ROW,te.ROW),g.append(_)}}const u=n.getPreviousSibling();be(u)&&Zv(u)===i?(u.append(...c.getChildren()),n.remove()):n.replace(c),c.selectEnd()},type:"element"};function Zv(n){const e=n.getFirstChild();return ce(e)?e.getChildrenSize():0}const cm=n=>{const e=lt(te.NO_STATUS),t=ne();return n!=null&&t.append($e(n.trim())),e.append(t),e},Vf=n=>{const e=n.match(lm);return!e||!e[1]?null:e[1].split("|").map(t=>cm(t))},Qv=[Vv,Gv,Jv,qv,Yv,Mv,...sm,...im,...am],e1=S.lazy(()=>me(()=>import("./ExcalidrawComponent-
|
|
91
|
+
`)},regExp:lm,replace:(n,e,t)=>{const r=Vf(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=Vf(f.getTextContent());if(d==null)break;i=Math.max(i,d.length),o.unshift(d);const g=s.getPreviousSibling();s.remove(),s=g}const a=o.findIndex(f=>f.every(d=>Xv.test(d.getTextContent().trim())));if(a===0){const f=n.getPreviousSibling();if(be(f)){const d=f.getLastChild();ce(d)&&d.getChildren().forEach(g=>{J(g)&&g.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=Ho();for(const[f,d]of o.entries()){const g=pn();c.append(g);for(let h=0;h<i;h++){const _=h<d.length?d[h]:cm(null);f<l&&_.setHeaderStyles(te.ROW,te.ROW),g.append(_)}}const u=n.getPreviousSibling();be(u)&&Zv(u)===i?(u.append(...c.getChildren()),n.remove()):n.replace(c),c.selectEnd()},type:"element"};function Zv(n){const e=n.getFirstChild();return ce(e)?e.getChildrenSize():0}const cm=n=>{const e=lt(te.NO_STATUS),t=ne();return n!=null&&t.append($e(n.trim())),e.append(t),e},Vf=n=>{const e=n.match(lm);return!e||!e[1]?null:e[1].split("|").map(t=>cm(t))},Qv=[Vv,Gv,Jv,qv,Yv,Mv,...sm,...im,...am],e1=S.lazy(()=>me(()=>import("./ExcalidrawComponent-Cb8yeXqu.js"),[],import.meta.url));function t1(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:ju(e,i,s)}:null}class Yn extends Bt{__data;__width;__height;static getType(){return"excalidraw"}static clone(e){return new Yn(e.__data,e.__width,e.__height,e.__key)}static importJSON(e){return new Yn(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:t1,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 x.jsx(e1,{nodeKey:this.getKey(),data:this.__data,width:this.__width,height:this.__height})}}function ju(n="[]",e="inherit",t="inherit"){return new Yn(n,e,t)}function Fu(n){return n instanceof Yn}const n1=Object.freeze(Object.defineProperty({__proto__:null,$createExcalidrawNode:ju,$isExcalidrawNode:Fu,ExcalidrawNode:Yn},Symbol.toStringTag,{value:"Module"}));function r1(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 cc(n){const e=n.getFormatType();return e==="center"||e==="right"||e==="justify"?e:"left"}function fr(n,e){return Bu(n.getChildren(),e)}function Bu(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(...fr(r,r.getURL()));else if(Rr(r))t.push({kind:"equation",equation:r.getEquation(),key:r.getKey()});else if(q(r))t.push(...fr(r,e));else if(It(r)){const o=r.getTextContent();o&&t.push({kind:"text",text:o,link:e})}return t}function vi(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(vi(r.blocks));break;case"list":r.items.forEach((o,s)=>{const i=r.ordered?`${r.start+s}. `:"• ";t([{kind:"text",text:i},...vi(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(vi(o)));break}return e}function o1(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=Yi(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(q(i)&&!Pe(i)){const a=Yi(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(...Bu([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 Yi(n){if(Wr(n))return{kind:"heading",level:Math.min(6,Math.max(1,Number(n.getTag().slice(1))||1)),inlines:fr(n),align:cc(n),indent:n.getIndent()};if(Vn(n))return{kind:"quote",blocks:[{kind:"paragraph",inlines:fr(n),align:"left",indent:0}]};if(Z(n))return{kind:"list",ordered:n.getListType()==="number",start:n.getStart(),items:o1(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(Cu(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:vi(cs(o.getChildren()))});e.push(r)}return{kind:"table",rows:e}}if(Ci(n)){const e=n.getChildren().filter(Au),t=n.getTemplateColumns().trim(),r=Math.max(e.length,t?t.split(/\s+/).length:0);return{kind:"columns",weights:r1(n.getTemplateColumns(),r).slice(0,e.length),columns:e.map(o=>cs(o.getChildren()))}}if(Pt(n)){const e=n.getChildren().find(xi),t=n.getChildren().find(Lu);return{kind:"collapsible",title:e?fr(e):[],blocks:t?cs(t.getChildren()):[],open:n.getOpen()}}if(ch(n))return{kind:"rule"};if(Hn(n))return{kind:"image",src:n.getSrc(),alt:n.getAltText(),key:n.getKey()};if(Rr(n))return{kind:"equation",equation:n.getEquation(),key:n.getKey()};if(W_(n)){const e=n.getId();return{kind:"embed",label:`YouTube video ${e}`,url:`https://www.youtube.com/watch?v=${e}`,key:n.getKey()}}if(Fu(n))return{kind:"drawing",key:n.getKey(),label:"Drawing"};if(Du(n)){const{url:e,title:t}=n.getVideo();return kn(e)?{kind:"embed",label:t?`Loom video: ${t}`:"Loom video",url:e,key:n.getKey()}:null}if(ht(n)){const e=fr(n),t=n.getChildrenSize()===1?n.getFirstChild():null;return t&&Rr(t)&&!t.__inline?{kind:"equation",equation:t.getEquation(),key:t.getKey()}:t&&Hn(t)?{kind:"image",src:t.getSrc(),alt:t.getAltText(),key:t.getKey()}:{kind:"paragraph",inlines:e,align:cc(n),indent:n.getIndent()}}if(q(n)){const e=cs(n.getChildren());if(e.length)return e.length===1?e[0]:{kind:"quote",blocks:e};const t=fr(n);return t.length?{kind:"paragraph",inlines:t,align:"left",indent:0}:null}return It(n)?{kind:"drawing",key:n.getKey(),label:n.getTextContent()||n.getType()}:null}function um(n){return q(n)&&!Pe(n)&&!n.isInline()&&!ht(n)||be(n)||Z(n)||je(n)||Hn(n)||Fu(n)||W_(n)||Du(n)||Rr(n)&&!n.__inline}function s1(n){const e=[];let t=[];const r=()=>{if(t.length){const o=Bu(t);o.length&&e.push({kind:"paragraph",inlines:o,align:cc(n),indent:n.getIndent()}),t=[]}};for(const o of n.getChildren())if(um(o)){r();const s=Yi(o);s&&e.push(s)}else t.push(o);return r(),e}function cs(n){const e=[];for(const t of n){if(ht(t)&&t.getChildren().some(um)){e.push(...s1(t));continue}const r=Yi(t);r&&e.push(r)}return e}function dm(n){return n.map(e=>e.kind==="text"?e.text:e.kind==="break"?`
|
|
92
92
|
`:e.equation).join("")}function i1(){const n=cs(se().getChildren()),e=n.find(t=>t.kind==="heading");return{blocks:n,title:e&&e.kind==="heading"?dm(e.inlines):null}}function Uu(n){return n.getEditorState().read(i1)}const fi=["Helvetica","Helvetica-Bold","Helvetica-Oblique","Helvetica-BoldOblique","Courier","Courier-Bold"],Yf=[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],Xf=[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],a1={"—":[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]},l1={"−":"-","→":"->","←":"<-","⇒":"=>","≤":"<=","≥":">=","≠":"!=","≈":"~","∎":"#","■":"#","□":"[ ]","☐":"[ ]","☑":"[x]","☒":"[x]","✓":"v","✔":"v","▸":">","▾":"v"," ":" "," ":" "," ":" ","":"","\uFEFF":"","":""},Gf={"€":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 c1(n){const e=[];let t="";for(const r of n){const o=l1[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(Gf[i]!==void 0)e.push(Gf[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 u1(n){return n==="Helvetica-Bold"||n==="Helvetica-BoldOblique"}function d1(n,e){if(e==="Courier"||e==="Courier-Bold")return 600;const t=u1(e),r=n.codePointAt(0)??32;if(r>=32&&r<=126)return(t?Xf:Yf)[r-32];const o=a1[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?Xf:Yf)[i-32]:t?611:556}function cr(n,e,t){let r=0;for(const o of n)r+=d1(o,e);return r*t/1e3}function Zf(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 Rs={a4:{width:595.28,height:841.89},letter:{width:612,height:792}};function gi(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 fm(n){let e="";for(const t of n)e+=t.toString(16).padStart(2,"0");return e}function rs(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`<${fm(e)}>`}function f1(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 g1{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}=c1(r);a.length!==0&&this.ops.push(`BT ${gi(i)} rg /${this.fontName(o)} ${Fe(s)} Tf 1 0 0 1 ${Fe(e)} ${Fe(this.height-t)} Tm <${fm(a)}> Tj ET`)}rect(e,t,r,o,s){const i=["q"];s.fill&&i.push(`${gi(s.fill)} rg`),s.stroke&&i.push(`${gi(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 ${gi(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 gm{options;pages=[];size;images=[];fonts=new Map;constructor(e={}){this.options=e,this.size=e.size??Rs.a4,fi.forEach((t,r)=>this.fonts.set(t,`F${r+1}`))}addPage(){const e=new g1(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=C=>{const v=typeof C=="string"?p1(C):C;t.push(v),r+=v.length},s=[],i=(C,v)=>{s[C]=r,o(`${C} 0 obj
|
|
93
93
|
`),typeof v=="string"?o(v):v.forEach(o),o(`
|
|
94
94
|
endobj
|
|
@@ -211,7 +211,7 @@ ${n.stack}`:r}function Mk(){let n,e;try{const o=p.__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 hc(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 x.jsx(IN,{completionText:this.__completionText})}isInline(){return!0}isKeyboardSelectable(){return!1}}function hc(n){return new Xs(n)}function ds(n){return n instanceof Xs}function IN({completionText:n}){return x.jsx("span",{className:"inline-completion-text",style:{opacity:.5,color:"var(--vscode-editorSuggestWidget-foreground, #999)",pointerEvents:"none",userSelect:"none",whiteSpace:"pre"},children:n})}const EN=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,NN=/(([^<>()[\]\\.,;:\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,}))/,LN=[n=>{const e=EN.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=NN.exec(n);return e?{index:e.index,length:e[0].length,text:e[0],url:`mailto:${e[0]}`}:null}],ON=pe({name:"@datalayer/jupyter-lexical/AutoLink",dependencies:[ln(mC,{matchers:LN})]});function Bm(n){const e=n.anchor,t=n.focus,r=n.anchor.getNode(),o=n.focus.getNode();return r===o?r:n.isBackward()?jd(t)?r:o:jd(e)?o:r}const RN=new Set(["http:","https:","mailto:","sms:","tel:"]);function AN(n){try{const e=new URL(n);if(!RN.has(e.protocol))return"about:blank"}catch{return n}return n}const MN=new RegExp(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/);function qM(n){return n==="https://"||MN.test(n)}function Um(n,e,t){const r=S.useRef(null);return r.current=n,S.useMemo(()=>Lx((...o)=>{r.current&&r.current(...o)},e,{maxWait:t}),[e,t])}function pl(n){return n instanceof HTMLElement}class zm{_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 $N(n){return n instanceof zm}class pr{_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($N(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,g=r<=a?r:a;return u-d<=o+l&&f-g<=s+c}generateNewRect({left:e=this.left,top:t=this.top,right:r=this.right,bottom:o=this.bottom}){return new pr(e,t,r,o)}static fromLTRB(e,t,r,o){return new pr(e,t,r,o)}static fromLWTH(e,t,r,o){return new pr(e,r,e+t,r+o)}static fromPoints(e,t){const{y:r,x:o}=e,{y:s,x:i}=t;return pr.fromLTRB(o,r,i,s)}static fromDOM(e){const{top:t,width:r,left:o,height:s}=e.getBoundingClientRect();return pr.fromLWTH(o,r,t,s)}}const Gi=new Map,$s=new Map,_c=new Set;function Ii(n,e){e?Gi.set(n,e):Gi.delete(n),_c.forEach(t=>t())}function DN(n){return _c.add(n),()=>_c.delete(n)}function PN(n){return Gi.get(n)}function jN(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`video-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function FN(){return typeof MediaRecorder<"u"&&typeof navigator<"u"&&!!navigator.mediaDevices}function BN(){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 UN(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 zN(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 KN(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 WN(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 b=await i.getUserMedia({audio:!0}).catch(()=>{});b&&(o.push(b),l.push(...b.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=KN(l),u=new MediaStream(c.track?[a,c.track]:[a]),f=BN(),d=new MediaRecorder(u,f?{mimeType:f}:void 0),g=[],h=Date.now();d.ondataavailable=m=>{m.data.size>0&&g.push(m.data)};const _=()=>{s(),c.close()};d.onstop=()=>{_(),$s.delete(n);const m=d.mimeType||f||"video/webm",b=new Blob(g,{type:m}),w={status:"recorded",url:URL.createObjectURL(b),blob:b,mimeType:m,durationMs:Date.now()-h};Ii(n,w),r?.(w)},a.addEventListener("ended",()=>Vu(n)),$s.set(n,{recorder:d,release:_}),d.start(1e3),Ii(n,{status:"recording",startedAt:h,preview:new MediaStream([a])})}catch(i){s(),Ii(n,{status:"failed",message:zN(i)})}}function Vu(n){const e=$s.get(n);e&&e.recorder.state!=="inactive"&&e.recorder.stop()}function HN(n){const e=$s.get(n);e&&(e.recorder.onstop=null,e.recorder.state!=="inactive"&&e.recorder.stop(),e.release(),$s.delete(n));const t=Gi.get(n);t?.status==="recorded"&&URL.revokeObjectURL(t.url),Ii(n,void 0)}function JN(n,e){return e?e.status:n?"lost":"idle"}const Yu=j_?S.useLayoutEffect:S.useEffect;function qN({editor:n,getCodeDOMNode:e}){const[t,r]=S.useState(!1),o=Um(()=>{r(!1)},1e3);async function s(){const i=e();if(!i)return;let a="";n.update(()=>{const l=Ae(i);je(l)&&(a=l.getTextContent());const c=D();Ee(c)});try{await navigator.clipboard.writeText(a),r(!0),o()}catch(l){console.error("Failed to copy: ",l)}}return x.jsx(Ft,{icon:t?xh:pw,size:"small",variant:"invisible",onClick:s,"aria-label":"copy",sx:t?{color:"var(--fgColor-success)"}:void 0})}const VN=8;function YN({anchorElem:n}){const[e]=fe(),[t,r]=S.useState(""),[o,s]=S.useState(!1),[i,a]=S.useState(!1),[l,c]=S.useState({right:"0",top:"0"}),u=S.useRef(new Set),f=S.useRef(null);function d(){return f.current}const g=Um(m=>{const{codeDOMNode:b,isOutside:w}=XN(m);if(w){s(!1);return}if(!b)return;f.current=b;let C=null,v="";if(e.update(()=>{const k=Ae(b);je(k)&&(C=k,v=C.getLanguage()||"")}),C){const{y:k,right:I}=n.getBoundingClientRect(),{y:E,right:N}=b.getBoundingClientRect();r(v),s(!0),c({right:`${I-N+VN}px`,top:`${E-k}px`})}},50,1e3);S.useEffect(()=>{if(i)return document.addEventListener("mousemove",g),()=>{s(!1),g.cancel(),document.removeEventListener("mousemove",g)}},[i,g]),S.useEffect(()=>e.registerMutationListener(dn,m=>{e.getEditorState().read(()=>{for(const[b,w]of m)switch(w){case"created":u.current.add(b);break;case"destroyed":u.current.delete(b);break}}),a(u.current.size>0)},{skipInitialization:!1}),[e]);const h=C0(t),_=x0(t);return x.jsx(x.Fragment,{children:o?x.jsxs("div",{className:"code-action-menu-container",style:{...l},children:[x.jsx(Le,{sx:{fontSize:0,color:"var(--fgColor-muted)",alignSelf:"center",px:1},children:_}),x.jsx(qN,{editor:e,getCodeDOMNode:d}),E0(h)?x.jsx(L0,{editor:e,getCodeDOMNode:d,lang:h}):null]}):null})}function XN(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 VM({anchorElem:n=document.body}){return St.createPortal(x.jsx(YN,{anchorElem:n}),n)}function Og(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 Km(n){const e=[];if(n instanceof dn&&e.push(n),q(n))for(const t of n.getChildren())q(t)&&e.push(...Km(t));return e}function GN(n){const e=de(S0(n),n.registerNodeTransform(dn,t=>{Og(t,n)}));return n.getEditorState().read(()=>{for(const t of Km(se()))Og(t,n)}),e}const ZN=pe({name:"@datalayer/jupyter-lexical/CodeBlockHighlight",dependencies:[Vh],register:GN}),Xu=he("INSERT_COLLAPSIBLE_COMMAND"),Rg=()=>{const n=D();if(F(n)&&n.isCollapsed()&&n.anchor.offset===0){const e=re(n.anchor.getNode(),Pt);if(Pt(e)){const t=e.getParent();t!==null&&t.getFirstChild()===e&&n.anchor.key===e.getFirstDescendant()?.getKey()&&e.insertBefore(ne())}}return!1},Ag=()=>{const n=D();if(F(n)&&n.isCollapsed()){const e=re(n.anchor.getNode(),Pt);if(Pt(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 QN(n){if(!n.hasNodes([Mr,Os,$r]))throw new Error("CollapsiblePlugin: CollapsibleContainerNode, CollapsibleTitleNode, or CollapsibleContentNode not registered on editor");return de(n.registerNodeTransform($r,e=>{const t=e.getParent();if(!Pt(t)){const r=e.getChildren();for(const o of r)e.insertBefore(o);e.remove()}}),n.registerNodeTransform(Os,e=>{const t=e.getParent();if(!Pt(t)){e.replace(ne().append(...e.getChildren()));return}}),n.registerNodeTransform(Mr,e=>{const t=e.getChildren();if(t.length!==2||!xi(t[0])||!Lu(t[1])){for(const r of t)e.insertBefore(r);e.remove()}}),n.registerCommand(Vt,Ag,ee),n.registerCommand(ia,Ag,ee),n.registerCommand(pt,Rg,ee),n.registerCommand(zs,Rg,ee),n.registerCommand(Lo,()=>{const e=D();if(F(e)){const t=re(e.anchor.getNode(),r=>xi(r));if(xi(t)){const r=t.getParent();if(r&&Pt(r))return r.getOpen()||r.toggleOpen(),t.getNextSibling()?.selectEnd(),!0}}return!1},ee),n.registerCommand(Xu,()=>(n.update(()=>{const e=Z_(),t=ne();sr(Eu(!0).append(e.append(t),Nu().append(ne()))),t.select()}),!0),ee))}const e2=pe({name:"@datalayer/jupyter-lexical/Collapsible",nodes:()=>[Mr,Os,$r],register:QN}),t2=qn?S.useLayoutEffect:S.useEffect;class Wm{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 Mg=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 $g(n,e){const t=n.getBoundingClientRect(),r=e.getBoundingClientRect();return t.top>=r.top-6&&t.top<=r.bottom+6}function n2(n,e,t,r){const[o]=fe();S.useEffect(()=>{if(e!=null&&n!=null){const s=o.getRootElement(),i=s!=null?bh(s,!1):document.body;let a=!1,l=$g(e,i);const c=function(){a||(window.requestAnimationFrame(function(){t(),a=!1}),a=!0);const d=$g(e,i);d!==l&&(l=d,r?.(d))},u=new ResizeObserver(t),f=yh(s??e);return u.observe(e),de(Jt(window,"resize",t),Jt(document,"scroll",c,{capture:!0,passive:!0}),...f.map(d=>Jt(d,"scroll",c,{capture:!0,passive:!0})),()=>u.unobserve(e))}},[e,o,r,t,n])}const Dg=he("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function r2({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){let s="item";return e&&(s+=" selected"),x.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,x.jsx("span",{className:"text",children:o.title})]},o.key)}function o2({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]=S.useState(null),d=u!==null?Math.min(o.length-1,u):null,g=r.match&&r.match.matchingString;S.useEffect(()=>{c&&f(0)},[g,c]);const h=S.useCallback(w=>{e.update(()=>{const C=r.match!=null&&a?(function(v){const k=D();if(!F(k)||!k.isCollapsed())return null;const I=k.anchor;if(I.type!=="text")return null;const E=I.getNode();if(!E.isSimpleText())return null;const N=I.offset,O=E.getTextContent().slice(0,N),M=v.replaceableString.length,R=N-(function(L,A,B){let j=B;for(let U=j;U<=A.length;U++)L.slice(-U)===A.substring(0,U)&&(j=U);return j})(O,v.matchingString,M);if(R<0)return null;let $;return R===0?[$]=E.splitText(N):[,$]=E.splitText(R,N),$})(r.match):null;i(w,C,n,r.match?r.match.matchingString:"")})},[e,a,r.match,i,n]),_=S.useCallback(w=>{const C=e.getRootElement();C!==null&&(C.setAttribute("aria-activedescendant","typeahead-item-"+w),f(w))},[e]),m=S.useCallback(()=>t.current&&o.length?wh.createPortal(x.jsx("div",{className:"typeahead-popover mentions-menu",children:x.jsx("ul",{children:o.map((w,C)=>x.jsx(r2,{index:C,isSelected:d===C,onClick:()=>{f(C),h(w)},onMouseEnter:()=>{f(C)},option:w},w.key))})}),t.current):null,[t,o,d,h,f]);S.useEffect(()=>()=>{const w=e.getRootElement();w!==null&&w.removeAttribute("aria-activedescendant")},[e]),t2(()=>{o===null?f(null):d===null&&c&&_(0)},[o,d,_,c]),S.useEffect(()=>de(e.registerCommand(Dg,({option:w})=>!(!w.ref||w.ref.current==null)&&(Mg(w.ref.current),!0),l)),[e,_,l]),S.useEffect(()=>de(e.registerCommand(Vt,w=>{const C=w;if(o!==null&&o.length){const v=d===null?0:d!==o.length-1?d+1:0;_(v);const k=o[v];if(!k)return _(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;k.ref&&k.ref.current&&e.dispatchCommand(Dg,{index:v,option:k}),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),e.registerCommand(pt,w=>{const C=w;if(o!==null&&o.length){const v=d===null?o.length-1:d!==0?d-1:o.length-1;_(v);const k=o[v];if(!k)return _(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;k.ref&&k.ref.current&&Mg(k.ref.current),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),e.registerCommand(Nn,w=>{const C=w;return C.preventDefault(),C.stopImmediatePropagation(),n(),!0},l),e.registerCommand(Kr,w=>{const C=w;return o!==null&&d!==null&&o[d]!=null&&(C.preventDefault(),C.stopImmediatePropagation(),h(o[d]),!0)},l),e.registerCommand(zr,w=>!(o===null||d===null||o[d]==null||w&&w.shiftKey)&&(w!==null&&(w.preventDefault(),w.stopImmediatePropagation()),h(o[d]),!0),l)),[h,n,e,o,d,_,l]);const b=S.useMemo(()=>({options:o,selectOptionAndCleanUp:h,selectedIndex:d,setHighlightedIndex:f}),[h,d,o]);return s!=null?s(t,b,r.match?r.match.matchingString:""):m()}function Pg(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 s2(n,e,t,r,o=!0){const[s]=fe(),i=r??(function(f){if(!qn)return;const d=f.getRootElement();if(d!==null){const g=d.getRootNode();return jc(g)?g:d.ownerDocument.body}return document.body})(s),a=qn?mh(s.getRootElement()).createElement("div"):null,l=S.useRef(a),c=S.useCallback(()=>{if(l.current===null||i===void 0)return;l.current.style.top=l.current.style.bottom;const f=s.getRootElement(),d=l.current,g=d.firstChild;if(f!==null&&n!==null){const{left:h,top:_,width:m,height:b}=n.getRect(),w=l.current.offsetHeight;if(d.style.top=`${_+w+3+(o?window.pageYOffset:0)}px`,d.style.left=`${h+window.pageXOffset}px`,d.style.height=`${b}px`,d.style.width=`${m}px`,g!==null){g.style.top=`${_}`;const C=g.getBoundingClientRect(),v=C.height,k=C.width,I=f.getBoundingClientRect();h+k>I.right&&(d.style.left=`${I.right-k+window.pageXOffset}px`),(_+v>window.innerHeight||_+v>I.bottom)&&_-I.top>v+b&&(d.style.top=`${_-v-b+(o?window.pageYOffset:0)}px`)}d.isConnected||(Pg(d,t),i.append(d)),d.setAttribute("id","typeahead-menu"),f.setAttribute("aria-controls","typeahead-menu")}},[s,n,o,t,i]);S.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=S.useCallback(f=>{n!==null&&(f||e(null))},[n,e]);return n2(n,l.current,c,u),a!=null&&a===l.current&&(Pg(a,t),i?.append(a)),l}const i2=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function Hm(n,{minLength:e=1,maxLength:t=75,punctuation:r=i2,allowWhitespace:o=!1}){return S.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 Jm({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(),[g,h]=S.useState(null),_=s2(g,h,a,c),m=S.useCallback(()=>{if(g===null)return;const w=()=>{h(null)};let C;try{C=o&&o()}finally{C?C.then(w,w):w()}},[o,g]),b=S.useCallback(w=>{h(w),r!=null&&g===null&&r(w)},[r,g]);return S.useEffect(()=>{const w=d.registerUpdateListener(()=>{d.read("latest",()=>{if(!d.isEditable())return void m();if(d.isComposing())return;const C=d._window||window,v=C.document.createRange(),k=D(),I=(function(N){let O=null;return N.read("latest",()=>{const M=D();F(M)&&(O=(function(R){const $=R.anchor;if($.type!=="text")return null;const L=$.getNode();if(!L.isSimpleText())return null;const A=$.offset;return L.getTextContent().slice(0,A)})(M))}),O})(d);if(!F(k)||!k.isCollapsed()||I===null||v===null)return void m();const E=i(I,d);if(e(E?E.matchingString:null),E!==null&&(f||!(function(N,O){return O===0&&N.read("latest",()=>{const M=D();if(F(M)){const R=M.anchor.getNode().getPreviousSibling();return oe(R)&&R.isTextEntity()}return!1})})(d,E.leadOffset))&&(function(O,M,R,$){const L=or(R);if(L===null||!L.isCollapsed)return!1;const A=Pc(L,$),B=A.anchorNode,j=O,U=A.anchorOffset;if(B==null||U==null)return!1;try{M.setStart(B,j),M.setEnd(B,U)}catch{return!1}return!0})(E.leadOffset,v,C,d.getRootElement())!==null)return void S.startTransition(()=>b({getRect:()=>v.getBoundingClientRect(),match:E}));m()})});return()=>{w()}},[d,i,e,g,m,b,f]),S.useEffect(()=>d.registerEditableListener(w=>{w||m()}),[d,m]),g===null||d===null||_.current===null?null:x.jsx(o2,{close:m,resolution:g,editor:d,anchorElementRef:_,options:n,menuRenderFn:s,shouldSplitNodeWithQuery:!0,onSelectOption:t,commandPriority:l,preselectFirstItem:u})}const a2=n=>n.split(/[\s._-]+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join("")||"?";function l2({author:n,size:e}){const t=Jc(n);return n.avatarUrl?x.jsx(ax,{src:n.avatarUrl,size:e,alt:t}):x.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"?x.jsx(hw,{size:Math.round(e*.65)}):a2(t)})}const jr=S.createContext({}),c2=[],u2=250;function qm(n){const{searchPeople:e}=S.useContext(jr),[t,r]=S.useState(null);return S.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:[]})})},u2);return()=>{o=!1,clearTimeout(s)}},[n,e]),t&&t.query===n?t.people:c2}class d2 extends Wm{person;constructor(e){super(e.uid),this.person=e}}function f2({onMention:n}){const[e]=fe(),{searchPeople:t}=S.useContext(jr),[r,o]=S.useState(null),s=qm(r),i=S.useMemo(()=>s.map(c=>new d2(c)),[s]),a=Hm("@",{minLength:1}),l=S.useCallback((c,u,f)=>{e.update(()=>{const d=$e(`@${wo(c.person)} `);u&&u.replace(d),d.select(),f()}),n(c.person)},[e,n]);return t?x.jsx(Jm,{onQueryChange:o,onSelectOption:l,triggerFn:a,options:i,menuRenderFn:(c,{selectedIndex:u,selectOptionAndCleanUp:f,setHighlightedIndex:d})=>c.current&&i.length>0?St.createPortal(x.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((g,h)=>x.jsxs(Y,{as:"li",role:"option","aria-selected":u===h,ref:_=>g.setRefElement(_),onMouseEnter:()=>d(h),onClick:()=>{d(h),f(g)},sx:{px:2,py:1,borderRadius:1,cursor:"pointer",bg:u===h?"actionListItem.default.hoverBg":"transparent"},children:[x.jsx(Le,{children:wo(g.person)}),g.person.handle?x.jsxs(Le,{sx:{color:"var(--fgColor-muted)",ml:1},children:["@",g.person.handle]}):null]},g.key))}),c.current):null}):null}function g2({thread:n}){const{searchPeople:e,assignThread:t}=S.useContext(jr),[r,o]=S.useState(!1),[s,i]=S.useState(""),a=qm(r&&s.trim()?s.trim():null),l=n.assignee??null;if(!t||!e)return l?x.jsxs(Le,{as:"p",sx:{fontSize:0,color:"var(--fgColor-muted)",m:0,mt:1},children:["Assigned to ",wo(l)]}):null;const c=u=>{t(n,u),o(!1),i("")};return x.jsxs(Y,{sx:{mt:1},onClick:u=>u.stopPropagation(),children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:1},children:[x.jsx(Le,{sx:{fontSize:0,color:"var(--fgColor-muted)"},children:l?`Assigned to ${wo(l)}`:"Not assigned"}),x.jsx(Ft,{icon:ex,"aria-label":"Assign thread",variant:"invisible",size:"small",onClick:()=>o(!r)}),l?x.jsx(ft,{variant:"invisible",size:"small",onClick:()=>c(null),children:"Unassign"}):null]}),r?x.jsxs(Y,{sx:{mt:1},children:[x.jsx(vn,{"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)}),x.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0,mt:1},children:a.map(u=>x.jsx(Y,{as:"li",children:x.jsx(ft,{variant:"invisible",size:"small",onClick:()=>c(u),children:wo(u)})},u.uid))})]}):null]})}const p2={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"}},h2={...p2,paragraph:"CommentEditorTheme__paragraph"},ys=he();function _2({anchorKey:n,editor:e,onAddComment:t}){const r=S.useRef(null),o=S.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 S.useEffect(()=>(window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o)}),[e,o]),Yu(()=>{o()},[n,e,o]),x.jsx(Y,{ref:r,sx:{position:"absolute",zIndex:10},children:x.jsx(Ft,{icon:Pi,"aria-label":"Add comment",variant:"invisible",size:"small",onClick:t})})}const Vm=pe({name:"@datalayer/jupyter-lexical/CommentComposer",namespace:"Commenting",theme:h2,dependencies:[Cw,Sh,Sw]}),m2=pe({name:"@datalayer/jupyter-lexical/CommentComposer/Focused",dependencies:[Vm,vw]});function b2({editorRef:n}){const[e]=fe();return Yu(()=>(n.current=e,()=>{n.current=null}),[e,n]),null}function y2({onEscape:n}){const[e]=fe();return S.useEffect(()=>e.registerCommand(Nn,t=>n(t),2),[e,n]),null}function Ym({style:n,autoFocus:e,onEscape:t,onChange:r,onMention:o,editorRef:s,placeholder:i="Type a comment..."}){const a=e===!1?Vm:m2;return x.jsx(ww,{extension:a,contentEditable:null,children:x.jsxs(Y,{sx:{position:"relative",m:"10px",borderRadius:2},children:[x.jsx(Ap,{className:"ContentEditable__root",style:n,placeholder:x.jsx(Bh,{children:i}),"aria-placeholder":i}),x.jsx(xw,{onChange:r}),x.jsx(y2,{onEscape:t}),o!==void 0&&x.jsx(f2,{onMention:o}),s!==void 0&&x.jsx(b2,{editorRef:s})]})})}function Xm(n,e){return S.useCallback((t,r)=>{t.read(()=>{n(bw()),e(!yw(r.isComposing(),!0))})},[e,n])}const jg=256;function w2({editor:n,cancelAddComment:e,submitAddComment:t}){const[r,o]=S.useState(""),[s,i]=S.useState(!1),[a,l]=S.useState(null),c=S.useRef(null),u=S.useMemo(()=>({container:document.createElement("div"),elements:[]}),[]),f=Zm(),d=S.useCallback(()=>{n.getEditorState().read(()=>{const C=D();if(F(C)){const v=C.anchor,k=C.focus,I=fh(n,v.getNode(),v.offset,k.getNode(),k.offset);if(I!==null){const{left:E,bottom:N,width:O}=I.getBoundingClientRect(),M=Ml(n,I);let R=M.length===1?E+O/2-jg/2:E-jg/2;R<10&&(R=10),l({left:R,top:N+20});const $=M.length,{container:L}=u,A=u.elements,B=A.length;for(let j=0;j<$;j++){const U=M[j];let z=A[j];z===void 0&&(z=document.createElement("span"),A[j]=z,L.appendChild(z));const H=`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;`;z.style.cssText=H}for(let j=B-1;j>=$;j--){const U=A[j];L.removeChild(U),A.pop()}}}})},[n,u]);Yu(()=>{c.current=n.getRootElement(),d();const C=u.container,v=document.body;if(v!==null)return v.appendChild(C),()=>{v.removeChild(C)}},[n,u.container,d]),S.useEffect(()=>(window.addEventListener("resize",d),()=>{window.removeEventListener("resize",d)}),[d]);const g=C=>(C.preventDefault(),e(),!0),h=S.useRef(new Map),_=S.useCallback(C=>{h.current.set(C.uid,C)},[]),m=()=>{if(s){let C=n.getEditorState().read(()=>{const v=D();return v!==null?v.getTextContent():""});C.length>100&&(C=C.slice(0,99)+"…"),t(Px(C,[Ph(r,f,void 0,void 0,void 0,$h(r,h.current.values()))]),!0)}},b=Xm(o,i),w=C=>{const v=C.target;v instanceof HTMLElement&&v.closest('[role="listbox"]')||e()};return a===null?null:x.jsxs(kl,{role:"dialog","aria-label":"Add a comment",width:"small",position:"fixed",left:a.left,top:a.top,onEscape:e,onClickOutside:w,returnFocusRef:c,preventFocusOnOpen:!0,children:[x.jsx(Ym,{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:g,onChange:b,onMention:_}),x.jsxs(Y,{sx:{display:"flex",gap:2,justifyContent:"flex-end",mt:2,px:2,pb:2},children:[x.jsx(ft,{onClick:e,variant:"invisible",size:"small",children:"Cancel"}),x.jsx(ft,{onClick:m,disabled:!s,variant:"primary",size:"small",children:"Comment"})]})]})}function x2({submitAddComment:n,thread:e,placeholder:t}){const[r,o]=S.useState(""),[s,i]=S.useState(!1),a=S.useRef(null),l=Zm(),c=S.useRef(new Map),u=S.useCallback(g=>{c.current.set(g.uid,g)},[]),f=Xm(o,i),d=()=>{if(s){n(Ph(r,l,void 0,void 0,void 0,$h(r,c.current.values())),!1,e),c.current.clear();const g=a.current;g!==null&&g.dispatchCommand(Tw,void 0)}};return x.jsxs(x.Fragment,{children:[x.jsx(Ym,{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}),x.jsx(Ft,{icon:kw,"aria-label":"Send comment",variant:"invisible",size:"small",onClick:d,disabled:!s})]})}function Gm({commentOrThread:n,deleteCommentOrThread:e,onClose:t,thread:r=void 0}){return x.jsxs(x.Fragment,{children:["Are you sure you want to delete this ",n.type,"?",x.jsxs(Y,{sx:{display:"flex",gap:2,justifyContent:"flex-end",mt:3},children:[x.jsx(ft,{variant:"invisible",onClick:()=>{t()},children:"Cancel"}),x.jsx(ft,{variant:"danger",onClick:()=>{e(n,r),t()},children:"Delete"})]})]})}function C2(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 Fg({comment:n,deleteComment:e,thread:t,rtf:r}){const[o,s]=Xo(),{Avatar:i=l2}=S.useContext(jr),a=Dx(n);return x.jsxs(Y,{as:"li",sx:{p:2,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)"},children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[x.jsx(i,{author:a,size:20}),x.jsx(Le,{sx:{fontWeight:"bold",fontSize:1},children:Jc(a)}),a.agentUid&&x.jsx(Le,{sx:{color:"var(--fgColor-muted)",fontSize:0},children:"· with an agent"}),x.jsxs(Le,{sx:{color:"var(--fgColor-muted)",fontSize:0},children:["· ",C2(r,n.timeStamp)]})]}),x.jsx(Le,{as:"p",sx:{fontSize:1,m:0,...n.deleted?{color:"var(--fgColor-muted)",fontStyle:"italic"}:{}},children:n.content}),!n.deleted&&x.jsxs(x.Fragment,{children:[x.jsx(Ft,{icon:Ch,"aria-label":"Delete comment",variant:"invisible",size:"small",sx:{color:"var(--fgColor-danger)",mt:1},onClick:()=>{s("Delete Comment",l=>x.jsx(Gm,{commentOrThread:n,deleteCommentOrThread:e,thread:t,onClose:l}))}}),o]})]})}function S2({activeIDs:n,comments:e,deleteCommentOrThread:t,listRef:r,submitAddComment:o,markNodeMap:s,resolveThread:i}){const[a]=fe(),[l,c]=S.useState(0),[u,f]=Xo(),d=S.useMemo(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return S.useEffect(()=>{const g=setTimeout(()=>{c(l+1)},1e4);return()=>{clearTimeout(g)}},[l]),x.jsx(Y,{as:"ul",ref:r,sx:{listStyle:"none",m:0,p:0},children:e.map(g=>{const h=g.id;if(g.type==="thread"){const _=()=>{const m=s.get(h);if(m!==void 0&&(n===null||n.indexOf(h)===-1)){const b=document.activeElement;a.update(()=>{const w=Array.from(m)[0],C=Q(w);Ro(C)&&C.selectStart()},{onUpdate(){b!==null&&b.focus()}})}};return x.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:[x.jsxs(Y,{sx:{display:"flex",alignItems:"flex-start",gap:2},children:[x.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:["> ",x.jsx("span",{children:g.quote})]}),i&&x.jsx(Ft,{icon:xh,"aria-label":"Resolve thread",variant:"invisible",size:"small",onClick:m=>{m.stopPropagation(),i(g)}}),x.jsx(Ft,{icon:Ch,"aria-label":"Delete thread",variant:"invisible",size:"small",sx:{color:"var(--fgColor-danger)"},onClick:()=>{f("Delete Thread",m=>x.jsx(Gm,{commentOrThread:g,deleteCommentOrThread:t,onClose:m}))}}),u]}),x.jsx(g2,{thread:g}),x.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0,mt:2},children:g.comments.map(m=>x.jsx(Fg,{comment:m,deleteComment:t,thread:g,rtf:d},m.id))}),x.jsx(Y,{sx:{mt:2},children:x.jsx(x2,{submitAddComment:o,thread:g,placeholder:"Reply to comment..."})})]},h)}return x.jsx(Fg,{comment:g,deleteComment:t,rtf:d},h)})})}function v2({activeIDs:n,deleteCommentOrThread:e,comments:t,submitAddComment:r,markNodeMap:o,resolveThread:s}){const i=S.useRef(null),a=t.length===0;return x.jsxs(Y,{sx:{bg:"var(--bgColor-default)",borderRadius:2,overflow:"hidden",width:"100%",flex:1,display:"flex",flexDirection:"column"},children:[x.jsx(mw,{as:"h2",sx:{fontSize:2,p:3,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)",m:0},children:"Comments"}),a?x.jsx(Y,{sx:{p:3,color:"var(--fgColor-muted)",textAlign:"center"},children:"No Comments"}):x.jsx(S2,{activeIDs:n,comments:t,deleteCommentOrThread:e,listRef:i,submitAddComment:r,markNodeMap:o,resolveThread:s})]})}function Zm(){const{author:n}=S.useContext(jr),{name:e}=Lm();return n??qc(e)}function YM({providerFactory:n,showFloatingAddButton:e=!0,commentStore:t,author:r,Avatar:o}){const[s]=fe(),{showComments:i,setShowComments:a}=e_(),l=S.useRef(null),c=S.useRef(null),u=S.useMemo(()=>t??new Bx(s),[s,t]),f=Ux(u),d=S.useMemo(()=>new Map,[]),[g,h]=S.useState(),[_,m]=S.useState([]),[b,w]=S.useState(!1),C=S.useCallback(R=>{a(typeof R=="function"?R(i):R)},[a,i]),v=S.useCallback(()=>{s.update(()=>{const R=D();R!==null&&(R.dirty=!0)}),w(!1)},[s]),k=S.useCallback(R=>{const $=d.get(R);$!==void 0&&setTimeout(()=>{s.update(()=>{for(const L of $){const A=Q(L);Ro(A)&&(A.deleteID(R),A.getIDs().length===0&&Ox(A))}})})},[s,d]),I=S.useCallback((R,$)=>{R.type==="comment"?u.deleteComment(R,$):(u.deleteThread(R),k($!==void 0?$.id:R.id))},[u,k]),E=S.useMemo(()=>{if(u.resolveThread)return R=>{u.resolveThread?.(R),k(R.id)}},[u,k]),N=S.useCallback((R,$,L)=>{u.addComment(R,L),$&&(s.update(()=>{const A=D();if(F(A)){const B=A.focus,j=A.anchor,U=A.isBackward(),z=R.id;Rx(A,U,z),U?B.set(j.key,j.offset,j.type):j.set(B.key,B.offset,B.type)}}),w(!1))},[u,s]);S.useEffect(()=>{const R=[];for(let $=0;$<_.length;$++){const L=_[$],A=d.get(L);if(A!==void 0)for(const B of A){const j=s.getElementByKey(B);j!==null&&(j.classList.add("selected"),R.push(j),a(!0))}}return()=>{for(let $=0;$<R.length;$++)R[$].classList.remove("selected")}},[_,s,d]),S.useEffect(()=>{const R=new Map;return de(_w(s,Ts,$=>Hc($.getIDs()),($,L)=>{$.getIDs().forEach(B=>{L.addID(B)})}),s.registerMutationListener(Ts,$=>{s.getEditorState().read(()=>{for(const[L,A]of $){const B=Q(L);let j=[];A==="destroyed"?j=R.get(L)||[]:Ro(B)&&(j=B.getIDs());for(let U=0;U<j.length;U++){const z=j[U];let K=d.get(z);R.set(L,j),A==="destroyed"?K!==void 0&&(K.delete(L),K.size===0&&d.delete(z)):(K===void 0&&(K=new Set,d.set(z,K)),K.has(L)||K.add(L))}}})}),s.registerUpdateListener(({editorState:$,tags:L})=>{$.read(()=>{const A=D();let B=!1,j=!1;if(F(A)){const U=A.anchor.getNode();if(oe(U)){const z=Ax(U,A.anchor.offset);z!==null&&(m(z),B=!0),A.isCollapsed()||(h(U.getKey()),j=!0)}}B||m(U=>U.length===0?U:[]),j||h(null)}),L.has("collaboration")||w(!1)}),s.registerCommand(ys,()=>{const $=window.getSelection();return $!==null&&$.removeAllRanges(),w(!0),!0},V))},[s,d]);const O=()=>{s.dispatchCommand(ys,void 0)},M=S.useMemo(()=>({searchPeople:u.searchPeople?.bind(u),assignThread:u.assignThread?.bind(u),author:r,Avatar:o}),[u,r,o]);return x.jsxs(jr.Provider,{value:M,children:[b&&x.jsx(jr.Provider,{value:M,children:x.jsx(w2,{editor:s,cancelAddComment:v,submitAddComment:N})}),e&&g!==null&&g!==void 0&&!b&&St.createPortal(x.jsx(_2,{anchorKey:g,editor:s,onAddComment:O}),document.body),x.jsx("button",{ref:l,style:{display:"none"},"aria-hidden":"true"}),x.jsx(vx,{isOpen:i,setIsOpen:C,openButtonRef:l,closeButtonRef:c,direction:"right",width:"350px",content:x.jsx(v2,{comments:f,submitAddComment:N,deleteCommentOrThread:I,activeIDs:_,markNodeMap:d,resolveThread:E})})]})}const Fo=Qe().describe("CSS colour, e.g. '#1e1e1e', '#e03131', 'transparent'"),Qm=Lt({type:wr(["rectangle","ellipse","diamond","text","arrow","line","frame"]).describe("What to draw"),x:Ke().describe("Left edge, in scene coordinates"),y:Ke().describe("Top edge, in scene coordinates"),width:Ke().optional().describe("Width in pixels (shapes only)"),height:Ke().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:Ke().optional().describe("Font size in pixels, e.g. 16, 20, 28"),strokeColor:Fo.optional().describe("Outline colour"),backgroundColor:Fo.optional().describe("Fill colour"),fillStyle:wr(["hachure","cross-hatch","solid"]).optional().describe("How the fill is drawn"),strokeWidth:Ke().optional().describe("Outline thickness, 1 | 2 | 4"),strokeStyle:wr(["solid","dashed","dotted"]).optional().describe("Outline style"),roughness:Ke().optional().describe("0 for architect (clean), 1 for artist, 2 for cartoonist"),opacity:Ke().optional().describe("0-100"),angle:Ke().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:yr(yr(Ke())).optional().describe("For 'arrow' and 'line' without bindings: points relative to x,y, e.g. [[0,0],[120,0]]"),children:yr(Qe()).optional().describe("For 'frame': the ids of the elements it contains"),name:Qe().optional().describe("For 'frame': its name")}),eb=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"),On=Qe().describe("The block_id of the drawing, from excalidrawListDrawings or readAllBlocks"),tb=Lt({afterId:eb,elements:yr(Qm).optional().describe("The drawing itself. Omit to insert an empty canvas for a person to draw on."),width:Ke().optional().describe("Rendered width in pixels. Omit to size to the content."),height:Ke().optional().describe("Rendered height in pixels. Omit to size to the content.")}),nb=Lt({}),rb=Lt({blockId:On,detail:wr(["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.")}),ob=Lt({blockId:On,elements:yr(Qm).describe("The elements to add. Existing elements are left alone.")}),sb=Lt({blockId:On,updates:yr(Lt({id:Qe().describe("The element id, from excalidrawReadScene"),x:Ke().optional(),y:Ke().optional(),width:Ke().optional(),height:Ke().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:Fo.optional(),backgroundColor:Fo.optional(),fillStyle:wr(["hachure","cross-hatch","solid"]).optional(),strokeWidth:Ke().optional(),strokeStyle:wr(["solid","dashed","dotted"]).optional(),opacity:Ke().optional().describe("0-100"),angle:Ke().optional().describe("Rotation in radians")})).describe("One entry per element to change. Fields left out are kept.")}),ib=Lt({blockId:On,elementIds:yr(Qe()).describe("The ids to remove, from excalidrawReadScene")}),ab=Lt({blockId:On,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:Fo.optional(),strokeStyle:wr(["solid","dashed","dotted"]).optional()}),lb=Lt({blockId:On,viewBackgroundColor:Fo.optional().describe("The canvas colour behind the drawing"),gridSize:Ke().optional().describe("Grid spacing in pixels. 0 turns the grid off.")}),cb=Lt({blockId:On,width:Ke().optional().describe("Rendered width in pixels. Omit to go back to sizing by content."),height:Ke().optional().describe("Rendered height in pixels. Omit to go back to sizing by content.")}),ub=Lt({blockId:On}),db=Lt({blockId:On.optional().describe("The drawing to replace. Omit to insert a new drawing instead, positioned by afterId."),afterId:eb.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:Ke().optional().describe("Font size for the generated text, in pixels")}),Qt=n=>`datalayer_${n}`,Qr={requiresConfirmation:!1,canBeReferencedInPrompt:!0,priority:"medium"},en=["lexical","excalidraw","drawing","diagram"],k2={name:Qt("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:Zt(tb),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:[...en,"insert"]},T2={name:Qt("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:Zt(nb),operation:"excalidrawListDrawings",config:{...Qr,invocationMessage:()=>"Looking for drawings"},tags:[...en,"read"]},I2={name:Qt("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:Zt(rb),operation:"excalidrawReadScene",config:{...Qr,invocationMessage:()=>"Reading the drawing"},tags:[...en,"read"]},E2={name:Qt("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:Zt(ob),operation:"excalidrawAddElements",config:{...Qr,invocationMessage:()=>"Adding to the drawing",priority:"high"},tags:[...en,"edit"]},N2={name:Qt("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:Zt(sb),operation:"excalidrawUpdateElements",config:{...Qr,invocationMessage:()=>"Changing the drawing"},tags:[...en,"edit"]},L2={name:Qt("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:Zt(ib),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:[...en,"edit","delete"]},O2={name:Qt("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:Zt(ab),operation:"excalidrawConnectElements",config:{...Qr,invocationMessage:()=>"Connecting two shapes"},tags:[...en,"edit"]},R2={name:Qt("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:Zt(lb),operation:"excalidrawSetAppState",config:{...Qr,invocationMessage:()=>"Setting up the canvas"},tags:[...en,"edit"]},A2={name:Qt("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:Zt(cb),operation:"excalidrawResize",config:{...Qr,invocationMessage:()=>"Resizing the drawing"},tags:[...en,"edit"]},M2={name:Qt("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:Zt(ub),operation:"excalidrawClearScene",config:{confirmationMessage:()=>"Empty this drawing?",invocationMessage:()=>"Emptying the drawing",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"low"},tags:[...en,"edit","delete"]},$2={name:Qt("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:Zt(db),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:[...en,"insert","mermaid"]},fb=[k2,$2,T2,I2,E2,N2,O2,L2,R2,A2,M2],hl=()=>({elements:[],appState:{},files:{}});function Gu(n){if(!n)return hl();let e;try{e=JSON.parse(n)}catch{return hl()}if(Array.isArray(e))return{elements:e,appState:{},files:{}};if(!e||typeof e!="object")return hl();const t=e;return{elements:Array.isArray(t.elements)?t.elements:[],appState:t.appState??{},files:t.files??{}}}function Zu(n){return JSON.stringify({elements:n.elements,appState:n.appState,files:n.files})}const Gs=n=>n.elements.filter(e=>!e?.isDeleted);function D2(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 P2(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=D2(t);if(r.text===void 0){const o=e.get(r.id);o&&(r.text=o)}return r})}function Qu(n){const e=Gs(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 ed(n){return{...n,version:Number(n?.version??1)+1,versionNonce:Math.floor(Math.random()*2**31),updated:Date.now()}}const Zi=4;function gb(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 Rn(n,e){const t=gb(n,e);let r="";return n.getEditorState().read(()=>{r=t.__data??""}),Gu(r)}function eo(n,e,t){const r=Zu(t);return new Promise(o=>{n.update(()=>{const s=Q(e);s?.setData&&s.setData(r)},{onUpdate:()=>o()})})}const hn=(n,e,t)=>({success:!0,blockId:n,elementCount:Gs(e).length,...t});let j2=0;const F2=()=>`dla-${Date.now().toString(36)}-${(j2+=1).toString(36)}`;function B2(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 td(n,e){const{convertToExcalidrawElements:t}=await me(async()=>{const{convertToExcalidrawElements:i}=await import("./percentages-BXMCSKIN-mjCCp4uI.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=F2()),e.add(a),r.push(a),B2(i,a)});return{elements:[...t(o,{regenerateIds:!1})],ids:r}}const mc=n=>({x:Number(n.x??0)+Number(n.width??0)/2,y:Number(n.y??0)+Number(n.height??0)/2});function Bg(n,e){const t=mc(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+Zi,i=Number(n.height??0)/2+Zi,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 U2(n,e){const t=Array.isArray(n.boundElements)?[...n.boundElements]:[];return t.some(r=>r?.id===e)||t.push({id:e,type:"arrow"}),ed({...n,boundElements:t})}function pb(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=Bg(o,mc(s)),a=Bg(s,mc(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:Zi},endBinding:{elementId:r,focus:0,gap:Zi}};return n.elements=n.elements.map(c=>c.id===t||c.id===r?U2(c,String(e.id)):c),l}const z2=async(n,e)=>{const t=e.elements??[],r=t.length>0?await td(t,new Set):{elements:[],ids:[]},o={elements:r.elements,appState:{},files:{}},s=await n.insertBlock({block_id:"",block_type:"excalidraw",source:"",metadata:{data:Zu(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 hn(s.blockId,o,{createdIds:r.ids,message:`Drawing inserted with ${r.elements.length} element(s)`})},K2=async n=>{const t=(await n.getBlocks("detailed")).filter(r=>r.block_type==="excalidraw").map(r=>{const o=Gu(r.metadata?.data);return{blockId:r.block_id,elementCount:Gs(o).length,description:Qu(o),width:r.metadata?.width,height:r.metadata?.height}});return{drawings:t,count:t.length}},W2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=Gs(r);return{blockId:t,elementCount:o.length,elements:e.detail==="full"?o:P2(o),appState:r.appState,description:Qu(r)}},H2=async(n,e)=>{const t=String(e.blockId),r=Rn(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:g}=u;if((u.type==="arrow"||u.type==="line")&&d&&g&&(!i.has(String(d))||!i.has(String(g)))){a.set(f,{fromId:String(d),toId:String(g)});const{startId:_,endId:m,...b}=u;return b}return u}),c=await td(l,o);r.elements=[...r.elements,...c.elements];for(const[u,f]of a){const d=c.ids[u],g=r.elements.find(h=>h.id===d);if(g){const h=pb(r,g,f.fromId,f.toId);r.elements=r.elements.map(_=>_.id===d?h:_)}}return await eo(n.editor,t,r),hn(t,r,{createdIds:c.ids,message:`Added ${c.elements.length} element(s)`})},J2=async(n,e)=>{const t=String(e.blockId),r=Rn(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,...g}=l,h=u.type!=="text"&&s.get(c);d!==void 0&&(h?i.set(h,{...i.get(h)??{},text:d,originalText:d}):(g.text=d,g.originalText=d)),Object.keys(g).length>0&&i.set(c,{...i.get(c)??{},...g})}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?ed({...l,...c}):l}),await eo(n.editor,t,r),hn(t,r,{message:`Updated ${o.length} element(s)`})},q2=async(n,e)=>{const t=String(e.blockId),r=Rn(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?ed({...a,...l}):a}),await eo(n.editor,t,r),hn(t,r,{message:`Removed ${i-r.elements.length} element(s)`})},V2=async(n,e)=>{const t=String(e.blockId),r=Rn(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 td([{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=pb(r,u,o,s);return r.elements=r.elements.map(d=>d.id===c?f:d),await eo(n.editor,t,r),hn(t,r,{createdIds:[c],message:`Connected '${o}' to '${s}'`})},Y2=async(n,e)=>{const t=String(e.blockId),r=Rn(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 eo(n.editor,t,r),hn(t,r,{message:"Canvas updated"})},X2=async(n,e)=>{const t=String(e.blockId),r=gb(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=Rn(n.editor,t);return hn(t,i,{message:o==="inherit"&&s==="inherit"?"Drawing sized to its content":`Drawing sized to ${o} x ${s}`})},G2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=Gs(r).length;return r.elements=[],r.files={},await eo(n.editor,t,r),hn(t,r,{message:`Emptied the drawing (${o} element(s) removed)`})},Z2=async(n,e)=>{const{parseMermaidToExcalidraw:t}=await me(async()=>{const{parseMermaidToExcalidraw:c}=await import("./index-B063q-PC.js").then(u=>u.an);return{parseMermaidToExcalidraw:c}},[],import.meta.url),{convertToExcalidrawElements:r}=await me(async()=>{const{convertToExcalidrawElements:c}=await import("./percentages-BXMCSKIN-mjCCp4uI.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=Rn(n.editor,c);return u.elements=s,u.files=i,await eo(n.editor,c,u),hn(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:Zu(a)}},String(e.afterId??"BOTTOM"));if(!l.success||!l.blockId)throw new Error(l.error||"Failed to insert the drawing");return hn(l.blockId,a,{createdIds:s.map(c=>String(c.id)),message:`Drawing inserted with ${s.length} element(s) from Mermaid`})},bc={excalidrawInsertNode:z2,excalidrawListDrawings:K2,excalidrawReadScene:W2,excalidrawAddElements:H2,excalidrawUpdateElements:J2,excalidrawDeleteElements:q2,excalidrawConnectElements:V2,excalidrawSetAppState:Y2,excalidrawResize:X2,excalidrawClearScene:G2,excalidrawFromMermaid:Z2};function tn(n,e){return{name:n,async execute(t,r){const o=Iw(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 Q2=tn("excalidrawInsertNode",tb),eL=tn("excalidrawListDrawings",nb),tL=tn("excalidrawReadScene",rb),nL=tn("excalidrawAddElements",ob),rL=tn("excalidrawUpdateElements",sb),oL=tn("excalidrawDeleteElements",ib),sL=tn("excalidrawConnectElements",ab),iL=tn("excalidrawSetAppState",lb),aL=tn("excalidrawResize",cb),lL=tn("excalidrawClearScene",ub),cL=tn("excalidrawFromMermaid",db),Ei={excalidrawInsertNode:Q2,excalidrawListDrawings:eL,excalidrawReadScene:tL,excalidrawAddElements:nL,excalidrawUpdateElements:rL,excalidrawDeleteElements:oL,excalidrawConnectElements:sL,excalidrawSetAppState:iL,excalidrawResize:aL,excalidrawClearScene:lL,excalidrawFromMermaid:cL},Ug={name:"excalidraw",definitions:fb,operations:Ei,handlers:bc};function XM(){const n=[];for(const e of fb)Ei[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(Ei))bc[e]||n.push(`operation '${e}' has no handler`);for(const e of Object.keys(bc))Ei[e]||n.push(`handler '${e}' has no operation`);return n}const uL=S.lazy(()=>me(()=>import("./ExcalidrawModal-9ZnOB03n.js"),[],import.meta.url)),nd=he();function dL(){const[n]=fe(),[e,t]=S.useState(!1),o=M0()?.lexicalId;S.useEffect(()=>{if(!n.hasNodes([Yn]))throw new Error("ExcalidrawPlugin: ExcalidrawNode not registered");return n.registerCommand(nd,()=>(t(!0),!0),V)},[n]),S.useEffect(()=>{if(o)return go.getState().registerPluginTools(o,Ug),()=>{go.getState().unregisterPluginTools(o,Ug.name)}},[o]);const s=(l,c,u)=>{n.update(()=>{const f=ju();f.setData(JSON.stringify({elements:l,appState:c,files:u})),Tr([f]),wt(f.getParentOrThrow())&&Fc(f,ne).selectEnd()}),t(!1)},i=()=>{t(!1)},a=()=>{t(!1)};return e?x.jsx(S.Suspense,{fallback:null,children:x.jsx(uL,{initialElements:[],initialAppState:{},initialFiles:{},isShown:e,onSave:s,onDelete:i,onClose:a,closeOnClickOutside:!1})}):null}const fL=S.lazy(()=>me(()=>import("./DeckComponent-82GVdsoi.js"),[],import.meta.url));function gL(){return{deck:{title:"Untitled deck",template:"datalayer"},slides:[{type:"title",title:"A new slide",meta:"Double-click to edit its specification"}]}}function pL(n){const e=n.getAttribute("data-lexical-deck");if(!e)return null;try{return{node:rd(JSON.parse(e))}}catch{return null}}class Go extends Jo{__spec;static getType(){return"deck"}static clone(e){return new Go(e.__spec,e.__format,e.__key)}static importJSON(e){const t=rd(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:pL,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??gL()}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 x.jsx(S.Suspense,{fallback:null,children:x.jsx(fL,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),spec:this.__spec})})}isTopLevel(){return!0}}function rd(n){return new Go(n)}function GM(n){return n instanceof Go}const od=he("INSERT_DECK_COMMAND");function hL(n){if(!n.hasNodes([Go]))throw new Error("DeckExtension: DeckNode not registered on editor");return n.registerCommand(od,e=>(sr(rd(e)),!0),V)}const _L=pe({name:"@datalayer/jupyter-lexical/Deck",nodes:()=>[Go],register:hL}),zg="Kept in this page’s memory only: it is lost when the page reloads, and nobody else sees it. Download it to keep it.",hb={position:"relative",width:"100%",aspectRatio:"16 / 9",borderRadius:2,overflow:"hidden",bg:"black"};function mL(n){const e=Math.max(0,Math.floor(n/1e3));return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}function bL(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 yL({recordingId:n,recording:e}){const t=S.useRef(null),[r,o]=S.useState(()=>Date.now());return S.useEffect(()=>{t.current&&(t.current.srcObject=e.preview)},[e.preview]),S.useEffect(()=>{const s=window.setInterval(()=>o(Date.now()),500);return()=>window.clearInterval(s)},[]),x.jsxs(Y,{sx:{display:"grid",gap:2},children:[x.jsx(Y,{sx:hb,children:x.jsx("video",{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"100%",objectFit:"contain"}})}),x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[x.jsx(Y,{"aria-hidden":!0,sx:{width:10,height:10,borderRadius:"50%",bg:"danger.fg"}}),x.jsx(Le,{sx:{fontFamily:"mono"},"aria-live":"off",children:mL(r-e.startedAt)}),x.jsx(ft,{variant:"danger",leadingVisual:Nw,onClick:()=>Vu(n),sx:{ml:"auto"},children:"Stop"})]})]})}function wL({className:n,format:e,nodeKey:t,recordingId:r,recorded:o}){const[s]=fe(),i=Hr(),a=S.useSyncExternalStore(DN,()=>PN(r)),l=JN(o,a),[c,u]=S.useState("screen"),[f,d]=S.useState(!0),g=S.useCallback(w=>{s.update(()=>{const C=Q(t);_b(C)&&C.setRecorded(w)})},[s,t]),h=()=>{WN(r,{source:c,microphone:f},()=>g(!0))},_=()=>{HN(r),g(!1)},m=w=>{const C=document.createElement("a");C.href=w.url,C.download=UN(w),C.click()};let b;return a?.status==="recording"?b=x.jsx(yL,{recordingId:r,recording:a}):a?.status==="recorded"?b=x.jsxs(Y,{sx:{display:"grid",gap:2},children:[x.jsx(Y,{sx:hb,children:x.jsx("video",{src:a.url,controls:!0,playsInline:!0,onLoadedMetadata:bL,style:{width:"100%",height:"100%",objectFit:"contain"}})}),x.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:2},children:[x.jsx(Le,{sx:{color:"fg.muted",fontSize:0,flex:"1 1 240px"},children:zg}),x.jsx(ft,{leadingVisual:Ew,onClick:()=>m(a),children:"Download"}),i&&x.jsx(ft,{onClick:_,children:"Record again"})]})]}):l==="lost"?b=x.jsxs(Y,{sx:{display:"grid",gap:2,justifyItems:"start"},children:[x.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&&x.jsx(ft,{onClick:()=>g(!1),children:"Record a new one"})]}):i?b=x.jsxs(Y,{sx:{display:"grid",gap:2},children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[x.jsx(Wc,{size:16}),x.jsx(Le,{sx:{fontWeight:"bold"},children:"Video"})]}),x.jsxs(Le,{sx:{color:"fg.muted",fontSize:0},children:["Recorded by this browser, with no account. ",zg]}),FN()?x.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:3},children:[x.jsxs(Aa,{"aria-label":"What to record",size:"small",children:[x.jsx(Aa.Button,{selected:c==="screen",onClick:()=>u("screen"),children:"Screen"}),x.jsx(Aa.Button,{selected:c==="camera",onClick:()=>u("camera"),children:"Camera"})]}),x.jsxs(Mt,{children:[x.jsx(Mp,{checked:f,onChange:w=>d(w.target.checked)}),x.jsx(Mt.Label,{children:"Microphone"})]}),x.jsx(ft,{variant:"primary",onClick:h,children:"Record"})]}):x.jsx(Le,{sx:{color:"danger.fg",fontSize:1},children:"This browser cannot record video."}),a?.status==="failed"&&x.jsx(Le,{role:"alert",sx:{color:"danger.fg",fontSize:1},children:a.message})]}):b=x.jsx(Le,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:"A video goes here."}),x.jsx(Ls,{className:n,format:e,nodeKey:t,children:x.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:b})})}class Zn extends Jo{__recordingId;__recorded;static getType(){return"video"}static clone(e){return new Zn(e.__recordingId,e.__recorded,e.__format,e.__key)}static importJSON(e){const t=new Zn(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||jN(),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 x.jsx(wL,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),recordingId:this.__recordingId,recorded:this.__recorded})}isTopLevel(){return!0}}function xL(){return new Zn}function _b(n){return n instanceof Zn}const sd=he("INSERT_VIDEO_COMMAND");function CL(n){if(!n.hasNodes([Zn]))throw new Error("VideoExtension: VideoNode not registered on editor");return de(n.registerCommand(sd,()=>(sr(xL()),!0),V),n.registerMutationListener(Zn,(e,{prevEditorState:t})=>{for(const[r,o]of e){if(o!=="destroyed")continue;const s=t.read(()=>{const i=Q(r);return _b(i)?i.__recordingId:void 0});s&&Vu(s)}},{skipInitialization:!0}))}const SL=pe({name:"@datalayer/jupyter-lexical/Video",nodes:()=>[Zn],register:CL});function vL({onConfirm:n,onClose:e}){const[t,r]=S.useState("5"),[o,s]=S.useState("5"),i=S.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 x.jsx($p,{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:x.jsxs(Y,{sx:{display:"flex",flexDirection:"column",gap:3},onKeyDown:l,children:[x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:"Rows"}),x.jsx(vn,{ref:i,type:"number",min:1,max:500,value:t,onChange:c=>r(c.target.value),block:!0})]}),x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:"Columns"}),x.jsx(vn,{type:"number",min:1,max:50,value:o,onChange:c=>s(c.target.value),block:!0})]})]})})}const ws=he();function mb(){const[n]=fe(),[e,t]=S.useState(!1);S.useEffect(()=>n.registerCommand(ws,()=>(t(!0),!0),V),[n]);const r=(s,i)=>{n.dispatchCommand(nu,{rows:s.toString(),columns:i.toString()}),t(!1)},o=()=>{t(!1)};return e?x.jsx(vL,{onConfirm:r,onClose:o}):null}function ZM(){return x.jsxs(x.Fragment,{children:[x.jsx(P_,{}),x.jsx(mb,{})]})}const id=he("INSERT_EQUATION_COMMAND");function bb(n){if(!n.hasNodes([ir]))throw new Error("EquationsPlugins: EquationsNode not registered on editor");return n.registerCommand(id,e=>{const{equation:t,inline:r}=e,o=ya(t,r);return Tr([o]),wt(o.getParentOrThrow())&&Fc(o,ne).selectEnd(),!0},V)}const yb=pe({name:"@datalayer/jupyter-lexical/Equations",nodes:()=>[ir],register:bb});function ad({activeEditor:n,onClose:e}){const t=S.useCallback((r,o)=>{n.dispatchCommand(id,{equation:r,inline:o}),e()},[n,e]);return x.jsx(Vx,{onConfirm:t})}const Kg=()=>{const[n]=fe();return S.useEffect(()=>bb(n),[n]),null},kL=Object.freeze(Object.defineProperty({__proto__:null,EquationsPlugin:Kg,INSERT_EQUATION_COMMAND:id,InsertEquationDialog:ad,default:Kg},Symbol.toStringTag,{value:"Module"}));class ze extends Wm{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 TL({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){const s=S.useCallback(l=>o.setRefElement(l),[o]),i=o.disabled?void 0:t,a=o.disabled?void 0:r;return x.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:[x.jsx(Y,{sx:{display:"flex",alignItems:"center",color:"var(--fgColor-muted)",flexShrink:0},children:o.icon}),x.jsx(Le,{sx:{fontSize:1},children:o.title})]},o.key)}const IL=({kernel:n,initCode:e=""}={})=>{const[t]=fe(),[r,o]=Xo(),[s,i]=S.useState(null),a=Hm("/",{minLength:0}),l=S.useCallback(()=>{const f=[];if(s==null)return f;const d=new RegExp(/^([1-9]|10)x([1-9]|10)$/),g=new RegExp(/^([1-9]|10)x?$/),h=d.exec(s),_=g.exec(s);if(h){const[m,b]=h[0].split("x").map(w=>parseInt(w,10));f.push(new ze(`${m}x${b} Table`,{icon:x.jsx(yi,{size:16}),keywords:["table"],onSelect:()=>t.dispatchCommand(ws,void 0)}))}else if(_){const m=parseInt(_[0],10);f.push(...Array.from({length:5},(b,w)=>w+1).map(b=>new ze(`${m}x${b} Table`,{icon:x.jsx(yi,{size:16}),keywords:["table"],onSelect:()=>t.dispatchCommand(ws,void 0)})))}return f},[t,s]),c=S.useMemo(()=>{const f=[new ze("Jupyter Cell",{icon:x.jsx(br,{size:16}),keywords:["javascript","python","js","codeblock","jupyter"],onSelect:()=>{t.dispatchCommand(Vi,{code:e,outputs:ac,loading:"Loading..."})}}),new ze("Marimo Cell",{icon:x.jsx(br,{size:16}),keywords:["marimo","reactive","python","cell"],onSelect:()=>{t.dispatchCommand(Vi,{code:e,outputs:ac,loading:"Loading...",variant:"marimo"})}}),new ze("Paragraph",{icon:x.jsx(Ih,{size:16}),keywords:["normal","paragraph","p","text"],onSelect:()=>t.update(()=>{const g=D();F(g)&&Un(g,()=>ne())})}),...Array.from({length:3},(g,h)=>h+1).map(g=>new ze(`Heading ${g}`,{icon:x.jsx(tx,{size:16}),keywords:["heading","header",`h${g}`],onSelect:()=>t.update(()=>{const h=D();F(h)&&Un(h,()=>fn(`h${g}`))})})),new ze("Numbered List",{icon:x.jsx(Eh,{size:16}),keywords:["numbered list","ordered list","ol"],onSelect:()=>t.dispatchCommand(eu,void 0)}),new ze("Bulleted List",{icon:x.jsx(vh,{size:16}),keywords:["bulleted list","unordered list","ul"],onSelect:()=>t.dispatchCommand(Qc,void 0)}),new ze("Check List",{icon:x.jsx(Lw,{size:16}),keywords:["check list","todo list"],onSelect:()=>t.dispatchCommand(Zc,void 0)}),new ze("Table",{icon:x.jsx(yi,{size:16}),keywords:["table","grid","spreadsheet"],onSelect:()=>{ge("[ComponentPicker] Table selected, dispatching INSERT_TABLE_WITH_DIALOG_COMMAND"),t.dispatchCommand(ws,void 0)}}),new ze("Collapsible Container",{icon:x.jsx(zc,{size:16}),keywords:["collapsible","collapse","expand","toggle","accordion","container"],onSelect:()=>t.dispatchCommand(Xu,void 0)}),new ze("Excalidraw",{icon:x.jsx(Ow,{size:16}),keywords:["excalidraw","drawing","diagram","sketch","whiteboard","draw"],onSelect:()=>t.dispatchCommand(nd,void 0)}),new ze("Video",{icon:x.jsx(Wc,{size:16}),keywords:["video","record","recording","screen","camera","webcam"],onSelect:()=>t.dispatchCommand(sd,void 0)}),new ze("Loom Video",{icon:x.jsx(Ws,{size:16}),keywords:["loom","video","record","recording","screen"],onSelect:()=>t.dispatchCommand(ka,void 0)}),new ze("Deck Slide",{icon:x.jsx(hs,{size:16}),keywords:["deck","slide","slides","presentation","pitch"],onSelect:()=>t.dispatchCommand(od,void 0)}),new ze("Quote",{icon:x.jsx(Nh,{size:16}),keywords:["block quote"],onSelect:()=>t.update(()=>{const g=D();F(g)&&Un(g,()=>Ln())})}),new ze("Code",{icon:x.jsx(br,{size:16}),keywords:["javascript","python","js","codeblock"],onSelect:()=>t.update(()=>{const g=D();if(F(g))if(g.isCollapsed())Un(g,()=>Ze());else{const h=g.getTextContent(),_=Ze();g.insertNodes([_]),g.insertRawText(h)}})}),new ze("Divider",{icon:x.jsx(ji,{size:16}),keywords:["horizontal rule","divider","hr"],onSelect:()=>t.dispatchCommand(Kc,void 0)}),...qu.map(g=>new ze(`Embed ${g.contentName}`,{icon:g.icon,keywords:[...g.keywords,"embed"],onSelect:()=>t.dispatchCommand(Ju,g.type)})),new ze("Equation",{icon:x.jsx(Rw,{size:16}),keywords:["equation","latex","math"],onSelect:()=>o("Insert Equation",g=>x.jsx(ad,{activeEditor:t,onClose:g}))}),new ze("GIF",{icon:x.jsx(hs,{size:16}),keywords:["gif","animate","image","file"],onSelect:()=>{yu().then(g=>{g&&t.dispatchCommand(Ys,g)})}}),new ze("Image",{icon:x.jsx(hs,{size:16}),keywords:["image","photo","picture","file"],onSelect:()=>o("Insert Image",g=>x.jsx(z_,{activeEditor:t,onClose:g}))}),...["left","center","right","justify"].map(g=>new ze(`Align ${g}`,{icon:g==="left"?x.jsx(nx,{size:16}):g==="right"?x.jsx(rx,{size:16}):x.jsx(ji,{size:16}),keywords:["align","justify",g],onSelect:()=>t.dispatchCommand(Bn,g)}))],d=l();return s?[...d,...f.filter(g=>new RegExp(s,"gi").exec(g.title)||g.keywords!=null?g.keywords.some(h=>new RegExp(s,"gi").exec(h)):!1)]:f},[t,l,s,o,n,e]),u=S.useCallback((f,d,g,h)=>{f.disabled||t.update(()=>{d&&d.remove(),f.onSelect(h),g()})},[t]);return x.jsxs(x.Fragment,{children:[r,x.jsx(Jm,{onQueryChange:i,onSelectOption:u,triggerFn:a,options:c,menuRenderFn:(f,{selectedIndex:d,selectOptionAndCleanUp:g,setHighlightedIndex:h})=>f.current&&c.length?St.createPortal(x.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:x.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0},children:c.map((_,m)=>x.jsx(TL,{index:m,isSelected:d===m,onClick:()=>{_.disabled||(h(m),g(_))},onMouseEnter:()=>{_.disabled||h(m)},option:_},_.key))})}),f.current):null})]})},yc=4,EL=2,NL="draggable-block-menu",Wg="application/x-lexical-drag-block",Hg=28,LL=1,OL=-1,Jg=0;let Ni=1/0;function RL(n){return n===0?1/0:Ni>=0&&Ni<n?Ni:Math.floor(n/2)}function AL(n){return n.getEditorState().read(()=>se().getChildrenKeys())}function wb(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 _l(n,e,t,r=!1){const o=n.getBoundingClientRect(),s=AL(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 g=Wn(c),h=Wn(u);if(t.y/g<f.top?i=c:t.y/h>d.bottom&&(i=u),i)return}}let a=RL(s.length),l=Jg;for(;a>=0&&a<s.length;){const c=s[a],u=e.getElementByKey(c);if(u===null)break;const f=Wn(u),d=new zm(t.x/f,t.y/f),g=pr.fromDOM(u),{marginTop:h,marginBottom:_}=wb(u),m=g.generateNewRect({bottom:g.bottom+_,left:o.left,right:o.right,top:g.top-h}),{result:b,reason:{isOnTopSide:w,isOnBottomSide:C}}=m.contains(d);if(b){i=u,Ni=a;break}l===Jg&&(w?l=OL:C?l=LL:l=1/0),a+=l}}),i}function ML(n){return!!n.closest(`.${NL}`)}function xb(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 $L(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}=xb(t),c=(parseInt(o.lineHeight,10)-s.height)/2,u=r.top+c-i.top+a,f=yc;e.style.opacity="1",e.style.transform=`translate(${f}px, ${u}px)`}function DL(n,e){const{transform:t}=e.style;e.style.transform="translateZ(0)",n.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=t})}function PL(n,e,t,r){const{top:o,height:s}=e.getBoundingClientRect(),{top:i,width:a}=r.getBoundingClientRect(),{marginTop:l,marginBottom:c}=wb(e),{scrollTop:u}=xb(r);let f=o;t>=o?f+=s+c/2:f-=l/2;const d=f-i-EL+u,g=Hg-yc;n.style.transform=`translate(${g}px, ${d}px)`,n.style.width=`${a-(Hg-yc)*2}px`,n.style.opacity=".4"}function jL(n){n&&(n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)")}function FL(n,e,t){const r=S.useRef(null),o=S.useRef(null),s=S.useRef(!1),[i,a]=S.useState(null),l=n._config.theme,c=l.draggableBlockMenu||"",u=l.draggableBlockTargetLine||"";S.useEffect(()=>{function g(_){const m=_.target;if(!pl(m)){a(null);return}if(!e.contains(m)||ML(m))return;const b=_l(e,n,_);a(b)}function h(){a(null)}return document.addEventListener("mousemove",g),document.addEventListener("mouseleave",h),()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseleave",h)}},[e,n]),S.useEffect(()=>{r.current&&$L(i,r.current,e)},[e,i]),S.useEffect(()=>{function g(_){if(!s.current)return!1;const[m]=uo(_);if(m)return!1;const{pageY:b,target:w}=_;if(!pl(w))return!1;const C=_l(e,n,_,!0),v=o.current;return C===null||v===null?!1:(PL(v,C,b/Wn(w),e),_.preventDefault(),!0)}function h(_){if(!s.current)return!1;const[m]=uo(_);if(m)return!1;const{target:b,dataTransfer:w,pageY:C}=_,v=w?.getData(Wg)||"",k=Q(v);if(!k||!pl(b))return!1;const I=_l(e,n,_,!0);if(!I)return!1;const E=Ae(I);if(!E)return!1;if(E===k)return!0;const N=I.getBoundingClientRect().top;return C/Wn(b)>=N?E.insertAfter(k):E.insertBefore(k),a(null),!0}return de(n.registerCommand(Nc,_=>g(_),ee),n.registerCommand(Lc,_=>h(_),qe))},[e,n]);function f(g){const h=g.dataTransfer;if(!h||!i)return;DL(h,i);let _="";n.update(()=>{const m=Ae(i);m&&(_=m.getKey())}),s.current=!0,h.setData(Wg,_)}function d(){s.current=!1,jL(o.current)}return St.createPortal(x.jsxs(x.Fragment,{children:[x.jsx("div",{className:`draggable-block-menu ${c}`,ref:r,draggable:!0,onDragStart:f,onDragEnd:d,children:t?x.jsx(Aw,{size:16}):null}),x.jsx("div",{className:`draggable-block-target-line ${u}`,ref:o})]}),e)}function QM({anchorElem:n=document.body}){const[e]=fe();return FL(e,n,e._editable)}const BL=()=>x.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:[x.jsx("path",{d:"M4.5 2v5.5a3.5 3.5 0 1 0 7 0V2H13v5.5a5 5 0 0 1-10 0V2h1.5Z"}),x.jsx("rect",{x:"2",y:"14",width:"12",height:"1.5",rx:".75"})]});function UL(n,e,t,r){const[o,s]=S.useState(!1),[i,a]=S.useState(!1),[l,c]=S.useState(!1),[u,f]=S.useState(!1),[d,g]=S.useState(!1),[h,_]=S.useState(!1),[m,b]=S.useState(!1),[w,C]=S.useState(!1),[v,k]=S.useState(!1),I=S.useCallback(()=>{n.getEditorState().read(()=>{if(n.isComposing())return;const M=D(),R=window.getSelection(),$=n.getRootElement();if(R!==null&&(!F(M)||$===null||!$.contains(R.anchorNode))){s(!1);return}if(!F(M))return;const L=Bm(M);c(M.hasFormat("bold")),f(M.hasFormat("italic")),g(M.hasFormat("underline")),_(M.hasFormat("strikethrough")),b(M.hasFormat("subscript")),C(M.hasFormat("superscript")),k(M.hasFormat("code"));const A=L.getParent();Pe(A)||Pe(L)?a(!0):a(!1),!Ve(M.anchor.getNode())&&M.getTextContent()!==""?s(oe(L)):s(!1)})},[n]);S.useEffect(()=>(document.addEventListener("selectionchange",I),()=>{document.removeEventListener("selectionchange",I)}),[I]),S.useEffect(()=>de(n.registerUpdateListener(()=>{I()}),n.registerRootListener(()=>{n.getRootElement()===null&&s(!1)}),n.registerCommand(ys,()=>(s(!1),!1),ee)),[n,I]);const E=S.useCallback(()=>{i?(t(!1),n.dispatchCommand(Lr,null)):(t(!0),n.dispatchCommand(Lr,"https://example.com"))},[n,i,t]),N=S.useMemo(()=>n.isEditable()?[{key:"bold",type:"button",order:0,ariaLabel:"Format text as bold",title:"Bold",icon:Lh,isActive:l,onClick:()=>n.dispatchCommand(Ge,"bold")},{key:"italic",type:"button",order:1,ariaLabel:"Format text as italics",title:"Italic",icon:Oh,isActive:u,onClick:()=>n.dispatchCommand(Ge,"italic")},{key:"underline",type:"button",order:2,ariaLabel:"Format text to underlined",title:"Underline",icon:BL,isActive:d,onClick:()=>n.dispatchCommand(Ge,"underline")},{key:"strikethrough",type:"button",order:3,ariaLabel:"Format text with a strikethrough",title:"Strikethrough",icon:Rh,isActive:h,onClick:()=>n.dispatchCommand(Ge,"strikethrough")},{key:"subscript",type:"button",order:4,ariaLabel:"Format Subscript",title:"Subscript",icon:void 0,label:"x₂",isActive:m,onClick:()=>n.dispatchCommand(Ge,"subscript")},{key:"superscript",type:"button",order:5,ariaLabel:"Format Superscript",title:"Superscript",icon:void 0,label:"x²",isActive:w,onClick:()=>n.dispatchCommand(Ge,"superscript")},{key:"code",type:"button",order:6,ariaLabel:"Insert code block",title:"Code",icon:br,isActive:v,onClick:()=>n.dispatchCommand(Ge,"code")},{key:"link",type:"button",order:7,ariaLabel:"Insert link",title:"Link",icon:Ah,isActive:i,onClick:E},{key:"comment",type:"button",order:8,ariaLabel:"Insert comment",title:"Comment",icon:Pi,onClick:()=>n.dispatchCommand(ys,void 0)}]:[{key:"comment",type:"button",order:100,ariaLabel:"Insert comment",icon:Pi,onClick:()=>n.dispatchCommand(ys,void 0)}],[n,l,u,d,h,m,w,v,i,E]),O=o&&!i;return x.jsx(Tx,{items:N,extraItems:r,anchorElement:e,isVisible:O,ariaLabel:"Floating text format toolbar"})}function e$({anchorElem:n=document.body,setIsLinkEditMode:e,extraItems:t}){const[r]=fe();return UL(r,n,e,t)}function zL(n){return n.registerCommand(Kc,()=>{const e=D();if(!F(e))return!1;if(e.focus.getNode()!==null){const r=ba();e.insertParagraph(),e.focus.getNode().getTopLevelElementOrThrow().insertBefore(r)}return!0},V)}const Cb=pe({name:"@datalayer/jupyter-lexical/HorizontalRule",nodes:()=>[mu],register:zL}),ss={code:{triggerMode:"auto",contextBefore:-1,contextAfter:-1,language:"python"},prose:{triggerMode:"manual",contextBefore:-1,contextAfter:-1},debounceMs:200,manualTriggerKey:"Cmd+Shift+,"};function KL(n){return n?{code:{...ss.code,...n.code},prose:{...ss.prose,...n.prose},debounceMs:n.debounceMs??ss.debounceMs,manualTriggerKey:n.manualTriggerKey??ss.manualTriggerKey}:{...ss}}function t$(n){return n===-1||n>=0}function n$(n){return n.triggerMode==="auto"}function r$(n){return n.triggerMode==="manual"||n.triggerMode==="auto"}function o$(n){return n.triggerMode==="disabled"}const qg="jupyter-cell";class Fr extends Bt{__code;__outputs;__loading;__autoStart;__data;__variant;static getType(){return qg}static clone(e){return console.debug(`clone: node: ${JSON.stringify(e,null,2)}`),new Fr(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}`),x.jsx(_x,{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 Fr(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:qg,version:1}}}function Vg(n){const{code:e,outputs:t,loading:r,autoStart:o}=n;return new Fr(e,t,r,o)}function s$(n){return n instanceof Fr}const WL=he(),HL=he();function JL(n){if(!n.hasNodes([Fr]))throw new Error("JupyterCellNode is not registered.");return de(n.registerCommand(WL,e=>{const t=Vg(e);return Tr([t]),!0},V),n.registerCommand(HL,e=>{const t=Vg({...e});return Tr([t]),!0},V))}const qL=pe({name:"@datalayer/jupyter-lexical/JupyterCell",nodes:()=>[Fr],register:JL}),VL=he("INSERT_LAYOUT_COMMAND");function YL(n){return n.trim().split(/\s+/).length}function i$(n){return Array.from({length:Math.max(1,n)},()=>"1fr").join(" ")}function XL(n){if(!n.hasNodes([Dr,Pr]))throw new Error("LayoutPlugin: LayoutContainerNode, or LayoutItemNode not registered on editor");const e=t=>{const r=D();if(F(r)&&r.isCollapsed()&&r.anchor.offset===0){const o=re(r.anchor.getNode(),Ci);if(Ci(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(Vt,()=>e(!1),ee),n.registerCommand(ia,()=>e(!1),ee),n.registerCommand(pt,()=>e(!0),ee),n.registerCommand(zs,()=>e(!0),ee),n.registerCommand(VL,t=>(n.update(()=>{const r=Ou(t);for(let o=0;o<YL(t);o++)r.append(Ru().append(ne()));sr(r),r.selectStart()}),!0),V),n.registerNodeTransform(Pr,t=>{const r=t.getParent();if(!Ci(r)){for(const o of t.getChildren())t.insertBefore(o);t.remove();return}t.isEmpty()&&t.append(ne())}),n.registerNodeTransform(Dr,t=>{const r=t.getChildren();if(!r.every(Au)){for(const o of r)t.insertBefore(o);t.remove();return}r.length===0&&t.remove()}))}const GL=pe({name:"@datalayer/jupyter-lexical/Layout",nodes:()=>[Dr,Pr],register:XL});function Yg(n,e,t,r,o){return n==="code"?ZL(e,t):QL(e,t,r,o)}function ZL(n,e){const t=n.getTextContent(),r=nO(n,e),o=t.substring(0,r),s=t.substring(r);return{before:o,after:s,fullText:t}}function QL(n,e,t,r){const s=se().getChildren(),i=eO(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 Km(n){const e=[];if(n instanceof dn&&e.push(n),q(n))for(const t of n.getChildren())q(t)&&e.push(...Km(t));return e}function GN(n){const e=de(S0(n),n.registerNodeTransform(dn,t=>{Og(t,n)}));return n.getEditorState().read(()=>{for(const t of Km(se()))Og(t,n)}),e}const ZN=pe({name:"@datalayer/jupyter-lexical/CodeBlockHighlight",dependencies:[Vh],register:GN}),Xu=he("INSERT_COLLAPSIBLE_COMMAND"),Rg=()=>{const n=D();if(F(n)&&n.isCollapsed()&&n.anchor.offset===0){const e=re(n.anchor.getNode(),Pt);if(Pt(e)){const t=e.getParent();t!==null&&t.getFirstChild()===e&&n.anchor.key===e.getFirstDescendant()?.getKey()&&e.insertBefore(ne())}}return!1},Ag=()=>{const n=D();if(F(n)&&n.isCollapsed()){const e=re(n.anchor.getNode(),Pt);if(Pt(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 QN(n){if(!n.hasNodes([Mr,Os,$r]))throw new Error("CollapsiblePlugin: CollapsibleContainerNode, CollapsibleTitleNode, or CollapsibleContentNode not registered on editor");return de(n.registerNodeTransform($r,e=>{const t=e.getParent();if(!Pt(t)){const r=e.getChildren();for(const o of r)e.insertBefore(o);e.remove()}}),n.registerNodeTransform(Os,e=>{const t=e.getParent();if(!Pt(t)){e.replace(ne().append(...e.getChildren()));return}}),n.registerNodeTransform(Mr,e=>{const t=e.getChildren();if(t.length!==2||!xi(t[0])||!Lu(t[1])){for(const r of t)e.insertBefore(r);e.remove()}}),n.registerCommand(Vt,Ag,ee),n.registerCommand(ia,Ag,ee),n.registerCommand(pt,Rg,ee),n.registerCommand(zs,Rg,ee),n.registerCommand(Lo,()=>{const e=D();if(F(e)){const t=re(e.anchor.getNode(),r=>xi(r));if(xi(t)){const r=t.getParent();if(r&&Pt(r))return r.getOpen()||r.toggleOpen(),t.getNextSibling()?.selectEnd(),!0}}return!1},ee),n.registerCommand(Xu,()=>(n.update(()=>{const e=Z_(),t=ne();sr(Eu(!0).append(e.append(t),Nu().append(ne()))),t.select()}),!0),ee))}const e2=pe({name:"@datalayer/jupyter-lexical/Collapsible",nodes:()=>[Mr,Os,$r],register:QN}),t2=qn?S.useLayoutEffect:S.useEffect;class Wm{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 Mg=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 $g(n,e){const t=n.getBoundingClientRect(),r=e.getBoundingClientRect();return t.top>=r.top-6&&t.top<=r.bottom+6}function n2(n,e,t,r){const[o]=fe();S.useEffect(()=>{if(e!=null&&n!=null){const s=o.getRootElement(),i=s!=null?bh(s,!1):document.body;let a=!1,l=$g(e,i);const c=function(){a||(window.requestAnimationFrame(function(){t(),a=!1}),a=!0);const d=$g(e,i);d!==l&&(l=d,r?.(d))},u=new ResizeObserver(t),f=yh(s??e);return u.observe(e),de(Jt(window,"resize",t),Jt(document,"scroll",c,{capture:!0,passive:!0}),...f.map(d=>Jt(d,"scroll",c,{capture:!0,passive:!0})),()=>u.unobserve(e))}},[e,o,r,t,n])}const Dg=he("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function r2({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){let s="item";return e&&(s+=" selected"),x.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,x.jsx("span",{className:"text",children:o.title})]},o.key)}function o2({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]=S.useState(null),d=u!==null?Math.min(o.length-1,u):null,g=r.match&&r.match.matchingString;S.useEffect(()=>{c&&f(0)},[g,c]);const h=S.useCallback(w=>{e.update(()=>{const C=r.match!=null&&a?(function(v){const k=D();if(!F(k)||!k.isCollapsed())return null;const I=k.anchor;if(I.type!=="text")return null;const E=I.getNode();if(!E.isSimpleText())return null;const N=I.offset,O=E.getTextContent().slice(0,N),M=v.replaceableString.length,R=N-(function(L,A,B){let j=B;for(let U=j;U<=A.length;U++)L.slice(-U)===A.substring(0,U)&&(j=U);return j})(O,v.matchingString,M);if(R<0)return null;let $;return R===0?[$]=E.splitText(N):[,$]=E.splitText(R,N),$})(r.match):null;i(w,C,n,r.match?r.match.matchingString:"")})},[e,a,r.match,i,n]),_=S.useCallback(w=>{const C=e.getRootElement();C!==null&&(C.setAttribute("aria-activedescendant","typeahead-item-"+w),f(w))},[e]),m=S.useCallback(()=>t.current&&o.length?wh.createPortal(x.jsx("div",{className:"typeahead-popover mentions-menu",children:x.jsx("ul",{children:o.map((w,C)=>x.jsx(r2,{index:C,isSelected:d===C,onClick:()=>{f(C),h(w)},onMouseEnter:()=>{f(C)},option:w},w.key))})}),t.current):null,[t,o,d,h,f]);S.useEffect(()=>()=>{const w=e.getRootElement();w!==null&&w.removeAttribute("aria-activedescendant")},[e]),t2(()=>{o===null?f(null):d===null&&c&&_(0)},[o,d,_,c]),S.useEffect(()=>de(e.registerCommand(Dg,({option:w})=>!(!w.ref||w.ref.current==null)&&(Mg(w.ref.current),!0),l)),[e,_,l]),S.useEffect(()=>de(e.registerCommand(Vt,w=>{const C=w;if(o!==null&&o.length){const v=d===null?0:d!==o.length-1?d+1:0;_(v);const k=o[v];if(!k)return _(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;k.ref&&k.ref.current&&e.dispatchCommand(Dg,{index:v,option:k}),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),e.registerCommand(pt,w=>{const C=w;if(o!==null&&o.length){const v=d===null?o.length-1:d!==0?d-1:o.length-1;_(v);const k=o[v];if(!k)return _(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;k.ref&&k.ref.current&&Mg(k.ref.current),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),e.registerCommand(Nn,w=>{const C=w;return C.preventDefault(),C.stopImmediatePropagation(),n(),!0},l),e.registerCommand(Kr,w=>{const C=w;return o!==null&&d!==null&&o[d]!=null&&(C.preventDefault(),C.stopImmediatePropagation(),h(o[d]),!0)},l),e.registerCommand(zr,w=>!(o===null||d===null||o[d]==null||w&&w.shiftKey)&&(w!==null&&(w.preventDefault(),w.stopImmediatePropagation()),h(o[d]),!0),l)),[h,n,e,o,d,_,l]);const b=S.useMemo(()=>({options:o,selectOptionAndCleanUp:h,selectedIndex:d,setHighlightedIndex:f}),[h,d,o]);return s!=null?s(t,b,r.match?r.match.matchingString:""):m()}function Pg(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 s2(n,e,t,r,o=!0){const[s]=fe(),i=r??(function(f){if(!qn)return;const d=f.getRootElement();if(d!==null){const g=d.getRootNode();return jc(g)?g:d.ownerDocument.body}return document.body})(s),a=qn?mh(s.getRootElement()).createElement("div"):null,l=S.useRef(a),c=S.useCallback(()=>{if(l.current===null||i===void 0)return;l.current.style.top=l.current.style.bottom;const f=s.getRootElement(),d=l.current,g=d.firstChild;if(f!==null&&n!==null){const{left:h,top:_,width:m,height:b}=n.getRect(),w=l.current.offsetHeight;if(d.style.top=`${_+w+3+(o?window.pageYOffset:0)}px`,d.style.left=`${h+window.pageXOffset}px`,d.style.height=`${b}px`,d.style.width=`${m}px`,g!==null){g.style.top=`${_}`;const C=g.getBoundingClientRect(),v=C.height,k=C.width,I=f.getBoundingClientRect();h+k>I.right&&(d.style.left=`${I.right-k+window.pageXOffset}px`),(_+v>window.innerHeight||_+v>I.bottom)&&_-I.top>v+b&&(d.style.top=`${_-v-b+(o?window.pageYOffset:0)}px`)}d.isConnected||(Pg(d,t),i.append(d)),d.setAttribute("id","typeahead-menu"),f.setAttribute("aria-controls","typeahead-menu")}},[s,n,o,t,i]);S.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=S.useCallback(f=>{n!==null&&(f||e(null))},[n,e]);return n2(n,l.current,c,u),a!=null&&a===l.current&&(Pg(a,t),i?.append(a)),l}const i2=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function Hm(n,{minLength:e=1,maxLength:t=75,punctuation:r=i2,allowWhitespace:o=!1}){return S.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 Jm({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(),[g,h]=S.useState(null),_=s2(g,h,a,c),m=S.useCallback(()=>{if(g===null)return;const w=()=>{h(null)};let C;try{C=o&&o()}finally{C?C.then(w,w):w()}},[o,g]),b=S.useCallback(w=>{h(w),r!=null&&g===null&&r(w)},[r,g]);return S.useEffect(()=>{const w=d.registerUpdateListener(()=>{d.read("latest",()=>{if(!d.isEditable())return void m();if(d.isComposing())return;const C=d._window||window,v=C.document.createRange(),k=D(),I=(function(N){let O=null;return N.read("latest",()=>{const M=D();F(M)&&(O=(function(R){const $=R.anchor;if($.type!=="text")return null;const L=$.getNode();if(!L.isSimpleText())return null;const A=$.offset;return L.getTextContent().slice(0,A)})(M))}),O})(d);if(!F(k)||!k.isCollapsed()||I===null||v===null)return void m();const E=i(I,d);if(e(E?E.matchingString:null),E!==null&&(f||!(function(N,O){return O===0&&N.read("latest",()=>{const M=D();if(F(M)){const R=M.anchor.getNode().getPreviousSibling();return oe(R)&&R.isTextEntity()}return!1})})(d,E.leadOffset))&&(function(O,M,R,$){const L=or(R);if(L===null||!L.isCollapsed)return!1;const A=Pc(L,$),B=A.anchorNode,j=O,U=A.anchorOffset;if(B==null||U==null)return!1;try{M.setStart(B,j),M.setEnd(B,U)}catch{return!1}return!0})(E.leadOffset,v,C,d.getRootElement())!==null)return void S.startTransition(()=>b({getRect:()=>v.getBoundingClientRect(),match:E}));m()})});return()=>{w()}},[d,i,e,g,m,b,f]),S.useEffect(()=>d.registerEditableListener(w=>{w||m()}),[d,m]),g===null||d===null||_.current===null?null:x.jsx(o2,{close:m,resolution:g,editor:d,anchorElementRef:_,options:n,menuRenderFn:s,shouldSplitNodeWithQuery:!0,onSelectOption:t,commandPriority:l,preselectFirstItem:u})}const a2=n=>n.split(/[\s._-]+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join("")||"?";function l2({author:n,size:e}){const t=Jc(n);return n.avatarUrl?x.jsx(ax,{src:n.avatarUrl,size:e,alt:t}):x.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"?x.jsx(hw,{size:Math.round(e*.65)}):a2(t)})}const jr=S.createContext({}),c2=[],u2=250;function qm(n){const{searchPeople:e}=S.useContext(jr),[t,r]=S.useState(null);return S.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:[]})})},u2);return()=>{o=!1,clearTimeout(s)}},[n,e]),t&&t.query===n?t.people:c2}class d2 extends Wm{person;constructor(e){super(e.uid),this.person=e}}function f2({onMention:n}){const[e]=fe(),{searchPeople:t}=S.useContext(jr),[r,o]=S.useState(null),s=qm(r),i=S.useMemo(()=>s.map(c=>new d2(c)),[s]),a=Hm("@",{minLength:1}),l=S.useCallback((c,u,f)=>{e.update(()=>{const d=$e(`@${wo(c.person)} `);u&&u.replace(d),d.select(),f()}),n(c.person)},[e,n]);return t?x.jsx(Jm,{onQueryChange:o,onSelectOption:l,triggerFn:a,options:i,menuRenderFn:(c,{selectedIndex:u,selectOptionAndCleanUp:f,setHighlightedIndex:d})=>c.current&&i.length>0?St.createPortal(x.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((g,h)=>x.jsxs(Y,{as:"li",role:"option","aria-selected":u===h,ref:_=>g.setRefElement(_),onMouseEnter:()=>d(h),onClick:()=>{d(h),f(g)},sx:{px:2,py:1,borderRadius:1,cursor:"pointer",bg:u===h?"actionListItem.default.hoverBg":"transparent"},children:[x.jsx(Le,{children:wo(g.person)}),g.person.handle?x.jsxs(Le,{sx:{color:"var(--fgColor-muted)",ml:1},children:["@",g.person.handle]}):null]},g.key))}),c.current):null}):null}function g2({thread:n}){const{searchPeople:e,assignThread:t}=S.useContext(jr),[r,o]=S.useState(!1),[s,i]=S.useState(""),a=qm(r&&s.trim()?s.trim():null),l=n.assignee??null;if(!t||!e)return l?x.jsxs(Le,{as:"p",sx:{fontSize:0,color:"var(--fgColor-muted)",m:0,mt:1},children:["Assigned to ",wo(l)]}):null;const c=u=>{t(n,u),o(!1),i("")};return x.jsxs(Y,{sx:{mt:1},onClick:u=>u.stopPropagation(),children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:1},children:[x.jsx(Le,{sx:{fontSize:0,color:"var(--fgColor-muted)"},children:l?`Assigned to ${wo(l)}`:"Not assigned"}),x.jsx(Ft,{icon:ex,"aria-label":"Assign thread",variant:"invisible",size:"small",onClick:()=>o(!r)}),l?x.jsx(ft,{variant:"invisible",size:"small",onClick:()=>c(null),children:"Unassign"}):null]}),r?x.jsxs(Y,{sx:{mt:1},children:[x.jsx(vn,{"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)}),x.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0,mt:1},children:a.map(u=>x.jsx(Y,{as:"li",children:x.jsx(ft,{variant:"invisible",size:"small",onClick:()=>c(u),children:wo(u)})},u.uid))})]}):null]})}const p2={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"}},h2={...p2,paragraph:"CommentEditorTheme__paragraph"},ys=he();function _2({anchorKey:n,editor:e,onAddComment:t}){const r=S.useRef(null),o=S.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 S.useEffect(()=>(window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o)}),[e,o]),Yu(()=>{o()},[n,e,o]),x.jsx(Y,{ref:r,sx:{position:"absolute",zIndex:10},children:x.jsx(Ft,{icon:Pi,"aria-label":"Add comment",variant:"invisible",size:"small",onClick:t})})}const Vm=pe({name:"@datalayer/jupyter-lexical/CommentComposer",namespace:"Commenting",theme:h2,dependencies:[Cw,Sh,Sw]}),m2=pe({name:"@datalayer/jupyter-lexical/CommentComposer/Focused",dependencies:[Vm,vw]});function b2({editorRef:n}){const[e]=fe();return Yu(()=>(n.current=e,()=>{n.current=null}),[e,n]),null}function y2({onEscape:n}){const[e]=fe();return S.useEffect(()=>e.registerCommand(Nn,t=>n(t),2),[e,n]),null}function Ym({style:n,autoFocus:e,onEscape:t,onChange:r,onMention:o,editorRef:s,placeholder:i="Type a comment..."}){const a=e===!1?Vm:m2;return x.jsx(ww,{extension:a,contentEditable:null,children:x.jsxs(Y,{sx:{position:"relative",m:"10px",borderRadius:2},children:[x.jsx(Ap,{className:"ContentEditable__root",style:n,placeholder:x.jsx(Bh,{children:i}),"aria-placeholder":i}),x.jsx(xw,{onChange:r}),x.jsx(y2,{onEscape:t}),o!==void 0&&x.jsx(f2,{onMention:o}),s!==void 0&&x.jsx(b2,{editorRef:s})]})})}function Xm(n,e){return S.useCallback((t,r)=>{t.read(()=>{n(bw()),e(!yw(r.isComposing(),!0))})},[e,n])}const jg=256;function w2({editor:n,cancelAddComment:e,submitAddComment:t}){const[r,o]=S.useState(""),[s,i]=S.useState(!1),[a,l]=S.useState(null),c=S.useRef(null),u=S.useMemo(()=>({container:document.createElement("div"),elements:[]}),[]),f=Zm(),d=S.useCallback(()=>{n.getEditorState().read(()=>{const C=D();if(F(C)){const v=C.anchor,k=C.focus,I=fh(n,v.getNode(),v.offset,k.getNode(),k.offset);if(I!==null){const{left:E,bottom:N,width:O}=I.getBoundingClientRect(),M=Ml(n,I);let R=M.length===1?E+O/2-jg/2:E-jg/2;R<10&&(R=10),l({left:R,top:N+20});const $=M.length,{container:L}=u,A=u.elements,B=A.length;for(let j=0;j<$;j++){const U=M[j];let z=A[j];z===void 0&&(z=document.createElement("span"),A[j]=z,L.appendChild(z));const H=`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;`;z.style.cssText=H}for(let j=B-1;j>=$;j--){const U=A[j];L.removeChild(U),A.pop()}}}})},[n,u]);Yu(()=>{c.current=n.getRootElement(),d();const C=u.container,v=document.body;if(v!==null)return v.appendChild(C),()=>{v.removeChild(C)}},[n,u.container,d]),S.useEffect(()=>(window.addEventListener("resize",d),()=>{window.removeEventListener("resize",d)}),[d]);const g=C=>(C.preventDefault(),e(),!0),h=S.useRef(new Map),_=S.useCallback(C=>{h.current.set(C.uid,C)},[]),m=()=>{if(s){let C=n.getEditorState().read(()=>{const v=D();return v!==null?v.getTextContent():""});C.length>100&&(C=C.slice(0,99)+"…"),t(Px(C,[Ph(r,f,void 0,void 0,void 0,$h(r,h.current.values()))]),!0)}},b=Xm(o,i),w=C=>{const v=C.target;v instanceof HTMLElement&&v.closest('[role="listbox"]')||e()};return a===null?null:x.jsxs(kl,{role:"dialog","aria-label":"Add a comment",width:"small",position:"fixed",left:a.left,top:a.top,onEscape:e,onClickOutside:w,returnFocusRef:c,preventFocusOnOpen:!0,children:[x.jsx(Ym,{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:g,onChange:b,onMention:_}),x.jsxs(Y,{sx:{display:"flex",gap:2,justifyContent:"flex-end",mt:2,px:2,pb:2},children:[x.jsx(ft,{onClick:e,variant:"invisible",size:"small",children:"Cancel"}),x.jsx(ft,{onClick:m,disabled:!s,variant:"primary",size:"small",children:"Comment"})]})]})}function x2({submitAddComment:n,thread:e,placeholder:t}){const[r,o]=S.useState(""),[s,i]=S.useState(!1),a=S.useRef(null),l=Zm(),c=S.useRef(new Map),u=S.useCallback(g=>{c.current.set(g.uid,g)},[]),f=Xm(o,i),d=()=>{if(s){n(Ph(r,l,void 0,void 0,void 0,$h(r,c.current.values())),!1,e),c.current.clear();const g=a.current;g!==null&&g.dispatchCommand(Tw,void 0)}};return x.jsxs(x.Fragment,{children:[x.jsx(Ym,{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}),x.jsx(Ft,{icon:kw,"aria-label":"Send comment",variant:"invisible",size:"small",onClick:d,disabled:!s})]})}function Gm({commentOrThread:n,deleteCommentOrThread:e,onClose:t,thread:r=void 0}){return x.jsxs(x.Fragment,{children:["Are you sure you want to delete this ",n.type,"?",x.jsxs(Y,{sx:{display:"flex",gap:2,justifyContent:"flex-end",mt:3},children:[x.jsx(ft,{variant:"invisible",onClick:()=>{t()},children:"Cancel"}),x.jsx(ft,{variant:"danger",onClick:()=>{e(n,r),t()},children:"Delete"})]})]})}function C2(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 Fg({comment:n,deleteComment:e,thread:t,rtf:r}){const[o,s]=Xo(),{Avatar:i=l2}=S.useContext(jr),a=Dx(n);return x.jsxs(Y,{as:"li",sx:{p:2,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)"},children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[x.jsx(i,{author:a,size:20}),x.jsx(Le,{sx:{fontWeight:"bold",fontSize:1},children:Jc(a)}),a.agentUid&&x.jsx(Le,{sx:{color:"var(--fgColor-muted)",fontSize:0},children:"· with an agent"}),x.jsxs(Le,{sx:{color:"var(--fgColor-muted)",fontSize:0},children:["· ",C2(r,n.timeStamp)]})]}),x.jsx(Le,{as:"p",sx:{fontSize:1,m:0,...n.deleted?{color:"var(--fgColor-muted)",fontStyle:"italic"}:{}},children:n.content}),!n.deleted&&x.jsxs(x.Fragment,{children:[x.jsx(Ft,{icon:Ch,"aria-label":"Delete comment",variant:"invisible",size:"small",sx:{color:"var(--fgColor-danger)",mt:1},onClick:()=>{s("Delete Comment",l=>x.jsx(Gm,{commentOrThread:n,deleteCommentOrThread:e,thread:t,onClose:l}))}}),o]})]})}function S2({activeIDs:n,comments:e,deleteCommentOrThread:t,listRef:r,submitAddComment:o,markNodeMap:s,resolveThread:i}){const[a]=fe(),[l,c]=S.useState(0),[u,f]=Xo(),d=S.useMemo(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return S.useEffect(()=>{const g=setTimeout(()=>{c(l+1)},1e4);return()=>{clearTimeout(g)}},[l]),x.jsx(Y,{as:"ul",ref:r,sx:{listStyle:"none",m:0,p:0},children:e.map(g=>{const h=g.id;if(g.type==="thread"){const _=()=>{const m=s.get(h);if(m!==void 0&&(n===null||n.indexOf(h)===-1)){const b=document.activeElement;a.update(()=>{const w=Array.from(m)[0],C=Q(w);Ro(C)&&C.selectStart()},{onUpdate(){b!==null&&b.focus()}})}};return x.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:[x.jsxs(Y,{sx:{display:"flex",alignItems:"flex-start",gap:2},children:[x.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:["> ",x.jsx("span",{children:g.quote})]}),i&&x.jsx(Ft,{icon:xh,"aria-label":"Resolve thread",variant:"invisible",size:"small",onClick:m=>{m.stopPropagation(),i(g)}}),x.jsx(Ft,{icon:Ch,"aria-label":"Delete thread",variant:"invisible",size:"small",sx:{color:"var(--fgColor-danger)"},onClick:()=>{f("Delete Thread",m=>x.jsx(Gm,{commentOrThread:g,deleteCommentOrThread:t,onClose:m}))}}),u]}),x.jsx(g2,{thread:g}),x.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0,mt:2},children:g.comments.map(m=>x.jsx(Fg,{comment:m,deleteComment:t,thread:g,rtf:d},m.id))}),x.jsx(Y,{sx:{mt:2},children:x.jsx(x2,{submitAddComment:o,thread:g,placeholder:"Reply to comment..."})})]},h)}return x.jsx(Fg,{comment:g,deleteComment:t,rtf:d},h)})})}function v2({activeIDs:n,deleteCommentOrThread:e,comments:t,submitAddComment:r,markNodeMap:o,resolveThread:s}){const i=S.useRef(null),a=t.length===0;return x.jsxs(Y,{sx:{bg:"var(--bgColor-default)",borderRadius:2,overflow:"hidden",width:"100%",flex:1,display:"flex",flexDirection:"column"},children:[x.jsx(mw,{as:"h2",sx:{fontSize:2,p:3,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)",m:0},children:"Comments"}),a?x.jsx(Y,{sx:{p:3,color:"var(--fgColor-muted)",textAlign:"center"},children:"No Comments"}):x.jsx(S2,{activeIDs:n,comments:t,deleteCommentOrThread:e,listRef:i,submitAddComment:r,markNodeMap:o,resolveThread:s})]})}function Zm(){const{author:n}=S.useContext(jr),{name:e}=Lm();return n??qc(e)}function YM({providerFactory:n,showFloatingAddButton:e=!0,commentStore:t,author:r,Avatar:o}){const[s]=fe(),{showComments:i,setShowComments:a}=e_(),l=S.useRef(null),c=S.useRef(null),u=S.useMemo(()=>t??new Bx(s),[s,t]),f=Ux(u),d=S.useMemo(()=>new Map,[]),[g,h]=S.useState(),[_,m]=S.useState([]),[b,w]=S.useState(!1),C=S.useCallback(R=>{a(typeof R=="function"?R(i):R)},[a,i]),v=S.useCallback(()=>{s.update(()=>{const R=D();R!==null&&(R.dirty=!0)}),w(!1)},[s]),k=S.useCallback(R=>{const $=d.get(R);$!==void 0&&setTimeout(()=>{s.update(()=>{for(const L of $){const A=Q(L);Ro(A)&&(A.deleteID(R),A.getIDs().length===0&&Ox(A))}})})},[s,d]),I=S.useCallback((R,$)=>{R.type==="comment"?u.deleteComment(R,$):(u.deleteThread(R),k($!==void 0?$.id:R.id))},[u,k]),E=S.useMemo(()=>{if(u.resolveThread)return R=>{u.resolveThread?.(R),k(R.id)}},[u,k]),N=S.useCallback((R,$,L)=>{u.addComment(R,L),$&&(s.update(()=>{const A=D();if(F(A)){const B=A.focus,j=A.anchor,U=A.isBackward(),z=R.id;Rx(A,U,z),U?B.set(j.key,j.offset,j.type):j.set(B.key,B.offset,B.type)}}),w(!1))},[u,s]);S.useEffect(()=>{const R=[];for(let $=0;$<_.length;$++){const L=_[$],A=d.get(L);if(A!==void 0)for(const B of A){const j=s.getElementByKey(B);j!==null&&(j.classList.add("selected"),R.push(j),a(!0))}}return()=>{for(let $=0;$<R.length;$++)R[$].classList.remove("selected")}},[_,s,d]),S.useEffect(()=>{const R=new Map;return de(_w(s,Ts,$=>Hc($.getIDs()),($,L)=>{$.getIDs().forEach(B=>{L.addID(B)})}),s.registerMutationListener(Ts,$=>{s.getEditorState().read(()=>{for(const[L,A]of $){const B=Q(L);let j=[];A==="destroyed"?j=R.get(L)||[]:Ro(B)&&(j=B.getIDs());for(let U=0;U<j.length;U++){const z=j[U];let K=d.get(z);R.set(L,j),A==="destroyed"?K!==void 0&&(K.delete(L),K.size===0&&d.delete(z)):(K===void 0&&(K=new Set,d.set(z,K)),K.has(L)||K.add(L))}}})}),s.registerUpdateListener(({editorState:$,tags:L})=>{$.read(()=>{const A=D();let B=!1,j=!1;if(F(A)){const U=A.anchor.getNode();if(oe(U)){const z=Ax(U,A.anchor.offset);z!==null&&(m(z),B=!0),A.isCollapsed()||(h(U.getKey()),j=!0)}}B||m(U=>U.length===0?U:[]),j||h(null)}),L.has("collaboration")||w(!1)}),s.registerCommand(ys,()=>{const $=window.getSelection();return $!==null&&$.removeAllRanges(),w(!0),!0},V))},[s,d]);const O=()=>{s.dispatchCommand(ys,void 0)},M=S.useMemo(()=>({searchPeople:u.searchPeople?.bind(u),assignThread:u.assignThread?.bind(u),author:r,Avatar:o}),[u,r,o]);return x.jsxs(jr.Provider,{value:M,children:[b&&x.jsx(jr.Provider,{value:M,children:x.jsx(w2,{editor:s,cancelAddComment:v,submitAddComment:N})}),e&&g!==null&&g!==void 0&&!b&&St.createPortal(x.jsx(_2,{anchorKey:g,editor:s,onAddComment:O}),document.body),x.jsx("button",{ref:l,style:{display:"none"},"aria-hidden":"true"}),x.jsx(vx,{isOpen:i,setIsOpen:C,openButtonRef:l,closeButtonRef:c,direction:"right",width:"350px",content:x.jsx(v2,{comments:f,submitAddComment:N,deleteCommentOrThread:I,activeIDs:_,markNodeMap:d,resolveThread:E})})]})}const Fo=Qe().describe("CSS colour, e.g. '#1e1e1e', '#e03131', 'transparent'"),Qm=Lt({type:wr(["rectangle","ellipse","diamond","text","arrow","line","frame"]).describe("What to draw"),x:Ke().describe("Left edge, in scene coordinates"),y:Ke().describe("Top edge, in scene coordinates"),width:Ke().optional().describe("Width in pixels (shapes only)"),height:Ke().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:Ke().optional().describe("Font size in pixels, e.g. 16, 20, 28"),strokeColor:Fo.optional().describe("Outline colour"),backgroundColor:Fo.optional().describe("Fill colour"),fillStyle:wr(["hachure","cross-hatch","solid"]).optional().describe("How the fill is drawn"),strokeWidth:Ke().optional().describe("Outline thickness, 1 | 2 | 4"),strokeStyle:wr(["solid","dashed","dotted"]).optional().describe("Outline style"),roughness:Ke().optional().describe("0 for architect (clean), 1 for artist, 2 for cartoonist"),opacity:Ke().optional().describe("0-100"),angle:Ke().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:yr(yr(Ke())).optional().describe("For 'arrow' and 'line' without bindings: points relative to x,y, e.g. [[0,0],[120,0]]"),children:yr(Qe()).optional().describe("For 'frame': the ids of the elements it contains"),name:Qe().optional().describe("For 'frame': its name")}),eb=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"),On=Qe().describe("The block_id of the drawing, from excalidrawListDrawings or readAllBlocks"),tb=Lt({afterId:eb,elements:yr(Qm).optional().describe("The drawing itself. Omit to insert an empty canvas for a person to draw on."),width:Ke().optional().describe("Rendered width in pixels. Omit to size to the content."),height:Ke().optional().describe("Rendered height in pixels. Omit to size to the content.")}),nb=Lt({}),rb=Lt({blockId:On,detail:wr(["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.")}),ob=Lt({blockId:On,elements:yr(Qm).describe("The elements to add. Existing elements are left alone.")}),sb=Lt({blockId:On,updates:yr(Lt({id:Qe().describe("The element id, from excalidrawReadScene"),x:Ke().optional(),y:Ke().optional(),width:Ke().optional(),height:Ke().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:Fo.optional(),backgroundColor:Fo.optional(),fillStyle:wr(["hachure","cross-hatch","solid"]).optional(),strokeWidth:Ke().optional(),strokeStyle:wr(["solid","dashed","dotted"]).optional(),opacity:Ke().optional().describe("0-100"),angle:Ke().optional().describe("Rotation in radians")})).describe("One entry per element to change. Fields left out are kept.")}),ib=Lt({blockId:On,elementIds:yr(Qe()).describe("The ids to remove, from excalidrawReadScene")}),ab=Lt({blockId:On,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:Fo.optional(),strokeStyle:wr(["solid","dashed","dotted"]).optional()}),lb=Lt({blockId:On,viewBackgroundColor:Fo.optional().describe("The canvas colour behind the drawing"),gridSize:Ke().optional().describe("Grid spacing in pixels. 0 turns the grid off.")}),cb=Lt({blockId:On,width:Ke().optional().describe("Rendered width in pixels. Omit to go back to sizing by content."),height:Ke().optional().describe("Rendered height in pixels. Omit to go back to sizing by content.")}),ub=Lt({blockId:On}),db=Lt({blockId:On.optional().describe("The drawing to replace. Omit to insert a new drawing instead, positioned by afterId."),afterId:eb.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:Ke().optional().describe("Font size for the generated text, in pixels")}),Qt=n=>`datalayer_${n}`,Qr={requiresConfirmation:!1,canBeReferencedInPrompt:!0,priority:"medium"},en=["lexical","excalidraw","drawing","diagram"],k2={name:Qt("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:Zt(tb),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:[...en,"insert"]},T2={name:Qt("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:Zt(nb),operation:"excalidrawListDrawings",config:{...Qr,invocationMessage:()=>"Looking for drawings"},tags:[...en,"read"]},I2={name:Qt("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:Zt(rb),operation:"excalidrawReadScene",config:{...Qr,invocationMessage:()=>"Reading the drawing"},tags:[...en,"read"]},E2={name:Qt("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:Zt(ob),operation:"excalidrawAddElements",config:{...Qr,invocationMessage:()=>"Adding to the drawing",priority:"high"},tags:[...en,"edit"]},N2={name:Qt("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:Zt(sb),operation:"excalidrawUpdateElements",config:{...Qr,invocationMessage:()=>"Changing the drawing"},tags:[...en,"edit"]},L2={name:Qt("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:Zt(ib),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:[...en,"edit","delete"]},O2={name:Qt("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:Zt(ab),operation:"excalidrawConnectElements",config:{...Qr,invocationMessage:()=>"Connecting two shapes"},tags:[...en,"edit"]},R2={name:Qt("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:Zt(lb),operation:"excalidrawSetAppState",config:{...Qr,invocationMessage:()=>"Setting up the canvas"},tags:[...en,"edit"]},A2={name:Qt("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:Zt(cb),operation:"excalidrawResize",config:{...Qr,invocationMessage:()=>"Resizing the drawing"},tags:[...en,"edit"]},M2={name:Qt("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:Zt(ub),operation:"excalidrawClearScene",config:{confirmationMessage:()=>"Empty this drawing?",invocationMessage:()=>"Emptying the drawing",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"low"},tags:[...en,"edit","delete"]},$2={name:Qt("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:Zt(db),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:[...en,"insert","mermaid"]},fb=[k2,$2,T2,I2,E2,N2,O2,L2,R2,A2,M2],hl=()=>({elements:[],appState:{},files:{}});function Gu(n){if(!n)return hl();let e;try{e=JSON.parse(n)}catch{return hl()}if(Array.isArray(e))return{elements:e,appState:{},files:{}};if(!e||typeof e!="object")return hl();const t=e;return{elements:Array.isArray(t.elements)?t.elements:[],appState:t.appState??{},files:t.files??{}}}function Zu(n){return JSON.stringify({elements:n.elements,appState:n.appState,files:n.files})}const Gs=n=>n.elements.filter(e=>!e?.isDeleted);function D2(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 P2(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=D2(t);if(r.text===void 0){const o=e.get(r.id);o&&(r.text=o)}return r})}function Qu(n){const e=Gs(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 ed(n){return{...n,version:Number(n?.version??1)+1,versionNonce:Math.floor(Math.random()*2**31),updated:Date.now()}}const Zi=4;function gb(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 Rn(n,e){const t=gb(n,e);let r="";return n.getEditorState().read(()=>{r=t.__data??""}),Gu(r)}function eo(n,e,t){const r=Zu(t);return new Promise(o=>{n.update(()=>{const s=Q(e);s?.setData&&s.setData(r)},{onUpdate:()=>o()})})}const hn=(n,e,t)=>({success:!0,blockId:n,elementCount:Gs(e).length,...t});let j2=0;const F2=()=>`dla-${Date.now().toString(36)}-${(j2+=1).toString(36)}`;function B2(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 td(n,e){const{convertToExcalidrawElements:t}=await me(async()=>{const{convertToExcalidrawElements:i}=await import("./percentages-BXMCSKIN-CfzulzOv.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=F2()),e.add(a),r.push(a),B2(i,a)});return{elements:[...t(o,{regenerateIds:!1})],ids:r}}const mc=n=>({x:Number(n.x??0)+Number(n.width??0)/2,y:Number(n.y??0)+Number(n.height??0)/2});function Bg(n,e){const t=mc(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+Zi,i=Number(n.height??0)/2+Zi,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 U2(n,e){const t=Array.isArray(n.boundElements)?[...n.boundElements]:[];return t.some(r=>r?.id===e)||t.push({id:e,type:"arrow"}),ed({...n,boundElements:t})}function pb(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=Bg(o,mc(s)),a=Bg(s,mc(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:Zi},endBinding:{elementId:r,focus:0,gap:Zi}};return n.elements=n.elements.map(c=>c.id===t||c.id===r?U2(c,String(e.id)):c),l}const z2=async(n,e)=>{const t=e.elements??[],r=t.length>0?await td(t,new Set):{elements:[],ids:[]},o={elements:r.elements,appState:{},files:{}},s=await n.insertBlock({block_id:"",block_type:"excalidraw",source:"",metadata:{data:Zu(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 hn(s.blockId,o,{createdIds:r.ids,message:`Drawing inserted with ${r.elements.length} element(s)`})},K2=async n=>{const t=(await n.getBlocks("detailed")).filter(r=>r.block_type==="excalidraw").map(r=>{const o=Gu(r.metadata?.data);return{blockId:r.block_id,elementCount:Gs(o).length,description:Qu(o),width:r.metadata?.width,height:r.metadata?.height}});return{drawings:t,count:t.length}},W2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=Gs(r);return{blockId:t,elementCount:o.length,elements:e.detail==="full"?o:P2(o),appState:r.appState,description:Qu(r)}},H2=async(n,e)=>{const t=String(e.blockId),r=Rn(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:g}=u;if((u.type==="arrow"||u.type==="line")&&d&&g&&(!i.has(String(d))||!i.has(String(g)))){a.set(f,{fromId:String(d),toId:String(g)});const{startId:_,endId:m,...b}=u;return b}return u}),c=await td(l,o);r.elements=[...r.elements,...c.elements];for(const[u,f]of a){const d=c.ids[u],g=r.elements.find(h=>h.id===d);if(g){const h=pb(r,g,f.fromId,f.toId);r.elements=r.elements.map(_=>_.id===d?h:_)}}return await eo(n.editor,t,r),hn(t,r,{createdIds:c.ids,message:`Added ${c.elements.length} element(s)`})},J2=async(n,e)=>{const t=String(e.blockId),r=Rn(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,...g}=l,h=u.type!=="text"&&s.get(c);d!==void 0&&(h?i.set(h,{...i.get(h)??{},text:d,originalText:d}):(g.text=d,g.originalText=d)),Object.keys(g).length>0&&i.set(c,{...i.get(c)??{},...g})}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?ed({...l,...c}):l}),await eo(n.editor,t,r),hn(t,r,{message:`Updated ${o.length} element(s)`})},q2=async(n,e)=>{const t=String(e.blockId),r=Rn(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?ed({...a,...l}):a}),await eo(n.editor,t,r),hn(t,r,{message:`Removed ${i-r.elements.length} element(s)`})},V2=async(n,e)=>{const t=String(e.blockId),r=Rn(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 td([{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=pb(r,u,o,s);return r.elements=r.elements.map(d=>d.id===c?f:d),await eo(n.editor,t,r),hn(t,r,{createdIds:[c],message:`Connected '${o}' to '${s}'`})},Y2=async(n,e)=>{const t=String(e.blockId),r=Rn(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 eo(n.editor,t,r),hn(t,r,{message:"Canvas updated"})},X2=async(n,e)=>{const t=String(e.blockId),r=gb(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=Rn(n.editor,t);return hn(t,i,{message:o==="inherit"&&s==="inherit"?"Drawing sized to its content":`Drawing sized to ${o} x ${s}`})},G2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=Gs(r).length;return r.elements=[],r.files={},await eo(n.editor,t,r),hn(t,r,{message:`Emptied the drawing (${o} element(s) removed)`})},Z2=async(n,e)=>{const{parseMermaidToExcalidraw:t}=await me(async()=>{const{parseMermaidToExcalidraw:c}=await import("./index-CRpZyQIR.js").then(u=>u.an);return{parseMermaidToExcalidraw:c}},[],import.meta.url),{convertToExcalidrawElements:r}=await me(async()=>{const{convertToExcalidrawElements:c}=await import("./percentages-BXMCSKIN-CfzulzOv.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=Rn(n.editor,c);return u.elements=s,u.files=i,await eo(n.editor,c,u),hn(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:Zu(a)}},String(e.afterId??"BOTTOM"));if(!l.success||!l.blockId)throw new Error(l.error||"Failed to insert the drawing");return hn(l.blockId,a,{createdIds:s.map(c=>String(c.id)),message:`Drawing inserted with ${s.length} element(s) from Mermaid`})},bc={excalidrawInsertNode:z2,excalidrawListDrawings:K2,excalidrawReadScene:W2,excalidrawAddElements:H2,excalidrawUpdateElements:J2,excalidrawDeleteElements:q2,excalidrawConnectElements:V2,excalidrawSetAppState:Y2,excalidrawResize:X2,excalidrawClearScene:G2,excalidrawFromMermaid:Z2};function tn(n,e){return{name:n,async execute(t,r){const o=Iw(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 Q2=tn("excalidrawInsertNode",tb),eL=tn("excalidrawListDrawings",nb),tL=tn("excalidrawReadScene",rb),nL=tn("excalidrawAddElements",ob),rL=tn("excalidrawUpdateElements",sb),oL=tn("excalidrawDeleteElements",ib),sL=tn("excalidrawConnectElements",ab),iL=tn("excalidrawSetAppState",lb),aL=tn("excalidrawResize",cb),lL=tn("excalidrawClearScene",ub),cL=tn("excalidrawFromMermaid",db),Ei={excalidrawInsertNode:Q2,excalidrawListDrawings:eL,excalidrawReadScene:tL,excalidrawAddElements:nL,excalidrawUpdateElements:rL,excalidrawDeleteElements:oL,excalidrawConnectElements:sL,excalidrawSetAppState:iL,excalidrawResize:aL,excalidrawClearScene:lL,excalidrawFromMermaid:cL},Ug={name:"excalidraw",definitions:fb,operations:Ei,handlers:bc};function XM(){const n=[];for(const e of fb)Ei[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(Ei))bc[e]||n.push(`operation '${e}' has no handler`);for(const e of Object.keys(bc))Ei[e]||n.push(`handler '${e}' has no operation`);return n}const uL=S.lazy(()=>me(()=>import("./ExcalidrawModal-DaPSGYek.js"),[],import.meta.url)),nd=he();function dL(){const[n]=fe(),[e,t]=S.useState(!1),o=M0()?.lexicalId;S.useEffect(()=>{if(!n.hasNodes([Yn]))throw new Error("ExcalidrawPlugin: ExcalidrawNode not registered");return n.registerCommand(nd,()=>(t(!0),!0),V)},[n]),S.useEffect(()=>{if(o)return go.getState().registerPluginTools(o,Ug),()=>{go.getState().unregisterPluginTools(o,Ug.name)}},[o]);const s=(l,c,u)=>{n.update(()=>{const f=ju();f.setData(JSON.stringify({elements:l,appState:c,files:u})),Tr([f]),wt(f.getParentOrThrow())&&Fc(f,ne).selectEnd()}),t(!1)},i=()=>{t(!1)},a=()=>{t(!1)};return e?x.jsx(S.Suspense,{fallback:null,children:x.jsx(uL,{initialElements:[],initialAppState:{},initialFiles:{},isShown:e,onSave:s,onDelete:i,onClose:a,closeOnClickOutside:!1})}):null}const fL=S.lazy(()=>me(()=>import("./DeckComponent-CbmzVWcF.js"),[],import.meta.url));function gL(){return{deck:{title:"Untitled deck",template:"datalayer"},slides:[{type:"title",title:"A new slide",meta:"Double-click to edit its specification"}]}}function pL(n){const e=n.getAttribute("data-lexical-deck");if(!e)return null;try{return{node:rd(JSON.parse(e))}}catch{return null}}class Go extends Jo{__spec;static getType(){return"deck"}static clone(e){return new Go(e.__spec,e.__format,e.__key)}static importJSON(e){const t=rd(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:pL,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??gL()}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 x.jsx(S.Suspense,{fallback:null,children:x.jsx(fL,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),spec:this.__spec})})}isTopLevel(){return!0}}function rd(n){return new Go(n)}function GM(n){return n instanceof Go}const od=he("INSERT_DECK_COMMAND");function hL(n){if(!n.hasNodes([Go]))throw new Error("DeckExtension: DeckNode not registered on editor");return n.registerCommand(od,e=>(sr(rd(e)),!0),V)}const _L=pe({name:"@datalayer/jupyter-lexical/Deck",nodes:()=>[Go],register:hL}),zg="Kept in this page’s memory only: it is lost when the page reloads, and nobody else sees it. Download it to keep it.",hb={position:"relative",width:"100%",aspectRatio:"16 / 9",borderRadius:2,overflow:"hidden",bg:"black"};function mL(n){const e=Math.max(0,Math.floor(n/1e3));return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}function bL(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 yL({recordingId:n,recording:e}){const t=S.useRef(null),[r,o]=S.useState(()=>Date.now());return S.useEffect(()=>{t.current&&(t.current.srcObject=e.preview)},[e.preview]),S.useEffect(()=>{const s=window.setInterval(()=>o(Date.now()),500);return()=>window.clearInterval(s)},[]),x.jsxs(Y,{sx:{display:"grid",gap:2},children:[x.jsx(Y,{sx:hb,children:x.jsx("video",{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"100%",objectFit:"contain"}})}),x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[x.jsx(Y,{"aria-hidden":!0,sx:{width:10,height:10,borderRadius:"50%",bg:"danger.fg"}}),x.jsx(Le,{sx:{fontFamily:"mono"},"aria-live":"off",children:mL(r-e.startedAt)}),x.jsx(ft,{variant:"danger",leadingVisual:Nw,onClick:()=>Vu(n),sx:{ml:"auto"},children:"Stop"})]})]})}function wL({className:n,format:e,nodeKey:t,recordingId:r,recorded:o}){const[s]=fe(),i=Hr(),a=S.useSyncExternalStore(DN,()=>PN(r)),l=JN(o,a),[c,u]=S.useState("screen"),[f,d]=S.useState(!0),g=S.useCallback(w=>{s.update(()=>{const C=Q(t);_b(C)&&C.setRecorded(w)})},[s,t]),h=()=>{WN(r,{source:c,microphone:f},()=>g(!0))},_=()=>{HN(r),g(!1)},m=w=>{const C=document.createElement("a");C.href=w.url,C.download=UN(w),C.click()};let b;return a?.status==="recording"?b=x.jsx(yL,{recordingId:r,recording:a}):a?.status==="recorded"?b=x.jsxs(Y,{sx:{display:"grid",gap:2},children:[x.jsx(Y,{sx:hb,children:x.jsx("video",{src:a.url,controls:!0,playsInline:!0,onLoadedMetadata:bL,style:{width:"100%",height:"100%",objectFit:"contain"}})}),x.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:2},children:[x.jsx(Le,{sx:{color:"fg.muted",fontSize:0,flex:"1 1 240px"},children:zg}),x.jsx(ft,{leadingVisual:Ew,onClick:()=>m(a),children:"Download"}),i&&x.jsx(ft,{onClick:_,children:"Record again"})]})]}):l==="lost"?b=x.jsxs(Y,{sx:{display:"grid",gap:2,justifyItems:"start"},children:[x.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&&x.jsx(ft,{onClick:()=>g(!1),children:"Record a new one"})]}):i?b=x.jsxs(Y,{sx:{display:"grid",gap:2},children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[x.jsx(Wc,{size:16}),x.jsx(Le,{sx:{fontWeight:"bold"},children:"Video"})]}),x.jsxs(Le,{sx:{color:"fg.muted",fontSize:0},children:["Recorded by this browser, with no account. ",zg]}),FN()?x.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:3},children:[x.jsxs(Aa,{"aria-label":"What to record",size:"small",children:[x.jsx(Aa.Button,{selected:c==="screen",onClick:()=>u("screen"),children:"Screen"}),x.jsx(Aa.Button,{selected:c==="camera",onClick:()=>u("camera"),children:"Camera"})]}),x.jsxs(Mt,{children:[x.jsx(Mp,{checked:f,onChange:w=>d(w.target.checked)}),x.jsx(Mt.Label,{children:"Microphone"})]}),x.jsx(ft,{variant:"primary",onClick:h,children:"Record"})]}):x.jsx(Le,{sx:{color:"danger.fg",fontSize:1},children:"This browser cannot record video."}),a?.status==="failed"&&x.jsx(Le,{role:"alert",sx:{color:"danger.fg",fontSize:1},children:a.message})]}):b=x.jsx(Le,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:"A video goes here."}),x.jsx(Ls,{className:n,format:e,nodeKey:t,children:x.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:b})})}class Zn extends Jo{__recordingId;__recorded;static getType(){return"video"}static clone(e){return new Zn(e.__recordingId,e.__recorded,e.__format,e.__key)}static importJSON(e){const t=new Zn(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||jN(),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 x.jsx(wL,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),recordingId:this.__recordingId,recorded:this.__recorded})}isTopLevel(){return!0}}function xL(){return new Zn}function _b(n){return n instanceof Zn}const sd=he("INSERT_VIDEO_COMMAND");function CL(n){if(!n.hasNodes([Zn]))throw new Error("VideoExtension: VideoNode not registered on editor");return de(n.registerCommand(sd,()=>(sr(xL()),!0),V),n.registerMutationListener(Zn,(e,{prevEditorState:t})=>{for(const[r,o]of e){if(o!=="destroyed")continue;const s=t.read(()=>{const i=Q(r);return _b(i)?i.__recordingId:void 0});s&&Vu(s)}},{skipInitialization:!0}))}const SL=pe({name:"@datalayer/jupyter-lexical/Video",nodes:()=>[Zn],register:CL});function vL({onConfirm:n,onClose:e}){const[t,r]=S.useState("5"),[o,s]=S.useState("5"),i=S.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 x.jsx($p,{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:x.jsxs(Y,{sx:{display:"flex",flexDirection:"column",gap:3},onKeyDown:l,children:[x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:"Rows"}),x.jsx(vn,{ref:i,type:"number",min:1,max:500,value:t,onChange:c=>r(c.target.value),block:!0})]}),x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:"Columns"}),x.jsx(vn,{type:"number",min:1,max:50,value:o,onChange:c=>s(c.target.value),block:!0})]})]})})}const ws=he();function mb(){const[n]=fe(),[e,t]=S.useState(!1);S.useEffect(()=>n.registerCommand(ws,()=>(t(!0),!0),V),[n]);const r=(s,i)=>{n.dispatchCommand(nu,{rows:s.toString(),columns:i.toString()}),t(!1)},o=()=>{t(!1)};return e?x.jsx(vL,{onConfirm:r,onClose:o}):null}function ZM(){return x.jsxs(x.Fragment,{children:[x.jsx(P_,{}),x.jsx(mb,{})]})}const id=he("INSERT_EQUATION_COMMAND");function bb(n){if(!n.hasNodes([ir]))throw new Error("EquationsPlugins: EquationsNode not registered on editor");return n.registerCommand(id,e=>{const{equation:t,inline:r}=e,o=ya(t,r);return Tr([o]),wt(o.getParentOrThrow())&&Fc(o,ne).selectEnd(),!0},V)}const yb=pe({name:"@datalayer/jupyter-lexical/Equations",nodes:()=>[ir],register:bb});function ad({activeEditor:n,onClose:e}){const t=S.useCallback((r,o)=>{n.dispatchCommand(id,{equation:r,inline:o}),e()},[n,e]);return x.jsx(Vx,{onConfirm:t})}const Kg=()=>{const[n]=fe();return S.useEffect(()=>bb(n),[n]),null},kL=Object.freeze(Object.defineProperty({__proto__:null,EquationsPlugin:Kg,INSERT_EQUATION_COMMAND:id,InsertEquationDialog:ad,default:Kg},Symbol.toStringTag,{value:"Module"}));class ze extends Wm{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 TL({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){const s=S.useCallback(l=>o.setRefElement(l),[o]),i=o.disabled?void 0:t,a=o.disabled?void 0:r;return x.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:[x.jsx(Y,{sx:{display:"flex",alignItems:"center",color:"var(--fgColor-muted)",flexShrink:0},children:o.icon}),x.jsx(Le,{sx:{fontSize:1},children:o.title})]},o.key)}const IL=({kernel:n,initCode:e=""}={})=>{const[t]=fe(),[r,o]=Xo(),[s,i]=S.useState(null),a=Hm("/",{minLength:0}),l=S.useCallback(()=>{const f=[];if(s==null)return f;const d=new RegExp(/^([1-9]|10)x([1-9]|10)$/),g=new RegExp(/^([1-9]|10)x?$/),h=d.exec(s),_=g.exec(s);if(h){const[m,b]=h[0].split("x").map(w=>parseInt(w,10));f.push(new ze(`${m}x${b} Table`,{icon:x.jsx(yi,{size:16}),keywords:["table"],onSelect:()=>t.dispatchCommand(ws,void 0)}))}else if(_){const m=parseInt(_[0],10);f.push(...Array.from({length:5},(b,w)=>w+1).map(b=>new ze(`${m}x${b} Table`,{icon:x.jsx(yi,{size:16}),keywords:["table"],onSelect:()=>t.dispatchCommand(ws,void 0)})))}return f},[t,s]),c=S.useMemo(()=>{const f=[new ze("Jupyter Cell",{icon:x.jsx(br,{size:16}),keywords:["javascript","python","js","codeblock","jupyter"],onSelect:()=>{t.dispatchCommand(Vi,{code:e,outputs:ac,loading:"Loading..."})}}),new ze("Marimo Cell",{icon:x.jsx(br,{size:16}),keywords:["marimo","reactive","python","cell"],onSelect:()=>{t.dispatchCommand(Vi,{code:e,outputs:ac,loading:"Loading...",variant:"marimo"})}}),new ze("Paragraph",{icon:x.jsx(Ih,{size:16}),keywords:["normal","paragraph","p","text"],onSelect:()=>t.update(()=>{const g=D();F(g)&&Un(g,()=>ne())})}),...Array.from({length:3},(g,h)=>h+1).map(g=>new ze(`Heading ${g}`,{icon:x.jsx(tx,{size:16}),keywords:["heading","header",`h${g}`],onSelect:()=>t.update(()=>{const h=D();F(h)&&Un(h,()=>fn(`h${g}`))})})),new ze("Numbered List",{icon:x.jsx(Eh,{size:16}),keywords:["numbered list","ordered list","ol"],onSelect:()=>t.dispatchCommand(eu,void 0)}),new ze("Bulleted List",{icon:x.jsx(vh,{size:16}),keywords:["bulleted list","unordered list","ul"],onSelect:()=>t.dispatchCommand(Qc,void 0)}),new ze("Check List",{icon:x.jsx(Lw,{size:16}),keywords:["check list","todo list"],onSelect:()=>t.dispatchCommand(Zc,void 0)}),new ze("Table",{icon:x.jsx(yi,{size:16}),keywords:["table","grid","spreadsheet"],onSelect:()=>{ge("[ComponentPicker] Table selected, dispatching INSERT_TABLE_WITH_DIALOG_COMMAND"),t.dispatchCommand(ws,void 0)}}),new ze("Collapsible Container",{icon:x.jsx(zc,{size:16}),keywords:["collapsible","collapse","expand","toggle","accordion","container"],onSelect:()=>t.dispatchCommand(Xu,void 0)}),new ze("Excalidraw",{icon:x.jsx(Ow,{size:16}),keywords:["excalidraw","drawing","diagram","sketch","whiteboard","draw"],onSelect:()=>t.dispatchCommand(nd,void 0)}),new ze("Video",{icon:x.jsx(Wc,{size:16}),keywords:["video","record","recording","screen","camera","webcam"],onSelect:()=>t.dispatchCommand(sd,void 0)}),new ze("Loom Video",{icon:x.jsx(Ws,{size:16}),keywords:["loom","video","record","recording","screen"],onSelect:()=>t.dispatchCommand(ka,void 0)}),new ze("Deck Slide",{icon:x.jsx(hs,{size:16}),keywords:["deck","slide","slides","presentation","pitch"],onSelect:()=>t.dispatchCommand(od,void 0)}),new ze("Quote",{icon:x.jsx(Nh,{size:16}),keywords:["block quote"],onSelect:()=>t.update(()=>{const g=D();F(g)&&Un(g,()=>Ln())})}),new ze("Code",{icon:x.jsx(br,{size:16}),keywords:["javascript","python","js","codeblock"],onSelect:()=>t.update(()=>{const g=D();if(F(g))if(g.isCollapsed())Un(g,()=>Ze());else{const h=g.getTextContent(),_=Ze();g.insertNodes([_]),g.insertRawText(h)}})}),new ze("Divider",{icon:x.jsx(ji,{size:16}),keywords:["horizontal rule","divider","hr"],onSelect:()=>t.dispatchCommand(Kc,void 0)}),...qu.map(g=>new ze(`Embed ${g.contentName}`,{icon:g.icon,keywords:[...g.keywords,"embed"],onSelect:()=>t.dispatchCommand(Ju,g.type)})),new ze("Equation",{icon:x.jsx(Rw,{size:16}),keywords:["equation","latex","math"],onSelect:()=>o("Insert Equation",g=>x.jsx(ad,{activeEditor:t,onClose:g}))}),new ze("GIF",{icon:x.jsx(hs,{size:16}),keywords:["gif","animate","image","file"],onSelect:()=>{yu().then(g=>{g&&t.dispatchCommand(Ys,g)})}}),new ze("Image",{icon:x.jsx(hs,{size:16}),keywords:["image","photo","picture","file"],onSelect:()=>o("Insert Image",g=>x.jsx(z_,{activeEditor:t,onClose:g}))}),...["left","center","right","justify"].map(g=>new ze(`Align ${g}`,{icon:g==="left"?x.jsx(nx,{size:16}):g==="right"?x.jsx(rx,{size:16}):x.jsx(ji,{size:16}),keywords:["align","justify",g],onSelect:()=>t.dispatchCommand(Bn,g)}))],d=l();return s?[...d,...f.filter(g=>new RegExp(s,"gi").exec(g.title)||g.keywords!=null?g.keywords.some(h=>new RegExp(s,"gi").exec(h)):!1)]:f},[t,l,s,o,n,e]),u=S.useCallback((f,d,g,h)=>{f.disabled||t.update(()=>{d&&d.remove(),f.onSelect(h),g()})},[t]);return x.jsxs(x.Fragment,{children:[r,x.jsx(Jm,{onQueryChange:i,onSelectOption:u,triggerFn:a,options:c,menuRenderFn:(f,{selectedIndex:d,selectOptionAndCleanUp:g,setHighlightedIndex:h})=>f.current&&c.length?St.createPortal(x.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:x.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0},children:c.map((_,m)=>x.jsx(TL,{index:m,isSelected:d===m,onClick:()=>{_.disabled||(h(m),g(_))},onMouseEnter:()=>{_.disabled||h(m)},option:_},_.key))})}),f.current):null})]})},yc=4,EL=2,NL="draggable-block-menu",Wg="application/x-lexical-drag-block",Hg=28,LL=1,OL=-1,Jg=0;let Ni=1/0;function RL(n){return n===0?1/0:Ni>=0&&Ni<n?Ni:Math.floor(n/2)}function AL(n){return n.getEditorState().read(()=>se().getChildrenKeys())}function wb(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 _l(n,e,t,r=!1){const o=n.getBoundingClientRect(),s=AL(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 g=Wn(c),h=Wn(u);if(t.y/g<f.top?i=c:t.y/h>d.bottom&&(i=u),i)return}}let a=RL(s.length),l=Jg;for(;a>=0&&a<s.length;){const c=s[a],u=e.getElementByKey(c);if(u===null)break;const f=Wn(u),d=new zm(t.x/f,t.y/f),g=pr.fromDOM(u),{marginTop:h,marginBottom:_}=wb(u),m=g.generateNewRect({bottom:g.bottom+_,left:o.left,right:o.right,top:g.top-h}),{result:b,reason:{isOnTopSide:w,isOnBottomSide:C}}=m.contains(d);if(b){i=u,Ni=a;break}l===Jg&&(w?l=OL:C?l=LL:l=1/0),a+=l}}),i}function ML(n){return!!n.closest(`.${NL}`)}function xb(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 $L(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}=xb(t),c=(parseInt(o.lineHeight,10)-s.height)/2,u=r.top+c-i.top+a,f=yc;e.style.opacity="1",e.style.transform=`translate(${f}px, ${u}px)`}function DL(n,e){const{transform:t}=e.style;e.style.transform="translateZ(0)",n.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=t})}function PL(n,e,t,r){const{top:o,height:s}=e.getBoundingClientRect(),{top:i,width:a}=r.getBoundingClientRect(),{marginTop:l,marginBottom:c}=wb(e),{scrollTop:u}=xb(r);let f=o;t>=o?f+=s+c/2:f-=l/2;const d=f-i-EL+u,g=Hg-yc;n.style.transform=`translate(${g}px, ${d}px)`,n.style.width=`${a-(Hg-yc)*2}px`,n.style.opacity=".4"}function jL(n){n&&(n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)")}function FL(n,e,t){const r=S.useRef(null),o=S.useRef(null),s=S.useRef(!1),[i,a]=S.useState(null),l=n._config.theme,c=l.draggableBlockMenu||"",u=l.draggableBlockTargetLine||"";S.useEffect(()=>{function g(_){const m=_.target;if(!pl(m)){a(null);return}if(!e.contains(m)||ML(m))return;const b=_l(e,n,_);a(b)}function h(){a(null)}return document.addEventListener("mousemove",g),document.addEventListener("mouseleave",h),()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseleave",h)}},[e,n]),S.useEffect(()=>{r.current&&$L(i,r.current,e)},[e,i]),S.useEffect(()=>{function g(_){if(!s.current)return!1;const[m]=uo(_);if(m)return!1;const{pageY:b,target:w}=_;if(!pl(w))return!1;const C=_l(e,n,_,!0),v=o.current;return C===null||v===null?!1:(PL(v,C,b/Wn(w),e),_.preventDefault(),!0)}function h(_){if(!s.current)return!1;const[m]=uo(_);if(m)return!1;const{target:b,dataTransfer:w,pageY:C}=_,v=w?.getData(Wg)||"",k=Q(v);if(!k||!pl(b))return!1;const I=_l(e,n,_,!0);if(!I)return!1;const E=Ae(I);if(!E)return!1;if(E===k)return!0;const N=I.getBoundingClientRect().top;return C/Wn(b)>=N?E.insertAfter(k):E.insertBefore(k),a(null),!0}return de(n.registerCommand(Nc,_=>g(_),ee),n.registerCommand(Lc,_=>h(_),qe))},[e,n]);function f(g){const h=g.dataTransfer;if(!h||!i)return;DL(h,i);let _="";n.update(()=>{const m=Ae(i);m&&(_=m.getKey())}),s.current=!0,h.setData(Wg,_)}function d(){s.current=!1,jL(o.current)}return St.createPortal(x.jsxs(x.Fragment,{children:[x.jsx("div",{className:`draggable-block-menu ${c}`,ref:r,draggable:!0,onDragStart:f,onDragEnd:d,children:t?x.jsx(Aw,{size:16}):null}),x.jsx("div",{className:`draggable-block-target-line ${u}`,ref:o})]}),e)}function QM({anchorElem:n=document.body}){const[e]=fe();return FL(e,n,e._editable)}const BL=()=>x.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:[x.jsx("path",{d:"M4.5 2v5.5a3.5 3.5 0 1 0 7 0V2H13v5.5a5 5 0 0 1-10 0V2h1.5Z"}),x.jsx("rect",{x:"2",y:"14",width:"12",height:"1.5",rx:".75"})]});function UL(n,e,t,r){const[o,s]=S.useState(!1),[i,a]=S.useState(!1),[l,c]=S.useState(!1),[u,f]=S.useState(!1),[d,g]=S.useState(!1),[h,_]=S.useState(!1),[m,b]=S.useState(!1),[w,C]=S.useState(!1),[v,k]=S.useState(!1),I=S.useCallback(()=>{n.getEditorState().read(()=>{if(n.isComposing())return;const M=D(),R=window.getSelection(),$=n.getRootElement();if(R!==null&&(!F(M)||$===null||!$.contains(R.anchorNode))){s(!1);return}if(!F(M))return;const L=Bm(M);c(M.hasFormat("bold")),f(M.hasFormat("italic")),g(M.hasFormat("underline")),_(M.hasFormat("strikethrough")),b(M.hasFormat("subscript")),C(M.hasFormat("superscript")),k(M.hasFormat("code"));const A=L.getParent();Pe(A)||Pe(L)?a(!0):a(!1),!Ve(M.anchor.getNode())&&M.getTextContent()!==""?s(oe(L)):s(!1)})},[n]);S.useEffect(()=>(document.addEventListener("selectionchange",I),()=>{document.removeEventListener("selectionchange",I)}),[I]),S.useEffect(()=>de(n.registerUpdateListener(()=>{I()}),n.registerRootListener(()=>{n.getRootElement()===null&&s(!1)}),n.registerCommand(ys,()=>(s(!1),!1),ee)),[n,I]);const E=S.useCallback(()=>{i?(t(!1),n.dispatchCommand(Lr,null)):(t(!0),n.dispatchCommand(Lr,"https://example.com"))},[n,i,t]),N=S.useMemo(()=>n.isEditable()?[{key:"bold",type:"button",order:0,ariaLabel:"Format text as bold",title:"Bold",icon:Lh,isActive:l,onClick:()=>n.dispatchCommand(Ge,"bold")},{key:"italic",type:"button",order:1,ariaLabel:"Format text as italics",title:"Italic",icon:Oh,isActive:u,onClick:()=>n.dispatchCommand(Ge,"italic")},{key:"underline",type:"button",order:2,ariaLabel:"Format text to underlined",title:"Underline",icon:BL,isActive:d,onClick:()=>n.dispatchCommand(Ge,"underline")},{key:"strikethrough",type:"button",order:3,ariaLabel:"Format text with a strikethrough",title:"Strikethrough",icon:Rh,isActive:h,onClick:()=>n.dispatchCommand(Ge,"strikethrough")},{key:"subscript",type:"button",order:4,ariaLabel:"Format Subscript",title:"Subscript",icon:void 0,label:"x₂",isActive:m,onClick:()=>n.dispatchCommand(Ge,"subscript")},{key:"superscript",type:"button",order:5,ariaLabel:"Format Superscript",title:"Superscript",icon:void 0,label:"x²",isActive:w,onClick:()=>n.dispatchCommand(Ge,"superscript")},{key:"code",type:"button",order:6,ariaLabel:"Insert code block",title:"Code",icon:br,isActive:v,onClick:()=>n.dispatchCommand(Ge,"code")},{key:"link",type:"button",order:7,ariaLabel:"Insert link",title:"Link",icon:Ah,isActive:i,onClick:E},{key:"comment",type:"button",order:8,ariaLabel:"Insert comment",title:"Comment",icon:Pi,onClick:()=>n.dispatchCommand(ys,void 0)}]:[{key:"comment",type:"button",order:100,ariaLabel:"Insert comment",icon:Pi,onClick:()=>n.dispatchCommand(ys,void 0)}],[n,l,u,d,h,m,w,v,i,E]),O=o&&!i;return x.jsx(Tx,{items:N,extraItems:r,anchorElement:e,isVisible:O,ariaLabel:"Floating text format toolbar"})}function e$({anchorElem:n=document.body,setIsLinkEditMode:e,extraItems:t}){const[r]=fe();return UL(r,n,e,t)}function zL(n){return n.registerCommand(Kc,()=>{const e=D();if(!F(e))return!1;if(e.focus.getNode()!==null){const r=ba();e.insertParagraph(),e.focus.getNode().getTopLevelElementOrThrow().insertBefore(r)}return!0},V)}const Cb=pe({name:"@datalayer/jupyter-lexical/HorizontalRule",nodes:()=>[mu],register:zL}),ss={code:{triggerMode:"auto",contextBefore:-1,contextAfter:-1,language:"python"},prose:{triggerMode:"manual",contextBefore:-1,contextAfter:-1},debounceMs:200,manualTriggerKey:"Cmd+Shift+,"};function KL(n){return n?{code:{...ss.code,...n.code},prose:{...ss.prose,...n.prose},debounceMs:n.debounceMs??ss.debounceMs,manualTriggerKey:n.manualTriggerKey??ss.manualTriggerKey}:{...ss}}function t$(n){return n===-1||n>=0}function n$(n){return n.triggerMode==="auto"}function r$(n){return n.triggerMode==="manual"||n.triggerMode==="auto"}function o$(n){return n.triggerMode==="disabled"}const qg="jupyter-cell";class Fr extends Bt{__code;__outputs;__loading;__autoStart;__data;__variant;static getType(){return qg}static clone(e){return console.debug(`clone: node: ${JSON.stringify(e,null,2)}`),new Fr(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}`),x.jsx(_x,{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 Fr(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:qg,version:1}}}function Vg(n){const{code:e,outputs:t,loading:r,autoStart:o}=n;return new Fr(e,t,r,o)}function s$(n){return n instanceof Fr}const WL=he(),HL=he();function JL(n){if(!n.hasNodes([Fr]))throw new Error("JupyterCellNode is not registered.");return de(n.registerCommand(WL,e=>{const t=Vg(e);return Tr([t]),!0},V),n.registerCommand(HL,e=>{const t=Vg({...e});return Tr([t]),!0},V))}const qL=pe({name:"@datalayer/jupyter-lexical/JupyterCell",nodes:()=>[Fr],register:JL}),VL=he("INSERT_LAYOUT_COMMAND");function YL(n){return n.trim().split(/\s+/).length}function i$(n){return Array.from({length:Math.max(1,n)},()=>"1fr").join(" ")}function XL(n){if(!n.hasNodes([Dr,Pr]))throw new Error("LayoutPlugin: LayoutContainerNode, or LayoutItemNode not registered on editor");const e=t=>{const r=D();if(F(r)&&r.isCollapsed()&&r.anchor.offset===0){const o=re(r.anchor.getNode(),Ci);if(Ci(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(Vt,()=>e(!1),ee),n.registerCommand(ia,()=>e(!1),ee),n.registerCommand(pt,()=>e(!0),ee),n.registerCommand(zs,()=>e(!0),ee),n.registerCommand(VL,t=>(n.update(()=>{const r=Ou(t);for(let o=0;o<YL(t);o++)r.append(Ru().append(ne()));sr(r),r.selectStart()}),!0),V),n.registerNodeTransform(Pr,t=>{const r=t.getParent();if(!Ci(r)){for(const o of t.getChildren())t.insertBefore(o);t.remove();return}t.isEmpty()&&t.append(ne())}),n.registerNodeTransform(Dr,t=>{const r=t.getChildren();if(!r.every(Au)){for(const o of r)t.insertBefore(o);t.remove();return}r.length===0&&t.remove()}))}const GL=pe({name:"@datalayer/jupyter-lexical/Layout",nodes:()=>[Dr,Pr],register:XL});function Yg(n,e,t,r,o){return n==="code"?ZL(e,t):QL(e,t,r,o)}function ZL(n,e){const t=n.getTextContent(),r=nO(n,e),o=t.substring(0,r),s=t.substring(r);return{before:o,after:s,fullText:t}}function QL(n,e,t,r){const s=se().getChildren(),i=eO(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=tO(i,e);u+=f.substring(0,d);let g=f.substring(d);for(let _=a+1;_<=c;_++)g+=`
|
|
216
216
|
`+s[_].getTextContent();const h=u+g;return{before:u,after:g,fullText:h}}function eO(n){let e=n;for(;e;){if(ht(e)||e.getType()==="heading"||e.getType()==="listitem")return e;e=e.getParent()}return se()}function tO(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 nO(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 rO(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 oO(n,e){if(!e||e.length===0)return x.jsx(x.Fragment,{children:n});const t=n.toLowerCase(),r=e.toLowerCase(),o=t.indexOf(r);if(o===-1)return x.jsx(x.Fragment,{children:n});const s=n.substring(0,o),i=n.substring(o,o+e.length),a=n.substring(o+e.length);return x.jsxs(x.Fragment,{children:[s,x.jsx("strong",{style:{color:"var(--vscode-editorSuggestWidget-highlightForeground)",fontWeight:"bold"},children:i}),a]})}function sO({items:n,onSelect:e,onClose:t,position:r,filterText:o}){const[s,i]=S.useState(0),[a,l]=S.useState(r),c=S.useRef(null),u=S.useRef([]),f=S.useRef(null);return S.useEffect(()=>{const d=window.getSelection();if(d&&d.rangeCount>0){const g=d.getRangeAt(0);f.current=g.startContainer.parentElement}},[]),S.useEffect(()=>{const d=()=>{const g=window.getSelection();if(!g||g.rangeCount===0)return;const _=g.getRangeAt(0).getBoundingClientRect();l({top:_.bottom+window.scrollY,left:_.left+window.scrollX})};return window.addEventListener("scroll",d,!0),()=>window.removeEventListener("scroll",d,!0)},[]),S.useEffect(()=>{const d=u.current[s];d&&d.scrollIntoView({block:"nearest"})},[s]),S.useEffect(()=>{const d=g=>{switch(g.key){case"ArrowDown":g.preventDefault(),i(h=>Math.min(h+1,n.length-1));break;case"ArrowUp":g.preventDefault(),i(h=>Math.max(h-1,0));break;case"Enter":g.preventDefault(),n[s]&&e(n[s]);break;case"Escape":g.preventDefault(),t();break;case"Tab":g.preventDefault(),n[s]&&e(n[s]);break}};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,n,e,t]),S.useEffect(()=>{const d=g=>{c.current&&!c.current.contains(g.target)&&t()};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[t]),n.length===0?x.jsx(x.Fragment,{}):x.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:x.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0"},children:n.map((d,g)=>{const h=g===s;return x.jsxs("li",{ref:_=>{u.current[g]=_},onClick:()=>e(d),onMouseEnter:()=>i(g),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:[x.jsx("span",{style:{opacity:.7,fontSize:"12px",minWidth:"16px",textAlign:"center"},children:rO(d.kind)}),x.jsx("span",{style:{flex:1},children:oO(d.label,o)}),d.detail&&x.jsx("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"auto"},children:d.detail})]},`${d.label}-${g}`)})})})}const wc=he("LSP_MENU_STATE_COMMAND"),xc=he("LSP_COMPLETION_INSERTED_COMMAND");function ml(n,e,t){let r=0;function o(i){if(i===e)return r+=t,!0;if(q(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 iO(n){const e=n.getChildren();for(const t of e)if(ds(t))return!0;return!1}function Xg(n){let e=n;for(;e;){if(st(e))return e;e=e.getParent()}return null}function aO(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 lO(n){const e=n.getLanguage();return!e||e==="python"||e==="py"?"python":e==="markdown"||e==="md"||e==="text"?"markdown":"unknown"}function cO(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 a$({providers:n,disabled:e=!1}){const[t]=fe(),[r,o]=S.useState([]),[s,i]=S.useState([]),[a,l]=S.useState(!1),[c,u]=S.useState({top:0,left:0}),[f,d]=S.useState(""),g=S.useRef(0),h=S.useRef(null),_=S.useCallback(()=>{const C=window.getSelection();if(!C||C.rangeCount===0)return{top:0,left:0};const k=C.getRangeAt(0).getBoundingClientRect();return{top:k.bottom+window.scrollY,left:k.left+window.scrollX}},[]),m=S.useCallback(()=>{l(!1),o([]),i([]),d(""),g.current=0,h.current=null,t.dispatchCommand(wc,!1)},[t]),b=S.useCallback(C=>{t.update(()=>{const v=D();if(!F(v))return;const k=v.anchor.getNode(),I=v.anchor.offset,E=h.current;if(E){const O=ml(E,k,I)-g.current;if(O>0){const M=I-O;if(M>=0){const R=k.getKey();v.anchor.set(R,M,"text"),v.focus.set(R,I,"text")}}}v.insertText(C.insertText)}),t.dispatchCommand(xc,void 0),m()},[t,m]);S.useEffect(()=>{if(!(!a||r.length===0))return t.registerUpdateListener(({editorState:C})=>{C.read(()=>{const v=D();if(!F(v)||!v.isCollapsed()){m();return}const k=v.anchor.getNode(),I=h.current;if(!I)return;const E=Xg(k);if(!E){m();return}const N=E.getJupyterInputNodeUuid(),O=I.getJupyterInputNodeUuid();if(N!==O){m();return}h.current=E;const M=v.anchor.offset,R=ml(E,k,M);if(R<g.current){m();return}const L=E.getTextContent().substring(g.current,R),A=cO(r,L);i(A),d(L),A.length===0&&m()})})},[t,a,r,m]);const w=S.useCallback(async(C,v)=>{if(n.length===0||e)return;const k=C.getJupyterInputNodeUuid(),I=C.getTextContent(),E=lO(C);if(E==="unknown")return;const N=aO(I,v),M=(await Promise.all(n.map(R=>R.fetchCompletions(k,I,N,E)))).flat();if(M.length===1){const R=M[0];t.update(()=>{const $=D();if(F($)){const L=$.anchor.getNode(),A=$.anchor.offset,B=L.getTextContent();let j=A;for(;j>0&&/[a-zA-Z0-9_]/.test(B[j-1]);)j--;if(A-j>0){const z=L.getKey();$.anchor.set(z,j,"text"),$.focus.set(z,A,"text")}$.insertText(R.insertText)}}),t.dispatchCommand(xc,void 0)}else if(M.length>1){const R=_();u(R),o(M),i(M),d(""),g.current=v,h.current=C,l(!0),t.dispatchCommand(wc,!0)}},[n,e,_,t]);return S.useEffect(()=>{if(!e)return t.registerCommand(Kr,C=>{const v=D();if(!F(v)||!v.isCollapsed())return!1;const k=v.anchor.getNode(),I=Xg(k);if(!I||iO(I))return!1;if(a)return C?.preventDefault(),!0;C?.preventDefault();const E=v.anchor.getNode(),N=v.anchor.offset,O=ml(I,E,N);return w(I,O),!0},bo)},[t,e,a,w]),e||n.length===0?null:a&&s.length>0?x.jsx(sO,{items:s,onSelect:b,onClose:m,position:c,filterText:f}):null}const Gg=he("TRIGGER_INLINE_COMPLETION_COMMAND");function uO({providers:n,debounceMs:e,enabled:t=!0,config:r}){const[o]=fe(),[s,i]=S.useState(null),[a,l]=S.useState(!1),c=S.useMemo(()=>KL(r),[r]),u=r?.debounceMs??e??Math.max(c.debounceMs,500),f=S.useRef(null),d=S.useRef(""),g=S.useRef(""),h=S.useRef(null),_=S.useRef(null),m=S.useRef(0);S.useEffect(()=>()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]),S.useEffect(()=>{if(t)return o.registerCommand(wc,w=>(l(w),w&&(f.current&&(clearTimeout(f.current),f.current=null),i(null)),!1),ee)},[o,t]),S.useEffect(()=>{if(t)return o.registerCommand(xc,()=>(m.current=Date.now(),i(null),!1),ee)},[o,t]);const b=S.useCallback(async(w,C,v,k="code",I="auto")=>{if(!n||n.length===0)return;const E=n[0];try{const N=w.substring(0,C),O=w.substring(C),M=await E.fetch({text:w,offset:C,language:v,contentType:k},{before:N,after:O,inCodeCell:k==="code",triggerKind:I});if(M&&M.items&&M.items.length>0){const R=M.items[0].insertText;i(R)}else i(null)}catch(N){console.error("[InlineCompletionPlugin] Error requesting completion:",N),i(null)}},[n]);return S.useEffect(()=>{_.current=b},[b]),S.useEffect(()=>{if(t)return o.registerUpdateListener(({editorState:w})=>{w.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 k=D();if(!F(k)||!k.isCollapsed()){i(null);return}const I=k.anchor.getNode(),E=Zg(I),N=E==="code"?c.code:c.prose;if(ge("[InlineCompletionPlugin] Auto-trigger check:",{contentType:E,triggerMode:N.triggerMode,willTrigger:N.triggerMode==="auto"}),N.triggerMode==="auto")if(E==="code"){const O=bl(I);if(!O){i(null);return}const M=O.getTextContent(),R=Qg(O,k);if(M===g.current)return;g.current=M;const $=M.substring(0,R);if($.trim().length===0){i(null);return}const L=$.lastIndexOf(`
|
|
@@ -224,16 +224,16 @@ ${n.stack}`:r}function Mk(){let n,e;try{const o=p.__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 lo(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=lo(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 tp(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 pO{_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=yl(this._editor,e);t(r)})}async getBlock(e){return new Promise(t=>{const r=yl(this._editor,"detailed");e>=0&&e<r.length?t(r[e]):t(null)})}async getBlockById(e){return new Promise(t=>{const o=yl(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(g=>g.getKey()===s);if(!c||c.getType()!=="collapsible-container"){i({success:!1,error:`Collapsible container ${s} not found`});return}const f=(c.getChildren?.()||[]).find(g=>g.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(g=>{if(!g.success||!g.blockId){i({success:!1,error:`Failed to insert ${e.block_type}: ${g.error||"Unknown error"}`});return}setTimeout(()=>{this._editor.update(()=>{const m=se().getChildren().find(b=>b.getKey()===g.blockId);if(!m){i({success:!1,error:`Could not find inserted node ${g.blockId}`});return}m.remove(),f.append(m),i({success:!0,blockId:g.blockId,message:`Block of type '${e.block_type}' inserted inside collapsible ${s}`})})},50)}).catch(g=>{i({success:!1,error:`Failed to insert block: ${g.message||String(g)}`})})})})}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=D();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,g="";const h=m=>{if(m.getType()==="jupyter-cell"&&m.getKey()===e)return m.getChildren().forEach(C=>{C.getType()==="jupyter-input"?g=C.getTextContent():C.getType()==="jupyter-output"&&(d=C)}),!0;if(m.getType()==="jupyter-input"&&m.getKey()===e){g=m.getTextContent();const w=m.getJupyterInputNodeUuid();return d=dr(w),!0}const b=m.getChildren?.()||[];for(const w of b)if(h(w))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(!g||g.trim()===""){u(new Error("No code to execute"));return}d.executeCode(g);const _=d.__outputAdapter;if(!_){u(new Error("No outputAdapter available"));return}c({outputAdapter:_,code:g})}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(()=>Uf),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(()=>kL);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($e("__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(()=>Uf);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 g=null;if(f.getType()===d&&(g=f),"getChildren"in f&&typeof f.getChildren=="function")for(const h of f.getChildren()){const _=c(h,d);_&&(g=_)}return g},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-
|
|
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(()=>n1);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.
|
|
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 g=null;if(f.getType()===d&&(g=f),"getChildren"in f&&typeof f.getChildren=="function")for(const h of f.getChildren()){const _=c(h,d);_&&(g=_)}return g},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-BEQBWMwx.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(()=>n1);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.tx);return{$wrapNodeInElement:f}},[],import.meta.url),{$isRootOrShadowRoot:i}=await me(async()=>{const{$isRootOrShadowRoot:f}=await import("../datalayer-app-main.js").then(d=>d.tw);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:g}=await Promise.resolve().then(()=>Tf);return{INSERT_TABLE_COMMAND:g}},void 0,import.meta.url),{$getTableCellNodeFromLexicalNode:s,$getTableNodeFromLexicalNodeOrThrow:i}=await me(async()=>{const{$getTableCellNodeFromLexicalNode:g,$getTableNodeFromLexicalNodeOrThrow:h}=await Promise.resolve().then(()=>Tf);return{$getTableCellNodeFromLexicalNode:g,$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 g=f.split(`
|
|
230
|
-
`).filter(_=>_.trim()),h=[];for(const _ of g){if(_.match(/^\|?[\s-|]+\|?$/))continue;const m=_.split("|").slice(1,-1).map(b=>b.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 b=i(h[_]).getChildren();for(let w=0;w<Math.min(c.length,b.length);w++){const v=b[w].getChildren();for(let k=0;k<Math.min(c[w].length,v.length);k++){const I=s(v[k]);I&&(I.clear(),I.append($e(c[w][k])))}}}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("./index-
|
|
230
|
+
`).filter(_=>_.trim()),h=[];for(const _ of g){if(_.match(/^\|?[\s-|]+\|?$/))continue;const m=_.split("|").slice(1,-1).map(b=>b.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 b=i(h[_]).getChildren();for(let w=0;w<Math.min(c.length,b.length);w++){const v=b[w].getChildren();for(let k=0;k<Math.min(c[w].length,v.length);k++){const I=s(v[k]);I&&(I.clear(),I.append($e(c[w][k])))}}}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("./index-CsgaCZaW.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($e(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=$e(o.text);return o.format&&s.setFormat(o.format),s}):tp(t||"").map(s=>{const i=$e(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=fn(s);return r().forEach(a=>i.append(a)),i}case"code":{const o=e.metadata?.language||"plaintext",s=Ze(o);return s.append($e(t)),s}case"quote":{const o=Ln();return r().forEach(s=>o.append(s)),o}case"list":{const o=e.metadata?.listType||"bullet",s=Et(o),i=t.split(`
|
|
233
233
|
`).map(a=>a.trim()).filter(a=>a.length>0);if(i.length===0){const a=xt();s.append(a)}else i.forEach(a=>{const l=xt();tp(a).forEach(u=>{const f=$e(u.text);u.format&&f.setFormat(u.format),l.append(f)}),s.append(l)});return s}case"horizontalrule":return ba();case"listitem":{const o=xt();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($e("__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-
|
|
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($e("__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-BJ6mpMWn.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 Sb(n,e,t){const r=new pO(n,t),o=new Map(go.getState().lexicals);return o.set(e,{adapter:r}),go.getState().setLexicals(o),()=>{const s=new Map(go.getState().lexicals);s.delete(e),go.getState().setLexicals(s)}}const hO=pe({name:"@datalayer/jupyter-lexical/LexicalState",config:tr({lexicalId:null,serviceManager:void 0}),build:(n,e)=>nr(e),register:(n,e,t)=>{const{lexicalId:r,serviceManager:o}=t.getOutput();return zt(()=>{const s=r.value;if(s)return Sb(n,s,o.value)})}});function l$(){const[n]=fe(),{lexicalId:e,serviceManager:t}=A0();return S.useEffect(()=>Sb(n,e,t),[n,e,t]),null}const vb=7;function _O(n){const e=n.getNodes();return e.length===0?new Set([n.anchor.getNode().getParentOrThrow(),n.focus.getNode().getParentOrThrow()]):new Set(e.map(t=>q(t)?t:t.getParentOrThrow()))}function mO(n){const e=D();if(!F(e))return!1;const t=_O(e);let r=0;for(const o of t)if(Z(o))r=Math.max(Is(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(Is(s)+1,r)}return r<=n}function bO(n,e=vb){return n.registerCommand(Dt,()=>!mO(e),qe)}const yO=pe({name:"@datalayer/jupyter-lexical/ListMaxIndentLevel",config:tr({maxDepth:vb}),dependencies:[da],build:(n,e)=>nr(e),register:(n,e,t)=>{const{maxDepth:r}=t.getOutput();return zt(()=>bO(n,r.value))}});function Cc(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 wO(n){const e=Cc(n,t=>t.type);return{element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const np=/[!-/:-@[-`{-~\s]/;function rp(n){return n.replace(/\\([!-/:-@[-`{-~])/g,"$1").replace(/&#(\d+);/g,(e,t)=>String.fromCodePoint(Number(t)))}const xO=/^(\s*)(\d{1,})\.\s/,CO=/^(\s*)[-*+]\s/,SO=/^(#{1,6})\s/,vO=/^>\s/,kO=/^([ \t]*`{3,})([\w-]+)?[ \t]?/,TO=/^[ \t]*`{3,}$/,fs=Us("mdListMarker",{parse:n=>typeof n=="string"&&/^[-*+]$/.test(n)?n:"-",resetOnCopyNode:!0}),op=Us("mdCodeFence",{parse:n=>typeof n=="string"&&/^`{3,}$/.test(n)?n:"```",resetOnCopyNode:!0}),IO=Us("mdHardLineBreak",{parse:n=>typeof n=="string"&&/^(\\| {2,})$/.test(n)?n:"",resetOnCopyNode:!0});function EO(n){if(n.endsWith("\\"))return[n.slice(0,-1),"\\"];const e=n.match(/^(.*?\S)( {2,})$/);return e?[e[1],e[2]]:null}function NO(n){const e=n.getChildren(),t=e.length-1,r=e[t];if(!oe(r))return null;const o=r.getTextContent(),s=EO(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 LO(n){const e=vt(),t=NO(n);return t!==null&&xn(e,IO,t),e}const kb=n=>(e,t,r,o)=>{const s=n(r);s.append(...t),e.replace(s),o||s.select(0,0)},Tb=n=>(e,t,r,o)=>{if(Wr(e))return!1;const s=e.getPreviousSibling(),i=e.getNextSibling(),a=xt(n==="check"?r[3]==="x":void 0),l=r[0].trim()[0],c=n!=="bullet"&&n!=="check"||l!==fs.parse(l)?void 0:l;if(Z(i)&&i.getListType()===n){c&&xn(i,fs,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&&xn(s,fs,c),s.append(a),e.remove();else{const f=Et(n,n==="number"?Number(r[2]):void 0);c&&xn(f,fs,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),g=f.match(/ /g);let h=0;return d&&(h+=d.length),g&&(h+=Math.floor(g.length/4)),h})(r[1]);u&&a.setIndent(u)},ld=(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 g=a.getFirstChild();if(Z(g)){const h=ld(g,e,t+1,r);h&&o.push(h);continue}}if(r&&!a.getChildren().some(g=>g.isSelected(r)))continue;const l=" ".repeat(4*t),c=n.getListType(),u=Cs(n,fs),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
|
`)},OO={dependencies:[qs],export:(n,e)=>{if(!Wr(n))return null;const t=Number(n.getTag().slice(1));return"#".repeat(t)+" "+e(n)},regExp:SO,replace:kb(n=>{const e="h"+n[1].length;return fn(e)}),triggerOnEnter:!0,type:"element"},RO={dependencies:[Js],export:(n,e)=>{if(!Vn(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:vO,replace:(n,e,t,r)=>{if(r){const s=n.getPreviousSibling();if(Vn(s))return s.splice(s.getChildrenSize(),0,[LO(s),...e]),void n.remove()}const o=Ln();o.append(...e),n.replace(o),r||o.select(0,0)},triggerOnEnter:!0,type:"element"},Li={dependencies:[dn],export:n=>{if(!je(n))return null;const e=n.getTextContent();let t=Cs(n,op);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?`
|