braian 0.0.4 → 0.0.5
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/README.md +31 -7
- package/bin/braian.mjs +337 -60
- package/bin/launch-target.mjs +15 -27
- package/bin/run-state.mjs +203 -0
- package/dist/app.module.js +2 -0
- package/dist/bootstrap.js +4 -1
- package/dist/http/api-controllers.js +6 -0
- package/dist/http/vault-http-error.js +4 -1
- package/dist/http/web-app-fallback.js +37 -0
- package/dist/logging/logging.middleware.js +3 -1
- package/dist/main.js +3 -0
- package/dist/mcp/mcp-path.js +12 -0
- package/dist/mcp/mcp-settings.controller.js +78 -0
- package/dist/mcp/mcp.controller.js +147 -0
- package/dist/mcp/mcp.dto.js +53 -0
- package/dist/mcp/mcp.module.js +20 -0
- package/dist/mcp/mcp.service.js +117 -0
- package/dist/providers/model-provider.service.js +3 -3
- package/dist/rss/rss-profiles.controller.js +167 -0
- package/dist/rss/rss-profiles.dto.js +511 -0
- package/dist/rss/rss-profiles.service.js +149 -0
- package/dist/rss/rss.module.js +5 -2
- package/dist/search/search.controller.js +1 -1
- package/dist/vaults/vault.controller.js +41 -0
- package/dist/vaults/vault.dto.js +80 -6
- package/dist/vaults/vaults.module.js +2 -1
- package/dist/vaults/vaults.service.js +30 -2
- package/dist/workspace/workspace-config.js +3 -3
- package/node_modules/@braian/ai-providers/dist/index.js +4 -1
- package/node_modules/@braian/ai-providers/dist/jev-routing.js +41 -13
- package/node_modules/@braian/graph-agent/dist/agent-profiles/tool-catalog.js +4 -4
- package/node_modules/@braian/graph-agent/dist/data-workspace.js +44 -0
- package/node_modules/@braian/graph-agent/dist/demo-vaults.js +348 -0
- package/node_modules/@braian/graph-agent/dist/feature-switch.js +1 -1
- package/node_modules/@braian/graph-agent/dist/graph-agent.js +40 -7
- package/node_modules/@braian/graph-agent/dist/index.js +24 -2
- package/node_modules/@braian/graph-agent/dist/mcp-tokens.js +62 -0
- package/node_modules/@braian/graph-agent/dist/rss/index.js +43 -1
- package/node_modules/@braian/graph-agent/dist/rss/rss-profile-model.js +378 -0
- package/node_modules/@braian/graph-agent/dist/rss/rss-profile-store.js +170 -0
- package/node_modules/@braian/graph-agent/dist/rss/rss-profile-test.js +120 -0
- package/node_modules/@braian/graph-agent/dist/rss/rss-profile-use-cases.js +74 -0
- package/node_modules/@braian/graph-agent/dist/vault-changes.js +3 -0
- package/node_modules/@braian/graph-agent/dist/vault-settings-operations.js +3 -1
- package/node_modules/@braian/graph-agent/dist/vault-settings-registry.js +1 -1
- package/node_modules/@braian/voice-transcription/dist/transcribe.js +1 -1
- package/package.json +3 -1
- package/public/assets/{agent-profiles-settings-I5Ux2GnH.js → agent-profiles-settings-yElCnMJo.js} +1 -1
- package/public/assets/{appearance-settings-module-CD3bJpfR.js → appearance-settings-module-BFDKE-mZ.js} +1 -1
- package/public/assets/{ar-SA-G6X2FPQ2-BPq1dwIU.js → ar-SA-G6X2FPQ2-R9ND2Rw0.js} +1 -1
- package/public/assets/{attachment-embed-BkP-B_Pa.js → attachment-embed-BX0XSPNZ.js} +1 -1
- package/public/assets/{attachments-settings-BeAekkzf.js → attachments-settings-CSEjOoFg.js} +1 -1
- package/public/assets/{az-AZ-76LH7QW2-nXEHcVXP.js → az-AZ-76LH7QW2-DpGlptKS.js} +1 -1
- package/public/assets/{bg-BG-XCXSNQG7-CpTkmSSX.js → bg-BG-XCXSNQG7-WKBfRf7q.js} +1 -1
- package/public/assets/{bn-BD-2XOGV67Q-BDMEyCuA.js → bn-BD-2XOGV67Q-BmT7jnvl.js} +1 -1
- package/public/assets/board-workspace-CmetKvXF.js +1 -0
- package/public/assets/{boards-settings-module-CCN_ZNks.js → boards-settings-module-Bh5dh9jG.js} +1 -1
- package/public/assets/{boards-view-B1B8wHHn.js → boards-view-3JR36W_w.js} +1 -1
- package/public/assets/{ca-ES-6MX7JW3Y-D0UEot-K.js → ca-ES-6MX7JW3Y-CBR9ytrG.js} +1 -1
- package/public/assets/{calendar-view-BlTCcAzD.js → calendar-view-Cr1VSpj0.js} +1 -1
- package/public/assets/calendar-workspace-B-2Himdy.js +1 -0
- package/public/assets/{calendars-settings-module-ActBZM9v.js → calendars-settings-module-BWI1k_YA.js} +1 -1
- package/public/assets/{card-fields-nzhTsBAW.js → card-fields-eo7dqj1P.js} +1 -1
- package/public/assets/{chat-composer-editor-CRtsZz3W.js → chat-composer-editor-DCmWVP16.js} +1 -1
- package/public/assets/chat-message-list-DPXjDBw1.js +1 -0
- package/public/assets/{chunk-EIO257PC-CGqfS2j0.js → chunk-EIO257PC-Bfdsn_q8.js} +1 -1
- package/public/assets/{code-editor-DnrGU9QQ.js → code-editor-CxLqzVwa.js} +1 -1
- package/public/assets/color-picker-DK8V_DI0.js +1 -0
- package/public/assets/{contents-view-C6RdJxE2.js → contents-view-DHRWEBwV.js} +1 -1
- package/public/assets/{conversation-debug-panel-DIjQShXO.js → conversation-debug-panel-zsrBEMxW.js} +1 -1
- package/public/assets/create-note-popup-C9IB_IZr.js +1 -0
- package/public/assets/{cs-CZ-2BRQDIVT-DvEBYfBD.js → cs-CZ-2BRQDIVT-fiabtlu1.js} +1 -1
- package/public/assets/{cypher-editor-Cdd9vqJj.js → cypher-editor-ef6RdDgm.js} +1 -1
- package/public/assets/{da-DK-5WZEPLOC-nBVf9B0e.js → da-DK-5WZEPLOC-C-5tRCvs.js} +1 -1
- package/public/assets/{daily-notes-settings-DG9RUcYk.js → daily-notes-settings-CCotd1Iq.js} +1 -1
- package/public/assets/{dashboard-grid-BvlcalWZ.js → dashboard-grid-DKMK4z_a.js} +1 -1
- package/public/assets/dashboard-workspace-4u-QaXby.js +4 -0
- package/public/assets/{dashboards-settings-module-CMkRnuLc.js → dashboards-settings-module-DmE0Krje.js} +1 -1
- package/public/assets/{dashboards-view-BB1CRB2G.js → dashboards-view-DxUAl6zg.js} +1 -1
- package/public/assets/{de-DE-XR44H4JA-wIoI5uHM.js → de-DE-XR44H4JA-4wneKMQi.js} +1 -1
- package/public/assets/{desktop-server-settings-j8RrUDQh.js → desktop-server-settings-DDd8PcxW.js} +1 -1
- package/public/assets/{directory-picker-columns-BDdL8yxc.js → directory-picker-columns-CqPZNMT8.js} +1 -1
- package/public/assets/{discovery-create-popup-DpDB1MTg.js → discovery-create-popup-BSOSYM4o.js} +1 -1
- package/public/assets/{discovery-import-popup-BsyONSTT.js → discovery-import-popup-NodFxSW1.js} +1 -1
- package/public/assets/{discovery-settings-module-CSz3wdqd.js → discovery-settings-module-DQMZismj.js} +1 -1
- package/public/assets/{discovery-view-DOb6HJff.js → discovery-view-PiwStXSa.js} +1 -1
- package/public/assets/discovery-workspace-BTrjBF19.js +2 -0
- package/public/assets/{dist-tLZONR8L.js → dist-B58c6eJE.js} +1 -1
- package/public/assets/drag-preview-D61OK7zr.js +1 -0
- package/public/assets/{drawing-note-BZkhWRBb.js → drawing-note-BytzAih9.js} +1 -1
- package/public/assets/{el-GR-BZB4AONW-BoxDB0UD.js → el-GR-BZB4AONW-BUDxOK9m.js} +1 -1
- package/public/assets/{en-B4ZKOASM-D3_h4H29.js → en-B4ZKOASM-jB7I34Md.js} +1 -1
- package/public/assets/{es-ES-U4NZUMDT-BTF8-J9f.js → es-ES-U4NZUMDT-gXLOOlpz.js} +1 -1
- package/public/assets/{esm-zhVSGSwY.js → esm-BSlSeh8A.js} +1 -1
- package/public/assets/{eu-ES-A7QVB2H4-PqSQa04Y.js → eu-ES-A7QVB2H4-4kiV_opo.js} +1 -1
- package/public/assets/{fa-IR-HGAKTJCU-B03HX6BC.js → fa-IR-HGAKTJCU-C7F0Dl4h.js} +1 -1
- package/public/assets/{feature-switch-section-CDTUV6B-.js → feature-switch-section-617S6UWP.js} +1 -1
- package/public/assets/{fi-FI-Z5N7JZ37-D5Rn9AGc.js → fi-FI-Z5N7JZ37-DEUSwc4a.js} +1 -1
- package/public/assets/{file-editor-DTm2a8_D.js → file-editor-DvP7rRI9.js} +3 -3
- package/public/assets/{file-language-C8bPT8Wh.js → file-language-DjeubQk3.js} +1 -1
- package/public/assets/{file-preview-Bp9k2YvK.js → file-preview-AkYowAab.js} +1 -1
- package/public/assets/{file-preview-media-CNZHdx05.js → file-preview-media-DL2hGeeZ.js} +1 -1
- package/public/assets/{file-references-api-CSyFnFFm.js → file-references-api-C2G0bSy9.js} +1 -1
- package/public/assets/{files-settings-module-D4HPlkbW.js → files-settings-module-DsylYhrR.js} +1 -1
- package/public/assets/files-view-B6_Mlm9V.css +1 -0
- package/public/assets/files-view-DPSrj_WW.js +3 -0
- package/public/assets/{folder-picker-dialog-D57Q15N4.js → folder-picker-dialog-D_VCqm_i.js} +1 -1
- package/public/assets/{format-panel-value-DYwL3ttM.js → format-panel-value-vueBm4DQ.js} +1 -1
- package/public/assets/{fr-FR-RHASNOE6-BoIuGpVa.js → fr-FR-RHASNOE6-BKLo10bn.js} +1 -1
- package/public/assets/{gl-ES-HMX3MZ6V-R9gfMkm_.js → gl-ES-HMX3MZ6V-D_nHnidC.js} +1 -1
- package/public/assets/{graph-explorer-DtYVExeD.js → graph-explorer-CHz-bFkx.js} +5 -5
- package/public/assets/{graph-settings-module-D--vzqKr.js → graph-settings-module-9hY9bkdT.js} +1 -1
- package/public/assets/{he-IL-6SHJWFNN-DLh6r8yJ.js → he-IL-6SHJWFNN-BXKK7JWx.js} +1 -1
- package/public/assets/{hi-IN-IWLTKZ5I-DsP1yUVR.js → hi-IN-IWLTKZ5I-D2utCBQM.js} +1 -1
- package/public/assets/{hu-HU-A5ZG7DT2-ttWV7_mJ.js → hu-HU-A5ZG7DT2-BENIngFF.js} +1 -1
- package/public/assets/{id-ID-SAP4L64H-DIFD1Rmb.js → id-ID-SAP4L64H-Bw77jJOj.js} +1 -1
- package/public/assets/{ide-settings-module-Dsg4tJV6.js → ide-settings-module-BbIX3okW.js} +1 -1
- package/public/assets/ide-view-0vK2duKI.js +2 -0
- package/public/assets/{image-GAAHSSAO-C38PUNrv.js → image-GAAHSSAO-D4NDL8F6.js} +1 -1
- package/public/assets/{imap-accounts-QVDGlYad.js → imap-accounts-BRbnITJv.js} +1 -1
- package/public/assets/index-BVDhmwI8.js +11 -0
- package/public/assets/index-DjUUY3gd.css +1 -0
- package/public/assets/{it-IT-JPQ66NNP-D9CIdJgS.js → it-IT-JPQ66NNP-DiG4G8vQ.js} +1 -1
- package/public/assets/{ja-JP-DBVTYXUO-CYn7dH3E.js → ja-JP-DBVTYXUO-CILN9NGs.js} +1 -1
- package/public/assets/{journal-create-popup-DnYgWgDU.js → journal-create-popup-39y9ieVG.js} +1 -1
- package/public/assets/{journal-day-route-DpsYGWU7.js → journal-day-route-CYlyL-u0.js} +1 -1
- package/public/assets/{journal-folder-field-DuvIgT6Y.js → journal-folder-field-BfO-_ied.js} +1 -1
- package/public/assets/{journal-page-BdQlNdyB.js → journal-page-TgyVFaPE.js} +2 -2
- package/public/assets/{journal-settings-Dq-9Conv.js → journal-settings-CfjXOXzF.js} +1 -1
- package/public/assets/{journal-typography-QR4z5v0X.js → journal-typography-D3O3AK2U.js} +1 -1
- package/public/assets/journal-writing-route-CYhXzipC.js +1 -0
- package/public/assets/journals-view-DNomC0nF.js +1 -0
- package/public/assets/{kaa-6HZHGXH3-DmZqyxcr.js → kaa-6HZHGXH3-BUua-YiR.js} +1 -1
- package/public/assets/{kab-KAB-ZGHBKWFO-BnEoO3f6.js → kab-KAB-ZGHBKWFO-yPJB-J7N.js} +1 -1
- package/public/assets/{kk-KZ-P5N5QNE5-DcYcuRxx.js → kk-KZ-P5N5QNE5-CAitSjw5.js} +1 -1
- package/public/assets/{km-KH-HSX4SM5Z-DO6DHT6h.js → km-KH-HSX4SM5Z-CSZjabru.js} +1 -1
- package/public/assets/{ko-KR-MTYHY66A-Ch6OwlXE.js → ko-KR-MTYHY66A-CGEXYXZz.js} +1 -1
- package/public/assets/{ku-TR-6OUDTVRD-C9KHFYbx.js → ku-TR-6OUDTVRD-DOfuZRKI.js} +1 -1
- package/public/assets/{link-file-browser-BvVwFMvC.js → link-file-browser-A_Mappx0.js} +1 -1
- package/public/assets/{link-kind-icon-r9mUfWOh.js → link-kind-icon-BMfHfR_C.js} +1 -1
- package/public/assets/{link-picker-C90irWTA.js → link-picker-BfwWXJZg.js} +2 -2
- package/public/assets/{locked-shares-prompt-CA0MuZ_G.js → locked-shares-prompt-BsM-ai_V.js} +1 -1
- package/public/assets/{logging-settings-contribution-C55dtngt.js → logging-settings-contribution-BLHCBnwO.js} +1 -1
- package/public/assets/logic-DtHJ5GlU.js +28 -0
- package/public/assets/{lt-LT-XHIRWOB4-CrK3hZ26.js → lt-LT-XHIRWOB4-CmbJTJAh.js} +1 -1
- package/public/assets/{lv-LV-5QDEKY6T-BOA9oRt-.js → lv-LV-5QDEKY6T-Br-VqxTs.js} +1 -1
- package/public/assets/{markdown-message-9f2rcF0-.js → markdown-message-BIo2pHhE.js} +2 -2
- package/public/assets/{markdown-task-toggle-DiIwYCgC.js → markdown-task-toggle-9k1EldDD.js} +3 -3
- package/public/assets/{matrices-settings-module-DPI1_WsY.js → matrices-settings-module-DKGdrCad.js} +1 -1
- package/public/assets/{matrices-view-CQlirOdv.js → matrices-view-DYF7e5ES.js} +1 -1
- package/public/assets/matrix-workspace-JZhH-HQ5.js +1 -0
- package/public/assets/{maximize-2-C6N1RKlt.js → maximize-2-DATMN9kx.js} +1 -1
- package/public/assets/{mermaid-diagram-CnzQOrTI.js → mermaid-diagram-gUL2-JyE.js} +1 -1
- package/public/assets/{mobile-file-text-B4j-_eP4.js → mobile-file-text-meniSeto.js} +1 -1
- package/public/assets/{mobile-note-content-editor-znLhIM9A.js → mobile-note-content-editor-C6TUyA4F.js} +2 -2
- package/public/assets/{mobile-panel-layer-C2OowtdM.js → mobile-panel-layer-2EcEm-JB.js} +1 -1
- package/public/assets/model-provider-settings-contribution-CfHiu3nS.js +1 -0
- package/public/assets/model-providers-cQOCMmwX.js +1 -0
- package/public/assets/{mr-IN-CRQNXWMA-GWTqYMNI.js → mr-IN-CRQNXWMA-DwF8SFQB.js} +1 -1
- package/public/assets/{my-MM-5M5IBNSE-DnqvLQeM.js → my-MM-5M5IBNSE-BEiMo9eJ.js} +1 -1
- package/public/assets/{nb-NO-T6EIAALU-DyrWt8fZ.js → nb-NO-T6EIAALU-BelWzTQs.js} +1 -1
- package/public/assets/{nl-NL-IS3SIHDZ-COWPkkr8.js → nl-NL-IS3SIHDZ-Ce06PPL4.js} +1 -1
- package/public/assets/{nn-NO-6E72VCQL-8aH2uP9Y.js → nn-NO-6E72VCQL-BbXlzJzR.js} +1 -1
- package/public/assets/note-collab-provider-B9DpnE58.js +1 -0
- package/public/assets/note-collab-transport-BHZ891IL.js +1 -0
- package/public/assets/{note-create-settings-module-CV4dWr8t.js → note-create-settings-module-rIZc1DjQ.js} +1 -1
- package/public/assets/{note-documents-DCd2HaSQ.js → note-documents-CcJDTkta.js} +2 -2
- package/public/assets/note-editor-container-DL3yLdYs.js +2 -0
- package/public/assets/{note-editor-settings-module-CbPu_40k.js → note-editor-settings-module-DI0jRyPy.js} +1 -1
- package/public/assets/{note-excalidraw-editor-RjnG4My9.js → note-excalidraw-editor-fDQ1JVBh.js} +11 -11
- package/public/assets/{note-export-api-2u0sbOpc.js → note-export-api-CwuXGV0y.js} +1 -1
- package/public/assets/{note-export-flow-B3wRdMj0.js → note-export-flow-DcBoI5Pp.js} +1 -1
- package/public/assets/{note-filter-rule-rows-BajgD2k3.js → note-filter-rule-rows-DFSWBwql.js} +1 -1
- package/public/assets/{note-folds-settings-module-DZju6Mum.js → note-folds-settings-module-CFfVg1Cp.js} +1 -1
- package/public/assets/{note-frontmatter-summary-BSKg__aS.js → note-frontmatter-summary-iubFPHA_.js} +1 -1
- package/public/assets/{note-link-list-DKU2PqtO.js → note-link-list-CI9-GM_3.js} +1 -1
- package/public/assets/{note-markdown-editor-CXelEHqr.js → note-markdown-editor-lG6gZT9i.js} +10 -10
- package/public/assets/{note-outline-CNoqBtUP.js → note-outline-BFidIp-8.js} +1 -1
- package/public/assets/note-page-content-8gzPBWMV.js +2 -0
- package/public/assets/{note-page-editor-rhBoxKYB.js → note-page-editor-DpVUxkCx.js} +4 -4
- package/public/assets/{note-path-breadcrumb-uTSXCQK4.js → note-path-breadcrumb-HmtWyYZP.js} +1 -1
- package/public/assets/{note-picker-BD8rmAOq.js → note-picker-B5i41l1u.js} +1 -1
- package/public/assets/{note-picker-popover-DI9Wc706.js → note-picker-popover-B9VTeHiM.js} +1 -1
- package/public/assets/{note-shares-popup-9sJOmL1-.js → note-shares-popup-aUO1SNLN.js} +1 -1
- package/public/assets/{note-source-editor-DWyDYMCj.js → note-source-editor-BXPR_-41.js} +1 -1
- package/public/assets/{note-type-grid-BFX3oTAC.js → note-type-grid-CRCfpYZy.js} +2 -2
- package/public/assets/{note-values-BqD4746M.js → note-values-6D6wWXPg.js} +1 -1
- package/public/assets/{notes-settings-module-C5IPmwKt.js → notes-settings-module-DcP9Hid-.js} +1 -1
- package/public/assets/{oc-FR-POXYY2M6-C_R_VP74.js → oc-FR-POXYY2M6-CyRgkETq.js} +1 -1
- package/public/assets/{open-journal-writing-Bd-CppeX.js → open-journal-writing-Bub8Zn13.js} +1 -1
- package/public/assets/{pa-IN-N4M65BXN-B21EEaul.js → pa-IN-N4M65BXN-A1_Q9748.js} +1 -1
- package/public/assets/page-content-B3fNjwr-.js +1 -0
- package/public/assets/{page-files-BMj9IzfB.js → page-files-CSqFupDZ.js} +1 -1
- package/public/assets/page-note-nmiinGCs.js +1 -0
- package/public/assets/{pane-keys-CTLoUZZR.js → pane-keys-osajBGnu.js} +1 -1
- package/public/assets/{panel-columns-fields-DPjV39xn.js → panel-columns-fields-ZlW6A4My.js} +1 -1
- package/public/assets/{pdf-view-Cm78nuSA.js → pdf-view-BATpBLO5.js} +1 -1
- package/public/assets/{pencil-DQ9fAqT6.js → pencil-xxFNyZzr.js} +1 -1
- package/public/assets/{percentages-BXMCSKIN-CUt8fyAS.js → percentages-BXMCSKIN-DzsiA6IB.js} +1 -1
- package/public/assets/{phone-numbers-CHQaYRah.js → phone-numbers-BQgyhfcH.js} +1 -1
- package/public/assets/{pl-PL-T2D74RX3-Bdo_j9QK.js → pl-PL-T2D74RX3-DaINIVjz.js} +1 -1
- package/public/assets/provider-configuration-CSnNV6ps.css +1 -0
- package/public/assets/provider-configuration-DaFovElx.js +8 -0
- package/public/assets/provider-use-select-D-lJiZ2W.js +1 -0
- package/public/assets/{pt-BR-5N22H2LF-C9DRQ7CW.js → pt-BR-5N22H2LF-ENVHjTz_.js} +1 -1
- package/public/assets/{pt-PT-UZXXM6DQ-ColydZPV.js → pt-PT-UZXXM6DQ-D5Uqv0Vz.js} +1 -1
- package/public/assets/{qr-code-Bm7I0KYt.js → qr-code-CDBCi1Cu.js} +2 -2
- package/public/assets/{qr-code-svg-D0RAuUIk.js → qr-code-svg-8ENstC8b.js} +1 -1
- package/public/assets/qr-defaults-settings-C_8ybA4R.js +1 -0
- package/public/assets/qr-settings-fields-C2-DGF6a.js +1 -0
- package/public/assets/qr-viewer-DAOzDI8d.js +1 -0
- package/public/assets/{reader-clock-22DkpiWR.js → reader-clock-7x7Yvzv1.js} +1 -1
- package/public/assets/{recording-bar-DOm-SEGc.js → recording-bar-BcuvYwhh.js} +2 -2
- package/public/assets/{recording-setup-CV3LE2_1.js → recording-setup-D_MgrYb7.js} +1 -1
- package/public/assets/{recordings-api-C-Bxpzgo.js → recordings-api-Ds77lFsk.js} +1 -1
- package/public/assets/resource-overview-card-BainFWKz.js +1 -0
- package/public/assets/{ro-RO-JPDTUUEW-iJAQDPe9.js → ro-RO-JPDTUUEW-Dq_ouOp1.js} +1 -1
- package/public/assets/{rss-preferences-Bx1Wa4ri.js → rss-preferences-BafuZ3Ku.js} +1 -1
- package/public/assets/{rss-settings-module-BmDISWDk.js → rss-settings-module-Df-YS9tr.js} +1 -1
- package/public/assets/rss-view-BORHnuIQ.js +3 -0
- package/public/assets/rss-view-DIPQBTLT.css +1 -0
- package/public/assets/{ru-RU-B4JR7IUQ-CX_CWbT7.js → ru-RU-B4JR7IUQ-CqqISqJC.js} +1 -1
- package/public/assets/{safe-block-copy-DygjvDD4.js → safe-block-copy-BOVhmncw.js} +1 -1
- package/public/assets/{safe-block-qr-button-Cn9WpEkl.js → safe-block-qr-button-CD7cJG3N.js} +1 -1
- package/public/assets/{safe-block-reader-CNfzTExh.js → safe-block-reader-BkilW4Hj.js} +1 -1
- package/public/assets/safe-folder-conversion-DWTRwvTH.js +1 -0
- package/public/assets/{safe-folders-DCf8IdrM.js → safe-folders-DmvM6dtV.js} +1 -1
- package/public/assets/{safe-move-leaving-tN-IMhDo.js → safe-move-leaving-BT5e1h3p.js} +1 -1
- package/public/assets/{safe-note-locked-B_lt0XcX.js → safe-note-locked-BDCeVwpK.js} +1 -1
- package/public/assets/{safe-notes-settings-module-CMvkyfNG.js → safe-notes-settings-module-BrZreYgf.js} +1 -1
- package/public/assets/search-settings-module-CPnculiI.js +1 -0
- package/public/assets/{secret-form-DSD348Om.js → secret-form-B-YAlbZf.js} +1 -1
- package/public/assets/{secret-popup-y9W7WIrZ.js → secret-popup-CoVpeLZV.js} +1 -1
- package/public/assets/{security-settings-contribution-B_Syg5ab.js → security-settings-contribution-BmcZq1hf.js} +1 -1
- package/public/assets/settings-CU8YR8di.js +1 -0
- package/public/assets/{settings-edit-dialog-B5emNjJi.js → settings-edit-dialog-C_AeTz9Y.js} +1 -1
- package/public/assets/settings-panel-Ds7lOtnD.js +1 -0
- package/public/assets/settings-view-BTz2XbnW.js +4 -0
- package/public/assets/{settings-view-6_hMxTXD.css → settings-view-Bd65kLGK.css} +1 -1
- package/public/assets/{setup-prompt-6JRbE0oa.js → setup-prompt-BbpHVdla.js} +1 -1
- package/public/assets/{share-access-control-C5mpELVT.js → share-access-control-CzAVEv6b.js} +1 -1
- package/public/assets/share-label-CbjQ9iMF.js +1 -0
- package/public/assets/{shared-board-lanes-UWl9klys.js → shared-board-lanes-CAbJAFk6.js} +1 -1
- package/public/assets/{shared-calendar-view-DcCO3mNo.js → shared-calendar-view-DTzDjSs0.js} +1 -1
- package/public/assets/shared-note-route-B_gfX0Nl.js +4 -0
- package/public/assets/{shared-note-text-BdCw7a9a.js → shared-note-text-DFBEyL8Z.js} +1 -1
- package/public/assets/{shares-settings-module-9oF4v70A.js → shares-settings-module-pIdBLmCq.js} +1 -1
- package/public/assets/{si-LK-N5RQ5JYF-DfLSaLm6.js → si-LK-N5RQ5JYF-DmhE8IT5.js} +1 -1
- package/public/assets/{sk-SK-C5VTKIMK-DrAaUVFC.js → sk-SK-C5VTKIMK-YiOZ-xKA.js} +1 -1
- package/public/assets/{sl-SI-NN7IZMDC-WxYLW2Uj.js → sl-SI-NN7IZMDC-BKb37Hlu.js} +1 -1
- package/public/assets/{spaces-settings-module-Dh_QfANj.js → spaces-settings-module-BLU1RsTS.js} +1 -1
- package/public/assets/spaces-view-BhWD3mAw.js +2 -0
- package/public/assets/{sqlite-browser-BfIrq_0x.js → sqlite-browser-C98PFoRG.js} +2 -2
- package/public/assets/{store-attachments-DNyH0asy.js → store-attachments-DbqF7LgE.js} +1 -1
- package/public/assets/{stored-color-picker-CYL7LYdQ.js → stored-color-picker-DLX-e5Nq.js} +1 -1
- package/public/assets/subset-shared.chunk-D8M638AI.js +1 -0
- package/public/assets/{subset-worker.chunk-BrbK91mW.js → subset-worker.chunk-B9ZhBm-P.js} +1 -1
- package/public/assets/{sv-SE-XGPEYMSR-DOB2jm3x.js → sv-SE-XGPEYMSR-VT0snW-T.js} +1 -1
- package/public/assets/{ta-IN-2NMHFXQM-DfC3wGVU.js → ta-IN-2NMHFXQM--MqIf2Jf.js} +1 -1
- package/public/assets/{text-diff-BzNG8nfy.js → text-diff-BmKfp7mY.js} +1 -1
- package/public/assets/{th-TH-HPSO5L25-BsqplWuv.js → th-TH-HPSO5L25-CTKAmQrO.js} +1 -1
- package/public/assets/{theme-colors-2LJ6VIeK.js → theme-colors-zbTaiYL0.js} +1 -1
- package/public/assets/{toolbar-items-DF7H0MSb.js → toolbar-items-DLi0bl0c.js} +1 -1
- package/public/assets/{topology-code-editor-B7zxDyT3.js → topology-code-editor-CNnSyUQ3.js} +1 -1
- package/public/assets/topology-designer-T54LYLYv.js +1 -0
- package/public/assets/topology-editor-aGtCktzA.js +8 -0
- package/public/assets/{topology-folder-migration-popup-Bj4nu8HE.js → topology-folder-migration-popup-C0Wc3ViK.js} +1 -1
- package/public/assets/{topology-settings-module-cWWujj9j.js → topology-settings-module-Dp-Sm37Z.js} +1 -1
- package/public/assets/{tr-TR-DEFEU3FU-DWO1lNTH.js → tr-TR-DEFEU3FU-BVLSiyVW.js} +1 -1
- package/public/assets/{transcription-settings-HrJHl14H.js → transcription-settings-BldPwHO7.js} +4 -4
- package/public/assets/{uk-UA-QMV73CPH-ZHBKj9kv.js → uk-UA-QMV73CPH-DQ4YsZml.js} +1 -1
- package/public/assets/{unlock-prompt-C1AEyIR_.js → unlock-prompt-CkkcVo9g.js} +1 -1
- package/public/assets/{use-candidate-notes-Du1V_uun.js → use-candidate-notes-jH4-EW29.js} +1 -1
- package/public/assets/{use-directory-listing-BaYgcuHI.js → use-directory-listing-Cn9t21ra.js} +1 -1
- package/public/assets/{use-folding-enabled-CyYip5Go.js → use-folding-enabled-DKvri2UA.js} +1 -1
- package/public/assets/{use-live-document-Ck_XPFVd.js → use-live-document-D4PkZrbU.js} +1 -1
- package/public/assets/{use-mobile-layer-navigation-CBRepW9w.js → use-mobile-layer-navigation-BIC7HlT_.js} +1 -1
- package/public/assets/{use-note-attachments-SPgAe-M0.js → use-note-attachments-Bew073Hl.js} +1 -1
- package/public/assets/{use-note-delete-Dvrzq6Pl.js → use-note-delete-fFNH1Glk.js} +1 -1
- package/public/assets/use-note-editor-session-R1wm0xDf.js +1 -0
- package/public/assets/{use-note-export-flow-0uAfXAwf.js → use-note-export-flow-Dm7yhW5s.js} +2 -2
- package/public/assets/use-provider-dialogs-CrxN9JCo.js +1 -0
- package/public/assets/{use-reflection-request-DV5-_c14.js → use-reflection-request-C1DxtaYX.js} +3 -3
- package/public/assets/{use-safe-folder-moves-0nw2jjTX.js → use-safe-folder-moves-DjQUnMvz.js} +1 -1
- package/public/assets/{use-safe-folders-apply-C9pni8YW.js → use-safe-folders-apply-B1V8l7WU.js} +1 -1
- package/public/assets/{use-screen-source-BllYITR6.js → use-screen-source-CF-48NnC.js} +1 -1
- package/public/assets/use-share-actions-kb7uFat_.js +1 -0
- package/public/assets/{use-vault-file-link-C0ZO_VPm.js → use-vault-file-link-B-ZRcKDu.js} +1 -1
- package/public/assets/{use-voice-questions-Bjgb45Dc.js → use-voice-questions-DGVQlAST.js} +1 -1
- package/public/assets/{vault-entries-api-DVVjgeZh.js → vault-entries-api-pFsJiGnJ.js} +1 -1
- package/public/assets/vault-manager-YKz_Ib18.js +1 -0
- package/public/assets/{vault-settings-module-DMjLQmKz.js → vault-settings-module-CCMMSy4B.js} +1 -1
- package/public/assets/{vault-shares-popup-CCPGkRmF.js → vault-shares-popup-CaGnEIJA.js} +1 -1
- package/public/assets/{versioning-preferences-dvxhrMo9.js → versioning-preferences-DrNq-y_0.js} +1 -1
- package/public/assets/{versioning-settings-module-CnDDngKG.js → versioning-settings-module-Ddug486c.js} +1 -1
- package/public/assets/versioning-view-PR4R4gks.js +2 -0
- package/public/assets/{vi-VN-M7AON7JQ-uUfHJEho.js → vi-VN-M7AON7JQ-B-fHV7o8.js} +1 -1
- package/public/assets/video-recording-dialog-CxRs1eLE.js +1 -0
- package/public/assets/{video-recording-settings-D6YT_FW3.js → video-recording-settings-B2iE6IdW.js} +1 -1
- package/public/assets/{widget-frame-CjlAZSUy.js → widget-frame-DiF4946k.js} +1 -1
- package/public/assets/{zh-CN-LNUGB5OW-COz3oRg3.js → zh-CN-LNUGB5OW-CUgxiiUV.js} +1 -1
- package/public/assets/{zh-HK-E62DVLB3-C8ICkLhf.js → zh-HK-E62DVLB3-D-87W8QH.js} +1 -1
- package/public/assets/{zh-TW-RAJ6MFWO-AYdVqmV8.js → zh-TW-RAJ6MFWO-BVaf47B6.js} +1 -1
- package/public/index.html +3 -3
- package/public/assets/board-workspace-DPSlmJ8w.js +0 -1
- package/public/assets/calendar-workspace-6t1kuFgj.js +0 -1
- package/public/assets/chat-message-list-ClUR56GV.js +0 -1
- package/public/assets/color-picker-ClAn42eA.js +0 -1
- package/public/assets/create-note-popup-CRi210cC.js +0 -1
- package/public/assets/dashboard-workspace-D45MA_Wf.js +0 -4
- package/public/assets/discovery-workspace-Cyc70gQ1.js +0 -2
- package/public/assets/drag-preview-Cb6aidku.js +0 -1
- package/public/assets/files-view-BIDZtZgg.js +0 -3
- package/public/assets/files-view-Bo1uBB_W.css +0 -1
- package/public/assets/ide-view-DCvwb5Bx.js +0 -2
- package/public/assets/index-B8xguO4f.css +0 -1
- package/public/assets/index-CCUyKE6q.js +0 -11
- package/public/assets/journal-writing-route-JP-jPBGZ.js +0 -1
- package/public/assets/journals-view-No5xQN8-.js +0 -1
- package/public/assets/logic-BNk_20eJ.js +0 -28
- package/public/assets/matrix-workspace-C3LhTNPX.js +0 -1
- package/public/assets/model-provider-settings-contribution-DYmNbsgA.js +0 -1
- package/public/assets/model-providers-7VKk3K9H.js +0 -8
- package/public/assets/model-providers-DgRkVmP5.css +0 -1
- package/public/assets/note-collab-provider-969Kgyu8.js +0 -1
- package/public/assets/note-collab-transport-CQDYt_Db.js +0 -1
- package/public/assets/note-editor-container-CTnEE-98.js +0 -2
- package/public/assets/note-page-content-DIqkiMvt.js +0 -2
- package/public/assets/page-content-C1jtzs7H.js +0 -1
- package/public/assets/page-note-Chw2UF0u.js +0 -1
- package/public/assets/provider-use-select-DCSwSrlz.js +0 -1
- package/public/assets/qr-defaults-settings-2_Yt9x4N.js +0 -1
- package/public/assets/qr-settings-fields-DDO4XgMl.js +0 -1
- package/public/assets/qr-viewer-CvEfRC2r.js +0 -1
- package/public/assets/resource-overview-card-Co8aU6jw.js +0 -1
- package/public/assets/rss-view-5aqCVOCs.css +0 -1
- package/public/assets/rss-view-BCEFsYtS.js +0 -1
- package/public/assets/safe-folder-conversion-BOLpnv8P.js +0 -1
- package/public/assets/search-settings-module-DmczYjcQ.js +0 -1
- package/public/assets/settings-ChT117Ke.js +0 -1
- package/public/assets/settings-panel-Cl5kUs9O.js +0 -1
- package/public/assets/settings-view-C_lfjngd.js +0 -3
- package/public/assets/share-label-BU3So3s7.js +0 -1
- package/public/assets/shared-note-route-DaI6hm83.js +0 -4
- package/public/assets/spaces-view-Dw2uxDxU.js +0 -2
- package/public/assets/subset-shared.chunk-D1nlqSEH.js +0 -1
- package/public/assets/topology-designer-CvJN6QTV.js +0 -1
- package/public/assets/topology-editor-RZ0_yLuO.js +0 -8
- package/public/assets/use-note-editor-session-CRC-natg.js +0 -1
- package/public/assets/use-share-actions-ujEMhCfl.js +0 -1
- package/public/assets/vault-manager-CMQaGDss.js +0 -1
- package/public/assets/versioning-view-BsIFugt4.js +0 -2
- package/public/assets/video-recording-dialog-7IGrQMwx.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{f as n,m as r,p as i,t as a}from"./react-B3NTyEzE.js";import{Ft as o,Pt as s}from"./codemirror-BqrpJAnL.js";import{t as c}from"./yjs-DhdecF1t.js";import{$ as l,B as u,E as d,F as f,H as p,J as m,K as h,L as g,M as _,N as v,O as y,P as b,Q as x,R as S,T as C,U as w,W as T,X as E,Y as ee,Z as te,j as ne,k as re,q as ie,w as ae,z as oe}from"./interaction-BeNMN0Kn.js";import{n as se,t as ce}from"./with-selector-BI5p7ODC.js";import{Ac as le,El as ue,Lc as de,Nc as fe,Rc as pe}from"./logic-BNk_20eJ.js";import{Tn as me,ar as he,hr as ge}from"./index-CCUyKE6q.js";import{t as _e}from"./page-files-BMj9IzfB.js";import{i as ve,o as ye,t as be}from"./matching-notes-DRkG0koD.js";import{t as xe}from"./page-note-Chw2UF0u.js";var D=e(r(),1),O=a(),Se=e(ce(),1),Ce=Object.defineProperty,we=(e,t)=>{let n={};for(var r in e)Ce(n,r,{get:e[r],enumerable:!0});return t||Ce(n,Symbol.toStringTag,{value:`Module`}),n};function Te(e){this.content=e}Te.prototype={constructor:Te,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new Te(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new Te(n)},addToStart:function(e,t){return new Te([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Te(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new Te(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=Te.from(e),e.size?new Te(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=Te.from(e),e.size?new Te(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Te.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},Te.from=function(e){if(e instanceof Te)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Te(t)};function Ee(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a)n+=i.nodeSize;else{if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&ke(e.charCodeAt(r-1))&&Oe(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=Ee(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}}function De(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s)n-=c,r-=c;else{if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&ke(e.charCodeAt(i-1))&&Oe(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=De(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}}function Oe(e){return e>=56320&&e<57344}function ke(e){return e>=55296&&e<56320}var k=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Ee(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return De(this,e,t,n)}findIndex(e){if(e==0)return je(0,e);if(e==this.size)return je(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?je(t+1,i):je(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};k.empty=new k([],0);var Ae={index:0,offset:0};function je(e,t){return Ae.index=e,Ae.offset=t,Ae}function Me(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Me(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Me(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var A=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Me(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};A.none=[];var Ne=class extends Error{},j=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Fe(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Pe(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(k.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};j.empty=new j(k.empty,0,0);function Pe(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Pe(a.content,t-i-1,n-i-1)))}function Fe(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Fe(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function Ie(e,t,n){if(n.openStart>e.depth)throw new Ne(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Ne(`Inconsistent open depths`);return Le(e,t,n,0)}function Le(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=Le(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}if(!n.content.size)return He(a,We(e,t,r));if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return He(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}{let{start:i,end:o}=Ge(n,e);return He(a,Ue(e,i,o,t,r))}}function Re(e,t){if(!t.type.compatibleContent(e.type))throw new Ne(`Cannot join `+t.type.name+` onto `+e.type.name)}function ze(e,t,n){let r=e.node(n);return Re(r,t.node(n)),r}function Be(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Ve(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Be(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Be(i.child(e),r);t&&t.depth==n&&t.textOffset&&Be(t.nodeBefore,r)}function He(e,t){if(!e.type.validContent(t))throw new Ne(`Invalid content for node `+e.type.name);return e.copy(t)}function Ue(e,t,n,r,i){let a=e.depth>i&&ze(e,t,i+1),o=r.depth>i&&ze(n,r,i+1),s=[];return Ve(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Re(a,o),Be(He(a,Ue(e,t,n,r,i+1)),s)):(a&&Be(He(a,We(e,t,i+1)),s),Ve(t,n,i,s),o&&Be(He(o,We(n,r,i+1)),s)),Ve(r,null,i,s),new k(s)}function We(e,t,n){let r=[];return Ve(null,e,n,r),e.depth>n&&Be(He(ze(e,t,n+1),We(e,t,n+1)),r),Ve(t,null,n,r),new k(r)}function Ge(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(k.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ke=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return A.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive!==!1||r&&i[a].isInSet(r.marks)||(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive!==!1||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Xe(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Ye.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Ye.set(t,r=new qe);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Je,i}},qe=class{constructor(){this.elts=[],this.i=0}},Je=12,Ye=new WeakMap,Xe=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Ze=Object.create(null),Qe=class e{constructor(e,t,n,r=A.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||k.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Me(this.attrs,t||e.defaultAttrs||Ze)&&A.sameSet(this.marks,n||A.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return j.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new j(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Ie(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ke.resolveCached(this,e)}resolveNoCache(e){return Ke.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),et(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=k.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),tt(this.type.attrs,this.attrs,`node`,this.type.name);let e=A.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];tt(n.type.attrs,n.attrs,`mark`,n.type.name),e=n.addToSet(e)}if(!A.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=k.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}};Qe.prototype.text=void 0;var $e=class e extends Qe{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):et(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function et(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}function tt(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}var nt=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new rt(t,n);if(r.next==null)return e.empty;let i=it(r);r.next&&r.err(`Unexpected trailing text`);let a=mt(dt(i));return ht(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return k.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];a.isLeaf||a.hasRequiredAttrs()||a.name in t||r.type&&!o.validEnd||(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
1
|
+
import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{f as n,m as r,p as i,t as a}from"./react-B3NTyEzE.js";import{Ft as o,Pt as s}from"./codemirror-BqrpJAnL.js";import{t as c}from"./yjs-DhdecF1t.js";import{$ as l,B as u,E as d,F as f,H as p,J as m,K as h,L as g,M as _,N as v,O as y,P as b,Q as x,R as S,T as C,U as w,W as T,X as E,Y as ee,Z as te,j as ne,k as re,q as ie,w as ae,z as oe}from"./interaction-BeNMN0Kn.js";import{n as se,t as ce}from"./with-selector-BI5p7ODC.js";import{Fc as le,Ic as ue,Oc as de,Ol as fe,jc as pe}from"./logic-DtHJ5GlU.js";import{Dn as me,_r as he,sr as ge}from"./index-BVDhmwI8.js";import{t as _e}from"./page-files-CSqFupDZ.js";import{i as ve,o as ye,t as be}from"./matching-notes-DRkG0koD.js";import{t as xe}from"./page-note-nmiinGCs.js";var D=e(r(),1),O=a(),Se=e(ce(),1),Ce=Object.defineProperty,we=(e,t)=>{let n={};for(var r in e)Ce(n,r,{get:e[r],enumerable:!0});return t||Ce(n,Symbol.toStringTag,{value:`Module`}),n};function Te(e){this.content=e}Te.prototype={constructor:Te,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new Te(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new Te(n)},addToStart:function(e,t){return new Te([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Te(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new Te(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=Te.from(e),e.size?new Te(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=Te.from(e),e.size?new Te(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Te.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},Te.from=function(e){if(e instanceof Te)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Te(t)};function Ee(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a)n+=i.nodeSize;else{if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&ke(e.charCodeAt(r-1))&&Oe(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=Ee(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}}function De(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s)n-=c,r-=c;else{if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&ke(e.charCodeAt(i-1))&&Oe(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=De(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}}function Oe(e){return e>=56320&&e<57344}function ke(e){return e>=55296&&e<56320}var k=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Ee(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return De(this,e,t,n)}findIndex(e){if(e==0)return je(0,e);if(e==this.size)return je(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?je(t+1,i):je(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};k.empty=new k([],0);var Ae={index:0,offset:0};function je(e,t){return Ae.index=e,Ae.offset=t,Ae}function Me(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Me(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Me(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var A=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Me(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};A.none=[];var Ne=class extends Error{},j=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Fe(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Pe(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(k.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};j.empty=new j(k.empty,0,0);function Pe(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Pe(a.content,t-i-1,n-i-1)))}function Fe(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Fe(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function Ie(e,t,n){if(n.openStart>e.depth)throw new Ne(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Ne(`Inconsistent open depths`);return Le(e,t,n,0)}function Le(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=Le(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}if(!n.content.size)return He(a,We(e,t,r));if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return He(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}{let{start:i,end:o}=Ge(n,e);return He(a,Ue(e,i,o,t,r))}}function Re(e,t){if(!t.type.compatibleContent(e.type))throw new Ne(`Cannot join `+t.type.name+` onto `+e.type.name)}function ze(e,t,n){let r=e.node(n);return Re(r,t.node(n)),r}function Be(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Ve(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Be(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Be(i.child(e),r);t&&t.depth==n&&t.textOffset&&Be(t.nodeBefore,r)}function He(e,t){if(!e.type.validContent(t))throw new Ne(`Invalid content for node `+e.type.name);return e.copy(t)}function Ue(e,t,n,r,i){let a=e.depth>i&&ze(e,t,i+1),o=r.depth>i&&ze(n,r,i+1),s=[];return Ve(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Re(a,o),Be(He(a,Ue(e,t,n,r,i+1)),s)):(a&&Be(He(a,We(e,t,i+1)),s),Ve(t,n,i,s),o&&Be(He(o,We(n,r,i+1)),s)),Ve(r,null,i,s),new k(s)}function We(e,t,n){let r=[];return Ve(null,e,n,r),e.depth>n&&Be(He(ze(e,t,n+1),We(e,t,n+1)),r),Ve(t,null,n,r),new k(r)}function Ge(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(k.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ke=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return A.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive!==!1||r&&i[a].isInSet(r.marks)||(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive!==!1||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Xe(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Ye.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Ye.set(t,r=new qe);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Je,i}},qe=class{constructor(){this.elts=[],this.i=0}},Je=12,Ye=new WeakMap,Xe=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Ze=Object.create(null),Qe=class e{constructor(e,t,n,r=A.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||k.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Me(this.attrs,t||e.defaultAttrs||Ze)&&A.sameSet(this.marks,n||A.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return j.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new j(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Ie(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ke.resolveCached(this,e)}resolveNoCache(e){return Ke.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),et(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=k.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),tt(this.type.attrs,this.attrs,`node`,this.type.name);let e=A.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];tt(n.type.attrs,n.attrs,`mark`,n.type.name),e=n.addToSet(e)}if(!A.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=k.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}};Qe.prototype.text=void 0;var $e=class e extends Qe{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):et(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function et(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}function tt(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}var nt=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new rt(t,n);if(r.next==null)return e.empty;let i=it(r);r.next&&r.err(`Unexpected trailing text`);let a=mt(dt(i));return ht(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return k.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];a.isLeaf||a.hasRequiredAttrs()||a.name in t||r.type&&!o.validEnd||(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
2
2
|
`)}};nt.empty=new nt(!0);var rt=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function it(e){let t=[];do t.push(at(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function at(e){let t=[];do t.push(ot(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function ot(e){let t=ut(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=ct(e,t);else break;return t}function st(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function ct(e,t){let n=st(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:st(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function lt(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function ut(e){if(e.eat(`(`)){let t=it(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=lt(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function dt(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function ft(e,t){return t-e}function pt(e,t){let n=[];return r(t),n.sort(ft);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function mt(e){let t=Object.create(null);return n(pt(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);pt(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new nt(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(ft);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function ht(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function gt(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function _t(e,t){let n=Object.create(null);for(let r in e){let i=e[r],a=t&&t[r];if(a===void 0){if(i.hasDefault)a=i.default;else throw RangeError(`No value supplied for attribute `+r)}else i.validate&&i.validate(a);n[r]=a}return n}function vt(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new xt(e,r,t[r]);return n}var yt=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=vt(e,n.attrs),this.defaultAttrs=gt(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==nt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:_t(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new Qe(this,this.computeAttrs(e),k.from(t),A.setFrom(n))}createChecked(e=null,t,n){return t=k.from(t),this.checkContent(t),new Qe(this,this.computeAttrs(e),t,A.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=k.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(k.empty,!0);return i?new Qe(this,e,t.append(i),A.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:A.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function bt(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var xt=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?bt(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},St=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=vt(e,r.attrs),this.excluded=null;let i=gt(this.attrs);this.instance=i?new A(this,i):null}create(e=null){return!e&&this.instance?this.instance:new A(this,_t(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}},Ct=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=Te.from(e.nodes),t.marks=Te.from(e.marks||{}),this.nodes=yt.compile(this.spec.nodes,this),this.marks=St.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=nt.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?wt(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:wt(this,n.split(` `))}this.nodeFromJSON=e=>Qe.fromJSON(this,e),this.markFromJSON=e=>A.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof yt))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new $e(n,n.defaultAttrs,e,A.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function wt(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function Tt(e){return e.tag!=null}function Et(e){return e.style!=null}var Dt=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(Tt(e))this.tags.push(e);else if(Et(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new It(this,t,!1);return n.addAll(e,A.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new It(this,t,!0);return n.addAll(e,A.none,t.from,t.to),j.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Rt(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=zt(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=zt(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},Ot={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},kt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},At={ol:!0,ul:!0},jt=1,Mt=2,Nt=4;function Pt(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?jt:0)|(t===`full`?Mt:0)}var Ft=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=A.none,this.match=i||(a&Nt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(k.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&jt)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=k.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(k.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ot.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},It=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=Pt(null,t.preserveWhitespace,0)|(n?Nt:0);i=r?new Ft(r.type,r.attrs,A.none,!0,t.topMatch||r.type.contentMatch,a):n?new Ft(null,null,A.none,!0,null,a):new Ft(e.schema.topNodeType,null,A.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&Mt?`full`:this.localPreserveWS||(r.options&jt)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
3
3
|
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;At.hasOwnProperty(a)&&this.parser.normalizeLists&&Lt(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:kt.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(Ot.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
4
|
`),t)}ignoreFallback(e,t){e.nodeName!=`BR`||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node){if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=A.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Bt(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=Pt(e,i,a.options);a.options&Nt&&a.content.length==0&&(o|=Nt);let s=A.none;return n=n.filter(t=>!(a.type?a.type.allowsMarkType(t.type):Bt(t.type,e))||(s=t.addToSet(s),!1)),this.nodes.push(new Ft(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=jt);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function Lt(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&At.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Rt(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function zt(e){let t={};for(let n in e)t[n]=e[n];return t}function Bt(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var Vt=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=Ut(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name])a++;else{if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return Ut(t).createTextNode(e.text);let{dom:n,contentDOM:r}=qt(Ut(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&qt(Ut(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:qt(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=Ht(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return Ht(e.marks)}};function Ht(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Ut(e){return e.document||window.document}var Wt=new WeakMap;function Gt(e){let t=Wt.get(e);return t===void 0&&Wt.set(e,t=Kt(e)),t}function Kt(e){let t=null;function n(e){if(e&&typeof e==`object`){if(Array.isArray(e)){if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t])}else for(let t in e)n(e[t])}}return n(e),t}function qt(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Gt(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=qt(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Jt=65535,Yt=2**16;function Xt(e,t){return e+t*Yt}function Zt(e){return e&Jt}function Qt(e){return(e-(e&Jt))/Yt}var $t=1,en=2,tn=4,nn=8,rn=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&nn)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&tn)>0}},an=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=Zt(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+Qt(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Xt(o/3,e-s),f=0;return c&&(f|=e==s?en:e==u?$t:tn,(t<0?e!=s:e!=u)&&(f|=nn)),new rn(a,f,d)}r+=l-c}return n?e+r:new rn(e+r,0,null)}touches(e,t){let n=0,r=Zt(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};an.empty=new an([]);var on=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new rn(e,r,null)}},sn=Object.create(null),cn=class{getMap(){return an.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=sn[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in sn)throw RangeError(`Duplicate use of step JSON ID `+e);return sn[e]=t,t.prototype.jsonID=e,t}},ln=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof Ne)return e.fail(t.message);throw t}}};function un(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(un(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return k.fromArray(r)}var dn=class e extends cn{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new j(un(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return ln.fromReplace(e,this.from,this.to,i)}invert(){return new fn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};cn.jsonID(`addMark`,dn);var fn=class e extends cn{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new j(un(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return ln.fromReplace(e,this.from,this.to,n)}invert(){return new dn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};cn.jsonID(`removeMark`,fn);var pn=class e extends cn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ln.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ln.fromReplace(e,this.pos,this.pos+1,new j(k.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new mn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};cn.jsonID(`addNodeMark`,pn);var mn=class e extends cn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ln.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ln.fromReplace(e,this.pos,this.pos+1,new j(k.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new pn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};cn.jsonID(`removeNodeMark`,mn);var hn=class e extends cn{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&_n(e,this.from,this.to)?ln.fail(`Structure replace would overwrite content`):ln.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new an([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?j.empty:new j(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?j.empty:new j(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,j.fromJSON(t,n.slice),!!n.structure)}};hn.MAP_BIAS=1,cn.jsonID(`replace`,hn);var gn=class e extends cn{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(_n(e,this.from,this.gapFrom)||_n(e,this.gapTo,this.to)))return ln.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ln.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?ln.fromReplace(e,this.from,this.to,n):ln.fail(`Content does not fit in gap`)}getMap(){return new an([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,j.fromJSON(t,n.slice),n.insert,!!n.structure)}};cn.jsonID(`replaceAround`,gn);function _n(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function vn(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new fn(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new dn(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function yn(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof St){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new fn(t.from,t.to,t.style)))}function bn(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new hn(s,l,j.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new fn(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new j(k.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new hn(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(k.empty,!0);e.replace(s,s,new j(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function xn(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Sn(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!xn(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function Cn(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=k.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=k.from(r.node(e).copy(u)),d++):c--;let f=k.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=k.from(i.node(e).copy(f)),p++):l++;e.step(new gn(c,l,o,s,new j(u.append(f),d,p),u.size-d,!0))}function wn(e,t,n=null,r=e){let i=En(e,t),a=i&&Dn(r,t);return a?i.map(Tn).concat({type:t,attrs:n}).concat(a.map(Tn)):null}function Tn(e){return{type:e,attrs:null}}function En(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function Dn(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function On(e,t,n){let r=k.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=k.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new gn(i,a,i,a,new j(r,0,0),n.length,!0))}function kn(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Mn(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&jn(e,t,n,a),bn(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new gn(c,l,c+1,l-1,new j(k.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&An(e,t,n,a),!1}})}function An(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function jn(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
@@ -150,7 +150,7 @@ img.ProseMirror-separator {
|
|
|
150
150
|
`}function nx(e,t){return!e||e===t?t:`[${e}](${rx(t)})`}function rx(e){return e.replace(/[\\()]/g,`\\$&`)}function ix(e,t){let n=e.querySelector(`summary`);if(!n)return kb(e,t);let r=n.querySelector(`h1, h2, h3, h4, h5, h6`);if(r){let i=Mb(r,t);for(let r of Array.from(e.children))r!==n&&(i+=Ab(r,t));return i}return kb(n,t)}function ax(e){let t=``;for(let n of Array.from(e.childNodes))if(n.nodeType===3)t+=n.textContent||``;else if(n.nodeType===1){let e=n;switch(e.tagName.toLowerCase()){case`strong`:case`b`:{let{content:n,trailing:r}=ox(ax(e));t+=n?`**${n}**${r}`:r;break}case`em`:case`i`:{let{content:n,trailing:r}=ox(ax(e));t+=n?`*${n}*${r}`:r;break}case`s`:case`del`:t+=`~~${ax(e)}~~`;break;case`code`:{let n=e.textContent||``,r=Math.max(0,...(n.match(/`+/g)??[]).map(e=>e.length)),i="`".repeat(r+1),a=n.startsWith("`")||n.endsWith("`");t+=i+(a?` ${n} `:n)+i;break}case`u`:t+=ax(e);break;case`a`:{let n=e.getAttribute(`href`)||``,r=ax(e);t+=nx(r,n);break}case`br`:t+=`\\
|
|
151
151
|
`;break;case`math`:{let n=Fb(e).split(`
|
|
152
152
|
`).map(e=>e.trim()).join(` `);t+=`$${n}$`;break}case`span`:t+=ax(e);break;case`img`:{let n=e.getAttribute(`src`)||``,r=e.getAttribute(`alt`)||``;t+=``;break}case`video`:{let n=e.getAttribute(`src`)||e.getAttribute(`data-url`)||``,r=e.getAttribute(`data-name`)||e.getAttribute(`title`)||``;t+=``;break}case`p`:t+=ax(e);break;case`input`:break;default:t+=ax(e)}}return t}function ox(e){let t=e.match(/^(.*?)(\s*)$/);return t?{content:t[1],trailing:t[2]}:{content:e,trailing:``}}function sx(e){let t=e.replace(/^(\\\n)+/,``);return t=t.replace(/(\\\n)+$/,``),t}function cx(e){return Ob(e.split(``).join(``))}function lx(e,t,n,r){return cx(Qy(t,n).exportBlocks(e,r))}function ux(e){let t=[];return e.descendants(e=>e.type.name===`blockContainer`&&e.firstChild?.type.name===`blockGroup`?!0:e.type.name===`columnList`&&e.childCount===1?(e.firstChild?.forEach(n=>{t.push(Ng(n,e))}),!1):!e.type.isInGroup(`bnBlock`)||(t.push(Ng(e,e)),!1)),t}var dx=class e extends M{nodes;constructor(e,t){super(e,t);let n=e.node();this.nodes=[],e.doc.nodesBetween(e.pos,t.pos,(e,t,r)=>{if(r!==null&&r.eq(n))return this.nodes.push(e),!1})}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}content(){return new j(k.from(this.nodes),0,0)}eq(t){if(!(t instanceof e)||this.nodes.length!==t.nodes.length||this.from!==t.from||this.to!==t.to)return!1;for(let e=0;e<this.nodes.length;e++)if(!this.nodes[e].eq(t.nodes[e]))return!1;return!0}map(t,n){let r=n.mapResult(this.from),i=n.mapResult(this.to);return i.deleted?M.near(t.resolve(r.pos)):r.deleted?M.near(t.resolve(i.pos)):new e(t.resolve(r.pos),t.resolve(i.pos))}toJSON(){return{type:`multiple-node`,anchor:this.anchor,head:this.head}}};M.jsonID(`multiple-node`,dx);var fx;function px(e,t){let n,r,i=t.resolve(e.from).node().type.spec.group===`blockContent`,a=t.resolve(e.to).node().type.spec.group===`blockContent`,o=Math.min(e.$anchor.depth,e.$head.depth);if(i&&a){let i=e.$from.start(o-1),a=e.$to.end(o-1);n=t.resolve(i-1).pos,r=t.resolve(a+1).pos}else n=e.from,r=e.to;return{from:n,to:r}}function mx(e,t,n=t){t===n&&(n+=e.state.doc.resolve(t+1).node().nodeSize);let r=e.domAtPos(t).node.cloneNode(!0),i=e.domAtPos(t).node,a=(e,t)=>Array.prototype.indexOf.call(e.children,t),o=a(i,e.domAtPos(t+1).node.parentElement),s=a(i,e.domAtPos(n-1).node.parentElement);for(let e=i.childElementCount-1;e>=0;e--)(e>s||e<o)&&r.removeChild(r.children[e]);hx(e.root),fx=r,fx.querySelectorAll(`iframe, embed, object`).forEach(e=>e.parentElement?.removeChild(e));let c=e.dom.className.split(` `).filter(e=>e!==`ProseMirror`&&e!==`bn-root`&&e!==`bn-editor`).join(` `);fx.className=fx.className+` bn-drag-preview `+c,e.root instanceof ShadowRoot?e.root.appendChild(fx):e.root.body.appendChild(fx)}function hx(e){fx!==void 0&&(e instanceof ShadowRoot?e.removeChild(fx):e.body.removeChild(fx),fx=void 0)}function gx(e,t,n){if(!e.dataTransfer||n.headless)return;let r=n.prosemirrorView,i=R_(t.id,r.state.doc);if(!i)throw Error(`Block with ID ${t.id} not found`);let a=i.posBeforeNode;if(a!=null){let t=r.state.selection,i=r.state.doc,{from:o,to:s}=px(t,i),c=o<=a&&a<s,l=t.$anchor.node()!==t.$head.node()||t instanceof dx;c&&l?(r.dispatch(r.state.tr.setSelection(dx.create(i,o,s))),mx(r,o,s)):(r.dispatch(r.state.tr.setSelection(P.create(r.state.doc,a))),mx(r,a));let u=r.state.selection.content(),d=n.pmSchema,f=r.serializeForClipboard(u).dom.innerHTML,p=Qy(d,n),m=ux(u.content),h=p.exportBlocks(m,{}),g=cx(h);e.dataTransfer.clearData(),e.dataTransfer.setData(`blocknote/html`,f),e.dataTransfer.setData(`text/html`,h),e.dataTransfer.setData(`text/plain`,g),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setDragImage(fx,0,0)}}var _x=250;function vx(e,t,n=!0){let r=e.root.elementsFromPoint(t.left,t.top);for(let i of r)if(e.dom.contains(i))return n&&i.closest(`[data-node-type=columnList]`)?vx(e,{left:t.left+50,top:t.top},!1):Db(i,e)}function yx(e,t){if(!t.dom.firstChild)return;let n=t.dom.firstChild.getBoundingClientRect(),r=vx(t,{left:Math.min(Math.max(n.left+10,e.x),n.right-10),top:e.y});if(r)return vx(t,{left:r.node.getBoundingClientRect().right-10,top:e.y},!1)}var bx=class{editor;pmView;state;emitUpdate;mousePos;hoveredBlock;menuFrozen=!1;isDragOrigin=!1;constructor(e,t,n){this.editor=e,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw Error(`Attempting to update uninitialized side menu`);n(this.state)},this.pmView.root.addEventListener(`dragstart`,this.onDragStart),this.pmView.root.addEventListener(`dragover`,this.onDragOver),this.pmView.root.addEventListener(`drop`,this.onDrop,!0),this.pmView.root.addEventListener(`dragend`,this.onDragEnd,!0),this.pmView.root.addEventListener(`mousemove`,this.onMouseMove,!0),this.pmView.root.addEventListener(`keydown`,this.onKeyDown,!0)}updateState=e=>{this.state=e,this.emitUpdate(this.state)};updateStateFromMousePos=()=>{if(this.menuFrozen||!this.mousePos)return;let e=this.findClosestEditorElement({clientX:this.mousePos.x,clientY:this.mousePos.y});if(e?.element!==this.pmView.dom||e.distance>_x){this.state?.show&&(this.state.show=!1,this.updateState(this.state));return}let t=yx(this.mousePos,this.pmView);if(!t||!this.editor.isEditable)this.state?.show&&(this.state.show=!1,this.updateState(this.state));else if(!(this.state?.show&&this.hoveredBlock?.hasAttribute(`data-id`)&&this.hoveredBlock?.getAttribute(`data-id`)===t.id)&&(this.hoveredBlock=t.node,this.editor.isEditable)){let e=t.node.getBoundingClientRect(),n=t.node.closest(`[data-node-type=column]`),r=this.editor.getBlock(this.hoveredBlock.getAttribute(`data-id`));if(!r){this.state?.show&&(this.state.show=!1,this.hoveredBlock=void 0,this.emitUpdate(this.state));return}this.state={show:!0,referencePos:new DOMRect(n?n.firstElementChild.getBoundingClientRect().x:this.pmView.dom.firstChild.getBoundingClientRect().x,e.y,e.width,e.height),block:r},this.updateState(this.state)}};onDragStart=e=>{let t=e.dataTransfer?.getData(`blocknote/html`);if(!t||this.pmView.dragging)return;let n=document.createElement(`div`);n.innerHTML=t;let r=Dt.fromSchema(this.pmView.state.schema).parse(n,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new j(r.content,0,0),move:!0}};findClosestEditorElement=e=>{let t=Array.from(this.pmView.root.querySelectorAll(`.bn-editor`));if(t.length===0)return null;let n=t[0],r=Number.MAX_VALUE;return t.forEach(t=>{let i=t.querySelector(`.bn-block-group`).getBoundingClientRect(),a=e.clientX<i.left?i.left-e.clientX:e.clientX>i.right?e.clientX-i.right:0,o=e.clientY<i.top?i.top-e.clientY:e.clientY>i.bottom?e.clientY-i.bottom:0,s=Math.sqrt(a**2+o**2);s<r&&(r=s,n=t)}),{element:n,distance:r}};onDragOver=e=>{if(e.synthetic||!(this.pmView.dragging!==null||this.isDragOrigin||e.dataTransfer?.types.includes(`blocknote/html`)||e.target instanceof Node&&this.pmView.dom.contains(e.target)))return;let t=this.getDragEventContext(e);!t||!t.isDropPoint?this.closeDropCursor():t.isDropPoint&&!t.isDropWithinEditorBounds&&this.dispatchSyntheticEvent(e)};closeDropCursor=()=>{let e=new Event(`dragleave`,{bubbles:!1});e.synthetic=!0,this.pmView.dom.dispatchEvent(e)};getDragEventContext=e=>{if(!(this.pmView.dragging!==null||this.isDragOrigin||e.dataTransfer?.types.includes(`blocknote/html`)||e.target instanceof Node&&this.pmView.dom.contains(e.target)))return;let t=!e.dataTransfer?.types.includes(`blocknote/html`)&&!!this.pmView.dragging,n=!!this.isDragOrigin,r=t||n,i=this.findClosestEditorElement(e);if(!i||i.distance>_x)return;let a=i.element===this.pmView.dom,o=a&&i.distance===0;if(a||r)return{isDropPoint:a,isDropWithinEditorBounds:o,isDragOrigin:r}};onDrop=e=>{if(e.synthetic||!(this.pmView.dragging!==null||this.isDragOrigin||e.dataTransfer?.types.includes(`blocknote/html`)||e.target instanceof Node&&this.pmView.dom.contains(e.target)))return;let t=this.getDragEventContext(e);if(!t){this.closeDropCursor();return}let{isDropPoint:n,isDropWithinEditorBounds:r,isDragOrigin:i}=t;if(!r&&n&&this.dispatchSyntheticEvent(e),n){if(this.pmView.dragging)return;this.pmView.dispatch(this.pmView.state.tr.setSelection(N.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.anchor)))}else i&&setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0)};onDragEnd=e=>{e.synthetic||(this.pmView.dragging=null)};onKeyDown=e=>{this.state?.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))};onMouseMove=e=>{if(this.menuFrozen||!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY)||e.target instanceof Node&&!this.pmView.dom.contains(e.target)&&this.editor.isWithinEditor(e.target))return;this.mousePos={x:e.clientX,y:e.clientY};let t=this.pmView.dom.getBoundingClientRect();this.mousePos.x>t.left&&this.mousePos.x<t.right&&this.mousePos.y>t.top&&this.mousePos.y<t.bottom&&e&&e.target&&!this.editor.isWithinEditor(e.target)?this.state?.show&&(this.state.show=!1,this.emitUpdate(this.state)):this.updateStateFromMousePos()};dispatchSyntheticEvent(e){let t=new Event(e.type,e),n=this.pmView.dom.firstChild.getBoundingClientRect();t.clientX=e.clientX,t.clientY=e.clientY,t.clientX=Math.min(Math.max(e.clientX,n.left),n.left+n.width),t.clientY=Math.min(Math.max(e.clientY,n.top),n.top+n.height),t.dataTransfer=e.dataTransfer,t.preventDefault=()=>e.preventDefault(),t.synthetic=!0,this.pmView.dom.dispatchEvent(t)}update(e,t){!t.doc.eq(this.pmView.state.doc)&&this.state?.show&&this.updateStateFromMousePos()}destroy(){this.state?.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.pmView.root.removeEventListener(`mousemove`,this.onMouseMove,!0),this.pmView.root.removeEventListener(`dragstart`,this.onDragStart),this.pmView.root.removeEventListener(`dragover`,this.onDragOver),this.pmView.root.removeEventListener(`drop`,this.onDrop,!0),this.pmView.root.removeEventListener(`dragend`,this.onDragEnd,!0),this.pmView.root.removeEventListener(`keydown`,this.onKeyDown,!0)}},xx=new jr(`SideMenuPlugin`),Sx=z(({editor:e})=>{let t,n=Lp(void 0);return{key:`sideMenu`,store:n,prosemirrorPlugins:[new F({key:xx,view:r=>(t=new bx(e,r,e=>{n.setState({...e})}),t)})],blockDragStart(n,r){t&&(t.isDragOrigin=!0),gx(n,r,e)},blockDragEnd(){hx(e.prosemirrorView.root),t&&(t.isDragOrigin=!1),e.blur()},get menuFrozen(){return t.menuFrozen},freezeMenu(){t.menuFrozen=!0,t.state.show=!0,t.emitUpdate(t.state)},unfreezeMenu(){t.menuFrozen=!1,t.state.show=!1,t.emitUpdate(t.state)},hideMenuIfNotFrozen(){!t.menuFrozen&&t.state?.show&&(t.state.show=!1,t.emitUpdate(t.state))}}}),Cx=z(({editor:e})=>{let t=Lp({popupOpen:void 0,selected:void 0}),n=t=>!!e.schema.blockSpecs[t.type]?.implementation?.meta?.hasPreview,r=e=>({editor:r})=>{let{block:i,prevBlock:a,nextBlock:o}=r.getTextCursorPosition();if(!n(i)||t.state.popupOpen===i.id)return!1;let s=e===`prev`?a:o;return s?(r.setTextCursorPosition(s.id,e===`prev`?`end`:`start`),!0):!1};return{key:`sourceBlockWithPreview`,store:t,keyboardShortcuts:{Enter:({editor:e})=>{let{block:r}=e.getTextCursorPosition();if(!n(r))return!1;if(t.state.popupOpen===r.id&&e.schema.blockSpecs[r.type]?.implementation?.meta?.hardBreakShortcut===`enter`){let t=e.prosemirrorView;return t.dispatch(t.state.tr.insertText(`
|
|
153
|
-
`)),!0}return e.setTextCursorPosition(r.id,`end`),t.setState(e=>({...e,popupOpen:t.state.popupOpen===r.id?void 0:r.id})),!0},Escape:({editor:e})=>{let{block:r}=e.getTextCursorPosition();return!n(r)||t.state.popupOpen!==r.id?!1:(e.setTextCursorPosition(r.id,`end`),t.setState(e=>({...e,popupOpen:void 0})),!0)},"Mod-a":({editor:e})=>{let{block:r}=e.getTextCursorPosition();if(!n(r)||t.state.popupOpen!==r.id)return!1;let i=e.prosemirrorView,{$from:a}=i.state.selection;return a.parent.type.name===r.type&&(i.dispatch(i.state.tr.setSelection(N.create(i.state.doc,a.start(),a.end()))),!0)},ArrowUp:r(`prev`),ArrowLeft:r(`prev`),ArrowDown:r(`next`),ArrowRight:r(`next`)},mount:({dom:r,signal:i})=>{let a=e.onSelectionChange(()=>{let{block:r}=e.getTextCursorPosition(),i=n(r)?r.id:void 0,a=t.state.popupOpen&&t.state.popupOpen!==r.id?void 0:t.state.popupOpen;(i!==t.state.selected||a!==t.state.popupOpen)&&t.setState(e=>({...e,selected:i,popupOpen:a}))});i.addEventListener(`abort`,a),r.addEventListener(`keydown`,r=>{if(!e.isEditable)return;let{block:i}=e.getTextCursorPosition();if(n(i)&&t.state.popupOpen!==i.id){if(r.key===`Backspace`||r.key===`Delete`){r.preventDefault(),r.stopImmediatePropagation(),e.removeBlocks([i.id]);return}(r.key.length===1&&!r.ctrlKey&&!r.metaKey||r.key===`Tab`)&&(r.preventDefault(),r.stopImmediatePropagation())}},{capture:!0,signal:i}),r.addEventListener(`blur`,()=>t.setState(e=>({...e,popupOpen:void 0})),{capture:!0,signal:i})}}}),wx=z(({editor:e})=>{let t=Lp({selected:void 0}),n=t=>!!e.schema.inlineContentSpecs[t]?.implementation?.meta?.hasPreview,r=e=>({editor:t})=>{let{$from:r}=t.prosemirrorState.selection,i=r.node();if(!n(i.type.name))return!1;let a=t.prosemirrorView,o=M.near(a.state.doc.resolve(e===`before`?r.before():r.after()),e===`before`?-1:1);return a.dispatch(a.state.tr.setSelection(o)),!0};return{key:`sourceInlineContentWithPreview`,store:t,keyboardShortcuts:{Enter:r(`after`),"Shift-Enter":r(`after`),Escape:r(`after`),ArrowUp:r(`before`),ArrowDown:r(`after`),"Mod-a":({editor:e})=>{let{$from:t}=e.prosemirrorState.selection;if(!n(t.node().type.name))return!1;let r=e.prosemirrorView;return r.dispatch(r.state.tr.setSelection(N.create(r.state.doc,t.start(),t.end()))),!0}},mount:({dom:r,signal:i})=>{let a=e.onSelectionChange(()=>{let{$from:r}=e.prosemirrorState.selection,i=r.node();t.setState({selected:n(i.type.name)?r.before():void 0})});i.addEventListener(`abort`,a),r.addEventListener(`keydown`,t=>{if(t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;let{$from:i}=e.prosemirrorState.selection;n(i.node().type.name)||(r.classList.add(`bn-suppress-source-popup-caret`),requestAnimationFrame(()=>r.classList.remove(`bn-suppress-source-popup-caret`)))},{capture:!0,signal:i}),r.addEventListener(`blur`,()=>t.setState({selected:void 0}),{capture:!0,signal:i})}}}),Tx=Symbol.for(`blocknote.shikiParser`),Ex=Symbol.for(`blocknote.shikiHighlighterPromise`),Dx=[`text`,`none`,`plaintext`,`txt`];function Ox(e,t,n){let r=globalThis,i,a,o=new Set;return Vy({parser:t=>{if(!e.createHighlighter)return[];if(!i)return r[Ex]=r[Ex]||e.createHighlighter(),r[Ex].then(e=>{i=e});let n=t.language;return!n||Dx.includes(n)||o.has(n)?[]:i.getLoadedLanguages().includes(n)?(a||(a=r[Tx]||Wy(i,kx(i)),r[Tx]=a),a(t)):i.loadLanguage(n).catch(()=>{o.add(n)})},languageExtractor:e=>{let t={type:e.type.name,props:e.attrs};return(n.blockSpecs[t.type]||n.inlineContentSpecs[t.type])?.implementation?.meta?.highlight?.(t)??void 0},nodeTypes:t})}function kx(e){let t=e.getLoadedThemes(),n=t.find(e=>/light/i.test(e)),r=t.find(e=>/dark/i.test(e));if(n&&r)return{themes:{light:n,dark:r},defaultColor:!1}}function Ax(e){let t=Object.values(e.blockSpecs).filter(e=>typeof e?.config==`object`&&e.config.content===`plain`&&!!e.implementation?.meta?.highlight).map(e=>e.config.type),n=Object.values(e.inlineContentSpecs).filter(e=>typeof e?.config==`object`&&e.config.content===`plain`&&!!e.implementation?.meta?.highlight).map(e=>e.config.type);return[...t,...n]}z(({editor:e,options:t})=>({key:`syntaxHighlighting`,prosemirrorPlugins:[Ox(t,Ax(e.schema),e.schema)]}));var jx;async function Mx(){return jx||(jx=(async()=>{let[e,t]=await Promise.all([ue(()=>import(`./module-CvVAOmRW.js`),[]),ue(()=>import(`./native-Cqs-2kTC.js`),[])]),n=`default`in e?e.default:e,r=`default`in t?t.default:t;return await n.init({data:r}),{emojiMart:n,emojiData:r}})(),jx)}async function Nx(e,t){if(!(`text`in e.schema.inlineContentSchema)||e.schema.inlineContentSchema.text!==Ny.text)return[];let{emojiData:n,emojiMart:r}=await Mx();return(t.trim()===``?Object.values(n.emojis):await r.SearchIndex.search(t)).map(t=>({id:t.skins[0].native,onItemClick:()=>e.insertInlineContent(t.skins[0].native+` `)}))}var Px;function Fx(e){Px||(Px=document.createElement(`div`),Px.innerHTML=`_`,Px.style.opacity=`0`,Px.style.height=`1px`,Px.style.width=`1px`,e instanceof Document?e.body.appendChild(Px):e.appendChild(Px))}function Ix(e){Px&&=(e instanceof Document?e.body.removeChild(Px):e.removeChild(Px),void 0)}function Lx(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function Rx(e){let t=e;for(;t&&t.nodeName!==`TD`&&t.nodeName!==`TH`&&!t.classList.contains(`tableWrapper`);){if(t.classList.contains(`ProseMirror`))return;let e=t.parentNode;if(!e||!(e instanceof Element))return;t=e}return t.nodeName===`TD`||t.nodeName===`TH`?{type:`cell`,domNode:t,tbodyNode:t.closest(`tbody`)}:{type:`wrapper`,domNode:t,tbodyNode:t.querySelector(`tbody`)}}function zx(e,t){let n=t.querySelectorAll(e);for(let e=0;e<n.length;e++)n[e].style.visibility=`hidden`}var Bx=class{editor;pmView;state;emitUpdate;tableId;tablePos;tableElement;menuFrozen=!1;mouseState=`up`;prevWasEditable=null;constructor(e,t,n){this.editor=e,this.pmView=t,this.emitUpdate=()=>{n(this.state)},t.dom.addEventListener(`mousemove`,this.mouseMoveHandler),t.dom.addEventListener(`mousedown`,this.viewMousedownHandler),window.addEventListener(`mouseup`,this.mouseUpHandler),t.root.addEventListener(`dragover`,this.dragOverHandler),t.root.addEventListener(`drop`,this.dropHandler)}viewMousedownHandler=()=>{this.mouseState=`down`};hideHandles=()=>{this.state?.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate())};mouseUpHandler=e=>{this.mouseState=`up`,this.mouseMoveHandler(e)};mouseMoveHandler=e=>{if(this.menuFrozen||this.mouseState===`selecting`||!(e.target instanceof Element)||!this.pmView.dom.contains(e.target))return;let t=Rx(e.target);if(t?.type===`cell`&&this.mouseState===`down`&&!this.state?.draggingState){this.mouseState=`selecting`,this.hideHandles();return}if(!t||!this.editor.isEditable){this.hideHandles();return}if(!t.tbodyNode)return;let n=t.tbodyNode.getBoundingClientRect(),r=Db(t.domNode,this.pmView);if(!r)return;let{pmNodeInfo:i,doc:a}=this.editor.transact(e=>({pmNodeInfo:R_(r.id,e.doc),doc:e.doc}));if(!i){this.hideHandles();return}let o=Ng(i.node,a);if(!hy(o,this.editor,`table`)){this.hideHandles();return}let s=o;this.tablePos=i.posBeforeNode+1,this.tableElement=r.node,this.tableId=r.id;let c=t.domNode.closest(`.tableWrapper`)?.querySelector(`.table-widgets-container`);if(t?.type===`wrapper`){let t=e.clientY>=n.bottom-1&&e.clientY<n.bottom+20,r=e.clientX>=n.right-1&&e.clientX<n.right+20,i=this.state?.block?.id!==s.id||e.clientX>n.right||e.clientY>n.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:t,showAddOrRemoveColumnsButton:r,referencePosTable:n,block:s,widgetContainer:c,colIndex:i?void 0:this.state?.colIndex,rowIndex:i?void 0:this.state?.rowIndex,referencePosCell:i?void 0:this.state?.referencePosCell}}else{let e=Lx(t.domNode),i=Lx(t.domNode.parentElement),a=t.domNode.getBoundingClientRect();if(this.state!==void 0&&this.state.show&&this.tableId===r.id&&this.state.rowIndex===i&&this.state.colIndex===e)return;this.state={show:!0,showAddOrRemoveColumnsButton:e===s.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:i===s.content.rows.length-1,referencePosTable:n,block:s,draggingState:void 0,referencePosCell:a,colIndex:e,rowIndex:i,widgetContainer:c}}return this.emitUpdate(),!1};dragOverHandler=e=>{if(this.state?.draggingState===void 0)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`,zx(`.prosemirror-dropcursor-block, .prosemirror-dropcursor-inline`,this.pmView.root);let t={left:Math.min(Math.max(e.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(e.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},n=this.pmView.root.elementsFromPoint(t.left,t.top).filter(e=>e.tagName===`TD`||e.tagName===`TH`);if(n.length===0)return;let r=n[0],i=!1,a=Lx(r.parentElement),o=Lx(r),s=this.state.draggingState.draggedCellOrientation===`row`?this.state.rowIndex:this.state.colIndex,c=(this.state.draggingState.draggedCellOrientation===`row`?a:o)!==s;(this.state.rowIndex!==a||this.state.colIndex!==o)&&(this.state.rowIndex=a,this.state.colIndex=o,this.state.referencePosCell=r.getBoundingClientRect(),i=!0);let l=this.state.draggingState.draggedCellOrientation===`row`?t.top:t.left;this.state.draggingState.mousePos!==l&&(this.state.draggingState.mousePos=l,i=!0),i&&this.emitUpdate(),c&&this.editor.transact(e=>e.setMeta(Vx,!0))};dropHandler=e=>{if(this.mouseState=`up`,this.state===void 0||this.state.draggingState===void 0)return!1;if(this.state.rowIndex===void 0||this.state.colIndex===void 0)throw Error(`Attempted to drop table row or column, but no table block was hovered prior.`);e.preventDefault();let{draggingState:t,colIndex:n,rowIndex:r}=this.state;this.state.draggingState=void 0;let i=this.state.block.content.columnWidths;if(t.draggedCellOrientation===`row`){if(!O_(this.state.block,t.originalIndex,r))return!1;let e=w_(this.state.block,t.originalIndex,r);this.editor.updateBlock(this.state.block,{type:`table`,content:{...this.state.block.content,rows:e}})}else{if(!k_(this.state.block,t.originalIndex,n))return!1;let e=C_(this.state.block,t.originalIndex,n),[r]=i.splice(t.originalIndex,1);i.splice(n,0,r),this.editor.updateBlock(this.state.block,{type:`table`,content:{...this.state.block.content,columnWidths:i,rows:e}})}return this.editor.setTextCursorPosition(this.state.block.id),!0};getTablePos(e){if(this.tableId===void 0)return;let t=R_(this.tableId,e);return t&&t.posBeforeNode+1}update(){if(!this.state||!this.state.show)return;let e=this.editor.getBlock(this.state.block.id);if(!e||e.type!==`table`||!this.tableElement?.isConnected){this.state=void 0,this.tableId=void 0,this.tablePos=void 0,this.tableElement=void 0,this.emitUpdate();return}this.state.block=e,this.tablePos=this.getTablePos(this.pmView.state.doc);let{height:t,width:n}=y_(this.state.block);this.state.rowIndex!==void 0&&this.state.colIndex!==void 0&&(this.state.rowIndex>=t&&(this.state.rowIndex=t-1),this.state.colIndex>=n&&(this.state.colIndex=n-1));let r=this.tableElement.querySelector(`tbody`);if(!r)throw Error(`Table block does not contain a 'tbody' HTML element. This should never happen.`);if(this.state.rowIndex!==void 0&&this.state.colIndex!==void 0){let e=r.children[this.state.rowIndex].children[this.state.colIndex];e?this.state.referencePosCell=e.getBoundingClientRect():(this.state.rowIndex=void 0,this.state.colIndex=void 0)}this.state.referencePosTable=r.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener(`mousemove`,this.mouseMoveHandler),window.removeEventListener(`mouseup`,this.mouseUpHandler),this.pmView.dom.removeEventListener(`mousedown`,this.viewMousedownHandler),this.pmView.root.removeEventListener(`dragover`,this.dragOverHandler),this.pmView.root.removeEventListener(`drop`,this.dropHandler)}},Vx=new jr(`TableHandlesPlugin`),Hx=z(({editor:e})=>{let t,n=Lp(void 0);return{key:`tableHandles`,store:n,prosemirrorPlugins:[new F({key:Vx,view:r=>(t=new Bx(e,r,e=>{n.setState(e?.block?{...e,draggingState:e.draggingState?{...e.draggingState}:void 0}:void 0)}),t),props:{decorations:e=>{if(t===void 0||t.state===void 0||t.state.draggingState===void 0)return;let n=t.getTablePos(e.doc);if(n===void 0)return;let r=t.state.draggingState.draggedCellOrientation===`row`?t.state.rowIndex:t.state.colIndex;if(r===void 0)return;let i=[],{block:a,draggingState:o}=t.state,{originalIndex:s,draggedCellOrientation:c}=o;if(r===s||!a||c===`row`&&!O_(a,s,r)||c===`col`&&!k_(a,s,r))return L.create(e.doc,i);let l=e.doc.resolve(n+1);return t.state.draggingState.draggedCellOrientation===`row`?x_(t.state.block,r).forEach(({row:t,col:n})=>{let a=e.doc.resolve(l.posAtIndex(t)+1),o=e.doc.resolve(a.posAtIndex(n)+1),c=o.node(),u=o.pos+(r>s?c.nodeSize-2:0);i.push(ic.widget(u,()=>{let e=document.createElement(`div`);return e.className=`bn-table-drop-cursor`,e.style.left=`0`,e.style.right=`0`,r>s?e.style.bottom=`-2px`:e.style.top=`-3px`,e.style.height=`4px`,e}))}):S_(t.state.block,r).forEach(({row:t,col:n})=>{let a=e.doc.resolve(l.posAtIndex(t)+1),o=e.doc.resolve(a.posAtIndex(n)+1),c=o.node(),u=o.pos+(r>s?c.nodeSize-2:0);i.push(ic.widget(u,()=>{let e=document.createElement(`div`);return e.className=`bn-table-drop-cursor`,e.style.top=`0`,e.style.bottom=`0`,r>s?e.style.right=`-2px`:e.style.left=`-3px`,e.style.width=`4px`,e}))}),L.create(e.doc,i)}}})],colDragStart(n){if(t===void 0||t.state===void 0||t.state.colIndex===void 0)throw Error(`Attempted to drag table column, but no table block was hovered prior.`);t.state.draggingState={draggedCellOrientation:`col`,originalIndex:t.state.colIndex,mousePos:n.clientX},t.emitUpdate(),e.transact(e=>e.setMeta(Vx,{draggedCellOrientation:t.state.draggingState.draggedCellOrientation,originalIndex:t.state.colIndex,newIndex:t.state.colIndex,tablePos:t.tablePos})),!e.headless&&(Fx(e.prosemirrorView.root),n.dataTransfer.setDragImage(Px,0,0),n.dataTransfer.effectAllowed=`move`)},rowDragStart(n){if(t.state===void 0||t.state.rowIndex===void 0)throw Error(`Attempted to drag table row, but no table block was hovered prior.`);t.state.draggingState={draggedCellOrientation:`row`,originalIndex:t.state.rowIndex,mousePos:n.clientY},t.emitUpdate(),e.transact(e=>e.setMeta(Vx,{draggedCellOrientation:t.state.draggingState.draggedCellOrientation,originalIndex:t.state.rowIndex,newIndex:t.state.rowIndex,tablePos:t.tablePos})),!e.headless&&(Fx(e.prosemirrorView.root),n.dataTransfer.setDragImage(Px,0,0),n.dataTransfer.effectAllowed=`copyMove`)},dragEnd(){if(t.state===void 0)throw Error(`Attempted to drag table row, but no table block was hovered prior.`);t.state.draggingState=void 0,t.emitUpdate(),e.transact(e=>e.setMeta(Vx,null)),!e.headless&&Ix(e.prosemirrorView.root)},freezeHandles(){t.menuFrozen=!0},unfreezeHandles(){t.menuFrozen=!1},hideHandlesIfNotFrozen(){t.menuFrozen||t.hideHandles()},getCellsAtRowHandle(e,t){return x_(e,t)},getCellsAtColumnHandle(e,t){return S_(e,t)},setCellSelection(e,n,r=n){if(!t)throw Error(`Table handles view not initialized`);let i=t.getTablePos(e.doc);if(i===void 0)throw Error(`Attempted to select table cells, but the hovered table is no longer in the document.`);let a=e.doc.resolve(i+1),o=e.doc.resolve(a.posAtIndex(n.row)+1),s=e.doc.resolve(o.posAtIndex(n.col)),c=e.doc.resolve(a.posAtIndex(r.row)+1),l=e.doc.resolve(c.posAtIndex(r.col)),u=e.tr;return u.setSelection(new am(s,l)),e.apply(u)},addRowOrColumn(t,n){e.exec((e,r)=>{let i=this.setCellSelection(e,n.orientation===`row`?{row:t,col:0}:{row:0,col:t});return n.orientation===`row`?n.side===`above`?Cm(i,r):wm(i,r):n.side===`left`?_m(i,r):vm(i,r)})},removeRowOrColumn(t,n){return n===`row`?e.exec((e,n)=>Em(this.setCellSelection(e,{row:t,col:0}),n)):e.exec((e,n)=>bm(this.setCellSelection(e,{row:0,col:t}),n))},mergeCells(t){return e.exec((e,n)=>km(t?this.setCellSelection(e,t.relativeStartCell,t.relativeEndCell):e,n))},splitCell(t){return e.exec((e,n)=>Am(t?this.setCellSelection(e,t):e,n))},getCellSelection(){return e.transact(e=>{let t=e.selection,n=t.$from,r=t.$to;if(gy(t)){let{ranges:e}=t;e.forEach(e=>{n=e.$from.min(n??e.$from),r=e.$to.max(r??e.$to)})}else{let i=t.$from.pos-t.$from.parentOffset-1,a=t.$to.pos-t.$to.parentOffset-1;if(i<0||a<0||(n=e.doc.resolve(i),r=e.doc.resolve(a),!_y(n.parent)||!_y(r.parent)))return}let i=e.doc.resolve(n.pos-n.parentOffset-1),a=e.doc.resolve(r.pos-r.parentOffset-1),o=e.doc.resolve(i.pos-i.parentOffset-1),s=n.index(i.depth),c=i.index(o.depth),l=r.index(a.depth),u=a.index(o.depth),d=[];for(let e=c;e<=u;e++)for(let t=s;t<=l;t++)d.push({row:e,col:t});return{from:{row:c,col:s},to:{row:u,col:l},cells:d}})},getMergeDirection(t){return e.transact(e=>{let n=gy(e.selection)?e.selection:void 0;if(!n||!t||n.ranges.length<=1)return;let r=this.getCellSelection();if(r)return A_(r.from,r.to,t)?`vertical`:`horizontal`})},cropEmptyRowsOrColumns(e,t){return E_(e,t)},addRowsOrColumns(e,t,n){return D_(e,t,n)}}}),Ux=new jr(`trailingNode`);function Wx(e){let t=e.lastChild,n=t?.firstChild;return t?.type.name!==`blockContainer`||n?.type.name!==`paragraph`||n.content.size!==0}function Gx(e){if(!e.type.schema.nodes.column){let t=e.lastChild;return t&&Wx(t)?[e.content.size-1]:[]}let t=[];return e.descendants((e,n,r)=>!e.isTextblock&&((e.type.name===`column`||e.type.name===`blockGroup`&&r?.type.name===`doc`)&&Wx(e)&&t.push(n+e.nodeSize-1),!0)),t}var Kx=z(({editor:e})=>{function t(t){return ic.widget(t,()=>{let t=document.createElement(`div`);return t.className=`bn-trailing-block`,t.contentEditable=`false`,t.addEventListener(`mousedown`,n=>{n.preventDefault();let r=e.prosemirrorView;if(!r)return;let i=r.state.doc.resolve(r.posAtDOM(t,0)).parent.lastChild?.attrs.id;i&&(e.transact(t=>{let[n]=e.insertBlocks([{type:`paragraph`}],i,`after`);e.setTextCursorPosition(n,`start`),t.scrollIntoView()}),r.focus())}),t},{side:1})}function n(e,n,r){let i=n.map(e.mapping,e.doc),a=new Set(r?Gx(e.doc):[]),o=new Set,s=[];for(let e of i.find())a.has(e.from)&&!o.has(e.from)?o.add(e.from):s.push(e);let c=[...a].filter(e=>!o.has(e)),l=i;return s.length>0&&(l=l.remove(s)),c.length>0&&(l=l.add(e.doc,c.map(t))),l}return{key:`trailingNode`,prosemirrorPlugins:[new F({key:Ux,state:{init:(t,r)=>n(r.tr,L.empty,e.isEditable),apply:(t,r)=>!t.docChanged&&!t.getMeta(Ux)?r:n(t,r,e.isEditable)},view(e){let t=e.editable;return{update(e){e.editable!==t&&(t=e.editable,e.dispatch(e.state.tr.setMeta(Ux,!0)))}}},props:{decorations:e=>Ux.getState(e),handleKeyDown:(t,n)=>{if(n.key!==`ArrowRight`&&n.key!==`ArrowDown`)return!1;let{selection:r}=t.state;if(!r.empty)return!1;let i=M.atEnd(t.state.doc);if(r.$head.pos!==i.$head.pos)return!1;let a=t.state.doc.lastChild;return!e.isEditable||!a||!Wx(a)?!1:(n.preventDefault(),!0)}}})]}}),qx=Symbol(`bn-current-version`);function Jx(e){return[...e].sort((e,t)=>t.createdAt-e.createdAt)}function Yx(e){let t=typeof e==`object`?e.id:e;throw Error(`Snapshot not found: ${String(t)}`)}z(({options:e,editor:t})=>{let{endpoints:n,preview:r,getCurrentDocument:i,serializeCurrentContent:a,resolveUsers:o}=typeof e==`function`?e(t):e,s=typeof n==`function`?n(t):n,c=Ry(o),l=Lp({snapshots:[],previewedSnapshotId:void 0,compareToSnapshotId:void 0}),u=e=>{let t=typeof e==`object`?e.id:e;return l.state.snapshots.find(e=>e.id===t)},d=async()=>{let e=Jx(await s.list());return l.setState(t=>({...t,snapshots:e})),e},f=async(e,t)=>{let n=u(e);n||Yx(e);let i=t?.compareTo?u(t.compareTo):void 0;l.setState(e=>({...e,previewedSnapshotId:n.id,compareToSnapshotId:i?.id}));let a,o;i&&(a=await s.getContent(i),s.getAttributions&&(o=await s.getAttributions(n,i)));let c=await s.getContent(n);r.enterPreview(c,a,o,{snapshot:n,compareTo:i})},p=async e=>{if(!a)throw Error("previewCurrentVersion requires `serializeCurrentContent` to be provided to the VersioningExtension options.");let t=e?.compareTo?u(e.compareTo):void 0;l.setState(e=>({...e,previewedSnapshotId:qx,compareToSnapshotId:t?.id}));let n={id:qx,createdAt:Date.now(),updatedAt:Date.now()},i,o;t&&(i=await s.getContent(t),s.getAttributions&&(o=await s.getAttributions(n,t)));let c=await a();r.enterPreview(c,i,o,{snapshot:n,compareTo:t})},m=()=>{l.setState(e=>({...e,previewedSnapshotId:void 0,compareToSnapshotId:void 0})),r.exitPreview()};return{key:`versioning`,store:l,userStore:c,list:async()=>await d(),get canCompare(){return r.supportsComparison!==!1},canCreate:s.create!==void 0,create:s.create?async e=>{let t=await s.create(i(),{name:e?.name,restoredFromSnapshot:u(e?.restoredFromSnapshot)});l.setState(e=>({...e,snapshots:Jx([...e.snapshots,t])}));let n=await s.list();return l.setState(e=>({...e,snapshots:Jx(n.some(e=>e.id===t.id)?n:[...n,t])})),t}:void 0,canRestore:s.restore!==void 0,restore:s.restore?async e=>{m();let t=u(e);t||Yx(e);let n=await s.restore(i(),t);return r.applyRestore(n),await d(),n}:void 0,canRename:s.rename!==void 0,rename:s.rename?async(e,t)=>{let n=u(e);n||Yx(e),await s.rename(n,t),l.setState(n=>({...n,snapshots:n.snapshots.map(n=>n.id===e?{...n,name:t,updatedAt:Date.now()}:n)}))}:void 0,canRemove:s.remove!==void 0,remove:s.remove?async e=>{let t=u(e);t||Yx(e),(l.state.previewedSnapshotId===t.id||l.state.compareToSnapshotId===t.id)&&m(),await s.remove(t),l.setState(e=>({...e,snapshots:e.snapshots.filter(e=>e.id!==t.id)})),await d()}:void 0,previewSnapshot:f,canPreviewCurrent:a!==void 0,previewCurrentVersion:a?p:void 0,exitPreview:m}});var Xx={slash_menu:{heading:{title:`Heading 1`,subtext:`Top-level heading`,aliases:[`h`,`heading1`,`h1`],group:`Headings`},heading_2:{title:`Heading 2`,subtext:`Key section heading`,aliases:[`h2`,`heading2`,`subheading`],group:`Headings`},heading_3:{title:`Heading 3`,subtext:`Subsection and group heading`,aliases:[`h3`,`heading3`,`subheading`],group:`Headings`},heading_4:{title:`Heading 4`,subtext:`Minor subsection heading`,aliases:[`h4`,`heading4`,`subheading4`],group:`Subheadings`},heading_5:{title:`Heading 5`,subtext:`Small subsection heading`,aliases:[`h5`,`heading5`,`subheading5`],group:`Subheadings`},heading_6:{title:`Heading 6`,subtext:`Lowest-level heading`,aliases:[`h6`,`heading6`,`subheading6`],group:`Subheadings`},toggle_heading:{title:`Toggle Heading 1`,subtext:`Toggleable top-level heading`,aliases:[`h`,`heading1`,`h1`,`collapsable`],group:`Subheadings`},toggle_heading_2:{title:`Toggle Heading 2`,subtext:`Toggleable key section heading`,aliases:[`h2`,`heading2`,`subheading`,`collapsable`],group:`Subheadings`},toggle_heading_3:{title:`Toggle Heading 3`,subtext:`Toggleable subsection and group heading`,aliases:[`h3`,`heading3`,`subheading`,`collapsable`],group:`Subheadings`},quote:{title:`Quote`,subtext:`Quote or excerpt`,aliases:[`quotation`,`blockquote`,`bq`],group:`Basic blocks`},toggle_list:{title:`Toggle List`,subtext:`List with hideable sub-items`,aliases:[`li`,`list`,`toggleList`,`toggle list`,`collapsable list`],group:`Basic blocks`},numbered_list:{title:`Numbered List`,subtext:`List with ordered items`,aliases:[`ol`,`li`,`list`,`numberedlist`,`numbered list`],group:`Basic blocks`},bullet_list:{title:`Bullet List`,subtext:`List with unordered items`,aliases:[`ul`,`li`,`list`,`bulletlist`,`bullet list`],group:`Basic blocks`},check_list:{title:`Check List`,subtext:`List with checkboxes`,aliases:[`ul`,`li`,`list`,`checklist`,`check list`,`checked list`,`checkbox`],group:`Basic blocks`},paragraph:{title:`Paragraph`,subtext:`The body of your document`,aliases:[`p`,`paragraph`],group:`Basic blocks`},code_block:{title:`Code Block`,subtext:`Code block with syntax highlighting`,aliases:[`code`,`pre`],group:`Basic blocks`},page_break:{title:`Page Break`,subtext:`Page separator`,aliases:[`page`,`break`,`separator`],group:`Basic blocks`},table:{title:`Table`,subtext:`Table with editable cells`,aliases:[`table`],group:`Advanced`},image:{title:`Image`,subtext:`Resizable image with caption`,aliases:[`image`,`imageUpload`,`upload`,`img`,`picture`,`media`,`url`],group:`Media`},video:{title:`Video`,subtext:`Resizable video with caption`,aliases:[`video`,`videoUpload`,`upload`,`mp4`,`film`,`media`,`url`],group:`Media`},audio:{title:`Audio`,subtext:`Embedded audio with caption`,aliases:[`audio`,`audioUpload`,`upload`,`mp3`,`sound`,`media`,`url`],group:`Media`},file:{title:`File`,subtext:`Embedded file`,aliases:[`file`,`upload`,`embed`,`media`,`url`],group:`Media`},emoji:{title:`Emoji`,subtext:`Search for and insert an emoji`,aliases:[`emoji`,`emote`,`emotion`,`face`],group:`Others`},divider:{title:`Divider`,subtext:`Visually divide blocks`,aliases:[`divider`,`hr`,`line`,`horizontal rule`],group:`Basic blocks`}},placeholders:{default:`Enter text or type '/' for commands`,heading:`Heading`,toggleListItem:`Toggle`,bulletListItem:`List`,numberedListItem:`List`,checkListItem:`List`,emptyDocument:void 0,new_comment:`Write a comment...`,edit_comment:`Edit comment...`,comment_reply:`Add comment...`},file_blocks:{add_button_text:{image:`Add image`,video:`Add video`,audio:`Add audio`,file:`Add file`}},toggle_blocks:{add_block_button:`Empty toggle. Click to add a block.`},code_block:{add_source_button_text:`Add source code`,ok_button_text:`OK`},side_menu:{add_block_label:`Add block`,drag_handle_label:`Open block menu`},drag_handle:{delete_menuitem:`Delete`,colors_menuitem:`Colors`,header_row_menuitem:`Header row`,header_column_menuitem:`Header column`},table_handle:{delete_column_menuitem:`Delete column`,delete_row_menuitem:`Delete row`,add_left_menuitem:`Add column left`,add_right_menuitem:`Add column right`,add_above_menuitem:`Add row above`,add_below_menuitem:`Add row below`,split_cell_menuitem:`Split cell`,merge_cells_menuitem:`Merge cells`,background_color_menuitem:`Background color`},suggestion_menu:{no_items_title:`No items found`},color_picker:{text_title:`Text`,background_title:`Background`,colors:{default:`Auto`,gray:`Gray`,brown:`Brown`,red:`Red`,orange:`Orange`,yellow:`Yellow`,green:`Green`,blue:`Blue`,purple:`Purple`,pink:`Pink`}},formatting_toolbar:{bold:{tooltip:`Bold`,secondary_tooltip:`Mod+B`},italic:{tooltip:`Italic`,secondary_tooltip:`Mod+I`},underline:{tooltip:`Underline`,secondary_tooltip:`Mod+U`},strike:{tooltip:`Strike`,secondary_tooltip:`Mod+Shift+S`},code:{tooltip:`Code`,secondary_tooltip:``},colors:{tooltip:`Colors`},link:{tooltip:`Create link`,secondary_tooltip:`Mod+K`},file_caption:{tooltip:`Edit caption`,input_placeholder:`Edit caption`},file_replace:{tooltip:{image:`Replace image`,video:`Replace video`,audio:`Replace audio`,file:`Replace file`}},file_rename:{tooltip:{image:`Rename image`,video:`Rename video`,audio:`Rename audio`,file:`Rename file`},input_placeholder:{image:`Rename image`,video:`Rename video`,audio:`Rename audio`,file:`Rename file`}},file_download:{tooltip:{image:`Download image`,video:`Download video`,audio:`Download audio`,file:`Download file`}},file_delete:{tooltip:{image:`Delete image`,video:`Delete video`,audio:`Delete audio`,file:`Delete file`}},file_preview_toggle:{tooltip:`Toggle preview`},nest:{tooltip:`Nest block`,secondary_tooltip:`Tab`},unnest:{tooltip:`Unnest block`,secondary_tooltip:`Shift+Tab`},align_left:{tooltip:`Align text left`},align_center:{tooltip:`Align text center`},align_right:{tooltip:`Align text right`},align_justify:{tooltip:`Justify text`},table_cell_merge:{tooltip:`Merge cells`},comment:{tooltip:`Add comment`}},file_panel:{upload:{title:`Upload`,file_placeholder:{image:`Upload image`,video:`Upload video`,audio:`Upload audio`,file:`Upload file`},upload_error:`Error: Upload failed`},embed:{title:`Embed`,embed_button:{image:`Embed image`,video:`Embed video`,audio:`Embed audio`,file:`Embed file`},url_placeholder:`Enter URL`}},link_toolbar:{delete:{tooltip:`Remove link`},edit:{text:`Edit link`,tooltip:`Edit`},open:{tooltip:`Open in new tab`},form:{title_placeholder:`Edit title`,url_placeholder:`Edit URL`}},comments:{edited:`edited`,save_button_text:`Save`,cancel_button_text:`Cancel`,deleted_reference_text:`Original content deleted`,discard_pending_comment:`Are you sure you want to discard this comment?`,actions:{add_reaction:`Add reaction`,resolve:`Resolve`,reopen:`Re-open`,edit_comment:`Edit comment`,delete_comment:`Delete comment`,more_actions:`More actions`},reactions:{reacted_by:`Reacted by`},sidebar:{marked_as_resolved:`Marked as resolved`,more_replies:e=>`${e} more replies`}},suggestion_changes:{formatting_change:`Formatting Change`,deleted:`Deleted`,inserted_by:e=>`Inserted by: ${e}`,deleted_by:e=>`Deleted by: ${e}`,formatting_change_by:(e,t)=>`Formatting change (${e}) by: ${t}`},exporter:{open_file:`Open file`,open_video_file:`Open video`,open_audio_file:`Open audio`},generic:{ctrl_shortcut:`Ctrl`,form_submit:`OK`}},Zx=class{match;handler;undoable;inCode;inCodeMark;constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?Qx(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function Qx(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var $x=500;function eS({rules:e}){let t=new F({state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return tS(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&tS(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function tS(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state.tr.insertText(r,t,n),s=o.mapping.map(t),c=o.mapping.map(n),l=null,u=o.doc.resolve(s),d=u.parent.textBetween(Math.max(0,u.parentOffset-$x),u.parentOffset,null,``);for(let t=0;t<i.length;t++){let n=i[t];if(!n.inCodeMark&&u.marks().some(e=>e.type.spec.code))continue;if(u.parent.type.spec.code){if(!n.inCode)continue}else if(n.inCode===`only`)continue;let f=n.match.exec(d);if(!f||f[0].length<r.length)continue;l??=e.state.apply(o);let p=n.handler(l,f,s-f[0].length,c);if(p)return e.dispatch(o),e.dispatch(yl(e.state.tr)),n.undoable&&p.setMeta(a,{transform:p,from:s,to:c,text:r}),e.dispatch(p),!0}return!1}new Zx(/--$/,`—`,{inCodeMark:!1}),new Zx(/\.\.\.$/,`…`,{inCodeMark:!1}),new Zx(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new Zx(/"$/,`”`,{inCodeMark:!1}),new Zx(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new Zx(/'$/,`’`,{inCodeMark:!1});var nS=Ep.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),rS=class e extends M{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):M.near(r)}content(){return j.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new iS(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!oS(e)||!sS(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!P.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};rS.prototype.visible=!1,rS.findFrom=rS.findGapCursorFrom,M.jsonID(`gapcursor`,rS);var iS=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return rS.valid(t)?new rS(t):M.near(t)}};function aS(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function oS(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0}else for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||aS(e.type))return!0;if(e.inlineContent)return!1}}return!0}function sS(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0}else for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||aS(e.type))return!0;if(e.inlineContent)return!1}}return!0}function cS(){return new F({props:{decorations:pS,createSelectionBetween(e,t,n){return t.pos==n.pos&&rS.valid(n)?new rS(n):null},handleClick:dS,handleKeyDown:lS,handleDOMEvents:{beforeinput:fS}}})}var lS=el({ArrowLeft:uS(`horiz`,-1),ArrowRight:uS(`horiz`,1),ArrowUp:uS(`vert`,-1),ArrowDown:uS(`vert`,1)});function uS(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof N){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=rS.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new rS(c))),!0):!1}}function dS(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!rS.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&P.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new rS(r))),!0)}function fS(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof rS))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=k.empty;for(let e=r.length-1;e>=0;e--)i=k.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new j(i,0,0));return a.setSelection(N.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function pS(e){if(!(e.selection instanceof rS))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,L.create(e.doc,[ic.widget(e.selection.head,t,{key:`gapcursor`})])}var mS=sp.create({name:`gapCursor`,addProseMirrorPlugins(){return[cS()]},extendNodeSchema(e){return{allowGapCursor:$u(R(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}});function hS(e){return e.matches(`[data-editable]`)?e:e.querySelector(`[data-editable]`)||e}function gS(e,t){return Dt.fromSchema(t).parse(e,{topNode:t.nodes.paragraph.create(),preserveWhitespace:!0}).content}function _S(e,t){let n=[];return e.forEach(e=>{if(e.isText)n.push(e);else{let r=e.type===t.linebreakReplacement?`
|
|
153
|
+
`)),!0}return e.setTextCursorPosition(r.id,`end`),t.setState(e=>({...e,popupOpen:t.state.popupOpen===r.id?void 0:r.id})),!0},Escape:({editor:e})=>{let{block:r}=e.getTextCursorPosition();return!n(r)||t.state.popupOpen!==r.id?!1:(e.setTextCursorPosition(r.id,`end`),t.setState(e=>({...e,popupOpen:void 0})),!0)},"Mod-a":({editor:e})=>{let{block:r}=e.getTextCursorPosition();if(!n(r)||t.state.popupOpen!==r.id)return!1;let i=e.prosemirrorView,{$from:a}=i.state.selection;return a.parent.type.name===r.type&&(i.dispatch(i.state.tr.setSelection(N.create(i.state.doc,a.start(),a.end()))),!0)},ArrowUp:r(`prev`),ArrowLeft:r(`prev`),ArrowDown:r(`next`),ArrowRight:r(`next`)},mount:({dom:r,signal:i})=>{let a=e.onSelectionChange(()=>{let{block:r}=e.getTextCursorPosition(),i=n(r)?r.id:void 0,a=t.state.popupOpen&&t.state.popupOpen!==r.id?void 0:t.state.popupOpen;(i!==t.state.selected||a!==t.state.popupOpen)&&t.setState(e=>({...e,selected:i,popupOpen:a}))});i.addEventListener(`abort`,a),r.addEventListener(`keydown`,r=>{if(!e.isEditable)return;let{block:i}=e.getTextCursorPosition();if(n(i)&&t.state.popupOpen!==i.id){if(r.key===`Backspace`||r.key===`Delete`){r.preventDefault(),r.stopImmediatePropagation(),e.removeBlocks([i.id]);return}(r.key.length===1&&!r.ctrlKey&&!r.metaKey||r.key===`Tab`)&&(r.preventDefault(),r.stopImmediatePropagation())}},{capture:!0,signal:i}),r.addEventListener(`blur`,()=>t.setState(e=>({...e,popupOpen:void 0})),{capture:!0,signal:i})}}}),wx=z(({editor:e})=>{let t=Lp({selected:void 0}),n=t=>!!e.schema.inlineContentSpecs[t]?.implementation?.meta?.hasPreview,r=e=>({editor:t})=>{let{$from:r}=t.prosemirrorState.selection,i=r.node();if(!n(i.type.name))return!1;let a=t.prosemirrorView,o=M.near(a.state.doc.resolve(e===`before`?r.before():r.after()),e===`before`?-1:1);return a.dispatch(a.state.tr.setSelection(o)),!0};return{key:`sourceInlineContentWithPreview`,store:t,keyboardShortcuts:{Enter:r(`after`),"Shift-Enter":r(`after`),Escape:r(`after`),ArrowUp:r(`before`),ArrowDown:r(`after`),"Mod-a":({editor:e})=>{let{$from:t}=e.prosemirrorState.selection;if(!n(t.node().type.name))return!1;let r=e.prosemirrorView;return r.dispatch(r.state.tr.setSelection(N.create(r.state.doc,t.start(),t.end()))),!0}},mount:({dom:r,signal:i})=>{let a=e.onSelectionChange(()=>{let{$from:r}=e.prosemirrorState.selection,i=r.node();t.setState({selected:n(i.type.name)?r.before():void 0})});i.addEventListener(`abort`,a),r.addEventListener(`keydown`,t=>{if(t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;let{$from:i}=e.prosemirrorState.selection;n(i.node().type.name)||(r.classList.add(`bn-suppress-source-popup-caret`),requestAnimationFrame(()=>r.classList.remove(`bn-suppress-source-popup-caret`)))},{capture:!0,signal:i}),r.addEventListener(`blur`,()=>t.setState({selected:void 0}),{capture:!0,signal:i})}}}),Tx=Symbol.for(`blocknote.shikiParser`),Ex=Symbol.for(`blocknote.shikiHighlighterPromise`),Dx=[`text`,`none`,`plaintext`,`txt`];function Ox(e,t,n){let r=globalThis,i,a,o=new Set;return Vy({parser:t=>{if(!e.createHighlighter)return[];if(!i)return r[Ex]=r[Ex]||e.createHighlighter(),r[Ex].then(e=>{i=e});let n=t.language;return!n||Dx.includes(n)||o.has(n)?[]:i.getLoadedLanguages().includes(n)?(a||(a=r[Tx]||Wy(i,kx(i)),r[Tx]=a),a(t)):i.loadLanguage(n).catch(()=>{o.add(n)})},languageExtractor:e=>{let t={type:e.type.name,props:e.attrs};return(n.blockSpecs[t.type]||n.inlineContentSpecs[t.type])?.implementation?.meta?.highlight?.(t)??void 0},nodeTypes:t})}function kx(e){let t=e.getLoadedThemes(),n=t.find(e=>/light/i.test(e)),r=t.find(e=>/dark/i.test(e));if(n&&r)return{themes:{light:n,dark:r},defaultColor:!1}}function Ax(e){let t=Object.values(e.blockSpecs).filter(e=>typeof e?.config==`object`&&e.config.content===`plain`&&!!e.implementation?.meta?.highlight).map(e=>e.config.type),n=Object.values(e.inlineContentSpecs).filter(e=>typeof e?.config==`object`&&e.config.content===`plain`&&!!e.implementation?.meta?.highlight).map(e=>e.config.type);return[...t,...n]}z(({editor:e,options:t})=>({key:`syntaxHighlighting`,prosemirrorPlugins:[Ox(t,Ax(e.schema),e.schema)]}));var jx;async function Mx(){return jx||(jx=(async()=>{let[e,t]=await Promise.all([fe(()=>import(`./module-CvVAOmRW.js`),[]),fe(()=>import(`./native-Cqs-2kTC.js`),[])]),n=`default`in e?e.default:e,r=`default`in t?t.default:t;return await n.init({data:r}),{emojiMart:n,emojiData:r}})(),jx)}async function Nx(e,t){if(!(`text`in e.schema.inlineContentSchema)||e.schema.inlineContentSchema.text!==Ny.text)return[];let{emojiData:n,emojiMart:r}=await Mx();return(t.trim()===``?Object.values(n.emojis):await r.SearchIndex.search(t)).map(t=>({id:t.skins[0].native,onItemClick:()=>e.insertInlineContent(t.skins[0].native+` `)}))}var Px;function Fx(e){Px||(Px=document.createElement(`div`),Px.innerHTML=`_`,Px.style.opacity=`0`,Px.style.height=`1px`,Px.style.width=`1px`,e instanceof Document?e.body.appendChild(Px):e.appendChild(Px))}function Ix(e){Px&&=(e instanceof Document?e.body.removeChild(Px):e.removeChild(Px),void 0)}function Lx(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function Rx(e){let t=e;for(;t&&t.nodeName!==`TD`&&t.nodeName!==`TH`&&!t.classList.contains(`tableWrapper`);){if(t.classList.contains(`ProseMirror`))return;let e=t.parentNode;if(!e||!(e instanceof Element))return;t=e}return t.nodeName===`TD`||t.nodeName===`TH`?{type:`cell`,domNode:t,tbodyNode:t.closest(`tbody`)}:{type:`wrapper`,domNode:t,tbodyNode:t.querySelector(`tbody`)}}function zx(e,t){let n=t.querySelectorAll(e);for(let e=0;e<n.length;e++)n[e].style.visibility=`hidden`}var Bx=class{editor;pmView;state;emitUpdate;tableId;tablePos;tableElement;menuFrozen=!1;mouseState=`up`;prevWasEditable=null;constructor(e,t,n){this.editor=e,this.pmView=t,this.emitUpdate=()=>{n(this.state)},t.dom.addEventListener(`mousemove`,this.mouseMoveHandler),t.dom.addEventListener(`mousedown`,this.viewMousedownHandler),window.addEventListener(`mouseup`,this.mouseUpHandler),t.root.addEventListener(`dragover`,this.dragOverHandler),t.root.addEventListener(`drop`,this.dropHandler)}viewMousedownHandler=()=>{this.mouseState=`down`};hideHandles=()=>{this.state?.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate())};mouseUpHandler=e=>{this.mouseState=`up`,this.mouseMoveHandler(e)};mouseMoveHandler=e=>{if(this.menuFrozen||this.mouseState===`selecting`||!(e.target instanceof Element)||!this.pmView.dom.contains(e.target))return;let t=Rx(e.target);if(t?.type===`cell`&&this.mouseState===`down`&&!this.state?.draggingState){this.mouseState=`selecting`,this.hideHandles();return}if(!t||!this.editor.isEditable){this.hideHandles();return}if(!t.tbodyNode)return;let n=t.tbodyNode.getBoundingClientRect(),r=Db(t.domNode,this.pmView);if(!r)return;let{pmNodeInfo:i,doc:a}=this.editor.transact(e=>({pmNodeInfo:R_(r.id,e.doc),doc:e.doc}));if(!i){this.hideHandles();return}let o=Ng(i.node,a);if(!hy(o,this.editor,`table`)){this.hideHandles();return}let s=o;this.tablePos=i.posBeforeNode+1,this.tableElement=r.node,this.tableId=r.id;let c=t.domNode.closest(`.tableWrapper`)?.querySelector(`.table-widgets-container`);if(t?.type===`wrapper`){let t=e.clientY>=n.bottom-1&&e.clientY<n.bottom+20,r=e.clientX>=n.right-1&&e.clientX<n.right+20,i=this.state?.block?.id!==s.id||e.clientX>n.right||e.clientY>n.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:t,showAddOrRemoveColumnsButton:r,referencePosTable:n,block:s,widgetContainer:c,colIndex:i?void 0:this.state?.colIndex,rowIndex:i?void 0:this.state?.rowIndex,referencePosCell:i?void 0:this.state?.referencePosCell}}else{let e=Lx(t.domNode),i=Lx(t.domNode.parentElement),a=t.domNode.getBoundingClientRect();if(this.state!==void 0&&this.state.show&&this.tableId===r.id&&this.state.rowIndex===i&&this.state.colIndex===e)return;this.state={show:!0,showAddOrRemoveColumnsButton:e===s.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:i===s.content.rows.length-1,referencePosTable:n,block:s,draggingState:void 0,referencePosCell:a,colIndex:e,rowIndex:i,widgetContainer:c}}return this.emitUpdate(),!1};dragOverHandler=e=>{if(this.state?.draggingState===void 0)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`,zx(`.prosemirror-dropcursor-block, .prosemirror-dropcursor-inline`,this.pmView.root);let t={left:Math.min(Math.max(e.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(e.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},n=this.pmView.root.elementsFromPoint(t.left,t.top).filter(e=>e.tagName===`TD`||e.tagName===`TH`);if(n.length===0)return;let r=n[0],i=!1,a=Lx(r.parentElement),o=Lx(r),s=this.state.draggingState.draggedCellOrientation===`row`?this.state.rowIndex:this.state.colIndex,c=(this.state.draggingState.draggedCellOrientation===`row`?a:o)!==s;(this.state.rowIndex!==a||this.state.colIndex!==o)&&(this.state.rowIndex=a,this.state.colIndex=o,this.state.referencePosCell=r.getBoundingClientRect(),i=!0);let l=this.state.draggingState.draggedCellOrientation===`row`?t.top:t.left;this.state.draggingState.mousePos!==l&&(this.state.draggingState.mousePos=l,i=!0),i&&this.emitUpdate(),c&&this.editor.transact(e=>e.setMeta(Vx,!0))};dropHandler=e=>{if(this.mouseState=`up`,this.state===void 0||this.state.draggingState===void 0)return!1;if(this.state.rowIndex===void 0||this.state.colIndex===void 0)throw Error(`Attempted to drop table row or column, but no table block was hovered prior.`);e.preventDefault();let{draggingState:t,colIndex:n,rowIndex:r}=this.state;this.state.draggingState=void 0;let i=this.state.block.content.columnWidths;if(t.draggedCellOrientation===`row`){if(!O_(this.state.block,t.originalIndex,r))return!1;let e=w_(this.state.block,t.originalIndex,r);this.editor.updateBlock(this.state.block,{type:`table`,content:{...this.state.block.content,rows:e}})}else{if(!k_(this.state.block,t.originalIndex,n))return!1;let e=C_(this.state.block,t.originalIndex,n),[r]=i.splice(t.originalIndex,1);i.splice(n,0,r),this.editor.updateBlock(this.state.block,{type:`table`,content:{...this.state.block.content,columnWidths:i,rows:e}})}return this.editor.setTextCursorPosition(this.state.block.id),!0};getTablePos(e){if(this.tableId===void 0)return;let t=R_(this.tableId,e);return t&&t.posBeforeNode+1}update(){if(!this.state||!this.state.show)return;let e=this.editor.getBlock(this.state.block.id);if(!e||e.type!==`table`||!this.tableElement?.isConnected){this.state=void 0,this.tableId=void 0,this.tablePos=void 0,this.tableElement=void 0,this.emitUpdate();return}this.state.block=e,this.tablePos=this.getTablePos(this.pmView.state.doc);let{height:t,width:n}=y_(this.state.block);this.state.rowIndex!==void 0&&this.state.colIndex!==void 0&&(this.state.rowIndex>=t&&(this.state.rowIndex=t-1),this.state.colIndex>=n&&(this.state.colIndex=n-1));let r=this.tableElement.querySelector(`tbody`);if(!r)throw Error(`Table block does not contain a 'tbody' HTML element. This should never happen.`);if(this.state.rowIndex!==void 0&&this.state.colIndex!==void 0){let e=r.children[this.state.rowIndex].children[this.state.colIndex];e?this.state.referencePosCell=e.getBoundingClientRect():(this.state.rowIndex=void 0,this.state.colIndex=void 0)}this.state.referencePosTable=r.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener(`mousemove`,this.mouseMoveHandler),window.removeEventListener(`mouseup`,this.mouseUpHandler),this.pmView.dom.removeEventListener(`mousedown`,this.viewMousedownHandler),this.pmView.root.removeEventListener(`dragover`,this.dragOverHandler),this.pmView.root.removeEventListener(`drop`,this.dropHandler)}},Vx=new jr(`TableHandlesPlugin`),Hx=z(({editor:e})=>{let t,n=Lp(void 0);return{key:`tableHandles`,store:n,prosemirrorPlugins:[new F({key:Vx,view:r=>(t=new Bx(e,r,e=>{n.setState(e?.block?{...e,draggingState:e.draggingState?{...e.draggingState}:void 0}:void 0)}),t),props:{decorations:e=>{if(t===void 0||t.state===void 0||t.state.draggingState===void 0)return;let n=t.getTablePos(e.doc);if(n===void 0)return;let r=t.state.draggingState.draggedCellOrientation===`row`?t.state.rowIndex:t.state.colIndex;if(r===void 0)return;let i=[],{block:a,draggingState:o}=t.state,{originalIndex:s,draggedCellOrientation:c}=o;if(r===s||!a||c===`row`&&!O_(a,s,r)||c===`col`&&!k_(a,s,r))return L.create(e.doc,i);let l=e.doc.resolve(n+1);return t.state.draggingState.draggedCellOrientation===`row`?x_(t.state.block,r).forEach(({row:t,col:n})=>{let a=e.doc.resolve(l.posAtIndex(t)+1),o=e.doc.resolve(a.posAtIndex(n)+1),c=o.node(),u=o.pos+(r>s?c.nodeSize-2:0);i.push(ic.widget(u,()=>{let e=document.createElement(`div`);return e.className=`bn-table-drop-cursor`,e.style.left=`0`,e.style.right=`0`,r>s?e.style.bottom=`-2px`:e.style.top=`-3px`,e.style.height=`4px`,e}))}):S_(t.state.block,r).forEach(({row:t,col:n})=>{let a=e.doc.resolve(l.posAtIndex(t)+1),o=e.doc.resolve(a.posAtIndex(n)+1),c=o.node(),u=o.pos+(r>s?c.nodeSize-2:0);i.push(ic.widget(u,()=>{let e=document.createElement(`div`);return e.className=`bn-table-drop-cursor`,e.style.top=`0`,e.style.bottom=`0`,r>s?e.style.right=`-2px`:e.style.left=`-3px`,e.style.width=`4px`,e}))}),L.create(e.doc,i)}}})],colDragStart(n){if(t===void 0||t.state===void 0||t.state.colIndex===void 0)throw Error(`Attempted to drag table column, but no table block was hovered prior.`);t.state.draggingState={draggedCellOrientation:`col`,originalIndex:t.state.colIndex,mousePos:n.clientX},t.emitUpdate(),e.transact(e=>e.setMeta(Vx,{draggedCellOrientation:t.state.draggingState.draggedCellOrientation,originalIndex:t.state.colIndex,newIndex:t.state.colIndex,tablePos:t.tablePos})),!e.headless&&(Fx(e.prosemirrorView.root),n.dataTransfer.setDragImage(Px,0,0),n.dataTransfer.effectAllowed=`move`)},rowDragStart(n){if(t.state===void 0||t.state.rowIndex===void 0)throw Error(`Attempted to drag table row, but no table block was hovered prior.`);t.state.draggingState={draggedCellOrientation:`row`,originalIndex:t.state.rowIndex,mousePos:n.clientY},t.emitUpdate(),e.transact(e=>e.setMeta(Vx,{draggedCellOrientation:t.state.draggingState.draggedCellOrientation,originalIndex:t.state.rowIndex,newIndex:t.state.rowIndex,tablePos:t.tablePos})),!e.headless&&(Fx(e.prosemirrorView.root),n.dataTransfer.setDragImage(Px,0,0),n.dataTransfer.effectAllowed=`copyMove`)},dragEnd(){if(t.state===void 0)throw Error(`Attempted to drag table row, but no table block was hovered prior.`);t.state.draggingState=void 0,t.emitUpdate(),e.transact(e=>e.setMeta(Vx,null)),!e.headless&&Ix(e.prosemirrorView.root)},freezeHandles(){t.menuFrozen=!0},unfreezeHandles(){t.menuFrozen=!1},hideHandlesIfNotFrozen(){t.menuFrozen||t.hideHandles()},getCellsAtRowHandle(e,t){return x_(e,t)},getCellsAtColumnHandle(e,t){return S_(e,t)},setCellSelection(e,n,r=n){if(!t)throw Error(`Table handles view not initialized`);let i=t.getTablePos(e.doc);if(i===void 0)throw Error(`Attempted to select table cells, but the hovered table is no longer in the document.`);let a=e.doc.resolve(i+1),o=e.doc.resolve(a.posAtIndex(n.row)+1),s=e.doc.resolve(o.posAtIndex(n.col)),c=e.doc.resolve(a.posAtIndex(r.row)+1),l=e.doc.resolve(c.posAtIndex(r.col)),u=e.tr;return u.setSelection(new am(s,l)),e.apply(u)},addRowOrColumn(t,n){e.exec((e,r)=>{let i=this.setCellSelection(e,n.orientation===`row`?{row:t,col:0}:{row:0,col:t});return n.orientation===`row`?n.side===`above`?Cm(i,r):wm(i,r):n.side===`left`?_m(i,r):vm(i,r)})},removeRowOrColumn(t,n){return n===`row`?e.exec((e,n)=>Em(this.setCellSelection(e,{row:t,col:0}),n)):e.exec((e,n)=>bm(this.setCellSelection(e,{row:0,col:t}),n))},mergeCells(t){return e.exec((e,n)=>km(t?this.setCellSelection(e,t.relativeStartCell,t.relativeEndCell):e,n))},splitCell(t){return e.exec((e,n)=>Am(t?this.setCellSelection(e,t):e,n))},getCellSelection(){return e.transact(e=>{let t=e.selection,n=t.$from,r=t.$to;if(gy(t)){let{ranges:e}=t;e.forEach(e=>{n=e.$from.min(n??e.$from),r=e.$to.max(r??e.$to)})}else{let i=t.$from.pos-t.$from.parentOffset-1,a=t.$to.pos-t.$to.parentOffset-1;if(i<0||a<0||(n=e.doc.resolve(i),r=e.doc.resolve(a),!_y(n.parent)||!_y(r.parent)))return}let i=e.doc.resolve(n.pos-n.parentOffset-1),a=e.doc.resolve(r.pos-r.parentOffset-1),o=e.doc.resolve(i.pos-i.parentOffset-1),s=n.index(i.depth),c=i.index(o.depth),l=r.index(a.depth),u=a.index(o.depth),d=[];for(let e=c;e<=u;e++)for(let t=s;t<=l;t++)d.push({row:e,col:t});return{from:{row:c,col:s},to:{row:u,col:l},cells:d}})},getMergeDirection(t){return e.transact(e=>{let n=gy(e.selection)?e.selection:void 0;if(!n||!t||n.ranges.length<=1)return;let r=this.getCellSelection();if(r)return A_(r.from,r.to,t)?`vertical`:`horizontal`})},cropEmptyRowsOrColumns(e,t){return E_(e,t)},addRowsOrColumns(e,t,n){return D_(e,t,n)}}}),Ux=new jr(`trailingNode`);function Wx(e){let t=e.lastChild,n=t?.firstChild;return t?.type.name!==`blockContainer`||n?.type.name!==`paragraph`||n.content.size!==0}function Gx(e){if(!e.type.schema.nodes.column){let t=e.lastChild;return t&&Wx(t)?[e.content.size-1]:[]}let t=[];return e.descendants((e,n,r)=>!e.isTextblock&&((e.type.name===`column`||e.type.name===`blockGroup`&&r?.type.name===`doc`)&&Wx(e)&&t.push(n+e.nodeSize-1),!0)),t}var Kx=z(({editor:e})=>{function t(t){return ic.widget(t,()=>{let t=document.createElement(`div`);return t.className=`bn-trailing-block`,t.contentEditable=`false`,t.addEventListener(`mousedown`,n=>{n.preventDefault();let r=e.prosemirrorView;if(!r)return;let i=r.state.doc.resolve(r.posAtDOM(t,0)).parent.lastChild?.attrs.id;i&&(e.transact(t=>{let[n]=e.insertBlocks([{type:`paragraph`}],i,`after`);e.setTextCursorPosition(n,`start`),t.scrollIntoView()}),r.focus())}),t},{side:1})}function n(e,n,r){let i=n.map(e.mapping,e.doc),a=new Set(r?Gx(e.doc):[]),o=new Set,s=[];for(let e of i.find())a.has(e.from)&&!o.has(e.from)?o.add(e.from):s.push(e);let c=[...a].filter(e=>!o.has(e)),l=i;return s.length>0&&(l=l.remove(s)),c.length>0&&(l=l.add(e.doc,c.map(t))),l}return{key:`trailingNode`,prosemirrorPlugins:[new F({key:Ux,state:{init:(t,r)=>n(r.tr,L.empty,e.isEditable),apply:(t,r)=>!t.docChanged&&!t.getMeta(Ux)?r:n(t,r,e.isEditable)},view(e){let t=e.editable;return{update(e){e.editable!==t&&(t=e.editable,e.dispatch(e.state.tr.setMeta(Ux,!0)))}}},props:{decorations:e=>Ux.getState(e),handleKeyDown:(t,n)=>{if(n.key!==`ArrowRight`&&n.key!==`ArrowDown`)return!1;let{selection:r}=t.state;if(!r.empty)return!1;let i=M.atEnd(t.state.doc);if(r.$head.pos!==i.$head.pos)return!1;let a=t.state.doc.lastChild;return!e.isEditable||!a||!Wx(a)?!1:(n.preventDefault(),!0)}}})]}}),qx=Symbol(`bn-current-version`);function Jx(e){return[...e].sort((e,t)=>t.createdAt-e.createdAt)}function Yx(e){let t=typeof e==`object`?e.id:e;throw Error(`Snapshot not found: ${String(t)}`)}z(({options:e,editor:t})=>{let{endpoints:n,preview:r,getCurrentDocument:i,serializeCurrentContent:a,resolveUsers:o}=typeof e==`function`?e(t):e,s=typeof n==`function`?n(t):n,c=Ry(o),l=Lp({snapshots:[],previewedSnapshotId:void 0,compareToSnapshotId:void 0}),u=e=>{let t=typeof e==`object`?e.id:e;return l.state.snapshots.find(e=>e.id===t)},d=async()=>{let e=Jx(await s.list());return l.setState(t=>({...t,snapshots:e})),e},f=async(e,t)=>{let n=u(e);n||Yx(e);let i=t?.compareTo?u(t.compareTo):void 0;l.setState(e=>({...e,previewedSnapshotId:n.id,compareToSnapshotId:i?.id}));let a,o;i&&(a=await s.getContent(i),s.getAttributions&&(o=await s.getAttributions(n,i)));let c=await s.getContent(n);r.enterPreview(c,a,o,{snapshot:n,compareTo:i})},p=async e=>{if(!a)throw Error("previewCurrentVersion requires `serializeCurrentContent` to be provided to the VersioningExtension options.");let t=e?.compareTo?u(e.compareTo):void 0;l.setState(e=>({...e,previewedSnapshotId:qx,compareToSnapshotId:t?.id}));let n={id:qx,createdAt:Date.now(),updatedAt:Date.now()},i,o;t&&(i=await s.getContent(t),s.getAttributions&&(o=await s.getAttributions(n,t)));let c=await a();r.enterPreview(c,i,o,{snapshot:n,compareTo:t})},m=()=>{l.setState(e=>({...e,previewedSnapshotId:void 0,compareToSnapshotId:void 0})),r.exitPreview()};return{key:`versioning`,store:l,userStore:c,list:async()=>await d(),get canCompare(){return r.supportsComparison!==!1},canCreate:s.create!==void 0,create:s.create?async e=>{let t=await s.create(i(),{name:e?.name,restoredFromSnapshot:u(e?.restoredFromSnapshot)});l.setState(e=>({...e,snapshots:Jx([...e.snapshots,t])}));let n=await s.list();return l.setState(e=>({...e,snapshots:Jx(n.some(e=>e.id===t.id)?n:[...n,t])})),t}:void 0,canRestore:s.restore!==void 0,restore:s.restore?async e=>{m();let t=u(e);t||Yx(e);let n=await s.restore(i(),t);return r.applyRestore(n),await d(),n}:void 0,canRename:s.rename!==void 0,rename:s.rename?async(e,t)=>{let n=u(e);n||Yx(e),await s.rename(n,t),l.setState(n=>({...n,snapshots:n.snapshots.map(n=>n.id===e?{...n,name:t,updatedAt:Date.now()}:n)}))}:void 0,canRemove:s.remove!==void 0,remove:s.remove?async e=>{let t=u(e);t||Yx(e),(l.state.previewedSnapshotId===t.id||l.state.compareToSnapshotId===t.id)&&m(),await s.remove(t),l.setState(e=>({...e,snapshots:e.snapshots.filter(e=>e.id!==t.id)})),await d()}:void 0,previewSnapshot:f,canPreviewCurrent:a!==void 0,previewCurrentVersion:a?p:void 0,exitPreview:m}});var Xx={slash_menu:{heading:{title:`Heading 1`,subtext:`Top-level heading`,aliases:[`h`,`heading1`,`h1`],group:`Headings`},heading_2:{title:`Heading 2`,subtext:`Key section heading`,aliases:[`h2`,`heading2`,`subheading`],group:`Headings`},heading_3:{title:`Heading 3`,subtext:`Subsection and group heading`,aliases:[`h3`,`heading3`,`subheading`],group:`Headings`},heading_4:{title:`Heading 4`,subtext:`Minor subsection heading`,aliases:[`h4`,`heading4`,`subheading4`],group:`Subheadings`},heading_5:{title:`Heading 5`,subtext:`Small subsection heading`,aliases:[`h5`,`heading5`,`subheading5`],group:`Subheadings`},heading_6:{title:`Heading 6`,subtext:`Lowest-level heading`,aliases:[`h6`,`heading6`,`subheading6`],group:`Subheadings`},toggle_heading:{title:`Toggle Heading 1`,subtext:`Toggleable top-level heading`,aliases:[`h`,`heading1`,`h1`,`collapsable`],group:`Subheadings`},toggle_heading_2:{title:`Toggle Heading 2`,subtext:`Toggleable key section heading`,aliases:[`h2`,`heading2`,`subheading`,`collapsable`],group:`Subheadings`},toggle_heading_3:{title:`Toggle Heading 3`,subtext:`Toggleable subsection and group heading`,aliases:[`h3`,`heading3`,`subheading`,`collapsable`],group:`Subheadings`},quote:{title:`Quote`,subtext:`Quote or excerpt`,aliases:[`quotation`,`blockquote`,`bq`],group:`Basic blocks`},toggle_list:{title:`Toggle List`,subtext:`List with hideable sub-items`,aliases:[`li`,`list`,`toggleList`,`toggle list`,`collapsable list`],group:`Basic blocks`},numbered_list:{title:`Numbered List`,subtext:`List with ordered items`,aliases:[`ol`,`li`,`list`,`numberedlist`,`numbered list`],group:`Basic blocks`},bullet_list:{title:`Bullet List`,subtext:`List with unordered items`,aliases:[`ul`,`li`,`list`,`bulletlist`,`bullet list`],group:`Basic blocks`},check_list:{title:`Check List`,subtext:`List with checkboxes`,aliases:[`ul`,`li`,`list`,`checklist`,`check list`,`checked list`,`checkbox`],group:`Basic blocks`},paragraph:{title:`Paragraph`,subtext:`The body of your document`,aliases:[`p`,`paragraph`],group:`Basic blocks`},code_block:{title:`Code Block`,subtext:`Code block with syntax highlighting`,aliases:[`code`,`pre`],group:`Basic blocks`},page_break:{title:`Page Break`,subtext:`Page separator`,aliases:[`page`,`break`,`separator`],group:`Basic blocks`},table:{title:`Table`,subtext:`Table with editable cells`,aliases:[`table`],group:`Advanced`},image:{title:`Image`,subtext:`Resizable image with caption`,aliases:[`image`,`imageUpload`,`upload`,`img`,`picture`,`media`,`url`],group:`Media`},video:{title:`Video`,subtext:`Resizable video with caption`,aliases:[`video`,`videoUpload`,`upload`,`mp4`,`film`,`media`,`url`],group:`Media`},audio:{title:`Audio`,subtext:`Embedded audio with caption`,aliases:[`audio`,`audioUpload`,`upload`,`mp3`,`sound`,`media`,`url`],group:`Media`},file:{title:`File`,subtext:`Embedded file`,aliases:[`file`,`upload`,`embed`,`media`,`url`],group:`Media`},emoji:{title:`Emoji`,subtext:`Search for and insert an emoji`,aliases:[`emoji`,`emote`,`emotion`,`face`],group:`Others`},divider:{title:`Divider`,subtext:`Visually divide blocks`,aliases:[`divider`,`hr`,`line`,`horizontal rule`],group:`Basic blocks`}},placeholders:{default:`Enter text or type '/' for commands`,heading:`Heading`,toggleListItem:`Toggle`,bulletListItem:`List`,numberedListItem:`List`,checkListItem:`List`,emptyDocument:void 0,new_comment:`Write a comment...`,edit_comment:`Edit comment...`,comment_reply:`Add comment...`},file_blocks:{add_button_text:{image:`Add image`,video:`Add video`,audio:`Add audio`,file:`Add file`}},toggle_blocks:{add_block_button:`Empty toggle. Click to add a block.`},code_block:{add_source_button_text:`Add source code`,ok_button_text:`OK`},side_menu:{add_block_label:`Add block`,drag_handle_label:`Open block menu`},drag_handle:{delete_menuitem:`Delete`,colors_menuitem:`Colors`,header_row_menuitem:`Header row`,header_column_menuitem:`Header column`},table_handle:{delete_column_menuitem:`Delete column`,delete_row_menuitem:`Delete row`,add_left_menuitem:`Add column left`,add_right_menuitem:`Add column right`,add_above_menuitem:`Add row above`,add_below_menuitem:`Add row below`,split_cell_menuitem:`Split cell`,merge_cells_menuitem:`Merge cells`,background_color_menuitem:`Background color`},suggestion_menu:{no_items_title:`No items found`},color_picker:{text_title:`Text`,background_title:`Background`,colors:{default:`Auto`,gray:`Gray`,brown:`Brown`,red:`Red`,orange:`Orange`,yellow:`Yellow`,green:`Green`,blue:`Blue`,purple:`Purple`,pink:`Pink`}},formatting_toolbar:{bold:{tooltip:`Bold`,secondary_tooltip:`Mod+B`},italic:{tooltip:`Italic`,secondary_tooltip:`Mod+I`},underline:{tooltip:`Underline`,secondary_tooltip:`Mod+U`},strike:{tooltip:`Strike`,secondary_tooltip:`Mod+Shift+S`},code:{tooltip:`Code`,secondary_tooltip:``},colors:{tooltip:`Colors`},link:{tooltip:`Create link`,secondary_tooltip:`Mod+K`},file_caption:{tooltip:`Edit caption`,input_placeholder:`Edit caption`},file_replace:{tooltip:{image:`Replace image`,video:`Replace video`,audio:`Replace audio`,file:`Replace file`}},file_rename:{tooltip:{image:`Rename image`,video:`Rename video`,audio:`Rename audio`,file:`Rename file`},input_placeholder:{image:`Rename image`,video:`Rename video`,audio:`Rename audio`,file:`Rename file`}},file_download:{tooltip:{image:`Download image`,video:`Download video`,audio:`Download audio`,file:`Download file`}},file_delete:{tooltip:{image:`Delete image`,video:`Delete video`,audio:`Delete audio`,file:`Delete file`}},file_preview_toggle:{tooltip:`Toggle preview`},nest:{tooltip:`Nest block`,secondary_tooltip:`Tab`},unnest:{tooltip:`Unnest block`,secondary_tooltip:`Shift+Tab`},align_left:{tooltip:`Align text left`},align_center:{tooltip:`Align text center`},align_right:{tooltip:`Align text right`},align_justify:{tooltip:`Justify text`},table_cell_merge:{tooltip:`Merge cells`},comment:{tooltip:`Add comment`}},file_panel:{upload:{title:`Upload`,file_placeholder:{image:`Upload image`,video:`Upload video`,audio:`Upload audio`,file:`Upload file`},upload_error:`Error: Upload failed`},embed:{title:`Embed`,embed_button:{image:`Embed image`,video:`Embed video`,audio:`Embed audio`,file:`Embed file`},url_placeholder:`Enter URL`}},link_toolbar:{delete:{tooltip:`Remove link`},edit:{text:`Edit link`,tooltip:`Edit`},open:{tooltip:`Open in new tab`},form:{title_placeholder:`Edit title`,url_placeholder:`Edit URL`}},comments:{edited:`edited`,save_button_text:`Save`,cancel_button_text:`Cancel`,deleted_reference_text:`Original content deleted`,discard_pending_comment:`Are you sure you want to discard this comment?`,actions:{add_reaction:`Add reaction`,resolve:`Resolve`,reopen:`Re-open`,edit_comment:`Edit comment`,delete_comment:`Delete comment`,more_actions:`More actions`},reactions:{reacted_by:`Reacted by`},sidebar:{marked_as_resolved:`Marked as resolved`,more_replies:e=>`${e} more replies`}},suggestion_changes:{formatting_change:`Formatting Change`,deleted:`Deleted`,inserted_by:e=>`Inserted by: ${e}`,deleted_by:e=>`Deleted by: ${e}`,formatting_change_by:(e,t)=>`Formatting change (${e}) by: ${t}`},exporter:{open_file:`Open file`,open_video_file:`Open video`,open_audio_file:`Open audio`},generic:{ctrl_shortcut:`Ctrl`,form_submit:`OK`}},Zx=class{match;handler;undoable;inCode;inCodeMark;constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?Qx(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function Qx(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var $x=500;function eS({rules:e}){let t=new F({state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return tS(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&tS(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function tS(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state.tr.insertText(r,t,n),s=o.mapping.map(t),c=o.mapping.map(n),l=null,u=o.doc.resolve(s),d=u.parent.textBetween(Math.max(0,u.parentOffset-$x),u.parentOffset,null,``);for(let t=0;t<i.length;t++){let n=i[t];if(!n.inCodeMark&&u.marks().some(e=>e.type.spec.code))continue;if(u.parent.type.spec.code){if(!n.inCode)continue}else if(n.inCode===`only`)continue;let f=n.match.exec(d);if(!f||f[0].length<r.length)continue;l??=e.state.apply(o);let p=n.handler(l,f,s-f[0].length,c);if(p)return e.dispatch(o),e.dispatch(yl(e.state.tr)),n.undoable&&p.setMeta(a,{transform:p,from:s,to:c,text:r}),e.dispatch(p),!0}return!1}new Zx(/--$/,`—`,{inCodeMark:!1}),new Zx(/\.\.\.$/,`…`,{inCodeMark:!1}),new Zx(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new Zx(/"$/,`”`,{inCodeMark:!1}),new Zx(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new Zx(/'$/,`’`,{inCodeMark:!1});var nS=Ep.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),rS=class e extends M{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):M.near(r)}content(){return j.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new iS(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!oS(e)||!sS(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!P.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};rS.prototype.visible=!1,rS.findFrom=rS.findGapCursorFrom,M.jsonID(`gapcursor`,rS);var iS=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return rS.valid(t)?new rS(t):M.near(t)}};function aS(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function oS(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0}else for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||aS(e.type))return!0;if(e.inlineContent)return!1}}return!0}function sS(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0}else for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||aS(e.type))return!0;if(e.inlineContent)return!1}}return!0}function cS(){return new F({props:{decorations:pS,createSelectionBetween(e,t,n){return t.pos==n.pos&&rS.valid(n)?new rS(n):null},handleClick:dS,handleKeyDown:lS,handleDOMEvents:{beforeinput:fS}}})}var lS=el({ArrowLeft:uS(`horiz`,-1),ArrowRight:uS(`horiz`,1),ArrowUp:uS(`vert`,-1),ArrowDown:uS(`vert`,1)});function uS(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof N){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=rS.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new rS(c))),!0):!1}}function dS(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!rS.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&P.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new rS(r))),!0)}function fS(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof rS))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=k.empty;for(let e=r.length-1;e>=0;e--)i=k.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new j(i,0,0));return a.setSelection(N.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function pS(e){if(!(e.selection instanceof rS))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,L.create(e.doc,[ic.widget(e.selection.head,t,{key:`gapcursor`})])}var mS=sp.create({name:`gapCursor`,addProseMirrorPlugins(){return[cS()]},extendNodeSchema(e){return{allowGapCursor:$u(R(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}});function hS(e){return e.matches(`[data-editable]`)?e:e.querySelector(`[data-editable]`)||e}function gS(e,t){return Dt.fromSchema(t).parse(e,{topNode:t.nodes.paragraph.create(),preserveWhitespace:!0}).content}function _S(e,t){let n=[];return e.forEach(e=>{if(e.isText)n.push(e);else{let r=e.type===t.linebreakReplacement?`
|
|
154
154
|
`:e.textContent;r&&n.push(t.text(r,e.marks))}}),k.fromArray(n)}function vS(e,t,n){let r=e.content===`plain`||n&&e.content===`styled`?t=>(r,i)=>{let a=n?.({el:r,schema:i});if(a!==void 0)return e.content===`plain`?_S(a,i):a;let o=gS(t(r),i);return e.content===`plain`?_S(o,i):o}:void 0,i=[{tag:`[data-inline-content-type="${e.type}"]`,contentElement:e=>hS(e),getContent:r?(e,t)=>r(hS)(e,t):void 0}];return t&&i.push({tag:`*`,getAttrs(e){if(typeof e==`string`)return!1;let n=t?.(e);return n!==void 0&&n},preserveWhitespace:r?!0:void 0,getContent:r?(e,t)=>r(e=>e)(e,t):void 0}),i}function yS(e,t,n,r=`before`){let i=typeof n==`string`?n:n.id,a=Sg(e),o=t.map(e=>{let t=L_(e,a);return t.check(),t}),s=R_(i,e.doc);if(!s)throw Error(`Block with ID ${i} not found`);let c=s.posBeforeNode;return r===`after`&&(c+=s.node.nodeSize),e.step(new hn(c,c,new j(k.from(o),0,0))),o.map(t=>Ng(t,e.doc))}function bS(e){if(!e||e.type.name!==`column`)throw Error(`Invalid columnPos: does not point to column node.`);let t=e.firstChild;if(!t)throw Error(`Invalid column: does not have child node.`);let n=t.firstChild;if(!n)throw Error(`Invalid blockContainer: does not have child node.`);return e.childCount===1&&t.childCount===1&&n.type.name===`paragraph`&&n.content.content.length===0}function xS(e,t){let n=e.doc.resolve(t),r=n.nodeAfter;if(!r||r.type.name!==`columnList`)throw Error(`Invalid columnListPos: does not point to columnList node.`);for(let t=r.childCount-1;t>=0;t--){let r=e.doc.resolve(n.pos+1).posAtIndex(t),i=e.doc.resolve(r).nodeAfter;if(!i||i.type.name!==`column`)throw Error(`Invalid columnPos: does not point to column node.`);bS(i)&&e.delete(r,r+i.nodeSize)}}function SS(e,t){xS(e,t);let n=e.doc.resolve(t).nodeAfter;if(!n||n.type.name!==`columnList`)throw Error(`Invalid columnListPos: does not point to columnList node.`);if(n.childCount>2)return;if(n.childCount<2)throw Error(`Invalid columnList: contains fewer than two children.`);let r=t+1,i=e.doc.resolve(r).nodeAfter,a=t+n.nodeSize-1,o=e.doc.resolve(a).nodeBefore;if(!i||!o)throw Error(`Invalid columnList: does not contain children.`);let s=bS(i),c=bS(o);s&&c?e.delete(t,t+n.nodeSize):s?e.step(new gn(t,t+n.nodeSize,a-o.nodeSize+1,a-1,j.empty,0,!1)):c&&e.step(new gn(t,t+n.nodeSize,r+1,r+i.nodeSize-1,j.empty,0,!1))}function CS(e,t,n,r={}){let i=Sg(e),a=n.map(e=>{let t=L_(e,i);return t.check(),t}),o=new Set(t.map(e=>typeof e==`string`?e:e.id)),s=[],c=new Set,l=typeof t[0]==`string`?t[0]:t[0].id,u=0;if(e.doc.descendants((t,r)=>{if(o.size===0)return!1;if(!t.type.isInGroup(`bnBlock`))return!0;let i=Kh(t,e.doc);if(!o.has(i))return!0;if(s.push(Ng(t,e.doc)),o.delete(i),n.length>0&&i===l){let t=e.doc.nodeSize;e.insert(r,a);let n=e.doc.nodeSize;u+=t-n}let d=e.doc.nodeSize,f=e.doc.resolve(r-u);f.node().type.name===`column`?c.add(f.before(-1)):f.node().type.name===`columnList`&&c.add(f.before()),f.node().type.name===`blockGroup`&&f.node(f.depth-1).type.name!==`doc`&&f.node().childCount===1?e.delete(f.before(),f.after()):e.delete(r-u,r-u+t.nodeSize);let p=e.doc.nodeSize;return u+=d-p,!1}),o.size>0){let e=[...o].join(`
|
|
155
155
|
`);throw Error(`Blocks with the following IDs could not be found in the editor: `+e)}return r.fixColumns!==!1&&c.forEach(t=>SS(e,t)),{insertedBlocks:a.map(t=>Ng(t,e.doc)),removedBlocks:s}}function wS(e,t,n,r,i){let a;if(!t)throw Error(`blockContent is required`);if(typeof t==`string`)a=P_([t],e.pmSchema,r);else if(Array.isArray(t))a=P_(t,e.pmSchema,r);else if(t.type===`tableContent`)a=F_(t,e.pmSchema);else throw new dg(t.type);let o=(i?.document??document).createDocumentFragment();for(let t of a)if(t.type.name!==`text`&&e.schema.inlineContentSchema[t.type.name]){let r=e.schema.inlineContentSpecs[t.type.name].implementation;if(r){let a=Mg(t,e.schema.inlineContentSchema,e.schema.styleSchema),s=r.render.call({renderType:`dom`,props:void 0},a,()=>{},e);if(s){if(o.appendChild(s.dom),s.contentDOM){let e=n.serializeFragment(t.content,i);s.contentDOM.dataset.editable=``,s.contentDOM.appendChild(e)}continue}}}else if(t.type.name===`text`){let n=document.createTextNode(t.textContent);for(let r of t.marks.toReversed())if(r.type.name in e.schema.styleSpecs){let t=e.schema.styleSpecs[r.type.name].implementation.render(r.attrs.stringValue,e);t.contentDOM.appendChild(n),n=t.dom}else{let e=r.type.spec.toDOM(r,!0),t=Vt.renderSpec(document,e);t.contentDOM.appendChild(n),n=t.dom}o.appendChild(n)}else{let e=n.serializeFragment(k.from([t]),i);o.appendChild(e)}return o}function TS(e,t,n,r){let i=e.pmSchema.nodes.blockContainer,a=t.props||{};for(let[n,r]of Object.entries(e.schema.blockSchema[t.type].propSchema))!(n in a)&&r.default!==void 0&&(a[n]=r.default);let o=t.children||[],s=e.blockImplementations[t.type].implementation.render.call({renderType:`dom`,props:void 0},{...t,props:a,children:o},e);if(s.contentDOM&&t.content){let i=wS(e,t.content,n,t.type,r);s.contentDOM.appendChild(i)}if(e.pmSchema.nodes[t.type].isInGroup(`bnBlock`)){if(t.children&&t.children.length>0){let i=ES(e,t.children,n,r);s.contentDOM?.append(i)}return s.dom}let c=i.spec?.toDOM?.(i.create({id:t.id,...a}));return c.contentDOM?.appendChild(s.dom),t.children&&t.children.length>0&&c.contentDOM?.appendChild(DS(e,t.children,n,r)),c.dom}function ES(e,t,n,r){let i=(r?.document??document).createDocumentFragment();for(let a of t){let t=TS(e,a,n,r);i.appendChild(t)}return i}var DS=(e,t,n,r)=>{let i=e.pmSchema.nodes.blockGroup,a=i.spec.toDOM(i.create({})),o=ES(e,t,n,r);return a.contentDOM?.appendChild(o),a.dom},OS=e=>(e.querySelectorAll(`[data-content-type="numberedListItem"]`).forEach(e=>{let t=e.closest(`.bn-block-outer`)?.previousElementSibling?.querySelector(`[data-content-type="numberedListItem"]`);if(!t)e.setAttribute(`data-index`,e.getAttribute(`data-start`)||`1`);else{let n=t.getAttribute(`data-index`);e.setAttribute(`data-index`,(parseInt(n||`0`)+1).toString())}}),e),kS=e=>(e.querySelectorAll(`[data-content-type="checkListItem"] input`).forEach(e=>{e.disabled=!0}),e),AS=e=>(e.querySelectorAll(`.bn-toggle-wrapper[data-show-children="false"]`).forEach(e=>{e.setAttribute(`data-show-children`,`true`)}),e),jS=e=>(e.querySelectorAll(`[data-content-type="table"] table`).forEach(e=>{e.setAttribute(`style`,`--default-cell-min-width: 120px;`),e.setAttribute(`data-show-children`,`true`)}),e),MS=e=>(e.querySelectorAll(`[data-content-type="table"] table`).forEach(e=>{let t=document.createElement(`div`);t.className=`tableWrapper`;let n=document.createElement(`div`);n.className=`tableWrapper-inner`,t.appendChild(n),e.parentElement?.appendChild(t),t.appendChild(e)}),e),NS=e=>(e.querySelectorAll(`.bn-inline-content:empty`).forEach(e=>{let t=document.createElement(`span`);t.className=`ProseMirror-trailingBreak`,t.setAttribute(`style`,`display: inline-block;`),e.appendChild(t)}),e),PS=(e,t)=>{let n=Vt.fromSchema(e),r=[OS,kS,AS,jS,MS,NS];return{serializeBlocks:(e,i)=>{let a=DS(t,e,n,i);for(let e of r)a=e(a);return a.outerHTML}}},FS=class{callbacks={};on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),()=>this.off(e,t)}emit(e,...t){let n=this.callbacks[e];n&&n.forEach(e=>e.apply(this,t))}off(e,t){let n=this.callbacks[e];n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e])}removeAllListeners(){this.callbacks={}}};function IS(e){return e.transact(e=>{let t=Qh(e,e.selection.anchor),n=Kh(t.bnBlock.node,e.doc);if(e.selection instanceof am)return{type:`cell`,anchorBlockId:n,anchorCellOffset:e.selection.$anchorCell.pos-t.bnBlock.beforePos,headCellOffset:e.selection.$headCell.pos-t.bnBlock.beforePos};if(e.selection instanceof P)return{type:`node`,anchorBlockId:n};{let r=Qh(e,e.selection.head);return{type:`text`,anchorBlockId:n,headBlockId:Kh(r.bnBlock.node,e.doc),anchorOffset:e.selection.anchor-t.bnBlock.beforePos,headOffset:e.selection.head-r.bnBlock.beforePos}}})}function LS(e,t){let n=R_(t.anchorBlockId,e.doc)?.posBeforeNode;if(n===void 0)throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);let r;if(t.type===`cell`)r=am.create(e.doc,n+t.anchorCellOffset,n+t.headCellOffset);else if(t.type===`node`)r=P.create(e.doc,n+1);else{let i=R_(t.headBlockId,e.doc)?.posBeforeNode;if(i===void 0)throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);r=N.create(e.doc,n+t.anchorOffset,i+t.headOffset)}e.setSelection(r)}function RS(e){return e.flatMap(e=>e.type===`column`?e.children:[e])}function zS(e,t,n,r){e.transact(e=>{CS(e,t,[],{fixColumns:!1}),yS(e,RS(t),n,r)})}function BS(e,t,n){e.transact(r=>{let i=e.getSelection()?.blocks||[e.getTextCursorPosition().block],a=IS(e);zS(e,i,t,n),LS(r,a)})}function VS(e){return!e||e.type!==`columnList`}function HS(e,t,n){let r,i;if(t?t.children.length>0?(r=t.children[t.children.length-1],i=`after`):(r=t,i=`before`):n&&(r=n,i=`before`),!r||!i)return;let a=e.getParentBlock(r);return VS(a)?{referenceBlock:r,placement:i}:HS(e,i===`after`?r:e.getPrevBlock(r),a)}function US(e,t,n){let r,i;if(t?t.children.length>0?(r=t.children[0],i=`before`):(r=t,i=`after`):n&&(r=n,i=`after`),!r||!i)return;let a=e.getParentBlock(r);return VS(a)?{referenceBlock:r,placement:i}:US(e,i===`before`?r:e.getNextBlock(r),a)}function WS(e,t){e.transact(()=>{let n;if(t){if(n=e.getBlock(t),!n)return}else n=e.getSelection()?.blocks[0]||e.getTextCursorPosition().block;let r=HS(e,e.getPrevBlock(n),e.getParentBlock(n));r&&(t?zS(e,[n],r.referenceBlock,r.placement):BS(e,r.referenceBlock,r.placement))})}function GS(e,t){e.transact(()=>{let n;if(t){if(n=e.getBlock(t),!n)return}else{let t=e.getSelection();n=t?.blocks[t?.blocks.length-1]||e.getTextCursorPosition().block}let r=US(e,e.getNextBlock(n),e.getParentBlock(n));r&&(t?zS(e,[n],r.referenceBlock,r.placement):BS(e,r.referenceBlock,r.placement))})}function KS(e,t,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,e=>e.childCount>0&&(e.type.name===`blockGroup`||e.type.name===`column`));if(!a)return!1;let o=a.startIndex;if(o===0)return!1;let s=a.parent.child(o-1);if(s.type!==t)return!1;let c=s.lastChild&&s.lastChild.type===n,l=k.from(c?t.create():null),u=new j(k.from(t.create(null,k.from(n.create(null,l)))),c?3:1,0),d=a.start,f=a.end;return e.step(new gn(d-(c?3:1),f,d,f,u,1,!0)).scrollIntoView(),!0}function qS(e){return e.transact(t=>KS(t,e.pmSchema.nodes.blockContainer,e.pmSchema.nodes.blockGroup))}function JS(e,t,n,r){let i=r.end,a=r.$to.end(r.depth);if(i<a){let o=r.parent.child(r.endIndex-1),s=o.lastChild&&o.lastChild.type===n;e.step(new gn(i-(s?2:1),a,i,a,new j(k.from(t.create(null,n.create())),s?2:1,0),+!s,!0)),r=new Xe(e.doc.resolve(r.$from.pos),e.doc.resolve(a),r.depth)}let o=Sn(r);if(o==null)return!1;e.lift(r,o);let s=e.doc.resolve(e.mapping.map(i,-1)-1);return In(e.doc,s.pos)&&s.nodeBefore.type===s.nodeAfter.type&&e.join(s.pos),e.scrollIntoView(),!0}function YS(e,t,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,e=>e.childCount>0&&(e.type.name===`blockGroup`||e.type.name===`column`));return a?r.node(a.depth-1).type===t&&JS(e,t,n,a):!1}function XS(e){return e.transact(t=>YS(t,e.pmSchema.nodes.blockContainer,e.pmSchema.nodes.blockGroup))}function ZS(e){return e.transact(e=>{let{bnBlock:t}=Zh(e);return e.doc.resolve(t.beforePos).nodeBefore!==null})}function QS(e){return e.transact(e=>{let{bnBlock:t}=Zh(e);return e.doc.resolve(t.beforePos).depth>1})}function $S(e,t){let n=R_(typeof t==`string`?t:t.id,e);if(n)return Ng(n.node,e)}function eC(e,t){let n=R_(typeof t==`string`?t:t.id,e);if(!n)return;let r=e.resolve(n.posBeforeNode).nodeBefore;if(r)return Ng(r,e)}function tC(e,t){let n=R_(typeof t==`string`?t:t.id,e);if(!n)return;let r=e.resolve(n.posBeforeNode+n.node.nodeSize).nodeAfter;if(r)return Ng(r,e)}function nC(e,t){let n=R_(typeof t==`string`?t:t.id,e);if(!n)return;let r=e.resolve(n.posBeforeNode),i=r.node(),a=r.node(-1),o=a.type.name===`doc`?void 0:i.type.name===`blockGroup`?a:i;if(o)return Ng(o,e)}var rC=class{editor;constructor(e){this.editor=e}get document(){return this.editor.transact(e=>Pg(e.doc))}getBlock(e){return this.editor.transact(t=>$S(t.doc,e))}getPrevBlock(e){return this.editor.transact(t=>eC(t.doc,e))}getNextBlock(e){return this.editor.transact(t=>tC(t.doc,e))}getParentBlock(e){return this.editor.transact(t=>nC(t.doc,e))}forEachBlock(e,t=!1){let n=this.document.slice();t&&n.reverse();function r(n){for(let i of n)if(e(i)===!1||!r(t?i.children.slice().reverse():i.children))return!1;return!0}r(n)}insertBlocks(e,t,n=`before`){return this.editor.transact(r=>yS(r,e,t,n))}updateBlock(e,t){return this.editor.transact(n=>q_(n,e,t))}removeBlocks(e){return this.editor.transact(t=>CS(t,e,[]).removedBlocks)}replaceBlocks(e,t){return this.editor.transact(n=>CS(n,e,t))}canNestBlock(){return ZS(this.editor)}nestBlock(){qS(this.editor)}canUnnestBlock(){return QS(this.editor)}unnestBlock(){XS(this.editor)}moveBlocksUp(e){return WS(this.editor,e)}moveBlocksDown(e){return GS(this.editor,e)}},iC=class extends FS{editor;constructor(e){super(),this.editor=e,e.on(`create`,()=>{e._tiptapEditor.on(`update`,({transaction:t,appendedTransactions:n})=>{this.emit(`onChange`,{editor:e,transaction:t,appendedTransactions:n})}),e._tiptapEditor.on(`selectionUpdate`,({transaction:t})=>{this.emit(`onSelectionChange`,{editor:e,transaction:t})}),e._tiptapEditor.on(`focus`,({event:t})=>{this.emit(`onFocusChange`,{editor:e,focused:!0,event:t})}),e._tiptapEditor.on(`blur`,({event:t})=>{this.emit(`onFocusChange`,{editor:e,focused:!1,event:t})}),e._tiptapEditor.on(`mount`,()=>{this.emit(`onMount`,{editor:e})}),e._tiptapEditor.on(`unmount`,()=>{this.emit(`onUnmount`,{editor:e})});let t;this.onMount(()=>{t=this.attachUIFocusTracker()}),this.onUnmount(()=>{t&&t()})})}attachUIFocusTracker(){if(typeof document>`u`)return()=>{};let e=this.editor.isFocused({includeEditorUI:!0}),t,n=t=>{let n=this.editor.isFocused({includeEditorUI:!0});n!==e&&(e=n,this.emit(`onFocusChangeWithinUI`,{editor:this.editor,focused:n,event:t}))},r=e=>n(e),i=e=>{clearTimeout(t),t=setTimeout(()=>n(e))};return document.addEventListener(`focusin`,r,!0),document.addEventListener(`focusout`,i,!0),()=>{clearTimeout(t),document.removeEventListener(`focusin`,r,!0),document.removeEventListener(`focusout`,i,!0)}}onChange(e,t=!0){return this.on(`onChange`,({transaction:n,appendedTransactions:r})=>{!t&&aC(n)||e(this.editor,{getChanges(){return ib(n,r)}})})}onSelectionChange(e,t=!1){return this.on(`onSelectionChange`,({transaction:n})=>{!t&&aC(n)||e(this.editor)})}onFocusChange(e,t){return this.on(t?.includeEditorUI?`onFocusChangeWithinUI`:`onFocusChange`,({focused:t,event:n})=>e(this.editor,{focused:t,event:n}))}onMount(e){return this.on(`onMount`,e)}onUnmount(e){return this.on(`onUnmount`,e)}};function aC(e){return!!e.getMeta(`y-sync$`)}function oC(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function sC(e){return e.nodeType===3&&!/\S/.test(e.nodeValue||``)}function cC(e){e.querySelectorAll(`li > ul, li > ol`).forEach(e=>{let t=oC(e),n=e.parentElement,r=Array.from(n.childNodes).slice(t+1);e.remove(),r.forEach(e=>{e.remove()}),n.insertAdjacentElement(`afterend`,e),r.reverse().forEach(t=>{if(sC(t))return;let n=document.createElement(`li`);n.append(t),e.insertAdjacentElement(`afterend`,n)}),n.childNodes.length===0&&n.remove()})}function lC(e){e.querySelectorAll(`li + ul, li + ol`).forEach(e=>{let t=e.previousElementSibling,n=document.createElement(`div`);t.insertAdjacentElement(`afterend`,n),n.append(t);let r=document.createElement(`div`);for(r.setAttribute(`data-node-type`,`blockGroup`),n.append(r);n.nextElementSibling?.nodeName===`UL`||n.nextElementSibling?.nodeName===`OL`;)r.append(n.nextElementSibling)})}var uC=null;function dC(){return uC||=document.implementation.createHTMLDocument(`title`)}function fC(e){if(typeof e==`string`){let t=dC().createElement(`div`);t.innerHTML=e,e=t}return cC(e),lC(e),e}function pC(e){let t=e.ownerDocument.createTreeWalker(e,128),n;for(;n=t.nextNode();)if(/^\s*notionvc:/.test(n.nodeValue||``))return!0;return!1}function mC(e){let t=new Set([`PRE`,`CODE`]),n=e.ownerDocument.createTreeWalker(e,4,{acceptNode(n){let r=n.parentElement;for(;r&&r!==e;){if(t.has(r.tagName))return 2;r=r.parentElement}return 1}}),r=[],i;for(;i=n.nextNode();)r.push(i);for(let e of r)e.nodeValue&&/[\r\n]/.test(e.nodeValue)&&(e.nodeValue=e.nodeValue.replace(/[ \t\r\n\f]+/g,` `))}function hC(e){pC(e)||mC(e)}function gC(e){let t=[];for(let n of e)if(n.type===`text`){let e=n.text.split(``).join(``);e.length>0&&t.push({...n,text:e})}else Array.isArray(n.content)?t.push({...n,content:gC(n.content)}):t.push(n);return t}function _C(e){for(let t of e)Array.isArray(t.content)&&(t.content=gC(t.content)),t.children.length>0&&_C(t.children)}function vC(e,t){let n=fC(e);hC(n);let r=Dt.fromSchema(t).parse(n,{topNode:t.nodes.blockGroup.create()}),i=[];for(let e=0;e<r.childCount;e++)i.push(Ng(r.child(e),r));return _C(i),i}function yC(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function bC(e){return e?/\w/.test(e):!1}function xC(e,t,n){let r=t>0?e[t-1]:void 0,i=t+n<e.length?e[t+n]:void 0;return bC(r)&&bC(i)}function SC(e,t){if(e[t]!==`\\`||t+1>=e.length)return null;let n=e[t+1];return n===`
|
|
156
156
|
`?{html:`<br>
|
|
@@ -171,5 +171,5 @@ img.ProseMirror-separator {
|
|
|
171
171
|
`}}),zw=(e,t)=>{let n=e.resolve(t),r=n.depth-1;if(r<1)return;let i=n.before(r),a=e.resolve(i).nodeAfter;if(a)return a.type.spec.group?.includes(`bnBlock`)?Xh(e.resolve(i)):zw(e,i)},Bw=(e,t)=>{let n=e.resolve(t),r=n.index();if(r===0)return;let i=n.posAtIndex(r-1);return Xh(e.resolve(i))},Vw=(e,t)=>{let n=e.resolve(t),r=n.index();if(r===n.node().childCount-1)return;let i=n.posAtIndex(r+1);return Xh(e.resolve(i))},Hw=(e,t)=>{for(;t.childContainer;){let n=t.childContainer.node,r=e.resolve(t.childContainer.beforePos+1).posAtIndex(n.childCount-1);t=Xh(e.resolve(r))}return t},Uw=(e,t)=>e.isBlockContainer&&e.blockContent.node.type.spec.content===`inline*`&&e.blockContent.node.childCount>0&&t.isBlockContainer&&t.blockContent.node.type.spec.content===`inline*`,Ww=(e,t,n,r)=>{if(!r.isBlockContainer)throw Error(`Attempted to merge block at position ${r.bnBlock.beforePos} into previous block at position ${n.bnBlock.beforePos}, but next block is not a block container`);if(r.childContainer){let n=e.doc.resolve(r.childContainer.beforePos+1),i=e.doc.resolve(r.childContainer.afterPos-1),a=n.blockRange(i);if(t){let t=e.doc.resolve(r.bnBlock.beforePos);e.tr.lift(a,t.depth)}}if(t){if(!n.isBlockContainer)throw Error(`Attempted to merge block at position ${r.bnBlock.beforePos} into previous block at position ${n.bnBlock.beforePos}, but previous block is not a block container`);t(e.tr.delete(n.blockContent.afterPos-1,r.blockContent.beforePos+1))}return!0},Gw=e=>({state:t,dispatch:n})=>{let r=Xh(t.doc.resolve(e)),i=Bw(t.doc,r.bnBlock.beforePos);if(!i)return!1;let a=Hw(t.doc,i);return Uw(a,r)?Ww(t,n,a,r):!1},Kw=sp.create({priority:50,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({chain:e,commands:t})=>[()=>t.deleteSelection(),()=>t.undoInputRule(),()=>t.command(({state:e})=>{let n=Zh(e);if(!n.isBlockContainer)return!1;let r=e.selection.from===n.blockContent.beforePos+1,i=n.blockContent.node.type.name===`paragraph`;return r&&!i?t.command(B_(n.bnBlock.beforePos,{type:`paragraph`,props:{}})):!1}),()=>t.command(({state:e,tr:t})=>{let n=Zh(e);if(!n.isBlockContainer)return!1;let{blockContent:r}=n;return e.selection.from===r.beforePos+1&&YS(t,t.doc.type.schema.nodes.blockContainer,t.doc.type.schema.nodes.blockGroup)}),()=>t.command(({state:t})=>{let n=Zh(t);if(!n.isBlockContainer)return!1;let{bnBlock:r,blockContent:i}=n,a=Bw(t.doc,n.bnBlock.beforePos);if(!a||!a.isBlockContainer||a.blockContent.node.type.spec.content!==`inline*`)return!1;let o=t.selection.from===i.beforePos+1,s=t.selection.empty,c=r.beforePos;return o&&s?e().command(Gw(c)).scrollIntoView().run():!1}),()=>t.command(({state:e,tr:t,dispatch:n})=>{let r=Zh(e);if(!r.isBlockContainer||e.selection.from!==r.blockContent.beforePos+1)return!1;let i=Bw(e.doc,r.bnBlock.beforePos);if(!i||i.isBlockContainer)return!1;if(n){let e=i.bnBlock.afterPos-1,n=t.doc.resolve(e-1);return t.delete(r.bnBlock.beforePos,r.bnBlock.afterPos),t.insert(n.pos,r.bnBlock.node),t.setSelection(N.near(t.doc.resolve(n.pos+1))),!0}return!1}),()=>t.command(({state:e,tr:t,dispatch:n})=>{let r=Zh(e);if(!r.isBlockContainer||t.selection.from!==r.blockContent.beforePos+1)return!1;let i=t.doc.resolve(r.bnBlock.beforePos);if(i.nodeBefore||i.node().type.name!==`column`)return!1;let a=t.doc.resolve(r.bnBlock.beforePos),o=t.doc.resolve(a.before()),s=o.before();return n&&(t.delete(r.bnBlock.beforePos,r.bnBlock.afterPos),SS(t,s),o.pos===s+1?(t.insert(s,r.bnBlock.node),t.setSelection(N.near(t.doc.resolve(s)))):(t.insert(o.pos-1,r.bnBlock.node),t.setSelection(N.near(t.doc.resolve(o.pos))))),!0}),()=>t.command(({state:t})=>{let n=Zh(t);if(!n.isBlockContainer)return!1;if(n.blockContent.node.childCount===0&&n.blockContent.node.type.spec.content===`inline*`){let r=Bw(t.doc,n.bnBlock.beforePos);if(!r)return!1;let i=Hw(t.doc,r);if(!i.isBlockContainer||!i||!i.isBlockContainer)return!1;let a=e();if(n.childContainer&&a.insertContentAt(n.bnBlock.afterPos,n.childContainer?.node.content),i.blockContent.node.type.spec.content===`tableRow+`){let e=n.bnBlock.beforePos-1-1-1-1-1;a=a.setTextSelection(e)}else if(i.blockContent.node.type.spec.content===``)a=a.setNodeSelection(i.blockContent.beforePos);else{let e=i.blockContent.afterPos-1;a=a.setTextSelection(e)}return a.deleteRange({from:n.bnBlock.beforePos,to:n.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>t.command(({state:t})=>{let n=Zh(t);if(!n.isBlockContainer)return!1;let r=t.selection.from===n.blockContent.beforePos+1,i=t.selection.empty,a=Bw(t.doc,n.bnBlock.beforePos);if(a&&r&&i){let r=Hw(t.doc,a);if(!r.isBlockContainer)return!1;if(r.blockContent.node.type.spec.content===``||r.blockContent.node.type.spec.content===`inline*`&&r.blockContent.node.childCount===0)return e().cut({from:n.bnBlock.beforePos,to:n.bnBlock.afterPos},r.bnBlock.afterPos).deleteRange({from:r.bnBlock.beforePos,to:r.bnBlock.afterPos}).run()}return!1})]),t=()=>this.editor.commands.first(({chain:e,commands:t})=>[()=>t.deleteSelection(),()=>t.command(({state:t})=>{let n=Zh(t);if(!n.isBlockContainer||!n.childContainer)return!1;let{blockContent:r,childContainer:i}=n,a=t.selection.from===r.afterPos-1,o=t.selection.empty,s=Xh(t.doc.resolve(i.beforePos+1));if(!s.isBlockContainer)return!1;if(a&&o){let n=s.blockContent.node,a=n.type.spec.content===`inline*`,o=r.node.type.spec.content===`inline*`;return e().insertContentAt(s.bnBlock.afterPos,s.childContainer?.node.content||k.empty).deleteRange(i.node.childCount===1?{from:i.beforePos,to:i.afterPos}:{from:s.bnBlock.beforePos,to:s.bnBlock.afterPos}).insertContentAt(t.selection.from,a&&o?n.content:null).setTextSelection(t.selection.from).scrollIntoView().run()}return!1}),()=>t.command(({state:t})=>{let n=Zh(t);if(!n.isBlockContainer)return!1;let{bnBlock:r,blockContent:i}=n,a=Vw(t.doc,n.bnBlock.beforePos);if(!a||!a.isBlockContainer)return!1;let o=t.selection.from===i.afterPos-1,s=t.selection.empty,c=r.afterPos;return o&&s?e().command(Gw(c)).scrollIntoView().run():!1}),()=>t.command(({state:e,tr:t,dispatch:n})=>{let r=Zh(e);if(!r.isBlockContainer||e.selection.from!==r.blockContent.afterPos-1)return!1;let i=Vw(e.doc,r.bnBlock.beforePos);if(!i||i.isBlockContainer)return!1;if(n){let e=i.bnBlock.beforePos+1,n=t.doc.resolve(e+1);return t.delete(n.pos,n.pos+n.nodeAfter.nodeSize),SS(t,i.bnBlock.beforePos),t.insert(r.bnBlock.afterPos,n.nodeAfter),t.setSelection(N.near(t.doc.resolve(n.pos))),!0}return!1}),()=>t.command(({state:e,tr:t,dispatch:n})=>{let r=Zh(e);if(!r.isBlockContainer||t.selection.from!==r.blockContent.afterPos-1)return!1;let i=t.doc.resolve(r.bnBlock.afterPos);if(i.nodeAfter||i.node().type.name!==`column`)return!1;let a=t.doc.resolve(r.bnBlock.afterPos),o=t.doc.resolve(a.after()),s=o.after();if(n){let e=o.pos===s-1?s:o.pos+1,n=Xh(t.doc.resolve(e));t.delete(n.bnBlock.beforePos,n.bnBlock.afterPos),SS(t,s-o.node().nodeSize),t.insert(a.pos,n.bnBlock.node),t.setSelection(N.near(t.doc.resolve(e)))}return!0}),()=>t.command(({state:t})=>{let n=Zh(t);if(!n.isBlockContainer)return!1;let{blockContent:r}=n,i=t.selection.from===r.afterPos-1,a=t.selection.empty;if(i&&a){let i=(e,t)=>{let n=Vw(e,t);if(n)return n;let r=zw(e,t);if(r)return i(e,r.bnBlock.beforePos)},a=i(t.doc,n.bnBlock.beforePos);if(!a||!a.isBlockContainer)return!1;let o=a.blockContent.node,s=o.type.spec.content===`inline*`,c=r.node.type.spec.content===`inline*`;return e().insertContentAt(a.bnBlock.afterPos,a.childContainer?.node.content||k.empty).deleteRange({from:a.bnBlock.beforePos,to:a.bnBlock.afterPos}).insertContentAt(t.selection.from,s&&c?o.content:null).setTextSelection(t.selection.from).scrollIntoView().run()}return!1}),()=>t.command(({state:t})=>{let n=Zh(t);if(!n.isBlockContainer)return!1;if(n.blockContent.node.childCount===0&&n.blockContent.node.type.spec.content===`inline*`){let r=Vw(t.doc,n.bnBlock.beforePos);if(!r||!r.isBlockContainer)return!1;let i=e();if(r.blockContent.node.type.spec.content===`tableRow+`){let e=n.bnBlock.afterPos+1+1+1+1+1;i=i.setTextSelection(e)}else i=r.blockContent.node.type.spec.content===``?i.setNodeSelection(r.blockContent.beforePos):i.setTextSelection(r.blockContent.beforePos+1);return i.deleteRange({from:n.bnBlock.beforePos,to:n.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>t.command(({state:t})=>{let n=Zh(t);if(!n.isBlockContainer)return!1;let r=t.selection.from===n.blockContent.afterPos-1,i=t.selection.empty,a=Vw(t.doc,n.bnBlock.beforePos);if(!a||!a.isBlockContainer)return!1;if(a&&r&&i&&(a.blockContent.node.type.spec.content===``||a.blockContent.node.type.spec.content===`inline*`&&a.blockContent.node.childCount===0)){let t=a.bnBlock.node.lastChild.content;return e().deleteRange({from:a.bnBlock.beforePos,to:a.bnBlock.afterPos}).insertContentAt(n.bnBlock.afterPos,a.bnBlock.node.childCount===2?t:null).run()}return!1})]),n=(e=!1)=>this.editor.commands.first(({commands:t,tr:n})=>[()=>t.command(({state:e,tr:t})=>{let n=Zh(e);if(!n.isBlockContainer)return!1;let{bnBlock:r,blockContent:i}=n,{depth:a}=e.doc.resolve(r.beforePos),o=e.selection.$anchor.parentOffset===0,s=e.selection.anchor===e.selection.head,c=i.node.childCount===0;return o&&s&&c&&a>1?YS(t,t.doc.type.schema.nodes.blockContainer,t.doc.type.schema.nodes.blockGroup):!1}),()=>t.command(({state:t})=>{let r=Zh(t),i=this.options.editor.schema.blockSpecs[r.blockNoteType],a=i?.implementation?.meta?.hardBreakShortcut??`shift+enter`;if(a===`none`)return!1;if(a===`shift+enter`&&e||a===`enter`){if(i?.config?.content===`plain`)return n.insertText(`
|
|
172
172
|
`,n.selection.head),!0;let e=n.storedMarks||n.selection.$head.marks().filter(e=>this.editor.extensionManager.splittableMarks.includes(e.type.name));return n.insert(n.selection.head,n.doc.type.schema.nodes.hardBreak.create()).ensureMarks(e),!0}return!1}),()=>t.command(({state:e,dispatch:t,tr:n})=>{let r=Zh(e);if(!r.isBlockContainer)return!1;let{bnBlock:i,blockContent:a}=r,o=e.selection.$anchor.parentOffset===0,s=e.selection.anchor===e.selection.head,c=a.node.childCount===0;if(o&&s&&c){let a=i.afterPos,o=a+2;if(t){let t=e.schema.nodes.blockContainer.createAndFill(void 0,[e.schema.nodes.paragraph.createAndFill()||void 0,r.childContainer?.node].filter(e=>e!==void 0));n.insert(a,t).setSelection(new N(n.doc.resolve(o))).scrollIntoView(),r.childContainer&&n.delete(r.childContainer.beforePos,r.childContainer.afterPos)}return!0}return!1}),()=>t.command(({state:e,chain:t})=>{let n=Zh(e);if(!n.isBlockContainer)return!1;let{blockContent:r}=n,i=e.selection.$anchor.parentOffset===0;return r.node.childCount!==0&&(t().deleteSelection().command(Vv(e.selection.from,i,i)).scrollIntoView().run(),!0)})]);return{Backspace:e,Delete:t,Enter:()=>n(),"Shift-Enter":()=>n(!0),Tab:()=>this.options.tabBehavior!==`prefer-indent`&&(this.options.editor.getExtension(vy)?.store.state||this.options.editor.getExtension(rv)?.store.state!==void 0)?!1:qS(this.options.editor),"Shift-Tab":()=>this.options.tabBehavior!==`prefer-indent`&&(this.options.editor.getExtension(vy)?.store.state||this.options.editor.getExtension(rv)?.store.state!==void 0)?!1:XS(this.options.editor),"Shift-Mod-ArrowUp":()=>(this.options.editor.moveBlocksUp(),!0),"Shift-Mod-ArrowDown":()=>(this.options.editor.moveBlocksDown(),!0),"Mod-z":()=>this.options.editor.undo(),"Mod-y":()=>this.options.editor.redo(),"Shift-Mod-z":()=>this.options.editor.redo()}}}),qw=sp.create({name:`textAlignment`,addGlobalAttributes(){return[{types:[`tableCell`,`tableHeader`],attributes:{textAlignment:{default:`left`,parseHTML:e=>e.getAttribute(`data-text-alignment`),renderHTML:e=>e.textAlignment===`left`?{}:{"data-text-alignment":e.textAlignment}}}}]}}),Jw=sp.create({name:`blockTextColor`,addGlobalAttributes(){return[{types:[`table`,`tableCell`,`tableHeader`],attributes:{textColor:tv()}}]}}),Yw=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`;function Xw(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;r+i<e.length&&e.charCodeAt(r+i)>=48&&e.charCodeAt(r+i)<=57;)i++;if(i>0){t.push(n.join(``));let a=parseInt(e.substring(r,r+i),10);for(;a-->0;)n.pop();r+=i}else n.push(e[r]),r++}return t}var Zw=new Set(Xw(Yw)),Qw=new Set([`localhost`]),$w=/[.,;:!?"']+$/,eT=/(?:https?|ftp|ftps):\/\/[^\s]+/g,tT=/mailto:[^\s]+/g,nT=/[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}/g,rT=/(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:[/?#][^\s]*)?/g;function iT(e){let t=e,n=!0;for(;n;){n=!1;let e=t;t=t.replace($w,``),t!==e&&(n=!0);for(let[e,r]of[[`(`,`)`],[`[`,`]`]])for(;t.endsWith(r);){let i=aT(t,e);if(aT(t,r)>i)t=t.slice(0,-1),n=!0;else break}}return t}function aT(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function oT(e){let t=e.split(`.`);return t[t.length-1].toLowerCase()}function sT(e){let t=oT(e);return Zw.has(t)}function cT(e,t,n){return t===`email`?`mailto:`+e:/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(e)||/^mailto:/i.test(e)?e:n+`://`+e}function lT(e,t){if(!e)return[];let n=t?.defaultProtocol||`http`,r=[];for(let t of e.matchAll(eT))r.push({type:`url`,value:t[0],start:t.index,end:t.index+t[0].length});for(let t of e.matchAll(tT))r.push({type:`url`,value:t[0],start:t.index,end:t.index+t[0].length});for(let t of e.matchAll(nT))r.push({type:`email`,value:t[0],start:t.index,end:t.index+t[0].length});for(let t of e.matchAll(rT))r.push({type:`url`,value:t[0],start:t.index,end:t.index+t[0].length});r.sort((e,t)=>e.start-t.start||t.end-e.end);let i=[],a=-1;for(let e of r)e.start>=a&&(i.push(e),a=e.end);let o=[];for(let e of i){let t=iT(e.value);if(!t)continue;let r=e.start,i=r+t.length;if(e.type===`url`&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)){let e=new URL(`http://`+t).hostname;if(!sT(e))continue}if(e.type===`email`){let e=t.split(`@`)[1];if(!sT(e))continue}let a=cT(t,e.type,n);o.push({type:e.type,value:t,isLink:!0,href:a,start:r,end:i})}return o}function uT(e,t=`http`){if(!e)return[pT(e,0,0)];for(let[n,r]of[[`(`,`)`],[`[`,`]`],[`{`,`}`]])if(e.startsWith(n)&&e.endsWith(r)&&e.length>2){let i=e.slice(1,-1);if(dT(i))return[pT(n,0,1),fT(i,1,1+i.length,t),pT(r,1+i.length,e.length)]}if(e.endsWith(`.`)&&e.length>1){let n=e.slice(0,-1);if(dT(n))return[fT(n,0,n.length,t),pT(`.`,n.length,e.length)]}return dT(e)?[fT(e,0,e.length,t)]:[pT(e,0,e.length)]}function dT(e){if(/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e)||/^mailto:[^\s]+$/.test(e)||Qw.has(e.toLowerCase()))return!0;let t=e.match(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+([a-zA-Z]{2,})(?::\d{1,5})?(?:[/?#][^\s]*)?$/);if(t){let e=t[1].toLowerCase();if(Zw.has(e))return!0}return!1}function fT(e,t,n,r){let i=e.includes(`@`)&&!e.includes(`://`)&&!e.startsWith(`mailto:`)?`email`:`url`;return{type:i,value:e,isLink:!0,href:cT(e,i,r),start:t,end:n}}function pT(e,t,n){return{type:`text`,value:e,isLink:!1,href:e,start:t,end:n}}var mT=`[\0- \xA0 -\u2029 ]`,hT=new RegExp(mT),gT=RegExp(`${mT}$`),_T=new RegExp(mT,`g`);function vT(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function yT(e){return new F({key:new jr(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(Cd(Ku(n.doc,[...t])).forEach(({newRange:t})=>{let n=qu(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!gT.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(hT).filter(Boolean);if(t.length<=0)return;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return;let c=uT(n,e.defaultProtocol);if(!vT(c))return;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{wd(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function bT(e){return new F({key:new jr(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement&&r.target.getAttribute(`data-inline-content-type`)===`link`)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.tiptapEditor.view.dom;i=t.closest(`a[data-inline-content-type="link"]`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;if(e.onClick){if(!e.editor)throw Error(`BlockNoteEditor not found in Link click handler`);return e.onClick(r,e.editor)??!0}let a=bd(t.state,e.type.name),o=i.href??a.href,s=i.target??a.target;return o?(window.open(o,s),!0):!1}}})}function xT(e){return new F({key:new jr(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i,isValidLink:a}=e,{state:o}=t,{selection:s}=o,{empty:c}=s;if(c)return!1;let l=``;r.content.forEach(e=>{l+=e.textContent});let u=lT(l,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===l);return!l||!u||!a(u.value)||i!==void 0&&!i(u.value)?!1:e.editor.commands.setMark(e.type,{href:u.href})}}})}var ST=`https`,CT=/^(?:(?:http|https|ftp|ftps|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))/i;function wT(e){if(!e)return!0;let t=e.replace(_T,``);return CT.test(t)}function TT(e){let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}var ET=$f.create({name:`link`,keepOnSplit:!1,exitable:!0,inclusive:!1,addOptions(){return{HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,className:`bn-inline-content-section`,"data-inline-content-type":`link`},editor:void 0,onClick:void 0,isValidLink:wT}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}}}},parseHTML(){let e=this.options.isValidLink;return[{tag:`a[href]`,getAttrs:t=>{let n=t.getAttribute(`href`);return!n||!e(n)?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isValidLink(e.href)?[`a`,ad(e,this.options.HTMLAttributes),0]:[`a`,ad({...e,href:``},this.options.HTMLAttributes),0]},addPasteRules(){let e=this.options.isValidLink;return[Op({find:t=>{let n=[];if(t){let r=lT(t,{defaultProtocol:ST}).filter(t=>t.isLink&&e(t.value));for(let e of r)TT(e.value)&&n.push({text:e.value,data:{href:e.href},index:e.start})}return n},type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[];return e.push(yT({type:this.type,defaultProtocol:ST,validate:this.options.isValidLink,shouldAutoLink:TT})),e.push(bT({type:this.type,tiptapEditor:this.editor,editor:this.options.editor,onClick:this.options.onClick})),e.push(xT({editor:this.editor,defaultProtocol:ST,type:this.type,shouldAutoLink:TT,isValidLink:this.options.isValidLink})),e}}),DT=z(({editor:e,options:t})=>({key:`link`,tiptapExtensions:[ET.configure({HTMLAttributes:t.HTMLAttributes??{},editor:e,onClick:t.onClick,...t.isValidLink?{isValidLink:t.isValidLink}:{}})]})),OT={blockColor:`data-block-color`,blockStyle:`data-block-style`,id:`data-id`,depth:`data-depth`,depthChange:`data-depth-change`},kT=Ep.create({name:`blockContainer`,group:`blockGroupChild bnBlock`,content:`blockContent blockGroup?`,priority:50,defining:!0,marks(){return ey(this.editor)},parseHTML(){return[{tag:`div[data-node-type=`+this.name+`]`,getAttrs:e=>{if(typeof e==`string`)return!1;let t={};for(let[n,r]of Object.entries(OT))e.getAttribute(r)&&(t[n]=e.getAttribute(r));return t}},{tag:`div[data-node-type="blockOuter"]`,skip:!0}]},renderHTML({HTMLAttributes:e}){let t=document.createElement(`div`);t.className=`bn-block-outer`,t.setAttribute(`data-node-type`,`blockOuter`);for(let[n,r]of Object.entries(e))n!==`class`&&t.setAttribute(n,r);let n={...this.options.domAttributes?.block||{},...e},r=document.createElement(`div`);r.className=V(`bn-block`,n.class),r.setAttribute(`data-node-type`,this.name);for(let[e,t]of Object.entries(n))e!==`class`&&r.setAttribute(e,t);return t.appendChild(r),{dom:t,contentDOM:r}}}),AT=Ep.create({name:`blockGroup`,group:`childContainer`,content:`blockGroupChild+`,marks(){return ey(this.editor)},parseHTML(){return[{tag:`div`,getAttrs:e=>typeof e!=`string`&&e.getAttribute(`data-node-type`)===`blockGroup`&&null}]},renderHTML({HTMLAttributes:e}){let t={...this.options.domAttributes?.blockGroup||{},...e},n=document.createElement(`div`);n.className=V(`bn-block-group`,t.class),n.setAttribute(`data-node-type`,`blockGroup`);for(let[e,r]of Object.entries(t))e!==`class`&&n.setAttribute(e,r);return{dom:n,contentDOM:n}}}),jT=Ep.create({name:`doc`,topNode:!0,content:`blockGroup`,marks(){return ey(this.editor)}});function MT(e,t){return[yp.ClipboardTextSerializer,yp.Commands,yp.Editable,yp.FocusEvents,yp.Tabindex,mS,ng.configure({types:[`blockContainer`,`columnList`,`column`],setIdAttribute:t.setIdAttribute,isWithinEditor:e.isWithinEditor}),Rw,nS,...Object.values(e.schema.styleSpecs).map(t=>t.implementation.mark.configure({editor:e})),Jw,Lw,qw,sp.create({name:`OverrideEscape`,addKeyboardShortcuts:()=>({Escape:()=>!e.getExtension(Cy)?.shown()&&(e.blur(),!0)})}),jT,kT.configure({editor:e,domAttributes:t.domAttributes}),Kw.configure({editor:e,tabBehavior:t.tabBehavior}),AT.configure({domAttributes:t.domAttributes}),...Object.values(e.schema.inlineContentSpecs).filter(e=>e.config!==`link`&&e.config!==`text`).map(t=>t.implementation.node.configure({editor:e})),...Object.values(e.schema.blockSpecs).flatMap(n=>[...`node`in n.implementation?[n.implementation.node.configure({editor:e,domAttributes:t.domAttributes})]:[]]),Iw(e),jw(e,t.pasteHandler||(e=>e.defaultPasteHandler())),mw(e)]}function NT(e,t){let n=[ab(),db(t),rv(t),vy(t),DT({HTMLAttributes:t.links?.HTMLAttributes??{},onClick:t.links?.onClick,...t.links?.isValidLink?{isValidLink:t.links.isValidLink}:{}}),gb(t),bb(),Sb(t),Iy(t),Sx(t),Cx(),wx(),Cy(t),fb(),hb(),Cb(),...t.trailingBlock===!1?[]:[Kx()]];return`table`in e.schema.blockSpecs&&n.push(Hx(t)),t.animations!==!1&&n.push(Eb()),n}var PT=class{editor;options;disabledExtensions=new Set;extensions=[];abortMap=new Map;extensionFactories=new Map;extensionPlugins=new Map;blockNoteExtensionDependents=new Map;constructor(e,t){this.editor=e,this.options=t,e.onMount(()=>{for(let t of this.extensions)if(t.mount){let n=new window.AbortController,r=t.mount({dom:e.prosemirrorView.dom,root:e.prosemirrorView.root,signal:n.signal});r&&n.signal.addEventListener(`abort`,()=>{r()}),this.abortMap.set(t,n)}}),e.onUnmount(()=>{for(let[e,t]of this.abortMap.entries())this.abortMap.delete(e),t.abort()}),this.disabledExtensions=new Set(t.disableExtensions||[]);for(let e of NT(this.editor,this.options))this.addExtension(e);for(let e of this.options.extensions??[])this.addExtension(e);for(let e of Object.values(this.editor.schema.blockSpecs))for(let t of e.extensions??[])this.addExtension(t)}registerExtension(e){this.replaceExtension(void 0,e)}addExtension(e,t){let n;if(n=typeof e==`function`?e({editor:this.editor}):e,n&&!this.disabledExtensions.has(n.key)){if(t){let e=this.blockNoteExtensionDependents.get(n.key);e||(e=new Set,this.blockNoteExtensionDependents.set(n.key,e)),e.add(t)}if(!this.extensions.some(e=>e.key===n.key)){if(typeof e==`function`){let e=n[Ip];typeof e==`function`&&this.extensionFactories.set(e,n)}if(this.extensions.push(n),n.blockNoteExtensions)for(let e of n.blockNoteExtensions)this.addExtension(e,n.key);return n}}}resolveExtensions(e){let t=[];if(typeof e==`function`){let n=this.extensionFactories.get(e);n&&t.push(n)}else if(Array.isArray(e))for(let n of e)t.push(...this.resolveExtensions(n));else if(typeof e==`object`&&`key`in e)t.push(e);else if(typeof e==`string`){let n=this.extensions.find(t=>t.key===e);n&&t.push(n)}return t}unregisterExtension(e){this.replaceExtension(e,[])}replaceExtension(e,t){let n=this.resolveExtensions(e);e&&!n.length&&console.warn(`No extensions found to unregister`,e);let r=!1,i=new Set,a=new Set;for(let t of n)this.extensions=this.extensions.filter(e=>e!==t),this.extensionFactories.forEach((e,n)=>{e===t&&this.extensionFactories.delete(n)}),this.abortMap.get(t)?.abort(),this.abortMap.delete(t),this.extensionPlugins.get(t)?.forEach(e=>{i.add(e);let t=e.spec?.key,n=typeof t==`object`&&t?t.key:t;typeof n==`string`&&a.add(n)}),this.extensionPlugins.delete(t),t.tiptapExtensions&&!r&&(r=!0,console.warn(`Extension ${t.key} has tiptap extensions, but they will not be removed. Please separate the extension into multiple extensions if you want to remove them, or re-initialize the editor.`,e));let o=[].concat(t).filter(Boolean).map(e=>this.addExtension(e)).filter(Boolean),s=[];for(let e of o)e?.tiptapExtensions&&console.warn(`Extension ${e.key} has tiptap extensions, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`,e),e?.inputRules?.length&&console.warn(`Extension ${e.key} has input rules, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`,e),this.getProsemirrorPluginsFromExtension(e).plugins.forEach(e=>{s.push(e)});!i.size&&!a.size&&!s.length||this.updatePlugins(e=>[...e.filter(e=>{if(i.has(e))return!1;if(a.size){let t=e.spec?.key,n=typeof t==`object`&&t?t.key:t;if(typeof n==`string`&&a.has(n))return!1}return!0}),...s])}updatePlugins(e){let t=this.editor.prosemirrorState,n=t.reconfigure({plugins:e(t.plugins.slice())});this.editor.prosemirrorView.updateState(n)}getTiptapExtensions(){let e=MT(this.editor,this.options).filter(e=>!this.disabledExtensions.has(e.name)),t=p_(this.extensions.map(e=>{let t=this.blockNoteExtensionDependents.get(e.key);return t?.size?{key:e.key,runsBefore:[...e.runsBefore??[],...t]}:e})),n=new Map;for(let r of this.extensions){r.tiptapExtensions&&e.push(...r.tiptapExtensions);let i=t(r.key),{plugins:a,inputRules:o}=this.getProsemirrorPluginsFromExtension(r);a.length&&e.push(sp.create({name:r.key,priority:i,addProseMirrorPlugins:()=>a})),o.length&&(n.has(i)||n.set(i,[]),n.get(i).push(...o))}e.push(sp.create({name:`blocknote-input-rules`,addProseMirrorPlugins(){let e=[];Array.from(n.keys()).sort((e,t)=>e-t).reverse().forEach(t=>{e.push(...n.get(t))});let t=eS({rules:e});return[t,new F({props:{handleKeyDown(e,n){if(n.key!==`Enter`||n.shiftKey||n.ctrlKey||n.metaKey||n.altKey)return!1;let{$cursor:r}=e.state.selection;return r?!!t.props.handleTextInput?.call(t,e,r.pos,r.pos,`
|
|
173
173
|
`,()=>e.state.tr.insertText(`
|
|
174
|
-
`,r.pos,r.pos)):!1}}})]}}));for(let t of this.options._tiptapOptions?.extensions??[])e.push(t);return e}getProsemirrorPluginsFromExtension(e){let t=[...e.prosemirrorPlugins??[]],n=[];if(!e.prosemirrorPlugins?.length&&!Object.keys(e.keyboardShortcuts||{}).length&&!e.inputRules?.length)return{plugins:t,inputRules:n};if(this.extensionPlugins.set(e,t),e.inputRules?.length&&n.push(...e.inputRules.map(e=>new Zx(e.find,(t,n,r,i)=>{let a=e.replace({match:n,range:{from:r,to:i},editor:this.editor});if(a){let e=t.tr,n=Zh(e);return!n.isBlockContainer||this.editor.schema.blockSchema[n.blockNoteType]?.content!==`inline`?null:(e.deleteRange(r,i),V_(e,n.bnBlock.beforePos,a),cw(e,Kh(n.bnBlock.node,e.doc),`start`),e)}return null},{undoable:!0}))),Object.keys(e.keyboardShortcuts||{}).length){let n,r=el(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([e,t])=>[e,()=>{if(!n)throw Error(`Keyboard shortcut called outside handleKeyDown`);return t({editor:this.editor,event:n})}])));t.push(new F({props:{handleKeyDown:(e,t)=>{let i=n;n=t;try{return r(e,t)}finally{n=i}}}}))}return{plugins:t,inputRules:n}}getExtensions(){return new Map(this.extensions.map(e=>[e.key,e]))}getExtension(e){if(typeof e==`string`)return this.extensions.find(t=>t.key===e)||void 0;if(typeof e==`function`)return this.extensionFactories.get(e)||void 0;throw Error(`Invalid extension type: ${typeof e}`)}hasExtension(e){return typeof e==`string`?this.extensions.some(t=>t.key===e):typeof e==`object`&&`key`in e?this.extensions.some(t=>t.key===e.key):typeof e==`function`&&this.extensionFactories.has(e)}};function FT(e,t){let{$from:n,$to:r}=t;if(n.pos>n.start()&&n.pos<e.content.size){let t=e.textBetween(n.pos,n.pos+1);if(/^[\w\p{P}]$/u.test(t)){let t=e.textBetween(n.start(),n.pos).match(/[\w\p{P}]+$/u);t&&(n=e.resolve(n.pos-t[0].length))}}if(r.pos<r.end()&&r.pos>0){let t=e.textBetween(r.pos-1,r.pos);if(/^[\w\p{P}]$/u.test(t)){let t=e.textBetween(r.pos,r.end()).match(/^[\w\p{P}]+/u);t&&(r=e.resolve(r.pos+t[0].length))}}return{$from:n,$to:r,from:n.pos,to:r.pos}}function IT(e){if(e.selection.empty||`node`in e.selection)return;let t=e.doc.resolve(qh(e.doc,e.selection.from).posBeforeNode),n=e.doc.resolve(qh(e.doc,e.selection.to).posBeforeNode),r=(n,r)=>{let i=t.posAtIndex(n,r),a=e.doc.resolve(i).nodeAfter;if(!a)throw Error(`Error getting selection - node not found at position ${i}`);return Ng(a,e.doc)},i=[],a=t.sharedDepth(n.pos),o=t.index(a),s=n.index(a);if(t.depth>a){i.push(Ng(t.nodeAfter,e.doc));for(let e=t.depth;e>a;e--)if(t.node(e).type.isInGroup(`childContainer`)){let n=t.index(e)+1,a=t.node(e).childCount;for(let t=n;t<a;t++)i.push(r(t,e))}}else i.push(r(o,a));for(let e=o+1;e<=s;e++)i.push(r(e,a));if(i.length===0)throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);return{blocks:i}}function LT(e,t,n){let r=typeof t==`string`?t:t.id,i=typeof n==`string`?n:n.id,a=wg(Sg(e));if(r===i)throw Error(`Attempting to set selection with the same anchor and head blocks (id ${r})`);let o=R_(r,e.doc);if(!o)throw Error(`Block with ID ${r} not found`);let s=R_(i,e.doc);if(!s)throw Error(`Block with ID ${i} not found`);let c=Yh(o),l=Yh(s),u=a.blockSchema[c.blockNoteType],d=a.blockSchema[l.blockNoteType];if(!c.isBlockContainer||u.content===`none`)throw Error(`Attempting to set selection anchor in block without content (id ${r})`);if(!l.isBlockContainer||d.content===`none`)throw Error(`Attempting to set selection anchor in block without content (id ${i})`);let f,p;if(u.content===`table`){let e=Bp.get(c.blockContent.node);f=c.blockContent.beforePos+e.positionAt(0,0,c.blockContent.node)+1+2}else f=c.blockContent.beforePos+1;if(d.content===`table`){let t=Bp.get(l.blockContent.node),n=l.blockContent.beforePos+t.positionAt(t.height-1,t.width-1,l.blockContent.node)+1;p=n+e.doc.resolve(n).nodeAfter.nodeSize-2}else p=l.blockContent.afterPos-1;e.setSelection(N.create(e.doc,f,p))}function RT(e,t=!1){let n=t?FT(e.doc,e.selection):e.selection,r=n.$from,i=n.$to;for(;i.parentOffset>=i.parent.nodeSize-2&&i.depth>0;)i=e.doc.resolve(i.pos+1);for(;i.parentOffset===0&&i.depth>0;)i=e.doc.resolve(i.pos-1);for(;r.parentOffset===0&&r.depth>0;)r=e.doc.resolve(r.pos-1);for(;r.parentOffset>=r.parent.nodeSize-2&&r.depth>0;)r=e.doc.resolve(r.pos+1);let a=Fg(e.doc.slice(r.pos,i.pos,!0));return{_meta:{startPos:r.pos,endPos:i.pos},...a}}var zT=class{editor;constructor(e){this.editor=e}getSelection(){return this.editor.transact(e=>IT(e))}getSelectionCutBlocks(e=!1){return this.editor.transact(t=>RT(t,e))}setSelection(e,t){return this.editor.transact(n=>LT(n,e,t))}getTextCursorPosition(){return this.editor.transact(e=>sw(e))}setTextCursorPosition(e,t=`start`){return this.editor.transact(n=>cw(n,e,t))}getSelectionBoundingBox(){if(!this.editor.prosemirrorView)return;let{selection:e}=this.editor.prosemirrorState,{ranges:t}=e,n=Math.min(...t.map(e=>e.$from.pos)),r=Math.max(...t.map(e=>e.$to.pos));if(Nd(e)){let e=this.editor.prosemirrorView.nodeDOM(n);if(e)return e.getBoundingClientRect()}return Ld(this.editor.prosemirrorView,n,r).toJSON()}},BT=class{editor;constructor(e){this.editor=e}activeTransaction=null;can(e){try{return this.isInCan=!0,e()}finally{this.isInCan=!1}}isInCan=!1;exec(e){if(this.activeTransaction)throw Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");if(this.isInCan)return this.canExec(e);let t=this.prosemirrorState,n=this.prosemirrorView;return e(t,e=>this.prosemirrorView.dispatch(e),n)}canExec(e){if(this.activeTransaction)throw Error("`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call");let t=this.prosemirrorState,n=this.prosemirrorView;return e(t,void 0,n)}transact(e){if(this.activeTransaction)return e(this.activeTransaction);try{this.activeTransaction=this.editor._tiptapEditor.state.tr;let t=e(this.activeTransaction),n=this.activeTransaction;return this.activeTransaction=null,n&&(n.docChanged||n.selectionSet||n.scrolledIntoView||n.storedMarksSet||!n.isGeneric)&&this.prosemirrorView.dispatch(n),t}finally{this.activeTransaction=null}}get prosemirrorState(){if(this.activeTransaction)throw Error("`prosemirrorState` should not be called within a `transact` call, move the `prosemirrorState` call outside of the `transact` call or use `editor.transact` to read the current editor state");return this.editor._tiptapEditor.state}get prosemirrorView(){return this.editor._tiptapEditor.view}isFocused(){return this.prosemirrorView?.hasFocus()||!1}focus(){this.prosemirrorView?.focus()}get isEditable(){if(!this.editor._tiptapEditor){if(!this.editor.headless)throw Error(`no editor, but also not headless?`);return!1}return this.editor._tiptapEditor.isEditable===void 0||this.editor._tiptapEditor.isEditable}set isEditable(e){if(this.editor._tiptapEditor)this.editor._tiptapEditor.options.editable!==e&&this.editor._tiptapEditor.setEditable(e);else if(!this.editor.headless)throw Error(`no editor, but also not headless?`)}undo(){let e=this.editor.getExtension(`yUndo`);if(e)return this.exec(e.undoCommand);let t=this.editor.getExtension(`history`);if(t)return this.exec(t.undoCommand);throw Error(`No undo plugin found`)}redo(){let e=this.editor.getExtension(`yUndo`);if(e)return this.exec(e.redoCommand);let t=this.editor.getExtension(`history`);if(t)return this.exec(t.redoCommand);throw Error(`No redo plugin found`)}};function VT(e,t,n,r={updateSelection:!0}){let{from:i,to:a}=typeof t==`number`?{from:t,to:t}:{from:t.from,to:t.to},o=!0,s=!0,c=``;if(n.forEach(e=>{e.check(),o&&e.isText&&e.marks.length===0?c+=e.text:o=!1,s=s?e.isBlock:!1}),i===a&&s){let{parent:t}=e.doc.resolve(i);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(--i,a+=1)}return o?e.insertText(c,i,a):e.replaceWith(i,a,n),r.updateSelection&&fu(e,e.steps.length-1,-1),!0}var HT=class{editor;constructor(e){this.editor=e}insertInlineContent(e,{updateSelection:t=!1}={}){let n=P_(e,this.editor.pmSchema);this.editor.transact(e=>{VT(e,{from:e.selection.from,to:e.selection.to},n,{updateSelection:t})})}getActiveStyles(){return this.editor.transact(e=>{let t={},n=e.selection.empty&&e.storedMarks||e.selection.$to.marks();for(let e of n){let n=this.editor.schema.styleSchema[e.type.name];n?n.propSchema===`boolean`?t[n.type]=!0:t[n.type]=e.attrs.stringValue:e.type.name!==`link`&&!e.type.spec.blocknoteIgnore&&console.warn(`mark not found in styleschema`,e.type.name)}return t})}addStyles(e){for(let[t,n]of Object.entries(e)){let e=this.editor.schema.styleSchema[t];if(!e)throw Error(`style ${t} not found in styleSchema`);if(e.propSchema===`boolean`)this.editor._tiptapEditor.commands.setMark(t);else if(e.propSchema===`string`)this.editor._tiptapEditor.commands.setMark(t,{stringValue:n});else throw new dg(e.propSchema)}}removeStyles(e){for(let t of Object.keys(e))this.editor._tiptapEditor.commands.unsetMark(t)}toggleStyles(e){for(let[t,n]of Object.entries(e)){let e=this.editor.schema.styleSchema[t];if(!e)throw Error(`style ${t} not found in styleSchema`);if(e.propSchema===`boolean`)this.editor._tiptapEditor.commands.toggleMark(t);else if(e.propSchema===`string`)this.editor._tiptapEditor.commands.toggleMark(t,{stringValue:n});else throw new dg(e.propSchema)}}getSelectedText(){return this.editor.transact(e=>e.doc.textBetween(e.selection.from,e.selection.to))}getLinkMarkAtPos(e){return this.editor.transact(t=>{let n=this.editor.pmSchema.marks.link,r=Jl(t.doc.resolve(e),n);if(!r)return;let i=t.doc.nodeAt(r.from)?.marks.find(e=>e.type===n);if(i)return{href:i.attrs.href,from:r.from,to:r.to,text:t.doc.textBetween(r.from,r.to)}})}getSelectedLinkUrl(){return this.editor.transact(e=>(e.doc.nodeAt(e.selection.from)?.marks.find(e=>e.type.name===`link`))?.attrs.href)}createLink(e,t){e!==``&&this.editor.transact(n=>{let{from:r,to:i}=n.selection,a=this.editor.pmSchema.mark(`link`,{href:e});t?n.insertText(t,r,i).addMark(r,r+t.length,a):n.addMark(r,i,a)})}editLink(e,t,n=this.editor.transact(e=>e.selection.anchor)){this.editor.transact(r=>{let{from:i,to:a}=this.getLinkMarkAtPos(n)||{from:r.selection.from,to:r.selection.to},o=this.editor.pmSchema.mark(`link`,{href:e});t!==r.doc.textBetween(i,a)&&r.insertText(t,i,a),r.addMark(i,i+t.length,o)}),this.editor.prosemirrorView.focus()}deleteLink(e=this.editor.transact(e=>e.selection.anchor)){this.editor.transact(t=>{let{from:n,to:r}=this.getLinkMarkAtPos(e)||{from:t.selection.from,to:t.selection.to};t.removeMark(n,r,this.editor.pmSchema.marks.link).setMeta(`preventAutolink`,!0)}),this.editor.prosemirrorView.focus()}};function UT(e){return Ju(e.state.selection.$from,e=>e.type.name===`tableCell`||e.type.name===`tableHeader`)!==void 0}function WT(e,t){let n=t.nodes.hardBreak,r=k.empty;return e.forEach(e=>{e.isTextblock&&e.childCount>0?(r=r.append(e.content),r=r.addToEnd(n.create())):e.isText?r=r.addToEnd(e):e.isBlock&&e.childCount>0&&(r=r.append(WT(e.content,t)),r=r.addToEnd(n.create()))}),r.lastChild?.type===n&&(r=r.cut(0,r.size-1)),r}function GT(e,t){let n=[];return e.forEach((e,r,i)=>{i!==t&&n.push(e)}),k.from(n)}function KT(e,t){let n=[];for(let r=0;r<e.childCount;r++)if(e.child(r).type.name===`tableRow`){if(n.length>0&&n[n.length-1].type.name===`table`){let t=n[n.length-1],i=t.copy(t.content.addToEnd(e.child(r)));n[n.length-1]=i}else{let i=t.nodes.table.createChecked(void 0,e.child(r));n.push(i)}}else n.push(e.child(r));return e=k.from(n),e}function qT(e,t){let n=k.from(e.content);n=KT(n,t.state.schema);let r=JT(n,t,e);if(r)return r;if(UT(t)){let e=!1;if(n.descendants(t=>{t.type.isInGroup(`tableContent`)&&(e=!0)}),!e&&!t.state.schema.nodes.tableParagraph.validContent(n))return new j(WT(n,t.state.schema),0,0)}if(!YT(n,t))return new j(n,e.openStart,e.openEnd);for(let e=0;e<n.childCount;e++)if(n.child(e).type.spec.group===`blockContent`){let r=[n.child(e)];if(e+1<n.childCount&&n.child(e+1).type.name===`blockGroup`){let t=n.child(e+1).child(0).child(0);(t.type.name===`bulletListItem`||t.type.name===`numberedListItem`||t.type.name===`checkListItem`)&&(r.push(n.child(e+1)),n=GT(n,e+1))}let i=t.state.schema.nodes.blockContainer.createChecked(void 0,r);n=n.replaceChild(e,i)}return new j(n,e.openStart,e.openEnd)}function JT(e,t,n){if(UT(t)||t.dragging)return null;let r=Zh(t.state),i=r.isBlockContainer?r.blockContent.node:null;if(!i||i.type.name===`paragraph`||i.type.spec.content!==`inline*`||i.childCount>0)return null;let a=e.firstChild,o=a?.firstChild,s=o?.firstChild;if(a?.type.name!==`blockGroup`||o?.type.name!==`blockContainer`||s?.type.name!==`paragraph`)return null;let c=i.type.create(i.attrs,s.content),l=o.copy(o.content.replaceChild(0,c)),u=a.copy(a.content.replaceChild(0,l));return new j(e.replaceChild(0,u),n.openStart,n.openEnd)}function YT(e,t){let n=e.childCount===1,r=e.firstChild?.type.spec.content===`inline*`,i=e.firstChild?.type.spec.content===`tableRow+`;if(n){if(r)return!1;if(i){let e=Zh(t.state);if(e.isBlockContainer)return e.blockContent.node.type.spec.content!==`tableRow+`}}return!0}var XT={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1},ZT=class e extends FS{options;pmSchema;_tiptapEditor;elementRenderer=null;blockCache=new WeakMap;dictionary;schema;blockImplementations;inlineContentImplementations;styleImplementations;uploadFile;onUploadStartCallbacks=[];onUploadEndCallbacks=[];resolveFileUrl;settings;static create(t){return new e(t??{})}constructor(e){super(),this.options=e,this.dictionary=e.dictionary||Xx,this.settings={tables:{splitCells:e?.tables?.splitCells??!1,cellBackgroundColor:e?.tables?.cellBackgroundColor??!1,cellTextColor:e?.tables?.cellTextColor??!1,headers:e?.tables?.headers??!1}};let t={defaultStyles:!0,schema:e.schema||Py.create(),...e,placeholders:{...this.dictionary.placeholders,...e.placeholders}};if(this.schema=t.schema,this.blockImplementations=t.schema.blockSpecs,this.inlineContentImplementations=t.schema.inlineContentSpecs,this.styleImplementations=t.schema.styleSpecs,t.uploadFile){let e=t.uploadFile;this.uploadFile=async(t,n)=>{this.onUploadStartCallbacks.forEach(e=>e.apply(this,[n]));try{return await e(t,n)}finally{this.onUploadEndCallbacks.forEach(e=>e.apply(this,[n]))}}}this.resolveFileUrl=t.resolveFileUrl,this._eventManager=new iC(this),this._extensionManager=new PT(this,t);let n=this._extensionManager.getTiptapExtensions(),r={...XT,...t._tiptapOptions,element:null,autofocus:t.autofocus??!1,extensions:n,editorProps:{scrollMargin:{top:72,bottom:72,left:0,right:0},...t._tiptapOptions?.editorProps,attributes:{tabIndex:`0`,...t._tiptapOptions?.editorProps?.attributes,...t.domAttributes?.editor,class:V(`bn-editor`,t.defaultStyles?`bn-default-styles`:``,t.domAttributes?.editor?.class||``)},transformPasted:qT}};try{let e=t.initialContent||[{type:`paragraph`,id:ng.options.generateID()}];if(!Array.isArray(e)||e.length===0)throw Error(`initialContent must be a non-empty array of blocks, received: `+JSON.stringify(e));let n=hd(r.extensions);n.cached.blockNoteEditor=this;let i=Uu({type:`doc`,content:[{type:`blockGroup`,content:e.map(e=>L_(e,n,this.schema.styleSchema).toJSON())}]},n,r.parseOptions);this._tiptapEditor=new wp({...r,content:i.toJSON()}),this.pmSchema=this._tiptapEditor.schema}catch(e){throw Error("Error creating document from blocks passed as `initialContent`",{cause:e})}this.pmSchema.cached.blockNoteEditor=this,this._tiptapEditor.on(`mount`,()=>{this.headless=!1}),this._tiptapEditor.on(`unmount`,()=>{this.headless=!0}),this._blockManager=new rC(this),this._exportManager=new ow(this),this._selectionManager=new zT(this),this._stateManager=new BT(this),this._styleManager=new HT(this),this.emit(`create`)}_blockManager;_eventManager;_exportManager;_extensionManager;_selectionManager;_stateManager;_styleManager;get extensions(){return this._extensionManager.getExtensions()}exec(e){return this._stateManager.exec(e)}canExec(e){return this._stateManager.canExec(e)}transact(e){return this._stateManager.transact(e)}unregisterExtension=(...e)=>this._extensionManager.unregisterExtension(...e);registerExtension=(...e)=>this._extensionManager.registerExtension(...e);replaceExtension=(...e)=>this._extensionManager.replaceExtension(...e);getExtension=(e=>this._extensionManager.getExtension(e));mount=e=>{this._tiptapEditor.mount({mount:e})};unmount=()=>{this._tiptapEditor.unmount()};get prosemirrorState(){return this._stateManager.prosemirrorState}get prosemirrorView(){return this._stateManager.prosemirrorView}get domElement(){if(!this.headless)return this.prosemirrorView?.dom}_portalElements=new Map;registerPortalElement=e=>{this._portalElements.set(e,(this._portalElements.get(e)??0)+1)};unregisterPortalElement=e=>{let t=this._portalElements.get(e);t!==void 0&&(t<=1?this._portalElements.delete(e):this._portalElements.set(e,t-1))};isWithinEditor=e=>{if(this.domElement?.parentElement?.contains(e))return!0;for(let t of this._portalElements.keys())if(t.contains(e))return!0;return!1};isFocused(e){if(this.headless)return!1;let t=this.prosemirrorView?.hasFocus()||!1;if(!e?.includeEditorUI)return t;let n=typeof document<`u`?document.activeElement:null;return t||!!n&&this.isWithinEditor(n)}headless=!0;focus(){this.headless||this.prosemirrorView.focus()}blur(){this.headless||this.domElement?.blur()}onUploadStart(e){return this.onUploadStartCallbacks.push(e),()=>{let t=this.onUploadStartCallbacks.indexOf(e);t>-1&&this.onUploadStartCallbacks.splice(t,1)}}onUploadEnd(e){return this.onUploadEndCallbacks.push(e),()=>{let t=this.onUploadEndCallbacks.indexOf(e);t>-1&&this.onUploadEndCallbacks.splice(t,1)}}get topLevelBlocks(){return this.document}get document(){return this._blockManager.document}getBlock(e){return this._blockManager.getBlock(e)}getPrevBlock(e){return this._blockManager.getPrevBlock(e)}getNextBlock(e){return this._blockManager.getNextBlock(e)}getParentBlock(e){return this._blockManager.getParentBlock(e)}forEachBlock(e,t=!1){this._blockManager.forEachBlock(e,t)}onEditorContentChange(e){this._tiptapEditor.on(`update`,e)}onEditorSelectionChange(e){this._tiptapEditor.on(`selectionUpdate`,e)}onBeforeChange(e){return this._extensionManager.getExtension(ab).subscribe(e)}getTextCursorPosition(){return this._selectionManager.getTextCursorPosition()}setTextCursorPosition(e,t=`start`){return this._selectionManager.setTextCursorPosition(e,t)}getSelection(){return this._selectionManager.getSelection()}getSelectionCutBlocks(e=!1){return this._selectionManager.getSelectionCutBlocks(e)}setSelection(e,t){return this._selectionManager.setSelection(e,t)}get isEditable(){return this._stateManager.isEditable}set isEditable(e){this._stateManager.isEditable=e}insertBlocks(e,t,n=`before`){return this._blockManager.insertBlocks(e,t,n)}updateBlock(e,t){return this._blockManager.updateBlock(e,t)}removeBlocks(e){return this._blockManager.removeBlocks(e)}replaceBlocks(e,t){return this._blockManager.replaceBlocks(e,t)}undo(){return this._stateManager.undo()}redo(){return this._stateManager.redo()}insertInlineContent(e,{updateSelection:t=!1}={}){this._styleManager.insertInlineContent(e,{updateSelection:t})}getActiveStyles(){return this._styleManager.getActiveStyles()}addStyles(e){this._styleManager.addStyles(e)}removeStyles(e){this._styleManager.removeStyles(e)}toggleStyles(e){this._styleManager.toggleStyles(e)}getSelectedText(){return this._styleManager.getSelectedText()}getSelectedLinkUrl(){return this._styleManager.getSelectedLinkUrl()}createLink(e,t){this._styleManager.createLink(e,t)}getLinkMarkAtPos(e){return this._styleManager.getLinkMarkAtPos(e)}editLink(e,t,n){this._styleManager.editLink(e,t,n)}deleteLink(e){this._styleManager.deleteLink(e)}canNestBlock(){return this._blockManager.canNestBlock()}nestBlock(){this._blockManager.nestBlock()}canUnnestBlock(){return this._blockManager.canUnnestBlock()}unnestBlock(){this._blockManager.unnestBlock()}moveBlocksUp(e){return this._blockManager.moveBlocksUp(e)}moveBlocksDown(e){return this._blockManager.moveBlocksDown(e)}blocksToHTMLLossy(e=this.document){return this._exportManager.blocksToHTMLLossy(e)}blocksToFullHTML(e=this.document){return this._exportManager.blocksToFullHTML(e)}tryParseHTMLToBlocks(e){return this._exportManager.tryParseHTMLToBlocks(e)}blocksToMarkdownLossy(e=this.document){return this._exportManager.blocksToMarkdownLossy(e)}tryParseMarkdownToBlocks(e){return this._exportManager.tryParseMarkdownToBlocks(e)}onChange(e,t){return this._eventManager.onChange(e,t)}onSelectionChange(e,t){return this._eventManager.onSelectionChange(e,t)}onFocusChange(e,t){return this._eventManager.onFocusChange(e,t)}onMount(e){return this._eventManager.onMount(e)}onUnmount(e){return this._eventManager.onUnmount(e)}getSelectionBoundingBox(){return this._selectionManager.getSelectionBoundingBox()}get isEmpty(){let e=this.document;return e.length===0||e.length===1&&e[0].type===`paragraph`&&e[0].content.length===0}pasteHTML(e,t=!1){this._exportManager.pasteHTML(e,t)}pasteText(e){return this._exportManager.pasteText(e)}pasteMarkdown(e){return this._exportManager.pasteMarkdown(e)}},QT=e(t(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(i of t.entries())if(!n.has(i[0]))return!1;for(i of t.entries())if(!e(i[1],n.get(i[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(i of t.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(t[i]!==n[i])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!(o===`_owner`&&t.$$typeof)&&!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}}))(),1),$T=(0,D.createContext)(void 0);function eE(e){return(0,D.useContext)($T)}function H(e){let t=eE(e);if(!t?.editor)throw Error(`useBlockNoteEditor was called outside of a BlockNoteContext provider or BlockNoteView component`);return t.editor}function tE(e,t=e=>e){return(0,Se.useSyncExternalStoreWithSelector)(e.subscribe,()=>e.state,()=>e.state,t,nE)}function nE(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=rE(e);return n.length===rE(t).length&&n.every(n=>Object.prototype.hasOwnProperty.call(t,n)&&Object.is(e[n],t[n]))}function rE(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function iE(e,t){let n=(t?.editor??H()).getExtension(e);if(!n)throw Error(`Extension not found`,{cause:{plugin:e}});return n}function aE(e,t){let{store:n}=iE(e,t);if(!n)throw Error(`Store not found on plugin`,{cause:{plugin:e}});return tE(n,t?.selector)}var oE=typeof window<`u`?D.useLayoutEffect:D.useEffect,sE=class{transactionNumber=0;lastTransactionNumber=0;lastSnapshot;editor;subscribers=new Set;constructor(e){this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e,t){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},n=this.editor._tiptapEditor,r={all:[`transaction`,`create`,`mount`,`unmount`],mount:[`create`,`mount`,`unmount`],selection:[`selectionUpdate`],change:[`update`]};for(let i of r[t])n.on(i,e);return()=>{for(let i of r[t])n.off(i,e)}}}};function cE(e){let t=eE(),n=e.editor||t?.editor||null,r=e.on||`all`,[i]=(0,D.useState)(()=>new sE(n)),a=(0,Se.useSyncExternalStoreWithSelector)(i.subscribe,i.getSnapshot,i.getServerSnapshot,e.selector,e.equalityFn??QT.default);return oE(()=>i.watch(n,r),[n,i,r]),(0,D.useDebugValue)(a),a}function lE(e){let t=eE();if(e||=t?.editor,!e)throw Error("'editor' is required in `useEditorDOMElement`, either from BlockNoteContext or as a function argument");return cE({editor:e,selector:e=>e.editor.domElement,equalityFn:(e,t)=>e===t,on:`mount`})}var uE=(0,D.createContext)(void 0);function dE(){return(0,D.useContext)(uE)}var fE=typeof window<`u`?D.useInsertionEffect:D.useEffect,pE=(0,D.createContext)(null);function mE(){let e=(0,D.useContext)(pE),t=lE();return e||(t?.parentElement??null)}function hE(e){return(0,O.jsx)(pE.Provider,{value:null,children:e.children})}function gE(e){let{target:t,children:n}=e,r=H(),i=dE()?.applyThemedRoot,[a]=(0,D.useState)(()=>typeof document>`u`?null:document.createElement(`div`));return fE(()=>{if(a&&t)return t.appendChild(a),()=>a.remove()},[a,t]),fE(()=>{!a||!t||i?.(a)},[a,t,i]),fE(()=>{if(a&&t)return r.registerPortalElement(a),()=>r.unregisterPortalElement(a)},[r,a,t]),t===void 0?n:(0,O.jsx)(pE.Provider,{value:a,children:n})}function _E(){let[e]=(0,D.useState)(()=>{if(typeof document>`u`)return null;let e=document.createElement(`span`);return e.className=`bn-portal-anchor`,e}),t=(0,D.useCallback)(t=>{t&&e&&e.parentElement!==t&&t.appendChild(e)},[e]);return{anchor:e,holder:(0,O.jsx)(`span`,{ref:t,className:vE,style:{position:`absolute`,width:0,height:0,overflow:`visible`}})}}var vE=`bn-portal-anchor-holder`;function yE(e){return Array.from(e.childNodes).some(e=>!(e instanceof Element&&e.classList.contains(vE)))}function bE(e){let{anchor:t,holder:n}=_E(),r=mE(),i=t??r,a=typeof e.children==`function`?e.children(i):e.children;return(0,O.jsxs)(O.Fragment,{children:[n,(0,O.jsx)(pE.Provider,{value:i,children:a})]})}function xE(e){let t=new DOMRect,n=`getBoundingClientRect`in e?()=>e.getBoundingClientRect():()=>e.element.getBoundingClientRect();return()=>e.element&&(e.cacheMountedBoundingClientRect??!0)?(e.element.isConnected&&(t=n()),t):n()}function SE(e,t){return e?t?(n,r,i)=>{let a=e(n,r,i),o=t(n,r,i);return()=>{a?.(),o?.()}}:e:t}var CE=e=>{let t=H(),n=mE(),{whileElementsMounted:r,middleware:i,...a}=e.useFloatingOptions??{},{refs:o,floatingStyles:s,context:c,middlewareData:l}=re({whileElementsMounted:SE(ie,e.useFloatingOptions?.whileElementsMounted),middleware:[...i??[],oe()],...a}),{isMounted:u,styles:d}=f(c,e.useTransitionStylesProps),{status:p}=b(c,e.useTransitionStatusProps),m=y(c,e.useDismissProps),h=ne(c,{enabled:!1,...e.useHoverProps}),{getFloatingProps:g}=_([m,h]),x=(0,D.useRef)(``),S=(0,D.useRef)(null),w=v([S,o.setFloating]);if((0,D.useEffect)(()=>{if(e.reference){let n=`element`in e.reference?e.reference.element:void 0;n!==void 0&&(e.focusManagerProps?.disabled||!t.isWithinEditor(n))&&o.setReference(n);let r=`getClientRects`in e.reference?e.reference.getClientRects:void 0;o.setPositionReference({getBoundingClientRect:xE(e.reference),...r?{getClientRects:r}:{},contextElement:n})}},[e.reference,o,e.focusManagerProps?.disabled,t]),(0,D.useEffect)(()=>{(p===`initial`||p===`open`)&&S.current&&yE(S.current)&&(x.current=S.current.innerHTML)},[p,e.reference,e.children]),!u||!n)return!1;let T={...e.elementProps,style:{display:`flex`,...e.elementProps?.style,zIndex:`calc(var(--bn-ui-base-z-index, 0) + ${e.elementProps?.style?.zIndex||0})`,...s,...d,...l.hide?.referenceHidden?{visibility:`hidden`}:{}},...g()};return p===`close`?(0,O.jsx)(C,{root:n,children:(0,O.jsx)(`div`,{ref:w,...T,dangerouslySetInnerHTML:{__html:x.current}})}):e.focusManagerProps?.disabled?(0,O.jsx)(C,{root:n,children:(0,O.jsx)(`div`,{ref:w,...T,children:(0,O.jsx)(bE,{children:e.children})})}):(0,O.jsx)(C,{root:n,children:(0,O.jsx)(ae,{...e.focusManagerProps,context:c,children:(0,O.jsx)(`div`,{ref:w,...T,children:(0,O.jsx)(bE,{children:e.children})})})})},wE=(0,D.createContext)(void 0);function U(){return(0,D.useContext)(wE)}function W(){return eE().editor.dictionary}var TE=e=>{let{position:t,children:n,...r}=e,{from:i,to:a}=t||{},o=H(),s=lE(),c=(0,D.useMemo)(()=>{if(i!==void 0&&a!==void 0)return{element:s?.firstElementChild||void 0,getBoundingClientRect:()=>Ld(o.prosemirrorView,i,a??i)}},[o,s,i,a]);return(0,O.jsx)(CE,{reference:c,...r,children:t!==void 0&&n})},EE=(e={},t=[])=>(0,D.useMemo)(()=>{let t=ZT.create(e);return window&&(window.ProseMirror=t._tiptapEditor),t},t),DE=e=>{let[t,n]=(0,D.useState)(!1),r=cE({editor:e.editor,selector:({editor:e})=>e.isEmpty}),i=U(),a=(0,D.useCallback)(()=>{n(!0)},[]),o=(0,D.useCallback)(()=>{n(!1)},[]);return(0,D.useEffect)(()=>{e.editable&&e.autoFocus&&e.editor.focus()},[e.autoFocus,e.editable,e.editor]),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i.Comments.Editor,{autoFocus:e.autoFocus,className:`bn-comment-editor`,editor:e.editor,onFocus:a,onBlur:o,editable:e.editable}),e.actions&&(0,O.jsx)(`div`,{className:`bn-comment-actions-wrapper`,children:e.actions({isFocused:t,isEmpty:r})})]})},{textColor:OE,backgroundColor:kE,...AE}=jy,jE=Py.create({blockSpecs:{paragraph:Zv()},styleSpecs:AE});function ME(e){return!e.hasUnsavedContent||!e.confirmBeforeDiscard||(e.confirm??(e=>window.confirm(e)))(e.message)}var NE=z(({editor:e,options:{submitOnEnter:t=!0,onSubmit:n}})=>{let r=!1;async function i(){if(!(!e.isEditable||e.isEmpty||r)){r=!0;try{await n(e)}finally{r=!1}}}function a({event:t}){let n=e.prosemirrorView;return!n.editable||n.composing||t.isComposing||t.keyCode===229?!1:(t.repeat||i(),!0)}return{key:`commentEditorSubmit`,submit:i,runsBefore:[`default`],keyboardShortcuts:{"Mod-Enter":a,...t?{Enter:a}:{}}}}),PE=$f.create({name:`comment`,excludes:``,inclusive:!1,keepOnSplit:!0,group:kp,addAttributes(){return{orphan:{parseHTML:e=>!!e.getAttribute(`data-orphan`),renderHTML:e=>e.orphan?{"data-orphan":`true`}:{},default:!1},threadId:{parseHTML:e=>e.getAttribute(`data-bn-thread-id`),renderHTML:e=>({"data-bn-thread-id":e.threadId}),default:``}}},renderHTML({HTMLAttributes:e}){return[`span`,ad(e,{class:`bn-thread-mark`})]},parseHTML(){return[{tag:`span.bn-thread-mark`}]},extendMarkSchema(e){return e.name===`comment`?{blocknoteIgnore:!0}:{}}}),FE=new jr(`blocknote-comments`);function IE(e,t){let n=new Map;return e.descendants((e,r)=>{e.marks.forEach(i=>{if(i.type.name===t){let t=i.attrs.threadId;if(!t)return;let a=r,o=a+e.nodeSize,s=n.get(t)??{from:1/0,to:0};n.set(t,{from:Math.min(a,s.from),to:Math.max(o,s.to)})}})}),n}var LE=z(({editor:e,options:{schema:t,threadStore:n,resolveUsers:r,confirmBeforeDiscard:i=!0,submitOnEnter:a=!0}})=>{if(!r)throw Error(`resolveUsers is required to be defined when using comments`);if(!n)throw Error(`threadStore is required to be defined when using comments`);let o=Ry(r),s=PE.name,c=Lp({pendingComment:!1,selectedThreadId:void 0,threadPositions:new Map},{onUpdate(t,n){t.selectedThreadId!==n.selectedThreadId&&e.transact(e=>e.setMeta(FE,!0))}}),l=t=>{e.transact(e=>{e.doc.descendants((n,r)=>{n.marks.forEach(i=>{if(i.type.name===s){let a=i.type,o=i.attrs.threadId,s=t.get(o),l=!!(!s||s.resolved||s.deletedAt);if(l!==i.attrs.orphan){let t=Math.max(r,0),s=Math.min(r+n.nodeSize,e.doc.content.size-1,e.doc.content.size-1);e.removeMark(t,s,i),e.addMark(t,s,a.create({...i.attrs,orphan:l})),l&&c.state.selectedThreadId===o&&c.setState(e=>({...e,selectedThreadId:void 0}))}}})})})};return{key:`comments`,store:c,userStore:o,runsBefore:[`link`],tiptapExtensions:[PE],prosemirrorPlugins:[new F({key:FE,state:{init(){return{decorations:L.empty}},apply(e,t){let n=e.getMeta(FE);if(!e.docChanged&&!n)return t;let r=e.docChanged?IE(e.doc,s):c.state.threadPositions;(r.size>0||c.state.threadPositions.size>0)&&c.setState(e=>({...e,threadPositions:r}));let i=[];if(c.state.selectedThreadId){let e=r.get(c.state.selectedThreadId);e&&i.push(ic.inline(e.from,e.to,{class:`bn-thread-mark-selected`}))}return{decorations:L.create(e.doc,i)}}},props:{decorations(e){return FE.getState(e)?.decorations??L.empty},handleClick:(e,t,n)=>{if(n.button!==0)return!1;let r=e.state.doc.nodeAt(t);if(!r)return c.setState(e=>({...e,selectedThreadId:void 0})),!1;let i=r.marks.find(e=>e.type.name===s&&e.attrs.orphan!==!0);if(!i)return c.state.selectedThreadId!==void 0&&c.setState(e=>({...e,selectedThreadId:void 0})),!1;let a=i.attrs.threadId;return a!==c.state.selectedThreadId&&(c.setState(e=>({...e,selectedThreadId:a})),!0)}}})],threadStore:n,mount(){let t=n.subscribe(l);l(n.getThreads());let r=e.onSelectionChange(()=>{c.state.pendingComment&&c.setState(e=>({...e,pendingComment:!1}))});return()=>{t(),r()}},selectThread(t,n=!0){if(c.state.selectedThreadId!==t&&(c.setState(e=>({...e,pendingComment:!1,selectedThreadId:t})),t&&n)){let n=c.state.threadPositions.get(t);if(!n)return;(e.prosemirrorView?.domAtPos(n.from).node)?.scrollIntoView({behavior:`smooth`,block:`center`})}},startPendingComment(){c.setState(e=>({...e,selectedThreadId:void 0,pendingComment:!0})),e.domElement?.focus(),e.getExtension(Iy)?.showSelection(!0,`comments`)},stopPendingComment(){c.setState(e=>({...e,selectedThreadId:void 0,pendingComment:!1})),e.getExtension(Iy)?.showSelection(!1,`comments`)},async createThread(t){let r=await n.createThread(t);n.addThreadToDocument?await n.addThreadToDocument({threadId:r.id,selection:e.transact(e=>e.selection),editor:e}):e._tiptapEditor.commands.setMark(s,{orphan:!1,threadId:r.id})},commentEditorSchema:t,confirmBeforeDiscard:i,submitOnEnter:a}}),RE=e(i(),1),zE=se();function BE(e,t){if(e.isDestroyed||t.defaultPrevented||!t.cancelable||!e.isEditable||t.inputType!==`insertParagraph`&&t.inputType!==`insertLineBreak`||!nu()&&!tu())return;let n=e.view,r=n.root,i=(r.getSelection?.call(r)??n.dom.ownerDocument.getSelection())?.anchorNode,a=(i?.nodeType===1?i:i?.parentElement)?.closest(`[data-node-view-content-react]`);if(!a||!n.dom.contains(a))return;let o=n.input.lastKeyCode;o===13&&(n.input.lastKeyCode=null),n.domObserver.forceFlush(),n.domObserver.flush();let s=new KeyboardEvent(`keydown`,{key:`Enter`,code:`Enter`,keyCode:13,shiftKey:t.inputType===`insertLineBreak`,bubbles:!0,cancelable:!0});n.someProp(`handleKeyDown`,e=>e(n,s))?(t.preventDefault(),n.input.lastIOSEnter=0,clearTimeout(n.input.lastIOSEnterFallbackTimeout)):o===13&&(n.input.lastKeyCode=o)}var VE=new jr(`reactMobileEnter`),HE=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},UE=({contentComponent:e})=>{let t=(0,zE.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,O.jsx)(O.Fragment,{children:Object.values(t)})};function WE(){let e=new Set,t={},n=!1,r=()=>{!n&&e.size&&(n=!0,queueMicrotask(()=>{n=!1,e.forEach(e=>e())}))};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(e,n){t={...t,[e]:RE.createPortal(n.reactElement,n.element,e)},r()},removeRenderer(e){let n={...t};delete n[e],t=n,r()}}}var GE=class extends D.Component{constructor(e){super(e),this.editorContentRef=D.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=WE(),e.createNodeViews(),e.registerPlugin(new F({key:VE,props:{handleDOMEvents:{beforeinput:(t,n)=>BE(e,n)}}})),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||(e.unregisterPlugin(VE),e.view.setProps({nodeViews:{}})),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{ref:HE(t,this.editorContentRef),...n}),e?.contentComponent&&(0,O.jsx)(UE,{contentComponent:e.contentComponent})]})}},KE=(0,D.forwardRef)((e,t)=>{let n=D.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return D.createElement(GE,{key:n,innerRef:t,...e})}),qE=D.memo(KE);typeof window>`u`||typeof window<`u`&&window.next;var JE=(0,D.createContext)({editor:null});JE.Consumer;var YE=(0,D.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),XE=()=>(0,D.useContext)(YE),ZE=D.forwardRef((e,t)=>{let{onDragStart:n}=XE(),r=e.as||`div`;return(0,O.jsx)(r,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})});function QE(e){return!!(typeof e==`function`&&e.prototype&&e.prototype.isReactComponent)}function $E(e){return!(typeof e!=`object`||!e.$$typeof||e.$$typeof.toString()!==`Symbol(react.forward_ref)`&&e.$$typeof.description!==`react.forward_ref`)}function eD(e){return!(typeof e!=`object`||!e.$$typeof||e.$$typeof.toString()!==`Symbol(react.memo)`&&e.$$typeof.description!==`react.memo`)}function tD(e){if(QE(e)||$E(e))return!0;if(eD(e)){let t=e.type;if(t)return QE(t)||$E(t)}return!1}function nD(){try{if(D.version)return parseInt(D.version.split(`.`)[0],10)>=19}catch{}return!1}var rD=class{constructor(e,{editor:t,props:n={},as:r=`div`,className:i=``}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add(`react-renderer`),i&&this.element.classList.add(...i.split(` `)),this.editor.isEditorContentInitialized?(0,RE.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,i=nD(),a=tD(t),o={...n};o.ref&&!(i||a)&&delete o.ref,!o.ref&&(i||a)&&(o.ref=e=>{this.ref=e}),this.reactElement=(0,O.jsx)(t,{...o}),r==null||(e=r.contentComponent)==null||e.setRenderer(this.id,this)}updateProps(e={}){if(this.destroyed)return;let t=!1,n=Object.keys(e);for(let r=0;r<n.length;r+=1){let i=n[r];if(e[i]!==this.props[i]){t=!0;break}}t&&(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0;let t=this.editor;t==null||(e=t.contentComponent)==null||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}};D.createContext({markViewContentRef:()=>{}});function iD(e){var t;let n=e.getRootNode(),r=typeof n.getSelection==`function`?n.getSelection():(t=e.ownerDocument)==null||(t=t.defaultView)==null?void 0:t.getSelection();if(!r||r.rangeCount===0)return null;let{anchorNode:i,anchorOffset:a,focusNode:o,focusOffset:s}=r;return!i||!o||!e.contains(i)||!e.contains(o)?null:()=>{try{r.setBaseAndExtent(i,a,o,s)}catch{}}}function aD(e,t,n){return e.node(n)===t.node(n)&&e.before(n)===t.before(n)}function oD(e){if(!Ql(e))return[];let{$from:t,$to:n}=e,r=[],i=Math.min(t.depth,n.depth);for(let e=1;e<=i&&aD(t,n,e);e+=1)r.push(t.before(e));return r}var sD=class{constructor(e){this.views=new WeakMap,this.viewCount=0,this.insideViews=new Set,this.syncQueued=!1,this.scheduleSync=()=>{this.syncQueued||(this.syncQueued=!0,queueMicrotask(()=>{this.syncQueued=!1,this.sync()}))},this.handleTransaction=()=>this.scheduleSync(),this.editor=e}register(e){this.viewCount===0&&this.editor.on(`transaction`,this.handleTransaction),this.views.set(e.dom,e),this.viewCount+=1,this.scheduleSync()}unregister(e){this.views.delete(e.dom),--this.viewCount,this.insideViews.delete(e),this.viewCount===0&&this.editor.off(`transaction`,this.handleTransaction)}sync(){if(this.viewCount===0||this.editor.isDestroyed)return;let e=this.findInsideViews();this.updateViews(this.insideViews,e,!1),this.updateViews(e,this.insideViews,!0),this.insideViews=e}updateViews(e,t,n){for(let r of e)t.has(r)||r.setSelectionInside(n)}findInsideViews(){let e=new Set;for(let t of oD(this.editor.state.selection)){let n=this.editor.view.nodeDOM(t),r=n?this.views.get(n):void 0;r&&e.add(r)}return e}},cD=new WeakMap;function lD(e){let t=cD.get(e);return t||(t=new sD(e),cD.set(e,t)),t}var uD=class extends Dp{constructor(e,t,n){if(super(e,t,n),this.nodeSelected=!1,this.handlePositionUpdate=()=>{let e=this.getPos();typeof e==`number`&&e!==this.currentPos&&(this.currentPos=e,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs==`function`&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.contentDOMElement=this.options.contentDOMElementTag?document.createElement(this.options.contentDOMElementTag):document.createElement(this.node.isInline?`span`:`div`),this.contentDOMElement.dataset.nodeViewContentReact=``,this.contentDOMElement.dataset.nodeViewWrapper=``,this.contentDOMElement.style.whiteSpace=`inherit`;let e=this.dom.querySelector(`[data-node-view-content]`);e?e.appendChild(this.contentDOMElement):this.dom.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on(`update`,this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){return r===`storage`?e.storage[t.name]??{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,selectionInside:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:(0,D.createRef)()};if(!this.component.displayName){let e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}let t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{if(e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement){e.hasAttribute(`data-node-view-wrapper`)&&e.removeAttribute(`data-node-view-wrapper`);let t=iD(this.contentDOMElement);e.appendChild(this.contentDOMElement),t?.()}}},n=this.component,r=(0,D.memo)(e=>(0,O.jsx)(YE.Provider,{value:t,children:(0,D.createElement)(n,e)}));r.displayName=`ReactNodeView`;let i=this.node.isInline?`span`:`div`;this.options.as&&(i=this.options.as);let{className:a=``}=this.options;this.renderer=new rD(r,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${a}`.trim()}),lD(this.editor).register(this),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){if(this.renderer.element.firstElementChild&&!this.renderer.element.firstElementChild?.hasAttribute(`data-node-view-wrapper`))throw Error(`Please use the NodeViewWrapper component for your node view.`);return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}update(e,t,n){let r=e=>{this.renderer.updateProps(e),typeof this.options.attrs==`function`&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update==`function`){let i=this.node,a=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:i,oldDecorations:a,newNode:e,newDecorations:t,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(e===this.node)return this.node=e,this.decorations=t,this.innerDecorations=n,!0;let i=this.getPos();this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=i;let a={node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(a.getPos=()=>this.getPos()),r(a),!0}selectNode(){this.nodeSelected=!0,this.updateSelectedState(!0)}deselectNode(){this.nodeSelected=!1,this.updateSelectedState(this.options.selectedOnTextSelection===!0&&this.isTextSelectionInside())}setSelectionInside(e){let t=this.nodeSelected||this.options.selectedOnTextSelection===!0&&e;this.renderer.updateProps({selectionInside:e,selected:t}),this.renderer.element.classList.toggle(`ProseMirror-selectednode`,t)}updateSelectedState(e){this.renderer.updateProps({selected:e}),this.renderer.element.classList.toggle(`ProseMirror-selectednode`,e)}isTextSelectionInside(){let e=this.getPos();return typeof e==`number`&&oD(this.editor.state.selection).includes(e)}destroy(){this.renderer.destroy(),lD(this.editor).unregister(this),this.options.trackNodeViewPosition&&this.editor.off(`update`,this.handlePositionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs==`function`){let t=this.editor.extensionManager.attributes,n=od(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function dD(e,t){return n=>n.editor.contentComponent?new uD(e,n,t):{dom:document.createElement(`span`),contentDOM:null,update:()=>!1,destroy:()=>{},selectNode:()=>{},deselectNode:()=>{},stopEvent:()=>!1,ignoreMutation:()=>!0}}var fD=(0,D.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});fD.displayName=`TiptapContext`;var pD=()=>(0,D.useContext)(fD);function mD({children:e,...t}){let n=`editor`in t?t.editor:t.instance;if(!n)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let r=(0,D.useMemo)(()=>({editor:n}),[n]),i=(0,D.useMemo)(()=>({editor:n}),[n]);return(0,O.jsx)(JE.Provider,{value:i,children:(0,O.jsx)(fD.Provider,{value:r,children:e})})}mD.displayName=`Tiptap`;function hD({...e}){let{editor:t}=pD();return(0,O.jsx)(qE,{editor:t,...e})}hD.displayName=`Tiptap.Content`,Object.assign(mD,{Content:hD});var gD=n(),_D=Object.defineProperty,vD=(e,t)=>{let n={};for(var r in e)_D(n,r,{get:e[r],enumerable:!0});return t||_D(n,Symbol.toStringTag,{value:`Module`}),n},yD=e=>{let{blockId:t,children:n,...r}=e,i=H(),a=(0,D.useMemo)(()=>i.transact(e=>{if(!t)return;let n=R_(t,e.doc);if(!n)return;let{node:r}=i.prosemirrorView.domAtPos(n.posBeforeNode+1);if(r instanceof Element)return{element:r}}),[i,t]);return(0,O.jsx)(CE,{reference:a,...r,children:t!==void 0&&n})},bD=e=>{let t=U(),n=W(),r=H(),i=r.getBlock(e.blockId),[a,o]=(0,D.useState)(``),s=(0,D.useCallback)(e=>{o(e.currentTarget.value)},[]),c=(0,D.useCallback)(()=>{r.getBlock(e.blockId)&&r.updateBlock(e.blockId,{props:{name:Lg(a),url:a}})},[r,e.blockId,a]);return i?(0,O.jsx)(t.FilePanel.TabPanel,{className:`bn-tab-panel`,children:(0,O.jsx)(t.Generic.Form.Root,{onSubmit:c,submitButton:(0,O.jsx)(t.FilePanel.Button,{className:`bn-button`,type:`submit`,"data-test":`embed-input-button`,children:n.file_panel.embed.embed_button[i.type]||n.file_panel.embed.embed_button.file}),children:(0,O.jsx)(t.FilePanel.TextInput,{className:`bn-text-input`,placeholder:n.file_panel.embed.url_placeholder,value:a,onChange:s,"data-test":`embed-input`})})}):null},xD=e=>{let t=U(),n=W(),{setLoading:r}=e,i=H(),a=i.getBlock(e.blockId),[o,s]=(0,D.useState)(!1);(0,D.useEffect)(()=>{o&&setTimeout(()=>{s(!1)},3e3)},[o]);let c=(0,D.useCallback)(t=>{if(t===null)return;async function n(t){if(r(!0),i.uploadFile!==void 0)try{let n=await i.uploadFile(t,e.blockId);if(!i.getBlock(e.blockId))return;typeof n==`string`&&(n={props:{name:t.name,url:n}}),i.updateBlock(e.blockId,n)}catch{s(!0)}finally{r(!1)}}n(t)},[e.blockId,i,r]);if(!a)return null;let l=i.schema.blockSpecs[a.type],u=l.implementation.meta?.fileBlockAccept?.length?l.implementation.meta.fileBlockAccept.join(`,`):`*/*`;return(0,O.jsxs)(t.FilePanel.TabPanel,{className:`bn-tab-panel`,children:[(0,O.jsx)(t.FilePanel.FileInput,{className:`bn-file-input`,"data-test":`upload-input`,accept:u,placeholder:n.file_panel.upload.file_placeholder[a.type]||n.file_panel.upload.file_placeholder.file,value:null,onChange:c}),o&&(0,O.jsx)(`div`,{className:`bn-error-text`,children:n.file_panel.upload.upload_error})]})},SD=e=>{let t=U(),n=W(),r=H(),[i,a]=(0,D.useState)(!1),o=e.tabs??[...r.uploadFile===void 0?[]:[{name:n.file_panel.upload.title,tabPanel:(0,O.jsx)(xD,{blockId:e.blockId,setLoading:a})}],{name:n.file_panel.embed.title,tabPanel:(0,O.jsx)(bD,{blockId:e.blockId})}],[s,c]=(0,D.useState)(e.defaultOpenTab||o[0].name);return(0,O.jsx)(t.FilePanel.Root,{className:`bn-panel`,defaultOpenTab:s,openTab:s,setOpenTab:c,tabs:o,loading:i})},CD=e=>{let t=H(),n=iE(rv),r=aE(rv),i=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!r,onOpenChange:(e,r,i)=>{e||n.closeMenu(),i===`escape-key`&&t.focus()},middleware:[p(10),S()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:90},...e.floatingUIOptions?.elementProps}}),[r,t,n,e.floatingUIOptions]),a=e.filePanel||SD;return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(yD,{blockId:r,...i,children:r&&(0,O.jsx)(a,{blockId:r})})})},wD={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},TD=D.createContext&&D.createContext(wD),ED=[`attr`,`size`,`title`];function DD(e,t){if(e==null)return{};var n,r,i=OD(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function OD(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function kD(){return kD=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},kD.apply(null,arguments)}function AD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function jD(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?AD(Object(n),!0).forEach(function(t){MD(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):AD(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function MD(e,t,n){return(t=ND(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ND(e){var t=PD(e,`string`);return typeof t==`symbol`?t:t+``}function PD(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function FD(e){return e&&e.map((e,t)=>D.createElement(e.tag,jD({key:t},e.attr),FD(e.child)))}function G(e){return t=>D.createElement(ID,kD({attr:jD({},e.attr)},t),FD(e.child))}function ID(e){var t=t=>{var{attr:n,size:r,title:i}=e,a=DD(e,ED),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),D.createElement(`svg`,kD({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:jD(jD({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&D.createElement(`title`,null,i),e.children)};return TD===void 0?t(wD):D.createElement(TD.Consumer,null,e=>t(e))}function LD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM8 13H16C16 15.2091 14.2091 17 12 17C9.79086 17 8 15.2091 8 13ZM8 11C7.17157 11 6.5 10.3284 6.5 9.5C6.5 8.67157 7.17157 8 8 8C8.82843 8 9.5 8.67157 9.5 9.5C9.5 10.3284 8.82843 11 8 11ZM16 11C15.1716 11 14.5 10.3284 14.5 9.5C14.5 8.67157 15.1716 8 16 8C16.8284 8 17.5 8.67157 17.5 9.5C17.5 10.3284 16.8284 11 16 11Z`},child:[]}]})(e)}function RD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM8 13C8 15.2091 9.79086 17 12 17C14.2091 17 16 15.2091 16 13H8ZM8 11C8.82843 11 9.5 10.3284 9.5 9.5C9.5 8.67157 8.82843 8 8 8C7.17157 8 6.5 8.67157 6.5 9.5C6.5 10.3284 7.17157 11 8 11ZM16 11C16.8284 11 17.5 10.3284 17.5 9.5C17.5 8.67157 16.8284 8 16 8C15.1716 8 14.5 8.67157 14.5 9.5C14.5 10.3284 15.1716 11 16 11Z`},child:[]}]})(e)}function zD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5 11V13H19V11H5Z`},child:[]}]})(e)}function BD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5 10C3.9 10 3 10.9 3 12C3 13.1 3.9 14 5 14C6.1 14 7 13.1 7 12C7 10.9 6.1 10 5 10ZM19 10C17.9 10 17 10.9 17 12C17 13.1 17.9 14 19 14C20.1 14 21 13.1 21 12C21 10.9 20.1 10 19 10ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10Z`},child:[]}]})(e)}function VD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V12L17.206 8.207L11.2071 14.2071L9.79289 12.7929L15.792 6.793L12 3H21Z`},child:[]}]})(e)}function HD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M4 19H20V12H22V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V12H4V19ZM14 9H19L12 16L5 9H10V3H14V9Z`},child:[]}]})(e)}function UD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM9 11V17H11V11H9ZM13 11V17H15V11H13ZM9 4V6H15V4H9Z`},child:[]}]})(e)}function WD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 4V6H15V4H9Z`},child:[]}]})(e)}function GD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z`},child:[]}]})(e)}function KD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z`},child:[]}]})(e)}function qD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z`},child:[]}]})(e)}function JD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M22 18V20H2V18H22ZM2 3.5L10 8.5L2 13.5V3.5ZM22 11V13H12V11H22ZM22 4V6H12V4H22Z`},child:[]}]})(e)}function YD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M20 3C20.5523 3 21 3.44772 21 4V5.757L19 7.757V5H5V13.1L9 9.1005L13.328 13.429L12.0012 14.7562L11.995 18.995L16.2414 19.0012L17.571 17.671L18.8995 19H19V16.242L21 14.242V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM21.7782 7.80761L23.1924 9.22183L15.4142 17L13.9979 16.9979L14 15.5858L21.7782 7.80761ZM15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7Z`},child:[]}]})(e)}function XD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21 15V18H24V20H21V23H19V20H16V18H19V15H21ZM21.0082 3C21.556 3 22 3.44495 22 3.9934L22.0007 13.3417C21.3749 13.1204 20.7015 13 20 13V5H4L4.001 19L13.2929 9.70715C13.6528 9.34604 14.22 9.31823 14.6123 9.62322L14.7065 9.70772L18.2521 13.2586C15.791 14.0069 14 16.2943 14 19C14 19.7015 14.1204 20.3749 14.3417 21.0007L2.9918 21C2.44405 21 2 20.5551 2 20.0066V3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082ZM8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7Z`},child:[]}]})(e)}function ZD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z`},child:[]}]})(e)}function QD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z`},child:[]}]})(e)}function $D(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 3V12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12V3H18V12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12V3H8ZM4 20H20V22H4V20Z`},child:[]}]})(e)}function eO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 6V21H11V6H5V4H19V6H13Z`},child:[]}]})(e)}function tO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 10V14H19V10H13ZM11 10H5V14H11V10ZM13 19H19V16H13V19ZM11 19V16H5V19H11ZM13 5V8H19V5H13ZM11 5H5V8H11V5ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3Z`},child:[]}]})(e)}function nO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17.1538 14C17.3846 14.5161 17.5 15.0893 17.5 15.7196C17.5 17.0625 16.9762 18.1116 15.9286 18.867C14.8809 19.6223 13.4335 20 11.5862 20C9.94674 20 8.32335 19.6185 6.71592 18.8555V16.6009C8.23538 17.4783 9.7908 17.917 11.3822 17.917C13.9333 17.917 15.2128 17.1846 15.2208 15.7196C15.2208 15.0939 15.0049 14.5598 14.5731 14.1173C14.5339 14.0772 14.4939 14.0381 14.4531 14H3V12H21V14H17.1538ZM13.076 11H7.62908C7.4566 10.8433 7.29616 10.6692 7.14776 10.4778C6.71592 9.92084 6.5 9.24559 6.5 8.45207C6.5 7.21602 6.96583 6.165 7.89749 5.299C8.82916 4.43299 10.2706 4 12.2219 4C13.6934 4 15.1009 4.32808 16.4444 4.98426V7.13591C15.2448 6.44921 13.9293 6.10587 12.4978 6.10587C10.0187 6.10587 8.77917 6.88793 8.77917 8.45207C8.77917 8.87172 8.99709 9.23796 9.43293 9.55079C9.86878 9.86362 10.4066 10.1135 11.0463 10.3004C11.6665 10.4816 12.3431 10.7148 13.076 11H13.076Z`},child:[]}]})(e)}function rO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21 4H3V6H21V4ZM21 11H8V13H21V11ZM21 18H8V20H21V18ZM5 11H3V20H5V11Z`},child:[]}]})(e)}function iO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21 20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20C20.5523 3 21 3.44772 21 4V20ZM19 11V5H13.001V7H15L12 10L9 7H11V5H5V11H7V13H5V19H11V17H9L12 14L15 17H13.001V19H19V13H17V11H19ZM11 13H9V11H11V13ZM15 13H13V11H15V13Z`},child:[]}]})(e)}function aO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M20 3C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM11 5H5V10.999H7V9L10 12L7 15V13H5V19H11V17H13V19H19V13H17V15L14 12L17 9V10.999H19V5H13V7H11V5ZM13 13V15H11V13H13ZM13 9V11H11V9H13Z`},child:[]}]})(e)}function oO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 4H21V6H8V4ZM4.5 6.5C3.67157 6.5 3 5.82843 3 5C3 4.17157 3.67157 3.5 4.5 3.5C5.32843 3.5 6 4.17157 6 5C6 5.82843 5.32843 6.5 4.5 6.5ZM4.5 13.5C3.67157 13.5 3 12.8284 3 12C3 11.1716 3.67157 10.5 4.5 10.5C5.32843 10.5 6 11.1716 6 12C6 12.8284 5.32843 13.5 4.5 13.5ZM4.5 20.4C3.67157 20.4 3 19.7284 3 18.9C3 18.0716 3.67157 17.4 4.5 17.4C5.32843 17.4 6 18.0716 6 18.9C6 19.7284 5.32843 20.4 4.5 20.4ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z`},child:[]}]})(e)}function sO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 4H21V6H8V4ZM5 3V6H6V7H3V6H4V4H3V3H5ZM3 14V11.5H5V11H3V10H6V12.5H4V13H6V14H3ZM5 19.5H3V18.5H5V18H3V17H6V21H3V20H5V19.5ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z`},child:[]}]})(e)}function cO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z`},child:[]}]})(e)}function lO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M18.3638 15.5355L16.9496 14.1213L18.3638 12.7071C20.3164 10.7545 20.3164 7.58866 18.3638 5.63604C16.4112 3.68341 13.2453 3.68341 11.2927 5.63604L9.87849 7.05025L8.46428 5.63604L9.87849 4.22182C12.6122 1.48815 17.0443 1.48815 19.778 4.22182C22.5117 6.95549 22.5117 11.3876 19.778 14.1213L18.3638 15.5355ZM15.5353 18.364L14.1211 19.7782C11.3875 22.5118 6.95531 22.5118 4.22164 19.7782C1.48797 17.0445 1.48797 12.6123 4.22164 9.87868L5.63585 8.46446L7.05007 9.87868L5.63585 11.2929C3.68323 13.2455 3.68323 16.4113 5.63585 18.364C7.58847 20.3166 10.7543 20.3166 12.7069 18.364L14.1211 16.9497L15.5353 18.364ZM14.8282 7.75736L16.2425 9.17157L9.17139 16.2426L7.75717 14.8284L14.8282 7.75736Z`},child:[]}]})(e)}function uO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17 17H22V19H19V22H17V17ZM7 7H2V5H5V2H7V7ZM18.364 15.5355L16.9497 14.1213L18.364 12.7071C20.3166 10.7545 20.3166 7.58866 18.364 5.63604C16.4113 3.68342 13.2455 3.68342 11.2929 5.63604L9.87868 7.05025L8.46447 5.63604L9.87868 4.22183C12.6123 1.48816 17.0445 1.48816 19.7782 4.22183C22.5118 6.9555 22.5118 11.3877 19.7782 14.1213L18.364 15.5355ZM15.5355 18.364L14.1213 19.7782C11.3877 22.5118 6.9555 22.5118 4.22183 19.7782C1.48816 17.0445 1.48816 12.6123 4.22183 9.87868L5.63604 8.46447L7.05025 9.87868L5.63604 11.2929C3.68342 13.2455 3.68342 16.4113 5.63604 18.364C7.58866 20.3166 10.7545 20.3166 12.7071 18.364L14.1213 16.9497L15.5355 18.364ZM14.8284 7.75736L16.2426 9.17157L9.17157 16.2426L7.75736 14.8284L14.8284 7.75736Z`},child:[]}]})(e)}function dO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M15 20H7V18H9.92661L12.0425 6H9V4H17V6H14.0734L11.9575 18H15V20Z`},child:[]}]})(e)}function fO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 5H11V19H8V21H16V19H13V5H16V3H8V5ZM2 7C1.44772 7 1 7.44772 1 8V16C1 16.5523 1.44772 17 2 17H8V15H3V9H8V7H2ZM16 9H21V15H16V17H22C22.5523 17 23 16.5523 23 16V8C23 7.44772 22.5523 7 22 7H16V9Z`},child:[]}]})(e)}function pO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM7 12.5L3 16V9L7 12.5Z`},child:[]}]})(e)}function mO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM3 12.5L7 9V16L3 12.5Z`},child:[]}]})(e)}function hO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21.097 8L18.499 12.5C20.7091 12.5 22.5 14.2909 22.5 16.5C22.5 18.7091 20.7091 20.5 18.5 20.5C16.2909 20.5 14.5 18.7091 14.5 16.5C14.5 15.7636 14.699 15.0737 15.0461 14.4811L18.788 8H21.097ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 14.5C17.3954 14.5 16.5 15.3954 16.5 16.5C16.5 17.6046 17.3954 18.5 18.5 18.5C19.6046 18.5 20.5 17.6046 20.5 16.5C20.5 15.3954 19.6046 14.5 18.5 14.5Z`},child:[]}]})(e)}function gO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M22 8V10H17.6769L17.2126 12.6358C17.5435 12.5472 17.8912 12.5 18.25 12.5C20.4591 12.5 22.25 14.2909 22.25 16.5C22.25 18.7091 20.4591 20.5 18.25 20.5C16.4233 20.5 14.8827 19.2756 14.4039 17.6027L16.3271 17.0519C16.5667 17.8881 17.3369 18.5 18.25 18.5C19.3546 18.5 20.25 17.6046 20.25 16.5C20.25 15.3954 19.3546 14.5 18.25 14.5C17.6194 14.5 17.057 14.7918 16.6904 15.2478L14.8803 14.3439L16 8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z`},child:[]}]})(e)}function _O(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM22 8V16H23.5V18H22V20H20V18H14.5V16.66L19.5 8H22ZM20 11.133L17.19 16H20V11.133Z`},child:[]}]})(e)}function vO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M22 8L21.9984 10L19.4934 12.883C21.0823 13.3184 22.25 14.7728 22.25 16.5C22.25 18.5711 20.5711 20.25 18.5 20.25C16.674 20.25 15.1528 18.9449 14.8184 17.2166L16.7821 16.8352C16.9384 17.6413 17.6481 18.25 18.5 18.25C19.4665 18.25 20.25 17.4665 20.25 16.5C20.25 15.5335 19.4665 14.75 18.5 14.75C18.214 14.75 17.944 14.8186 17.7056 14.9403L16.3992 13.3932L19.3484 10H15V8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z`},child:[]}]})(e)}function yO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 8C20.5711 8 22.25 9.67893 22.25 11.75C22.25 12.6074 21.9623 13.3976 21.4781 14.0292L21.3302 14.2102L18.0343 18H22V20H15L14.9993 18.444L19.8207 12.8981C20.0881 12.5908 20.25 12.1893 20.25 11.75C20.25 10.7835 19.4665 10 18.5 10C17.5818 10 16.8288 10.7071 16.7558 11.6065L16.75 11.75H14.75C14.75 9.67893 16.4289 8 18.5 8Z`},child:[]}]})(e)}function bO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM21.0005 8V20H19.0005L19 10.204L17 10.74V8.67L19.5005 8H21.0005Z`},child:[]}]})(e)}function xO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5.55397 22H3.3999L10.9999 3H12.9999L20.5999 22H18.4458L16.0458 16H7.95397L5.55397 22ZM8.75397 14H15.2458L11.9999 5.88517L8.75397 14Z`},child:[]}]})(e)}function SO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3.41436 5.99995L5.70726 3.70706L4.29304 2.29285L0.585938 5.99995L4.29304 9.70706L5.70726 8.29285L3.41436 5.99995ZM9.58594 5.99995L7.29304 3.70706L8.70726 2.29285L12.4144 5.99995L8.70726 9.70706L7.29304 8.29285L9.58594 5.99995ZM14.0002 2.99995H21.0002C21.5524 2.99995 22.0002 3.44767 22.0002 3.99995V20C22.0002 20.5522 21.5524 21 21.0002 21H3.00015C2.44787 21 2.00015 20.5522 2.00015 20V12H4.00015V19H20.0002V4.99995H14.0002V2.99995Z`},child:[]}]})(e)}function CO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 11H12.5C13.8807 11 15 9.88071 15 8.5C15 7.11929 13.8807 6 12.5 6H8V11ZM18 15.5C18 17.9853 15.9853 20 13.5 20H6V4H12.5C14.9853 4 17 6.01472 17 8.5C17 9.70431 16.5269 10.7981 15.7564 11.6058C17.0979 12.3847 18 13.837 18 15.5ZM8 13V18H13.5C14.8807 18 16 16.8807 16 15.5C16 14.1193 14.8807 13 13.5 13H8Z`},child:[]}]})(e)}function wO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z`},child:[]}]})(e)}function TO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z`},child:[]}]})(e)}function EO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z`},child:[]}]})(e)}function DO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM5 19H19V21H5V19ZM3 14H21V16H3V14ZM5 9H19V11H5V9Z`},child:[]}]})(e)}function OO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M23 12L15.9289 19.0711L14.5147 17.6569L20.1716 12L14.5147 6.34317L15.9289 4.92896L23 12ZM3.82843 12L9.48528 17.6569L8.07107 19.0711L1 12L8.07107 4.92896L9.48528 6.34317L3.82843 12Z`},child:[]}]})(e)}function kO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z`},child:[]}]})(e)}function AO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M7.29117 20.8242L2 22L3.17581 16.7088C2.42544 15.3056 2 13.7025 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C10.2975 22 8.6944 21.5746 7.29117 20.8242ZM7.58075 18.711L8.23428 19.0605C9.38248 19.6745 10.6655 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 13.3345 4.32549 14.6175 4.93949 15.7657L5.28896 16.4192L4.63416 19.3658L7.58075 18.711Z`},child:[]}]})(e)}function jO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M7.24264 17.9967H3V13.754L14.435 2.319C14.8256 1.92848 15.4587 1.92848 15.8492 2.319L18.6777 5.14743C19.0682 5.53795 19.0682 6.17112 18.6777 6.56164L7.24264 17.9967ZM3 19.9967H21V21.9967H3V19.9967Z`},child:[]}]})(e)}function MO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 7V11L2 6L8 1V5H13C17.4183 5 21 8.58172 21 13C21 17.4183 17.4183 21 13 21H4V19H13C16.3137 19 19 16.3137 19 13C19 9.68629 16.3137 7 13 7H8Z`},child:[]}]})(e)}var NO={bold:CO,italic:dO,underline:$D,strike:nO,code:OO};function PO(e,t){return e in t.schema.styleSchema&&t.schema.styleSchema[e].type===e&&t.schema.styleSchema[e].propSchema===`boolean`}var FO=e=>{let t=W(),n=U(),r=H(),i=cE({editor:r,selector:({editor:t})=>{if(t.isEditable&&PO(e.basicTextStyle,t)&&(t.getSelection()?.blocks||[t.getTextCursorPosition().block]).find(e=>e.content!==void 0))return e.basicTextStyle in t.getActiveStyles()?{active:!0}:{active:!1}}}),a=(0,D.useCallback)(e=>{r.focus(),r.toggleStyles({[e]:!0})},[r]);if(i===void 0)return null;let o=NO[e.basicTextStyle];return(0,O.jsx)(n.FormattingToolbar.Button,{className:`bn-button`,"data-test":e.basicTextStyle,onClick:()=>a(e.basicTextStyle),isSelected:i.active,label:t.formatting_toolbar[e.basicTextStyle].tooltip,mainTooltip:t.formatting_toolbar[e.basicTextStyle].tooltip,secondaryTooltip:pg(t.formatting_toolbar[e.basicTextStyle].secondary_tooltip,t.generic.ctrl_shortcut),icon:(0,O.jsx)(o,{})})},IO=(0,D.createContext)(`desktop`);function LO(){return(0,D.useContext)(IO)}var RO=e=>{let t=e.textColor||`default`,n=e.backgroundColor||`default`,r=e.size||16,i=(0,D.useMemo)(()=>({pointerEvents:`none`,fontSize:(r*.75).toString()+`px`,height:r.toString()+`px`,lineHeight:r.toString()+`px`,textAlign:`center`,width:r.toString()+`px`}),[r]);return(0,O.jsx)(`div`,{className:`bn-color-icon`,"data-background-color":n,"data-text-color":t,style:i,children:`A`})},zO=[`default`,`gray`,`brown`,`red`,`orange`,`yellow`,`green`,`blue`,`purple`,`pink`],BO=e=>{let t=U(),n=W();return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(()=>e.text?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(t.Generic.Menu.Label,{children:n.color_picker.text_title}),zO.map(r=>(0,O.jsx)(t.Generic.Menu.Item,{onClick:()=>{e.onClick?.(),e.text.setColor(r)},"data-test":`text-color-`+r,icon:(0,O.jsx)(RO,{textColor:r,size:e.iconSize}),checked:e.text.color===r,children:n.color_picker.colors[r]},`text-color-`+r))]}):null,{}),(0,O.jsx)(()=>e.background?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(t.Generic.Menu.Label,{children:n.color_picker.background_title}),zO.map(r=>(0,O.jsx)(t.Generic.Menu.Item,{onClick:()=>{e.onClick?.(),e.background.setColor(r)},"data-test":`background-color-`+r,icon:(0,O.jsx)(RO,{backgroundColor:r,size:e.iconSize}),checked:e.background.color===r,children:n.color_picker.colors[r]},`background-color-`+r))]}):null,{})]})};function VO(e,t){return`${e}Color`in t.schema.styleSchema&&t.schema.styleSchema[`${e}Color`].type===`${e}Color`&&t.schema.styleSchema[`${e}Color`].propSchema===`string`}var HO=()=>{let e=U(),t=W(),n=LO(),r=mE(),i=H(),a=VO(`text`,i),o=VO(`background`,i),s=cE({editor:i,selector:({editor:e})=>{if(!e.isEditable||!(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return;let t=VO(`text`,e),n=VO(`background`,e);if(t||n)return{textColor:t?e.getActiveStyles().textColor||`default`:void 0,backgroundColor:n?e.getActiveStyles().backgroundColor||`default`:void 0}}}),c=(0,D.useCallback)(e=>{if(!a)throw Error(`Tried to set text color, but style does not exist in editor schema.`);e==="default"?i.removeStyles({textColor:e}):i.addStyles({textColor:e}),i.focus()},[i,a]),l=(0,D.useCallback)(e=>{if(!o)throw Error(`Tried to set background color, but style does not exist in editor schema.`);e==="default"?i.removeStyles({backgroundColor:e}):i.addStyles({backgroundColor:e}),i.focus()},[o,i]);return s===void 0?null:(0,O.jsxs)(e.Generic.Menu.Root,{portalElement:r,preventFocusOnOpen:n===`mobile`,children:[(0,O.jsx)(e.Generic.Menu.Trigger,{children:(0,O.jsx)(e.FormattingToolbar.Button,{className:`bn-button`,"data-test":`colors`,label:t.formatting_toolbar.colors.tooltip,mainTooltip:t.formatting_toolbar.colors.tooltip,icon:(0,O.jsx)(RO,{textColor:s.textColor,backgroundColor:s.backgroundColor,size:20})})}),(0,O.jsx)(e.Generic.Menu.Dropdown,{className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,O.jsx)(BO,{text:s.textColor?{color:s.textColor,setColor:c}:void 0,background:s.backgroundColor?{color:s.backgroundColor,setColor:l}:void 0})})]})};function UO(){let e=W();return(0,O.jsx)(`button`,{className:`bn-screen-reader-only-submit`,tabIndex:-1,type:`submit`,children:e.generic.form_submit})}var WO=e=>{for(let t of _b)if(e.startsWith(t))return e;return`${vb}://${e}`},GO=e=>{let t=U(),n=W(),{editLink:r}=iE(gb),{url:i,text:a,showTextField:o}=e,[s,c]=(0,D.useState)(i),[l,u]=(0,D.useState)(a);(0,D.useEffect)(()=>{c(i),u(a)},[a,i]);let d=(0,D.useCallback)(e=>c(e.currentTarget.value),[]),f=(0,D.useCallback)(e=>u(e.currentTarget.value),[]),p=(0,D.useCallback)(()=>{r(WO(s),l,e.range.from),e.setToolbarOpen?.(!1),e.setToolbarPositionFrozen?.(!1)},[r,s,l,e]);return(0,O.jsxs)(t.Generic.Form.Root,{onSubmit:p,submitButton:(0,O.jsx)(UO,{}),children:[(0,O.jsx)(t.Generic.Form.TextInput,{className:`bn-text-input`,name:`url`,icon:(0,O.jsx)(lO,{}),autoFocus:!0,placeholder:n.link_toolbar.form.url_placeholder,value:s,onChange:d}),o!==!1&&(0,O.jsx)(t.Generic.Form.TextInput,{className:`bn-text-input`,name:`title`,icon:(0,O.jsx)(eO,{}),placeholder:n.link_toolbar.form.title_placeholder,value:l,onChange:f})]})};function KO(e){return`link`in e.schema.inlineContentSchema&&e.schema.inlineContentSchema.link===`link`}var qO=()=>{let e=H(),t=lE(),n=U(),r=W(),i=mE(),a=iE(vy),{showSelection:o}=iE(Iy),[s,c]=(0,D.useState)(!1);(0,D.useEffect)(()=>(o(s,`createLinkButton`),()=>o(!1,`createLinkButton`)),[s,o]);let l=(0,D.useCallback)(t=>{t||e.focus(),c(t)},[e]),u=cE({editor:e,selector:({editor:e})=>{if(e.isEditable&&!e.prosemirrorState.selection.empty&&KO(e)&&!gy(e.prosemirrorState.selection)&&(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return{url:e.getSelectedLinkUrl(),text:e.getSelectedText(),range:{from:e.prosemirrorState.selection.from,to:e.prosemirrorState.selection.to}}}});return(0,D.useEffect)(()=>{c(!1)},[u]),(0,D.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key===`k`&&(c(!0),e.preventDefault())};return t?.addEventListener(`keydown`,e),()=>{t?.removeEventListener(`keydown`,e)}},[t]),u===void 0?null:(0,O.jsxs)(n.Generic.Popover.Root,{open:s,onOpenChange:l,portalElement:i,children:[(0,O.jsx)(n.Generic.Popover.Trigger,{children:(0,O.jsx)(n.FormattingToolbar.Button,{className:`bn-button`,"data-test":`createLink`,label:r.formatting_toolbar.link.tooltip,mainTooltip:r.formatting_toolbar.link.tooltip,secondaryTooltip:pg(r.formatting_toolbar.link.secondary_tooltip,r.generic.ctrl_shortcut),icon:(0,O.jsx)(lO,{}),onClick:()=>l(!s)})}),(0,O.jsx)(n.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,O.jsx)(GO,{url:u.url||``,text:u.text,range:u.range,showTextField:!1,setToolbarOpen:e=>a.store.setState(e)})})]})},JO=()=>{let e=W(),t=U(),n=mE(),r=H(),i=cE({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(hy(n,e,n.type,{url:`string`,caption:`string`}))return n}}),[a,o]=(0,D.useState)(!1),s=(0,D.useCallback)(e=>{e||r.focus(),o(e)},[r]),c=(0,D.useCallback)(e=>{i!==void 0&&my(r,i.type,{caption:`string`})&&r.updateBlock(i.id,{props:{caption:e.currentTarget.value}})},[i,r]);return i===void 0?null:(0,O.jsxs)(t.Generic.Popover.Root,{open:a,onOpenChange:s,portalElement:n,children:[(0,O.jsx)(t.Generic.Popover.Trigger,{children:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_caption.tooltip,mainTooltip:e.formatting_toolbar.file_caption.tooltip,icon:(0,O.jsx)(fO,{}),onClick:()=>s(!a)})}),(0,O.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,O.jsx)(t.Generic.Form.Root,{onSubmit:()=>s(!1),submitButton:(0,O.jsx)(UO,{}),children:(0,O.jsx)(t.Generic.Form.TextInput,{name:`file-caption`,icon:(0,O.jsx)(fO,{}),value:i.props.caption,autoFocus:!0,placeholder:e.formatting_toolbar.file_caption.input_placeholder,onChange:c})})})]})},YO=()=>{let e=W(),t=U(),n=H(),r=cE({editor:n,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(hy(n,e,n.type,{url:`string`}))return n}}),i=(0,D.useCallback)(()=>{r!==void 0&&(n.focus(),n.removeBlocks([r.id]))},[r,n]);return r===void 0?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_delete.tooltip[r.type]||e.formatting_toolbar.file_delete.tooltip.file,mainTooltip:e.formatting_toolbar.file_delete.tooltip[r.type]||e.formatting_toolbar.file_delete.tooltip.file,icon:(0,O.jsx)(WD,{}),onClick:i})},XO=()=>{let e=W(),t=U(),n=mE(),r=H(),i=cE({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(hy(n,e,n.type,{url:`string`,name:`string`}))return n}}),[a,o]=(0,D.useState)(!1),s=(0,D.useCallback)(e=>{e||r.focus(),o(e)},[r]),c=(0,D.useCallback)(e=>{i!==void 0&&my(r,i.type,{name:`string`})&&r.updateBlock(i.id,{props:{name:e.currentTarget.value}})},[i,r]);return i===void 0?null:(0,O.jsxs)(t.Generic.Popover.Root,{open:a,onOpenChange:s,portalElement:n,children:[(0,O.jsx)(t.Generic.Popover.Trigger,{children:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_rename.tooltip[i.type]||e.formatting_toolbar.file_rename.tooltip.file,mainTooltip:e.formatting_toolbar.file_rename.tooltip[i.type]||e.formatting_toolbar.file_rename.tooltip.file,icon:(0,O.jsx)(xO,{}),onClick:()=>s(!a)})}),(0,O.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,O.jsx)(t.Generic.Form.Root,{onSubmit:()=>s(!1),submitButton:(0,O.jsx)(UO,{}),children:(0,O.jsx)(t.Generic.Form.TextInput,{name:`file-name`,icon:(0,O.jsx)(xO,{}),value:i.props.name,autoFocus:!0,placeholder:e.formatting_toolbar.file_rename.input_placeholder[i.type]||e.formatting_toolbar.file_rename.input_placeholder.file,onChange:c})})})]})},ZO=()=>{let e=W(),t=U(),n=mE(),r=H(),i=cE({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(hy(n,e,n.type,{url:`string`}))return n}});return i===void 0?null:(0,O.jsxs)(t.Generic.Popover.Root,{onOpenChange:e=>{e||r.focus()},portalElement:n,children:[(0,O.jsx)(t.Generic.Popover.Trigger,{children:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,mainTooltip:e.formatting_toolbar.file_replace.tooltip[i.type]||e.formatting_toolbar.file_replace.tooltip.file,label:e.formatting_toolbar.file_replace.tooltip[i.type]||e.formatting_toolbar.file_replace.tooltip.file,icon:(0,O.jsx)(YD,{})})}),(0,O.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-panel-popover`,variant:`panel-popover`,children:(0,O.jsx)(SD,{blockId:i.id})})]})},QO=()=>{let e=W(),t=U(),n=H(),r=cE({editor:n,selector:({editor:e})=>{if(e.isEditable&&(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return{canNestBlock:e.canNestBlock()}}}),i=(0,D.useCallback)(()=>{r!==void 0&&r.canNestBlock&&(n.focus(),n.nestBlock())},[n,r]);return r===void 0?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,"data-test":`nestBlock`,onClick:i,isDisabled:!r.canNestBlock,label:e.formatting_toolbar.nest.tooltip,mainTooltip:e.formatting_toolbar.nest.tooltip,secondaryTooltip:pg(e.formatting_toolbar.nest.secondary_tooltip,e.generic.ctrl_shortcut),icon:(0,O.jsx)(pO,{})})},$O=()=>{let e=W(),t=U(),n=H(),r=cE({editor:n,selector:({editor:e})=>{if(e.isEditable&&(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return{canUnnestBlock:e.canUnnestBlock()}}}),i=(0,D.useCallback)(()=>{r!==void 0&&r.canUnnestBlock&&(n.focus(),n.unnestBlock())},[n,r]);return r===void 0?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,"data-test":`unnestBlock`,onClick:i,isDisabled:!r.canUnnestBlock,label:e.formatting_toolbar.unnest.tooltip,mainTooltip:e.formatting_toolbar.unnest.tooltip,secondaryTooltip:pg(e.formatting_toolbar.unnest.secondary_tooltip,e.generic.ctrl_shortcut),icon:(0,O.jsx)(mO,{})})},ek=e=>[{name:e.slash_menu.paragraph.title,type:`paragraph`,icon:eO},{name:e.slash_menu.heading.title,type:`heading`,props:{level:1,isToggleable:!1},icon:bO},{name:e.slash_menu.heading_2.title,type:`heading`,props:{level:2,isToggleable:!1},icon:yO},{name:e.slash_menu.heading_3.title,type:`heading`,props:{level:3,isToggleable:!1},icon:vO},{name:e.slash_menu.heading_4.title,type:`heading`,props:{level:4,isToggleable:!1},icon:_O},{name:e.slash_menu.heading_5.title,type:`heading`,props:{level:5,isToggleable:!1},icon:gO},{name:e.slash_menu.heading_6.title,type:`heading`,props:{level:6,isToggleable:!1},icon:hO},{name:e.slash_menu.toggle_heading.title,type:`heading`,props:{level:1,isToggleable:!0},icon:bO},{name:e.slash_menu.toggle_heading_2.title,type:`heading`,props:{level:2,isToggleable:!0},icon:yO},{name:e.slash_menu.toggle_heading_3.title,type:`heading`,props:{level:3,isToggleable:!0},icon:vO},{name:e.slash_menu.quote.title,type:`quote`,icon:rO},{name:e.slash_menu.toggle_list.title,type:`toggleListItem`,icon:JD},{name:e.slash_menu.bullet_list.title,type:`bulletListItem`,icon:oO},{name:e.slash_menu.numbered_list.title,type:`numberedListItem`,icon:sO},{name:e.slash_menu.check_list.title,type:`checkListItem`,icon:cO}],tk=e=>{let t=U(),n=LO(),r=mE(),i=H(),a=cE({editor:i,selector:({editor:e})=>e.getSelection()?.blocks||[e.getTextCursorPosition().block]}),o=a[0],s=(0,D.useMemo)(()=>(e.items||ek(i.dictionary)).filter(e=>my(i,e.type,Object.fromEntries(Object.entries(e.props||{}).map(([e,t])=>[e,typeof t])))),[i,e.items]),c=(0,D.useMemo)(()=>s.map(e=>{let t=e.icon,n=e.type===o.type,r=Object.entries(e.props||{}).filter(([e,t])=>t!==o.props[e]).length===0;return{text:e.name,icon:(0,O.jsx)(t,{size:16}),onClick:()=>{i.focus(),i.transact(()=>{for(let t of a)i.updateBlock(t,{type:e.type,props:e.props})})},isSelected:n&&r}}),[i,s,o.props,o.type,a]);return!(0,D.useMemo)(()=>c.find(e=>e.isSelected)!==void 0,[c])||!i.isEditable?null:(0,O.jsx)(t.FormattingToolbar.Select,{className:`bn-select`,items:c,portalElement:r,preventFocusOnOpen:n===`mobile`})},nk=()=>{let e=W(),t=U(),n=H(),r=iE(`comments`),{store:i}=iE(vy),a=cE({editor:n,selector:({editor:e})=>e.prosemirrorState.selection.empty}),o=(0,D.useCallback)(()=>{r.startPendingComment(),i.setState(!1)},[r,i]);return a?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.comment.tooltip,mainTooltip:e.formatting_toolbar.comment.tooltip,icon:(0,O.jsx)(AO,{}),onClick:o})},rk=()=>H().getExtension(`comments`)?(0,O.jsx)(nk,{}):null,ik=()=>{let e=W(),t=U(),n=H(),r=cE({editor:n,selector:({editor:e})=>e.prosemirrorState.selection.empty}),i=(0,D.useCallback)(()=>{n._tiptapEditor.chain().focus().addPendingComment().run()},[n]);return!n._tiptapEditor.commands.addPendingComment||!n.isEditable||r?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.comment.tooltip,mainTooltip:e.formatting_toolbar.comment.tooltip,icon:(0,O.jsx)(AO,{}),onClick:i})};function ak(e,t){try{let n=new URL(e,t);if(n.protocol!==`javascript:`)return n.href}catch{}return`#`}var ok=()=>{let e=W(),t=U(),n=H(),r=cE({editor:n,selector:({editor:e})=>{let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(hy(n,e,n.type,{url:`string`}))return n}}),i=(0,D.useCallback)(()=>{r!==void 0&&(n.focus(),n.resolveFileUrl?n.resolveFileUrl(r.props.url).then(e=>window.open(ak(e,window.location.href))):window.open(ak(r.props.url,window.location.href)))},[r,n]);return r===void 0?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_download.tooltip[r.type]||e.formatting_toolbar.file_download.tooltip.file,mainTooltip:e.formatting_toolbar.file_download.tooltip[r.type]||e.formatting_toolbar.file_download.tooltip.file,icon:(0,O.jsx)(HD,{}),onClick:i})},sk=()=>{let e=W(),t=U(),n=H(),r=cE({editor:n,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(hy(n,e,n.type,{url:`string`,showPreview:`boolean`}))return n}}),i=(0,D.useCallback)(()=>{r!==void 0&&my(n,r.type,{showPreview:`boolean`})&&n.updateBlock(r.id,{props:{showPreview:!r.props.showPreview}})},[r,n]);return r===void 0?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:`Toggle preview`,mainTooltip:e.formatting_toolbar.file_preview_toggle.tooltip,icon:(0,O.jsx)(XD,{}),isSelected:r.props.showPreview,onClick:i})},ck=()=>{let e=W(),t=U(),n=H(),r=iE(Hx),i=cE({editor:n,selector:({editor:e})=>{if(!e.isEditable||!e.settings.tables.splitCells)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(n.type===`table`)return{mergeDirection:r.getMergeDirection(n)}}}),a=(0,D.useCallback)(()=>{r?.mergeCells()},[r]);return i===void 0?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.table_cell_merge.tooltip,mainTooltip:e.formatting_toolbar.table_cell_merge.tooltip,icon:i.mergeDirection===`horizontal`?(0,O.jsx)(aO,{}):(0,O.jsx)(iO,{}),onClick:a})},lk=()=>H().getExtension(Hx)?(0,O.jsx)(ck,{}):null,uk={left:TO,center:DO,right:wO,justify:EO},dk=e=>{let t=U(),n=W(),r=H(),i=cE({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block],n=t[0];if(hy(n,e,n.type,{textAlignment:Z_.textAlignment}))return{textAlignment:n.props.textAlignment,blocks:t};if(t.length===1&&hy(n,e,`table`))return e.getExtension(Hx)?.getCellSelection()?{textAlignment:og(n.content.rows[0].cells[0]).props.textAlignment,blocks:[n]}:void 0}}),a=(0,D.useCallback)(e=>{if(i!==void 0){r.focus();for(let t of i.blocks)if(hy(t,r,t.type,{textAlignment:Z_.textAlignment})&&my(r,t.type,{textAlignment:Z_.textAlignment}))r.updateBlock(t,{props:{textAlignment:e}});else if(t.type===`table`){let n=r.getExtension(Hx)?.getCellSelection();if(!n)continue;let i=t.content.rows.map(e=>({...e,cells:e.cells.map(e=>og(e))}));n.cells.forEach(({row:t,col:n})=>{i[t].cells[n].props.textAlignment=e}),r.updateBlock(t,{type:`table`,content:{...t.content,type:`tableContent`,rows:i}}),r.setTextCursorPosition(t)}}},[r,i]);if(i===void 0)return null;let o=uk[e.textAlignment];return(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,"data-test":`alignText${e.textAlignment.slice(0,1).toUpperCase()+e.textAlignment.slice(1)}`,onClick:()=>a(e.textAlignment),isSelected:i.textAlignment===e.textAlignment,label:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,mainTooltip:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,icon:(0,O.jsx)(o,{})})},fk=e=>[(0,O.jsx)(tk,{items:e},`blockTypeSelect`),(0,O.jsx)(lk,{},`tableCellMergeButton`),(0,O.jsx)(JO,{},`fileCaptionButton`),(0,O.jsx)(ZO,{},`replaceFileButton`),(0,O.jsx)(XO,{},`fileRenameButton`),(0,O.jsx)(YO,{},`fileDeleteButton`),(0,O.jsx)(ok,{},`fileDownloadButton`),(0,O.jsx)(sk,{},`filePreviewButton`),(0,O.jsx)(FO,{basicTextStyle:`bold`},`boldStyleButton`),(0,O.jsx)(FO,{basicTextStyle:`italic`},`italicStyleButton`),(0,O.jsx)(FO,{basicTextStyle:`underline`},`underlineStyleButton`),(0,O.jsx)(FO,{basicTextStyle:`strike`},`strikeStyleButton`),(0,O.jsx)(dk,{textAlignment:`left`},`textAlignLeftButton`),(0,O.jsx)(dk,{textAlignment:`center`},`textAlignCenterButton`),(0,O.jsx)(dk,{textAlignment:`right`},`textAlignRightButton`),(0,O.jsx)(HO,{},`colorStyleButton`),(0,O.jsx)(QO,{},`nestBlockButton`),(0,O.jsx)($O,{},`unnestBlockButton`),(0,O.jsx)(qO,{},`createLinkButton`),(0,O.jsx)(rk,{},`addCommentButton`),(0,O.jsx)(ik,{},`addTiptapCommentButton`)],pk=e=>{let t=U();return(0,O.jsx)(t.FormattingToolbar.Root,{className:`bn-toolbar bn-formatting-toolbar`,children:e.children||fk(e.blockTypeSelectItems)})},mk=e=>{switch(e){case`left`:return`top-start`;case`center`:return`top`;case`right`:return`top-end`;default:return`top-start`}},hk=e=>{let t=H(),n=iE(vy,{editor:t}),r=aE(vy,{editor:t}),i=cE({editor:t,selector:({editor:e})=>n.store.state?{from:e.prosemirrorState.selection.from,to:e.prosemirrorState.selection.to}:void 0}),a=cE({editor:t,selector:({editor:e})=>{let t=e.getTextCursorPosition().block;return hy(t,e,t.type,{textAlignment:Z_.textAlignment})?mk(t.props.textAlignment):`top-start`}}),o=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:r,onOpenChange:(e,r,i)=>{n.store.setState(e),i===`escape-key`&&t.focus()},placement:a,middleware:[p(10),w(),S()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:40},...e.floatingUIOptions?.elementProps}}),[r,a,e.floatingUIOptions,n.store,t]),s=e.formattingToolbar||pk;return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(TE,{position:i,...o,children:r&&(0,O.jsx)(s,{})})})};function gk(e,t){let n=eE(),r=t??n?.editor;if(!r)throw Error(`'editor' is required, either from BlockNoteContext or as a function argument`);let i=e?.includeEditorUI??!1,a=(0,D.useRef)(void 0);(a.current===void 0||a.current.editor!==r||a.current.includeEditorUI!==i)&&(a.current={editor:r,includeEditorUI:i,value:r.isFocused({includeEditorUI:i})});let o=(0,D.useCallback)(e=>(a.current={editor:r,includeEditorUI:i,value:r.isFocused({includeEditorUI:i})},e(),r.onFocusChange((t,n)=>{a.current={editor:r,includeEditorUI:i,value:n.focused},e()},{includeEditorUI:i})),[r,i]),s=(0,D.useCallback)(()=>a.current.value,[]);return(0,D.useSyncExternalStore)(o,s,s)}var _k=0,vk=0;function yk(){if(typeof window>`u`)return!1;let e=window.visualViewport,t=e?.scale??1,n=(e?.height??window.innerHeight)*t,r=document.documentElement.clientWidth;return Math.abs(r-vk)>vk*.2&&(vk=r,_k=0),_k=Math.max(_k,n),_k-n>150}var bk=[`--bn-vv-top`,`--bn-vv-left`,`--bn-vv-width`,`--bn-vv-height`,`--bn-vv-scale`],xk=0;function Sk(){let[e,t]=(0,D.useState)(yk);return(0,D.useLayoutEffect)(()=>{let e=document.documentElement,n=window.visualViewport,r=()=>document.querySelectorAll(`.bn-scroll-container`),i=()=>{e.style.setProperty(`--bn-vv-top`,`${n?.offsetTop??0}px`),e.style.setProperty(`--bn-vv-left`,`${n?.offsetLeft??0}px`),e.style.setProperty(`--bn-vv-width`,`${n?.width??window.innerWidth}px`),e.style.setProperty(`--bn-vv-height`,`${n?.height??window.innerHeight}px`),e.style.setProperty(`--bn-vv-scale`,`${n?.scale??1}`)},a=(e,t)=>e.toggleAttribute(`data-bn-allow-pull-to-refresh`,!t&&e.scrollTop<=0),o=()=>{let e=yk();t(e),i();for(let t of r())a(t,e)};xk++,o(),n?.addEventListener(`resize`,o),n?.addEventListener(`scroll`,o),window.addEventListener(`resize`,o);let s=e=>{e.target instanceof HTMLElement&&e.target.classList.contains(`bn-scroll-container`)&&a(e.target,yk())};return document.addEventListener(`scroll`,s,{capture:!0,passive:!0}),()=>{if(n?.removeEventListener(`resize`,o),n?.removeEventListener(`scroll`,o),window.removeEventListener(`resize`,o),document.removeEventListener(`scroll`,s,{capture:!0}),xk--,xk===0){for(let t of bk)e.style.removeProperty(t);for(let e of r())e.removeAttribute(`data-bn-allow-pull-to-refresh`);_k=0,vk=0}}},[]),e}var Ck=e=>{let t=Sk(),n=gk({includeEditorUI:!0});return!t||!n?null:(0,O.jsx)(gE,{target:document.body,children:(0,O.jsx)(IO.Provider,{value:`mobile`,children:(0,O.jsx)(wk,{formattingToolbar:e.formattingToolbar||pk})})})};function wk(e){let t=mE(),n=e.formattingToolbar;return t?(0,RE.createPortal)((0,O.jsx)(bE,{children:(0,O.jsx)(`div`,{className:`bn-mobile-formatting-toolbar`,children:(0,O.jsx)(n,{})})}),t):null}var Tk=e=>{let t=Sk();return gg()&&t?(0,O.jsx)(Ck,{formattingToolbar:e.formattingToolbar}):(0,O.jsx)(hk,{...e})},Ek=e=>{let t=U(),n=W(),{deleteLink:r}=iE(gb);return(0,O.jsx)(t.LinkToolbar.Button,{className:`bn-button`,label:n.link_toolbar.delete.tooltip,mainTooltip:n.link_toolbar.delete.tooltip,isSelected:!1,onClick:()=>{r(e.range.from),e.setToolbarOpen?.(!1)},icon:(0,O.jsx)(uO,{})})},Dk=e=>{let t=U(),n=mE(),r=W();return(0,O.jsxs)(t.Generic.Popover.Root,{onOpenChange:e.setToolbarPositionFrozen,portalElement:n,children:[(0,O.jsx)(t.Generic.Popover.Trigger,{children:(0,O.jsx)(t.LinkToolbar.Button,{className:`bn-button`,mainTooltip:r.link_toolbar.edit.tooltip,isSelected:!1,children:r.link_toolbar.edit.text})}),(0,O.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,O.jsx)(GO,{url:e.url,text:e.text,range:e.range,setToolbarOpen:e.setToolbarOpen,setToolbarPositionFrozen:e.setToolbarPositionFrozen})})]})},Ok=e=>{let t=U(),n=W();return(0,O.jsx)(t.LinkToolbar.Button,{className:`bn-button`,mainTooltip:n.link_toolbar.open.tooltip,label:n.link_toolbar.open.tooltip,isSelected:!1,onClick:()=>{window.open(ak(e.url,window.location.href),`_blank`)},icon:(0,O.jsx)(VD,{})})},kk=e=>{let t=U();return(0,O.jsx)(t.LinkToolbar.Root,{className:`bn-toolbar bn-link-toolbar`,children:e.children||(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Dk,{url:e.url,text:e.text,range:e.range,setToolbarOpen:e.setToolbarOpen,setToolbarPositionFrozen:e.setToolbarPositionFrozen}),(0,O.jsx)(Ok,{url:e.url}),(0,O.jsx)(Ek,{range:e.range,setToolbarOpen:e.setToolbarOpen})]})})},Ak=e=>{let t=H(),[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(!1),o=lE(),s=iE(gb),[c,l]=(0,D.useState)(void 0);(0,D.useEffect)(()=>{let e=()=>{let e=s.getLinkAtSelection();e?(l({cursorType:`text`,url:e.mark.attrs.href,text:e.text,range:e.range,element:s.getLinkElementAtPos(e.range.from)}),i||r(!0)):(l(void 0),i||r(!1))},n=e=>{if(c!==void 0&&c.cursorType===`text`||!(e.target instanceof HTMLElement))return;let t=s.getLinkAtElement(e.target);t&&l({cursorType:`mouse`,url:t.mark.attrs.href,text:t.text,range:t.range,element:s.getLinkElementAtPos(t.range.from)})},a=t.onChange(e),u=t.onSelectionChange(e);return o?.addEventListener(`mouseover`,n),()=>{a(),u(),o?.removeEventListener(`mouseover`,n)}},[t,o,s,c,i]);let u=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:n,onOpenChange:(e,n,a)=>{i||(c===void 0||c.cursorType!==`text`||a!==`hover`)&&(a===`escape-key`&&t.focus(),r(e))},placement:`top-start`,middleware:[p(10),S()],...e.floatingUIOptions?.useFloatingOptions},useHoverProps:{enabled:c!==void 0&&c.cursorType===`mouse`,delay:{open:250,close:250},handleClose:d(),...e.floatingUIOptions?.useHoverProps},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:50},...e.floatingUIOptions?.elementProps}}),[t,c,e.floatingUIOptions,n,i]),f=(0,D.useMemo)(()=>c?.element?{element:c.element}:void 0,[c?.element]);if(!t.isEditable)return null;let m=e.linkToolbar||kk;return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(CE,{reference:f,...u,children:c&&(0,O.jsx)(m,{url:c.url,text:c.text,range:c.range,setToolbarOpen:r,setToolbarPositionFrozen:a})})})};function jk(e){return G({tag:`svg`,attr:{viewBox:`0 0 1024 1024`},child:[{tag:`path`,attr:{d:`M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8Z`},child:[]},{tag:`path`,attr:{d:`M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8Z`},child:[]}]})(e)}var Mk=()=>{let e=U(),t=W(),n=H(),r=iE(Cy),i=aE(Sx,{editor:n,selector:e=>e?.block}),a=(0,D.useCallback)(()=>{if(i===void 0)return;let e=i.content;if(e!==void 0&&Array.isArray(e)&&e.length===0)n.setTextCursorPosition(i),r.openSuggestionMenu(`/`);else{let e=n.insertBlocks([{type:`paragraph`}],i,`after`)[0];n.setTextCursorPosition(e),r.openSuggestionMenu(`/`)}},[i,n,r]);return i===void 0?null:(0,O.jsx)(e.SideMenu.Button,{className:`bn-button`,label:t.side_menu.add_block_label,icon:(0,O.jsx)(jk,{size:24,onClick:a,"data-test":`dragHandleAdd`})})};function Nk(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`m7 10 5 5 5-5z`},child:[]}]})(e)}function Pk(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0V0z`},child:[]},{tag:`path`,attr:{d:`M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z`},child:[]}]})(e)}var Fk=e=>{let t=U(),n=mE(),r=H(),i=aE(Sx,{editor:r,selector:e=>e?.block});return i===void 0||!hy(i,r,i.type,{textColor:`string`})&&!hy(i,r,i.type,{backgroundColor:`string`})?null:(0,O.jsxs)(t.Generic.Menu.Root,{position:`right`,sub:!0,portalElement:n,children:[(0,O.jsx)(t.Generic.Menu.Trigger,{sub:!0,children:(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,subTrigger:!0,children:e.children})}),(0,O.jsx)(t.Generic.Menu.Dropdown,{sub:!0,className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,O.jsx)(BO,{iconSize:18,text:hy(i,r,i.type,{textColor:`string`})&&my(r,i.type,{textColor:`string`})?{color:i.props.textColor,setColor:e=>r.updateBlock(i,{type:i.type,props:{textColor:e}})}:void 0,background:hy(i,r,i.type,{backgroundColor:`string`})&&my(r,i.type,{backgroundColor:`string`})?{color:i.props.backgroundColor,setColor:e=>r.updateBlock(i,{props:{backgroundColor:e}})}:void 0})})]})},Ik=e=>{let t=U(),n=H(),r=aE(Sx,{editor:n,selector:e=>e?.block});return r===void 0?null:(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,onClick:()=>{let e=n.getSelection()?.blocks,t=e&&e.some(e=>e.id===r.id)?e:[r];n.removeBlocks(t)},children:e.children})},Lk=e=>{let t=U(),n=H(),r=aE(Sx,{editor:n,selector:e=>e?.block});if(r===void 0||r.type!==`table`||!n.settings.tables.headers)return null;let i=!!r.content.headerRows;return(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:i,onClick:()=>{n.updateBlock(r,{content:{...r.content,headerRows:i?void 0:1}})},children:e.children})},Rk=e=>{let t=U(),n=H(),r=aE(Sx,{editor:n,selector:e=>e?.block});if(r===void 0||r.type!==`table`||!n.settings.tables.headers)return null;let i=!!r.content.headerCols;return(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:i,onClick:()=>{n.updateBlock(r,{content:{...r.content,headerCols:i?void 0:1}})},children:e.children})},zk=e=>{let t=U(),n=W();return(0,O.jsx)(t.Generic.Menu.Dropdown,{className:`bn-menu-dropdown bn-drag-handle-menu`,children:e.children||(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Ik,{children:n.drag_handle.delete_menuitem}),(0,O.jsx)(Fk,{children:n.drag_handle.colors_menuitem}),(0,O.jsx)(Lk,{children:n.drag_handle.header_row_menuitem}),(0,O.jsx)(Rk,{children:n.drag_handle.header_column_menuitem})]})})},Bk=e=>{let t=U(),n=mE(),r=W(),i=iE(Sx),a=aE(Sx,{selector:e=>e?.block});if(a===void 0)return null;let o=e.dragHandleMenu||zk;return(0,O.jsxs)(t.Generic.Menu.Root,{onOpenChange:e=>{e?i.freezeMenu():i.unfreezeMenu()},position:`left`,portalElement:n,children:[(0,O.jsx)(t.Generic.Menu.Trigger,{children:(0,O.jsx)(t.SideMenu.Button,{label:r.side_menu.drag_handle_label,draggable:!0,onDragStart:e=>i.blockDragStart(e,a),onDragEnd:i.blockDragEnd,className:`bn-button`,icon:(0,O.jsx)(Pk,{size:24,"data-test":`dragHandle`})})}),(0,O.jsx)(o,{children:e.children})]})},Vk=e=>{let t=U();return(0,O.jsx)(t.SideMenu.Root,{className:`bn-side-menu`,children:e.children||(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Mk,{}),(0,O.jsx)(Bk,{dragHandleMenu:e.dragHandleMenu})]})})};function Hk(e,t){if(t.type===`heading`)switch(t.props.level){case 1:return 39;case 2:return 27;case 3:return 18.5;default:return 0}return e.schema.blockSpecs[t.type]?.implementation.meta?.fileBlockAccept&&!t.props.url?12:t.type===`file`?4:t.type===`audio`||t.type===`table`?15:0}var Uk=e=>{let t=H(),{show:n,block:r}=aE(Sx,{selector:e=>e===void 0?void 0:{show:e.show,block:e.block}})||{},i=(0,D.useCallback)((e,n,r)=>{let i=!1;return ie(e,n,()=>{i?t.getExtension(Sx)?.hideMenuIfNotFrozen():i=!0},{ancestorScroll:!0,ancestorResize:!1,elementResize:!1,layoutShift:!1})},[t]),a=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:n,placement:`left-start`,middleware:[p({crossAxis:r?Hk(t,r):0})],whileElementsMounted:i,...e.floatingUIOptions?.useFloatingOptions},useDismissProps:{enabled:!1,...e.floatingUIOptions?.useDismissProps},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:20},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,n,r,t,i]),o=e.sideMenu||Vk;return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(yD,{blockId:n?r?.id:void 0,...a,children:r?.id&&(0,O.jsx)(o,{})})})},Wk=({format:e,dictionary:t})=>{let n=t.suggestion_changes.formatting_change;if(e.length===0)return n;let r=t.formatting_toolbar,i=[];for(let t of e){let e=r[t],a=e&&typeof e==`object`&&`tooltip`in e?e.tooltip:void 0;if(typeof a!=`string`)return n;i.push(a)}return i.join(`, `)},Gk=e=>{let t=U(),n=W(),r=(0,D.useMemo)(()=>{let t=n.suggestion_changes,r=e.formatChangeLabel??Wk,i=e.users.join(`, `);if(e.modificationType===`insert`)return t.inserted_by(i);if(e.modificationType===`delete`)return t.deleted_by(i);let a=e.format?r({format:e.format,dictionary:n}):``;return t.formatting_change_by(a,i)},[n,e.formatChangeLabel,e.users,e.modificationType,e.format]);return(0,O.jsx)(t.AttributionTooltip.Root,{className:`bn-suggestion-tooltip`,markClassName:e.className,backgroundColor:e.className?void 0:e.color,children:r})},Kk=e=>{let t=aE(`attribution`,{selector:e=>e}),n=(0,D.useMemo)(()=>t?{element:t.anchor,getBoundingClientRect:()=>{let e=t.anchor.firstElementChild??t.anchor,n=e.getBoundingClientRect();return(n.width||n.height?e:e.firstElementChild??e).getBoundingClientRect()},getClientRects:()=>{let e=t.anchor.firstElementChild??t.anchor,n=e.getBoundingClientRect();return(n.width||n.height?e:e.firstElementChild??e).getClientRects()}}:void 0,[t]),r=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!t,placement:`top-start`,middleware:[u(),p(4),S(),w({padding:4})],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:1e4,pointerEvents:`none`},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,t]),i=e.attributionTooltip||Gk,a=(0,D.useMemo)(()=>t?{color:t.color,className:t.className,modificationType:t.modificationType,contentType:t.contentType,users:t.users,format:t.format,formatChangeLabel:e.formatChangeLabel}:void 0,[t,e.formatChangeLabel]);return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(CE,{reference:n,...r,children:a&&(0,O.jsx)(i,{...a})})})};async function qk(e,t){return(await Nx(e,t)).map(({id:e,onItemClick:t})=>({id:e,onItemClick:t,icon:e}))}function Jk(e){let t=U(),n=W(),{items:r,loadingState:i,selectedIndex:a,onItemClick:o,columns:s}=e,c=i===`loading-initial`||i===`loading`?(0,O.jsx)(t.GridSuggestionMenu.Loader,{className:`bn-grid-suggestion-menu-loader`,columns:s}):null,l=(0,D.useMemo)(()=>{let e=[];for(let n=0;n<r.length;n++){let i=r[n];e.push((0,O.jsx)(t.GridSuggestionMenu.Item,{className:`bn-grid-suggestion-menu-item`,item:i,id:`bn-grid-suggestion-menu-item-${n}`,isSelected:n===a,onClick:()=>o?.(i)},i.id))}return e},[t,r,o,a]);return(0,O.jsxs)(t.GridSuggestionMenu.Root,{id:`bn-grid-suggestion-menu`,columns:s,className:`bn-grid-suggestion-menu`,children:[c,l,l.length===0&&e.loadingState===`loaded`&&(0,O.jsx)(t.GridSuggestionMenu.EmptyItem,{className:`bn-grid-suggestion-menu-empty-item`,columns:s,children:n.suggestion_menu.no_items_title})]})}function Yk(e){return e===void 0?void 0:`bn-suggestion-menu-item-`+e}function Xk(e,t,n,r=3){let i=(0,D.useRef)(0);(0,D.useEffect)(()=>{t!==void 0&&(e.length>0?i.current=t.length:t.length-i.current>r&&n())},[n,r,e.length,t])}function Zk(e,t){let[n,r]=(0,D.useState)([]),[i,a]=(0,D.useState)(!1),o=(0,D.useRef)(void 0),s=(0,D.useRef)(void 0);return(0,D.useEffect)(()=>{let n=e;o.current=e,a(!0),t(e).then(e=>{o.current===n&&(r(e),a(!1),s.current=n)})},[e,t]),{items:n||[],usedQuery:s.current,loadingState:s.current===void 0?`loading-initial`:i?`loading`:`loaded`}}function Qk(e,t,n,r,i){let a=lE(e),[o,s]=(0,D.useState)(0);return(0,D.useEffect)(()=>{let e=e=>(e.key===`ArrowLeft`&&(e.preventDefault(),n.length&&s((o-1+n.length)%n.length)),e.key===`ArrowRight`&&(e.preventDefault(),n.length&&s((o+1+n.length)%n.length)),e.key===`ArrowUp`?(e.preventDefault(),n.length&&s((o-r+n.length)%n.length),!0):e.key===`ArrowDown`?(e.preventDefault(),n.length&&s((o+r)%n.length),!0):e.key===`Enter`&&!e.isComposing&&(e.stopPropagation(),e.preventDefault(),n.length&&i?.(n[o]),!0));return a?.addEventListener(`keydown`,e,!0),()=>{a?.removeEventListener(`keydown`,e,!0)}},[a,n,o,i,r,r!==void 0&&r>1]),(0,D.useEffect)(()=>{s(0)},[t]),{selectedIndex:n.length===0?void 0:o}}function $k(e){let t=eE().setContentEditableProps,n=H(),{getItems:r,gridSuggestionMenuComponent:i,query:a,clearQuery:o,closeMenu:s,onItemClick:c,columns:l}=e,u=(0,D.useCallback)(e=>{s(),o(),c?.(e)},[c,s,o]),{items:d,usedQuery:f,loadingState:p}=Zk(a,r);Xk(d,f,s);let{selectedIndex:m}=Qk(n,a,d,l,u);return(0,D.useEffect)(()=>(t(e=>({...e,"aria-expanded":!0,"aria-controls":`bn-suggestion-menu`})),()=>{t(e=>({...e,"aria-expanded":!1,"aria-controls":void 0}))}),[t]),(0,D.useEffect)(()=>(t(e=>({...e,"aria-activedescendant":Yk(m)})),()=>{t(e=>({...e,"aria-activedescendant":void 0}))}),[t,m]),(0,O.jsx)(i,{items:d,onItemClick:u,loadingState:p,selectedIndex:m,columns:l})}function eA(e){let t=H(),n=lE(),{triggerCharacter:r,gridSuggestionMenuComponent:i,columns:a,shouldOpen:o,minQueryLength:s,onItemClick:c,getItems:l}=e,u=(0,D.useMemo)(()=>c||(e=>{e.onItemClick(t)}),[t,c]),d=(0,D.useMemo)(()=>l||(async e=>await qk(t,e)),[t,l]),f=iE(Cy);(0,D.useEffect)(()=>{f.addSuggestionMenu({triggerCharacter:r,shouldOpen:o})},[f,r,o]);let m=aE(Cy),h=aE(Cy,{selector:e=>({element:n?.firstChild||void 0,getBoundingClientRect:()=>e?.referencePos||new DOMRect})}),_=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:m?.show&&m?.triggerCharacter===r,onOpenChange:e=>{e||f.closeMenu()},placement:`bottom-start`,middleware:[p(10),g({allowedPlacements:[`bottom-start`,`top-start`],padding:10}),w(),T({apply({elements:e,availableHeight:t}){e.floating.style.maxHeight=`${Math.max(0,t)}px`},padding:10})],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{onMouseDownCapture:e=>e.preventDefault(),style:{zIndex:70},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,m?.show,m?.triggerCharacter,f,r]);return!m||!m.ignoreQueryLength&&s&&(m.query.startsWith(` `)||m.query.length<s)?null:(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(CE,{reference:h,..._,children:r&&(0,O.jsx)($k,{query:m.query,closeMenu:f.closeMenu,clearQuery:f.clearQuery,getItems:d,columns:a,gridSuggestionMenuComponent:i||Jk,onItemClick:u})})})}function tA(e){let t=U(),n=W(),{items:r,loadingState:i,selectedIndex:a,onItemClick:o}=e,s=i===`loading-initial`||i===`loading`?(0,O.jsx)(t.SuggestionMenu.Loader,{className:`bn-suggestion-menu-loader`}):null,c=(0,D.useMemo)(()=>{let e,n=[];for(let i=0;i<r.length;i++){let s=r[i];s.group!==e&&(e=s.group,n.push((0,O.jsx)(t.SuggestionMenu.Label,{className:`bn-suggestion-menu-label`,children:e},e))),n.push((0,O.jsx)(t.SuggestionMenu.Item,{className:V(`bn-suggestion-menu-item`,s.size===`small`?`bn-suggestion-menu-item-small`:``),item:s,id:`bn-suggestion-menu-item-${i}`,isSelected:i===a,onClick:()=>o?.(s)},s.title))}return n},[t,r,o,a]);return(0,O.jsxs)(t.SuggestionMenu.Root,{id:`bn-suggestion-menu`,className:`bn-suggestion-menu`,children:[c,c.length===0&&(e.loadingState===`loading`||e.loadingState===`loaded`)&&(0,O.jsx)(t.SuggestionMenu.EmptyItem,{className:`bn-suggestion-menu-item`,children:n.suggestion_menu.no_items_title}),s]})}function nA(e,t){let[n,r]=(0,D.useState)(0);return{selectedIndex:n,setSelectedIndex:r,handler:i=>{if(i.key===`ArrowUp`)return i.preventDefault(),e.length&&r((n-1+e.length)%e.length),!0;if(i.key===`ArrowDown`)return i.preventDefault(),e.length&&r((n+1)%e.length),!0;if(i.key===`PageUp`)return i.preventDefault(),e.length&&r(0),!0;if(i.key===`PageDown`)return i.preventDefault(),e.length&&r(e.length-1),!0;let a=rA(i)?i.nativeEvent.isComposing:i.isComposing;return i.key===`Enter`&&!a&&(i.preventDefault(),i.stopPropagation(),e.length&&t?.(e[n]),!0)}}}function rA(e){return e.nativeEvent!==void 0}function iA(e,t,n,r,i){let a=lE(),{selectedIndex:o,setSelectedIndex:s,handler:c}=nA(n,r);return(0,D.useEffect)(()=>{let e=i||a;return e?.addEventListener(`keydown`,c,!0),()=>{e?.removeEventListener(`keydown`,c,!0)}},[a,n,o,r,i,c]),(0,D.useEffect)(()=>{s(0)},[t,s]),{selectedIndex:n.length===0?void 0:o}}function aA(e){let t=eE().setContentEditableProps,n=H(),{getItems:r,suggestionMenuComponent:i,query:a,clearQuery:o,closeMenu:s,onItemClick:c}=e,l=(0,D.useCallback)(e=>{s(),o(),c?.(e)},[c,s,o]),{items:u,usedQuery:d,loadingState:f}=Zk(a,r);Xk(u,d,s);let{selectedIndex:p}=iA(n,a,u,l);return(0,D.useEffect)(()=>(t(e=>({...e,"aria-expanded":!0,"aria-controls":`bn-suggestion-menu`})),()=>{t(e=>({...e,"aria-expanded":!1,"aria-controls":void 0}))}),[t]),(0,D.useEffect)(()=>(t(e=>({...e,"aria-activedescendant":Yk(p)})),()=>{t(e=>({...e,"aria-activedescendant":void 0}))}),[t,p]),(0,O.jsx)(i,{items:u,onItemClick:l,loadingState:f,selectedIndex:p})}var oA={heading:bO,heading_2:yO,heading_3:vO,heading_4:_O,heading_5:gO,heading_6:hO,toggle_heading:bO,toggle_heading_2:yO,toggle_heading_3:vO,quote:rO,toggle_list:JD,numbered_list:sO,bullet_list:oO,check_list:cO,paragraph:eO,table:tO,image:ZD,video:QD,audio:qD,file:kO,emoji:RD,code_block:SO,divider:zD};function sA(e){return Ey(e).map(e=>{let t=oA[e.key];return{...e,icon:(0,O.jsx)(t,{size:18})}})}function cA(e){let t=H(),n=lE(),{triggerCharacter:r,suggestionMenuComponent:i,shouldOpen:a,minQueryLength:o,onItemClick:s,getItems:c}=e,l=(0,D.useMemo)(()=>s||(e=>{e.onItemClick(t)}),[t,s]),u=(0,D.useMemo)(()=>c||(async e=>Dy(sA(t),e)),[t,c]),d=iE(Cy);(0,D.useEffect)(()=>{d.addSuggestionMenu({triggerCharacter:r,shouldOpen:a})},[d,r,a]);let f=aE(Cy),m=aE(Cy,{selector:e=>({element:n?.firstChild||void 0,getBoundingClientRect:()=>e?.referencePos||new DOMRect})}),h=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:f?.show&&f?.triggerCharacter===r,onOpenChange:e=>{e||d.closeMenu()},placement:`bottom-start`,middleware:[p(10),g({allowedPlacements:[`bottom-start`,`top-start`],padding:10}),w(),T({apply({elements:e,availableHeight:t}){e.floating.style.maxHeight=`${Math.max(0,t)}px`},padding:10})],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{onMouseDownCapture:e=>e.preventDefault(),style:{zIndex:80},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,f?.show,f?.triggerCharacter,d,r]);return!f||!f.ignoreQueryLength&&o&&(f.query.startsWith(` `)||f.query.length<o)?null:(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(CE,{reference:m,...h,children:r&&(0,O.jsx)(aA,{query:f.query,closeMenu:d.closeMenu,clearQuery:d.clearQuery,getItems:u,suggestionMenuComponent:i||tA,onItemClick:l})})})}var lA=(e,t=.3)=>{let n=Math.floor(e)+t,r=Math.ceil(e)-t;return e>=n&&e<=r?Math.round(e):e<n?Math.floor(e):Math.ceil(e)},uA=e=>{let t=U(),n=H(),r=iE(Hx),i=aE(Hx,{selector:e=>e?.block}),a=(0,D.useRef)(!1),[o,s]=(0,D.useState)(),c=(0,D.useCallback)(t=>{r.freezeHandles(),e.hideOtherElements(!0),i&&(s({originalContent:i.content,originalCroppedContent:{rows:r.cropEmptyRowsOrColumns(i,e.orientation===`addOrRemoveColumns`?`columns`:`rows`)},startPos:e.orientation===`addOrRemoveColumns`?t.clientX:t.clientY}),a.current=!1,t.preventDefault())},[i,e,r]),l=(0,D.useCallback)(()=>{!i||a.current||n.updateBlock(i,{type:`table`,content:{...i.content,rows:e.orientation===`addOrRemoveColumns`?r.addRowsOrColumns(i,`columns`,1):r.addRowsOrColumns(i,`rows`,1)}})},[i,n,e.orientation,r]);return(0,D.useEffect)(()=>{let t=t=>{if(!i)return;if(!o)throw Error(`editingState is undefined`);a.current=!0;let s=(e.orientation===`addOrRemoveColumns`?t.clientX:t.clientY)-o.startPos,c=e.orientation===`addOrRemoveColumns`?o.originalCroppedContent.rows[0]?.cells.length??0:o.originalCroppedContent.rows.length,l=e.orientation===`addOrRemoveColumns`?o.originalContent.rows[0]?.cells.length??0:o.originalContent.rows.length,u=e.orientation===`addOrRemoveColumns`?i.content.rows[0].cells.length:i.content.rows.length,d=l+lA(s/(e.orientation===`addOrRemoveColumns`?120:31),.3);d>=c&&d>0&&d!==u&&(n.updateBlock(i,{type:`table`,content:{...i.content,rows:e.orientation===`addOrRemoveColumns`?r.addRowsOrColumns({type:`table`,content:o.originalCroppedContent},`columns`,d-c):r.addRowsOrColumns({type:`table`,content:o.originalCroppedContent},`rows`,d-c)}}),i.content&&n.setTextCursorPosition(i))};return o&&window.addEventListener(`mousemove`,t),()=>{window.removeEventListener(`mousemove`,t)}},[i,o,n,e.orientation,r]),(0,D.useEffect)(()=>{let t=()=>{e.hideOtherElements(!1),r.unfreezeHandles(),s(void 0)};return o&&window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mouseup`,t)}},[o,e,r]),n.isEditable?(0,O.jsx)(t.TableHandle.ExtendButton,{className:V(`bn-extend-button`,e.orientation===`addOrRemoveColumns`?`bn-extend-button-add-remove-columns`:`bn-extend-button-add-remove-rows`,o===null?``:`bn-extend-button-editing`),onClick:l,onMouseDown:c,children:e.children||(0,O.jsx)(KD,{size:18,"data-test":`extendButton`})}):null},dA=e=>{let t=U(),n=mE(),r=W(),i=H(),{block:a,colIndex:o,rowIndex:s}=aE(Hx,{selector:e=>({block:e?.block,colIndex:e?.colIndex,rowIndex:e?.rowIndex})}),c=(e,t)=>{if(a===void 0||o===void 0||s===void 0)return;let n=a.content.rows.map(e=>({...e,cells:e.cells.map(e=>og(e))}));t===`text`?n[s].cells[o].props.textColor=e:n[s].cells[o].props.backgroundColor=e,i.updateBlock(a,{type:`table`,content:{...a.content,rows:n}}),i.setTextCursorPosition(a)};if(a===void 0||o===void 0||s===void 0)return null;let l=a.content.rows[s]?.cells?.[o];return!l||i.settings.tables.cellTextColor===!1&&i.settings.tables.cellBackgroundColor===!1?null:(0,O.jsxs)(t.Generic.Menu.Root,{position:`right`,sub:!0,portalElement:n,children:[(0,O.jsx)(t.Generic.Menu.Trigger,{sub:!0,children:(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,subTrigger:!0,children:e.children||r.drag_handle.colors_menuitem})}),(0,O.jsx)(t.Generic.Menu.Dropdown,{sub:!0,className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,O.jsx)(BO,{iconSize:18,text:i.settings.tables.cellTextColor?{color:cg(l)?l.props.textColor:`default`,setColor:e=>c(e,`text`)}:void 0,background:i.settings.tables.cellBackgroundColor?{color:cg(l)?l.props.backgroundColor:`default`,setColor:e=>c(e,`background`)}:void 0})})]})},fA=()=>{let e=U(),t=W(),n=H(),r=iE(Hx),{block:i,colIndex:a,rowIndex:o}=aE(Hx,{selector:e=>({block:e?.block,colIndex:e?.colIndex,rowIndex:e?.rowIndex})});if(i===void 0||a===void 0||o===void 0)return null;let s=i.content.rows[o]?.cells?.[a];return!s||!cg(s)||ug(s)===1&&lg(s)===1||!n.settings.tables.splitCells?null:(0,O.jsx)(e.Generic.Menu.Item,{onClick:()=>{r.splitCell({row:o,col:a})},children:t.table_handle.split_cell_menuitem})},pA=e=>{let t=U();return(0,O.jsx)(t.Generic.Menu.Dropdown,{className:`bn-menu-dropdown bn-table-handle-menu`,children:e.children||(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(fA,{}),(0,O.jsx)(dA,{})]})})},mA=e=>{let t=U(),n=mE(),r=H(),i=iE(Hx),a=e.tableCellMenu||pA;return!r.settings.tables.splitCells&&!r.settings.tables.cellBackgroundColor&&!r.settings.tables.cellTextColor?null:(0,O.jsxs)(t.Generic.Menu.Root,{onOpenChange:t=>{t?(i.freezeHandles(),e.hideOtherElements(!0)):(i.unfreezeHandles(),e.hideOtherElements(!1),r.focus())},position:`right`,portalElement:n,children:[(0,O.jsx)(t.Generic.Menu.Trigger,{children:(0,O.jsx)(t.Generic.Menu.Button,{className:`bn-table-cell-handle`,children:e.children||(0,O.jsx)(Nk,{size:12,"data-test":`tableCellHandle`})})}),(0,O.jsx)(a,{})]})},hA=e=>{let t=U(),n=W(),r=iE(Hx),i=aE(Hx,{selector:t=>e.orientation===`column`?t?.colIndex:t?.rowIndex});return r===void 0||i===void 0?null:(0,O.jsx)(t.Generic.Menu.Item,{onClick:()=>{r.addRowOrColumn(i,e.orientation===`row`?{orientation:`row`,side:e.side}:{orientation:`column`,side:e.side})},children:n.table_handle[`add_${e.side}_menuitem`]})},gA=e=>{let t=U(),n=W(),r=iE(Hx),i=aE(Hx,{selector:t=>e.orientation===`column`?t?.colIndex:t?.rowIndex});return r===void 0||i===void 0?null:(0,O.jsx)(t.Generic.Menu.Item,{onClick:()=>r.removeRowOrColumn(i,e.orientation),children:e.orientation===`row`?n.table_handle.delete_row_menuitem:n.table_handle.delete_column_menuitem})},_A=e=>{let t=U(),n=mE(),r=W(),i=H(),a=iE(Hx),{block:o,index:s}=aE(Hx,{selector:t=>({block:t?.block,index:e.orientation===`column`?t?.colIndex:t?.rowIndex})}),c=(0,D.useMemo)(()=>a===void 0||o===void 0||s===void 0?[]:e.orientation===`row`?a.getCellsAtRowHandle(o,s):a.getCellsAtColumnHandle(o,s),[o,s,e.orientation,a]),l=(e,t)=>{if(o===void 0)return;let n=o.content.rows.map(e=>({...e,cells:e.cells.map(e=>og(e))}));c.forEach(({row:r,col:i})=>{t===`text`?n[r].cells[i].props.textColor=e:n[r].cells[i].props.backgroundColor=e}),i.updateBlock(o,{type:`table`,content:{...o.content,rows:n}}),i.setTextCursorPosition(o)};if(!c||!c[0]||!a||i.settings.tables.cellTextColor===!1&&i.settings.tables.cellBackgroundColor===!1)return null;let u=og(c[0].cell);return(0,O.jsxs)(t.Generic.Menu.Root,{position:`right`,sub:!0,portalElement:n,children:[(0,O.jsx)(t.Generic.Menu.Trigger,{sub:!0,children:(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,subTrigger:!0,children:e.children||r.drag_handle.colors_menuitem})}),(0,O.jsx)(t.Generic.Menu.Dropdown,{sub:!0,className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,O.jsx)(BO,{iconSize:18,text:i.settings.tables.cellTextColor?{color:c.every(({cell:e})=>cg(e)&&e.props.textColor===u.props.textColor)?u.props.textColor:`default`,setColor:e=>{l(e,`text`)}}:void 0,background:i.settings.tables.cellBackgroundColor?{color:c.every(({cell:e})=>cg(e)&&e.props.backgroundColor===u.props.backgroundColor)?u.props.backgroundColor:`default`,setColor:e=>l(e,`background`)}:void 0})})]})},vA=e=>{let t=U(),n=W(),r=H(),i=iE(Hx),{block:a,index:o}=aE(Hx,{selector:t=>({block:t?.block,index:e.orientation===`column`?t?.colIndex:t?.rowIndex})});if(i===void 0||a===void 0||o!==0||e.orientation!==`row`||!r.settings.tables.headers)return null;let s=!!a.content.headerRows;return(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:s,onClick:()=>{r.updateBlock(a,{...a,content:{...a.content,headerRows:s?void 0:1}})},children:n.drag_handle.header_row_menuitem})},yA=e=>{let t=U(),n=W(),r=H(),i=iE(Hx),a=aE(Hx,{selector:e=>e?.block}),o=aE(Hx,{selector:t=>e.orientation===`column`?t?.colIndex:t?.rowIndex});if(!i||o!==0||!a||e.orientation!==`column`||!r.settings.tables.headers)return null;let s=!!a.content.headerCols;return(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:s,onClick:()=>{r.updateBlock(a,{...a,content:{...a.content,headerCols:s?void 0:1}})},children:n.drag_handle.header_column_menuitem})},bA=e=>{let t=U();return(0,O.jsx)(t.Generic.Menu.Dropdown,{className:`bn-table-handle-menu`,children:e.children||(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(gA,{orientation:e.orientation}),(0,O.jsx)(hA,{orientation:e.orientation,side:e.orientation===`row`?`above`:`left`}),(0,O.jsx)(hA,{orientation:e.orientation,side:e.orientation===`row`?`below`:`right`}),(0,O.jsx)(vA,{orientation:e.orientation}),(0,O.jsx)(yA,{orientation:e.orientation}),(0,O.jsx)(_A,{orientation:e.orientation})]})})},xA=e=>{let t=H(),n=U(),r=mE(),[i,a]=(0,D.useState)(!1),o=e.tableHandleMenu||bA,s=iE(Hx),c=aE(Hx),l=(0,D.useMemo)(()=>!s||!c||!c.block||c.block.type!==`table`?!1:e.orientation===`column`?s.getCellsAtColumnHandle(c.block,c.colIndex).every(({cell:e})=>lg(e)===1):s.getCellsAtRowHandle(c.block,c.rowIndex).every(({cell:e})=>ug(e)===1),[e.orientation,c,s]);return c?(0,O.jsxs)(n.Generic.Menu.Root,{onOpenChange:n=>{n?(s.freezeHandles(),e.hideOtherElements(!0)):(s.unfreezeHandles(),e.hideOtherElements(!1),t.focus())},position:`right`,portalElement:r,children:[(0,O.jsx)(n.Generic.Menu.Trigger,{children:(0,O.jsx)(n.TableHandle.Root,{className:V(`bn-table-handle`,i?`bn-table-handle-dragging`:``,l?``:`bn-table-handle-not-draggable`),draggable:l,onDragStart:t=>{a(!0),e.hideOtherElements(!0),e.orientation===`column`?s.colDragStart(t):s.rowDragStart(t)},onDragEnd:()=>{s.dragEnd(),e.hideOtherElements(!1),a(!1)},style:e.orientation===`column`?{transform:`rotate(0.25turn)`}:void 0,children:e.children||(0,O.jsx)(Pk,{size:24,"data-test":`tableHandle`})})}),(0,O.jsx)(o,{orientation:e.orientation})]}):null},SA=e=>{let t=H(),[n,r]=(0,D.useState)(),i=aE(Hx),a=(0,D.useMemo)(()=>{let e={};if(i===void 0)return{};let n=R_(i.block.id,t.prosemirrorState.doc);if(!n)return{};let r=n.posBeforeNode+1,a=t.prosemirrorView.domAtPos(r+1).node;if(!(a instanceof Element))return{};if(e.tableReference={element:a},i.rowIndex===void 0||i.colIndex===void 0)return e;let o=t.prosemirrorState.doc.resolve(r+1).posAtIndex(i.rowIndex),s=t.prosemirrorState.doc.resolve(o+1).posAtIndex(i.colIndex),c=t.prosemirrorView.domAtPos(s+1).node;return c instanceof Element?(e.cellReference={element:c},e.rowReference={element:a,getBoundingClientRect:()=>{let e=a.getBoundingClientRect(),t=c.getBoundingClientRect();return new DOMRect(e.x,i.draggingState&&i.draggingState.draggedCellOrientation===`row`?i.draggingState.mousePos-t.height/2:t.y,e.width,t.height)}},e.columnReference={element:a,getBoundingClientRect:()=>{let e=a.getBoundingClientRect(),t=c.getBoundingClientRect();return new DOMRect(i.draggingState&&i.draggingState.draggedCellOrientation===`col`?i.draggingState.mousePos-t.width/2:t.x,e.y,t.width,e.height)}},e):{}},[t,i]),o=(0,D.useCallback)((e,n,r)=>{let i=!1;return ie(e,n,()=>{i?t.getExtension(Hx)?.hideHandlesIfNotFrozen():i=!0},{ancestorScroll:!0,ancestorResize:!1,elementResize:!1,layoutShift:!1})},[t]),s=(0,D.useMemo)(()=>i===void 0?void 0:{rowTableHandle:{useFloatingOptions:{open:i.show&&i.rowIndex!==void 0&&(!n||n===`rowTableHandle`),placement:`left`,middleware:[p(-10)],whileElementsMounted:o},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},columnTableHandle:{useFloatingOptions:{open:i.show&&i.colIndex!==void 0&&(!n||n===`columnTableHandle`),placement:`top`,middleware:[p(-12)],whileElementsMounted:o},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},tableCellHandle:{useFloatingOptions:{open:i.show&&i.rowIndex!==void 0&&i.colIndex!==void 0&&(!n||n===`tableCellHandle`),placement:`top-end`,middleware:[p({mainAxis:-15,crossAxis:-1})],whileElementsMounted:o},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},extendRowsButton:{useFloatingOptions:{open:i.show&&i.showAddOrRemoveRowsButton&&(!n||n===`extendRowsButton`),placement:`bottom`,whileElementsMounted:o,middleware:[T({apply({rects:e,elements:t}){Object.assign(t.floating.style,{width:`${e.reference.width}px`})}})]},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},extendColumnsButton:{useFloatingOptions:{open:i.show&&i.showAddOrRemoveColumnsButton&&(!n||n===`extendColumnsButton`),placement:`right`,whileElementsMounted:o,middleware:[T({apply({rects:e,elements:t}){Object.assign(t.floating.style,{height:`${e.reference.height}px`})}})]},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}}},[n,i,o]);if(!i)return null;let c=e.tableHandle||xA,l=e.extendButton||uA,u=e.tableCellHandle||mA;return(0,O.jsxs)(gE,{target:e.portalElement,children:[(0,O.jsx)(CE,{reference:a?.rowReference,...s?.rowTableHandle,children:i.show&&i.rowIndex!==void 0&&(!n||n===`rowTableHandle`)&&(0,O.jsx)(c,{orientation:`row`,hideOtherElements:e=>r(e?`rowTableHandle`:void 0)})}),(0,O.jsx)(CE,{reference:a?.columnReference,...s?.columnTableHandle,children:i.show&&i.colIndex!==void 0&&(!n||n===`columnTableHandle`)&&(0,O.jsx)(c,{orientation:`column`,hideOtherElements:e=>r(e?`columnTableHandle`:void 0)})}),(0,O.jsx)(CE,{reference:a?.cellReference,...s?.tableCellHandle,children:i.show&&i.rowIndex!==void 0&&i.colIndex!==void 0&&(!n||n===`tableCellHandle`)&&(0,O.jsx)(u,{hideOtherElements:e=>r(e?`tableCellHandle`:void 0)})}),(0,O.jsx)(CE,{reference:a?.tableReference,...s?.extendRowsButton,children:i.show&&i.showAddOrRemoveRowsButton&&(!n||n===`extendRowsButton`)&&(0,O.jsx)(l,{orientation:`addOrRemoveRows`,hideOtherElements:e=>r(e?`extendRowsButton`:void 0)})}),(0,O.jsx)(CE,{reference:a?.tableReference,...s?.extendColumnsButton,children:i.show&&i.showAddOrRemoveColumnsButton&&(!n||n===`extendColumnsButton`)&&(0,O.jsx)(l,{orientation:`addOrRemoveColumns`,hideOtherElements:e=>r(e?`extendColumnsButton`:void 0)})})]})};function CA(e){if(e!==void 0){if(typeof e==`string`){if(typeof document>`u`)return;let t=document.querySelector(e);if(!t){console.warn(`[BlockNote] portalElements selector "${e}" did not match any element`);return}return t}return e}}var wA=(0,D.lazy)(()=>Promise.resolve().then(()=>ej)),TA=(0,D.lazy)(()=>Promise.resolve().then(()=>aj));function EA(e){let t=H();if(!t)throw Error(`BlockNoteDefaultUI must be used within a BlockNoteContext.Provider`);let n=e.portalElements,r=CA(n?.formattingToolbar),i=CA(n?.linkToolbar),a=CA(n?.slashMenu),o=CA(n?.emojiPicker),s=CA(n?.sideMenu),c=CA(n?.filePanel),l=CA(n?.tableHandles),u=CA(n?.comments),d=CA(n?.attributionTooltip);return(0,O.jsxs)(O.Fragment,{children:[t.getExtension(vy)&&e.formattingToolbar!==!1&&(0,O.jsx)(Tk,{portalElement:r}),t.getExtension(gb)&&e.linkToolbar!==!1&&(0,O.jsx)(Ak,{portalElement:i}),t.getExtension(Cy)&&e.slashMenu!==!1&&(0,O.jsx)(cA,{triggerCharacter:`/`,shouldOpen:e=>!e.selection.$from.parent.type.isInGroup(`tableContent`),portalElement:a}),t.getExtension(Cy)&&e.emojiPicker!==!1&&(0,O.jsx)(eA,{triggerCharacter:`:`,columns:10,minQueryLength:2,portalElement:o}),t.getExtension(Sx)&&e.sideMenu!==!1&&(0,O.jsx)(Uk,{portalElement:s}),t.getExtension(rv)&&e.filePanel!==!1&&(0,O.jsx)(CD,{portalElement:c}),t.getExtension(Hx)&&e.tableHandles!==!1&&(0,O.jsx)(SA,{portalElement:l}),t.getExtension(LE)&&e.comments!==!1&&(0,O.jsxs)(D.Suspense,{children:[(0,O.jsx)(wA,{portalElement:u}),(0,O.jsx)(TA,{portalElement:u})]}),t.getExtension(`attribution`)&&e.attributionTooltip!==!1&&(0,O.jsx)(Kk,{portalElement:d})]})}var DA=!1;function OA(){typeof process<`u`||DA||typeof document>`u`||(DA=!0,(document.querySelector(`meta[name="viewport"]`)?.getAttribute(`content`)??``).replace(/\s/g,``).includes(`interactive-widget=resizes-content`)||console.warn(`[BlockNote] This page's viewport meta tag is missing "interactive-widget=resizes-content" in its content attribute. Add it to ensure proper mobile functionality, e.g. <meta name="viewport" content="width=device-width, initial-scale=1, interactive-widget=resizes-content">. See https://www.blocknotejs.org/docs/getting-started#mobile-compatibility for more information`))}function kA(e,t){let n=eE();t||=n?.editor;let r=(0,D.useRef)(e);oE(()=>{r.current=e}),(0,D.useEffect)(()=>{if(!t)throw Error(`'editor' is required, either from BlockNoteContext or as a function argument`);return t.onChange((...e)=>r.current(...e))},[t])}function AA(e,t,n){let r=eE();t||=r?.editor;let i=(0,D.useRef)(e);oE(()=>{i.current=e}),(0,D.useEffect)(()=>{if(!t)throw Error(`'editor' is required, either from BlockNoteContext or as a function argument`);return t.onSelectionChange(e=>i.current(e),n)},[t,n])}var jA=()=>{let e=(0,D.useMemo)(()=>window.matchMedia?.(`(prefers-color-scheme: dark)`),[]),t=(0,D.useMemo)(()=>window.matchMedia?.(`(prefers-color-scheme: light)`),[]),n=e?.matches,r=t?.matches,[i,a]=(0,D.useState)(n?`dark`:r?`light`:`no-preference`);return(0,D.useEffect)(()=>{a(n?`dark`:r?`light`:`no-preference`)},[n,r]),(0,D.useEffect)(()=>{if(typeof e?.addEventListener==`function`){let n=({matches:e})=>e&&a(`dark`),r=({matches:e})=>e&&a(`light`);return e?.addEventListener(`change`,n),t?.addEventListener(`change`,r),()=>{e?.removeEventListener(`change`,n),t?.removeEventListener(`change`,r)}}{let n=()=>a(e.matches?`dark`:t.matches?`light`:`no-preference`);return e?.addEventListener(`change`,n),t?.addEventListener(`change`,n),()=>{e?.removeEventListener(`change`,n),t?.removeEventListener(`change`,n)}}},[e,t]),window.matchMedia,i};function MA(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:(0,RE.createPortal)(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var NA=({contentComponent:e})=>{let t=(0,D.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,O.jsx)(O.Fragment,{children:Object.values(t)})},PA=(0,D.forwardRef)((e,t)=>{let[n,r]=(0,D.useState)();return(0,D.useImperativeHandle)(t,()=>(e,t)=>{(0,RE.flushSync)(()=>{r({node:e,container:t})}),r(void 0)},[]),(0,O.jsx)(O.Fragment,{children:n&&(0,RE.createPortal)(n.node,n.container)})}),FA=()=>{};function IA(e,t){let{editor:n,className:r,theme:i,children:a,editable:o,onSelectionChange:s,onChange:c,formattingToolbar:l,linkToolbar:u,slashMenu:d,emojiPicker:f,sideMenu:p,filePanel:m,tableHandles:h,comments:g,portalElements:_,applyThemedRoot:v,autoFocus:y,renderEditor:b=!0,...x}=e,S=(0,D.useMemo)(()=>CA(_?.default),[_?.default]),[C,w]=(0,D.useState)(),T=eE(),E=jA(),ee=T?.colorSchemePreference||E,te=i||(ee===`dark`?`dark`:`light`),ne=U(),re=(0,D.useMemo)(()=>({formattingToolbar:ne?l:!1,linkToolbar:ne?u:!1,sideMenu:ne?p:!1,slashMenu:ne?d:!1,filePanel:ne?m:!1,tableHandles:ne?h:!1,emojiPicker:ne?f:!1,comments:ne?g:!1,portalElements:_}),[g,ne,f,m,l,u,p,d,h,_]);kA(c||FA,n),AA(s||FA,n);let ie=(0,D.useCallback)(e=>{n.elementRenderer=e},[n]),ae=(0,D.useCallback)(e=>{e.className=V(`bn-root`,te,r||``),e.setAttribute(`data-color-scheme`,te),v?.(e)},[te,r,v]),oe=(0,D.useMemo)(()=>({...T,editor:n,setContentEditableProps:w,colorSchemePreference:te}),[T,n,te]),se=(0,D.useMemo)(()=>({editorProps:{autoFocus:y,contentEditableProps:C,editable:o},defaultUIProps:re,applyThemedRoot:ae}),[y,C,o,re,ae]);return(0,O.jsx)($T.Provider,{value:oe,children:(0,O.jsxs)(uE.Provider,{value:se,children:[(0,O.jsx)(PA,{ref:ie}),(0,O.jsx)(LA,{className:r,renderEditor:b,editorColorScheme:te,defaultPortalElement:S,ref:t,...x,children:a})]})})}var LA=D.forwardRef(({className:e,renderEditor:t,editorColorScheme:n,defaultPortalElement:r,children:i,...a},o)=>(0,O.jsx)(`div`,{className:V(`bn-root`,`bn-container`,n,e),"data-color-scheme":n,...a,ref:o,children:(0,O.jsx)(hE,{children:(0,O.jsx)(gE,{target:r,children:t?(0,O.jsx)(zA,{children:i}):i})})})),RA=D.forwardRef(IA),zA=e=>{let t=dE(),n=H(),r=(0,D.useMemo)(()=>MA(),[]);(0,D.useEffect)(()=>{OA()},[]);let i=(0,D.useCallback)(e=>{n.isEditable=t.editorProps.editable!==!1,n._tiptapEditor.contentComponent=r,e?n.mount(e):n.unmount()},[t.editorProps.editable,n,r]);return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(NA,{contentComponent:r}),(0,O.jsx)(BA,{...t.editorProps,...e,mount:i}),(0,O.jsx)(EA,{...t.defaultUIProps}),e.children]})},BA=e=>{let{autoFocus:t,mount:n,contentEditableProps:r}=e;return(0,O.jsx)(`div`,{"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"data-bn-autofocus":t,ref:n,...r})};function VA(e,t){let n,r=document.createElement(`div`),i;if(t?.elementRenderer)t.elementRenderer(e(e=>n=e||void 0),r);else{if(!t?.headless)throw Error(`elementRenderer not available, expected headless editor`);i=(0,gD.createRoot)(r),(0,RE.flushSync)(()=>{i.render(e(e=>n=e||void 0))})}if(!r.childElementCount)return console.warn(`ReactInlineContentSpec: renderHTML() failed`),{dom:document.createElement(`span`)};n?.setAttribute(`data-tmp-find`,`true`);let a=r.cloneNode(!0),o=a.firstElementChild,s=a.querySelector(`[data-tmp-find]`);return s?.removeAttribute(`data-tmp-find`),i?.unmount(),{dom:o,contentDOM:s||void 0}}var HA;async function UA(){return HA||(HA=(async()=>{let[e,t]=await Promise.all([ue(()=>import(`./module-CvVAOmRW.js`),[]),ue(()=>import(`./native-Cqs-2kTC.js`),[])]),n=`default`in e?e.default:e,r=`default`in t?t.default:t;return await n.init({data:r}),{emojiMart:n,emojiData:r}})(),HA)}function WA(e){let t=(0,D.useRef)(null),n=(0,D.useRef)(null);return n.current&&n.current.update(e),(0,D.useEffect)(()=>((async()=>{let{emojiMart:r}=await UA();n.current=new r.Picker({...e,ref:t})})(),()=>{n.current=null}),[]),D.createElement(`div`,{ref:t})}var GA=e=>{let[t,n]=(0,D.useState)(!1),r=U(),i=eE(),a=mE();return(0,O.jsxs)(r.Generic.Popover.Root,{open:t,portalElement:a,children:[(0,O.jsx)(r.Generic.Popover.Trigger,{children:(0,O.jsx)(`div`,{onClick:r=>{r.preventDefault(),r.stopPropagation(),n(!t),e.onOpenChange?.(!t)},style:{display:`flex`,justifyContent:`center`,alignItems:`center`},children:e.children})}),(0,O.jsx)(r.Generic.Popover.Content,{className:`bn-emoji-picker-popover`,variant:`panel-popover`,children:(0,O.jsx)(WA,{perLine:7,onClickOutside:()=>{n(!1),e.onOpenChange?.(!1)},onEmojiSelect:t=>{e.onEmojiSelect(t),n(!1),e.onOpenChange?.(!1)},theme:i?.colorSchemePreference})})]})};function KA(e){let{userStore:t}=iE(LE),n=e.join(`,`);return(0,D.useEffect)(()=>{t.loadUsers(e)},[t,n]),tE(t.store,t=>{let n=new Map;for(let r of e){let e=t.get(r);e&&n.set(r,e)}return n})}function qA(e){return KA([e]).get(e)}var JA=e=>{let t=U(),n=W(),r=iE(LE),i=e.comment.reactions.find(t=>t.emoji===e.emoji);if(!i)throw Error(`Trying to render reaction badge for non-existing reaction`);let[a,o]=(0,D.useState)([]),s=KA(a);return(0,O.jsx)(t.Generic.Badge.Root,{className:V(`bn-badge`,`bn-comment-reaction`),text:i.userIds.length.toString(),icon:i.emoji,isSelected:r.threadStore.auth.canDeleteReaction(e.comment,i.emoji),onClick:()=>e.onReactionSelect(i.emoji),onMouseEnter:()=>o(i.userIds),mainTooltip:n.comments.reactions.reacted_by,secondaryTooltip:`${Array.from(s.values()).map(e=>e.username).join(`
|
|
175
|
-
`)}`},i.emoji)},YA=(0,D.memo)(({isEmpty:e,comment:t,isEditing:n,threadStore:r,onReactionSelect:i,onEditSubmit:a,onEditCancel:o,onEmojiPickerOpenChange:s,Components:c,dict:l})=>{let u=r.auth.canAddReaction(t);return(0,O.jsxs)(O.Fragment,{children:[t.reactions.length>0&&!n&&(0,O.jsxs)(c.Generic.Badge.Group,{className:V(`bn-badge-group`,`bn-comment-reactions`),children:[t.reactions.map(e=>(0,O.jsx)(JA,{comment:t,emoji:e.emoji,onReactionSelect:i},e.emoji)),u&&(0,O.jsx)(GA,{onEmojiSelect:e=>i(e.native),onOpenChange:s,children:(0,O.jsx)(c.Generic.Badge.Root,{className:V(`bn-badge`,`bn-comment-add-reaction`),text:`+`,icon:(0,O.jsx)(LD,{size:16}),mainTooltip:l.comments.actions.add_reaction})})]}),n&&(0,O.jsxs)(c.Generic.Toolbar.Root,{variant:`action-toolbar`,className:V(`bn-action-toolbar`,`bn-comment-actions`),children:[(0,O.jsx)(c.Generic.Toolbar.Button,{mainTooltip:l.comments.save_button_text,variant:`compact`,onClick:a,isDisabled:e,children:l.comments.save_button_text}),(0,O.jsx)(c.Generic.Toolbar.Button,{className:`bn-button`,mainTooltip:l.comments.cancel_button_text,variant:`compact`,onClick:o,children:l.comments.cancel_button_text})]})]})}),XA=({comment:e,thread:t,showResolveButton:n})=>{let r=iE(LE),i=W(),[a,o]=(0,D.useState)(!1),s=EE({initialContent:e.body,trailingBlock:!1,dictionary:{...i,placeholders:{emptyDocument:i.placeholders.edit_comment}},schema:r.commentEditorSchema||jE,extensions:[NE({submitOnEnter:r.submitOnEnter,onSubmit:async n=>{await r.threadStore.updateComment({commentId:e.id,comment:{body:n.document},threadId:t.id}),o(!1)}})]}),c=U(),l=mE(),[u,d]=(0,D.useState)(!1),[f,p]=(0,D.useState)(!1),m=r.threadStore,h=(0,D.useCallback)(()=>{o(!0)},[]),g=(0,D.useCallback)(()=>{s.replaceBlocks(s.document,e.body),o(!1)},[s,e.body]),_=s.getExtension(NE).submit,v=(0,D.useCallback)(async()=>{await m.deleteComment({commentId:e.id,threadId:t.id})},[e,t.id,m]),y=(0,D.useCallback)(async n=>{m.auth.canAddReaction(e,n)?await m.addReaction({threadId:t.id,commentId:e.id,emoji:n}):m.auth.canDeleteReaction(e,n)&&await m.deleteReaction({threadId:t.id,commentId:e.id,emoji:n})},[m,e,t.id]),b=(0,D.useCallback)(async()=>{await m.resolveThread({threadId:t.id})},[t.id,m]),x=(0,D.useCallback)(async()=>{await m.unresolveThread({threadId:t.id})},[t.id,m]),S=qA(e.userId);if(!e.body)return null;let C,w=m.auth.canAddReaction(e),T=m.auth.canDeleteComment(e),E=m.auth.canUpdateComment(e),ee=n&&(t.resolved?m.auth.canUnresolveThread(t):m.auth.canResolveThread(t));a||(C=(0,O.jsxs)(c.Generic.Toolbar.Root,{className:V(`bn-action-toolbar`,`bn-comment-actions`),variant:`action-toolbar`,children:[w&&(0,O.jsx)(GA,{onEmojiSelect:e=>y(e.native),onOpenChange:d,children:(0,O.jsx)(c.Generic.Toolbar.Button,{mainTooltip:i.comments.actions.add_reaction,variant:`compact`,children:(0,O.jsx)(LD,{size:16})},`add-reaction`)}),ee&&(t.resolved?(0,O.jsx)(c.Generic.Toolbar.Button,{mainTooltip:i.comments.actions.reopen,variant:`compact`,onClick:x,children:(0,O.jsx)(MO,{size:16})},`reopen`):(0,O.jsx)(c.Generic.Toolbar.Button,{mainTooltip:i.comments.actions.resolve,variant:`compact`,onClick:b,children:(0,O.jsx)(GD,{size:16})},`resolve`)),(T||E)&&(0,O.jsxs)(c.Generic.Menu.Root,{position:`bottom-start`,onOpenChange:p,portalElement:l,children:[(0,O.jsx)(c.Generic.Menu.Trigger,{children:(0,O.jsx)(c.Generic.Toolbar.Button,{mainTooltip:i.comments.actions.more_actions,variant:`compact`,children:(0,O.jsx)(BD,{size:16})},`more-actions`)}),(0,O.jsxs)(c.Generic.Menu.Dropdown,{className:`bn-menu-dropdown`,children:[E&&(0,O.jsx)(c.Generic.Menu.Item,{icon:(0,O.jsx)(jO,{}),onClick:h,children:i.comments.actions.edit_comment},`edit-comment`),T&&(0,O.jsx)(c.Generic.Menu.Item,{icon:(0,O.jsx)(UD,{}),onClick:v,children:i.comments.actions.delete_comment},`delete-comment`)]})]})]}));let te=e.createdAt.toLocaleDateString(void 0,{month:`short`,day:`numeric`});if(!e.body)throw Error(`soft deletes are not yet supported`);return(0,O.jsx)(c.Comments.Comment,{authorInfo:S??`loading`,timeString:te,edited:e.updatedAt.getTime()!==e.createdAt.getTime(),showActions:f||`hover`,actions:C,className:`bn-thread-comment`,emojiPickerOpen:u,children:(0,O.jsx)(DE,{autoFocus:a,editor:s,editable:a,actions:e.reactions.length>0||a?({isFocused:t,isEmpty:n})=>(0,O.jsx)(YA,{isFocused:t,isEmpty:n,comment:e,isEditing:a,threadStore:m,onReactionSelect:y,onEditSubmit:_,onEditCancel:g,onEmojiPickerOpenChange:d,Components:c,dict:i}):void 0})})},ZA=({thread:e,maxCommentsBeforeCollapse:t})=>{let n=U(),r=W(),i=KA(e.resolvedBy?[e.resolvedBy]:[]),a=e.comments.map((t,n)=>(0,O.jsx)(XA,{thread:e,comment:t,showResolveButton:n===0},t.id+JSON.stringify(t.body||`{}`)));if(e.resolved&&e.resolvedUpdatedAt&&e.resolvedBy){if(!i.get(e.resolvedBy))throw Error(`User ${e.resolvedBy} resolved thread ${e.id}, but their data could not be found.`);let t=e.comments.findLastIndex(t=>e.resolvedUpdatedAt.getTime()>t.createdAt.getTime())+1;a.splice(t,0,(0,O.jsx)(n.Comments.Comment,{className:`bn-thread-comment`,authorInfo:e.resolvedBy&&i.get(e.resolvedBy)||`loading`,timeString:e.resolvedUpdatedAt.toLocaleDateString(void 0,{month:`short`,day:`numeric`}),edited:!1,showActions:!1,children:(0,O.jsx)(`div`,{className:`bn-resolved-text`,children:r.comments.sidebar.marked_as_resolved})},`resolved-comment`))}return t&&a.length>t&&a.splice(1,a.length-2,(0,O.jsx)(n.Comments.ExpandSectionsPrompt,{className:`bn-thread-expand-prompt`,children:r.comments.sidebar.more_replies(e.comments.length-2)},`expand-prompt`)),a},QA=(0,D.memo)(({isEmpty:e,onSave:t,Components:n,dict:r})=>(0,O.jsx)(n.Generic.Toolbar.Root,{className:V(`bn-action-toolbar`,`bn-comment-actions`),variant:`action-toolbar`,children:(0,O.jsx)(n.Generic.Toolbar.Button,{className:`bn-button`,mainTooltip:r.comments.save_button_text,variant:`compact`,isDisabled:e,onClick:t,children:r.comments.save_button_text})}));function $A(e){let t=e.newCommentEditor,n=U(),r=W(),i=t.getExtension(NE);if(!i)throw Error(`FloatingComposer's newCommentEditor must include CommentEditorSubmitExtension.`);let a=i.submit;return(0,O.jsx)(n.Comments.Card,{className:`bn-thread`,children:(0,O.jsx)(DE,{autoFocus:!0,editable:!0,editor:t,actions:({isFocused:e,isEmpty:t})=>(0,O.jsx)(QA,{isFocused:e,isEmpty:t,onSave:a,Components:n,dict:r})})})}var ej=vD({default:()=>tj});function tj(e){let t=H(),n=W(),r=iE(LE),i=aE(LE,{editor:t,selector:e=>e.pendingComment}),a=EE({trailingBlock:!1,dictionary:{...n,placeholders:{emptyDocument:n.placeholders.new_comment}},schema:r.commentEditorSchema||jE,extensions:[NE({submitOnEnter:r.submitOnEnter,onSubmit:async e=>{await r.createThread({initialComment:{body:e.document}}),r.stopPendingComment(),t.transact(e=>{e.setSelection(N.create(e.doc,e.selection.to))}),t.focus()}})]},[i]),o=cE({editor:t,selector:({editor:e})=>i?{from:e.prosemirrorState.selection.from,to:e.prosemirrorState.selection.to}:void 0}),s=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!i,onOpenChange:e=>{if(!e){if(!ME({hasUnsavedContent:!a.isEmpty,confirmBeforeDiscard:r.confirmBeforeDiscard,message:n.comments.discard_pending_comment}))return;r.stopPendingComment(),t.focus()}},placement:`bottom`,middleware:[p(10),w(),S()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!1},elementProps:{style:{zIndex:60},...e.floatingUIOptions?.elementProps}}),[r,n,t,a,i,e.floatingUIOptions]),c=e.floatingComposer||$A;return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(TE,{position:o,...s,children:(0,O.jsx)(c,{newCommentEditor:a})})})}var nj=(0,D.memo)(({isEmpty:e,onNewCommentSave:t,Components:n,dict:r})=>e?null:(0,O.jsx)(n.Generic.Toolbar.Root,{variant:`action-toolbar`,className:V(`bn-action-toolbar`,`bn-comment-actions`),children:(0,O.jsx)(n.Generic.Toolbar.Button,{mainTooltip:r.comments.save_button_text,variant:`compact`,isDisabled:e,onClick:t,children:r.comments.save_button_text})})),rj=({thread:e,selected:t,orphaned:n,referenceText:r,maxCommentsBeforeCollapse:i,onFocus:a,onBlur:o,tabIndex:s,newCommentEditor:c})=>{let l=U(),u=W(),d=iE(LE),f=(0,D.useRef)(e.id);f.current=e.id;let p=EE({trailingBlock:!1,dictionary:{...u,placeholders:{emptyDocument:u.placeholders.comment_reply}},schema:d.commentEditorSchema||jE,extensions:[NE({submitOnEnter:d.submitOnEnter,onSubmit:async e=>{await d.threadStore.addComment({comment:{body:e.document},threadId:f.current}),e.removeBlocks(e.document)}})]}),m=c??p,h=m.getExtension(NE);if(!h)throw Error(`Thread's newCommentEditor must include CommentEditorSubmitExtension.`);let g=h.submit;return(0,O.jsxs)(l.Comments.Card,{className:V(`bn-thread`,n&&`bn-thread-orphaned`),headerText:r,onFocus:a,onBlur:o,selected:t,tabIndex:s,children:[(0,O.jsx)(l.Comments.CardSection,{className:`bn-thread-comments`,children:(0,O.jsx)(ZA,{thread:e,maxCommentsBeforeCollapse:t?void 0:i||5})}),t&&(0,O.jsx)(l.Comments.CardSection,{className:`bn-thread-composer`,children:(0,O.jsx)(DE,{autoFocus:!1,editable:!0,editor:m,actions:({isFocused:e,isEmpty:t})=>(0,O.jsx)(nj,{isFocused:e,isEmpty:t,onNewCommentSave:g,Components:l,dict:u})})})]})};function ij(){let e=iE(LE).threadStore,t=(0,D.useRef)(void 0);t.current||=e.getThreads();let n=(0,D.useCallback)(n=>e.subscribe(e=>{t.current=e,n()}),[e]);return(0,D.useSyncExternalStore)(n,()=>t.current)}var aj=vD({default:()=>oj});function oj(e){let t=H(),n=W(),r=iE(LE),i=aE(LE,{editor:t,selector:e=>e.selectedThreadId?{id:e.selectedThreadId,position:e.threadPositions.get(e.selectedThreadId)}:void 0}),a=EE({trailingBlock:!1,dictionary:{...n,placeholders:{emptyDocument:n.placeholders.comment_reply}},schema:r.commentEditorSchema||jE,extensions:[NE({submitOnEnter:r.submitOnEnter,onSubmit:async e=>{i&&(await r.threadStore.addComment({comment:{body:e.document},threadId:i.id}),e.removeBlocks(e.document))}})]},[i?.id]),o=ij(),s=(0,D.useMemo)(()=>i?o.get(i.id):void 0,[i,o]),c=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!i,onOpenChange:(e,i,o)=>{if(!e){if(!ME({hasUnsavedContent:!a.isEmpty,confirmBeforeDiscard:r.confirmBeforeDiscard,message:n.comments.discard_pending_comment}))return;o===`escape-key`&&t.focus(),r.selectThread(void 0)}},placement:`bottom`,middleware:[p(10),w(),S()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:30},...e.floatingUIOptions?.elementProps}}),[r,n,t,a,e.floatingUIOptions,i]),l=e.floatingThread||rj;return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(TE,{position:i?.position,...c,children:s&&(0,O.jsx)(l,{thread:s,selected:!0,newCommentEditor:a})})})}D.memo(({thread:e,selectedThreadId:t,maxCommentsBeforeCollapse:n,referenceText:r,orphaned:i})=>{let a=iE(LE),o=(0,D.useCallback)(t=>{t.target.closest(`.bn-action-toolbar`)||a.selectThread(e.id)},[a,e.id]),s=(0,D.useCallback)(e=>{if(!e.relatedTarget||e.relatedTarget.closest(`.bn-action-toolbar`))return;let t=e.target instanceof Node?e.target:null,n=e.relatedTarget instanceof Node?e.relatedTarget.closest(`.bn-thread`):null;t&&n&&n.contains(t)||a.selectThread(void 0)},[a]);return(0,O.jsx)(rj,{thread:e,selected:e.id===t,orphaned:i,referenceText:r,maxCommentsBeforeCollapse:n,onFocus:o,onBlur:s,tabIndex:0})}),(0,D.createContext)(void 0);function sj(e){let t=(0,D.useRef)(null);return(0,D.useEffect)(()=>{e&&t.current?.focus({preventScroll:!0})},[e]),t}function cj(e){return e.currentTarget instanceof HTMLElement&&e.relatedTarget instanceof HTMLElement&&e.currentTarget.contains(e.relatedTarget)}function lj({onBlur:e,onFocus:t}={}){let n=(0,D.useRef)(null),[r,i]=(0,D.useState)(!1),a=(0,D.useRef)(!1),o=e=>{i(e),a.current=e},s=(0,D.useCallback)(e=>{a.current||(o(!0),t?.(e))},[t]),c=(0,D.useCallback)(t=>{a.current&&!cj(t)&&(o(!1),e?.(t))},[e]);return(0,D.useEffect)(()=>{let e=n.current;if(e)return e.addEventListener(`focusin`,s),e.addEventListener(`focusout`,c),()=>{e?.removeEventListener(`focusin`,s),e?.removeEventListener(`focusout`,c)}},[s,c]),{ref:n,focused:r}}function uj(e){return(0,O.jsx)(ZE,{as:`span`,className:`bn-inline-content-section`,"data-inline-content-type":e.inlineContentType,...Object.fromEntries(Object.entries(e.inlineContentProps).filter(([t,n])=>n!==e.propSchema[t].default).map(([e,t])=>[Ig(e),t])),children:e.children})}function dj(e,t,n){let r=Ep.create({name:e.type,inline:!0,group:`inline`,selectable:e.content!==`none`,atom:e.content===`none`,draggable:t.meta?.draggable,code:t.meta?.code,content:e.content===`styled`?`inline*`:e.content===`plain`?`text*`:``,marks(){return e.content===`plain`?Ap(this.editor):void 0},addAttributes(){return zg(e.propSchema)},addKeyboardShortcuts(){return Xg(e)},parseHTML(){return vS(e,t.parse,t.parseContent)},renderHTML({node:n}){let r=this.options.editor,i=Mg(n,r.schema.inlineContentSchema,r.schema.styleSchema),a=t.toExternalHTML||t.render;return Yg(VA(e=>(0,O.jsx)(a,{contentRef:t=>{e(t),t&&(t.dataset.editable=``)},inlineContent:i,updateInlineContent:()=>{},editor:r,node:n,getPos:()=>void 0}),r),e.type,n.attrs,e.propSchema)},addNodeView(){let n=this.options.editor;return r=>dD(r=>{let i=XE().nodeViewContentRef;if(!i)throw Error(`nodeViewContentRef is not set`);let a=t.render;return(0,O.jsx)(uj,{inlineContentProps:r.node.attrs,inlineContentType:e.type,propSchema:e.propSchema,children:(0,O.jsx)(a,{contentRef:e=>{i(e),e&&(e.dataset.editable=``)},editor:n,node:r.node,getPos:r.getPos,inlineContent:Mg(r.node,n.schema.inlineContentSchema,n.schema.styleSchema),updateInlineContent:e=>{let t=P_([e],n.pmSchema),i=r.getPos();i!==void 0&&n.transact(e=>e.replaceWith(i,i+r.node.nodeSize,t))}})})},{className:`bn-ic-react-node-view-renderer`,as:`span`})(r)}});return Zg(e,{...t,node:r,render(n,r,i){let a=t.render,o=P_([n],i.pmSchema)[0];return VA(t=>(0,O.jsx)(uj,{inlineContentProps:n.props,inlineContentType:e.type,propSchema:e.propSchema,children:(0,O.jsx)(a,{contentRef:e=>{t(e),e&&(e.dataset.editable=``)},editor:i,inlineContent:n,updateInlineContent:r,node:o,getPos:()=>void 0})}),i)},toExternalHTML(n,r){let i=t.toExternalHTML||t.render,a=P_([n],r.pmSchema)[0];return VA(t=>(0,O.jsx)(uj,{inlineContentProps:n.props,inlineContentType:e.type,propSchema:e.propSchema,children:(0,O.jsx)(i,{contentRef:e=>{t(e),e&&(e.dataset.editable=``)},editor:r,inlineContent:n,updateInlineContent:()=>{},node:a,getPos:()=>void 0})}),r)}},n)}function fj(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.top<r.top,a=n.bottom>r.bottom;return i&&a?`both`:i?`top`:a?`bottom`:`none`}function pj(e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}function mj(e){return(0,D.useMemo)(()=>pj(e),e)}function hj(e){gg()?e.preventDefault():mg()&&e.currentTarget.focus()}function gj(e){let{render:t,type:n}=e;return t||n!==void 0?e:{...e,type:`button`}}function _j(e){return Array.isArray(e)?e:e===void 0?[]:[e]}function vj(e){let t=[];for(let n of e)t.push(...n);return t}function yj(e){return e.slice().reverse()}function bj(...e){}function xj(e,t){return Sj(e)?e(Cj(t)?t():t):e}function Sj(e){return typeof e==`function`}function Cj(e){return typeof e==`function`}function wj(e){return typeof e==`object`&&!!e}function Tj(e,t){return typeof Object.hasOwn==`function`?Object.hasOwn(e,t):Object.prototype.hasOwnProperty.call(e,t)}function Ej(...e){return(...t)=>{for(let n of e)typeof n==`function`&&n(...t)}}function Dj(...e){return e.filter(Boolean).join(` `)||void 0}function Oj(e){return e.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``)}function kj(e,t){let n={...e};for(let e of t)Tj(n,e)&&delete n[e];return n}function Aj(e,t){let n={};for(let r of t)Tj(e,r)&&(n[r]=e[r]);return n}function jj(e){return e}function Mj(e=bj){let t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)});return()=>cancelAnimationFrame(t)}function Nj(e,t){if(!e)throw Error(typeof t==`string`?t:`Invariant failed`)}function Pj(e){return Object.keys(e)}function Fj(e,...t){let n=typeof e==`function`?e(...t):e;return n!=null&&!n}function Ij(e){return e.disabled||e[`aria-disabled`]===!0||e[`aria-disabled`]===`true`}function Lj(e){return e.getAttribute(`aria-disabled`)===`true`||`disabled`in e&&e.disabled===!0}function Rj(e){let t={};for(let n in e)Tj(e,n)&&n!==`__proto__`&&e[n]!==void 0&&(t[n]=e[n]);return t}function K(...e){for(let t of e)if(t!==void 0)return t}var zj=Bj();function Bj(){return typeof window<`u`&&!!window.document?.createElement}function Vj(e,t){let n=e;for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e?.get)return e.get;n=Object.getPrototypeOf(n)}}var Hj=zj?Vj(Object.getPrototypeOf(window.document),`nodeType`):void 0,Uj=zj?Vj(Object.getPrototypeOf(window.document),`activeElement`):void 0;function Wj(e){return e?e.window===e:!1}function Gj(e){if(!e)return!1;if(!Hj)return e.nodeType===9;try{return Hj.call(e)===9}catch{return!1}}function Kj(e,t){try{return e.document===t}catch{return!1}}function q(e){if(!e)return document;if(Gj(e))return e;if(Wj(e))return e.document;let t=e.ownerDocument;return Gj(t)?t:document}function qj(e){if(!e)return self;if(Wj(e))return e;let t=q(e),{defaultView:n}=t;return Wj(n)&&Kj(n,t)?n:window}function Jj(e,{frame:t=!0,activeDescendant:n=!1}={}){let r=q(e),i=Uj?Uj.call(r):r.activeElement;if(!i?.nodeName)return null;if(t&&Qj(i)&&i.contentDocument?.body)return Jj(i.contentDocument.body,{frame:t,activeDescendant:n});if(n){let e=i.getAttribute(`aria-activedescendant`);if(e){let t=q(i).getElementById(e);if(t)return t}}return i}function Yj(e,t){return e===t||e.contains(t)}function Xj(e){return e?.nodeType===1}function Zj(e){return typeof e?.nodeType==`number`}function Qj(e){return e.tagName===`IFRAME`}function $j(e){let t=e.tagName.toLowerCase();return t===`button`?!0:t===`input`&&e.type?eM.indexOf(e.type)!==-1:!1}var eM=[`button`,`color`,`file`,`image`,`reset`,`submit`];function tM(e){if(typeof e.checkVisibility==`function`)return e.checkVisibility();let t=e;return t.offsetWidth>0||t.offsetHeight>0||e.getClientRects().length>0}function nM(e){try{return e.tagName===`TEXTAREA`||e.tagName===`INPUT`&&e.selectionStart!==null}catch{return!1}}function rM(e){return e.isContentEditable||nM(e)}function iM(e){if(nM(e))return e.value;if(e.isContentEditable){let t=q(e).createRange();return t.selectNodeContents(e),t.toString()}return``}function aM(e){let t=0,n=0;if(nM(e))t=e.selectionStart||0,n=e.selectionEnd||0;else if(e.isContentEditable){let r=q(e).getSelection();if(r?.rangeCount&&r.anchorNode&&Yj(e,r.anchorNode)&&r.focusNode&&Yj(e,r.focusNode)){let i=r.getRangeAt(0),a=i.cloneRange();a.selectNodeContents(e),a.setEnd(i.startContainer,i.startOffset),t=a.toString().length,a.setEnd(i.endContainer,i.endOffset),n=a.toString().length}}return{start:t,end:n}}var oM=[`dialog`,`menu`,`listbox`,`tree`,`grid`],sM={menu:`menuitem`,listbox:`option`,tree:`treeitem`};function cM(e,t){let n=e?.getAttribute(`role`);return n&&oM.indexOf(n)!==-1?n:t}function lM(e){if(e!=null&&Tj(sM,e))return sM[e]}function uM(e,t){let n=cM(e);return typeof n==`string`?lM(n)??t:t}function dM(e){if(!e)return null;let t=e=>e===`auto`||e===`scroll`;if(e.clientHeight&&e.scrollHeight>e.clientHeight){let{overflowY:n}=getComputedStyle(e);if(t(n))return e}else if(e.clientWidth&&e.scrollWidth>e.clientWidth){let{overflowX:n}=getComputedStyle(e);if(t(n))return e}let n=q(e);return dM(e.parentElement)||n.scrollingElement||n.body}function fM(e,t){let n=e.map((e,t)=>[t,e]),r=!1;return n.sort(([e,n],[i,a])=>{let o=t(n),s=t(a);return o===s||!o||!s?0:pM(o,s)?(e>i&&(r=!0),-1):(e<i&&(r=!0),1)}),r?n.map(([e,t])=>t):e}function pM(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function mM(){return zj&&!!navigator.maxTouchPoints}function hM(){return zj?/mac|iphone|ipad|ipod/i.test(navigator.platform):!1}function gM(){return zj&&hM()&&/apple/i.test(navigator.vendor)}function _M(){return zj&&/firefox\//i.test(navigator.userAgent)}function vM(){return zj&&navigator.platform.startsWith(`Mac`)&&!mM()}function yM(e){let{currentTarget:t,target:n}=e;return t?!Zj(n)||!Yj(t,n):!1}function bM(e){return e.target===e.currentTarget}function xM(e){if(!Xj(e))return!1;let t=e,n=t.tagName.toLowerCase();return n===`a`||n===`button`&&t.type===`submit`||n===`input`&&t.type===`submit`}function SM(e){let t=hM();return t&&!e.metaKey||!t&&!e.ctrlKey?!1:xM(e.currentTarget)}function CM(e){return e.altKey?xM(e.currentTarget):!1}function wM(e,t,n){let{Event:r}=qj(e),i=new r(t,n);return e.dispatchEvent(i)}function TM(e,t){let{FocusEvent:n}=qj(e),r=new n(`blur`,t),i=e.dispatchEvent(r),a={...t,bubbles:!0};return e.dispatchEvent(new n(`focusout`,a)),i}var EM={width:!0,height:!0,pressure:!0,tangentialPressure:!0,tiltX:!0,tiltY:!0,twist:!0,altitudeAngle:!0,azimuthAngle:!0,isPrimary:!0,coalescedEvents:!0,predictedEvents:!0,persistentDeviceId:!0};function DM(e,t){let n=t??{},r=e.Window,i=typeof r==`function`&&e instanceof r?e:null;return new Proxy({},{get(e,t){if(t===`view`)return i;if(t===`composed`)return!0;if(t===`pointerId`)return n.pointerId??-1;if(t===`pointerType`)return n.pointerType??``;if(!Tj(EM,t))return Reflect.get(n,t)}})}function OM(e,t){let n=qj(e),r=new(n.PointerEvent??n.MouseEvent)(`click`,DM(n,t));return e.dispatchEvent(r)}function kM(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!Zj(r)||!Yj(n,r)}function AM(e,t,n,r){let i=(e=>{if(r){let t=setTimeout(e,r);return()=>clearTimeout(t)}let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)})(()=>{e.removeEventListener(t,a,!0),n()}),a=()=>{i(),n()};return e.addEventListener(t,a,{once:!0,capture:!0}),()=>{i(),e.removeEventListener(t,a,!0)}}function jM(e,t,n,r=window){let i=[];try{r.document.addEventListener(e,t,n);for(let a of Array.from(r.frames))i.push(jM(e,t,n,a))}catch{}return()=>{try{r.document.removeEventListener(e,t,n)}catch{}for(let e of i)e()}}var MM=`input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])`;function NM(e){return Number.parseInt(e.getAttribute(`tabindex`)||`0`,10)<0}function PM(e){return!(!e.matches(MM)||!tM(e)||e.closest(`[inert]`))}function FM(e){if(!PM(e)||NM(e))return!1;if(!(`form`in e)||!e.form||e.checked||e.type!==`radio`)return!0;let t=e.form.elements.namedItem(e.name);if(!t||!(`length`in t))return!0;let n=Jj(e);return!n||n===e||!(`form`in n)||n.form!==e.form||!(`name`in n)||n.name!==e.name}function IM(e,t){let n=Array.from(e.querySelectorAll(MM));t&&n.unshift(e);let r=n.filter(PM);return r.forEach((e,t)=>{if(!Qj(e))return;let n=e.contentDocument?.body;n&&r.splice(t,1,...IM(n))}),r}function LM(e,t){let[n]=IM(e,t);return n||null}function RM(e,t,n){let r=Array.from(e.querySelectorAll(MM)).filter(FM);return t&&FM(e)&&r.unshift(e),r.forEach((e,t)=>{if(!Qj(e))return;let i=e.contentDocument?.body;if(!i)return;let a=RM(i,!1,n);r.splice(t,1,...a)}),!r.length&&n?IM(e):r}function zM(e,t,n){if(t&&FM(e)){if(!Qj(e))return e;let t=e.contentDocument?.body;if(!t)return e;let r=zM(t,!1,n);if(r)return r}let r=e.querySelectorAll(MM);for(let e of r)if(FM(e)){if(Qj(e)){let t=e.contentDocument?.body;if(!t)return e;let r=zM(t,!1,n);if(r)return r}else return e}return n?LM(e):null}function BM({container:e,includeContainer:t,reverse:n,fallbackToEdge:r,fallbackToFocusable:i}){let a=Jj(e),o=IM(e,t);n&&o.reverse();let s=o.indexOf(a),c=o.slice(s+1);return c.find(FM)||(r?o.find(FM):null)||(i?c[0]:null)||null}function VM(e,t,n,r){return BM({container:e,includeContainer:t,fallbackToEdge:n,fallbackToFocusable:r})}function HM(e,t){return VM(document.body,!1,e,t)}function UM(e,t,n,r){return BM({container:e,includeContainer:t,reverse:!0,fallbackToEdge:n,fallbackToFocusable:r})}function WM(e,t){return UM(document.body,!1,e,t)}function GM(e){let t=Jj(e);if(!t)return!1;if(t===e)return!0;let n=t.getAttribute(`aria-activedescendant`);return n?n===e.id:!1}function KM(e){let t=Jj(e);if(!t)return!1;if(Yj(e,t))return!0;let n=t.getAttribute(`aria-activedescendant`);return!n||!(`id`in e)?!1:n===e.id||!!e.querySelector(`#${CSS.escape(n)}`)}function qM(e){let t=e.getAttribute(`tabindex`)??``;e.setAttribute(`data-tabindex`,t),e.setAttribute(`tabindex`,`-1`)}function JM(e,t){let n=RM(e,t);for(let e of n)qM(e)}function YM(e){let t=e.querySelectorAll(`[data-tabindex]`),n=e=>{let t=e.getAttribute(`data-tabindex`);e.removeAttribute(`data-tabindex`),t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)};e.hasAttribute(`data-tabindex`)&&n(e);for(let e of t)n(e)}function XM(e){return async()=>{let t=await e?.();return XM(async()=>(await t?.(),e))}}ZM();function ZM({limit:e=100}={}){let t=[],n=[],r=null,i=()=>t.length>0,a=()=>n.length>0;return{canUndo:i,canRedo:a,undo:async()=>{i()&&(r=null,n.push(await t.pop()?.()))},redo:async()=>{a()&&(r=null,t.push(await n.pop()?.()))},execute:async(i,a)=>{if(!i)return;let o=a===r;r=a??null;let s=o?Math.max(0,t.length-1):t.length,c=await i();if(!c)return;n=[];let l=t[s];for(t[s]=XM(async()=>{await c?.();let e=await l?.();return async()=>{await e?.(),await i?.()}});t.length>e;)t.shift()}}}var QM=Symbol(`accessibleWhenDisabled`);function $M(e){return e.accessibleWhenDisabled??e.onLoadedMetadataCapture?.[QM]}var eN=`data-truly-disabled`;function tN(e){return e.getAttribute(eN)===`true`}function nN(e){let t=e.getAttribute(eN);if(t===`true`)return!0;if(t===`false`)return!1}function rN(e){return e===`ArrowUp`||e===`ArrowRight`||e===`ArrowDown`||e===`ArrowLeft`||e===`Home`||e===`End`||e===`PageUp`||e===`PageDown`}function iN(e){return e.nodeType===e.DOCUMENT_FRAGMENT_NODE&&`host`in e}function aN(e){let t=e?.getRootNode();return t&&iN(t)&&t.activeElement?t.activeElement:Jj(e)}function oN(e){return GM(e)||aN(e)===e}var sN=(0,D.createContext)(!0);function cN(e,t){if(typeof e==`function`){let n=e(t);if(typeof n==`function`)return n}else e&&(e.current=t)}function lN(e){return!e||!(0,D.isValidElement)(e)?!1:`ref`in e.props||`ref`in e}function uN(e){return lN(e)?{...e.props}.ref||e.ref:null}function dN(e,t){let n={...e};for(let r in t){if(!Tj(t,r)||r===`__proto__`)continue;if(r===`className`){let r=`className`,i=e[r],a=t[r];n[r]=i&&a?`${i} ${a}`:a||i;continue}if(r===`style`){let r=`style`;n[r]=e[r]?{...e[r],...t[r]}:t[r];continue}let i=t[r];if(i!==void 0){if(r.startsWith(`on`)){if(typeof i!=`function`)continue;let t=e[r];if(typeof t==`function`){n[r]=(...e)=>{i(...e),t(...e)};continue}}n[r]=i}}return n}var fN={...D},pN=fN.useId;fN.useDeferredValue;var mN=fN.useInsertionEffect??(e=>e()),J=zj?D.useLayoutEffect:D.useEffect;function hN(e){let[t]=(0,D.useState)(e);return t}function gN(e){let t=(0,D.useRef)(e);return J(()=>{t.current=e}),t}function Y(e){let t=(0,D.useRef)(()=>{throw Error(`Cannot call an event handler while rendering.`)});return mN(()=>{t.current=e}),(0,D.useCallback)((...e)=>t.current?.(...e),[])}function _N(e){let[t,n]=(0,D.useState)(null);return J(()=>{if(t==null||!e)return;let n=null;return e(e=>(n=e,t)),()=>{e(n)}},[t,e]),[t,n]}function vN(...e){return(0,D.useMemo)(()=>{if(e.some(Boolean))return t=>{let n=[];for(let r of e){if(!r)continue;let e=cN(r,t);n.push({ref:r,cleanup:typeof e==`function`?e:void 0})}if(n.some(e=>e.cleanup))return()=>{for(let{ref:e,cleanup:t}of n)t?t():cN(e,null)}}},e)}function yN(e){let[t,n]=(0,D.useState)(e);return J(()=>{if(e||t)return;let r=Math.random().toString(36).slice(2,8);n(`id-${r}`)},[e,t]),e||t}function bN(e){let t=pN();return e||t}var xN=pN?bN:yN;function SN(e){return xN(e)}function CN(e,t){let n=e=>{if(typeof e==`string`)return e},[r,i]=(0,D.useState)(()=>n(t));return J(()=>{let r=e&&`current`in e?e.current:e;i(r?.tagName.toLowerCase()||n(t))},[e,t]),r}function wN(e,t,n){let r=hN(n),[i,a]=(0,D.useState)(r);return(0,D.useEffect)(()=>{let n=e&&`current`in e?e.current:e;if(!n)return;let i=()=>{let e=n.getAttribute(t);a(e??r)},o=new MutationObserver(i);return o.observe(n,{attributeFilter:[t]}),i(),()=>o.disconnect()},[e,t,r]),i}function TN(e,t){let n=(0,D.useRef)(!1);(0,D.useEffect)(()=>{if(n.current)return e();n.current=!0},t),(0,D.useEffect)(()=>()=>{n.current=!1},[])}function EN(){return(0,D.useReducer)(()=>[],[])}function DN(e){return Y(typeof e==`function`?e:()=>e)}function ON(e,t,n=[]){let r=(0,D.useCallback)(n=>(e.wrapElement&&(n=e.wrapElement(n)),t(n)),[...n,e.wrapElement]);return{...e,wrapElement:r}}function kN(e=!1,t){let[n,r]=(0,D.useState)(null);return{portalRef:vN(r,t),portalNode:n,domReady:!e||n}}function AN(e,t,n){let r=e.onLoadedMetadataCapture,i=(0,D.useMemo)(()=>Object.assign(bj.bind(null),r,...n===void 0?[]:[{[t]:n}]),[r,t,n]);return[r?.[t],{onLoadedMetadataCapture:i}]}var jN=!1;function MN(){return(0,D.useEffect)(()=>{jN||=(jM(`mousemove`,LN,!0),jM(`mousedown`,RN,!0),jM(`mouseup`,RN,!0),jM(`keydown`,RN,!0),jM(`scroll`,RN,!0),!0)},[]),Y(()=>NN)}var NN=!1,PN=0,FN=0;function IN(e){let t=e.movementX||e.screenX-PN,n=e.movementY||e.screenY-FN;return PN=e.screenX,FN=e.screenY,t||n||!1}function LN(e){IN(e)&&(NN=!0)}function RN(){NN=!1}function X(e){let t=D.forwardRef((t,n)=>e(Rj({...t,ref:n})));return t.displayName=e.displayName||e.name,t}function zN(e,t){return D.memo(e,t)}function Z(e,t){let{wrapElement:n,render:r,...i}=t,a=vN(t.ref,uN(r)),o;if(D.isValidElement(r)){let e={...r.props,ref:a};o=D.cloneElement(r,dN(i,e))}else o=r?r(i):(0,O.jsx)(e,{...i});return n?n(o):o}function Q(e){let t=(t={})=>e(t);return t.displayName=e.name,t}function BN(e=[],t=[]){let n=D.createContext(void 0),r=D.createContext(void 0),i=()=>D.useContext(n),a=(e=!1)=>{let t=D.useContext(r),n=i();return e?t:t||n},o=()=>{let e=D.useContext(r),t=i();if(!(e&&e===t))return t},s=t=>e.reduceRight((e,n)=>(0,O.jsx)(n,{...t,children:e}),(0,O.jsx)(n.Provider,{...t}));return{context:n,scopedContext:r,useContext:i,useScopedContext:a,useProviderContext:o,ContextProvider:s,ScopedContextProvider:e=>(0,O.jsx)(s,{...e,children:t.reduceRight((t,n)=>(0,O.jsx)(n,{...e,children:t}),(0,O.jsx)(r.Provider,{...e}))})}}var VN=`div`,HN=gM(),UN=1,WN=2,GN=3,KN=[`text`,`search`,`url`,`tel`,`email`,`password`,`number`,`date`,`month`,`week`,`time`,`datetime`,`datetime-local`];function qN(e){let{tagName:t,readOnly:n,type:r}=e;return t===`TEXTAREA`&&!n||t===`SELECT`&&!n?!0:t===`INPUT`&&!n?KN.includes(r):!!(e.isContentEditable||e.getAttribute(`role`)===`combobox`&&e.dataset.name)}function JN(e){return!e||e===`button`||e===`summary`||e===`input`||e===`select`||e===`textarea`||e===`a`}function YN(e){return!e||e===`button`||e===`input`||e===`select`||e===`textarea`}function XN(e){let t=0;return JN(e)&&(t|=UN),YN(e)&&(t|=WN),t}function ZN(e){if(e.tagName===`BUTTON`){let{type:t}=e;return t===`submit`}if(e.tagName===`INPUT`){let{type:t}=e;return t===`submit`||t===`image`}return!1}function QN({focusable:e,trulyDisabled:t,nativeTabbable:n,supportsDisabled:r,safariTabIndex:i,tabIndexProp:a}){return e?t?n&&!r?-1:void 0:n?i&&a==null?0:a:a??0:a}function $N(e,t){return Y(n=>{e?.(n),n.defaultPrevented||t&&(n.stopPropagation(),n.preventDefault())})}var eP=!1,tP=!0;function nP(e){let t=e.target;Xj(t)&&!t.hasAttribute(`data-focus-visible`)&&(tP=!1)}function rP(e){rN(e.key)?tP=!0:e.metaKey||e.ctrlKey||(!e.altKey||HN&&e.key===`Tab`)&&(tP=!0)}var iP=Q(function({focusable:e=!0,accessibleWhenDisabled:t,autoFocus:n,onFocusVisible:r,...i}){let a=(0,D.useRef)(null),[o,s]=AN(i,QM,t);t??=o,(0,D.useEffect)(()=>{e&&(eP||=(jM(`mousedown`,nP,!0),jM(`keydown`,rP,!0),!0))},[e]);let c=e&&Ij(i),l=c&&!t,[u,d]=(0,D.useState)(!1),f=(0,D.useRef)(!1),p=(0,D.useRef)(null),m=Y(e=>{p.current?.(),p.current=null,f.current=!1,e?.removeAttribute(`data-focus-visible`)});(0,D.useEffect)(()=>{(!e||l)&&(m(a.current),u&&d(!1))},[e,l,u,m]),(0,D.useEffect)(()=>{if(!e||!u)return;let t=a.current;if(!t||typeof IntersectionObserver>`u`)return;let n=new IntersectionObserver(()=>{PM(t)||(f.current=!1,d(!1))});return n.observe(t),()=>n.disconnect()},[e,u]),(0,D.useEffect)(()=>()=>p.current?.(),[]);let h=$N(i.onKeyPressCapture,c),g=$N(i.onMouseDownCapture,c),_=$N(i.onClickCapture,c),v=$N(i.onAuxClickCapture,c),y=(t,n)=>{if(n&&(t.currentTarget=n),!e)return;let i=t.currentTarget;if(i&&oN(i)&&(r?.(t),!t.defaultPrevented)){if(i.dataset.focusVisible=`true`,f.current=!0,ZN(i)){if(p.current?.(),p.current=null,typeof IntersectionObserver<`u`){let e=new IntersectionObserver(()=>{PM(i)||m(i)});e.observe(i),p.current=()=>e.disconnect()}}else d(!0)}},b=i.onKeyDownCapture,x=Y(t=>{if(b?.(t),t.defaultPrevented||!e||u||f.current||(t.metaKey||t.altKey||t.ctrlKey)&&!rN(t.key)||!bM(t))return;let n=t.currentTarget;AM(n,`focusout`,()=>y(t,n))}),S=i.onFocusCapture,C=Y(t=>{if(S?.(t),t.defaultPrevented||!e)return;if(!bM(t)){d(!1);return}let n=t.currentTarget;tP||qN(t.target)?AM(t.target,`focusout`,()=>y(t,n)):d(!1)}),w=i.onBlur,T=Y(t=>{w?.(t),e&&kM(t)&&(m(t.currentTarget),d(!1))}),E=(0,D.useContext)(sN),ee=Y(t=>{e&&n&&t&&E&&queueMicrotask(()=>{GM(t)||PM(t)&&t.focus()})}),[te,ne]=(0,D.useState)(GN);J(()=>{let e=a.current;if(!e)return;let t=XN(e.tagName.toLowerCase());t!==GN&&ne(t)},[]);let re=e&&!!(te&UN),ie=e&&!!(te&WN),[ae,oe]=(0,D.useState)(!1);HN&&(0,D.useEffect)(()=>{if(!e)return;let t=a.current;if(!t)return;let{type:n}=t,r=t.tagName===`INPUT`&&(n===`checkbox`||n===`radio`);oe($j(t)||r)},[e]);let se=i.style,ce=(0,D.useMemo)(()=>l?{pointerEvents:`none`,...se}:se,[l,se]);return i={"data-focus-visible":e&&u||void 0,"data-autofocus":n||void 0,"aria-disabled":c||void 0,...i,...s,ref:vN(a,ee,i.ref),style:ce,tabIndex:QN({focusable:e,trulyDisabled:l,nativeTabbable:re,supportsDisabled:ie,safariTabIndex:ae,tabIndexProp:i.tabIndex}),disabled:ie&&l?!0:void 0,[eN]:c?l:void 0,contentEditable:c?void 0:i.contentEditable,onKeyPressCapture:h,onClickCapture:_,onAuxClickCapture:v,onMouseDownCapture:g,onKeyDownCapture:x,onFocusCapture:C,onBlur:T},Rj(i)});X(function(e){return Z(VN,iP(e))});var aP=`button`;function oP(e){if(!e.isTrusted)return!1;let t=e.currentTarget;return e.key===`Enter`?$j(t)||t.tagName===`SUMMARY`||t.tagName===`A`:e.key===` `?$j(t)||t.tagName===`SUMMARY`||t.tagName===`INPUT`||t.tagName===`SELECT`:!1}var sP=Symbol(`command`),cP=Q(function({clickOnEnter:e=!0,clickOnSpace:t=!0,...n}){let r=(0,D.useRef)(null),[i,a]=(0,D.useState)(!1),o=n.type;(0,D.useEffect)(()=>{let e=r.current;if(!e)return;let t=$j(e);o!==void 0&&t&&e.type===`button`||a(t)},[o]);let[s,c]=(0,D.useState)(!1),l=(0,D.useRef)(!1),u=Ij(n),[d,f]=AN(n,sP,!0);J(()=>{u&&(l.current=!1,c(!1))},[u]);let p=n.onKeyDown,m=Y(n=>{p?.(n);let r=n.currentTarget;if(n.defaultPrevented||d||u||!bM(n)||nM(r)||r.isContentEditable)return;let i=e&&n.key===`Enter`,a=t&&n.key===` `,o=n.key===`Enter`&&!e,s=n.key===` `&&!t;if(o||s)n.preventDefault();else if(i||a){let e=oP(n);if(i){if(!e){n.preventDefault();let{view:e,...t}=n,i=()=>OM(r,t);_M()?AM(r,`keyup`,i):queueMicrotask(i)}}else a&&(l.current=!0,e||(n.preventDefault(),c(!0)))}}),h=n.onKeyUp,g=Y(e=>{if(h?.(e),d)return;let n=t&&e.key===` `;if(!l.current||!n)return;let r=oP(e);if(l.current=!1,r||c(!1),e.defaultPrevented||!bM(e)||u||e.metaKey||r)return;e.preventDefault();let i=e.currentTarget,{view:a,...o}=e;queueMicrotask(()=>OM(i,o))}),_=n.onBlur,v=Y(e=>{_?.(e),l.current&&(l.current=!1,c(!1))});return n={"data-active":s||void 0,type:i?`button`:void 0,...f,...n,ref:vN(r,n.ref),onKeyDown:m,onKeyUp:g,onBlur:v},n=iP(n),n});X(function(e){return Z(aP,cP(gj(e)))});var lP=BN(),uP=lP.useContext;lP.useScopedContext,lP.useProviderContext;var dP=lP.ContextProvider,fP=lP.ScopedContextProvider,pP=`div`,mP=Q(function({store:e,shouldRegisterItem:t=!0,getItem:n=jj,element:r,...i}){let a=uP();e||=a;let o=SN(i.id),s=(0,D.useRef)(r);return(0,D.useEffect)(()=>{let r=s.current;if(!o||!r||!t)return;let i=n({id:o,element:r});return e?.renderItem(i)},[o,t,n,e]),i={...i,ref:vN(s,i.ref)},i});X(function(e){return Z(pP,mP(e))});var hP=BN([dP],[fP]);hP.useContext;var gP=hP.useScopedContext,_P=hP.useProviderContext,vP=hP.ContextProvider,yP=hP.ScopedContextProvider,bP=(0,D.createContext)(void 0),xP=(0,D.createContext)(void 0);function SP(e,t){let n=e.__unstableInternals;return Nj(n,`Invalid store`),n[t]}function CP(e,t){if(!e)return!0;for(let n of e)if(t instanceof Set){if(t.has(n))return!0}else if(wP(n,t))return!0;return!1}function wP(e,t){return e===t||e!==e&&t!==t}function TP(e,t,n,r){let i;for(let a of Pj(t))wP(t[a],n[a])||r!==void 0&&CP([a],r)||(i??={...e},i[a]=t[a]);return i}var EP=100;function DP(e,t,n){if(t)for(let r of t){let t=e.get(r);t||(t=new Set,e.set(r,t)),t.add(n)}}function OP(e,t,n){if(e&&t)for(let r of t){let t=e.get(r);t&&(t.delete(n),t.size||e.delete(r))}}function kP(e){let t=new Set,n=e.currentListener;if(!n)return t;for(let r of e.keyedListeners)if(t.add(r),r===n)return t;return t.clear(),t.add(n),t}function AP(e){e.notifiedListeners??=kP(e)}function jP(e,t){if(!e.currentListener)return!1;let n=!1;for(let r of e.keyedListeners)if(r===e.currentListener)n=!0;else if(n&&r===t)return!1;let r=!1;for(let n of e.group.listeners){if(n===e.currentListener)return r;n===t&&(r=!0)}return!1}function MP(e,t,n){for(let r of e)if(r.group===t&&!r.recovering&&(!n||r.keyedListeners.has(n))){AP(r);for(let e of r.group.listeners){if(e===r.currentListener)break;jP(r,e)&&r.notifiedListeners?.add(e)}}}function NP(e,t,n){for(let r of e)r.group===t&&(r.recovering||jP(r,n)&&(AP(r),r.notifiedListeners?.add(n)))}function PP({fastPathFrames:e,group:t,keys:n,listener:r}){let i=t.listeners.has(r);for(let a of e)a.group===t&&(a.recovering||n.includes(a.updatedKey)&&(jP(a,r)?(AP(a),a.notifiedListeners?.add(r)):i&&(AP(a),a.recoverToLive=!0)))}function FP(e,t,n){for(let r of e)r.group===t&&r.notifiedListeners?.delete(n)}function IP({fastPathFrames:e,group:t,keys:n,listener:r}){for(let i of e)i.group===t&&(i.recovering||n.includes(i.updatedKey)&&i.keyedListeners.add(r))}function LP(e,t){if(!e.disposables.size)return;let n=e.disposables.get(t);n&&(e.disposables.delete(t),n())}function RP(e,t,n){let r=e.disposables.get(t);r?e.disposables.set(t,()=>{r(),n()}):e.disposables.set(t,n)}function zP(e,t,n,r,i,a){if(e.suspendCounts?.has(t))return;let{disposables:o}=e,s=o.size?o.get(t):void 0;if(s){o.delete(t);let e=n;s(),n=i?.()??n,n!==e&&(r=TP(r,n,e,a)??r)}let c=t(n,r);c&&RP(e,t,c)}function BP({group:e,getState:t,prevState:n,updatedKey:r,notifiedListeners:i}){let a=e.allKeysListeners;for(let o of e.listeners)i?.has(o)||(a?.has(o)||CP(e.listenerKeys.get(o),r))&&(i?.add(o),zP(e,o,t(),n,t,r))}function VP(e,...t){let n=e,r=n,i=bj,a=!1,o=!1,s=new Set,c=new Set,l=new Set,u={listeners:new Set,disposables:new Map,listenerKeys:new WeakMap},d={listeners:new Set,disposables:new Map,listenerKeys:new WeakMap},f=e=>(l.add(e),()=>l.delete(e)),p=()=>{let e=c.size,r=Symbol();c.add(r);let a=()=>{c.delete(r)&&(c.size||i())};if(e)return a;let o=Pj(n),s=[];for(let e of t){let n=e?.getState?.();if(!n)continue;let r=o.filter(e=>Tj(n,e));if(r.length){if(t.length===1||r.length===o.length)for(let t of r)s.push(GP(e,[t],e=>{T(t,e[t],!0)}));else{s.push(WP(e,r,(e,t)=>{for(let n of r)e[n]!==t[n]&&T(n,e[n],!0)}));for(let t of r){let n=e?.getState?.();n&&T(t,n[t],!0)}}}}let u=[];for(let e of l)u.push(e());let d=t.map(UP);return i=Ej(...s,...u,...d),a},m=(e,t,n)=>{n!==void 0&&(n?OP(e.listenersByKey,n,t):e.allKeysListeners?.delete(t))},h=[],g=(e,t,n=u)=>{let r=e?[...e]:null,i=n.listeners.has(t);return i||FP(h,n,t),r?PP({fastPathFrames:h,group:n,keys:r,listener:t}):(i&&MP(h,n),NP(h,n,t)),i&&(MP(h,n,t),m(n,t,n.listenerKeys.get(t))),n.listeners.add(t),r?(n.listenersByKey??=new Map,DP(n.listenersByKey,r,t),IP({fastPathFrames:h,group:n,keys:r,listener:t})):(n.allKeysListeners??=new Set,n.allKeysListeners.add(t)),n.listenerKeys.set(t,r),()=>{let e=n.disposables.get(t);n.disposables.delete(t),MP(h,n,t);let i=n.listenerKeys.get(t);m(n,t,r),i!==r&&m(n,t,i),n.listenerKeys.delete(t),n.listeners.delete(t),e?.()}},_=(e,t)=>g(e,t),v=(e,t,r)=>{let i=e.listeners.has(t);if(i){e.suspendCounts??=new Map;let n=e.suspendCounts.get(t)??0;e.suspendCounts.set(t,n+1)}let a;try{let i=n;LP(e,t),n!==i&&(a=TP(r,n,i));let o=t(n,a??r);o&&RP(e,t,o)}finally{if(i){let n=e.suspendCounts,r=n?.get(t);r&&r>1?n?.set(t,r-1):n?.delete(t),n?.size||delete e.suspendCounts}}},y=(e,t)=>(v(u,t,n),g(e,t)),b=(e,t)=>(!d.listeners.size&&!o&&(r=n),v(d,t,r),g(e,t,d)),x=e=>VP(Aj(n,e),E),S=e=>VP(kj(n,e),E),C=()=>n,w=(e,t,r)=>{if(!(r instanceof Set)&&!e.allKeysListeners?.size){let i=e.listenersByKey?.get(r);if(!i)return;let a={group:e,keyedListeners:i,updatedKey:r,currentListener:null};h.push(a);try{for(let o of i){if(a.notifiedListeners?.has(o)||(a.currentListener=o,a.notifiedListeners?.add(o),zP(e,o,n,t,C,r),!e.allKeysListeners?.size&&!a.recoverToLive))continue;let i=a.notifiedListeners??kP(a);a.notifiedListeners=i,a.recovering=!0,BP({group:e,getState:C,prevState:t,updatedKey:r,notifiedListeners:i});return}}finally{h.pop()}}else BP({group:e,getState:C,prevState:t,updatedKey:r})},T=(e,i,c=!1)=>{if(!Tj(n,e))return;let l=n[e],f=xj(i,()=>l);if(wP(f,l))return;let p=o;o=!0;let m=n,h={...n,[e]:f};n=h;let g=!1;try{if(!c&&t.length){for(let r of t)if(r?.setState?.(e,f),!wP(n[e],f)){g=!0;break}if(g){let r=0;for(;r<EP;r+=1){let r=!1;for(let i of t){let t=n[e];i?.setState?.(e,t),wP(n[e],t)||(r=!0)}if(!r)break}}}if(!g){let t=n===h?m:{...n,[e]:m[e]};w(u,t,e)}}finally{o=p}d.listeners.size?(s.add(e),a||(a=!0,queueMicrotask(()=>{a=!1;let e=n,t=s;s=new Set;let i=r;w(d,i,t),r===i&&(r=e)}))):o||(r=n)},E={getState:C,setState:T,__unstableInternals:{setup:f,init:p,subscribe:_,sync:y,batch:b,pick:x,omit:S}};return E}function HP(e,...t){if(e)return SP(e,`setup`)(...t)}function UP(e,...t){if(e)return SP(e,`init`)(...t)}function WP(e,...t){if(e)return SP(e,`subscribe`)(...t)}function GP(e,...t){if(e)return SP(e,`sync`)(...t)}function KP(e,...t){if(e)return SP(e,`batch`)(...t)}function qP(e,...t){if(e)return SP(e,`omit`)(...t)}function JP(e,...t){if(e)return SP(e,`pick`)(...t)}function YP(...e){let t={};for(let n of e){let e=n?.getState?.();e&&Object.assign(t,e)}let n=VP(t,...e);return Object.assign({},...e,n)}function XP(e){let t=e.find(e=>!!e.element),n=[...e].reverse().find(e=>!!e.element)?.element,r=t?.element?.parentElement;if(!n)return q(r).body;for(;r;){if(r.contains(n))return r;r=r.parentElement}return q(r).body}function ZP(e){return e?.__unstablePrivateStore}var QP=64;function $P(e,t){if(e.length<QP){t.ids&&=(t.items=void 0,void 0);return}if(t.items===e)return t.ids;let n=new Set;for(let t of e)n.add(t.id);return t.items=e,t.ids=n,n}function eF(e,t,n){if(e.length<QP)t.ids&&=(t.items=void 0,void 0);else{if(!n){n=new Set;for(let t of e)n.add(t.id)}t.items=e,t.ids=n}}function tF(e={}){e.store;let t=e.store?.getState(),n=K(e.items,t?.items,e.defaultItems,[]),r=ZP(e.store),i=r?.__unstableCollectionLookup??{controlledItems:new Map(n.map(e=>[e.id,e])),registeredItems:new Map,controlledItemsSource:n,propagatedItems:n},{controlledItems:a,registeredItems:o}=i,s={},c={},l={items:n,renderedItems:K(t?.renderedItems,[])},u=VP(l,e.store),d=Object.assign(VP({items:n,renderedItems:l.renderedItems},r),{__unstableCollectionLookup:i}),f=e=>{let t=fM(e,e=>e.element);d.setState(`renderedItems`,t),u.setState(`renderedItems`,t)},p=e=>{if(e!==i.controlledItemsSource){i.controlledItemsSource=e,a.clear();for(let t of e)a.set(t.id,t)}},m=(e,t)=>{e===`items`?u.setState(`items`,e=>{let n=xj(t,e);return n===e?e:(i.propagatedItems=n,p(n),n)}):u.setState(e,t)};HP(u,()=>UP(d)),r||(WP(u,[`items`],({items:e})=>{e!==i.propagatedItems&&(i.propagatedItems=e,p(e))}),HP(d,()=>KP(d,[`items`],({items:e})=>{i.propagatedItems=e,u.setState(`items`,e)}))),HP(d,()=>KP(d,[`renderedItems`],e=>{if(e.renderedItems!==u.getState().renderedItems&&f(e.renderedItems),typeof IntersectionObserver!=`function`)return;let t=!0,n=0,r=()=>{t?t=!1:(cancelAnimationFrame(n),n=requestAnimationFrame(()=>f(e.renderedItems)))},i=XP(e.renderedItems),a=new IntersectionObserver(r,{root:i});for(let t of e.renderedItems)t.element&&a.observe(t.element);return()=>{cancelAnimationFrame(n),a.disconnect()}}));let h=(e,t,n)=>{let r=n?.registeredItems,i=n?.controlledItems;return n=>{let a=r?.get(n.id),o=!!a||!!i?.has(n.id),s;return d.setState(e,e=>{let i=t.ids||e.length>=QP&&!o?$P(e,t):void 0,a=i&&!i.has(n.id)?-1:e.findIndex(({id:e})=>e===n.id),c=e.slice();if(a!==-1){s=e[a];let t={...s,...n};c[a]=t,r?.set(n.id,t)}else c.push(n),r?.set(n.id,n),i?.add(n.id);return(t.ids||a===-1&&c.length>=QP)&&eF(c,t,i),c}),()=>{r&&(a?r.set(n.id,a):r.delete(n.id)),d.setState(e,e=>{let r=t.ids?$P(e,t):void 0;if(!s){let i=e.filter(({id:e})=>e!==n.id);return r?.delete(n.id),t.ids&&eF(i,t,r),i}let i=e.findIndex(({id:e})=>e===n.id);if(i===-1)return e;let a=e.slice();return a[i]=s,t.ids&&eF(a,t,r),a})}}},g=h(`items`,s,i),_=h(`renderedItems`,c);return{...u,setState:m,registerItem:g,renderItem:e=>Ej(g(e),_(e)),item:e=>e?o.size?o.get(e)??a.get(e)??null:a.get(e)??null:null,__unstablePrivateStore:d}}var nF={id:null};function rF(e,t){return e.find(e=>t?!e.disabled&&e.id!==t:!e.disabled)}function iF(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n&&!n.disabled)return n}}function aF(e,t){return e.filter(e=>t?!e.disabled&&e.id!==t:!e.disabled)}function oF(e,t){return e.filter(e=>e.rowId===t)}function sF({items:e,fromIndex:t,step:n,rowId:r,excludeId:i}){for(let a=t;a>=0&&a<e.length;a+=n){let t=e[a];if(!t||t.rowId!==r||t.disabled)continue;let n=t.id;if(i==null||n!==i)return n}}function cF(e,t,n=!1){let r=e.findIndex(e=>e.id===t);return[...e.slice(r+1),...n?[nF]:[],...e.slice(0,r)]}var lF=48,uF=4;function dF(e){let t=[],n,r;for(let i of e){let e=i.rowId;if(n&&r===e){n.push(i);continue}let a=t.find(t=>t[0]?.rowId===e);a?(a.push(i),n=a):(n=[i],t.push(n)),r=e}return t}function fF(e){let t=e[0];if(!t)return[];let n=1;for(;n<e.length&&e[n]?.rowId===t.rowId;)n+=1;let r=e.slice(0,n);if(n===e.length)return[r];let i=[r],a;for(;n<e.length;n+=1){let t=e[n];if(!t)continue;let r=a?a.get(t.rowId):i.find(e=>e[0]?.rowId===t.rowId);if(r){r.push(t);continue}let o=[t];i.push(o),a?a.set(t.rowId,o):i.length===uF&&(a=new Map(i.map(e=>[e[0]?.rowId,e])))}return i}function pF(e){return e.length>=lF?fF(e):dF(e)}function mF(e){let t=0;for(let{length:n}of e)n>t&&(t=n);return t}function hF(e){return{id:`__EMPTY_ITEM__`,disabled:!0,rowId:e}}function gF(e,t,n){let r=mF(e);for(let i of e)for(let e=0;e<r;e+=1){let r=i[e];if(!r||n&&r.disabled){let r=e===0&&n?rF(i):i[e-1];i[e]=r&&t!==r.id&&n?r:hF(r?.rowId)}}return e}function _F(e){let t=pF(e),n=mF(t),r=[];for(let e=0;e<n;e+=1)for(let n of t){let t=n[e];t&&r.push({...t,rowId:t.rowId?`${e}`:void 0})}return r}function vF(e={}){let t=e.store?.getState(),n=tF(e),r=K(e.activeId,t?.activeId,e.defaultActiveId),i=K(t?.compositeElement,t?.baseElement,null),a=K(e.compositeElementInFocusOrder,e.includesBaseElement,t?.compositeElementInFocusOrder,t?.includesBaseElement,r===null),o=VP({...n.getState(),id:K(e.id,t?.id)??`id-${Math.random().toString(36).slice(2,8)}`,activeId:r,compositeElement:i,baseElement:i,compositeElementInFocusOrder:a,includesBaseElement:a,moves:K(t?.moves,0),orientation:K(e.orientation,t?.orientation,`both`),rtl:K(e.rtl,t?.rtl,!1),virtualFocus:K(e.virtualFocus,t?.virtualFocus,!1),focusLoop:K(e.focusLoop,t?.focusLoop,!1),focusWrap:K(e.focusWrap,t?.focusWrap,!1),focusShift:K(e.focusShift,t?.focusShift,!1)},n,e.store);HP(o,()=>Ej(GP(o,[`compositeElement`],e=>{o.setState(`baseElement`,e.compositeElement)}),GP(o,[`baseElement`],e=>{o.setState(`compositeElement`,e.baseElement)}),GP(o,[`compositeElementInFocusOrder`],e=>{o.setState(`includesBaseElement`,e.compositeElementInFocusOrder)}),GP(o,[`includesBaseElement`],e=>{o.setState(`compositeElementInFocusOrder`,e.includesBaseElement)}))),HP(o,()=>GP(o,[`renderedItems`,`activeId`],e=>{o.setState(`activeId`,t=>t===void 0?rF(e.renderedItems)?.id:t)}));let s=(e=`next`,t={})=>{let r=o.getState(),i=K(t.compositeElementInFocusOrder,t.includesBaseElement,r.compositeElementInFocusOrder),{skip:a=0,activeId:s=r.activeId,focusShift:c=r.focusShift,focusLoop:l=r.focusLoop,focusWrap:u=r.focusWrap,renderedItems:d=r.renderedItems,rtl:f=r.rtl}=t,p=e===`up`||e===`down`,m=e===`next`||e===`down`,h=m?f&&!p:!f||p,g=c&&!a;if(!a&&!u&&!i&&s!=null&&(!p||!g&&!d.some(e=>e.rowId!=null))){let e=-1;if(d===r.renderedItems){let t=d[0];if(t&&n.item(t.id)===t){let t=n.item(s);t?.id===s&&(e=d.indexOf(t))}}e===-1&&(e=d.findIndex(e=>e.id===s));let t=d[e];if(t){let n=h?-1:1,r=sF({items:d,fromIndex:e+n,step:n,rowId:t.rowId,excludeId:s});return r===void 0?l&&(p?l!==`horizontal`:l!==`vertical`)?sF({items:d,fromIndex:n===1?0:d.length-1,step:n,rowId:t.rowId,excludeId:s}):void 0:r}}let _=p?vj(gF(pF(d),s,g)):d;if(_=h?yj(_):_,_=p?_F(_):_,s==null)return rF(_)?.id;let v=_.find(e=>e.id===s);if(!v)return rF(_)?.id;let y=_.some(e=>e.rowId),b=_.indexOf(v),x=_.slice(b+1),S=oF(x,v.rowId);if(a){let e=aF(S,s);return(e.slice(a)[0]||e[e.length-1])?.id}let C=l&&(p?l!==`horizontal`:l!==`vertical`),w=y&&u&&(p?u!==`horizontal`:u!==`vertical`),T=m?(!y||p)&&C&&i:p?i:!1;if(C)return rF(cF(w&&!T?_:oF(_,v.rowId),s,T),s)?.id;if(w){let e=rF(T?S:x,s);return T?e?.id||null:e?.id}let E=rF(S,s);return!E&&T?null:E?.id},c=(e,t)=>typeof t==`number`?s(e,{skip:t}):s(e,t);return{...n,...o,setCompositeElement:e=>o.setState(`compositeElement`,e),setBaseElement:e=>o.setState(`compositeElement`,e),setActiveId:e=>o.setState(`activeId`,e),move:e=>{e!==void 0&&(o.setState(`activeId`,e),o.setState(`moves`,e=>e+1))},first:()=>rF(o.getState().renderedItems)?.id,last:()=>iF(o.getState().renderedItems)?.id,next:e=>c(`next`,e),previous:e=>c(`previous`,e),down:e=>c(`down`,e),up:e=>c(`up`,e)}}var yF=cF,bF=rF,xF=pF,SF=new WeakSet;function CF(e){Jj(e)===e&&(SF.add(e),queueMicrotask(()=>SF.delete(e)))}function wF(e){SF.delete(e)}function TF(e,t){let{virtualFocus:n,compositeElement:r}=e.getState();if(!n||!r||!nM(r)){t();return}let i=r.scrollLeft,a=r.scrollTop;t(),r.scrollLeft=i,r.scrollTop=a}function EF(e){let t=e.getState();return`contentElement`in t?t.contentElement:null}function DF(e){let{compositeElement:t}=e.getState(),n=aN(t);return n?t?.contains(n)||FF(e,n)?!0:!!EF(e)?.contains(n):!1}function OF({store:e,id:t,focus:n,markedOnly:r,requireFocus:i,focusOwner:a,scrollIntoView:o,onConsume:s}){let c=null,l,u=!1,d=!1,f=!1,p=!1,m=!1,h=e.getState().compositeElement,g=aN(h),_=i?a||g:null,v=!!h?.contains(g),y=t=>{if(!_)return!0;let n=aN(_);return n===_||n===t||DF(e)},b=e=>{if(`mounted`in e){if(e.mounted)p=!0;else if(p)return!0}if(`open`in e){if(e.open)m=!0;else if(m)return!0}return t!=null&&e.activeId!=null&&e.activeId!==t},x=(t,n)=>{if(!(`open`in t)||t.open)return!1;let r=EF(e);if(!r?.contains(n))return!1;let{compositeElement:i}=t;return!i||r.contains(i)?!1:tM(n)},S=n=>{let r=AF(e,l??(t===void 0?n.activeId:t));return r?.element?.isConnected?(l=r.id,r.element):null},C,w,T=()=>{f=!0,C?.(),w?.()},E=!1,ee=()=>{E||(E=!0,s?.())},te=()=>{if(!f)return ee(),T()},ne=()=>{if(f)return;let t=e.getState();if(b(t))return te();let i=!1;if(!c){if(c=S(t),!c)return}else if(!c.isConnected&&(i=u&&!d&&Jj(c)===q(c).body,c=S(t),!c))return te();if(i)u=!1;else if(!y(c))return te();let a=n&&v&&x(t,c);if(a){let{activeId:e}=t;if(e!=null&&e!==l)return te()}if(n&&!u&&!a){u=!0,ee(),d=!1;let t=c;C?.();let n=()=>{d=!SF.has(t)},r=()=>{d=!1};if(t.addEventListener(`blur`,n),t.addEventListener(`focus`,r),C=()=>{t.removeEventListener(`blur`,n),t.removeEventListener(`focus`,r)},TF(e,()=>{t.focus({preventScroll:!0})}),f)return}if(r&&!c.hasAttribute(`data-autofocus`))return a?void 0:te();tM(c)&&(`unstable_placing`in t&&t.unstable_placing||(a||te(),o?o(c):c.scrollIntoView({block:`nearest`,inline:`nearest`})))};return w=WP(e,[`activeId`,`items`,`mounted`,`open`,`unstable_placing`],ne),ne(),Object.assign(T,{settle:te})}function kF(e){let t=(0,D.useRef)(null),n=(0,D.useRef)(e),r=(0,D.useCallback)(()=>{t.current?.(),t.current=null},[]),i=(0,D.useCallback)(r=>{if(!e||n.current!==e)return;t.current?.settle(),t.current=null;let i=OF({store:e,...r});return t.current=i,i},[e]);return J(()=>(n.current=e,()=>{n.current=void 0,r()}),[e,r]),i}function AF(e,t){return t&&e.item(t)||null}function jF(e,t=!1){if(nM(e))e.setSelectionRange(t?e.value.length:0,e.value.length);else if(e.isContentEditable){let n=q(e).getSelection();n?.selectAllChildren(e),t&&n?.collapseToEnd()}}var MF=Symbol(`FOCUS_SILENTLY`);function NF(e){e[MF]=!0,e.focus({preventScroll:!0})}function PF(e){let t=e[MF];return delete e[MF],t}function FF(e,t,n){if(!t||t===n)return!1;let r=e.item(t.id);return!(!r||n&&r.element===n)}var IF=()=>()=>{};function LF(e){return Array.isArray(e)}function RF(e,t){return e===t||e!==e&&t!==t}function zF(e,t){if(e?.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n];if(!RF(r,t[n]))return!1}return!0}function BF(e){let[t,n]=D.useState(()=>e===null?null:[...e]);if(e===null)return t!==null&&n(null),null;if(zF(t,e))return t;let r=[...e];return n(r),r}function $(e,t=jj,n){let r=BF(LF(t)?t:typeof t==`function`?null:[t]),i=D.useCallback(t=>!e||r?.length===0?IF():WP(e,r,t),[e,r]),a=()=>{let r=e?.getState();if(LF(t))return n?.(r);if(typeof t==`function`)return t(r);if(r&&Tj(r,t))return r[t]};return(0,zE.useSyncExternalStore)(i,a,a)}function VF(e,t){let n=[],r=!1;for(let t in e){let i=e[t];i!==void 0&&(typeof i==`function`?r=!0:n.includes(i)||n.push(i))}if(!r)return n;if(!t)return null;for(let e of t)n.includes(e)||n.push(e);return n}function HF(e,t,n){let r=LF(t)?n??{}:t,i=LF(t)?t:void 0,a=D.useRef({}),o=BF(VF(r,i)),s=D.useCallback(t=>!e||o?.length===0?IF():WP(e,o,t),[e,o]),c=()=>{let t=e?.getState(),n=!1,i=a.current;for(let e in r){let a=r[e];if(a===void 0)continue;if(typeof a==`function`){let r=a(t);Object.is(r,i[e])||(i[e]=r,n=!0)}if(typeof a==`function`)continue;let o=t&&Tj(t,a)?t[a]:void 0;Object.is(o,i[e])||(i[e]=o,n=!0)}return n&&(a.current={...i}),a.current};return(0,zE.useSyncExternalStore)(s,c,c)}function UF(e,t,n,r){let i=Tj(t,n)?t[n]:void 0,a=r?t[r]:void 0,o=!!a,s=gN({value:i,setValue:a});J(()=>{if(o)return WP(e,[n],(e,t)=>{let{value:r,setValue:i}=s.current;i&&(RF(e[n],t[n])||RF(e[n],r)||i(e[n]))})},[e,n,o,s]),J(()=>{if(i!==void 0)return e.setState(n,i),KP(e,[n],()=>{i!==void 0&&e.setState(n,i)})})}function WF(e,t){let[n,r]=D.useState(()=>e(t));J(()=>UP(n),[n]);let i=D.useCallback(e=>$(n,e),[n]);return[D.useMemo(()=>({...n,useState:i}),[n,i]),Y(()=>{r(n=>e({...t,...n.getState()}))})]}var GF=`button`;function KF(e){return rM(e)?!0:e.tagName===`INPUT`&&!$j(e)}function qF(e,t=!1){let n=e.clientHeight,{top:r}=e.getBoundingClientRect(),i=Math.max(n*.875,n-40)*1.5,a=t?n-i+r:i+r;return e.tagName===`HTML`?a+e.scrollTop:a}function JF(e,t=!1){let{top:n}=e.getBoundingClientRect();return t?n+e.clientHeight:n}function YF(e,t,n,r=!1){if(!t||!n)return;let{renderedItems:i}=t.getState(),a=dM(e);if(!a)return;let o=qF(a,r),s,c;for(let e=0;e<i.length;e+=1){let i=s;if(s=n(e),!s)break;if(s===i)continue;let a=AF(t,s)?.element;if(!a)continue;let l=JF(a,r)-o,u=Math.abs(l);if(r&&l<=0||!r&&l>=0){c!==void 0&&c<u&&(s=i);break}c=u}return s}function XF(e,t){return!bM(e)&&FF(t,e.target)}var ZF=Q(function({store:e,rowId:t,preventScrollOnKeyDown:n=!1,moveOnKeyPress:r=!0,tabbable:i=!1,getItem:a,typeaheadText:o,"aria-setsize":s,"aria-posinset":c,unstable_scrollIntoView:l,...u}){let d=gP();e||=d;let f=$M(u),p=SN(u.id),m=(0,D.useRef)(null),h=(0,D.useRef)(null),g=(0,D.useCallback)(e=>{let t=h.current;!e&&t&&CF(t),e&&wF(e),h.current=e},[]),_=(0,D.useContext)(xP),v=Ij(u),y=v&&!f,b=v&&u.focusable===!1,x=u.shouldRegisterItem,S=e=>{if(t)return t;if(e&&_?.compositeElement&&_.compositeElement===e.compositeElement)return _.id},{rowId:C,compositeElement:w,ariaSetSize:T,ariaPosInSet:E}=HF(e,[`compositeElement`,`renderedItems`],{rowId:S,compositeElement(e){return e?.compositeElement||void 0},ariaSetSize(e){if(s!=null)return s;if(e&&_?.ariaSetSize&&_.compositeElement===e.compositeElement)return _.ariaSetSize},ariaPosInSet(e){if(c!=null)return c;if(!e||!_?.ariaPosInSet||_.compositeElement!==e.compositeElement)return;let t=S(e),n=e.renderedItems.filter(e=>e.rowId===t);return _.ariaPosInSet+n.findIndex(e=>e.id===p)}}),{isActiveItem:ee,isTabbable:te}=HF(e,[`activeId`,`compositeElement`,`renderedItems`,`virtualFocus`,`items`],{isActiveItem(e){return!!e&&e.activeId===p},isTabbable(t){if(!t||!t.compositeElement&&!t.renderedItems.length)return!0;if(t.virtualFocus)return!1;if(!t.renderedItems.length||i)return!0;if(t.activeId===null)return!1;let n=e?.item(t.activeId);return n?.disabled||!n?.element?!0:t.activeId===p}}),ne=(0,D.useCallback)(e=>{let t=(e.element?nN(e.element):void 0)??(b||y),n={...e,id:p||e.id,rowId:C,disabled:t,children:e.element?.textContent,typeaheadText:o};return a?a(n):n},[p,C,b,y,o,a]),re=u.onFocus,ie=(0,D.useRef)(!1),ae=(0,D.useRef)(null),oe=kF(e),se=Y(t=>{if(re?.(t),t.defaultPrevented||yM(t)||!p||!e||XF(t,e))return;let{virtualFocus:n,compositeElement:r}=e.getState();if(e.setActiveId(p),rM(t.currentTarget)&&jF(t.currentTarget),!n){bM(t)&&e.item(p)&&oe({id:p,markedOnly:!0,requireFocus:!0,scrollIntoView:l});return}if(!bM(t)||KF(t.currentTarget))return;let i=(t,n)=>{if(!PM(n))return;let r=t===n||FF(e,t);e.item(p)&&oe({id:p,markedOnly:!0,requireFocus:!0,scrollIntoView:l}),ie.current=!0,r?NF(n):n.focus({preventScroll:!0})};if(r?.isConnected){i(t.relatedTarget,r);return}if(x===!1)return;let{currentTarget:a,relatedTarget:o}=t,s=()=>{ae.current?.(),ae.current=null};s(),ae.current=WP(e,null,()=>{if(Jj(a)!==a){s();return}let t=e.getState(),n=t.compositeElement;n?.isConnected&&(s(),t.virtualFocus&&i(o,n))})}),ce=u.onBlurCapture,le=Y(t=>{ce?.(t),t.defaultPrevented||e?.getState()?.virtualFocus&&ie.current&&(ie.current=!1,t.preventDefault(),t.stopPropagation())}),ue=u.onKeyDown,de=DN(n),fe=DN(r),pe=Y(t=>{if(ue?.(t),t.defaultPrevented||!bM(t)||!e)return;let{currentTarget:n}=t,r=e.getState(),i=!!e.item(p)?.rowId,a=r.orientation!==`horizontal`,o=r.orientation!==`vertical`,s=()=>!(!i&&!o&&r.compositeElement&&nM(r.compositeElement)),c={ArrowUp:(i||a)&&e.up,ArrowRight:(i||o)&&e.next,ArrowDown:(i||a)&&e.down,ArrowLeft:(i||o)&&e.previous,Home:()=>{if(s())return!i||t.ctrlKey?e?.first():e?.previous(-1)},End:()=>{if(s())return!i||t.ctrlKey?e?.last():e?.next(-1)},PageUp:()=>YF(n,e,e?.up,!0),PageDown:()=>YF(n,e,e?.down)}[t.key];if(c){if(rM(n)){let e=aM(n),r=o&&t.key===`ArrowLeft`,i=o&&t.key===`ArrowRight`,s=a&&t.key===`ArrowUp`,c=a&&t.key===`ArrowDown`;if(i||c){let{length:t}=iM(n);if(e.end!==t)return}else if((r||s)&&e.start!==0)return}let r=c();if(de(t)||r!==void 0){if(!fe(t))return;t.preventDefault(),e.move(r)}}}),me=(0,D.useMemo)(()=>({id:p,compositeElement:w}),[p,w]);return u=ON(u,e=>(0,O.jsx)(bP.Provider,{value:me,children:e}),[me]),u={"data-active-item":ee||void 0,...u,id:p,ref:vN(m,g,u.ref),tabIndex:te?u.tabIndex:-1,onFocus:se,onBlurCapture:le,onKeyDown:pe},u=cP(u),u=mP({store:e,...u,getItem:ne,shouldRegisterItem:p?x:!1}),{...u,"aria-setsize":T,"aria-posinset":E}}),QF=zN(X(function(e){return Z(GF,ZF(gj(e)))})),$F=BN([vP],[yP]);$F.useContext;var eI=$F.useScopedContext,tI=$F.useProviderContext,nI=$F.ContextProvider,rI=$F.ScopedContextProvider,iI=`button`,aI=Q(function({store:e,getItem:t,...n}){let r=eI();e||=r,Nj(e,!1);let i=SN(),a=n.id||i,o=Ij(n),s=(0,D.useCallback)(e=>{let n={...e,dimmed:o};return t?t(n):n},[o,t]),c=n.onClick,l=Y(t=>{c?.(t),t.defaultPrevented||e?.setSelectedId(a)}),u=$(e.panels,[`items`],()=>e.panel(a)?.id),d=i?n.shouldRegisterItem:!1,f=$(e,[`selectedId`],e=>!!a&&e.selectedId===a),p=$(e.composite?e:void 0,[`activeId`,`items`,`selectedId`],t=>!t||!a?!1:t.activeId===a||t.selectedId===a&&!e.item(t.activeId)),m=f||(n.accessibleWhenDisabled??!0);if($(e.combobox||e.composite,`virtualFocus`)&&(n={...n,tabIndex:-1}),n={role:`tab`,"aria-selected":f,"aria-controls":u||void 0,...n,id:a,onClick:l},e.composite){let t={id:a,accessibleWhenDisabled:m,store:e.composite,shouldRegisterItem:p&&d,rowId:n.rowId,render:n.render};n={...n,render:(0,O.jsx)(QF,{...t,render:e.combobox&&e.composite!==e.combobox?(0,O.jsx)(QF,{...t,store:e.combobox}):t.render})}}return n=ZF({store:e,...n,accessibleWhenDisabled:m,getItem:s,shouldRegisterItem:d}),n}),oI=zN(X(function(e){return Z(iI,aI(gj(e)))})),sI=new WeakMap;function cI(e,t,n){let{KeyboardEvent:r}=qj(e),i=new r(t.type,n);return sI.set(i,lI(t)),e.dispatchEvent(i)}function lI(e){return sI.get(e)??e}var uI=Symbol(`cancelled`),dI=new WeakMap;function fI(e,t){let n=e.getState,r=dI.get(n);if(r)return r;let i=t?.getState();if(t&&i&&Tj(i,`moves`)&&Tj(i,`activeId`)){let e=fI(t);return dI.set(n,e),e}let a={consumedBy:null,targetId:e.getState().activeId};return dI.set(n,a),GP(e,[`moves`,`activeId`],(e,t)=>{e.moves===t.moves?e.activeId!==t.activeId&&(a.targetId=uI):(a.consumedBy=null,a.targetId=e.activeId)}),a}var pI=`div`;function mI(e){return e.some(e=>!!e.rowId)}function hI(e){let t=e.target;return t&&!nM(t)?!1:e.key.length===1&&!e.ctrlKey&&!e.metaKey}function gI(e){return e.key===`Shift`||e.key===`Control`||e.key===`Alt`||e.key===`Meta`}function _I(e,t,n){return Y(r=>{if(t?.(r),r.defaultPrevented||r.isPropagationStopped()||!bM(r)||gI(r)||hI(r))return;let i=AF(e,e.getState().activeId)?.element;if(!i)return;let{view:a,...o}=r;i!==n?.current&&i.focus({preventScroll:!0}),cI(i,r.nativeEvent,o)||r.preventDefault(),r.currentTarget.contains(i)&&r.stopPropagation()})}function vI(e){return bF(vj(yj(xF(e))))}function yI(e,t){let{consumedBy:n}=fI(e);return!n||n===t}function bI(e,t,n){e.getState().moves===n&&(fI(e).consumedBy=t)}var xI=zN(function({store:e,focusOnMove:t,previousElementRef:n,present:r,scrollIntoView:i}){let a=$(e,`moves`),o=$(e,`compositeElement`),s=(0,D.useMemo)(()=>({}),[e.getState]);return(0,D.useEffect)(()=>{let n=fI(e);if(!a||!t||!yI(e,s))return;let{activeId:o}=e.getState();if(o!=null&&o===n.targetId)return r({id:o,requireFocus:DF(e),focus:!0,scrollIntoView:i,onConsume:()=>bI(e,s,a)})},[e,a,t,o,r,i,s]),J(()=>{let t=fI(e);if(!a||!o||!yI(e,s))return;let{activeId:r}=e.getState();if(r!==null||r!==t.targetId)return;bI(e,s,a);let i=n.current;n.current=null,i&&TM(i,{relatedTarget:o}),GM(o)||(PM(o)&&o.scrollIntoView({block:`nearest`,inline:`nearest`}),o.focus({preventScroll:!0}))},[e,a,o,n,s]),null}),SI=Q(function({store:e,composite:t=!0,focusOnMove:n=t,moveOnKeyPress:r=!0,unstable_scrollIntoView:i,...a}){let o=_P();e||=o,Nj(e,!1);let s=(0,D.useRef)(null),c=(0,D.useRef)(null),l=kF(e),[,u]=_N(t?e.setCompositeElement:null),d=$(e,`virtualFocus`),f=$(e,t&&d?[`activeId`]:[],e=>t&&d?e.activeId:null);J(()=>{if(!e||!t||!d)return;let n=c.current;if(c.current=null,!n)return;let r=AF(e,f)?.element||Jj(n);r!==n&&TM(n,{relatedTarget:r})},[e,f,d,t]);let p=_I(e,a.onKeyDownCapture,c),m=_I(e,a.onKeyUpCapture,c),h=a.onFocusCapture,g=Y(t=>{if(h?.(t),t.defaultPrevented||!e)return;let{virtualFocus:n}=e.getState();if(!n)return;let r=t.relatedTarget,i=PF(t.currentTarget);bM(t)&&i&&(t.stopPropagation(),c.current=r)}),_=a.onFocus,v=Y(n=>{if(_?.(n),n.defaultPrevented||!t||!e)return;let{relatedTarget:r}=n,{virtualFocus:a}=e.getState();if(a)bM(n)&&!FF(e,r)&&queueMicrotask(()=>l({focus:!0,markedOnly:!0,requireFocus:!0,scrollIntoView:i}));else if(bM(n)){if(!FF(e,r)){let{activeId:t}=e.getState();t!=null&&l({id:t,markedOnly:!0,requireFocus:!0,scrollIntoView:i})}e.setActiveId(null)}}),y=a.onBlurCapture,b=Y(t=>{if(y?.(t),t.defaultPrevented||!e)return;let{virtualFocus:n,activeId:r,compositeElement:i}=e.getState();if(!n||t.currentTarget!==i)return;let a=AF(e,r)?.element,o=t.relatedTarget,s=FF(e,o),l=c.current;c.current=null,bM(t)&&s?(o===a?l&&l!==o&&TM(l,t):a?TM(a,t):l&&TM(l,t),t.stopPropagation()):!FF(e,t.target)&&a&&TM(a,t)}),x=a.onKeyDown,S=DN(r),C=Y(t=>{if(x?.(t),t.nativeEvent.isComposing||t.defaultPrevented||!e||!bM(t))return;let{orientation:n,items:r,renderedItems:i,activeId:a,rtl:o}=e.getState(),s=AF(e,a);if(s?.element?.isConnected)return;let c=s&&a!=null,l=c?r:i,u=n!==`horizontal`,d=n!==`vertical`,f=mI(l);if((t.key===`ArrowLeft`||t.key===`ArrowRight`||t.key===`Home`||t.key===`End`)&&nM(t.currentTarget))return;let p={ArrowUp:(f||u)&&(()=>c?e.up({activeId:a,renderedItems:l}):f?vI(i)?.id:e?.last()),ArrowRight:(f||d)&&(()=>c?e.next({activeId:a,renderedItems:l}):o?e.last():e.first()),ArrowDown:(f||u)&&(()=>c?e.down({activeId:a,renderedItems:l}):e.first()),ArrowLeft:(f||d)&&(()=>c?e.previous({activeId:a,renderedItems:l}):o?e.first():e.last()),Home:e.first,End:e.last,PageUp:e.first,PageDown:e.last}[t.key];if(p){let n=p();if(n!==void 0){if(!S(t))return;t.preventDefault(),e.move(n)}}});return a=ON(a,r=>(0,O.jsxs)(yP,{value:e,children:[r,t&&(0,O.jsx)(xI,{store:e,focusOnMove:n,previousElementRef:c,present:l,scrollIntoView:i})]}),[e,t,n,l]),a={"aria-activedescendant":$(e,t&&d?[`items`]:[],()=>{if(e&&t&&d)return AF(e,f)?.id}),...a,ref:vN(s,u,a.ref),onKeyDownCapture:p,onKeyUpCapture:m,onFocusCapture:g,onFocus:v,onBlurCapture:b,onKeyDown:C},a=iP({focusable:$(e,t&&!d?[`activeId`]:[],e=>t&&(d||e.activeId===null)),...a}),a});X(function(e){return Z(pI,SI(e))});var CI=`div`,wI=Q(function({store:e,...t}){let n=tI();e||=n,Nj(e,!1);let r=$(e,[`orientation`],e=>e.orientation===`both`?void 0:e.orientation);return t=ON(t,t=>(0,O.jsx)(rI,{value:e,children:t}),[e]),e.composite&&(t={focusable:!1,...t}),t={role:`tablist`,"aria-orientation":r,...t},t=SI({store:e,...t}),t}),TI=X(function(e){return Z(CI,wI(e))}),EI=BN();EI.useContext,EI.useScopedContext;var DI=EI.useProviderContext,OI=EI.ContextProvider,kI=EI.ScopedContextProvider,AI=BN([OI],[kI]);AI.useContext,AI.useScopedContext;var jI=AI.useProviderContext,MI=AI.ContextProvider,NI=AI.ScopedContextProvider,PI=(0,D.createContext)(void 0),FI=(0,D.createContext)(void 0),II=`div`;function LI(e,t){let n=setTimeout(t,e);return()=>clearTimeout(n)}function RI(e){let t=e?.trim()||`0s`,n=t.endsWith(`ms`)?1:1e3,r=Number.parseFloat(t)*n;return Number.isNaN(r)?0:r}function zI(e,t,n){let r=e.split(`,`),i=t.split(`,`),a=n.split(`,`),o=0;for(let[e,t]of r.entries()){if(t.trim()===`none`)continue;let n=RI(i[e%i.length]),r=RI(a[e%a.length]);o=Math.max(o,n+r)}return o}function BI(e){let{transitionProperty:t,transitionDuration:n,transitionDelay:r,animationName:i,animationDuration:a,animationDelay:o}=getComputedStyle(e);return Math.max(zI(t,r,n),zI(i,o,a))}function VI(e,t,n){return!n&&t!==!1&&(!e||!!t)}var HI=Q(function({store:e,alwaysVisible:t,unstable_otherElementRef:n,...r}){let i=DI();e||=i,Nj(e,!1);let a=(0,D.useRef)(null),o=SN(r.id),[s,c]=(0,D.useState)(null),{open:l,mounted:u,animated:d,contentElement:f}=HF(e,{open:`open`,mounted:`mounted`,animated:`animated`,contentElement:`contentElement`}),p=$(e.disclosure,`contentElement`),m=(0,D.useRef)(!1);J(()=>{a.current&&e?.setContentElement(a.current)},[e]),J(()=>{let t;return e?.setState(`animated`,e=>(t=e,!0)),()=>{t!==void 0&&e?.setState(`animated`,t)}},[e]),J(()=>{if(!d)l?m.current&&(m.current=!1,c(`enter`)):(m.current=!0,c(null));else if(!f?.isConnected)c(null);else return Mj(()=>{c(l?`enter`:u?`leave`:null)})},[d,f,l,u]),J(()=>{if(!e||!d||!s||!f)return;let t=()=>e?.setState(`animating`,!1),r=()=>(0,RE.flushSync)(t);if(s===`leave`&&l||s===`enter`&&!l)return;if(typeof d==`number`)return LI(d,r);let i=[f];p&&i.push(p);let a=n?.current;a&&i.push(a);let o=Math.max(...i.map(BI));if(!o)s===`enter`&&e.setState(`animated`,!1),t();else return LI(Math.max(o-1e3/60,0),r)},[e,d,f,p,n,l,s]),r=ON(r,t=>(0,O.jsx)(NI,{value:e,children:t}),[e]);let h=VI(u,r.hidden,t),g=r.style,_=(0,D.useMemo)(()=>h?{...g,display:`none`}:g,[h,g]);return r={"data-open":l||void 0,"data-enter":s===`enter`||void 0,"data-leave":s===`leave`||void 0,hidden:h,...r,id:o,ref:vN(o?e.setContentElement:null,a,r.ref),style:_},Rj(r)}),UI=X(function(e){return Z(II,HI(e))});X(function({unmountOnHide:e,...t}){let n=DI();return $(t.store||n,[`mounted`],t=>!e||t?.mounted)===!1?null:(0,O.jsx)(UI,{...t})});function WI(e){let t=e?.unstable_onHideRequest,n=e?.unstable_requestHide;if(t&&n)return{onHideRequest:t,requestHide:n}}function GI(e={}){let t=e.store||e.disclosure?YP(e.store,qP(e.disclosure,[`contentElement`,`disclosureElement`])):void 0,n=t?.getState(),r=K(e.open,n?.open,e.defaultOpen,!1),i=K(e.animated,n?.animated,!1),a={open:r,animated:i,animating:!!i&&r,mounted:r,contentElement:K(n?.contentElement,null),disclosureElement:K(n?.disclosureElement,null)},o=t?VP(a,t):VP(a);HP(o,()=>GP(o,[`animated`,`animating`],e=>{e.animated||o.setState(`animating`,!1)})),HP(o,()=>WP(o,[`open`],()=>{o.getState().animated&&o.setState(`animating`,!0)})),HP(o,()=>GP(o,[`open`,`animating`],e=>{o.setState(`mounted`,e.open||e.animating)}));let s=WI(e.store),c=new Map,l=s?.onHideRequest??(e=>e===u?()=>{}:(c.set(e,(c.get(e)??0)+1),()=>{let t=c.get(e);t!=null&&(t>1?c.set(e,t-1):c.delete(e))})),u=s?.requestHide??(e=>{let t=[...c.keys()],n=r=>{let i=t[r];i?i(()=>n(r+1)):e()};n(0)});HP(o,()=>{if(e.disclosure)return l(e.disclosure.unstable_requestHide)});let d=e=>{let{open:t}=o.getState(),n=xj(e,t);!t||n?o.setState(`open`,n):u(()=>o.setState(`open`,!1))};return{...o,disclosure:e.disclosure,setOpen:d,show:()=>o.setState(`open`,!0),hide:()=>d(!1),toggle:()=>d(e=>!e),unstable_onHideRequest:l,unstable_requestHide:u,stopAnimation:()=>o.setState(`animating`,!1),setContentElement:e=>o.setState(`contentElement`,e),setDisclosureElement:e=>o.setState(`disclosureElement`,e)}}function KI(e,t,n){return TN(t,[n.store,n.disclosure,t]),UF(e,n,`open`,`setOpen`),UF(e,n,`mounted`,`setMounted`),UF(e,n,`animated`),Object.assign(e,{disclosure:n.disclosure})}function qI(e={}){let[t,n]=WF(GI,e);return KI(t,n,e)}var JI=`div`,YI=Q(function({store:e,unmountOnHide:t,tabId:n,getItem:r,scrollRestoration:i,scrollElement:a,...o}){let s=tI();e||=s,Nj(e,!1);let c=(0,D.useRef)(null),l=SN(o.id),u=$(n?void 0:e.panels,[`items`],()=>n||e?.panels.item(l)?.tabId),d=qI({open:$(e,[`selectedId`],e=>!!u&&e.selectedId===u)}),f=$(d,`mounted`),p=(0,D.useRef)(null),m=Y(()=>{let e=c.current;return e?a?typeof a==`function`?a(e):`current`in a?a.current:a:e:null});(0,D.useEffect)(()=>{if(!i||!f)return;let e=m();if(!e)return;if(i===`reset`){e.scroll(0,0);return}if(!u)return;let t=p.current;t||(t=new Map,p.current=t);let n=t.get(u);e.scroll(n?.x??0,n?.y??0);let r=()=>{t.set(u,{x:e.scrollLeft,y:e.scrollTop})};return e.addEventListener(`scroll`,r),()=>{e.removeEventListener(`scroll`,r)}},[i,f,u,m]);let[h,g]=(0,D.useState)(!1);J(()=>{if(!f)return;let e=c.current;e&&g(!!zM(e))},[f,u]);let _=(0,D.useCallback)(e=>{let t={...e,id:l||e.id,tabId:n};return r?r(t):t},[l,n,r]),v=o.onKeyDown,y=Y(t=>{if(v?.(t),t.defaultPrevented||!e?.composite)return;let n={ArrowLeft:e.previous,ArrowRight:e.next,Home:e.first,End:e.last}[t.key];if(!n)return;let{selectedId:r}=e.getState(),i=n({activeId:r});i&&(t.preventDefault(),e.move(i))});return o=ON(o,t=>(0,O.jsx)(rI,{value:e,children:t}),[e]),o={role:`tabpanel`,"aria-labelledby":o[`aria-label`]==null&&u||void 0,...o,id:l,children:t&&!f?null:o.children,ref:vN(c,o.ref),onKeyDown:y},o=iP({focusable:!e.composite&&!h,...o}),o=HI({store:d,...o}),o=mP({store:e.panels,...o,getItem:_}),o}),XI=X(function(e){return Z(JI,YI(e))}),ZI=BN([MI],[NI]),QI=ZI.useContext;ZI.useScopedContext;var $I=ZI.useProviderContext,eL=ZI.ContextProvider,tL=ZI.ScopedContextProvider;(0,D.createContext)(null);var nL=BN([eL,vP],[tL,yP]),rL=nL.useContext;nL.useScopedContext;var iL=nL.useProviderContext;nL.ContextProvider,nL.ScopedContextProvider,(0,D.createContext)(void 0),(0,D.createContext)(!1),(0,D.createContext)(null);function aL(e,t,n){return TN(t,[n.store,t]),UF(e,n,`items`,`setItems`),e}function oL(e){return{id:SN(e.id),...e}}function sL(e,t,n){e=aL(e,t,n),fI(e,n.store),UF(e,n,`activeId`,`setActiveId`);let r={compositeElementInFocusOrder:n.compositeElementInFocusOrder??n.includesBaseElement};return UF(e,r,`compositeElementInFocusOrder`),UF(e,n,`virtualFocus`),UF(e,n,`orientation`),UF(e,n,`rtl`),UF(e,n,`focusLoop`),UF(e,n,`focusWrap`),UF(e,n,`focusShift`),e}var cL=BN([eL,vP],[tL,yP]),lL=cL.useContext,uL=cL.useScopedContext,dL=cL.useProviderContext,fL=cL.ContextProvider,pL=cL.ScopedContextProvider,mL=(0,D.createContext)(!1),hL=(0,D.createContext)(null);function gL(e){let t=e[0]?.element;if(!t)return;let n=Jj(t);if(n)return e.find(e=>e.element===n)}function _L(e,t){if(t!=null)return e.find(e=>e.id===t)}function vL(e){return!(!e||e.disabled||e.dimmed)}function yL(){let e=tF(),t=new Map;return GP(e,[`items`],e=>{t.clear();for(let n of e.items){let{tabId:e}=n;e!=null&&(t.has(e)||t.set(e,n))}}),{panels:e,panel:e=>e==null?null:t.get(e)||null}}function bL({composite:e,combobox:t,...n}={}){let r=[`items`,`renderedItems`,`moves`,`orientation`,`virtualFocus`,`compositeElementInFocusOrder`,`includesBaseElement`,`compositeElement`,`baseElement`,`focusLoop`,`focusShift`,`focusWrap`,`selectOnMove`],i=YP(n.store,qP(e,r),qP(t,r)),a=i?.getState(),o=vF({...n,store:i,compositeElementInFocusOrder:K(n.compositeElementInFocusOrder,n.includesBaseElement,a?.compositeElementInFocusOrder,a?.includesBaseElement,!1),orientation:K(n.orientation,a?.orientation,`horizontal`),focusLoop:K(n.focusLoop,a?.focusLoop,!0)}),{panels:s,panel:c}=yL(),l=VP({...o.getState(),selectedId:K(n.selectedId,a?.selectedId,n.defaultSelectedId),selectOnMove:K(n.selectOnMove,a?.selectOnMove,!0)},o,i);HP(l,()=>GP(l,[`moves`],()=>{let{activeId:e,selectOnMove:t}=l.getState();if(!t||!e)return;let n=o.item(e);vL(n)&&l.setState(`selectedId`,n.id)}));let u=!1,d;HP(l,()=>(u=!1,KP(l,[`selectedId`],(t,n)=>{if(u&&(u=!1,t.selectedId===d)||e&&t.selectedId===n.selectedId)return;let{activeId:r,renderedItems:i}=l.getState();if(r===t.selectedId)return;let a=gL(i),s=_L(i,t.selectedId);a&&vL(s)?o.move(s.id):l.setState(`activeId`,t.selectedId)}))),HP(l,()=>GP(l,[`selectedId`,`renderedItems`],e=>{if(e.selectedId!==void 0)return;let{activeId:t,renderedItems:n}=l.getState(),r=o.item(t);if(vL(r))l.setState(`selectedId`,r.id);else{let e=n.find(vL);l.setState(`selectedId`,e?.id)}})),HP(l,()=>GP(l,[`renderedItems`],e=>{let t=e.renderedItems;if(t.length)return GP(s,[`renderedItems`],e=>{let n=e.renderedItems;n.some(e=>!e.tabId)&&n.forEach((e,n)=>{if(e.tabId)return;let r=t[n];r&&s.renderItem({...e,tabId:r.id})})})}));let f=null;return HP(l,()=>{let n=()=>{f=l.getState().selectedId},r=()=>{let{selectedId:e}=l.getState();e!==f&&(u=!0,d=f,l.setState(`selectedId`,f))},i=!!e&&`setSelectedValue`in e,a=i?e:t;if(e&&!i&&`setSelectElement`in e)return Ej(GP(e,[`value`],n),GP(e,[`mounted`],r));if(a)return Ej(GP(a,[`selectedValue`],n),GP(a,[`mounted`],r))}),{...o,...l,panels:s,panel:c,setSelectedId:e=>l.setState(`selectedId`,e),select:e=>{l.setState(`selectedId`,e),o.move(e)}}}function xL(e,t,n){TN(t,[n.composite,n.combobox,t]);let r=sL(e,t,n);UF(r,n,`selectedId`,`setSelectedId`),UF(r,n,`selectOnMove`);let[i,a]=WF(()=>r.panels,{});return TN(a,[r,a]),Object.assign((0,D.useMemo)(()=>({...r,panels:i}),[r,i]),{composite:n.composite,combobox:n.combobox})}function SL(e={}){let t=rL(),n=lL()||t,r={...e,composite:e.composite===void 0?n:e.composite,combobox:e.combobox===void 0?t:e.combobox},[i,a]=WF(bL,r);return xL(i,a,r)}function CL(e={}){let t=SL(e);return(0,O.jsx)(nI,{value:t,children:e.children})}var wL=BN([vP],[yP]),TL=wL.useContext;wL.useScopedContext;var EL=wL.useProviderContext;wL.ContextProvider;var DL=wL.ScopedContextProvider;function OL(e={}){let t=e.store?.getState();return vF({...e,orientation:K(e.orientation,t?.orientation,`horizontal`),focusLoop:K(e.focusLoop,t?.focusLoop,!0)})}function kL(e,t,n){return sL(e,t,n)}function AL(e={}){let[t,n]=WF(OL,e);return kL(t,n,e)}var jL=`div`,ML=Q(function({store:e,orientation:t,virtualFocus:n,focusLoop:r,rtl:i,...a}){let o=EL();e||=o;let s=AL({store:e,orientation:t,virtualFocus:n,focusLoop:r,rtl:i}),c=$(s,[`orientation`],e=>e.orientation===`both`?void 0:e.orientation);return a=ON(a,e=>(0,O.jsx)(DL,{value:s,children:e}),[s]),a={role:`toolbar`,"aria-orientation":c,...a},a=SI({store:s,...a}),a}),NL=X(function(e){return Z(jL,ML(e))}),PL=`button`,FL=Q(function({store:e,...t}){let n=TL();return e||=n,t=ZF({store:e,...t}),t}),IL=zN(X(function(e){return Z(PL,FL(gj(e)))})),LL=`hr`,RL=Q(function({orientation:e=`horizontal`,...t}){return t={role:`separator`,"aria-orientation":e,...t},t});X(function(e){return Z(LL,RL(e))});var zL=`hr`,BL=Q(function({store:e,orientation:t,...n}){let r=gP();e||=r,Nj(e,!1);let i=$(e,[`orientation`],e=>t??(e.orientation===`horizontal`?`vertical`:`horizontal`));return n=RL({...n,orientation:i}),n});X(function(e){return Z(zL,BL(e))});var VL=`div`,HL=Q(function({autoFocusOnShow:e=!0,...t}){return t=ON(t,t=>(0,O.jsx)(sN.Provider,{value:e,children:t}),[e]),t});X(function(e){return Z(VL,HL(e))});var UL=(0,D.createContext)(0);function WL({level:e,children:t}){let n=(0,D.useContext)(UL),r=Math.max(Math.min(e||n+1,6),1);return(0,O.jsx)(UL.Provider,{value:r,children:t})}var GL=`span`;function KL(e){return{borderWidth:0,clipPath:`inset(50%)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,whiteSpace:`nowrap`,width:`1px`,...e}}var qL=Q(function(e){return e={...e,style:KL(e.style)},e});X(function(e){return Z(GL,qL(e))});var JL=`span`,YL=Q(function(e){return e={"data-focus-trap":``,tabIndex:0,"aria-hidden":!0,...e,style:{position:`fixed`,top:0,left:0,...e.style}},e=qL(e),e}),XL=X(function(e){return Z(JL,YL(e))}),ZL=(0,D.createContext)(null),QL=`div`;function $L(e){let t=q(e),{fullscreenElement:n}=t,r=qj(e).HTMLElement;return r&&n instanceof r?n:t.body}function eR(e,t){return t?typeof t==`function`?t(e):t:q(e).createElement(`div`)}function tR(e=`id`){return`${e?`${e}-`:``}${Math.random().toString(36).slice(2,8)}`}function nR(e){queueMicrotask(()=>{e?.focus()})}function rR(e,t){return{ref:e,node:t,cleanup:cN(e,t)}}function iR(e){typeof e.cleanup==`function`?e.cleanup():cN(e.ref,null)}var aR=Q(function({preserveTabOrder:e,preserveTabOrderAnchor:t,portalElement:n,portalRef:r,portal:i=!0,...a}){let o=(0,D.useRef)(null),s=vN(o,a.ref),c=(0,D.useContext)(ZL),[l,u]=(0,D.useState)(null),[d,f]=(0,D.useState)(null),p=(0,D.useRef)(null),m=(0,D.useRef)(null),h=(0,D.useRef)(null),g=(0,D.useRef)(null),_=gN(r),v=(0,D.useRef)(null);return J(()=>{let e=o.current;if(!e||!i){u(null);return}let t=eR(e,n);if(!t){u(null);return}let r=t.isConnected;return r||(c||$L(e)).appendChild(t),t.id||=e.id?`portal/${e.id}`:tR(),u(t),v.current=rR(_.current,t),()=>{let e=v.current;e&&(v.current=null,iR(e)),r||t.remove()}},[i,n,c,_]),J(()=>{let e=v.current;e&&e.ref!==r&&(iR(e),v.current=rR(r,e.node))},[r]),(0,D.useEffect)(()=>{if(!l||c||n)return;let e=q(l),t=()=>{let e=$L(l);l.parentElement!==e&&e.appendChild(l)};return l.isConnected&&t(),e.addEventListener(`fullscreenchange`,t),()=>{e.removeEventListener(`fullscreenchange`,t)}},[l,c,n]),J(()=>{if(!i||!e||!t)return;let n=q(t).createElement(`span`);return n.style.position=`fixed`,t.insertAdjacentElement(`afterend`,n),f(n),()=>{n.remove(),f(null)}},[i,e,t]),(0,D.useEffect)(()=>{if(!l||!e)return;let t=0,n=e=>{if(!kM(e))return;let n=e.type===`focusin`;if(cancelAnimationFrame(t),n)return YM(l);t=requestAnimationFrame(()=>{JM(l,!0)})};return l.addEventListener(`focusin`,n,!0),l.addEventListener(`focusout`,n,!0),()=>{cancelAnimationFrame(t),l.removeEventListener(`focusin`,n,!0),l.removeEventListener(`focusout`,n,!0)}},[l,e]),a=ON(a,t=>{if(t=(0,O.jsx)(ZL.Provider,{value:l||c,children:t}),!i)return t;if(!l)return(0,O.jsx)(`span`,{ref:s,id:a.id,style:{position:`fixed`},hidden:!0});t=(0,O.jsxs)(O.Fragment,{children:[e&&(0,O.jsx)(XL,{ref:m,"data-focus-trap":a.id,className:`__focus-trap-inner-before`,onFocus:e=>{kM(e,l)?nR(HM()):nR(p.current)}}),t,e&&(0,O.jsx)(XL,{ref:h,"data-focus-trap":a.id,className:`__focus-trap-inner-after`,onFocus:e=>{kM(e,l)?nR(WM()):nR(g.current)}})]}),t=(0,RE.createPortal)(t,l);let n=(0,O.jsxs)(O.Fragment,{children:[e&&(0,O.jsx)(XL,{ref:p,"data-focus-trap":a.id,className:`__focus-trap-outer-before`,onFocus:e=>{e.relatedTarget!==g.current&&kM(e,l)?nR(m.current):nR(WM())}}),e&&(0,O.jsx)(`span`,{"aria-owns":l.id,style:{position:`fixed`}}),e&&(0,O.jsx)(XL,{ref:g,"data-focus-trap":a.id,className:`__focus-trap-outer-after`,onFocus:e=>{if(kM(e,l))nR(h.current);else{let e=HM();if(e===m.current){requestAnimationFrame(()=>HM()?.focus());return}nR(e)}}})]});return d&&e&&(n=(0,RE.createPortal)(n,d)),(0,O.jsxs)(O.Fragment,{children:[n,t]})},[l,c,i,a.id,e,d]),a={...a,ref:s},a});X(function(e){return Z(QL,aR(e))});function oR(e,...t){if(!e)return!1;let n=e.getAttribute(`data-backdrop`);return n==null?!1:n===``||n===`true`||!t.length||t.some(e=>n===e)}var sR=new WeakMap;function cR(e,t,n){for(;n.length;){let r=n[n.length-1];if(!r){e.delete(t);return}if(!r.disposed)return;n.pop(),r.cleanup()}e.delete(t)}function lR(e,t,n){let r=sR.get(e);r||(r=new Map,sR.set(e,r));let i=r.get(t)??[],a={cleanup:n(),disposed:!1};return i.length||r.set(t,i),i.push(a),()=>{i.includes(a)&&(a.disposed=!0,cR(r,t,i))}}function uR(e,t,n){return lR(e,t,()=>{let r=e.getAttribute(t);return e.setAttribute(t,n),()=>{r==null?e.removeAttribute(t):e.setAttribute(t,r)}})}function dR(e,t,n){return lR(e,t,()=>{let r=t in e,i=e[t];return e[t]=n,()=>{r?e[t]=i:delete e[t]}})}function fR(e,t){return e?lR(e,`style`,()=>{let n=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=n}}):()=>{}}function pR(e,t,n){return e?lR(e,t,()=>{let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{r?e.style.setProperty(t,r,i):e.style.removeProperty(t)}}):()=>{}}function mR(e,t){if(!t)return!1;if(t.get(e)?.has(`ancestorMark`))return!0;do{if(t.get(e)?.has(`mark`))return!0;if(!e.parentElement)return!1;e=e.parentElement}while(1)}var hR=new WeakMap;function gR(e=``,t=`outside`){return`__ariakit-dialog-${t}${e?`-${e}`:``}`}function _R(e,t=``){return Ej(dR(e,gR(),!0),dR(e,gR(t),!0))}function vR(e,t=``){return Ej(dR(e,gR(``,`ancestor`),!0),dR(e,gR(t,`ancestor`),!0))}function yR(e,t){let n=new WeakSet;hR.set(e,n);for(let e of t)e&&n.add(e);return()=>{hR.get(e)===n&&hR.delete(e)}}function bR(e,t){let n=hR.get(t);if(!n)return!1;do{if(n.has(e))return!0;if(!e.parentElement)return!1;e=e.parentElement}while(1)}function xR(e,t){let n=gR(t,`ancestor`);if(e[n])return!0;let r=gR(t);do{if(e[r])return!0;if(!e.parentElement)return!1;e=e.parentElement}while(1)}function SR(e){return{cleanups:new Map,previousCleanups:e}}function CR({walk:e,element:t,kind:n,setup:r}){let i=e.cleanups.get(t)??new Map;if(i.has(n))return;e.cleanups.set(t,i);let a=e.previousCleanups?.get(t),o=a?.get(n);a?.delete(n),i.set(n,o??r())}function wR(e){return e.previousCleanups&&DR(e.previousCleanups),e.cleanups}function TR({walk:e,element:t,id:n,ids:r}){oR(t,...r)||CR({walk:e,element:t,kind:`mark`,setup:()=>_R(t,n)})}function ER({walk:e,ancestor:t,element:n,id:r}){n.hasAttribute(`data-dialog`)&&n.id!==r||CR({walk:e,element:t,kind:`ancestorMark`,setup:()=>vR(t,r)})}function DR(e){for(let t of e.values())for(let e of t.values())e();e.clear()}function OR(e){return`__ariakit-dialog-snapshot-${e}`}function kR(e,t){let n=OR(e),r=[];for(let e of t)r.push(dR(e,n,!0));return()=>{for(let e of r)e()}}var AR=[`SCRIPT`,`STYLE`];function jR(e,t){let n=q(t),r=OR(e);if(!n.body[r])return!0;do{if(t===n.body)return!1;if(t[r])return!0;if(!t.parentElement)return!1;t=t.parentElement}while(1)}function MR(e,t,n){return AR.includes(t.tagName)||!jR(e,t)?!1:!n.some(e=>e&&Yj(t,e))}function NR(e,t,n,r){for(let i of t){if(!i?.isConnected)continue;let a=t.some(e=>!e||e===i?!1:e.contains(i)),o=q(i),s=i;for(;i.parentElement&&i!==o.body;){if(r?.(i.parentElement,s),!a)for(let r of i.parentElement.children)MR(e,r,t)&&n(r,s);i=i.parentElement}}}function PR(e,t){let{body:n}=q(t[0]),r=[];return NR(e,t,e=>{r.push(e)}),Ej(dR(n,OR(e),!0),kR(e,r))}function FR(e,t,n){let r=SR(n),i=t.map(e=>e?.id);return NR(e,t,t=>{TR({walk:r,element:t,id:e,ids:i})},(t,n)=>{ER({walk:r,ancestor:t,element:n,id:e})}),wR(r)}var IR=`a.abbr.address.area.article.aside.audio.b.base.bdi.bdo.blockquote.body.br.button.canvas.caption.cite.code.col.colgroup.data.datalist.dd.del.details.dfn.dialog.div.dl.dt.em.embed.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.iframe.img.input.ins.kbd.label.legend.li.link.main.map.mark.menu.meta.meter.nav.noscript.object.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.script.section.select.slot.small.source.span.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.title.tr.track.u.ul.var.video.wbr.svg`.split(`.`),LR=`div`;Q(function(e){return e});var RR=X(function(e){return Z(LR,e)});Object.assign(RR,IR.reduce((e,t)=>(e[t]=X(function(e){return Z(t,e)}),e),{}));function zR({store:e,backdrop:t,backdropRef:n,alwaysVisible:r,hidden:i}){let a=(0,D.useRef)(null),o=qI({disclosure:e}),s=$(e,`contentElement`);J(()=>{let e=a.current,t=s;e&&t&&(e.style.zIndex=getComputedStyle(t).zIndex)},[s]),J(()=>{let e=s?.id;if(!e)return;let t=a.current;if(t)return vR(t,e)},[s]);let c=HI({ref:vN(a,n),store:o,role:`presentation`,"data-backdrop":s?.id||``,alwaysVisible:r,...i!=null&&{hidden:i},style:{position:`fixed`,top:0,right:0,bottom:0,left:0}});if(!t)return null;if((0,D.isValidElement)(t))return(0,O.jsx)(RR,{...c,render:t});let l=typeof t==`boolean`?`div`:t;return(0,O.jsx)(RR,{...c,render:(0,O.jsx)(l,{})})}function BR(e={}){return GI(e)}function VR(e,t,n){return KI(e,t,n)}function HR(e={}){let[t,n]=WF(BR,e);return VR(t,n,e)}function UR(e,...t){if(!e)return!1;let n=e.getAttribute(`data-dialog-hidden-dismiss`);return n==null?!1:n===``||!t.length||t.some(e=>n===e)}function WR(){return`inert`in HTMLElement.prototype}function GR(e){return uR(e,`aria-hidden`,`true`)}function KR(e,...t){if(!e)return!1;let n=e.getAttribute(`data-focus-trap`);return n==null?!1:!t.length||n!==``&&t.some(e=>n===e)}function qR(e,t){return`style`in e?WR()?dR(e,`inert`,!0):Ej(...RM(e,!0).map(e=>{if(t?.some(t=>t&&Yj(t,e)))return bj;let n=lR(e,`focus`,()=>(e.focus=bj,()=>{delete e.focus}));return Ej(uR(e,`tabindex`,`-1`),n)}),GR(e),fR(e,{pointerEvents:`none`,userSelect:`none`,cursor:`default`})):bj}function JR({walk:e,element:t,elements:n,ids:r}){oR(t,...r)||KR(t,...r)||UR(t,...r)||CR({walk:e,element:t,kind:`disable`,setup:()=>qR(t,n)})}function YR(e,t,n){t.hasAttribute(`role`)&&(n.some(e=>e&&Yj(e,t))||CR({walk:e,element:t,kind:`role`,setup:()=>uR(t,`role`,`none`)}))}function XR(e,t,n){n&&!WR()&&DR(n);let r=SR(n),i=t.map(e=>e?.id);return NR(e,t,n=>{TR({walk:r,element:n,id:e,ids:i}),JR({walk:r,element:n,elements:t,ids:i})},(n,i)=>{ER({walk:r,ancestor:n,element:i,id:e}),YR(r,n,t)}),wR(r)}function ZR(e){let t=[e];for(;;){let n;try{n=qj(e).frameElement}catch{return t}if(!Xj(n))return t;t.push(n),e=n}}function QR(e,t){let n=e.composedPath().filter(Xj);!n.length&&Xj(e.target)&&n.push(e.target);let r=n[0];if(r)for(let e of ZR(r).slice(1))n.includes(e)||n.push(e);let i=t?.getRootNode();return{elements:n,rootTarget:i?n.find(e=>e.getRootNode()===i)||e.target:n[0]||e.target}}function $R(e,t,n){let r=(0,D.useRef)(null);return(0,D.useEffect)(()=>{if(!e)r.current=null;else return jM(`mousedown`,e=>{r.current=QR(e,n)},!0,t)},[e,t,n]),r}function ez(e){return qj(ZR(e).at(-1)??e)}function tz(e){return e.isConnected}function nz(e,t){if(!e)return!1;if(Yj(e,t))return!0;let n=t.getAttribute(`aria-activedescendant`);if(n){let r=q(t).getElementById(n);if(r)return Yj(e,r)}return!1}function rz(e,t){if(!(`clientY`in e))return!1;let n=t.getBoundingClientRect();return n.width===0||n.height===0?!1:n.top<=e.clientY&&e.clientY<=n.top+n.height&&n.left<=e.clientX&&e.clientX<=n.left+n.width}function iz(e,t,n){return Yj(t,e)||nz(n,e)||e.hasAttribute(`data-focus-trap`)||UR(e,t.id)?!0:bR(e,t)}function az(e,t,n){return e.elements.some(e=>iz(e,t,n))}function oz({store:e,type:t,listener:n,capture:r,open:i,contentElement:a,focusedRef:o}){let s=Y(n);(0,D.useEffect)(()=>i?jM(t,t=>{let{contentElement:n,disclosureElement:r}=e.getState();if(!n)return;let i=QR(t,n),a=i.elements[0],c=i.rootTarget;if(!Xj(c)||a&&!tz(a)||!tz(c)||az(i,n,r))return;let l=q(n);q(c)===l?q(a??c)===l&&rz(t,n)||(!o.current||xR(c,n.id))&&s(t):s(t)},r,a?ez(a):void 0):void 0,[i,r,e,t,s,a,o])}function sz(e,t){return typeof e==`function`?e(t):!!e}function cz({store:e,hideOnInteractOutside:t,domReady:n,interactedOutsideRef:r,focusedStoreRef:i}){let a=$(e,`open`),o=$(e,`contentElement`),s=$R(a,o?ez(o):void 0,o),c=(0,D.useRef)(!1);J(()=>{if(!a||!n||!o)return;c.current=!1;let t=()=>{c.current=!0,i.current=e};return o.addEventListener(`focusin`,t,!0),()=>o.removeEventListener(`focusin`,t,!0)},[a,n,o,e,i]);let l={store:e,capture:!0,open:a,contentElement:o,focusedRef:c},u=()=>{e.hide(),e.getState().open&&(r.current=!1)};oz({...l,type:`click`,listener:n=>{let{contentElement:i,disclosureElement:a}=e.getState(),o=s.current;if(!o||!i||az(o,i,a))return;let c=o.rootTarget;Xj(c)&&(q(c)!==q(i)||xR(c,i.id))&&sz(t,n)&&(r.current=!0,u())}}),oz({...l,type:`focusin`,listener:n=>{let{contentElement:i}=e.getState();if(!i||n.target===q(i)||!sz(t,n))return;let a=n.target;Xj(a)&&q(a)!==q(i)&&(r.current=!0),u()}}),oz({...l,type:`contextmenu`,listener:e=>{sz(t,e)&&(r.current=!0,u())}})}var lz=(0,D.createContext)({});function uz(e){let t=(0,D.useContext)(lz),[n,r]=(0,D.useState)([]),i=(0,D.useCallback)(e=>(r(t=>[...t,e]),Ej(t.add?.(e),()=>{r(t=>t.filter(t=>t!==e))})),[t]);J(()=>GP(e,[`open`,`contentElement`],n=>{if(n.open&&n.contentElement)return t.add?.(e)}),[e,t]);let a=(0,D.useMemo)(()=>({store:e,add:i}),[e,i]);return{wrapElement:(0,D.useCallback)(e=>(0,O.jsx)(lz.Provider,{value:a,children:e}),[a]),nestedDialogs:n}}function dz({attribute:e,contentId:t,contentElement:n,enabled:r}){let[i,a]=EN(),o=(0,D.useCallback)(()=>{if(!r||!n)return!1;let{body:i}=q(n),a=i.getAttribute(e);return!a||a===t},[i,r,n,e,t]);return J(()=>{if(!r||!t||!n)return;let{body:i}=q(n);if(o())return i.setAttribute(e,t),()=>i.removeAttribute(e);let s=new MutationObserver(()=>(0,RE.flushSync)(a));return s.observe(i,{attributeFilter:[e]}),()=>s.disconnect()},[i,r,t,n,o,e,a]),o}var fz=hM()&&!vM(),pz=fz?D.useEffect:J;function mz(e){let{CSS:t}=e;return!!t?.supports(`scrollbar-gutter`,`stable`)}function hz(e){let t=e.getBoundingClientRect().left;return Math.round(t)+e.scrollLeft?`paddingLeft`:`paddingRight`}function gz(e,t,n){let r=dz({attribute:`data-dialog-prevent-body-scroll`,contentElement:e,contentId:t,enabled:n});pz(()=>{if(!r()||!e)return;let t=q(e),n=qj(e),{documentElement:i,body:a}=t,o=i.style.getPropertyValue(`--scrollbar-width`),s=o?Number.parseInt(o,10):n.innerWidth-i.clientWidth,c=()=>{let e=n.getComputedStyle(i),t=e.getPropertyValue(`scrollbar-gutter`),r=t.includes(`stable`),o=e=>!e||e===`visible`,c=!o(e.getPropertyValue(`overflow-x`))||!o(e.getPropertyValue(`overflow-y`)),l=()=>Ej(pR(i,`overflow-x`,`hidden`),pR(i,`overflow-y`,`hidden`)),u=e=>c?Ej(e,l()):e;return!r&&!s?u(fR(a,{overflow:`hidden`})):r||mz(n)?Ej(pR(i,`scrollbar-gutter`,r?t:`stable`),l()):u(Ej(pR(i,`--scrollbar-width`,`${s}px`),fR(a,{overflow:`hidden`,[hz(i)]:`${s}px`})))},l=()=>{let{scrollX:e,scrollY:t,visualViewport:r}=n,o=r?.offsetLeft??0,c=r?.offsetTop??0,l=fR(a,{position:`fixed`,overflow:`hidden`,top:`${-(t-Math.floor(c))}px`,left:`${-(e-Math.floor(o))}px`,right:`0`,[hz(i)]:`${s}px`});return()=>{l(),n.scrollTo({left:e,top:t,behavior:`instant`})}};if(fz)return l();let u=c();return()=>{queueMicrotask(u)}},[r,e])}var _z=new WeakSet;function vz(e){_z.add(e)}function yz(e){return _z.has(e)}var bz=new Map;function xz(e,t={}){return bz.set(e,t),()=>{bz.delete(e)}}function Sz(e){let t=[];for(let n of bz.keys()){if(n===e)break;let{current:r}=n;r?.isConnected&&(e.current&&Yj(r,e.current)||t.push(r))}return t}function Cz(e){let t=!1;for(let[n,r]of bz)n===e?t=!0:t&&r.onEarlierDialogElementChange?.()}function wz(e){let t=e.current;if(!t||!xR(t))return!1;let n=bz.get(e)?.getOutsideCleanups?.(),r=!1,i=!1;for(let[a,o]of bz){if(a===e){r=!0;continue}let s=a.current;if(s&&mR(t,o.getOutsideCleanups?.())){if(r||!mR(s,n))return!0;i=!0}}return!(r&&i)}var Tz=`div`,Ez=gM(),Dz=new WeakSet,Oz=new WeakSet;function kz(e){let t=Jj(e);return!t||e&&Yj(e,t)||UR(t,e?.id)?!1:!!PM(t)}function Az(e){let t=e;for(;t.shadowRoot;){let e=t.shadowRoot.activeElement;if(!Xj(e))break;t=e}return t}function jz(e,t,n){return Yj(t,e)||n&&Yj(n,e)?!0:bR(e,t)}function Mz(e){let t=e.querySelectorAll(`[data-dialog-dismiss]`);for(let n of t)if(n.closest(`[data-dialog]`)===e)return!0;return!1}function Nz(e,t=!1){if(!e)return null;let n=`current`in e?e.current:e;return n?t?PM(n)?n:null:n:null}function Pz(e){if(!e.isConnected)return[];let t=e.getRootNode(),n=t.querySelectorAll(`[data-dialog][data-dialog-portal][data-open]`),r=[],i=!1;for(let a of n){if(a===e){i=!0;continue}if(!i)continue;let n=a.getAttribute(`data-dialog-portal`);if(!n)continue;let o=t.getElementById(n);o&&Yj(o,a)&&(Dz.has(o)||r.push(o))}return r}var Fz=Q(function({store:e,open:t,onClose:n,focusable:r=!0,modal:i=!0,portal:a=i,backdrop:o=i,hideOnEscape:s=!0,hideOnInteractOutside:c=!0,getPersistentElements:l,preventBodyScroll:u=i,autoFocusOnShow:d=!0,autoFocusOnHide:f=!0,initialFocus:p,finalFocus:m,unmountOnHide:h,unstable_treeSnapshotKey:g,..._}){let v=jI(),y=(0,D.useRef)(null),b=(0,D.useRef)(null),x=i&&a&&!_.portalElement,S=(0,D.useRef)(!1),C=Y(()=>{let e=y.current;if(!e)return!0;let t=new Event(`close`,{bubbles:!1,cancelable:!0});return n&&e.addEventListener(`close`,n,{once:!0}),e.dispatchEvent(t),!t.defaultPrevented}),w=HR({store:e||v,open:t,setOpen(e){e||S.current||C()||w.setOpen(!0)}});J(()=>w.unstable_onHideRequest(e=>{if(!S.current){S.current=!0;try{if(!C())return;e()}finally{S.current=!1}}}),[w,C]);let{portalRef:T,portalNode:E,domReady:ee}=kN(a,_.portalRef),te=_.preserveTabOrder,ne=$(w,[`mounted`],e=>te&&!i&&e.mounted),re=SN(_.id),ie=$(w,`open`),ae=$(w,`mounted`),oe=$(w,`contentElement`),se=VI(ae,_.hidden,_.alwaysVisible);gz(oe,re,u&&!se);let ce=(0,D.useRef)(!1),le=(0,D.useRef)(null);J(()=>GP(w,[`open`],e=>{e.open?(ce.current=!1,le.current!==w&&(le.current=null)):le.current=null}),[w]),cz({store:w,hideOnInteractOutside:c,domReady:ee,interactedOutsideRef:ce,focusedStoreRef:le});let{wrapElement:ue,nestedDialogs:de}=uz(w);_=ON(_,ue,[ue]);let fe=(0,D.useRef)(null);Ez&&(0,D.useEffect)(()=>{if(!ee)return;let e=y.current;if(!e)return;let t=q(e),n=e=>{fe.current=e.target};return t.addEventListener(`mousedown`,n,!0),()=>{t.removeEventListener(`mousedown`,n,!0)}},[ee]),J(()=>{if(!ie||le.current===w)return;let e=y.current;if((()=>{let{disclosureElement:t}=w.getState();return!(!t||yz(t)||!t.isConnected||e&&Yj(e,t))})())return;let t=e=>{vz(e),w.setDisclosureElement(e)},n=Jj(e,{activeDescendant:!0});if(n){if(n.tagName===`BODY`){let n=fe.current;if(fe.current=null,!n?.isConnected||!PM(n)||e&&Yj(e,n))return;t(n)}else e&&Yj(e,n)||t(n)}},[w,ie]),(0,D.useEffect)(()=>{if(!ae||!ee)return;let e=y.current;if(!e)return;let t=qj(e),n=t.visualViewport||t,r=()=>{let n=t.visualViewport?.height??t.innerHeight;e.style.setProperty(`--dialog-viewport-height`,`${n}px`)};return r(),n.addEventListener(`resize`,r),()=>{n.removeEventListener(`resize`,r)}},[ae,ee]);let[pe,me]=(0,D.useState)(!1);J(()=>{if(!(i&&ie&&ee)||!oe){me(!1);return}let e=()=>{me(!Mz(oe))};e();let{MutationObserver:t}=qj(oe),n=new t(e);return n.observe(oe,{childList:!0,subtree:!0}),()=>n.disconnect()},[i,ie,ee,oe]),J(()=>{if(!WR()||ie||!ae||!ee)return;let e=y.current;if(e)return qR(e)},[ie,ae,ee]);let he=ie&&ee,ge=(0,D.useRef)(null);J(()=>{if(!re||!x||!he||!E){ge.current=null;return}let e=y.current;if(!e||!Yj(E,e))ge.current=null;else return ge.current?.portal!==E&&(ge.current={portal:E,peers:Pz(e)}),Dz.add(E),()=>{Dz.delete(E)}},[re,he,x,E]);let _e=!!he,[ve,ye]=(0,D.useState)(0);J(()=>{if(_e)return xz(y,{getOutsideCleanups:()=>Se.current?.outsideCleanups,onEarlierDialogElementChange:()=>{ye(e=>e+1)}})},[_e]);let be=(0,D.useRef)(null);J(()=>{if(!_e){be.current=null;return}if(!oe)return;let e=be.current;be.current=oe,e&&e!==oe&&Cz(y)},[_e,oe]),J(()=>{if(!re||!he)return;let e=y.current;return PR(re,[e])},[re,he,g]),J(()=>{if(!re||!he)return;let e=Sz(y);return kR(re,e)},[re,he,ve]);let xe=Y(l),Se=(0,D.useRef)(null);J(()=>()=>{let e=Se.current;e&&(Se.current=null,e.restoreInsideMarks(),DR(e.outsideCleanups))},[re,w,he,oe,i,x,xe,g]),J(()=>{if(!re||!he)return;let{disclosureElement:e}=w.getState(),t=oe??y.current;if(!t)return;let n=[t,...xe()||[],...ge.current?.peers||[],...de.map(e=>e.getState().contentElement)],r=Se.current;r?.restoreInsideMarks();let a=yR(t,n),o=i?XR(re,n,r?.outsideCleanups):FR(re,[e,...n],r?.outsideCleanups);Se.current={restoreInsideMarks:a,outsideCleanups:o}},[re,w,he,oe,i,x,xe,de,g,ve]);let Ce=!!d,we=DN(d),[Te,Ee]=(0,D.useState)(!1);(0,D.useEffect)(()=>{if(!ie||!Ce||!ee||!oe?.isConnected)return;let e=Nz(p,!0)||oe.querySelector(`[data-autofocus=true],[autofocus]`)||zM(oe,!0,a&&ne)||oe,t=PM(e);we(t?e:null)&&(Ee(!0),queueMicrotask(()=>{let{open:t,disclosureElement:n}=w.getState();if(!t)return;let r=Jj(oe,{frame:!1}),i=r&&Az(r);le.current===w&&r&&i&&PM(i)&&!jz(r,oe,n)&&!jz(i,oe,n)||(PM(e)&&e.scrollIntoView({block:`nearest`,inline:`nearest`}),e.focus({preventScroll:!0}))}))},[ie,Ce,ee,oe,p,a,ne,w,we,le]);let De=!!f,Oe=DN(f),[ke,k]=(0,D.useState)(!1);J(()=>{if(ie)return k(!0),()=>k(!1)},[ie]);let Ae=(0,D.useCallback)((e,t=!0)=>{if(ce.current)return;let{disclosureElement:n}=w.getState();if(kz(e))return;let r=Nz(m)||n;if(r?.id){let e=q(r),t=`[aria-activedescendant="${r.id}"]`,n=e.querySelector(t);n&&(r=n)}if(r&&!PM(r)){let e=r.closest(`[data-dialog]`);if(e?.id){let t=q(e),n=`[aria-controls~="${e.id}"]`,i=t.querySelector(n);i&&(r=i)}}let i=r&&PM(r);!i&&t?requestAnimationFrame(()=>Ae(e,!1)):Oe(i?r:null)&&i&&r?.focus()},[w,m,Oe]),je=(0,D.useRef)(!1);J(()=>{if(ie||!ke||!De)return;let e=y.current;je.current=!0,Ae(e)},[ie,ke,ee,De,Ae]),(0,D.useEffect)(()=>{if(!ke||!De)return;let e=y.current;return()=>{je.current?je.current=!1:Ae(e)}},[ke,De,Ae]);let Me=DN(s),[A]=(0,D.useState)(()=>new WeakMap),[Ne]=(0,D.useState)(()=>new WeakMap),j=_.onKeyDown,Pe=_.onKeyDownCapture,Fe=_.onFocusCapture,Ie=Y(e=>{if(Fe?.(e),!w.getState().open)return;let t=e.target;Zj(t)&&Yj(e.currentTarget,t)&&(le.current=w)}),Le=Y(e=>{if(e.key!==`Escape`||!e.bubbles)return!1;let t=A.get(e);if(t)return e.defaultPrevented&&!t.defaultPrevented?!1:t.accepted;if(e.defaultPrevented)return!1;let n=y.current;if(!ae||!n)return!1;let r=lI(e),i=Ne.get(r);return i||(i={accepted:!wz(y)&&!Oz.has(r)&&Me(e),hidden:!1},Ne.set(r,i)),A.set(e,{accepted:i.accepted,defaultPrevented:e.defaultPrevented}),i.accepted}),Re=Y(e=>{let t=Le(e);if(A.delete(e),!t)return!1;let n=lI(e),r=Ne.get(n);return r?.hidden||(r&&(r.hidden=!0),Oz.add(n),w.hide()),!0}),ze=Y(e=>{let t=e.nativeEvent,n=t.cancelBubble;j?.(e),n?A.delete(t):Re(t)&&e.stopPropagation()}),Be=Y(e=>{let t=e.nativeEvent,n=t.cancelBubble;Pe?.(e),n?A.delete(t):Le(t)&&(e.isPropagationStopped()||t.cancelBubble)&&Re(t)});(0,D.useEffect)(()=>{if(!ee||!ae)return;let e=e=>{if(e.key!==`Escape`||!e.bubbles)return;if(e.cancelBubble){A.delete(e);return}if(A.has(e))return;let t=y.current;if(!t)return;let n=[e.target,e.composedPath()[0]].filter(Zj),{disclosureElement:r}=w.getState();n.some(e=>!!(Xj(e)&&e.tagName===`BODY`||Yj(t,e)||!r||Yj(r,e)||Xj(e)&&xR(e,t.id)||Xj(e)&&UR(e,t.id)))&&Le(e)&&e.cancelBubble&&Re(e)},t=e=>{A.has(e)&&(e.cancelBubble?A.delete(e):Re(e)&&e.stopPropagation())},n=oe?qj(oe):void 0;return Ej(jM(`keydown`,e,!0,n),jM(`keydown`,t,!1,n))},[w,ee,ae,oe,Re,Le,A]),_=ON(_,e=>(0,O.jsx)(WL,{level:i?1:void 0,children:e}),[i]);let Ve=_.hidden,He=_.alwaysVisible;_=ON(_,e=>(0,O.jsxs)(O.Fragment,{children:[pe&&(0,O.jsx)(`button`,{type:`button`,tabIndex:-1,"data-dialog-hidden-dismiss":re||``,style:KL(),onClick:w.hide,children:`Dismiss popup`}),e]}),[pe,re,w]),_=ON(_,e=>(0,O.jsxs)(O.Fragment,{children:[!!o&&(0,O.jsx)(zR,{store:w,backdrop:o,backdropRef:b,hidden:Ve,alwaysVisible:He}),e]}),[w,o,Ve,He]);let[Ue,We]=(0,D.useState)(),[Ge,Ke]=(0,D.useState)();return _=ON(_,e=>(0,O.jsx)(NI,{value:w,children:(0,O.jsx)(PI.Provider,{value:We,children:(0,O.jsx)(FI.Provider,{value:Ke,children:e})})}),[w]),_={"data-dialog":``,role:`dialog`,tabIndex:r?-1:void 0,"aria-labelledby":_[`aria-label`]==null?Ue:void 0,"aria-describedby":Ge,..._,"data-dialog-portal":x?E?.id:void 0,id:re,ref:vN(y,_.ref),onFocusCapture:Ie,onKeyDown:ze,onKeyDownCapture:Be},_=HL({..._,autoFocusOnShow:Te}),_=HI({store:w,..._,unstable_otherElementRef:b}),_=iP({..._,focusable:r}),_=aR({portal:a,..._,portalRef:T,preserveTabOrder:ne}),_});function Iz(e,t=jI){return X(function(n){let r=t();return $(n.store||r,[`mounted`],e=>!n.unmountOnHide||e?.mounted||!!n.open)?(0,O.jsx)(e,{...n}):null})}var Lz=Iz(X(function(e){return Z(Tz,Fz(e))}),jI),Rz=X(function(e){let t=HR({open:e.open});return(0,O.jsx)(Lz,{...e,store:t})});X(function(e){let t=jI();return e.store||t||!e.unmountOnHide?(0,O.jsx)(Lz,{...e}):(0,O.jsx)(Rz,{...e})});function zz(e){return e.split(`-`)[0]}var Bz=`div`,Vz=new WeakMap;function Hz(e=0,t=0,n=0,r=0){if(typeof DOMRect==`function`)return new DOMRect(e,t,n,r);let i={x:e,y:t,width:n,height:r,top:t,right:e+n,bottom:t+r,left:e};return{...i,toJSON:()=>i}}function Uz(e){if(!e)return Hz();let{x:t,y:n,width:r,height:i}=e;return Hz(t,n,r,i)}function Wz(e,t){return{contextElement:e||void 0,getBoundingClientRect:()=>{let n=e,r=t?.(n);return r||!n?Uz(r):n.getBoundingClientRect()}}}function Gz(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}function Kz(e){let t=window.devicePixelRatio||1;return Math.round(e*t)/t}function qz(e){return typeof e==`number`?e:Math.max(e.left??0,e.right??0)}function Jz(e,t){return te(({placement:n})=>{let r=(e?.clientHeight||0)/2,i=typeof t.gutter==`number`?t.gutter+r:t.gutter??r;return{crossAxis:n.split(`-`)[1]?void 0:t.shift,mainAxis:i,alignmentAxis:t.shift}})}function Yz(e){if(e.flip===!1)return;let t=typeof e.flip==`string`?e.flip.split(` `):void 0;return Nj(!t||t.every(Gz),!1),ee({padding:e.overflowPadding,fallbackPlacements:t})}function Xz(e){if(e.slide||e.overlap)return x({mainAxis:e.slide,crossAxis:e.overlap,padding:e.overflowPadding,limiter:E()})}function Zz(e,t){return l({padding:e.overflowPadding,apply({elements:n,availableWidth:r,availableHeight:i,rects:a}){if(t?.())return;let o=n.floating,s=Math.round(a.reference.width);r=Math.floor(r),i=Math.floor(i),o.style.setProperty(`--popover-anchor-width`,`${s}px`),o.style.setProperty(`--popover-available-width`,`${r}px`),o.style.setProperty(`--popover-available-height`,`${i}px`),e.sameWidth&&(o.style.width=`${s}px`),e.fitViewport&&(o.style.maxWidth=`${r}px`,o.style.maxHeight=`${i}px`)}})}function Qz(e,t){if(e)return h({element:e,padding:t.arrowPadding})}var $z=Q(function({store:e,modal:t=!1,portal:n=t,preserveTabOrder:r=!0,autoFocusOnShow:i=!0,wrapperProps:a,fixed:o=!1,flip:s=!0,shift:c=0,slide:l=!0,overlap:u=!1,sameWidth:d=!1,fitViewport:f=!1,gutter:p,arrowPadding:h=4,overflowPadding:g=8,getAnchorRect:_,updatePosition:v,...y}){let b=$I();e||=b,Nj(e,!1);let x=$(e,`arrowElement`),S=$(e,`anchorElement`),C=r&&n&&!t,w=$(e,C?[`disclosureElement`]:[],e=>C?e.disclosureElement:null),T=$(e,`popoverElement`),E=$(e,`unstable_placing`),ee=$(e,`contentElement`),te=$(e,`placement`),ne=$(e,`mounted`),re=$(e,`rendered`),ae=(0,D.useRef)(null),oe=!E,{portalRef:se,domReady:ce}=kN(n,y.portalRef),le=Y(_),ue=Y(v),de=!!v,fe=typeof g==`number`?g:g.top??0,pe=typeof g==`number`?g:g.right??0,me=typeof g==`number`?g:g.bottom??0,he=typeof g==`number`?g:g.left??0,ge=!ne&&VI(ne,y.hidden,y.alwaysVisible);J(()=>{if(ne&&e?.setState(`unstable_placing`,!0),!T?.isConnected)return;let t={top:fe,right:pe,bottom:me,left:he};if(T.style.setProperty(`--popover-overflow-padding`,`${qz(t)}px`),ge&&!de)return;let n=Wz(S,le),r=!1,i=!1,a=()=>!(!r&&T.isConnected),g=async()=>{if(a()||!ne)return;x||(ae.current=ae.current||document.createElement(`div`));let r=x||ae.current,g=[Jz(r,{gutter:p,shift:c}),Yz({flip:s,overflowPadding:t}),Xz({slide:l,shift:c,overlap:u,overflowPadding:t}),Qz(r,{arrowPadding:h}),Zz({sameWidth:d,fitViewport:f,overflowPadding:t},a)],_=await m(n,T,{placement:te,strategy:o?`fixed`:`absolute`,middleware:g});if(a())return;e?.setState(`currentPlacement`,_.placement);let v=Kz(_.x),y=Kz(_.y);if(Object.assign(T.style,{top:`0`,left:`0`,transform:`translate3d(${v}px,${y}px,0)`}),i=!0,r&&_.middlewareData.arrow){let{x:e,y:t}=_.middlewareData.arrow,n=zz(_.placement),i=r.clientWidth/2,a=r.clientHeight/2,o=e==null?-i:e+i,s=t==null?-a:t+a;T.style.setProperty(`--popover-transform-origin`,{top:`${o}px calc(100% + ${a}px)`,bottom:`${o}px ${-a}px`,left:`calc(100% + ${i}px) ${s}px`,right:`${-i}px ${s}px`}[n]),Object.assign(r.style,{left:e==null?``:`${e}px`,top:t==null?``:`${t}px`,right:``,bottom:``,[n]:`100%`})}},_=ie(n,T,async()=>{if(!a()){try{de?await ue({updatePosition:g}):await g()}catch(t){throw i&&!a()&&e?.setState(`unstable_placing`,!1),t}a()||e?.setState(`unstable_placing`,!1)}},{elementResize:typeof ResizeObserver==`function`});return()=>{r=!0,_()}},[e,re,T,x,S,te,ne,ge,ce,o,s,c,l,u,d,f,p,h,fe,pe,me,he,le,de,ue]),J(()=>{if(!ne||!ce||!T?.isConnected||!ee?.isConnected)return;let e=()=>{T.style.zIndex=getComputedStyle(ee).zIndex};e();let t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)});return()=>cancelAnimationFrame(t)},[ne,ce,T,ee]),J(()=>{if(!e)return;let t=e;Vz.set(t,(Vz.get(t)??0)+1);let n=GP(t,[`mounted`],e=>{t.setState(`unstable_placing`,e.mounted)});return()=>{n(),Vz.set(t,(Vz.get(t)??1)-1),queueMicrotask(()=>{Vz.get(t)||t.setState(`unstable_placing`,!1)})}},[e]);let _e=o?`fixed`:`absolute`;return y=ON(y,t=>(0,O.jsx)(`div`,{...a,style:{position:_e,top:0,left:0,width:`max-content`,...a?.style},ref:e?.setPopoverElement,children:t}),[e,_e,a]),y=ON(y,t=>(0,O.jsx)(tL,{value:e,children:t}),[e]),y={"data-placing":E||void 0,...y,style:{position:`relative`,...y.style}},y=Fz({store:e,modal:t,portal:n,preserveTabOrder:r,preserveTabOrderAnchor:w||S,autoFocusOnShow:oe&&i,...y,portalRef:se}),y}),eB=Iz(X(function(e){return Z(Bz,$z(e))}),$I),tB=BN([eL],[tL]);tB.useContext,tB.useScopedContext;var nB=tB.useProviderContext,rB=tB.ContextProvider,iB=tB.ScopedContextProvider;function aB(e){return[e.clientX,e.clientY]}function oB(e,t){let[n,r]=e,i=!1,a=t.length;for(let e=a,o=0,s=e-1;o<e;s=o++){let a=t[o],c=t[s],l=t[s===0?e-1:s-1];if(a==null||c==null||l==null)return!1;let[u,d]=a,[f,p]=c,[,m]=l,h=(d-p)*(n-u)-(u-f)*(r-d);if(p<d){if(r>=p&&r<d){if(h===0)return!0;h>0&&(r===p?r>m&&(i=!i):i=!i)}}else if(d<p){if(r>d&&r<=p){if(h===0)return!0;h<0&&(r===p?r<m&&(i=!i):i=!i)}}else if(r===d&&(n>=f&&n<=u||n>=u&&n<=f))return!0}return i}function sB(e,t){let{top:n,right:r,bottom:i,left:a}=t,[o,s]=e;return[o<a?`left`:o>r?`right`:null,s<n?`top`:s>i?`bottom`:null]}function cB(e,t){let n=e.getBoundingClientRect(),{top:r,right:i,bottom:a,left:o}=n,[s,c]=sB(t,n),l=[t];return s?(c!==`top`&&l.push([s===`left`?o:i,r]),l.push([s===`left`?i:o,r]),l.push([s===`left`?i:o,a]),c!==`bottom`&&l.push([s===`left`?o:i,a])):c===`top`?(l.push([o,r]),l.push([o,a]),l.push([i,a]),l.push([i,r])):(l.push([o,a]),l.push([o,r]),l.push([i,r]),l.push([i,a])),l}function lB({hideOnEscape:e,onClose:t,onEscapeClose:n}){let r=(0,D.useRef)(null);return{hideOnEscape:Y(t=>{if(Fj(e,t))return!1;let n={};return r.current=n,setTimeout(()=>{r.current===n&&(r.current=null)}),!0}),onClose:Y(e=>{let i=r.current;r.current=null,t?.(e),e.defaultPrevented||i&&n()})}}var uB=`div`;function dB(e,t,n,r){return!!(KM(t)||e.includes(t)||n.some(t=>t&&e.includes(t))||r?.some(t=>KM(t)||e.includes(t)))}function fB({event:e,element:t,enterPointRef:n,disablePointerEvents:r,refreshEnterPoint:i=!1}){let a=n.current;if(!a)return!1;let o=aB(e);return oB(o,cB(t,a))?(i&&(n.current=o),r(e)&&(e.preventDefault(),e.stopPropagation()),!0):!1}function pB({store:e,...t}){let[n,r]=(0,D.useState)(!1),i=$(e,`mounted`);(0,D.useEffect)(()=>{i||r(!1)},[i]);let a=t.onFocus,o=Y(e=>{a?.(e),e.defaultPrevented||r(!0)}),s=(0,D.useRef)(null);return(0,D.useEffect)(()=>GP(e,[`anchorElement`],e=>{s.current=e.anchorElement}),[e]),t={autoFocusOnHide:n,finalFocus:s,...t,onFocus:o},t}var mB=(0,D.createContext)(null),hB=Q(function({store:e,modal:t=!1,portal:n=t,hideOnEscape:r=!0,hideOnHoverOutside:i=!0,disablePointerEventsOnApproach:a=!!i,...o}){let s=nB();e||=s,Nj(e,!1);let c=(0,D.useRef)(null),l=(0,D.useRef)([]),u=(0,D.useRef)(0),d=(0,D.useRef)(null),{portalRef:f,domReady:p}=kN(n,o.portalRef),m=MN(),h=!!i,g=DN(i),_=!!a,v=DN(a),y=$(e,`open`),b=$(e,`mounted`),x=(0,D.useCallback)(()=>{window.clearTimeout(u.current),u.current=0},[]);(0,D.useEffect)(()=>{if(!p||!b||!h&&!_)return;let t=c.current;return t?Ej(jM(`mousemove`,n=>{if(!e||!m())return;let{anchorElement:r,disclosureElement:i,hideTimeout:a,timeout:o}=e.getState(),s=n.composedPath(),c=[r,i],f=c.find(e=>e&&s.includes(e));dB(s,t,c,l.current)?(d.current=f?aB(n):null,x()):u.current||fB({event:n,element:t,enterPointRef:d,disablePointerEvents:v,refreshEnterPoint:!0})||g(n)&&(u.current=window.setTimeout(()=>{u.current=0,e?.hide()},a??o))},!0),x):void 0},[e,m,p,b,h,_,l,x,v,g]),(0,D.useEffect)(()=>{if(!p||!b||!_)return;let e=e=>{let t=c.current;t&&fB({event:e,element:t,enterPointRef:d,disablePointerEvents:v})};return Ej(jM(`mouseenter`,e,!0),jM(`mouseover`,e,!0),jM(`mouseout`,e,!0),jM(`mouseleave`,e,!0))},[p,b,_,v]),(0,D.useEffect)(()=>{p&&(y||e?.setAutoFocusOnShow(!1))},[e,p,y]);let S=gN(y);(0,D.useEffect)(()=>{if(p)return()=>{S.current||e?.setAutoFocusOnShow(!1)}},[e,p]);let C=(0,D.useContext)(mB);J(()=>{if(t||!n||!b||!p)return;let e=c.current;if(e)return C?.(e)},[t,n,b,p,C]);let w=(0,D.useCallback)(e=>{x(),l.current=[...l.current,e];let t=C?.(e);return()=>{x(),l.current=l.current.filter(t=>t!==e),t?.()}},[x,C]);o=ON(o,t=>(0,O.jsx)(iB,{value:e,children:(0,O.jsx)(mB.Provider,{value:w,children:t})}),[e,w]),o={...o,ref:vN(c,o.ref)},o=pB({store:e,...o});let T=$(e,[`autoFocusOnShow`],e=>t||e.autoFocusOnShow),E=lB({hideOnEscape:r,onClose:o.onClose,onEscapeClose(){requestAnimationFrame(()=>{requestAnimationFrame(()=>{e?.getState().open&&e.hide()})})}});return o=$z({store:e,modal:t,portal:n,autoFocusOnShow:T,...o,portalRef:f,hideOnEscape:E.hideOnEscape,onClose:E.onClose}),o});Iz(X(function(e){return Z(uB,hB(e))}),nB);var gB=BN([rB],[iB]);gB.useContext,gB.useScopedContext;var _B=gB.useProviderContext,vB=gB.ContextProvider,yB=gB.ScopedContextProvider,bB=`div`,xB=Q(function({store:e,portal:t=!0,gutter:n=8,preserveTabOrder:r=!1,hideOnHoverOutside:i=!0,hideOnInteractOutside:a=!0,...o}){let s=_B();return e||=s,Nj(e,!1),o=ON(o,t=>(0,O.jsx)(yB,{value:e,children:t}),[e]),o={role:$(e,[`type`],e=>e.type===`description`?`tooltip`:`none`),...o},o=hB({...o,store:e,portal:t,gutter:n,preserveTabOrder:r,hideOnHoverOutside(t){if(Fj(i,t))return!1;let n=e?.getState().anchorElement;return!n||!(`focusVisible`in n.dataset)},hideOnInteractOutside:t=>{if(Fj(a,t))return!1;let n=e?.getState().anchorElement;return!n||!Yj(n,t.target)}}),o}),SB=Iz(X(function(e){return Z(bB,xB(e))}),_B),CB=Q(function({store:e,showOnHover:t=!0,unstable_showOnHoverWhenDisabled:n=!0,setAnchorElement:r=!1,...i}){let a=Ij(i),o=i.focusable!==!1,s=(0,D.useRef)(null),c=(0,D.useRef)(0),l=Y(e=>a&&!o?!0:tN(e));(0,D.useEffect)(()=>()=>window.clearTimeout(c.current),[]),(0,D.useEffect)(()=>jM(`mouseleave`,e=>{let t=s.current;t&&e.target===t&&(window.clearTimeout(c.current),c.current=0)},!0),[]);let u=i.onMouseMove,d=DN(t),f=DN(n),p=MN(),m=Y(t=>{if(u?.(t),t.defaultPrevented||c.current||!p())return;let n=t.currentTarget;if(l(n)||(a||Lj(n))&&!f(t)||!d(t))return;r&&e.setAnchorElement(n),e.setDisclosureElement(n);let{showTimeout:i,timeout:o}=e.getState(),s=()=>{c.current=0,p()&&(l(n)||(r&&e.setAnchorElement(n),e.show(),queueMicrotask(()=>{e.setDisclosureElement(n)})))},m=i??o;m===0?s():c.current=window.setTimeout(s,m)}),h=i.onClick,g=Y(e=>{h?.(e),window.clearTimeout(c.current),c.current=0}),_=(0,D.useCallback)(t=>{if(s.current=t,!r)return;let{anchorElement:n}=e.getState();n?.isConnected||e.setAnchorElement(t)},[e,r]);return i={...i,ref:vN(_,i.ref),onMouseMove:m,onClick:g},i=iP(i),i}),wB=`a`,TB=Q(function({store:e,showOnHover:t=!0,...n}){let r=nB();return e||=r,Nj(e,!1),CB({store:e,showOnHover:t,setAnchorElement:!0,...n})});X(function(e){return Z(wB,TB(e))});var EB=`div`,DB=VP({activeStore:null}),OB=new WeakSet;function kB(e){return()=>{let{activeStore:t}=DB.getState();t===e&&DB.setState(`activeStore`,null)}}function AB(e){return`key`in e&&e.key===`Escape`}function jB(e){e&&(OB.add(e),e.hide(),queueMicrotask(()=>OB.delete(e)))}var MB=Q(function({store:e,showOnHover:t=!0,...n}){let r=_B();e||=r,Nj(e,!1);let i=(0,D.useRef)(!1);(0,D.useEffect)(()=>GP(e,[`mounted`],e=>{e.mounted||(i.current=!1)}),[e]);let a=(0,D.useRef)(!1),o=(0,D.useRef)(null);(0,D.useEffect)(()=>GP(e,[`open`],t=>{if(t.open||!e)return;let{contentElement:n}=e.getState();n&&KM(n)&&(a.current=!0,setTimeout(()=>{a.current=!1}))}),[e]);let s=n.onFocus,c=Y(e=>{s?.(e),a.current&&(a.current=!1,o.current=e.nativeEvent)});(0,D.useEffect)(()=>{if(!e)return;let t=kB(e);return Ej(t,GP(e,[`mounted`],n=>{if(!e)return;if(n.mounted){let{activeStore:t}=DB.getState();if(t!==e){if(OB.has(e))return;jB(t)}return DB.setState(`activeStore`,e)}let r=setTimeout(t,e.getState().skipTimeout);return()=>clearTimeout(r)}))},[e]);let l=n.onMouseEnter,u=Y(e=>{l?.(e),i.current=!0}),d=n.onFocusVisible,f=Y(t=>{d?.(t),t.defaultPrevented||AB(t.nativeEvent)||t.nativeEvent!==o.current&&(e?.setAnchorElement(t.currentTarget),e?.show())}),p=n.onBlur,m=Y(t=>{if(p?.(t),t.defaultPrevented)return;let{activeStore:n}=DB.getState();i.current=!1,n===e&&DB.setState(`activeStore`,null)}),h=$(e,[`type`,`contentElement`],e=>e.type===`label`?e.contentElement:null);wN(h,`id`);let g=h?.id;return n={"aria-labelledby":n[`aria-label`]==null?g:void 0,...n,onMouseEnter:u,onFocus:c,onFocusVisible:f,onBlur:m},n=TB({store:e,showOnHover(n){if(!i.current||Fj(t,n))return!1;let{activeStore:r}=DB.getState();return!r||(e?.show(),!1)},...n}),n}),NB=X(function(e){return Z(EB,MB(e))});function PB({popover:e,...t}={}){let n=YP(t.store,qP(e,[`arrowElement`,`anchorElement`,`contentElement`,`popoverElement`,`disclosureElement`,`unstable_placing`])),r=n?.getState(),i=BR({...t,store:n}),a=K(t.placement,r?.placement,`bottom`),o={...i.getState(),placement:a,currentPlacement:a,anchorElement:K(r?.anchorElement,null),popoverElement:K(r?.popoverElement,null),arrowElement:K(r?.arrowElement,null),rendered:Symbol(`rendered`),unstable_placing:!1},s=VP(o,i,n),c=o.anchorElement===o.disclosureElement?o.anchorElement:null;return HP(s,()=>GP(s,[`anchorElement`,`disclosureElement`],e=>{e.anchorElement&&e.anchorElement!==c?c=null:(c=e.disclosureElement,s.setState(`anchorElement`,c))})),HP(s,()=>e?.unstable_onHideRequest(i.unstable_requestHide)),{...i,...s,setAnchorElement:e=>s.setState(`anchorElement`,e),setPopoverElement:e=>s.setState(`popoverElement`,e),setArrowElement:e=>s.setState(`arrowElement`,e),render:()=>s.setState(`rendered`,Symbol(`rendered`))}}function FB(e,t,n){return TN(t,[n.popover,t]),UF(e,n,`placement`),VR(e,t,n)}function IB(e={}){let[t,n]=WF(PB,e);return FB(t,n,e)}function LB(e={}){let t=e.store?.getState(),n=PB({...e,placement:K(e.placement,t?.placement,`bottom`)}),r=K(e.timeout,t?.timeout,500),i=VP({...n.getState(),timeout:r,showTimeout:K(e.showTimeout,t?.showTimeout),hideTimeout:K(e.hideTimeout,t?.hideTimeout),autoFocusOnShow:K(t?.autoFocusOnShow,!1)},n,e.store);return{...n,...i,setAutoFocusOnShow:e=>i.setState(`autoFocusOnShow`,e)}}function RB(e,t,n){return UF(e,n,`timeout`),UF(e,n,`showTimeout`),UF(e,n,`hideTimeout`),FB(e,t,n)}function zB(e={}){let t=e.store?.getState(),n=LB({...e,placement:K(e.placement,t?.placement,`top`),hideTimeout:K(e.hideTimeout,t?.hideTimeout,0)}),r=VP({...n.getState(),type:K(e.type,t?.type,`description`),skipTimeout:K(e.skipTimeout,t?.skipTimeout,300)},n,e.store);return{...n,...r}}function BB(e,t,n){return UF(e,n,`type`),UF(e,n,`skipTimeout`),RB(e,t,n)}function VB(e={}){let[t,n]=WF(zB,e);return BB(t,n,e)}function HB(e={}){let t=VB(e);return(0,O.jsx)(vB,{value:t,children:e.children})}var UB=BN([vP],[yP]),WB=UB.useContext,GB=UB.useScopedContext;UB.useProviderContext,UB.ContextProvider,UB.ScopedContextProvider;var KB=`button`,qB=Q(function(e){let t=(0,D.useRef)(null),n=CN(t,KB),[r,i]=(0,D.useState)(()=>!!n&&$j({tagName:n,type:e.type}));return(0,D.useEffect)(()=>{t.current&&i($j(t.current))},[]),e={role:!r&&n!==`a`?`button`:void 0,...e,ref:vN(t,e.ref)},e=cP(e),e}),JB=X(function(e){return Z(KB,qB(gj(e)))}),YB=`button`,XB=Symbol(`disclosure`),ZB=Q(function({store:e,toggleOnClick:t=!0,...n}){let r=DI();e||=r,Nj(e,!1);let i=(0,D.useRef)(null),[a,o]=(0,D.useState)(!1),s=$(e,`disclosureElement`),c=$(e,`open`),l=(0,D.useCallback)(t=>{let n=i.current;i.current=t,t?e?.getState().disclosureElement?.isConnected||e.setDisclosureElement(t):e?.getState().disclosureElement===n&&e.setDisclosureElement(null)},[e]);(0,D.useEffect)(()=>{let t=s===i.current;s?.isConnected||(e?.setDisclosureElement(i.current),t=!0),o(c&&t)},[s,e,c]);let u=n.onClick,d=DN(t),[f,p]=AN(n,XB,!0),m=Y(t=>{u?.(t),t.defaultPrevented||f||d(t)&&(e?.setDisclosureElement(t.currentTarget),e?.toggle())});return n={"aria-expanded":a,"aria-controls":$(e,`contentElement`)?.id,...p,...n,ref:vN(l,n.ref),onClick:m},n=qB(n),n});X(function(e){return Z(YB,ZB(gj(e)))});var QB=`button`,$B=Q(function({store:e,...t}){let n=jI();return e||=n,Nj(e,!1),t={"aria-haspopup":cM($(e,`contentElement`),`dialog`),...t},t=ZB({store:e,...t}),t});X(function(e){return Z(QB,$B(gj(e)))});var eV=`button`,tV=Q(function({store:e,...t}){let n=$I();return e||=n,Nj(e,!1),t=ON(t,t=>(0,O.jsx)(tL,{value:e,children:t}),[e]),t=$B({store:e,...t}),t}),nV=X(function(e){return Z(eV,tV(gj(e)))}),rV=`span`,iV={top:`4,10 8,6 12,10`,right:`6,4 10,8 6,12`,bottom:`4,6 8,10 12,6`,left:`10,4 6,8 10,12`},aV=Q(function({store:e,placement:t,...n}){let r=QI();e||=r,Nj(e,!1);let i=iV[zz($(e,[`placement`],e=>t||e.placement))];return n={children:(0,D.useMemo)(()=>(0,O.jsx)(`svg`,{display:`block`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,viewBox:`0 0 16 16`,height:`1em`,width:`1em`,children:(0,O.jsx)(`polyline`,{points:i})}),[i]),"aria-hidden":!0,...n,style:{width:`1em`,height:`1em`,pointerEvents:`none`,...n.style}},n});X(function(e){return Z(rV,aV(e))});function oV(e={}){let t=IB(e);return(0,O.jsx)(eL,{value:t,children:e.children})}var sV=`div`,cV=new WeakMap;function lV(e){let t=cV.get(e);return t||(t={chars:``,cleanupTimeout:0},cV.set(e,t)),t}function uV(e){e.chars=``}function dV(e,t){let n=e.target;return n&&nM(n)?!1:e.key===` `&&t.chars.length?!0:e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&/^[\p{Letter}\p{Number}]$/u.test(e.key)}function fV(e,t){if(bM(e))return!0;let n=e.target;return n?t.some(e=>e.element===n):!1}function pV(e){return e.filter(e=>!e.disabled)}function mV(e,t){let n=e.typeaheadText??(e.element?.textContent||e.children||`value`in e&&e.value);return n?Oj(n).trim().toLowerCase().startsWith(t.toLowerCase()):!1}function hV({activeId:e,char:t,items:n,typeaheadState:r}){if(!e)return n;let i=n.find(t=>t.id===e);if(!i||!mV(i,t))return n;let{chars:a}=r;return a!==t&&mV(i,a)?n:(r.chars=t,yF(n.filter(e=>mV(e,t)),e).filter(t=>t.id!==e))}var gV=Q(function({store:e,typeahead:t=!0,...n}){let r=gP();e||=r,Nj(e,!1);let i=n.onKeyDownCapture,a=Y(n=>{if(i?.(n),n.defaultPrevented||!t||!e)return;let r=lV(e);if(!dV(n,r))return uV(r);let{renderedItems:a,items:o,activeId:s}=e.getState(),c=pV(o.length>a.length?o:a);if(!fV(n,c))return uV(r);n.preventDefault(),window.clearTimeout(r.cleanupTimeout),r.cleanupTimeout=window.setTimeout(()=>{uV(r)},500);let l=n.key.toLowerCase();r.chars+=l,c=hV({activeId:s,char:l,items:c,typeaheadState:r});let u=c.find(e=>mV(e,r.chars));u?e.move(u.id):uV(r)});return n={...n,onKeyDownCapture:a},Rj(n)});X(function(e){return Z(sV,gV(e))});var _V=`span`,vV=Q(function({store:e,...t}){let n=lL();return e||=n,t=aV({store:e,...t}),t}),yV=X(function(e){return Z(_V,vV(e))}),bV=`button`;function xV(e){return Array.from(e.selectedOptions).map(e=>e.value)}function SV(e,t){return()=>{let n=new Set,r=t();for(;r;){let i=e.item(r);if(!i)return;if(i.value!=null)return i.id;if(n.has(r))return;n.add(r),r=t({activeId:r})}}}var CV=Q(function({store:e,name:t,form:n,required:r,showOnKeyDown:i=!0,moveOnKeyDown:a=!0,toggleOnPress:o=!0,toggleOnClick:s=o,...c}){let l=dL();e||=l,Nj(e,!1);let u=c.onKeyDown,d=Ij(c),f=DN(i),p=DN(a),m=zz($(e,`placement`)),h=$(e,`value`),g=Array.isArray(h),_=Y(t=>{if(u?.(t),t.defaultPrevented||!e)return;let{orientation:n,items:r,activeId:i}=e.getState(),a=n!==`horizontal`,o=n!==`vertical`,s=!!r.find(e=>!e.disabled&&e.value!=null)?.rowId,c={ArrowUp:(s||a)&&SV(e,e.up),ArrowRight:(s||o)&&SV(e,e.next),ArrowDown:(s||a)&&SV(e,e.down),ArrowLeft:(s||o)&&SV(e,e.previous)}[t.key];c&&p(t)&&(t.preventDefault(),e.move(c()));let l=m===`top`||m===`bottom`;({ArrowDown:l,ArrowUp:l,ArrowLeft:m===`left`,ArrowRight:m===`right`})[t.key]&&f(t)&&(t.preventDefault(),e.move(i),AM(t.currentTarget,`keyup`,e.show))});c=ON(c,t=>(0,O.jsx)(pL,{value:e,children:t}),[e]);let[v,y]=(0,D.useState)(!1),b=(0,D.useRef)(!1);(0,D.useEffect)(()=>{let e=b.current;b.current=!1,e||y(!1)},[h]);let x=$(e,`labelElement`);wN(x,`id`);let S=x?.id,C=c[`aria-label`],w=c[`aria-labelledby`]||S,T=$(e,[`items`],e=>{if(t)return e.items}),E=(0,D.useMemo)(()=>{let e=T?.flatMap(e=>e.value??[]);return[...new Set(e)]},[T]);c=ON(c,i=>(0,O.jsxs)(O.Fragment,{children:[!!t&&(0,O.jsxs)(`select`,{style:KL(),tabIndex:-1,"aria-hidden":!0,"aria-label":C,"aria-labelledby":C==null?w:void 0,name:t,form:n,required:r,disabled:d,value:h,multiple:g,onFocus:()=>e?.getState().selectElement?.focus(),onChange:t=>{b.current=!0,y(!0),e?.setValue(g?xV(t.target):t.target.value)},children:[_j(h).map(e=>e==null||E.includes(e)?null:(0,O.jsx)(`option`,{value:e,children:e},e)),E.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e))]}),i]}),[e,C,w,t,n,r,h,g,E,d]);let ee=(0,O.jsxs)(O.Fragment,{children:[h,(0,O.jsx)(yV,{})]}),te=$(e,`contentElement`);return c={role:`combobox`,"aria-autocomplete":`none`,"aria-labelledby":c[`aria-label`]==null?S:void 0,"aria-haspopup":cM(te,`listbox`),"data-autofill":v||void 0,"data-name":t,children:ee,...c,ref:vN(e.setSelectElement,c.ref),onKeyDown:_},c=tV({store:e,toggleOnClick:s,...c}),c=gV({store:e,...c}),c}),wV=X(function(e){return Z(bV,CV(gj(e)))}),TV=(0,D.createContext)(void 0),EV=`div`,DV=Q(function(e){let[t,n]=(0,D.useState)();return e=ON(e,e=>(0,O.jsx)(TV.Provider,{value:n,children:e}),[]),e={role:`group`,"aria-labelledby":e[`aria-label`]==null?t:void 0,...e},e}),OV=X(function(e){return Z(EV,DV(e))}),kV=`div`,AV=Q(function(e){let t=(0,D.useContext)(TV),n=SN(e.id);return J(()=>(t?.(n),()=>t?.(void 0)),[t,n]),e={"aria-hidden":!0,...e,id:n},e});X(function(e){return Z(kV,AV(e))});var jV=`div`,MV=Q(function({store:e,...t}){return t=AV(t),t});X(function(e){return Z(jV,MV(e))});var NV=`div`;function PV(e){let t=e.relatedTarget;return Xj(t)?Yj(e.currentTarget,t):!1}var FV=Symbol(`composite-hover`);function IV(e){let{relatedTarget:t}=e;if(!Xj(t))return!1;let n=t;do{if(Tj(n,FV)&&n[FV])return!0;n=n.parentElement}while(n);return!1}var LV=Q(function({store:e,focusOnHover:t=!0,blurOnHoverEnd:n=!!t,...r}){let i=gP();e||=i,Nj(e,!1);let a=MN(),o=r.onMouseMove,s=DN(t),c=Y(t=>{if(o?.(t),!t.defaultPrevented&&a()&&s(t)){if(!KM(t.currentTarget)){let t=e?.getState().compositeElement;t&&!GM(t)&&t.focus({preventScroll:!0})}e?.setActiveId(t.currentTarget.id)}}),l=r.onMouseLeave,u=DN(n),d=Y(t=>{l?.(t),t.defaultPrevented||a()&&(PV(t)||IV(t)||s(t)&&u(t)&&(e?.setActiveId(null),e?.getState().compositeElement?.focus({preventScroll:!0})))}),f=(0,D.useCallback)(e=>{e&&(e[FV]=!0)},[]);return r={...r,ref:vN(f,r.ref),onMouseMove:c,onMouseLeave:d},r});zN(X(function(e){return Z(NV,LV(e))}));var RV=`div`;function zV(e,t){if(t!=null)return e==null?!1:Array.isArray(e)?e.includes(t):e===t}var BV=Q(function({store:e,value:t,getItem:n,hideOnClick:r,setValueOnClick:i=t!=null,preventScrollOnKeyDown:a=!0,focusOnHover:o=!0,...s}){let c=uL();e||=c,Nj(e,!1);let l=SN(s.id),u=Ij(s),{listElement:d,multiSelectable:f,selected:p,autoFocus:m}=HF(e,[`value`,`activeId`,`items`],{listElement:`listElement`,multiSelectable(e){return Array.isArray(e.value)},selected(e){return zV(e.value,t)},autoFocus(n){return t==null||n.value==null||n.activeId!==l&&e?.item(n.activeId)?!1:Array.isArray(n.value)?n.value[n.value.length-1]===t:n.value===t}}),h=$(e?.combobox,`virtualFocus`),g=(0,D.useCallback)(e=>{let r={...e,value:u?void 0:t};return n?n(r):r},[u,t,n]);r??=t!=null&&!f;let _=s.onClick,v=DN(i),y=DN(r),b=Y(n=>{_?.(n),n.defaultPrevented||CM(n)||SM(n)||(v(n)&&t!=null&&e?.setValue(e=>Array.isArray(e)?e.includes(t)?e.filter(e=>e!==t):[...e,t]:t),y(n)&&e?.hide())});s=ON(s,e=>(0,O.jsx)(mL.Provider,{value:p??!1,children:e}),[p]);let x=s.autoFocus??m;s={role:uM(d),"aria-selected":p,children:t,...s,id:l,autoFocus:h!==!1&&x,"data-autofocus":x||void 0,onClick:b},s=ZF({store:e,getItem:g,preventScrollOnKeyDown:a,...s});let S=DN(o);return s=LV({store:e,...s,focusOnHover(t){return!e.getState().open||!S(t)?!1:e.getState().open}}),s}),VV=zN(X(function(e){return Z(RV,BV(e))})),HV=(0,D.createContext)(!1),UV=`span`,WV=(0,O.jsx)(`svg`,{display:`block`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,viewBox:`0 0 16 16`,height:`1em`,width:`1em`,children:(0,O.jsx)(`polyline`,{points:`4,8 7,12 12,4`})});function GV(e){return e.checked?e.children||WV:null}var KV=Q(function({store:e,checked:t,...n}){let r=(0,D.useContext)(HV);t??=r;let i=GV({checked:t,children:n.children});return n={"aria-hidden":!0,...n,children:i,style:{width:`1em`,height:`1em`,pointerEvents:`none`,...n.style}},n}),qV=X(function(e){return Z(UV,KV(e))}),JV=`span`,YV=Q(function({store:e,checked:t,...n}){let r=(0,D.useContext)(mL);return t??=r,n=KV({...n,checked:t}),n}),XV=X(function(e){return Z(JV,YV(e))}),ZV=`div`,QV=(0,D.createContext)(null),$V=Q(function({store:e,resetOnEscape:t=!0,hideOnEnter:n=!0,composite:r,alwaysVisible:i,...a}){let o=lL();e||=o,Nj(e,!1);let s=SN(a.id),c=$(e,`value`),l=Array.isArray(c),[u,d]=(0,D.useState)(c),f=$(e,`mounted`);(0,D.useEffect)(()=>{f||d(c)},[f,c]),t&&=!l;let p=a.onKeyDown,m=DN(t),h=DN(n),g=Y(t=>{p?.(t),t.defaultPrevented||(t.key===`Escape`&&m(t)&&e?.setValue(u),(t.key===` `||t.key===`Enter`)&&bM(t)&&h(t)&&(t.preventDefault(),e?.hide()))}),_=(0,D.useContext)(hL),v=(0,D.useState)(),[y,b]=_||v,x=(0,D.useMemo)(()=>[y,b],[y,b]),[S,C]=(0,D.useState)(null),w=(0,D.useContext)(QV);(0,D.useEffect)(()=>{if(w)return w(e),()=>w(null)},[w,e]),a=ON(a,t=>(0,O.jsx)(pL,{value:e,children:(0,O.jsx)(QV.Provider,{value:C,children:(0,O.jsx)(hL.Provider,{value:x,children:t})})}),[e,x]);let T=!!e.combobox;r??=!T&&S!==e;let[,E]=_N(r?e.setListElement:null),ee=VI(f,a.hidden,i),te=ee?{...a.style,display:`none`}:a.style;r&&(a={role:`listbox`,"aria-multiselectable":l||void 0,...a});let ne=$(e,[`labelElement`],e=>y?null:e.labelElement);wN(ne,`id`);let re=y||ne?.id;return a={"aria-labelledby":a[`aria-label`]==null?re:void 0,hidden:ee,...a,id:s,ref:vN(E,a.ref),style:te,onKeyDown:g},a=SI({store:e,...a,composite:r}),a=gV({store:e,typeahead:!T,...a}),a});X(function(e){return Z(ZV,$V(e))});var eH=`div`,tH=Q(function({store:e,alwaysVisible:t,...n}){let r=dL();return e||=r,n=$V({store:e,alwaysVisible:t,...n}),n=$z({store:e,alwaysVisible:t,...n}),n}),nH=Iz(X(function(e){return Z(eH,tH(e))}),dL);function rH({combobox:e,...t}={}){let n=YP(t.store,qP(e,[`value`,`items`,`renderedItems`,`compositeElement`,`baseElement`,`arrowElement`,`anchorElement`,`contentElement`,`popoverElement`,`disclosureElement`,`inputElement`,`labelElement`,`selectElement`,`selectLabelElement`])),r=n.getState(),i=vF({...t,store:n,virtualFocus:K(t.virtualFocus,r.virtualFocus,!0),compositeElementInFocusOrder:K(t.compositeElementInFocusOrder,t.includesBaseElement,r.compositeElementInFocusOrder,r.includesBaseElement,!1),activeId:K(t.activeId,r.activeId,t.defaultActiveId,null),orientation:K(t.orientation,r.orientation,`vertical`)}),a=PB({...t,store:n,placement:K(t.placement,r.placement,`bottom-start`)}),o=new String(``),s={...i.getState(),...a.getState(),value:K(t.value,r.value,t.defaultValue,o),setValueOnMove:K(t.setValueOnMove,r.setValueOnMove,!1),labelElement:K(r.labelElement,null),selectElement:K(r.selectElement,null),listElement:K(r.listElement,null)},c=VP(s,i,a,n);return HP(c,()=>e?.unstable_onHideRequest(a.unstable_requestHide)),HP(c,()=>GP(c,[`value`,`items`],e=>{if(e.value!==o||!e.items.length)return;let t=e.items.find(e=>!e.disabled&&e.value!=null);t?.value!=null&&c.setState(`value`,t.value)})),HP(c,()=>GP(c,[`mounted`],e=>{e.mounted||c.setState(`activeId`,s.activeId)})),HP(c,()=>GP(c,[`mounted`,`items`,`value`],t=>{if(e||t.mounted)return;let n=_j(t.value),r=n[n.length-1];if(r==null)return;let i=t.items.find(e=>!e.disabled&&e.value===r);i&&c.setState(`activeId`,i.id)})),HP(c,()=>KP(c,[`setValueOnMove`,`moves`],e=>{let{mounted:t,value:n,activeId:r}=c.getState();if(!e.setValueOnMove&&t||Array.isArray(n)||!e.moves||!r)return;let a=i.item(r);a&&!a.disabled&&a.value!=null&&c.setState(`value`,a.value)})),{...i,...a,...c,combobox:e,setValue:e=>c.setState(`value`,e),setLabelElement:t=>{c.setState(`labelElement`,t),e?.setSelectLabelElement(t)},setSelectElement:e=>c.setState(`selectElement`,e),setListElement:e=>c.setState(`listElement`,e)}}function iH(e){let t=iL();return e={...e,combobox:e.combobox===void 0?t:e.combobox},oL(e)}function aH(e,t,n){return TN(t,[n.combobox,t]),UF(e,n,`value`,`setValue`),UF(e,n,`setValueOnMove`),Object.assign(FB(sL(e,t,n),t,n),{combobox:n.combobox})}function oH(e={}){e=iH(e);let[t,n]=WF(rH,e);return aH(t,n,e)}function sH(e={}){let t=oH(e);return(0,O.jsx)(fL,{value:t,children:e.children})}var cH=BN([dP],[fP]),lH=cH.useContext;function uH({store:e,name:t,component:n}){let r=lH(),i=e||r;return Nj(i,!1),{store:i,name:String(t)}}function dH({id:e,type:t,getItem:n,...r}){let{store:i,name:a}=uH(r),o=SN(e);return{store:i,name:a,id:o,ref:(0,D.useRef)(null),getItem:(0,D.useCallback)(e=>{let r={...e,id:o||e.id,name:a,type:t};return n?n(r):r},[o,a,t,n])}}cH.useScopedContext,cH.useProviderContext;var fH=cH.ContextProvider;cH.ScopedContextProvider;var pH=2**32-2;function mH(e){return Array.isArray(e)?e.map(e=>typeof e==`number`?e:String(e)):String(e).split(`.`)}function hH(e){return e===`__proto__`||e===`constructor`}function gH(){return new Promise(e=>{let t=setTimeout(e,100);requestAnimationFrame(()=>{clearTimeout(t),e()})})}function _H(e){let t=Object.keys(e);for(let n of t)if(!hH(n)){if(wj(e[n])){if(_H(e[n]))return!0}else if(e[n])return!0}return!1}function vH(e,t,n){return yH(e,mH(t),n)}function yH(e,t,n){let[r,...i]=t;return r==null||!e||hH(r)?n:i.length?yH(e[r],i,n):e[r]??n}function bH(e){if(typeof e!=`string`&&typeof e!=`number`)return!1;let t=String(e),n=Number(t);return Number.isInteger(n)&&n>=0&&n<=pH&&String(n)===t}function xH(e,t){return Array.isArray(e)||wj(e)?e:bH(t)?[]:{}}function SH(e,t,n){let r={};if(e){let t=Object.keys(e);for(let n of t)hH(n)||(r[n]=e[n])}return r[t]=n,r}function CH(e,t,n){let r=mH(t);return r.some(hH)?e:wH(e,r,n)}function wH(e,t,n){let[r,...i]=t;if(r==null)return e;let a=r,o=bH(r),s=(o?e||[]:e||{})[a],c=i[0],l=i.length&&c!=null?wH(xH(s,c),i,n):n;if(o){let t=Number(a);if(e&&Array.isArray(e)){let n=[...e];return n[t]=l,n}let n=[];return n[t]=l,n}return SH(e,a,l)}function TH(e,t){let n={},r=Object.keys(e);for(let i of r){if(hH(i))continue;let r=e[i];n[i]=Array.isArray(r)?r.map(e=>wj(e)?TH(e,t):t):wj(r)?TH(r,t):t}return n}function EH(e,t=[]){return{get(n,r){if(typeof r==`symbol`)return r===Symbol.toPrimitive?()=>t.join(`.`):void 0;if(r===`toString`||r===`valueOf`)return()=>t.join(`.`);let i=[...t,r],a=i.join(`.`);if(e[a])return e[a];let o=new Proxy(n,EH(e,i));return e[a]=o,o}}}function DH(e){return e?.__unstableCallbacks}function OH(){return new Proxy(Object.create(null),EH(Object.create(null)))}function kH(e={}){e.store;let t=e.store?.getState(),n=tF(e),r=K(e.values,t?.values,e.defaultValues,{}),i=K(e.errors,t?.errors,e.defaultErrors,{}),a=K(e.touched,t?.touched,e.defaultTouched,{}),o=VP({...n.getState(),values:r,errors:i,touched:a,validating:K(t?.validating,!1),submitting:K(t?.submitting,!1),submitSucceed:K(t?.submitSucceed,0),submitFailed:K(t?.submitFailed,0),valid:!_H(i)},n,e.store),s=DH(e.store),c=s?.getState(),l=VP({validate:c?.validate||[],submit:c?.submit||[]},s);HP(o,()=>UP(l)),HP(o,()=>GP(o,[`validating`,`errors`],e=>{e.validating||o.setState(`valid`,!_H(e.errors))}));let u=async()=>{o.setState(`validating`,!0),o.setState(`errors`,{});let e=l.getState().validate;try{for(let t of e)await t(o.getState());return await gH(),!_H(o.getState().errors)}finally{o.setState(`validating`,!1)}};return{...n,...o,names:OH(),setValues:e=>o.setState(`values`,e),getValue:e=>vH(o.getState().values,e),setValue:(e,t)=>o.setState(`values`,n=>{let r=vH(n,e),i=xj(t,r);return i===r?n:CH(n,e,i)}),pushValue:(e,t)=>o.setState(`values`,n=>CH(n,e,[...vH(n,e,[]),t])),removeValue:(e,t)=>o.setState(`values`,n=>{let r=vH(n,e,[]);return CH(n,e,[...r.slice(0,t),null,...r.slice(t+1)])}),setErrors:e=>o.setState(`errors`,e),getError:e=>vH(o.getState().errors,e),setError:(e,t)=>o.setState(`errors`,n=>{let r=vH(n,e),i=xj(t,r);return i===r?n:CH(n,e,i)}),setTouched:e=>o.setState(`touched`,e),getFieldTouched:e=>!!vH(o.getState().touched,e),setFieldTouched:(e,t)=>o.setState(`touched`,n=>{let r=vH(n,e),i=xj(t,r);return i===r?n:CH(n,e,i)}),onValidate:e=>(l.setState(`validate`,t=>[...t,e]),()=>{l.setState(`validate`,t=>t.filter(t=>t!==e))}),validate:u,onSubmit:e=>(l.setState(`submit`,t=>[...t,e]),()=>{l.setState(`submit`,t=>t.filter(t=>t!==e))}),submit:async()=>{o.setState(`submitting`,!0),o.setState(`touched`,TH(o.getState().values,!0));try{if(await u()){let e=l.getState().submit;for(let t of e)await t(o.getState());if(await gH(),!_H(o.getState().errors))return o.setState(`submitSucceed`,e=>e+1),!0}return o.setState(`submitFailed`,e=>e+1),!1}catch(e){throw o.setState(`submitFailed`,e=>e+1),e}finally{o.setState(`submitting`,!1)}},reset:()=>{o.setState(`values`,r),o.setState(`errors`,i),o.setState(`touched`,a),o.setState(`validating`,!1),o.setState(`submitting`,!1),o.setState(`submitSucceed`,0),o.setState(`submitFailed`,0),o.setState(`valid`,!_H(i))},__unstableCallbacks:l}}function AH(e,t){return $(e,[`values`],()=>e.getValue(t))}function jH(e,t){let n=Y(t),r=$(e,`items`);(0,D.useEffect)(()=>e.onValidate(n),[e,r,n])}function MH(e,t){let n=Y(t),r=$(e,`items`);(0,D.useEffect)(()=>e.onSubmit(n),[e,r,n])}function NH(e,t,n){let r=aL(e,t,n);UF(r,n,`values`,`setValues`),UF(r,n,`errors`,`setErrors`),UF(r,n,`touched`,`setTouched`);let i=(0,D.useCallback)(e=>AH(r,e),[r]),a=(0,D.useCallback)(e=>{jH(r,e)},[r]),o=(0,D.useCallback)(e=>{MH(r,e)},[r]);return(0,D.useMemo)(()=>({...r,useValue:i,useValidate:a,useSubmit:o}),[r,i,a,o])}function PH(e={}){let[t,n]=WF(kH,e);return NH(t,n,e)}var FH=`input`;function IH(e,t){let n=e.current;return n?n.name===t?n:n.form?n.form.elements.namedItem(t):q(n).getElementsByName(t)[0]:null}function LH(e,t){let n={};for(let r of e)if(r.name===t&&(r.type===`label`&&n.labelId===void 0?n.labelId=r.id:r.type===`error`&&n.errorId===void 0?n.errorId=r.id:r.type===`description`&&n.descriptionId===void 0&&(n.descriptionId=r.id),n.labelId!==void 0&&n.errorId!==void 0&&n.descriptionId!==void 0))break;return n}function RH(e,t){let n=(0,D.useMemo)(()=>{let e,n={};return r=>(r.items!==e&&(e=r.items,n=LH(r.items,t)),n)},[t]);return HF(e,[`items`,`errors`,`touched`],{labelId:e=>n(e).labelId,errorId:e=>n(e).errorId,descriptionId:e=>n(e).descriptionId,invalid:()=>!!e.getError(t)&&e.getFieldTouched(t)})}var zH=Q(function({store:e,name:t,getItem:n,touchOnBlur:r=!0,...i}){let{store:a,name:o,id:s,ref:c,getItem:l}=dH({store:e,name:t,id:i.id,type:`field`,getItem:n,component:`FormControl`});jH(a,async()=>{let e=IH(c,o);e&&(await Promise.resolve(),`validity`in e&&!e.validity.valid&&a.setError(o,e.validationMessage))});let u=i.onBlur,d=DN(r),f=Y(e=>{u?.(e),e.defaultPrevented||d(e)&&a.setFieldTouched(o,!0)}),{labelId:p,errorId:m,descriptionId:h,invalid:g}=RH(a,o),_=Dj(m,h,i[`aria-describedby`]);return i={"aria-labelledby":i[`aria-label`]==null?p:void 0,"aria-invalid":g,...i,id:s,"aria-describedby":_||void 0,ref:vN(c,i.ref),onBlur:f},i=mP({store:a,...i,name:o,getItem:l}),i});zN(X(function(e){return Z(FH,zH(e))}));var BH=`input`,VH=Q(function({store:e,name:t,...n}){let{store:r,name:i}=uH({store:e,name:t,component:`FormInput`}),a=n.onChange,o=Y(e=>{a?.(e),e.defaultPrevented||r.setValue(i,e.target.value)});return n={value:AH(r,i),...n,onChange:o},n=iP(n),n=zH({store:r,name:i,...n}),n}),HH=zN(X(function(e){return Z(BH,VH(e))})),UH=`label`;function WH(e){return e===`input`||e===`textarea`||e===`select`||e===`meter`||e===`progress`}var GH=Q(function({store:e,name:t,getItem:n,...r}){let{store:i,name:a,id:o,ref:s,getItem:c}=dH({store:e,name:t,id:r.id,type:`label`,getItem:n,component:`FormLabel`}),l=$(i,[`items`],e=>e.items.find(e=>e.type===`field`&&e.name===a)),u=WH(CN(l?.element,`input`)),d=r.onClick,f=Y(e=>{if(d?.(e),e.defaultPrevented||u)return;let t=l?.element;t&&queueMicrotask(()=>{let e=zM(t,!0,!0);e?.focus(),e?.getAttribute(`role`)!==`combobox`&&e?.click()})});return r={render:u?(0,O.jsx)(`label`,{}):(0,O.jsx)(`span`,{}),htmlFor:u?l?.id:void 0,...r,id:o,ref:vN(s,r.ref),onClick:f},u||(r={...r,style:{cursor:`default`,...r.style}}),r=mP({store:i,...r,getItem:c}),r}),KH=zN(X(function(e){return Z(UH,GH(e))}));function qH(e={}){let t=PH(e);return(0,O.jsx)(fH,{value:t,children:e.children})}var JH=BN([vP,rB],[yP,iB]),YH=JH.useContext,XH=JH.useScopedContext,ZH=JH.useProviderContext,QH=JH.ContextProvider,$H=JH.ScopedContextProvider;(0,D.createContext)(void 0);var eU=(0,D.createContext)(!1),tU=`div`;function nU({store:e,...t}){let[n,r]=(0,D.useState)(void 0),i=t[`aria-label`],a=$(e,`disclosureElement`),o=$(e,`contentElement`);return(0,D.useEffect)(()=>{let e=o;if(!e)return;let t=i||e.hasAttribute(`aria-label`)?void 0:a?.id||void 0;r(t)},[i,a,o]),n}var rU=Q(function({store:e,alwaysVisible:t,composite:n,...r}){let i=ZH();e||=i,Nj(e,!1);let a=e.parent,o=e.menubar,s=!!a,c=SN(r.id),l=r.onKeyDown,u=$(e,[`placement`],e=>zz(e.placement)),d=$(e,[`orientation`],e=>e.orientation===`both`?void 0:e.orientation),f=d!==`vertical`,p=$(o,[`orientation`],e=>!!e&&e.orientation!==`vertical`),m=Y(t=>{if(l?.(t),t.defaultPrevented)return;let n=t.target;if(bM(t)||FF(e,n)){if(rM(n)){let e=aM(n),r=t.key===`ArrowLeft`||t.key===`ArrowUp`,i=t.key===`ArrowRight`||t.key===`ArrowDown`;if(r&&e.start!==0||i&&e.end!==iM(n).length)return}if(s||o&&!f){let n={ArrowRight:()=>u===`left`&&!f,ArrowLeft:()=>u===`right`&&!f,ArrowUp:()=>u===`bottom`&&f,ArrowDown:()=>u===`top`&&f}[t.key];if(n?.())return t.stopPropagation(),t.preventDefault(),e?.hide()}if(o){let e={ArrowRight:()=>{if(p)return o.next()},ArrowLeft:()=>{if(p)return o.previous()},ArrowDown:()=>{if(!p)return o.down()},ArrowUp:()=>{if(!p)return o.up()}}[t.key],n=e?.();n!==void 0&&(t.stopPropagation(),t.preventDefault(),o.move(n))}}});r=ON(r,t=>(0,O.jsx)($H,{value:e,children:t}),[e]);let h=nU({store:e,...r}),g=VI($(e,`mounted`),r.hidden,t),_=g?{...r.style,display:`none`}:r.style;r=ON(r,e=>(0,O.jsx)(eU.Provider,{value:g,children:e}),[g]),r={"aria-labelledby":h,hidden:g,...r,id:c,ref:vN(c?e.setContentElement:null,r.ref),style:_,onKeyDown:m};let v=!!e.combobox;return n??=!v,n&&(r={role:`menu`,"aria-orientation":d,...r}),r=SI({store:e,composite:n,...r}),r=gV({store:e,typeahead:!v,...r}),r});X(function(e){return Z(tU,rU(e))});var iU=`div`,aU=Q(function({store:e,modal:t=!1,portal:n=t,hideOnEscape:r=!0,autoFocusOnShow:i=!0,hideOnHoverOutside:a,alwaysVisible:o,getPersistentElements:s,unstable_treeSnapshotKey:c,...l}){let u=ZH();e||=u,Nj(e,!1);let d=(0,D.useRef)(null),f=e.parent,p=e.menubar,m=!!f,h=!!p&&!m,g=!m&&t;l={...l,ref:vN(d,l.ref)};let{"aria-labelledby":_,...v}=rU({store:e,alwaysVisible:o,...l});l=v;let[y,b]=(0,D.useState)(),x=$(e,[`autoFocusOnShow`,`initialFocus`,`renderedItems`,`compositeElement`],e=>{if(!e.autoFocusOnShow)return;let t=e=>!e.disabled&&!!e.element;switch(e.initialFocus){case`first`:return e.renderedItems.find(t)?.element||null;case`last`:for(let n=e.renderedItems.length-1;n>=0;--n){let r=e.renderedItems[n];if(r&&t(r))return r.element}return null;default:return e.compositeElement}});(0,D.useEffect)(()=>{let e=!1;return b(t=>{if(e)return;if(g&&t?.current?.isConnected)return t;if(x===void 0)return;if(x&&x===t?.current)return t;let n=(0,D.createRef)();return n.current=x,n}),()=>{e=!0}},[g,x]);let S=!!y||!!l.initialFocus||g,C=i!==!1&&S&&i,w=$(e,[`disclosureElement`,`anchorElement`],e=>e.disclosureElement||e.anchorElement),T=$(e,[`disclosureElement`,`contentElement`],e=>{let{disclosureElement:t,contentElement:n}=e;return!t?.isConnected||yz(t)||n?.contains(t)?null:t}),E=g?T:null,ee=(0,D.useMemo)(()=>[c,E],[c,E]),te=$(e.combobox||e,`contentElement`),ne=$(f?.combobox||f,`contentElement`),re=(0,D.useMemo)(()=>{if(!ne||!te)return;let e=te.getAttribute(`role`),t=ne.getAttribute(`role`);if(t!==`menu`&&t!==`menubar`||e!==`menu`)return ne},[te,ne]);re!==void 0&&(l={preserveTabOrderAnchor:re,...l});let ie=lB({hideOnEscape:r,onClose:l.onClose,onEscapeClose:()=>f?.hideAll()});return l=hB({store:e,alwaysVisible:o,initialFocus:y,autoFocusOnShow:C,finalFocus:w,...l,hideOnEscape:ie.hideOnEscape,onClose:ie.onClose,hideOnHoverOutside(t){let n=e?.getState().disclosureElement;return(typeof a==`function`?a(t):a??(m?!0:h?!n||!KM(n):!1))?t.defaultPrevented||!m||!n||(wM(n,`mouseout`,t),!KM(n))?!0:(requestAnimationFrame(()=>{KM(n)||e?.hide()}),!1):!1},getPersistentElements(){let e=s?.()||[];return!g||!T?e:[...e,T]},unstable_treeSnapshotKey:ee,modal:g,portal:n,backdrop:!m&&l.backdrop}),l={"aria-labelledby":_,...l},l}),oU=Iz(X(function(e){return Z(iU,aU(e))}),ZH),sU=`button`;function cU(e,t){return{ArrowDown:t===`bottom`||t===`top`?`first`:!1,ArrowUp:t===`bottom`||t===`top`?`last`:!1,ArrowRight:t===`right`&&`first`,ArrowLeft:t===`left`&&`first`}[e.key]}function lU(e,t){return!!e?.some(e=>!e.element||e.element===t?!1:e.element.getAttribute(`aria-expanded`)===`true`)}var uU=Q(function({store:e,focusable:t,accessibleWhenDisabled:n,showOnHover:r,unstable_showOnHoverWhenDisabled:i=!1,...a}){let o=ZH();e||=o,Nj(e,!1);let s=(0,D.useRef)(null),c=e.parent,l=e.menubar,u=!!c,d=!!l&&!u,f=Ij(a),p=e=>f||Lj(e),m=()=>{let t=s.current;t&&(e?.setDisclosureElement(t),e?.show())},h=a.onFocus,g=Y(t=>{if(h?.(t),p(t.currentTarget)||t.defaultPrevented||(e?.setAutoFocusOnShow(!1),e?.setActiveId(null),!l)||!d)return;let{items:n}=l.getState();lU(n,t.currentTarget)&&m()}),_=$(e,[`placement`],e=>zz(e.placement)),v=a.onKeyDown,y=Y(t=>{if(v?.(t),p(t.currentTarget)||t.defaultPrevented)return;let n=cU(t,_);if(n){t.preventDefault();let{open:r}=e.getState();if(r){let t=n===`last`?e.last():e.first();e.move(t);return}m(),e?.setAutoFocusOnShow(!0),e?.setInitialFocus(n)}}),b=a.onClick,x=Y(t=>{if(b?.(t),t.defaultPrevented||!e)return;let n=!t.detail,{open:r}=e.getState();(!r||n)&&((!u||n)&&e.setAutoFocusOnShow(!0),e.setInitialFocus(n?`first`:`container`)),u&&m()});a=ON(a,t=>(0,O.jsx)(QH,{value:e,children:t}),[e]),u&&(a={...a,render:(0,O.jsx)(RR.div,{render:a.render})});let S=SN(a.id),C=$(c?.combobox||c,`contentElement`);return a={role:u||d?uM(C,`menuitem`):void 0,"aria-haspopup":cM($(e,`contentElement`),e.combobox?`dialog`:`menu`),...a,id:S,ref:vN(s,a.ref),onFocus:g,onKeyDown:y,onClick:x},a=CB({store:e,focusable:t,accessibleWhenDisabled:n,...a,unstable_showOnHoverWhenDisabled:i,showOnHover:e=>{if(!(()=>{if(typeof r==`function`)return r(e);if(r!=null)return r;if(u)return!0;if(!l)return!1;let{items:t}=l.getState();return d&&lU(t)})())return!1;let t=d?l:c;return t&&t.setActiveId(e.currentTarget.id),!0}}),a=tV({store:e,toggleOnClick:!u,focusable:t,accessibleWhenDisabled:n,...a}),a=gV({store:e,typeahead:d,...a}),a}),dU=X(function(e){return Z(sU,gj(uU(e)))}),fU=`span`,pU=Q(function({store:e,...t}){let n=YH();return e||=n,t=aV({store:e,...t}),t}),mU=X(function(e){return Z(fU,pU(e))}),hU=`div`,gU=Q(function(e){return e=MV(e),e}),_U=X(function(e){return Z(hU,gU(e))}),vU=`div`;function yU(e,t,n){if(!e)return!1;if(KM(e))return!0;let r=(t?.find(e=>e.element!==n&&e.element?.getAttribute(`aria-expanded`)===`true`))?.element?.getAttribute(`aria-controls`);if(!r)return!1;let i=q(e).getElementById(r);return i?KM(i)?!0:!!i.querySelector(`[role=menuitem][aria-expanded=true]`):!1}var bU=Q(function({store:e,hideOnClick:t=!0,preventScrollOnKeyDown:n=!0,focusOnHover:r,blurOnHoverEnd:i,...a}){let o=XH(!0),s=GB();e=e||o||s,Nj(e,!1);let c=a.onClick,l=DN(t),u=`hideAll`in e?e.hideAll:void 0,d=!!u,f=Y(e=>{if(c?.(e),e.defaultPrevented||CM(e)||SM(e)||!u)return;let t=e.currentTarget.getAttribute(`aria-haspopup`);t&&t!==`false`||l(e)&&u()}),p=$(e,[`contentElement`],e=>`contentElement`in e?e.contentElement:null),m=(0,D.useContext)(eU);return a={role:uM(p,`menuitem`),...a,onClick:f},a=ZF({store:e,preventScrollOnKeyDown:n,...a,shouldRegisterItem:!m&&a.shouldRegisterItem}),a=LV({store:e,...a,focusOnHover(t){if(!e||!(typeof r==`function`?r(t):r??!0))return!1;let{compositeElement:n,items:i}=e.getState();return d?(t.currentTarget.hasAttribute(`aria-expanded`)&&t.currentTarget.focus({preventScroll:!0}),!0):yU(n,i,t.currentTarget)?(t.currentTarget.focus({preventScroll:!0}),!0):!1},blurOnHoverEnd(e){return typeof i==`function`?i(e):i??d}}),a}),xU=zN(X(function(e){return Z(vU,bU(e))}));function SU({combobox:e,parent:t,menubar:n,...r}={}){let i=!!n&&!t,a=YP(r.store,JP(t,[`values`]),qP(e,[`arrowElement`,`anchorElement`,`contentElement`,`popoverElement`,`disclosureElement`,`placement`,`currentPlacement`])),o=a.getState(),s=(t||n)?.getState().orientation===`vertical`?`right-start`:`bottom-start`,c=vF({...r,store:a,orientation:K(r.orientation,o.orientation,`vertical`)}),l=LB({...r,store:a,placement:K(r.placement,o.placement,s),timeout:K(r.timeout,o.timeout,i?0:150),hideTimeout:K(r.hideTimeout,o.hideTimeout,0)}),u=VP({...c.getState(),...l.getState(),initialFocus:K(o.initialFocus,`container`),values:K(r.values,o.values,r.defaultValues,{})},c,l,a);return HP(u,()=>e?.unstable_onHideRequest(l.unstable_requestHide)),HP(u,()=>GP(u,[`mounted`],e=>{e.mounted||u.setState(`activeId`,null)})),{...c,...l,...u,combobox:e,parent:t,menubar:n,hideAll:()=>{l.hide(),t?.hideAll()},setInitialFocus:e=>u.setState(`initialFocus`,e),setValues:e=>u.setState(`values`,e),setValue:(e,t)=>{e!==`__proto__`&&e!==`constructor`&&(Array.isArray(e)||u.setState(`values`,n=>{let r=n[e],i=xj(t,r);return i===r?n:{...n,[e]:i!==void 0&&i}}))}}}function CU(e,t,n){return TN(t,[n.combobox,n.parent,n.menubar,t]),UF(e,n,`values`,`setValues`),Object.assign(RB(sL(e,t,n),t,n),{combobox:n.combobox,parent:n.parent,menubar:n.menubar})}function wU(e={}){let t=YH(),n=WB(),r=iL();e={...e,parent:e.parent===void 0?t:e.parent,menubar:e.menubar===void 0?n:e.menubar,combobox:e.combobox===void 0?r:e.combobox};let[i,a]=WF(SU,e);return CU(i,a,e)}function TU(e={}){let t=wU(e);return(0,O.jsx)(QH,{value:t,children:e.children})}var EU=`hr`,DU=Q(function({store:e,...t}){let n=YH();return e||=n,t=BL({store:e,...t}),t}),OU=X(function(e){return Z(EU,DU(e))}),kU=e=>{let{children:t,onSubmit:n,submitButton:r,...i}=e;return B(i),(0,O.jsx)(qH,{children:(0,O.jsxs)(`form`,{className:`bn-form`,onSubmit:e=>{e.preventDefault(),n?.()},children:[t,r===`none`?null:r]})})},AU=(0,D.forwardRef)((e,t)=>{let{className:n,name:r,label:i,variant:a,icon:o,value:s,autoFocus:c,placeholder:l,disabled:u,onKeyDown:d,onChange:f,autoComplete:p,"aria-activedescendant":m,rightSection:h,...g}=e;B(g);let _=mj([sj(c),t]);return(0,O.jsxs)(O.Fragment,{children:[e.label&&(0,O.jsx)(KH,{name:r,children:i}),(0,O.jsxs)(`div`,{className:`bn-ak-input-wrapper`,children:[o,(0,O.jsx)(HH,{className:V(`bn-ak-input`,n||``,a===`large`?`bn-ak-input-large`:``),ref:_,name:r,value:s,placeholder:l,disabled:u,onKeyDown:d,onChange:f,autoComplete:p,"aria-activedescendant":m}),h]})]})}),jU=(0,D.createContext)({portalElement:null,preventFocusOnOpen:!1}),MU=e=>{let{children:t,onOpenChange:n,position:r,portalElement:i,preventFocusOnOpen:a,sub:o,...s}=e;return B(s),(0,O.jsx)(TU,{placement:r,setOpen:n,virtualFocus:!0,children:(0,O.jsx)(jU.Provider,{value:{portalElement:i,preventFocusOnOpen:a??!1},children:t})})},NU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,sub:i,...a}=e;B(a);let{portalElement:o,preventFocusOnOpen:s}=(0,D.useContext)(jU);return(0,O.jsx)(oU,{unmountOnHide:!0,className:V(`bn-ak-menu`,n||``),autoFocusOnShow:s?()=>!1:!0,portal:o!==null,portalElement:o,ref:t,children:r})}),PU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,icon:i,checked:a,subTrigger:o,onClick:s,...c}=e;B(c);let{preventFocusOnOpen:l}=(0,D.useContext)(jU);return o?(0,O.jsxs)(dU,{render:(0,O.jsx)(xU,{focusOnHover:!l,onMouseDown:hj}),className:V(`bn-ak-menu-item`,n||``),ref:t,onClick:s,children:[i,r,(0,O.jsx)(mU,{}),a!==void 0&&(0,O.jsx)(qV,{checked:a})]}):(0,O.jsxs)(xU,{className:V(`bn-ak-menu-item`,n||``),ref:t,onClick:s,focusOnHover:!l,onMouseDown:hj,children:[i,r,a!==void 0&&(0,O.jsx)(qV,{checked:a})]})}),FU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i),(0,O.jsx)(_U,{className:V(`bn-ak-group-label`,n||``),ref:t,children:r})}),IU=e=>{let{children:t,sub:n,...r}=e;return B(r),n?t:(0,O.jsx)(dU,{render:t})},LU=(0,D.forwardRef)((e,t)=>{let{className:n,...r}=e;return B(r),(0,O.jsx)(OU,{className:V(`bn-ak-separator`,n||``),ref:t})}),RU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,icon:i,onClick:a,label:o,onDragEnd:s,onDragStart:c,draggable:l,...u}=e;return B(u,!1),(0,O.jsxs)(JB,{onDragEnd:s,onDragStart:c,draggable:l,"aria-label":o,className:V(`bn-ak-button bn-ak-secondary`,n||``),ref:t,onClick:a,...u,children:[i,r]})}),zU=(0,D.forwardRef)((e,t)=>{let{className:n,tabs:r,defaultOpenTab:i,openTab:a,setOpenTab:o,loading:s,...c}=e;return B(c),(0,O.jsx)(`div`,{className:V(`bn-ak-wrapper`,n||``),ref:t,children:(0,O.jsxs)(CL,{defaultSelectedId:i,selectedId:a,setActiveId:e=>{e&&o(e)},children:[(0,O.jsx)(TI,{className:`bn-ak-tab-list`,children:r.map(e=>(0,O.jsx)(oI,{className:`bn-ak-tab`,id:e.name,children:e.name},e.name))}),(0,O.jsx)(`div`,{className:`bn-ak-panels`,children:r.map(e=>(0,O.jsx)(XI,{tabId:e.name,children:e.tabPanel},e.name))})]})})}),BU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,type:i,onClick:a,label:o,...s}=e;return B(s),(0,O.jsx)(JB,{type:i,className:V(`bn-ak-button`,n||``),onClick:a,"aria-label":o,ref:t,children:r})}),VU=(0,D.forwardRef)((e,t)=>{let{className:n,accept:r,value:i,placeholder:a,onChange:o,...s}=e;return B(s),(0,O.jsx)(qH,{children:(0,O.jsx)(HH,{className:n,ref:t,name:`panel-input`,type:`file`,accept:r,value:i?i.name:void 0,onChange:async e=>o?.(e.target.files[0]),placeholder:a})})}),HU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i),(0,O.jsx)(`div`,{className:n,ref:t,children:r})}),UU=(0,D.forwardRef)((e,t)=>{let{className:n,value:r,placeholder:i,onKeyDown:a,onChange:o,...s}=e;return B(s),(0,O.jsx)(qH,{children:(0,O.jsx)(HH,{className:V(`bn-ak-input`,n||``),name:`panel-input`,value:r,placeholder:i,onChange:o,onKeyDown:a,"data-test":`embed-input`,ref:t})})}),WU=(0,D.createContext)(null),GU=(0,D.forwardRef)((e,t)=>{let{children:n,...r}=e;return B(r),(0,O.jsx)(nV,{render:n,ref:t})}),KU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,variant:i,...a}=e;B(a);let o=(0,D.useContext)(WU);return(0,O.jsx)(eB,{className:V(`bn-ak-popover`,n||``,i===`panel-popover`?`bn-ak-panel-popover`:``),autoFocusOnShow:!1,unmountOnHide:!0,portal:o!==null,portalElement:o,ref:t,children:r})}),qU=e=>{let{children:t,open:n,onOpenChange:r,position:i,portalElement:a,...o}=e;return B(o),(0,O.jsx)(oV,{open:n,setOpen:r,placement:i,children:(0,O.jsx)(WU.Provider,{value:a,children:t})})},JU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i,!1),(0,O.jsx)(OV,{className:n,ref:t,...i,children:r})}),YU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,icon:i,onClick:a,label:o,onDragEnd:s,onDragStart:c,draggable:l,...u}=e;return B(u,!1),(0,O.jsxs)(JB,{onDragEnd:s,onDragStart:c,draggable:l,"aria-label":o,className:V(`bn-ak-button bn-ak-secondary`,n||``),ref:t,onClick:a,...u,children:[i,r]})}),XU=(0,D.forwardRef)((e,t)=>{let{className:n,markClassName:r,backgroundColor:i,children:a,...o}=e;return B(o),(0,O.jsx)(`span`,{className:V(n||``,r||``),style:r?void 0:{backgroundColor:i},ref:t,children:a})}),ZU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,id:i,columns:a,...o}=e;return B(o),(0,O.jsx)(`div`,{className:n,style:{gridTemplateColumns:`repeat(${a}, 1fr)`},ref:t,id:i,role:`grid`,children:r})}),QU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,columns:i,...a}=e;return B(a),(0,O.jsx)(`div`,{className:V(`bn-ak-menu-item`,n||``),style:{gridColumn:`1 / ${i+1}`},ref:t,children:(0,O.jsx)(`div`,{className:`bn-ak-suggestion-menu-item-label`,children:r})})}),$U=(0,D.forwardRef)((e,t)=>{let{className:n,isSelected:r,onClick:i,item:a,id:o,...s}=e;B(s);let c=(0,D.useRef)(null);return(0,D.useEffect)(()=>{!c.current||!r||fj(c.current,c.current.closest(`.bn-grid-suggestion-menu`))!==`none`&&c.current.scrollIntoView({block:`nearest`})},[r]),(0,O.jsx)(`div`,{className:n,ref:pj([t,c]),id:o,role:`option`,onClick:i,"aria-selected":r||void 0,children:a.icon})}),eW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,columns:i,...a}=e;return B(a),(0,O.jsx)(`div`,{className:n,style:{gridColumn:`1 / ${i+1}`},ref:t,children:r})}),tW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,id:i,...a}=e;return B(a),(0,O.jsx)(OV,{className:V(`bn-ak-menu`,n||``),id:i,role:`listbox`,ref:t,children:r})}),nW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i),(0,O.jsx)(`div`,{className:V(`bn-ak-menu-item`,n||``),ref:t,children:(0,O.jsx)(`div`,{className:`bn-ak-suggestion-menu-item-label`,children:r})})}),rW=(0,D.forwardRef)((e,t)=>{let{className:n,item:r,isSelected:i,onClick:a,id:o,...s}=e;B(s);let c=(0,D.useRef)(null);return(0,D.useEffect)(()=>{!c.current||!i||fj(c.current,c.current.closest(`.bn-suggestion-menu, #ai-suggestion-menu`))!==`none`&&c.current.scrollIntoView({block:`nearest`})},[i]),(0,O.jsxs)(`div`,{className:V(`bn-ak-menu-item`,n||``),ref:pj([t,c]),id:o,onMouseDown:e=>e.preventDefault(),onClick:a,role:`option`,"aria-selected":i||void 0,children:[r.icon&&(0,O.jsx)(`div`,{className:`bn-ak-suggestion-menu-item-section`,"data-position":`left`,children:r.icon}),(0,O.jsxs)(`div`,{className:`bn-ak-suggestion-menu-item-body`,children:[(0,O.jsx)(`div`,{className:`bn-ak-suggestion-menu-item-title`,children:r.title}),(0,O.jsx)(`div`,{className:`bn-ak-suggestion-menu-item-subtitle`,children:r.subtext})]}),r.badge&&(0,O.jsx)(`div`,{"data-position":`right`,className:`bn-ak-suggestion-menu-item-section`,children:(0,O.jsx)(`div`,{children:r.badge})})]})}),iW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i),(0,O.jsx)(`div`,{className:V(`bn-ak-group-label`,n||``),ref:t,children:r})}),aW=(0,D.forwardRef)((e,t)=>{let{className:n,...r}=e;return B(r),(0,O.jsx)(`div`,{className:n,ref:t,children:(0,O.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`1em`,viewBox:`0 -960 960 960`,width:`1em`,fill:`#e8eaed`,children:(0,O.jsx)(`path`,{d:`M480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 31.5-155.5t86-127Q252-817 325-848.5T480-880q17 0 28.5 11.5T520-840q0 17-11.5 28.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160q133 0 226.5-93.5T800-480q0-17 11.5-28.5T840-520q17 0 28.5 11.5T880-480q0 82-31.5 155t-86 127.5q-54.5 54.5-127 86T480-80Z`})})})}),oW=(0,D.forwardRef)((e,t)=>{let{children:n,className:r,onMouseDown:i,onClick:a,...o}=e;return B(o,!1),(0,O.jsx)(JB,{className:V(`bn-ak-button bn-ak-secondary`,r||``),ref:t,onMouseDown:i,onClick:a,...o,children:n})}),sW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,draggable:i,onDragStart:a,onDragEnd:o,style:s,label:c,...l}=e;return B(l,!1),(0,O.jsx)(JB,{className:V(`bn-ak-button bn-ak-secondary`,n||``),ref:t,"aria-label":c,draggable:i,onDragStart:a,onDragEnd:o,style:s,...l,children:r})}),cW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,onMouseEnter:i,onMouseLeave:a,variant:o,...s}=e;return B(s),(0,O.jsx)(NL,{className:V(`bn-ak-toolbar`,n||``),ref:t,onMouseEnter:i,onMouseLeave:a,children:r})}),lW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,mainTooltip:i,secondaryTooltip:a,icon:o,isSelected:s,isDisabled:c,onClick:l,label:u,variant:d,onMouseDown:f,...p}=e;return B(p,!1),(0,O.jsxs)(HB,{children:[(0,O.jsx)(NB,{render:(0,O.jsxs)(IL,{"aria-label":u,className:V(`bn-ak-button bn-ak-secondary`,n||``),...p,onMouseDown:e=>{hj(e),f?.(e)},onClick:l,"aria-pressed":s,"data-selected":s?`true`:void 0,disabled:c||!1,ref:t,children:[o,r]})}),(0,O.jsxs)(SB,{className:`bn-ak-tooltip`,portal:!1,children:[(0,O.jsx)(`span`,{children:i}),a&&(0,O.jsx)(`span`,{children:a})]})]})}),uW=(0,D.forwardRef)((e,t)=>{let{className:n,items:r,isDisabled:i,portalElement:a,preventFocusOnOpen:o,...s}=e;B(s);let c=e.items.filter(e=>e.isSelected)[0];return(0,O.jsxs)(sH,{value:c.text,setValue:e=>{r.find(t=>t.text===e).onClick?.()},children:[(0,O.jsxs)(wV,{className:`bn-ak-button bn-ak-secondary`,disabled:i,onMouseDown:hj,render:(0,O.jsx)(IL,{}),children:[c.icon,` `,c.text,` `,(0,O.jsx)(yV,{})]}),(0,O.jsx)(nH,{className:V(`bn-ak-popover`,n||``),ref:t,gutter:4,autoFocusOnShow:!o,portal:a!==null,portalElement:a,children:r.map(e=>(0,O.jsxs)(VV,{className:`bn-ak-select-item`,value:e.text,focusOnHover:!o,onMouseDown:hj,children:[e.icon,e.text,e.text===c.text&&(0,O.jsx)(XV,{})]},e.text))})]})}),dW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,selected:i,headerText:a,onFocus:o,onBlur:s,tabIndex:c,...l}=e;return B(l,!1),(0,O.jsxs)(OV,{className:V(n,`bn-ak-hovercard`,i&&`selected`),onFocus:o,onBlur:s,tabIndex:c,ref:t,children:[a&&(0,O.jsx)(`div`,{className:`bn-header-text`,children:a}),r]})}),fW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i,!1),(0,O.jsx)(OV,{className:V(n,`bn-ak-card-section`),ref:t,children:r})}),pW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i,!1),(0,O.jsx)(JB,{className:V(n,`bn-ak-button bn-ak-secondary bn-ak-expand-sections-prompt`),ref:t,children:r})}),mW=(0,D.forwardRef)((e,t)=>{let{authorInfo:n,timeString:r,edited:i,...a}=e,o=W();return B(a,!1),n===`loading`?(0,O.jsxs)(OV,{className:`bn-ak-author-info`,children:[(0,O.jsx)(`div`,{className:`bn-ak-avatar bn-ak-skeleton`}),(0,O.jsx)(`div`,{className:`bn-ak-username bn-ak-skeleton`})]}):(0,O.jsxs)(OV,{className:`bn-ak-author-info`,children:[(0,O.jsx)(`img`,{src:n.avatarUrl,alt:n.username,className:`bn-ak-avatar`}),(0,O.jsxs)(`div`,{className:`bn-ak-username`,children:[n.username,(0,O.jsxs)(`span`,{children:[r,` `,i&&`(${o.comments.edited})`]})]})]})}),hW=(0,D.forwardRef)((e,t)=>{let{className:n,showActions:r,authorInfo:i,timeString:a,actions:o,children:s,edited:c,emojiPickerOpen:l,...u}=e;B(u,!1);let[d,f]=(0,D.useState)(!1),{focused:p,ref:m}=lj();return(0,O.jsxs)(OV,{ref:t,className:n,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[o&&(r===!0||r===void 0||r===`hover`&&d||p||l)?(0,O.jsx)(OV,{ref:m,style:{position:`absolute`,right:0,top:0,zIndex:10},children:o}):null,(0,O.jsx)(mW,{...e}),s]})}),gW=(0,D.forwardRef)((e,t)=>{let{className:n,onFocus:r,onBlur:i,autoFocus:a,editor:o,editable:s,...c}=e;B(c,!1);let l=eE();return(0,O.jsx)(CW,{autoFocus:a,className:n,editor:e.editor,sideMenu:!1,slashMenu:!1,tableHandles:!1,filePanel:!1,formattingToolbar:!1,editable:s,theme:l?.colorSchemePreference,ref:t,onFocus:r,onBlur:i,children:(0,O.jsx)(Tk,{formattingToolbar:_W})})}),_W=()=>{let e=fk([]).filter(e=>e.key!==`nestBlockButton`&&e.key!==`unnestBlockButton`);return(0,O.jsx)(pk,{blockTypeSelectItems:[],children:e})},vW=(0,D.forwardRef)((e,t)=>{let{className:n,text:r,icon:i,isSelected:a,mainTooltip:o,secondaryTooltip:s,onClick:c,onMouseEnter:l,...u}=e;B(u,!1);let d=(0,O.jsxs)(JB,{className:V(n,`bn-ak-badge bn-ak-button`,a&&`bn-ak-primary`),"aria-selected":a===!0,onClick:e=>c?.(e),onMouseEnter:l,ref:t,children:[(0,O.jsx)(`span`,{children:i}),(0,O.jsx)(`span`,{children:r})]});return o?(0,O.jsxs)(HB,{children:[(0,O.jsx)(NB,{render:d}),(0,O.jsxs)(SB,{className:`bn-ak-tooltip`,portal:!1,children:[(0,O.jsx)(`span`,{children:o}),s&&(0,O.jsx)(`span`,{children:s})]})]}):d}),yW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i),(0,O.jsx)(OV,{className:V(n,`bn-ak-badge-group`),ref:t,children:r})}),bW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i,!1),(0,O.jsx)(`div`,{className:V(n),ref:t,children:r})}),xW=(0,D.forwardRef)((e,t)=>{let{className:n,selected:r,comparing:i,onClick:a,actions:o,children:s,...c}=e;return B(c,!1),(0,O.jsxs)(`div`,{className:V(n,r?`selected`:``,i?`comparing`:``),onClick:a,ref:t,children:[s,o&&(0,O.jsx)(`div`,{className:`bn-snapshot-menu`,onClick:e=>e.stopPropagation(),children:o})]})}),SW={FormattingToolbar:{Root:cW,Button:lW,Select:uW},FilePanel:{Root:zU,Button:BU,FileInput:VU,TabPanel:HU,TextInput:UU},GridSuggestionMenu:{Root:ZU,Item:$U,EmptyItem:QU,Loader:eW},LinkToolbar:{Root:cW,Button:lW,Select:uW},SideMenu:{Root:JU,Button:YU},SuggestionMenu:{Root:tW,Item:rW,EmptyItem:nW,Label:iW,Loader:aW},AttributionTooltip:{Root:XU},TableHandle:{Root:sW,ExtendButton:oW},Comments:{Comment:hW,Editor:gW,Card:dW,CardSection:fW,ExpandSectionsPrompt:pW},Versioning:{Sidebar:bW,Snapshot:xW},Generic:{Badge:{Root:vW,Group:yW},Toolbar:{Root:cW,Button:lW,Select:uW},Form:{Root:kU,TextInput:AU},Menu:{Root:MU,Trigger:IU,Dropdown:NU,Divider:LU,Label:FU,Item:PU,Button:RU},Popover:{Root:qU,Trigger:GU,Content:KU}}},CW=e=>{let{className:t,...n}=e;return(0,O.jsx)(wE.Provider,{value:SW,children:(0,O.jsx)(RA,{className:V(`bn-ariakit`,t||``),...n})})};function wW(e,t,n){let r=be(e,t).map(t=>({title:t.label||ve(t.id),subtext:t.id,...t.type?{badge:t.type}:{},onItemClick:()=>n(ye(t.id,e))})),i=t.trim();return i&&!/[[\]|\n]/.test(i)&&!e.some(e=>[e.label,ve(e.id),e.id].some(e=>e?.toLocaleLowerCase()===i.toLocaleLowerCase()))&&r.push({title:`Link to “${i}”`,subtext:`No note has this name yet`,onItemClick:()=>n(i)}),r}var TW=/\n?(?:%%\n)?```blocknote[\s\S]*$/;function EW(e){let t=de(e);return t?fe(e)?{status:`edited`,blocks:t.blocks,markdown:t.markdown}:{status:`page`,blocks:t.blocks}:{status:`unreadable`,markdown:e.replace(TW,``).trim()}}function DW({kind:e,onRebuild:t,onKeep:n}){return(0,O.jsxs)(`div`,{className:`note-page-notice`,role:`status`,children:[(0,O.jsx)(he,{as:`p`,size:`small`,children:e===`edited`?`This page’s Markdown was changed outside BrAIan. Rebuild the page from it, or keep the page as BrAIan saved it.`:`This page has no block source BrAIan can read. Below is what its Markdown rebuilds into.`}),(0,O.jsxs)(`div`,{className:`note-page-notice-actions`,children:[(0,O.jsx)(ge,{size:`small`,variant:`primary`,onClick:t,children:e===`edited`?`Rebuild from Markdown`:`Rebuild page`}),e===`edited`&&(0,O.jsx)(ge,{size:`small`,onClick:n,children:`Keep the page`})]})]})}var OW=(0,D.createContext)({resolve:()=>void 0,open:()=>void 0});function kW({target:e,label:t}){let n=(0,D.useContext)(OW),r=n.resolve(e);return(0,O.jsx)(`a`,{className:r?`note-page-link`:`note-page-link note-page-link-unresolved`,href:`#${encodeURIComponent(e)}`,"data-target":e,title:r?void 0:`No note is called ${e}`,onClick:e=>{e.preventDefault(),r&&n.open(r.id)},children:t||r?.title||e})}var AW=dj({type:pe,propSchema:{target:{default:``},label:{default:``}},content:`none`},{render:({inlineContent:e})=>(0,O.jsx)(kW,{target:e.props.target,label:e.props.label})}),jW=Py.create({inlineContentSpecs:{...My,wikiLink:AW}}),MW=/(\[\[[^[\]\n]+\]\])/,NW=/^!\[\[([^[\]\n|]+)(?:\|[^[\]\n]*)?\]\](?:\n([\s\S]*))?$/,PW=[[/\.(png|jpe?g|gif|webp|avif|svg|bmp)$/i,`image`],[/\.(mp4|webm|mov|m4v|ogv)$/i,`video`],[/\.(mp3|wav|ogg|oga|m4a|flac|aac|opus)$/i,`audio`]];function FW(e){return e.map(LW)}function IW(e){return PW.find(([t])=>t.test(e))?.[1]??`file`}function LW(e){let t=e.children?.length?{children:FW(e.children)}:{};if(!Array.isArray(e.content))return{...e,...t};let n=e.type===`paragraph`?NW.exec(VW(e.content)):null;if(n){let r=n[2]?.trim();return{...e.id?{id:e.id}:{},type:IW(n[1].trim()),props:{url:n[1].trim(),...r?{caption:r}:{}},...t}}return{...e,content:RW(e.content),...t}}function RW(e){return e.flatMap(e=>{if(e.type!==`text`)return[e];let t=e;return t.text.split(MW).filter(Boolean).map(e=>{if(!MW.test(e)||t.styles?.code===!0)return{...t,text:e};let n=e.slice(2,-2),r=n.indexOf(`|`);return{type:pe,props:{target:(r<0?n:n.slice(0,r)).trim(),label:r<0?``:n.slice(r+1).trim()}}})}).reduce((e,t)=>{let n=e.at(-1),r=t.type===`wikiLink`&&n?.type===`text`&&n.text.endsWith(`!`)?{...n,text:zW(t.props)}:t;return n?.type===`text`&&r.type===`text`&&BW(n,r)?e[e.length-1]={...n,text:n.text+r.text}:e.push(r),e},[])}function zW({target:e,label:t}){return`[[${e}${t?`|${t}`:``}]]`}function BW(e,t){return JSON.stringify(e.styles??{})===JSON.stringify(t.styles??{})}function VW(e){return e.map(e=>e.type===`text`?e.text:``).join(``)}var HW=300,UW=2e3;function WW({blocks:e,emitted:t,viewOnly:n,onBodyChange:r}){let i=(0,D.useRef)(!1),a=(0,D.useRef)(!1),o=(0,D.useRef)(void 0),s=(0,D.useRef)(void 0),c=(0,D.useRef)({blocks:e,viewOnly:n,onBodyChange:r});c.current={blocks:e,viewOnly:n,onBodyChange:r};let l=(0,D.useCallback)(()=>{o.current!==void 0&&(window.clearTimeout(o.current),o.current=void 0),s.current=void 0},[]),u=(0,D.useCallback)(()=>{l();let e=c.current.blocks();if(!a.current||!e||c.current.viewOnly)return;a.current=!1;let n=le(e,xe);n!==t.current&&(t.current=n,c.current.onBodyChange(n))},[l,t]),d=(0,D.useCallback)(()=>{if(c.current.viewOnly||!i.current)return;a.current=!0;let e=Date.now();s.current??=e,o.current!==void 0&&window.clearTimeout(o.current),o.current=window.setTimeout(u,Math.max(0,Math.min(HW,s.current+UW-e)))},[u]),f=(0,D.useCallback)(()=>{i.current=!0},[]),p=(0,D.useCallback)(()=>{c.current.viewOnly||(a.current=!0,u())},[u]),m=(0,D.useCallback)(()=>{l(),i.current=!1,a.current=!1},[l]);return(0,D.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()===`s`&&u()};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[u]),(0,D.useLayoutEffect)(()=>()=>u(),[u]),(0,D.useMemo)(()=>({onChange:d,touch:f,commit:p,reset:m,flush:u}),[p,u,d,m,f])}var GW=e=>e.status===`page`?void 0:e.status,KW=[{type:`paragraph`}];function qW(e){return e.length?e:KW}function JW(e,t){return t.status===`unreadable`?YW(e,t.markdown):t.blocks}function YW(e,t){return FW(e.tryParseMarkdownToBlocks(t))}function XW(e){let t=me(),[n]=(0,D.useState)(()=>EW(e.body)),[r,i]=(0,D.useState)(()=>GW(n)),a=(0,D.useRef)(e.body),o=(0,D.useRef)(!1),s=(0,D.useRef)(e);s.current=e;let c=EE({schema:jW,...n.status===`unreadable`?{}:{initialContent:qW(n.blocks)},...e.upload?{uploadFile:e=>s.current.upload(e)}:{},resolveFileUrl:e=>_e(s.current.files)(e)},[]),l=WW({blocks:()=>c.document,emitted:a,viewOnly:e.viewOnly,onBodyChange:e=>s.current.onBodyChange?.(e)}),u=!e.viewOnly&&!r,d=(0,D.useCallback)(e=>{o.current=!0;try{c.replaceBlocks(c.document,qW(e))}finally{o.current=!1}l.reset()},[c,l]);(0,D.useLayoutEffect)(()=>{n.status===`unreadable`&&d(JW(c,n))},[c,n,d]),(0,D.useEffect)(()=>{if(e.body===a.current)return;a.current=e.body;let t=EW(e.body);d(JW(c,t)),i(GW(t))},[c,e.body,d]);let f=(0,D.useRef)(!!e.focusOnMount&&u);(0,D.useEffect)(()=>{f.current&&c.focus()},[c]);let p=(0,D.useCallback)(()=>{let e=EW(a.current);e.status===`edited`&&d(YW(c,e.markdown)),i(void 0),l.commit()},[c,l,d]),m=(0,D.useCallback)(()=>{i(void 0),l.commit()},[l]),h=(0,D.useMemo)(()=>{let t=new Map(e.notes.map(e=>[e.id,e.label||e.id]));return{resolve:e=>{let n=s.current.resolveNoteReference(e);return n?{id:n,title:t.get(n)??e}:void 0},open:e=>s.current.onOpenNote(e)}},[e.notes]),g=(0,D.useCallback)(async e=>wW(s.current.notes,e,e=>{c.insertInlineContent([{type:`wikiLink`,props:{target:e,label:``}},` `])}),[c]);return(0,O.jsxs)(`div`,{className:e.inline?`note-page note-page-inline`:`note-page`,...u?{"data-keyboard-owns-keys":`true`}:{},onPointerDownCapture:l.touch,onKeyDownCapture:l.touch,onPasteCapture:l.touch,onDropCapture:l.touch,children:[r&&!e.viewOnly&&(0,O.jsx)(DW,{kind:r,onRebuild:p,onKeep:m}),(0,O.jsx)(OW.Provider,{value:h,children:(0,O.jsx)(CW,{editor:c,editable:u,theme:t,onChange:()=>{o.current||l.onChange()},children:u&&(0,O.jsx)(cA,{triggerCharacter:`[[`,getItems:g})})})]})}export{XW as NotePageEditor};
|
|
174
|
+
`,r.pos,r.pos)):!1}}})]}}));for(let t of this.options._tiptapOptions?.extensions??[])e.push(t);return e}getProsemirrorPluginsFromExtension(e){let t=[...e.prosemirrorPlugins??[]],n=[];if(!e.prosemirrorPlugins?.length&&!Object.keys(e.keyboardShortcuts||{}).length&&!e.inputRules?.length)return{plugins:t,inputRules:n};if(this.extensionPlugins.set(e,t),e.inputRules?.length&&n.push(...e.inputRules.map(e=>new Zx(e.find,(t,n,r,i)=>{let a=e.replace({match:n,range:{from:r,to:i},editor:this.editor});if(a){let e=t.tr,n=Zh(e);return!n.isBlockContainer||this.editor.schema.blockSchema[n.blockNoteType]?.content!==`inline`?null:(e.deleteRange(r,i),V_(e,n.bnBlock.beforePos,a),cw(e,Kh(n.bnBlock.node,e.doc),`start`),e)}return null},{undoable:!0}))),Object.keys(e.keyboardShortcuts||{}).length){let n,r=el(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([e,t])=>[e,()=>{if(!n)throw Error(`Keyboard shortcut called outside handleKeyDown`);return t({editor:this.editor,event:n})}])));t.push(new F({props:{handleKeyDown:(e,t)=>{let i=n;n=t;try{return r(e,t)}finally{n=i}}}}))}return{plugins:t,inputRules:n}}getExtensions(){return new Map(this.extensions.map(e=>[e.key,e]))}getExtension(e){if(typeof e==`string`)return this.extensions.find(t=>t.key===e)||void 0;if(typeof e==`function`)return this.extensionFactories.get(e)||void 0;throw Error(`Invalid extension type: ${typeof e}`)}hasExtension(e){return typeof e==`string`?this.extensions.some(t=>t.key===e):typeof e==`object`&&`key`in e?this.extensions.some(t=>t.key===e.key):typeof e==`function`&&this.extensionFactories.has(e)}};function FT(e,t){let{$from:n,$to:r}=t;if(n.pos>n.start()&&n.pos<e.content.size){let t=e.textBetween(n.pos,n.pos+1);if(/^[\w\p{P}]$/u.test(t)){let t=e.textBetween(n.start(),n.pos).match(/[\w\p{P}]+$/u);t&&(n=e.resolve(n.pos-t[0].length))}}if(r.pos<r.end()&&r.pos>0){let t=e.textBetween(r.pos-1,r.pos);if(/^[\w\p{P}]$/u.test(t)){let t=e.textBetween(r.pos,r.end()).match(/^[\w\p{P}]+/u);t&&(r=e.resolve(r.pos+t[0].length))}}return{$from:n,$to:r,from:n.pos,to:r.pos}}function IT(e){if(e.selection.empty||`node`in e.selection)return;let t=e.doc.resolve(qh(e.doc,e.selection.from).posBeforeNode),n=e.doc.resolve(qh(e.doc,e.selection.to).posBeforeNode),r=(n,r)=>{let i=t.posAtIndex(n,r),a=e.doc.resolve(i).nodeAfter;if(!a)throw Error(`Error getting selection - node not found at position ${i}`);return Ng(a,e.doc)},i=[],a=t.sharedDepth(n.pos),o=t.index(a),s=n.index(a);if(t.depth>a){i.push(Ng(t.nodeAfter,e.doc));for(let e=t.depth;e>a;e--)if(t.node(e).type.isInGroup(`childContainer`)){let n=t.index(e)+1,a=t.node(e).childCount;for(let t=n;t<a;t++)i.push(r(t,e))}}else i.push(r(o,a));for(let e=o+1;e<=s;e++)i.push(r(e,a));if(i.length===0)throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);return{blocks:i}}function LT(e,t,n){let r=typeof t==`string`?t:t.id,i=typeof n==`string`?n:n.id,a=wg(Sg(e));if(r===i)throw Error(`Attempting to set selection with the same anchor and head blocks (id ${r})`);let o=R_(r,e.doc);if(!o)throw Error(`Block with ID ${r} not found`);let s=R_(i,e.doc);if(!s)throw Error(`Block with ID ${i} not found`);let c=Yh(o),l=Yh(s),u=a.blockSchema[c.blockNoteType],d=a.blockSchema[l.blockNoteType];if(!c.isBlockContainer||u.content===`none`)throw Error(`Attempting to set selection anchor in block without content (id ${r})`);if(!l.isBlockContainer||d.content===`none`)throw Error(`Attempting to set selection anchor in block without content (id ${i})`);let f,p;if(u.content===`table`){let e=Bp.get(c.blockContent.node);f=c.blockContent.beforePos+e.positionAt(0,0,c.blockContent.node)+1+2}else f=c.blockContent.beforePos+1;if(d.content===`table`){let t=Bp.get(l.blockContent.node),n=l.blockContent.beforePos+t.positionAt(t.height-1,t.width-1,l.blockContent.node)+1;p=n+e.doc.resolve(n).nodeAfter.nodeSize-2}else p=l.blockContent.afterPos-1;e.setSelection(N.create(e.doc,f,p))}function RT(e,t=!1){let n=t?FT(e.doc,e.selection):e.selection,r=n.$from,i=n.$to;for(;i.parentOffset>=i.parent.nodeSize-2&&i.depth>0;)i=e.doc.resolve(i.pos+1);for(;i.parentOffset===0&&i.depth>0;)i=e.doc.resolve(i.pos-1);for(;r.parentOffset===0&&r.depth>0;)r=e.doc.resolve(r.pos-1);for(;r.parentOffset>=r.parent.nodeSize-2&&r.depth>0;)r=e.doc.resolve(r.pos+1);let a=Fg(e.doc.slice(r.pos,i.pos,!0));return{_meta:{startPos:r.pos,endPos:i.pos},...a}}var zT=class{editor;constructor(e){this.editor=e}getSelection(){return this.editor.transact(e=>IT(e))}getSelectionCutBlocks(e=!1){return this.editor.transact(t=>RT(t,e))}setSelection(e,t){return this.editor.transact(n=>LT(n,e,t))}getTextCursorPosition(){return this.editor.transact(e=>sw(e))}setTextCursorPosition(e,t=`start`){return this.editor.transact(n=>cw(n,e,t))}getSelectionBoundingBox(){if(!this.editor.prosemirrorView)return;let{selection:e}=this.editor.prosemirrorState,{ranges:t}=e,n=Math.min(...t.map(e=>e.$from.pos)),r=Math.max(...t.map(e=>e.$to.pos));if(Nd(e)){let e=this.editor.prosemirrorView.nodeDOM(n);if(e)return e.getBoundingClientRect()}return Ld(this.editor.prosemirrorView,n,r).toJSON()}},BT=class{editor;constructor(e){this.editor=e}activeTransaction=null;can(e){try{return this.isInCan=!0,e()}finally{this.isInCan=!1}}isInCan=!1;exec(e){if(this.activeTransaction)throw Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");if(this.isInCan)return this.canExec(e);let t=this.prosemirrorState,n=this.prosemirrorView;return e(t,e=>this.prosemirrorView.dispatch(e),n)}canExec(e){if(this.activeTransaction)throw Error("`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call");let t=this.prosemirrorState,n=this.prosemirrorView;return e(t,void 0,n)}transact(e){if(this.activeTransaction)return e(this.activeTransaction);try{this.activeTransaction=this.editor._tiptapEditor.state.tr;let t=e(this.activeTransaction),n=this.activeTransaction;return this.activeTransaction=null,n&&(n.docChanged||n.selectionSet||n.scrolledIntoView||n.storedMarksSet||!n.isGeneric)&&this.prosemirrorView.dispatch(n),t}finally{this.activeTransaction=null}}get prosemirrorState(){if(this.activeTransaction)throw Error("`prosemirrorState` should not be called within a `transact` call, move the `prosemirrorState` call outside of the `transact` call or use `editor.transact` to read the current editor state");return this.editor._tiptapEditor.state}get prosemirrorView(){return this.editor._tiptapEditor.view}isFocused(){return this.prosemirrorView?.hasFocus()||!1}focus(){this.prosemirrorView?.focus()}get isEditable(){if(!this.editor._tiptapEditor){if(!this.editor.headless)throw Error(`no editor, but also not headless?`);return!1}return this.editor._tiptapEditor.isEditable===void 0||this.editor._tiptapEditor.isEditable}set isEditable(e){if(this.editor._tiptapEditor)this.editor._tiptapEditor.options.editable!==e&&this.editor._tiptapEditor.setEditable(e);else if(!this.editor.headless)throw Error(`no editor, but also not headless?`)}undo(){let e=this.editor.getExtension(`yUndo`);if(e)return this.exec(e.undoCommand);let t=this.editor.getExtension(`history`);if(t)return this.exec(t.undoCommand);throw Error(`No undo plugin found`)}redo(){let e=this.editor.getExtension(`yUndo`);if(e)return this.exec(e.redoCommand);let t=this.editor.getExtension(`history`);if(t)return this.exec(t.redoCommand);throw Error(`No redo plugin found`)}};function VT(e,t,n,r={updateSelection:!0}){let{from:i,to:a}=typeof t==`number`?{from:t,to:t}:{from:t.from,to:t.to},o=!0,s=!0,c=``;if(n.forEach(e=>{e.check(),o&&e.isText&&e.marks.length===0?c+=e.text:o=!1,s=s?e.isBlock:!1}),i===a&&s){let{parent:t}=e.doc.resolve(i);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(--i,a+=1)}return o?e.insertText(c,i,a):e.replaceWith(i,a,n),r.updateSelection&&fu(e,e.steps.length-1,-1),!0}var HT=class{editor;constructor(e){this.editor=e}insertInlineContent(e,{updateSelection:t=!1}={}){let n=P_(e,this.editor.pmSchema);this.editor.transact(e=>{VT(e,{from:e.selection.from,to:e.selection.to},n,{updateSelection:t})})}getActiveStyles(){return this.editor.transact(e=>{let t={},n=e.selection.empty&&e.storedMarks||e.selection.$to.marks();for(let e of n){let n=this.editor.schema.styleSchema[e.type.name];n?n.propSchema===`boolean`?t[n.type]=!0:t[n.type]=e.attrs.stringValue:e.type.name!==`link`&&!e.type.spec.blocknoteIgnore&&console.warn(`mark not found in styleschema`,e.type.name)}return t})}addStyles(e){for(let[t,n]of Object.entries(e)){let e=this.editor.schema.styleSchema[t];if(!e)throw Error(`style ${t} not found in styleSchema`);if(e.propSchema===`boolean`)this.editor._tiptapEditor.commands.setMark(t);else if(e.propSchema===`string`)this.editor._tiptapEditor.commands.setMark(t,{stringValue:n});else throw new dg(e.propSchema)}}removeStyles(e){for(let t of Object.keys(e))this.editor._tiptapEditor.commands.unsetMark(t)}toggleStyles(e){for(let[t,n]of Object.entries(e)){let e=this.editor.schema.styleSchema[t];if(!e)throw Error(`style ${t} not found in styleSchema`);if(e.propSchema===`boolean`)this.editor._tiptapEditor.commands.toggleMark(t);else if(e.propSchema===`string`)this.editor._tiptapEditor.commands.toggleMark(t,{stringValue:n});else throw new dg(e.propSchema)}}getSelectedText(){return this.editor.transact(e=>e.doc.textBetween(e.selection.from,e.selection.to))}getLinkMarkAtPos(e){return this.editor.transact(t=>{let n=this.editor.pmSchema.marks.link,r=Jl(t.doc.resolve(e),n);if(!r)return;let i=t.doc.nodeAt(r.from)?.marks.find(e=>e.type===n);if(i)return{href:i.attrs.href,from:r.from,to:r.to,text:t.doc.textBetween(r.from,r.to)}})}getSelectedLinkUrl(){return this.editor.transact(e=>(e.doc.nodeAt(e.selection.from)?.marks.find(e=>e.type.name===`link`))?.attrs.href)}createLink(e,t){e!==``&&this.editor.transact(n=>{let{from:r,to:i}=n.selection,a=this.editor.pmSchema.mark(`link`,{href:e});t?n.insertText(t,r,i).addMark(r,r+t.length,a):n.addMark(r,i,a)})}editLink(e,t,n=this.editor.transact(e=>e.selection.anchor)){this.editor.transact(r=>{let{from:i,to:a}=this.getLinkMarkAtPos(n)||{from:r.selection.from,to:r.selection.to},o=this.editor.pmSchema.mark(`link`,{href:e});t!==r.doc.textBetween(i,a)&&r.insertText(t,i,a),r.addMark(i,i+t.length,o)}),this.editor.prosemirrorView.focus()}deleteLink(e=this.editor.transact(e=>e.selection.anchor)){this.editor.transact(t=>{let{from:n,to:r}=this.getLinkMarkAtPos(e)||{from:t.selection.from,to:t.selection.to};t.removeMark(n,r,this.editor.pmSchema.marks.link).setMeta(`preventAutolink`,!0)}),this.editor.prosemirrorView.focus()}};function UT(e){return Ju(e.state.selection.$from,e=>e.type.name===`tableCell`||e.type.name===`tableHeader`)!==void 0}function WT(e,t){let n=t.nodes.hardBreak,r=k.empty;return e.forEach(e=>{e.isTextblock&&e.childCount>0?(r=r.append(e.content),r=r.addToEnd(n.create())):e.isText?r=r.addToEnd(e):e.isBlock&&e.childCount>0&&(r=r.append(WT(e.content,t)),r=r.addToEnd(n.create()))}),r.lastChild?.type===n&&(r=r.cut(0,r.size-1)),r}function GT(e,t){let n=[];return e.forEach((e,r,i)=>{i!==t&&n.push(e)}),k.from(n)}function KT(e,t){let n=[];for(let r=0;r<e.childCount;r++)if(e.child(r).type.name===`tableRow`){if(n.length>0&&n[n.length-1].type.name===`table`){let t=n[n.length-1],i=t.copy(t.content.addToEnd(e.child(r)));n[n.length-1]=i}else{let i=t.nodes.table.createChecked(void 0,e.child(r));n.push(i)}}else n.push(e.child(r));return e=k.from(n),e}function qT(e,t){let n=k.from(e.content);n=KT(n,t.state.schema);let r=JT(n,t,e);if(r)return r;if(UT(t)){let e=!1;if(n.descendants(t=>{t.type.isInGroup(`tableContent`)&&(e=!0)}),!e&&!t.state.schema.nodes.tableParagraph.validContent(n))return new j(WT(n,t.state.schema),0,0)}if(!YT(n,t))return new j(n,e.openStart,e.openEnd);for(let e=0;e<n.childCount;e++)if(n.child(e).type.spec.group===`blockContent`){let r=[n.child(e)];if(e+1<n.childCount&&n.child(e+1).type.name===`blockGroup`){let t=n.child(e+1).child(0).child(0);(t.type.name===`bulletListItem`||t.type.name===`numberedListItem`||t.type.name===`checkListItem`)&&(r.push(n.child(e+1)),n=GT(n,e+1))}let i=t.state.schema.nodes.blockContainer.createChecked(void 0,r);n=n.replaceChild(e,i)}return new j(n,e.openStart,e.openEnd)}function JT(e,t,n){if(UT(t)||t.dragging)return null;let r=Zh(t.state),i=r.isBlockContainer?r.blockContent.node:null;if(!i||i.type.name===`paragraph`||i.type.spec.content!==`inline*`||i.childCount>0)return null;let a=e.firstChild,o=a?.firstChild,s=o?.firstChild;if(a?.type.name!==`blockGroup`||o?.type.name!==`blockContainer`||s?.type.name!==`paragraph`)return null;let c=i.type.create(i.attrs,s.content),l=o.copy(o.content.replaceChild(0,c)),u=a.copy(a.content.replaceChild(0,l));return new j(e.replaceChild(0,u),n.openStart,n.openEnd)}function YT(e,t){let n=e.childCount===1,r=e.firstChild?.type.spec.content===`inline*`,i=e.firstChild?.type.spec.content===`tableRow+`;if(n){if(r)return!1;if(i){let e=Zh(t.state);if(e.isBlockContainer)return e.blockContent.node.type.spec.content!==`tableRow+`}}return!0}var XT={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1},ZT=class e extends FS{options;pmSchema;_tiptapEditor;elementRenderer=null;blockCache=new WeakMap;dictionary;schema;blockImplementations;inlineContentImplementations;styleImplementations;uploadFile;onUploadStartCallbacks=[];onUploadEndCallbacks=[];resolveFileUrl;settings;static create(t){return new e(t??{})}constructor(e){super(),this.options=e,this.dictionary=e.dictionary||Xx,this.settings={tables:{splitCells:e?.tables?.splitCells??!1,cellBackgroundColor:e?.tables?.cellBackgroundColor??!1,cellTextColor:e?.tables?.cellTextColor??!1,headers:e?.tables?.headers??!1}};let t={defaultStyles:!0,schema:e.schema||Py.create(),...e,placeholders:{...this.dictionary.placeholders,...e.placeholders}};if(this.schema=t.schema,this.blockImplementations=t.schema.blockSpecs,this.inlineContentImplementations=t.schema.inlineContentSpecs,this.styleImplementations=t.schema.styleSpecs,t.uploadFile){let e=t.uploadFile;this.uploadFile=async(t,n)=>{this.onUploadStartCallbacks.forEach(e=>e.apply(this,[n]));try{return await e(t,n)}finally{this.onUploadEndCallbacks.forEach(e=>e.apply(this,[n]))}}}this.resolveFileUrl=t.resolveFileUrl,this._eventManager=new iC(this),this._extensionManager=new PT(this,t);let n=this._extensionManager.getTiptapExtensions(),r={...XT,...t._tiptapOptions,element:null,autofocus:t.autofocus??!1,extensions:n,editorProps:{scrollMargin:{top:72,bottom:72,left:0,right:0},...t._tiptapOptions?.editorProps,attributes:{tabIndex:`0`,...t._tiptapOptions?.editorProps?.attributes,...t.domAttributes?.editor,class:V(`bn-editor`,t.defaultStyles?`bn-default-styles`:``,t.domAttributes?.editor?.class||``)},transformPasted:qT}};try{let e=t.initialContent||[{type:`paragraph`,id:ng.options.generateID()}];if(!Array.isArray(e)||e.length===0)throw Error(`initialContent must be a non-empty array of blocks, received: `+JSON.stringify(e));let n=hd(r.extensions);n.cached.blockNoteEditor=this;let i=Uu({type:`doc`,content:[{type:`blockGroup`,content:e.map(e=>L_(e,n,this.schema.styleSchema).toJSON())}]},n,r.parseOptions);this._tiptapEditor=new wp({...r,content:i.toJSON()}),this.pmSchema=this._tiptapEditor.schema}catch(e){throw Error("Error creating document from blocks passed as `initialContent`",{cause:e})}this.pmSchema.cached.blockNoteEditor=this,this._tiptapEditor.on(`mount`,()=>{this.headless=!1}),this._tiptapEditor.on(`unmount`,()=>{this.headless=!0}),this._blockManager=new rC(this),this._exportManager=new ow(this),this._selectionManager=new zT(this),this._stateManager=new BT(this),this._styleManager=new HT(this),this.emit(`create`)}_blockManager;_eventManager;_exportManager;_extensionManager;_selectionManager;_stateManager;_styleManager;get extensions(){return this._extensionManager.getExtensions()}exec(e){return this._stateManager.exec(e)}canExec(e){return this._stateManager.canExec(e)}transact(e){return this._stateManager.transact(e)}unregisterExtension=(...e)=>this._extensionManager.unregisterExtension(...e);registerExtension=(...e)=>this._extensionManager.registerExtension(...e);replaceExtension=(...e)=>this._extensionManager.replaceExtension(...e);getExtension=(e=>this._extensionManager.getExtension(e));mount=e=>{this._tiptapEditor.mount({mount:e})};unmount=()=>{this._tiptapEditor.unmount()};get prosemirrorState(){return this._stateManager.prosemirrorState}get prosemirrorView(){return this._stateManager.prosemirrorView}get domElement(){if(!this.headless)return this.prosemirrorView?.dom}_portalElements=new Map;registerPortalElement=e=>{this._portalElements.set(e,(this._portalElements.get(e)??0)+1)};unregisterPortalElement=e=>{let t=this._portalElements.get(e);t!==void 0&&(t<=1?this._portalElements.delete(e):this._portalElements.set(e,t-1))};isWithinEditor=e=>{if(this.domElement?.parentElement?.contains(e))return!0;for(let t of this._portalElements.keys())if(t.contains(e))return!0;return!1};isFocused(e){if(this.headless)return!1;let t=this.prosemirrorView?.hasFocus()||!1;if(!e?.includeEditorUI)return t;let n=typeof document<`u`?document.activeElement:null;return t||!!n&&this.isWithinEditor(n)}headless=!0;focus(){this.headless||this.prosemirrorView.focus()}blur(){this.headless||this.domElement?.blur()}onUploadStart(e){return this.onUploadStartCallbacks.push(e),()=>{let t=this.onUploadStartCallbacks.indexOf(e);t>-1&&this.onUploadStartCallbacks.splice(t,1)}}onUploadEnd(e){return this.onUploadEndCallbacks.push(e),()=>{let t=this.onUploadEndCallbacks.indexOf(e);t>-1&&this.onUploadEndCallbacks.splice(t,1)}}get topLevelBlocks(){return this.document}get document(){return this._blockManager.document}getBlock(e){return this._blockManager.getBlock(e)}getPrevBlock(e){return this._blockManager.getPrevBlock(e)}getNextBlock(e){return this._blockManager.getNextBlock(e)}getParentBlock(e){return this._blockManager.getParentBlock(e)}forEachBlock(e,t=!1){this._blockManager.forEachBlock(e,t)}onEditorContentChange(e){this._tiptapEditor.on(`update`,e)}onEditorSelectionChange(e){this._tiptapEditor.on(`selectionUpdate`,e)}onBeforeChange(e){return this._extensionManager.getExtension(ab).subscribe(e)}getTextCursorPosition(){return this._selectionManager.getTextCursorPosition()}setTextCursorPosition(e,t=`start`){return this._selectionManager.setTextCursorPosition(e,t)}getSelection(){return this._selectionManager.getSelection()}getSelectionCutBlocks(e=!1){return this._selectionManager.getSelectionCutBlocks(e)}setSelection(e,t){return this._selectionManager.setSelection(e,t)}get isEditable(){return this._stateManager.isEditable}set isEditable(e){this._stateManager.isEditable=e}insertBlocks(e,t,n=`before`){return this._blockManager.insertBlocks(e,t,n)}updateBlock(e,t){return this._blockManager.updateBlock(e,t)}removeBlocks(e){return this._blockManager.removeBlocks(e)}replaceBlocks(e,t){return this._blockManager.replaceBlocks(e,t)}undo(){return this._stateManager.undo()}redo(){return this._stateManager.redo()}insertInlineContent(e,{updateSelection:t=!1}={}){this._styleManager.insertInlineContent(e,{updateSelection:t})}getActiveStyles(){return this._styleManager.getActiveStyles()}addStyles(e){this._styleManager.addStyles(e)}removeStyles(e){this._styleManager.removeStyles(e)}toggleStyles(e){this._styleManager.toggleStyles(e)}getSelectedText(){return this._styleManager.getSelectedText()}getSelectedLinkUrl(){return this._styleManager.getSelectedLinkUrl()}createLink(e,t){this._styleManager.createLink(e,t)}getLinkMarkAtPos(e){return this._styleManager.getLinkMarkAtPos(e)}editLink(e,t,n){this._styleManager.editLink(e,t,n)}deleteLink(e){this._styleManager.deleteLink(e)}canNestBlock(){return this._blockManager.canNestBlock()}nestBlock(){this._blockManager.nestBlock()}canUnnestBlock(){return this._blockManager.canUnnestBlock()}unnestBlock(){this._blockManager.unnestBlock()}moveBlocksUp(e){return this._blockManager.moveBlocksUp(e)}moveBlocksDown(e){return this._blockManager.moveBlocksDown(e)}blocksToHTMLLossy(e=this.document){return this._exportManager.blocksToHTMLLossy(e)}blocksToFullHTML(e=this.document){return this._exportManager.blocksToFullHTML(e)}tryParseHTMLToBlocks(e){return this._exportManager.tryParseHTMLToBlocks(e)}blocksToMarkdownLossy(e=this.document){return this._exportManager.blocksToMarkdownLossy(e)}tryParseMarkdownToBlocks(e){return this._exportManager.tryParseMarkdownToBlocks(e)}onChange(e,t){return this._eventManager.onChange(e,t)}onSelectionChange(e,t){return this._eventManager.onSelectionChange(e,t)}onFocusChange(e,t){return this._eventManager.onFocusChange(e,t)}onMount(e){return this._eventManager.onMount(e)}onUnmount(e){return this._eventManager.onUnmount(e)}getSelectionBoundingBox(){return this._selectionManager.getSelectionBoundingBox()}get isEmpty(){let e=this.document;return e.length===0||e.length===1&&e[0].type===`paragraph`&&e[0].content.length===0}pasteHTML(e,t=!1){this._exportManager.pasteHTML(e,t)}pasteText(e){return this._exportManager.pasteText(e)}pasteMarkdown(e){return this._exportManager.pasteMarkdown(e)}},QT=e(t(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(i of t.entries())if(!n.has(i[0]))return!1;for(i of t.entries())if(!e(i[1],n.get(i[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(i of t.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(t[i]!==n[i])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!(o===`_owner`&&t.$$typeof)&&!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}}))(),1),$T=(0,D.createContext)(void 0);function eE(e){return(0,D.useContext)($T)}function H(e){let t=eE(e);if(!t?.editor)throw Error(`useBlockNoteEditor was called outside of a BlockNoteContext provider or BlockNoteView component`);return t.editor}function tE(e,t=e=>e){return(0,Se.useSyncExternalStoreWithSelector)(e.subscribe,()=>e.state,()=>e.state,t,nE)}function nE(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=rE(e);return n.length===rE(t).length&&n.every(n=>Object.prototype.hasOwnProperty.call(t,n)&&Object.is(e[n],t[n]))}function rE(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function iE(e,t){let n=(t?.editor??H()).getExtension(e);if(!n)throw Error(`Extension not found`,{cause:{plugin:e}});return n}function aE(e,t){let{store:n}=iE(e,t);if(!n)throw Error(`Store not found on plugin`,{cause:{plugin:e}});return tE(n,t?.selector)}var oE=typeof window<`u`?D.useLayoutEffect:D.useEffect,sE=class{transactionNumber=0;lastTransactionNumber=0;lastSnapshot;editor;subscribers=new Set;constructor(e){this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e,t){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},n=this.editor._tiptapEditor,r={all:[`transaction`,`create`,`mount`,`unmount`],mount:[`create`,`mount`,`unmount`],selection:[`selectionUpdate`],change:[`update`]};for(let i of r[t])n.on(i,e);return()=>{for(let i of r[t])n.off(i,e)}}}};function cE(e){let t=eE(),n=e.editor||t?.editor||null,r=e.on||`all`,[i]=(0,D.useState)(()=>new sE(n)),a=(0,Se.useSyncExternalStoreWithSelector)(i.subscribe,i.getSnapshot,i.getServerSnapshot,e.selector,e.equalityFn??QT.default);return oE(()=>i.watch(n,r),[n,i,r]),(0,D.useDebugValue)(a),a}function lE(e){let t=eE();if(e||=t?.editor,!e)throw Error("'editor' is required in `useEditorDOMElement`, either from BlockNoteContext or as a function argument");return cE({editor:e,selector:e=>e.editor.domElement,equalityFn:(e,t)=>e===t,on:`mount`})}var uE=(0,D.createContext)(void 0);function dE(){return(0,D.useContext)(uE)}var fE=typeof window<`u`?D.useInsertionEffect:D.useEffect,pE=(0,D.createContext)(null);function mE(){let e=(0,D.useContext)(pE),t=lE();return e||(t?.parentElement??null)}function hE(e){return(0,O.jsx)(pE.Provider,{value:null,children:e.children})}function gE(e){let{target:t,children:n}=e,r=H(),i=dE()?.applyThemedRoot,[a]=(0,D.useState)(()=>typeof document>`u`?null:document.createElement(`div`));return fE(()=>{if(a&&t)return t.appendChild(a),()=>a.remove()},[a,t]),fE(()=>{!a||!t||i?.(a)},[a,t,i]),fE(()=>{if(a&&t)return r.registerPortalElement(a),()=>r.unregisterPortalElement(a)},[r,a,t]),t===void 0?n:(0,O.jsx)(pE.Provider,{value:a,children:n})}function _E(){let[e]=(0,D.useState)(()=>{if(typeof document>`u`)return null;let e=document.createElement(`span`);return e.className=`bn-portal-anchor`,e}),t=(0,D.useCallback)(t=>{t&&e&&e.parentElement!==t&&t.appendChild(e)},[e]);return{anchor:e,holder:(0,O.jsx)(`span`,{ref:t,className:vE,style:{position:`absolute`,width:0,height:0,overflow:`visible`}})}}var vE=`bn-portal-anchor-holder`;function yE(e){return Array.from(e.childNodes).some(e=>!(e instanceof Element&&e.classList.contains(vE)))}function bE(e){let{anchor:t,holder:n}=_E(),r=mE(),i=t??r,a=typeof e.children==`function`?e.children(i):e.children;return(0,O.jsxs)(O.Fragment,{children:[n,(0,O.jsx)(pE.Provider,{value:i,children:a})]})}function xE(e){let t=new DOMRect,n=`getBoundingClientRect`in e?()=>e.getBoundingClientRect():()=>e.element.getBoundingClientRect();return()=>e.element&&(e.cacheMountedBoundingClientRect??!0)?(e.element.isConnected&&(t=n()),t):n()}function SE(e,t){return e?t?(n,r,i)=>{let a=e(n,r,i),o=t(n,r,i);return()=>{a?.(),o?.()}}:e:t}var CE=e=>{let t=H(),n=mE(),{whileElementsMounted:r,middleware:i,...a}=e.useFloatingOptions??{},{refs:o,floatingStyles:s,context:c,middlewareData:l}=re({whileElementsMounted:SE(ie,e.useFloatingOptions?.whileElementsMounted),middleware:[...i??[],oe()],...a}),{isMounted:u,styles:d}=f(c,e.useTransitionStylesProps),{status:p}=b(c,e.useTransitionStatusProps),m=y(c,e.useDismissProps),h=ne(c,{enabled:!1,...e.useHoverProps}),{getFloatingProps:g}=_([m,h]),x=(0,D.useRef)(``),S=(0,D.useRef)(null),w=v([S,o.setFloating]);if((0,D.useEffect)(()=>{if(e.reference){let n=`element`in e.reference?e.reference.element:void 0;n!==void 0&&(e.focusManagerProps?.disabled||!t.isWithinEditor(n))&&o.setReference(n);let r=`getClientRects`in e.reference?e.reference.getClientRects:void 0;o.setPositionReference({getBoundingClientRect:xE(e.reference),...r?{getClientRects:r}:{},contextElement:n})}},[e.reference,o,e.focusManagerProps?.disabled,t]),(0,D.useEffect)(()=>{(p===`initial`||p===`open`)&&S.current&&yE(S.current)&&(x.current=S.current.innerHTML)},[p,e.reference,e.children]),!u||!n)return!1;let T={...e.elementProps,style:{display:`flex`,...e.elementProps?.style,zIndex:`calc(var(--bn-ui-base-z-index, 0) + ${e.elementProps?.style?.zIndex||0})`,...s,...d,...l.hide?.referenceHidden?{visibility:`hidden`}:{}},...g()};return p===`close`?(0,O.jsx)(C,{root:n,children:(0,O.jsx)(`div`,{ref:w,...T,dangerouslySetInnerHTML:{__html:x.current}})}):e.focusManagerProps?.disabled?(0,O.jsx)(C,{root:n,children:(0,O.jsx)(`div`,{ref:w,...T,children:(0,O.jsx)(bE,{children:e.children})})}):(0,O.jsx)(C,{root:n,children:(0,O.jsx)(ae,{...e.focusManagerProps,context:c,children:(0,O.jsx)(`div`,{ref:w,...T,children:(0,O.jsx)(bE,{children:e.children})})})})},wE=(0,D.createContext)(void 0);function U(){return(0,D.useContext)(wE)}function W(){return eE().editor.dictionary}var TE=e=>{let{position:t,children:n,...r}=e,{from:i,to:a}=t||{},o=H(),s=lE(),c=(0,D.useMemo)(()=>{if(i!==void 0&&a!==void 0)return{element:s?.firstElementChild||void 0,getBoundingClientRect:()=>Ld(o.prosemirrorView,i,a??i)}},[o,s,i,a]);return(0,O.jsx)(CE,{reference:c,...r,children:t!==void 0&&n})},EE=(e={},t=[])=>(0,D.useMemo)(()=>{let t=ZT.create(e);return window&&(window.ProseMirror=t._tiptapEditor),t},t),DE=e=>{let[t,n]=(0,D.useState)(!1),r=cE({editor:e.editor,selector:({editor:e})=>e.isEmpty}),i=U(),a=(0,D.useCallback)(()=>{n(!0)},[]),o=(0,D.useCallback)(()=>{n(!1)},[]);return(0,D.useEffect)(()=>{e.editable&&e.autoFocus&&e.editor.focus()},[e.autoFocus,e.editable,e.editor]),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i.Comments.Editor,{autoFocus:e.autoFocus,className:`bn-comment-editor`,editor:e.editor,onFocus:a,onBlur:o,editable:e.editable}),e.actions&&(0,O.jsx)(`div`,{className:`bn-comment-actions-wrapper`,children:e.actions({isFocused:t,isEmpty:r})})]})},{textColor:OE,backgroundColor:kE,...AE}=jy,jE=Py.create({blockSpecs:{paragraph:Zv()},styleSpecs:AE});function ME(e){return!e.hasUnsavedContent||!e.confirmBeforeDiscard||(e.confirm??(e=>window.confirm(e)))(e.message)}var NE=z(({editor:e,options:{submitOnEnter:t=!0,onSubmit:n}})=>{let r=!1;async function i(){if(!(!e.isEditable||e.isEmpty||r)){r=!0;try{await n(e)}finally{r=!1}}}function a({event:t}){let n=e.prosemirrorView;return!n.editable||n.composing||t.isComposing||t.keyCode===229?!1:(t.repeat||i(),!0)}return{key:`commentEditorSubmit`,submit:i,runsBefore:[`default`],keyboardShortcuts:{"Mod-Enter":a,...t?{Enter:a}:{}}}}),PE=$f.create({name:`comment`,excludes:``,inclusive:!1,keepOnSplit:!0,group:kp,addAttributes(){return{orphan:{parseHTML:e=>!!e.getAttribute(`data-orphan`),renderHTML:e=>e.orphan?{"data-orphan":`true`}:{},default:!1},threadId:{parseHTML:e=>e.getAttribute(`data-bn-thread-id`),renderHTML:e=>({"data-bn-thread-id":e.threadId}),default:``}}},renderHTML({HTMLAttributes:e}){return[`span`,ad(e,{class:`bn-thread-mark`})]},parseHTML(){return[{tag:`span.bn-thread-mark`}]},extendMarkSchema(e){return e.name===`comment`?{blocknoteIgnore:!0}:{}}}),FE=new jr(`blocknote-comments`);function IE(e,t){let n=new Map;return e.descendants((e,r)=>{e.marks.forEach(i=>{if(i.type.name===t){let t=i.attrs.threadId;if(!t)return;let a=r,o=a+e.nodeSize,s=n.get(t)??{from:1/0,to:0};n.set(t,{from:Math.min(a,s.from),to:Math.max(o,s.to)})}})}),n}var LE=z(({editor:e,options:{schema:t,threadStore:n,resolveUsers:r,confirmBeforeDiscard:i=!0,submitOnEnter:a=!0}})=>{if(!r)throw Error(`resolveUsers is required to be defined when using comments`);if(!n)throw Error(`threadStore is required to be defined when using comments`);let o=Ry(r),s=PE.name,c=Lp({pendingComment:!1,selectedThreadId:void 0,threadPositions:new Map},{onUpdate(t,n){t.selectedThreadId!==n.selectedThreadId&&e.transact(e=>e.setMeta(FE,!0))}}),l=t=>{e.transact(e=>{e.doc.descendants((n,r)=>{n.marks.forEach(i=>{if(i.type.name===s){let a=i.type,o=i.attrs.threadId,s=t.get(o),l=!!(!s||s.resolved||s.deletedAt);if(l!==i.attrs.orphan){let t=Math.max(r,0),s=Math.min(r+n.nodeSize,e.doc.content.size-1,e.doc.content.size-1);e.removeMark(t,s,i),e.addMark(t,s,a.create({...i.attrs,orphan:l})),l&&c.state.selectedThreadId===o&&c.setState(e=>({...e,selectedThreadId:void 0}))}}})})})};return{key:`comments`,store:c,userStore:o,runsBefore:[`link`],tiptapExtensions:[PE],prosemirrorPlugins:[new F({key:FE,state:{init(){return{decorations:L.empty}},apply(e,t){let n=e.getMeta(FE);if(!e.docChanged&&!n)return t;let r=e.docChanged?IE(e.doc,s):c.state.threadPositions;(r.size>0||c.state.threadPositions.size>0)&&c.setState(e=>({...e,threadPositions:r}));let i=[];if(c.state.selectedThreadId){let e=r.get(c.state.selectedThreadId);e&&i.push(ic.inline(e.from,e.to,{class:`bn-thread-mark-selected`}))}return{decorations:L.create(e.doc,i)}}},props:{decorations(e){return FE.getState(e)?.decorations??L.empty},handleClick:(e,t,n)=>{if(n.button!==0)return!1;let r=e.state.doc.nodeAt(t);if(!r)return c.setState(e=>({...e,selectedThreadId:void 0})),!1;let i=r.marks.find(e=>e.type.name===s&&e.attrs.orphan!==!0);if(!i)return c.state.selectedThreadId!==void 0&&c.setState(e=>({...e,selectedThreadId:void 0})),!1;let a=i.attrs.threadId;return a!==c.state.selectedThreadId&&(c.setState(e=>({...e,selectedThreadId:a})),!0)}}})],threadStore:n,mount(){let t=n.subscribe(l);l(n.getThreads());let r=e.onSelectionChange(()=>{c.state.pendingComment&&c.setState(e=>({...e,pendingComment:!1}))});return()=>{t(),r()}},selectThread(t,n=!0){if(c.state.selectedThreadId!==t&&(c.setState(e=>({...e,pendingComment:!1,selectedThreadId:t})),t&&n)){let n=c.state.threadPositions.get(t);if(!n)return;(e.prosemirrorView?.domAtPos(n.from).node)?.scrollIntoView({behavior:`smooth`,block:`center`})}},startPendingComment(){c.setState(e=>({...e,selectedThreadId:void 0,pendingComment:!0})),e.domElement?.focus(),e.getExtension(Iy)?.showSelection(!0,`comments`)},stopPendingComment(){c.setState(e=>({...e,selectedThreadId:void 0,pendingComment:!1})),e.getExtension(Iy)?.showSelection(!1,`comments`)},async createThread(t){let r=await n.createThread(t);n.addThreadToDocument?await n.addThreadToDocument({threadId:r.id,selection:e.transact(e=>e.selection),editor:e}):e._tiptapEditor.commands.setMark(s,{orphan:!1,threadId:r.id})},commentEditorSchema:t,confirmBeforeDiscard:i,submitOnEnter:a}}),RE=e(i(),1),zE=se();function BE(e,t){if(e.isDestroyed||t.defaultPrevented||!t.cancelable||!e.isEditable||t.inputType!==`insertParagraph`&&t.inputType!==`insertLineBreak`||!nu()&&!tu())return;let n=e.view,r=n.root,i=(r.getSelection?.call(r)??n.dom.ownerDocument.getSelection())?.anchorNode,a=(i?.nodeType===1?i:i?.parentElement)?.closest(`[data-node-view-content-react]`);if(!a||!n.dom.contains(a))return;let o=n.input.lastKeyCode;o===13&&(n.input.lastKeyCode=null),n.domObserver.forceFlush(),n.domObserver.flush();let s=new KeyboardEvent(`keydown`,{key:`Enter`,code:`Enter`,keyCode:13,shiftKey:t.inputType===`insertLineBreak`,bubbles:!0,cancelable:!0});n.someProp(`handleKeyDown`,e=>e(n,s))?(t.preventDefault(),n.input.lastIOSEnter=0,clearTimeout(n.input.lastIOSEnterFallbackTimeout)):o===13&&(n.input.lastKeyCode=o)}var VE=new jr(`reactMobileEnter`),HE=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},UE=({contentComponent:e})=>{let t=(0,zE.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,O.jsx)(O.Fragment,{children:Object.values(t)})};function WE(){let e=new Set,t={},n=!1,r=()=>{!n&&e.size&&(n=!0,queueMicrotask(()=>{n=!1,e.forEach(e=>e())}))};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(e,n){t={...t,[e]:RE.createPortal(n.reactElement,n.element,e)},r()},removeRenderer(e){let n={...t};delete n[e],t=n,r()}}}var GE=class extends D.Component{constructor(e){super(e),this.editorContentRef=D.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=WE(),e.createNodeViews(),e.registerPlugin(new F({key:VE,props:{handleDOMEvents:{beforeinput:(t,n)=>BE(e,n)}}})),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||(e.unregisterPlugin(VE),e.view.setProps({nodeViews:{}})),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{ref:HE(t,this.editorContentRef),...n}),e?.contentComponent&&(0,O.jsx)(UE,{contentComponent:e.contentComponent})]})}},KE=(0,D.forwardRef)((e,t)=>{let n=D.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return D.createElement(GE,{key:n,innerRef:t,...e})}),qE=D.memo(KE);typeof window>`u`||typeof window<`u`&&window.next;var JE=(0,D.createContext)({editor:null});JE.Consumer;var YE=(0,D.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),XE=()=>(0,D.useContext)(YE),ZE=D.forwardRef((e,t)=>{let{onDragStart:n}=XE(),r=e.as||`div`;return(0,O.jsx)(r,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})});function QE(e){return!!(typeof e==`function`&&e.prototype&&e.prototype.isReactComponent)}function $E(e){return!(typeof e!=`object`||!e.$$typeof||e.$$typeof.toString()!==`Symbol(react.forward_ref)`&&e.$$typeof.description!==`react.forward_ref`)}function eD(e){return!(typeof e!=`object`||!e.$$typeof||e.$$typeof.toString()!==`Symbol(react.memo)`&&e.$$typeof.description!==`react.memo`)}function tD(e){if(QE(e)||$E(e))return!0;if(eD(e)){let t=e.type;if(t)return QE(t)||$E(t)}return!1}function nD(){try{if(D.version)return parseInt(D.version.split(`.`)[0],10)>=19}catch{}return!1}var rD=class{constructor(e,{editor:t,props:n={},as:r=`div`,className:i=``}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add(`react-renderer`),i&&this.element.classList.add(...i.split(` `)),this.editor.isEditorContentInitialized?(0,RE.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,i=nD(),a=tD(t),o={...n};o.ref&&!(i||a)&&delete o.ref,!o.ref&&(i||a)&&(o.ref=e=>{this.ref=e}),this.reactElement=(0,O.jsx)(t,{...o}),r==null||(e=r.contentComponent)==null||e.setRenderer(this.id,this)}updateProps(e={}){if(this.destroyed)return;let t=!1,n=Object.keys(e);for(let r=0;r<n.length;r+=1){let i=n[r];if(e[i]!==this.props[i]){t=!0;break}}t&&(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0;let t=this.editor;t==null||(e=t.contentComponent)==null||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}};D.createContext({markViewContentRef:()=>{}});function iD(e){var t;let n=e.getRootNode(),r=typeof n.getSelection==`function`?n.getSelection():(t=e.ownerDocument)==null||(t=t.defaultView)==null?void 0:t.getSelection();if(!r||r.rangeCount===0)return null;let{anchorNode:i,anchorOffset:a,focusNode:o,focusOffset:s}=r;return!i||!o||!e.contains(i)||!e.contains(o)?null:()=>{try{r.setBaseAndExtent(i,a,o,s)}catch{}}}function aD(e,t,n){return e.node(n)===t.node(n)&&e.before(n)===t.before(n)}function oD(e){if(!Ql(e))return[];let{$from:t,$to:n}=e,r=[],i=Math.min(t.depth,n.depth);for(let e=1;e<=i&&aD(t,n,e);e+=1)r.push(t.before(e));return r}var sD=class{constructor(e){this.views=new WeakMap,this.viewCount=0,this.insideViews=new Set,this.syncQueued=!1,this.scheduleSync=()=>{this.syncQueued||(this.syncQueued=!0,queueMicrotask(()=>{this.syncQueued=!1,this.sync()}))},this.handleTransaction=()=>this.scheduleSync(),this.editor=e}register(e){this.viewCount===0&&this.editor.on(`transaction`,this.handleTransaction),this.views.set(e.dom,e),this.viewCount+=1,this.scheduleSync()}unregister(e){this.views.delete(e.dom),--this.viewCount,this.insideViews.delete(e),this.viewCount===0&&this.editor.off(`transaction`,this.handleTransaction)}sync(){if(this.viewCount===0||this.editor.isDestroyed)return;let e=this.findInsideViews();this.updateViews(this.insideViews,e,!1),this.updateViews(e,this.insideViews,!0),this.insideViews=e}updateViews(e,t,n){for(let r of e)t.has(r)||r.setSelectionInside(n)}findInsideViews(){let e=new Set;for(let t of oD(this.editor.state.selection)){let n=this.editor.view.nodeDOM(t),r=n?this.views.get(n):void 0;r&&e.add(r)}return e}},cD=new WeakMap;function lD(e){let t=cD.get(e);return t||(t=new sD(e),cD.set(e,t)),t}var uD=class extends Dp{constructor(e,t,n){if(super(e,t,n),this.nodeSelected=!1,this.handlePositionUpdate=()=>{let e=this.getPos();typeof e==`number`&&e!==this.currentPos&&(this.currentPos=e,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs==`function`&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.contentDOMElement=this.options.contentDOMElementTag?document.createElement(this.options.contentDOMElementTag):document.createElement(this.node.isInline?`span`:`div`),this.contentDOMElement.dataset.nodeViewContentReact=``,this.contentDOMElement.dataset.nodeViewWrapper=``,this.contentDOMElement.style.whiteSpace=`inherit`;let e=this.dom.querySelector(`[data-node-view-content]`);e?e.appendChild(this.contentDOMElement):this.dom.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on(`update`,this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){return r===`storage`?e.storage[t.name]??{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,selectionInside:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:(0,D.createRef)()};if(!this.component.displayName){let e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}let t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{if(e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement){e.hasAttribute(`data-node-view-wrapper`)&&e.removeAttribute(`data-node-view-wrapper`);let t=iD(this.contentDOMElement);e.appendChild(this.contentDOMElement),t?.()}}},n=this.component,r=(0,D.memo)(e=>(0,O.jsx)(YE.Provider,{value:t,children:(0,D.createElement)(n,e)}));r.displayName=`ReactNodeView`;let i=this.node.isInline?`span`:`div`;this.options.as&&(i=this.options.as);let{className:a=``}=this.options;this.renderer=new rD(r,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${a}`.trim()}),lD(this.editor).register(this),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){if(this.renderer.element.firstElementChild&&!this.renderer.element.firstElementChild?.hasAttribute(`data-node-view-wrapper`))throw Error(`Please use the NodeViewWrapper component for your node view.`);return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}update(e,t,n){let r=e=>{this.renderer.updateProps(e),typeof this.options.attrs==`function`&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update==`function`){let i=this.node,a=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:i,oldDecorations:a,newNode:e,newDecorations:t,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(e===this.node)return this.node=e,this.decorations=t,this.innerDecorations=n,!0;let i=this.getPos();this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=i;let a={node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(a.getPos=()=>this.getPos()),r(a),!0}selectNode(){this.nodeSelected=!0,this.updateSelectedState(!0)}deselectNode(){this.nodeSelected=!1,this.updateSelectedState(this.options.selectedOnTextSelection===!0&&this.isTextSelectionInside())}setSelectionInside(e){let t=this.nodeSelected||this.options.selectedOnTextSelection===!0&&e;this.renderer.updateProps({selectionInside:e,selected:t}),this.renderer.element.classList.toggle(`ProseMirror-selectednode`,t)}updateSelectedState(e){this.renderer.updateProps({selected:e}),this.renderer.element.classList.toggle(`ProseMirror-selectednode`,e)}isTextSelectionInside(){let e=this.getPos();return typeof e==`number`&&oD(this.editor.state.selection).includes(e)}destroy(){this.renderer.destroy(),lD(this.editor).unregister(this),this.options.trackNodeViewPosition&&this.editor.off(`update`,this.handlePositionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs==`function`){let t=this.editor.extensionManager.attributes,n=od(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function dD(e,t){return n=>n.editor.contentComponent?new uD(e,n,t):{dom:document.createElement(`span`),contentDOM:null,update:()=>!1,destroy:()=>{},selectNode:()=>{},deselectNode:()=>{},stopEvent:()=>!1,ignoreMutation:()=>!0}}var fD=(0,D.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});fD.displayName=`TiptapContext`;var pD=()=>(0,D.useContext)(fD);function mD({children:e,...t}){let n=`editor`in t?t.editor:t.instance;if(!n)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let r=(0,D.useMemo)(()=>({editor:n}),[n]),i=(0,D.useMemo)(()=>({editor:n}),[n]);return(0,O.jsx)(JE.Provider,{value:i,children:(0,O.jsx)(fD.Provider,{value:r,children:e})})}mD.displayName=`Tiptap`;function hD({...e}){let{editor:t}=pD();return(0,O.jsx)(qE,{editor:t,...e})}hD.displayName=`Tiptap.Content`,Object.assign(mD,{Content:hD});var gD=n(),_D=Object.defineProperty,vD=(e,t)=>{let n={};for(var r in e)_D(n,r,{get:e[r],enumerable:!0});return t||_D(n,Symbol.toStringTag,{value:`Module`}),n},yD=e=>{let{blockId:t,children:n,...r}=e,i=H(),a=(0,D.useMemo)(()=>i.transact(e=>{if(!t)return;let n=R_(t,e.doc);if(!n)return;let{node:r}=i.prosemirrorView.domAtPos(n.posBeforeNode+1);if(r instanceof Element)return{element:r}}),[i,t]);return(0,O.jsx)(CE,{reference:a,...r,children:t!==void 0&&n})},bD=e=>{let t=U(),n=W(),r=H(),i=r.getBlock(e.blockId),[a,o]=(0,D.useState)(``),s=(0,D.useCallback)(e=>{o(e.currentTarget.value)},[]),c=(0,D.useCallback)(()=>{r.getBlock(e.blockId)&&r.updateBlock(e.blockId,{props:{name:Lg(a),url:a}})},[r,e.blockId,a]);return i?(0,O.jsx)(t.FilePanel.TabPanel,{className:`bn-tab-panel`,children:(0,O.jsx)(t.Generic.Form.Root,{onSubmit:c,submitButton:(0,O.jsx)(t.FilePanel.Button,{className:`bn-button`,type:`submit`,"data-test":`embed-input-button`,children:n.file_panel.embed.embed_button[i.type]||n.file_panel.embed.embed_button.file}),children:(0,O.jsx)(t.FilePanel.TextInput,{className:`bn-text-input`,placeholder:n.file_panel.embed.url_placeholder,value:a,onChange:s,"data-test":`embed-input`})})}):null},xD=e=>{let t=U(),n=W(),{setLoading:r}=e,i=H(),a=i.getBlock(e.blockId),[o,s]=(0,D.useState)(!1);(0,D.useEffect)(()=>{o&&setTimeout(()=>{s(!1)},3e3)},[o]);let c=(0,D.useCallback)(t=>{if(t===null)return;async function n(t){if(r(!0),i.uploadFile!==void 0)try{let n=await i.uploadFile(t,e.blockId);if(!i.getBlock(e.blockId))return;typeof n==`string`&&(n={props:{name:t.name,url:n}}),i.updateBlock(e.blockId,n)}catch{s(!0)}finally{r(!1)}}n(t)},[e.blockId,i,r]);if(!a)return null;let l=i.schema.blockSpecs[a.type],u=l.implementation.meta?.fileBlockAccept?.length?l.implementation.meta.fileBlockAccept.join(`,`):`*/*`;return(0,O.jsxs)(t.FilePanel.TabPanel,{className:`bn-tab-panel`,children:[(0,O.jsx)(t.FilePanel.FileInput,{className:`bn-file-input`,"data-test":`upload-input`,accept:u,placeholder:n.file_panel.upload.file_placeholder[a.type]||n.file_panel.upload.file_placeholder.file,value:null,onChange:c}),o&&(0,O.jsx)(`div`,{className:`bn-error-text`,children:n.file_panel.upload.upload_error})]})},SD=e=>{let t=U(),n=W(),r=H(),[i,a]=(0,D.useState)(!1),o=e.tabs??[...r.uploadFile===void 0?[]:[{name:n.file_panel.upload.title,tabPanel:(0,O.jsx)(xD,{blockId:e.blockId,setLoading:a})}],{name:n.file_panel.embed.title,tabPanel:(0,O.jsx)(bD,{blockId:e.blockId})}],[s,c]=(0,D.useState)(e.defaultOpenTab||o[0].name);return(0,O.jsx)(t.FilePanel.Root,{className:`bn-panel`,defaultOpenTab:s,openTab:s,setOpenTab:c,tabs:o,loading:i})},CD=e=>{let t=H(),n=iE(rv),r=aE(rv),i=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!r,onOpenChange:(e,r,i)=>{e||n.closeMenu(),i===`escape-key`&&t.focus()},middleware:[p(10),S()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:90},...e.floatingUIOptions?.elementProps}}),[r,t,n,e.floatingUIOptions]),a=e.filePanel||SD;return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(yD,{blockId:r,...i,children:r&&(0,O.jsx)(a,{blockId:r})})})},wD={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},TD=D.createContext&&D.createContext(wD),ED=[`attr`,`size`,`title`];function DD(e,t){if(e==null)return{};var n,r,i=OD(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function OD(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function kD(){return kD=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},kD.apply(null,arguments)}function AD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function jD(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?AD(Object(n),!0).forEach(function(t){MD(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):AD(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function MD(e,t,n){return(t=ND(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ND(e){var t=PD(e,`string`);return typeof t==`symbol`?t:t+``}function PD(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function FD(e){return e&&e.map((e,t)=>D.createElement(e.tag,jD({key:t},e.attr),FD(e.child)))}function G(e){return t=>D.createElement(ID,kD({attr:jD({},e.attr)},t),FD(e.child))}function ID(e){var t=t=>{var{attr:n,size:r,title:i}=e,a=DD(e,ED),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),D.createElement(`svg`,kD({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:jD(jD({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&D.createElement(`title`,null,i),e.children)};return TD===void 0?t(wD):D.createElement(TD.Consumer,null,e=>t(e))}function LD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM8 13H16C16 15.2091 14.2091 17 12 17C9.79086 17 8 15.2091 8 13ZM8 11C7.17157 11 6.5 10.3284 6.5 9.5C6.5 8.67157 7.17157 8 8 8C8.82843 8 9.5 8.67157 9.5 9.5C9.5 10.3284 8.82843 11 8 11ZM16 11C15.1716 11 14.5 10.3284 14.5 9.5C14.5 8.67157 15.1716 8 16 8C16.8284 8 17.5 8.67157 17.5 9.5C17.5 10.3284 16.8284 11 16 11Z`},child:[]}]})(e)}function RD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM8 13C8 15.2091 9.79086 17 12 17C14.2091 17 16 15.2091 16 13H8ZM8 11C8.82843 11 9.5 10.3284 9.5 9.5C9.5 8.67157 8.82843 8 8 8C7.17157 8 6.5 8.67157 6.5 9.5C6.5 10.3284 7.17157 11 8 11ZM16 11C16.8284 11 17.5 10.3284 17.5 9.5C17.5 8.67157 16.8284 8 16 8C15.1716 8 14.5 8.67157 14.5 9.5C14.5 10.3284 15.1716 11 16 11Z`},child:[]}]})(e)}function zD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5 11V13H19V11H5Z`},child:[]}]})(e)}function BD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5 10C3.9 10 3 10.9 3 12C3 13.1 3.9 14 5 14C6.1 14 7 13.1 7 12C7 10.9 6.1 10 5 10ZM19 10C17.9 10 17 10.9 17 12C17 13.1 17.9 14 19 14C20.1 14 21 13.1 21 12C21 10.9 20.1 10 19 10ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10Z`},child:[]}]})(e)}function VD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V12L17.206 8.207L11.2071 14.2071L9.79289 12.7929L15.792 6.793L12 3H21Z`},child:[]}]})(e)}function HD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M4 19H20V12H22V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V12H4V19ZM14 9H19L12 16L5 9H10V3H14V9Z`},child:[]}]})(e)}function UD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM9 11V17H11V11H9ZM13 11V17H15V11H13ZM9 4V6H15V4H9Z`},child:[]}]})(e)}function WD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 4V6H15V4H9Z`},child:[]}]})(e)}function GD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z`},child:[]}]})(e)}function KD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z`},child:[]}]})(e)}function qD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z`},child:[]}]})(e)}function JD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M22 18V20H2V18H22ZM2 3.5L10 8.5L2 13.5V3.5ZM22 11V13H12V11H22ZM22 4V6H12V4H22Z`},child:[]}]})(e)}function YD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M20 3C20.5523 3 21 3.44772 21 4V5.757L19 7.757V5H5V13.1L9 9.1005L13.328 13.429L12.0012 14.7562L11.995 18.995L16.2414 19.0012L17.571 17.671L18.8995 19H19V16.242L21 14.242V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM21.7782 7.80761L23.1924 9.22183L15.4142 17L13.9979 16.9979L14 15.5858L21.7782 7.80761ZM15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7Z`},child:[]}]})(e)}function XD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21 15V18H24V20H21V23H19V20H16V18H19V15H21ZM21.0082 3C21.556 3 22 3.44495 22 3.9934L22.0007 13.3417C21.3749 13.1204 20.7015 13 20 13V5H4L4.001 19L13.2929 9.70715C13.6528 9.34604 14.22 9.31823 14.6123 9.62322L14.7065 9.70772L18.2521 13.2586C15.791 14.0069 14 16.2943 14 19C14 19.7015 14.1204 20.3749 14.3417 21.0007L2.9918 21C2.44405 21 2 20.5551 2 20.0066V3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082ZM8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7Z`},child:[]}]})(e)}function ZD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z`},child:[]}]})(e)}function QD(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z`},child:[]}]})(e)}function $D(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 3V12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12V3H18V12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12V3H8ZM4 20H20V22H4V20Z`},child:[]}]})(e)}function eO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 6V21H11V6H5V4H19V6H13Z`},child:[]}]})(e)}function tO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 10V14H19V10H13ZM11 10H5V14H11V10ZM13 19H19V16H13V19ZM11 19V16H5V19H11ZM13 5V8H19V5H13ZM11 5H5V8H11V5ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3Z`},child:[]}]})(e)}function nO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17.1538 14C17.3846 14.5161 17.5 15.0893 17.5 15.7196C17.5 17.0625 16.9762 18.1116 15.9286 18.867C14.8809 19.6223 13.4335 20 11.5862 20C9.94674 20 8.32335 19.6185 6.71592 18.8555V16.6009C8.23538 17.4783 9.7908 17.917 11.3822 17.917C13.9333 17.917 15.2128 17.1846 15.2208 15.7196C15.2208 15.0939 15.0049 14.5598 14.5731 14.1173C14.5339 14.0772 14.4939 14.0381 14.4531 14H3V12H21V14H17.1538ZM13.076 11H7.62908C7.4566 10.8433 7.29616 10.6692 7.14776 10.4778C6.71592 9.92084 6.5 9.24559 6.5 8.45207C6.5 7.21602 6.96583 6.165 7.89749 5.299C8.82916 4.43299 10.2706 4 12.2219 4C13.6934 4 15.1009 4.32808 16.4444 4.98426V7.13591C15.2448 6.44921 13.9293 6.10587 12.4978 6.10587C10.0187 6.10587 8.77917 6.88793 8.77917 8.45207C8.77917 8.87172 8.99709 9.23796 9.43293 9.55079C9.86878 9.86362 10.4066 10.1135 11.0463 10.3004C11.6665 10.4816 12.3431 10.7148 13.076 11H13.076Z`},child:[]}]})(e)}function rO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21 4H3V6H21V4ZM21 11H8V13H21V11ZM21 18H8V20H21V18ZM5 11H3V20H5V11Z`},child:[]}]})(e)}function iO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21 20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20C20.5523 3 21 3.44772 21 4V20ZM19 11V5H13.001V7H15L12 10L9 7H11V5H5V11H7V13H5V19H11V17H9L12 14L15 17H13.001V19H19V13H17V11H19ZM11 13H9V11H11V13ZM15 13H13V11H15V13Z`},child:[]}]})(e)}function aO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M20 3C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM11 5H5V10.999H7V9L10 12L7 15V13H5V19H11V17H13V19H19V13H17V15L14 12L17 9V10.999H19V5H13V7H11V5ZM13 13V15H11V13H13ZM13 9V11H11V9H13Z`},child:[]}]})(e)}function oO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 4H21V6H8V4ZM4.5 6.5C3.67157 6.5 3 5.82843 3 5C3 4.17157 3.67157 3.5 4.5 3.5C5.32843 3.5 6 4.17157 6 5C6 5.82843 5.32843 6.5 4.5 6.5ZM4.5 13.5C3.67157 13.5 3 12.8284 3 12C3 11.1716 3.67157 10.5 4.5 10.5C5.32843 10.5 6 11.1716 6 12C6 12.8284 5.32843 13.5 4.5 13.5ZM4.5 20.4C3.67157 20.4 3 19.7284 3 18.9C3 18.0716 3.67157 17.4 4.5 17.4C5.32843 17.4 6 18.0716 6 18.9C6 19.7284 5.32843 20.4 4.5 20.4ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z`},child:[]}]})(e)}function sO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 4H21V6H8V4ZM5 3V6H6V7H3V6H4V4H3V3H5ZM3 14V11.5H5V11H3V10H6V12.5H4V13H6V14H3ZM5 19.5H3V18.5H5V18H3V17H6V21H3V20H5V19.5ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z`},child:[]}]})(e)}function cO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z`},child:[]}]})(e)}function lO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M18.3638 15.5355L16.9496 14.1213L18.3638 12.7071C20.3164 10.7545 20.3164 7.58866 18.3638 5.63604C16.4112 3.68341 13.2453 3.68341 11.2927 5.63604L9.87849 7.05025L8.46428 5.63604L9.87849 4.22182C12.6122 1.48815 17.0443 1.48815 19.778 4.22182C22.5117 6.95549 22.5117 11.3876 19.778 14.1213L18.3638 15.5355ZM15.5353 18.364L14.1211 19.7782C11.3875 22.5118 6.95531 22.5118 4.22164 19.7782C1.48797 17.0445 1.48797 12.6123 4.22164 9.87868L5.63585 8.46446L7.05007 9.87868L5.63585 11.2929C3.68323 13.2455 3.68323 16.4113 5.63585 18.364C7.58847 20.3166 10.7543 20.3166 12.7069 18.364L14.1211 16.9497L15.5353 18.364ZM14.8282 7.75736L16.2425 9.17157L9.17139 16.2426L7.75717 14.8284L14.8282 7.75736Z`},child:[]}]})(e)}function uO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17 17H22V19H19V22H17V17ZM7 7H2V5H5V2H7V7ZM18.364 15.5355L16.9497 14.1213L18.364 12.7071C20.3166 10.7545 20.3166 7.58866 18.364 5.63604C16.4113 3.68342 13.2455 3.68342 11.2929 5.63604L9.87868 7.05025L8.46447 5.63604L9.87868 4.22183C12.6123 1.48816 17.0445 1.48816 19.7782 4.22183C22.5118 6.9555 22.5118 11.3877 19.7782 14.1213L18.364 15.5355ZM15.5355 18.364L14.1213 19.7782C11.3877 22.5118 6.9555 22.5118 4.22183 19.7782C1.48816 17.0445 1.48816 12.6123 4.22183 9.87868L5.63604 8.46447L7.05025 9.87868L5.63604 11.2929C3.68342 13.2455 3.68342 16.4113 5.63604 18.364C7.58866 20.3166 10.7545 20.3166 12.7071 18.364L14.1213 16.9497L15.5355 18.364ZM14.8284 7.75736L16.2426 9.17157L9.17157 16.2426L7.75736 14.8284L14.8284 7.75736Z`},child:[]}]})(e)}function dO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M15 20H7V18H9.92661L12.0425 6H9V4H17V6H14.0734L11.9575 18H15V20Z`},child:[]}]})(e)}function fO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 5H11V19H8V21H16V19H13V5H16V3H8V5ZM2 7C1.44772 7 1 7.44772 1 8V16C1 16.5523 1.44772 17 2 17H8V15H3V9H8V7H2ZM16 9H21V15H16V17H22C22.5523 17 23 16.5523 23 16V8C23 7.44772 22.5523 7 22 7H16V9Z`},child:[]}]})(e)}function pO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM7 12.5L3 16V9L7 12.5Z`},child:[]}]})(e)}function mO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM3 12.5L7 9V16L3 12.5Z`},child:[]}]})(e)}function hO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21.097 8L18.499 12.5C20.7091 12.5 22.5 14.2909 22.5 16.5C22.5 18.7091 20.7091 20.5 18.5 20.5C16.2909 20.5 14.5 18.7091 14.5 16.5C14.5 15.7636 14.699 15.0737 15.0461 14.4811L18.788 8H21.097ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 14.5C17.3954 14.5 16.5 15.3954 16.5 16.5C16.5 17.6046 17.3954 18.5 18.5 18.5C19.6046 18.5 20.5 17.6046 20.5 16.5C20.5 15.3954 19.6046 14.5 18.5 14.5Z`},child:[]}]})(e)}function gO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M22 8V10H17.6769L17.2126 12.6358C17.5435 12.5472 17.8912 12.5 18.25 12.5C20.4591 12.5 22.25 14.2909 22.25 16.5C22.25 18.7091 20.4591 20.5 18.25 20.5C16.4233 20.5 14.8827 19.2756 14.4039 17.6027L16.3271 17.0519C16.5667 17.8881 17.3369 18.5 18.25 18.5C19.3546 18.5 20.25 17.6046 20.25 16.5C20.25 15.3954 19.3546 14.5 18.25 14.5C17.6194 14.5 17.057 14.7918 16.6904 15.2478L14.8803 14.3439L16 8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z`},child:[]}]})(e)}function _O(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM22 8V16H23.5V18H22V20H20V18H14.5V16.66L19.5 8H22ZM20 11.133L17.19 16H20V11.133Z`},child:[]}]})(e)}function vO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M22 8L21.9984 10L19.4934 12.883C21.0823 13.3184 22.25 14.7728 22.25 16.5C22.25 18.5711 20.5711 20.25 18.5 20.25C16.674 20.25 15.1528 18.9449 14.8184 17.2166L16.7821 16.8352C16.9384 17.6413 17.6481 18.25 18.5 18.25C19.4665 18.25 20.25 17.4665 20.25 16.5C20.25 15.5335 19.4665 14.75 18.5 14.75C18.214 14.75 17.944 14.8186 17.7056 14.9403L16.3992 13.3932L19.3484 10H15V8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z`},child:[]}]})(e)}function yO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 8C20.5711 8 22.25 9.67893 22.25 11.75C22.25 12.6074 21.9623 13.3976 21.4781 14.0292L21.3302 14.2102L18.0343 18H22V20H15L14.9993 18.444L19.8207 12.8981C20.0881 12.5908 20.25 12.1893 20.25 11.75C20.25 10.7835 19.4665 10 18.5 10C17.5818 10 16.8288 10.7071 16.7558 11.6065L16.75 11.75H14.75C14.75 9.67893 16.4289 8 18.5 8Z`},child:[]}]})(e)}function bO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM21.0005 8V20H19.0005L19 10.204L17 10.74V8.67L19.5005 8H21.0005Z`},child:[]}]})(e)}function xO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5.55397 22H3.3999L10.9999 3H12.9999L20.5999 22H18.4458L16.0458 16H7.95397L5.55397 22ZM8.75397 14H15.2458L11.9999 5.88517L8.75397 14Z`},child:[]}]})(e)}function SO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3.41436 5.99995L5.70726 3.70706L4.29304 2.29285L0.585938 5.99995L4.29304 9.70706L5.70726 8.29285L3.41436 5.99995ZM9.58594 5.99995L7.29304 3.70706L8.70726 2.29285L12.4144 5.99995L8.70726 9.70706L7.29304 8.29285L9.58594 5.99995ZM14.0002 2.99995H21.0002C21.5524 2.99995 22.0002 3.44767 22.0002 3.99995V20C22.0002 20.5522 21.5524 21 21.0002 21H3.00015C2.44787 21 2.00015 20.5522 2.00015 20V12H4.00015V19H20.0002V4.99995H14.0002V2.99995Z`},child:[]}]})(e)}function CO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 11H12.5C13.8807 11 15 9.88071 15 8.5C15 7.11929 13.8807 6 12.5 6H8V11ZM18 15.5C18 17.9853 15.9853 20 13.5 20H6V4H12.5C14.9853 4 17 6.01472 17 8.5C17 9.70431 16.5269 10.7981 15.7564 11.6058C17.0979 12.3847 18 13.837 18 15.5ZM8 13V18H13.5C14.8807 18 16 16.8807 16 15.5C16 14.1193 14.8807 13 13.5 13H8Z`},child:[]}]})(e)}function wO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z`},child:[]}]})(e)}function TO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z`},child:[]}]})(e)}function EO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z`},child:[]}]})(e)}function DO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM5 19H19V21H5V19ZM3 14H21V16H3V14ZM5 9H19V11H5V9Z`},child:[]}]})(e)}function OO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M23 12L15.9289 19.0711L14.5147 17.6569L20.1716 12L14.5147 6.34317L15.9289 4.92896L23 12ZM3.82843 12L9.48528 17.6569L8.07107 19.0711L1 12L8.07107 4.92896L9.48528 6.34317L3.82843 12Z`},child:[]}]})(e)}function kO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z`},child:[]}]})(e)}function AO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M7.29117 20.8242L2 22L3.17581 16.7088C2.42544 15.3056 2 13.7025 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C10.2975 22 8.6944 21.5746 7.29117 20.8242ZM7.58075 18.711L8.23428 19.0605C9.38248 19.6745 10.6655 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 13.3345 4.32549 14.6175 4.93949 15.7657L5.28896 16.4192L4.63416 19.3658L7.58075 18.711Z`},child:[]}]})(e)}function jO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M7.24264 17.9967H3V13.754L14.435 2.319C14.8256 1.92848 15.4587 1.92848 15.8492 2.319L18.6777 5.14743C19.0682 5.53795 19.0682 6.17112 18.6777 6.56164L7.24264 17.9967ZM3 19.9967H21V21.9967H3V19.9967Z`},child:[]}]})(e)}function MO(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 7V11L2 6L8 1V5H13C17.4183 5 21 8.58172 21 13C21 17.4183 17.4183 21 13 21H4V19H13C16.3137 19 19 16.3137 19 13C19 9.68629 16.3137 7 13 7H8Z`},child:[]}]})(e)}var NO={bold:CO,italic:dO,underline:$D,strike:nO,code:OO};function PO(e,t){return e in t.schema.styleSchema&&t.schema.styleSchema[e].type===e&&t.schema.styleSchema[e].propSchema===`boolean`}var FO=e=>{let t=W(),n=U(),r=H(),i=cE({editor:r,selector:({editor:t})=>{if(t.isEditable&&PO(e.basicTextStyle,t)&&(t.getSelection()?.blocks||[t.getTextCursorPosition().block]).find(e=>e.content!==void 0))return e.basicTextStyle in t.getActiveStyles()?{active:!0}:{active:!1}}}),a=(0,D.useCallback)(e=>{r.focus(),r.toggleStyles({[e]:!0})},[r]);if(i===void 0)return null;let o=NO[e.basicTextStyle];return(0,O.jsx)(n.FormattingToolbar.Button,{className:`bn-button`,"data-test":e.basicTextStyle,onClick:()=>a(e.basicTextStyle),isSelected:i.active,label:t.formatting_toolbar[e.basicTextStyle].tooltip,mainTooltip:t.formatting_toolbar[e.basicTextStyle].tooltip,secondaryTooltip:pg(t.formatting_toolbar[e.basicTextStyle].secondary_tooltip,t.generic.ctrl_shortcut),icon:(0,O.jsx)(o,{})})},IO=(0,D.createContext)(`desktop`);function LO(){return(0,D.useContext)(IO)}var RO=e=>{let t=e.textColor||`default`,n=e.backgroundColor||`default`,r=e.size||16,i=(0,D.useMemo)(()=>({pointerEvents:`none`,fontSize:(r*.75).toString()+`px`,height:r.toString()+`px`,lineHeight:r.toString()+`px`,textAlign:`center`,width:r.toString()+`px`}),[r]);return(0,O.jsx)(`div`,{className:`bn-color-icon`,"data-background-color":n,"data-text-color":t,style:i,children:`A`})},zO=[`default`,`gray`,`brown`,`red`,`orange`,`yellow`,`green`,`blue`,`purple`,`pink`],BO=e=>{let t=U(),n=W();return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(()=>e.text?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(t.Generic.Menu.Label,{children:n.color_picker.text_title}),zO.map(r=>(0,O.jsx)(t.Generic.Menu.Item,{onClick:()=>{e.onClick?.(),e.text.setColor(r)},"data-test":`text-color-`+r,icon:(0,O.jsx)(RO,{textColor:r,size:e.iconSize}),checked:e.text.color===r,children:n.color_picker.colors[r]},`text-color-`+r))]}):null,{}),(0,O.jsx)(()=>e.background?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(t.Generic.Menu.Label,{children:n.color_picker.background_title}),zO.map(r=>(0,O.jsx)(t.Generic.Menu.Item,{onClick:()=>{e.onClick?.(),e.background.setColor(r)},"data-test":`background-color-`+r,icon:(0,O.jsx)(RO,{backgroundColor:r,size:e.iconSize}),checked:e.background.color===r,children:n.color_picker.colors[r]},`background-color-`+r))]}):null,{})]})};function VO(e,t){return`${e}Color`in t.schema.styleSchema&&t.schema.styleSchema[`${e}Color`].type===`${e}Color`&&t.schema.styleSchema[`${e}Color`].propSchema===`string`}var HO=()=>{let e=U(),t=W(),n=LO(),r=mE(),i=H(),a=VO(`text`,i),o=VO(`background`,i),s=cE({editor:i,selector:({editor:e})=>{if(!e.isEditable||!(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return;let t=VO(`text`,e),n=VO(`background`,e);if(t||n)return{textColor:t?e.getActiveStyles().textColor||`default`:void 0,backgroundColor:n?e.getActiveStyles().backgroundColor||`default`:void 0}}}),c=(0,D.useCallback)(e=>{if(!a)throw Error(`Tried to set text color, but style does not exist in editor schema.`);e==="default"?i.removeStyles({textColor:e}):i.addStyles({textColor:e}),i.focus()},[i,a]),l=(0,D.useCallback)(e=>{if(!o)throw Error(`Tried to set background color, but style does not exist in editor schema.`);e==="default"?i.removeStyles({backgroundColor:e}):i.addStyles({backgroundColor:e}),i.focus()},[o,i]);return s===void 0?null:(0,O.jsxs)(e.Generic.Menu.Root,{portalElement:r,preventFocusOnOpen:n===`mobile`,children:[(0,O.jsx)(e.Generic.Menu.Trigger,{children:(0,O.jsx)(e.FormattingToolbar.Button,{className:`bn-button`,"data-test":`colors`,label:t.formatting_toolbar.colors.tooltip,mainTooltip:t.formatting_toolbar.colors.tooltip,icon:(0,O.jsx)(RO,{textColor:s.textColor,backgroundColor:s.backgroundColor,size:20})})}),(0,O.jsx)(e.Generic.Menu.Dropdown,{className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,O.jsx)(BO,{text:s.textColor?{color:s.textColor,setColor:c}:void 0,background:s.backgroundColor?{color:s.backgroundColor,setColor:l}:void 0})})]})};function UO(){let e=W();return(0,O.jsx)(`button`,{className:`bn-screen-reader-only-submit`,tabIndex:-1,type:`submit`,children:e.generic.form_submit})}var WO=e=>{for(let t of _b)if(e.startsWith(t))return e;return`${vb}://${e}`},GO=e=>{let t=U(),n=W(),{editLink:r}=iE(gb),{url:i,text:a,showTextField:o}=e,[s,c]=(0,D.useState)(i),[l,u]=(0,D.useState)(a);(0,D.useEffect)(()=>{c(i),u(a)},[a,i]);let d=(0,D.useCallback)(e=>c(e.currentTarget.value),[]),f=(0,D.useCallback)(e=>u(e.currentTarget.value),[]),p=(0,D.useCallback)(()=>{r(WO(s),l,e.range.from),e.setToolbarOpen?.(!1),e.setToolbarPositionFrozen?.(!1)},[r,s,l,e]);return(0,O.jsxs)(t.Generic.Form.Root,{onSubmit:p,submitButton:(0,O.jsx)(UO,{}),children:[(0,O.jsx)(t.Generic.Form.TextInput,{className:`bn-text-input`,name:`url`,icon:(0,O.jsx)(lO,{}),autoFocus:!0,placeholder:n.link_toolbar.form.url_placeholder,value:s,onChange:d}),o!==!1&&(0,O.jsx)(t.Generic.Form.TextInput,{className:`bn-text-input`,name:`title`,icon:(0,O.jsx)(eO,{}),placeholder:n.link_toolbar.form.title_placeholder,value:l,onChange:f})]})};function KO(e){return`link`in e.schema.inlineContentSchema&&e.schema.inlineContentSchema.link===`link`}var qO=()=>{let e=H(),t=lE(),n=U(),r=W(),i=mE(),a=iE(vy),{showSelection:o}=iE(Iy),[s,c]=(0,D.useState)(!1);(0,D.useEffect)(()=>(o(s,`createLinkButton`),()=>o(!1,`createLinkButton`)),[s,o]);let l=(0,D.useCallback)(t=>{t||e.focus(),c(t)},[e]),u=cE({editor:e,selector:({editor:e})=>{if(e.isEditable&&!e.prosemirrorState.selection.empty&&KO(e)&&!gy(e.prosemirrorState.selection)&&(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return{url:e.getSelectedLinkUrl(),text:e.getSelectedText(),range:{from:e.prosemirrorState.selection.from,to:e.prosemirrorState.selection.to}}}});return(0,D.useEffect)(()=>{c(!1)},[u]),(0,D.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key===`k`&&(c(!0),e.preventDefault())};return t?.addEventListener(`keydown`,e),()=>{t?.removeEventListener(`keydown`,e)}},[t]),u===void 0?null:(0,O.jsxs)(n.Generic.Popover.Root,{open:s,onOpenChange:l,portalElement:i,children:[(0,O.jsx)(n.Generic.Popover.Trigger,{children:(0,O.jsx)(n.FormattingToolbar.Button,{className:`bn-button`,"data-test":`createLink`,label:r.formatting_toolbar.link.tooltip,mainTooltip:r.formatting_toolbar.link.tooltip,secondaryTooltip:pg(r.formatting_toolbar.link.secondary_tooltip,r.generic.ctrl_shortcut),icon:(0,O.jsx)(lO,{}),onClick:()=>l(!s)})}),(0,O.jsx)(n.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,O.jsx)(GO,{url:u.url||``,text:u.text,range:u.range,showTextField:!1,setToolbarOpen:e=>a.store.setState(e)})})]})},JO=()=>{let e=W(),t=U(),n=mE(),r=H(),i=cE({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(hy(n,e,n.type,{url:`string`,caption:`string`}))return n}}),[a,o]=(0,D.useState)(!1),s=(0,D.useCallback)(e=>{e||r.focus(),o(e)},[r]),c=(0,D.useCallback)(e=>{i!==void 0&&my(r,i.type,{caption:`string`})&&r.updateBlock(i.id,{props:{caption:e.currentTarget.value}})},[i,r]);return i===void 0?null:(0,O.jsxs)(t.Generic.Popover.Root,{open:a,onOpenChange:s,portalElement:n,children:[(0,O.jsx)(t.Generic.Popover.Trigger,{children:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_caption.tooltip,mainTooltip:e.formatting_toolbar.file_caption.tooltip,icon:(0,O.jsx)(fO,{}),onClick:()=>s(!a)})}),(0,O.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,O.jsx)(t.Generic.Form.Root,{onSubmit:()=>s(!1),submitButton:(0,O.jsx)(UO,{}),children:(0,O.jsx)(t.Generic.Form.TextInput,{name:`file-caption`,icon:(0,O.jsx)(fO,{}),value:i.props.caption,autoFocus:!0,placeholder:e.formatting_toolbar.file_caption.input_placeholder,onChange:c})})})]})},YO=()=>{let e=W(),t=U(),n=H(),r=cE({editor:n,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(hy(n,e,n.type,{url:`string`}))return n}}),i=(0,D.useCallback)(()=>{r!==void 0&&(n.focus(),n.removeBlocks([r.id]))},[r,n]);return r===void 0?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_delete.tooltip[r.type]||e.formatting_toolbar.file_delete.tooltip.file,mainTooltip:e.formatting_toolbar.file_delete.tooltip[r.type]||e.formatting_toolbar.file_delete.tooltip.file,icon:(0,O.jsx)(WD,{}),onClick:i})},XO=()=>{let e=W(),t=U(),n=mE(),r=H(),i=cE({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(hy(n,e,n.type,{url:`string`,name:`string`}))return n}}),[a,o]=(0,D.useState)(!1),s=(0,D.useCallback)(e=>{e||r.focus(),o(e)},[r]),c=(0,D.useCallback)(e=>{i!==void 0&&my(r,i.type,{name:`string`})&&r.updateBlock(i.id,{props:{name:e.currentTarget.value}})},[i,r]);return i===void 0?null:(0,O.jsxs)(t.Generic.Popover.Root,{open:a,onOpenChange:s,portalElement:n,children:[(0,O.jsx)(t.Generic.Popover.Trigger,{children:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_rename.tooltip[i.type]||e.formatting_toolbar.file_rename.tooltip.file,mainTooltip:e.formatting_toolbar.file_rename.tooltip[i.type]||e.formatting_toolbar.file_rename.tooltip.file,icon:(0,O.jsx)(xO,{}),onClick:()=>s(!a)})}),(0,O.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,O.jsx)(t.Generic.Form.Root,{onSubmit:()=>s(!1),submitButton:(0,O.jsx)(UO,{}),children:(0,O.jsx)(t.Generic.Form.TextInput,{name:`file-name`,icon:(0,O.jsx)(xO,{}),value:i.props.name,autoFocus:!0,placeholder:e.formatting_toolbar.file_rename.input_placeholder[i.type]||e.formatting_toolbar.file_rename.input_placeholder.file,onChange:c})})})]})},ZO=()=>{let e=W(),t=U(),n=mE(),r=H(),i=cE({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(hy(n,e,n.type,{url:`string`}))return n}});return i===void 0?null:(0,O.jsxs)(t.Generic.Popover.Root,{onOpenChange:e=>{e||r.focus()},portalElement:n,children:[(0,O.jsx)(t.Generic.Popover.Trigger,{children:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,mainTooltip:e.formatting_toolbar.file_replace.tooltip[i.type]||e.formatting_toolbar.file_replace.tooltip.file,label:e.formatting_toolbar.file_replace.tooltip[i.type]||e.formatting_toolbar.file_replace.tooltip.file,icon:(0,O.jsx)(YD,{})})}),(0,O.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-panel-popover`,variant:`panel-popover`,children:(0,O.jsx)(SD,{blockId:i.id})})]})},QO=()=>{let e=W(),t=U(),n=H(),r=cE({editor:n,selector:({editor:e})=>{if(e.isEditable&&(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return{canNestBlock:e.canNestBlock()}}}),i=(0,D.useCallback)(()=>{r!==void 0&&r.canNestBlock&&(n.focus(),n.nestBlock())},[n,r]);return r===void 0?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,"data-test":`nestBlock`,onClick:i,isDisabled:!r.canNestBlock,label:e.formatting_toolbar.nest.tooltip,mainTooltip:e.formatting_toolbar.nest.tooltip,secondaryTooltip:pg(e.formatting_toolbar.nest.secondary_tooltip,e.generic.ctrl_shortcut),icon:(0,O.jsx)(pO,{})})},$O=()=>{let e=W(),t=U(),n=H(),r=cE({editor:n,selector:({editor:e})=>{if(e.isEditable&&(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return{canUnnestBlock:e.canUnnestBlock()}}}),i=(0,D.useCallback)(()=>{r!==void 0&&r.canUnnestBlock&&(n.focus(),n.unnestBlock())},[n,r]);return r===void 0?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,"data-test":`unnestBlock`,onClick:i,isDisabled:!r.canUnnestBlock,label:e.formatting_toolbar.unnest.tooltip,mainTooltip:e.formatting_toolbar.unnest.tooltip,secondaryTooltip:pg(e.formatting_toolbar.unnest.secondary_tooltip,e.generic.ctrl_shortcut),icon:(0,O.jsx)(mO,{})})},ek=e=>[{name:e.slash_menu.paragraph.title,type:`paragraph`,icon:eO},{name:e.slash_menu.heading.title,type:`heading`,props:{level:1,isToggleable:!1},icon:bO},{name:e.slash_menu.heading_2.title,type:`heading`,props:{level:2,isToggleable:!1},icon:yO},{name:e.slash_menu.heading_3.title,type:`heading`,props:{level:3,isToggleable:!1},icon:vO},{name:e.slash_menu.heading_4.title,type:`heading`,props:{level:4,isToggleable:!1},icon:_O},{name:e.slash_menu.heading_5.title,type:`heading`,props:{level:5,isToggleable:!1},icon:gO},{name:e.slash_menu.heading_6.title,type:`heading`,props:{level:6,isToggleable:!1},icon:hO},{name:e.slash_menu.toggle_heading.title,type:`heading`,props:{level:1,isToggleable:!0},icon:bO},{name:e.slash_menu.toggle_heading_2.title,type:`heading`,props:{level:2,isToggleable:!0},icon:yO},{name:e.slash_menu.toggle_heading_3.title,type:`heading`,props:{level:3,isToggleable:!0},icon:vO},{name:e.slash_menu.quote.title,type:`quote`,icon:rO},{name:e.slash_menu.toggle_list.title,type:`toggleListItem`,icon:JD},{name:e.slash_menu.bullet_list.title,type:`bulletListItem`,icon:oO},{name:e.slash_menu.numbered_list.title,type:`numberedListItem`,icon:sO},{name:e.slash_menu.check_list.title,type:`checkListItem`,icon:cO}],tk=e=>{let t=U(),n=LO(),r=mE(),i=H(),a=cE({editor:i,selector:({editor:e})=>e.getSelection()?.blocks||[e.getTextCursorPosition().block]}),o=a[0],s=(0,D.useMemo)(()=>(e.items||ek(i.dictionary)).filter(e=>my(i,e.type,Object.fromEntries(Object.entries(e.props||{}).map(([e,t])=>[e,typeof t])))),[i,e.items]),c=(0,D.useMemo)(()=>s.map(e=>{let t=e.icon,n=e.type===o.type,r=Object.entries(e.props||{}).filter(([e,t])=>t!==o.props[e]).length===0;return{text:e.name,icon:(0,O.jsx)(t,{size:16}),onClick:()=>{i.focus(),i.transact(()=>{for(let t of a)i.updateBlock(t,{type:e.type,props:e.props})})},isSelected:n&&r}}),[i,s,o.props,o.type,a]);return!(0,D.useMemo)(()=>c.find(e=>e.isSelected)!==void 0,[c])||!i.isEditable?null:(0,O.jsx)(t.FormattingToolbar.Select,{className:`bn-select`,items:c,portalElement:r,preventFocusOnOpen:n===`mobile`})},nk=()=>{let e=W(),t=U(),n=H(),r=iE(`comments`),{store:i}=iE(vy),a=cE({editor:n,selector:({editor:e})=>e.prosemirrorState.selection.empty}),o=(0,D.useCallback)(()=>{r.startPendingComment(),i.setState(!1)},[r,i]);return a?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.comment.tooltip,mainTooltip:e.formatting_toolbar.comment.tooltip,icon:(0,O.jsx)(AO,{}),onClick:o})},rk=()=>H().getExtension(`comments`)?(0,O.jsx)(nk,{}):null,ik=()=>{let e=W(),t=U(),n=H(),r=cE({editor:n,selector:({editor:e})=>e.prosemirrorState.selection.empty}),i=(0,D.useCallback)(()=>{n._tiptapEditor.chain().focus().addPendingComment().run()},[n]);return!n._tiptapEditor.commands.addPendingComment||!n.isEditable||r?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.comment.tooltip,mainTooltip:e.formatting_toolbar.comment.tooltip,icon:(0,O.jsx)(AO,{}),onClick:i})};function ak(e,t){try{let n=new URL(e,t);if(n.protocol!==`javascript:`)return n.href}catch{}return`#`}var ok=()=>{let e=W(),t=U(),n=H(),r=cE({editor:n,selector:({editor:e})=>{let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(hy(n,e,n.type,{url:`string`}))return n}}),i=(0,D.useCallback)(()=>{r!==void 0&&(n.focus(),n.resolveFileUrl?n.resolveFileUrl(r.props.url).then(e=>window.open(ak(e,window.location.href))):window.open(ak(r.props.url,window.location.href)))},[r,n]);return r===void 0?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_download.tooltip[r.type]||e.formatting_toolbar.file_download.tooltip.file,mainTooltip:e.formatting_toolbar.file_download.tooltip[r.type]||e.formatting_toolbar.file_download.tooltip.file,icon:(0,O.jsx)(HD,{}),onClick:i})},sk=()=>{let e=W(),t=U(),n=H(),r=cE({editor:n,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(hy(n,e,n.type,{url:`string`,showPreview:`boolean`}))return n}}),i=(0,D.useCallback)(()=>{r!==void 0&&my(n,r.type,{showPreview:`boolean`})&&n.updateBlock(r.id,{props:{showPreview:!r.props.showPreview}})},[r,n]);return r===void 0?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:`Toggle preview`,mainTooltip:e.formatting_toolbar.file_preview_toggle.tooltip,icon:(0,O.jsx)(XD,{}),isSelected:r.props.showPreview,onClick:i})},ck=()=>{let e=W(),t=U(),n=H(),r=iE(Hx),i=cE({editor:n,selector:({editor:e})=>{if(!e.isEditable||!e.settings.tables.splitCells)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(n.type===`table`)return{mergeDirection:r.getMergeDirection(n)}}}),a=(0,D.useCallback)(()=>{r?.mergeCells()},[r]);return i===void 0?null:(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.table_cell_merge.tooltip,mainTooltip:e.formatting_toolbar.table_cell_merge.tooltip,icon:i.mergeDirection===`horizontal`?(0,O.jsx)(aO,{}):(0,O.jsx)(iO,{}),onClick:a})},lk=()=>H().getExtension(Hx)?(0,O.jsx)(ck,{}):null,uk={left:TO,center:DO,right:wO,justify:EO},dk=e=>{let t=U(),n=W(),r=H(),i=cE({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block],n=t[0];if(hy(n,e,n.type,{textAlignment:Z_.textAlignment}))return{textAlignment:n.props.textAlignment,blocks:t};if(t.length===1&&hy(n,e,`table`))return e.getExtension(Hx)?.getCellSelection()?{textAlignment:og(n.content.rows[0].cells[0]).props.textAlignment,blocks:[n]}:void 0}}),a=(0,D.useCallback)(e=>{if(i!==void 0){r.focus();for(let t of i.blocks)if(hy(t,r,t.type,{textAlignment:Z_.textAlignment})&&my(r,t.type,{textAlignment:Z_.textAlignment}))r.updateBlock(t,{props:{textAlignment:e}});else if(t.type===`table`){let n=r.getExtension(Hx)?.getCellSelection();if(!n)continue;let i=t.content.rows.map(e=>({...e,cells:e.cells.map(e=>og(e))}));n.cells.forEach(({row:t,col:n})=>{i[t].cells[n].props.textAlignment=e}),r.updateBlock(t,{type:`table`,content:{...t.content,type:`tableContent`,rows:i}}),r.setTextCursorPosition(t)}}},[r,i]);if(i===void 0)return null;let o=uk[e.textAlignment];return(0,O.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,"data-test":`alignText${e.textAlignment.slice(0,1).toUpperCase()+e.textAlignment.slice(1)}`,onClick:()=>a(e.textAlignment),isSelected:i.textAlignment===e.textAlignment,label:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,mainTooltip:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,icon:(0,O.jsx)(o,{})})},fk=e=>[(0,O.jsx)(tk,{items:e},`blockTypeSelect`),(0,O.jsx)(lk,{},`tableCellMergeButton`),(0,O.jsx)(JO,{},`fileCaptionButton`),(0,O.jsx)(ZO,{},`replaceFileButton`),(0,O.jsx)(XO,{},`fileRenameButton`),(0,O.jsx)(YO,{},`fileDeleteButton`),(0,O.jsx)(ok,{},`fileDownloadButton`),(0,O.jsx)(sk,{},`filePreviewButton`),(0,O.jsx)(FO,{basicTextStyle:`bold`},`boldStyleButton`),(0,O.jsx)(FO,{basicTextStyle:`italic`},`italicStyleButton`),(0,O.jsx)(FO,{basicTextStyle:`underline`},`underlineStyleButton`),(0,O.jsx)(FO,{basicTextStyle:`strike`},`strikeStyleButton`),(0,O.jsx)(dk,{textAlignment:`left`},`textAlignLeftButton`),(0,O.jsx)(dk,{textAlignment:`center`},`textAlignCenterButton`),(0,O.jsx)(dk,{textAlignment:`right`},`textAlignRightButton`),(0,O.jsx)(HO,{},`colorStyleButton`),(0,O.jsx)(QO,{},`nestBlockButton`),(0,O.jsx)($O,{},`unnestBlockButton`),(0,O.jsx)(qO,{},`createLinkButton`),(0,O.jsx)(rk,{},`addCommentButton`),(0,O.jsx)(ik,{},`addTiptapCommentButton`)],pk=e=>{let t=U();return(0,O.jsx)(t.FormattingToolbar.Root,{className:`bn-toolbar bn-formatting-toolbar`,children:e.children||fk(e.blockTypeSelectItems)})},mk=e=>{switch(e){case`left`:return`top-start`;case`center`:return`top`;case`right`:return`top-end`;default:return`top-start`}},hk=e=>{let t=H(),n=iE(vy,{editor:t}),r=aE(vy,{editor:t}),i=cE({editor:t,selector:({editor:e})=>n.store.state?{from:e.prosemirrorState.selection.from,to:e.prosemirrorState.selection.to}:void 0}),a=cE({editor:t,selector:({editor:e})=>{let t=e.getTextCursorPosition().block;return hy(t,e,t.type,{textAlignment:Z_.textAlignment})?mk(t.props.textAlignment):`top-start`}}),o=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:r,onOpenChange:(e,r,i)=>{n.store.setState(e),i===`escape-key`&&t.focus()},placement:a,middleware:[p(10),w(),S()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:40},...e.floatingUIOptions?.elementProps}}),[r,a,e.floatingUIOptions,n.store,t]),s=e.formattingToolbar||pk;return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(TE,{position:i,...o,children:r&&(0,O.jsx)(s,{})})})};function gk(e,t){let n=eE(),r=t??n?.editor;if(!r)throw Error(`'editor' is required, either from BlockNoteContext or as a function argument`);let i=e?.includeEditorUI??!1,a=(0,D.useRef)(void 0);(a.current===void 0||a.current.editor!==r||a.current.includeEditorUI!==i)&&(a.current={editor:r,includeEditorUI:i,value:r.isFocused({includeEditorUI:i})});let o=(0,D.useCallback)(e=>(a.current={editor:r,includeEditorUI:i,value:r.isFocused({includeEditorUI:i})},e(),r.onFocusChange((t,n)=>{a.current={editor:r,includeEditorUI:i,value:n.focused},e()},{includeEditorUI:i})),[r,i]),s=(0,D.useCallback)(()=>a.current.value,[]);return(0,D.useSyncExternalStore)(o,s,s)}var _k=0,vk=0;function yk(){if(typeof window>`u`)return!1;let e=window.visualViewport,t=e?.scale??1,n=(e?.height??window.innerHeight)*t,r=document.documentElement.clientWidth;return Math.abs(r-vk)>vk*.2&&(vk=r,_k=0),_k=Math.max(_k,n),_k-n>150}var bk=[`--bn-vv-top`,`--bn-vv-left`,`--bn-vv-width`,`--bn-vv-height`,`--bn-vv-scale`],xk=0;function Sk(){let[e,t]=(0,D.useState)(yk);return(0,D.useLayoutEffect)(()=>{let e=document.documentElement,n=window.visualViewport,r=()=>document.querySelectorAll(`.bn-scroll-container`),i=()=>{e.style.setProperty(`--bn-vv-top`,`${n?.offsetTop??0}px`),e.style.setProperty(`--bn-vv-left`,`${n?.offsetLeft??0}px`),e.style.setProperty(`--bn-vv-width`,`${n?.width??window.innerWidth}px`),e.style.setProperty(`--bn-vv-height`,`${n?.height??window.innerHeight}px`),e.style.setProperty(`--bn-vv-scale`,`${n?.scale??1}`)},a=(e,t)=>e.toggleAttribute(`data-bn-allow-pull-to-refresh`,!t&&e.scrollTop<=0),o=()=>{let e=yk();t(e),i();for(let t of r())a(t,e)};xk++,o(),n?.addEventListener(`resize`,o),n?.addEventListener(`scroll`,o),window.addEventListener(`resize`,o);let s=e=>{e.target instanceof HTMLElement&&e.target.classList.contains(`bn-scroll-container`)&&a(e.target,yk())};return document.addEventListener(`scroll`,s,{capture:!0,passive:!0}),()=>{if(n?.removeEventListener(`resize`,o),n?.removeEventListener(`scroll`,o),window.removeEventListener(`resize`,o),document.removeEventListener(`scroll`,s,{capture:!0}),xk--,xk===0){for(let t of bk)e.style.removeProperty(t);for(let e of r())e.removeAttribute(`data-bn-allow-pull-to-refresh`);_k=0,vk=0}}},[]),e}var Ck=e=>{let t=Sk(),n=gk({includeEditorUI:!0});return!t||!n?null:(0,O.jsx)(gE,{target:document.body,children:(0,O.jsx)(IO.Provider,{value:`mobile`,children:(0,O.jsx)(wk,{formattingToolbar:e.formattingToolbar||pk})})})};function wk(e){let t=mE(),n=e.formattingToolbar;return t?(0,RE.createPortal)((0,O.jsx)(bE,{children:(0,O.jsx)(`div`,{className:`bn-mobile-formatting-toolbar`,children:(0,O.jsx)(n,{})})}),t):null}var Tk=e=>{let t=Sk();return gg()&&t?(0,O.jsx)(Ck,{formattingToolbar:e.formattingToolbar}):(0,O.jsx)(hk,{...e})},Ek=e=>{let t=U(),n=W(),{deleteLink:r}=iE(gb);return(0,O.jsx)(t.LinkToolbar.Button,{className:`bn-button`,label:n.link_toolbar.delete.tooltip,mainTooltip:n.link_toolbar.delete.tooltip,isSelected:!1,onClick:()=>{r(e.range.from),e.setToolbarOpen?.(!1)},icon:(0,O.jsx)(uO,{})})},Dk=e=>{let t=U(),n=mE(),r=W();return(0,O.jsxs)(t.Generic.Popover.Root,{onOpenChange:e.setToolbarPositionFrozen,portalElement:n,children:[(0,O.jsx)(t.Generic.Popover.Trigger,{children:(0,O.jsx)(t.LinkToolbar.Button,{className:`bn-button`,mainTooltip:r.link_toolbar.edit.tooltip,isSelected:!1,children:r.link_toolbar.edit.text})}),(0,O.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,O.jsx)(GO,{url:e.url,text:e.text,range:e.range,setToolbarOpen:e.setToolbarOpen,setToolbarPositionFrozen:e.setToolbarPositionFrozen})})]})},Ok=e=>{let t=U(),n=W();return(0,O.jsx)(t.LinkToolbar.Button,{className:`bn-button`,mainTooltip:n.link_toolbar.open.tooltip,label:n.link_toolbar.open.tooltip,isSelected:!1,onClick:()=>{window.open(ak(e.url,window.location.href),`_blank`)},icon:(0,O.jsx)(VD,{})})},kk=e=>{let t=U();return(0,O.jsx)(t.LinkToolbar.Root,{className:`bn-toolbar bn-link-toolbar`,children:e.children||(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Dk,{url:e.url,text:e.text,range:e.range,setToolbarOpen:e.setToolbarOpen,setToolbarPositionFrozen:e.setToolbarPositionFrozen}),(0,O.jsx)(Ok,{url:e.url}),(0,O.jsx)(Ek,{range:e.range,setToolbarOpen:e.setToolbarOpen})]})})},Ak=e=>{let t=H(),[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(!1),o=lE(),s=iE(gb),[c,l]=(0,D.useState)(void 0);(0,D.useEffect)(()=>{let e=()=>{let e=s.getLinkAtSelection();e?(l({cursorType:`text`,url:e.mark.attrs.href,text:e.text,range:e.range,element:s.getLinkElementAtPos(e.range.from)}),i||r(!0)):(l(void 0),i||r(!1))},n=e=>{if(c!==void 0&&c.cursorType===`text`||!(e.target instanceof HTMLElement))return;let t=s.getLinkAtElement(e.target);t&&l({cursorType:`mouse`,url:t.mark.attrs.href,text:t.text,range:t.range,element:s.getLinkElementAtPos(t.range.from)})},a=t.onChange(e),u=t.onSelectionChange(e);return o?.addEventListener(`mouseover`,n),()=>{a(),u(),o?.removeEventListener(`mouseover`,n)}},[t,o,s,c,i]);let u=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:n,onOpenChange:(e,n,a)=>{i||(c===void 0||c.cursorType!==`text`||a!==`hover`)&&(a===`escape-key`&&t.focus(),r(e))},placement:`top-start`,middleware:[p(10),S()],...e.floatingUIOptions?.useFloatingOptions},useHoverProps:{enabled:c!==void 0&&c.cursorType===`mouse`,delay:{open:250,close:250},handleClose:d(),...e.floatingUIOptions?.useHoverProps},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:50},...e.floatingUIOptions?.elementProps}}),[t,c,e.floatingUIOptions,n,i]),f=(0,D.useMemo)(()=>c?.element?{element:c.element}:void 0,[c?.element]);if(!t.isEditable)return null;let m=e.linkToolbar||kk;return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(CE,{reference:f,...u,children:c&&(0,O.jsx)(m,{url:c.url,text:c.text,range:c.range,setToolbarOpen:r,setToolbarPositionFrozen:a})})})};function jk(e){return G({tag:`svg`,attr:{viewBox:`0 0 1024 1024`},child:[{tag:`path`,attr:{d:`M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8Z`},child:[]},{tag:`path`,attr:{d:`M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8Z`},child:[]}]})(e)}var Mk=()=>{let e=U(),t=W(),n=H(),r=iE(Cy),i=aE(Sx,{editor:n,selector:e=>e?.block}),a=(0,D.useCallback)(()=>{if(i===void 0)return;let e=i.content;if(e!==void 0&&Array.isArray(e)&&e.length===0)n.setTextCursorPosition(i),r.openSuggestionMenu(`/`);else{let e=n.insertBlocks([{type:`paragraph`}],i,`after`)[0];n.setTextCursorPosition(e),r.openSuggestionMenu(`/`)}},[i,n,r]);return i===void 0?null:(0,O.jsx)(e.SideMenu.Button,{className:`bn-button`,label:t.side_menu.add_block_label,icon:(0,O.jsx)(jk,{size:24,onClick:a,"data-test":`dragHandleAdd`})})};function Nk(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`m7 10 5 5 5-5z`},child:[]}]})(e)}function Pk(e){return G({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0V0z`},child:[]},{tag:`path`,attr:{d:`M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z`},child:[]}]})(e)}var Fk=e=>{let t=U(),n=mE(),r=H(),i=aE(Sx,{editor:r,selector:e=>e?.block});return i===void 0||!hy(i,r,i.type,{textColor:`string`})&&!hy(i,r,i.type,{backgroundColor:`string`})?null:(0,O.jsxs)(t.Generic.Menu.Root,{position:`right`,sub:!0,portalElement:n,children:[(0,O.jsx)(t.Generic.Menu.Trigger,{sub:!0,children:(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,subTrigger:!0,children:e.children})}),(0,O.jsx)(t.Generic.Menu.Dropdown,{sub:!0,className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,O.jsx)(BO,{iconSize:18,text:hy(i,r,i.type,{textColor:`string`})&&my(r,i.type,{textColor:`string`})?{color:i.props.textColor,setColor:e=>r.updateBlock(i,{type:i.type,props:{textColor:e}})}:void 0,background:hy(i,r,i.type,{backgroundColor:`string`})&&my(r,i.type,{backgroundColor:`string`})?{color:i.props.backgroundColor,setColor:e=>r.updateBlock(i,{props:{backgroundColor:e}})}:void 0})})]})},Ik=e=>{let t=U(),n=H(),r=aE(Sx,{editor:n,selector:e=>e?.block});return r===void 0?null:(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,onClick:()=>{let e=n.getSelection()?.blocks,t=e&&e.some(e=>e.id===r.id)?e:[r];n.removeBlocks(t)},children:e.children})},Lk=e=>{let t=U(),n=H(),r=aE(Sx,{editor:n,selector:e=>e?.block});if(r===void 0||r.type!==`table`||!n.settings.tables.headers)return null;let i=!!r.content.headerRows;return(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:i,onClick:()=>{n.updateBlock(r,{content:{...r.content,headerRows:i?void 0:1}})},children:e.children})},Rk=e=>{let t=U(),n=H(),r=aE(Sx,{editor:n,selector:e=>e?.block});if(r===void 0||r.type!==`table`||!n.settings.tables.headers)return null;let i=!!r.content.headerCols;return(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:i,onClick:()=>{n.updateBlock(r,{content:{...r.content,headerCols:i?void 0:1}})},children:e.children})},zk=e=>{let t=U(),n=W();return(0,O.jsx)(t.Generic.Menu.Dropdown,{className:`bn-menu-dropdown bn-drag-handle-menu`,children:e.children||(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Ik,{children:n.drag_handle.delete_menuitem}),(0,O.jsx)(Fk,{children:n.drag_handle.colors_menuitem}),(0,O.jsx)(Lk,{children:n.drag_handle.header_row_menuitem}),(0,O.jsx)(Rk,{children:n.drag_handle.header_column_menuitem})]})})},Bk=e=>{let t=U(),n=mE(),r=W(),i=iE(Sx),a=aE(Sx,{selector:e=>e?.block});if(a===void 0)return null;let o=e.dragHandleMenu||zk;return(0,O.jsxs)(t.Generic.Menu.Root,{onOpenChange:e=>{e?i.freezeMenu():i.unfreezeMenu()},position:`left`,portalElement:n,children:[(0,O.jsx)(t.Generic.Menu.Trigger,{children:(0,O.jsx)(t.SideMenu.Button,{label:r.side_menu.drag_handle_label,draggable:!0,onDragStart:e=>i.blockDragStart(e,a),onDragEnd:i.blockDragEnd,className:`bn-button`,icon:(0,O.jsx)(Pk,{size:24,"data-test":`dragHandle`})})}),(0,O.jsx)(o,{children:e.children})]})},Vk=e=>{let t=U();return(0,O.jsx)(t.SideMenu.Root,{className:`bn-side-menu`,children:e.children||(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Mk,{}),(0,O.jsx)(Bk,{dragHandleMenu:e.dragHandleMenu})]})})};function Hk(e,t){if(t.type===`heading`)switch(t.props.level){case 1:return 39;case 2:return 27;case 3:return 18.5;default:return 0}return e.schema.blockSpecs[t.type]?.implementation.meta?.fileBlockAccept&&!t.props.url?12:t.type===`file`?4:t.type===`audio`||t.type===`table`?15:0}var Uk=e=>{let t=H(),{show:n,block:r}=aE(Sx,{selector:e=>e===void 0?void 0:{show:e.show,block:e.block}})||{},i=(0,D.useCallback)((e,n,r)=>{let i=!1;return ie(e,n,()=>{i?t.getExtension(Sx)?.hideMenuIfNotFrozen():i=!0},{ancestorScroll:!0,ancestorResize:!1,elementResize:!1,layoutShift:!1})},[t]),a=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:n,placement:`left-start`,middleware:[p({crossAxis:r?Hk(t,r):0})],whileElementsMounted:i,...e.floatingUIOptions?.useFloatingOptions},useDismissProps:{enabled:!1,...e.floatingUIOptions?.useDismissProps},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:20},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,n,r,t,i]),o=e.sideMenu||Vk;return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(yD,{blockId:n?r?.id:void 0,...a,children:r?.id&&(0,O.jsx)(o,{})})})},Wk=({format:e,dictionary:t})=>{let n=t.suggestion_changes.formatting_change;if(e.length===0)return n;let r=t.formatting_toolbar,i=[];for(let t of e){let e=r[t],a=e&&typeof e==`object`&&`tooltip`in e?e.tooltip:void 0;if(typeof a!=`string`)return n;i.push(a)}return i.join(`, `)},Gk=e=>{let t=U(),n=W(),r=(0,D.useMemo)(()=>{let t=n.suggestion_changes,r=e.formatChangeLabel??Wk,i=e.users.join(`, `);if(e.modificationType===`insert`)return t.inserted_by(i);if(e.modificationType===`delete`)return t.deleted_by(i);let a=e.format?r({format:e.format,dictionary:n}):``;return t.formatting_change_by(a,i)},[n,e.formatChangeLabel,e.users,e.modificationType,e.format]);return(0,O.jsx)(t.AttributionTooltip.Root,{className:`bn-suggestion-tooltip`,markClassName:e.className,backgroundColor:e.className?void 0:e.color,children:r})},Kk=e=>{let t=aE(`attribution`,{selector:e=>e}),n=(0,D.useMemo)(()=>t?{element:t.anchor,getBoundingClientRect:()=>{let e=t.anchor.firstElementChild??t.anchor,n=e.getBoundingClientRect();return(n.width||n.height?e:e.firstElementChild??e).getBoundingClientRect()},getClientRects:()=>{let e=t.anchor.firstElementChild??t.anchor,n=e.getBoundingClientRect();return(n.width||n.height?e:e.firstElementChild??e).getClientRects()}}:void 0,[t]),r=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!t,placement:`top-start`,middleware:[u(),p(4),S(),w({padding:4})],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:1e4,pointerEvents:`none`},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,t]),i=e.attributionTooltip||Gk,a=(0,D.useMemo)(()=>t?{color:t.color,className:t.className,modificationType:t.modificationType,contentType:t.contentType,users:t.users,format:t.format,formatChangeLabel:e.formatChangeLabel}:void 0,[t,e.formatChangeLabel]);return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(CE,{reference:n,...r,children:a&&(0,O.jsx)(i,{...a})})})};async function qk(e,t){return(await Nx(e,t)).map(({id:e,onItemClick:t})=>({id:e,onItemClick:t,icon:e}))}function Jk(e){let t=U(),n=W(),{items:r,loadingState:i,selectedIndex:a,onItemClick:o,columns:s}=e,c=i===`loading-initial`||i===`loading`?(0,O.jsx)(t.GridSuggestionMenu.Loader,{className:`bn-grid-suggestion-menu-loader`,columns:s}):null,l=(0,D.useMemo)(()=>{let e=[];for(let n=0;n<r.length;n++){let i=r[n];e.push((0,O.jsx)(t.GridSuggestionMenu.Item,{className:`bn-grid-suggestion-menu-item`,item:i,id:`bn-grid-suggestion-menu-item-${n}`,isSelected:n===a,onClick:()=>o?.(i)},i.id))}return e},[t,r,o,a]);return(0,O.jsxs)(t.GridSuggestionMenu.Root,{id:`bn-grid-suggestion-menu`,columns:s,className:`bn-grid-suggestion-menu`,children:[c,l,l.length===0&&e.loadingState===`loaded`&&(0,O.jsx)(t.GridSuggestionMenu.EmptyItem,{className:`bn-grid-suggestion-menu-empty-item`,columns:s,children:n.suggestion_menu.no_items_title})]})}function Yk(e){return e===void 0?void 0:`bn-suggestion-menu-item-`+e}function Xk(e,t,n,r=3){let i=(0,D.useRef)(0);(0,D.useEffect)(()=>{t!==void 0&&(e.length>0?i.current=t.length:t.length-i.current>r&&n())},[n,r,e.length,t])}function Zk(e,t){let[n,r]=(0,D.useState)([]),[i,a]=(0,D.useState)(!1),o=(0,D.useRef)(void 0),s=(0,D.useRef)(void 0);return(0,D.useEffect)(()=>{let n=e;o.current=e,a(!0),t(e).then(e=>{o.current===n&&(r(e),a(!1),s.current=n)})},[e,t]),{items:n||[],usedQuery:s.current,loadingState:s.current===void 0?`loading-initial`:i?`loading`:`loaded`}}function Qk(e,t,n,r,i){let a=lE(e),[o,s]=(0,D.useState)(0);return(0,D.useEffect)(()=>{let e=e=>(e.key===`ArrowLeft`&&(e.preventDefault(),n.length&&s((o-1+n.length)%n.length)),e.key===`ArrowRight`&&(e.preventDefault(),n.length&&s((o+1+n.length)%n.length)),e.key===`ArrowUp`?(e.preventDefault(),n.length&&s((o-r+n.length)%n.length),!0):e.key===`ArrowDown`?(e.preventDefault(),n.length&&s((o+r)%n.length),!0):e.key===`Enter`&&!e.isComposing&&(e.stopPropagation(),e.preventDefault(),n.length&&i?.(n[o]),!0));return a?.addEventListener(`keydown`,e,!0),()=>{a?.removeEventListener(`keydown`,e,!0)}},[a,n,o,i,r,r!==void 0&&r>1]),(0,D.useEffect)(()=>{s(0)},[t]),{selectedIndex:n.length===0?void 0:o}}function $k(e){let t=eE().setContentEditableProps,n=H(),{getItems:r,gridSuggestionMenuComponent:i,query:a,clearQuery:o,closeMenu:s,onItemClick:c,columns:l}=e,u=(0,D.useCallback)(e=>{s(),o(),c?.(e)},[c,s,o]),{items:d,usedQuery:f,loadingState:p}=Zk(a,r);Xk(d,f,s);let{selectedIndex:m}=Qk(n,a,d,l,u);return(0,D.useEffect)(()=>(t(e=>({...e,"aria-expanded":!0,"aria-controls":`bn-suggestion-menu`})),()=>{t(e=>({...e,"aria-expanded":!1,"aria-controls":void 0}))}),[t]),(0,D.useEffect)(()=>(t(e=>({...e,"aria-activedescendant":Yk(m)})),()=>{t(e=>({...e,"aria-activedescendant":void 0}))}),[t,m]),(0,O.jsx)(i,{items:d,onItemClick:u,loadingState:p,selectedIndex:m,columns:l})}function eA(e){let t=H(),n=lE(),{triggerCharacter:r,gridSuggestionMenuComponent:i,columns:a,shouldOpen:o,minQueryLength:s,onItemClick:c,getItems:l}=e,u=(0,D.useMemo)(()=>c||(e=>{e.onItemClick(t)}),[t,c]),d=(0,D.useMemo)(()=>l||(async e=>await qk(t,e)),[t,l]),f=iE(Cy);(0,D.useEffect)(()=>{f.addSuggestionMenu({triggerCharacter:r,shouldOpen:o})},[f,r,o]);let m=aE(Cy),h=aE(Cy,{selector:e=>({element:n?.firstChild||void 0,getBoundingClientRect:()=>e?.referencePos||new DOMRect})}),_=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:m?.show&&m?.triggerCharacter===r,onOpenChange:e=>{e||f.closeMenu()},placement:`bottom-start`,middleware:[p(10),g({allowedPlacements:[`bottom-start`,`top-start`],padding:10}),w(),T({apply({elements:e,availableHeight:t}){e.floating.style.maxHeight=`${Math.max(0,t)}px`},padding:10})],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{onMouseDownCapture:e=>e.preventDefault(),style:{zIndex:70},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,m?.show,m?.triggerCharacter,f,r]);return!m||!m.ignoreQueryLength&&s&&(m.query.startsWith(` `)||m.query.length<s)?null:(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(CE,{reference:h,..._,children:r&&(0,O.jsx)($k,{query:m.query,closeMenu:f.closeMenu,clearQuery:f.clearQuery,getItems:d,columns:a,gridSuggestionMenuComponent:i||Jk,onItemClick:u})})})}function tA(e){let t=U(),n=W(),{items:r,loadingState:i,selectedIndex:a,onItemClick:o}=e,s=i===`loading-initial`||i===`loading`?(0,O.jsx)(t.SuggestionMenu.Loader,{className:`bn-suggestion-menu-loader`}):null,c=(0,D.useMemo)(()=>{let e,n=[];for(let i=0;i<r.length;i++){let s=r[i];s.group!==e&&(e=s.group,n.push((0,O.jsx)(t.SuggestionMenu.Label,{className:`bn-suggestion-menu-label`,children:e},e))),n.push((0,O.jsx)(t.SuggestionMenu.Item,{className:V(`bn-suggestion-menu-item`,s.size===`small`?`bn-suggestion-menu-item-small`:``),item:s,id:`bn-suggestion-menu-item-${i}`,isSelected:i===a,onClick:()=>o?.(s)},s.title))}return n},[t,r,o,a]);return(0,O.jsxs)(t.SuggestionMenu.Root,{id:`bn-suggestion-menu`,className:`bn-suggestion-menu`,children:[c,c.length===0&&(e.loadingState===`loading`||e.loadingState===`loaded`)&&(0,O.jsx)(t.SuggestionMenu.EmptyItem,{className:`bn-suggestion-menu-item`,children:n.suggestion_menu.no_items_title}),s]})}function nA(e,t){let[n,r]=(0,D.useState)(0);return{selectedIndex:n,setSelectedIndex:r,handler:i=>{if(i.key===`ArrowUp`)return i.preventDefault(),e.length&&r((n-1+e.length)%e.length),!0;if(i.key===`ArrowDown`)return i.preventDefault(),e.length&&r((n+1)%e.length),!0;if(i.key===`PageUp`)return i.preventDefault(),e.length&&r(0),!0;if(i.key===`PageDown`)return i.preventDefault(),e.length&&r(e.length-1),!0;let a=rA(i)?i.nativeEvent.isComposing:i.isComposing;return i.key===`Enter`&&!a&&(i.preventDefault(),i.stopPropagation(),e.length&&t?.(e[n]),!0)}}}function rA(e){return e.nativeEvent!==void 0}function iA(e,t,n,r,i){let a=lE(),{selectedIndex:o,setSelectedIndex:s,handler:c}=nA(n,r);return(0,D.useEffect)(()=>{let e=i||a;return e?.addEventListener(`keydown`,c,!0),()=>{e?.removeEventListener(`keydown`,c,!0)}},[a,n,o,r,i,c]),(0,D.useEffect)(()=>{s(0)},[t,s]),{selectedIndex:n.length===0?void 0:o}}function aA(e){let t=eE().setContentEditableProps,n=H(),{getItems:r,suggestionMenuComponent:i,query:a,clearQuery:o,closeMenu:s,onItemClick:c}=e,l=(0,D.useCallback)(e=>{s(),o(),c?.(e)},[c,s,o]),{items:u,usedQuery:d,loadingState:f}=Zk(a,r);Xk(u,d,s);let{selectedIndex:p}=iA(n,a,u,l);return(0,D.useEffect)(()=>(t(e=>({...e,"aria-expanded":!0,"aria-controls":`bn-suggestion-menu`})),()=>{t(e=>({...e,"aria-expanded":!1,"aria-controls":void 0}))}),[t]),(0,D.useEffect)(()=>(t(e=>({...e,"aria-activedescendant":Yk(p)})),()=>{t(e=>({...e,"aria-activedescendant":void 0}))}),[t,p]),(0,O.jsx)(i,{items:u,onItemClick:l,loadingState:f,selectedIndex:p})}var oA={heading:bO,heading_2:yO,heading_3:vO,heading_4:_O,heading_5:gO,heading_6:hO,toggle_heading:bO,toggle_heading_2:yO,toggle_heading_3:vO,quote:rO,toggle_list:JD,numbered_list:sO,bullet_list:oO,check_list:cO,paragraph:eO,table:tO,image:ZD,video:QD,audio:qD,file:kO,emoji:RD,code_block:SO,divider:zD};function sA(e){return Ey(e).map(e=>{let t=oA[e.key];return{...e,icon:(0,O.jsx)(t,{size:18})}})}function cA(e){let t=H(),n=lE(),{triggerCharacter:r,suggestionMenuComponent:i,shouldOpen:a,minQueryLength:o,onItemClick:s,getItems:c}=e,l=(0,D.useMemo)(()=>s||(e=>{e.onItemClick(t)}),[t,s]),u=(0,D.useMemo)(()=>c||(async e=>Dy(sA(t),e)),[t,c]),d=iE(Cy);(0,D.useEffect)(()=>{d.addSuggestionMenu({triggerCharacter:r,shouldOpen:a})},[d,r,a]);let f=aE(Cy),m=aE(Cy,{selector:e=>({element:n?.firstChild||void 0,getBoundingClientRect:()=>e?.referencePos||new DOMRect})}),h=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:f?.show&&f?.triggerCharacter===r,onOpenChange:e=>{e||d.closeMenu()},placement:`bottom-start`,middleware:[p(10),g({allowedPlacements:[`bottom-start`,`top-start`],padding:10}),w(),T({apply({elements:e,availableHeight:t}){e.floating.style.maxHeight=`${Math.max(0,t)}px`},padding:10})],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{onMouseDownCapture:e=>e.preventDefault(),style:{zIndex:80},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,f?.show,f?.triggerCharacter,d,r]);return!f||!f.ignoreQueryLength&&o&&(f.query.startsWith(` `)||f.query.length<o)?null:(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(CE,{reference:m,...h,children:r&&(0,O.jsx)(aA,{query:f.query,closeMenu:d.closeMenu,clearQuery:d.clearQuery,getItems:u,suggestionMenuComponent:i||tA,onItemClick:l})})})}var lA=(e,t=.3)=>{let n=Math.floor(e)+t,r=Math.ceil(e)-t;return e>=n&&e<=r?Math.round(e):e<n?Math.floor(e):Math.ceil(e)},uA=e=>{let t=U(),n=H(),r=iE(Hx),i=aE(Hx,{selector:e=>e?.block}),a=(0,D.useRef)(!1),[o,s]=(0,D.useState)(),c=(0,D.useCallback)(t=>{r.freezeHandles(),e.hideOtherElements(!0),i&&(s({originalContent:i.content,originalCroppedContent:{rows:r.cropEmptyRowsOrColumns(i,e.orientation===`addOrRemoveColumns`?`columns`:`rows`)},startPos:e.orientation===`addOrRemoveColumns`?t.clientX:t.clientY}),a.current=!1,t.preventDefault())},[i,e,r]),l=(0,D.useCallback)(()=>{!i||a.current||n.updateBlock(i,{type:`table`,content:{...i.content,rows:e.orientation===`addOrRemoveColumns`?r.addRowsOrColumns(i,`columns`,1):r.addRowsOrColumns(i,`rows`,1)}})},[i,n,e.orientation,r]);return(0,D.useEffect)(()=>{let t=t=>{if(!i)return;if(!o)throw Error(`editingState is undefined`);a.current=!0;let s=(e.orientation===`addOrRemoveColumns`?t.clientX:t.clientY)-o.startPos,c=e.orientation===`addOrRemoveColumns`?o.originalCroppedContent.rows[0]?.cells.length??0:o.originalCroppedContent.rows.length,l=e.orientation===`addOrRemoveColumns`?o.originalContent.rows[0]?.cells.length??0:o.originalContent.rows.length,u=e.orientation===`addOrRemoveColumns`?i.content.rows[0].cells.length:i.content.rows.length,d=l+lA(s/(e.orientation===`addOrRemoveColumns`?120:31),.3);d>=c&&d>0&&d!==u&&(n.updateBlock(i,{type:`table`,content:{...i.content,rows:e.orientation===`addOrRemoveColumns`?r.addRowsOrColumns({type:`table`,content:o.originalCroppedContent},`columns`,d-c):r.addRowsOrColumns({type:`table`,content:o.originalCroppedContent},`rows`,d-c)}}),i.content&&n.setTextCursorPosition(i))};return o&&window.addEventListener(`mousemove`,t),()=>{window.removeEventListener(`mousemove`,t)}},[i,o,n,e.orientation,r]),(0,D.useEffect)(()=>{let t=()=>{e.hideOtherElements(!1),r.unfreezeHandles(),s(void 0)};return o&&window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mouseup`,t)}},[o,e,r]),n.isEditable?(0,O.jsx)(t.TableHandle.ExtendButton,{className:V(`bn-extend-button`,e.orientation===`addOrRemoveColumns`?`bn-extend-button-add-remove-columns`:`bn-extend-button-add-remove-rows`,o===null?``:`bn-extend-button-editing`),onClick:l,onMouseDown:c,children:e.children||(0,O.jsx)(KD,{size:18,"data-test":`extendButton`})}):null},dA=e=>{let t=U(),n=mE(),r=W(),i=H(),{block:a,colIndex:o,rowIndex:s}=aE(Hx,{selector:e=>({block:e?.block,colIndex:e?.colIndex,rowIndex:e?.rowIndex})}),c=(e,t)=>{if(a===void 0||o===void 0||s===void 0)return;let n=a.content.rows.map(e=>({...e,cells:e.cells.map(e=>og(e))}));t===`text`?n[s].cells[o].props.textColor=e:n[s].cells[o].props.backgroundColor=e,i.updateBlock(a,{type:`table`,content:{...a.content,rows:n}}),i.setTextCursorPosition(a)};if(a===void 0||o===void 0||s===void 0)return null;let l=a.content.rows[s]?.cells?.[o];return!l||i.settings.tables.cellTextColor===!1&&i.settings.tables.cellBackgroundColor===!1?null:(0,O.jsxs)(t.Generic.Menu.Root,{position:`right`,sub:!0,portalElement:n,children:[(0,O.jsx)(t.Generic.Menu.Trigger,{sub:!0,children:(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,subTrigger:!0,children:e.children||r.drag_handle.colors_menuitem})}),(0,O.jsx)(t.Generic.Menu.Dropdown,{sub:!0,className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,O.jsx)(BO,{iconSize:18,text:i.settings.tables.cellTextColor?{color:cg(l)?l.props.textColor:`default`,setColor:e=>c(e,`text`)}:void 0,background:i.settings.tables.cellBackgroundColor?{color:cg(l)?l.props.backgroundColor:`default`,setColor:e=>c(e,`background`)}:void 0})})]})},fA=()=>{let e=U(),t=W(),n=H(),r=iE(Hx),{block:i,colIndex:a,rowIndex:o}=aE(Hx,{selector:e=>({block:e?.block,colIndex:e?.colIndex,rowIndex:e?.rowIndex})});if(i===void 0||a===void 0||o===void 0)return null;let s=i.content.rows[o]?.cells?.[a];return!s||!cg(s)||ug(s)===1&&lg(s)===1||!n.settings.tables.splitCells?null:(0,O.jsx)(e.Generic.Menu.Item,{onClick:()=>{r.splitCell({row:o,col:a})},children:t.table_handle.split_cell_menuitem})},pA=e=>{let t=U();return(0,O.jsx)(t.Generic.Menu.Dropdown,{className:`bn-menu-dropdown bn-table-handle-menu`,children:e.children||(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(fA,{}),(0,O.jsx)(dA,{})]})})},mA=e=>{let t=U(),n=mE(),r=H(),i=iE(Hx),a=e.tableCellMenu||pA;return!r.settings.tables.splitCells&&!r.settings.tables.cellBackgroundColor&&!r.settings.tables.cellTextColor?null:(0,O.jsxs)(t.Generic.Menu.Root,{onOpenChange:t=>{t?(i.freezeHandles(),e.hideOtherElements(!0)):(i.unfreezeHandles(),e.hideOtherElements(!1),r.focus())},position:`right`,portalElement:n,children:[(0,O.jsx)(t.Generic.Menu.Trigger,{children:(0,O.jsx)(t.Generic.Menu.Button,{className:`bn-table-cell-handle`,children:e.children||(0,O.jsx)(Nk,{size:12,"data-test":`tableCellHandle`})})}),(0,O.jsx)(a,{})]})},hA=e=>{let t=U(),n=W(),r=iE(Hx),i=aE(Hx,{selector:t=>e.orientation===`column`?t?.colIndex:t?.rowIndex});return r===void 0||i===void 0?null:(0,O.jsx)(t.Generic.Menu.Item,{onClick:()=>{r.addRowOrColumn(i,e.orientation===`row`?{orientation:`row`,side:e.side}:{orientation:`column`,side:e.side})},children:n.table_handle[`add_${e.side}_menuitem`]})},gA=e=>{let t=U(),n=W(),r=iE(Hx),i=aE(Hx,{selector:t=>e.orientation===`column`?t?.colIndex:t?.rowIndex});return r===void 0||i===void 0?null:(0,O.jsx)(t.Generic.Menu.Item,{onClick:()=>r.removeRowOrColumn(i,e.orientation),children:e.orientation===`row`?n.table_handle.delete_row_menuitem:n.table_handle.delete_column_menuitem})},_A=e=>{let t=U(),n=mE(),r=W(),i=H(),a=iE(Hx),{block:o,index:s}=aE(Hx,{selector:t=>({block:t?.block,index:e.orientation===`column`?t?.colIndex:t?.rowIndex})}),c=(0,D.useMemo)(()=>a===void 0||o===void 0||s===void 0?[]:e.orientation===`row`?a.getCellsAtRowHandle(o,s):a.getCellsAtColumnHandle(o,s),[o,s,e.orientation,a]),l=(e,t)=>{if(o===void 0)return;let n=o.content.rows.map(e=>({...e,cells:e.cells.map(e=>og(e))}));c.forEach(({row:r,col:i})=>{t===`text`?n[r].cells[i].props.textColor=e:n[r].cells[i].props.backgroundColor=e}),i.updateBlock(o,{type:`table`,content:{...o.content,rows:n}}),i.setTextCursorPosition(o)};if(!c||!c[0]||!a||i.settings.tables.cellTextColor===!1&&i.settings.tables.cellBackgroundColor===!1)return null;let u=og(c[0].cell);return(0,O.jsxs)(t.Generic.Menu.Root,{position:`right`,sub:!0,portalElement:n,children:[(0,O.jsx)(t.Generic.Menu.Trigger,{sub:!0,children:(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,subTrigger:!0,children:e.children||r.drag_handle.colors_menuitem})}),(0,O.jsx)(t.Generic.Menu.Dropdown,{sub:!0,className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,O.jsx)(BO,{iconSize:18,text:i.settings.tables.cellTextColor?{color:c.every(({cell:e})=>cg(e)&&e.props.textColor===u.props.textColor)?u.props.textColor:`default`,setColor:e=>{l(e,`text`)}}:void 0,background:i.settings.tables.cellBackgroundColor?{color:c.every(({cell:e})=>cg(e)&&e.props.backgroundColor===u.props.backgroundColor)?u.props.backgroundColor:`default`,setColor:e=>l(e,`background`)}:void 0})})]})},vA=e=>{let t=U(),n=W(),r=H(),i=iE(Hx),{block:a,index:o}=aE(Hx,{selector:t=>({block:t?.block,index:e.orientation===`column`?t?.colIndex:t?.rowIndex})});if(i===void 0||a===void 0||o!==0||e.orientation!==`row`||!r.settings.tables.headers)return null;let s=!!a.content.headerRows;return(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:s,onClick:()=>{r.updateBlock(a,{...a,content:{...a.content,headerRows:s?void 0:1}})},children:n.drag_handle.header_row_menuitem})},yA=e=>{let t=U(),n=W(),r=H(),i=iE(Hx),a=aE(Hx,{selector:e=>e?.block}),o=aE(Hx,{selector:t=>e.orientation===`column`?t?.colIndex:t?.rowIndex});if(!i||o!==0||!a||e.orientation!==`column`||!r.settings.tables.headers)return null;let s=!!a.content.headerCols;return(0,O.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:s,onClick:()=>{r.updateBlock(a,{...a,content:{...a.content,headerCols:s?void 0:1}})},children:n.drag_handle.header_column_menuitem})},bA=e=>{let t=U();return(0,O.jsx)(t.Generic.Menu.Dropdown,{className:`bn-table-handle-menu`,children:e.children||(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(gA,{orientation:e.orientation}),(0,O.jsx)(hA,{orientation:e.orientation,side:e.orientation===`row`?`above`:`left`}),(0,O.jsx)(hA,{orientation:e.orientation,side:e.orientation===`row`?`below`:`right`}),(0,O.jsx)(vA,{orientation:e.orientation}),(0,O.jsx)(yA,{orientation:e.orientation}),(0,O.jsx)(_A,{orientation:e.orientation})]})})},xA=e=>{let t=H(),n=U(),r=mE(),[i,a]=(0,D.useState)(!1),o=e.tableHandleMenu||bA,s=iE(Hx),c=aE(Hx),l=(0,D.useMemo)(()=>!s||!c||!c.block||c.block.type!==`table`?!1:e.orientation===`column`?s.getCellsAtColumnHandle(c.block,c.colIndex).every(({cell:e})=>lg(e)===1):s.getCellsAtRowHandle(c.block,c.rowIndex).every(({cell:e})=>ug(e)===1),[e.orientation,c,s]);return c?(0,O.jsxs)(n.Generic.Menu.Root,{onOpenChange:n=>{n?(s.freezeHandles(),e.hideOtherElements(!0)):(s.unfreezeHandles(),e.hideOtherElements(!1),t.focus())},position:`right`,portalElement:r,children:[(0,O.jsx)(n.Generic.Menu.Trigger,{children:(0,O.jsx)(n.TableHandle.Root,{className:V(`bn-table-handle`,i?`bn-table-handle-dragging`:``,l?``:`bn-table-handle-not-draggable`),draggable:l,onDragStart:t=>{a(!0),e.hideOtherElements(!0),e.orientation===`column`?s.colDragStart(t):s.rowDragStart(t)},onDragEnd:()=>{s.dragEnd(),e.hideOtherElements(!1),a(!1)},style:e.orientation===`column`?{transform:`rotate(0.25turn)`}:void 0,children:e.children||(0,O.jsx)(Pk,{size:24,"data-test":`tableHandle`})})}),(0,O.jsx)(o,{orientation:e.orientation})]}):null},SA=e=>{let t=H(),[n,r]=(0,D.useState)(),i=aE(Hx),a=(0,D.useMemo)(()=>{let e={};if(i===void 0)return{};let n=R_(i.block.id,t.prosemirrorState.doc);if(!n)return{};let r=n.posBeforeNode+1,a=t.prosemirrorView.domAtPos(r+1).node;if(!(a instanceof Element))return{};if(e.tableReference={element:a},i.rowIndex===void 0||i.colIndex===void 0)return e;let o=t.prosemirrorState.doc.resolve(r+1).posAtIndex(i.rowIndex),s=t.prosemirrorState.doc.resolve(o+1).posAtIndex(i.colIndex),c=t.prosemirrorView.domAtPos(s+1).node;return c instanceof Element?(e.cellReference={element:c},e.rowReference={element:a,getBoundingClientRect:()=>{let e=a.getBoundingClientRect(),t=c.getBoundingClientRect();return new DOMRect(e.x,i.draggingState&&i.draggingState.draggedCellOrientation===`row`?i.draggingState.mousePos-t.height/2:t.y,e.width,t.height)}},e.columnReference={element:a,getBoundingClientRect:()=>{let e=a.getBoundingClientRect(),t=c.getBoundingClientRect();return new DOMRect(i.draggingState&&i.draggingState.draggedCellOrientation===`col`?i.draggingState.mousePos-t.width/2:t.x,e.y,t.width,e.height)}},e):{}},[t,i]),o=(0,D.useCallback)((e,n,r)=>{let i=!1;return ie(e,n,()=>{i?t.getExtension(Hx)?.hideHandlesIfNotFrozen():i=!0},{ancestorScroll:!0,ancestorResize:!1,elementResize:!1,layoutShift:!1})},[t]),s=(0,D.useMemo)(()=>i===void 0?void 0:{rowTableHandle:{useFloatingOptions:{open:i.show&&i.rowIndex!==void 0&&(!n||n===`rowTableHandle`),placement:`left`,middleware:[p(-10)],whileElementsMounted:o},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},columnTableHandle:{useFloatingOptions:{open:i.show&&i.colIndex!==void 0&&(!n||n===`columnTableHandle`),placement:`top`,middleware:[p(-12)],whileElementsMounted:o},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},tableCellHandle:{useFloatingOptions:{open:i.show&&i.rowIndex!==void 0&&i.colIndex!==void 0&&(!n||n===`tableCellHandle`),placement:`top-end`,middleware:[p({mainAxis:-15,crossAxis:-1})],whileElementsMounted:o},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},extendRowsButton:{useFloatingOptions:{open:i.show&&i.showAddOrRemoveRowsButton&&(!n||n===`extendRowsButton`),placement:`bottom`,whileElementsMounted:o,middleware:[T({apply({rects:e,elements:t}){Object.assign(t.floating.style,{width:`${e.reference.width}px`})}})]},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},extendColumnsButton:{useFloatingOptions:{open:i.show&&i.showAddOrRemoveColumnsButton&&(!n||n===`extendColumnsButton`),placement:`right`,whileElementsMounted:o,middleware:[T({apply({rects:e,elements:t}){Object.assign(t.floating.style,{height:`${e.reference.height}px`})}})]},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}}},[n,i,o]);if(!i)return null;let c=e.tableHandle||xA,l=e.extendButton||uA,u=e.tableCellHandle||mA;return(0,O.jsxs)(gE,{target:e.portalElement,children:[(0,O.jsx)(CE,{reference:a?.rowReference,...s?.rowTableHandle,children:i.show&&i.rowIndex!==void 0&&(!n||n===`rowTableHandle`)&&(0,O.jsx)(c,{orientation:`row`,hideOtherElements:e=>r(e?`rowTableHandle`:void 0)})}),(0,O.jsx)(CE,{reference:a?.columnReference,...s?.columnTableHandle,children:i.show&&i.colIndex!==void 0&&(!n||n===`columnTableHandle`)&&(0,O.jsx)(c,{orientation:`column`,hideOtherElements:e=>r(e?`columnTableHandle`:void 0)})}),(0,O.jsx)(CE,{reference:a?.cellReference,...s?.tableCellHandle,children:i.show&&i.rowIndex!==void 0&&i.colIndex!==void 0&&(!n||n===`tableCellHandle`)&&(0,O.jsx)(u,{hideOtherElements:e=>r(e?`tableCellHandle`:void 0)})}),(0,O.jsx)(CE,{reference:a?.tableReference,...s?.extendRowsButton,children:i.show&&i.showAddOrRemoveRowsButton&&(!n||n===`extendRowsButton`)&&(0,O.jsx)(l,{orientation:`addOrRemoveRows`,hideOtherElements:e=>r(e?`extendRowsButton`:void 0)})}),(0,O.jsx)(CE,{reference:a?.tableReference,...s?.extendColumnsButton,children:i.show&&i.showAddOrRemoveColumnsButton&&(!n||n===`extendColumnsButton`)&&(0,O.jsx)(l,{orientation:`addOrRemoveColumns`,hideOtherElements:e=>r(e?`extendColumnsButton`:void 0)})})]})};function CA(e){if(e!==void 0){if(typeof e==`string`){if(typeof document>`u`)return;let t=document.querySelector(e);if(!t){console.warn(`[BlockNote] portalElements selector "${e}" did not match any element`);return}return t}return e}}var wA=(0,D.lazy)(()=>Promise.resolve().then(()=>ej)),TA=(0,D.lazy)(()=>Promise.resolve().then(()=>aj));function EA(e){let t=H();if(!t)throw Error(`BlockNoteDefaultUI must be used within a BlockNoteContext.Provider`);let n=e.portalElements,r=CA(n?.formattingToolbar),i=CA(n?.linkToolbar),a=CA(n?.slashMenu),o=CA(n?.emojiPicker),s=CA(n?.sideMenu),c=CA(n?.filePanel),l=CA(n?.tableHandles),u=CA(n?.comments),d=CA(n?.attributionTooltip);return(0,O.jsxs)(O.Fragment,{children:[t.getExtension(vy)&&e.formattingToolbar!==!1&&(0,O.jsx)(Tk,{portalElement:r}),t.getExtension(gb)&&e.linkToolbar!==!1&&(0,O.jsx)(Ak,{portalElement:i}),t.getExtension(Cy)&&e.slashMenu!==!1&&(0,O.jsx)(cA,{triggerCharacter:`/`,shouldOpen:e=>!e.selection.$from.parent.type.isInGroup(`tableContent`),portalElement:a}),t.getExtension(Cy)&&e.emojiPicker!==!1&&(0,O.jsx)(eA,{triggerCharacter:`:`,columns:10,minQueryLength:2,portalElement:o}),t.getExtension(Sx)&&e.sideMenu!==!1&&(0,O.jsx)(Uk,{portalElement:s}),t.getExtension(rv)&&e.filePanel!==!1&&(0,O.jsx)(CD,{portalElement:c}),t.getExtension(Hx)&&e.tableHandles!==!1&&(0,O.jsx)(SA,{portalElement:l}),t.getExtension(LE)&&e.comments!==!1&&(0,O.jsxs)(D.Suspense,{children:[(0,O.jsx)(wA,{portalElement:u}),(0,O.jsx)(TA,{portalElement:u})]}),t.getExtension(`attribution`)&&e.attributionTooltip!==!1&&(0,O.jsx)(Kk,{portalElement:d})]})}var DA=!1;function OA(){typeof process<`u`||DA||typeof document>`u`||(DA=!0,(document.querySelector(`meta[name="viewport"]`)?.getAttribute(`content`)??``).replace(/\s/g,``).includes(`interactive-widget=resizes-content`)||console.warn(`[BlockNote] This page's viewport meta tag is missing "interactive-widget=resizes-content" in its content attribute. Add it to ensure proper mobile functionality, e.g. <meta name="viewport" content="width=device-width, initial-scale=1, interactive-widget=resizes-content">. See https://www.blocknotejs.org/docs/getting-started#mobile-compatibility for more information`))}function kA(e,t){let n=eE();t||=n?.editor;let r=(0,D.useRef)(e);oE(()=>{r.current=e}),(0,D.useEffect)(()=>{if(!t)throw Error(`'editor' is required, either from BlockNoteContext or as a function argument`);return t.onChange((...e)=>r.current(...e))},[t])}function AA(e,t,n){let r=eE();t||=r?.editor;let i=(0,D.useRef)(e);oE(()=>{i.current=e}),(0,D.useEffect)(()=>{if(!t)throw Error(`'editor' is required, either from BlockNoteContext or as a function argument`);return t.onSelectionChange(e=>i.current(e),n)},[t,n])}var jA=()=>{let e=(0,D.useMemo)(()=>window.matchMedia?.(`(prefers-color-scheme: dark)`),[]),t=(0,D.useMemo)(()=>window.matchMedia?.(`(prefers-color-scheme: light)`),[]),n=e?.matches,r=t?.matches,[i,a]=(0,D.useState)(n?`dark`:r?`light`:`no-preference`);return(0,D.useEffect)(()=>{a(n?`dark`:r?`light`:`no-preference`)},[n,r]),(0,D.useEffect)(()=>{if(typeof e?.addEventListener==`function`){let n=({matches:e})=>e&&a(`dark`),r=({matches:e})=>e&&a(`light`);return e?.addEventListener(`change`,n),t?.addEventListener(`change`,r),()=>{e?.removeEventListener(`change`,n),t?.removeEventListener(`change`,r)}}{let n=()=>a(e.matches?`dark`:t.matches?`light`:`no-preference`);return e?.addEventListener(`change`,n),t?.addEventListener(`change`,n),()=>{e?.removeEventListener(`change`,n),t?.removeEventListener(`change`,n)}}},[e,t]),window.matchMedia,i};function MA(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:(0,RE.createPortal)(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var NA=({contentComponent:e})=>{let t=(0,D.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,O.jsx)(O.Fragment,{children:Object.values(t)})},PA=(0,D.forwardRef)((e,t)=>{let[n,r]=(0,D.useState)();return(0,D.useImperativeHandle)(t,()=>(e,t)=>{(0,RE.flushSync)(()=>{r({node:e,container:t})}),r(void 0)},[]),(0,O.jsx)(O.Fragment,{children:n&&(0,RE.createPortal)(n.node,n.container)})}),FA=()=>{};function IA(e,t){let{editor:n,className:r,theme:i,children:a,editable:o,onSelectionChange:s,onChange:c,formattingToolbar:l,linkToolbar:u,slashMenu:d,emojiPicker:f,sideMenu:p,filePanel:m,tableHandles:h,comments:g,portalElements:_,applyThemedRoot:v,autoFocus:y,renderEditor:b=!0,...x}=e,S=(0,D.useMemo)(()=>CA(_?.default),[_?.default]),[C,w]=(0,D.useState)(),T=eE(),E=jA(),ee=T?.colorSchemePreference||E,te=i||(ee===`dark`?`dark`:`light`),ne=U(),re=(0,D.useMemo)(()=>({formattingToolbar:ne?l:!1,linkToolbar:ne?u:!1,sideMenu:ne?p:!1,slashMenu:ne?d:!1,filePanel:ne?m:!1,tableHandles:ne?h:!1,emojiPicker:ne?f:!1,comments:ne?g:!1,portalElements:_}),[g,ne,f,m,l,u,p,d,h,_]);kA(c||FA,n),AA(s||FA,n);let ie=(0,D.useCallback)(e=>{n.elementRenderer=e},[n]),ae=(0,D.useCallback)(e=>{e.className=V(`bn-root`,te,r||``),e.setAttribute(`data-color-scheme`,te),v?.(e)},[te,r,v]),oe=(0,D.useMemo)(()=>({...T,editor:n,setContentEditableProps:w,colorSchemePreference:te}),[T,n,te]),se=(0,D.useMemo)(()=>({editorProps:{autoFocus:y,contentEditableProps:C,editable:o},defaultUIProps:re,applyThemedRoot:ae}),[y,C,o,re,ae]);return(0,O.jsx)($T.Provider,{value:oe,children:(0,O.jsxs)(uE.Provider,{value:se,children:[(0,O.jsx)(PA,{ref:ie}),(0,O.jsx)(LA,{className:r,renderEditor:b,editorColorScheme:te,defaultPortalElement:S,ref:t,...x,children:a})]})})}var LA=D.forwardRef(({className:e,renderEditor:t,editorColorScheme:n,defaultPortalElement:r,children:i,...a},o)=>(0,O.jsx)(`div`,{className:V(`bn-root`,`bn-container`,n,e),"data-color-scheme":n,...a,ref:o,children:(0,O.jsx)(hE,{children:(0,O.jsx)(gE,{target:r,children:t?(0,O.jsx)(zA,{children:i}):i})})})),RA=D.forwardRef(IA),zA=e=>{let t=dE(),n=H(),r=(0,D.useMemo)(()=>MA(),[]);(0,D.useEffect)(()=>{OA()},[]);let i=(0,D.useCallback)(e=>{n.isEditable=t.editorProps.editable!==!1,n._tiptapEditor.contentComponent=r,e?n.mount(e):n.unmount()},[t.editorProps.editable,n,r]);return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(NA,{contentComponent:r}),(0,O.jsx)(BA,{...t.editorProps,...e,mount:i}),(0,O.jsx)(EA,{...t.defaultUIProps}),e.children]})},BA=e=>{let{autoFocus:t,mount:n,contentEditableProps:r}=e;return(0,O.jsx)(`div`,{"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"data-bn-autofocus":t,ref:n,...r})};function VA(e,t){let n,r=document.createElement(`div`),i;if(t?.elementRenderer)t.elementRenderer(e(e=>n=e||void 0),r);else{if(!t?.headless)throw Error(`elementRenderer not available, expected headless editor`);i=(0,gD.createRoot)(r),(0,RE.flushSync)(()=>{i.render(e(e=>n=e||void 0))})}if(!r.childElementCount)return console.warn(`ReactInlineContentSpec: renderHTML() failed`),{dom:document.createElement(`span`)};n?.setAttribute(`data-tmp-find`,`true`);let a=r.cloneNode(!0),o=a.firstElementChild,s=a.querySelector(`[data-tmp-find]`);return s?.removeAttribute(`data-tmp-find`),i?.unmount(),{dom:o,contentDOM:s||void 0}}var HA;async function UA(){return HA||(HA=(async()=>{let[e,t]=await Promise.all([fe(()=>import(`./module-CvVAOmRW.js`),[]),fe(()=>import(`./native-Cqs-2kTC.js`),[])]),n=`default`in e?e.default:e,r=`default`in t?t.default:t;return await n.init({data:r}),{emojiMart:n,emojiData:r}})(),HA)}function WA(e){let t=(0,D.useRef)(null),n=(0,D.useRef)(null);return n.current&&n.current.update(e),(0,D.useEffect)(()=>((async()=>{let{emojiMart:r}=await UA();n.current=new r.Picker({...e,ref:t})})(),()=>{n.current=null}),[]),D.createElement(`div`,{ref:t})}var GA=e=>{let[t,n]=(0,D.useState)(!1),r=U(),i=eE(),a=mE();return(0,O.jsxs)(r.Generic.Popover.Root,{open:t,portalElement:a,children:[(0,O.jsx)(r.Generic.Popover.Trigger,{children:(0,O.jsx)(`div`,{onClick:r=>{r.preventDefault(),r.stopPropagation(),n(!t),e.onOpenChange?.(!t)},style:{display:`flex`,justifyContent:`center`,alignItems:`center`},children:e.children})}),(0,O.jsx)(r.Generic.Popover.Content,{className:`bn-emoji-picker-popover`,variant:`panel-popover`,children:(0,O.jsx)(WA,{perLine:7,onClickOutside:()=>{n(!1),e.onOpenChange?.(!1)},onEmojiSelect:t=>{e.onEmojiSelect(t),n(!1),e.onOpenChange?.(!1)},theme:i?.colorSchemePreference})})]})};function KA(e){let{userStore:t}=iE(LE),n=e.join(`,`);return(0,D.useEffect)(()=>{t.loadUsers(e)},[t,n]),tE(t.store,t=>{let n=new Map;for(let r of e){let e=t.get(r);e&&n.set(r,e)}return n})}function qA(e){return KA([e]).get(e)}var JA=e=>{let t=U(),n=W(),r=iE(LE),i=e.comment.reactions.find(t=>t.emoji===e.emoji);if(!i)throw Error(`Trying to render reaction badge for non-existing reaction`);let[a,o]=(0,D.useState)([]),s=KA(a);return(0,O.jsx)(t.Generic.Badge.Root,{className:V(`bn-badge`,`bn-comment-reaction`),text:i.userIds.length.toString(),icon:i.emoji,isSelected:r.threadStore.auth.canDeleteReaction(e.comment,i.emoji),onClick:()=>e.onReactionSelect(i.emoji),onMouseEnter:()=>o(i.userIds),mainTooltip:n.comments.reactions.reacted_by,secondaryTooltip:`${Array.from(s.values()).map(e=>e.username).join(`
|
|
175
|
+
`)}`},i.emoji)},YA=(0,D.memo)(({isEmpty:e,comment:t,isEditing:n,threadStore:r,onReactionSelect:i,onEditSubmit:a,onEditCancel:o,onEmojiPickerOpenChange:s,Components:c,dict:l})=>{let u=r.auth.canAddReaction(t);return(0,O.jsxs)(O.Fragment,{children:[t.reactions.length>0&&!n&&(0,O.jsxs)(c.Generic.Badge.Group,{className:V(`bn-badge-group`,`bn-comment-reactions`),children:[t.reactions.map(e=>(0,O.jsx)(JA,{comment:t,emoji:e.emoji,onReactionSelect:i},e.emoji)),u&&(0,O.jsx)(GA,{onEmojiSelect:e=>i(e.native),onOpenChange:s,children:(0,O.jsx)(c.Generic.Badge.Root,{className:V(`bn-badge`,`bn-comment-add-reaction`),text:`+`,icon:(0,O.jsx)(LD,{size:16}),mainTooltip:l.comments.actions.add_reaction})})]}),n&&(0,O.jsxs)(c.Generic.Toolbar.Root,{variant:`action-toolbar`,className:V(`bn-action-toolbar`,`bn-comment-actions`),children:[(0,O.jsx)(c.Generic.Toolbar.Button,{mainTooltip:l.comments.save_button_text,variant:`compact`,onClick:a,isDisabled:e,children:l.comments.save_button_text}),(0,O.jsx)(c.Generic.Toolbar.Button,{className:`bn-button`,mainTooltip:l.comments.cancel_button_text,variant:`compact`,onClick:o,children:l.comments.cancel_button_text})]})]})}),XA=({comment:e,thread:t,showResolveButton:n})=>{let r=iE(LE),i=W(),[a,o]=(0,D.useState)(!1),s=EE({initialContent:e.body,trailingBlock:!1,dictionary:{...i,placeholders:{emptyDocument:i.placeholders.edit_comment}},schema:r.commentEditorSchema||jE,extensions:[NE({submitOnEnter:r.submitOnEnter,onSubmit:async n=>{await r.threadStore.updateComment({commentId:e.id,comment:{body:n.document},threadId:t.id}),o(!1)}})]}),c=U(),l=mE(),[u,d]=(0,D.useState)(!1),[f,p]=(0,D.useState)(!1),m=r.threadStore,h=(0,D.useCallback)(()=>{o(!0)},[]),g=(0,D.useCallback)(()=>{s.replaceBlocks(s.document,e.body),o(!1)},[s,e.body]),_=s.getExtension(NE).submit,v=(0,D.useCallback)(async()=>{await m.deleteComment({commentId:e.id,threadId:t.id})},[e,t.id,m]),y=(0,D.useCallback)(async n=>{m.auth.canAddReaction(e,n)?await m.addReaction({threadId:t.id,commentId:e.id,emoji:n}):m.auth.canDeleteReaction(e,n)&&await m.deleteReaction({threadId:t.id,commentId:e.id,emoji:n})},[m,e,t.id]),b=(0,D.useCallback)(async()=>{await m.resolveThread({threadId:t.id})},[t.id,m]),x=(0,D.useCallback)(async()=>{await m.unresolveThread({threadId:t.id})},[t.id,m]),S=qA(e.userId);if(!e.body)return null;let C,w=m.auth.canAddReaction(e),T=m.auth.canDeleteComment(e),E=m.auth.canUpdateComment(e),ee=n&&(t.resolved?m.auth.canUnresolveThread(t):m.auth.canResolveThread(t));a||(C=(0,O.jsxs)(c.Generic.Toolbar.Root,{className:V(`bn-action-toolbar`,`bn-comment-actions`),variant:`action-toolbar`,children:[w&&(0,O.jsx)(GA,{onEmojiSelect:e=>y(e.native),onOpenChange:d,children:(0,O.jsx)(c.Generic.Toolbar.Button,{mainTooltip:i.comments.actions.add_reaction,variant:`compact`,children:(0,O.jsx)(LD,{size:16})},`add-reaction`)}),ee&&(t.resolved?(0,O.jsx)(c.Generic.Toolbar.Button,{mainTooltip:i.comments.actions.reopen,variant:`compact`,onClick:x,children:(0,O.jsx)(MO,{size:16})},`reopen`):(0,O.jsx)(c.Generic.Toolbar.Button,{mainTooltip:i.comments.actions.resolve,variant:`compact`,onClick:b,children:(0,O.jsx)(GD,{size:16})},`resolve`)),(T||E)&&(0,O.jsxs)(c.Generic.Menu.Root,{position:`bottom-start`,onOpenChange:p,portalElement:l,children:[(0,O.jsx)(c.Generic.Menu.Trigger,{children:(0,O.jsx)(c.Generic.Toolbar.Button,{mainTooltip:i.comments.actions.more_actions,variant:`compact`,children:(0,O.jsx)(BD,{size:16})},`more-actions`)}),(0,O.jsxs)(c.Generic.Menu.Dropdown,{className:`bn-menu-dropdown`,children:[E&&(0,O.jsx)(c.Generic.Menu.Item,{icon:(0,O.jsx)(jO,{}),onClick:h,children:i.comments.actions.edit_comment},`edit-comment`),T&&(0,O.jsx)(c.Generic.Menu.Item,{icon:(0,O.jsx)(UD,{}),onClick:v,children:i.comments.actions.delete_comment},`delete-comment`)]})]})]}));let te=e.createdAt.toLocaleDateString(void 0,{month:`short`,day:`numeric`});if(!e.body)throw Error(`soft deletes are not yet supported`);return(0,O.jsx)(c.Comments.Comment,{authorInfo:S??`loading`,timeString:te,edited:e.updatedAt.getTime()!==e.createdAt.getTime(),showActions:f||`hover`,actions:C,className:`bn-thread-comment`,emojiPickerOpen:u,children:(0,O.jsx)(DE,{autoFocus:a,editor:s,editable:a,actions:e.reactions.length>0||a?({isFocused:t,isEmpty:n})=>(0,O.jsx)(YA,{isFocused:t,isEmpty:n,comment:e,isEditing:a,threadStore:m,onReactionSelect:y,onEditSubmit:_,onEditCancel:g,onEmojiPickerOpenChange:d,Components:c,dict:i}):void 0})})},ZA=({thread:e,maxCommentsBeforeCollapse:t})=>{let n=U(),r=W(),i=KA(e.resolvedBy?[e.resolvedBy]:[]),a=e.comments.map((t,n)=>(0,O.jsx)(XA,{thread:e,comment:t,showResolveButton:n===0},t.id+JSON.stringify(t.body||`{}`)));if(e.resolved&&e.resolvedUpdatedAt&&e.resolvedBy){if(!i.get(e.resolvedBy))throw Error(`User ${e.resolvedBy} resolved thread ${e.id}, but their data could not be found.`);let t=e.comments.findLastIndex(t=>e.resolvedUpdatedAt.getTime()>t.createdAt.getTime())+1;a.splice(t,0,(0,O.jsx)(n.Comments.Comment,{className:`bn-thread-comment`,authorInfo:e.resolvedBy&&i.get(e.resolvedBy)||`loading`,timeString:e.resolvedUpdatedAt.toLocaleDateString(void 0,{month:`short`,day:`numeric`}),edited:!1,showActions:!1,children:(0,O.jsx)(`div`,{className:`bn-resolved-text`,children:r.comments.sidebar.marked_as_resolved})},`resolved-comment`))}return t&&a.length>t&&a.splice(1,a.length-2,(0,O.jsx)(n.Comments.ExpandSectionsPrompt,{className:`bn-thread-expand-prompt`,children:r.comments.sidebar.more_replies(e.comments.length-2)},`expand-prompt`)),a},QA=(0,D.memo)(({isEmpty:e,onSave:t,Components:n,dict:r})=>(0,O.jsx)(n.Generic.Toolbar.Root,{className:V(`bn-action-toolbar`,`bn-comment-actions`),variant:`action-toolbar`,children:(0,O.jsx)(n.Generic.Toolbar.Button,{className:`bn-button`,mainTooltip:r.comments.save_button_text,variant:`compact`,isDisabled:e,onClick:t,children:r.comments.save_button_text})}));function $A(e){let t=e.newCommentEditor,n=U(),r=W(),i=t.getExtension(NE);if(!i)throw Error(`FloatingComposer's newCommentEditor must include CommentEditorSubmitExtension.`);let a=i.submit;return(0,O.jsx)(n.Comments.Card,{className:`bn-thread`,children:(0,O.jsx)(DE,{autoFocus:!0,editable:!0,editor:t,actions:({isFocused:e,isEmpty:t})=>(0,O.jsx)(QA,{isFocused:e,isEmpty:t,onSave:a,Components:n,dict:r})})})}var ej=vD({default:()=>tj});function tj(e){let t=H(),n=W(),r=iE(LE),i=aE(LE,{editor:t,selector:e=>e.pendingComment}),a=EE({trailingBlock:!1,dictionary:{...n,placeholders:{emptyDocument:n.placeholders.new_comment}},schema:r.commentEditorSchema||jE,extensions:[NE({submitOnEnter:r.submitOnEnter,onSubmit:async e=>{await r.createThread({initialComment:{body:e.document}}),r.stopPendingComment(),t.transact(e=>{e.setSelection(N.create(e.doc,e.selection.to))}),t.focus()}})]},[i]),o=cE({editor:t,selector:({editor:e})=>i?{from:e.prosemirrorState.selection.from,to:e.prosemirrorState.selection.to}:void 0}),s=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!i,onOpenChange:e=>{if(!e){if(!ME({hasUnsavedContent:!a.isEmpty,confirmBeforeDiscard:r.confirmBeforeDiscard,message:n.comments.discard_pending_comment}))return;r.stopPendingComment(),t.focus()}},placement:`bottom`,middleware:[p(10),w(),S()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!1},elementProps:{style:{zIndex:60},...e.floatingUIOptions?.elementProps}}),[r,n,t,a,i,e.floatingUIOptions]),c=e.floatingComposer||$A;return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(TE,{position:o,...s,children:(0,O.jsx)(c,{newCommentEditor:a})})})}var nj=(0,D.memo)(({isEmpty:e,onNewCommentSave:t,Components:n,dict:r})=>e?null:(0,O.jsx)(n.Generic.Toolbar.Root,{variant:`action-toolbar`,className:V(`bn-action-toolbar`,`bn-comment-actions`),children:(0,O.jsx)(n.Generic.Toolbar.Button,{mainTooltip:r.comments.save_button_text,variant:`compact`,isDisabled:e,onClick:t,children:r.comments.save_button_text})})),rj=({thread:e,selected:t,orphaned:n,referenceText:r,maxCommentsBeforeCollapse:i,onFocus:a,onBlur:o,tabIndex:s,newCommentEditor:c})=>{let l=U(),u=W(),d=iE(LE),f=(0,D.useRef)(e.id);f.current=e.id;let p=EE({trailingBlock:!1,dictionary:{...u,placeholders:{emptyDocument:u.placeholders.comment_reply}},schema:d.commentEditorSchema||jE,extensions:[NE({submitOnEnter:d.submitOnEnter,onSubmit:async e=>{await d.threadStore.addComment({comment:{body:e.document},threadId:f.current}),e.removeBlocks(e.document)}})]}),m=c??p,h=m.getExtension(NE);if(!h)throw Error(`Thread's newCommentEditor must include CommentEditorSubmitExtension.`);let g=h.submit;return(0,O.jsxs)(l.Comments.Card,{className:V(`bn-thread`,n&&`bn-thread-orphaned`),headerText:r,onFocus:a,onBlur:o,selected:t,tabIndex:s,children:[(0,O.jsx)(l.Comments.CardSection,{className:`bn-thread-comments`,children:(0,O.jsx)(ZA,{thread:e,maxCommentsBeforeCollapse:t?void 0:i||5})}),t&&(0,O.jsx)(l.Comments.CardSection,{className:`bn-thread-composer`,children:(0,O.jsx)(DE,{autoFocus:!1,editable:!0,editor:m,actions:({isFocused:e,isEmpty:t})=>(0,O.jsx)(nj,{isFocused:e,isEmpty:t,onNewCommentSave:g,Components:l,dict:u})})})]})};function ij(){let e=iE(LE).threadStore,t=(0,D.useRef)(void 0);t.current||=e.getThreads();let n=(0,D.useCallback)(n=>e.subscribe(e=>{t.current=e,n()}),[e]);return(0,D.useSyncExternalStore)(n,()=>t.current)}var aj=vD({default:()=>oj});function oj(e){let t=H(),n=W(),r=iE(LE),i=aE(LE,{editor:t,selector:e=>e.selectedThreadId?{id:e.selectedThreadId,position:e.threadPositions.get(e.selectedThreadId)}:void 0}),a=EE({trailingBlock:!1,dictionary:{...n,placeholders:{emptyDocument:n.placeholders.comment_reply}},schema:r.commentEditorSchema||jE,extensions:[NE({submitOnEnter:r.submitOnEnter,onSubmit:async e=>{i&&(await r.threadStore.addComment({comment:{body:e.document},threadId:i.id}),e.removeBlocks(e.document))}})]},[i?.id]),o=ij(),s=(0,D.useMemo)(()=>i?o.get(i.id):void 0,[i,o]),c=(0,D.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!i,onOpenChange:(e,i,o)=>{if(!e){if(!ME({hasUnsavedContent:!a.isEmpty,confirmBeforeDiscard:r.confirmBeforeDiscard,message:n.comments.discard_pending_comment}))return;o===`escape-key`&&t.focus(),r.selectThread(void 0)}},placement:`bottom`,middleware:[p(10),w(),S()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:30},...e.floatingUIOptions?.elementProps}}),[r,n,t,a,e.floatingUIOptions,i]),l=e.floatingThread||rj;return(0,O.jsx)(gE,{target:e.portalElement,children:(0,O.jsx)(TE,{position:i?.position,...c,children:s&&(0,O.jsx)(l,{thread:s,selected:!0,newCommentEditor:a})})})}D.memo(({thread:e,selectedThreadId:t,maxCommentsBeforeCollapse:n,referenceText:r,orphaned:i})=>{let a=iE(LE),o=(0,D.useCallback)(t=>{t.target.closest(`.bn-action-toolbar`)||a.selectThread(e.id)},[a,e.id]),s=(0,D.useCallback)(e=>{if(!e.relatedTarget||e.relatedTarget.closest(`.bn-action-toolbar`))return;let t=e.target instanceof Node?e.target:null,n=e.relatedTarget instanceof Node?e.relatedTarget.closest(`.bn-thread`):null;t&&n&&n.contains(t)||a.selectThread(void 0)},[a]);return(0,O.jsx)(rj,{thread:e,selected:e.id===t,orphaned:i,referenceText:r,maxCommentsBeforeCollapse:n,onFocus:o,onBlur:s,tabIndex:0})}),(0,D.createContext)(void 0);function sj(e){let t=(0,D.useRef)(null);return(0,D.useEffect)(()=>{e&&t.current?.focus({preventScroll:!0})},[e]),t}function cj(e){return e.currentTarget instanceof HTMLElement&&e.relatedTarget instanceof HTMLElement&&e.currentTarget.contains(e.relatedTarget)}function lj({onBlur:e,onFocus:t}={}){let n=(0,D.useRef)(null),[r,i]=(0,D.useState)(!1),a=(0,D.useRef)(!1),o=e=>{i(e),a.current=e},s=(0,D.useCallback)(e=>{a.current||(o(!0),t?.(e))},[t]),c=(0,D.useCallback)(t=>{a.current&&!cj(t)&&(o(!1),e?.(t))},[e]);return(0,D.useEffect)(()=>{let e=n.current;if(e)return e.addEventListener(`focusin`,s),e.addEventListener(`focusout`,c),()=>{e?.removeEventListener(`focusin`,s),e?.removeEventListener(`focusout`,c)}},[s,c]),{ref:n,focused:r}}function uj(e){return(0,O.jsx)(ZE,{as:`span`,className:`bn-inline-content-section`,"data-inline-content-type":e.inlineContentType,...Object.fromEntries(Object.entries(e.inlineContentProps).filter(([t,n])=>n!==e.propSchema[t].default).map(([e,t])=>[Ig(e),t])),children:e.children})}function dj(e,t,n){let r=Ep.create({name:e.type,inline:!0,group:`inline`,selectable:e.content!==`none`,atom:e.content===`none`,draggable:t.meta?.draggable,code:t.meta?.code,content:e.content===`styled`?`inline*`:e.content===`plain`?`text*`:``,marks(){return e.content===`plain`?Ap(this.editor):void 0},addAttributes(){return zg(e.propSchema)},addKeyboardShortcuts(){return Xg(e)},parseHTML(){return vS(e,t.parse,t.parseContent)},renderHTML({node:n}){let r=this.options.editor,i=Mg(n,r.schema.inlineContentSchema,r.schema.styleSchema),a=t.toExternalHTML||t.render;return Yg(VA(e=>(0,O.jsx)(a,{contentRef:t=>{e(t),t&&(t.dataset.editable=``)},inlineContent:i,updateInlineContent:()=>{},editor:r,node:n,getPos:()=>void 0}),r),e.type,n.attrs,e.propSchema)},addNodeView(){let n=this.options.editor;return r=>dD(r=>{let i=XE().nodeViewContentRef;if(!i)throw Error(`nodeViewContentRef is not set`);let a=t.render;return(0,O.jsx)(uj,{inlineContentProps:r.node.attrs,inlineContentType:e.type,propSchema:e.propSchema,children:(0,O.jsx)(a,{contentRef:e=>{i(e),e&&(e.dataset.editable=``)},editor:n,node:r.node,getPos:r.getPos,inlineContent:Mg(r.node,n.schema.inlineContentSchema,n.schema.styleSchema),updateInlineContent:e=>{let t=P_([e],n.pmSchema),i=r.getPos();i!==void 0&&n.transact(e=>e.replaceWith(i,i+r.node.nodeSize,t))}})})},{className:`bn-ic-react-node-view-renderer`,as:`span`})(r)}});return Zg(e,{...t,node:r,render(n,r,i){let a=t.render,o=P_([n],i.pmSchema)[0];return VA(t=>(0,O.jsx)(uj,{inlineContentProps:n.props,inlineContentType:e.type,propSchema:e.propSchema,children:(0,O.jsx)(a,{contentRef:e=>{t(e),e&&(e.dataset.editable=``)},editor:i,inlineContent:n,updateInlineContent:r,node:o,getPos:()=>void 0})}),i)},toExternalHTML(n,r){let i=t.toExternalHTML||t.render,a=P_([n],r.pmSchema)[0];return VA(t=>(0,O.jsx)(uj,{inlineContentProps:n.props,inlineContentType:e.type,propSchema:e.propSchema,children:(0,O.jsx)(i,{contentRef:e=>{t(e),e&&(e.dataset.editable=``)},editor:r,inlineContent:n,updateInlineContent:()=>{},node:a,getPos:()=>void 0})}),r)}},n)}function fj(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.top<r.top,a=n.bottom>r.bottom;return i&&a?`both`:i?`top`:a?`bottom`:`none`}function pj(e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}function mj(e){return(0,D.useMemo)(()=>pj(e),e)}function hj(e){gg()?e.preventDefault():mg()&&e.currentTarget.focus()}function gj(e){let{render:t,type:n}=e;return t||n!==void 0?e:{...e,type:`button`}}function _j(e){return Array.isArray(e)?e:e===void 0?[]:[e]}function vj(e){let t=[];for(let n of e)t.push(...n);return t}function yj(e){return e.slice().reverse()}function bj(...e){}function xj(e,t){return Sj(e)?e(Cj(t)?t():t):e}function Sj(e){return typeof e==`function`}function Cj(e){return typeof e==`function`}function wj(e){return typeof e==`object`&&!!e}function Tj(e,t){return typeof Object.hasOwn==`function`?Object.hasOwn(e,t):Object.prototype.hasOwnProperty.call(e,t)}function Ej(...e){return(...t)=>{for(let n of e)typeof n==`function`&&n(...t)}}function Dj(...e){return e.filter(Boolean).join(` `)||void 0}function Oj(e){return e.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``)}function kj(e,t){let n={...e};for(let e of t)Tj(n,e)&&delete n[e];return n}function Aj(e,t){let n={};for(let r of t)Tj(e,r)&&(n[r]=e[r]);return n}function jj(e){return e}function Mj(e=bj){let t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)});return()=>cancelAnimationFrame(t)}function Nj(e,t){if(!e)throw Error(typeof t==`string`?t:`Invariant failed`)}function Pj(e){return Object.keys(e)}function Fj(e,...t){let n=typeof e==`function`?e(...t):e;return n!=null&&!n}function Ij(e){return e.disabled||e[`aria-disabled`]===!0||e[`aria-disabled`]===`true`}function Lj(e){return e.getAttribute(`aria-disabled`)===`true`||`disabled`in e&&e.disabled===!0}function Rj(e){let t={};for(let n in e)Tj(e,n)&&n!==`__proto__`&&e[n]!==void 0&&(t[n]=e[n]);return t}function K(...e){for(let t of e)if(t!==void 0)return t}var zj=Bj();function Bj(){return typeof window<`u`&&!!window.document?.createElement}function Vj(e,t){let n=e;for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e?.get)return e.get;n=Object.getPrototypeOf(n)}}var Hj=zj?Vj(Object.getPrototypeOf(window.document),`nodeType`):void 0,Uj=zj?Vj(Object.getPrototypeOf(window.document),`activeElement`):void 0;function Wj(e){return e?e.window===e:!1}function Gj(e){if(!e)return!1;if(!Hj)return e.nodeType===9;try{return Hj.call(e)===9}catch{return!1}}function Kj(e,t){try{return e.document===t}catch{return!1}}function q(e){if(!e)return document;if(Gj(e))return e;if(Wj(e))return e.document;let t=e.ownerDocument;return Gj(t)?t:document}function qj(e){if(!e)return self;if(Wj(e))return e;let t=q(e),{defaultView:n}=t;return Wj(n)&&Kj(n,t)?n:window}function Jj(e,{frame:t=!0,activeDescendant:n=!1}={}){let r=q(e),i=Uj?Uj.call(r):r.activeElement;if(!i?.nodeName)return null;if(t&&Qj(i)&&i.contentDocument?.body)return Jj(i.contentDocument.body,{frame:t,activeDescendant:n});if(n){let e=i.getAttribute(`aria-activedescendant`);if(e){let t=q(i).getElementById(e);if(t)return t}}return i}function Yj(e,t){return e===t||e.contains(t)}function Xj(e){return e?.nodeType===1}function Zj(e){return typeof e?.nodeType==`number`}function Qj(e){return e.tagName===`IFRAME`}function $j(e){let t=e.tagName.toLowerCase();return t===`button`?!0:t===`input`&&e.type?eM.indexOf(e.type)!==-1:!1}var eM=[`button`,`color`,`file`,`image`,`reset`,`submit`];function tM(e){if(typeof e.checkVisibility==`function`)return e.checkVisibility();let t=e;return t.offsetWidth>0||t.offsetHeight>0||e.getClientRects().length>0}function nM(e){try{return e.tagName===`TEXTAREA`||e.tagName===`INPUT`&&e.selectionStart!==null}catch{return!1}}function rM(e){return e.isContentEditable||nM(e)}function iM(e){if(nM(e))return e.value;if(e.isContentEditable){let t=q(e).createRange();return t.selectNodeContents(e),t.toString()}return``}function aM(e){let t=0,n=0;if(nM(e))t=e.selectionStart||0,n=e.selectionEnd||0;else if(e.isContentEditable){let r=q(e).getSelection();if(r?.rangeCount&&r.anchorNode&&Yj(e,r.anchorNode)&&r.focusNode&&Yj(e,r.focusNode)){let i=r.getRangeAt(0),a=i.cloneRange();a.selectNodeContents(e),a.setEnd(i.startContainer,i.startOffset),t=a.toString().length,a.setEnd(i.endContainer,i.endOffset),n=a.toString().length}}return{start:t,end:n}}var oM=[`dialog`,`menu`,`listbox`,`tree`,`grid`],sM={menu:`menuitem`,listbox:`option`,tree:`treeitem`};function cM(e,t){let n=e?.getAttribute(`role`);return n&&oM.indexOf(n)!==-1?n:t}function lM(e){if(e!=null&&Tj(sM,e))return sM[e]}function uM(e,t){let n=cM(e);return typeof n==`string`?lM(n)??t:t}function dM(e){if(!e)return null;let t=e=>e===`auto`||e===`scroll`;if(e.clientHeight&&e.scrollHeight>e.clientHeight){let{overflowY:n}=getComputedStyle(e);if(t(n))return e}else if(e.clientWidth&&e.scrollWidth>e.clientWidth){let{overflowX:n}=getComputedStyle(e);if(t(n))return e}let n=q(e);return dM(e.parentElement)||n.scrollingElement||n.body}function fM(e,t){let n=e.map((e,t)=>[t,e]),r=!1;return n.sort(([e,n],[i,a])=>{let o=t(n),s=t(a);return o===s||!o||!s?0:pM(o,s)?(e>i&&(r=!0),-1):(e<i&&(r=!0),1)}),r?n.map(([e,t])=>t):e}function pM(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function mM(){return zj&&!!navigator.maxTouchPoints}function hM(){return zj?/mac|iphone|ipad|ipod/i.test(navigator.platform):!1}function gM(){return zj&&hM()&&/apple/i.test(navigator.vendor)}function _M(){return zj&&/firefox\//i.test(navigator.userAgent)}function vM(){return zj&&navigator.platform.startsWith(`Mac`)&&!mM()}function yM(e){let{currentTarget:t,target:n}=e;return t?!Zj(n)||!Yj(t,n):!1}function bM(e){return e.target===e.currentTarget}function xM(e){if(!Xj(e))return!1;let t=e,n=t.tagName.toLowerCase();return n===`a`||n===`button`&&t.type===`submit`||n===`input`&&t.type===`submit`}function SM(e){let t=hM();return t&&!e.metaKey||!t&&!e.ctrlKey?!1:xM(e.currentTarget)}function CM(e){return e.altKey?xM(e.currentTarget):!1}function wM(e,t,n){let{Event:r}=qj(e),i=new r(t,n);return e.dispatchEvent(i)}function TM(e,t){let{FocusEvent:n}=qj(e),r=new n(`blur`,t),i=e.dispatchEvent(r),a={...t,bubbles:!0};return e.dispatchEvent(new n(`focusout`,a)),i}var EM={width:!0,height:!0,pressure:!0,tangentialPressure:!0,tiltX:!0,tiltY:!0,twist:!0,altitudeAngle:!0,azimuthAngle:!0,isPrimary:!0,coalescedEvents:!0,predictedEvents:!0,persistentDeviceId:!0};function DM(e,t){let n=t??{},r=e.Window,i=typeof r==`function`&&e instanceof r?e:null;return new Proxy({},{get(e,t){if(t===`view`)return i;if(t===`composed`)return!0;if(t===`pointerId`)return n.pointerId??-1;if(t===`pointerType`)return n.pointerType??``;if(!Tj(EM,t))return Reflect.get(n,t)}})}function OM(e,t){let n=qj(e),r=new(n.PointerEvent??n.MouseEvent)(`click`,DM(n,t));return e.dispatchEvent(r)}function kM(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!Zj(r)||!Yj(n,r)}function AM(e,t,n,r){let i=(e=>{if(r){let t=setTimeout(e,r);return()=>clearTimeout(t)}let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)})(()=>{e.removeEventListener(t,a,!0),n()}),a=()=>{i(),n()};return e.addEventListener(t,a,{once:!0,capture:!0}),()=>{i(),e.removeEventListener(t,a,!0)}}function jM(e,t,n,r=window){let i=[];try{r.document.addEventListener(e,t,n);for(let a of Array.from(r.frames))i.push(jM(e,t,n,a))}catch{}return()=>{try{r.document.removeEventListener(e,t,n)}catch{}for(let e of i)e()}}var MM=`input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])`;function NM(e){return Number.parseInt(e.getAttribute(`tabindex`)||`0`,10)<0}function PM(e){return!(!e.matches(MM)||!tM(e)||e.closest(`[inert]`))}function FM(e){if(!PM(e)||NM(e))return!1;if(!(`form`in e)||!e.form||e.checked||e.type!==`radio`)return!0;let t=e.form.elements.namedItem(e.name);if(!t||!(`length`in t))return!0;let n=Jj(e);return!n||n===e||!(`form`in n)||n.form!==e.form||!(`name`in n)||n.name!==e.name}function IM(e,t){let n=Array.from(e.querySelectorAll(MM));t&&n.unshift(e);let r=n.filter(PM);return r.forEach((e,t)=>{if(!Qj(e))return;let n=e.contentDocument?.body;n&&r.splice(t,1,...IM(n))}),r}function LM(e,t){let[n]=IM(e,t);return n||null}function RM(e,t,n){let r=Array.from(e.querySelectorAll(MM)).filter(FM);return t&&FM(e)&&r.unshift(e),r.forEach((e,t)=>{if(!Qj(e))return;let i=e.contentDocument?.body;if(!i)return;let a=RM(i,!1,n);r.splice(t,1,...a)}),!r.length&&n?IM(e):r}function zM(e,t,n){if(t&&FM(e)){if(!Qj(e))return e;let t=e.contentDocument?.body;if(!t)return e;let r=zM(t,!1,n);if(r)return r}let r=e.querySelectorAll(MM);for(let e of r)if(FM(e)){if(Qj(e)){let t=e.contentDocument?.body;if(!t)return e;let r=zM(t,!1,n);if(r)return r}else return e}return n?LM(e):null}function BM({container:e,includeContainer:t,reverse:n,fallbackToEdge:r,fallbackToFocusable:i}){let a=Jj(e),o=IM(e,t);n&&o.reverse();let s=o.indexOf(a),c=o.slice(s+1);return c.find(FM)||(r?o.find(FM):null)||(i?c[0]:null)||null}function VM(e,t,n,r){return BM({container:e,includeContainer:t,fallbackToEdge:n,fallbackToFocusable:r})}function HM(e,t){return VM(document.body,!1,e,t)}function UM(e,t,n,r){return BM({container:e,includeContainer:t,reverse:!0,fallbackToEdge:n,fallbackToFocusable:r})}function WM(e,t){return UM(document.body,!1,e,t)}function GM(e){let t=Jj(e);if(!t)return!1;if(t===e)return!0;let n=t.getAttribute(`aria-activedescendant`);return n?n===e.id:!1}function KM(e){let t=Jj(e);if(!t)return!1;if(Yj(e,t))return!0;let n=t.getAttribute(`aria-activedescendant`);return!n||!(`id`in e)?!1:n===e.id||!!e.querySelector(`#${CSS.escape(n)}`)}function qM(e){let t=e.getAttribute(`tabindex`)??``;e.setAttribute(`data-tabindex`,t),e.setAttribute(`tabindex`,`-1`)}function JM(e,t){let n=RM(e,t);for(let e of n)qM(e)}function YM(e){let t=e.querySelectorAll(`[data-tabindex]`),n=e=>{let t=e.getAttribute(`data-tabindex`);e.removeAttribute(`data-tabindex`),t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)};e.hasAttribute(`data-tabindex`)&&n(e);for(let e of t)n(e)}function XM(e){return async()=>{let t=await e?.();return XM(async()=>(await t?.(),e))}}ZM();function ZM({limit:e=100}={}){let t=[],n=[],r=null,i=()=>t.length>0,a=()=>n.length>0;return{canUndo:i,canRedo:a,undo:async()=>{i()&&(r=null,n.push(await t.pop()?.()))},redo:async()=>{a()&&(r=null,t.push(await n.pop()?.()))},execute:async(i,a)=>{if(!i)return;let o=a===r;r=a??null;let s=o?Math.max(0,t.length-1):t.length,c=await i();if(!c)return;n=[];let l=t[s];for(t[s]=XM(async()=>{await c?.();let e=await l?.();return async()=>{await e?.(),await i?.()}});t.length>e;)t.shift()}}}var QM=Symbol(`accessibleWhenDisabled`);function $M(e){return e.accessibleWhenDisabled??e.onLoadedMetadataCapture?.[QM]}var eN=`data-truly-disabled`;function tN(e){return e.getAttribute(eN)===`true`}function nN(e){let t=e.getAttribute(eN);if(t===`true`)return!0;if(t===`false`)return!1}function rN(e){return e===`ArrowUp`||e===`ArrowRight`||e===`ArrowDown`||e===`ArrowLeft`||e===`Home`||e===`End`||e===`PageUp`||e===`PageDown`}function iN(e){return e.nodeType===e.DOCUMENT_FRAGMENT_NODE&&`host`in e}function aN(e){let t=e?.getRootNode();return t&&iN(t)&&t.activeElement?t.activeElement:Jj(e)}function oN(e){return GM(e)||aN(e)===e}var sN=(0,D.createContext)(!0);function cN(e,t){if(typeof e==`function`){let n=e(t);if(typeof n==`function`)return n}else e&&(e.current=t)}function lN(e){return!e||!(0,D.isValidElement)(e)?!1:`ref`in e.props||`ref`in e}function uN(e){return lN(e)?{...e.props}.ref||e.ref:null}function dN(e,t){let n={...e};for(let r in t){if(!Tj(t,r)||r===`__proto__`)continue;if(r===`className`){let r=`className`,i=e[r],a=t[r];n[r]=i&&a?`${i} ${a}`:a||i;continue}if(r===`style`){let r=`style`;n[r]=e[r]?{...e[r],...t[r]}:t[r];continue}let i=t[r];if(i!==void 0){if(r.startsWith(`on`)){if(typeof i!=`function`)continue;let t=e[r];if(typeof t==`function`){n[r]=(...e)=>{i(...e),t(...e)};continue}}n[r]=i}}return n}var fN={...D},pN=fN.useId;fN.useDeferredValue;var mN=fN.useInsertionEffect??(e=>e()),J=zj?D.useLayoutEffect:D.useEffect;function hN(e){let[t]=(0,D.useState)(e);return t}function gN(e){let t=(0,D.useRef)(e);return J(()=>{t.current=e}),t}function Y(e){let t=(0,D.useRef)(()=>{throw Error(`Cannot call an event handler while rendering.`)});return mN(()=>{t.current=e}),(0,D.useCallback)((...e)=>t.current?.(...e),[])}function _N(e){let[t,n]=(0,D.useState)(null);return J(()=>{if(t==null||!e)return;let n=null;return e(e=>(n=e,t)),()=>{e(n)}},[t,e]),[t,n]}function vN(...e){return(0,D.useMemo)(()=>{if(e.some(Boolean))return t=>{let n=[];for(let r of e){if(!r)continue;let e=cN(r,t);n.push({ref:r,cleanup:typeof e==`function`?e:void 0})}if(n.some(e=>e.cleanup))return()=>{for(let{ref:e,cleanup:t}of n)t?t():cN(e,null)}}},e)}function yN(e){let[t,n]=(0,D.useState)(e);return J(()=>{if(e||t)return;let r=Math.random().toString(36).slice(2,8);n(`id-${r}`)},[e,t]),e||t}function bN(e){let t=pN();return e||t}var xN=pN?bN:yN;function SN(e){return xN(e)}function CN(e,t){let n=e=>{if(typeof e==`string`)return e},[r,i]=(0,D.useState)(()=>n(t));return J(()=>{let r=e&&`current`in e?e.current:e;i(r?.tagName.toLowerCase()||n(t))},[e,t]),r}function wN(e,t,n){let r=hN(n),[i,a]=(0,D.useState)(r);return(0,D.useEffect)(()=>{let n=e&&`current`in e?e.current:e;if(!n)return;let i=()=>{let e=n.getAttribute(t);a(e??r)},o=new MutationObserver(i);return o.observe(n,{attributeFilter:[t]}),i(),()=>o.disconnect()},[e,t,r]),i}function TN(e,t){let n=(0,D.useRef)(!1);(0,D.useEffect)(()=>{if(n.current)return e();n.current=!0},t),(0,D.useEffect)(()=>()=>{n.current=!1},[])}function EN(){return(0,D.useReducer)(()=>[],[])}function DN(e){return Y(typeof e==`function`?e:()=>e)}function ON(e,t,n=[]){let r=(0,D.useCallback)(n=>(e.wrapElement&&(n=e.wrapElement(n)),t(n)),[...n,e.wrapElement]);return{...e,wrapElement:r}}function kN(e=!1,t){let[n,r]=(0,D.useState)(null);return{portalRef:vN(r,t),portalNode:n,domReady:!e||n}}function AN(e,t,n){let r=e.onLoadedMetadataCapture,i=(0,D.useMemo)(()=>Object.assign(bj.bind(null),r,...n===void 0?[]:[{[t]:n}]),[r,t,n]);return[r?.[t],{onLoadedMetadataCapture:i}]}var jN=!1;function MN(){return(0,D.useEffect)(()=>{jN||=(jM(`mousemove`,LN,!0),jM(`mousedown`,RN,!0),jM(`mouseup`,RN,!0),jM(`keydown`,RN,!0),jM(`scroll`,RN,!0),!0)},[]),Y(()=>NN)}var NN=!1,PN=0,FN=0;function IN(e){let t=e.movementX||e.screenX-PN,n=e.movementY||e.screenY-FN;return PN=e.screenX,FN=e.screenY,t||n||!1}function LN(e){IN(e)&&(NN=!0)}function RN(){NN=!1}function X(e){let t=D.forwardRef((t,n)=>e(Rj({...t,ref:n})));return t.displayName=e.displayName||e.name,t}function zN(e,t){return D.memo(e,t)}function Z(e,t){let{wrapElement:n,render:r,...i}=t,a=vN(t.ref,uN(r)),o;if(D.isValidElement(r)){let e={...r.props,ref:a};o=D.cloneElement(r,dN(i,e))}else o=r?r(i):(0,O.jsx)(e,{...i});return n?n(o):o}function Q(e){let t=(t={})=>e(t);return t.displayName=e.name,t}function BN(e=[],t=[]){let n=D.createContext(void 0),r=D.createContext(void 0),i=()=>D.useContext(n),a=(e=!1)=>{let t=D.useContext(r),n=i();return e?t:t||n},o=()=>{let e=D.useContext(r),t=i();if(!(e&&e===t))return t},s=t=>e.reduceRight((e,n)=>(0,O.jsx)(n,{...t,children:e}),(0,O.jsx)(n.Provider,{...t}));return{context:n,scopedContext:r,useContext:i,useScopedContext:a,useProviderContext:o,ContextProvider:s,ScopedContextProvider:e=>(0,O.jsx)(s,{...e,children:t.reduceRight((t,n)=>(0,O.jsx)(n,{...e,children:t}),(0,O.jsx)(r.Provider,{...e}))})}}var VN=`div`,HN=gM(),UN=1,WN=2,GN=3,KN=[`text`,`search`,`url`,`tel`,`email`,`password`,`number`,`date`,`month`,`week`,`time`,`datetime`,`datetime-local`];function qN(e){let{tagName:t,readOnly:n,type:r}=e;return t===`TEXTAREA`&&!n||t===`SELECT`&&!n?!0:t===`INPUT`&&!n?KN.includes(r):!!(e.isContentEditable||e.getAttribute(`role`)===`combobox`&&e.dataset.name)}function JN(e){return!e||e===`button`||e===`summary`||e===`input`||e===`select`||e===`textarea`||e===`a`}function YN(e){return!e||e===`button`||e===`input`||e===`select`||e===`textarea`}function XN(e){let t=0;return JN(e)&&(t|=UN),YN(e)&&(t|=WN),t}function ZN(e){if(e.tagName===`BUTTON`){let{type:t}=e;return t===`submit`}if(e.tagName===`INPUT`){let{type:t}=e;return t===`submit`||t===`image`}return!1}function QN({focusable:e,trulyDisabled:t,nativeTabbable:n,supportsDisabled:r,safariTabIndex:i,tabIndexProp:a}){return e?t?n&&!r?-1:void 0:n?i&&a==null?0:a:a??0:a}function $N(e,t){return Y(n=>{e?.(n),n.defaultPrevented||t&&(n.stopPropagation(),n.preventDefault())})}var eP=!1,tP=!0;function nP(e){let t=e.target;Xj(t)&&!t.hasAttribute(`data-focus-visible`)&&(tP=!1)}function rP(e){rN(e.key)?tP=!0:e.metaKey||e.ctrlKey||(!e.altKey||HN&&e.key===`Tab`)&&(tP=!0)}var iP=Q(function({focusable:e=!0,accessibleWhenDisabled:t,autoFocus:n,onFocusVisible:r,...i}){let a=(0,D.useRef)(null),[o,s]=AN(i,QM,t);t??=o,(0,D.useEffect)(()=>{e&&(eP||=(jM(`mousedown`,nP,!0),jM(`keydown`,rP,!0),!0))},[e]);let c=e&&Ij(i),l=c&&!t,[u,d]=(0,D.useState)(!1),f=(0,D.useRef)(!1),p=(0,D.useRef)(null),m=Y(e=>{p.current?.(),p.current=null,f.current=!1,e?.removeAttribute(`data-focus-visible`)});(0,D.useEffect)(()=>{(!e||l)&&(m(a.current),u&&d(!1))},[e,l,u,m]),(0,D.useEffect)(()=>{if(!e||!u)return;let t=a.current;if(!t||typeof IntersectionObserver>`u`)return;let n=new IntersectionObserver(()=>{PM(t)||(f.current=!1,d(!1))});return n.observe(t),()=>n.disconnect()},[e,u]),(0,D.useEffect)(()=>()=>p.current?.(),[]);let h=$N(i.onKeyPressCapture,c),g=$N(i.onMouseDownCapture,c),_=$N(i.onClickCapture,c),v=$N(i.onAuxClickCapture,c),y=(t,n)=>{if(n&&(t.currentTarget=n),!e)return;let i=t.currentTarget;if(i&&oN(i)&&(r?.(t),!t.defaultPrevented)){if(i.dataset.focusVisible=`true`,f.current=!0,ZN(i)){if(p.current?.(),p.current=null,typeof IntersectionObserver<`u`){let e=new IntersectionObserver(()=>{PM(i)||m(i)});e.observe(i),p.current=()=>e.disconnect()}}else d(!0)}},b=i.onKeyDownCapture,x=Y(t=>{if(b?.(t),t.defaultPrevented||!e||u||f.current||(t.metaKey||t.altKey||t.ctrlKey)&&!rN(t.key)||!bM(t))return;let n=t.currentTarget;AM(n,`focusout`,()=>y(t,n))}),S=i.onFocusCapture,C=Y(t=>{if(S?.(t),t.defaultPrevented||!e)return;if(!bM(t)){d(!1);return}let n=t.currentTarget;tP||qN(t.target)?AM(t.target,`focusout`,()=>y(t,n)):d(!1)}),w=i.onBlur,T=Y(t=>{w?.(t),e&&kM(t)&&(m(t.currentTarget),d(!1))}),E=(0,D.useContext)(sN),ee=Y(t=>{e&&n&&t&&E&&queueMicrotask(()=>{GM(t)||PM(t)&&t.focus()})}),[te,ne]=(0,D.useState)(GN);J(()=>{let e=a.current;if(!e)return;let t=XN(e.tagName.toLowerCase());t!==GN&&ne(t)},[]);let re=e&&!!(te&UN),ie=e&&!!(te&WN),[ae,oe]=(0,D.useState)(!1);HN&&(0,D.useEffect)(()=>{if(!e)return;let t=a.current;if(!t)return;let{type:n}=t,r=t.tagName===`INPUT`&&(n===`checkbox`||n===`radio`);oe($j(t)||r)},[e]);let se=i.style,ce=(0,D.useMemo)(()=>l?{pointerEvents:`none`,...se}:se,[l,se]);return i={"data-focus-visible":e&&u||void 0,"data-autofocus":n||void 0,"aria-disabled":c||void 0,...i,...s,ref:vN(a,ee,i.ref),style:ce,tabIndex:QN({focusable:e,trulyDisabled:l,nativeTabbable:re,supportsDisabled:ie,safariTabIndex:ae,tabIndexProp:i.tabIndex}),disabled:ie&&l?!0:void 0,[eN]:c?l:void 0,contentEditable:c?void 0:i.contentEditable,onKeyPressCapture:h,onClickCapture:_,onAuxClickCapture:v,onMouseDownCapture:g,onKeyDownCapture:x,onFocusCapture:C,onBlur:T},Rj(i)});X(function(e){return Z(VN,iP(e))});var aP=`button`;function oP(e){if(!e.isTrusted)return!1;let t=e.currentTarget;return e.key===`Enter`?$j(t)||t.tagName===`SUMMARY`||t.tagName===`A`:e.key===` `?$j(t)||t.tagName===`SUMMARY`||t.tagName===`INPUT`||t.tagName===`SELECT`:!1}var sP=Symbol(`command`),cP=Q(function({clickOnEnter:e=!0,clickOnSpace:t=!0,...n}){let r=(0,D.useRef)(null),[i,a]=(0,D.useState)(!1),o=n.type;(0,D.useEffect)(()=>{let e=r.current;if(!e)return;let t=$j(e);o!==void 0&&t&&e.type===`button`||a(t)},[o]);let[s,c]=(0,D.useState)(!1),l=(0,D.useRef)(!1),u=Ij(n),[d,f]=AN(n,sP,!0);J(()=>{u&&(l.current=!1,c(!1))},[u]);let p=n.onKeyDown,m=Y(n=>{p?.(n);let r=n.currentTarget;if(n.defaultPrevented||d||u||!bM(n)||nM(r)||r.isContentEditable)return;let i=e&&n.key===`Enter`,a=t&&n.key===` `,o=n.key===`Enter`&&!e,s=n.key===` `&&!t;if(o||s)n.preventDefault();else if(i||a){let e=oP(n);if(i){if(!e){n.preventDefault();let{view:e,...t}=n,i=()=>OM(r,t);_M()?AM(r,`keyup`,i):queueMicrotask(i)}}else a&&(l.current=!0,e||(n.preventDefault(),c(!0)))}}),h=n.onKeyUp,g=Y(e=>{if(h?.(e),d)return;let n=t&&e.key===` `;if(!l.current||!n)return;let r=oP(e);if(l.current=!1,r||c(!1),e.defaultPrevented||!bM(e)||u||e.metaKey||r)return;e.preventDefault();let i=e.currentTarget,{view:a,...o}=e;queueMicrotask(()=>OM(i,o))}),_=n.onBlur,v=Y(e=>{_?.(e),l.current&&(l.current=!1,c(!1))});return n={"data-active":s||void 0,type:i?`button`:void 0,...f,...n,ref:vN(r,n.ref),onKeyDown:m,onKeyUp:g,onBlur:v},n=iP(n),n});X(function(e){return Z(aP,cP(gj(e)))});var lP=BN(),uP=lP.useContext;lP.useScopedContext,lP.useProviderContext;var dP=lP.ContextProvider,fP=lP.ScopedContextProvider,pP=`div`,mP=Q(function({store:e,shouldRegisterItem:t=!0,getItem:n=jj,element:r,...i}){let a=uP();e||=a;let o=SN(i.id),s=(0,D.useRef)(r);return(0,D.useEffect)(()=>{let r=s.current;if(!o||!r||!t)return;let i=n({id:o,element:r});return e?.renderItem(i)},[o,t,n,e]),i={...i,ref:vN(s,i.ref)},i});X(function(e){return Z(pP,mP(e))});var hP=BN([dP],[fP]);hP.useContext;var gP=hP.useScopedContext,_P=hP.useProviderContext,vP=hP.ContextProvider,yP=hP.ScopedContextProvider,bP=(0,D.createContext)(void 0),xP=(0,D.createContext)(void 0);function SP(e,t){let n=e.__unstableInternals;return Nj(n,`Invalid store`),n[t]}function CP(e,t){if(!e)return!0;for(let n of e)if(t instanceof Set){if(t.has(n))return!0}else if(wP(n,t))return!0;return!1}function wP(e,t){return e===t||e!==e&&t!==t}function TP(e,t,n,r){let i;for(let a of Pj(t))wP(t[a],n[a])||r!==void 0&&CP([a],r)||(i??={...e},i[a]=t[a]);return i}var EP=100;function DP(e,t,n){if(t)for(let r of t){let t=e.get(r);t||(t=new Set,e.set(r,t)),t.add(n)}}function OP(e,t,n){if(e&&t)for(let r of t){let t=e.get(r);t&&(t.delete(n),t.size||e.delete(r))}}function kP(e){let t=new Set,n=e.currentListener;if(!n)return t;for(let r of e.keyedListeners)if(t.add(r),r===n)return t;return t.clear(),t.add(n),t}function AP(e){e.notifiedListeners??=kP(e)}function jP(e,t){if(!e.currentListener)return!1;let n=!1;for(let r of e.keyedListeners)if(r===e.currentListener)n=!0;else if(n&&r===t)return!1;let r=!1;for(let n of e.group.listeners){if(n===e.currentListener)return r;n===t&&(r=!0)}return!1}function MP(e,t,n){for(let r of e)if(r.group===t&&!r.recovering&&(!n||r.keyedListeners.has(n))){AP(r);for(let e of r.group.listeners){if(e===r.currentListener)break;jP(r,e)&&r.notifiedListeners?.add(e)}}}function NP(e,t,n){for(let r of e)r.group===t&&(r.recovering||jP(r,n)&&(AP(r),r.notifiedListeners?.add(n)))}function PP({fastPathFrames:e,group:t,keys:n,listener:r}){let i=t.listeners.has(r);for(let a of e)a.group===t&&(a.recovering||n.includes(a.updatedKey)&&(jP(a,r)?(AP(a),a.notifiedListeners?.add(r)):i&&(AP(a),a.recoverToLive=!0)))}function FP(e,t,n){for(let r of e)r.group===t&&r.notifiedListeners?.delete(n)}function IP({fastPathFrames:e,group:t,keys:n,listener:r}){for(let i of e)i.group===t&&(i.recovering||n.includes(i.updatedKey)&&i.keyedListeners.add(r))}function LP(e,t){if(!e.disposables.size)return;let n=e.disposables.get(t);n&&(e.disposables.delete(t),n())}function RP(e,t,n){let r=e.disposables.get(t);r?e.disposables.set(t,()=>{r(),n()}):e.disposables.set(t,n)}function zP(e,t,n,r,i,a){if(e.suspendCounts?.has(t))return;let{disposables:o}=e,s=o.size?o.get(t):void 0;if(s){o.delete(t);let e=n;s(),n=i?.()??n,n!==e&&(r=TP(r,n,e,a)??r)}let c=t(n,r);c&&RP(e,t,c)}function BP({group:e,getState:t,prevState:n,updatedKey:r,notifiedListeners:i}){let a=e.allKeysListeners;for(let o of e.listeners)i?.has(o)||(a?.has(o)||CP(e.listenerKeys.get(o),r))&&(i?.add(o),zP(e,o,t(),n,t,r))}function VP(e,...t){let n=e,r=n,i=bj,a=!1,o=!1,s=new Set,c=new Set,l=new Set,u={listeners:new Set,disposables:new Map,listenerKeys:new WeakMap},d={listeners:new Set,disposables:new Map,listenerKeys:new WeakMap},f=e=>(l.add(e),()=>l.delete(e)),p=()=>{let e=c.size,r=Symbol();c.add(r);let a=()=>{c.delete(r)&&(c.size||i())};if(e)return a;let o=Pj(n),s=[];for(let e of t){let n=e?.getState?.();if(!n)continue;let r=o.filter(e=>Tj(n,e));if(r.length){if(t.length===1||r.length===o.length)for(let t of r)s.push(GP(e,[t],e=>{T(t,e[t],!0)}));else{s.push(WP(e,r,(e,t)=>{for(let n of r)e[n]!==t[n]&&T(n,e[n],!0)}));for(let t of r){let n=e?.getState?.();n&&T(t,n[t],!0)}}}}let u=[];for(let e of l)u.push(e());let d=t.map(UP);return i=Ej(...s,...u,...d),a},m=(e,t,n)=>{n!==void 0&&(n?OP(e.listenersByKey,n,t):e.allKeysListeners?.delete(t))},h=[],g=(e,t,n=u)=>{let r=e?[...e]:null,i=n.listeners.has(t);return i||FP(h,n,t),r?PP({fastPathFrames:h,group:n,keys:r,listener:t}):(i&&MP(h,n),NP(h,n,t)),i&&(MP(h,n,t),m(n,t,n.listenerKeys.get(t))),n.listeners.add(t),r?(n.listenersByKey??=new Map,DP(n.listenersByKey,r,t),IP({fastPathFrames:h,group:n,keys:r,listener:t})):(n.allKeysListeners??=new Set,n.allKeysListeners.add(t)),n.listenerKeys.set(t,r),()=>{let e=n.disposables.get(t);n.disposables.delete(t),MP(h,n,t);let i=n.listenerKeys.get(t);m(n,t,r),i!==r&&m(n,t,i),n.listenerKeys.delete(t),n.listeners.delete(t),e?.()}},_=(e,t)=>g(e,t),v=(e,t,r)=>{let i=e.listeners.has(t);if(i){e.suspendCounts??=new Map;let n=e.suspendCounts.get(t)??0;e.suspendCounts.set(t,n+1)}let a;try{let i=n;LP(e,t),n!==i&&(a=TP(r,n,i));let o=t(n,a??r);o&&RP(e,t,o)}finally{if(i){let n=e.suspendCounts,r=n?.get(t);r&&r>1?n?.set(t,r-1):n?.delete(t),n?.size||delete e.suspendCounts}}},y=(e,t)=>(v(u,t,n),g(e,t)),b=(e,t)=>(!d.listeners.size&&!o&&(r=n),v(d,t,r),g(e,t,d)),x=e=>VP(Aj(n,e),E),S=e=>VP(kj(n,e),E),C=()=>n,w=(e,t,r)=>{if(!(r instanceof Set)&&!e.allKeysListeners?.size){let i=e.listenersByKey?.get(r);if(!i)return;let a={group:e,keyedListeners:i,updatedKey:r,currentListener:null};h.push(a);try{for(let o of i){if(a.notifiedListeners?.has(o)||(a.currentListener=o,a.notifiedListeners?.add(o),zP(e,o,n,t,C,r),!e.allKeysListeners?.size&&!a.recoverToLive))continue;let i=a.notifiedListeners??kP(a);a.notifiedListeners=i,a.recovering=!0,BP({group:e,getState:C,prevState:t,updatedKey:r,notifiedListeners:i});return}}finally{h.pop()}}else BP({group:e,getState:C,prevState:t,updatedKey:r})},T=(e,i,c=!1)=>{if(!Tj(n,e))return;let l=n[e],f=xj(i,()=>l);if(wP(f,l))return;let p=o;o=!0;let m=n,h={...n,[e]:f};n=h;let g=!1;try{if(!c&&t.length){for(let r of t)if(r?.setState?.(e,f),!wP(n[e],f)){g=!0;break}if(g){let r=0;for(;r<EP;r+=1){let r=!1;for(let i of t){let t=n[e];i?.setState?.(e,t),wP(n[e],t)||(r=!0)}if(!r)break}}}if(!g){let t=n===h?m:{...n,[e]:m[e]};w(u,t,e)}}finally{o=p}d.listeners.size?(s.add(e),a||(a=!0,queueMicrotask(()=>{a=!1;let e=n,t=s;s=new Set;let i=r;w(d,i,t),r===i&&(r=e)}))):o||(r=n)},E={getState:C,setState:T,__unstableInternals:{setup:f,init:p,subscribe:_,sync:y,batch:b,pick:x,omit:S}};return E}function HP(e,...t){if(e)return SP(e,`setup`)(...t)}function UP(e,...t){if(e)return SP(e,`init`)(...t)}function WP(e,...t){if(e)return SP(e,`subscribe`)(...t)}function GP(e,...t){if(e)return SP(e,`sync`)(...t)}function KP(e,...t){if(e)return SP(e,`batch`)(...t)}function qP(e,...t){if(e)return SP(e,`omit`)(...t)}function JP(e,...t){if(e)return SP(e,`pick`)(...t)}function YP(...e){let t={};for(let n of e){let e=n?.getState?.();e&&Object.assign(t,e)}let n=VP(t,...e);return Object.assign({},...e,n)}function XP(e){let t=e.find(e=>!!e.element),n=[...e].reverse().find(e=>!!e.element)?.element,r=t?.element?.parentElement;if(!n)return q(r).body;for(;r;){if(r.contains(n))return r;r=r.parentElement}return q(r).body}function ZP(e){return e?.__unstablePrivateStore}var QP=64;function $P(e,t){if(e.length<QP){t.ids&&=(t.items=void 0,void 0);return}if(t.items===e)return t.ids;let n=new Set;for(let t of e)n.add(t.id);return t.items=e,t.ids=n,n}function eF(e,t,n){if(e.length<QP)t.ids&&=(t.items=void 0,void 0);else{if(!n){n=new Set;for(let t of e)n.add(t.id)}t.items=e,t.ids=n}}function tF(e={}){e.store;let t=e.store?.getState(),n=K(e.items,t?.items,e.defaultItems,[]),r=ZP(e.store),i=r?.__unstableCollectionLookup??{controlledItems:new Map(n.map(e=>[e.id,e])),registeredItems:new Map,controlledItemsSource:n,propagatedItems:n},{controlledItems:a,registeredItems:o}=i,s={},c={},l={items:n,renderedItems:K(t?.renderedItems,[])},u=VP(l,e.store),d=Object.assign(VP({items:n,renderedItems:l.renderedItems},r),{__unstableCollectionLookup:i}),f=e=>{let t=fM(e,e=>e.element);d.setState(`renderedItems`,t),u.setState(`renderedItems`,t)},p=e=>{if(e!==i.controlledItemsSource){i.controlledItemsSource=e,a.clear();for(let t of e)a.set(t.id,t)}},m=(e,t)=>{e===`items`?u.setState(`items`,e=>{let n=xj(t,e);return n===e?e:(i.propagatedItems=n,p(n),n)}):u.setState(e,t)};HP(u,()=>UP(d)),r||(WP(u,[`items`],({items:e})=>{e!==i.propagatedItems&&(i.propagatedItems=e,p(e))}),HP(d,()=>KP(d,[`items`],({items:e})=>{i.propagatedItems=e,u.setState(`items`,e)}))),HP(d,()=>KP(d,[`renderedItems`],e=>{if(e.renderedItems!==u.getState().renderedItems&&f(e.renderedItems),typeof IntersectionObserver!=`function`)return;let t=!0,n=0,r=()=>{t?t=!1:(cancelAnimationFrame(n),n=requestAnimationFrame(()=>f(e.renderedItems)))},i=XP(e.renderedItems),a=new IntersectionObserver(r,{root:i});for(let t of e.renderedItems)t.element&&a.observe(t.element);return()=>{cancelAnimationFrame(n),a.disconnect()}}));let h=(e,t,n)=>{let r=n?.registeredItems,i=n?.controlledItems;return n=>{let a=r?.get(n.id),o=!!a||!!i?.has(n.id),s;return d.setState(e,e=>{let i=t.ids||e.length>=QP&&!o?$P(e,t):void 0,a=i&&!i.has(n.id)?-1:e.findIndex(({id:e})=>e===n.id),c=e.slice();if(a!==-1){s=e[a];let t={...s,...n};c[a]=t,r?.set(n.id,t)}else c.push(n),r?.set(n.id,n),i?.add(n.id);return(t.ids||a===-1&&c.length>=QP)&&eF(c,t,i),c}),()=>{r&&(a?r.set(n.id,a):r.delete(n.id)),d.setState(e,e=>{let r=t.ids?$P(e,t):void 0;if(!s){let i=e.filter(({id:e})=>e!==n.id);return r?.delete(n.id),t.ids&&eF(i,t,r),i}let i=e.findIndex(({id:e})=>e===n.id);if(i===-1)return e;let a=e.slice();return a[i]=s,t.ids&&eF(a,t,r),a})}}},g=h(`items`,s,i),_=h(`renderedItems`,c);return{...u,setState:m,registerItem:g,renderItem:e=>Ej(g(e),_(e)),item:e=>e?o.size?o.get(e)??a.get(e)??null:a.get(e)??null:null,__unstablePrivateStore:d}}var nF={id:null};function rF(e,t){return e.find(e=>t?!e.disabled&&e.id!==t:!e.disabled)}function iF(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n&&!n.disabled)return n}}function aF(e,t){return e.filter(e=>t?!e.disabled&&e.id!==t:!e.disabled)}function oF(e,t){return e.filter(e=>e.rowId===t)}function sF({items:e,fromIndex:t,step:n,rowId:r,excludeId:i}){for(let a=t;a>=0&&a<e.length;a+=n){let t=e[a];if(!t||t.rowId!==r||t.disabled)continue;let n=t.id;if(i==null||n!==i)return n}}function cF(e,t,n=!1){let r=e.findIndex(e=>e.id===t);return[...e.slice(r+1),...n?[nF]:[],...e.slice(0,r)]}var lF=48,uF=4;function dF(e){let t=[],n,r;for(let i of e){let e=i.rowId;if(n&&r===e){n.push(i);continue}let a=t.find(t=>t[0]?.rowId===e);a?(a.push(i),n=a):(n=[i],t.push(n)),r=e}return t}function fF(e){let t=e[0];if(!t)return[];let n=1;for(;n<e.length&&e[n]?.rowId===t.rowId;)n+=1;let r=e.slice(0,n);if(n===e.length)return[r];let i=[r],a;for(;n<e.length;n+=1){let t=e[n];if(!t)continue;let r=a?a.get(t.rowId):i.find(e=>e[0]?.rowId===t.rowId);if(r){r.push(t);continue}let o=[t];i.push(o),a?a.set(t.rowId,o):i.length===uF&&(a=new Map(i.map(e=>[e[0]?.rowId,e])))}return i}function pF(e){return e.length>=lF?fF(e):dF(e)}function mF(e){let t=0;for(let{length:n}of e)n>t&&(t=n);return t}function hF(e){return{id:`__EMPTY_ITEM__`,disabled:!0,rowId:e}}function gF(e,t,n){let r=mF(e);for(let i of e)for(let e=0;e<r;e+=1){let r=i[e];if(!r||n&&r.disabled){let r=e===0&&n?rF(i):i[e-1];i[e]=r&&t!==r.id&&n?r:hF(r?.rowId)}}return e}function _F(e){let t=pF(e),n=mF(t),r=[];for(let e=0;e<n;e+=1)for(let n of t){let t=n[e];t&&r.push({...t,rowId:t.rowId?`${e}`:void 0})}return r}function vF(e={}){let t=e.store?.getState(),n=tF(e),r=K(e.activeId,t?.activeId,e.defaultActiveId),i=K(t?.compositeElement,t?.baseElement,null),a=K(e.compositeElementInFocusOrder,e.includesBaseElement,t?.compositeElementInFocusOrder,t?.includesBaseElement,r===null),o=VP({...n.getState(),id:K(e.id,t?.id)??`id-${Math.random().toString(36).slice(2,8)}`,activeId:r,compositeElement:i,baseElement:i,compositeElementInFocusOrder:a,includesBaseElement:a,moves:K(t?.moves,0),orientation:K(e.orientation,t?.orientation,`both`),rtl:K(e.rtl,t?.rtl,!1),virtualFocus:K(e.virtualFocus,t?.virtualFocus,!1),focusLoop:K(e.focusLoop,t?.focusLoop,!1),focusWrap:K(e.focusWrap,t?.focusWrap,!1),focusShift:K(e.focusShift,t?.focusShift,!1)},n,e.store);HP(o,()=>Ej(GP(o,[`compositeElement`],e=>{o.setState(`baseElement`,e.compositeElement)}),GP(o,[`baseElement`],e=>{o.setState(`compositeElement`,e.baseElement)}),GP(o,[`compositeElementInFocusOrder`],e=>{o.setState(`includesBaseElement`,e.compositeElementInFocusOrder)}),GP(o,[`includesBaseElement`],e=>{o.setState(`compositeElementInFocusOrder`,e.includesBaseElement)}))),HP(o,()=>GP(o,[`renderedItems`,`activeId`],e=>{o.setState(`activeId`,t=>t===void 0?rF(e.renderedItems)?.id:t)}));let s=(e=`next`,t={})=>{let r=o.getState(),i=K(t.compositeElementInFocusOrder,t.includesBaseElement,r.compositeElementInFocusOrder),{skip:a=0,activeId:s=r.activeId,focusShift:c=r.focusShift,focusLoop:l=r.focusLoop,focusWrap:u=r.focusWrap,renderedItems:d=r.renderedItems,rtl:f=r.rtl}=t,p=e===`up`||e===`down`,m=e===`next`||e===`down`,h=m?f&&!p:!f||p,g=c&&!a;if(!a&&!u&&!i&&s!=null&&(!p||!g&&!d.some(e=>e.rowId!=null))){let e=-1;if(d===r.renderedItems){let t=d[0];if(t&&n.item(t.id)===t){let t=n.item(s);t?.id===s&&(e=d.indexOf(t))}}e===-1&&(e=d.findIndex(e=>e.id===s));let t=d[e];if(t){let n=h?-1:1,r=sF({items:d,fromIndex:e+n,step:n,rowId:t.rowId,excludeId:s});return r===void 0?l&&(p?l!==`horizontal`:l!==`vertical`)?sF({items:d,fromIndex:n===1?0:d.length-1,step:n,rowId:t.rowId,excludeId:s}):void 0:r}}let _=p?vj(gF(pF(d),s,g)):d;if(_=h?yj(_):_,_=p?_F(_):_,s==null)return rF(_)?.id;let v=_.find(e=>e.id===s);if(!v)return rF(_)?.id;let y=_.some(e=>e.rowId),b=_.indexOf(v),x=_.slice(b+1),S=oF(x,v.rowId);if(a){let e=aF(S,s);return(e.slice(a)[0]||e[e.length-1])?.id}let C=l&&(p?l!==`horizontal`:l!==`vertical`),w=y&&u&&(p?u!==`horizontal`:u!==`vertical`),T=m?(!y||p)&&C&&i:p?i:!1;if(C)return rF(cF(w&&!T?_:oF(_,v.rowId),s,T),s)?.id;if(w){let e=rF(T?S:x,s);return T?e?.id||null:e?.id}let E=rF(S,s);return!E&&T?null:E?.id},c=(e,t)=>typeof t==`number`?s(e,{skip:t}):s(e,t);return{...n,...o,setCompositeElement:e=>o.setState(`compositeElement`,e),setBaseElement:e=>o.setState(`compositeElement`,e),setActiveId:e=>o.setState(`activeId`,e),move:e=>{e!==void 0&&(o.setState(`activeId`,e),o.setState(`moves`,e=>e+1))},first:()=>rF(o.getState().renderedItems)?.id,last:()=>iF(o.getState().renderedItems)?.id,next:e=>c(`next`,e),previous:e=>c(`previous`,e),down:e=>c(`down`,e),up:e=>c(`up`,e)}}var yF=cF,bF=rF,xF=pF,SF=new WeakSet;function CF(e){Jj(e)===e&&(SF.add(e),queueMicrotask(()=>SF.delete(e)))}function wF(e){SF.delete(e)}function TF(e,t){let{virtualFocus:n,compositeElement:r}=e.getState();if(!n||!r||!nM(r)){t();return}let i=r.scrollLeft,a=r.scrollTop;t(),r.scrollLeft=i,r.scrollTop=a}function EF(e){let t=e.getState();return`contentElement`in t?t.contentElement:null}function DF(e){let{compositeElement:t}=e.getState(),n=aN(t);return n?t?.contains(n)||FF(e,n)?!0:!!EF(e)?.contains(n):!1}function OF({store:e,id:t,focus:n,markedOnly:r,requireFocus:i,focusOwner:a,scrollIntoView:o,onConsume:s}){let c=null,l,u=!1,d=!1,f=!1,p=!1,m=!1,h=e.getState().compositeElement,g=aN(h),_=i?a||g:null,v=!!h?.contains(g),y=t=>{if(!_)return!0;let n=aN(_);return n===_||n===t||DF(e)},b=e=>{if(`mounted`in e){if(e.mounted)p=!0;else if(p)return!0}if(`open`in e){if(e.open)m=!0;else if(m)return!0}return t!=null&&e.activeId!=null&&e.activeId!==t},x=(t,n)=>{if(!(`open`in t)||t.open)return!1;let r=EF(e);if(!r?.contains(n))return!1;let{compositeElement:i}=t;return!i||r.contains(i)?!1:tM(n)},S=n=>{let r=AF(e,l??(t===void 0?n.activeId:t));return r?.element?.isConnected?(l=r.id,r.element):null},C,w,T=()=>{f=!0,C?.(),w?.()},E=!1,ee=()=>{E||(E=!0,s?.())},te=()=>{if(!f)return ee(),T()},ne=()=>{if(f)return;let t=e.getState();if(b(t))return te();let i=!1;if(!c){if(c=S(t),!c)return}else if(!c.isConnected&&(i=u&&!d&&Jj(c)===q(c).body,c=S(t),!c))return te();if(i)u=!1;else if(!y(c))return te();let a=n&&v&&x(t,c);if(a){let{activeId:e}=t;if(e!=null&&e!==l)return te()}if(n&&!u&&!a){u=!0,ee(),d=!1;let t=c;C?.();let n=()=>{d=!SF.has(t)},r=()=>{d=!1};if(t.addEventListener(`blur`,n),t.addEventListener(`focus`,r),C=()=>{t.removeEventListener(`blur`,n),t.removeEventListener(`focus`,r)},TF(e,()=>{t.focus({preventScroll:!0})}),f)return}if(r&&!c.hasAttribute(`data-autofocus`))return a?void 0:te();tM(c)&&(`unstable_placing`in t&&t.unstable_placing||(a||te(),o?o(c):c.scrollIntoView({block:`nearest`,inline:`nearest`})))};return w=WP(e,[`activeId`,`items`,`mounted`,`open`,`unstable_placing`],ne),ne(),Object.assign(T,{settle:te})}function kF(e){let t=(0,D.useRef)(null),n=(0,D.useRef)(e),r=(0,D.useCallback)(()=>{t.current?.(),t.current=null},[]),i=(0,D.useCallback)(r=>{if(!e||n.current!==e)return;t.current?.settle(),t.current=null;let i=OF({store:e,...r});return t.current=i,i},[e]);return J(()=>(n.current=e,()=>{n.current=void 0,r()}),[e,r]),i}function AF(e,t){return t&&e.item(t)||null}function jF(e,t=!1){if(nM(e))e.setSelectionRange(t?e.value.length:0,e.value.length);else if(e.isContentEditable){let n=q(e).getSelection();n?.selectAllChildren(e),t&&n?.collapseToEnd()}}var MF=Symbol(`FOCUS_SILENTLY`);function NF(e){e[MF]=!0,e.focus({preventScroll:!0})}function PF(e){let t=e[MF];return delete e[MF],t}function FF(e,t,n){if(!t||t===n)return!1;let r=e.item(t.id);return!(!r||n&&r.element===n)}var IF=()=>()=>{};function LF(e){return Array.isArray(e)}function RF(e,t){return e===t||e!==e&&t!==t}function zF(e,t){if(e?.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n];if(!RF(r,t[n]))return!1}return!0}function BF(e){let[t,n]=D.useState(()=>e===null?null:[...e]);if(e===null)return t!==null&&n(null),null;if(zF(t,e))return t;let r=[...e];return n(r),r}function $(e,t=jj,n){let r=BF(LF(t)?t:typeof t==`function`?null:[t]),i=D.useCallback(t=>!e||r?.length===0?IF():WP(e,r,t),[e,r]),a=()=>{let r=e?.getState();if(LF(t))return n?.(r);if(typeof t==`function`)return t(r);if(r&&Tj(r,t))return r[t]};return(0,zE.useSyncExternalStore)(i,a,a)}function VF(e,t){let n=[],r=!1;for(let t in e){let i=e[t];i!==void 0&&(typeof i==`function`?r=!0:n.includes(i)||n.push(i))}if(!r)return n;if(!t)return null;for(let e of t)n.includes(e)||n.push(e);return n}function HF(e,t,n){let r=LF(t)?n??{}:t,i=LF(t)?t:void 0,a=D.useRef({}),o=BF(VF(r,i)),s=D.useCallback(t=>!e||o?.length===0?IF():WP(e,o,t),[e,o]),c=()=>{let t=e?.getState(),n=!1,i=a.current;for(let e in r){let a=r[e];if(a===void 0)continue;if(typeof a==`function`){let r=a(t);Object.is(r,i[e])||(i[e]=r,n=!0)}if(typeof a==`function`)continue;let o=t&&Tj(t,a)?t[a]:void 0;Object.is(o,i[e])||(i[e]=o,n=!0)}return n&&(a.current={...i}),a.current};return(0,zE.useSyncExternalStore)(s,c,c)}function UF(e,t,n,r){let i=Tj(t,n)?t[n]:void 0,a=r?t[r]:void 0,o=!!a,s=gN({value:i,setValue:a});J(()=>{if(o)return WP(e,[n],(e,t)=>{let{value:r,setValue:i}=s.current;i&&(RF(e[n],t[n])||RF(e[n],r)||i(e[n]))})},[e,n,o,s]),J(()=>{if(i!==void 0)return e.setState(n,i),KP(e,[n],()=>{i!==void 0&&e.setState(n,i)})})}function WF(e,t){let[n,r]=D.useState(()=>e(t));J(()=>UP(n),[n]);let i=D.useCallback(e=>$(n,e),[n]);return[D.useMemo(()=>({...n,useState:i}),[n,i]),Y(()=>{r(n=>e({...t,...n.getState()}))})]}var GF=`button`;function KF(e){return rM(e)?!0:e.tagName===`INPUT`&&!$j(e)}function qF(e,t=!1){let n=e.clientHeight,{top:r}=e.getBoundingClientRect(),i=Math.max(n*.875,n-40)*1.5,a=t?n-i+r:i+r;return e.tagName===`HTML`?a+e.scrollTop:a}function JF(e,t=!1){let{top:n}=e.getBoundingClientRect();return t?n+e.clientHeight:n}function YF(e,t,n,r=!1){if(!t||!n)return;let{renderedItems:i}=t.getState(),a=dM(e);if(!a)return;let o=qF(a,r),s,c;for(let e=0;e<i.length;e+=1){let i=s;if(s=n(e),!s)break;if(s===i)continue;let a=AF(t,s)?.element;if(!a)continue;let l=JF(a,r)-o,u=Math.abs(l);if(r&&l<=0||!r&&l>=0){c!==void 0&&c<u&&(s=i);break}c=u}return s}function XF(e,t){return!bM(e)&&FF(t,e.target)}var ZF=Q(function({store:e,rowId:t,preventScrollOnKeyDown:n=!1,moveOnKeyPress:r=!0,tabbable:i=!1,getItem:a,typeaheadText:o,"aria-setsize":s,"aria-posinset":c,unstable_scrollIntoView:l,...u}){let d=gP();e||=d;let f=$M(u),p=SN(u.id),m=(0,D.useRef)(null),h=(0,D.useRef)(null),g=(0,D.useCallback)(e=>{let t=h.current;!e&&t&&CF(t),e&&wF(e),h.current=e},[]),_=(0,D.useContext)(xP),v=Ij(u),y=v&&!f,b=v&&u.focusable===!1,x=u.shouldRegisterItem,S=e=>{if(t)return t;if(e&&_?.compositeElement&&_.compositeElement===e.compositeElement)return _.id},{rowId:C,compositeElement:w,ariaSetSize:T,ariaPosInSet:E}=HF(e,[`compositeElement`,`renderedItems`],{rowId:S,compositeElement(e){return e?.compositeElement||void 0},ariaSetSize(e){if(s!=null)return s;if(e&&_?.ariaSetSize&&_.compositeElement===e.compositeElement)return _.ariaSetSize},ariaPosInSet(e){if(c!=null)return c;if(!e||!_?.ariaPosInSet||_.compositeElement!==e.compositeElement)return;let t=S(e),n=e.renderedItems.filter(e=>e.rowId===t);return _.ariaPosInSet+n.findIndex(e=>e.id===p)}}),{isActiveItem:ee,isTabbable:te}=HF(e,[`activeId`,`compositeElement`,`renderedItems`,`virtualFocus`,`items`],{isActiveItem(e){return!!e&&e.activeId===p},isTabbable(t){if(!t||!t.compositeElement&&!t.renderedItems.length)return!0;if(t.virtualFocus)return!1;if(!t.renderedItems.length||i)return!0;if(t.activeId===null)return!1;let n=e?.item(t.activeId);return n?.disabled||!n?.element?!0:t.activeId===p}}),ne=(0,D.useCallback)(e=>{let t=(e.element?nN(e.element):void 0)??(b||y),n={...e,id:p||e.id,rowId:C,disabled:t,children:e.element?.textContent,typeaheadText:o};return a?a(n):n},[p,C,b,y,o,a]),re=u.onFocus,ie=(0,D.useRef)(!1),ae=(0,D.useRef)(null),oe=kF(e),se=Y(t=>{if(re?.(t),t.defaultPrevented||yM(t)||!p||!e||XF(t,e))return;let{virtualFocus:n,compositeElement:r}=e.getState();if(e.setActiveId(p),rM(t.currentTarget)&&jF(t.currentTarget),!n){bM(t)&&e.item(p)&&oe({id:p,markedOnly:!0,requireFocus:!0,scrollIntoView:l});return}if(!bM(t)||KF(t.currentTarget))return;let i=(t,n)=>{if(!PM(n))return;let r=t===n||FF(e,t);e.item(p)&&oe({id:p,markedOnly:!0,requireFocus:!0,scrollIntoView:l}),ie.current=!0,r?NF(n):n.focus({preventScroll:!0})};if(r?.isConnected){i(t.relatedTarget,r);return}if(x===!1)return;let{currentTarget:a,relatedTarget:o}=t,s=()=>{ae.current?.(),ae.current=null};s(),ae.current=WP(e,null,()=>{if(Jj(a)!==a){s();return}let t=e.getState(),n=t.compositeElement;n?.isConnected&&(s(),t.virtualFocus&&i(o,n))})}),ce=u.onBlurCapture,le=Y(t=>{ce?.(t),t.defaultPrevented||e?.getState()?.virtualFocus&&ie.current&&(ie.current=!1,t.preventDefault(),t.stopPropagation())}),ue=u.onKeyDown,de=DN(n),fe=DN(r),pe=Y(t=>{if(ue?.(t),t.defaultPrevented||!bM(t)||!e)return;let{currentTarget:n}=t,r=e.getState(),i=!!e.item(p)?.rowId,a=r.orientation!==`horizontal`,o=r.orientation!==`vertical`,s=()=>!(!i&&!o&&r.compositeElement&&nM(r.compositeElement)),c={ArrowUp:(i||a)&&e.up,ArrowRight:(i||o)&&e.next,ArrowDown:(i||a)&&e.down,ArrowLeft:(i||o)&&e.previous,Home:()=>{if(s())return!i||t.ctrlKey?e?.first():e?.previous(-1)},End:()=>{if(s())return!i||t.ctrlKey?e?.last():e?.next(-1)},PageUp:()=>YF(n,e,e?.up,!0),PageDown:()=>YF(n,e,e?.down)}[t.key];if(c){if(rM(n)){let e=aM(n),r=o&&t.key===`ArrowLeft`,i=o&&t.key===`ArrowRight`,s=a&&t.key===`ArrowUp`,c=a&&t.key===`ArrowDown`;if(i||c){let{length:t}=iM(n);if(e.end!==t)return}else if((r||s)&&e.start!==0)return}let r=c();if(de(t)||r!==void 0){if(!fe(t))return;t.preventDefault(),e.move(r)}}}),me=(0,D.useMemo)(()=>({id:p,compositeElement:w}),[p,w]);return u=ON(u,e=>(0,O.jsx)(bP.Provider,{value:me,children:e}),[me]),u={"data-active-item":ee||void 0,...u,id:p,ref:vN(m,g,u.ref),tabIndex:te?u.tabIndex:-1,onFocus:se,onBlurCapture:le,onKeyDown:pe},u=cP(u),u=mP({store:e,...u,getItem:ne,shouldRegisterItem:p?x:!1}),{...u,"aria-setsize":T,"aria-posinset":E}}),QF=zN(X(function(e){return Z(GF,ZF(gj(e)))})),$F=BN([vP],[yP]);$F.useContext;var eI=$F.useScopedContext,tI=$F.useProviderContext,nI=$F.ContextProvider,rI=$F.ScopedContextProvider,iI=`button`,aI=Q(function({store:e,getItem:t,...n}){let r=eI();e||=r,Nj(e,!1);let i=SN(),a=n.id||i,o=Ij(n),s=(0,D.useCallback)(e=>{let n={...e,dimmed:o};return t?t(n):n},[o,t]),c=n.onClick,l=Y(t=>{c?.(t),t.defaultPrevented||e?.setSelectedId(a)}),u=$(e.panels,[`items`],()=>e.panel(a)?.id),d=i?n.shouldRegisterItem:!1,f=$(e,[`selectedId`],e=>!!a&&e.selectedId===a),p=$(e.composite?e:void 0,[`activeId`,`items`,`selectedId`],t=>!t||!a?!1:t.activeId===a||t.selectedId===a&&!e.item(t.activeId)),m=f||(n.accessibleWhenDisabled??!0);if($(e.combobox||e.composite,`virtualFocus`)&&(n={...n,tabIndex:-1}),n={role:`tab`,"aria-selected":f,"aria-controls":u||void 0,...n,id:a,onClick:l},e.composite){let t={id:a,accessibleWhenDisabled:m,store:e.composite,shouldRegisterItem:p&&d,rowId:n.rowId,render:n.render};n={...n,render:(0,O.jsx)(QF,{...t,render:e.combobox&&e.composite!==e.combobox?(0,O.jsx)(QF,{...t,store:e.combobox}):t.render})}}return n=ZF({store:e,...n,accessibleWhenDisabled:m,getItem:s,shouldRegisterItem:d}),n}),oI=zN(X(function(e){return Z(iI,aI(gj(e)))})),sI=new WeakMap;function cI(e,t,n){let{KeyboardEvent:r}=qj(e),i=new r(t.type,n);return sI.set(i,lI(t)),e.dispatchEvent(i)}function lI(e){return sI.get(e)??e}var uI=Symbol(`cancelled`),dI=new WeakMap;function fI(e,t){let n=e.getState,r=dI.get(n);if(r)return r;let i=t?.getState();if(t&&i&&Tj(i,`moves`)&&Tj(i,`activeId`)){let e=fI(t);return dI.set(n,e),e}let a={consumedBy:null,targetId:e.getState().activeId};return dI.set(n,a),GP(e,[`moves`,`activeId`],(e,t)=>{e.moves===t.moves?e.activeId!==t.activeId&&(a.targetId=uI):(a.consumedBy=null,a.targetId=e.activeId)}),a}var pI=`div`;function mI(e){return e.some(e=>!!e.rowId)}function hI(e){let t=e.target;return t&&!nM(t)?!1:e.key.length===1&&!e.ctrlKey&&!e.metaKey}function gI(e){return e.key===`Shift`||e.key===`Control`||e.key===`Alt`||e.key===`Meta`}function _I(e,t,n){return Y(r=>{if(t?.(r),r.defaultPrevented||r.isPropagationStopped()||!bM(r)||gI(r)||hI(r))return;let i=AF(e,e.getState().activeId)?.element;if(!i)return;let{view:a,...o}=r;i!==n?.current&&i.focus({preventScroll:!0}),cI(i,r.nativeEvent,o)||r.preventDefault(),r.currentTarget.contains(i)&&r.stopPropagation()})}function vI(e){return bF(vj(yj(xF(e))))}function yI(e,t){let{consumedBy:n}=fI(e);return!n||n===t}function bI(e,t,n){e.getState().moves===n&&(fI(e).consumedBy=t)}var xI=zN(function({store:e,focusOnMove:t,previousElementRef:n,present:r,scrollIntoView:i}){let a=$(e,`moves`),o=$(e,`compositeElement`),s=(0,D.useMemo)(()=>({}),[e.getState]);return(0,D.useEffect)(()=>{let n=fI(e);if(!a||!t||!yI(e,s))return;let{activeId:o}=e.getState();if(o!=null&&o===n.targetId)return r({id:o,requireFocus:DF(e),focus:!0,scrollIntoView:i,onConsume:()=>bI(e,s,a)})},[e,a,t,o,r,i,s]),J(()=>{let t=fI(e);if(!a||!o||!yI(e,s))return;let{activeId:r}=e.getState();if(r!==null||r!==t.targetId)return;bI(e,s,a);let i=n.current;n.current=null,i&&TM(i,{relatedTarget:o}),GM(o)||(PM(o)&&o.scrollIntoView({block:`nearest`,inline:`nearest`}),o.focus({preventScroll:!0}))},[e,a,o,n,s]),null}),SI=Q(function({store:e,composite:t=!0,focusOnMove:n=t,moveOnKeyPress:r=!0,unstable_scrollIntoView:i,...a}){let o=_P();e||=o,Nj(e,!1);let s=(0,D.useRef)(null),c=(0,D.useRef)(null),l=kF(e),[,u]=_N(t?e.setCompositeElement:null),d=$(e,`virtualFocus`),f=$(e,t&&d?[`activeId`]:[],e=>t&&d?e.activeId:null);J(()=>{if(!e||!t||!d)return;let n=c.current;if(c.current=null,!n)return;let r=AF(e,f)?.element||Jj(n);r!==n&&TM(n,{relatedTarget:r})},[e,f,d,t]);let p=_I(e,a.onKeyDownCapture,c),m=_I(e,a.onKeyUpCapture,c),h=a.onFocusCapture,g=Y(t=>{if(h?.(t),t.defaultPrevented||!e)return;let{virtualFocus:n}=e.getState();if(!n)return;let r=t.relatedTarget,i=PF(t.currentTarget);bM(t)&&i&&(t.stopPropagation(),c.current=r)}),_=a.onFocus,v=Y(n=>{if(_?.(n),n.defaultPrevented||!t||!e)return;let{relatedTarget:r}=n,{virtualFocus:a}=e.getState();if(a)bM(n)&&!FF(e,r)&&queueMicrotask(()=>l({focus:!0,markedOnly:!0,requireFocus:!0,scrollIntoView:i}));else if(bM(n)){if(!FF(e,r)){let{activeId:t}=e.getState();t!=null&&l({id:t,markedOnly:!0,requireFocus:!0,scrollIntoView:i})}e.setActiveId(null)}}),y=a.onBlurCapture,b=Y(t=>{if(y?.(t),t.defaultPrevented||!e)return;let{virtualFocus:n,activeId:r,compositeElement:i}=e.getState();if(!n||t.currentTarget!==i)return;let a=AF(e,r)?.element,o=t.relatedTarget,s=FF(e,o),l=c.current;c.current=null,bM(t)&&s?(o===a?l&&l!==o&&TM(l,t):a?TM(a,t):l&&TM(l,t),t.stopPropagation()):!FF(e,t.target)&&a&&TM(a,t)}),x=a.onKeyDown,S=DN(r),C=Y(t=>{if(x?.(t),t.nativeEvent.isComposing||t.defaultPrevented||!e||!bM(t))return;let{orientation:n,items:r,renderedItems:i,activeId:a,rtl:o}=e.getState(),s=AF(e,a);if(s?.element?.isConnected)return;let c=s&&a!=null,l=c?r:i,u=n!==`horizontal`,d=n!==`vertical`,f=mI(l);if((t.key===`ArrowLeft`||t.key===`ArrowRight`||t.key===`Home`||t.key===`End`)&&nM(t.currentTarget))return;let p={ArrowUp:(f||u)&&(()=>c?e.up({activeId:a,renderedItems:l}):f?vI(i)?.id:e?.last()),ArrowRight:(f||d)&&(()=>c?e.next({activeId:a,renderedItems:l}):o?e.last():e.first()),ArrowDown:(f||u)&&(()=>c?e.down({activeId:a,renderedItems:l}):e.first()),ArrowLeft:(f||d)&&(()=>c?e.previous({activeId:a,renderedItems:l}):o?e.first():e.last()),Home:e.first,End:e.last,PageUp:e.first,PageDown:e.last}[t.key];if(p){let n=p();if(n!==void 0){if(!S(t))return;t.preventDefault(),e.move(n)}}});return a=ON(a,r=>(0,O.jsxs)(yP,{value:e,children:[r,t&&(0,O.jsx)(xI,{store:e,focusOnMove:n,previousElementRef:c,present:l,scrollIntoView:i})]}),[e,t,n,l]),a={"aria-activedescendant":$(e,t&&d?[`items`]:[],()=>{if(e&&t&&d)return AF(e,f)?.id}),...a,ref:vN(s,u,a.ref),onKeyDownCapture:p,onKeyUpCapture:m,onFocusCapture:g,onFocus:v,onBlurCapture:b,onKeyDown:C},a=iP({focusable:$(e,t&&!d?[`activeId`]:[],e=>t&&(d||e.activeId===null)),...a}),a});X(function(e){return Z(pI,SI(e))});var CI=`div`,wI=Q(function({store:e,...t}){let n=tI();e||=n,Nj(e,!1);let r=$(e,[`orientation`],e=>e.orientation===`both`?void 0:e.orientation);return t=ON(t,t=>(0,O.jsx)(rI,{value:e,children:t}),[e]),e.composite&&(t={focusable:!1,...t}),t={role:`tablist`,"aria-orientation":r,...t},t=SI({store:e,...t}),t}),TI=X(function(e){return Z(CI,wI(e))}),EI=BN();EI.useContext,EI.useScopedContext;var DI=EI.useProviderContext,OI=EI.ContextProvider,kI=EI.ScopedContextProvider,AI=BN([OI],[kI]);AI.useContext,AI.useScopedContext;var jI=AI.useProviderContext,MI=AI.ContextProvider,NI=AI.ScopedContextProvider,PI=(0,D.createContext)(void 0),FI=(0,D.createContext)(void 0),II=`div`;function LI(e,t){let n=setTimeout(t,e);return()=>clearTimeout(n)}function RI(e){let t=e?.trim()||`0s`,n=t.endsWith(`ms`)?1:1e3,r=Number.parseFloat(t)*n;return Number.isNaN(r)?0:r}function zI(e,t,n){let r=e.split(`,`),i=t.split(`,`),a=n.split(`,`),o=0;for(let[e,t]of r.entries()){if(t.trim()===`none`)continue;let n=RI(i[e%i.length]),r=RI(a[e%a.length]);o=Math.max(o,n+r)}return o}function BI(e){let{transitionProperty:t,transitionDuration:n,transitionDelay:r,animationName:i,animationDuration:a,animationDelay:o}=getComputedStyle(e);return Math.max(zI(t,r,n),zI(i,o,a))}function VI(e,t,n){return!n&&t!==!1&&(!e||!!t)}var HI=Q(function({store:e,alwaysVisible:t,unstable_otherElementRef:n,...r}){let i=DI();e||=i,Nj(e,!1);let a=(0,D.useRef)(null),o=SN(r.id),[s,c]=(0,D.useState)(null),{open:l,mounted:u,animated:d,contentElement:f}=HF(e,{open:`open`,mounted:`mounted`,animated:`animated`,contentElement:`contentElement`}),p=$(e.disclosure,`contentElement`),m=(0,D.useRef)(!1);J(()=>{a.current&&e?.setContentElement(a.current)},[e]),J(()=>{let t;return e?.setState(`animated`,e=>(t=e,!0)),()=>{t!==void 0&&e?.setState(`animated`,t)}},[e]),J(()=>{if(!d)l?m.current&&(m.current=!1,c(`enter`)):(m.current=!0,c(null));else if(!f?.isConnected)c(null);else return Mj(()=>{c(l?`enter`:u?`leave`:null)})},[d,f,l,u]),J(()=>{if(!e||!d||!s||!f)return;let t=()=>e?.setState(`animating`,!1),r=()=>(0,RE.flushSync)(t);if(s===`leave`&&l||s===`enter`&&!l)return;if(typeof d==`number`)return LI(d,r);let i=[f];p&&i.push(p);let a=n?.current;a&&i.push(a);let o=Math.max(...i.map(BI));if(!o)s===`enter`&&e.setState(`animated`,!1),t();else return LI(Math.max(o-1e3/60,0),r)},[e,d,f,p,n,l,s]),r=ON(r,t=>(0,O.jsx)(NI,{value:e,children:t}),[e]);let h=VI(u,r.hidden,t),g=r.style,_=(0,D.useMemo)(()=>h?{...g,display:`none`}:g,[h,g]);return r={"data-open":l||void 0,"data-enter":s===`enter`||void 0,"data-leave":s===`leave`||void 0,hidden:h,...r,id:o,ref:vN(o?e.setContentElement:null,a,r.ref),style:_},Rj(r)}),UI=X(function(e){return Z(II,HI(e))});X(function({unmountOnHide:e,...t}){let n=DI();return $(t.store||n,[`mounted`],t=>!e||t?.mounted)===!1?null:(0,O.jsx)(UI,{...t})});function WI(e){let t=e?.unstable_onHideRequest,n=e?.unstable_requestHide;if(t&&n)return{onHideRequest:t,requestHide:n}}function GI(e={}){let t=e.store||e.disclosure?YP(e.store,qP(e.disclosure,[`contentElement`,`disclosureElement`])):void 0,n=t?.getState(),r=K(e.open,n?.open,e.defaultOpen,!1),i=K(e.animated,n?.animated,!1),a={open:r,animated:i,animating:!!i&&r,mounted:r,contentElement:K(n?.contentElement,null),disclosureElement:K(n?.disclosureElement,null)},o=t?VP(a,t):VP(a);HP(o,()=>GP(o,[`animated`,`animating`],e=>{e.animated||o.setState(`animating`,!1)})),HP(o,()=>WP(o,[`open`],()=>{o.getState().animated&&o.setState(`animating`,!0)})),HP(o,()=>GP(o,[`open`,`animating`],e=>{o.setState(`mounted`,e.open||e.animating)}));let s=WI(e.store),c=new Map,l=s?.onHideRequest??(e=>e===u?()=>{}:(c.set(e,(c.get(e)??0)+1),()=>{let t=c.get(e);t!=null&&(t>1?c.set(e,t-1):c.delete(e))})),u=s?.requestHide??(e=>{let t=[...c.keys()],n=r=>{let i=t[r];i?i(()=>n(r+1)):e()};n(0)});HP(o,()=>{if(e.disclosure)return l(e.disclosure.unstable_requestHide)});let d=e=>{let{open:t}=o.getState(),n=xj(e,t);!t||n?o.setState(`open`,n):u(()=>o.setState(`open`,!1))};return{...o,disclosure:e.disclosure,setOpen:d,show:()=>o.setState(`open`,!0),hide:()=>d(!1),toggle:()=>d(e=>!e),unstable_onHideRequest:l,unstable_requestHide:u,stopAnimation:()=>o.setState(`animating`,!1),setContentElement:e=>o.setState(`contentElement`,e),setDisclosureElement:e=>o.setState(`disclosureElement`,e)}}function KI(e,t,n){return TN(t,[n.store,n.disclosure,t]),UF(e,n,`open`,`setOpen`),UF(e,n,`mounted`,`setMounted`),UF(e,n,`animated`),Object.assign(e,{disclosure:n.disclosure})}function qI(e={}){let[t,n]=WF(GI,e);return KI(t,n,e)}var JI=`div`,YI=Q(function({store:e,unmountOnHide:t,tabId:n,getItem:r,scrollRestoration:i,scrollElement:a,...o}){let s=tI();e||=s,Nj(e,!1);let c=(0,D.useRef)(null),l=SN(o.id),u=$(n?void 0:e.panels,[`items`],()=>n||e?.panels.item(l)?.tabId),d=qI({open:$(e,[`selectedId`],e=>!!u&&e.selectedId===u)}),f=$(d,`mounted`),p=(0,D.useRef)(null),m=Y(()=>{let e=c.current;return e?a?typeof a==`function`?a(e):`current`in a?a.current:a:e:null});(0,D.useEffect)(()=>{if(!i||!f)return;let e=m();if(!e)return;if(i===`reset`){e.scroll(0,0);return}if(!u)return;let t=p.current;t||(t=new Map,p.current=t);let n=t.get(u);e.scroll(n?.x??0,n?.y??0);let r=()=>{t.set(u,{x:e.scrollLeft,y:e.scrollTop})};return e.addEventListener(`scroll`,r),()=>{e.removeEventListener(`scroll`,r)}},[i,f,u,m]);let[h,g]=(0,D.useState)(!1);J(()=>{if(!f)return;let e=c.current;e&&g(!!zM(e))},[f,u]);let _=(0,D.useCallback)(e=>{let t={...e,id:l||e.id,tabId:n};return r?r(t):t},[l,n,r]),v=o.onKeyDown,y=Y(t=>{if(v?.(t),t.defaultPrevented||!e?.composite)return;let n={ArrowLeft:e.previous,ArrowRight:e.next,Home:e.first,End:e.last}[t.key];if(!n)return;let{selectedId:r}=e.getState(),i=n({activeId:r});i&&(t.preventDefault(),e.move(i))});return o=ON(o,t=>(0,O.jsx)(rI,{value:e,children:t}),[e]),o={role:`tabpanel`,"aria-labelledby":o[`aria-label`]==null&&u||void 0,...o,id:l,children:t&&!f?null:o.children,ref:vN(c,o.ref),onKeyDown:y},o=iP({focusable:!e.composite&&!h,...o}),o=HI({store:d,...o}),o=mP({store:e.panels,...o,getItem:_}),o}),XI=X(function(e){return Z(JI,YI(e))}),ZI=BN([MI],[NI]),QI=ZI.useContext;ZI.useScopedContext;var $I=ZI.useProviderContext,eL=ZI.ContextProvider,tL=ZI.ScopedContextProvider;(0,D.createContext)(null);var nL=BN([eL,vP],[tL,yP]),rL=nL.useContext;nL.useScopedContext;var iL=nL.useProviderContext;nL.ContextProvider,nL.ScopedContextProvider,(0,D.createContext)(void 0),(0,D.createContext)(!1),(0,D.createContext)(null);function aL(e,t,n){return TN(t,[n.store,t]),UF(e,n,`items`,`setItems`),e}function oL(e){return{id:SN(e.id),...e}}function sL(e,t,n){e=aL(e,t,n),fI(e,n.store),UF(e,n,`activeId`,`setActiveId`);let r={compositeElementInFocusOrder:n.compositeElementInFocusOrder??n.includesBaseElement};return UF(e,r,`compositeElementInFocusOrder`),UF(e,n,`virtualFocus`),UF(e,n,`orientation`),UF(e,n,`rtl`),UF(e,n,`focusLoop`),UF(e,n,`focusWrap`),UF(e,n,`focusShift`),e}var cL=BN([eL,vP],[tL,yP]),lL=cL.useContext,uL=cL.useScopedContext,dL=cL.useProviderContext,fL=cL.ContextProvider,pL=cL.ScopedContextProvider,mL=(0,D.createContext)(!1),hL=(0,D.createContext)(null);function gL(e){let t=e[0]?.element;if(!t)return;let n=Jj(t);if(n)return e.find(e=>e.element===n)}function _L(e,t){if(t!=null)return e.find(e=>e.id===t)}function vL(e){return!(!e||e.disabled||e.dimmed)}function yL(){let e=tF(),t=new Map;return GP(e,[`items`],e=>{t.clear();for(let n of e.items){let{tabId:e}=n;e!=null&&(t.has(e)||t.set(e,n))}}),{panels:e,panel:e=>e==null?null:t.get(e)||null}}function bL({composite:e,combobox:t,...n}={}){let r=[`items`,`renderedItems`,`moves`,`orientation`,`virtualFocus`,`compositeElementInFocusOrder`,`includesBaseElement`,`compositeElement`,`baseElement`,`focusLoop`,`focusShift`,`focusWrap`,`selectOnMove`],i=YP(n.store,qP(e,r),qP(t,r)),a=i?.getState(),o=vF({...n,store:i,compositeElementInFocusOrder:K(n.compositeElementInFocusOrder,n.includesBaseElement,a?.compositeElementInFocusOrder,a?.includesBaseElement,!1),orientation:K(n.orientation,a?.orientation,`horizontal`),focusLoop:K(n.focusLoop,a?.focusLoop,!0)}),{panels:s,panel:c}=yL(),l=VP({...o.getState(),selectedId:K(n.selectedId,a?.selectedId,n.defaultSelectedId),selectOnMove:K(n.selectOnMove,a?.selectOnMove,!0)},o,i);HP(l,()=>GP(l,[`moves`],()=>{let{activeId:e,selectOnMove:t}=l.getState();if(!t||!e)return;let n=o.item(e);vL(n)&&l.setState(`selectedId`,n.id)}));let u=!1,d;HP(l,()=>(u=!1,KP(l,[`selectedId`],(t,n)=>{if(u&&(u=!1,t.selectedId===d)||e&&t.selectedId===n.selectedId)return;let{activeId:r,renderedItems:i}=l.getState();if(r===t.selectedId)return;let a=gL(i),s=_L(i,t.selectedId);a&&vL(s)?o.move(s.id):l.setState(`activeId`,t.selectedId)}))),HP(l,()=>GP(l,[`selectedId`,`renderedItems`],e=>{if(e.selectedId!==void 0)return;let{activeId:t,renderedItems:n}=l.getState(),r=o.item(t);if(vL(r))l.setState(`selectedId`,r.id);else{let e=n.find(vL);l.setState(`selectedId`,e?.id)}})),HP(l,()=>GP(l,[`renderedItems`],e=>{let t=e.renderedItems;if(t.length)return GP(s,[`renderedItems`],e=>{let n=e.renderedItems;n.some(e=>!e.tabId)&&n.forEach((e,n)=>{if(e.tabId)return;let r=t[n];r&&s.renderItem({...e,tabId:r.id})})})}));let f=null;return HP(l,()=>{let n=()=>{f=l.getState().selectedId},r=()=>{let{selectedId:e}=l.getState();e!==f&&(u=!0,d=f,l.setState(`selectedId`,f))},i=!!e&&`setSelectedValue`in e,a=i?e:t;if(e&&!i&&`setSelectElement`in e)return Ej(GP(e,[`value`],n),GP(e,[`mounted`],r));if(a)return Ej(GP(a,[`selectedValue`],n),GP(a,[`mounted`],r))}),{...o,...l,panels:s,panel:c,setSelectedId:e=>l.setState(`selectedId`,e),select:e=>{l.setState(`selectedId`,e),o.move(e)}}}function xL(e,t,n){TN(t,[n.composite,n.combobox,t]);let r=sL(e,t,n);UF(r,n,`selectedId`,`setSelectedId`),UF(r,n,`selectOnMove`);let[i,a]=WF(()=>r.panels,{});return TN(a,[r,a]),Object.assign((0,D.useMemo)(()=>({...r,panels:i}),[r,i]),{composite:n.composite,combobox:n.combobox})}function SL(e={}){let t=rL(),n=lL()||t,r={...e,composite:e.composite===void 0?n:e.composite,combobox:e.combobox===void 0?t:e.combobox},[i,a]=WF(bL,r);return xL(i,a,r)}function CL(e={}){let t=SL(e);return(0,O.jsx)(nI,{value:t,children:e.children})}var wL=BN([vP],[yP]),TL=wL.useContext;wL.useScopedContext;var EL=wL.useProviderContext;wL.ContextProvider;var DL=wL.ScopedContextProvider;function OL(e={}){let t=e.store?.getState();return vF({...e,orientation:K(e.orientation,t?.orientation,`horizontal`),focusLoop:K(e.focusLoop,t?.focusLoop,!0)})}function kL(e,t,n){return sL(e,t,n)}function AL(e={}){let[t,n]=WF(OL,e);return kL(t,n,e)}var jL=`div`,ML=Q(function({store:e,orientation:t,virtualFocus:n,focusLoop:r,rtl:i,...a}){let o=EL();e||=o;let s=AL({store:e,orientation:t,virtualFocus:n,focusLoop:r,rtl:i}),c=$(s,[`orientation`],e=>e.orientation===`both`?void 0:e.orientation);return a=ON(a,e=>(0,O.jsx)(DL,{value:s,children:e}),[s]),a={role:`toolbar`,"aria-orientation":c,...a},a=SI({store:s,...a}),a}),NL=X(function(e){return Z(jL,ML(e))}),PL=`button`,FL=Q(function({store:e,...t}){let n=TL();return e||=n,t=ZF({store:e,...t}),t}),IL=zN(X(function(e){return Z(PL,FL(gj(e)))})),LL=`hr`,RL=Q(function({orientation:e=`horizontal`,...t}){return t={role:`separator`,"aria-orientation":e,...t},t});X(function(e){return Z(LL,RL(e))});var zL=`hr`,BL=Q(function({store:e,orientation:t,...n}){let r=gP();e||=r,Nj(e,!1);let i=$(e,[`orientation`],e=>t??(e.orientation===`horizontal`?`vertical`:`horizontal`));return n=RL({...n,orientation:i}),n});X(function(e){return Z(zL,BL(e))});var VL=`div`,HL=Q(function({autoFocusOnShow:e=!0,...t}){return t=ON(t,t=>(0,O.jsx)(sN.Provider,{value:e,children:t}),[e]),t});X(function(e){return Z(VL,HL(e))});var UL=(0,D.createContext)(0);function WL({level:e,children:t}){let n=(0,D.useContext)(UL),r=Math.max(Math.min(e||n+1,6),1);return(0,O.jsx)(UL.Provider,{value:r,children:t})}var GL=`span`;function KL(e){return{borderWidth:0,clipPath:`inset(50%)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,whiteSpace:`nowrap`,width:`1px`,...e}}var qL=Q(function(e){return e={...e,style:KL(e.style)},e});X(function(e){return Z(GL,qL(e))});var JL=`span`,YL=Q(function(e){return e={"data-focus-trap":``,tabIndex:0,"aria-hidden":!0,...e,style:{position:`fixed`,top:0,left:0,...e.style}},e=qL(e),e}),XL=X(function(e){return Z(JL,YL(e))}),ZL=(0,D.createContext)(null),QL=`div`;function $L(e){let t=q(e),{fullscreenElement:n}=t,r=qj(e).HTMLElement;return r&&n instanceof r?n:t.body}function eR(e,t){return t?typeof t==`function`?t(e):t:q(e).createElement(`div`)}function tR(e=`id`){return`${e?`${e}-`:``}${Math.random().toString(36).slice(2,8)}`}function nR(e){queueMicrotask(()=>{e?.focus()})}function rR(e,t){return{ref:e,node:t,cleanup:cN(e,t)}}function iR(e){typeof e.cleanup==`function`?e.cleanup():cN(e.ref,null)}var aR=Q(function({preserveTabOrder:e,preserveTabOrderAnchor:t,portalElement:n,portalRef:r,portal:i=!0,...a}){let o=(0,D.useRef)(null),s=vN(o,a.ref),c=(0,D.useContext)(ZL),[l,u]=(0,D.useState)(null),[d,f]=(0,D.useState)(null),p=(0,D.useRef)(null),m=(0,D.useRef)(null),h=(0,D.useRef)(null),g=(0,D.useRef)(null),_=gN(r),v=(0,D.useRef)(null);return J(()=>{let e=o.current;if(!e||!i){u(null);return}let t=eR(e,n);if(!t){u(null);return}let r=t.isConnected;return r||(c||$L(e)).appendChild(t),t.id||=e.id?`portal/${e.id}`:tR(),u(t),v.current=rR(_.current,t),()=>{let e=v.current;e&&(v.current=null,iR(e)),r||t.remove()}},[i,n,c,_]),J(()=>{let e=v.current;e&&e.ref!==r&&(iR(e),v.current=rR(r,e.node))},[r]),(0,D.useEffect)(()=>{if(!l||c||n)return;let e=q(l),t=()=>{let e=$L(l);l.parentElement!==e&&e.appendChild(l)};return l.isConnected&&t(),e.addEventListener(`fullscreenchange`,t),()=>{e.removeEventListener(`fullscreenchange`,t)}},[l,c,n]),J(()=>{if(!i||!e||!t)return;let n=q(t).createElement(`span`);return n.style.position=`fixed`,t.insertAdjacentElement(`afterend`,n),f(n),()=>{n.remove(),f(null)}},[i,e,t]),(0,D.useEffect)(()=>{if(!l||!e)return;let t=0,n=e=>{if(!kM(e))return;let n=e.type===`focusin`;if(cancelAnimationFrame(t),n)return YM(l);t=requestAnimationFrame(()=>{JM(l,!0)})};return l.addEventListener(`focusin`,n,!0),l.addEventListener(`focusout`,n,!0),()=>{cancelAnimationFrame(t),l.removeEventListener(`focusin`,n,!0),l.removeEventListener(`focusout`,n,!0)}},[l,e]),a=ON(a,t=>{if(t=(0,O.jsx)(ZL.Provider,{value:l||c,children:t}),!i)return t;if(!l)return(0,O.jsx)(`span`,{ref:s,id:a.id,style:{position:`fixed`},hidden:!0});t=(0,O.jsxs)(O.Fragment,{children:[e&&(0,O.jsx)(XL,{ref:m,"data-focus-trap":a.id,className:`__focus-trap-inner-before`,onFocus:e=>{kM(e,l)?nR(HM()):nR(p.current)}}),t,e&&(0,O.jsx)(XL,{ref:h,"data-focus-trap":a.id,className:`__focus-trap-inner-after`,onFocus:e=>{kM(e,l)?nR(WM()):nR(g.current)}})]}),t=(0,RE.createPortal)(t,l);let n=(0,O.jsxs)(O.Fragment,{children:[e&&(0,O.jsx)(XL,{ref:p,"data-focus-trap":a.id,className:`__focus-trap-outer-before`,onFocus:e=>{e.relatedTarget!==g.current&&kM(e,l)?nR(m.current):nR(WM())}}),e&&(0,O.jsx)(`span`,{"aria-owns":l.id,style:{position:`fixed`}}),e&&(0,O.jsx)(XL,{ref:g,"data-focus-trap":a.id,className:`__focus-trap-outer-after`,onFocus:e=>{if(kM(e,l))nR(h.current);else{let e=HM();if(e===m.current){requestAnimationFrame(()=>HM()?.focus());return}nR(e)}}})]});return d&&e&&(n=(0,RE.createPortal)(n,d)),(0,O.jsxs)(O.Fragment,{children:[n,t]})},[l,c,i,a.id,e,d]),a={...a,ref:s},a});X(function(e){return Z(QL,aR(e))});function oR(e,...t){if(!e)return!1;let n=e.getAttribute(`data-backdrop`);return n==null?!1:n===``||n===`true`||!t.length||t.some(e=>n===e)}var sR=new WeakMap;function cR(e,t,n){for(;n.length;){let r=n[n.length-1];if(!r){e.delete(t);return}if(!r.disposed)return;n.pop(),r.cleanup()}e.delete(t)}function lR(e,t,n){let r=sR.get(e);r||(r=new Map,sR.set(e,r));let i=r.get(t)??[],a={cleanup:n(),disposed:!1};return i.length||r.set(t,i),i.push(a),()=>{i.includes(a)&&(a.disposed=!0,cR(r,t,i))}}function uR(e,t,n){return lR(e,t,()=>{let r=e.getAttribute(t);return e.setAttribute(t,n),()=>{r==null?e.removeAttribute(t):e.setAttribute(t,r)}})}function dR(e,t,n){return lR(e,t,()=>{let r=t in e,i=e[t];return e[t]=n,()=>{r?e[t]=i:delete e[t]}})}function fR(e,t){return e?lR(e,`style`,()=>{let n=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=n}}):()=>{}}function pR(e,t,n){return e?lR(e,t,()=>{let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{r?e.style.setProperty(t,r,i):e.style.removeProperty(t)}}):()=>{}}function mR(e,t){if(!t)return!1;if(t.get(e)?.has(`ancestorMark`))return!0;do{if(t.get(e)?.has(`mark`))return!0;if(!e.parentElement)return!1;e=e.parentElement}while(1)}var hR=new WeakMap;function gR(e=``,t=`outside`){return`__ariakit-dialog-${t}${e?`-${e}`:``}`}function _R(e,t=``){return Ej(dR(e,gR(),!0),dR(e,gR(t),!0))}function vR(e,t=``){return Ej(dR(e,gR(``,`ancestor`),!0),dR(e,gR(t,`ancestor`),!0))}function yR(e,t){let n=new WeakSet;hR.set(e,n);for(let e of t)e&&n.add(e);return()=>{hR.get(e)===n&&hR.delete(e)}}function bR(e,t){let n=hR.get(t);if(!n)return!1;do{if(n.has(e))return!0;if(!e.parentElement)return!1;e=e.parentElement}while(1)}function xR(e,t){let n=gR(t,`ancestor`);if(e[n])return!0;let r=gR(t);do{if(e[r])return!0;if(!e.parentElement)return!1;e=e.parentElement}while(1)}function SR(e){return{cleanups:new Map,previousCleanups:e}}function CR({walk:e,element:t,kind:n,setup:r}){let i=e.cleanups.get(t)??new Map;if(i.has(n))return;e.cleanups.set(t,i);let a=e.previousCleanups?.get(t),o=a?.get(n);a?.delete(n),i.set(n,o??r())}function wR(e){return e.previousCleanups&&DR(e.previousCleanups),e.cleanups}function TR({walk:e,element:t,id:n,ids:r}){oR(t,...r)||CR({walk:e,element:t,kind:`mark`,setup:()=>_R(t,n)})}function ER({walk:e,ancestor:t,element:n,id:r}){n.hasAttribute(`data-dialog`)&&n.id!==r||CR({walk:e,element:t,kind:`ancestorMark`,setup:()=>vR(t,r)})}function DR(e){for(let t of e.values())for(let e of t.values())e();e.clear()}function OR(e){return`__ariakit-dialog-snapshot-${e}`}function kR(e,t){let n=OR(e),r=[];for(let e of t)r.push(dR(e,n,!0));return()=>{for(let e of r)e()}}var AR=[`SCRIPT`,`STYLE`];function jR(e,t){let n=q(t),r=OR(e);if(!n.body[r])return!0;do{if(t===n.body)return!1;if(t[r])return!0;if(!t.parentElement)return!1;t=t.parentElement}while(1)}function MR(e,t,n){return AR.includes(t.tagName)||!jR(e,t)?!1:!n.some(e=>e&&Yj(t,e))}function NR(e,t,n,r){for(let i of t){if(!i?.isConnected)continue;let a=t.some(e=>!e||e===i?!1:e.contains(i)),o=q(i),s=i;for(;i.parentElement&&i!==o.body;){if(r?.(i.parentElement,s),!a)for(let r of i.parentElement.children)MR(e,r,t)&&n(r,s);i=i.parentElement}}}function PR(e,t){let{body:n}=q(t[0]),r=[];return NR(e,t,e=>{r.push(e)}),Ej(dR(n,OR(e),!0),kR(e,r))}function FR(e,t,n){let r=SR(n),i=t.map(e=>e?.id);return NR(e,t,t=>{TR({walk:r,element:t,id:e,ids:i})},(t,n)=>{ER({walk:r,ancestor:t,element:n,id:e})}),wR(r)}var IR=`a.abbr.address.area.article.aside.audio.b.base.bdi.bdo.blockquote.body.br.button.canvas.caption.cite.code.col.colgroup.data.datalist.dd.del.details.dfn.dialog.div.dl.dt.em.embed.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.iframe.img.input.ins.kbd.label.legend.li.link.main.map.mark.menu.meta.meter.nav.noscript.object.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.script.section.select.slot.small.source.span.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.title.tr.track.u.ul.var.video.wbr.svg`.split(`.`),LR=`div`;Q(function(e){return e});var RR=X(function(e){return Z(LR,e)});Object.assign(RR,IR.reduce((e,t)=>(e[t]=X(function(e){return Z(t,e)}),e),{}));function zR({store:e,backdrop:t,backdropRef:n,alwaysVisible:r,hidden:i}){let a=(0,D.useRef)(null),o=qI({disclosure:e}),s=$(e,`contentElement`);J(()=>{let e=a.current,t=s;e&&t&&(e.style.zIndex=getComputedStyle(t).zIndex)},[s]),J(()=>{let e=s?.id;if(!e)return;let t=a.current;if(t)return vR(t,e)},[s]);let c=HI({ref:vN(a,n),store:o,role:`presentation`,"data-backdrop":s?.id||``,alwaysVisible:r,...i!=null&&{hidden:i},style:{position:`fixed`,top:0,right:0,bottom:0,left:0}});if(!t)return null;if((0,D.isValidElement)(t))return(0,O.jsx)(RR,{...c,render:t});let l=typeof t==`boolean`?`div`:t;return(0,O.jsx)(RR,{...c,render:(0,O.jsx)(l,{})})}function BR(e={}){return GI(e)}function VR(e,t,n){return KI(e,t,n)}function HR(e={}){let[t,n]=WF(BR,e);return VR(t,n,e)}function UR(e,...t){if(!e)return!1;let n=e.getAttribute(`data-dialog-hidden-dismiss`);return n==null?!1:n===``||!t.length||t.some(e=>n===e)}function WR(){return`inert`in HTMLElement.prototype}function GR(e){return uR(e,`aria-hidden`,`true`)}function KR(e,...t){if(!e)return!1;let n=e.getAttribute(`data-focus-trap`);return n==null?!1:!t.length||n!==``&&t.some(e=>n===e)}function qR(e,t){return`style`in e?WR()?dR(e,`inert`,!0):Ej(...RM(e,!0).map(e=>{if(t?.some(t=>t&&Yj(t,e)))return bj;let n=lR(e,`focus`,()=>(e.focus=bj,()=>{delete e.focus}));return Ej(uR(e,`tabindex`,`-1`),n)}),GR(e),fR(e,{pointerEvents:`none`,userSelect:`none`,cursor:`default`})):bj}function JR({walk:e,element:t,elements:n,ids:r}){oR(t,...r)||KR(t,...r)||UR(t,...r)||CR({walk:e,element:t,kind:`disable`,setup:()=>qR(t,n)})}function YR(e,t,n){t.hasAttribute(`role`)&&(n.some(e=>e&&Yj(e,t))||CR({walk:e,element:t,kind:`role`,setup:()=>uR(t,`role`,`none`)}))}function XR(e,t,n){n&&!WR()&&DR(n);let r=SR(n),i=t.map(e=>e?.id);return NR(e,t,n=>{TR({walk:r,element:n,id:e,ids:i}),JR({walk:r,element:n,elements:t,ids:i})},(n,i)=>{ER({walk:r,ancestor:n,element:i,id:e}),YR(r,n,t)}),wR(r)}function ZR(e){let t=[e];for(;;){let n;try{n=qj(e).frameElement}catch{return t}if(!Xj(n))return t;t.push(n),e=n}}function QR(e,t){let n=e.composedPath().filter(Xj);!n.length&&Xj(e.target)&&n.push(e.target);let r=n[0];if(r)for(let e of ZR(r).slice(1))n.includes(e)||n.push(e);let i=t?.getRootNode();return{elements:n,rootTarget:i?n.find(e=>e.getRootNode()===i)||e.target:n[0]||e.target}}function $R(e,t,n){let r=(0,D.useRef)(null);return(0,D.useEffect)(()=>{if(!e)r.current=null;else return jM(`mousedown`,e=>{r.current=QR(e,n)},!0,t)},[e,t,n]),r}function ez(e){return qj(ZR(e).at(-1)??e)}function tz(e){return e.isConnected}function nz(e,t){if(!e)return!1;if(Yj(e,t))return!0;let n=t.getAttribute(`aria-activedescendant`);if(n){let r=q(t).getElementById(n);if(r)return Yj(e,r)}return!1}function rz(e,t){if(!(`clientY`in e))return!1;let n=t.getBoundingClientRect();return n.width===0||n.height===0?!1:n.top<=e.clientY&&e.clientY<=n.top+n.height&&n.left<=e.clientX&&e.clientX<=n.left+n.width}function iz(e,t,n){return Yj(t,e)||nz(n,e)||e.hasAttribute(`data-focus-trap`)||UR(e,t.id)?!0:bR(e,t)}function az(e,t,n){return e.elements.some(e=>iz(e,t,n))}function oz({store:e,type:t,listener:n,capture:r,open:i,contentElement:a,focusedRef:o}){let s=Y(n);(0,D.useEffect)(()=>i?jM(t,t=>{let{contentElement:n,disclosureElement:r}=e.getState();if(!n)return;let i=QR(t,n),a=i.elements[0],c=i.rootTarget;if(!Xj(c)||a&&!tz(a)||!tz(c)||az(i,n,r))return;let l=q(n);q(c)===l?q(a??c)===l&&rz(t,n)||(!o.current||xR(c,n.id))&&s(t):s(t)},r,a?ez(a):void 0):void 0,[i,r,e,t,s,a,o])}function sz(e,t){return typeof e==`function`?e(t):!!e}function cz({store:e,hideOnInteractOutside:t,domReady:n,interactedOutsideRef:r,focusedStoreRef:i}){let a=$(e,`open`),o=$(e,`contentElement`),s=$R(a,o?ez(o):void 0,o),c=(0,D.useRef)(!1);J(()=>{if(!a||!n||!o)return;c.current=!1;let t=()=>{c.current=!0,i.current=e};return o.addEventListener(`focusin`,t,!0),()=>o.removeEventListener(`focusin`,t,!0)},[a,n,o,e,i]);let l={store:e,capture:!0,open:a,contentElement:o,focusedRef:c},u=()=>{e.hide(),e.getState().open&&(r.current=!1)};oz({...l,type:`click`,listener:n=>{let{contentElement:i,disclosureElement:a}=e.getState(),o=s.current;if(!o||!i||az(o,i,a))return;let c=o.rootTarget;Xj(c)&&(q(c)!==q(i)||xR(c,i.id))&&sz(t,n)&&(r.current=!0,u())}}),oz({...l,type:`focusin`,listener:n=>{let{contentElement:i}=e.getState();if(!i||n.target===q(i)||!sz(t,n))return;let a=n.target;Xj(a)&&q(a)!==q(i)&&(r.current=!0),u()}}),oz({...l,type:`contextmenu`,listener:e=>{sz(t,e)&&(r.current=!0,u())}})}var lz=(0,D.createContext)({});function uz(e){let t=(0,D.useContext)(lz),[n,r]=(0,D.useState)([]),i=(0,D.useCallback)(e=>(r(t=>[...t,e]),Ej(t.add?.(e),()=>{r(t=>t.filter(t=>t!==e))})),[t]);J(()=>GP(e,[`open`,`contentElement`],n=>{if(n.open&&n.contentElement)return t.add?.(e)}),[e,t]);let a=(0,D.useMemo)(()=>({store:e,add:i}),[e,i]);return{wrapElement:(0,D.useCallback)(e=>(0,O.jsx)(lz.Provider,{value:a,children:e}),[a]),nestedDialogs:n}}function dz({attribute:e,contentId:t,contentElement:n,enabled:r}){let[i,a]=EN(),o=(0,D.useCallback)(()=>{if(!r||!n)return!1;let{body:i}=q(n),a=i.getAttribute(e);return!a||a===t},[i,r,n,e,t]);return J(()=>{if(!r||!t||!n)return;let{body:i}=q(n);if(o())return i.setAttribute(e,t),()=>i.removeAttribute(e);let s=new MutationObserver(()=>(0,RE.flushSync)(a));return s.observe(i,{attributeFilter:[e]}),()=>s.disconnect()},[i,r,t,n,o,e,a]),o}var fz=hM()&&!vM(),pz=fz?D.useEffect:J;function mz(e){let{CSS:t}=e;return!!t?.supports(`scrollbar-gutter`,`stable`)}function hz(e){let t=e.getBoundingClientRect().left;return Math.round(t)+e.scrollLeft?`paddingLeft`:`paddingRight`}function gz(e,t,n){let r=dz({attribute:`data-dialog-prevent-body-scroll`,contentElement:e,contentId:t,enabled:n});pz(()=>{if(!r()||!e)return;let t=q(e),n=qj(e),{documentElement:i,body:a}=t,o=i.style.getPropertyValue(`--scrollbar-width`),s=o?Number.parseInt(o,10):n.innerWidth-i.clientWidth,c=()=>{let e=n.getComputedStyle(i),t=e.getPropertyValue(`scrollbar-gutter`),r=t.includes(`stable`),o=e=>!e||e===`visible`,c=!o(e.getPropertyValue(`overflow-x`))||!o(e.getPropertyValue(`overflow-y`)),l=()=>Ej(pR(i,`overflow-x`,`hidden`),pR(i,`overflow-y`,`hidden`)),u=e=>c?Ej(e,l()):e;return!r&&!s?u(fR(a,{overflow:`hidden`})):r||mz(n)?Ej(pR(i,`scrollbar-gutter`,r?t:`stable`),l()):u(Ej(pR(i,`--scrollbar-width`,`${s}px`),fR(a,{overflow:`hidden`,[hz(i)]:`${s}px`})))},l=()=>{let{scrollX:e,scrollY:t,visualViewport:r}=n,o=r?.offsetLeft??0,c=r?.offsetTop??0,l=fR(a,{position:`fixed`,overflow:`hidden`,top:`${-(t-Math.floor(c))}px`,left:`${-(e-Math.floor(o))}px`,right:`0`,[hz(i)]:`${s}px`});return()=>{l(),n.scrollTo({left:e,top:t,behavior:`instant`})}};if(fz)return l();let u=c();return()=>{queueMicrotask(u)}},[r,e])}var _z=new WeakSet;function vz(e){_z.add(e)}function yz(e){return _z.has(e)}var bz=new Map;function xz(e,t={}){return bz.set(e,t),()=>{bz.delete(e)}}function Sz(e){let t=[];for(let n of bz.keys()){if(n===e)break;let{current:r}=n;r?.isConnected&&(e.current&&Yj(r,e.current)||t.push(r))}return t}function Cz(e){let t=!1;for(let[n,r]of bz)n===e?t=!0:t&&r.onEarlierDialogElementChange?.()}function wz(e){let t=e.current;if(!t||!xR(t))return!1;let n=bz.get(e)?.getOutsideCleanups?.(),r=!1,i=!1;for(let[a,o]of bz){if(a===e){r=!0;continue}let s=a.current;if(s&&mR(t,o.getOutsideCleanups?.())){if(r||!mR(s,n))return!0;i=!0}}return!(r&&i)}var Tz=`div`,Ez=gM(),Dz=new WeakSet,Oz=new WeakSet;function kz(e){let t=Jj(e);return!t||e&&Yj(e,t)||UR(t,e?.id)?!1:!!PM(t)}function Az(e){let t=e;for(;t.shadowRoot;){let e=t.shadowRoot.activeElement;if(!Xj(e))break;t=e}return t}function jz(e,t,n){return Yj(t,e)||n&&Yj(n,e)?!0:bR(e,t)}function Mz(e){let t=e.querySelectorAll(`[data-dialog-dismiss]`);for(let n of t)if(n.closest(`[data-dialog]`)===e)return!0;return!1}function Nz(e,t=!1){if(!e)return null;let n=`current`in e?e.current:e;return n?t?PM(n)?n:null:n:null}function Pz(e){if(!e.isConnected)return[];let t=e.getRootNode(),n=t.querySelectorAll(`[data-dialog][data-dialog-portal][data-open]`),r=[],i=!1;for(let a of n){if(a===e){i=!0;continue}if(!i)continue;let n=a.getAttribute(`data-dialog-portal`);if(!n)continue;let o=t.getElementById(n);o&&Yj(o,a)&&(Dz.has(o)||r.push(o))}return r}var Fz=Q(function({store:e,open:t,onClose:n,focusable:r=!0,modal:i=!0,portal:a=i,backdrop:o=i,hideOnEscape:s=!0,hideOnInteractOutside:c=!0,getPersistentElements:l,preventBodyScroll:u=i,autoFocusOnShow:d=!0,autoFocusOnHide:f=!0,initialFocus:p,finalFocus:m,unmountOnHide:h,unstable_treeSnapshotKey:g,..._}){let v=jI(),y=(0,D.useRef)(null),b=(0,D.useRef)(null),x=i&&a&&!_.portalElement,S=(0,D.useRef)(!1),C=Y(()=>{let e=y.current;if(!e)return!0;let t=new Event(`close`,{bubbles:!1,cancelable:!0});return n&&e.addEventListener(`close`,n,{once:!0}),e.dispatchEvent(t),!t.defaultPrevented}),w=HR({store:e||v,open:t,setOpen(e){e||S.current||C()||w.setOpen(!0)}});J(()=>w.unstable_onHideRequest(e=>{if(!S.current){S.current=!0;try{if(!C())return;e()}finally{S.current=!1}}}),[w,C]);let{portalRef:T,portalNode:E,domReady:ee}=kN(a,_.portalRef),te=_.preserveTabOrder,ne=$(w,[`mounted`],e=>te&&!i&&e.mounted),re=SN(_.id),ie=$(w,`open`),ae=$(w,`mounted`),oe=$(w,`contentElement`),se=VI(ae,_.hidden,_.alwaysVisible);gz(oe,re,u&&!se);let ce=(0,D.useRef)(!1),le=(0,D.useRef)(null);J(()=>GP(w,[`open`],e=>{e.open?(ce.current=!1,le.current!==w&&(le.current=null)):le.current=null}),[w]),cz({store:w,hideOnInteractOutside:c,domReady:ee,interactedOutsideRef:ce,focusedStoreRef:le});let{wrapElement:ue,nestedDialogs:de}=uz(w);_=ON(_,ue,[ue]);let fe=(0,D.useRef)(null);Ez&&(0,D.useEffect)(()=>{if(!ee)return;let e=y.current;if(!e)return;let t=q(e),n=e=>{fe.current=e.target};return t.addEventListener(`mousedown`,n,!0),()=>{t.removeEventListener(`mousedown`,n,!0)}},[ee]),J(()=>{if(!ie||le.current===w)return;let e=y.current;if((()=>{let{disclosureElement:t}=w.getState();return!(!t||yz(t)||!t.isConnected||e&&Yj(e,t))})())return;let t=e=>{vz(e),w.setDisclosureElement(e)},n=Jj(e,{activeDescendant:!0});if(n){if(n.tagName===`BODY`){let n=fe.current;if(fe.current=null,!n?.isConnected||!PM(n)||e&&Yj(e,n))return;t(n)}else e&&Yj(e,n)||t(n)}},[w,ie]),(0,D.useEffect)(()=>{if(!ae||!ee)return;let e=y.current;if(!e)return;let t=qj(e),n=t.visualViewport||t,r=()=>{let n=t.visualViewport?.height??t.innerHeight;e.style.setProperty(`--dialog-viewport-height`,`${n}px`)};return r(),n.addEventListener(`resize`,r),()=>{n.removeEventListener(`resize`,r)}},[ae,ee]);let[pe,me]=(0,D.useState)(!1);J(()=>{if(!(i&&ie&&ee)||!oe){me(!1);return}let e=()=>{me(!Mz(oe))};e();let{MutationObserver:t}=qj(oe),n=new t(e);return n.observe(oe,{childList:!0,subtree:!0}),()=>n.disconnect()},[i,ie,ee,oe]),J(()=>{if(!WR()||ie||!ae||!ee)return;let e=y.current;if(e)return qR(e)},[ie,ae,ee]);let he=ie&&ee,ge=(0,D.useRef)(null);J(()=>{if(!re||!x||!he||!E){ge.current=null;return}let e=y.current;if(!e||!Yj(E,e))ge.current=null;else return ge.current?.portal!==E&&(ge.current={portal:E,peers:Pz(e)}),Dz.add(E),()=>{Dz.delete(E)}},[re,he,x,E]);let _e=!!he,[ve,ye]=(0,D.useState)(0);J(()=>{if(_e)return xz(y,{getOutsideCleanups:()=>Se.current?.outsideCleanups,onEarlierDialogElementChange:()=>{ye(e=>e+1)}})},[_e]);let be=(0,D.useRef)(null);J(()=>{if(!_e){be.current=null;return}if(!oe)return;let e=be.current;be.current=oe,e&&e!==oe&&Cz(y)},[_e,oe]),J(()=>{if(!re||!he)return;let e=y.current;return PR(re,[e])},[re,he,g]),J(()=>{if(!re||!he)return;let e=Sz(y);return kR(re,e)},[re,he,ve]);let xe=Y(l),Se=(0,D.useRef)(null);J(()=>()=>{let e=Se.current;e&&(Se.current=null,e.restoreInsideMarks(),DR(e.outsideCleanups))},[re,w,he,oe,i,x,xe,g]),J(()=>{if(!re||!he)return;let{disclosureElement:e}=w.getState(),t=oe??y.current;if(!t)return;let n=[t,...xe()||[],...ge.current?.peers||[],...de.map(e=>e.getState().contentElement)],r=Se.current;r?.restoreInsideMarks();let a=yR(t,n),o=i?XR(re,n,r?.outsideCleanups):FR(re,[e,...n],r?.outsideCleanups);Se.current={restoreInsideMarks:a,outsideCleanups:o}},[re,w,he,oe,i,x,xe,de,g,ve]);let Ce=!!d,we=DN(d),[Te,Ee]=(0,D.useState)(!1);(0,D.useEffect)(()=>{if(!ie||!Ce||!ee||!oe?.isConnected)return;let e=Nz(p,!0)||oe.querySelector(`[data-autofocus=true],[autofocus]`)||zM(oe,!0,a&&ne)||oe,t=PM(e);we(t?e:null)&&(Ee(!0),queueMicrotask(()=>{let{open:t,disclosureElement:n}=w.getState();if(!t)return;let r=Jj(oe,{frame:!1}),i=r&&Az(r);le.current===w&&r&&i&&PM(i)&&!jz(r,oe,n)&&!jz(i,oe,n)||(PM(e)&&e.scrollIntoView({block:`nearest`,inline:`nearest`}),e.focus({preventScroll:!0}))}))},[ie,Ce,ee,oe,p,a,ne,w,we,le]);let De=!!f,Oe=DN(f),[ke,k]=(0,D.useState)(!1);J(()=>{if(ie)return k(!0),()=>k(!1)},[ie]);let Ae=(0,D.useCallback)((e,t=!0)=>{if(ce.current)return;let{disclosureElement:n}=w.getState();if(kz(e))return;let r=Nz(m)||n;if(r?.id){let e=q(r),t=`[aria-activedescendant="${r.id}"]`,n=e.querySelector(t);n&&(r=n)}if(r&&!PM(r)){let e=r.closest(`[data-dialog]`);if(e?.id){let t=q(e),n=`[aria-controls~="${e.id}"]`,i=t.querySelector(n);i&&(r=i)}}let i=r&&PM(r);!i&&t?requestAnimationFrame(()=>Ae(e,!1)):Oe(i?r:null)&&i&&r?.focus()},[w,m,Oe]),je=(0,D.useRef)(!1);J(()=>{if(ie||!ke||!De)return;let e=y.current;je.current=!0,Ae(e)},[ie,ke,ee,De,Ae]),(0,D.useEffect)(()=>{if(!ke||!De)return;let e=y.current;return()=>{je.current?je.current=!1:Ae(e)}},[ke,De,Ae]);let Me=DN(s),[A]=(0,D.useState)(()=>new WeakMap),[Ne]=(0,D.useState)(()=>new WeakMap),j=_.onKeyDown,Pe=_.onKeyDownCapture,Fe=_.onFocusCapture,Ie=Y(e=>{if(Fe?.(e),!w.getState().open)return;let t=e.target;Zj(t)&&Yj(e.currentTarget,t)&&(le.current=w)}),Le=Y(e=>{if(e.key!==`Escape`||!e.bubbles)return!1;let t=A.get(e);if(t)return e.defaultPrevented&&!t.defaultPrevented?!1:t.accepted;if(e.defaultPrevented)return!1;let n=y.current;if(!ae||!n)return!1;let r=lI(e),i=Ne.get(r);return i||(i={accepted:!wz(y)&&!Oz.has(r)&&Me(e),hidden:!1},Ne.set(r,i)),A.set(e,{accepted:i.accepted,defaultPrevented:e.defaultPrevented}),i.accepted}),Re=Y(e=>{let t=Le(e);if(A.delete(e),!t)return!1;let n=lI(e),r=Ne.get(n);return r?.hidden||(r&&(r.hidden=!0),Oz.add(n),w.hide()),!0}),ze=Y(e=>{let t=e.nativeEvent,n=t.cancelBubble;j?.(e),n?A.delete(t):Re(t)&&e.stopPropagation()}),Be=Y(e=>{let t=e.nativeEvent,n=t.cancelBubble;Pe?.(e),n?A.delete(t):Le(t)&&(e.isPropagationStopped()||t.cancelBubble)&&Re(t)});(0,D.useEffect)(()=>{if(!ee||!ae)return;let e=e=>{if(e.key!==`Escape`||!e.bubbles)return;if(e.cancelBubble){A.delete(e);return}if(A.has(e))return;let t=y.current;if(!t)return;let n=[e.target,e.composedPath()[0]].filter(Zj),{disclosureElement:r}=w.getState();n.some(e=>!!(Xj(e)&&e.tagName===`BODY`||Yj(t,e)||!r||Yj(r,e)||Xj(e)&&xR(e,t.id)||Xj(e)&&UR(e,t.id)))&&Le(e)&&e.cancelBubble&&Re(e)},t=e=>{A.has(e)&&(e.cancelBubble?A.delete(e):Re(e)&&e.stopPropagation())},n=oe?qj(oe):void 0;return Ej(jM(`keydown`,e,!0,n),jM(`keydown`,t,!1,n))},[w,ee,ae,oe,Re,Le,A]),_=ON(_,e=>(0,O.jsx)(WL,{level:i?1:void 0,children:e}),[i]);let Ve=_.hidden,He=_.alwaysVisible;_=ON(_,e=>(0,O.jsxs)(O.Fragment,{children:[pe&&(0,O.jsx)(`button`,{type:`button`,tabIndex:-1,"data-dialog-hidden-dismiss":re||``,style:KL(),onClick:w.hide,children:`Dismiss popup`}),e]}),[pe,re,w]),_=ON(_,e=>(0,O.jsxs)(O.Fragment,{children:[!!o&&(0,O.jsx)(zR,{store:w,backdrop:o,backdropRef:b,hidden:Ve,alwaysVisible:He}),e]}),[w,o,Ve,He]);let[Ue,We]=(0,D.useState)(),[Ge,Ke]=(0,D.useState)();return _=ON(_,e=>(0,O.jsx)(NI,{value:w,children:(0,O.jsx)(PI.Provider,{value:We,children:(0,O.jsx)(FI.Provider,{value:Ke,children:e})})}),[w]),_={"data-dialog":``,role:`dialog`,tabIndex:r?-1:void 0,"aria-labelledby":_[`aria-label`]==null?Ue:void 0,"aria-describedby":Ge,..._,"data-dialog-portal":x?E?.id:void 0,id:re,ref:vN(y,_.ref),onFocusCapture:Ie,onKeyDown:ze,onKeyDownCapture:Be},_=HL({..._,autoFocusOnShow:Te}),_=HI({store:w,..._,unstable_otherElementRef:b}),_=iP({..._,focusable:r}),_=aR({portal:a,..._,portalRef:T,preserveTabOrder:ne}),_});function Iz(e,t=jI){return X(function(n){let r=t();return $(n.store||r,[`mounted`],e=>!n.unmountOnHide||e?.mounted||!!n.open)?(0,O.jsx)(e,{...n}):null})}var Lz=Iz(X(function(e){return Z(Tz,Fz(e))}),jI),Rz=X(function(e){let t=HR({open:e.open});return(0,O.jsx)(Lz,{...e,store:t})});X(function(e){let t=jI();return e.store||t||!e.unmountOnHide?(0,O.jsx)(Lz,{...e}):(0,O.jsx)(Rz,{...e})});function zz(e){return e.split(`-`)[0]}var Bz=`div`,Vz=new WeakMap;function Hz(e=0,t=0,n=0,r=0){if(typeof DOMRect==`function`)return new DOMRect(e,t,n,r);let i={x:e,y:t,width:n,height:r,top:t,right:e+n,bottom:t+r,left:e};return{...i,toJSON:()=>i}}function Uz(e){if(!e)return Hz();let{x:t,y:n,width:r,height:i}=e;return Hz(t,n,r,i)}function Wz(e,t){return{contextElement:e||void 0,getBoundingClientRect:()=>{let n=e,r=t?.(n);return r||!n?Uz(r):n.getBoundingClientRect()}}}function Gz(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}function Kz(e){let t=window.devicePixelRatio||1;return Math.round(e*t)/t}function qz(e){return typeof e==`number`?e:Math.max(e.left??0,e.right??0)}function Jz(e,t){return te(({placement:n})=>{let r=(e?.clientHeight||0)/2,i=typeof t.gutter==`number`?t.gutter+r:t.gutter??r;return{crossAxis:n.split(`-`)[1]?void 0:t.shift,mainAxis:i,alignmentAxis:t.shift}})}function Yz(e){if(e.flip===!1)return;let t=typeof e.flip==`string`?e.flip.split(` `):void 0;return Nj(!t||t.every(Gz),!1),ee({padding:e.overflowPadding,fallbackPlacements:t})}function Xz(e){if(e.slide||e.overlap)return x({mainAxis:e.slide,crossAxis:e.overlap,padding:e.overflowPadding,limiter:E()})}function Zz(e,t){return l({padding:e.overflowPadding,apply({elements:n,availableWidth:r,availableHeight:i,rects:a}){if(t?.())return;let o=n.floating,s=Math.round(a.reference.width);r=Math.floor(r),i=Math.floor(i),o.style.setProperty(`--popover-anchor-width`,`${s}px`),o.style.setProperty(`--popover-available-width`,`${r}px`),o.style.setProperty(`--popover-available-height`,`${i}px`),e.sameWidth&&(o.style.width=`${s}px`),e.fitViewport&&(o.style.maxWidth=`${r}px`,o.style.maxHeight=`${i}px`)}})}function Qz(e,t){if(e)return h({element:e,padding:t.arrowPadding})}var $z=Q(function({store:e,modal:t=!1,portal:n=t,preserveTabOrder:r=!0,autoFocusOnShow:i=!0,wrapperProps:a,fixed:o=!1,flip:s=!0,shift:c=0,slide:l=!0,overlap:u=!1,sameWidth:d=!1,fitViewport:f=!1,gutter:p,arrowPadding:h=4,overflowPadding:g=8,getAnchorRect:_,updatePosition:v,...y}){let b=$I();e||=b,Nj(e,!1);let x=$(e,`arrowElement`),S=$(e,`anchorElement`),C=r&&n&&!t,w=$(e,C?[`disclosureElement`]:[],e=>C?e.disclosureElement:null),T=$(e,`popoverElement`),E=$(e,`unstable_placing`),ee=$(e,`contentElement`),te=$(e,`placement`),ne=$(e,`mounted`),re=$(e,`rendered`),ae=(0,D.useRef)(null),oe=!E,{portalRef:se,domReady:ce}=kN(n,y.portalRef),le=Y(_),ue=Y(v),de=!!v,fe=typeof g==`number`?g:g.top??0,pe=typeof g==`number`?g:g.right??0,me=typeof g==`number`?g:g.bottom??0,he=typeof g==`number`?g:g.left??0,ge=!ne&&VI(ne,y.hidden,y.alwaysVisible);J(()=>{if(ne&&e?.setState(`unstable_placing`,!0),!T?.isConnected)return;let t={top:fe,right:pe,bottom:me,left:he};if(T.style.setProperty(`--popover-overflow-padding`,`${qz(t)}px`),ge&&!de)return;let n=Wz(S,le),r=!1,i=!1,a=()=>!(!r&&T.isConnected),g=async()=>{if(a()||!ne)return;x||(ae.current=ae.current||document.createElement(`div`));let r=x||ae.current,g=[Jz(r,{gutter:p,shift:c}),Yz({flip:s,overflowPadding:t}),Xz({slide:l,shift:c,overlap:u,overflowPadding:t}),Qz(r,{arrowPadding:h}),Zz({sameWidth:d,fitViewport:f,overflowPadding:t},a)],_=await m(n,T,{placement:te,strategy:o?`fixed`:`absolute`,middleware:g});if(a())return;e?.setState(`currentPlacement`,_.placement);let v=Kz(_.x),y=Kz(_.y);if(Object.assign(T.style,{top:`0`,left:`0`,transform:`translate3d(${v}px,${y}px,0)`}),i=!0,r&&_.middlewareData.arrow){let{x:e,y:t}=_.middlewareData.arrow,n=zz(_.placement),i=r.clientWidth/2,a=r.clientHeight/2,o=e==null?-i:e+i,s=t==null?-a:t+a;T.style.setProperty(`--popover-transform-origin`,{top:`${o}px calc(100% + ${a}px)`,bottom:`${o}px ${-a}px`,left:`calc(100% + ${i}px) ${s}px`,right:`${-i}px ${s}px`}[n]),Object.assign(r.style,{left:e==null?``:`${e}px`,top:t==null?``:`${t}px`,right:``,bottom:``,[n]:`100%`})}},_=ie(n,T,async()=>{if(!a()){try{de?await ue({updatePosition:g}):await g()}catch(t){throw i&&!a()&&e?.setState(`unstable_placing`,!1),t}a()||e?.setState(`unstable_placing`,!1)}},{elementResize:typeof ResizeObserver==`function`});return()=>{r=!0,_()}},[e,re,T,x,S,te,ne,ge,ce,o,s,c,l,u,d,f,p,h,fe,pe,me,he,le,de,ue]),J(()=>{if(!ne||!ce||!T?.isConnected||!ee?.isConnected)return;let e=()=>{T.style.zIndex=getComputedStyle(ee).zIndex};e();let t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)});return()=>cancelAnimationFrame(t)},[ne,ce,T,ee]),J(()=>{if(!e)return;let t=e;Vz.set(t,(Vz.get(t)??0)+1);let n=GP(t,[`mounted`],e=>{t.setState(`unstable_placing`,e.mounted)});return()=>{n(),Vz.set(t,(Vz.get(t)??1)-1),queueMicrotask(()=>{Vz.get(t)||t.setState(`unstable_placing`,!1)})}},[e]);let _e=o?`fixed`:`absolute`;return y=ON(y,t=>(0,O.jsx)(`div`,{...a,style:{position:_e,top:0,left:0,width:`max-content`,...a?.style},ref:e?.setPopoverElement,children:t}),[e,_e,a]),y=ON(y,t=>(0,O.jsx)(tL,{value:e,children:t}),[e]),y={"data-placing":E||void 0,...y,style:{position:`relative`,...y.style}},y=Fz({store:e,modal:t,portal:n,preserveTabOrder:r,preserveTabOrderAnchor:w||S,autoFocusOnShow:oe&&i,...y,portalRef:se}),y}),eB=Iz(X(function(e){return Z(Bz,$z(e))}),$I),tB=BN([eL],[tL]);tB.useContext,tB.useScopedContext;var nB=tB.useProviderContext,rB=tB.ContextProvider,iB=tB.ScopedContextProvider;function aB(e){return[e.clientX,e.clientY]}function oB(e,t){let[n,r]=e,i=!1,a=t.length;for(let e=a,o=0,s=e-1;o<e;s=o++){let a=t[o],c=t[s],l=t[s===0?e-1:s-1];if(a==null||c==null||l==null)return!1;let[u,d]=a,[f,p]=c,[,m]=l,h=(d-p)*(n-u)-(u-f)*(r-d);if(p<d){if(r>=p&&r<d){if(h===0)return!0;h>0&&(r===p?r>m&&(i=!i):i=!i)}}else if(d<p){if(r>d&&r<=p){if(h===0)return!0;h<0&&(r===p?r<m&&(i=!i):i=!i)}}else if(r===d&&(n>=f&&n<=u||n>=u&&n<=f))return!0}return i}function sB(e,t){let{top:n,right:r,bottom:i,left:a}=t,[o,s]=e;return[o<a?`left`:o>r?`right`:null,s<n?`top`:s>i?`bottom`:null]}function cB(e,t){let n=e.getBoundingClientRect(),{top:r,right:i,bottom:a,left:o}=n,[s,c]=sB(t,n),l=[t];return s?(c!==`top`&&l.push([s===`left`?o:i,r]),l.push([s===`left`?i:o,r]),l.push([s===`left`?i:o,a]),c!==`bottom`&&l.push([s===`left`?o:i,a])):c===`top`?(l.push([o,r]),l.push([o,a]),l.push([i,a]),l.push([i,r])):(l.push([o,a]),l.push([o,r]),l.push([i,r]),l.push([i,a])),l}function lB({hideOnEscape:e,onClose:t,onEscapeClose:n}){let r=(0,D.useRef)(null);return{hideOnEscape:Y(t=>{if(Fj(e,t))return!1;let n={};return r.current=n,setTimeout(()=>{r.current===n&&(r.current=null)}),!0}),onClose:Y(e=>{let i=r.current;r.current=null,t?.(e),e.defaultPrevented||i&&n()})}}var uB=`div`;function dB(e,t,n,r){return!!(KM(t)||e.includes(t)||n.some(t=>t&&e.includes(t))||r?.some(t=>KM(t)||e.includes(t)))}function fB({event:e,element:t,enterPointRef:n,disablePointerEvents:r,refreshEnterPoint:i=!1}){let a=n.current;if(!a)return!1;let o=aB(e);return oB(o,cB(t,a))?(i&&(n.current=o),r(e)&&(e.preventDefault(),e.stopPropagation()),!0):!1}function pB({store:e,...t}){let[n,r]=(0,D.useState)(!1),i=$(e,`mounted`);(0,D.useEffect)(()=>{i||r(!1)},[i]);let a=t.onFocus,o=Y(e=>{a?.(e),e.defaultPrevented||r(!0)}),s=(0,D.useRef)(null);return(0,D.useEffect)(()=>GP(e,[`anchorElement`],e=>{s.current=e.anchorElement}),[e]),t={autoFocusOnHide:n,finalFocus:s,...t,onFocus:o},t}var mB=(0,D.createContext)(null),hB=Q(function({store:e,modal:t=!1,portal:n=t,hideOnEscape:r=!0,hideOnHoverOutside:i=!0,disablePointerEventsOnApproach:a=!!i,...o}){let s=nB();e||=s,Nj(e,!1);let c=(0,D.useRef)(null),l=(0,D.useRef)([]),u=(0,D.useRef)(0),d=(0,D.useRef)(null),{portalRef:f,domReady:p}=kN(n,o.portalRef),m=MN(),h=!!i,g=DN(i),_=!!a,v=DN(a),y=$(e,`open`),b=$(e,`mounted`),x=(0,D.useCallback)(()=>{window.clearTimeout(u.current),u.current=0},[]);(0,D.useEffect)(()=>{if(!p||!b||!h&&!_)return;let t=c.current;return t?Ej(jM(`mousemove`,n=>{if(!e||!m())return;let{anchorElement:r,disclosureElement:i,hideTimeout:a,timeout:o}=e.getState(),s=n.composedPath(),c=[r,i],f=c.find(e=>e&&s.includes(e));dB(s,t,c,l.current)?(d.current=f?aB(n):null,x()):u.current||fB({event:n,element:t,enterPointRef:d,disablePointerEvents:v,refreshEnterPoint:!0})||g(n)&&(u.current=window.setTimeout(()=>{u.current=0,e?.hide()},a??o))},!0),x):void 0},[e,m,p,b,h,_,l,x,v,g]),(0,D.useEffect)(()=>{if(!p||!b||!_)return;let e=e=>{let t=c.current;t&&fB({event:e,element:t,enterPointRef:d,disablePointerEvents:v})};return Ej(jM(`mouseenter`,e,!0),jM(`mouseover`,e,!0),jM(`mouseout`,e,!0),jM(`mouseleave`,e,!0))},[p,b,_,v]),(0,D.useEffect)(()=>{p&&(y||e?.setAutoFocusOnShow(!1))},[e,p,y]);let S=gN(y);(0,D.useEffect)(()=>{if(p)return()=>{S.current||e?.setAutoFocusOnShow(!1)}},[e,p]);let C=(0,D.useContext)(mB);J(()=>{if(t||!n||!b||!p)return;let e=c.current;if(e)return C?.(e)},[t,n,b,p,C]);let w=(0,D.useCallback)(e=>{x(),l.current=[...l.current,e];let t=C?.(e);return()=>{x(),l.current=l.current.filter(t=>t!==e),t?.()}},[x,C]);o=ON(o,t=>(0,O.jsx)(iB,{value:e,children:(0,O.jsx)(mB.Provider,{value:w,children:t})}),[e,w]),o={...o,ref:vN(c,o.ref)},o=pB({store:e,...o});let T=$(e,[`autoFocusOnShow`],e=>t||e.autoFocusOnShow),E=lB({hideOnEscape:r,onClose:o.onClose,onEscapeClose(){requestAnimationFrame(()=>{requestAnimationFrame(()=>{e?.getState().open&&e.hide()})})}});return o=$z({store:e,modal:t,portal:n,autoFocusOnShow:T,...o,portalRef:f,hideOnEscape:E.hideOnEscape,onClose:E.onClose}),o});Iz(X(function(e){return Z(uB,hB(e))}),nB);var gB=BN([rB],[iB]);gB.useContext,gB.useScopedContext;var _B=gB.useProviderContext,vB=gB.ContextProvider,yB=gB.ScopedContextProvider,bB=`div`,xB=Q(function({store:e,portal:t=!0,gutter:n=8,preserveTabOrder:r=!1,hideOnHoverOutside:i=!0,hideOnInteractOutside:a=!0,...o}){let s=_B();return e||=s,Nj(e,!1),o=ON(o,t=>(0,O.jsx)(yB,{value:e,children:t}),[e]),o={role:$(e,[`type`],e=>e.type===`description`?`tooltip`:`none`),...o},o=hB({...o,store:e,portal:t,gutter:n,preserveTabOrder:r,hideOnHoverOutside(t){if(Fj(i,t))return!1;let n=e?.getState().anchorElement;return!n||!(`focusVisible`in n.dataset)},hideOnInteractOutside:t=>{if(Fj(a,t))return!1;let n=e?.getState().anchorElement;return!n||!Yj(n,t.target)}}),o}),SB=Iz(X(function(e){return Z(bB,xB(e))}),_B),CB=Q(function({store:e,showOnHover:t=!0,unstable_showOnHoverWhenDisabled:n=!0,setAnchorElement:r=!1,...i}){let a=Ij(i),o=i.focusable!==!1,s=(0,D.useRef)(null),c=(0,D.useRef)(0),l=Y(e=>a&&!o?!0:tN(e));(0,D.useEffect)(()=>()=>window.clearTimeout(c.current),[]),(0,D.useEffect)(()=>jM(`mouseleave`,e=>{let t=s.current;t&&e.target===t&&(window.clearTimeout(c.current),c.current=0)},!0),[]);let u=i.onMouseMove,d=DN(t),f=DN(n),p=MN(),m=Y(t=>{if(u?.(t),t.defaultPrevented||c.current||!p())return;let n=t.currentTarget;if(l(n)||(a||Lj(n))&&!f(t)||!d(t))return;r&&e.setAnchorElement(n),e.setDisclosureElement(n);let{showTimeout:i,timeout:o}=e.getState(),s=()=>{c.current=0,p()&&(l(n)||(r&&e.setAnchorElement(n),e.show(),queueMicrotask(()=>{e.setDisclosureElement(n)})))},m=i??o;m===0?s():c.current=window.setTimeout(s,m)}),h=i.onClick,g=Y(e=>{h?.(e),window.clearTimeout(c.current),c.current=0}),_=(0,D.useCallback)(t=>{if(s.current=t,!r)return;let{anchorElement:n}=e.getState();n?.isConnected||e.setAnchorElement(t)},[e,r]);return i={...i,ref:vN(_,i.ref),onMouseMove:m,onClick:g},i=iP(i),i}),wB=`a`,TB=Q(function({store:e,showOnHover:t=!0,...n}){let r=nB();return e||=r,Nj(e,!1),CB({store:e,showOnHover:t,setAnchorElement:!0,...n})});X(function(e){return Z(wB,TB(e))});var EB=`div`,DB=VP({activeStore:null}),OB=new WeakSet;function kB(e){return()=>{let{activeStore:t}=DB.getState();t===e&&DB.setState(`activeStore`,null)}}function AB(e){return`key`in e&&e.key===`Escape`}function jB(e){e&&(OB.add(e),e.hide(),queueMicrotask(()=>OB.delete(e)))}var MB=Q(function({store:e,showOnHover:t=!0,...n}){let r=_B();e||=r,Nj(e,!1);let i=(0,D.useRef)(!1);(0,D.useEffect)(()=>GP(e,[`mounted`],e=>{e.mounted||(i.current=!1)}),[e]);let a=(0,D.useRef)(!1),o=(0,D.useRef)(null);(0,D.useEffect)(()=>GP(e,[`open`],t=>{if(t.open||!e)return;let{contentElement:n}=e.getState();n&&KM(n)&&(a.current=!0,setTimeout(()=>{a.current=!1}))}),[e]);let s=n.onFocus,c=Y(e=>{s?.(e),a.current&&(a.current=!1,o.current=e.nativeEvent)});(0,D.useEffect)(()=>{if(!e)return;let t=kB(e);return Ej(t,GP(e,[`mounted`],n=>{if(!e)return;if(n.mounted){let{activeStore:t}=DB.getState();if(t!==e){if(OB.has(e))return;jB(t)}return DB.setState(`activeStore`,e)}let r=setTimeout(t,e.getState().skipTimeout);return()=>clearTimeout(r)}))},[e]);let l=n.onMouseEnter,u=Y(e=>{l?.(e),i.current=!0}),d=n.onFocusVisible,f=Y(t=>{d?.(t),t.defaultPrevented||AB(t.nativeEvent)||t.nativeEvent!==o.current&&(e?.setAnchorElement(t.currentTarget),e?.show())}),p=n.onBlur,m=Y(t=>{if(p?.(t),t.defaultPrevented)return;let{activeStore:n}=DB.getState();i.current=!1,n===e&&DB.setState(`activeStore`,null)}),h=$(e,[`type`,`contentElement`],e=>e.type===`label`?e.contentElement:null);wN(h,`id`);let g=h?.id;return n={"aria-labelledby":n[`aria-label`]==null?g:void 0,...n,onMouseEnter:u,onFocus:c,onFocusVisible:f,onBlur:m},n=TB({store:e,showOnHover(n){if(!i.current||Fj(t,n))return!1;let{activeStore:r}=DB.getState();return!r||(e?.show(),!1)},...n}),n}),NB=X(function(e){return Z(EB,MB(e))});function PB({popover:e,...t}={}){let n=YP(t.store,qP(e,[`arrowElement`,`anchorElement`,`contentElement`,`popoverElement`,`disclosureElement`,`unstable_placing`])),r=n?.getState(),i=BR({...t,store:n}),a=K(t.placement,r?.placement,`bottom`),o={...i.getState(),placement:a,currentPlacement:a,anchorElement:K(r?.anchorElement,null),popoverElement:K(r?.popoverElement,null),arrowElement:K(r?.arrowElement,null),rendered:Symbol(`rendered`),unstable_placing:!1},s=VP(o,i,n),c=o.anchorElement===o.disclosureElement?o.anchorElement:null;return HP(s,()=>GP(s,[`anchorElement`,`disclosureElement`],e=>{e.anchorElement&&e.anchorElement!==c?c=null:(c=e.disclosureElement,s.setState(`anchorElement`,c))})),HP(s,()=>e?.unstable_onHideRequest(i.unstable_requestHide)),{...i,...s,setAnchorElement:e=>s.setState(`anchorElement`,e),setPopoverElement:e=>s.setState(`popoverElement`,e),setArrowElement:e=>s.setState(`arrowElement`,e),render:()=>s.setState(`rendered`,Symbol(`rendered`))}}function FB(e,t,n){return TN(t,[n.popover,t]),UF(e,n,`placement`),VR(e,t,n)}function IB(e={}){let[t,n]=WF(PB,e);return FB(t,n,e)}function LB(e={}){let t=e.store?.getState(),n=PB({...e,placement:K(e.placement,t?.placement,`bottom`)}),r=K(e.timeout,t?.timeout,500),i=VP({...n.getState(),timeout:r,showTimeout:K(e.showTimeout,t?.showTimeout),hideTimeout:K(e.hideTimeout,t?.hideTimeout),autoFocusOnShow:K(t?.autoFocusOnShow,!1)},n,e.store);return{...n,...i,setAutoFocusOnShow:e=>i.setState(`autoFocusOnShow`,e)}}function RB(e,t,n){return UF(e,n,`timeout`),UF(e,n,`showTimeout`),UF(e,n,`hideTimeout`),FB(e,t,n)}function zB(e={}){let t=e.store?.getState(),n=LB({...e,placement:K(e.placement,t?.placement,`top`),hideTimeout:K(e.hideTimeout,t?.hideTimeout,0)}),r=VP({...n.getState(),type:K(e.type,t?.type,`description`),skipTimeout:K(e.skipTimeout,t?.skipTimeout,300)},n,e.store);return{...n,...r}}function BB(e,t,n){return UF(e,n,`type`),UF(e,n,`skipTimeout`),RB(e,t,n)}function VB(e={}){let[t,n]=WF(zB,e);return BB(t,n,e)}function HB(e={}){let t=VB(e);return(0,O.jsx)(vB,{value:t,children:e.children})}var UB=BN([vP],[yP]),WB=UB.useContext,GB=UB.useScopedContext;UB.useProviderContext,UB.ContextProvider,UB.ScopedContextProvider;var KB=`button`,qB=Q(function(e){let t=(0,D.useRef)(null),n=CN(t,KB),[r,i]=(0,D.useState)(()=>!!n&&$j({tagName:n,type:e.type}));return(0,D.useEffect)(()=>{t.current&&i($j(t.current))},[]),e={role:!r&&n!==`a`?`button`:void 0,...e,ref:vN(t,e.ref)},e=cP(e),e}),JB=X(function(e){return Z(KB,qB(gj(e)))}),YB=`button`,XB=Symbol(`disclosure`),ZB=Q(function({store:e,toggleOnClick:t=!0,...n}){let r=DI();e||=r,Nj(e,!1);let i=(0,D.useRef)(null),[a,o]=(0,D.useState)(!1),s=$(e,`disclosureElement`),c=$(e,`open`),l=(0,D.useCallback)(t=>{let n=i.current;i.current=t,t?e?.getState().disclosureElement?.isConnected||e.setDisclosureElement(t):e?.getState().disclosureElement===n&&e.setDisclosureElement(null)},[e]);(0,D.useEffect)(()=>{let t=s===i.current;s?.isConnected||(e?.setDisclosureElement(i.current),t=!0),o(c&&t)},[s,e,c]);let u=n.onClick,d=DN(t),[f,p]=AN(n,XB,!0),m=Y(t=>{u?.(t),t.defaultPrevented||f||d(t)&&(e?.setDisclosureElement(t.currentTarget),e?.toggle())});return n={"aria-expanded":a,"aria-controls":$(e,`contentElement`)?.id,...p,...n,ref:vN(l,n.ref),onClick:m},n=qB(n),n});X(function(e){return Z(YB,ZB(gj(e)))});var QB=`button`,$B=Q(function({store:e,...t}){let n=jI();return e||=n,Nj(e,!1),t={"aria-haspopup":cM($(e,`contentElement`),`dialog`),...t},t=ZB({store:e,...t}),t});X(function(e){return Z(QB,$B(gj(e)))});var eV=`button`,tV=Q(function({store:e,...t}){let n=$I();return e||=n,Nj(e,!1),t=ON(t,t=>(0,O.jsx)(tL,{value:e,children:t}),[e]),t=$B({store:e,...t}),t}),nV=X(function(e){return Z(eV,tV(gj(e)))}),rV=`span`,iV={top:`4,10 8,6 12,10`,right:`6,4 10,8 6,12`,bottom:`4,6 8,10 12,6`,left:`10,4 6,8 10,12`},aV=Q(function({store:e,placement:t,...n}){let r=QI();e||=r,Nj(e,!1);let i=iV[zz($(e,[`placement`],e=>t||e.placement))];return n={children:(0,D.useMemo)(()=>(0,O.jsx)(`svg`,{display:`block`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,viewBox:`0 0 16 16`,height:`1em`,width:`1em`,children:(0,O.jsx)(`polyline`,{points:i})}),[i]),"aria-hidden":!0,...n,style:{width:`1em`,height:`1em`,pointerEvents:`none`,...n.style}},n});X(function(e){return Z(rV,aV(e))});function oV(e={}){let t=IB(e);return(0,O.jsx)(eL,{value:t,children:e.children})}var sV=`div`,cV=new WeakMap;function lV(e){let t=cV.get(e);return t||(t={chars:``,cleanupTimeout:0},cV.set(e,t)),t}function uV(e){e.chars=``}function dV(e,t){let n=e.target;return n&&nM(n)?!1:e.key===` `&&t.chars.length?!0:e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&/^[\p{Letter}\p{Number}]$/u.test(e.key)}function fV(e,t){if(bM(e))return!0;let n=e.target;return n?t.some(e=>e.element===n):!1}function pV(e){return e.filter(e=>!e.disabled)}function mV(e,t){let n=e.typeaheadText??(e.element?.textContent||e.children||`value`in e&&e.value);return n?Oj(n).trim().toLowerCase().startsWith(t.toLowerCase()):!1}function hV({activeId:e,char:t,items:n,typeaheadState:r}){if(!e)return n;let i=n.find(t=>t.id===e);if(!i||!mV(i,t))return n;let{chars:a}=r;return a!==t&&mV(i,a)?n:(r.chars=t,yF(n.filter(e=>mV(e,t)),e).filter(t=>t.id!==e))}var gV=Q(function({store:e,typeahead:t=!0,...n}){let r=gP();e||=r,Nj(e,!1);let i=n.onKeyDownCapture,a=Y(n=>{if(i?.(n),n.defaultPrevented||!t||!e)return;let r=lV(e);if(!dV(n,r))return uV(r);let{renderedItems:a,items:o,activeId:s}=e.getState(),c=pV(o.length>a.length?o:a);if(!fV(n,c))return uV(r);n.preventDefault(),window.clearTimeout(r.cleanupTimeout),r.cleanupTimeout=window.setTimeout(()=>{uV(r)},500);let l=n.key.toLowerCase();r.chars+=l,c=hV({activeId:s,char:l,items:c,typeaheadState:r});let u=c.find(e=>mV(e,r.chars));u?e.move(u.id):uV(r)});return n={...n,onKeyDownCapture:a},Rj(n)});X(function(e){return Z(sV,gV(e))});var _V=`span`,vV=Q(function({store:e,...t}){let n=lL();return e||=n,t=aV({store:e,...t}),t}),yV=X(function(e){return Z(_V,vV(e))}),bV=`button`;function xV(e){return Array.from(e.selectedOptions).map(e=>e.value)}function SV(e,t){return()=>{let n=new Set,r=t();for(;r;){let i=e.item(r);if(!i)return;if(i.value!=null)return i.id;if(n.has(r))return;n.add(r),r=t({activeId:r})}}}var CV=Q(function({store:e,name:t,form:n,required:r,showOnKeyDown:i=!0,moveOnKeyDown:a=!0,toggleOnPress:o=!0,toggleOnClick:s=o,...c}){let l=dL();e||=l,Nj(e,!1);let u=c.onKeyDown,d=Ij(c),f=DN(i),p=DN(a),m=zz($(e,`placement`)),h=$(e,`value`),g=Array.isArray(h),_=Y(t=>{if(u?.(t),t.defaultPrevented||!e)return;let{orientation:n,items:r,activeId:i}=e.getState(),a=n!==`horizontal`,o=n!==`vertical`,s=!!r.find(e=>!e.disabled&&e.value!=null)?.rowId,c={ArrowUp:(s||a)&&SV(e,e.up),ArrowRight:(s||o)&&SV(e,e.next),ArrowDown:(s||a)&&SV(e,e.down),ArrowLeft:(s||o)&&SV(e,e.previous)}[t.key];c&&p(t)&&(t.preventDefault(),e.move(c()));let l=m===`top`||m===`bottom`;({ArrowDown:l,ArrowUp:l,ArrowLeft:m===`left`,ArrowRight:m===`right`})[t.key]&&f(t)&&(t.preventDefault(),e.move(i),AM(t.currentTarget,`keyup`,e.show))});c=ON(c,t=>(0,O.jsx)(pL,{value:e,children:t}),[e]);let[v,y]=(0,D.useState)(!1),b=(0,D.useRef)(!1);(0,D.useEffect)(()=>{let e=b.current;b.current=!1,e||y(!1)},[h]);let x=$(e,`labelElement`);wN(x,`id`);let S=x?.id,C=c[`aria-label`],w=c[`aria-labelledby`]||S,T=$(e,[`items`],e=>{if(t)return e.items}),E=(0,D.useMemo)(()=>{let e=T?.flatMap(e=>e.value??[]);return[...new Set(e)]},[T]);c=ON(c,i=>(0,O.jsxs)(O.Fragment,{children:[!!t&&(0,O.jsxs)(`select`,{style:KL(),tabIndex:-1,"aria-hidden":!0,"aria-label":C,"aria-labelledby":C==null?w:void 0,name:t,form:n,required:r,disabled:d,value:h,multiple:g,onFocus:()=>e?.getState().selectElement?.focus(),onChange:t=>{b.current=!0,y(!0),e?.setValue(g?xV(t.target):t.target.value)},children:[_j(h).map(e=>e==null||E.includes(e)?null:(0,O.jsx)(`option`,{value:e,children:e},e)),E.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e))]}),i]}),[e,C,w,t,n,r,h,g,E,d]);let ee=(0,O.jsxs)(O.Fragment,{children:[h,(0,O.jsx)(yV,{})]}),te=$(e,`contentElement`);return c={role:`combobox`,"aria-autocomplete":`none`,"aria-labelledby":c[`aria-label`]==null?S:void 0,"aria-haspopup":cM(te,`listbox`),"data-autofill":v||void 0,"data-name":t,children:ee,...c,ref:vN(e.setSelectElement,c.ref),onKeyDown:_},c=tV({store:e,toggleOnClick:s,...c}),c=gV({store:e,...c}),c}),wV=X(function(e){return Z(bV,CV(gj(e)))}),TV=(0,D.createContext)(void 0),EV=`div`,DV=Q(function(e){let[t,n]=(0,D.useState)();return e=ON(e,e=>(0,O.jsx)(TV.Provider,{value:n,children:e}),[]),e={role:`group`,"aria-labelledby":e[`aria-label`]==null?t:void 0,...e},e}),OV=X(function(e){return Z(EV,DV(e))}),kV=`div`,AV=Q(function(e){let t=(0,D.useContext)(TV),n=SN(e.id);return J(()=>(t?.(n),()=>t?.(void 0)),[t,n]),e={"aria-hidden":!0,...e,id:n},e});X(function(e){return Z(kV,AV(e))});var jV=`div`,MV=Q(function({store:e,...t}){return t=AV(t),t});X(function(e){return Z(jV,MV(e))});var NV=`div`;function PV(e){let t=e.relatedTarget;return Xj(t)?Yj(e.currentTarget,t):!1}var FV=Symbol(`composite-hover`);function IV(e){let{relatedTarget:t}=e;if(!Xj(t))return!1;let n=t;do{if(Tj(n,FV)&&n[FV])return!0;n=n.parentElement}while(n);return!1}var LV=Q(function({store:e,focusOnHover:t=!0,blurOnHoverEnd:n=!!t,...r}){let i=gP();e||=i,Nj(e,!1);let a=MN(),o=r.onMouseMove,s=DN(t),c=Y(t=>{if(o?.(t),!t.defaultPrevented&&a()&&s(t)){if(!KM(t.currentTarget)){let t=e?.getState().compositeElement;t&&!GM(t)&&t.focus({preventScroll:!0})}e?.setActiveId(t.currentTarget.id)}}),l=r.onMouseLeave,u=DN(n),d=Y(t=>{l?.(t),t.defaultPrevented||a()&&(PV(t)||IV(t)||s(t)&&u(t)&&(e?.setActiveId(null),e?.getState().compositeElement?.focus({preventScroll:!0})))}),f=(0,D.useCallback)(e=>{e&&(e[FV]=!0)},[]);return r={...r,ref:vN(f,r.ref),onMouseMove:c,onMouseLeave:d},r});zN(X(function(e){return Z(NV,LV(e))}));var RV=`div`;function zV(e,t){if(t!=null)return e==null?!1:Array.isArray(e)?e.includes(t):e===t}var BV=Q(function({store:e,value:t,getItem:n,hideOnClick:r,setValueOnClick:i=t!=null,preventScrollOnKeyDown:a=!0,focusOnHover:o=!0,...s}){let c=uL();e||=c,Nj(e,!1);let l=SN(s.id),u=Ij(s),{listElement:d,multiSelectable:f,selected:p,autoFocus:m}=HF(e,[`value`,`activeId`,`items`],{listElement:`listElement`,multiSelectable(e){return Array.isArray(e.value)},selected(e){return zV(e.value,t)},autoFocus(n){return t==null||n.value==null||n.activeId!==l&&e?.item(n.activeId)?!1:Array.isArray(n.value)?n.value[n.value.length-1]===t:n.value===t}}),h=$(e?.combobox,`virtualFocus`),g=(0,D.useCallback)(e=>{let r={...e,value:u?void 0:t};return n?n(r):r},[u,t,n]);r??=t!=null&&!f;let _=s.onClick,v=DN(i),y=DN(r),b=Y(n=>{_?.(n),n.defaultPrevented||CM(n)||SM(n)||(v(n)&&t!=null&&e?.setValue(e=>Array.isArray(e)?e.includes(t)?e.filter(e=>e!==t):[...e,t]:t),y(n)&&e?.hide())});s=ON(s,e=>(0,O.jsx)(mL.Provider,{value:p??!1,children:e}),[p]);let x=s.autoFocus??m;s={role:uM(d),"aria-selected":p,children:t,...s,id:l,autoFocus:h!==!1&&x,"data-autofocus":x||void 0,onClick:b},s=ZF({store:e,getItem:g,preventScrollOnKeyDown:a,...s});let S=DN(o);return s=LV({store:e,...s,focusOnHover(t){return!e.getState().open||!S(t)?!1:e.getState().open}}),s}),VV=zN(X(function(e){return Z(RV,BV(e))})),HV=(0,D.createContext)(!1),UV=`span`,WV=(0,O.jsx)(`svg`,{display:`block`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,viewBox:`0 0 16 16`,height:`1em`,width:`1em`,children:(0,O.jsx)(`polyline`,{points:`4,8 7,12 12,4`})});function GV(e){return e.checked?e.children||WV:null}var KV=Q(function({store:e,checked:t,...n}){let r=(0,D.useContext)(HV);t??=r;let i=GV({checked:t,children:n.children});return n={"aria-hidden":!0,...n,children:i,style:{width:`1em`,height:`1em`,pointerEvents:`none`,...n.style}},n}),qV=X(function(e){return Z(UV,KV(e))}),JV=`span`,YV=Q(function({store:e,checked:t,...n}){let r=(0,D.useContext)(mL);return t??=r,n=KV({...n,checked:t}),n}),XV=X(function(e){return Z(JV,YV(e))}),ZV=`div`,QV=(0,D.createContext)(null),$V=Q(function({store:e,resetOnEscape:t=!0,hideOnEnter:n=!0,composite:r,alwaysVisible:i,...a}){let o=lL();e||=o,Nj(e,!1);let s=SN(a.id),c=$(e,`value`),l=Array.isArray(c),[u,d]=(0,D.useState)(c),f=$(e,`mounted`);(0,D.useEffect)(()=>{f||d(c)},[f,c]),t&&=!l;let p=a.onKeyDown,m=DN(t),h=DN(n),g=Y(t=>{p?.(t),t.defaultPrevented||(t.key===`Escape`&&m(t)&&e?.setValue(u),(t.key===` `||t.key===`Enter`)&&bM(t)&&h(t)&&(t.preventDefault(),e?.hide()))}),_=(0,D.useContext)(hL),v=(0,D.useState)(),[y,b]=_||v,x=(0,D.useMemo)(()=>[y,b],[y,b]),[S,C]=(0,D.useState)(null),w=(0,D.useContext)(QV);(0,D.useEffect)(()=>{if(w)return w(e),()=>w(null)},[w,e]),a=ON(a,t=>(0,O.jsx)(pL,{value:e,children:(0,O.jsx)(QV.Provider,{value:C,children:(0,O.jsx)(hL.Provider,{value:x,children:t})})}),[e,x]);let T=!!e.combobox;r??=!T&&S!==e;let[,E]=_N(r?e.setListElement:null),ee=VI(f,a.hidden,i),te=ee?{...a.style,display:`none`}:a.style;r&&(a={role:`listbox`,"aria-multiselectable":l||void 0,...a});let ne=$(e,[`labelElement`],e=>y?null:e.labelElement);wN(ne,`id`);let re=y||ne?.id;return a={"aria-labelledby":a[`aria-label`]==null?re:void 0,hidden:ee,...a,id:s,ref:vN(E,a.ref),style:te,onKeyDown:g},a=SI({store:e,...a,composite:r}),a=gV({store:e,typeahead:!T,...a}),a});X(function(e){return Z(ZV,$V(e))});var eH=`div`,tH=Q(function({store:e,alwaysVisible:t,...n}){let r=dL();return e||=r,n=$V({store:e,alwaysVisible:t,...n}),n=$z({store:e,alwaysVisible:t,...n}),n}),nH=Iz(X(function(e){return Z(eH,tH(e))}),dL);function rH({combobox:e,...t}={}){let n=YP(t.store,qP(e,[`value`,`items`,`renderedItems`,`compositeElement`,`baseElement`,`arrowElement`,`anchorElement`,`contentElement`,`popoverElement`,`disclosureElement`,`inputElement`,`labelElement`,`selectElement`,`selectLabelElement`])),r=n.getState(),i=vF({...t,store:n,virtualFocus:K(t.virtualFocus,r.virtualFocus,!0),compositeElementInFocusOrder:K(t.compositeElementInFocusOrder,t.includesBaseElement,r.compositeElementInFocusOrder,r.includesBaseElement,!1),activeId:K(t.activeId,r.activeId,t.defaultActiveId,null),orientation:K(t.orientation,r.orientation,`vertical`)}),a=PB({...t,store:n,placement:K(t.placement,r.placement,`bottom-start`)}),o=new String(``),s={...i.getState(),...a.getState(),value:K(t.value,r.value,t.defaultValue,o),setValueOnMove:K(t.setValueOnMove,r.setValueOnMove,!1),labelElement:K(r.labelElement,null),selectElement:K(r.selectElement,null),listElement:K(r.listElement,null)},c=VP(s,i,a,n);return HP(c,()=>e?.unstable_onHideRequest(a.unstable_requestHide)),HP(c,()=>GP(c,[`value`,`items`],e=>{if(e.value!==o||!e.items.length)return;let t=e.items.find(e=>!e.disabled&&e.value!=null);t?.value!=null&&c.setState(`value`,t.value)})),HP(c,()=>GP(c,[`mounted`],e=>{e.mounted||c.setState(`activeId`,s.activeId)})),HP(c,()=>GP(c,[`mounted`,`items`,`value`],t=>{if(e||t.mounted)return;let n=_j(t.value),r=n[n.length-1];if(r==null)return;let i=t.items.find(e=>!e.disabled&&e.value===r);i&&c.setState(`activeId`,i.id)})),HP(c,()=>KP(c,[`setValueOnMove`,`moves`],e=>{let{mounted:t,value:n,activeId:r}=c.getState();if(!e.setValueOnMove&&t||Array.isArray(n)||!e.moves||!r)return;let a=i.item(r);a&&!a.disabled&&a.value!=null&&c.setState(`value`,a.value)})),{...i,...a,...c,combobox:e,setValue:e=>c.setState(`value`,e),setLabelElement:t=>{c.setState(`labelElement`,t),e?.setSelectLabelElement(t)},setSelectElement:e=>c.setState(`selectElement`,e),setListElement:e=>c.setState(`listElement`,e)}}function iH(e){let t=iL();return e={...e,combobox:e.combobox===void 0?t:e.combobox},oL(e)}function aH(e,t,n){return TN(t,[n.combobox,t]),UF(e,n,`value`,`setValue`),UF(e,n,`setValueOnMove`),Object.assign(FB(sL(e,t,n),t,n),{combobox:n.combobox})}function oH(e={}){e=iH(e);let[t,n]=WF(rH,e);return aH(t,n,e)}function sH(e={}){let t=oH(e);return(0,O.jsx)(fL,{value:t,children:e.children})}var cH=BN([dP],[fP]),lH=cH.useContext;function uH({store:e,name:t,component:n}){let r=lH(),i=e||r;return Nj(i,!1),{store:i,name:String(t)}}function dH({id:e,type:t,getItem:n,...r}){let{store:i,name:a}=uH(r),o=SN(e);return{store:i,name:a,id:o,ref:(0,D.useRef)(null),getItem:(0,D.useCallback)(e=>{let r={...e,id:o||e.id,name:a,type:t};return n?n(r):r},[o,a,t,n])}}cH.useScopedContext,cH.useProviderContext;var fH=cH.ContextProvider;cH.ScopedContextProvider;var pH=2**32-2;function mH(e){return Array.isArray(e)?e.map(e=>typeof e==`number`?e:String(e)):String(e).split(`.`)}function hH(e){return e===`__proto__`||e===`constructor`}function gH(){return new Promise(e=>{let t=setTimeout(e,100);requestAnimationFrame(()=>{clearTimeout(t),e()})})}function _H(e){let t=Object.keys(e);for(let n of t)if(!hH(n)){if(wj(e[n])){if(_H(e[n]))return!0}else if(e[n])return!0}return!1}function vH(e,t,n){return yH(e,mH(t),n)}function yH(e,t,n){let[r,...i]=t;return r==null||!e||hH(r)?n:i.length?yH(e[r],i,n):e[r]??n}function bH(e){if(typeof e!=`string`&&typeof e!=`number`)return!1;let t=String(e),n=Number(t);return Number.isInteger(n)&&n>=0&&n<=pH&&String(n)===t}function xH(e,t){return Array.isArray(e)||wj(e)?e:bH(t)?[]:{}}function SH(e,t,n){let r={};if(e){let t=Object.keys(e);for(let n of t)hH(n)||(r[n]=e[n])}return r[t]=n,r}function CH(e,t,n){let r=mH(t);return r.some(hH)?e:wH(e,r,n)}function wH(e,t,n){let[r,...i]=t;if(r==null)return e;let a=r,o=bH(r),s=(o?e||[]:e||{})[a],c=i[0],l=i.length&&c!=null?wH(xH(s,c),i,n):n;if(o){let t=Number(a);if(e&&Array.isArray(e)){let n=[...e];return n[t]=l,n}let n=[];return n[t]=l,n}return SH(e,a,l)}function TH(e,t){let n={},r=Object.keys(e);for(let i of r){if(hH(i))continue;let r=e[i];n[i]=Array.isArray(r)?r.map(e=>wj(e)?TH(e,t):t):wj(r)?TH(r,t):t}return n}function EH(e,t=[]){return{get(n,r){if(typeof r==`symbol`)return r===Symbol.toPrimitive?()=>t.join(`.`):void 0;if(r===`toString`||r===`valueOf`)return()=>t.join(`.`);let i=[...t,r],a=i.join(`.`);if(e[a])return e[a];let o=new Proxy(n,EH(e,i));return e[a]=o,o}}}function DH(e){return e?.__unstableCallbacks}function OH(){return new Proxy(Object.create(null),EH(Object.create(null)))}function kH(e={}){e.store;let t=e.store?.getState(),n=tF(e),r=K(e.values,t?.values,e.defaultValues,{}),i=K(e.errors,t?.errors,e.defaultErrors,{}),a=K(e.touched,t?.touched,e.defaultTouched,{}),o=VP({...n.getState(),values:r,errors:i,touched:a,validating:K(t?.validating,!1),submitting:K(t?.submitting,!1),submitSucceed:K(t?.submitSucceed,0),submitFailed:K(t?.submitFailed,0),valid:!_H(i)},n,e.store),s=DH(e.store),c=s?.getState(),l=VP({validate:c?.validate||[],submit:c?.submit||[]},s);HP(o,()=>UP(l)),HP(o,()=>GP(o,[`validating`,`errors`],e=>{e.validating||o.setState(`valid`,!_H(e.errors))}));let u=async()=>{o.setState(`validating`,!0),o.setState(`errors`,{});let e=l.getState().validate;try{for(let t of e)await t(o.getState());return await gH(),!_H(o.getState().errors)}finally{o.setState(`validating`,!1)}};return{...n,...o,names:OH(),setValues:e=>o.setState(`values`,e),getValue:e=>vH(o.getState().values,e),setValue:(e,t)=>o.setState(`values`,n=>{let r=vH(n,e),i=xj(t,r);return i===r?n:CH(n,e,i)}),pushValue:(e,t)=>o.setState(`values`,n=>CH(n,e,[...vH(n,e,[]),t])),removeValue:(e,t)=>o.setState(`values`,n=>{let r=vH(n,e,[]);return CH(n,e,[...r.slice(0,t),null,...r.slice(t+1)])}),setErrors:e=>o.setState(`errors`,e),getError:e=>vH(o.getState().errors,e),setError:(e,t)=>o.setState(`errors`,n=>{let r=vH(n,e),i=xj(t,r);return i===r?n:CH(n,e,i)}),setTouched:e=>o.setState(`touched`,e),getFieldTouched:e=>!!vH(o.getState().touched,e),setFieldTouched:(e,t)=>o.setState(`touched`,n=>{let r=vH(n,e),i=xj(t,r);return i===r?n:CH(n,e,i)}),onValidate:e=>(l.setState(`validate`,t=>[...t,e]),()=>{l.setState(`validate`,t=>t.filter(t=>t!==e))}),validate:u,onSubmit:e=>(l.setState(`submit`,t=>[...t,e]),()=>{l.setState(`submit`,t=>t.filter(t=>t!==e))}),submit:async()=>{o.setState(`submitting`,!0),o.setState(`touched`,TH(o.getState().values,!0));try{if(await u()){let e=l.getState().submit;for(let t of e)await t(o.getState());if(await gH(),!_H(o.getState().errors))return o.setState(`submitSucceed`,e=>e+1),!0}return o.setState(`submitFailed`,e=>e+1),!1}catch(e){throw o.setState(`submitFailed`,e=>e+1),e}finally{o.setState(`submitting`,!1)}},reset:()=>{o.setState(`values`,r),o.setState(`errors`,i),o.setState(`touched`,a),o.setState(`validating`,!1),o.setState(`submitting`,!1),o.setState(`submitSucceed`,0),o.setState(`submitFailed`,0),o.setState(`valid`,!_H(i))},__unstableCallbacks:l}}function AH(e,t){return $(e,[`values`],()=>e.getValue(t))}function jH(e,t){let n=Y(t),r=$(e,`items`);(0,D.useEffect)(()=>e.onValidate(n),[e,r,n])}function MH(e,t){let n=Y(t),r=$(e,`items`);(0,D.useEffect)(()=>e.onSubmit(n),[e,r,n])}function NH(e,t,n){let r=aL(e,t,n);UF(r,n,`values`,`setValues`),UF(r,n,`errors`,`setErrors`),UF(r,n,`touched`,`setTouched`);let i=(0,D.useCallback)(e=>AH(r,e),[r]),a=(0,D.useCallback)(e=>{jH(r,e)},[r]),o=(0,D.useCallback)(e=>{MH(r,e)},[r]);return(0,D.useMemo)(()=>({...r,useValue:i,useValidate:a,useSubmit:o}),[r,i,a,o])}function PH(e={}){let[t,n]=WF(kH,e);return NH(t,n,e)}var FH=`input`;function IH(e,t){let n=e.current;return n?n.name===t?n:n.form?n.form.elements.namedItem(t):q(n).getElementsByName(t)[0]:null}function LH(e,t){let n={};for(let r of e)if(r.name===t&&(r.type===`label`&&n.labelId===void 0?n.labelId=r.id:r.type===`error`&&n.errorId===void 0?n.errorId=r.id:r.type===`description`&&n.descriptionId===void 0&&(n.descriptionId=r.id),n.labelId!==void 0&&n.errorId!==void 0&&n.descriptionId!==void 0))break;return n}function RH(e,t){let n=(0,D.useMemo)(()=>{let e,n={};return r=>(r.items!==e&&(e=r.items,n=LH(r.items,t)),n)},[t]);return HF(e,[`items`,`errors`,`touched`],{labelId:e=>n(e).labelId,errorId:e=>n(e).errorId,descriptionId:e=>n(e).descriptionId,invalid:()=>!!e.getError(t)&&e.getFieldTouched(t)})}var zH=Q(function({store:e,name:t,getItem:n,touchOnBlur:r=!0,...i}){let{store:a,name:o,id:s,ref:c,getItem:l}=dH({store:e,name:t,id:i.id,type:`field`,getItem:n,component:`FormControl`});jH(a,async()=>{let e=IH(c,o);e&&(await Promise.resolve(),`validity`in e&&!e.validity.valid&&a.setError(o,e.validationMessage))});let u=i.onBlur,d=DN(r),f=Y(e=>{u?.(e),e.defaultPrevented||d(e)&&a.setFieldTouched(o,!0)}),{labelId:p,errorId:m,descriptionId:h,invalid:g}=RH(a,o),_=Dj(m,h,i[`aria-describedby`]);return i={"aria-labelledby":i[`aria-label`]==null?p:void 0,"aria-invalid":g,...i,id:s,"aria-describedby":_||void 0,ref:vN(c,i.ref),onBlur:f},i=mP({store:a,...i,name:o,getItem:l}),i});zN(X(function(e){return Z(FH,zH(e))}));var BH=`input`,VH=Q(function({store:e,name:t,...n}){let{store:r,name:i}=uH({store:e,name:t,component:`FormInput`}),a=n.onChange,o=Y(e=>{a?.(e),e.defaultPrevented||r.setValue(i,e.target.value)});return n={value:AH(r,i),...n,onChange:o},n=iP(n),n=zH({store:r,name:i,...n}),n}),HH=zN(X(function(e){return Z(BH,VH(e))})),UH=`label`;function WH(e){return e===`input`||e===`textarea`||e===`select`||e===`meter`||e===`progress`}var GH=Q(function({store:e,name:t,getItem:n,...r}){let{store:i,name:a,id:o,ref:s,getItem:c}=dH({store:e,name:t,id:r.id,type:`label`,getItem:n,component:`FormLabel`}),l=$(i,[`items`],e=>e.items.find(e=>e.type===`field`&&e.name===a)),u=WH(CN(l?.element,`input`)),d=r.onClick,f=Y(e=>{if(d?.(e),e.defaultPrevented||u)return;let t=l?.element;t&&queueMicrotask(()=>{let e=zM(t,!0,!0);e?.focus(),e?.getAttribute(`role`)!==`combobox`&&e?.click()})});return r={render:u?(0,O.jsx)(`label`,{}):(0,O.jsx)(`span`,{}),htmlFor:u?l?.id:void 0,...r,id:o,ref:vN(s,r.ref),onClick:f},u||(r={...r,style:{cursor:`default`,...r.style}}),r=mP({store:i,...r,getItem:c}),r}),KH=zN(X(function(e){return Z(UH,GH(e))}));function qH(e={}){let t=PH(e);return(0,O.jsx)(fH,{value:t,children:e.children})}var JH=BN([vP,rB],[yP,iB]),YH=JH.useContext,XH=JH.useScopedContext,ZH=JH.useProviderContext,QH=JH.ContextProvider,$H=JH.ScopedContextProvider;(0,D.createContext)(void 0);var eU=(0,D.createContext)(!1),tU=`div`;function nU({store:e,...t}){let[n,r]=(0,D.useState)(void 0),i=t[`aria-label`],a=$(e,`disclosureElement`),o=$(e,`contentElement`);return(0,D.useEffect)(()=>{let e=o;if(!e)return;let t=i||e.hasAttribute(`aria-label`)?void 0:a?.id||void 0;r(t)},[i,a,o]),n}var rU=Q(function({store:e,alwaysVisible:t,composite:n,...r}){let i=ZH();e||=i,Nj(e,!1);let a=e.parent,o=e.menubar,s=!!a,c=SN(r.id),l=r.onKeyDown,u=$(e,[`placement`],e=>zz(e.placement)),d=$(e,[`orientation`],e=>e.orientation===`both`?void 0:e.orientation),f=d!==`vertical`,p=$(o,[`orientation`],e=>!!e&&e.orientation!==`vertical`),m=Y(t=>{if(l?.(t),t.defaultPrevented)return;let n=t.target;if(bM(t)||FF(e,n)){if(rM(n)){let e=aM(n),r=t.key===`ArrowLeft`||t.key===`ArrowUp`,i=t.key===`ArrowRight`||t.key===`ArrowDown`;if(r&&e.start!==0||i&&e.end!==iM(n).length)return}if(s||o&&!f){let n={ArrowRight:()=>u===`left`&&!f,ArrowLeft:()=>u===`right`&&!f,ArrowUp:()=>u===`bottom`&&f,ArrowDown:()=>u===`top`&&f}[t.key];if(n?.())return t.stopPropagation(),t.preventDefault(),e?.hide()}if(o){let e={ArrowRight:()=>{if(p)return o.next()},ArrowLeft:()=>{if(p)return o.previous()},ArrowDown:()=>{if(!p)return o.down()},ArrowUp:()=>{if(!p)return o.up()}}[t.key],n=e?.();n!==void 0&&(t.stopPropagation(),t.preventDefault(),o.move(n))}}});r=ON(r,t=>(0,O.jsx)($H,{value:e,children:t}),[e]);let h=nU({store:e,...r}),g=VI($(e,`mounted`),r.hidden,t),_=g?{...r.style,display:`none`}:r.style;r=ON(r,e=>(0,O.jsx)(eU.Provider,{value:g,children:e}),[g]),r={"aria-labelledby":h,hidden:g,...r,id:c,ref:vN(c?e.setContentElement:null,r.ref),style:_,onKeyDown:m};let v=!!e.combobox;return n??=!v,n&&(r={role:`menu`,"aria-orientation":d,...r}),r=SI({store:e,composite:n,...r}),r=gV({store:e,typeahead:!v,...r}),r});X(function(e){return Z(tU,rU(e))});var iU=`div`,aU=Q(function({store:e,modal:t=!1,portal:n=t,hideOnEscape:r=!0,autoFocusOnShow:i=!0,hideOnHoverOutside:a,alwaysVisible:o,getPersistentElements:s,unstable_treeSnapshotKey:c,...l}){let u=ZH();e||=u,Nj(e,!1);let d=(0,D.useRef)(null),f=e.parent,p=e.menubar,m=!!f,h=!!p&&!m,g=!m&&t;l={...l,ref:vN(d,l.ref)};let{"aria-labelledby":_,...v}=rU({store:e,alwaysVisible:o,...l});l=v;let[y,b]=(0,D.useState)(),x=$(e,[`autoFocusOnShow`,`initialFocus`,`renderedItems`,`compositeElement`],e=>{if(!e.autoFocusOnShow)return;let t=e=>!e.disabled&&!!e.element;switch(e.initialFocus){case`first`:return e.renderedItems.find(t)?.element||null;case`last`:for(let n=e.renderedItems.length-1;n>=0;--n){let r=e.renderedItems[n];if(r&&t(r))return r.element}return null;default:return e.compositeElement}});(0,D.useEffect)(()=>{let e=!1;return b(t=>{if(e)return;if(g&&t?.current?.isConnected)return t;if(x===void 0)return;if(x&&x===t?.current)return t;let n=(0,D.createRef)();return n.current=x,n}),()=>{e=!0}},[g,x]);let S=!!y||!!l.initialFocus||g,C=i!==!1&&S&&i,w=$(e,[`disclosureElement`,`anchorElement`],e=>e.disclosureElement||e.anchorElement),T=$(e,[`disclosureElement`,`contentElement`],e=>{let{disclosureElement:t,contentElement:n}=e;return!t?.isConnected||yz(t)||n?.contains(t)?null:t}),E=g?T:null,ee=(0,D.useMemo)(()=>[c,E],[c,E]),te=$(e.combobox||e,`contentElement`),ne=$(f?.combobox||f,`contentElement`),re=(0,D.useMemo)(()=>{if(!ne||!te)return;let e=te.getAttribute(`role`),t=ne.getAttribute(`role`);if(t!==`menu`&&t!==`menubar`||e!==`menu`)return ne},[te,ne]);re!==void 0&&(l={preserveTabOrderAnchor:re,...l});let ie=lB({hideOnEscape:r,onClose:l.onClose,onEscapeClose:()=>f?.hideAll()});return l=hB({store:e,alwaysVisible:o,initialFocus:y,autoFocusOnShow:C,finalFocus:w,...l,hideOnEscape:ie.hideOnEscape,onClose:ie.onClose,hideOnHoverOutside(t){let n=e?.getState().disclosureElement;return(typeof a==`function`?a(t):a??(m?!0:h?!n||!KM(n):!1))?t.defaultPrevented||!m||!n||(wM(n,`mouseout`,t),!KM(n))?!0:(requestAnimationFrame(()=>{KM(n)||e?.hide()}),!1):!1},getPersistentElements(){let e=s?.()||[];return!g||!T?e:[...e,T]},unstable_treeSnapshotKey:ee,modal:g,portal:n,backdrop:!m&&l.backdrop}),l={"aria-labelledby":_,...l},l}),oU=Iz(X(function(e){return Z(iU,aU(e))}),ZH),sU=`button`;function cU(e,t){return{ArrowDown:t===`bottom`||t===`top`?`first`:!1,ArrowUp:t===`bottom`||t===`top`?`last`:!1,ArrowRight:t===`right`&&`first`,ArrowLeft:t===`left`&&`first`}[e.key]}function lU(e,t){return!!e?.some(e=>!e.element||e.element===t?!1:e.element.getAttribute(`aria-expanded`)===`true`)}var uU=Q(function({store:e,focusable:t,accessibleWhenDisabled:n,showOnHover:r,unstable_showOnHoverWhenDisabled:i=!1,...a}){let o=ZH();e||=o,Nj(e,!1);let s=(0,D.useRef)(null),c=e.parent,l=e.menubar,u=!!c,d=!!l&&!u,f=Ij(a),p=e=>f||Lj(e),m=()=>{let t=s.current;t&&(e?.setDisclosureElement(t),e?.show())},h=a.onFocus,g=Y(t=>{if(h?.(t),p(t.currentTarget)||t.defaultPrevented||(e?.setAutoFocusOnShow(!1),e?.setActiveId(null),!l)||!d)return;let{items:n}=l.getState();lU(n,t.currentTarget)&&m()}),_=$(e,[`placement`],e=>zz(e.placement)),v=a.onKeyDown,y=Y(t=>{if(v?.(t),p(t.currentTarget)||t.defaultPrevented)return;let n=cU(t,_);if(n){t.preventDefault();let{open:r}=e.getState();if(r){let t=n===`last`?e.last():e.first();e.move(t);return}m(),e?.setAutoFocusOnShow(!0),e?.setInitialFocus(n)}}),b=a.onClick,x=Y(t=>{if(b?.(t),t.defaultPrevented||!e)return;let n=!t.detail,{open:r}=e.getState();(!r||n)&&((!u||n)&&e.setAutoFocusOnShow(!0),e.setInitialFocus(n?`first`:`container`)),u&&m()});a=ON(a,t=>(0,O.jsx)(QH,{value:e,children:t}),[e]),u&&(a={...a,render:(0,O.jsx)(RR.div,{render:a.render})});let S=SN(a.id),C=$(c?.combobox||c,`contentElement`);return a={role:u||d?uM(C,`menuitem`):void 0,"aria-haspopup":cM($(e,`contentElement`),e.combobox?`dialog`:`menu`),...a,id:S,ref:vN(s,a.ref),onFocus:g,onKeyDown:y,onClick:x},a=CB({store:e,focusable:t,accessibleWhenDisabled:n,...a,unstable_showOnHoverWhenDisabled:i,showOnHover:e=>{if(!(()=>{if(typeof r==`function`)return r(e);if(r!=null)return r;if(u)return!0;if(!l)return!1;let{items:t}=l.getState();return d&&lU(t)})())return!1;let t=d?l:c;return t&&t.setActiveId(e.currentTarget.id),!0}}),a=tV({store:e,toggleOnClick:!u,focusable:t,accessibleWhenDisabled:n,...a}),a=gV({store:e,typeahead:d,...a}),a}),dU=X(function(e){return Z(sU,gj(uU(e)))}),fU=`span`,pU=Q(function({store:e,...t}){let n=YH();return e||=n,t=aV({store:e,...t}),t}),mU=X(function(e){return Z(fU,pU(e))}),hU=`div`,gU=Q(function(e){return e=MV(e),e}),_U=X(function(e){return Z(hU,gU(e))}),vU=`div`;function yU(e,t,n){if(!e)return!1;if(KM(e))return!0;let r=(t?.find(e=>e.element!==n&&e.element?.getAttribute(`aria-expanded`)===`true`))?.element?.getAttribute(`aria-controls`);if(!r)return!1;let i=q(e).getElementById(r);return i?KM(i)?!0:!!i.querySelector(`[role=menuitem][aria-expanded=true]`):!1}var bU=Q(function({store:e,hideOnClick:t=!0,preventScrollOnKeyDown:n=!0,focusOnHover:r,blurOnHoverEnd:i,...a}){let o=XH(!0),s=GB();e=e||o||s,Nj(e,!1);let c=a.onClick,l=DN(t),u=`hideAll`in e?e.hideAll:void 0,d=!!u,f=Y(e=>{if(c?.(e),e.defaultPrevented||CM(e)||SM(e)||!u)return;let t=e.currentTarget.getAttribute(`aria-haspopup`);t&&t!==`false`||l(e)&&u()}),p=$(e,[`contentElement`],e=>`contentElement`in e?e.contentElement:null),m=(0,D.useContext)(eU);return a={role:uM(p,`menuitem`),...a,onClick:f},a=ZF({store:e,preventScrollOnKeyDown:n,...a,shouldRegisterItem:!m&&a.shouldRegisterItem}),a=LV({store:e,...a,focusOnHover(t){if(!e||!(typeof r==`function`?r(t):r??!0))return!1;let{compositeElement:n,items:i}=e.getState();return d?(t.currentTarget.hasAttribute(`aria-expanded`)&&t.currentTarget.focus({preventScroll:!0}),!0):yU(n,i,t.currentTarget)?(t.currentTarget.focus({preventScroll:!0}),!0):!1},blurOnHoverEnd(e){return typeof i==`function`?i(e):i??d}}),a}),xU=zN(X(function(e){return Z(vU,bU(e))}));function SU({combobox:e,parent:t,menubar:n,...r}={}){let i=!!n&&!t,a=YP(r.store,JP(t,[`values`]),qP(e,[`arrowElement`,`anchorElement`,`contentElement`,`popoverElement`,`disclosureElement`,`placement`,`currentPlacement`])),o=a.getState(),s=(t||n)?.getState().orientation===`vertical`?`right-start`:`bottom-start`,c=vF({...r,store:a,orientation:K(r.orientation,o.orientation,`vertical`)}),l=LB({...r,store:a,placement:K(r.placement,o.placement,s),timeout:K(r.timeout,o.timeout,i?0:150),hideTimeout:K(r.hideTimeout,o.hideTimeout,0)}),u=VP({...c.getState(),...l.getState(),initialFocus:K(o.initialFocus,`container`),values:K(r.values,o.values,r.defaultValues,{})},c,l,a);return HP(u,()=>e?.unstable_onHideRequest(l.unstable_requestHide)),HP(u,()=>GP(u,[`mounted`],e=>{e.mounted||u.setState(`activeId`,null)})),{...c,...l,...u,combobox:e,parent:t,menubar:n,hideAll:()=>{l.hide(),t?.hideAll()},setInitialFocus:e=>u.setState(`initialFocus`,e),setValues:e=>u.setState(`values`,e),setValue:(e,t)=>{e!==`__proto__`&&e!==`constructor`&&(Array.isArray(e)||u.setState(`values`,n=>{let r=n[e],i=xj(t,r);return i===r?n:{...n,[e]:i!==void 0&&i}}))}}}function CU(e,t,n){return TN(t,[n.combobox,n.parent,n.menubar,t]),UF(e,n,`values`,`setValues`),Object.assign(RB(sL(e,t,n),t,n),{combobox:n.combobox,parent:n.parent,menubar:n.menubar})}function wU(e={}){let t=YH(),n=WB(),r=iL();e={...e,parent:e.parent===void 0?t:e.parent,menubar:e.menubar===void 0?n:e.menubar,combobox:e.combobox===void 0?r:e.combobox};let[i,a]=WF(SU,e);return CU(i,a,e)}function TU(e={}){let t=wU(e);return(0,O.jsx)(QH,{value:t,children:e.children})}var EU=`hr`,DU=Q(function({store:e,...t}){let n=YH();return e||=n,t=BL({store:e,...t}),t}),OU=X(function(e){return Z(EU,DU(e))}),kU=e=>{let{children:t,onSubmit:n,submitButton:r,...i}=e;return B(i),(0,O.jsx)(qH,{children:(0,O.jsxs)(`form`,{className:`bn-form`,onSubmit:e=>{e.preventDefault(),n?.()},children:[t,r===`none`?null:r]})})},AU=(0,D.forwardRef)((e,t)=>{let{className:n,name:r,label:i,variant:a,icon:o,value:s,autoFocus:c,placeholder:l,disabled:u,onKeyDown:d,onChange:f,autoComplete:p,"aria-activedescendant":m,rightSection:h,...g}=e;B(g);let _=mj([sj(c),t]);return(0,O.jsxs)(O.Fragment,{children:[e.label&&(0,O.jsx)(KH,{name:r,children:i}),(0,O.jsxs)(`div`,{className:`bn-ak-input-wrapper`,children:[o,(0,O.jsx)(HH,{className:V(`bn-ak-input`,n||``,a===`large`?`bn-ak-input-large`:``),ref:_,name:r,value:s,placeholder:l,disabled:u,onKeyDown:d,onChange:f,autoComplete:p,"aria-activedescendant":m}),h]})]})}),jU=(0,D.createContext)({portalElement:null,preventFocusOnOpen:!1}),MU=e=>{let{children:t,onOpenChange:n,position:r,portalElement:i,preventFocusOnOpen:a,sub:o,...s}=e;return B(s),(0,O.jsx)(TU,{placement:r,setOpen:n,virtualFocus:!0,children:(0,O.jsx)(jU.Provider,{value:{portalElement:i,preventFocusOnOpen:a??!1},children:t})})},NU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,sub:i,...a}=e;B(a);let{portalElement:o,preventFocusOnOpen:s}=(0,D.useContext)(jU);return(0,O.jsx)(oU,{unmountOnHide:!0,className:V(`bn-ak-menu`,n||``),autoFocusOnShow:s?()=>!1:!0,portal:o!==null,portalElement:o,ref:t,children:r})}),PU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,icon:i,checked:a,subTrigger:o,onClick:s,...c}=e;B(c);let{preventFocusOnOpen:l}=(0,D.useContext)(jU);return o?(0,O.jsxs)(dU,{render:(0,O.jsx)(xU,{focusOnHover:!l,onMouseDown:hj}),className:V(`bn-ak-menu-item`,n||``),ref:t,onClick:s,children:[i,r,(0,O.jsx)(mU,{}),a!==void 0&&(0,O.jsx)(qV,{checked:a})]}):(0,O.jsxs)(xU,{className:V(`bn-ak-menu-item`,n||``),ref:t,onClick:s,focusOnHover:!l,onMouseDown:hj,children:[i,r,a!==void 0&&(0,O.jsx)(qV,{checked:a})]})}),FU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i),(0,O.jsx)(_U,{className:V(`bn-ak-group-label`,n||``),ref:t,children:r})}),IU=e=>{let{children:t,sub:n,...r}=e;return B(r),n?t:(0,O.jsx)(dU,{render:t})},LU=(0,D.forwardRef)((e,t)=>{let{className:n,...r}=e;return B(r),(0,O.jsx)(OU,{className:V(`bn-ak-separator`,n||``),ref:t})}),RU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,icon:i,onClick:a,label:o,onDragEnd:s,onDragStart:c,draggable:l,...u}=e;return B(u,!1),(0,O.jsxs)(JB,{onDragEnd:s,onDragStart:c,draggable:l,"aria-label":o,className:V(`bn-ak-button bn-ak-secondary`,n||``),ref:t,onClick:a,...u,children:[i,r]})}),zU=(0,D.forwardRef)((e,t)=>{let{className:n,tabs:r,defaultOpenTab:i,openTab:a,setOpenTab:o,loading:s,...c}=e;return B(c),(0,O.jsx)(`div`,{className:V(`bn-ak-wrapper`,n||``),ref:t,children:(0,O.jsxs)(CL,{defaultSelectedId:i,selectedId:a,setActiveId:e=>{e&&o(e)},children:[(0,O.jsx)(TI,{className:`bn-ak-tab-list`,children:r.map(e=>(0,O.jsx)(oI,{className:`bn-ak-tab`,id:e.name,children:e.name},e.name))}),(0,O.jsx)(`div`,{className:`bn-ak-panels`,children:r.map(e=>(0,O.jsx)(XI,{tabId:e.name,children:e.tabPanel},e.name))})]})})}),BU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,type:i,onClick:a,label:o,...s}=e;return B(s),(0,O.jsx)(JB,{type:i,className:V(`bn-ak-button`,n||``),onClick:a,"aria-label":o,ref:t,children:r})}),VU=(0,D.forwardRef)((e,t)=>{let{className:n,accept:r,value:i,placeholder:a,onChange:o,...s}=e;return B(s),(0,O.jsx)(qH,{children:(0,O.jsx)(HH,{className:n,ref:t,name:`panel-input`,type:`file`,accept:r,value:i?i.name:void 0,onChange:async e=>o?.(e.target.files[0]),placeholder:a})})}),HU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i),(0,O.jsx)(`div`,{className:n,ref:t,children:r})}),UU=(0,D.forwardRef)((e,t)=>{let{className:n,value:r,placeholder:i,onKeyDown:a,onChange:o,...s}=e;return B(s),(0,O.jsx)(qH,{children:(0,O.jsx)(HH,{className:V(`bn-ak-input`,n||``),name:`panel-input`,value:r,placeholder:i,onChange:o,onKeyDown:a,"data-test":`embed-input`,ref:t})})}),WU=(0,D.createContext)(null),GU=(0,D.forwardRef)((e,t)=>{let{children:n,...r}=e;return B(r),(0,O.jsx)(nV,{render:n,ref:t})}),KU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,variant:i,...a}=e;B(a);let o=(0,D.useContext)(WU);return(0,O.jsx)(eB,{className:V(`bn-ak-popover`,n||``,i===`panel-popover`?`bn-ak-panel-popover`:``),autoFocusOnShow:!1,unmountOnHide:!0,portal:o!==null,portalElement:o,ref:t,children:r})}),qU=e=>{let{children:t,open:n,onOpenChange:r,position:i,portalElement:a,...o}=e;return B(o),(0,O.jsx)(oV,{open:n,setOpen:r,placement:i,children:(0,O.jsx)(WU.Provider,{value:a,children:t})})},JU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i,!1),(0,O.jsx)(OV,{className:n,ref:t,...i,children:r})}),YU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,icon:i,onClick:a,label:o,onDragEnd:s,onDragStart:c,draggable:l,...u}=e;return B(u,!1),(0,O.jsxs)(JB,{onDragEnd:s,onDragStart:c,draggable:l,"aria-label":o,className:V(`bn-ak-button bn-ak-secondary`,n||``),ref:t,onClick:a,...u,children:[i,r]})}),XU=(0,D.forwardRef)((e,t)=>{let{className:n,markClassName:r,backgroundColor:i,children:a,...o}=e;return B(o),(0,O.jsx)(`span`,{className:V(n||``,r||``),style:r?void 0:{backgroundColor:i},ref:t,children:a})}),ZU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,id:i,columns:a,...o}=e;return B(o),(0,O.jsx)(`div`,{className:n,style:{gridTemplateColumns:`repeat(${a}, 1fr)`},ref:t,id:i,role:`grid`,children:r})}),QU=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,columns:i,...a}=e;return B(a),(0,O.jsx)(`div`,{className:V(`bn-ak-menu-item`,n||``),style:{gridColumn:`1 / ${i+1}`},ref:t,children:(0,O.jsx)(`div`,{className:`bn-ak-suggestion-menu-item-label`,children:r})})}),$U=(0,D.forwardRef)((e,t)=>{let{className:n,isSelected:r,onClick:i,item:a,id:o,...s}=e;B(s);let c=(0,D.useRef)(null);return(0,D.useEffect)(()=>{!c.current||!r||fj(c.current,c.current.closest(`.bn-grid-suggestion-menu`))!==`none`&&c.current.scrollIntoView({block:`nearest`})},[r]),(0,O.jsx)(`div`,{className:n,ref:pj([t,c]),id:o,role:`option`,onClick:i,"aria-selected":r||void 0,children:a.icon})}),eW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,columns:i,...a}=e;return B(a),(0,O.jsx)(`div`,{className:n,style:{gridColumn:`1 / ${i+1}`},ref:t,children:r})}),tW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,id:i,...a}=e;return B(a),(0,O.jsx)(OV,{className:V(`bn-ak-menu`,n||``),id:i,role:`listbox`,ref:t,children:r})}),nW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i),(0,O.jsx)(`div`,{className:V(`bn-ak-menu-item`,n||``),ref:t,children:(0,O.jsx)(`div`,{className:`bn-ak-suggestion-menu-item-label`,children:r})})}),rW=(0,D.forwardRef)((e,t)=>{let{className:n,item:r,isSelected:i,onClick:a,id:o,...s}=e;B(s);let c=(0,D.useRef)(null);return(0,D.useEffect)(()=>{!c.current||!i||fj(c.current,c.current.closest(`.bn-suggestion-menu, #ai-suggestion-menu`))!==`none`&&c.current.scrollIntoView({block:`nearest`})},[i]),(0,O.jsxs)(`div`,{className:V(`bn-ak-menu-item`,n||``),ref:pj([t,c]),id:o,onMouseDown:e=>e.preventDefault(),onClick:a,role:`option`,"aria-selected":i||void 0,children:[r.icon&&(0,O.jsx)(`div`,{className:`bn-ak-suggestion-menu-item-section`,"data-position":`left`,children:r.icon}),(0,O.jsxs)(`div`,{className:`bn-ak-suggestion-menu-item-body`,children:[(0,O.jsx)(`div`,{className:`bn-ak-suggestion-menu-item-title`,children:r.title}),(0,O.jsx)(`div`,{className:`bn-ak-suggestion-menu-item-subtitle`,children:r.subtext})]}),r.badge&&(0,O.jsx)(`div`,{"data-position":`right`,className:`bn-ak-suggestion-menu-item-section`,children:(0,O.jsx)(`div`,{children:r.badge})})]})}),iW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i),(0,O.jsx)(`div`,{className:V(`bn-ak-group-label`,n||``),ref:t,children:r})}),aW=(0,D.forwardRef)((e,t)=>{let{className:n,...r}=e;return B(r),(0,O.jsx)(`div`,{className:n,ref:t,children:(0,O.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`1em`,viewBox:`0 -960 960 960`,width:`1em`,fill:`#e8eaed`,children:(0,O.jsx)(`path`,{d:`M480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 31.5-155.5t86-127Q252-817 325-848.5T480-880q17 0 28.5 11.5T520-840q0 17-11.5 28.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160q133 0 226.5-93.5T800-480q0-17 11.5-28.5T840-520q17 0 28.5 11.5T880-480q0 82-31.5 155t-86 127.5q-54.5 54.5-127 86T480-80Z`})})})}),oW=(0,D.forwardRef)((e,t)=>{let{children:n,className:r,onMouseDown:i,onClick:a,...o}=e;return B(o,!1),(0,O.jsx)(JB,{className:V(`bn-ak-button bn-ak-secondary`,r||``),ref:t,onMouseDown:i,onClick:a,...o,children:n})}),sW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,draggable:i,onDragStart:a,onDragEnd:o,style:s,label:c,...l}=e;return B(l,!1),(0,O.jsx)(JB,{className:V(`bn-ak-button bn-ak-secondary`,n||``),ref:t,"aria-label":c,draggable:i,onDragStart:a,onDragEnd:o,style:s,...l,children:r})}),cW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,onMouseEnter:i,onMouseLeave:a,variant:o,...s}=e;return B(s),(0,O.jsx)(NL,{className:V(`bn-ak-toolbar`,n||``),ref:t,onMouseEnter:i,onMouseLeave:a,children:r})}),lW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,mainTooltip:i,secondaryTooltip:a,icon:o,isSelected:s,isDisabled:c,onClick:l,label:u,variant:d,onMouseDown:f,...p}=e;return B(p,!1),(0,O.jsxs)(HB,{children:[(0,O.jsx)(NB,{render:(0,O.jsxs)(IL,{"aria-label":u,className:V(`bn-ak-button bn-ak-secondary`,n||``),...p,onMouseDown:e=>{hj(e),f?.(e)},onClick:l,"aria-pressed":s,"data-selected":s?`true`:void 0,disabled:c||!1,ref:t,children:[o,r]})}),(0,O.jsxs)(SB,{className:`bn-ak-tooltip`,portal:!1,children:[(0,O.jsx)(`span`,{children:i}),a&&(0,O.jsx)(`span`,{children:a})]})]})}),uW=(0,D.forwardRef)((e,t)=>{let{className:n,items:r,isDisabled:i,portalElement:a,preventFocusOnOpen:o,...s}=e;B(s);let c=e.items.filter(e=>e.isSelected)[0];return(0,O.jsxs)(sH,{value:c.text,setValue:e=>{r.find(t=>t.text===e).onClick?.()},children:[(0,O.jsxs)(wV,{className:`bn-ak-button bn-ak-secondary`,disabled:i,onMouseDown:hj,render:(0,O.jsx)(IL,{}),children:[c.icon,` `,c.text,` `,(0,O.jsx)(yV,{})]}),(0,O.jsx)(nH,{className:V(`bn-ak-popover`,n||``),ref:t,gutter:4,autoFocusOnShow:!o,portal:a!==null,portalElement:a,children:r.map(e=>(0,O.jsxs)(VV,{className:`bn-ak-select-item`,value:e.text,focusOnHover:!o,onMouseDown:hj,children:[e.icon,e.text,e.text===c.text&&(0,O.jsx)(XV,{})]},e.text))})]})}),dW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,selected:i,headerText:a,onFocus:o,onBlur:s,tabIndex:c,...l}=e;return B(l,!1),(0,O.jsxs)(OV,{className:V(n,`bn-ak-hovercard`,i&&`selected`),onFocus:o,onBlur:s,tabIndex:c,ref:t,children:[a&&(0,O.jsx)(`div`,{className:`bn-header-text`,children:a}),r]})}),fW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i,!1),(0,O.jsx)(OV,{className:V(n,`bn-ak-card-section`),ref:t,children:r})}),pW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i,!1),(0,O.jsx)(JB,{className:V(n,`bn-ak-button bn-ak-secondary bn-ak-expand-sections-prompt`),ref:t,children:r})}),mW=(0,D.forwardRef)((e,t)=>{let{authorInfo:n,timeString:r,edited:i,...a}=e,o=W();return B(a,!1),n===`loading`?(0,O.jsxs)(OV,{className:`bn-ak-author-info`,children:[(0,O.jsx)(`div`,{className:`bn-ak-avatar bn-ak-skeleton`}),(0,O.jsx)(`div`,{className:`bn-ak-username bn-ak-skeleton`})]}):(0,O.jsxs)(OV,{className:`bn-ak-author-info`,children:[(0,O.jsx)(`img`,{src:n.avatarUrl,alt:n.username,className:`bn-ak-avatar`}),(0,O.jsxs)(`div`,{className:`bn-ak-username`,children:[n.username,(0,O.jsxs)(`span`,{children:[r,` `,i&&`(${o.comments.edited})`]})]})]})}),hW=(0,D.forwardRef)((e,t)=>{let{className:n,showActions:r,authorInfo:i,timeString:a,actions:o,children:s,edited:c,emojiPickerOpen:l,...u}=e;B(u,!1);let[d,f]=(0,D.useState)(!1),{focused:p,ref:m}=lj();return(0,O.jsxs)(OV,{ref:t,className:n,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[o&&(r===!0||r===void 0||r===`hover`&&d||p||l)?(0,O.jsx)(OV,{ref:m,style:{position:`absolute`,right:0,top:0,zIndex:10},children:o}):null,(0,O.jsx)(mW,{...e}),s]})}),gW=(0,D.forwardRef)((e,t)=>{let{className:n,onFocus:r,onBlur:i,autoFocus:a,editor:o,editable:s,...c}=e;B(c,!1);let l=eE();return(0,O.jsx)(CW,{autoFocus:a,className:n,editor:e.editor,sideMenu:!1,slashMenu:!1,tableHandles:!1,filePanel:!1,formattingToolbar:!1,editable:s,theme:l?.colorSchemePreference,ref:t,onFocus:r,onBlur:i,children:(0,O.jsx)(Tk,{formattingToolbar:_W})})}),_W=()=>{let e=fk([]).filter(e=>e.key!==`nestBlockButton`&&e.key!==`unnestBlockButton`);return(0,O.jsx)(pk,{blockTypeSelectItems:[],children:e})},vW=(0,D.forwardRef)((e,t)=>{let{className:n,text:r,icon:i,isSelected:a,mainTooltip:o,secondaryTooltip:s,onClick:c,onMouseEnter:l,...u}=e;B(u,!1);let d=(0,O.jsxs)(JB,{className:V(n,`bn-ak-badge bn-ak-button`,a&&`bn-ak-primary`),"aria-selected":a===!0,onClick:e=>c?.(e),onMouseEnter:l,ref:t,children:[(0,O.jsx)(`span`,{children:i}),(0,O.jsx)(`span`,{children:r})]});return o?(0,O.jsxs)(HB,{children:[(0,O.jsx)(NB,{render:d}),(0,O.jsxs)(SB,{className:`bn-ak-tooltip`,portal:!1,children:[(0,O.jsx)(`span`,{children:o}),s&&(0,O.jsx)(`span`,{children:s})]})]}):d}),yW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i),(0,O.jsx)(OV,{className:V(n,`bn-ak-badge-group`),ref:t,children:r})}),bW=(0,D.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return B(i,!1),(0,O.jsx)(`div`,{className:V(n),ref:t,children:r})}),xW=(0,D.forwardRef)((e,t)=>{let{className:n,selected:r,comparing:i,onClick:a,actions:o,children:s,...c}=e;return B(c,!1),(0,O.jsxs)(`div`,{className:V(n,r?`selected`:``,i?`comparing`:``),onClick:a,ref:t,children:[s,o&&(0,O.jsx)(`div`,{className:`bn-snapshot-menu`,onClick:e=>e.stopPropagation(),children:o})]})}),SW={FormattingToolbar:{Root:cW,Button:lW,Select:uW},FilePanel:{Root:zU,Button:BU,FileInput:VU,TabPanel:HU,TextInput:UU},GridSuggestionMenu:{Root:ZU,Item:$U,EmptyItem:QU,Loader:eW},LinkToolbar:{Root:cW,Button:lW,Select:uW},SideMenu:{Root:JU,Button:YU},SuggestionMenu:{Root:tW,Item:rW,EmptyItem:nW,Label:iW,Loader:aW},AttributionTooltip:{Root:XU},TableHandle:{Root:sW,ExtendButton:oW},Comments:{Comment:hW,Editor:gW,Card:dW,CardSection:fW,ExpandSectionsPrompt:pW},Versioning:{Sidebar:bW,Snapshot:xW},Generic:{Badge:{Root:vW,Group:yW},Toolbar:{Root:cW,Button:lW,Select:uW},Form:{Root:kU,TextInput:AU},Menu:{Root:MU,Trigger:IU,Dropdown:NU,Divider:LU,Label:FU,Item:PU,Button:RU},Popover:{Root:qU,Trigger:GU,Content:KU}}},CW=e=>{let{className:t,...n}=e;return(0,O.jsx)(wE.Provider,{value:SW,children:(0,O.jsx)(RA,{className:V(`bn-ariakit`,t||``),...n})})};function wW(e,t,n){let r=be(e,t).map(t=>({title:t.label||ve(t.id),subtext:t.id,...t.type?{badge:t.type}:{},onItemClick:()=>n(ye(t.id,e))})),i=t.trim();return i&&!/[[\]|\n]/.test(i)&&!e.some(e=>[e.label,ve(e.id),e.id].some(e=>e?.toLocaleLowerCase()===i.toLocaleLowerCase()))&&r.push({title:`Link to “${i}”`,subtext:`No note has this name yet`,onItemClick:()=>n(i)}),r}var TW=/\n?(?:%%\n)?```blocknote[\s\S]*$/;function EW(e){let t=le(e);return t?pe(e)?{status:`edited`,blocks:t.blocks,markdown:t.markdown}:{status:`page`,blocks:t.blocks}:{status:`unreadable`,markdown:e.replace(TW,``).trim()}}function DW({kind:e,onRebuild:t,onKeep:n}){return(0,O.jsxs)(`div`,{className:`note-page-notice`,role:`status`,children:[(0,O.jsx)(ge,{as:`p`,size:`small`,children:e===`edited`?`This page’s Markdown was changed outside BrAIan. Rebuild the page from it, or keep the page as BrAIan saved it.`:`This page has no block source BrAIan can read. Below is what its Markdown rebuilds into.`}),(0,O.jsxs)(`div`,{className:`note-page-notice-actions`,children:[(0,O.jsx)(he,{size:`small`,variant:`primary`,onClick:t,children:e===`edited`?`Rebuild from Markdown`:`Rebuild page`}),e===`edited`&&(0,O.jsx)(he,{size:`small`,onClick:n,children:`Keep the page`})]})]})}var OW=(0,D.createContext)({resolve:()=>void 0,open:()=>void 0});function kW({target:e,label:t}){let n=(0,D.useContext)(OW),r=n.resolve(e);return(0,O.jsx)(`a`,{className:r?`note-page-link`:`note-page-link note-page-link-unresolved`,href:`#${encodeURIComponent(e)}`,"data-target":e,title:r?void 0:`No note is called ${e}`,onClick:e=>{e.preventDefault(),r&&n.open(r.id)},children:t||r?.title||e})}var AW=dj({type:ue,propSchema:{target:{default:``},label:{default:``}},content:`none`},{render:({inlineContent:e})=>(0,O.jsx)(kW,{target:e.props.target,label:e.props.label})}),jW=Py.create({inlineContentSpecs:{...My,wikiLink:AW}}),MW=/(\[\[[^[\]\n]+\]\])/,NW=/^!\[\[([^[\]\n|]+)(?:\|[^[\]\n]*)?\]\](?:\n([\s\S]*))?$/,PW=[[/\.(png|jpe?g|gif|webp|avif|svg|bmp)$/i,`image`],[/\.(mp4|webm|mov|m4v|ogv)$/i,`video`],[/\.(mp3|wav|ogg|oga|m4a|flac|aac|opus)$/i,`audio`]];function FW(e){return e.map(LW)}function IW(e){return PW.find(([t])=>t.test(e))?.[1]??`file`}function LW(e){let t=e.children?.length?{children:FW(e.children)}:{};if(!Array.isArray(e.content))return{...e,...t};let n=e.type===`paragraph`?NW.exec(VW(e.content)):null;if(n){let r=n[2]?.trim();return{...e.id?{id:e.id}:{},type:IW(n[1].trim()),props:{url:n[1].trim(),...r?{caption:r}:{}},...t}}return{...e,content:RW(e.content),...t}}function RW(e){return e.flatMap(e=>{if(e.type!==`text`)return[e];let t=e;return t.text.split(MW).filter(Boolean).map(e=>{if(!MW.test(e)||t.styles?.code===!0)return{...t,text:e};let n=e.slice(2,-2),r=n.indexOf(`|`);return{type:ue,props:{target:(r<0?n:n.slice(0,r)).trim(),label:r<0?``:n.slice(r+1).trim()}}})}).reduce((e,t)=>{let n=e.at(-1),r=t.type===`wikiLink`&&n?.type===`text`&&n.text.endsWith(`!`)?{...n,text:zW(t.props)}:t;return n?.type===`text`&&r.type===`text`&&BW(n,r)?e[e.length-1]={...n,text:n.text+r.text}:e.push(r),e},[])}function zW({target:e,label:t}){return`[[${e}${t?`|${t}`:``}]]`}function BW(e,t){return JSON.stringify(e.styles??{})===JSON.stringify(t.styles??{})}function VW(e){return e.map(e=>e.type===`text`?e.text:``).join(``)}var HW=300,UW=2e3;function WW({blocks:e,emitted:t,viewOnly:n,onBodyChange:r}){let i=(0,D.useRef)(!1),a=(0,D.useRef)(!1),o=(0,D.useRef)(void 0),s=(0,D.useRef)(void 0),c=(0,D.useRef)({blocks:e,viewOnly:n,onBodyChange:r});c.current={blocks:e,viewOnly:n,onBodyChange:r};let l=(0,D.useCallback)(()=>{o.current!==void 0&&(window.clearTimeout(o.current),o.current=void 0),s.current=void 0},[]),u=(0,D.useCallback)(()=>{l();let e=c.current.blocks();if(!a.current||!e||c.current.viewOnly)return;a.current=!1;let n=de(e,xe);n!==t.current&&(t.current=n,c.current.onBodyChange(n))},[l,t]),d=(0,D.useCallback)(()=>{if(c.current.viewOnly||!i.current)return;a.current=!0;let e=Date.now();s.current??=e,o.current!==void 0&&window.clearTimeout(o.current),o.current=window.setTimeout(u,Math.max(0,Math.min(HW,s.current+UW-e)))},[u]),f=(0,D.useCallback)(()=>{i.current=!0},[]),p=(0,D.useCallback)(()=>{c.current.viewOnly||(a.current=!0,u())},[u]),m=(0,D.useCallback)(()=>{l(),i.current=!1,a.current=!1},[l]);return(0,D.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()===`s`&&u()};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[u]),(0,D.useLayoutEffect)(()=>()=>u(),[u]),(0,D.useMemo)(()=>({onChange:d,touch:f,commit:p,reset:m,flush:u}),[p,u,d,m,f])}var GW=e=>e.status===`page`?void 0:e.status,KW=[{type:`paragraph`}];function qW(e){return e.length?e:KW}function JW(e,t){return t.status===`unreadable`?YW(e,t.markdown):t.blocks}function YW(e,t){return FW(e.tryParseMarkdownToBlocks(t))}function XW(e){let t=me(),[n]=(0,D.useState)(()=>EW(e.body)),[r,i]=(0,D.useState)(()=>GW(n)),a=(0,D.useRef)(e.body),o=(0,D.useRef)(!1),s=(0,D.useRef)(e);s.current=e;let c=EE({schema:jW,...n.status===`unreadable`?{}:{initialContent:qW(n.blocks)},...e.upload?{uploadFile:e=>s.current.upload(e)}:{},resolveFileUrl:e=>_e(s.current.files)(e)},[]),l=WW({blocks:()=>c.document,emitted:a,viewOnly:e.viewOnly,onBodyChange:e=>s.current.onBodyChange?.(e)}),u=!e.viewOnly&&!r,d=(0,D.useCallback)(e=>{o.current=!0;try{c.replaceBlocks(c.document,qW(e))}finally{o.current=!1}l.reset()},[c,l]);(0,D.useLayoutEffect)(()=>{n.status===`unreadable`&&d(JW(c,n))},[c,n,d]),(0,D.useEffect)(()=>{if(e.body===a.current)return;a.current=e.body;let t=EW(e.body);d(JW(c,t)),i(GW(t))},[c,e.body,d]);let f=(0,D.useRef)(!!e.focusOnMount&&u);(0,D.useEffect)(()=>{f.current&&c.focus()},[c]);let p=(0,D.useCallback)(()=>{let e=EW(a.current);e.status===`edited`&&d(YW(c,e.markdown)),i(void 0),l.commit()},[c,l,d]),m=(0,D.useCallback)(()=>{i(void 0),l.commit()},[l]),h=(0,D.useMemo)(()=>{let t=new Map(e.notes.map(e=>[e.id,e.label||e.id]));return{resolve:e=>{let n=s.current.resolveNoteReference(e);return n?{id:n,title:t.get(n)??e}:void 0},open:e=>s.current.onOpenNote(e)}},[e.notes]),g=(0,D.useCallback)(async e=>wW(s.current.notes,e,e=>{c.insertInlineContent([{type:`wikiLink`,props:{target:e,label:``}},` `])}),[c]);return(0,O.jsxs)(`div`,{className:e.inline?`note-page note-page-inline`:`note-page`,...u?{"data-keyboard-owns-keys":`true`}:{},onPointerDownCapture:l.touch,onKeyDownCapture:l.touch,onPasteCapture:l.touch,onDropCapture:l.touch,children:[r&&!e.viewOnly&&(0,O.jsx)(DW,{kind:r,onRebuild:p,onKeep:m}),(0,O.jsx)(OW.Provider,{value:h,children:(0,O.jsx)(CW,{editor:c,editable:u,theme:t,onChange:()=>{o.current||l.onChange()},children:u&&(0,O.jsx)(cA,{triggerCharacter:`[[`,getItems:g})})})]})}export{XW as NotePageEditor};
|